@reason-machines/cli-linux-arm64-musl 0.2.277 → 0.2.279
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-m9tjjyvr.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-v1egrx6g.js +2 -0
- package/bin/vm-hands/local-capabilities-jpyj1dh1.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-hmqaj491.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-wbdkvw1s.js +2 -0
- package/bin/vm-hands/reason-hands-protocol-51gs8j7v.js +2 -0
- package/bin/vm-hands/status-pxc0vwbt.js +96 -0
- package/bin/vm-hands/version-n43gjzwa.js +2 -0
- package/bin/vm-hands/vm-hands-entry-lite-01dd716a.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-1hwdab4e.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-22f3c914.js +43 -0
- package/bin/vm-hands/vm-hands-entry-lite-2s3w4m10.js +529 -0
- package/bin/vm-hands/vm-hands-entry-lite-65pbrs1x.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-6tpswr2c.js +459 -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-9jfh56xt.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-cq7qt28m.js +179 -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-g7faacwr.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-gqncr2j0.js +42 -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-qdz95cmv.js +759 -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.js +2 -0
- package/bin/vm-hands/vm-hands-executor-xg99mezq.js +9 -0
- package/bin/vm-hands/vm-hands-op-runner-b0xkges8.js +2 -0
- package/bin/vm-hands/vm-hands-runtime-gnbcsqcy.js +4 -0
- package/bin/vm-hands/worker-sandbox-nnce49w0.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Zb as X}from"./vm-hands-entry-lite-n07kxrd1.js";import{spawn as M}from"child_process";import{existsSync as C}from"fs";import{homedir as g}from"os";import{basename as D,join as N}from"path";var Y="/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",G=Y.split(":"),f=5000,I=65536,U=new Set(["zsh","bash"]),V=[[".local","bin"],[".bun","bin"],[".cargo","bin"],["go","bin"]],j=(J,K)=>new Promise((W,Z)=>{let Q;try{Q=M(J,[...K],{detached:!0,stdio:["ignore","pipe","ignore"]})}catch($){Z($);return}let z=[],x=0,R=null,B=($)=>{R??=Error($);try{if(Q.pid!==void 0)process.kill(-Q.pid,"SIGKILL")}catch{}},F=setTimeout(()=>B("login_shell_timeout"),f);Q.stdout?.on("data",($)=>{if(x+=$.length,x>I)B("login_shell_output_too_large");else z.push($)}),Q.once("error",($)=>{clearTimeout(F),Z($)}),Q.once("close",($)=>{if(clearTimeout(F),R)Z(R);else if($!==0)Z(Error("login_shell_exit_nonzero"));else W(Buffer.concat(z).toString("utf8"))})});function O(J){return typeof J==="string"&&J.startsWith("/")&&!J.includes("\x00")&&U.has(D(J))}function q(J){let K=new Set,W=[];for(let Z of J){if(K.has(Z))continue;K.add(Z),W.push(Z)}return W}function H(J){let K=J.split(`
|
|
3
|
+
`).at(-1)??"",W=[];for(let Z of K.split(":")){let Q=Z.trim();if(!Q.startsWith("/"))continue;if(Q.includes("\x00"))continue;if(X(Q))continue;W.push(Q)}return q(W)}function k(J){let K=J?.home??g(),W=J?.directoryExists??C,Z=V.map((Q)=>N(K,...Q)).filter((Q)=>{try{return W(Q)}catch{return!1}});return q([...Z,...G]).join(":")}async function S(J){let K=J?.shell??process.env.SHELL,W=()=>({path:k({home:J?.home,directoryExists:J?.directoryExists}),source:"fallback"});if(!O(K))return W();let Z;try{Z=await(J?.runLoginShell??j)(K,["-lic",'printf %s "$PATH"'])}catch{return W()}if(Buffer.byteLength(Z,"utf8")>I)return W();let Q=H(Z);if(Q.length===0)return W();return{path:q([...Q,...G]).join(":"),source:"login_shell"}}function v(J){let K=null;return()=>{return K??=S(J),K}}function w(J){if(J===void 0||J.includes("\x00")||Buffer.byteLength(J,"utf8")>32768)return;return J}function P(J){let K=J.source??process.env,W={HOME:J.home,PATH:J.path??Y,TMPDIR:J.temporaryDirectory,SHELL:w(K.SHELL)??"/bin/zsh",LANG:w(K.LANG)??"C.UTF-8",LC_ALL:w(K.LC_ALL)??w(K.LANG)??"C.UTF-8"},Z=w(K.LC_CTYPE),Q=w(K.TERM),z=w(K.COLORTERM);if(Z)W.LC_CTYPE=Z;if(Q)W.TERM=Q;if(z)W.COLORTERM=z;return W}
|
|
4
|
+
export{Y as Qb,H as Rb,k as Sb,v as Tb,P as Ub};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Gh as l}from"./vm-hands-entry-lite-ffg7rf02.js";import{execFile as zj,spawn as I}from"child_process";var Cj="h264_ws_v1",kj="video",h=["smooth","sharp","data_saver","balanced"];var Yj="video_presets";var V=8388608,Y=65536,Lj="control",Aj="v1",d=200;function s(q){if(!q||typeof q!=="object"||Array.isArray(q))return null;let j=q,J=(Q)=>typeof Q==="string"&&Q.length>0&&Q.length<=d;if(Object.keys(j).length!==2||!J(j.user_id)||!J(j.name))return null;return{user_id:j.user_id,name:j.name}}var xj="windows",Mj="v1",A=200,o=(q)=>typeof q==="string"&&h.includes(q);function fj(q){if(!q||typeof q!=="object"||Array.isArray(q))return null;let j=q;if(Object.keys(j).length!==2||j.format!=="h264_ws_v1"||!o(j.preset))return null;return{format:"h264_ws_v1",preset:j.preset}}var $={hello:1,frame:2,stats:3,pong:4,serverClipboard:5,error:6,audioHello:7,audio:8,control:9,windows:10,pointer:16,key:17,config:18,ping:19,clientClipboard:20,keyframeRequest:21,ack:22,audioEnable:23};class U extends Error{constructor(q){super(q);this.name="DisplayVideoProtocolError"}}var e=new TextEncoder,jj=new TextDecoder("utf-8",{fatal:!0});function H(q,j){if(j.byteLength+1>V)throw new U("message_too_large");let J=new Uint8Array(5+j.byteLength),Q=new DataView(J.buffer);return Q.setUint32(0,j.byteLength+1),Q.setUint8(4,q),J.set(j,5),J}function R(q){let j=e.encode(q);if(j.byteLength>Y)throw new U("text_too_large");return j}function f(q,j){if(!Number.isInteger(q)||q<0||q>65535)throw new U(`invalid_${j}`);return q}function qj(q){if(!Number.isFinite(q))throw new U("invalid_window");return Math.max(-2147483648,Math.min(2147483647,Math.round(q)))}function hj(q){switch(q.type){case"hello":{let j=R(q.codec),J=new Uint8Array(6+j.byteLength),Q=new DataView(J.buffer);return Q.setUint16(0,f(q.width,"width")),Q.setUint16(2,f(q.height,"height")),Q.setUint8(4,Math.max(1,Math.min(240,Math.round(q.fps)))),Q.setUint8(5,h.indexOf(q.preset)),J.set(j,6),H($.hello,J)}case"frame":{let j=new Uint8Array(13+q.data.byteLength),J=new DataView(j.buffer);return J.setUint8(0,q.key?1:0),J.setUint32(1,q.seq>>>0),J.setBigUint64(5,BigInt(Math.max(0,Math.floor(q.captureMicros)))),j.set(q.data,13),H($.frame,j)}case"stats":return H($.stats,R(JSON.stringify(q.stats)));case"pong":case"ping":{let j=new Uint8Array(8);return new DataView(j.buffer).setFloat64(0,q.token),H(q.type==="ping"?$.ping:$.pong,j)}case"serverClipboard":return H($.serverClipboard,R(q.text));case"clientClipboard":return H($.clientClipboard,R(q.text));case"error":return H($.error,R(q.code));case"pointer":{let j=new Uint8Array(5),J=new DataView(j.buffer);return J.setUint16(0,f(q.x,"x")),J.setUint16(2,f(q.y,"y")),J.setUint8(4,q.buttons&255),H($.pointer,j)}case"key":{let j=new Uint8Array(5),J=new DataView(j.buffer);return J.setUint8(0,q.down?1:0),J.setUint32(1,q.keysym>>>0),H($.key,j)}case"config":return H($.config,Uint8Array.of(h.indexOf(q.preset)));case"keyframeRequest":return H($.keyframeRequest,new Uint8Array(0));case"audioHello":{let j=R(q.codec),J=new Uint8Array(5+j.byteLength),Q=new DataView(J.buffer);return Q.setUint32(0,q.sampleRate>>>0),Q.setUint8(4,q.channels&255),J.set(j,5),H($.audioHello,J)}case"audio":{let j=new Uint8Array(8+q.data.byteLength);return new DataView(j.buffer).setBigUint64(0,BigInt(Math.max(0,Math.floor(q.captureMicros)))),j.set(q.data,8),H($.audio,j)}case"control":return H($.control,R(JSON.stringify(q.control)));case"windows":{let j=q.bounds.slice(0,A),J=new Uint8Array(j.length*16),Q=new DataView(J.buffer);return j.forEach((Z,z)=>{[Z.x,Z.y,Z.width,Z.height].forEach((G,F)=>Q.setInt32(z*16+F*4,qj(G)))}),H($.windows,J)}case"audioEnable":return H($.audioEnable,Uint8Array.of(q.on?1:0));case"ack":{let j=new Uint8Array(4);return new DataView(j.buffer).setUint32(0,q.seq>>>0),H($.ack,j)}}}function T(q){let j=h[q];if(!j)throw new U("invalid_preset");return j}function C(q,j){if(q.byteLength!==j)throw new U("invalid_length")}function k(q){if(q.byteLength>Y)throw new U("text_too_large");try{return jj.decode(q)}catch{throw new U("invalid_text")}}function Jj(q){let j;try{j=JSON.parse(k(q))}catch{throw new U("invalid_stats")}let J=j;if(!J||typeof J!=="object"||["fps","kbps","dropped","restarts","queued_bytes"].some((Z)=>typeof J[Z]!=="number"||!Number.isFinite(J[Z])))throw new U("invalid_stats");return{fps:J.fps,kbps:J.kbps,dropped:J.dropped,restarts:J.restarts,queued_bytes:J.queued_bytes}}function Qj(q){let j;try{j=JSON.parse(k(q))}catch{throw new U("invalid_control")}let J=j;if(!J||typeof J!=="object"||typeof J.you!=="boolean"||typeof J.same_user!=="boolean")throw new U("invalid_control");let Q=J.holder===null?null:s(J.holder);if(Q===null&&J.holder!==null)throw new U("invalid_control");return{holder:Q,you:J.you,same_user:J.same_user}}function Zj(q,j){let J=new DataView(j.buffer,j.byteOffset,j.byteLength);switch(q){case $.hello:if(j.byteLength<6)throw new U("invalid_length");return{type:"hello",width:J.getUint16(0),height:J.getUint16(2),fps:J.getUint8(4),preset:T(J.getUint8(5)),codec:k(j.subarray(6))};case $.frame:if(j.byteLength<14)throw new U("invalid_length");if(J.getUint8(0)>1)throw new U("invalid_frame_flags");return{type:"frame",key:J.getUint8(0)===1,seq:J.getUint32(1),captureMicros:Number(J.getBigUint64(5)),data:j.subarray(13)};case $.stats:return{type:"stats",stats:Jj(j)};case $.ping:case $.pong:return C(j,8),{type:q===$.ping?"ping":"pong",token:J.getFloat64(0)};case $.serverClipboard:return{type:"serverClipboard",text:k(j)};case $.clientClipboard:return{type:"clientClipboard",text:k(j)};case $.error:return{type:"error",code:k(j)};case $.pointer:return C(j,5),{type:"pointer",x:J.getUint16(0),y:J.getUint16(2),buttons:J.getUint8(4)};case $.key:if(C(j,5),J.getUint8(0)>1)throw new U("invalid_key_flags");return{type:"key",down:J.getUint8(0)===1,keysym:J.getUint32(1)};case $.config:return C(j,1),{type:"config",preset:T(J.getUint8(0))};case $.keyframeRequest:return C(j,0),{type:"keyframeRequest"};case $.audioHello:if(j.byteLength<5)throw new U("invalid_length");return{type:"audioHello",sampleRate:J.getUint32(0),channels:J.getUint8(4),codec:k(j.subarray(5))};case $.audio:if(j.byteLength<9)throw new U("invalid_length");return{type:"audio",captureMicros:Number(J.getBigUint64(0)),data:j.subarray(8)};case $.audioEnable:if(C(j,1),J.getUint8(0)>1)throw new U("invalid_audio_flags");return{type:"audioEnable",on:J.getUint8(0)===1};case $.control:return{type:"control",control:Qj(j)};case $.windows:{if(j.byteLength%16!==0||j.byteLength>A*16)throw new U("invalid_length");let Q=[];for(let Z=0;Z<j.byteLength;Z+=16)Q.push({x:J.getInt32(Z),y:J.getInt32(Z+4),width:J.getInt32(Z+8),height:J.getInt32(Z+12)});return{type:"windows",bounds:Q}}case $.ack:return C(j,4),{type:"ack",seq:J.getUint32(0)};default:return null}}class $j{buffer=new Uint8Array(0);push(q){let j=new Uint8Array(this.buffer.byteLength+q.byteLength);j.set(this.buffer),j.set(q,this.buffer.byteLength);let J=[],Q=0;while(j.byteLength-Q>=4){let Z=new DataView(j.buffer,j.byteOffset+Q,4).getUint32(0);if(Z<1||Z>V)throw new U("invalid_message_length");if(j.byteLength-Q-4<Z)break;let z=j[Q+4],G=j.slice(Q+5,Q+4+Z),F=Zj(z,G);if(F)J.push(F);Q+=4+Z}return this.buffer=j.slice(Q),J}}var t="/usr/bin/osascript",Gj=5000,Kj=1048576,Uj=String.raw`
|
|
3
|
+
ObjC.import("CoreGraphics");
|
|
4
|
+
ObjC.import("ApplicationServices");
|
|
5
|
+
ObjC.import("AppKit");
|
|
6
|
+
ObjC.bindFunction("CGPreflightScreenCaptureAccess", ["bool", []]);
|
|
7
|
+
ObjC.bindFunction("CGRequestScreenCaptureAccess", ["bool", []]);
|
|
8
|
+
ObjC.bindFunction("getppid", ["int", []]);
|
|
9
|
+
function run(argv) {
|
|
10
|
+
const bounds = $.CGDisplayBounds($.CGMainDisplayID());
|
|
11
|
+
const stdout = $.NSFileHandle.fileHandleWithStandardOutput;
|
|
12
|
+
const screen = $.CGPreflightScreenCaptureAccess(), accessibility = $.AXIsProcessTrusted();
|
|
13
|
+
stdout.writeData($(JSON.stringify({ screen, accessibility,
|
|
14
|
+
width: bounds.size.width, height: bounds.size.height }) + "\n").dataUsingEncoding($.NSUTF8StringEncoding));
|
|
15
|
+
if (argv[0] === "request") {
|
|
16
|
+
if (!screen && argv[1] !== "accessibility") $.CGRequestScreenCaptureAccess();
|
|
17
|
+
if (!accessibility && argv[1] !== "screen") $.AXIsProcessTrustedWithOptions($({ AXTrustedCheckOptionPrompt: true }));
|
|
18
|
+
}
|
|
19
|
+
if (argv[0] === "probe" || argv[0] === "request") return;
|
|
20
|
+
if (argv[0] === "clipboard") {
|
|
21
|
+
const parent = $.getppid(), clipboard = $.NSPasteboard.generalPasteboard;
|
|
22
|
+
// Only changes made during this pairing: never export the initial pasteboard.
|
|
23
|
+
let last = Number(clipboard.changeCount);
|
|
24
|
+
while ($.getppid() === parent) {
|
|
25
|
+
$.NSThread.sleepForTimeInterval(0.1);
|
|
26
|
+
const count = Number(clipboard.changeCount);
|
|
27
|
+
if (count === last) continue;
|
|
28
|
+
last = count;
|
|
29
|
+
const text = clipboard.stringForType($.NSPasteboardTypeString);
|
|
30
|
+
if (!text) continue;
|
|
31
|
+
const bytes = text.dataUsingEncoding($.NSUTF8StringEncoding);
|
|
32
|
+
if (Number(bytes.length) > ${Y}) continue;
|
|
33
|
+
stdout.writeData($("c " + bytes.base64EncodedStringWithOptions(0).js + "\n").dataUsingEncoding($.NSUTF8StringEncoding));
|
|
34
|
+
}
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const stdin = $.NSFileHandle.fileHandleWithStandardInput;
|
|
38
|
+
let pending = "";
|
|
39
|
+
for (;;) {
|
|
40
|
+
const data = stdin.availableData;
|
|
41
|
+
if (Number(data.length) === 0) return;
|
|
42
|
+
pending += $.NSString.alloc.initWithDataEncoding(data, $.NSUTF8StringEncoding).js;
|
|
43
|
+
for (let end = pending.indexOf("\n"); end >= 0; end = pending.indexOf("\n")) {
|
|
44
|
+
const [kind, ...rest] = pending.slice(0, end).split(" ");
|
|
45
|
+
pending = pending.slice(end + 1);
|
|
46
|
+
const n = rest.map(Number);
|
|
47
|
+
let event = null;
|
|
48
|
+
if (kind === "m") {
|
|
49
|
+
event = $.CGEventCreateMouseEvent($(), n[0], { x: n[1], y: n[2] }, n[3]);
|
|
50
|
+
$.CGEventSetIntegerValueField(event, $.kCGMouseEventClickState, n[4]);
|
|
51
|
+
} else if (kind === "w") {
|
|
52
|
+
event = $.CGEventCreateScrollWheelEvent($(), $.kCGScrollEventUnitPixel, 2, n[0], n[1]);
|
|
53
|
+
} else if (kind === "k") {
|
|
54
|
+
event = $.CGEventCreateKeyboardEvent($(), n[0], n[1] === 1);
|
|
55
|
+
} else if (kind === "u") {
|
|
56
|
+
event = $.CGEventCreateKeyboardEvent($(), 0, n[0] === 1);
|
|
57
|
+
const unit = Ref("unsigned short");
|
|
58
|
+
unit[0] = n[1];
|
|
59
|
+
$.CGEventKeyboardSetUnicodeString(event, 1, unit);
|
|
60
|
+
} else if (kind === "c") {
|
|
61
|
+
const bytes = $.NSData.alloc.initWithBase64EncodedStringOptions($(rest[0] || ""), 0);
|
|
62
|
+
$.NSPasteboard.generalPasteboard.clearContents;
|
|
63
|
+
$.NSPasteboard.generalPasteboard.setStringForType($.NSString.alloc.initWithDataEncoding(bytes, $.NSUTF8StringEncoding), $.NSPasteboardTypeString);
|
|
64
|
+
}
|
|
65
|
+
if (event) {
|
|
66
|
+
$.CGEventSetFlags(event, n[n.length - 1]);
|
|
67
|
+
$.CGEventPost($.kCGHIDEventTap, event);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
`;function y(q){let j;try{j=JSON.parse(q)}catch{return null}if(!j||typeof j!=="object")return null;let J=j,Q=(G)=>typeof G==="number"&&Number.isFinite(G)?Math.min(65535,Math.round(G)):0;if(typeof J.screen!=="boolean"||typeof J.accessibility!=="boolean")return null;let Z=Q(J.width),z=Q(J.height);return Z>0&&z>0?{screen:J.screen,accessibility:J.accessibility,width:Z,height:z}:null}function w(q,...j){let[J,...Q]=[...q,t,"-l","JavaScript","-e",Uj,...j];return[J,Q]}function r(q,...j){return new Promise((J)=>{zj(...w(q,...j),{env:{},timeout:Gj,killSignal:"SIGKILL",maxBuffer:65536,encoding:"utf8"},(Q,Z)=>J(Q?null:y(Z.split(`
|
|
73
|
+
`)[0]??"")))})}function Sj(q=[]){return r(q,"probe")}function _j(q,j){return r(q,"request",...j?[j]:[])}var u=2,Fj=8,Bj=String.raw`
|
|
74
|
+
ObjC.import("CoreGraphics");
|
|
75
|
+
ObjC.import("Foundation");
|
|
76
|
+
ObjC.bindFunction("getppid", ["int", []]);
|
|
77
|
+
function run() {
|
|
78
|
+
const stdout = $.NSFileHandle.fileHandleWithStandardOutput;
|
|
79
|
+
const parent = $.getppid();
|
|
80
|
+
let last = "";
|
|
81
|
+
let wait = ${u};
|
|
82
|
+
// Ends with the worker that started it, even one that never got to kill it.
|
|
83
|
+
while ($.getppid() === parent) {
|
|
84
|
+
const list = ObjC.castRefToObject($.CGWindowListCopyWindowInfo($.kCGWindowListOptionOnScreenOnly | $.kCGWindowListExcludeDesktopElements, 0));
|
|
85
|
+
const bounds = [];
|
|
86
|
+
const count = Number(list.count);
|
|
87
|
+
for (let i = 0; i < count && bounds.length < ${A}; i++) {
|
|
88
|
+
const window = list.objectAtIndex(i);
|
|
89
|
+
if (Number(window.objectForKey("kCGWindowLayer").js) !== 0) continue;
|
|
90
|
+
const b = window.objectForKey("kCGWindowBounds");
|
|
91
|
+
bounds.push(["X", "Y", "Width", "Height"].map((key) => Math.round(Number(b.objectForKey(key).js))));
|
|
92
|
+
}
|
|
93
|
+
const line = JSON.stringify(bounds);
|
|
94
|
+
if (line !== last) {
|
|
95
|
+
last = line;
|
|
96
|
+
wait = ${u};
|
|
97
|
+
stdout.writeData($(line + "\n").dataUsingEncoding($.NSUTF8StringEncoding));
|
|
98
|
+
} else {
|
|
99
|
+
wait = Math.min(wait * 2, ${Fj});
|
|
100
|
+
}
|
|
101
|
+
$.NSThread.sleepForTimeInterval(wait);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
`;function Hj(q){let j;try{j=JSON.parse(q)}catch{return null}if(!Array.isArray(j))return null;let J=[];for(let Q of j.slice(0,A)){if(!Array.isArray(Q)||Q.length!==4||!Q.every((K)=>typeof K==="number"&&Number.isFinite(K)))return null;let[Z,z,G,F]=Q.map(Math.round);if(G>0&&F>0)J.push({x:Z,y:z,width:G,height:F})}return J}function Tj(q){let j=Date.now(),J=0,Q=!1,Z=(K,W={})=>{try{process.stderr.write(`${JSON.stringify({event:"display.windows_helper",state:K,...W})}
|
|
105
|
+
`)}catch{}},z=(K,W={})=>{if(Q)return;Q=!0,Z(K,{updates:J,duration_ms:Date.now()-j,...W})},G=I(t,["-l","JavaScript","-e",Bj],{env:{},stdio:["ignore","pipe","ignore"]});Z("started");let F="";return G.stdout.on("data",(K)=>{if(Q)return;F+=K.toString("utf8");for(let W=F.indexOf(`
|
|
106
|
+
`);W>=0;W=F.indexOf(`
|
|
107
|
+
`)){let L=Hj(F.slice(0,W));if(F=F.slice(W+1),L)J++,q(L)}if(F.length>65536)F=""}),G.once("error",(K)=>z("failed",{code:K.code??"spawn_failed"})),G.once("exit",(K,W)=>z("failed",{code:"exited",exit_code:K,signal:W})),{close(){z("stopped"),G.kill("SIGKILL")}}}var b=5,m=[{bit:1,button:0,down:1,up:2,drag:6},{bit:4,button:1,down:3,up:4,drag:7},{bit:2,button:2,down:25,up:26,drag:27}],Wj=[[8,1,0],[16,-1,0],[32,0,1],[64,0,-1]],g=50,Xj=500,v=4,P=131072,E=262144,x=524288,D=1048576,c=new Map([[65505,[56,P]],[65506,[60,P]],[65507,[59,E]],[65508,[62,E]],[65511,[58,x]],[65512,[61,x]],[65513,[58,x]],[65514,[61,x]],[65027,[61,x]],[65515,[55,D]],[65516,[54,D]]]),Nj=new Map([[65288,51],[65289,48],[65056,48],[65293,36],[65307,53],[65535,117],[65509,57],[65360,115],[65361,123],[65362,126],[65363,124],[65364,125],[65365,116],[65366,121],[65367,119],[65379,114],[65386,114],[65291,71],[65408,49],[65421,76],[65429,115],[65430,123],[65431,126],[65432,124],[65433,125],[65434,116],[65435,121],[65436,119],[65437,71],[65438,114],[65439,117],[65450,67],[65451,69],[65452,65],[65453,78],[65454,65],[65455,75],[65469,81],...[82,83,84,85,86,87,88,89,91,92].map((q,j)=>[65456+j,q]),...[122,120,99,118,96,97,98,100,101,109,103,111,105,107,113,106,64,79,80,90].map((q,j)=>[65470+j,q])]),p="asdfhgzxcv\x00bqweryt123465=97-80]ou[ip\x00lj'k;\\,/nm.\x00 `",n='~!@#$%^&*()_+{}|:"<>?',Rj="`1234567890-=[]\\;',./",M=new Map;for(let q=0;q<p.length;q++){let j=p[q];if(j==="\x00")continue;if(M.set(j.charCodeAt(0),[q,!1]),j>="a"&&j<="z")M.set(j.toUpperCase().charCodeAt(0),[q,!0])}for(let q=0;q<n.length;q++)M.set(n.charCodeAt(q),[M.get(Rj.charCodeAt(q))[0],!0]);class a{now;x=-1;y=-1;mask=0;clicks=0;lastDown=null;held=new Set;constructor(q=()=>performance.now()){this.now=q}flags(){let q=0;for(let j of this.held)q|=c.get(j)[1];return q}mouse(q,j){return`m ${q} ${this.x} ${this.y} ${j} ${q===b?0:this.clicks} ${this.flags()}`}pointer(q,j,J){let Q=[];if(q!==this.x||j!==this.y){this.x=q,this.y=j;let Z=m.find((z)=>this.mask&z.bit);Q.push(Z?this.mouse(Z.drag,Z.button):this.mouse(b,0))}for(let Z of m){let z=(this.mask&Z.bit)!==0,G=(J&Z.bit)!==0;if(!z&&G){let F=this.now(),K=this.lastDown;this.clicks=K&&K.button===Z.button&&F-K.at<=Xj&&Math.abs(q-K.x)<=v&&Math.abs(j-K.y)<=v?this.clicks+1:1,this.lastDown={button:Z.button,at:F,x:q,y:j},Q.push(this.mouse(Z.down,Z.button))}else if(z&&!G)Q.push(this.mouse(Z.up,Z.button))}for(let[Z,z,G]of Wj)if(!(this.mask&Z)&&J&Z)Q.push(`w ${z*g} ${G*g} ${this.flags()}`);return this.mask=J,Q}key(q,j){let J=q?1:0,Q=c.get(j);if(Q){if(q)this.held.add(j);else this.held.delete(j);return[`k ${Q[0]} ${J} ${this.flags()}`]}let Z=Nj.get(j);if(Z!==void 0)return[`k ${Z} ${J} ${this.flags()}`];let z=j<256?j:(j&4278190080)===16777216?j&16777215:0,G=M.get(z);if(G)return[`k ${G[0]} ${J} ${this.flags()|(G[1]?P:0)}`];if(z<160||z>65535||z>=55296&&z<57344)return[];return[`u ${J} ${z} ${this.flags()}`]}}function Vj(q,j=[]){let J=I(...w(j),{env:{},stdio:["pipe","pipe","ignore"]}),Q=new a,Z="",z=!1,G=null,F=()=>{J.kill("SIGKILL"),G?.kill("SIGKILL")},K=(B)=>{if(z)return;z=!0,F(),q.end(B)},W=(B)=>K({error:new l("display_unavailable",B)}),L=(B)=>{if(z||B.length===0)return;if(J.stdin.write(B.map((N)=>`${N}
|
|
108
|
+
`).join("")),J.stdin.writableLength>Kj)K({reason:"input_backpressure"})},i=()=>{G=I(...w(j,"clipboard"),{env:{},stdio:["ignore","pipe","ignore"]});let B="";G.stdout?.on("data",(N)=>{if(z)return;B+=N.toString("ascii");for(let X=B.indexOf(`
|
|
109
|
+
`);X>=0;X=B.indexOf(`
|
|
110
|
+
`)){let S=B.slice(0,X);if(B=B.slice(X+1),!S.startsWith("c "))continue;let O=S.slice(2);if(O.length>Math.ceil(Y/3)*4||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(O)){K({reason:"display_protocol"});return}let _=Buffer.from(O,"base64");if(_.byteLength<=Y)q.clipboard(_.toString("utf8"));if(z)return}if(B.length>Math.ceil(Y/3)*4+2)K({reason:"display_protocol"})}),G.once("error",()=>W("Reason could not watch this Mac's desktop clipboard.")),G.once("exit",()=>{if(!z)W("Reason could not watch this Mac's desktop clipboard.")})};return J.stdout.on("data",(B)=>{if(z||Z===null)return;Z+=B.toString("utf8");let N=Z.indexOf(`
|
|
111
|
+
`);if(N<0){if(Z.length>4096)K({reason:"display_protocol"});return}let X=y(Z.slice(0,N));if(Z=null,!X)K({reason:"display_protocol"});else if(!X.screen||!X.accessibility)W(j.length>0?"Reason's background worker needs Screen Recording and Accessibility on this Mac (its own Reason entry in System Settings > Privacy & Security, not the Reason app's): run `reason permissions allow` on this Mac.":"Allow Screen Recording and Accessibility for this Mac's Reason worker, then restart it.");else i(),q.ready({width:X.width,height:X.height})}),J.stdin.on("error",()=>{return}),J.once("error",()=>W("Reason could not start this Mac's desktop input.")),J.once("exit",()=>{if(Z!==null)W("Reason could not start this Mac's desktop input.");else K({reason:"display_closed"})}),{pointer:(B,N,X)=>L(Q.pointer(B,N,X)),key:(B,N)=>L(Q.key(B,N)),clipboard:(B)=>L([`c ${Buffer.from(B,"utf8").toString("base64")}`]),close(){z=!0,F()}}}
|
|
112
|
+
export{Cj as yg,kj as zg,h as Ag,Yj as Bg,Y as Cg,Lj as Dg,Aj as Eg,s as Fg,xj as Gg,Mj as Hg,fj as Ig,hj as Jg,$j as Kg,y as Lg,Sj as Mg,_j as Ng,Hj as Og,Tj as Pg,a as Qg,Vj as Rg};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Xg as J}from"./vm-hands-entry-lite-9pmag2qk.js";import{readFileSync as L}from"fs";import{isAbsolute as M,normalize as Q}from"path";var W="REASON_WORKER_DESKTOP_USER",G=null;function X(q,B){for(let I of B.split(`
|
|
3
|
+
`)){let j=I.split(":");if(j.length<7||Number(j[2])!==q||!/^\d+$/.test(j[2])||!/^\d+$/.test(j[3]))continue;let x=j[5];if(!/^[a-z_][a-z0-9_-]*$/i.test(j[0])||!M(x)||Q(x)!==x||x==="/")return null;return{username:j[0],uid:q,gid:Number(j[3]),home:x}}return null}function b(q={}){let B="value"in q?q.value:process.env[W];if(G=null,B===void 0||B==="")return null;let I=q.platform??process.platform,j="euid"in q?q.euid:process.geteuid?.(),x=/^[1-9]\d{0,9}$/.test(B)?Number(B):NaN,C=I==="linux"&&j===0&&Number.isSafeInteger(x)?X(x,(q.passwd??(()=>L("/etc/passwd","utf8")))()):null;if(!C||C.gid===0)throw Error("worker_desktop_user_invalid");return G=C,C}function k(){return G}function y(){return G?.home??J()}
|
|
4
|
+
export{W as Sg,X as Tg,b as Ug,k as Vg,y as Wg};
|