@reason-machines/cli-linux-arm64-musl 0.2.381 → 0.2.383
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/bin/ara +2 -2
- package/bin/vm-hands/api-credentials-xppmbg0m.js +2 -0
- package/bin/vm-hands/api-xmpbsm6b.js +2 -0
- package/bin/vm-hands/{ask-relay-fc0jc3t5.js → ask-relay-h8f5dmfh.js} +3 -3
- package/bin/vm-hands/connect-cli-qvfxpk5t.js +2 -0
- package/bin/vm-hands/{custom-endpoint-device-zhpake9f.js → custom-endpoint-device-bm94e9r0.js} +1 -1
- package/bin/vm-hands/desktop-account-3tnm4z5w.js +2 -0
- package/bin/vm-hands/{device-workspace-vbcry9d6.js → device-workspace-0xsj5ykf.js} +1 -1
- package/bin/vm-hands/hands-worker-source-azdrrhsz.js +2 -0
- package/bin/vm-hands/{index-bbk6a9sk.js → index-7f2kwwen.js} +1 -1
- package/bin/vm-hands/{install-receipt-7x81ek76.js → install-receipt-3xyx3rdd.js} +1 -1
- package/bin/vm-hands/local-automation-pvy9revm.js +2 -0
- package/bin/vm-hands/local-capabilities-zfzyknay.js +2 -0
- package/bin/vm-hands/local-desktop-users-ajb81vjm.js +2 -0
- package/bin/vm-hands/local-display-mac-9h6btvvq.js +2 -0
- package/bin/vm-hands/local-display-session-xqncvp30.js +2 -0
- package/bin/vm-hands/local-pty-session-cjas515w.js +2 -0
- package/bin/vm-hands/managed-runtime-s414h5nm.js +2 -0
- package/bin/vm-hands/{network-contract-zqvt1v0t.js → network-contract-dsw79qkc.js} +1 -1
- package/bin/vm-hands/package-smk3nqjs.js +2 -0
- package/bin/vm-hands/permissions-3mkk9mfw.js +2 -0
- package/bin/vm-hands/{reason-hands-protocol-8fxjynte.js → reason-hands-protocol-7d7xj1h3.js} +1 -1
- package/bin/vm-hands/serve-service-txzqn5kj.js +2 -0
- package/bin/vm-hands/status-23eqx9t3.js +96 -0
- package/bin/vm-hands/version-3gj9bqhc.js +2 -0
- package/bin/vm-hands/{vm-hands-entry-lite-7shpbsw8.js → vm-hands-entry-lite-1gxktkpe.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-2e18tm6w.js +245 -0
- package/bin/vm-hands/{vm-hands-entry-lite-g036gtem.js → vm-hands-entry-lite-2t0vcvd8.js} +1 -1
- package/bin/vm-hands/vm-hands-entry-lite-3dc4v5bd.js +11 -0
- package/bin/vm-hands/{vm-hands-entry-lite-hgkf1svv.js → vm-hands-entry-lite-41nygv3p.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-j2q1k9vb.js → vm-hands-entry-lite-51hmj6am.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-zfwg7ehq.js → vm-hands-entry-lite-5n4vsm6b.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-k7wwza46.js → vm-hands-entry-lite-7xbgw4m0.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-8fj07njx.js +3 -0
- package/bin/vm-hands/{vm-hands-entry-lite-3hbe4em3.js → vm-hands-entry-lite-9cmfthkq.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-4q8tsaqv.js → vm-hands-entry-lite-9r5tz2dx.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-45j8qwsf.js → vm-hands-entry-lite-9w5vs9zv.js} +1 -1
- package/bin/vm-hands/vm-hands-entry-lite-a0yfp7s2.js +251 -0
- package/bin/vm-hands/{vm-hands-entry-lite-za55dtte.js → vm-hands-entry-lite-ammr3xbc.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-dh5gwmyf.js +3 -0
- package/bin/vm-hands/{vm-hands-entry-lite-5pm6bhb8.js → vm-hands-entry-lite-e0gdt6r5.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-5kgvss4p.js → vm-hands-entry-lite-e2mjbqmr.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite-ejm5er3h.js +7 -0
- package/bin/vm-hands/vm-hands-entry-lite-eqhsewc0.js +105 -0
- package/bin/vm-hands/{vm-hands-entry-lite-mh0xecf3.js → vm-hands-entry-lite-f02906k8.js} +4 -4
- package/bin/vm-hands/vm-hands-entry-lite-f5230h6t.js +67 -0
- package/bin/vm-hands/{vm-hands-entry-lite-zh8p7ndn.js → vm-hands-entry-lite-fb5dzy9x.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-yjn6sk08.js → vm-hands-entry-lite-fcrqyxz0.js} +1 -1
- package/bin/vm-hands/vm-hands-entry-lite-fyvgav60.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-g5grabna.js +540 -0
- package/bin/vm-hands/vm-hands-entry-lite-g7h6wjqy.js +3 -0
- package/bin/vm-hands/{vm-hands-entry-lite-34e71nbe.js → vm-hands-entry-lite-g8pj1jxa.js} +174 -16
- package/bin/vm-hands/vm-hands-entry-lite-h1rxv02g.js +458 -0
- package/bin/vm-hands/vm-hands-entry-lite-h8dbw0c7.js +4 -0
- package/bin/vm-hands/{vm-hands-entry-lite-nhtb458c.js → vm-hands-entry-lite-hnsm5t36.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-0asdf4pm.js → vm-hands-entry-lite-jzcc9h71.js} +3 -3
- package/bin/vm-hands/{vm-hands-entry-lite-r6pap1kh.js → vm-hands-entry-lite-ma001vzh.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-anmv8hp7.js → vm-hands-entry-lite-mn64e4pt.js} +286 -104
- package/bin/vm-hands/{vm-hands-entry-lite-9cgm6g8t.js → vm-hands-entry-lite-pk3q774c.js} +1 -1
- package/bin/vm-hands/vm-hands-entry-lite-qef2ndkd.js +6 -0
- package/bin/vm-hands/vm-hands-entry-lite-qnnfvm5r.js +5 -0
- package/bin/vm-hands/vm-hands-entry-lite-r8qg3wp1.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-rd0ak4ye.js +4 -0
- package/bin/vm-hands/{vm-hands-entry-lite-00qsbphw.js → vm-hands-entry-lite-rpn0frzb.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-g9rvf5qk.js → vm-hands-entry-lite-rtt2w6c6.js} +1 -1
- package/bin/vm-hands/vm-hands-entry-lite-sex82vb1.js +3 -0
- package/bin/vm-hands/vm-hands-entry-lite-vcwgh8tr.js +346 -0
- package/bin/vm-hands/{vm-hands-entry-lite-dgxxsdwb.js → vm-hands-entry-lite-xrthfx3q.js} +2 -2
- package/bin/vm-hands/{vm-hands-entry-lite-kxdw4myj.js → vm-hands-entry-lite-y2s2w174.js} +1 -1
- package/bin/vm-hands/{vm-hands-entry-lite-hc3p6r9p.js → vm-hands-entry-lite-zjfr0zh8.js} +2 -2
- package/bin/vm-hands/vm-hands-entry-lite.js +1 -1
- package/bin/vm-hands/{vm-hands-executor-qssgfea1.js → vm-hands-executor-9p92j0mv.js} +1 -1
- package/bin/vm-hands/vm-hands-op-runner-ers4cefp.js +2 -0
- package/bin/vm-hands/{vm-hands-runtime-5me6cpmn.js → vm-hands-runtime-en4gj0t0.js} +3 -3
- package/bin/vm-hands/worker-sandbox-tgqbmy6b.js +2 -0
- package/package.json +1 -1
- package/bin/vm-hands/api-af9g18n7.js +0 -2
- package/bin/vm-hands/api-credentials-65mrr3tn.js +0 -2
- package/bin/vm-hands/connect-cli-j478km3s.js +0 -2
- package/bin/vm-hands/desktop-account-5zvgspyw.js +0 -2
- package/bin/vm-hands/hands-worker-source-h0b1j53p.js +0 -2
- package/bin/vm-hands/local-automation-c86tjeft.js +0 -2
- package/bin/vm-hands/local-capabilities-1h99gkt6.js +0 -2
- package/bin/vm-hands/local-desktop-users-0hadyvx1.js +0 -2
- package/bin/vm-hands/local-display-mac-v1pc7177.js +0 -2
- package/bin/vm-hands/local-display-session-tzq0hne8.js +0 -2
- package/bin/vm-hands/local-pty-session-hs7rq03x.js +0 -2
- package/bin/vm-hands/managed-runtime-5dqaaw1x.js +0 -2
- package/bin/vm-hands/package-3cd7cfyv.js +0 -2
- package/bin/vm-hands/permissions-vbyqjbyb.js +0 -2
- package/bin/vm-hands/serve-service-be739c9s.js +0 -2
- package/bin/vm-hands/status-s8ny6men.js +0 -96
- package/bin/vm-hands/version-8s4syrp2.js +0 -2
- package/bin/vm-hands/vm-hands-entry-lite-1085xsma.js +0 -5
- package/bin/vm-hands/vm-hands-entry-lite-4m40gwkf.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-62wmnm7g.js +0 -540
- package/bin/vm-hands/vm-hands-entry-lite-98076n5g.js +0 -62
- package/bin/vm-hands/vm-hands-entry-lite-bvbfcp1k.js +0 -4
- package/bin/vm-hands/vm-hands-entry-lite-c01eyep6.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-dcynw6t2.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-hh24bq0d.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-jb2sr2r7.js +0 -3
- package/bin/vm-hands/vm-hands-entry-lite-kt5aj2ax.js +0 -11
- package/bin/vm-hands/vm-hands-entry-lite-n9nnb482.js +0 -459
- package/bin/vm-hands/vm-hands-entry-lite-sb9a1jcn.js +0 -4
- package/bin/vm-hands/vm-hands-entry-lite-xg3d0a2y.js +0 -340
- package/bin/vm-hands/vm-hands-entry-lite-zamt8xp7.js +0 -181
- package/bin/vm-hands/vm-hands-entry-lite-ze9msfq1.js +0 -3
- package/bin/vm-hands/vm-hands-op-runner-b76rjaps.js +0 -2
- package/bin/vm-hands/worker-sandbox-wpzkvwer.js +0 -2
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var e=String.raw`(function(loadFfi, existsSync) {
|
|
3
|
+
const STARTF_USESTDHANDLES = 0x100;
|
|
4
|
+
const CREATE_SUSPENDED = 0x4;
|
|
5
|
+
const CREATE_UNICODE_ENVIRONMENT = 0x400;
|
|
6
|
+
const EXTENDED_STARTUPINFO_PRESENT = 0x80000;
|
|
7
|
+
const PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE = 0x20016;
|
|
8
|
+
const JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE = 0x2000;
|
|
9
|
+
const JOB_OBJECT_BASIC_ACCOUNTING_INFORMATION = 1;
|
|
10
|
+
const JOB_OBJECT_EXTENDED_LIMIT_INFORMATION = 9;
|
|
11
|
+
const POLL_MS = 10;
|
|
12
|
+
// Output the console renders after the shell exits still reaches the viewer.
|
|
13
|
+
const EXIT_LINGER_MS = 100;
|
|
14
|
+
const READ_CHUNK_BYTES = 65536;
|
|
15
|
+
const READ_TICK_BYTES = 1048576;
|
|
16
|
+
const PIPE_NOWAIT = 1;
|
|
17
|
+
let api = null, loadError = null;
|
|
18
|
+
function kernel32() {
|
|
19
|
+
if (api) return api;
|
|
20
|
+
const ffi = loadFfi();
|
|
21
|
+
const { symbols } = ffi.dlopen("kernel32.dll", {
|
|
22
|
+
CreatePipe: { args: ["ptr", "ptr", "ptr", "u32"], returns: "i32" },
|
|
23
|
+
CreatePseudoConsole: { args: ["u32", "u64", "u64", "u32", "ptr"], returns: "i32" },
|
|
24
|
+
ResizePseudoConsole: { args: ["u64", "u32"], returns: "i32" },
|
|
25
|
+
ClosePseudoConsole: { args: ["u64"], returns: "void" },
|
|
26
|
+
InitializeProcThreadAttributeList: { args: ["ptr", "u32", "u32", "ptr"], returns: "i32" },
|
|
27
|
+
UpdateProcThreadAttribute: { args: ["ptr", "u32", "u64", "u64", "u64", "ptr", "ptr"], returns: "i32" },
|
|
28
|
+
DeleteProcThreadAttributeList: { args: ["ptr"], returns: "void" },
|
|
29
|
+
CreateProcessW: { args: ["ptr", "ptr", "ptr", "ptr", "i32", "u32", "ptr", "ptr", "ptr", "ptr"], returns: "i32" },
|
|
30
|
+
CreateJobObjectW: { args: ["ptr", "ptr"], returns: "u64" },
|
|
31
|
+
SetInformationJobObject: { args: ["u64", "u32", "ptr", "u32"], returns: "i32" },
|
|
32
|
+
QueryInformationJobObject: { args: ["u64", "u32", "ptr", "u32", "ptr"], returns: "i32" },
|
|
33
|
+
AssignProcessToJobObject: { args: ["u64", "u64"], returns: "i32" },
|
|
34
|
+
TerminateJobObject: { args: ["u64", "u32"], returns: "i32" },
|
|
35
|
+
ResumeThread: { args: ["u64"], returns: "u32" },
|
|
36
|
+
TerminateProcess: { args: ["u64", "u32"], returns: "i32" },
|
|
37
|
+
PeekNamedPipe: { args: ["u64", "ptr", "u32", "ptr", "ptr", "ptr"], returns: "i32" },
|
|
38
|
+
ReadFile: { args: ["u64", "ptr", "u32", "ptr", "ptr"], returns: "i32" },
|
|
39
|
+
WriteFile: { args: ["u64", "ptr", "u32", "ptr", "ptr"], returns: "i32" },
|
|
40
|
+
SetNamedPipeHandleState: { args: ["u64", "ptr", "ptr", "ptr"], returns: "i32" },
|
|
41
|
+
WaitForSingleObject: { args: ["u64", "u32"], returns: "u32" },
|
|
42
|
+
GetExitCodeProcess: { args: ["u64", "ptr"], returns: "i32" },
|
|
43
|
+
CloseHandle: { args: ["u64"], returns: "i32" },
|
|
44
|
+
GetLastError: { args: [], returns: "u32" },
|
|
45
|
+
});
|
|
46
|
+
api = Object.assign({}, symbols, { ptr: ffi.ptr });
|
|
47
|
+
return api;
|
|
48
|
+
}
|
|
49
|
+
function available() {
|
|
50
|
+
try { kernel32(); return true; } catch (error) { loadError = String(error && error.message || error); return false; }
|
|
51
|
+
}
|
|
52
|
+
/** Why available() is false, for diagnostics only. */
|
|
53
|
+
function unavailableReason() { return loadError;
|
|
54
|
+
}
|
|
55
|
+
function variable(env, name) {
|
|
56
|
+
const key = Object.keys(env).find((candidate) => candidate.toUpperCase() === name);
|
|
57
|
+
return key === undefined ? undefined : env[key];
|
|
58
|
+
}
|
|
59
|
+
/** PowerShell 7 when it is on PATH, else Windows PowerShell, else cmd.exe. */
|
|
60
|
+
function defaultShell(env) {
|
|
61
|
+
for (const directory of String(variable(env, "PATH") || "").split(";")) {
|
|
62
|
+
if (!/^[A-Za-z]:\\/.test(directory)) continue;
|
|
63
|
+
const candidate = directory.replace(/\\+$/, "") + "\\pwsh.exe";
|
|
64
|
+
if (existsSync(candidate)) return candidate;
|
|
65
|
+
}
|
|
66
|
+
const systemRoot = variable(env, "SYSTEMROOT") || "C:\\Windows";
|
|
67
|
+
const powershell = systemRoot + "\\System32\\WindowsPowerShell\\v1.0\\powershell.exe";
|
|
68
|
+
if (existsSync(powershell)) return powershell;
|
|
69
|
+
return variable(env, "COMSPEC") || systemRoot + "\\System32\\cmd.exe";
|
|
70
|
+
}
|
|
71
|
+
function shellArgs(shell) {
|
|
72
|
+
return /(^|[\\/])(pwsh|powershell)(\.exe)?$/i.test(shell) ? ["-NoLogo"] : [];
|
|
73
|
+
}
|
|
74
|
+
/** One CreateProcessW argument, quoted as CommandLineToArgvW reads it. */
|
|
75
|
+
function quoteArg(value) {
|
|
76
|
+
if (value && !/[\s"]/.test(value)) return value;
|
|
77
|
+
let quoted = '"', backslashes = 0;
|
|
78
|
+
for (const character of value) {
|
|
79
|
+
if (character === "\\") { backslashes += 1; continue; }
|
|
80
|
+
quoted += "\\".repeat(character === '"' ? backslashes * 2 + 1 : backslashes) + character;
|
|
81
|
+
backslashes = 0;
|
|
82
|
+
}
|
|
83
|
+
return quoted + "\\".repeat(backslashes * 2) + '"';
|
|
84
|
+
}
|
|
85
|
+
/** A CREATE_UNICODE_ENVIRONMENT block: sorted name=value NUL entries, then NUL. */
|
|
86
|
+
function environmentBlock(env) {
|
|
87
|
+
const entries = Object.entries(env)
|
|
88
|
+
.filter(([name, value]) => typeof value === "string" && name !== "" && !name.includes("="))
|
|
89
|
+
.sort(([left], [right]) => left.toUpperCase() < right.toUpperCase() ? -1 : left.toUpperCase() > right.toUpperCase() ? 1 : 0);
|
|
90
|
+
return Buffer.from(entries.map(([name, value]) => name + "=" + value + "\0").join("") + "\0" + (entries.length ? "" : "\0"), "utf16le");
|
|
91
|
+
}
|
|
92
|
+
// Diagnostics name the failed call; codes only, never terminal content.
|
|
93
|
+
const win32Error = (name) => new Error(name + " (GetLastError " + kernel32().GetLastError() + ")");
|
|
94
|
+
const hresultError = (name, hr) => new Error(name + " (HRESULT 0x" + (hr >>> 0).toString(16).padStart(8, "0") + ")");
|
|
95
|
+
const wide = (value) => Buffer.from(value + "\0", "utf16le");
|
|
96
|
+
const coord = (cols, rows) => ((rows & 0xffff) << 16 | (cols & 0xffff)) >>> 0;
|
|
97
|
+
/** input: { file, args, cwd, cols, rows, env, onData(bytes) } */
|
|
98
|
+
function spawn(input) {
|
|
99
|
+
const k = kernel32();
|
|
100
|
+
const opened = [];
|
|
101
|
+
const own = (handle) => { opened.push(handle); return handle; };
|
|
102
|
+
const closeHandle = (handle) => {
|
|
103
|
+
const index = opened.indexOf(handle);
|
|
104
|
+
if (index < 0) return;
|
|
105
|
+
opened.splice(index, 1);
|
|
106
|
+
k.CloseHandle(handle);
|
|
107
|
+
};
|
|
108
|
+
const pipe = () => {
|
|
109
|
+
const read = new BigUint64Array(1), write = new BigUint64Array(1);
|
|
110
|
+
if (!k.CreatePipe(read, write, null, 0)) throw win32Error("conpty_pipe_failed");
|
|
111
|
+
return [own(read[0]), own(write[0])];
|
|
112
|
+
};
|
|
113
|
+
let hpc = null, attributes = null, job, processHandle, inputWrite, outputRead, pid;
|
|
114
|
+
try {
|
|
115
|
+
job = k.CreateJobObjectW(null, null);
|
|
116
|
+
if (!job) throw win32Error("conpty_job_failed");
|
|
117
|
+
own(job);
|
|
118
|
+
// JOBOBJECT_EXTENDED_LIMIT_INFORMATION (x64): LimitFlags at 16, 144 bytes.
|
|
119
|
+
const limits = new Uint8Array(144);
|
|
120
|
+
new DataView(limits.buffer).setUint32(16, JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE, true);
|
|
121
|
+
if (!k.SetInformationJobObject(job, JOB_OBJECT_EXTENDED_LIMIT_INFORMATION, limits, limits.length)) throw win32Error("conpty_job_failed");
|
|
122
|
+
const [inputRead, inputWriteEnd] = pipe();
|
|
123
|
+
const [outputReadEnd, outputWrite] = pipe();
|
|
124
|
+
inputWrite = inputWriteEnd; outputRead = outputReadEnd;
|
|
125
|
+
if (!k.SetNamedPipeHandleState(inputWrite, new Uint32Array([PIPE_NOWAIT]), null, null)) throw win32Error("conpty_pipe_failed");
|
|
126
|
+
const created = new BigUint64Array(1);
|
|
127
|
+
const createdResult = k.CreatePseudoConsole(coord(input.cols, input.rows), inputRead, outputWrite, 0, created);
|
|
128
|
+
if (createdResult !== 0) throw hresultError("conpty_create_failed", createdResult);
|
|
129
|
+
hpc = created[0];
|
|
130
|
+
// The console host holds its own duplicates of the far ends.
|
|
131
|
+
closeHandle(inputRead); closeHandle(outputWrite);
|
|
132
|
+
const size = new BigUint64Array(1);
|
|
133
|
+
k.InitializeProcThreadAttributeList(null, 1, 0, size);
|
|
134
|
+
const list = new Uint8Array(Number(size[0]));
|
|
135
|
+
if (!k.InitializeProcThreadAttributeList(list, 1, 0, size)) throw win32Error("conpty_attributes_failed");
|
|
136
|
+
attributes = list;
|
|
137
|
+
if (!k.UpdateProcThreadAttribute(attributes, 0, PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE, hpc, 8, null, null)) throw win32Error("conpty_attributes_failed");
|
|
138
|
+
// STARTUPINFOEXW (x64): dwFlags at 60, lpAttributeList at 104, 112 bytes.
|
|
139
|
+
// Null standard handles: otherwise an owner whose own stdio is
|
|
140
|
+
// redirected hands those pipes to the shell instead of the console.
|
|
141
|
+
const startup = new Uint8Array(112);
|
|
142
|
+
const startupView = new DataView(startup.buffer);
|
|
143
|
+
startupView.setUint32(0, startup.length, true);
|
|
144
|
+
startupView.setUint32(60, STARTF_USESTDHANDLES, true);
|
|
145
|
+
startupView.setBigUint64(104, BigInt(k.ptr(attributes)), true);
|
|
146
|
+
// PROCESS_INFORMATION (x64): hProcess 0, hThread 8, dwProcessId 16.
|
|
147
|
+
const information = new Uint8Array(24);
|
|
148
|
+
const commandLine = wide([input.file].concat(input.args).map(quoteArg).join(" "));
|
|
149
|
+
if (!k.CreateProcessW(null, commandLine, null, null, 0, EXTENDED_STARTUPINFO_PRESENT | CREATE_UNICODE_ENVIRONMENT | CREATE_SUSPENDED,
|
|
150
|
+
environmentBlock(input.env), wide(input.cwd), startup, information)) throw win32Error("conpty_spawn_failed");
|
|
151
|
+
const view = new DataView(information.buffer);
|
|
152
|
+
processHandle = own(view.getBigUint64(0, true));
|
|
153
|
+
const thread = own(view.getBigUint64(8, true));
|
|
154
|
+
pid = view.getUint32(16, true);
|
|
155
|
+
if (!k.AssignProcessToJobObject(job, processHandle)) {
|
|
156
|
+
k.TerminateProcess(processHandle, 1);
|
|
157
|
+
throw win32Error("conpty_job_failed");
|
|
158
|
+
}
|
|
159
|
+
if (k.ResumeThread(thread) === 0xffffffff) throw win32Error("conpty_spawn_failed");
|
|
160
|
+
closeHandle(thread);
|
|
161
|
+
} catch (error) {
|
|
162
|
+
if (attributes) k.DeleteProcThreadAttributeList(attributes);
|
|
163
|
+
if (outputRead !== undefined) closeHandle(outputRead);
|
|
164
|
+
if (hpc !== null) k.ClosePseudoConsole(hpc);
|
|
165
|
+
if (job) k.TerminateJobObject(job, 1);
|
|
166
|
+
for (const handle of opened.slice()) closeHandle(handle);
|
|
167
|
+
throw error;
|
|
168
|
+
}
|
|
169
|
+
k.DeleteProcThreadAttributeList(attributes);
|
|
170
|
+
|
|
171
|
+
const waiting = new Uint32Array(1), transferred = new Uint32Array(1), exitCode = new Uint32Array(1);
|
|
172
|
+
const accounting = new Uint8Array(48);
|
|
173
|
+
const chunk = new Uint8Array(READ_CHUNK_BYTES);
|
|
174
|
+
let closed = false, exitedAt = null, code = null, resolveExit, pending = [];
|
|
175
|
+
const exited = new Promise((resolve) => { resolveExit = resolve; });
|
|
176
|
+
const drain = () => {
|
|
177
|
+
for (let read = 0; read < READ_TICK_BYTES;) {
|
|
178
|
+
if (!k.PeekNamedPipe(outputRead, null, 0, null, waiting, null) || waiting[0] === 0) return;
|
|
179
|
+
if (!k.ReadFile(outputRead, chunk, Math.min(waiting[0], READ_CHUNK_BYTES), transferred, null)) return;
|
|
180
|
+
if (transferred[0] > 0) input.onData(chunk.slice(0, transferred[0]));
|
|
181
|
+
read += transferred[0];
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
// Nonblocking: a full input pipe accepts fewer bytes (possibly none).
|
|
185
|
+
const flush = () => {
|
|
186
|
+
while (pending.length > 0) {
|
|
187
|
+
if (!k.WriteFile(inputWrite, pending[0], pending[0].byteLength, transferred, null)) throw win32Error("conpty_write_failed");
|
|
188
|
+
if (transferred[0] === 0) return;
|
|
189
|
+
pending[0] = pending[0].subarray(transferred[0]);
|
|
190
|
+
if (pending[0].byteLength === 0) pending.shift();
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
function close() {
|
|
194
|
+
if (closed) return;
|
|
195
|
+
closed = true;
|
|
196
|
+
clearInterval(timer);
|
|
197
|
+
closeHandle(outputRead);
|
|
198
|
+
k.ClosePseudoConsole(hpc);
|
|
199
|
+
k.TerminateJobObject(job, 1);
|
|
200
|
+
for (const handle of opened.slice()) closeHandle(handle);
|
|
201
|
+
resolveExit(code);
|
|
202
|
+
}
|
|
203
|
+
const timer = setInterval(() => {
|
|
204
|
+
try {
|
|
205
|
+
if (exitedAt === null && k.WaitForSingleObject(processHandle, 0) === 0) {
|
|
206
|
+
exitedAt = Date.now();
|
|
207
|
+
if (k.GetExitCodeProcess(processHandle, exitCode)) code = exitCode[0];
|
|
208
|
+
}
|
|
209
|
+
drain();
|
|
210
|
+
flush();
|
|
211
|
+
if (exitedAt !== null && Date.now() - exitedAt >= EXIT_LINGER_MS) resolveExit(code);
|
|
212
|
+
} catch { close(); }
|
|
213
|
+
}, POLL_MS);
|
|
214
|
+
return {
|
|
215
|
+
pid,
|
|
216
|
+
exited,
|
|
217
|
+
write(data) {
|
|
218
|
+
if (closed) throw new Error("conpty_closed");
|
|
219
|
+
// A copy: the caller may reuse its buffer before the queue flushes.
|
|
220
|
+
const bytes = typeof data === "string" ? Buffer.from(data, "utf8") : Buffer.from(data);
|
|
221
|
+
if (bytes.byteLength > 0) pending.push(bytes);
|
|
222
|
+
flush();
|
|
223
|
+
},
|
|
224
|
+
resize(cols, rows) {
|
|
225
|
+
if (closed) throw new Error("conpty_closed");
|
|
226
|
+
const resized = k.ResizePseudoConsole(hpc, coord(cols, rows));
|
|
227
|
+
if (resized !== 0) throw hresultError("conpty_resize_failed", resized);
|
|
228
|
+
},
|
|
229
|
+
/** Ends the shell and everything it started; the console stays open. */
|
|
230
|
+
terminate() {
|
|
231
|
+
if (closed || !k.TerminateJobObject(job, 1)) throw win32Error("conpty_terminate_failed");
|
|
232
|
+
},
|
|
233
|
+
/** Live processes in the shell's job (JOBOBJECT_BASIC_ACCOUNTING_INFORMATION.ActiveProcesses). */
|
|
234
|
+
activeProcesses() {
|
|
235
|
+
if (closed || !k.QueryInformationJobObject(job, JOB_OBJECT_BASIC_ACCOUNTING_INFORMATION, accounting, accounting.length, null)) {
|
|
236
|
+
throw win32Error("conpty_job_unreadable");
|
|
237
|
+
}
|
|
238
|
+
return new DataView(accounting.buffer).getUint32(40, true);
|
|
239
|
+
},
|
|
240
|
+
close,
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
return { available, unavailableReason, defaultShell, shellArgs, quoteArg, environmentBlock, spawn };
|
|
244
|
+
})`;
|
|
245
|
+
export{e as Tg};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
var n=Object.create;var{getPrototypeOf:o,defineProperty:e,getOwnPropertyNames:k,getOwnPropertyDescriptor:p}=Object,l=Object.prototype.hasOwnProperty;function m(a){return this[a]}var q,r,u=(a,b,c)=>{var d=a!=null&&typeof a==="object";if(d){var h=b?q??=new WeakMap:r??=new WeakMap,i=h.get(a);if(i)return i}c=a!=null?n(o(a)):{};let f=b||!a||!a.__esModule?e(c,"default",{value:a,enumerable:!0}):c;for(let g of k(a))if(!l.call(f,g))e(f,g,{get:m.bind(a,g),enumerable:!0});if(d)h.set(a,f);return f},v=(a)=>{var b=(j??=new WeakMap).get(a),c;if(b)return b;if(b=e({},"__esModule",{value:!0}),a&&typeof a==="object"||typeof a==="function"){for(var d of k(a))if(!l.call(b,d))e(b,d,{get:m.bind(a,d),enumerable:!(c=p(a,d))||c.enumerable})}return j.set(a,b),b},j,w=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var s=(a)=>a;function t(a,b){this[a]=s.bind(null,b)}var x=(a,b)=>{for(var c in b)e(a,c,{get:b[c],enumerable:!0,configurable:!0,set:t.bind(b,c)})};var y=(a,b)=>()=>(a&&(b=a(a=0)),b);var z=import.meta.require;
|
|
3
|
-
export{u as
|
|
3
|
+
export{u as Fk,v as Gk,w as Hk,x as Ik,y as Jk,z as Kk};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{ed as hq,fd as lq}from"./vm-hands-entry-lite-g7h6wjqy.js";import{$h as Xq,Vh as Nq,Wh as vq,_h as Wq,ai as X,di as dq,fi as Aq,gi as cq,ii as c,ji as P,ki as Bq}from"./vm-hands-entry-lite-y2s2w174.js";import{Ci as Kq}from"./vm-hands-entry-lite-ma001vzh.js";import{Xi as oq,Zi as sq,aj as uq,bj as pq,cj as rq,dj as Dq}from"./vm-hands-entry-lite-9r5tz2dx.js";import{lj as d}from"./vm-hands-entry-lite-fyvgav60.js";import{Bk as Gq}from"./vm-hands-entry-lite-r8qg3wp1.js";import{randomUUID as C}from"crypto";import{chmodSync as Jq,closeSync as u,constants as m,existsSync as E,fstatSync as nq,lstatSync as D,mkdirSync as n,openSync as iq,readFileSync as g,readdirSync as Oq,readlinkSync as T,realpathSync as S,renameSync as k,rmSync as v,statSync as x,symlinkSync as Qq,unlinkSync as I,writeFileSync as h}from"fs";import{basename as r,dirname as B,isAbsolute as MG,join as K,relative as NG,resolve as O,sep as aq}from"path";import{spawnSync as Eq}from"child_process";import{createRequire as eq}from"module";var Zq=1,tq=1,qG=128,AG=65536,BG="https://reasonmachines.com/api/runtime-manifest-v2",DG=30000,OG=600000,Vq=1e4,EG=60000,IG=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;var Pq=/^[a-z0-9_.-]{1,80}$/,CG=64,TG="so.ara.device-broker",gq=["com.apple.security.cs.allow-jit","com.apple.security.cs.allow-unsigned-executable-memory"],SG=["service.install_started","service.install_completed","service.install_failed","service.launcher_adopted","service.launcher_conflict","service.started","service.reconnecting","service.reconnected","service.idle_sleep_held","service.idle_sleep_released","service.idle_sleep_failed","service.start_failed","service.stopped","service.exit_failed","service.singleton_rejected","credential.migration_started","credential.migration_completed","credential.migration_failed","credential.store_started","credential.store_completed","credential.store_failed","credential.delete_started","credential.delete_completed","credential.delete_failed","update.check_started","update.not_available","update.download_started","update.downloaded","update.verified","update.activated","update.rollback","update.failed","executor.update.check_started","executor.update.not_available","executor.update.download_started","executor.update.downloaded","executor.update.verified","executor.update.activated","executor.update.rollback","executor.update.failed","identity.refresh_completed","identity.refresh_failed","update.device_moved","update.components_installed","update.deferred","update.deferral_expired","worker.previous_exit","worker.capabilities_withheld","identity.computer_use_unavailable"];function t(q){if(q?.aborted)throw new X("update_cancelled","Managed runtime update request was cancelled.")}function Iq(q){return Boolean(q)&&typeof q==="object"&&!Array.isArray(q)}function Cq(q,G,J=[]){let Q=new Set([...G,...J]);return G.every((R)=>(R in q))&&Object.keys(q).every((R)=>Q.has(R))}function A(q){return typeof q==="string"&&IG.test(q)}function GG(q){return typeof q==="string"&&!Number.isNaN(Date.parse(q))&&new Date(q).toISOString()===q}function FG(q){return Xq.includes(q)}function b(q){n(q,{recursive:!0,mode:448}),Jq(q,448)}function JG(q,G){b(B(q));let J=`${q}.${process.pid}.${C()}.tmp`;try{h(J,G,{mode:384,flag:"wx"}),Jq(J,384),k(J,q)}finally{if(E(J))I(J)}}function Tq(q={}){if((q.platform??process.platform)!=="darwin")throw new X("unsupported_platform","The managed Reason runtime is currently available only on macOS.");let J=q.environment??process.env,Q=Kq(J,"REASON_CLI_CHANNEL")==="staging",R=Q?Kq(J,"REASON_MANAGED_RUNTIME_ROOT")?.trim():void 0,U=q.root!==void 0||Boolean(R&&MG(R))?null:K(q.home??d(),"Library","Application Support"),_=q.root??(U?K(U,Q?"Reason Staging":"Reason","CLI"):R);return{executableName:"reason",root:_,...U?{legacyRoot:K(U,"Ara",...Q?["staging","runtime"]:["runtime"])}:{},versions:K(_,"versions"),current:K(_,"current"),previous:K(_,"previous"),brokerLock:K(_,"broker.lock"),transitionLock:K(_,"transition.lock"),lifecycleEvents:K(_,"lifecycle-events")}}function gJ(q){let G=q.legacyRoot;if(!G)return null;return{root:G,versions:K(G,"versions"),current:K(G,"current"),previous:K(G,"previous"),brokerLock:K(G,"broker.lock"),transitionLock:K(G,"transition.lock"),lifecycleEvents:K(G,"lifecycle-events")}}function F(q,G){if(!A(G))throw new X("invalid_version","Invalid managed Reason runtime version.");let J=K(q.versions,G,"ara");if(!q.executableName)return J;let Q=K(q.versions,G,q.executableName),R=(_)=>{try{return D(_),!0}catch(Z){if(Z.code==="ENOENT")return!1;throw Z}},W=R(J),U=R(Q);if(W&&U)throw new X("installed_artifact_mismatch","Ambiguous managed runtime executable layout.");return W?J:Q}function i(q,G){if(!A(G))throw new X("invalid_version","Invalid managed Reason runtime version.");return Sq(F(q,G))}function Sq(q){return K(B(q),r(q)==="reason"?vq:Nq)}function QG(q,G){if(!A(q)||!A(G))throw new X("invalid_version","Invalid managed Reason runtime version.");let[J,Q]=q.split("-",2),[R,W]=G.split("-",2),U=J.split(".").map(Number),_=R.split(".").map(Number);for(let H=0;H<3;H+=1){let j=U[H]-_[H];if(j!==0)return j<0?-1:1}if(Q===void 0||W===void 0){if(Q===W)return 0;return Q===void 0?1:-1}let Z=Q.split("."),$=W.split("."),Y=Math.max(Z.length,$.length);for(let H=0;H<Y;H+=1){let j=Z[H],z=$[H];if(j===void 0||z===void 0){if(j===z)return 0;return j===void 0?-1:1}if(j===z)continue;let M=/^\d+$/.test(j),w=/^\d+$/.test(z);if(M&&w)return Number(j)<Number(z)?-1:1;if(M!==w)return M?-1:1;return j<z?-1:1}return 0}function LG(q=process.arch){let G=`darwin-${q}`;if(!FG(G))throw new X("unsupported_architecture","The managed Reason runtime supports only Apple Silicon and Intel Macs.");return G}function bq(q){return[...q.matchAll(/<key>\s*([^<]+?)\s*<\/key>/g)].map((G)=>G[1].trim())}function yq(q){let G=q.match(/^CodeDirectory .*$/gm)??[];return G.length>0&&G.every((J)=>{return(/ flags=0x[0-9a-f]+\(([^)]*)\)(?: |$)/.exec(J)?.[1]?.split(/[ ,]+/).filter(Boolean)??[]).includes("runtime")})}function wG(q){let G=`TeamIdentifier=${oq}`,J=`Identifier=${TG}`,Q=bq(q.brokerEntitlements),R=bq(q.credentialLibraryEntitlements);if(!q.brokerDetail.split(`
|
|
3
|
+
`).includes(G)||!q.brokerDetail.split(`
|
|
4
|
+
`).includes(J)||!yq(q.brokerDetail)||Q.length!==gq.length||gq.some((W)=>!new RegExp(`<key>\\s*${W.replaceAll(".","\\.")}\\s*</key>\\s*<true\\s*/>`).test(q.brokerEntitlements)))throw new X("invalid_code_signature","Managed runtime broker has an invalid Reason signature, identifier, or entitlement set.");if(!q.credentialLibraryDetail.split(`
|
|
5
|
+
`).includes(G)||!yq(q.credentialLibraryDetail)||R.length!==0)throw new X("invalid_code_signature","Managed runtime credential library has an invalid signature or entitlement.")}function y(q,G){let J=Eq("/usr/bin/codesign",q,{stdio:["ignore","pipe","pipe"]});if(J.status!==0)throw new X("invalid_code_signature",G);return[new TextDecoder().decode(J.stdout??new Uint8Array),new TextDecoder().decode(J.stderr??new Uint8Array)].join("")}var Fq=(q,G)=>{y(["--verify","--strict","--verbose=2",q],"Managed runtime broker code signature is invalid."),y(["--verify","--strict","--verbose=2",G],"Managed runtime credential library code signature is invalid."),wG({brokerDetail:y(["-d","--verbose=4",q],"Managed runtime broker signer could not be inspected."),brokerEntitlements:y(["-d","--entitlements",":-",q],"Managed runtime broker entitlements could not be inspected."),credentialLibraryDetail:y(["-d","--verbose=4",G],"Managed runtime credential library signer could not be inspected."),credentialLibraryEntitlements:y(["-d","--entitlements",":-",G],"Managed runtime credential library entitlements could not be inspected.")})};async function kG(q,G,J){let Q=q.headers.get("content-length");if(Q!==null){let Y=Number(Q);if(!Number.isSafeInteger(Y)||Y<0||Y>G)throw new X("response_too_large","Managed runtime response exceeded its size limit.")}if(!q.body){let Y=new Uint8Array(await q.arrayBuffer());if(Y.byteLength>G)throw new X("response_too_large","Managed runtime response exceeded its size limit.");return Y}let R=q.body.getReader(),W=[],U=0,_=()=>{if(!J)return R.read();return new Promise((Y,H)=>{let j=()=>{J.removeEventListener("abort",j),R.cancel(J.reason).catch(()=>{}),H(J.reason??new DOMException("Aborted","AbortError"))};if(J.aborted){j();return}J.addEventListener("abort",j,{once:!0}),R.read().then((z)=>{J.removeEventListener("abort",j),Y(z)},(z)=>{J.removeEventListener("abort",j),H(z)})})};try{while(!0){let Y=await _();if(Y.done)break;if(U+=Y.value.byteLength,U>G)throw await R.cancel(),new X("response_too_large","Managed runtime response exceeded its size limit.");W.push(Y.value)}}finally{try{R.releaseLock()}catch{}}let Z=new Uint8Array(U),$=0;for(let Y of W)Z.set(Y,$),$+=Y.byteLength;return Z}async function p(q){let G;try{G=new URL(q.url)}catch{throw new X("invalid_update_url","Managed runtime update URL is invalid.")}if(G.protocol!=="https:"||G.username||G.password||G.hash)throw new X("invalid_update_url","Managed runtime update URL must use HTTPS.");let J=new AbortController,Q,R=()=>{Q??="caller",J.abort(q.signal?.reason)};if(q.signal?.aborted)R();else q.signal?.addEventListener("abort",R,{once:!0});let W=setTimeout(()=>{Q??="timeout",J.abort(Error("managed runtime fetch timed out"))},q.timeoutMs),U=(_,Z)=>{if(_ instanceof X)return _;if(Q==="caller")return new X("update_cancelled","Managed runtime update request was cancelled.");if(Q==="timeout")return new X("update_fetch_timeout","Managed runtime update request timed out.");return new X("update_fetch_failed",Z)};try{let _;try{if(_=await q.fetchImpl(G,{headers:{accept:q.accept},signal:J.signal}),J.signal.aborted)throw U(J.signal.reason,"Managed runtime update request was cancelled.")}catch(Z){throw U(Z,"Managed runtime update request failed.")}if(!_.ok)throw new X("update_http_error","Managed runtime update request was rejected.");if(_.url&&new URL(_.url).protocol!=="https:")throw new X("insecure_redirect","Managed runtime update redirected to an insecure URL.");try{let Z=await kG(_,q.maximumBytes,J.signal);if(J.signal.aborted)throw U(J.signal.reason,"Managed runtime update response was cancelled.");return Z}catch(Z){throw U(Z,"Managed runtime update response failed.")}}finally{clearTimeout(W),q.signal?.removeEventListener("abort",R)}}async function RG(q,G,J=Vq,Q){let R=typeof J==="number"?J:Vq,W=typeof J==="number"?Q:J;if(W?.aborted)return!1;let U=await hq([q,"--version"],{timeoutMs:R,...W?{signal:W}:{}});return U.exitCode===0&&U.stdout.trim().replace(/^v/,"")===G}async function xG(q){let G=!1,J=null,Q=null,R=(W)=>{try{N(q.paths,W,{now:q.now})}catch{}};try{let W=q.home??d();if(!rq(q.manifest.version,W))return{status:"current"};Q=pq(W);let U=await p({url:new URL(dq,q.manifest.artifacts[q.target].broker.url).toString(),maximumBytes:Wq,fetchImpl:async(j,z)=>{let M=await q.fetchImpl(j,z);return G=M.status===404,M},timeoutMs:q.timeoutMs,accept:"application/json",signal:q.signal}),{manifest:_}=cq(new TextDecoder().decode(U),q.trustedKeys);if(_.version!==q.manifest.version||_.published_at!==q.manifest.published_at)throw new X("identity_manifest_mismatch","Background identity manifest names another release.");let Z=_.artifacts[q.target],$=await p({url:Z.url,maximumBytes:Z.size_bytes,fetchImpl:q.fetchImpl,timeoutMs:q.timeoutMs,accept:"application/octet-stream",signal:q.signal});P($,Z),b(q.workDirectory),J=K(q.workDirectory,`.identity-${process.pid}-${C()}`),n(J,{mode:448});let Y=K(J,"identity.tgz");if(h(Y,$,{mode:384,flag:"wx"}),Eq("/usr/bin/tar",["-xzf",Y,"-C",J],{stdio:"ignore",timeout:60000}).status!==0)throw new X("identity_extract_failed","Background identity archive could not be extracted.");return Dq({sourceApp:K(J,"Reason.app"),home:W,releaseSigned:!0,...q.command?{command:q.command}:{}}),R({event:"identity.refresh_completed",runtime_version:q.manifest.version,...Q?{from_version:Q}:{},to_version:q.manifest.version}),{status:"installed"}}catch(W){if(G)return{status:"unpublished"};let U=W instanceof X||W instanceof sq?W.code:"identity_install_failed";return process.stderr.write(`Reason background identity: identity_update_failed (${U})
|
|
6
|
+
`),R({event:"identity.refresh_failed",runtime_version:q.manifest.version,...Q?{from_version:Q}:{},to_version:q.manifest.version,reason_code:U}),{status:"failed",code:U}}finally{if(J)v(J,{recursive:!0,force:!0})}}async function bJ(q){if(!A(q.currentVersion))throw new X("invalid_version","Invalid current managed runtime version.");let G=q.paths??Tq(),J=q.target??LG(),Q=q.fetchImpl??fetch,R=q.timeoutMs??DG,W=q.timeoutMs??OG,U=q.healthCheck??((H,j,z)=>RG(H,j,EG,z)),_=q.verifyCodeSignatures??Fq,Z=q.now?.()??new Date,$,Y=!1;N(G,{event:"update.check_started",runtime_version:q.currentVersion,from_version:q.currentVersion},{now:()=>Z});try{await cG({paths:G,verifyCodeSignatures:_,healthCheck:U});let H=await p({url:q.manifestUrl??BG,maximumBytes:Wq,fetchImpl:Q,timeoutMs:R,accept:"application/json",signal:q.signal}),j=Aq(new TextDecoder().decode(H),q.trustedKeys);$=j.manifest.version;let z=()=>xG({paths:G,...q.now?{now:q.now}:{},manifest:j.manifest,target:J,trustedKeys:q.trustedKeys,fetchImpl:Q,timeoutMs:W,workDirectory:G.versions,...q.home?{home:q.home}:{},...q.identityCommand?{command:q.identityCommand}:{},...q.signal?{signal:q.signal}:{}});if(QG($,q.currentVersion)<=0)return N(G,{event:"update.not_available",runtime_version:q.currentVersion,from_version:q.currentVersion,to_version:$,duration_ms:Math.max(0,(q.now?.()??new Date).getTime()-Z.getTime())},{now:q.now}),Yq(G),{status:"not_available",currentVersion:q.currentVersion,offeredVersion:$,...$===q.currentVersion?{identity:await z()}:{}};let M=j.manifest.artifacts[J];N(G,{event:"update.download_started",runtime_version:q.currentVersion,from_version:q.currentVersion,to_version:$},{now:q.now});let w=await p({url:M.broker.url,maximumBytes:M.broker.size_bytes,fetchImpl:Q,timeoutMs:W,accept:"application/octet-stream",signal:q.signal});P(w,M.broker),t(q.signal);let e=await p({url:M.credential_library.url,maximumBytes:M.credential_library.size_bytes,fetchImpl:Q,timeoutMs:W,accept:"application/octet-stream",signal:q.signal});P(e,M.credential_library),N(G,{event:"update.downloaded",runtime_version:q.currentVersion,from_version:q.currentVersion,to_version:$},{now:q.now}),N(G,{event:"update.verified",runtime_version:q.currentVersion,from_version:q.currentVersion,to_version:$},{now:q.now}),t(q.signal);let kq=UG({paths:G,version:$,artifact:M.broker,bytes:w,credentialLibraryArtifact:M.credential_library,credentialLibraryBytes:e,verifyCodeSignatures:_}),xq;try{xq=await U(kq.executablePath,$,q.signal)}catch(l){throw t(q.signal),l}if(t(q.signal),!xq)throw new X("pre_activation_health_failed","Managed runtime preflight failed.");let V=fG(G,$);if(!V.changed&&V.toVersion!==$)return N(G,{event:"update.not_available",runtime_version:V.toVersion,from_version:V.toVersion,to_version:$,duration_ms:Math.max(0,(q.now?.()??new Date).getTime()-Z.getTime())},{now:q.now}),{status:"not_available",currentVersion:V.toVersion,offeredVersion:$};if(Y=V.changed,!await U(G.current,$)){if(V.fromVersion){let l=$G(G,$);N(G,{event:"update.rollback",runtime_version:l.toVersion,from_version:l.fromVersion,to_version:l.toVersion,reason_code:"post_activation_health_failed"},{now:q.now})}else KG(G,$);throw f(G),Y=!1,new X("post_activation_health_failed","Managed runtime activation failed.")}return f(G),Yq(G),N(G,{event:"update.activated",runtime_version:$,from_version:q.currentVersion,to_version:$,duration_ms:Math.max(0,(q.now?.()??new Date).getTime()-Z.getTime())},{now:q.now}),{status:"activated",fromVersion:q.currentVersion,toVersion:$,installed:kq.installed,identity:await z()}}catch(H){throw N(G,{event:"update.failed",runtime_version:Y?$??q.currentVersion:q.currentVersion,from_version:q.currentVersion,...$?{to_version:$}:{},reason_code:H instanceof X?H.code:"update_failed",duration_ms:Math.max(0,(q.now?.()??new Date).getTime()-Z.getTime())},{now:q.now}),H}}function fq(q,G,J){try{let Q=D(B(q));if(!Q.isDirectory()||Q.isSymbolicLink())return!1;let R=D(q);if(!R.isFile()||R.isSymbolicLink()||R.size!==G.size_bytes)return!1;let W=Sq(q),U=D(W);return U.isFile()&&!U.isSymbolicLink()&&U.size===J.size_bytes&&c(g(q))===G.sha256&&c(g(W))===J.sha256}catch{return!1}}function UG(q){let G=F(q.paths,q.version);P(q.bytes,q.artifact),P(q.credentialLibraryBytes,q.credentialLibraryArtifact);let J=q.verifyCodeSignatures??Fq;if(b(q.paths.root),b(q.paths.versions),E(B(G))){if(!fq(G,q.artifact,q.credentialLibraryArtifact))throw new X("installed_artifact_mismatch","The installed runtime version does not match the verified artifact.");return J(G,i(q.paths,q.version)),{installed:!1,executablePath:G}}let Q=K(q.paths.versions,`.install-${q.version}-${process.pid}-${C()}`),R=K(Q,r(G)),W=Sq(R);n(Q,{mode:448});try{h(R,q.bytes,{mode:448,flag:"wx"}),Jq(R,448),h(W,q.credentialLibraryBytes,{mode:448,flag:"wx"}),Jq(W,448),J(R,W);try{k(Q,B(G))}catch(U){if(!fq(G,q.artifact,q.credentialLibraryArtifact))throw U;return{installed:!1,executablePath:G}}return{installed:!0,executablePath:G}}finally{v(Q,{recursive:!0,force:!0})}}function VG(q,G){if(!A(G))throw new X("invalid_version","Invalid managed Reason runtime version.");return`versions/${G}/${r(F(q,G))}`}function Rq(q,G){b(B(q));let J=`${q}.${process.pid}.${C()}.tmp`;try{Qq(G,J),k(J,q)}finally{if(E(J))I(J)}}var PG=/^\.ara-worker-(\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?)-(darwin-(?:arm64|x64))\.([0-9A-Za-z]{6})$/;function gG(q,G){let J=B(q),Q=O(J,G),R=B(Q),W=PG.exec(r(R));if(r(Q)!=="ara"||B(R)!==J||!W||!A(W[1])||!Xq.includes(W[2]))return!1;try{return D(R).isDirectory()&&B(S(R))===S(J)&&D(Q).isFile()&&D(Bq(R)).isFile()}catch(U){if(U.code==="ENOENT")return!1;throw U}}function WG(q,G,J){try{if(T(q)!==G)return!1;I(q)}catch(Q){if(Q.code==="ENOENT")return!1;throw Q}try{return Qq(J,q),!0}catch(Q){if(Q.code==="EEXIST")return!1;try{Qq(G,q)}catch(R){if(R.code!=="EEXIST")throw R}throw Q}}function XG(q,G){if(!q.legacyRoot)return!1;let J;try{if(!D(G).isSymbolicLink())return!1;J=T(G)}catch(R){if(R.code==="ENOENT")return!1;throw R}if(O(B(G),J)!==K(q.legacyRoot,"current"))return!1;if(!WG(G,J,q.current))return!1;let Q=L(q);if(Q)N(q,{event:"service.launcher_adopted",runtime_version:Q,to_version:Q,reason_code:"legacy_runtime_root"});return!0}function bG(q){let G=q.launcherPath??K(q.home??d(),".local","bin","ara");try{if(D(G).isSymbolicLink()){let Q=T(G);if(Q===q.paths.current)return"managed";if(gG(G,Q)&&WG(G,Q,q.paths.current)){let R=_q(q.paths.current,q.paths.executableName)??"unknown";return N(q.paths,{event:"service.launcher_adopted",runtime_version:R,to_version:R,reason_code:"legacy_curl_entrypoint"}),"adopted"}if(XG(q.paths,G))return"adopted"}return"conflict"}catch(J){if(J.code!=="ENOENT")throw J}n(B(G),{recursive:!0,mode:448});for(let J=0;J<4;J+=1)try{return Qq(q.paths.current,G),"created"}catch(Q){if(Q.code!=="EEXIST")throw Q;try{return D(G).isSymbolicLink()&&T(G)===q.paths.current?"managed":"conflict"}catch(R){if(R.code!=="ENOENT")throw R}}return"conflict"}function _q(q,G){let J;try{if(!D(q).isSymbolicLink())return null;J=T(q)}catch{return null}let Q=J.match(/^versions\/(\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?)\/(ara|Reason|reason)$/);return Q&&(Q[2]==="ara"||Q[2]===G)?Q[1]:null}function L(q){return _q(q.current,q.executableName)}function yJ(q,G=process.execPath){try{return S(q.current)===S(G)}catch{return!1}}function Uq(q,G,J){let R=NG(G,q).split(aq);return R.length===2&&A(R[0])&&(R[1]==="ara"||J!==void 0&&R[1]===J)?R[0]:null}function ZG(q,G){try{return D(G).isSymbolicLink()&&O(B(G),T(G))===O(q.current)}catch{return!1}}function fJ(q,G=process.execPath){try{return Uq(S(G),S(q.versions),q.executableName)!==null}catch{let J=O(G);return J===O(q.current)||ZG(q,J)||Uq(J,O(q.versions),q.executableName)!==null}}function mJ(q,G=process.execPath){try{return Uq(S(G),S(q.versions),q.executableName)}catch{let J=O(G);if(J===O(q.current)||ZG(q,J))return L(q);return Uq(J,O(q.versions),q.executableName)}}function yG(q,G,J={}){let Q=F(q,G),R=i(q,G);if(!E(Q)||!x(Q).isFile()||!E(R)||!x(R).isFile())throw new X("runtime_not_installed","Managed Reason runtime version is not installed.");let W=Lq(q,G,J.allowDowngrade);if(W)return W;return a(q,G,()=>{return _G(q,G,void 0,J.allowDowngrade)})}function Lq(q,G,J=!1){let Q=L(q);if(!Q)return null;if(Q===G)return{changed:!1,fromVersion:Q,toVersion:Q};if(!J&&QG(G,Q)<=0&&!(/^\d+\.\d+\.\d+-desktop\.v1\.\d+\.\d+\.\d+$/.test(G)&&/^\d+\.\d+\.\d+-desktopdev\./.test(Q)))return{changed:!1,fromVersion:Q,toVersion:Q};return null}function _G(q,G,J,Q=!1){let R=Lq(q,G,Q);if(R)return R;let W=L(q);if(J?.(W),W)Rq(q.previous,T(q.current));else if(E(q.previous))I(q.previous);return Rq(q.current,VG(q,G)),{changed:!0,fromVersion:W,toVersion:G}}function fG(q,G){let J=F(q,G),Q=i(q,G);if(!E(J)||!x(J).isFile()||!E(Q)||!x(Q).isFile())throw new X("runtime_not_installed","Managed Reason runtime version is not installed.");return a(q,G,()=>_G(q,G,(R)=>{dG(q,{schema_version:Zq,from_version:R,to_version:G})}))}function $G(q,G){return a(q,G,()=>{if(L(q)!==G)throw new X("rollback_fence_failed","Managed runtime changed before rollback could be applied.");let J=_q(q.previous,q.executableName);if(!J||J===G)throw new X("rollback_unavailable","No previous managed runtime is available.");let Q=F(q,J),R=i(q,J);if(!E(Q)||!x(Q).isFile()||!E(R)||!x(R).isFile())throw new X("rollback_unavailable","Previous managed runtime is not installed.");let W=T(q.previous),U=T(q.current);if(O(B(q.previous),W)!==O(Q))throw new X("rollback_fence_failed","Previous runtime pointer does not match its installed layout.");return Rq(q.current,W),Rq(q.previous,U),{fromVersion:G,toVersion:J}})}function mG(){let q=Eq("/bin/ps",["-axww","-o","args="],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:5000,maxBuffer:16777216});return q.status===0&&typeof q.stdout==="string"?q.stdout:null}function Yq(q){let G=[];try{let J=L(q);if(!J||jq(q))return G;let Q=Oq(q.versions).filter((W)=>A(W));if(Q.length<=2)return G;let R=mG();if(R===null)return G;a(q,J,()=>{let W=new Set([L(q),_q(q.previous,q.executableName)]);if(jq(q))return;for(let U of Q){if(W.has(U))continue;let _=K(q.versions,U);if(R.includes(`${_}${aq}`))continue;try{v(_,{recursive:!0,force:!0}),G.push(U)}catch{}}})}catch{}return G}function KG(q,G){a(q,G,()=>{if(L(q)!==G)throw new X("rollback_fence_failed","Managed runtime changed before rollback could be applied.");I(q.current)})}function wq(q){return q.activationState??K(q.root,"activation.json")}function vG(q){return Iq(q)&&Cq(q,["schema_version","from_version","to_version"])&&q.schema_version===Zq&&(q.from_version===null||A(q.from_version))&&A(q.to_version)}function jq(q){try{let G=wq(q),J=D(G);if(!J.isFile()||J.isSymbolicLink()||J.nlink!==1||(J.mode&63)!==0||J.size>4096)throw new X("invalid_activation_state","Managed runtime activation state is invalid.");let Q=JSON.parse(g(G,"utf8"));if(!vG(Q))throw new X("invalid_activation_state","Managed runtime activation state is invalid.");return Q}catch(G){if(G instanceof X)throw G;if(G.code==="ENOENT")return null;throw new X("invalid_activation_state","Managed runtime activation state is invalid.")}}function dG(q,G){JG(wq(q),JSON.stringify(G)+`
|
|
7
|
+
`)}function f(q){try{I(wq(q))}catch(G){if(G.code!=="ENOENT")throw G}}async function cG(q){let G=jq(q.paths);if(!G)return"none";let J=L(q.paths);if(J===G.from_version)return f(q.paths),"cleared";if(J!==G.to_version)throw new X("rollback_fence_failed","Managed runtime changed before activation recovery could be applied.");let Q=q.verifyCodeSignatures??Fq,R=q.healthCheck??RG,W=!1;try{let U=F(q.paths,G.to_version);Q(U,i(q.paths,G.to_version)),W=await R(U,G.to_version)}catch{W=!1}if(W)return f(q.paths),N(q.paths,{event:"update.activated",runtime_version:G.to_version,...G.from_version?{from_version:G.from_version}:{},to_version:G.to_version,reason_code:"restart_recovery"}),"committed";if(G.from_version){let U=$G(q.paths,G.to_version);return f(q.paths),N(q.paths,{event:"update.rollback",runtime_version:U.toVersion,from_version:U.fromVersion,to_version:U.toVersion,reason_code:"restart_recovery"}),"rolled_back"}return KG(q.paths,G.to_version),f(q.paths),N(q.paths,{event:"update.rollback",runtime_version:G.to_version,from_version:G.to_version,reason_code:"restart_recovery"}),"rolled_back"}function hG(q){return Iq(q)&&Cq(q,["schema_version","pid","nonce","started_at","runtime_version"])&&q.schema_version===Zq&&typeof q.pid==="number"&&Number.isSafeInteger(q.pid)&&q.pid>0&&typeof q.nonce==="string"&&/^[0-9a-f-]{36}$/.test(q.nonce)&&GG(q.started_at)&&A(q.runtime_version)}function YG(q,G){try{let J=D(q);if(!J.isDirectory()||!Gq(J))return null;let Q=iq(K(q,G),m.O_RDONLY|m.O_NOFOLLOW|m.O_NONBLOCK);try{let R=nq(Q);if(!R.isFile()||R.nlink!==1||!Gq(R)||R.size>4096)return null;return g(Q,"utf8")}finally{u(Q)}}catch{return null}}function Hq(q){try{let G=JSON.parse(YG(q,"owner.json")??"null");return hG(G)?G:null}catch{return null}}function jG(q){try{return process.kill(q,0),!0}catch(G){return!(G instanceof Error&&("code"in G)&&G.code==="ESRCH")}}var mq="lease",lG=2,oG=4,o;function sG(){if(o!==void 0)return o;if(o=null,process.platform!=="linux"&&process.platform!=="darwin")return null;let q;try{q=eq(import.meta.url)("bun:ffi")}catch{return null}let G=process.platform==="darwin"?"__error":"__errno_location",J=process.platform==="darwin"?["/usr/lib/libSystem.B.dylib"]:["libc.so.6",`libc.musl-${process.arch==="arm64"?"aarch64":"x86_64"}.so.1`];for(let Q of J)try{let R=q.dlopen(Q,{flock:{args:[q.FFIType.i32,q.FFIType.i32],returns:q.FFIType.i32},[G]:{args:[],returns:q.FFIType.ptr}}),W=R.symbols[G]();if(W===null)continue;return o={flock:(U,_)=>R.symbols.flock(U,_),errno:()=>q.read.i32(W),wouldBlock:process.platform==="darwin"?35:11},o}catch{}return null}var s,uG=3221225472,pG=4,rG=128,nG=32;function iG(q){if(s===void 0){s=null;try{let W=eq(import.meta.url)("bun:ffi"),{FFIType:U}=W;s={kernel:W.dlopen("kernel32.dll",{CreateFileW:{args:[U.ptr,U.u32,U.u32,U.ptr,U.u32,U.u32,U.ptr],returns:U.i64_fast},CloseHandle:{args:[U.i64_fast],returns:U.i32},GetLastError:{args:[],returns:U.u32}}).symbols,ptr:(Z)=>W.ptr(Z)}}catch{return null}}if(!s)return null;let{kernel:G,ptr:J}=s,Q=Buffer.from(`${q}\x00`,"utf16le"),R=G.CreateFileW(J(Q),uG,0,null,pG,rG,null);if(Number(R)===-1)return G.GetLastError()===nG?"busy":null;return{release:()=>{G.CloseHandle(R)}}}function aG(q){if(process.platform==="win32")return iG(`${q}.lease`);let G=sG();if(!G)return null;let J=iq(`${q}.lease`,m.O_RDWR|m.O_CREAT|m.O_NOFOLLOW,384);try{let Q=nq(J);if(!Q.isFile()||Q.nlink!==1||!Gq(Q))return u(J),"busy";if(G.flock(J,lG|oG)===0)return{release:()=>u(J)};let R=G.errno();return u(J),R===G.wouldBlock?"busy":null}catch(Q){throw u(J),Q}}function zq(q){b(B(q.path));let G=aG(q.path);if(G==="busy")return{acquired:!1,owner:Hq(q.path),recoveredStaleOwner:!1};let J=G!==null;try{let Q=eG(q,G);if(Q.acquired)J=!1;return Q}finally{if(J)G.release()}}function eG(q,G){let J=q.alive??jG,Q=!1;for(let R=0;R<4;R+=1){let W={schema_version:Zq,pid:q.pid??process.pid,nonce:q.nonce?.()??C(),started_at:(q.now?.()??new Date).toISOString(),runtime_version:q.runtimeVersion},U=`${q.path}.init-${process.pid}-${C()}`,_=!1;try{if(n(U,{mode:448}),h(K(U,"owner.json"),`${JSON.stringify(W)}
|
|
8
|
+
`,{mode:384,flag:"wx"}),G!==null)h(K(U,mq),`flock
|
|
9
|
+
`,{mode:384,flag:"wx"});q.beforePublish?.();try{throw D(q.path),Object.assign(Error("Managed runtime lock exists."),{code:"EEXIST"})}catch($){if($.code!=="ENOENT")throw $}k(U,q.path),_=!0;let Z=!1;return{acquired:!0,owner:W,recoveredStaleOwner:Q,release(){if(Z)return;if(Z=!0,Hq(q.path)?.nonce===W.nonce)v(q.path,{recursive:!0,force:!0});G?.release()}}}catch(Z){let $=Z.code;if(!["EEXIST","ENOTEMPTY"].includes($??""))throw Z;let Y=Hq(q.path),H=(q.now?.()??new Date).getTime(),j=Y&&q.staleAfterMs!==void 0?H-Date.parse(Y.started_at)<q.staleAfterMs:!1,z=Y!==null&&!(G!==null&&YG(q.path,mq)!==null)&&J(Y.pid);if(!Y||z||j)return{acquired:!1,owner:Y,recoveredStaleOwner:!1};let M=`${q.path}.stale-${process.pid}-${C()}`;try{k(q.path,M),v(M,{recursive:!0,force:!0}),Q=!0}catch(w){let e=w.code;if(!["ENOENT","EEXIST"].includes(e??""))throw w}}finally{if(!_)v(U,{recursive:!0,force:!0})}}throw new X("lock_unavailable","Could not acquire the managed Reason runtime lock.")}var tG=20000;function a(q,G,J){if(!A(G))throw new X("invalid_version","Invalid managed Reason runtime version.");let Q=Date.now()+tG,R=zq({path:q.transitionLock,runtimeVersion:G,staleAfterMs:60000});while(!R.acquired&&Date.now()<Q)lq(100),R=zq({path:q.transitionLock,runtimeVersion:G,staleAfterMs:60000});if(!R.acquired)throw new X("transition_busy","Another managed Reason runtime transition is in progress.");try{return J()}finally{R.release()}}function vJ(q){if(!A(q.runtimeVersion))throw new X("invalid_version","Invalid managed Reason runtime version.");let G=q.paths??Tq();return zq({path:G.brokerLock,runtimeVersion:q.runtimeVersion,...q.pid===void 0?{}:{pid:q.pid},...q.now===void 0?{}:{now:q.now},...q.nonce===void 0?{}:{nonce:q.nonce},...q.alive===void 0?{}:{alive:q.alive},...q.beforePublish===void 0?{}:{beforePublish:q.beforePublish}})}function HG(q){return Iq(q)&&Cq(q,["schema_version","event_id","occurred_at","event","runtime_version"],["from_version","to_version","reason_code","duration_ms","attempt_count","retry_in_ms","capabilities"])&&q.schema_version===tq&&typeof q.event_id==="string"&&/^[0-9a-f-]{36}$/.test(q.event_id)&&GG(q.occurred_at)&&typeof q.event==="string"&&SG.includes(q.event)&&A(q.runtime_version)&&(q.from_version===void 0||A(q.from_version))&&(q.to_version===void 0||A(q.to_version))&&(q.reason_code===void 0||typeof q.reason_code==="string"&&Pq.test(q.reason_code))&&(q.duration_ms===void 0||typeof q.duration_ms==="number"&&Number.isSafeInteger(q.duration_ms)&&q.duration_ms>=0&&q.duration_ms<=86400000)&&(q.attempt_count===void 0||typeof q.attempt_count==="number"&&Number.isSafeInteger(q.attempt_count)&&q.attempt_count>=1&&q.attempt_count<=1e5)&&(q.retry_in_ms===void 0||typeof q.retry_in_ms==="number"&&Number.isSafeInteger(q.retry_in_ms)&&q.retry_in_ms>=0&&q.retry_in_ms<=30000)&&(q.capabilities===void 0||Array.isArray(q.capabilities)&&q.capabilities.length<=CG&&q.capabilities.every((G)=>typeof G==="string"&&Pq.test(G)))}var qJ=/^(\d{22}-[0-9a-f-]{36}\.json)$/,GJ=/^(\d{22}-[0-9a-f-]{36}\.json)\.sending-(\d+)-[0-9a-f-]{36}$/,JJ=300000,qq=0n;function QJ(q){let G=BigInt(new Date(q.occurred_at).getTime())*1000000n;return qq=G>qq?G:qq+1n,`${String(qq).padStart(22,"0")}-${q.event_id}.json`}function $q(q){try{return Oq(q.lifecycleEvents).filter((G)=>qJ.test(G)).sort()}catch{return[]}}function Mq(q){try{let G=JSON.parse(g(q,"utf8"));return HG(G)?G:null}catch{return null}}function zG(q,G=jG,J=Date.now()){let Q;try{Q=Oq(q.lifecycleEvents)}catch{return}for(let R of Q){let W=R.match(GJ);if(!W)continue;let U=K(q.lifecycleEvents,R),_=K(q.lifecycleEvents,W[1]),Z=!G(Number(W[2]));if(!Z)try{Z=J-x(U).mtimeMs>=JJ}catch{continue}if(!Z)continue;try{k(U,_)}catch($){let Y=$.code;if(Y==="EEXIST")I(U);else if(Y!=="ENOENT")throw $}}}function RJ(q){let J=$q(q).flatMap((R)=>{try{return[{name:R,size:x(K(q.lifecycleEvents,R)).size}]}catch{return[]}}),Q=J.reduce((R,W)=>R+W.size,0);while(J.length>qG||Q>AG){let R=J.shift();if(!R)break;try{I(K(q.lifecycleEvents,R.name)),Q-=R.size}catch(W){if(W.code!=="ENOENT")throw W}}}function dJ(q){return zG(q),$q(q).map((G)=>Mq(K(q.lifecycleEvents,G))).filter((G)=>G!==null).slice(-qG)}function N(q,G,J={}){let Q={schema_version:tq,event_id:J.eventId?.()??C(),occurred_at:(J.now?.()??new Date).toISOString(),...G};if(!HG(Q))throw new X("invalid_lifecycle_event","Managed runtime lifecycle event is invalid.");return b(q.lifecycleEvents),JG(K(q.lifecycleEvents,QJ(Q)),`${JSON.stringify(Q)}
|
|
10
|
+
`),RJ(q),Q}function cJ(q,G){if(G.length===0)return 0;let J=new Set(G),Q=0;for(let R of $q(q)){let W=R.slice(23,-5);if(!J.has(W))continue;try{I(K(q.lifecycleEvents,R)),Q+=1}catch(U){if(U.code!=="ENOENT")throw U}}return Q}async function hJ(q,G,J){zG(q);let Q=0;for(let R of $q(q)){let W=K(q.lifecycleEvents,R);if(J){let Z=Mq(W);if(!Z||!J(Z))continue}let U=`${W}.sending-${process.pid}-${C()}`;try{k(W,U)}catch(Z){if(Z.code==="ENOENT")continue;throw Z}let _=Mq(U);if(!_){I(U);continue}try{await G(_),I(U),Q+=1}catch{try{k(U,W)}catch(Z){if(Z.code!=="ENOENT")throw Z}break}}return Q}function lJ(q){let G=q.paths??Tq(),J=q.sourceExecutable??process.execPath,Q=q.sourceCredentialLibrary??Bq(B(S(J))),R=q.now?.()??new Date,W=E(F(G,q.version))&&Lq(G,q.version,q.allowDowngrade)!==null;if(!W)N(G,{event:"service.install_started",runtime_version:q.version,to_version:q.version},{now:()=>R});try{let U=g(J),_;try{_=g(Q)}catch{throw new X("credential_boundary_unavailable","Managed runtime credential boundary is unavailable.")}let Z={url:"https://bootstrap.invalid/ara",sha256:c(U),size_bytes:U.byteLength},$={url:`https://bootstrap.invalid/${Nq}`,sha256:c(_),size_bytes:_.byteLength},Y=UG({paths:G,version:q.version,artifact:Z,bytes:U,credentialLibraryArtifact:$,credentialLibraryBytes:_,...q.verifyCodeSignatures?{verifyCodeSignatures:q.verifyCodeSignatures}:{}}),H=uq(J);if(E(H))Dq({sourceApp:H,home:q.home??d()});let j=yG(G,q.version,{allowDowngrade:q.allowDowngrade});if(!W)Yq(G);let z=q.home??d(),M=q.installLauncher===!1?"skipped":bG({paths:G,...q.launcherPath?{launcherPath:q.launcherPath}:{home:z}});if(q.installLauncher!==!1&&!q.launcherPath)XG(G,K(z,".local","bin","reason"));if(M==="conflict")N(G,{event:"service.launcher_conflict",runtime_version:q.version,to_version:q.version,reason_code:"existing_entrypoint"},{now:q.now});if(!W)N(G,{event:"service.install_completed",runtime_version:q.version,to_version:q.version,duration_ms:Math.max(0,(q.now?.()??new Date).getTime()-R.getTime())},{now:q.now});return{installed:Y.installed,activated:j.changed,activeVersion:j.toVersion,executablePath:F(G,j.toVersion),launcher:M}}catch(U){throw N(G,{event:"service.install_failed",runtime_version:q.version,to_version:q.version,reason_code:U instanceof X?U.code:"install_failed",duration_ms:Math.max(0,(q.now?.()??new Date).getTime()-R.getTime())},{now:q.now}),U}}
|
|
11
|
+
export{Zq as L,tq as M,qG as N,AG as O,BG as P,DG as Q,OG as R,Vq as S,EG as T,SG as U,Tq as V,gJ as W,F as X,i as Y,QG as Z,LG as _,wG as $,Fq as aa,p as ba,RG as ca,bJ as da,UG as ea,bG as fa,_q as ga,L as ha,yJ as ia,fJ as ja,mJ as ka,yG as la,$G as ma,cG as na,zq as oa,vJ as pa,dJ as qa,N as ra,cJ as sa,hJ as ta,lJ as ua};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var r={name:"github-native-engineer-device-worker-production",version:"0.2.
|
|
3
|
-
export{r as
|
|
2
|
+
var r={name:"github-native-engineer-device-worker-production",version:"0.2.383",private:!0,type:"module",engines:{node:">=22",bun:">=1.3.0"},workspaces:["../../packages/runtime-distribution"],dependencies:{"@anthropic-ai/sandbox-runtime":"^0.0.73","@earendil-works/pi-tui":"1.0.0","@modelcontextprotocol/sdk":"^1.29.0","@reason/runtime-distribution":"workspace:*","playwright-core":"1.60.0",zod:"^4.4.3"},overrides:{"@hono/node-server":"^1.19.15","@earendil-works/pi-agent-core":"1.0.0","@earendil-works/pi-ai":"1.0.0","@earendil-works/pi-coding-agent":"1.0.0","@earendil-works/chord":"1.0.0","@earendil-works/pi-codemode":"1.0.0","@earendil-works/pi-mcp":"1.0.0","@earendil-works/pi-telemetry":"1.0.0","@earendil-works/pi-tui":"1.0.0","brace-expansion":"2.1.7",axios:"^1.20.0","basic-ftp":"^6.2.1","@grpc/grpc-js":"^1.14.5",browserslist:"^4.28.8","engine.io":"^6.6.7","fast-uri":"^3.1.8",hono:"^4.13.7","ip-address":"^10.7.1",nanoid:"^3.3.18",dompurify:"^3.4.17",postcss:"^8.5.23",qs:"^6.16.0","shell-quote":"^1.11.0","socket.io-parser":"^4.2.7",tmp:"^0.2.7",toml:"^4.2.0",undici:"^8.10.2",ws:"^8.21.0","js-yaml":"^4.3.2","@modelcontextprotocol/sdk":"^1.31.0","proxy-addr":"^2.0.8","source-map-js":"^1.2.2"}};
|
|
3
|
+
export{r as Pj};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{ik as W}from"./vm-hands-entry-lite-zjfr0zh8.js";var T=W.string().max(201).regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/).refine((Q)=>Q.split("/").every((Z)=>Z!=="."&&Z!=="..")),G=W.string().min(1).max(255).regex(/^[A-Za-z0-9_][A-Za-z0-9_./-]*$/).refine((Q)=>!Q.includes("..")&&!Q.includes("//")&&!Q.endsWith("/")&&!Q.endsWith(".lock")),M=W.string().regex(/^[a-f0-9]{40}$/),q=W.number().int().positive(),C=W.string().min(1).max(256),A=W.string().max(60000),B={version:W.literal(1),repoFullName:T},J=W.array(W.string().max(1024).regex(/^(?:Co-authored-by: [^<>\r\n\x00]+ <[^<>\s]+@[^<>\s]+>|Reason-Contributor-ID: rc_[a-f0-9]{32})$/)).max(1000),c=W.strictObject({expectedTrailers:J,missingFromHead:J}),y=W.discriminatedUnion("action",[W.strictObject({action:W.literal("edit"),title:C.optional(),body:A.optional(),base:G.optional()}),W.strictObject({action:W.enum(["ready","draft","close"])}),W.strictObject({action:W.literal("metadata"),field:W.enum(["reviewer","assignee","label"]),change:W.enum(["add","remove"]),value:W.string().min(1).max(100).refine((Q)=>!/[\r\n\0]/.test(Q))})]),d=W.discriminatedUnion("kind",[W.strictObject({...B,kind:W.literal("read"),path:W.string().min(1).max(2048),accept:W.enum(["application/vnd.github+json","application/vnd.github.full+json","application/vnd.github.v3.diff"]).optional()}),W.strictObject({...B,kind:W.literal("pr_review_context"),number:q,after:W.string().min(1).max(1024).optional()}),W.strictObject({...B,kind:W.literal("prepare"),branch:G,baseSha:M,defaultBranch:G,diagnosticsVersion:W.literal(1).optional()}),W.strictObject({...B,kind:W.literal("publish"),branch:G,defaultBranch:G,baseSha:M,remoteHeadSha:M.nullable(),contributorTrailers:J.optional()}),W.strictObject({...B,kind:W.literal("pr_create"),head:G,base:G,title:C,body:A,draft:W.boolean()}),W.strictObject({...B,kind:W.literal("pr_mutation"),number:q,mutation:y}),W.strictObject({...B,kind:W.literal("pr_merge"),number:q,expectedHeadSha:M,expectedBaseRef:G,method:W.enum(["merge","squash","rebase"]),commitBody:W.string().max(65536).optional()})]),O=["local_device_gh_prepare_setup","local_device_gh_prepare_metadata","local_device_gh_prepare_private_init","local_device_gh_prepare_fetch","local_device_gh_prepare_base_mismatch","local_device_gh_prepare_checkout_validation","local_device_gh_prepare_checkout_init","local_device_gh_prepare_materialization"];function h(Q){return O.some((Z)=>Z===Q)}class R extends Error{code;constructor(Q){super(Q);this.code=Q}}function ZQ(Q,Z,$){let z=d.safeParse(Q);return Z==="failed"&&z.success&&z.data.kind==="prepare"&&z.data.diagnosticsVersion===1&&h($)}var x=245760,$Q=W.discriminatedUnion("kind",[W.strictObject({kind:W.literal("pr_review_context"),body:W.string().max(x)}),W.strictObject({kind:W.literal("prepare"),headSha:M}),W.strictObject({kind:W.literal("read"),status:W.number().int().min(200).max(599),headers:W.record(W.string(),W.string().max(8192)).refine((Q)=>Object.keys(Q).every((Z)=>Z==="link"||Z==="content-type")),body:W.string().max(x)}),W.strictObject({kind:W.literal("publish"),headSha:M,scannedObjectCount:W.number().int().min(0).max(5000),attribution:c.optional()}),W.strictObject({kind:W.literal("pr_create"),url:W.string().max(1024).regex(/^https:\/\/github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/pull\/[1-9][0-9]*$/)}),W.strictObject({kind:W.literal("pr_mutation"),number:q,applied:W.literal(!0)}),W.strictObject({kind:W.literal("pr_merge"),number:q,merged:W.literal(!0)})]).refine((Q)=>new TextEncoder().encode(JSON.stringify(Q)).byteLength<=x,"local_device_gh_result_too_large"),r=W.strictObject({source:W.enum(["agent","human"]),operationId:W.uuid()}),m=W.strictObject({version:W.literal(1),userId:W.guid(),deviceId:W.guid(),rootId:W.guid(),runId:W.guid(),merge:r.optional(),contributorRefresh:W.guid().optional(),repoFullName:T.nullable(),rootRevision:W.string().regex(/^[1-9][0-9]*$/),readOnly:W.boolean(),generation:W.number().int().positive().nullable(),fenceId:W.guid().nullable()}).refine((Q)=>Q.generation===null===(Q.fenceId===null));function P(Q){return/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(Q)&&Q.split("/").every((Z)=>Z!=="."&&Z!=="..")}function KQ(Q,Z,$={},z="read"){if(P(Q)&&(Z==="/search/issues"||Z.startsWith("/search/issues?")))return p(Q,Z,$);if(!P(Q)||!Z.startsWith(`/repos/${Q}/`)&&Z!==`/repos/${Q}`)throw Error("local_device_gh_repository_mismatch");if(/[\\#\u0000-\u001f]/.test(Z)||/%(?:2e|5c|00)/i.test(Z))throw Error("local_device_gh_path_denied");let V=new URL(Z,"https://api.github.com");if(V.pathname!==Z.split("?")[0]||V.username||V.password)throw Error("local_device_gh_path_denied");let Y;try{Y=decodeURIComponent(V.pathname.slice(`/repos/${Q}`.length))}catch{throw Error("local_device_gh_path_denied")}if(Y.includes("%")||Y.split("/").some((D)=>D==="."||D===".."))throw Error("local_device_gh_path_denied");if(($.method??"GET").toUpperCase()!=="GET"||$.body!=null)throw Error("local_device_gh_mutation_not_admitted");if(![/^$/,/^\/commits$/,/^\/pulls$/,/^\/pulls\/[1-9][0-9]*(?:\/(?:commits|files|reviews|comments))?$/,/^\/issues\/[1-9][0-9]*(?:\/comments)?$/,/^\/issues\/comments\/[1-9][0-9]*\/reactions$/,/^\/commits\/[A-Za-z0-9_./-]+(?:\/(?:check-runs|status))?$/,/^\/check-runs\/[1-9][0-9]*(?:\/annotations)?$/,/^\/branches\/[A-Za-z0-9_./-]+$/,/^\/git\/ref\/heads\/[A-Za-z0-9_./-]+$/,/^\/compare\/[A-Za-z0-9_./-]+\.\.\.[A-Za-z0-9_./-]+$/].some((D)=>D.test(Y)))throw Error("local_device_gh_path_denied");if(V.searchParams.forEach((D,X)=>{if(X==="per_page"&&/^[1-9][0-9]*$/.test(D)&&Number(D)<=100)return;if(X==="page"&&/^[1-9][0-9]*$/.test(D)&&Number(D)<=100)return;if(Y==="/pulls"&&X==="state"&&["open","closed","all"].includes(D))return;if(Y==="/pulls"&&X==="sort"&&D==="updated")return;if(Y==="/pulls"&&X==="direction"&&D==="desc")return;if(Y==="/pulls"&&["head","base"].includes(X)&&/^[A-Za-z0-9_./:-]{1,255}$/.test(D))return;throw Error("local_device_gh_query_denied")}),$.headers)new Headers($.headers).forEach((X,_)=>{if(_!=="accept"||!["application/vnd.github+json","application/vnd.github.full+json","application/vnd.github.v3.diff"].includes(X))throw Error("local_device_gh_header_denied")})}function p(Q,Z,$){if(/[\\#\u0000-\u001f]/.test(Z))throw Error("local_device_gh_path_denied");let z=new URL(Z,"https://api.github.com");if(z.pathname!=="/search/issues"||z.username||z.password)throw Error("local_device_gh_path_denied");if(($.method??"GET").toUpperCase()!=="GET"||$.body!=null)throw Error("local_device_gh_mutation_not_admitted");let V=null;z.searchParams.forEach((H,D)=>{if(D==="q"&&V===null){V=H;return}if(D==="per_page"&&/^[1-9][0-9]*$/.test(H)&&Number(H)<=100)return;if(D==="page"&&/^[1-9][0-9]*$/.test(H)&&Number(H)<=100)return;throw Error("local_device_gh_query_denied")});let Y=`repo:${Q.toLowerCase()} `,N=V?.toLowerCase()??"";if(N.length>512||!(N+" ").startsWith(Y)||/(?:^|\s)(?:repo|org|user):/.test(N.slice(Y.length)))throw Error("local_device_gh_query_denied");if($.headers)new Headers($.headers).forEach((H,D)=>{if(D!=="accept"||H!=="application/vnd.github+json")throw Error("local_device_gh_header_denied")})}var DQ=`query PullRequestReviewContext($owner: String!, $repo: String!, $number: Int!, $after: String) {
|
|
3
3
|
repository(owner: $owner, name: $repo) {
|
|
4
4
|
nameWithOwner
|
|
5
5
|
pullRequest(number: $number) {
|
|
@@ -39,4 +39,4 @@ import{Vj as W}from"./vm-hands-entry-lite-hc3p6r9p.js";var T=W.string().max(201)
|
|
|
39
39
|
`)||!/^[a-f0-9]{64}$/.test(Q.bodySha256))throw Error("Invalid Reason Device proof input.");return Buffer.from([Z,$,Q.pathAndQuery,Q.timestamp,Q.nonce,Q.challenge,Q.bodySha256].join(`
|
|
40
40
|
`),"utf8")}function K(Q){return Boolean(Q)&&typeof Q==="object"&&!Array.isArray(Q)}function t(Q,Z){return typeof Q==="string"&&Z.some(($)=>$===Q)}function k(Q){return K(Q)&&typeof Q.id==="string"&&typeof Q.label==="string"&&typeof Q.path_fingerprint==="string"}function v(Q){return K(Q)&&Number.isInteger(Q.seq)&&Number(Q.seq)>=0&&typeof Q.kind==="string"&&/^[A-Za-z0-9._:-]{1,64}$/.test(Q.kind)&&K(Q.payload)}function w(Q){throw Error(Q)}function ZW(Q,Z){let $=K(Q)?Q:{},z=typeof $.error==="string"?$.error:`http_${Z}`,V=typeof $.detail==="string"?$.detail:typeof $.message==="string"?$.message:`Reason Device request failed (${Z})`;return{code:z,message:V}}function l(Q){if(!K(Q)||typeof Q.challenge!=="string"||Q.challenge.length<16||Q.challenge.length>1024||Q.challenge.includes(`
|
|
41
41
|
`)||typeof Q.expires_at!=="string"||!Number.isFinite(Date.parse(Q.expires_at)))w("Reason returned an invalid Device proof challenge.");return{challenge:Q.challenge,expires_at:Q.expires_at}}function L(Q,Z){if(!K(Q)||typeof Q.device_id!=="string"||Q.auth_scheme!=="p256"||Q.organization_id!==void 0&&typeof Q.organization_id!=="string"||Q.protocol_version!==j||!Array.isArray(Q.roots)||!Q.roots.every(k)||Z&&typeof Q.organization_id!=="string"||Q.device_credential!==void 0)w(Z?"Reason returned an invalid Device enrollment.":"Reason returned an invalid Device registration.");return{...{device_id:Q.device_id,...typeof Q.organization_id==="string"?{organization_id:Q.organization_id}:{},protocol_version:j,roots:Q.roots},auth_scheme:"p256"}}function $W(Q){return L(Q,!1)}function KW(Q){let Z=L(Q,!0);if(typeof Z.organization_id!=="string")return w("Reason returned an invalid Device enrollment.");return{...Z,organization_id:Z.organization_id}}function DW(Q){if(!K(Q)||typeof Q.server_time!=="string"||typeof Q.drain!=="boolean")return w("Reason returned an invalid Device heartbeat.");return{server_time:Q.server_time,drain:Q.drain,...f(Q),...typeof Q.update_policy==="string"||Q.update_policy===null?{update_policy:Q.update_policy}:{},...typeof Q.supported_protocol_version==="number"?{supported_protocol_version:Q.supported_protocol_version}:{},...a(Q.latest_cli_versions),...Q.hands_prespawn===!0?{hands_prespawn:!0}:{}}}var u=["account_root_metadata_supported","workspace_root_metadata_supported","account_root_path_supported","home_contained_roots_supported","root_paths_supported","startup_supported"];function f(Q){return Object.fromEntries(u.filter((Z)=>Q[Z]===!0).map((Z)=>[Z,!0]))}function zW(Q){if(!K(Q))return;try{return{...l(Q),...f(Q)}}catch{return}}function a(Q){if(!K(Q))return{};let Z={};for(let $ of s){let z=Q[$];if(typeof z==="string"&&/^(0|[1-9][0-9]{0,5})\.(0|[1-9][0-9]{0,5})\.(0|[1-9][0-9]{0,5})$/.test(z))Z[$]=z}return Object.keys(Z).length>0?{latest_cli_versions:Z}:{}}function FW(Q){if(!K(Q)||!Array.isArray(Q.roots)||!Q.roots.every(k))return w("Reason returned an invalid Device root sync.");return{roots:Q.roots}}function wW(Q){if(!K(Q)||Q.user_id!==void 0&&typeof Q.user_id!=="string"||typeof Q.organization_id!=="string"||typeof Q.organization_name!=="string"||typeof Q.organization_slug!=="string")return w("Reason returned an invalid Device identity.");return{...typeof Q.user_id==="string"?{user_id:Q.user_id}:{},organization_id:Q.organization_id,organization_name:Q.organization_name,organization_slug:Q.organization_slug}}function VW(Q){if(!K(Q)||Q.disconnected!==!0)return w("Reason did not disconnect this Device.");let Z=Q.sessions_moved;return typeof Z==="number"&&Number.isSafeInteger(Z)&&Z>=0?{disconnected:!0,sessions_moved:Z}:{disconnected:!0}}function YW(Q){if(K(Q)&&Q.ok===!0&&typeof Q.expires==="number")return{ok:!0,expires:Q.expires};if(K(Q)&&Q.ok===!1&&typeof Q.error==="string")return{ok:!1,error:Q.error};return w("Reason did not answer the local login hand-over.")}function HW(Q){if(!K(Q)||Q.accepted!==!0)return w("Reason did not accept the Device lifecycle event.");return{accepted:!0}}function e(Q){return Buffer.byteLength(JSON.stringify(Q),"utf8")}function XW(Q,Z=b){if(!K(Q)||typeof Q.operation_id!=="string"||typeof Q.attempt_id!=="string"||typeof Q.attempt_token!=="string"||!/^(?:reason|ara)_attempt_/.test(Q.attempt_token)||typeof Q.lease_until!=="string"||typeof Q.run_id!=="string"||typeof Q.root_id!=="string"||Q.owner!==void 0&&!E(Q.owner)||!t(Q.capability,Z)||!K(Q.payload)||Q.protocol_version!==j||e(Q.payload)>n||Q.authority!==void 0&&!U(Q.authority)||Q.local_github_authority!==void 0&&!m.safeParse(Q.local_github_authority).success||Q.capability==="github.local.v1"&&!m.safeParse(Q.local_github_authority).success||Q.recording_authority!==void 0&&!S(Q.recording_authority)||Q.capability==="browser.recording.v1"&&(!S(Q.recording_authority)||!E(Q.owner))||Q.capability!=="browser.recording.v1"&&Q.recording_authority!==void 0)return w("Reason returned an invalid Device operation claim.");let $={operation_id:Q.operation_id,attempt_id:Q.attempt_id,attempt_token:Q.attempt_token,lease_until:Q.lease_until,run_id:Q.run_id,root_id:Q.root_id,capability:Q.capability,payload:Q.payload,...U(Q.authority)?{authority:Q.authority}:{},...S(Q.recording_authority)?{recording_authority:Object.freeze({...Q.recording_authority})}:{},...Q.local_github_authority!==void 0?{local_github_authority:m.parse(Q.local_github_authority)}:{},...Q.capability==="hands.connect"&&K(Q.environment)&&K(Q.environment.payload)&&U(Q.environment.authority)?{environment:{payload:Q.environment.payload,authority:Q.environment.authority}}:{},protocol_version:j};if(Q.owner!==void 0)$.owner=Object.freeze({...Q.owner});return $}function GW(Q){if(!K(Q)||typeof Q.lease_until!=="string"||!Array.isArray(Q.controls)||!Q.controls.every(v)||!Number.isInteger(Q.next_control_seq)||Number(Q.next_control_seq)<0)return w("Reason returned an invalid Device operation heartbeat.");return{lease_until:Q.lease_until,controls:Q.controls,next_control_seq:Number(Q.next_control_seq)}}function BW(Q){if(!K(Q)||!Number.isInteger(Q.next_event_seq)||Number(Q.next_event_seq)<0||typeof Q.duplicate!=="boolean"||!Number.isInteger(Q.accepted_count)||Number(Q.accepted_count)<0)return w("Reason returned an invalid Device operation event result.");return{next_event_seq:Number(Q.next_event_seq),duplicate:Q.duplicate,accepted_count:Number(Q.accepted_count)}}function MW(Q){if(!K(Q)||!K(Q.payload)||!U(Q.authority))return w("Reason returned an invalid Device environment delivery.");return{payload:Q.payload,authority:Q.authority}}function QQ(Q){return Q==="succeeded"||Q==="failed"||Q==="cancelled"||Q==="expired"}function gW(Q){if(!K(Q)||!QQ(Q.status)||typeof Q.idempotent!=="boolean")return w("Reason returned an invalid Device operation completion.");return{status:Q.status,idempotent:Q.idempotent}}
|
|
42
|
-
export{d as
|
|
42
|
+
export{d as ye,R as ze,ZQ as Ae,x as Be,$Q as Ce,m as De,KQ as Ee,DQ as Fe,zQ as Ge,b as He,j as Ie,I as Je,n as Ke,HQ as Le,XQ as Me,GQ as Ne,BQ as Oe,MQ as Pe,gQ as Qe,qQ as Re,NQ as Se,mQ as Te,UQ as Ue,jQ as Ve,xQ as We,JQ as Xe,SQ as Ye,IQ as Ze,PQ as _e,TQ as $e,CQ as af,AQ as bf,bQ as cf,EQ as df,kQ as ef,LQ as ff,fQ as gf,_Q as hf,cQ as if,yQ as jf,dQ as kf,OQ as lf,hQ as mf,RQ as nf,rQ as of,pQ as pf,nQ as qf,oQ as rf,sQ as sf,iQ as tf,tQ as uf,vQ as vf,lQ as wf,uQ as xf,aQ as yf,eQ as zf,i as Af,QW as Bf,WW as Cf,ZW as Df,l as Ef,$W as Ff,KW as Gf,DW as Hf,zW as If,FW as Jf,wW as Kf,VW as Lf,YW as Mf,HW as Nf,XW as Of,GW as Pf,BW as Qf,MW as Rf,gW as Sf};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
export{O as
|
|
2
|
+
import{Pj as $}from"./vm-hands-entry-lite-41nygv3p.js";var O=$.version,Z=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;function S(B,D){if(!Z.test(B)||!Z.test(D))throw Error("cannot compare invalid CLI versions");let J=(q)=>{let y=q.indexOf("-");return y===-1?[q,void 0]:[q.slice(0,y),q.slice(y+1)]},[j,F]=J(B),[w,G]=J(D),K=j.split(".").map(BigInt),M=w.split(".").map(BigInt);for(let q=0;q<3;q+=1){if(K[q]===M[q])continue;return K[q]<M[q]?-1:1}if(F===void 0||G===void 0){if(F===G)return 0;return F===void 0?1:-1}let Q=F.split("."),U=G.split("."),A=Math.max(Q.length,U.length);for(let q=0;q<A;q+=1){let y=Q[q],z=U[q];if(y===void 0||z===void 0){if(y===z)return 0;return y===void 0?-1:1}if(y===z)continue;let H=/^\d+$/.test(y),W=/^\d+$/.test(z);if(H&&W){let X=BigInt(y),Y=BigInt(z);if(X===Y)continue;return X<Y?-1:1}if(H!==W)return H?-1:1;return y<z?-1:1}return 0}function k(B,D){return D?`cli ${B} \xB7 agent ${D}`:`cli ${B}`}
|
|
3
|
+
export{O as Lj,Z as Mj,S as Nj,k as Oj};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{ik as q}from"./vm-hands-entry-lite-zjfr0zh8.js";var u=25,U=q.object({machine:q.string().min(1).max(200),person:q.string().min(1).max(200),team:q.string().min(1).max(200),version:q.string().max(64).optional(),wait_seconds:q.number().int().min(0).max(u).optional()}),x=q.discriminatedUnion("kind",[q.object({id:q.string(),kind:q.literal("who"),all:q.boolean().optional()}),q.object({id:q.string(),kind:q.literal("send"),to:q.string(),body:q.string(),from_name:q.string(),from_agent:q.string(),wake:q.boolean(),reply_to:q.string().max(100).optional(),notify:q.boolean().optional()})]),V=q.object({job:x.nullable(),retry_after_seconds:q.number().optional()}),B=q.object({address:q.string(),person:q.string(),machine:q.string(),agent:q.string(),repo:q.string().nullable(),branch:q.string().nullable(),status:q.string(),since:q.number().nullable(),doing:q.string().nullable(),worker:q.boolean(),tier:q.string().max(10).optional()}),F=q.object({person:q.string(),machine:q.string(),online:q.boolean()}),G=q.object({team:q.string().nullable(),sessions:q.array(B).max(2000),machines:q.array(F).max(500),all:q.boolean().optional()}),H=q.object({address:q.string().max(300),state:q.string().max(40),note:q.string().max(500)}),X=q.union([q.object({who:G}),q.object({sent:q.object({ids:q.array(q.string().max(100)).max(500),recipients:q.array(q.string().max(300)).max(500),from:q.string().max(300),deliveries:q.array(H).max(500).optional()})}),q.object({error:q.string().min(1).max(2000)})]),K=q.object({id:q.string().max(100),from:q.string().max(300),from_agent:q.string().max(100).nullable(),to:q.string().max(300),reply_to:q.string().max(100).nullable(),body:q.string().max(64000),sent_at:q.number()}),Z=q.object({messages:q.array(K).max(100)});
|
|
3
3
|
export{u as va,V as wa};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{lj as F}from"./vm-hands-entry-lite-fyvgav60.js";import{Lj as b}from"./vm-hands-entry-lite-7xbgw4m0.js";import{randomUUID as d}from"crypto";import{spawnSync as C}from"child_process";import{chmodSync as zj,cpSync as Jj,existsSync as U,lstatSync as M,mkdirSync as h,readdirSync as Wj,readFileSync as I,readlinkSync as Zj,realpathSync as R,renameSync as P,rmdirSync as $j,rmSync as G,symlinkSync as E,writeFileSync as qj}from"fs";import{dirname as B,join as K,relative as Kj,resolve as Qj}from"path";var s="so.ara.cli",Vj="5LJFSBRY2F",wj="Background/Reason.app",m="ReasonBackgroundIdentity",Sj="Contents/Helpers/ReasonPermissionTile";var S="AraBackgroundIdentity",Xj="Reason",Dj=`anchor apple generic and identifier "${s}" and certificate leaf[subject.OU] = "${Vj}"`;class H extends Error{code;constructor(j,z){super(z);this.code=j;this.name="MacOSBackgroundIdentityError"}}var T="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister";function v(j=F()){return K(j,"Library","Application Support","Reason","Background","Reason.app")}function _(j=F()){return K(j,"Library","Application Support","Ara","Background","Ara.app")}function fj(j=process.execPath){return K(B(R(j)),wj)}function Fj(j){try{return M(j).isFile()}catch{return!1}}function f(j){return[m,S].map((z)=>K(j,"Contents","MacOS",z)).find(Fj)??null}function w(j){try{if(!M(j).isDirectory())return!1;let z=I(K(j,"Contents","Info.plist"),"utf8");return z.includes(`<string>${s}</string>`)&&(z.includes(`<string>${Xj}</string>`)||z.includes("<string>Ara</string>"))&&f(j)!==null}catch{return!1}}function u(j=F()){let z=v(j);if(!w(z))return null;try{let J=I(K(z,"Contents","Info.plist"),"utf8");return/<key>CFBundleVersion<\/key>\s*<string>(\d+\.\d+\.\d+)<\/string>/.exec(J)?.[1]??null}catch{return null}}function Gj(j,z=F()){let J=u(z);return J===null||p(A(J.split(".")),A(j.split(/[.-]/).slice(0,3)))}var Yj=1e4;function i(j,z){return C(j,[...z],{stdio:"ignore",timeout:Yj}).status??1}var l=new Set;function r(j){if(process.env.REASON_TEST_REFUSE_REAL_IDENTITY!=="1")return;let z=(J)=>{try{return R(J)}catch{return Qj(J)}};if(j!==void 0&&z(j)!==z(F()))return;throw Error("A test tried to change this computer's real Reason background identity; pass a temporary home. Refused by scripts/test-env.ts.")}var c=/\/(?:runtime|CLI)\/versions\/(\d+)\.(\d+)\.(\d+)[^/]*\/[^/]+$|\/\.ara(?:-staging)?-worker-(\d+)\.(\d+)\.(\d+)[^/]*\/[^/]+$/,o=new Set(["ara","ara.exe","reason","reason.exe"]);function A(j){return j.map((z)=>Number(z))}function p(j,z){for(let J=0;J<3;J+=1)if(j[J]!==z[J])return j[J]<z[J];return!1}var Nj=[0,2,161];function Pj(j){if(j===null)return!0;let z=Nj,J=null;try{J=R(process.execPath)}catch{}return j.some((W)=>{let Z=c.exec(W);if(Z){let X=Z[1]===void 0?Z.slice(4,7):Z.slice(1,4);return p(A(X),z)}let $=W.slice(W.lastIndexOf("/")+1);return o.has($)&&W!==J&&W!==process.execPath})}function Bj(){let j=C("/bin/ps",["-xo","pid=,comm="],{encoding:"utf8",timeout:5000});if(j.status!==0)return null;let z=[];for(let J of j.stdout.split(`
|
|
3
3
|
`)){let W=/^\s*(\d+)\s+(\S.*)$/.exec(J);if(!W||Number(W[1])===process.pid)continue;let Z=W[2].trimEnd(),$=Z.slice(Z.lastIndexOf("/")+1);if(!c.test(Z)&&o.has($)){let Q=C("/usr/sbin/lsof",["-a","-p",W[1],"-d","txt","-Fn"],{encoding:"utf8",timeout:5000}).stdout?.split(`
|
|
4
4
|
`).find((V)=>V.startsWith("n/"));if(Q)Z=Q.slice(1)}z.push(Z)}return z}function vj(j){if(r(j.home),!w(j.sourceApp))throw new H("identity_invalid","The packaged Reason background identity is missing or invalid.");let z=j.command??i,J=v(j.home),W=B(J);h(W,{recursive:!0,mode:448}),zj(W,448);let Z=R(j.sourceApp),$=null;try{$=R(J)}catch{}if(Z!==$){let X=`${process.pid}.${d()}`,Q=K(W,`.Reason.app.${X}.tmp`),V=K(W,`.Reason.app.${X}.old`),Y=!1;try{if(Jj(Z,Q,{recursive:!0,errorOnExist:!0,preserveTimestamps:!0}),!w(Q))throw new H("identity_invalid","The copied Reason background identity is invalid.");let O=j.releaseSigned?["--test-requirement",`=${Dj}`]:[];if(z("/usr/bin/codesign",["--verify","--strict",...O,Q])!==0)throw new H("identity_invalid_signature","The installed Reason background identity has an invalid signature.");let L=!1;for(let D=0;D<4;D+=1){let N=!1;try{P(J,V),N=!0,Y=!0}catch(q){if(q.code!=="ENOENT")throw q}if(D===0)j.beforePublish?.();try{P(Q,J),L=!0}catch(q){let jj=q.code;if(!["EEXIST","ENOTEMPTY"].includes(jj??""))throw q;if(N)G(V,{recursive:!0,force:!0}),Y=!1;if(D===3)throw q;continue}if(N)G(V,{recursive:!0,force:!0}),Y=!1;break}if(!L)throw Error("Could not publish Reason's background identity.")}catch(O){if(Y&&!U(J)&&U(V))P(V,J);throw O}finally{G(Q,{recursive:!0,force:!0}),G(V,{recursive:!0,force:!0})}}return e(J,j,{verified:Z!==$}),J}function n(j){return K(B(j),".Reason.app.registered")}function t(j){try{let z=M(j);return z.isDirectory()?`${z.ino}:${z.birthtimeMs}`:null}catch{return null}}function k(j){let z=t(j);try{return z!==null&&I(n(j),"utf8")===z}catch{return!1}}function a(j){if(w(j))return"bundle";try{if(M(K(j,"Contents","Info.plist"),{throwIfNoEntry:!1}))return null;return M(K(j,"Contents","MacOS",S)).isSymbolicLink()?"retired":null}catch{return null}}function e(j,z,J={}){let W=z.command??i;if(!J.verified&&W("/usr/bin/codesign",["--verify","--strict",j])!==0)throw new H("identity_invalid_signature","The installed Reason background identity has an invalid signature.");if(W(T,["-f",j])!==0)throw new H("identity_register_failed","Could not register Reason's macOS background identity.");let Z=t(j);try{if(Z)qj(n(j),Z,{mode:384})}catch{}try{Oj(j,z.home,W,z.runningExecutables??Bj)}catch($){let X=$.code??"unknown";process.stderr.write(`Reason background identity: legacy_identity_retire_failed (${X})
|
|
5
5
|
`)}}function Oj(j,z,J,W){let Z=f(j);if(!Z)return;let $=_(z),X=B($),Q=(q)=>K(q,"Contents","MacOS",S),V=Kj(B(Q($)),Z),Y=`${process.pid}.${d()}`,O=a($);if(O===null)return;let L=O==="bundle";if(L)J(T,["-u",$]);let D=K(X,`.Ara.app.${Y}.old`);if(!l.has($)&&!Pj(W())){if(!L)J(T,["-u",$]);try{P($,D)}catch(q){if(q.code==="ENOENT")return;throw q}G(D,{recursive:!0,force:!0}),Lj(X);return}if(!L){if(Zj(Q($))===V)return;let q=`${Q($)}.${Y}`;E(V,q);try{P(q,Q($))}finally{G(q,{force:!0})}return}let N=K(X,`.Ara.app.${Y}.shim`);h(B(Q(N)),{recursive:!0}),E(V,Q(N));try{try{P($,D)}catch(q){if(q.code==="ENOENT")return;throw q}try{P(N,$)}catch(q){if(U($))return;throw P(D,$),q}}finally{G(N,{recursive:!0,force:!0}),G(D,{recursive:!0,force:!0})}}function Lj(j){try{if(Wj(j).some((J)=>J!==".DS_Store"))return;G(K(j,".DS_Store"),{force:!0}),$j(j)}catch{}}var x=new Map;function Hj(j=F()){let z=x.get(j);if(z)return z;if(process.platform!=="darwin")return[];let J=g(j);if(J===null&&U(B(v(j))))Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,100),J=g(j);if(J===null)return[];return x.set(j,J),J}function g(j){let z=v(j),J=_(j);if(!w(z)||!k(z))try{Mj({home:j,skipWhenSettled:!0})}catch{}let W=w(z)&&(k(z)||!w(J))?z:w(J)?J:null,Z=W?f(W):null;if(!Z)return null;if(W===J)l.add(J);let $=C(Z,["--can-spawn"],{env:{},timeout:2000,encoding:"utf8"});return $.status===0&&$.stdout===`spawn
|
|
6
6
|
`?[Z,"--spawn"]:[]}var y=new Map;function Cj(j=F()){let z=Hj(j),J=z[0];if(!J)return[];let W=y.get(J);if(W===void 0){let Z=C(J,["--can-spawn-computer-use"],{env:{},timeout:2000,encoding:"utf8"});W=Z.status===0&&Z.stdout===`spawn
|
|
7
7
|
`,y.set(J,W)}return W?z:[]}function Ej(j=Cj(),z=F()){if(j.length>0)return null;if(u(z)===null)return"computer_use_identity_missing";return Gj(b,z)?"computer_use_identity_outdated":"computer_use_identity_unavailable"}function Mj(j={}){r(j.home);let z=v(j.home);if(j.skipWhenSettled&&w(z)&&k(z)&&a(_(j.home))===null)return!0;if(!w(z)){let J=_(j.home);if(!w(J))return!1;try{return vj({...j,sourceApp:J}),!0}catch(W){if(!w(z))throw W}}return e(z,j),!0}var Rj="REASON_WORKER_IDENTITY_APP";function xj(j,z=process.env,J=F()){let W=z[Rj];return W&&W===v(J)?W:j}function gj(j,z){if(process.platform!=="darwin")return null;let J=v(j),W=K(J,"Contents","MacOS",m),Z=C(W,["--can-run-worker",z],{env:{},timeout:2000,encoding:"utf8"});return Z.status===0&&Z.stdout===`run-worker
|
|
8
8
|
`?{app:J,executable:W}:null}
|
|
9
|
-
export{s as
|
|
9
|
+
export{s as Wi,Vj as Xi,Sj as Yi,H as Zi,T as _i,v as $i,fj as aj,u as bj,Gj as cj,vj as dj,Hj as ej,Cj as fj,Ej as gj,Mj as hj,Rj as ij,xj as jj,gj as kj};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Hk as e}from"./vm-hands-entry-lite-2t0vcvd8.js";var i=e((o,t)=>{t.exports={name:"playwright-core",version:"1.60.0",description:"A high-level API to automate web browsers",repository:{type:"git",url:"git+https://github.com/microsoft/playwright.git"},homepage:"https://playwright.dev",engines:{node:">=18"},author:{name:"Microsoft Corporation"},license:"Apache-2.0",exports:{".":{types:"./index.d.ts",import:"./index.mjs",require:"./index.js",default:"./index.js"},"./package.json":"./package.json","./lib/bootstrap":"./lib/bootstrap.js","./lib/coreBundle":"./lib/coreBundle.js","./lib/utilsBundle":"./lib/utilsBundle.js","./lib/tools/cli-client/program":"./lib/tools/cli-client/program.js"},bin:{"playwright-core":"cli.js"},types:"types/types.d.ts"}});
|
|
3
3
|
export{i as Aa};
|