@agentconnect.md/computer 2.12.0-rc.1 → 2.12.0-rc.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agentconnect-computer.mjs +1716 -805
- package/package.json +1 -1
|
@@ -971,12 +971,12 @@ var require_isexe = __commonJS({
|
|
|
971
971
|
if (typeof Promise !== "function") {
|
|
972
972
|
throw new TypeError("callback not provided");
|
|
973
973
|
}
|
|
974
|
-
return new Promise(function(
|
|
974
|
+
return new Promise(function(resolve5, reject) {
|
|
975
975
|
isexe(path, options || {}, function(er, is) {
|
|
976
976
|
if (er) {
|
|
977
977
|
reject(er);
|
|
978
978
|
} else {
|
|
979
|
-
|
|
979
|
+
resolve5(is);
|
|
980
980
|
}
|
|
981
981
|
});
|
|
982
982
|
});
|
|
@@ -1043,27 +1043,27 @@ var require_which = __commonJS({
|
|
|
1043
1043
|
opt = {};
|
|
1044
1044
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
1045
1045
|
const found = [];
|
|
1046
|
-
const step = (i) => new Promise((
|
|
1046
|
+
const step = (i) => new Promise((resolve5, reject) => {
|
|
1047
1047
|
if (i === pathEnv.length)
|
|
1048
|
-
return opt.all && found.length ?
|
|
1048
|
+
return opt.all && found.length ? resolve5(found) : reject(getNotFoundError(cmd));
|
|
1049
1049
|
const ppRaw = pathEnv[i];
|
|
1050
1050
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
1051
1051
|
const pCmd = path.join(pathPart, cmd);
|
|
1052
1052
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
1053
|
-
|
|
1053
|
+
resolve5(subStep(p, i, 0));
|
|
1054
1054
|
});
|
|
1055
|
-
const subStep = (p, i, ii) => new Promise((
|
|
1055
|
+
const subStep = (p, i, ii) => new Promise((resolve5, reject) => {
|
|
1056
1056
|
if (ii === pathExt.length)
|
|
1057
|
-
return
|
|
1057
|
+
return resolve5(step(i + 1));
|
|
1058
1058
|
const ext = pathExt[ii];
|
|
1059
1059
|
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
1060
1060
|
if (!er && is) {
|
|
1061
1061
|
if (opt.all)
|
|
1062
1062
|
found.push(p + ext);
|
|
1063
1063
|
else
|
|
1064
|
-
return
|
|
1064
|
+
return resolve5(p + ext);
|
|
1065
1065
|
}
|
|
1066
|
-
return
|
|
1066
|
+
return resolve5(subStep(p, i, ii + 1));
|
|
1067
1067
|
});
|
|
1068
1068
|
});
|
|
1069
1069
|
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
|
|
@@ -1364,7 +1364,7 @@ var require_cross_spawn = __commonJS({
|
|
|
1364
1364
|
var cp = __require("child_process");
|
|
1365
1365
|
var parse3 = require_parse();
|
|
1366
1366
|
var enoent = require_enoent();
|
|
1367
|
-
function
|
|
1367
|
+
function spawn13(command, args, options) {
|
|
1368
1368
|
const parsed = parse3(command, args, options);
|
|
1369
1369
|
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
|
|
1370
1370
|
enoent.hookChildProcess(spawned, parsed);
|
|
@@ -1376,8 +1376,8 @@ var require_cross_spawn = __commonJS({
|
|
|
1376
1376
|
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
|
1377
1377
|
return result;
|
|
1378
1378
|
}
|
|
1379
|
-
module.exports =
|
|
1380
|
-
module.exports.spawn =
|
|
1379
|
+
module.exports = spawn13;
|
|
1380
|
+
module.exports.spawn = spawn13;
|
|
1381
1381
|
module.exports.sync = spawnSync11;
|
|
1382
1382
|
module.exports._parse = parse3;
|
|
1383
1383
|
module.exports._enoent = enoent;
|
|
@@ -1595,8 +1595,8 @@ var require_common = __commonJS({
|
|
|
1595
1595
|
}
|
|
1596
1596
|
return debug2;
|
|
1597
1597
|
}
|
|
1598
|
-
function extend2(namespace,
|
|
1599
|
-
const newDebug = createDebug(this.namespace + (typeof
|
|
1598
|
+
function extend2(namespace, delimiter2) {
|
|
1599
|
+
const newDebug = createDebug(this.namespace + (typeof delimiter2 === "undefined" ? ":" : delimiter2) + namespace);
|
|
1600
1600
|
newDebug.log = this.log;
|
|
1601
1601
|
return newDebug;
|
|
1602
1602
|
}
|
|
@@ -4593,9 +4593,9 @@ var require_common3 = __commonJS({
|
|
|
4593
4593
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
4594
4594
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4595
4595
|
var BufferVisitor = class {
|
|
4596
|
-
constructor(buf,
|
|
4597
|
-
this.start =
|
|
4598
|
-
this.end = end >
|
|
4596
|
+
constructor(buf, start2 = 0, end = 0) {
|
|
4597
|
+
this.start = start2;
|
|
4598
|
+
this.end = end > start2 ? end : start2;
|
|
4599
4599
|
this.buf = buf;
|
|
4600
4600
|
}
|
|
4601
4601
|
/**
|
|
@@ -4609,8 +4609,8 @@ var require_common3 = __commonJS({
|
|
|
4609
4609
|
* @param start
|
|
4610
4610
|
* @param end
|
|
4611
4611
|
*/
|
|
4612
|
-
reset(
|
|
4613
|
-
this.start =
|
|
4612
|
+
reset(start2 = 0, end = 0) {
|
|
4613
|
+
this.start = start2;
|
|
4614
4614
|
if (end >= this.start) {
|
|
4615
4615
|
this.end = end;
|
|
4616
4616
|
} else if (this.end < this.start) {
|
|
@@ -5449,9 +5449,9 @@ var require_asn1 = __commonJS({
|
|
|
5449
5449
|
const bufv = new common_1.BufferVisitor(buf);
|
|
5450
5450
|
let readByteLen = 0;
|
|
5451
5451
|
while (readByteLen < len) {
|
|
5452
|
-
const
|
|
5452
|
+
const start2 = bufv.end;
|
|
5453
5453
|
values.push(_ASN1._fromDER(bufv, deepParse));
|
|
5454
|
-
readByteLen += bufv.end -
|
|
5454
|
+
readByteLen += bufv.end - start2;
|
|
5455
5455
|
}
|
|
5456
5456
|
return values;
|
|
5457
5457
|
}
|
|
@@ -5461,8 +5461,8 @@ var require_asn1 = __commonJS({
|
|
|
5461
5461
|
throw new Error("ASN1 syntax error: invalid Generalized Time");
|
|
5462
5462
|
}
|
|
5463
5463
|
bufv.mustWalk(1, "Too few bytes to read ASN.1 tag.");
|
|
5464
|
-
const
|
|
5465
|
-
const b1 = bufv.buf[
|
|
5464
|
+
const start2 = bufv.start;
|
|
5465
|
+
const b1 = bufv.buf[start2];
|
|
5466
5466
|
const tagClass = b1 & 192;
|
|
5467
5467
|
const tag = b1 & 31;
|
|
5468
5468
|
const valueLen = getValueLength(bufv);
|
|
@@ -5476,7 +5476,7 @@ var require_asn1 = __commonJS({
|
|
|
5476
5476
|
if (isCompound && deepParse) {
|
|
5477
5477
|
asn1._value = _ASN1._parseCompound(asn1.bytes, deepParse);
|
|
5478
5478
|
}
|
|
5479
|
-
asn1._der = bufv.buf.slice(
|
|
5479
|
+
asn1._der = bufv.buf.slice(start2, bufv.end);
|
|
5480
5480
|
return asn1;
|
|
5481
5481
|
}
|
|
5482
5482
|
constructor(tagClass, tag, data, isCompound = false) {
|
|
@@ -8351,11 +8351,11 @@ var require_tslib = __commonJS({
|
|
|
8351
8351
|
};
|
|
8352
8352
|
__awaiter = function(thisArg, _arguments, P, generator) {
|
|
8353
8353
|
function adopt(value) {
|
|
8354
|
-
return value instanceof P ? value : new P(function(
|
|
8355
|
-
|
|
8354
|
+
return value instanceof P ? value : new P(function(resolve5) {
|
|
8355
|
+
resolve5(value);
|
|
8356
8356
|
});
|
|
8357
8357
|
}
|
|
8358
|
-
return new (P || (P = Promise))(function(
|
|
8358
|
+
return new (P || (P = Promise))(function(resolve5, reject) {
|
|
8359
8359
|
function fulfilled(value) {
|
|
8360
8360
|
try {
|
|
8361
8361
|
step(generator.next(value));
|
|
@@ -8371,7 +8371,7 @@ var require_tslib = __commonJS({
|
|
|
8371
8371
|
}
|
|
8372
8372
|
}
|
|
8373
8373
|
function step(result) {
|
|
8374
|
-
result.done ?
|
|
8374
|
+
result.done ? resolve5(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
8375
8375
|
}
|
|
8376
8376
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8377
8377
|
});
|
|
@@ -8575,14 +8575,14 @@ var require_tslib = __commonJS({
|
|
|
8575
8575
|
}, i);
|
|
8576
8576
|
function verb(n) {
|
|
8577
8577
|
i[n] = o[n] && function(v) {
|
|
8578
|
-
return new Promise(function(
|
|
8579
|
-
v = o[n](v), settle2(
|
|
8578
|
+
return new Promise(function(resolve5, reject) {
|
|
8579
|
+
v = o[n](v), settle2(resolve5, reject, v.done, v.value);
|
|
8580
8580
|
});
|
|
8581
8581
|
};
|
|
8582
8582
|
}
|
|
8583
|
-
function settle2(
|
|
8583
|
+
function settle2(resolve5, reject, d, v) {
|
|
8584
8584
|
Promise.resolve(v).then(function(v2) {
|
|
8585
|
-
|
|
8585
|
+
resolve5({ value: v2, done: d });
|
|
8586
8586
|
}, reject);
|
|
8587
8587
|
}
|
|
8588
8588
|
};
|
|
@@ -13245,14 +13245,14 @@ var require_sequence = __commonJS({
|
|
|
13245
13245
|
return normalized;
|
|
13246
13246
|
}
|
|
13247
13247
|
function normalizeForwardRange(length, options) {
|
|
13248
|
-
const
|
|
13248
|
+
const start2 = clampIndex(options?.start, 0, length);
|
|
13249
13249
|
const end = clampIndex(options?.end, length, length);
|
|
13250
|
-
return end >=
|
|
13250
|
+
return end >= start2 ? [start2, end] : [start2, start2];
|
|
13251
13251
|
}
|
|
13252
13252
|
function normalizeReverseRange(length, options) {
|
|
13253
|
-
const
|
|
13253
|
+
const start2 = clampIndex(options?.start, length, length);
|
|
13254
13254
|
const end = clampIndex(options?.end, 0, length);
|
|
13255
|
-
return
|
|
13255
|
+
return start2 >= end ? [end, start2] : [start2, start2];
|
|
13256
13256
|
}
|
|
13257
13257
|
function normalizeSliceIndex(value, fallback, length) {
|
|
13258
13258
|
const normalized = Number.isFinite(value) ? Math.trunc(value) : fallback;
|
|
@@ -13291,15 +13291,15 @@ var require_sequence = __commonJS({
|
|
|
13291
13291
|
function indexOf(data, pattern, options) {
|
|
13292
13292
|
const bytes = (0, buffer_source_js_1.toUint8Array)(data);
|
|
13293
13293
|
const needle = toPatternBytes(pattern, options);
|
|
13294
|
-
const [
|
|
13294
|
+
const [start2, end] = normalizeForwardRange(bytes.byteLength, options);
|
|
13295
13295
|
if (needle.byteLength === 0) {
|
|
13296
|
-
return
|
|
13296
|
+
return start2;
|
|
13297
13297
|
}
|
|
13298
13298
|
const lastOffset = end - needle.byteLength;
|
|
13299
|
-
if (lastOffset <
|
|
13299
|
+
if (lastOffset < start2) {
|
|
13300
13300
|
return -1;
|
|
13301
13301
|
}
|
|
13302
|
-
for (let offset =
|
|
13302
|
+
for (let offset = start2; offset <= lastOffset; offset++) {
|
|
13303
13303
|
if (bytesEqualAt(bytes, needle, offset)) {
|
|
13304
13304
|
return offset;
|
|
13305
13305
|
}
|
|
@@ -13309,11 +13309,11 @@ var require_sequence = __commonJS({
|
|
|
13309
13309
|
function lastIndexOf(data, pattern, options) {
|
|
13310
13310
|
const bytes = (0, buffer_source_js_1.toUint8Array)(data);
|
|
13311
13311
|
const needle = toPatternBytes(pattern, options);
|
|
13312
|
-
const [end,
|
|
13312
|
+
const [end, start2] = normalizeReverseRange(bytes.byteLength, options);
|
|
13313
13313
|
if (needle.byteLength === 0) {
|
|
13314
|
-
return
|
|
13314
|
+
return start2;
|
|
13315
13315
|
}
|
|
13316
|
-
const firstOffset =
|
|
13316
|
+
const firstOffset = start2 - needle.byteLength;
|
|
13317
13317
|
if (firstOffset < end) {
|
|
13318
13318
|
return -1;
|
|
13319
13319
|
}
|
|
@@ -13343,9 +13343,9 @@ var require_sequence = __commonJS({
|
|
|
13343
13343
|
}
|
|
13344
13344
|
return bytesEqualAt(bytes, needle, bytes.byteLength - needle.byteLength);
|
|
13345
13345
|
}
|
|
13346
|
-
function slice(data,
|
|
13346
|
+
function slice(data, start2, end) {
|
|
13347
13347
|
const bytes = (0, buffer_source_js_1.toUint8Array)(data);
|
|
13348
|
-
const normalizedStart = normalizeSliceIndex(
|
|
13348
|
+
const normalizedStart = normalizeSliceIndex(start2, 0, bytes.byteLength);
|
|
13349
13349
|
const normalizedEnd = normalizeSliceIndex(end, bytes.byteLength, bytes.byteLength);
|
|
13350
13350
|
if (normalizedEnd <= normalizedStart) {
|
|
13351
13351
|
return bytes.subarray(normalizedStart, normalizedStart);
|
|
@@ -20962,11 +20962,11 @@ var require_tslib2 = __commonJS({
|
|
|
20962
20962
|
};
|
|
20963
20963
|
__awaiter = function(thisArg, _arguments, P, generator) {
|
|
20964
20964
|
function adopt(value) {
|
|
20965
|
-
return value instanceof P ? value : new P(function(
|
|
20966
|
-
|
|
20965
|
+
return value instanceof P ? value : new P(function(resolve5) {
|
|
20966
|
+
resolve5(value);
|
|
20967
20967
|
});
|
|
20968
20968
|
}
|
|
20969
|
-
return new (P || (P = Promise))(function(
|
|
20969
|
+
return new (P || (P = Promise))(function(resolve5, reject) {
|
|
20970
20970
|
function fulfilled(value) {
|
|
20971
20971
|
try {
|
|
20972
20972
|
step(generator.next(value));
|
|
@@ -20982,7 +20982,7 @@ var require_tslib2 = __commonJS({
|
|
|
20982
20982
|
}
|
|
20983
20983
|
}
|
|
20984
20984
|
function step(result) {
|
|
20985
|
-
result.done ?
|
|
20985
|
+
result.done ? resolve5(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
20986
20986
|
}
|
|
20987
20987
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20988
20988
|
});
|
|
@@ -21160,14 +21160,14 @@ var require_tslib2 = __commonJS({
|
|
|
21160
21160
|
}, i);
|
|
21161
21161
|
function verb(n) {
|
|
21162
21162
|
i[n] = o[n] && function(v) {
|
|
21163
|
-
return new Promise(function(
|
|
21164
|
-
v = o[n](v), settle2(
|
|
21163
|
+
return new Promise(function(resolve5, reject) {
|
|
21164
|
+
v = o[n](v), settle2(resolve5, reject, v.done, v.value);
|
|
21165
21165
|
});
|
|
21166
21166
|
};
|
|
21167
21167
|
}
|
|
21168
|
-
function settle2(
|
|
21168
|
+
function settle2(resolve5, reject, d, v) {
|
|
21169
21169
|
Promise.resolve(v).then(function(v2) {
|
|
21170
|
-
|
|
21170
|
+
resolve5({ value: v2, done: d });
|
|
21171
21171
|
}, reject);
|
|
21172
21172
|
}
|
|
21173
21173
|
};
|
|
@@ -28655,7 +28655,7 @@ var require_thunky = __commonJS({
|
|
|
28655
28655
|
state = isError(err5) ? run4 : finished;
|
|
28656
28656
|
while (stack.length) finished(stack.shift());
|
|
28657
28657
|
function finished(callback2) {
|
|
28658
|
-
nextTick(
|
|
28658
|
+
nextTick(apply2, callback2, args);
|
|
28659
28659
|
}
|
|
28660
28660
|
}
|
|
28661
28661
|
}
|
|
@@ -28665,7 +28665,7 @@ var require_thunky = __commonJS({
|
|
|
28665
28665
|
}
|
|
28666
28666
|
function noop() {
|
|
28667
28667
|
}
|
|
28668
|
-
function
|
|
28668
|
+
function apply2(callback, args) {
|
|
28669
28669
|
callback.apply(null, args);
|
|
28670
28670
|
}
|
|
28671
28671
|
function upgrade(val) {
|
|
@@ -28823,7 +28823,7 @@ var require_multicast_dns = __commonJS({
|
|
|
28823
28823
|
var net2 = networks[names[i]];
|
|
28824
28824
|
for (var j = 0; j < net2.length; j++) {
|
|
28825
28825
|
var iface = net2[j];
|
|
28826
|
-
if (
|
|
28826
|
+
if (isIPv46(iface.family) && !iface.internal) {
|
|
28827
28827
|
if (os2.platform() === "darwin" && names[i] === "en0") return iface.address;
|
|
28828
28828
|
return "0.0.0.0";
|
|
28829
28829
|
}
|
|
@@ -28839,7 +28839,7 @@ var require_multicast_dns = __commonJS({
|
|
|
28839
28839
|
var net2 = networks[names[i]];
|
|
28840
28840
|
for (var j = 0; j < net2.length; j++) {
|
|
28841
28841
|
var iface = net2[j];
|
|
28842
|
-
if (
|
|
28842
|
+
if (isIPv46(iface.family)) {
|
|
28843
28843
|
res.push(iface.address);
|
|
28844
28844
|
break;
|
|
28845
28845
|
}
|
|
@@ -28847,7 +28847,7 @@ var require_multicast_dns = __commonJS({
|
|
|
28847
28847
|
}
|
|
28848
28848
|
return res;
|
|
28849
28849
|
}
|
|
28850
|
-
function
|
|
28850
|
+
function isIPv46(family) {
|
|
28851
28851
|
return family === 4 || family === "IPv4";
|
|
28852
28852
|
}
|
|
28853
28853
|
}
|
|
@@ -30956,7 +30956,7 @@ var require_extension2 = __commonJS({
|
|
|
30956
30956
|
let inQuotes = false;
|
|
30957
30957
|
let extensionName;
|
|
30958
30958
|
let paramName;
|
|
30959
|
-
let
|
|
30959
|
+
let start2 = -1;
|
|
30960
30960
|
let code = -1;
|
|
30961
30961
|
let end = -1;
|
|
30962
30962
|
let i = 0;
|
|
@@ -30964,45 +30964,45 @@ var require_extension2 = __commonJS({
|
|
|
30964
30964
|
code = header.charCodeAt(i);
|
|
30965
30965
|
if (extensionName === void 0) {
|
|
30966
30966
|
if (end === -1 && tokenChars[code] === 1) {
|
|
30967
|
-
if (
|
|
30967
|
+
if (start2 === -1) start2 = i;
|
|
30968
30968
|
} else if (i !== 0 && (code === 32 || code === 9)) {
|
|
30969
|
-
if (end === -1 &&
|
|
30969
|
+
if (end === -1 && start2 !== -1) end = i;
|
|
30970
30970
|
} else if (code === 59 || code === 44) {
|
|
30971
|
-
if (
|
|
30971
|
+
if (start2 === -1) {
|
|
30972
30972
|
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
30973
30973
|
}
|
|
30974
30974
|
if (end === -1) end = i;
|
|
30975
|
-
const name = header.slice(
|
|
30975
|
+
const name = header.slice(start2, end);
|
|
30976
30976
|
if (code === 44) {
|
|
30977
30977
|
push(offers, name, params);
|
|
30978
30978
|
params = /* @__PURE__ */ Object.create(null);
|
|
30979
30979
|
} else {
|
|
30980
30980
|
extensionName = name;
|
|
30981
30981
|
}
|
|
30982
|
-
|
|
30982
|
+
start2 = end = -1;
|
|
30983
30983
|
} else {
|
|
30984
30984
|
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
30985
30985
|
}
|
|
30986
30986
|
} else if (paramName === void 0) {
|
|
30987
30987
|
if (end === -1 && tokenChars[code] === 1) {
|
|
30988
|
-
if (
|
|
30988
|
+
if (start2 === -1) start2 = i;
|
|
30989
30989
|
} else if (code === 32 || code === 9) {
|
|
30990
|
-
if (end === -1 &&
|
|
30990
|
+
if (end === -1 && start2 !== -1) end = i;
|
|
30991
30991
|
} else if (code === 59 || code === 44) {
|
|
30992
|
-
if (
|
|
30992
|
+
if (start2 === -1) {
|
|
30993
30993
|
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
30994
30994
|
}
|
|
30995
30995
|
if (end === -1) end = i;
|
|
30996
|
-
push(params, header.slice(
|
|
30996
|
+
push(params, header.slice(start2, end), true);
|
|
30997
30997
|
if (code === 44) {
|
|
30998
30998
|
push(offers, extensionName, params);
|
|
30999
30999
|
params = /* @__PURE__ */ Object.create(null);
|
|
31000
31000
|
extensionName = void 0;
|
|
31001
31001
|
}
|
|
31002
|
-
|
|
31003
|
-
} else if (code === 61 &&
|
|
31004
|
-
paramName = header.slice(
|
|
31005
|
-
|
|
31002
|
+
start2 = end = -1;
|
|
31003
|
+
} else if (code === 61 && start2 !== -1 && end === -1) {
|
|
31004
|
+
paramName = header.slice(start2, i);
|
|
31005
|
+
start2 = end = -1;
|
|
31006
31006
|
} else {
|
|
31007
31007
|
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
31008
31008
|
}
|
|
@@ -31011,13 +31011,13 @@ var require_extension2 = __commonJS({
|
|
|
31011
31011
|
if (tokenChars[code] !== 1) {
|
|
31012
31012
|
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
31013
31013
|
}
|
|
31014
|
-
if (
|
|
31014
|
+
if (start2 === -1) start2 = i;
|
|
31015
31015
|
else if (!mustUnescape) mustUnescape = true;
|
|
31016
31016
|
isEscaping = false;
|
|
31017
31017
|
} else if (inQuotes) {
|
|
31018
31018
|
if (tokenChars[code] === 1) {
|
|
31019
|
-
if (
|
|
31020
|
-
} else if (code === 34 &&
|
|
31019
|
+
if (start2 === -1) start2 = i;
|
|
31020
|
+
} else if (code === 34 && start2 !== -1) {
|
|
31021
31021
|
inQuotes = false;
|
|
31022
31022
|
end = i;
|
|
31023
31023
|
} else if (code === 92) {
|
|
@@ -31028,15 +31028,15 @@ var require_extension2 = __commonJS({
|
|
|
31028
31028
|
} else if (code === 34 && header.charCodeAt(i - 1) === 61) {
|
|
31029
31029
|
inQuotes = true;
|
|
31030
31030
|
} else if (end === -1 && tokenChars[code] === 1) {
|
|
31031
|
-
if (
|
|
31032
|
-
} else if (
|
|
31031
|
+
if (start2 === -1) start2 = i;
|
|
31032
|
+
} else if (start2 !== -1 && (code === 32 || code === 9)) {
|
|
31033
31033
|
if (end === -1) end = i;
|
|
31034
31034
|
} else if (code === 59 || code === 44) {
|
|
31035
|
-
if (
|
|
31035
|
+
if (start2 === -1) {
|
|
31036
31036
|
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
31037
31037
|
}
|
|
31038
31038
|
if (end === -1) end = i;
|
|
31039
|
-
let value = header.slice(
|
|
31039
|
+
let value = header.slice(start2, end);
|
|
31040
31040
|
if (mustUnescape) {
|
|
31041
31041
|
value = value.replace(/\\/g, "");
|
|
31042
31042
|
mustUnescape = false;
|
|
@@ -31048,17 +31048,17 @@ var require_extension2 = __commonJS({
|
|
|
31048
31048
|
extensionName = void 0;
|
|
31049
31049
|
}
|
|
31050
31050
|
paramName = void 0;
|
|
31051
|
-
|
|
31051
|
+
start2 = end = -1;
|
|
31052
31052
|
} else {
|
|
31053
31053
|
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
31054
31054
|
}
|
|
31055
31055
|
}
|
|
31056
31056
|
}
|
|
31057
|
-
if (
|
|
31057
|
+
if (start2 === -1 || inQuotes || code === 32 || code === 9) {
|
|
31058
31058
|
throw new SyntaxError("Unexpected end of input");
|
|
31059
31059
|
}
|
|
31060
31060
|
if (end === -1) end = i;
|
|
31061
|
-
const token = header.slice(
|
|
31061
|
+
const token = header.slice(start2, end);
|
|
31062
31062
|
if (extensionName === void 0) {
|
|
31063
31063
|
push(offers, token, params);
|
|
31064
31064
|
} else {
|
|
@@ -32109,34 +32109,34 @@ var require_subprotocol = __commonJS({
|
|
|
32109
32109
|
var { tokenChars } = require_validation3();
|
|
32110
32110
|
function parse3(header) {
|
|
32111
32111
|
const protocols = /* @__PURE__ */ new Set();
|
|
32112
|
-
let
|
|
32112
|
+
let start2 = -1;
|
|
32113
32113
|
let end = -1;
|
|
32114
32114
|
let i = 0;
|
|
32115
32115
|
for (i; i < header.length; i++) {
|
|
32116
32116
|
const code = header.charCodeAt(i);
|
|
32117
32117
|
if (end === -1 && tokenChars[code] === 1) {
|
|
32118
|
-
if (
|
|
32118
|
+
if (start2 === -1) start2 = i;
|
|
32119
32119
|
} else if (i !== 0 && (code === 32 || code === 9)) {
|
|
32120
|
-
if (end === -1 &&
|
|
32120
|
+
if (end === -1 && start2 !== -1) end = i;
|
|
32121
32121
|
} else if (code === 44) {
|
|
32122
|
-
if (
|
|
32122
|
+
if (start2 === -1) {
|
|
32123
32123
|
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
32124
32124
|
}
|
|
32125
32125
|
if (end === -1) end = i;
|
|
32126
|
-
const protocol2 = header.slice(
|
|
32126
|
+
const protocol2 = header.slice(start2, end);
|
|
32127
32127
|
if (protocols.has(protocol2)) {
|
|
32128
32128
|
throw new SyntaxError(`The "${protocol2}" subprotocol is duplicated`);
|
|
32129
32129
|
}
|
|
32130
32130
|
protocols.add(protocol2);
|
|
32131
|
-
|
|
32131
|
+
start2 = end = -1;
|
|
32132
32132
|
} else {
|
|
32133
32133
|
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
32134
32134
|
}
|
|
32135
32135
|
}
|
|
32136
|
-
if (
|
|
32136
|
+
if (start2 === -1 || end !== -1) {
|
|
32137
32137
|
throw new SyntaxError("Unexpected end of input");
|
|
32138
32138
|
}
|
|
32139
|
-
const protocol = header.slice(
|
|
32139
|
+
const protocol = header.slice(start2, i);
|
|
32140
32140
|
if (protocols.has(protocol)) {
|
|
32141
32141
|
throw new SyntaxError(`The "${protocol}" subprotocol is duplicated`);
|
|
32142
32142
|
}
|
|
@@ -32551,9 +32551,9 @@ var require_websocket_server = __commonJS({
|
|
|
32551
32551
|
|
|
32552
32552
|
// src/cli.ts
|
|
32553
32553
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
32554
|
-
import { existsSync as
|
|
32555
|
-
import { hostname as
|
|
32556
|
-
import { basename as
|
|
32554
|
+
import { existsSync as existsSync14, rmSync as rmSync13, writeFileSync as writeFileSync14 } from "node:fs";
|
|
32555
|
+
import { hostname as hostname6, networkInterfaces as networkInterfaces2 } from "node:os";
|
|
32556
|
+
import { basename as basename5, join as join19, resolve as resolve4 } from "node:path";
|
|
32557
32557
|
import { createInterface as createInterface4 } from "node:readline";
|
|
32558
32558
|
import { parseArgs } from "node:util";
|
|
32559
32559
|
|
|
@@ -33347,9 +33347,9 @@ function nullish(input2) {
|
|
|
33347
33347
|
return input2 === null || input2 === void 0;
|
|
33348
33348
|
}
|
|
33349
33349
|
function cleanRegex(source) {
|
|
33350
|
-
const
|
|
33350
|
+
const start2 = source.startsWith("^") ? 1 : 0;
|
|
33351
33351
|
const end = source.endsWith("$") ? source.length - 1 : source.length;
|
|
33352
|
-
return source.slice(
|
|
33352
|
+
return source.slice(start2, end);
|
|
33353
33353
|
}
|
|
33354
33354
|
function floatSafeRemainder(val, step) {
|
|
33355
33355
|
const ratio = val / step;
|
|
@@ -33820,9 +33820,9 @@ function sizeCaps(defChecks) {
|
|
|
33820
33820
|
}
|
|
33821
33821
|
return caps;
|
|
33822
33822
|
}
|
|
33823
|
-
function attachSchema(issues,
|
|
33823
|
+
function attachSchema(issues, start2, inst) {
|
|
33824
33824
|
var _a3;
|
|
33825
|
-
for (let i =
|
|
33825
|
+
for (let i = start2; i < issues.length; i++) {
|
|
33826
33826
|
(_a3 = issues[i]).schema ?? (_a3.schema = inst);
|
|
33827
33827
|
}
|
|
33828
33828
|
}
|
|
@@ -34658,8 +34658,8 @@ function emoji() {
|
|
|
34658
34658
|
}
|
|
34659
34659
|
var ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
|
|
34660
34660
|
var ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
|
|
34661
|
-
var mac = (
|
|
34662
|
-
const escapedDelim = escapeRegex(
|
|
34661
|
+
var mac = (delimiter2) => {
|
|
34662
|
+
const escapedDelim = escapeRegex(delimiter2 ?? ":");
|
|
34663
34663
|
return new RegExp(`^(?:[0-9A-F]{2}${escapedDelim}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${escapedDelim}){5}[0-9a-f]{2}$`);
|
|
34664
34664
|
};
|
|
34665
34665
|
var cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
|
|
@@ -35476,9 +35476,9 @@ var asciiTabOrNewline = /[\t\n\r]/g;
|
|
|
35476
35476
|
function stripTabAndNewline(value) {
|
|
35477
35477
|
return value.replace(asciiTabOrNewline, "");
|
|
35478
35478
|
}
|
|
35479
|
-
function urlHostnameOk(url2,
|
|
35480
|
-
|
|
35481
|
-
return
|
|
35479
|
+
function urlHostnameOk(url2, hostname7) {
|
|
35480
|
+
hostname7.lastIndex = 0;
|
|
35481
|
+
return hostname7.test(url2.hostname);
|
|
35482
35482
|
}
|
|
35483
35483
|
function urlProtocolOk(url2, protocol) {
|
|
35484
35484
|
protocol.lastIndex = 0;
|
|
@@ -36020,10 +36020,10 @@ function capSize(inst, size) {
|
|
|
36020
36020
|
if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
|
|
36021
36021
|
for (const [max, ch] of sizeCaps(inst._zod.def.checks)) {
|
|
36022
36022
|
if (n > max && ch._zod.def.when(payload)) {
|
|
36023
|
-
const
|
|
36023
|
+
const start2 = payload.issues.length;
|
|
36024
36024
|
ch._zod.check(payload);
|
|
36025
|
-
payload.issues[
|
|
36026
|
-
attachSchema(payload.issues,
|
|
36025
|
+
payload.issues[start2].continue = false;
|
|
36026
|
+
attachSchema(payload.issues, start2, inst);
|
|
36027
36027
|
return payload;
|
|
36028
36028
|
}
|
|
36029
36029
|
}
|
|
@@ -37718,7 +37718,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
|
|
|
37718
37718
|
var NONE = 0;
|
|
37719
37719
|
var ASSUMED = 1;
|
|
37720
37720
|
var PROVEN = 2;
|
|
37721
|
-
function isRecursive(inst, stack,
|
|
37721
|
+
function isRecursive(inst, stack, resolve5) {
|
|
37722
37722
|
const cached2 = recursive.get(inst);
|
|
37723
37723
|
if (cached2 !== void 0)
|
|
37724
37724
|
return cached2 ? PROVEN : NONE;
|
|
@@ -37728,7 +37728,7 @@ function isRecursive(inst, stack, resolve4) {
|
|
|
37728
37728
|
let result = NONE;
|
|
37729
37729
|
const check2 = (child2) => {
|
|
37730
37730
|
if (result !== PROVEN && child2?._zod) {
|
|
37731
|
-
const answer = isRecursive(child2, stack,
|
|
37731
|
+
const answer = isRecursive(child2, stack, resolve5);
|
|
37732
37732
|
if (answer > result)
|
|
37733
37733
|
result = answer;
|
|
37734
37734
|
}
|
|
@@ -37739,7 +37739,7 @@ function isRecursive(inst, stack, resolve4) {
|
|
|
37739
37739
|
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
37740
37740
|
if (spread && !desc.enumerable)
|
|
37741
37741
|
continue;
|
|
37742
|
-
const child2 = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack,
|
|
37742
|
+
const child2 = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve5) : NONE;
|
|
37743
37743
|
if (child2 > answer)
|
|
37744
37744
|
answer = child2;
|
|
37745
37745
|
}
|
|
@@ -37803,7 +37803,7 @@ function isRecursive(inst, stack, resolve4) {
|
|
|
37803
37803
|
break;
|
|
37804
37804
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
37805
37805
|
case "lazy": {
|
|
37806
|
-
const inner = def._cachedInner ?? (
|
|
37806
|
+
const inner = def._cachedInner ?? (resolve5 ? inst._zod.innerType : void 0);
|
|
37807
37807
|
merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
37808
37808
|
break;
|
|
37809
37809
|
}
|
|
@@ -56808,14 +56808,14 @@ function inputRequiredRoundsExceededMessage(method, maxRounds) {
|
|
|
56808
56808
|
return `Multi-round-trip request '${method}' still required input after ${maxRounds} rounds (inputRequired.maxRounds)`;
|
|
56809
56809
|
}
|
|
56810
56810
|
function sleep(ms, signal) {
|
|
56811
|
-
return new Promise((
|
|
56811
|
+
return new Promise((resolve5, reject) => {
|
|
56812
56812
|
if (signal?.aborted) {
|
|
56813
56813
|
reject(signal.reason instanceof SdkError ? signal.reason : new SdkError(SdkErrorCode.RequestTimeout, String(signal.reason)));
|
|
56814
56814
|
return;
|
|
56815
56815
|
}
|
|
56816
56816
|
const timer = setTimeout(() => {
|
|
56817
56817
|
signal?.removeEventListener("abort", onAbort);
|
|
56818
|
-
|
|
56818
|
+
resolve5();
|
|
56819
56819
|
}, ms);
|
|
56820
56820
|
const onAbort = () => {
|
|
56821
56821
|
clearTimeout(timer);
|
|
@@ -57611,7 +57611,7 @@ var Protocol = class {
|
|
|
57611
57611
|
const flowStartedAt = Date.now();
|
|
57612
57612
|
let onAbort;
|
|
57613
57613
|
let cleanupMessageId;
|
|
57614
|
-
return new Promise((
|
|
57614
|
+
return new Promise((resolve5, reject) => {
|
|
57615
57615
|
const earlyReject = (error63) => {
|
|
57616
57616
|
reject(error63);
|
|
57617
57617
|
};
|
|
@@ -57680,7 +57680,7 @@ var Protocol = class {
|
|
|
57680
57680
|
}
|
|
57681
57681
|
if (decoded.kind === "invalid") return reject(decoded.error);
|
|
57682
57682
|
if (decoded.kind === "input_required") {
|
|
57683
|
-
if (options?.allowInputRequired === true) return
|
|
57683
|
+
if (options?.allowInputRequired === true) return resolve5(manualInputRequiredValue(decoded));
|
|
57684
57684
|
const flow = {
|
|
57685
57685
|
codec: codec2,
|
|
57686
57686
|
request: request2,
|
|
@@ -57692,11 +57692,11 @@ var Protocol = class {
|
|
|
57692
57692
|
params
|
|
57693
57693
|
}, resultSchema, legOptions)
|
|
57694
57694
|
};
|
|
57695
|
-
return
|
|
57695
|
+
return resolve5(this._resolveNonCompleteResult(decoded, flow));
|
|
57696
57696
|
}
|
|
57697
57697
|
const result = decoded.result;
|
|
57698
57698
|
validateStandardSchema(resultSchema, result).then((parseResult) => {
|
|
57699
|
-
if (parseResult.success)
|
|
57699
|
+
if (parseResult.success) resolve5(parseResult.data);
|
|
57700
57700
|
else reject(new SdkError(SdkErrorCode.InvalidResult, `Invalid result for ${request2.method}: ${parseResult.error}`));
|
|
57701
57701
|
}, reject);
|
|
57702
57702
|
});
|
|
@@ -58453,9 +58453,9 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
58453
58453
|
const rhs = this.rhs === void 0 ? "" : ` = ${this.rhs}`;
|
|
58454
58454
|
return `${varKind} ${this.name}${rhs};` + _n;
|
|
58455
58455
|
}
|
|
58456
|
-
optimizeNames(names,
|
|
58456
|
+
optimizeNames(names, constants3) {
|
|
58457
58457
|
if (!names[this.name.str]) return;
|
|
58458
|
-
if (this.rhs) this.rhs = optimizeExpr(this.rhs, names,
|
|
58458
|
+
if (this.rhs) this.rhs = optimizeExpr(this.rhs, names, constants3);
|
|
58459
58459
|
return this;
|
|
58460
58460
|
}
|
|
58461
58461
|
get names() {
|
|
@@ -58472,9 +58472,9 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
58472
58472
|
render({ _n }) {
|
|
58473
58473
|
return `${this.lhs} = ${this.rhs};` + _n;
|
|
58474
58474
|
}
|
|
58475
|
-
optimizeNames(names,
|
|
58475
|
+
optimizeNames(names, constants3) {
|
|
58476
58476
|
if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects) return;
|
|
58477
|
-
this.rhs = optimizeExpr(this.rhs, names,
|
|
58477
|
+
this.rhs = optimizeExpr(this.rhs, names, constants3);
|
|
58478
58478
|
return this;
|
|
58479
58479
|
}
|
|
58480
58480
|
get names() {
|
|
@@ -58533,8 +58533,8 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
58533
58533
|
optimizeNodes() {
|
|
58534
58534
|
return `${this.code}` ? this : void 0;
|
|
58535
58535
|
}
|
|
58536
|
-
optimizeNames(names,
|
|
58537
|
-
this.code = optimizeExpr(this.code, names,
|
|
58536
|
+
optimizeNames(names, constants3) {
|
|
58537
|
+
this.code = optimizeExpr(this.code, names, constants3);
|
|
58538
58538
|
return this;
|
|
58539
58539
|
}
|
|
58540
58540
|
get names() {
|
|
@@ -58560,12 +58560,12 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
58560
58560
|
}
|
|
58561
58561
|
return nodes.length > 0 ? this : void 0;
|
|
58562
58562
|
}
|
|
58563
|
-
optimizeNames(names,
|
|
58563
|
+
optimizeNames(names, constants3) {
|
|
58564
58564
|
const { nodes } = this;
|
|
58565
58565
|
let i = nodes.length;
|
|
58566
58566
|
while (i--) {
|
|
58567
58567
|
const n = nodes[i];
|
|
58568
|
-
if (n.optimizeNames(names,
|
|
58568
|
+
if (n.optimizeNames(names, constants3)) continue;
|
|
58569
58569
|
subtractNames(names, n.names);
|
|
58570
58570
|
nodes.splice(i, 1);
|
|
58571
58571
|
}
|
|
@@ -58612,11 +58612,11 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
58612
58612
|
if (cond === false || !this.nodes.length) return void 0;
|
|
58613
58613
|
return this;
|
|
58614
58614
|
}
|
|
58615
|
-
optimizeNames(names,
|
|
58615
|
+
optimizeNames(names, constants3) {
|
|
58616
58616
|
var _a3;
|
|
58617
|
-
this.else = (_a3 = this.else) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names,
|
|
58618
|
-
if (!(super.optimizeNames(names,
|
|
58619
|
-
this.condition = optimizeExpr(this.condition, names,
|
|
58617
|
+
this.else = (_a3 = this.else) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants3);
|
|
58618
|
+
if (!(super.optimizeNames(names, constants3) || this.else)) return;
|
|
58619
|
+
this.condition = optimizeExpr(this.condition, names, constants3);
|
|
58620
58620
|
return this;
|
|
58621
58621
|
}
|
|
58622
58622
|
get names() {
|
|
@@ -58638,9 +58638,9 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
58638
58638
|
render(opts) {
|
|
58639
58639
|
return `for(${this.iteration})` + super.render(opts);
|
|
58640
58640
|
}
|
|
58641
|
-
optimizeNames(names,
|
|
58642
|
-
if (!super.optimizeNames(names,
|
|
58643
|
-
this.iteration = optimizeExpr(this.iteration, names,
|
|
58641
|
+
optimizeNames(names, constants3) {
|
|
58642
|
+
if (!super.optimizeNames(names, constants3)) return;
|
|
58643
|
+
this.iteration = optimizeExpr(this.iteration, names, constants3);
|
|
58644
58644
|
return this;
|
|
58645
58645
|
}
|
|
58646
58646
|
get names() {
|
|
@@ -58675,9 +58675,9 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
58675
58675
|
render(opts) {
|
|
58676
58676
|
return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
|
|
58677
58677
|
}
|
|
58678
|
-
optimizeNames(names,
|
|
58679
|
-
if (!super.optimizeNames(names,
|
|
58680
|
-
this.iterable = optimizeExpr(this.iterable, names,
|
|
58678
|
+
optimizeNames(names, constants3) {
|
|
58679
|
+
if (!super.optimizeNames(names, constants3)) return;
|
|
58680
|
+
this.iterable = optimizeExpr(this.iterable, names, constants3);
|
|
58681
58681
|
return this;
|
|
58682
58682
|
}
|
|
58683
58683
|
get names() {
|
|
@@ -58716,11 +58716,11 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
58716
58716
|
(_b = this.finally) === null || _b === void 0 || _b.optimizeNodes();
|
|
58717
58717
|
return this;
|
|
58718
58718
|
}
|
|
58719
|
-
optimizeNames(names,
|
|
58719
|
+
optimizeNames(names, constants3) {
|
|
58720
58720
|
var _a3, _b;
|
|
58721
|
-
super.optimizeNames(names,
|
|
58722
|
-
(_a3 = this.catch) === null || _a3 === void 0 || _a3.optimizeNames(names,
|
|
58723
|
-
(_b = this.finally) === null || _b === void 0 || _b.optimizeNames(names,
|
|
58721
|
+
super.optimizeNames(names, constants3);
|
|
58722
|
+
(_a3 = this.catch) === null || _a3 === void 0 || _a3.optimizeNames(names, constants3);
|
|
58723
|
+
(_b = this.finally) === null || _b === void 0 || _b.optimizeNames(names, constants3);
|
|
58724
58724
|
return this;
|
|
58725
58725
|
}
|
|
58726
58726
|
get names() {
|
|
@@ -58969,7 +58969,7 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
58969
58969
|
function addExprNames(names, from) {
|
|
58970
58970
|
return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names;
|
|
58971
58971
|
}
|
|
58972
|
-
function optimizeExpr(expr, names,
|
|
58972
|
+
function optimizeExpr(expr, names, constants3) {
|
|
58973
58973
|
if (expr instanceof code_1.Name) return replaceName(expr);
|
|
58974
58974
|
if (!canOptimize(expr)) return expr;
|
|
58975
58975
|
return new code_1._Code(expr._items.reduce((items, c) => {
|
|
@@ -58979,13 +58979,13 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
58979
58979
|
return items;
|
|
58980
58980
|
}, []));
|
|
58981
58981
|
function replaceName(n) {
|
|
58982
|
-
const c =
|
|
58982
|
+
const c = constants3[n.str];
|
|
58983
58983
|
if (c === void 0 || names[n.str] !== 1) return n;
|
|
58984
58984
|
delete names[n.str];
|
|
58985
58985
|
return c;
|
|
58986
58986
|
}
|
|
58987
58987
|
function canOptimize(e) {
|
|
58988
|
-
return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 &&
|
|
58988
|
+
return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants3[c.str] !== void 0);
|
|
58989
58989
|
}
|
|
58990
58990
|
}
|
|
58991
58991
|
function subtractNames(names, from) {
|
|
@@ -60645,7 +60645,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
60645
60645
|
ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref);
|
|
60646
60646
|
const schOrFunc = root.refs[ref];
|
|
60647
60647
|
if (schOrFunc) return schOrFunc;
|
|
60648
|
-
let _sch =
|
|
60648
|
+
let _sch = resolve5.call(this, root, ref);
|
|
60649
60649
|
if (_sch === void 0) {
|
|
60650
60650
|
const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
|
|
60651
60651
|
const { schemaId } = this.opts;
|
|
@@ -60671,7 +60671,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
60671
60671
|
function sameSchemaEnv(s1, s2) {
|
|
60672
60672
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
60673
60673
|
}
|
|
60674
|
-
function
|
|
60674
|
+
function resolve5(root, ref) {
|
|
60675
60675
|
let sch;
|
|
60676
60676
|
while (typeof (sch = this.refs[ref]) == "string") ref = sch;
|
|
60677
60677
|
return sch || this.schemas[ref] || resolveSchema.call(this, root, ref);
|
|
@@ -60753,7 +60753,7 @@ var require_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
60753
60753
|
}));
|
|
60754
60754
|
var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
60755
60755
|
const isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
|
|
60756
|
-
const
|
|
60756
|
+
const isIPv46 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
|
|
60757
60757
|
const isPort = RegExp.prototype.test.bind(/^\d*$/u);
|
|
60758
60758
|
const isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
|
|
60759
60759
|
const isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
|
|
@@ -60840,7 +60840,7 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
60840
60840
|
const part = parts[i];
|
|
60841
60841
|
if (part === "") return void 0;
|
|
60842
60842
|
if (part.indexOf(".") !== -1) {
|
|
60843
|
-
if (i !== parts.length - 1 || compression !== -1 && right.length === 0 || !
|
|
60843
|
+
if (i !== parts.length - 1 || compression !== -1 && right.length === 0 || !isIPv46(part)) return void 0;
|
|
60844
60844
|
hextetCount += 2;
|
|
60845
60845
|
continue;
|
|
60846
60846
|
}
|
|
@@ -61165,7 +61165,7 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
61165
61165
|
}
|
|
61166
61166
|
if (component.host !== void 0) {
|
|
61167
61167
|
let host = component.host;
|
|
61168
|
-
if (!
|
|
61168
|
+
if (!isIPv46(host)) {
|
|
61169
61169
|
let ipV6res = normalizeIPv6(host);
|
|
61170
61170
|
if (ipV6res.isIPV6 !== true && ipV6res.isIPVFuture !== true) {
|
|
61171
61171
|
host = normalizePercentEncoding(host, true);
|
|
@@ -61197,7 +61197,7 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
61197
61197
|
encodeFragment,
|
|
61198
61198
|
escapePreservingEscapes,
|
|
61199
61199
|
removeDotSegments,
|
|
61200
|
-
isIPv4:
|
|
61200
|
+
isIPv4: isIPv46,
|
|
61201
61201
|
isUUID,
|
|
61202
61202
|
normalizeIPv6,
|
|
61203
61203
|
stringArrayToHexStripped
|
|
@@ -61352,7 +61352,7 @@ var require_schemes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
61352
61352
|
};
|
|
61353
61353
|
}));
|
|
61354
61354
|
var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
61355
|
-
const { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4:
|
|
61355
|
+
const { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4: isIPv46, nonSimpleDomain } = require_utils();
|
|
61356
61356
|
const { SCHEMES, getSchemeHandler } = require_schemes();
|
|
61357
61357
|
const VALID_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/u;
|
|
61358
61358
|
const MALFORMED_SCHEME_ERROR = "URI scheme is malformed.";
|
|
@@ -61366,7 +61366,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
61366
61366
|
else if (typeof uri === "object") uri = parse3(serialize(uri, options), options);
|
|
61367
61367
|
return uri;
|
|
61368
61368
|
}
|
|
61369
|
-
function
|
|
61369
|
+
function resolve5(baseURI, relativeURI, options) {
|
|
61370
61370
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
61371
61371
|
const { parsed: baseParsed, malformedAuthorityOrPort: baseMalformed, malformedPercentEncoding: baseMalformedPercentEncoding, malformedSchemeSpecific: baseMalformedSchemeSpecific, malformedHost: baseMalformedHost, malformedScheme: baseMalformedScheme } = parseWithStatus(baseURI, schemelessOptions);
|
|
61372
61372
|
const { parsed: relativeParsed, malformedAuthorityOrPort: relativeMalformed, malformedPercentEncoding: relativeMalformedPercentEncoding, malformedSchemeSpecific: relativeMalformedSchemeSpecific, malformedHost: relativeMalformedHost, malformedScheme: relativeMalformedScheme } = parseWithStatus(relativeURI, schemelessOptions);
|
|
@@ -61374,7 +61374,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
61374
61374
|
const resolved = resolveComponent(baseParsed, relativeParsed, schemelessOptions, true);
|
|
61375
61375
|
const resolvedSchemeHandler = getSchemeHandler(options && options.scheme || resolved.scheme);
|
|
61376
61376
|
const resolvedHost = resolved.host;
|
|
61377
|
-
const resolvedHostIsIP = resolvedHost !== void 0 && resolvedHost !== "" && (
|
|
61377
|
+
const resolvedHostIsIP = resolvedHost !== void 0 && resolvedHost !== "" && (isIPv46(resolvedHost) || normalizeIPv6(resolvedHost).isIPV6);
|
|
61378
61378
|
canonicalizeHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP);
|
|
61379
61379
|
const encodedASCIIHost = resolvedHost && resolvedHost.indexOf("%") !== -1 && !new RegExp("\\P{ASCII}", "u").test(resolvedHost);
|
|
61380
61380
|
if (resolved.error && !encodedASCIIHost) throw new Error(resolved.error);
|
|
@@ -61574,7 +61574,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
61574
61574
|
parsed.error = parsed.error || parseError;
|
|
61575
61575
|
malformedAuthorityOrPort = true;
|
|
61576
61576
|
}
|
|
61577
|
-
if (parsed.host) if (
|
|
61577
|
+
if (parsed.host) if (isIPv46(parsed.host) === false) {
|
|
61578
61578
|
const bracketedIPLiteral = isIPLiteral(parsed.host);
|
|
61579
61579
|
const hasIPLiteralBracket = parsed.host.indexOf("[") !== -1 || parsed.host.indexOf("]") !== -1;
|
|
61580
61580
|
const ipv6result = normalizeIPv6(parsed.host);
|
|
@@ -61648,7 +61648,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
61648
61648
|
const fastUri = {
|
|
61649
61649
|
SCHEMES,
|
|
61650
61650
|
normalize,
|
|
61651
|
-
resolve:
|
|
61651
|
+
resolve: resolve5,
|
|
61652
61652
|
resolveComponent,
|
|
61653
61653
|
equal,
|
|
61654
61654
|
serialize,
|
|
@@ -65519,15 +65519,15 @@ var PerRequestHTTPServerTransport = class {
|
|
|
65519
65519
|
};
|
|
65520
65520
|
if (isJSONRPCRequest(message)) {
|
|
65521
65521
|
this._requestId = message.id;
|
|
65522
|
-
let
|
|
65522
|
+
let resolve5;
|
|
65523
65523
|
let reject;
|
|
65524
65524
|
const promise2 = new Promise((promiseResolve, promiseReject) => {
|
|
65525
|
-
|
|
65525
|
+
resolve5 = promiseResolve;
|
|
65526
65526
|
reject = promiseReject;
|
|
65527
65527
|
});
|
|
65528
65528
|
this._deferredResponse = {
|
|
65529
65529
|
promise: promise2,
|
|
65530
|
-
resolve:
|
|
65530
|
+
resolve: resolve5,
|
|
65531
65531
|
reject,
|
|
65532
65532
|
settled: false
|
|
65533
65533
|
};
|
|
@@ -65738,9 +65738,9 @@ function validateScopeChallenge(challenge) {
|
|
|
65738
65738
|
if (challenge.errorDescription !== void 0 && !/^[\u0020-\u0021\u0023-\u005B\u005D-\u007E]+$/.test(challenge.errorDescription)) throw new TypeError("scope challenge errorDescription must satisfy the RFC 6750 error-description grammar");
|
|
65739
65739
|
return challenge;
|
|
65740
65740
|
}
|
|
65741
|
-
async function findScopeChallenge(requests, authInfo,
|
|
65741
|
+
async function findScopeChallenge(requests, authInfo, resolve5) {
|
|
65742
65742
|
for (const request2 of requests) {
|
|
65743
|
-
const challenge = await
|
|
65743
|
+
const challenge = await resolve5({
|
|
65744
65744
|
request: request2,
|
|
65745
65745
|
...authInfo !== void 0 && { authInfo }
|
|
65746
65746
|
});
|
|
@@ -67252,7 +67252,7 @@ var StdioServerTransport = class {
|
|
|
67252
67252
|
}
|
|
67253
67253
|
send(message) {
|
|
67254
67254
|
if (this._closed) return Promise.reject(/* @__PURE__ */ new Error("StdioServerTransport is closed"));
|
|
67255
|
-
return new Promise((
|
|
67255
|
+
return new Promise((resolve5, reject) => {
|
|
67256
67256
|
const json4 = serializeMessage(message);
|
|
67257
67257
|
let settled = false;
|
|
67258
67258
|
const onError = (error63) => {
|
|
@@ -67267,14 +67267,14 @@ var StdioServerTransport = class {
|
|
|
67267
67267
|
settled = true;
|
|
67268
67268
|
this._stdout.off("error", onError);
|
|
67269
67269
|
this._stdout.off("drain", onDrain);
|
|
67270
|
-
|
|
67270
|
+
resolve5();
|
|
67271
67271
|
};
|
|
67272
67272
|
this._stdout.once("error", onError);
|
|
67273
67273
|
if (this._stdout.write(json4)) {
|
|
67274
67274
|
if (settled) return;
|
|
67275
67275
|
settled = true;
|
|
67276
67276
|
this._stdout.off("error", onError);
|
|
67277
|
-
|
|
67277
|
+
resolve5();
|
|
67278
67278
|
} else if (!settled) this._stdout.once("drain", onDrain);
|
|
67279
67279
|
});
|
|
67280
67280
|
}
|
|
@@ -67311,14 +67311,14 @@ var AdminPromptHelper = class _AdminPromptHelper {
|
|
|
67311
67311
|
const child2 = this.child;
|
|
67312
67312
|
if (!child2?.stdin || this.problem)
|
|
67313
67313
|
return Promise.reject(new Error(this.problem ?? "the prompt helper is not running"));
|
|
67314
|
-
return new Promise((
|
|
67314
|
+
return new Promise((resolve5, reject) => {
|
|
67315
67315
|
const timer = setTimeout(() => {
|
|
67316
67316
|
this.waiting.delete(id);
|
|
67317
67317
|
reject(new Error("the prompt helper did not answer in time"));
|
|
67318
67318
|
}, ANSWER_TIMEOUT_MS);
|
|
67319
67319
|
timer.unref();
|
|
67320
67320
|
this.waiting.set(id, {
|
|
67321
|
-
resolve: () => (clearTimeout(timer),
|
|
67321
|
+
resolve: () => (clearTimeout(timer), resolve5()),
|
|
67322
67322
|
reject: (error63) => (clearTimeout(timer), reject(error63))
|
|
67323
67323
|
});
|
|
67324
67324
|
child2.stdin.write(`${JSON.stringify({ id, answer })}
|
|
@@ -67438,14 +67438,1135 @@ function fileAuditSink(path) {
|
|
|
67438
67438
|
};
|
|
67439
67439
|
}
|
|
67440
67440
|
|
|
67441
|
-
// src/command
|
|
67441
|
+
// src/browser/command.ts
|
|
67442
|
+
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
67443
|
+
|
|
67444
|
+
// src/browser/close.ts
|
|
67445
|
+
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
67446
|
+
|
|
67447
|
+
// src/linux/x11.ts
|
|
67448
|
+
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
67449
|
+
import { readFileSync } from "node:fs";
|
|
67450
|
+
import { createConnection } from "node:net";
|
|
67451
|
+
import { homedir, hostname as hostname3 } from "node:os";
|
|
67452
|
+
import { join } from "node:path";
|
|
67453
|
+
function parseDisplay(display) {
|
|
67454
|
+
const match = /^([^:]*):(\d+)(?:\.\d+)?$/.exec(display ?? "");
|
|
67455
|
+
if (!match) return void 0;
|
|
67456
|
+
const host = match[1] ?? "";
|
|
67457
|
+
const number4 = Number(match[2]);
|
|
67458
|
+
if (host === "" || host === "unix") return { path: `/tmp/.X11-unix/X${number4}`, number: number4 };
|
|
67459
|
+
return { host, port: 6e3 + number4, number: number4 };
|
|
67460
|
+
}
|
|
67461
|
+
var FAMILY_LOCAL = 256;
|
|
67462
|
+
var FAMILY_WILD = 65535;
|
|
67463
|
+
var COOKIE = "MIT-MAGIC-COOKIE-1";
|
|
67464
|
+
function xauthCookie(file2, number4, host = hostname3()) {
|
|
67465
|
+
let offset = 0;
|
|
67466
|
+
let fallback;
|
|
67467
|
+
const field = () => {
|
|
67468
|
+
const length = file2.readUInt16BE(offset);
|
|
67469
|
+
const value = file2.subarray(offset + 2, offset + 2 + length);
|
|
67470
|
+
offset += 2 + length;
|
|
67471
|
+
return value;
|
|
67472
|
+
};
|
|
67473
|
+
try {
|
|
67474
|
+
while (offset < file2.length) {
|
|
67475
|
+
const family = file2.readUInt16BE(offset);
|
|
67476
|
+
offset += 2;
|
|
67477
|
+
const address = field().toString("latin1");
|
|
67478
|
+
const display = field().toString("latin1");
|
|
67479
|
+
const name = field().toString("latin1");
|
|
67480
|
+
const data = field();
|
|
67481
|
+
if (name !== COOKIE || display !== "" && display !== String(number4)) continue;
|
|
67482
|
+
if (family === FAMILY_WILD || family === FAMILY_LOCAL && address === host) return Buffer.from(data);
|
|
67483
|
+
fallback ??= Buffer.from(data);
|
|
67484
|
+
}
|
|
67485
|
+
} catch {
|
|
67486
|
+
}
|
|
67487
|
+
return fallback;
|
|
67488
|
+
}
|
|
67489
|
+
var pad4 = (n) => (4 - n % 4) % 4;
|
|
67490
|
+
var X11Error = class extends Error {
|
|
67491
|
+
constructor(code, sequence) {
|
|
67492
|
+
super(`X11 error ${code} (request ${sequence})`);
|
|
67493
|
+
this.code = code;
|
|
67494
|
+
this.sequence = sequence;
|
|
67495
|
+
this.name = "X11Error";
|
|
67496
|
+
}
|
|
67497
|
+
code;
|
|
67498
|
+
sequence;
|
|
67499
|
+
};
|
|
67500
|
+
var X11Connection = class _X11Connection {
|
|
67501
|
+
constructor(socket, setup2) {
|
|
67502
|
+
this.socket = socket;
|
|
67503
|
+
this.setup = setup2;
|
|
67504
|
+
socket.on("data", (chunk) => this.receive(chunk));
|
|
67505
|
+
socket.on("error", (error63) => this.close(error63));
|
|
67506
|
+
socket.on("close", () => this.close());
|
|
67507
|
+
}
|
|
67508
|
+
socket;
|
|
67509
|
+
setup;
|
|
67510
|
+
buffer = Buffer.alloc(0);
|
|
67511
|
+
sequence = 0;
|
|
67512
|
+
pending = /* @__PURE__ */ new Map();
|
|
67513
|
+
errors = /* @__PURE__ */ new Map();
|
|
67514
|
+
closed = false;
|
|
67515
|
+
onEvent = () => void 0;
|
|
67516
|
+
onClose = () => void 0;
|
|
67517
|
+
static async connect(options = {}) {
|
|
67518
|
+
const address = parseDisplay(options.display ?? process.env.DISPLAY);
|
|
67519
|
+
if (!address) throw new Error("DISPLAY is not set to an X11 display");
|
|
67520
|
+
const authFile = options.xauthority ?? process.env.XAUTHORITY ?? join(homedir(), ".Xauthority");
|
|
67521
|
+
let cookie;
|
|
67522
|
+
try {
|
|
67523
|
+
cookie = xauthCookie(readFileSync(authFile), address.number);
|
|
67524
|
+
} catch {
|
|
67525
|
+
}
|
|
67526
|
+
const socket = options.socketPath ? createConnection(options.socketPath) : "path" in address ? createConnection(address.path) : createConnection(address.port, address.host);
|
|
67527
|
+
socket.setNoDelay(true);
|
|
67528
|
+
const timeoutMs = options.timeoutMs ?? 5e3;
|
|
67529
|
+
const setup2 = await new Promise((resolve5, reject) => {
|
|
67530
|
+
let data = Buffer.alloc(0);
|
|
67531
|
+
const timer = setTimeout(() => fail(new Error("X11 connection setup timed out")), timeoutMs);
|
|
67532
|
+
const fail = (error63) => {
|
|
67533
|
+
clearTimeout(timer);
|
|
67534
|
+
socket.off("data", onData);
|
|
67535
|
+
socket.destroy();
|
|
67536
|
+
reject(error63);
|
|
67537
|
+
};
|
|
67538
|
+
const onData = (chunk) => {
|
|
67539
|
+
data = Buffer.concat([data, chunk]);
|
|
67540
|
+
if (data.length < 8) return;
|
|
67541
|
+
const total = 8 + data.readUInt16LE(6) * 4;
|
|
67542
|
+
if (data.length < total) return;
|
|
67543
|
+
clearTimeout(timer);
|
|
67544
|
+
socket.off("data", onData);
|
|
67545
|
+
socket.off("error", fail);
|
|
67546
|
+
if (data[0] !== 1) {
|
|
67547
|
+
const reason = data.subarray(8, 8 + (data[1] ?? 0)).toString("latin1");
|
|
67548
|
+
socket.destroy();
|
|
67549
|
+
return reject(new Error(`X11 server refused the connection: ${reason || "authorization required"}`));
|
|
67550
|
+
}
|
|
67551
|
+
try {
|
|
67552
|
+
resolve5({ setup: parseSetup(data.subarray(0, total)), rest: data.subarray(total) });
|
|
67553
|
+
} catch (error63) {
|
|
67554
|
+
fail(error63);
|
|
67555
|
+
}
|
|
67556
|
+
};
|
|
67557
|
+
socket.once("error", fail);
|
|
67558
|
+
socket.on("data", onData);
|
|
67559
|
+
socket.write(setupRequest(cookie));
|
|
67560
|
+
});
|
|
67561
|
+
const connection = new _X11Connection(socket, setup2.setup);
|
|
67562
|
+
if (setup2.rest.length) connection.receive(setup2.rest);
|
|
67563
|
+
return connection;
|
|
67564
|
+
}
|
|
67565
|
+
listen(listener) {
|
|
67566
|
+
this.onEvent = listener;
|
|
67567
|
+
}
|
|
67568
|
+
whenClosed(listener) {
|
|
67569
|
+
this.onClose = listener;
|
|
67570
|
+
}
|
|
67571
|
+
/** Sends a request that has a reply and resolves with the whole reply. */
|
|
67572
|
+
request(body) {
|
|
67573
|
+
if (this.closed) return Promise.reject(new Error("X11 connection closed"));
|
|
67574
|
+
const sequence = this.send(body);
|
|
67575
|
+
return new Promise((resolve5, reject) => this.pending.set(sequence, { resolve: resolve5, reject }));
|
|
67576
|
+
}
|
|
67577
|
+
/** Sends a request without a reply; resolves once the server processed it, rejecting with its error. */
|
|
67578
|
+
async checked(body) {
|
|
67579
|
+
const sequence = this.send(body);
|
|
67580
|
+
await this.request(request(43, 0, Buffer.alloc(0)));
|
|
67581
|
+
const error63 = this.errors.get(sequence);
|
|
67582
|
+
this.errors.delete(sequence);
|
|
67583
|
+
if (error63) throw error63;
|
|
67584
|
+
}
|
|
67585
|
+
close(error63) {
|
|
67586
|
+
if (this.closed) return;
|
|
67587
|
+
this.closed = true;
|
|
67588
|
+
this.socket.destroy();
|
|
67589
|
+
for (const pending of this.pending.values()) pending.reject(error63 ?? new Error("X11 connection closed"));
|
|
67590
|
+
this.pending.clear();
|
|
67591
|
+
this.onClose(error63);
|
|
67592
|
+
}
|
|
67593
|
+
send(body) {
|
|
67594
|
+
this.sequence = this.sequence + 1 & 65535;
|
|
67595
|
+
this.socket.write(body);
|
|
67596
|
+
return this.sequence;
|
|
67597
|
+
}
|
|
67598
|
+
receive(chunk) {
|
|
67599
|
+
this.buffer = this.buffer.length ? Buffer.concat([this.buffer, chunk]) : chunk;
|
|
67600
|
+
while (this.buffer.length >= 32) {
|
|
67601
|
+
const kind = this.buffer[0] & 127;
|
|
67602
|
+
const total = kind === 1 || kind === 35 ? 32 + this.buffer.readUInt32LE(4) * 4 : 32;
|
|
67603
|
+
if (this.buffer.length < total) return;
|
|
67604
|
+
const message = this.buffer.subarray(0, total);
|
|
67605
|
+
this.buffer = this.buffer.subarray(total);
|
|
67606
|
+
this.dispatch(kind, message);
|
|
67607
|
+
}
|
|
67608
|
+
}
|
|
67609
|
+
dispatch(kind, message) {
|
|
67610
|
+
const sequence = message.readUInt16LE(2);
|
|
67611
|
+
if (kind === 1 || kind === 0) {
|
|
67612
|
+
const pending = this.pending.get(sequence);
|
|
67613
|
+
if (pending) {
|
|
67614
|
+
this.pending.delete(sequence);
|
|
67615
|
+
if (kind === 1) pending.resolve(Buffer.from(message));
|
|
67616
|
+
else pending.reject(new X11Error(message[1], sequence));
|
|
67617
|
+
return;
|
|
67618
|
+
}
|
|
67619
|
+
if (kind === 0) {
|
|
67620
|
+
this.errors.set(sequence, new X11Error(message[1], sequence));
|
|
67621
|
+
if (this.errors.size > 64) this.errors.delete(this.errors.keys().next().value);
|
|
67622
|
+
}
|
|
67623
|
+
return;
|
|
67624
|
+
}
|
|
67625
|
+
this.onEvent(Buffer.from(message));
|
|
67626
|
+
}
|
|
67627
|
+
};
|
|
67628
|
+
function setupRequest(cookie) {
|
|
67629
|
+
const name = cookie ? Buffer.from(COOKIE, "latin1") : Buffer.alloc(0);
|
|
67630
|
+
const data = cookie ?? Buffer.alloc(0);
|
|
67631
|
+
const out = Buffer.alloc(12 + name.length + pad4(name.length) + data.length + pad4(data.length));
|
|
67632
|
+
out.write("l", 0, "latin1");
|
|
67633
|
+
out.writeUInt16LE(11, 2);
|
|
67634
|
+
out.writeUInt16LE(0, 4);
|
|
67635
|
+
out.writeUInt16LE(name.length, 6);
|
|
67636
|
+
out.writeUInt16LE(data.length, 8);
|
|
67637
|
+
name.copy(out, 12);
|
|
67638
|
+
data.copy(out, 12 + name.length + pad4(name.length));
|
|
67639
|
+
return out;
|
|
67640
|
+
}
|
|
67641
|
+
function parseSetup(reply2) {
|
|
67642
|
+
const vendorLength = reply2.readUInt16LE(24);
|
|
67643
|
+
const formats = reply2[29];
|
|
67644
|
+
const minKeycode = reply2[34];
|
|
67645
|
+
const maxKeycode = reply2[35];
|
|
67646
|
+
const screens = 40 + vendorLength + pad4(vendorLength) + formats * 8;
|
|
67647
|
+
if (reply2.length < screens + 4) throw new Error("X11 setup reply has no screen");
|
|
67648
|
+
return { root: reply2.readUInt32LE(screens), minKeycode, maxKeycode };
|
|
67649
|
+
}
|
|
67650
|
+
function request(opcode, minor, body) {
|
|
67651
|
+
const out = Buffer.alloc(4 + body.length + pad4(body.length));
|
|
67652
|
+
out[0] = opcode;
|
|
67653
|
+
out[1] = minor;
|
|
67654
|
+
out.writeUInt16LE(out.length / 4, 2);
|
|
67655
|
+
body.copy(out, 4);
|
|
67656
|
+
return out;
|
|
67657
|
+
}
|
|
67658
|
+
var OP_GRAB_KEY = 33;
|
|
67659
|
+
var OP_UNGRAB_KEY = 34;
|
|
67660
|
+
var OP_QUERY_EXTENSION = 98;
|
|
67661
|
+
var OP_GET_KEYBOARD_MAPPING = 101;
|
|
67662
|
+
var OP_GET_MODIFIER_MAPPING = 119;
|
|
67663
|
+
async function queryExtension(x, name) {
|
|
67664
|
+
const bytes = Buffer.from(name, "latin1");
|
|
67665
|
+
const body = Buffer.alloc(4 + bytes.length);
|
|
67666
|
+
body.writeUInt16LE(bytes.length, 0);
|
|
67667
|
+
bytes.copy(body, 4);
|
|
67668
|
+
const reply2 = await x.request(request(OP_QUERY_EXTENSION, 0, body));
|
|
67669
|
+
return reply2[8] ? reply2[9] : void 0;
|
|
67670
|
+
}
|
|
67671
|
+
|
|
67672
|
+
// src/browser/launcher.ts
|
|
67442
67673
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
67443
67674
|
import { spawn as spawn2 } from "node:child_process";
|
|
67675
|
+
import {
|
|
67676
|
+
accessSync,
|
|
67677
|
+
closeSync,
|
|
67678
|
+
constants,
|
|
67679
|
+
cpSync as cpSync2,
|
|
67680
|
+
existsSync as existsSync3,
|
|
67681
|
+
mkdirSync as mkdirSync3,
|
|
67682
|
+
openSync,
|
|
67683
|
+
readlinkSync,
|
|
67684
|
+
realpathSync as realpathSync2,
|
|
67685
|
+
rmSync as rmSync3,
|
|
67686
|
+
statSync as statSync2
|
|
67687
|
+
} from "node:fs";
|
|
67688
|
+
import { hostname as hostname4 } from "node:os";
|
|
67689
|
+
import { basename as basename2, delimiter, dirname as dirname2, join as join4, resolve } from "node:path";
|
|
67690
|
+
|
|
67691
|
+
// src/browser/profile-merge.ts
|
|
67692
|
+
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
67693
|
+
import {
|
|
67694
|
+
cpSync,
|
|
67695
|
+
existsSync as existsSync2,
|
|
67696
|
+
mkdtempSync,
|
|
67697
|
+
readFileSync as readFileSync3,
|
|
67698
|
+
readdirSync as readdirSync2,
|
|
67699
|
+
realpathSync,
|
|
67700
|
+
rmSync as rmSync2,
|
|
67701
|
+
statSync,
|
|
67702
|
+
writeFileSync as writeFileSync2
|
|
67703
|
+
} from "node:fs";
|
|
67704
|
+
import { tmpdir } from "node:os";
|
|
67705
|
+
import { basename, join as join3 } from "node:path";
|
|
67706
|
+
|
|
67707
|
+
// src/browser/leveldb.ts
|
|
67708
|
+
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
67709
|
+
import { existsSync, mkdirSync as mkdirSync2, readdirSync, readFileSync as readFileSync2, rmSync, writeFileSync } from "node:fs";
|
|
67710
|
+
import { join as join2 } from "node:path";
|
|
67711
|
+
var BLOCK_SIZE = 32 * 1024;
|
|
67712
|
+
var HEADER_SIZE = 7;
|
|
67713
|
+
var FULL = 1;
|
|
67714
|
+
var FIRST = 2;
|
|
67715
|
+
var MIDDLE = 3;
|
|
67716
|
+
var LAST = 4;
|
|
67717
|
+
var TYPE_DELETION = 0;
|
|
67718
|
+
var TYPE_VALUE = 1;
|
|
67719
|
+
var TABLE_MAGIC = 0xdb4775248b80fb57n;
|
|
67720
|
+
var BATCH_LIMIT_BYTES = 1024 * 1024;
|
|
67721
|
+
var CRC_TABLE = (() => {
|
|
67722
|
+
const table = new Uint32Array(256);
|
|
67723
|
+
for (let n = 0; n < 256; n++) {
|
|
67724
|
+
let c = n;
|
|
67725
|
+
for (let k = 0; k < 8; k++) c = c & 1 ? 2197175160 ^ c >>> 1 : c >>> 1;
|
|
67726
|
+
table[n] = c >>> 0;
|
|
67727
|
+
}
|
|
67728
|
+
return table;
|
|
67729
|
+
})();
|
|
67730
|
+
function crc32c(data, initial = 0) {
|
|
67731
|
+
let crc = ~initial >>> 0;
|
|
67732
|
+
for (const byte of data) crc = CRC_TABLE[(crc ^ byte) & 255] ^ crc >>> 8;
|
|
67733
|
+
return ~crc >>> 0;
|
|
67734
|
+
}
|
|
67735
|
+
function maskCrc(crc) {
|
|
67736
|
+
return (crc >>> 15 | crc << 17) + 2726488792 >>> 0;
|
|
67737
|
+
}
|
|
67738
|
+
var Reader = class {
|
|
67739
|
+
constructor(buf, pos = 0) {
|
|
67740
|
+
this.buf = buf;
|
|
67741
|
+
this.pos = pos;
|
|
67742
|
+
}
|
|
67743
|
+
buf;
|
|
67744
|
+
pos;
|
|
67745
|
+
get done() {
|
|
67746
|
+
return this.pos >= this.buf.length;
|
|
67747
|
+
}
|
|
67748
|
+
varint() {
|
|
67749
|
+
let result = 0;
|
|
67750
|
+
let shift = 0;
|
|
67751
|
+
for (; ; ) {
|
|
67752
|
+
if (this.pos >= this.buf.length) throw new Error("leveldb: truncated varint");
|
|
67753
|
+
const byte = this.buf[this.pos++];
|
|
67754
|
+
result += (byte & 127) * 2 ** shift;
|
|
67755
|
+
if (!(byte & 128)) return result;
|
|
67756
|
+
shift += 7;
|
|
67757
|
+
if (shift > 63) throw new Error("leveldb: varint too long");
|
|
67758
|
+
}
|
|
67759
|
+
}
|
|
67760
|
+
bytes(length) {
|
|
67761
|
+
if (this.pos + length > this.buf.length) throw new Error("leveldb: truncated slice");
|
|
67762
|
+
const out = this.buf.subarray(this.pos, this.pos + length);
|
|
67763
|
+
this.pos += length;
|
|
67764
|
+
return out;
|
|
67765
|
+
}
|
|
67766
|
+
slice() {
|
|
67767
|
+
return this.bytes(this.varint());
|
|
67768
|
+
}
|
|
67769
|
+
};
|
|
67770
|
+
function varint(value) {
|
|
67771
|
+
const out = [];
|
|
67772
|
+
let v = value;
|
|
67773
|
+
while (v >= 128) {
|
|
67774
|
+
out.push(v % 128 | 128);
|
|
67775
|
+
v = Math.floor(v / 128);
|
|
67776
|
+
}
|
|
67777
|
+
out.push(v);
|
|
67778
|
+
return Buffer.from(out);
|
|
67779
|
+
}
|
|
67780
|
+
function lengthPrefixed(data) {
|
|
67781
|
+
return Buffer.concat([varint(data.length), data]);
|
|
67782
|
+
}
|
|
67783
|
+
function snappyDecompress(input2) {
|
|
67784
|
+
const reader = new Reader(input2);
|
|
67785
|
+
const length = reader.varint();
|
|
67786
|
+
const out = Buffer.alloc(length);
|
|
67787
|
+
let o = 0;
|
|
67788
|
+
while (!reader.done) {
|
|
67789
|
+
const tag = input2[reader.pos++];
|
|
67790
|
+
const kind = tag & 3;
|
|
67791
|
+
if (kind === 0) {
|
|
67792
|
+
let len2 = tag >>> 2;
|
|
67793
|
+
if (len2 >= 60) {
|
|
67794
|
+
const extra = len2 - 59;
|
|
67795
|
+
len2 = input2.readUIntLE(reader.pos, extra);
|
|
67796
|
+
reader.pos += extra;
|
|
67797
|
+
}
|
|
67798
|
+
len2 += 1;
|
|
67799
|
+
input2.copy(out, o, reader.pos, reader.pos + len2);
|
|
67800
|
+
reader.pos += len2;
|
|
67801
|
+
o += len2;
|
|
67802
|
+
continue;
|
|
67803
|
+
}
|
|
67804
|
+
let len;
|
|
67805
|
+
let offset;
|
|
67806
|
+
if (kind === 1) {
|
|
67807
|
+
len = (tag >>> 2 & 7) + 4;
|
|
67808
|
+
offset = tag >>> 5 << 8 | input2[reader.pos++];
|
|
67809
|
+
} else if (kind === 2) {
|
|
67810
|
+
len = (tag >>> 2) + 1;
|
|
67811
|
+
offset = input2.readUInt16LE(reader.pos);
|
|
67812
|
+
reader.pos += 2;
|
|
67813
|
+
} else {
|
|
67814
|
+
len = (tag >>> 2) + 1;
|
|
67815
|
+
offset = input2.readUInt32LE(reader.pos);
|
|
67816
|
+
reader.pos += 4;
|
|
67817
|
+
}
|
|
67818
|
+
if (offset === 0 || offset > o) throw new Error("leveldb: bad snappy offset");
|
|
67819
|
+
for (let i = 0; i < len; i++, o++) out[o] = out[o - offset];
|
|
67820
|
+
}
|
|
67821
|
+
if (o !== length) throw new Error("leveldb: snappy length mismatch");
|
|
67822
|
+
return out;
|
|
67823
|
+
}
|
|
67824
|
+
function readLogRecords(data) {
|
|
67825
|
+
const records = [];
|
|
67826
|
+
let pending;
|
|
67827
|
+
let pos = 0;
|
|
67828
|
+
while (pos < data.length) {
|
|
67829
|
+
const left = BLOCK_SIZE - pos % BLOCK_SIZE;
|
|
67830
|
+
if (left < HEADER_SIZE) {
|
|
67831
|
+
pos += left;
|
|
67832
|
+
continue;
|
|
67833
|
+
}
|
|
67834
|
+
if (pos + HEADER_SIZE > data.length) break;
|
|
67835
|
+
const length = data.readUInt16LE(pos + 4);
|
|
67836
|
+
const type = data[pos + 6];
|
|
67837
|
+
if (type === 0 && length === 0) {
|
|
67838
|
+
pos += left;
|
|
67839
|
+
continue;
|
|
67840
|
+
}
|
|
67841
|
+
if (pos + HEADER_SIZE + length > data.length) break;
|
|
67842
|
+
const payload = data.subarray(pos + HEADER_SIZE, pos + HEADER_SIZE + length);
|
|
67843
|
+
pos += HEADER_SIZE + length;
|
|
67844
|
+
if (type === FULL) {
|
|
67845
|
+
records.push(Buffer.from(payload));
|
|
67846
|
+
pending = void 0;
|
|
67847
|
+
} else if (type === FIRST) pending = [payload];
|
|
67848
|
+
else if (type === MIDDLE && pending) pending.push(payload);
|
|
67849
|
+
else if (type === LAST && pending) {
|
|
67850
|
+
pending.push(payload);
|
|
67851
|
+
records.push(Buffer.concat(pending));
|
|
67852
|
+
pending = void 0;
|
|
67853
|
+
}
|
|
67854
|
+
}
|
|
67855
|
+
return records;
|
|
67856
|
+
}
|
|
67857
|
+
function writeLogRecords(records) {
|
|
67858
|
+
const chunks = [];
|
|
67859
|
+
let offset = 0;
|
|
67860
|
+
const emit = (type, payload) => {
|
|
67861
|
+
const header = Buffer.alloc(HEADER_SIZE);
|
|
67862
|
+
header.writeUInt32LE(maskCrc(crc32c(payload, crc32c(Buffer.from([type])))), 0);
|
|
67863
|
+
header.writeUInt16LE(payload.length, 4);
|
|
67864
|
+
header[6] = type;
|
|
67865
|
+
chunks.push(header, payload);
|
|
67866
|
+
offset += HEADER_SIZE + payload.length;
|
|
67867
|
+
};
|
|
67868
|
+
for (const record2 of records) {
|
|
67869
|
+
let pos = 0;
|
|
67870
|
+
let first = true;
|
|
67871
|
+
do {
|
|
67872
|
+
let left = BLOCK_SIZE - offset % BLOCK_SIZE;
|
|
67873
|
+
if (left < HEADER_SIZE) {
|
|
67874
|
+
chunks.push(Buffer.alloc(left));
|
|
67875
|
+
offset += left;
|
|
67876
|
+
left = BLOCK_SIZE;
|
|
67877
|
+
}
|
|
67878
|
+
const take = Math.min(left - HEADER_SIZE, record2.length - pos);
|
|
67879
|
+
const end = pos + take === record2.length;
|
|
67880
|
+
emit(first && end ? FULL : first ? FIRST : end ? LAST : MIDDLE, record2.subarray(pos, pos + take));
|
|
67881
|
+
pos += take;
|
|
67882
|
+
first = false;
|
|
67883
|
+
} while (pos < record2.length);
|
|
67884
|
+
}
|
|
67885
|
+
return Buffer.concat(chunks);
|
|
67886
|
+
}
|
|
67887
|
+
function apply(entries2, key, sequence, deleted, value) {
|
|
67888
|
+
const id = key.toString("latin1");
|
|
67889
|
+
const current = entries2.get(id);
|
|
67890
|
+
if (!current || current.sequence < sequence) entries2.set(id, { sequence, deleted, value: Buffer.from(value) });
|
|
67891
|
+
}
|
|
67892
|
+
function applyBatch(entries2, batch) {
|
|
67893
|
+
if (batch.length < 12) return;
|
|
67894
|
+
let sequence = batch.readBigUInt64LE(0);
|
|
67895
|
+
const count = batch.readUInt32LE(8);
|
|
67896
|
+
const reader = new Reader(batch, 12);
|
|
67897
|
+
for (let i = 0; i < count; i++, sequence++) {
|
|
67898
|
+
const type = batch[reader.pos++];
|
|
67899
|
+
if (type === TYPE_VALUE) {
|
|
67900
|
+
const key = reader.slice();
|
|
67901
|
+
apply(entries2, key, sequence, false, reader.slice());
|
|
67902
|
+
} else if (type === TYPE_DELETION) apply(entries2, reader.slice(), sequence, true, Buffer.alloc(0));
|
|
67903
|
+
else throw new Error("leveldb: unknown write batch record");
|
|
67904
|
+
}
|
|
67905
|
+
}
|
|
67906
|
+
function blockEntries(block, each) {
|
|
67907
|
+
if (block.length < 4) return;
|
|
67908
|
+
const restarts = block.readUInt32LE(block.length - 4);
|
|
67909
|
+
const end = block.length - 4 - restarts * 4;
|
|
67910
|
+
const reader = new Reader(block.subarray(0, end));
|
|
67911
|
+
let last = Buffer.alloc(0);
|
|
67912
|
+
while (!reader.done) {
|
|
67913
|
+
const shared = reader.varint();
|
|
67914
|
+
const unshared = reader.varint();
|
|
67915
|
+
const valueLength = reader.varint();
|
|
67916
|
+
const key = Buffer.concat([last.subarray(0, shared), reader.bytes(unshared)]);
|
|
67917
|
+
each(key, reader.bytes(valueLength));
|
|
67918
|
+
last = key;
|
|
67919
|
+
}
|
|
67920
|
+
}
|
|
67921
|
+
function readBlock(file2, handle) {
|
|
67922
|
+
const offset = handle.varint();
|
|
67923
|
+
const size = handle.varint();
|
|
67924
|
+
const contents = file2.subarray(offset, offset + size);
|
|
67925
|
+
const compression = file2[offset + size];
|
|
67926
|
+
if (compression === 0) return contents;
|
|
67927
|
+
if (compression === 1) return snappyDecompress(contents);
|
|
67928
|
+
throw new Error(`leveldb: unsupported block compression ${compression}`);
|
|
67929
|
+
}
|
|
67930
|
+
function readTable(file2, entries2) {
|
|
67931
|
+
if (file2.length < 48) throw new Error("leveldb: table too short");
|
|
67932
|
+
const footer = file2.subarray(file2.length - 48);
|
|
67933
|
+
if (footer.readBigUInt64LE(40) !== TABLE_MAGIC) throw new Error("leveldb: bad table magic");
|
|
67934
|
+
const handles = new Reader(footer);
|
|
67935
|
+
handles.varint();
|
|
67936
|
+
handles.varint();
|
|
67937
|
+
const index = readBlock(file2, handles);
|
|
67938
|
+
blockEntries(index, (_key, handle) => {
|
|
67939
|
+
blockEntries(readBlock(file2, new Reader(handle)), (internal, value) => {
|
|
67940
|
+
const tag = internal.readBigUInt64LE(internal.length - 8);
|
|
67941
|
+
apply(entries2, internal.subarray(0, internal.length - 8), tag >> 8n, Number(tag & 0xffn) === TYPE_DELETION, value);
|
|
67942
|
+
});
|
|
67943
|
+
});
|
|
67944
|
+
}
|
|
67945
|
+
function readManifest(data) {
|
|
67946
|
+
const manifest = { logNumber: 0, prevLogNumber: 0, tables: /* @__PURE__ */ new Set() };
|
|
67947
|
+
for (const record2 of readLogRecords(data)) {
|
|
67948
|
+
const reader = new Reader(record2);
|
|
67949
|
+
while (!reader.done) {
|
|
67950
|
+
const tag = reader.varint();
|
|
67951
|
+
if (tag === 1) reader.slice();
|
|
67952
|
+
else if (tag === 2) manifest.logNumber = reader.varint();
|
|
67953
|
+
else if (tag === 3) reader.varint();
|
|
67954
|
+
else if (tag === 4) reader.varint();
|
|
67955
|
+
else if (tag === 5) {
|
|
67956
|
+
reader.varint();
|
|
67957
|
+
reader.slice();
|
|
67958
|
+
} else if (tag === 6) {
|
|
67959
|
+
reader.varint();
|
|
67960
|
+
manifest.tables.delete(reader.varint());
|
|
67961
|
+
} else if (tag === 7) {
|
|
67962
|
+
reader.varint();
|
|
67963
|
+
manifest.tables.add(reader.varint());
|
|
67964
|
+
reader.varint();
|
|
67965
|
+
reader.slice();
|
|
67966
|
+
reader.slice();
|
|
67967
|
+
} else if (tag === 9) manifest.prevLogNumber = reader.varint();
|
|
67968
|
+
else throw new Error(`leveldb: unknown manifest tag ${tag}`);
|
|
67969
|
+
}
|
|
67970
|
+
}
|
|
67971
|
+
return manifest;
|
|
67972
|
+
}
|
|
67973
|
+
function readLevelDb(dir) {
|
|
67974
|
+
const entries2 = /* @__PURE__ */ new Map();
|
|
67975
|
+
if (!existsSync(join2(dir, "CURRENT"))) return /* @__PURE__ */ new Map();
|
|
67976
|
+
const current = readFileSync2(join2(dir, "CURRENT"), "latin1").trim();
|
|
67977
|
+
const manifest = readManifest(readFileSync2(join2(dir, current)));
|
|
67978
|
+
const files = readdirSync(dir);
|
|
67979
|
+
for (const number4 of manifest.tables) {
|
|
67980
|
+
const name = [`${String(number4).padStart(6, "0")}.ldb`, `${String(number4).padStart(6, "0")}.sst`].find(
|
|
67981
|
+
(n) => files.includes(n)
|
|
67982
|
+
);
|
|
67983
|
+
if (!name) throw new Error(`leveldb: table ${number4} is missing`);
|
|
67984
|
+
readTable(readFileSync2(join2(dir, name)), entries2);
|
|
67985
|
+
}
|
|
67986
|
+
for (const name of files) {
|
|
67987
|
+
const match = /^(\d+)\.log$/.exec(name);
|
|
67988
|
+
if (!match) continue;
|
|
67989
|
+
const number4 = Number(match[1]);
|
|
67990
|
+
if (number4 < manifest.logNumber && number4 !== manifest.prevLogNumber) continue;
|
|
67991
|
+
for (const batch of readLogRecords(readFileSync2(join2(dir, name)))) applyBatch(entries2, batch);
|
|
67992
|
+
}
|
|
67993
|
+
const out = /* @__PURE__ */ new Map();
|
|
67994
|
+
for (const [key, entry] of entries2) if (!entry.deleted) out.set(key, entry.value);
|
|
67995
|
+
return out;
|
|
67996
|
+
}
|
|
67997
|
+
function writeLevelDb(dir, data) {
|
|
67998
|
+
rmSync(dir, { recursive: true, force: true });
|
|
67999
|
+
mkdirSync2(dir, { recursive: true });
|
|
68000
|
+
const batches = [];
|
|
68001
|
+
let sequence = 1n;
|
|
68002
|
+
let records = [];
|
|
68003
|
+
let bytes = 0;
|
|
68004
|
+
const flush = () => {
|
|
68005
|
+
if (!records.length) return;
|
|
68006
|
+
const head = Buffer.alloc(12);
|
|
68007
|
+
head.writeBigUInt64LE(sequence, 0);
|
|
68008
|
+
head.writeUInt32LE(records.length, 8);
|
|
68009
|
+
batches.push(Buffer.concat([head, ...records]));
|
|
68010
|
+
sequence += BigInt(records.length);
|
|
68011
|
+
records = [];
|
|
68012
|
+
bytes = 0;
|
|
68013
|
+
};
|
|
68014
|
+
for (const [key, value] of data) {
|
|
68015
|
+
const record2 = Buffer.concat([
|
|
68016
|
+
Buffer.from([TYPE_VALUE]),
|
|
68017
|
+
lengthPrefixed(Buffer.from(key, "latin1")),
|
|
68018
|
+
lengthPrefixed(value)
|
|
68019
|
+
]);
|
|
68020
|
+
records.push(record2);
|
|
68021
|
+
bytes += record2.length;
|
|
68022
|
+
if (bytes >= BATCH_LIMIT_BYTES) flush();
|
|
68023
|
+
}
|
|
68024
|
+
flush();
|
|
68025
|
+
const edit = Buffer.concat([
|
|
68026
|
+
varint(1),
|
|
68027
|
+
lengthPrefixed(Buffer.from("leveldb.BytewiseComparator", "latin1")),
|
|
68028
|
+
varint(2),
|
|
68029
|
+
varint(3),
|
|
68030
|
+
varint(3),
|
|
68031
|
+
varint(4),
|
|
68032
|
+
varint(4),
|
|
68033
|
+
varint(0)
|
|
68034
|
+
]);
|
|
68035
|
+
writeFileSync(join2(dir, "000003.log"), writeLogRecords(batches));
|
|
68036
|
+
writeFileSync(join2(dir, "MANIFEST-000002"), writeLogRecords([edit]));
|
|
68037
|
+
writeFileSync(join2(dir, "CURRENT"), "MANIFEST-000002\n");
|
|
68038
|
+
}
|
|
68039
|
+
|
|
68040
|
+
// src/browser/profile-merge.ts
|
|
68041
|
+
var BASELINE_FILE = "ac-fork-baseline.json";
|
|
68042
|
+
var CHROME_EPOCH_OFFSET_US = 11644473600000000n;
|
|
68043
|
+
var SNAPSHOT_TRIES = 6;
|
|
68044
|
+
var SNAPSHOT_RETRY_MS = 300;
|
|
68045
|
+
function cookiesPath(profile) {
|
|
68046
|
+
const network = join3(profile, "Default", "Network", "Cookies");
|
|
68047
|
+
return existsSync2(network) ? network : join3(profile, "Default", "Cookies");
|
|
68048
|
+
}
|
|
68049
|
+
var sqlite;
|
|
68050
|
+
function openDb(path) {
|
|
68051
|
+
if (!sqlite) {
|
|
68052
|
+
const emit = process.emitWarning;
|
|
68053
|
+
process.emitWarning = ((warning, ...rest) => {
|
|
68054
|
+
if (!String(warning).includes("SQLite")) emit.call(process, warning, ...rest);
|
|
68055
|
+
});
|
|
68056
|
+
try {
|
|
68057
|
+
sqlite = process.getBuiltinModule("node:sqlite");
|
|
68058
|
+
} finally {
|
|
68059
|
+
process.emitWarning = emit;
|
|
68060
|
+
}
|
|
68061
|
+
}
|
|
68062
|
+
return new sqlite.DatabaseSync(path);
|
|
68063
|
+
}
|
|
68064
|
+
var localStoragePath = (profile) => join3(profile, "Default", "Local Storage", "leveldb");
|
|
68065
|
+
var indexedDbPath = (profile) => join3(profile, "Default", "IndexedDB");
|
|
68066
|
+
async function forkMerge(target, sources, options = {}) {
|
|
68067
|
+
const now = options.now ?? Date.now;
|
|
68068
|
+
const sleep3 = options.sleep ?? ((ms) => new Promise((resolve5) => setTimeout(resolve5, ms)));
|
|
68069
|
+
const baselinePath = join3(target, BASELINE_FILE);
|
|
68070
|
+
const baselines = loadBaselines(baselinePath);
|
|
68071
|
+
const reports = [];
|
|
68072
|
+
for (const source of sources) {
|
|
68073
|
+
const key = realpathSync(source);
|
|
68074
|
+
const previous = baselines.sources[key];
|
|
68075
|
+
const work = mkdtempSync(join3(tmpdir(), "ac-fork-"));
|
|
68076
|
+
try {
|
|
68077
|
+
const snapshot = await takeSnapshot(source, work, sleep3);
|
|
68078
|
+
const next = { cookies: {}, localStorage: {}, indexedDb: {} };
|
|
68079
|
+
const report = {
|
|
68080
|
+
source,
|
|
68081
|
+
firstFork: previous === void 0,
|
|
68082
|
+
cookies: { inserted: 0, updated: 0, kept: 0, expired: 0, deleted: 0 },
|
|
68083
|
+
localStorage: { taken: [], kept: 0 },
|
|
68084
|
+
indexedDb: { taken: [], kept: 0 }
|
|
68085
|
+
};
|
|
68086
|
+
if (snapshot.cookies) {
|
|
68087
|
+
mergeCookies(snapshot.cookies, cookiesPath(target), previous?.cookies, next.cookies, report.cookies, now);
|
|
68088
|
+
}
|
|
68089
|
+
mergeLocalStorage(
|
|
68090
|
+
snapshot.localStorage,
|
|
68091
|
+
localStoragePath(target),
|
|
68092
|
+
previous?.localStorage,
|
|
68093
|
+
next.localStorage,
|
|
68094
|
+
report.localStorage
|
|
68095
|
+
);
|
|
68096
|
+
if (snapshot.indexedDb) {
|
|
68097
|
+
mergeIndexedDb(snapshot.indexedDb, indexedDbPath(target), previous?.indexedDb, next.indexedDb, report.indexedDb);
|
|
68098
|
+
}
|
|
68099
|
+
baselines.sources[key] = next;
|
|
68100
|
+
reports.push(report);
|
|
68101
|
+
} finally {
|
|
68102
|
+
rmSync2(work, { recursive: true, force: true });
|
|
68103
|
+
}
|
|
68104
|
+
}
|
|
68105
|
+
writeFileSync2(baselinePath, JSON.stringify(baselines));
|
|
68106
|
+
return reports;
|
|
68107
|
+
}
|
|
68108
|
+
function loadBaselines(path) {
|
|
68109
|
+
try {
|
|
68110
|
+
const parsed = JSON.parse(readFileSync3(path, "utf8"));
|
|
68111
|
+
if (parsed.version === 1 && parsed.sources && typeof parsed.sources === "object") return parsed;
|
|
68112
|
+
} catch {
|
|
68113
|
+
}
|
|
68114
|
+
return { version: 1, sources: {} };
|
|
68115
|
+
}
|
|
68116
|
+
async function takeSnapshot(source, work, sleep3) {
|
|
68117
|
+
const snapshot = { localStorage: /* @__PURE__ */ new Map() };
|
|
68118
|
+
const cookies = cookiesPath(source);
|
|
68119
|
+
if (existsSync2(cookies)) {
|
|
68120
|
+
snapshot.cookies = join3(work, "Cookies");
|
|
68121
|
+
cpSync(cookies, snapshot.cookies);
|
|
68122
|
+
for (const suffix of ["-journal", "-wal"]) {
|
|
68123
|
+
if (existsSync2(cookies + suffix)) cpSync(cookies + suffix, snapshot.cookies + suffix);
|
|
68124
|
+
}
|
|
68125
|
+
}
|
|
68126
|
+
const localStorage2 = localStoragePath(source);
|
|
68127
|
+
if (existsSync2(localStorage2)) {
|
|
68128
|
+
snapshot.localStorage = await retried(sleep3, () => {
|
|
68129
|
+
const copy = join3(work, "ls");
|
|
68130
|
+
rmSync2(copy, { recursive: true, force: true });
|
|
68131
|
+
cpSync(localStorage2, copy, { recursive: true, filter: (path) => basename(path) !== "LOCK" });
|
|
68132
|
+
return readLevelDb(copy);
|
|
68133
|
+
});
|
|
68134
|
+
}
|
|
68135
|
+
const indexedDb = indexedDbPath(source);
|
|
68136
|
+
if (existsSync2(indexedDb)) {
|
|
68137
|
+
snapshot.indexedDb = join3(work, "idb");
|
|
68138
|
+
await retried(sleep3, () => {
|
|
68139
|
+
rmSync2(snapshot.indexedDb, { recursive: true, force: true });
|
|
68140
|
+
cpSync(indexedDb, snapshot.indexedDb, {
|
|
68141
|
+
recursive: true,
|
|
68142
|
+
preserveTimestamps: true,
|
|
68143
|
+
filter: (path) => basename(path) !== "LOCK"
|
|
68144
|
+
});
|
|
68145
|
+
});
|
|
68146
|
+
}
|
|
68147
|
+
return snapshot;
|
|
68148
|
+
}
|
|
68149
|
+
async function retried(sleep3, attempt) {
|
|
68150
|
+
let last;
|
|
68151
|
+
for (let i = 0; i < SNAPSHOT_TRIES; i++) {
|
|
68152
|
+
try {
|
|
68153
|
+
return attempt();
|
|
68154
|
+
} catch (error63) {
|
|
68155
|
+
last = error63;
|
|
68156
|
+
await sleep3(SNAPSHOT_RETRY_MS);
|
|
68157
|
+
}
|
|
68158
|
+
}
|
|
68159
|
+
throw new Error(`could not snapshot a running profile: ${last.message}`);
|
|
68160
|
+
}
|
|
68161
|
+
var scalar = (value) => typeof value === "bigint" ? value.toString() : value;
|
|
68162
|
+
var bindable = (value) => value instanceof Uint8Array ? Buffer.from(value) : value;
|
|
68163
|
+
function uniqueKey(db) {
|
|
68164
|
+
for (const index of db.prepare("PRAGMA index_list(cookies)").all()) {
|
|
68165
|
+
if (Number(index.unique) !== 1) continue;
|
|
68166
|
+
const name = String(index.name).replaceAll("'", "''");
|
|
68167
|
+
return db.prepare(`PRAGMA index_info('${name}')`).all().map((column) => String(column.name));
|
|
68168
|
+
}
|
|
68169
|
+
throw new Error("the cookies table has no unique index");
|
|
68170
|
+
}
|
|
68171
|
+
function mergeCookies(snapshot, target, previous, next, counts, now) {
|
|
68172
|
+
if (!existsSync2(target)) cpSync(snapshot, target);
|
|
68173
|
+
const source = openDb(snapshot);
|
|
68174
|
+
const db = openDb(target);
|
|
68175
|
+
try {
|
|
68176
|
+
const columns = db.prepare("PRAGMA table_info(cookies)").all().map((column) => String(column.name));
|
|
68177
|
+
const sourceColumns = source.prepare("PRAGMA table_info(cookies)").all().map(
|
|
68178
|
+
(column) => String(column.name)
|
|
68179
|
+
);
|
|
68180
|
+
if (columns.join() !== sourceColumns.join()) throw new Error("the cookie databases have different schemas");
|
|
68181
|
+
const key = uniqueKey(db);
|
|
68182
|
+
const stamp = columns.includes("last_update_utc") ? "last_update_utc" : "creation_utc";
|
|
68183
|
+
const keyOf2 = (row) => JSON.stringify(key.map((column) => scalar(row[column])));
|
|
68184
|
+
const list2 = (database, sql) => {
|
|
68185
|
+
const statement = database.prepare(sql);
|
|
68186
|
+
statement.setReadBigInts(true);
|
|
68187
|
+
return statement.all();
|
|
68188
|
+
};
|
|
68189
|
+
const quoted = columns.map((column) => `"${column}"`).join(",");
|
|
68190
|
+
const mine = /* @__PURE__ */ new Map();
|
|
68191
|
+
for (const row of list2(db, `SELECT rowid AS ac_rowid, ${quoted} FROM cookies`)) {
|
|
68192
|
+
mine.set(keyOf2(row), { rowid: row.ac_rowid, stamp: row[stamp] });
|
|
68193
|
+
}
|
|
68194
|
+
const insert = db.prepare(`INSERT OR REPLACE INTO cookies (${quoted}) VALUES (${columns.map(() => "?").join(",")})`);
|
|
68195
|
+
const remove = db.prepare("DELETE FROM cookies WHERE rowid = ?");
|
|
68196
|
+
const nowUs = BigInt(now()) * 1000n + CHROME_EPOCH_OFFSET_US;
|
|
68197
|
+
db.exec("BEGIN");
|
|
68198
|
+
try {
|
|
68199
|
+
for (const row of list2(source, `SELECT ${quoted} FROM cookies`)) {
|
|
68200
|
+
const id = keyOf2(row);
|
|
68201
|
+
const updated = row[stamp];
|
|
68202
|
+
next[id] = updated.toString();
|
|
68203
|
+
const expires = row.expires_utc;
|
|
68204
|
+
if (Number(row.is_persistent) === 1 && expires > 0n && expires < nowUs) {
|
|
68205
|
+
counts.expired++;
|
|
68206
|
+
continue;
|
|
68207
|
+
}
|
|
68208
|
+
const current = mine.get(id);
|
|
68209
|
+
const changed = previous === void 0 || previous[id] !== updated.toString();
|
|
68210
|
+
if (!changed || current?.stamp === updated) {
|
|
68211
|
+
counts.kept++;
|
|
68212
|
+
continue;
|
|
68213
|
+
}
|
|
68214
|
+
insert.run(...columns.map((column) => bindable(row[column])));
|
|
68215
|
+
counts[current ? "updated" : "inserted"]++;
|
|
68216
|
+
}
|
|
68217
|
+
if (previous) {
|
|
68218
|
+
for (const id of Object.keys(previous)) {
|
|
68219
|
+
if (id in next) continue;
|
|
68220
|
+
const current = mine.get(id);
|
|
68221
|
+
if (current) {
|
|
68222
|
+
remove.run(current.rowid);
|
|
68223
|
+
counts.deleted++;
|
|
68224
|
+
}
|
|
68225
|
+
}
|
|
68226
|
+
}
|
|
68227
|
+
db.exec("COMMIT");
|
|
68228
|
+
} catch (error63) {
|
|
68229
|
+
db.exec("ROLLBACK");
|
|
68230
|
+
throw error63;
|
|
68231
|
+
}
|
|
68232
|
+
} finally {
|
|
68233
|
+
source.close();
|
|
68234
|
+
db.close();
|
|
68235
|
+
}
|
|
68236
|
+
}
|
|
68237
|
+
function lastModified(meta3) {
|
|
68238
|
+
let pos = 0;
|
|
68239
|
+
while (pos < meta3.length) {
|
|
68240
|
+
const tag = meta3[pos++];
|
|
68241
|
+
let value = 0n;
|
|
68242
|
+
let shift = 0n;
|
|
68243
|
+
for (; ; ) {
|
|
68244
|
+
const byte = meta3[pos++];
|
|
68245
|
+
if (byte === void 0) return value.toString();
|
|
68246
|
+
value |= BigInt(byte & 127) << shift;
|
|
68247
|
+
shift += 7n;
|
|
68248
|
+
if (!(byte & 128)) break;
|
|
68249
|
+
}
|
|
68250
|
+
if (tag === 8) return value.toString();
|
|
68251
|
+
}
|
|
68252
|
+
return "0";
|
|
68253
|
+
}
|
|
68254
|
+
function mergeLocalStorage(source, target, previous, next, report) {
|
|
68255
|
+
const merged = readLevelDb(target);
|
|
68256
|
+
let changed = false;
|
|
68257
|
+
if (!merged.has("VERSION") && source.has("VERSION")) {
|
|
68258
|
+
merged.set("VERSION", source.get("VERSION"));
|
|
68259
|
+
changed = true;
|
|
68260
|
+
}
|
|
68261
|
+
for (const [key, meta3] of source) {
|
|
68262
|
+
if (!key.startsWith("META:")) continue;
|
|
68263
|
+
const origin = key.slice("META:".length);
|
|
68264
|
+
const modified = lastModified(meta3);
|
|
68265
|
+
next[origin] = modified;
|
|
68266
|
+
const mine = merged.get(key);
|
|
68267
|
+
if (previous !== void 0 && previous[origin] === modified || mine && mine.equals(meta3)) {
|
|
68268
|
+
report.kept++;
|
|
68269
|
+
continue;
|
|
68270
|
+
}
|
|
68271
|
+
const prefix = `_${origin}\0`;
|
|
68272
|
+
for (const existing of [...merged.keys()]) if (existing.startsWith(prefix)) merged.delete(existing);
|
|
68273
|
+
for (const [entry, value] of source) if (entry.startsWith(prefix)) merged.set(entry, value);
|
|
68274
|
+
merged.set(key, meta3);
|
|
68275
|
+
const access = source.get(`METAACCESS:${origin}`);
|
|
68276
|
+
if (access) merged.set(`METAACCESS:${origin}`, access);
|
|
68277
|
+
report.taken.push(origin);
|
|
68278
|
+
changed = true;
|
|
68279
|
+
}
|
|
68280
|
+
if (changed) writeLevelDb(target, merged);
|
|
68281
|
+
}
|
|
68282
|
+
function newestMtime(dir) {
|
|
68283
|
+
let newest = 0;
|
|
68284
|
+
for (const entry of readdirSync2(dir, { withFileTypes: true, recursive: true })) {
|
|
68285
|
+
if (entry.isFile()) newest = Math.max(newest, statSync(join3(entry.parentPath, entry.name)).mtimeMs);
|
|
68286
|
+
}
|
|
68287
|
+
return newest;
|
|
68288
|
+
}
|
|
68289
|
+
function mergeIndexedDb(snapshot, target, previous, next, report) {
|
|
68290
|
+
for (const name of readdirSync2(snapshot)) {
|
|
68291
|
+
if (!name.endsWith(".indexeddb.leveldb")) continue;
|
|
68292
|
+
const origin = name.slice(0, -".indexeddb.leveldb".length);
|
|
68293
|
+
const modified = newestMtime(join3(snapshot, name));
|
|
68294
|
+
next[origin] = modified;
|
|
68295
|
+
const mine = join3(target, name);
|
|
68296
|
+
if (previous !== void 0 && previous[origin] === modified || existsSync2(mine) && newestMtime(mine) === modified) {
|
|
68297
|
+
report.kept++;
|
|
68298
|
+
continue;
|
|
68299
|
+
}
|
|
68300
|
+
for (const suffix of [".indexeddb.leveldb", ".indexeddb.blob"]) {
|
|
68301
|
+
const to = join3(target, origin + suffix);
|
|
68302
|
+
rmSync2(to, { recursive: true, force: true });
|
|
68303
|
+
const from = join3(snapshot, origin + suffix);
|
|
68304
|
+
if (existsSync2(from)) cpSync(from, to, { recursive: true, preserveTimestamps: true });
|
|
68305
|
+
}
|
|
68306
|
+
report.taken.push(origin);
|
|
68307
|
+
}
|
|
68308
|
+
}
|
|
68309
|
+
|
|
68310
|
+
// src/browser/launcher.ts
|
|
68311
|
+
var BROWSER_NAMES = ["chromium", "chromium-browser", "google-chrome-stable", "google-chrome"];
|
|
68312
|
+
var BASE_FLAGS = ["--no-first-run", "--no-default-browser-check", "--hide-crash-restore-bubble"];
|
|
68313
|
+
var LOCK_STALE_MS = 6e4;
|
|
68314
|
+
var LOCK_WAIT_MS = 3e4;
|
|
68315
|
+
var OWN_WAIT_MS = 2e4;
|
|
68316
|
+
function profileOwner(profile, host = hostname4()) {
|
|
68317
|
+
let target;
|
|
68318
|
+
try {
|
|
68319
|
+
target = readlinkSync(join4(profile, "SingletonLock"));
|
|
68320
|
+
} catch {
|
|
68321
|
+
return void 0;
|
|
68322
|
+
}
|
|
68323
|
+
const match = /^(.*)-(\d+)$/.exec(target);
|
|
68324
|
+
if (!match || match[1] !== host) return void 0;
|
|
68325
|
+
const pid = Number(match[2]);
|
|
68326
|
+
try {
|
|
68327
|
+
process.kill(pid, 0);
|
|
68328
|
+
return pid;
|
|
68329
|
+
} catch (error63) {
|
|
68330
|
+
return error63.code === "EPERM" ? pid : void 0;
|
|
68331
|
+
}
|
|
68332
|
+
}
|
|
68333
|
+
function seedable(path) {
|
|
68334
|
+
const name = basename2(path);
|
|
68335
|
+
return !(name.startsWith("Singleton") || /cache$/i.test(name) || name === "Crash Reports" || name === "Sessions" || name === "Session Storage" || name === BASELINE_FILE);
|
|
68336
|
+
}
|
|
68337
|
+
function seedProfile(master, profile) {
|
|
68338
|
+
mkdirSync3(dirname2(profile), { recursive: true });
|
|
68339
|
+
cpSync2(master, profile, { recursive: true, preserveTimestamps: true, filter: seedable });
|
|
68340
|
+
}
|
|
68341
|
+
function findBrowser(path = process.env.PATH ?? "", skip = []) {
|
|
68342
|
+
const skipped = new Set(skip.map((dir) => resolve(dir)));
|
|
68343
|
+
for (const name of BROWSER_NAMES) {
|
|
68344
|
+
for (const dir of path.split(delimiter)) {
|
|
68345
|
+
if (!dir || skipped.has(resolve(dir))) continue;
|
|
68346
|
+
const candidate = join4(dir, name);
|
|
68347
|
+
try {
|
|
68348
|
+
accessSync(candidate, constants.X_OK);
|
|
68349
|
+
if (statSync2(candidate).isFile()) return candidate;
|
|
68350
|
+
} catch {
|
|
68351
|
+
}
|
|
68352
|
+
}
|
|
68353
|
+
}
|
|
68354
|
+
return void 0;
|
|
68355
|
+
}
|
|
68356
|
+
async function launchBrowser(options) {
|
|
68357
|
+
const log40 = options.log ?? (() => void 0);
|
|
68358
|
+
const release3 = await lockProfile(options.profile);
|
|
68359
|
+
try {
|
|
68360
|
+
if (profileOwner(options.profile) !== void 0) {
|
|
68361
|
+
start(options).unref();
|
|
68362
|
+
return { handedOff: true, reports: [] };
|
|
68363
|
+
}
|
|
68364
|
+
if (!existsSync3(options.profile)) {
|
|
68365
|
+
if (options.master && existsSync3(options.master)) {
|
|
68366
|
+
seedProfile(options.master, options.profile);
|
|
68367
|
+
log40(`browser profile ${options.profile} created from ${options.master}`);
|
|
68368
|
+
} else mkdirSync3(options.profile, { recursive: true });
|
|
68369
|
+
}
|
|
68370
|
+
for (const name of ["SingletonLock", "SingletonCookie", "SingletonSocket"]) {
|
|
68371
|
+
rmSync3(join4(options.profile, name), { force: true });
|
|
68372
|
+
}
|
|
68373
|
+
const self2 = realpathSync2(options.profile);
|
|
68374
|
+
const sources = options.sources.filter(
|
|
68375
|
+
(source) => existsSync3(join4(source, "Default")) && realpathSync2(source) !== self2
|
|
68376
|
+
);
|
|
68377
|
+
const reports = await forkMerge(options.profile, sources);
|
|
68378
|
+
for (const report of reports) log40(`browser fork-merge from ${report.source}: ${summarize(report)}`);
|
|
68379
|
+
const child2 = start(options);
|
|
68380
|
+
if (!await owned(options.profile, child2)) log40(`browser for ${options.profile} did not take its profile`);
|
|
68381
|
+
return { handedOff: false, reports, ...child2.pid !== void 0 ? { pid: child2.pid } : {} };
|
|
68382
|
+
} finally {
|
|
68383
|
+
release3();
|
|
68384
|
+
}
|
|
68385
|
+
}
|
|
68386
|
+
function start(options) {
|
|
68387
|
+
const child2 = spawn2(options.browser, [`--user-data-dir=${options.profile}`, ...BASE_FLAGS, ...options.args ?? []], {
|
|
68388
|
+
detached: true,
|
|
68389
|
+
stdio: "ignore",
|
|
68390
|
+
env: options.env ?? process.env
|
|
68391
|
+
});
|
|
68392
|
+
child2.on("error", () => void 0);
|
|
68393
|
+
return child2;
|
|
68394
|
+
}
|
|
68395
|
+
async function owned(profile, child2) {
|
|
68396
|
+
let ended = false;
|
|
68397
|
+
const end = () => void (ended = true);
|
|
68398
|
+
child2.once("error", end).once("exit", end);
|
|
68399
|
+
try {
|
|
68400
|
+
const deadline = Date.now() + OWN_WAIT_MS;
|
|
68401
|
+
for (; ; ) {
|
|
68402
|
+
if (profileOwner(profile) !== void 0) return true;
|
|
68403
|
+
if (ended || Date.now() > deadline) return false;
|
|
68404
|
+
await new Promise((resolveWait) => setTimeout(resolveWait, 100));
|
|
68405
|
+
}
|
|
68406
|
+
} finally {
|
|
68407
|
+
child2.off("error", end).off("exit", end);
|
|
68408
|
+
child2.unref();
|
|
68409
|
+
}
|
|
68410
|
+
}
|
|
68411
|
+
function summarize(report) {
|
|
68412
|
+
const c = report.cookies;
|
|
68413
|
+
return [
|
|
68414
|
+
report.firstFork ? "first fork" : "since last fork",
|
|
68415
|
+
`cookies +${c.inserted} ~${c.updated} -${c.deleted} (kept ${c.kept}, expired ${c.expired})`,
|
|
68416
|
+
`localStorage ${report.localStorage.taken.length} origin(s)`,
|
|
68417
|
+
`IndexedDB ${report.indexedDb.taken.length} origin(s)`
|
|
68418
|
+
].join(", ");
|
|
68419
|
+
}
|
|
68420
|
+
async function lockProfile(profile) {
|
|
68421
|
+
const path = `${profile}.launch-lock`;
|
|
68422
|
+
mkdirSync3(dirname2(path), { recursive: true });
|
|
68423
|
+
const deadline = Date.now() + LOCK_WAIT_MS;
|
|
68424
|
+
for (; ; ) {
|
|
68425
|
+
try {
|
|
68426
|
+
closeSync(openSync(path, "wx"));
|
|
68427
|
+
return () => rmSync3(path, { force: true });
|
|
68428
|
+
} catch (error63) {
|
|
68429
|
+
if (error63.code !== "EEXIST") throw error63;
|
|
68430
|
+
try {
|
|
68431
|
+
if (Date.now() - statSync2(path).mtimeMs > LOCK_STALE_MS) rmSync3(path, { force: true });
|
|
68432
|
+
} catch {
|
|
68433
|
+
}
|
|
68434
|
+
if (Date.now() > deadline) throw new Error(`another browser launch for ${profile} is still running`);
|
|
68435
|
+
await new Promise((resolveWait) => setTimeout(resolveWait, 200));
|
|
68436
|
+
}
|
|
68437
|
+
}
|
|
68438
|
+
}
|
|
68439
|
+
|
|
68440
|
+
// src/browser/close.ts
|
|
68441
|
+
var OP_QUERY_TREE = 15;
|
|
68442
|
+
var OP_INTERN_ATOM = 16;
|
|
68443
|
+
var OP_GET_PROPERTY = 20;
|
|
68444
|
+
var OP_SEND_EVENT = 25;
|
|
68445
|
+
var CLIENT_MESSAGE = 33;
|
|
68446
|
+
async function closeBrowser(options) {
|
|
68447
|
+
const log40 = options.log ?? (() => void 0);
|
|
68448
|
+
const pid = profileOwner(options.profile);
|
|
68449
|
+
if (pid === void 0) return "not-running";
|
|
68450
|
+
try {
|
|
68451
|
+
const x = await X11Connection.connect({
|
|
68452
|
+
display: options.display,
|
|
68453
|
+
...options.xauthority ? { xauthority: options.xauthority } : {}
|
|
68454
|
+
});
|
|
68455
|
+
try {
|
|
68456
|
+
const windows = await windowsOf(x, pid);
|
|
68457
|
+
const protocols = await internAtom(x, "WM_PROTOCOLS");
|
|
68458
|
+
const remove = await internAtom(x, "WM_DELETE_WINDOW");
|
|
68459
|
+
for (const window2 of windows) await sendClientMessage(x, window2, protocols, [remove, 0, 0, 0, 0]);
|
|
68460
|
+
log40(`asked ${windows.length} browser window(s) of ${options.profile} to close`);
|
|
68461
|
+
} finally {
|
|
68462
|
+
x.close();
|
|
68463
|
+
}
|
|
68464
|
+
} catch (error63) {
|
|
68465
|
+
log40(`could not ask the browser of ${options.profile} to close: ${error63.message}`);
|
|
68466
|
+
}
|
|
68467
|
+
if (await exited(pid, options.timeoutMs ?? 15e3)) return "closed";
|
|
68468
|
+
log40(`browser ${pid} did not exit after its windows closed; sending SIGTERM (unflushed cookies may be lost)`);
|
|
68469
|
+
process.kill(pid, "SIGTERM");
|
|
68470
|
+
if (await exited(pid, 5e3)) return "terminated";
|
|
68471
|
+
process.kill(pid, "SIGKILL");
|
|
68472
|
+
return "killed";
|
|
68473
|
+
}
|
|
68474
|
+
async function exited(pid, timeoutMs) {
|
|
68475
|
+
const deadline = Date.now() + timeoutMs;
|
|
68476
|
+
for (; ; ) {
|
|
68477
|
+
try {
|
|
68478
|
+
process.kill(pid, 0);
|
|
68479
|
+
} catch {
|
|
68480
|
+
return true;
|
|
68481
|
+
}
|
|
68482
|
+
if (Date.now() > deadline) return false;
|
|
68483
|
+
await new Promise((resolve5) => setTimeout(resolve5, 200));
|
|
68484
|
+
}
|
|
68485
|
+
}
|
|
68486
|
+
async function windowsOf(x, pid) {
|
|
68487
|
+
const pidAtom = await internAtom(x, "_NET_WM_PID");
|
|
68488
|
+
const found = [];
|
|
68489
|
+
for (const frame of await queryTree(x, x.setup.root)) {
|
|
68490
|
+
for (const window2 of [frame, ...await queryTree(x, frame)]) {
|
|
68491
|
+
const value = await cardinal(x, window2, pidAtom);
|
|
68492
|
+
if (value === pid) found.push(window2);
|
|
68493
|
+
}
|
|
68494
|
+
}
|
|
68495
|
+
return found;
|
|
68496
|
+
}
|
|
68497
|
+
async function internAtom(x, name) {
|
|
68498
|
+
const bytes = Buffer.from(name, "latin1");
|
|
68499
|
+
const body = Buffer.alloc(4 + bytes.length);
|
|
68500
|
+
body.writeUInt16LE(bytes.length, 0);
|
|
68501
|
+
bytes.copy(body, 4);
|
|
68502
|
+
return (await x.request(request(OP_INTERN_ATOM, 0, body))).readUInt32LE(8);
|
|
68503
|
+
}
|
|
68504
|
+
async function queryTree(x, window2) {
|
|
68505
|
+
const body = Buffer.alloc(4);
|
|
68506
|
+
body.writeUInt32LE(window2, 0);
|
|
68507
|
+
const reply2 = await x.request(request(OP_QUERY_TREE, 0, body)).catch(() => void 0);
|
|
68508
|
+
if (!reply2) return [];
|
|
68509
|
+
const count = reply2.readUInt16LE(16);
|
|
68510
|
+
return Array.from({ length: count }, (_, i) => reply2.readUInt32LE(32 + i * 4));
|
|
68511
|
+
}
|
|
68512
|
+
async function cardinal(x, window2, property) {
|
|
68513
|
+
const body = Buffer.alloc(20);
|
|
68514
|
+
body.writeUInt32LE(window2, 0);
|
|
68515
|
+
body.writeUInt32LE(property, 4);
|
|
68516
|
+
body.writeUInt32LE(0, 8);
|
|
68517
|
+
body.writeUInt32LE(0, 12);
|
|
68518
|
+
body.writeUInt32LE(1, 16);
|
|
68519
|
+
const reply2 = await x.request(request(OP_GET_PROPERTY, 0, body)).catch(() => void 0);
|
|
68520
|
+
if (!reply2 || reply2[1] !== 32 || reply2.readUInt32LE(16) < 1) return void 0;
|
|
68521
|
+
return reply2.readUInt32LE(32);
|
|
68522
|
+
}
|
|
68523
|
+
async function sendClientMessage(x, window2, type, data) {
|
|
68524
|
+
const event = Buffer.alloc(32);
|
|
68525
|
+
event[0] = CLIENT_MESSAGE;
|
|
68526
|
+
event[1] = 32;
|
|
68527
|
+
event.writeUInt32LE(window2, 4);
|
|
68528
|
+
event.writeUInt32LE(type, 8);
|
|
68529
|
+
data.forEach((value, i) => event.writeUInt32LE(value >>> 0, 12 + i * 4));
|
|
68530
|
+
const body = Buffer.alloc(40);
|
|
68531
|
+
body.writeUInt32LE(window2, 0);
|
|
68532
|
+
body.writeUInt32LE(0, 4);
|
|
68533
|
+
event.copy(body, 8);
|
|
68534
|
+
await x.checked(request(OP_SEND_EVENT, 0, body));
|
|
68535
|
+
}
|
|
68536
|
+
|
|
68537
|
+
// src/browser/command.ts
|
|
68538
|
+
async function browserCommand(values, args, log40) {
|
|
68539
|
+
if (!values.profile) {
|
|
68540
|
+
throw new Error("usage: browser --profile DIR [--master DIR] [--source DIR]... [--browser PATH] [-- BROWSER_ARGS]");
|
|
68541
|
+
}
|
|
68542
|
+
const browser = values.browser ?? findBrowser(process.env.PATH, values["skip-path"] ?? []);
|
|
68543
|
+
if (!browser) throw new Error("no Chromium or Google Chrome found on PATH");
|
|
68544
|
+
const result = await launchBrowser({
|
|
68545
|
+
profile: values.profile,
|
|
68546
|
+
...values.master ? { master: values.master } : {},
|
|
68547
|
+
sources: values.source ?? [],
|
|
68548
|
+
browser,
|
|
68549
|
+
args,
|
|
68550
|
+
log: log40
|
|
68551
|
+
});
|
|
68552
|
+
log40(
|
|
68553
|
+
result.handedOff ? "browser already running; the request went to it" : `browser started (pid ${result.pid ?? "?"})`
|
|
68554
|
+
);
|
|
68555
|
+
}
|
|
68556
|
+
async function browserCloseCommand(values, log40) {
|
|
68557
|
+
const display = values.display ?? process.env.DISPLAY;
|
|
68558
|
+
if (!values.profile || !display) throw new Error("usage: browser-close --profile DIR [--display :N]");
|
|
68559
|
+
log40(`browser: ${await closeBrowser({ profile: values.profile, display, log: log40 })}`);
|
|
68560
|
+
}
|
|
68561
|
+
|
|
68562
|
+
// src/command-line.ts
|
|
68563
|
+
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
68564
|
+
import { spawn as spawn3 } from "node:child_process";
|
|
67444
68565
|
import { createHash, randomBytes } from "node:crypto";
|
|
67445
68566
|
import { constants as fsConstants } from "node:fs";
|
|
67446
68567
|
import { lstat, open as open2, readdir, realpath, rename, rm, stat } from "node:fs/promises";
|
|
67447
|
-
import { homedir, userInfo } from "node:os";
|
|
67448
|
-
import { basename, dirname as
|
|
68568
|
+
import { homedir as homedir2, userInfo } from "node:os";
|
|
68569
|
+
import { basename as basename3, dirname as dirname3, extname, isAbsolute, join as join5, relative, resolve as resolve2, sep } from "node:path";
|
|
67449
68570
|
|
|
67450
68571
|
// ../protocol/src/frames/computer.ts
|
|
67451
68572
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
@@ -68339,9 +69460,9 @@ async function realOrPlanned(path) {
|
|
|
68339
69460
|
return await realpath(path);
|
|
68340
69461
|
} catch (error63) {
|
|
68341
69462
|
if (error63.code !== "ENOENT") throw error63;
|
|
68342
|
-
const parent =
|
|
69463
|
+
const parent = dirname3(path);
|
|
68343
69464
|
if (parent === path) return path;
|
|
68344
|
-
return
|
|
69465
|
+
return join5(await realOrPlanned(parent), basename3(path));
|
|
68345
69466
|
}
|
|
68346
69467
|
}
|
|
68347
69468
|
var Tail = class {
|
|
@@ -68372,7 +69493,7 @@ var CommandLine = class {
|
|
|
68372
69493
|
this.audit = deps.audit ?? (() => void 0);
|
|
68373
69494
|
this.now = deps.now ?? Date.now;
|
|
68374
69495
|
this.log = deps.log ?? (() => void 0);
|
|
68375
|
-
this.home = deps.home ??
|
|
69496
|
+
this.home = deps.home ?? homedir2();
|
|
68376
69497
|
this.shell = deps.shell ?? loginShell();
|
|
68377
69498
|
this.env = commandEnv(deps.env ?? process.env);
|
|
68378
69499
|
}
|
|
@@ -68386,7 +69507,7 @@ var CommandLine = class {
|
|
|
68386
69507
|
env;
|
|
68387
69508
|
/** The shell `computer_list` reports. */
|
|
68388
69509
|
shellName() {
|
|
68389
|
-
return
|
|
69510
|
+
return basename3(this.shell);
|
|
68390
69511
|
}
|
|
68391
69512
|
/** How many commands run now, for the local indicator. */
|
|
68392
69513
|
runningCount() {
|
|
@@ -68413,7 +69534,7 @@ var CommandLine = class {
|
|
|
68413
69534
|
if (mine >= COMPUTER_EXEC_PER_SESSION_MAX || this.running.size >= COMPUTER_EXEC_TOTAL_MAX)
|
|
68414
69535
|
throw new CommandLineError("exec_busy", "too many commands are running on this computer; wait for one to end");
|
|
68415
69536
|
const started = this.now();
|
|
68416
|
-
const child2 =
|
|
69537
|
+
const child2 = spawn3(this.shell, ["-c", args.command], {
|
|
68417
69538
|
cwd,
|
|
68418
69539
|
env: this.env,
|
|
68419
69540
|
// Its own process group, so a kill reaches everything the command started.
|
|
@@ -68523,7 +69644,7 @@ var CommandLine = class {
|
|
|
68523
69644
|
const names = (await readdir(path)).sort();
|
|
68524
69645
|
const entries2 = await Promise.all(
|
|
68525
69646
|
names.slice(0, COMPUTER_LIST_DIR_MAX).map(async (name) => {
|
|
68526
|
-
const entry = await lstat(
|
|
69647
|
+
const entry = await lstat(join5(path, name)).catch(() => void 0);
|
|
68527
69648
|
const type = !entry ? "unknown" : entry.isSymbolicLink() ? "symlink" : entry.isDirectory() ? "directory" : entry.isFile() ? "file" : "other";
|
|
68528
69649
|
return {
|
|
68529
69650
|
name,
|
|
@@ -68542,12 +69663,12 @@ var CommandLine = class {
|
|
|
68542
69663
|
if (bytes.length > COMPUTER_WRITE_MAX_BYTES)
|
|
68543
69664
|
throw new CommandLineError("too_large", `a write is limited to ${COMPUTER_WRITE_MAX_BYTES} bytes`);
|
|
68544
69665
|
const path = await this.fenced(args.path, roots);
|
|
68545
|
-
const parent = await stat(
|
|
68546
|
-
if (!parent?.isDirectory()) throw new CommandLineError("not_found", `no such directory: ${
|
|
69666
|
+
const parent = await stat(dirname3(path)).catch(() => void 0);
|
|
69667
|
+
if (!parent?.isDirectory()) throw new CommandLineError("not_found", `no such directory: ${dirname3(args.path)}`);
|
|
68547
69668
|
const existing = await stat(path).catch(() => void 0);
|
|
68548
69669
|
if (existing && !existing.isFile())
|
|
68549
69670
|
throw new CommandLineError("invalid_argument", `not a regular file: ${args.path}`);
|
|
68550
|
-
const staged =
|
|
69671
|
+
const staged = join5(dirname3(path), `.${basename3(path)}.agentconnect-${randomBytes(6).toString("hex")}`);
|
|
68551
69672
|
try {
|
|
68552
69673
|
const handle = await open2(
|
|
68553
69674
|
staged,
|
|
@@ -68572,15 +69693,15 @@ var CommandLine = class {
|
|
|
68572
69693
|
}
|
|
68573
69694
|
expand(path) {
|
|
68574
69695
|
if (path === "~") return this.home;
|
|
68575
|
-
if (path.startsWith("~/")) return
|
|
69696
|
+
if (path.startsWith("~/")) return join5(this.home, path.slice(2));
|
|
68576
69697
|
if (!isAbsolute(path)) throw new CommandLineError("invalid_argument", `expected an absolute path: ${path}`);
|
|
68577
|
-
return
|
|
69698
|
+
return resolve2(path);
|
|
68578
69699
|
}
|
|
68579
69700
|
/** The fence (§5.7): an absolute path, resolved through symlinks, inside a root and outside the data directory. */
|
|
68580
69701
|
async fenced(path, roots) {
|
|
68581
69702
|
if (path.includes("\0")) throw new CommandLineError("invalid_argument", "a path cannot hold NUL");
|
|
68582
69703
|
const real = await realOrPlanned(this.expand(path));
|
|
68583
|
-
const data = await realOrPlanned(
|
|
69704
|
+
const data = await realOrPlanned(resolve2(this.deps.dataDir));
|
|
68584
69705
|
if (within(real, data))
|
|
68585
69706
|
throw new CommandLineError("path_refused", "the computer daemon's own data directory is out of reach");
|
|
68586
69707
|
const allowed = await Promise.all((roots?.length ? roots : ["~"]).map((root) => realOrPlanned(this.expand(root))));
|
|
@@ -68895,15 +70016,15 @@ var ScreenshotStore = class {
|
|
|
68895
70016
|
|
|
68896
70017
|
// src/autostart.ts
|
|
68897
70018
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
68898
|
-
import { spawn as
|
|
68899
|
-
import { rmSync, writeFileSync } from "node:fs";
|
|
68900
|
-
import { join as
|
|
70019
|
+
import { spawn as spawn4, spawnSync } from "node:child_process";
|
|
70020
|
+
import { rmSync as rmSync4, writeFileSync as writeFileSync3 } from "node:fs";
|
|
70021
|
+
import { join as join6 } from "node:path";
|
|
68901
70022
|
var RUN_KEY = "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run";
|
|
68902
70023
|
var VALUE_NAME = "AgentConnectComputer";
|
|
68903
|
-
var launcherPath = (dataDir2) =>
|
|
70024
|
+
var launcherPath = (dataDir2) => join6(dataDir2, "start-desktop-daemon.cmd");
|
|
68904
70025
|
function enableAutostart(dataDir2, script) {
|
|
68905
70026
|
assertWindows();
|
|
68906
|
-
|
|
70027
|
+
writeFileSync3(
|
|
68907
70028
|
launcherPath(dataDir2),
|
|
68908
70029
|
`@echo off\r
|
|
68909
70030
|
title AgentConnect Computer\r
|
|
@@ -68915,11 +70036,11 @@ title AgentConnect Computer\r
|
|
|
68915
70036
|
function disableAutostart(dataDir2) {
|
|
68916
70037
|
assertWindows();
|
|
68917
70038
|
reg(["delete", RUN_KEY, "/v", VALUE_NAME, "/f"]);
|
|
68918
|
-
|
|
70039
|
+
rmSync4(launcherPath(dataDir2), { force: true });
|
|
68919
70040
|
}
|
|
68920
70041
|
function startAutostartNow(dataDir2) {
|
|
68921
70042
|
assertWindows();
|
|
68922
|
-
|
|
70043
|
+
spawn4("cmd.exe", ["/c", "start", '""', launcherPath(dataDir2)], { detached: true, stdio: "ignore" }).unref();
|
|
68923
70044
|
}
|
|
68924
70045
|
function reg(args) {
|
|
68925
70046
|
const result = spawnSync("reg.exe", args, { stdio: "inherit", windowsHide: true });
|
|
@@ -68931,7 +70052,7 @@ function assertWindows() {
|
|
|
68931
70052
|
|
|
68932
70053
|
// src/computer.ts
|
|
68933
70054
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
68934
|
-
import { hostname as
|
|
70055
|
+
import { hostname as hostname5, release } from "node:os";
|
|
68935
70056
|
|
|
68936
70057
|
// src/driver/client.ts
|
|
68937
70058
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
@@ -72372,14 +73493,14 @@ function inputRequiredRoundsExceededMessage2(method, maxRounds) {
|
|
|
72372
73493
|
return `Multi-round-trip request '${method}' still required input after ${maxRounds} rounds (inputRequired.maxRounds)`;
|
|
72373
73494
|
}
|
|
72374
73495
|
function sleep2(ms, signal) {
|
|
72375
|
-
return new Promise((
|
|
73496
|
+
return new Promise((resolve5, reject) => {
|
|
72376
73497
|
if (signal?.aborted) {
|
|
72377
73498
|
reject(signal.reason instanceof SdkError2 ? signal.reason : new SdkError2(SdkErrorCode2.RequestTimeout, String(signal.reason)));
|
|
72378
73499
|
return;
|
|
72379
73500
|
}
|
|
72380
73501
|
const timer = setTimeout(() => {
|
|
72381
73502
|
signal?.removeEventListener("abort", onAbort);
|
|
72382
|
-
|
|
73503
|
+
resolve5();
|
|
72383
73504
|
}, ms);
|
|
72384
73505
|
const onAbort = () => {
|
|
72385
73506
|
clearTimeout(timer);
|
|
@@ -73223,7 +74344,7 @@ var Protocol2 = class {
|
|
|
73223
74344
|
const flowStartedAt = Date.now();
|
|
73224
74345
|
let onAbort;
|
|
73225
74346
|
let cleanupMessageId;
|
|
73226
|
-
return new Promise((
|
|
74347
|
+
return new Promise((resolve5, reject) => {
|
|
73227
74348
|
const earlyReject = (error63) => {
|
|
73228
74349
|
reject(error63);
|
|
73229
74350
|
};
|
|
@@ -73292,7 +74413,7 @@ var Protocol2 = class {
|
|
|
73292
74413
|
}
|
|
73293
74414
|
if (decoded.kind === "invalid") return reject(decoded.error);
|
|
73294
74415
|
if (decoded.kind === "input_required") {
|
|
73295
|
-
if (options?.allowInputRequired === true) return
|
|
74416
|
+
if (options?.allowInputRequired === true) return resolve5(manualInputRequiredValue2(decoded));
|
|
73296
74417
|
const flow = {
|
|
73297
74418
|
codec: codec2,
|
|
73298
74419
|
request: request2,
|
|
@@ -73304,11 +74425,11 @@ var Protocol2 = class {
|
|
|
73304
74425
|
params
|
|
73305
74426
|
}, resultSchema, legOptions)
|
|
73306
74427
|
};
|
|
73307
|
-
return
|
|
74428
|
+
return resolve5(this._resolveNonCompleteResult(decoded, flow));
|
|
73308
74429
|
}
|
|
73309
74430
|
const result = decoded.result;
|
|
73310
74431
|
validateStandardSchema2(resultSchema, result).then((parseResult) => {
|
|
73311
|
-
if (parseResult.success)
|
|
74432
|
+
if (parseResult.success) resolve5(parseResult.data);
|
|
73312
74433
|
else reject(new SdkError2(SdkErrorCode2.InvalidResult, `Invalid result for ${request2.method}: ${parseResult.error}`));
|
|
73313
74434
|
}, reject);
|
|
73314
74435
|
});
|
|
@@ -74050,9 +75171,9 @@ var require_codegen2 = /* @__PURE__ */ __commonJSMin2(((exports) => {
|
|
|
74050
75171
|
const rhs = this.rhs === void 0 ? "" : ` = ${this.rhs}`;
|
|
74051
75172
|
return `${varKind} ${this.name}${rhs};` + _n;
|
|
74052
75173
|
}
|
|
74053
|
-
optimizeNames(names,
|
|
75174
|
+
optimizeNames(names, constants3) {
|
|
74054
75175
|
if (!names[this.name.str]) return;
|
|
74055
|
-
if (this.rhs) this.rhs = optimizeExpr(this.rhs, names,
|
|
75176
|
+
if (this.rhs) this.rhs = optimizeExpr(this.rhs, names, constants3);
|
|
74056
75177
|
return this;
|
|
74057
75178
|
}
|
|
74058
75179
|
get names() {
|
|
@@ -74069,9 +75190,9 @@ var require_codegen2 = /* @__PURE__ */ __commonJSMin2(((exports) => {
|
|
|
74069
75190
|
render({ _n }) {
|
|
74070
75191
|
return `${this.lhs} = ${this.rhs};` + _n;
|
|
74071
75192
|
}
|
|
74072
|
-
optimizeNames(names,
|
|
75193
|
+
optimizeNames(names, constants3) {
|
|
74073
75194
|
if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects) return;
|
|
74074
|
-
this.rhs = optimizeExpr(this.rhs, names,
|
|
75195
|
+
this.rhs = optimizeExpr(this.rhs, names, constants3);
|
|
74075
75196
|
return this;
|
|
74076
75197
|
}
|
|
74077
75198
|
get names() {
|
|
@@ -74130,8 +75251,8 @@ var require_codegen2 = /* @__PURE__ */ __commonJSMin2(((exports) => {
|
|
|
74130
75251
|
optimizeNodes() {
|
|
74131
75252
|
return `${this.code}` ? this : void 0;
|
|
74132
75253
|
}
|
|
74133
|
-
optimizeNames(names,
|
|
74134
|
-
this.code = optimizeExpr(this.code, names,
|
|
75254
|
+
optimizeNames(names, constants3) {
|
|
75255
|
+
this.code = optimizeExpr(this.code, names, constants3);
|
|
74135
75256
|
return this;
|
|
74136
75257
|
}
|
|
74137
75258
|
get names() {
|
|
@@ -74157,12 +75278,12 @@ var require_codegen2 = /* @__PURE__ */ __commonJSMin2(((exports) => {
|
|
|
74157
75278
|
}
|
|
74158
75279
|
return nodes.length > 0 ? this : void 0;
|
|
74159
75280
|
}
|
|
74160
|
-
optimizeNames(names,
|
|
75281
|
+
optimizeNames(names, constants3) {
|
|
74161
75282
|
const { nodes } = this;
|
|
74162
75283
|
let i = nodes.length;
|
|
74163
75284
|
while (i--) {
|
|
74164
75285
|
const n = nodes[i];
|
|
74165
|
-
if (n.optimizeNames(names,
|
|
75286
|
+
if (n.optimizeNames(names, constants3)) continue;
|
|
74166
75287
|
subtractNames(names, n.names);
|
|
74167
75288
|
nodes.splice(i, 1);
|
|
74168
75289
|
}
|
|
@@ -74209,11 +75330,11 @@ var require_codegen2 = /* @__PURE__ */ __commonJSMin2(((exports) => {
|
|
|
74209
75330
|
if (cond === false || !this.nodes.length) return void 0;
|
|
74210
75331
|
return this;
|
|
74211
75332
|
}
|
|
74212
|
-
optimizeNames(names,
|
|
75333
|
+
optimizeNames(names, constants3) {
|
|
74213
75334
|
var _a3;
|
|
74214
|
-
this.else = (_a3 = this.else) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names,
|
|
74215
|
-
if (!(super.optimizeNames(names,
|
|
74216
|
-
this.condition = optimizeExpr(this.condition, names,
|
|
75335
|
+
this.else = (_a3 = this.else) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants3);
|
|
75336
|
+
if (!(super.optimizeNames(names, constants3) || this.else)) return;
|
|
75337
|
+
this.condition = optimizeExpr(this.condition, names, constants3);
|
|
74217
75338
|
return this;
|
|
74218
75339
|
}
|
|
74219
75340
|
get names() {
|
|
@@ -74235,9 +75356,9 @@ var require_codegen2 = /* @__PURE__ */ __commonJSMin2(((exports) => {
|
|
|
74235
75356
|
render(opts) {
|
|
74236
75357
|
return `for(${this.iteration})` + super.render(opts);
|
|
74237
75358
|
}
|
|
74238
|
-
optimizeNames(names,
|
|
74239
|
-
if (!super.optimizeNames(names,
|
|
74240
|
-
this.iteration = optimizeExpr(this.iteration, names,
|
|
75359
|
+
optimizeNames(names, constants3) {
|
|
75360
|
+
if (!super.optimizeNames(names, constants3)) return;
|
|
75361
|
+
this.iteration = optimizeExpr(this.iteration, names, constants3);
|
|
74241
75362
|
return this;
|
|
74242
75363
|
}
|
|
74243
75364
|
get names() {
|
|
@@ -74272,9 +75393,9 @@ var require_codegen2 = /* @__PURE__ */ __commonJSMin2(((exports) => {
|
|
|
74272
75393
|
render(opts) {
|
|
74273
75394
|
return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
|
|
74274
75395
|
}
|
|
74275
|
-
optimizeNames(names,
|
|
74276
|
-
if (!super.optimizeNames(names,
|
|
74277
|
-
this.iterable = optimizeExpr(this.iterable, names,
|
|
75396
|
+
optimizeNames(names, constants3) {
|
|
75397
|
+
if (!super.optimizeNames(names, constants3)) return;
|
|
75398
|
+
this.iterable = optimizeExpr(this.iterable, names, constants3);
|
|
74278
75399
|
return this;
|
|
74279
75400
|
}
|
|
74280
75401
|
get names() {
|
|
@@ -74313,11 +75434,11 @@ var require_codegen2 = /* @__PURE__ */ __commonJSMin2(((exports) => {
|
|
|
74313
75434
|
(_b = this.finally) === null || _b === void 0 || _b.optimizeNodes();
|
|
74314
75435
|
return this;
|
|
74315
75436
|
}
|
|
74316
|
-
optimizeNames(names,
|
|
75437
|
+
optimizeNames(names, constants3) {
|
|
74317
75438
|
var _a3, _b;
|
|
74318
|
-
super.optimizeNames(names,
|
|
74319
|
-
(_a3 = this.catch) === null || _a3 === void 0 || _a3.optimizeNames(names,
|
|
74320
|
-
(_b = this.finally) === null || _b === void 0 || _b.optimizeNames(names,
|
|
75439
|
+
super.optimizeNames(names, constants3);
|
|
75440
|
+
(_a3 = this.catch) === null || _a3 === void 0 || _a3.optimizeNames(names, constants3);
|
|
75441
|
+
(_b = this.finally) === null || _b === void 0 || _b.optimizeNames(names, constants3);
|
|
74321
75442
|
return this;
|
|
74322
75443
|
}
|
|
74323
75444
|
get names() {
|
|
@@ -74566,7 +75687,7 @@ var require_codegen2 = /* @__PURE__ */ __commonJSMin2(((exports) => {
|
|
|
74566
75687
|
function addExprNames(names, from) {
|
|
74567
75688
|
return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names;
|
|
74568
75689
|
}
|
|
74569
|
-
function optimizeExpr(expr, names,
|
|
75690
|
+
function optimizeExpr(expr, names, constants3) {
|
|
74570
75691
|
if (expr instanceof code_1.Name) return replaceName(expr);
|
|
74571
75692
|
if (!canOptimize(expr)) return expr;
|
|
74572
75693
|
return new code_1._Code(expr._items.reduce((items, c) => {
|
|
@@ -74576,13 +75697,13 @@ var require_codegen2 = /* @__PURE__ */ __commonJSMin2(((exports) => {
|
|
|
74576
75697
|
return items;
|
|
74577
75698
|
}, []));
|
|
74578
75699
|
function replaceName(n) {
|
|
74579
|
-
const c =
|
|
75700
|
+
const c = constants3[n.str];
|
|
74580
75701
|
if (c === void 0 || names[n.str] !== 1) return n;
|
|
74581
75702
|
delete names[n.str];
|
|
74582
75703
|
return c;
|
|
74583
75704
|
}
|
|
74584
75705
|
function canOptimize(e) {
|
|
74585
|
-
return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 &&
|
|
75706
|
+
return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants3[c.str] !== void 0);
|
|
74586
75707
|
}
|
|
74587
75708
|
}
|
|
74588
75709
|
function subtractNames(names, from) {
|
|
@@ -76242,7 +77363,7 @@ var require_compile2 = /* @__PURE__ */ __commonJSMin2(((exports) => {
|
|
|
76242
77363
|
ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref);
|
|
76243
77364
|
const schOrFunc = root.refs[ref];
|
|
76244
77365
|
if (schOrFunc) return schOrFunc;
|
|
76245
|
-
let _sch =
|
|
77366
|
+
let _sch = resolve5.call(this, root, ref);
|
|
76246
77367
|
if (_sch === void 0) {
|
|
76247
77368
|
const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
|
|
76248
77369
|
const { schemaId } = this.opts;
|
|
@@ -76268,7 +77389,7 @@ var require_compile2 = /* @__PURE__ */ __commonJSMin2(((exports) => {
|
|
|
76268
77389
|
function sameSchemaEnv(s1, s2) {
|
|
76269
77390
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
76270
77391
|
}
|
|
76271
|
-
function
|
|
77392
|
+
function resolve5(root, ref) {
|
|
76272
77393
|
let sch;
|
|
76273
77394
|
while (typeof (sch = this.refs[ref]) == "string") ref = sch;
|
|
76274
77395
|
return sch || this.schemas[ref] || resolveSchema.call(this, root, ref);
|
|
@@ -76350,7 +77471,7 @@ var require_data2 = /* @__PURE__ */ __commonJSMin2(((exports, module) => {
|
|
|
76350
77471
|
}));
|
|
76351
77472
|
var require_utils2 = /* @__PURE__ */ __commonJSMin2(((exports, module) => {
|
|
76352
77473
|
const isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
|
|
76353
|
-
const
|
|
77474
|
+
const isIPv46 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
|
|
76354
77475
|
const isPort = RegExp.prototype.test.bind(/^\d*$/u);
|
|
76355
77476
|
const isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
|
|
76356
77477
|
const isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
|
|
@@ -76437,7 +77558,7 @@ var require_utils2 = /* @__PURE__ */ __commonJSMin2(((exports, module) => {
|
|
|
76437
77558
|
const part = parts[i];
|
|
76438
77559
|
if (part === "") return void 0;
|
|
76439
77560
|
if (part.indexOf(".") !== -1) {
|
|
76440
|
-
if (i !== parts.length - 1 || compression !== -1 && right.length === 0 || !
|
|
77561
|
+
if (i !== parts.length - 1 || compression !== -1 && right.length === 0 || !isIPv46(part)) return void 0;
|
|
76441
77562
|
hextetCount += 2;
|
|
76442
77563
|
continue;
|
|
76443
77564
|
}
|
|
@@ -76762,7 +77883,7 @@ var require_utils2 = /* @__PURE__ */ __commonJSMin2(((exports, module) => {
|
|
|
76762
77883
|
}
|
|
76763
77884
|
if (component.host !== void 0) {
|
|
76764
77885
|
let host = component.host;
|
|
76765
|
-
if (!
|
|
77886
|
+
if (!isIPv46(host)) {
|
|
76766
77887
|
let ipV6res = normalizeIPv6(host);
|
|
76767
77888
|
if (ipV6res.isIPV6 !== true && ipV6res.isIPVFuture !== true) {
|
|
76768
77889
|
host = normalizePercentEncoding(host, true);
|
|
@@ -76794,7 +77915,7 @@ var require_utils2 = /* @__PURE__ */ __commonJSMin2(((exports, module) => {
|
|
|
76794
77915
|
encodeFragment,
|
|
76795
77916
|
escapePreservingEscapes,
|
|
76796
77917
|
removeDotSegments,
|
|
76797
|
-
isIPv4:
|
|
77918
|
+
isIPv4: isIPv46,
|
|
76798
77919
|
isUUID,
|
|
76799
77920
|
normalizeIPv6,
|
|
76800
77921
|
stringArrayToHexStripped
|
|
@@ -76949,7 +78070,7 @@ var require_schemes2 = /* @__PURE__ */ __commonJSMin2(((exports, module) => {
|
|
|
76949
78070
|
};
|
|
76950
78071
|
}));
|
|
76951
78072
|
var require_fast_uri2 = /* @__PURE__ */ __commonJSMin2(((exports, module) => {
|
|
76952
|
-
const { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4:
|
|
78073
|
+
const { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4: isIPv46, nonSimpleDomain } = require_utils2();
|
|
76953
78074
|
const { SCHEMES, getSchemeHandler } = require_schemes2();
|
|
76954
78075
|
const VALID_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/u;
|
|
76955
78076
|
const MALFORMED_SCHEME_ERROR = "URI scheme is malformed.";
|
|
@@ -76963,7 +78084,7 @@ var require_fast_uri2 = /* @__PURE__ */ __commonJSMin2(((exports, module) => {
|
|
|
76963
78084
|
else if (typeof uri === "object") uri = parse3(serialize(uri, options), options);
|
|
76964
78085
|
return uri;
|
|
76965
78086
|
}
|
|
76966
|
-
function
|
|
78087
|
+
function resolve5(baseURI, relativeURI, options) {
|
|
76967
78088
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
76968
78089
|
const { parsed: baseParsed, malformedAuthorityOrPort: baseMalformed, malformedPercentEncoding: baseMalformedPercentEncoding, malformedSchemeSpecific: baseMalformedSchemeSpecific, malformedHost: baseMalformedHost, malformedScheme: baseMalformedScheme } = parseWithStatus(baseURI, schemelessOptions);
|
|
76969
78090
|
const { parsed: relativeParsed, malformedAuthorityOrPort: relativeMalformed, malformedPercentEncoding: relativeMalformedPercentEncoding, malformedSchemeSpecific: relativeMalformedSchemeSpecific, malformedHost: relativeMalformedHost, malformedScheme: relativeMalformedScheme } = parseWithStatus(relativeURI, schemelessOptions);
|
|
@@ -76971,7 +78092,7 @@ var require_fast_uri2 = /* @__PURE__ */ __commonJSMin2(((exports, module) => {
|
|
|
76971
78092
|
const resolved = resolveComponent(baseParsed, relativeParsed, schemelessOptions, true);
|
|
76972
78093
|
const resolvedSchemeHandler = getSchemeHandler(options && options.scheme || resolved.scheme);
|
|
76973
78094
|
const resolvedHost = resolved.host;
|
|
76974
|
-
const resolvedHostIsIP = resolvedHost !== void 0 && resolvedHost !== "" && (
|
|
78095
|
+
const resolvedHostIsIP = resolvedHost !== void 0 && resolvedHost !== "" && (isIPv46(resolvedHost) || normalizeIPv6(resolvedHost).isIPV6);
|
|
76975
78096
|
canonicalizeHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP);
|
|
76976
78097
|
const encodedASCIIHost = resolvedHost && resolvedHost.indexOf("%") !== -1 && !new RegExp("\\P{ASCII}", "u").test(resolvedHost);
|
|
76977
78098
|
if (resolved.error && !encodedASCIIHost) throw new Error(resolved.error);
|
|
@@ -77171,7 +78292,7 @@ var require_fast_uri2 = /* @__PURE__ */ __commonJSMin2(((exports, module) => {
|
|
|
77171
78292
|
parsed.error = parsed.error || parseError;
|
|
77172
78293
|
malformedAuthorityOrPort = true;
|
|
77173
78294
|
}
|
|
77174
|
-
if (parsed.host) if (
|
|
78295
|
+
if (parsed.host) if (isIPv46(parsed.host) === false) {
|
|
77175
78296
|
const bracketedIPLiteral = isIPLiteral(parsed.host);
|
|
77176
78297
|
const hasIPLiteralBracket = parsed.host.indexOf("[") !== -1 || parsed.host.indexOf("]") !== -1;
|
|
77177
78298
|
const ipv6result = normalizeIPv6(parsed.host);
|
|
@@ -77245,7 +78366,7 @@ var require_fast_uri2 = /* @__PURE__ */ __commonJSMin2(((exports, module) => {
|
|
|
77245
78366
|
const fastUri = {
|
|
77246
78367
|
SCHEMES,
|
|
77247
78368
|
normalize,
|
|
77248
|
-
resolve:
|
|
78369
|
+
resolve: resolve5,
|
|
77249
78370
|
resolveComponent,
|
|
77250
78371
|
equal,
|
|
77251
78372
|
serialize,
|
|
@@ -81866,14 +82987,14 @@ var ProbeWindow = class ProbeWindow2 {
|
|
|
81866
82987
|
*/
|
|
81867
82988
|
async exchange(buildRequest, timeoutMs) {
|
|
81868
82989
|
const id = `server-discover-probe-${++this._probeCounter}`;
|
|
81869
|
-
return new Promise((
|
|
82990
|
+
return new Promise((resolve5) => {
|
|
81870
82991
|
let settled = false;
|
|
81871
82992
|
const settle2 = (reply2) => {
|
|
81872
82993
|
if (settled) return;
|
|
81873
82994
|
settled = true;
|
|
81874
82995
|
clearTimeout(timer);
|
|
81875
82996
|
if (this._pending?.id === id) this._pending = void 0;
|
|
81876
|
-
|
|
82997
|
+
resolve5(reply2);
|
|
81877
82998
|
};
|
|
81878
82999
|
const timer = setTimeout(() => settle2({ kind: "timeout" }), timeoutMs);
|
|
81879
83000
|
this._pending = {
|
|
@@ -83108,13 +84229,13 @@ var Client = class extends Protocol2 {
|
|
|
83108
84229
|
let onCallerAbort;
|
|
83109
84230
|
let resolveOpening;
|
|
83110
84231
|
let rejectOpening;
|
|
83111
|
-
const opening = new Promise((
|
|
83112
|
-
resolveOpening =
|
|
84232
|
+
const opening = new Promise((resolve5, reject) => {
|
|
84233
|
+
resolveOpening = resolve5;
|
|
83113
84234
|
rejectOpening = reject;
|
|
83114
84235
|
});
|
|
83115
84236
|
let resolveClosed;
|
|
83116
|
-
const closed = new Promise((
|
|
83117
|
-
resolveClosed =
|
|
84237
|
+
const closed = new Promise((resolve5) => {
|
|
84238
|
+
resolveClosed = resolve5;
|
|
83118
84239
|
});
|
|
83119
84240
|
const settle2 = (outcome) => {
|
|
83120
84241
|
if (state === "closed") return;
|
|
@@ -83609,7 +84730,7 @@ var StdioClientTransport = class {
|
|
|
83609
84730
|
*/
|
|
83610
84731
|
async start() {
|
|
83611
84732
|
if (this._process) throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");
|
|
83612
|
-
return new Promise((
|
|
84733
|
+
return new Promise((resolve5, reject) => {
|
|
83613
84734
|
this._process = (0, import_cross_spawn.default)(this._serverParams.command, this._serverParams.args ?? [], {
|
|
83614
84735
|
env: {
|
|
83615
84736
|
...getDefaultEnvironment(),
|
|
@@ -83629,7 +84750,7 @@ var StdioClientTransport = class {
|
|
|
83629
84750
|
this.onerror?.(error63);
|
|
83630
84751
|
});
|
|
83631
84752
|
this._process.on("spawn", () => {
|
|
83632
|
-
|
|
84753
|
+
resolve5();
|
|
83633
84754
|
});
|
|
83634
84755
|
this._process.on("close", (_code) => {
|
|
83635
84756
|
this._process = void 0;
|
|
@@ -83694,7 +84815,7 @@ var StdioClientTransport = class {
|
|
|
83694
84815
|
const proc = this._process;
|
|
83695
84816
|
this._process = void 0;
|
|
83696
84817
|
if (proc && proc.exitCode === null && proc.signalCode === null) {
|
|
83697
|
-
const
|
|
84818
|
+
const exited2 = new Promise((resolve5) => proc.once("exit", () => resolve5()));
|
|
83698
84819
|
try {
|
|
83699
84820
|
proc.stdin?.end();
|
|
83700
84821
|
} catch {
|
|
@@ -83703,12 +84824,12 @@ var StdioClientTransport = class {
|
|
|
83703
84824
|
proc.kill("SIGTERM");
|
|
83704
84825
|
} catch {
|
|
83705
84826
|
}
|
|
83706
|
-
await Promise.race([
|
|
84827
|
+
await Promise.race([exited2, new Promise((resolve5) => setTimeout(resolve5, 1e3).unref())]);
|
|
83707
84828
|
if (proc.exitCode === null && proc.signalCode === null) try {
|
|
83708
84829
|
proc.kill("SIGKILL");
|
|
83709
84830
|
} catch {
|
|
83710
84831
|
}
|
|
83711
|
-
await
|
|
84832
|
+
await exited2;
|
|
83712
84833
|
}
|
|
83713
84834
|
try {
|
|
83714
84835
|
proc?.stdout?.destroy();
|
|
@@ -83728,22 +84849,22 @@ var StdioClientTransport = class {
|
|
|
83728
84849
|
if (this._process) {
|
|
83729
84850
|
const processToClose = this._process;
|
|
83730
84851
|
this._process = void 0;
|
|
83731
|
-
const closePromise = new Promise((
|
|
84852
|
+
const closePromise = new Promise((resolve5) => {
|
|
83732
84853
|
processToClose.once("close", () => {
|
|
83733
|
-
|
|
84854
|
+
resolve5();
|
|
83734
84855
|
});
|
|
83735
84856
|
});
|
|
83736
84857
|
try {
|
|
83737
84858
|
processToClose.stdin?.end();
|
|
83738
84859
|
} catch {
|
|
83739
84860
|
}
|
|
83740
|
-
await Promise.race([closePromise, new Promise((
|
|
84861
|
+
await Promise.race([closePromise, new Promise((resolve5) => setTimeout(resolve5, 2e3).unref())]);
|
|
83741
84862
|
if (processToClose.exitCode === null) {
|
|
83742
84863
|
try {
|
|
83743
84864
|
processToClose.kill("SIGTERM");
|
|
83744
84865
|
} catch {
|
|
83745
84866
|
}
|
|
83746
|
-
await Promise.race([closePromise, new Promise((
|
|
84867
|
+
await Promise.race([closePromise, new Promise((resolve5) => setTimeout(resolve5, 2e3).unref())]);
|
|
83747
84868
|
}
|
|
83748
84869
|
if (processToClose.exitCode === null) try {
|
|
83749
84870
|
processToClose.kill("SIGKILL");
|
|
@@ -83753,11 +84874,11 @@ var StdioClientTransport = class {
|
|
|
83753
84874
|
this._readBuffer.clear();
|
|
83754
84875
|
}
|
|
83755
84876
|
send(message) {
|
|
83756
|
-
return new Promise((
|
|
84877
|
+
return new Promise((resolve5) => {
|
|
83757
84878
|
if (!this._process?.stdin) throw new SdkError2(SdkErrorCode2.NotConnected, "Not connected");
|
|
83758
84879
|
const json4 = serializeMessage2(message);
|
|
83759
|
-
if (this._process.stdin.write(json4))
|
|
83760
|
-
else this._process.stdin.once("drain",
|
|
84880
|
+
if (this._process.stdin.write(json4)) resolve5();
|
|
84881
|
+
else this._process.stdin.once("drain", resolve5);
|
|
83761
84882
|
});
|
|
83762
84883
|
}
|
|
83763
84884
|
};
|
|
@@ -83801,7 +84922,7 @@ var CuaDriver = class {
|
|
|
83801
84922
|
if (this.client) return this.client;
|
|
83802
84923
|
this.connecting ??= (async () => {
|
|
83803
84924
|
const wait = this.lastStartAt + RESTART_BACKOFF_MS - Date.now();
|
|
83804
|
-
if (wait > 0) await new Promise((
|
|
84925
|
+
if (wait > 0) await new Promise((resolve5) => setTimeout(resolve5, wait));
|
|
83805
84926
|
this.lastStartAt = Date.now();
|
|
83806
84927
|
const transport = new StdioClientTransport({
|
|
83807
84928
|
command: this.options.wrapper?.[0] ?? this.options.command,
|
|
@@ -83951,7 +85072,7 @@ var Computer = class {
|
|
|
83951
85072
|
this.config = deps.config;
|
|
83952
85073
|
this.audit = deps.audit ?? (() => void 0);
|
|
83953
85074
|
this.now = deps.now ?? Date.now;
|
|
83954
|
-
this.sleep = deps.sleep ?? ((ms) => new Promise((
|
|
85075
|
+
this.sleep = deps.sleep ?? ((ms) => new Promise((resolve5) => setTimeout(resolve5, ms)));
|
|
83955
85076
|
this.log = deps.log ?? (() => void 0);
|
|
83956
85077
|
this.onStatus = deps.onStatus ?? (() => void 0);
|
|
83957
85078
|
this.platform = deps.platform ?? process.platform;
|
|
@@ -84113,7 +85234,7 @@ var Computer = class {
|
|
|
84113
85234
|
info() {
|
|
84114
85235
|
this.expireLease();
|
|
84115
85236
|
return {
|
|
84116
|
-
name: this.profile?.name ??
|
|
85237
|
+
name: this.profile?.name ?? hostname5(),
|
|
84117
85238
|
kind: "self-hosted",
|
|
84118
85239
|
os: process.platform === "win32" ? "windows" : process.platform === "darwin" ? "macos" : "linux",
|
|
84119
85240
|
osVersion: this.profile?.osVersion ?? release(),
|
|
@@ -84785,239 +85906,12 @@ function toComputerError(error63) {
|
|
|
84785
85906
|
// src/config.ts
|
|
84786
85907
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
84787
85908
|
import { createHash as createHash3, randomBytes as randomBytes2, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
|
|
84788
|
-
import { existsSync, mkdirSync as
|
|
85909
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync4, readFileSync as readFileSync4, renameSync, writeFileSync as writeFileSync4 } from "node:fs";
|
|
84789
85910
|
import { homedir as homedir3 } from "node:os";
|
|
84790
|
-
import { join as
|
|
85911
|
+
import { join as join7 } from "node:path";
|
|
84791
85912
|
|
|
84792
85913
|
// src/linux/x11-local.ts
|
|
84793
85914
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
84794
|
-
|
|
84795
|
-
// src/linux/x11.ts
|
|
84796
|
-
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
84797
|
-
import { readFileSync } from "node:fs";
|
|
84798
|
-
import { createConnection } from "node:net";
|
|
84799
|
-
import { homedir as homedir2, hostname as hostname4 } from "node:os";
|
|
84800
|
-
import { join as join3 } from "node:path";
|
|
84801
|
-
function parseDisplay(display) {
|
|
84802
|
-
const match = /^([^:]*):(\d+)(?:\.\d+)?$/.exec(display ?? "");
|
|
84803
|
-
if (!match) return void 0;
|
|
84804
|
-
const host = match[1] ?? "";
|
|
84805
|
-
const number4 = Number(match[2]);
|
|
84806
|
-
if (host === "" || host === "unix") return { path: `/tmp/.X11-unix/X${number4}`, number: number4 };
|
|
84807
|
-
return { host, port: 6e3 + number4, number: number4 };
|
|
84808
|
-
}
|
|
84809
|
-
var FAMILY_LOCAL = 256;
|
|
84810
|
-
var FAMILY_WILD = 65535;
|
|
84811
|
-
var COOKIE = "MIT-MAGIC-COOKIE-1";
|
|
84812
|
-
function xauthCookie(file2, number4, host = hostname4()) {
|
|
84813
|
-
let offset = 0;
|
|
84814
|
-
let fallback;
|
|
84815
|
-
const field = () => {
|
|
84816
|
-
const length = file2.readUInt16BE(offset);
|
|
84817
|
-
const value = file2.subarray(offset + 2, offset + 2 + length);
|
|
84818
|
-
offset += 2 + length;
|
|
84819
|
-
return value;
|
|
84820
|
-
};
|
|
84821
|
-
try {
|
|
84822
|
-
while (offset < file2.length) {
|
|
84823
|
-
const family = file2.readUInt16BE(offset);
|
|
84824
|
-
offset += 2;
|
|
84825
|
-
const address = field().toString("latin1");
|
|
84826
|
-
const display = field().toString("latin1");
|
|
84827
|
-
const name = field().toString("latin1");
|
|
84828
|
-
const data = field();
|
|
84829
|
-
if (name !== COOKIE || display !== "" && display !== String(number4)) continue;
|
|
84830
|
-
if (family === FAMILY_WILD || family === FAMILY_LOCAL && address === host) return Buffer.from(data);
|
|
84831
|
-
fallback ??= Buffer.from(data);
|
|
84832
|
-
}
|
|
84833
|
-
} catch {
|
|
84834
|
-
}
|
|
84835
|
-
return fallback;
|
|
84836
|
-
}
|
|
84837
|
-
var pad4 = (n) => (4 - n % 4) % 4;
|
|
84838
|
-
var X11Error = class extends Error {
|
|
84839
|
-
constructor(code, sequence) {
|
|
84840
|
-
super(`X11 error ${code} (request ${sequence})`);
|
|
84841
|
-
this.code = code;
|
|
84842
|
-
this.sequence = sequence;
|
|
84843
|
-
this.name = "X11Error";
|
|
84844
|
-
}
|
|
84845
|
-
code;
|
|
84846
|
-
sequence;
|
|
84847
|
-
};
|
|
84848
|
-
var X11Connection = class _X11Connection {
|
|
84849
|
-
constructor(socket, setup2) {
|
|
84850
|
-
this.socket = socket;
|
|
84851
|
-
this.setup = setup2;
|
|
84852
|
-
socket.on("data", (chunk) => this.receive(chunk));
|
|
84853
|
-
socket.on("error", (error63) => this.close(error63));
|
|
84854
|
-
socket.on("close", () => this.close());
|
|
84855
|
-
}
|
|
84856
|
-
socket;
|
|
84857
|
-
setup;
|
|
84858
|
-
buffer = Buffer.alloc(0);
|
|
84859
|
-
sequence = 0;
|
|
84860
|
-
pending = /* @__PURE__ */ new Map();
|
|
84861
|
-
errors = /* @__PURE__ */ new Map();
|
|
84862
|
-
closed = false;
|
|
84863
|
-
onEvent = () => void 0;
|
|
84864
|
-
onClose = () => void 0;
|
|
84865
|
-
static async connect(options = {}) {
|
|
84866
|
-
const address = parseDisplay(options.display ?? process.env.DISPLAY);
|
|
84867
|
-
if (!address) throw new Error("DISPLAY is not set to an X11 display");
|
|
84868
|
-
const authFile = options.xauthority ?? process.env.XAUTHORITY ?? join3(homedir2(), ".Xauthority");
|
|
84869
|
-
let cookie;
|
|
84870
|
-
try {
|
|
84871
|
-
cookie = xauthCookie(readFileSync(authFile), address.number);
|
|
84872
|
-
} catch {
|
|
84873
|
-
}
|
|
84874
|
-
const socket = options.socketPath ? createConnection(options.socketPath) : "path" in address ? createConnection(address.path) : createConnection(address.port, address.host);
|
|
84875
|
-
socket.setNoDelay(true);
|
|
84876
|
-
const timeoutMs = options.timeoutMs ?? 5e3;
|
|
84877
|
-
const setup2 = await new Promise((resolve4, reject) => {
|
|
84878
|
-
let data = Buffer.alloc(0);
|
|
84879
|
-
const timer = setTimeout(() => fail(new Error("X11 connection setup timed out")), timeoutMs);
|
|
84880
|
-
const fail = (error63) => {
|
|
84881
|
-
clearTimeout(timer);
|
|
84882
|
-
socket.off("data", onData);
|
|
84883
|
-
socket.destroy();
|
|
84884
|
-
reject(error63);
|
|
84885
|
-
};
|
|
84886
|
-
const onData = (chunk) => {
|
|
84887
|
-
data = Buffer.concat([data, chunk]);
|
|
84888
|
-
if (data.length < 8) return;
|
|
84889
|
-
const total = 8 + data.readUInt16LE(6) * 4;
|
|
84890
|
-
if (data.length < total) return;
|
|
84891
|
-
clearTimeout(timer);
|
|
84892
|
-
socket.off("data", onData);
|
|
84893
|
-
socket.off("error", fail);
|
|
84894
|
-
if (data[0] !== 1) {
|
|
84895
|
-
const reason = data.subarray(8, 8 + (data[1] ?? 0)).toString("latin1");
|
|
84896
|
-
socket.destroy();
|
|
84897
|
-
return reject(new Error(`X11 server refused the connection: ${reason || "authorization required"}`));
|
|
84898
|
-
}
|
|
84899
|
-
try {
|
|
84900
|
-
resolve4({ setup: parseSetup(data.subarray(0, total)), rest: data.subarray(total) });
|
|
84901
|
-
} catch (error63) {
|
|
84902
|
-
fail(error63);
|
|
84903
|
-
}
|
|
84904
|
-
};
|
|
84905
|
-
socket.once("error", fail);
|
|
84906
|
-
socket.on("data", onData);
|
|
84907
|
-
socket.write(setupRequest(cookie));
|
|
84908
|
-
});
|
|
84909
|
-
const connection = new _X11Connection(socket, setup2.setup);
|
|
84910
|
-
if (setup2.rest.length) connection.receive(setup2.rest);
|
|
84911
|
-
return connection;
|
|
84912
|
-
}
|
|
84913
|
-
listen(listener) {
|
|
84914
|
-
this.onEvent = listener;
|
|
84915
|
-
}
|
|
84916
|
-
whenClosed(listener) {
|
|
84917
|
-
this.onClose = listener;
|
|
84918
|
-
}
|
|
84919
|
-
/** Sends a request that has a reply and resolves with the whole reply. */
|
|
84920
|
-
request(body) {
|
|
84921
|
-
if (this.closed) return Promise.reject(new Error("X11 connection closed"));
|
|
84922
|
-
const sequence = this.send(body);
|
|
84923
|
-
return new Promise((resolve4, reject) => this.pending.set(sequence, { resolve: resolve4, reject }));
|
|
84924
|
-
}
|
|
84925
|
-
/** Sends a request without a reply; resolves once the server processed it, rejecting with its error. */
|
|
84926
|
-
async checked(body) {
|
|
84927
|
-
const sequence = this.send(body);
|
|
84928
|
-
await this.request(request(43, 0, Buffer.alloc(0)));
|
|
84929
|
-
const error63 = this.errors.get(sequence);
|
|
84930
|
-
this.errors.delete(sequence);
|
|
84931
|
-
if (error63) throw error63;
|
|
84932
|
-
}
|
|
84933
|
-
close(error63) {
|
|
84934
|
-
if (this.closed) return;
|
|
84935
|
-
this.closed = true;
|
|
84936
|
-
this.socket.destroy();
|
|
84937
|
-
for (const pending of this.pending.values()) pending.reject(error63 ?? new Error("X11 connection closed"));
|
|
84938
|
-
this.pending.clear();
|
|
84939
|
-
this.onClose(error63);
|
|
84940
|
-
}
|
|
84941
|
-
send(body) {
|
|
84942
|
-
this.sequence = this.sequence + 1 & 65535;
|
|
84943
|
-
this.socket.write(body);
|
|
84944
|
-
return this.sequence;
|
|
84945
|
-
}
|
|
84946
|
-
receive(chunk) {
|
|
84947
|
-
this.buffer = this.buffer.length ? Buffer.concat([this.buffer, chunk]) : chunk;
|
|
84948
|
-
while (this.buffer.length >= 32) {
|
|
84949
|
-
const kind = this.buffer[0] & 127;
|
|
84950
|
-
const total = kind === 1 || kind === 35 ? 32 + this.buffer.readUInt32LE(4) * 4 : 32;
|
|
84951
|
-
if (this.buffer.length < total) return;
|
|
84952
|
-
const message = this.buffer.subarray(0, total);
|
|
84953
|
-
this.buffer = this.buffer.subarray(total);
|
|
84954
|
-
this.dispatch(kind, message);
|
|
84955
|
-
}
|
|
84956
|
-
}
|
|
84957
|
-
dispatch(kind, message) {
|
|
84958
|
-
const sequence = message.readUInt16LE(2);
|
|
84959
|
-
if (kind === 1 || kind === 0) {
|
|
84960
|
-
const pending = this.pending.get(sequence);
|
|
84961
|
-
if (pending) {
|
|
84962
|
-
this.pending.delete(sequence);
|
|
84963
|
-
if (kind === 1) pending.resolve(Buffer.from(message));
|
|
84964
|
-
else pending.reject(new X11Error(message[1], sequence));
|
|
84965
|
-
return;
|
|
84966
|
-
}
|
|
84967
|
-
if (kind === 0) {
|
|
84968
|
-
this.errors.set(sequence, new X11Error(message[1], sequence));
|
|
84969
|
-
if (this.errors.size > 64) this.errors.delete(this.errors.keys().next().value);
|
|
84970
|
-
}
|
|
84971
|
-
return;
|
|
84972
|
-
}
|
|
84973
|
-
this.onEvent(Buffer.from(message));
|
|
84974
|
-
}
|
|
84975
|
-
};
|
|
84976
|
-
function setupRequest(cookie) {
|
|
84977
|
-
const name = cookie ? Buffer.from(COOKIE, "latin1") : Buffer.alloc(0);
|
|
84978
|
-
const data = cookie ?? Buffer.alloc(0);
|
|
84979
|
-
const out = Buffer.alloc(12 + name.length + pad4(name.length) + data.length + pad4(data.length));
|
|
84980
|
-
out.write("l", 0, "latin1");
|
|
84981
|
-
out.writeUInt16LE(11, 2);
|
|
84982
|
-
out.writeUInt16LE(0, 4);
|
|
84983
|
-
out.writeUInt16LE(name.length, 6);
|
|
84984
|
-
out.writeUInt16LE(data.length, 8);
|
|
84985
|
-
name.copy(out, 12);
|
|
84986
|
-
data.copy(out, 12 + name.length + pad4(name.length));
|
|
84987
|
-
return out;
|
|
84988
|
-
}
|
|
84989
|
-
function parseSetup(reply2) {
|
|
84990
|
-
const vendorLength = reply2.readUInt16LE(24);
|
|
84991
|
-
const formats = reply2[29];
|
|
84992
|
-
const minKeycode = reply2[34];
|
|
84993
|
-
const maxKeycode = reply2[35];
|
|
84994
|
-
const screens = 40 + vendorLength + pad4(vendorLength) + formats * 8;
|
|
84995
|
-
if (reply2.length < screens + 4) throw new Error("X11 setup reply has no screen");
|
|
84996
|
-
return { root: reply2.readUInt32LE(screens), minKeycode, maxKeycode };
|
|
84997
|
-
}
|
|
84998
|
-
function request(opcode, minor, body) {
|
|
84999
|
-
const out = Buffer.alloc(4 + body.length + pad4(body.length));
|
|
85000
|
-
out[0] = opcode;
|
|
85001
|
-
out[1] = minor;
|
|
85002
|
-
out.writeUInt16LE(out.length / 4, 2);
|
|
85003
|
-
body.copy(out, 4);
|
|
85004
|
-
return out;
|
|
85005
|
-
}
|
|
85006
|
-
var OP_GRAB_KEY = 33;
|
|
85007
|
-
var OP_UNGRAB_KEY = 34;
|
|
85008
|
-
var OP_QUERY_EXTENSION = 98;
|
|
85009
|
-
var OP_GET_KEYBOARD_MAPPING = 101;
|
|
85010
|
-
var OP_GET_MODIFIER_MAPPING = 119;
|
|
85011
|
-
async function queryExtension(x, name) {
|
|
85012
|
-
const bytes = Buffer.from(name, "latin1");
|
|
85013
|
-
const body = Buffer.alloc(4 + bytes.length);
|
|
85014
|
-
body.writeUInt16LE(bytes.length, 0);
|
|
85015
|
-
bytes.copy(body, 4);
|
|
85016
|
-
const reply2 = await x.request(request(OP_QUERY_EXTENSION, 0, body));
|
|
85017
|
-
return reply2[8] ? reply2[9] : void 0;
|
|
85018
|
-
}
|
|
85019
|
-
|
|
85020
|
-
// src/linux/x11-local.ts
|
|
85021
85915
|
var XI_QUERY_VERSION = 47;
|
|
85022
85916
|
var XI_SELECT_EVENTS = 46;
|
|
85023
85917
|
var XI_QUERY_DEVICE = 48;
|
|
@@ -85303,30 +86197,30 @@ var DaemonConfig = external_exports.object({
|
|
|
85303
86197
|
});
|
|
85304
86198
|
function dataDir() {
|
|
85305
86199
|
if (process.env.AGENTCONNECT_COMPUTER_HOME) return process.env.AGENTCONNECT_COMPUTER_HOME;
|
|
85306
|
-
if (process.platform === "win32" &&
|
|
86200
|
+
if (process.platform === "win32" && existsSync4(join7(windowsServiceHome(), "config.json"))) return windowsServiceHome();
|
|
85307
86201
|
return userDataDir();
|
|
85308
86202
|
}
|
|
85309
86203
|
function userDataDir() {
|
|
85310
86204
|
if (process.platform === "win32") {
|
|
85311
|
-
return
|
|
86205
|
+
return join7(process.env.LOCALAPPDATA ?? join7(homedir3(), "AppData", "Local"), "AgentConnect", "computer");
|
|
85312
86206
|
}
|
|
85313
|
-
return
|
|
86207
|
+
return join7(homedir3(), ".agentconnect", "computer");
|
|
85314
86208
|
}
|
|
85315
|
-
var windowsServiceHome = () =>
|
|
85316
|
-
var configPath = (dir = dataDir()) =>
|
|
86209
|
+
var windowsServiceHome = () => join7(process.env.ProgramData ?? "C:\\ProgramData", "AgentConnect", "computer");
|
|
86210
|
+
var configPath = (dir = dataDir()) => join7(dir, "config.json");
|
|
85317
86211
|
function loadConfig(dir = dataDir()) {
|
|
85318
86212
|
let raw = {};
|
|
85319
86213
|
try {
|
|
85320
|
-
raw = JSON.parse(
|
|
86214
|
+
raw = JSON.parse(readFileSync4(configPath(dir), "utf8"));
|
|
85321
86215
|
} catch (error63) {
|
|
85322
86216
|
if (error63.code !== "ENOENT") throw error63;
|
|
85323
86217
|
}
|
|
85324
86218
|
return DaemonConfig.parse(raw);
|
|
85325
86219
|
}
|
|
85326
86220
|
function saveConfig(config2, dir = dataDir()) {
|
|
85327
|
-
|
|
86221
|
+
mkdirSync4(dir, { recursive: true, mode: 448 });
|
|
85328
86222
|
const tmp = `${configPath(dir)}.tmp`;
|
|
85329
|
-
|
|
86223
|
+
writeFileSync4(tmp, `${JSON.stringify(config2, null, 2)}
|
|
85330
86224
|
`, { mode: 384 });
|
|
85331
86225
|
renameSync(tmp, configPath(dir));
|
|
85332
86226
|
}
|
|
@@ -85348,8 +86242,8 @@ function authenticate(config2, authorization) {
|
|
|
85348
86242
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
85349
86243
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
85350
86244
|
import { createHash as createHash4 } from "node:crypto";
|
|
85351
|
-
import { existsSync as
|
|
85352
|
-
import { join as
|
|
86245
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync5, mkdtempSync as mkdtempSync2, renameSync as renameSync2, rmSync as rmSync5, writeFileSync as writeFileSync5 } from "node:fs";
|
|
86246
|
+
import { join as join8 } from "node:path";
|
|
85353
86247
|
var CUA_DRIVER_VERSION = "0.35.2";
|
|
85354
86248
|
var RELEASE_BASE = `https://github.com/trycua/cua/releases/download/cua-driver-rs-v${CUA_DRIVER_VERSION}`;
|
|
85355
86249
|
var ARCHIVES = {
|
|
@@ -85379,18 +86273,18 @@ var ARCHIVES = {
|
|
|
85379
86273
|
}
|
|
85380
86274
|
};
|
|
85381
86275
|
var binaryName = () => process.platform === "win32" ? "cua-driver.exe" : "cua-driver";
|
|
85382
|
-
var installedDriverDir = (dataDir2) =>
|
|
86276
|
+
var installedDriverDir = (dataDir2) => join8(dataDir2, "cua-driver", CUA_DRIVER_VERSION);
|
|
85383
86277
|
function installedDriverPath(dataDir2) {
|
|
85384
|
-
return
|
|
86278
|
+
return join8(installedDriverDir(dataDir2), binaryName());
|
|
85385
86279
|
}
|
|
85386
86280
|
function resolveDriverPath(dataDir2, explicit) {
|
|
85387
86281
|
if (explicit) return explicit;
|
|
85388
86282
|
const installed = installedDriverPath(dataDir2);
|
|
85389
|
-
return
|
|
86283
|
+
return existsSync5(installed) ? installed : binaryName();
|
|
85390
86284
|
}
|
|
85391
86285
|
async function installDriver(dataDir2, log40 = console.log) {
|
|
85392
86286
|
const target = installedDriverPath(dataDir2);
|
|
85393
|
-
if (
|
|
86287
|
+
if (existsSync5(target)) {
|
|
85394
86288
|
log40(`Cua Driver ${CUA_DRIVER_VERSION} already installed at ${target}`);
|
|
85395
86289
|
return target;
|
|
85396
86290
|
}
|
|
@@ -85403,21 +86297,21 @@ async function installDriver(dataDir2, log40 = console.log) {
|
|
|
85403
86297
|
const bytes = Buffer.from(await response.arrayBuffer());
|
|
85404
86298
|
const digest = createHash4("sha256").update(bytes).digest("hex");
|
|
85405
86299
|
if (digest !== archive.sha256) throw new Error(`checksum mismatch for ${archive.file}: ${digest}`);
|
|
85406
|
-
const parent =
|
|
85407
|
-
|
|
85408
|
-
const staging =
|
|
86300
|
+
const parent = join8(dataDir2, "cua-driver");
|
|
86301
|
+
mkdirSync5(parent, { recursive: true });
|
|
86302
|
+
const staging = mkdtempSync2(join8(parent, ".staging-"));
|
|
85409
86303
|
try {
|
|
85410
|
-
const archivePath =
|
|
85411
|
-
|
|
85412
|
-
const tarCommand = process.platform === "win32" ?
|
|
86304
|
+
const archivePath = join8(staging, archive.file);
|
|
86305
|
+
writeFileSync5(archivePath, bytes);
|
|
86306
|
+
const tarCommand = process.platform === "win32" ? join8(process.env.SystemRoot ?? "C:\\Windows", "System32", "tar.exe") : "tar";
|
|
85413
86307
|
const tar = spawnSync2(tarCommand, ["-xf", archivePath, "-C", staging], { stdio: "inherit", windowsHide: true });
|
|
85414
86308
|
if (tar.status !== 0) throw new Error(`tar failed to extract ${archive.file}`);
|
|
85415
|
-
const extracted =
|
|
85416
|
-
if (!
|
|
85417
|
-
|
|
86309
|
+
const extracted = join8(staging, archive.file.replace(/\.(zip|tar\.gz)$/, ""));
|
|
86310
|
+
if (!existsSync5(join8(extracted, binaryName()))) throw new Error(`archive has no ${binaryName()}`);
|
|
86311
|
+
rmSync5(installedDriverDir(dataDir2), { recursive: true, force: true });
|
|
85418
86312
|
renameSync2(extracted, installedDriverDir(dataDir2));
|
|
85419
86313
|
} finally {
|
|
85420
|
-
|
|
86314
|
+
rmSync5(staging, { recursive: true, force: true });
|
|
85421
86315
|
}
|
|
85422
86316
|
log40(`Installed Cua Driver ${CUA_DRIVER_VERSION} at ${target}`);
|
|
85423
86317
|
return target;
|
|
@@ -85907,9 +86801,9 @@ data:
|
|
|
85907
86801
|
const streamId = crypto.randomUUID();
|
|
85908
86802
|
const initRequest = messages.find((m) => isInitializeRequest(m));
|
|
85909
86803
|
const clientProtocolVersion = initRequest ? initRequest.params.protocolVersion : req.headers.get("mcp-protocol-version") ?? DEFAULT_NEGOTIATED_PROTOCOL_VERSION;
|
|
85910
|
-
if (this._enableJsonResponse) return new Promise((
|
|
86804
|
+
if (this._enableJsonResponse) return new Promise((resolve5) => {
|
|
85911
86805
|
this._streamMapping.set(streamId, {
|
|
85912
|
-
resolveJson:
|
|
86806
|
+
resolveJson: resolve5,
|
|
85913
86807
|
cleanup: () => {
|
|
85914
86808
|
this._streamMapping.delete(streamId);
|
|
85915
86809
|
}
|
|
@@ -86145,7 +87039,7 @@ var X_ALREADY_SENT = "x-hono-already-sent";
|
|
|
86145
87039
|
|
|
86146
87040
|
// ../../node_modules/.pnpm/@hono+node-server@2.1.5_hono@4.13.14/node_modules/@hono/node-server/dist/index.mjs
|
|
86147
87041
|
import { STATUS_CODES, ServerResponse, createServer } from "node:http";
|
|
86148
|
-
import { Http2ServerRequest, constants } from "node:http2";
|
|
87042
|
+
import { Http2ServerRequest, constants as constants2 } from "node:http2";
|
|
86149
87043
|
import { Readable } from "node:stream";
|
|
86150
87044
|
|
|
86151
87045
|
// ../../node_modules/.pnpm/hono@4.13.14/node_modules/hono/dist/helper/websocket/index.js
|
|
@@ -86201,11 +87095,11 @@ var validHeaderName = /^[!#$%&'*+\-.^_`|~\dA-Za-z]+$/;
|
|
|
86201
87095
|
var isHttpWhitespace = (code) => code === 9 || code === 10 || code === 13 || code === 32;
|
|
86202
87096
|
var normalizeHeaderValue = (value) => {
|
|
86203
87097
|
if (!isHttpWhitespace(value.charCodeAt(0)) && !isHttpWhitespace(value.charCodeAt(value.length - 1))) return value;
|
|
86204
|
-
let
|
|
87098
|
+
let start2 = 0;
|
|
86205
87099
|
let end = value.length;
|
|
86206
|
-
while (
|
|
86207
|
-
while (end >
|
|
86208
|
-
return value.slice(
|
|
87100
|
+
while (start2 < end && isHttpWhitespace(value.charCodeAt(start2))) start2++;
|
|
87101
|
+
while (end > start2 && isHttpWhitespace(value.charCodeAt(end - 1))) end--;
|
|
87102
|
+
return value.slice(start2, end);
|
|
86209
87103
|
};
|
|
86210
87104
|
var forbiddenHeaderValue = /[\0\r\n]/;
|
|
86211
87105
|
var GlobalHeaders = globalThis.Headers;
|
|
@@ -86559,7 +87453,7 @@ var readBodyDirect = (request2) => {
|
|
|
86559
87453
|
request2[bodyBufferKey] = buffered;
|
|
86560
87454
|
return Promise.resolve(buffered);
|
|
86561
87455
|
}
|
|
86562
|
-
const promise2 = new Promise((
|
|
87456
|
+
const promise2 = new Promise((resolve5, reject) => {
|
|
86563
87457
|
const chunks = [];
|
|
86564
87458
|
let settled = false;
|
|
86565
87459
|
const finish = (callback) => {
|
|
@@ -86577,7 +87471,7 @@ var readBodyDirect = (request2) => {
|
|
|
86577
87471
|
else if (recovered === void 0) reject(error63 ?? normalizeAbortError(request2, incoming));
|
|
86578
87472
|
else {
|
|
86579
87473
|
request2[bodyBufferKey] = recovered;
|
|
86580
|
-
|
|
87474
|
+
resolve5(recovered);
|
|
86581
87475
|
}
|
|
86582
87476
|
});
|
|
86583
87477
|
return true;
|
|
@@ -86589,7 +87483,7 @@ var readBodyDirect = (request2) => {
|
|
|
86589
87483
|
finish(() => {
|
|
86590
87484
|
const buffer3 = chunks.length === 1 ? chunks[0] : Buffer.concat(chunks);
|
|
86591
87485
|
request2[bodyBufferKey] = buffer3;
|
|
86592
|
-
|
|
87486
|
+
resolve5(buffer3);
|
|
86593
87487
|
});
|
|
86594
87488
|
};
|
|
86595
87489
|
const onError = (error63) => {
|
|
@@ -86963,7 +87857,7 @@ var drainIncoming = (incoming) => {
|
|
|
86963
87857
|
incomingWithDrainState[incomingDraining] = true;
|
|
86964
87858
|
if (incoming instanceof Http2ServerRequest) {
|
|
86965
87859
|
try {
|
|
86966
|
-
incoming.stream?.close?.(
|
|
87860
|
+
incoming.stream?.close?.(constants2.NGHTTP2_NO_ERROR);
|
|
86967
87861
|
} catch {
|
|
86968
87862
|
}
|
|
86969
87863
|
return;
|
|
@@ -87136,7 +88030,7 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
|
|
|
87136
88030
|
});
|
|
87137
88031
|
if (!chunk) {
|
|
87138
88032
|
if (i === 1) {
|
|
87139
|
-
await new Promise((
|
|
88033
|
+
await new Promise((resolve5) => setTimeout(resolve5));
|
|
87140
88034
|
maxReadCount = 3;
|
|
87141
88035
|
continue;
|
|
87142
88036
|
}
|
|
@@ -87456,7 +88350,7 @@ var NodeStreamableHTTPServerTransport = class {
|
|
|
87456
88350
|
|
|
87457
88351
|
// src/local-controls.ts
|
|
87458
88352
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
87459
|
-
import { existsSync as
|
|
88353
|
+
import { existsSync as existsSync6 } from "node:fs";
|
|
87460
88354
|
|
|
87461
88355
|
// src/linux/tray.ts
|
|
87462
88356
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
@@ -87491,13 +88385,13 @@ var ALIGN = {
|
|
|
87491
88385
|
"(": 8,
|
|
87492
88386
|
"{": 8
|
|
87493
88387
|
};
|
|
87494
|
-
function typeEnd(signature,
|
|
87495
|
-
const c = signature[
|
|
88388
|
+
function typeEnd(signature, start2) {
|
|
88389
|
+
const c = signature[start2];
|
|
87496
88390
|
if (c === void 0) throw new Error(`truncated signature ${signature}`);
|
|
87497
|
-
if (c === "a") return typeEnd(signature,
|
|
88391
|
+
if (c === "a") return typeEnd(signature, start2 + 1);
|
|
87498
88392
|
if (c === "(" || c === "{") {
|
|
87499
88393
|
const close = c === "(" ? ")" : "}";
|
|
87500
|
-
let i =
|
|
88394
|
+
let i = start2 + 1;
|
|
87501
88395
|
while (signature[i] !== close) {
|
|
87502
88396
|
if (i >= signature.length) throw new Error(`unbalanced signature ${signature}`);
|
|
87503
88397
|
i = typeEnd(signature, i);
|
|
@@ -87505,7 +88399,7 @@ function typeEnd(signature, start) {
|
|
|
87505
88399
|
return i + 1;
|
|
87506
88400
|
}
|
|
87507
88401
|
if (!(c in ALIGN)) throw new Error(`unsupported type ${c} in ${signature}`);
|
|
87508
|
-
return
|
|
88402
|
+
return start2 + 1;
|
|
87509
88403
|
}
|
|
87510
88404
|
function splitSignature(signature) {
|
|
87511
88405
|
const types22 = [];
|
|
@@ -87610,7 +88504,7 @@ var Writer = class {
|
|
|
87610
88504
|
const lengthAt = this.length;
|
|
87611
88505
|
this.u32(0);
|
|
87612
88506
|
this.align(ALIGN[element[0]]);
|
|
87613
|
-
const
|
|
88507
|
+
const start2 = this.length;
|
|
87614
88508
|
if (element === "y" && Buffer.isBuffer(value)) this.raw(value);
|
|
87615
88509
|
else if (element[0] === "{") {
|
|
87616
88510
|
const [keyType, valueType] = splitSignature(element.slice(1, -1));
|
|
@@ -87620,7 +88514,7 @@ var Writer = class {
|
|
|
87620
88514
|
this.write(valueType, v);
|
|
87621
88515
|
}
|
|
87622
88516
|
} else for (const item of value) this.write(element, item);
|
|
87623
|
-
return this.u32(this.length -
|
|
88517
|
+
return this.u32(this.length - start2, lengthAt);
|
|
87624
88518
|
}
|
|
87625
88519
|
case "(":
|
|
87626
88520
|
return this.writeAll(type.slice(1, -1), value);
|
|
@@ -87629,11 +88523,11 @@ var Writer = class {
|
|
|
87629
88523
|
}
|
|
87630
88524
|
}
|
|
87631
88525
|
};
|
|
87632
|
-
var
|
|
87633
|
-
constructor(buffer3, littleEndian = true,
|
|
88526
|
+
var Reader2 = class {
|
|
88527
|
+
constructor(buffer3, littleEndian = true, start2 = 0) {
|
|
87634
88528
|
this.buffer = buffer3;
|
|
87635
88529
|
this.littleEndian = littleEndian;
|
|
87636
|
-
this.offset =
|
|
88530
|
+
this.offset = start2;
|
|
87637
88531
|
}
|
|
87638
88532
|
buffer;
|
|
87639
88533
|
littleEndian;
|
|
@@ -87782,7 +88676,7 @@ function messageLength(buffer3) {
|
|
|
87782
88676
|
}
|
|
87783
88677
|
function decodeMessage(buffer3) {
|
|
87784
88678
|
const le = buffer3[0] === 108;
|
|
87785
|
-
const reader = new
|
|
88679
|
+
const reader = new Reader2(buffer3, le, 4);
|
|
87786
88680
|
const bodyLength = reader.read("u");
|
|
87787
88681
|
const serial = reader.read("u");
|
|
87788
88682
|
const fields = reader.read("a(yv)");
|
|
@@ -87794,7 +88688,7 @@ function decodeMessage(buffer3) {
|
|
|
87794
88688
|
if (name) message[name] = variant.value;
|
|
87795
88689
|
}
|
|
87796
88690
|
if (message.signature && bodyLength > 0) {
|
|
87797
|
-
message.body = new
|
|
88691
|
+
message.body = new Reader2(buffer3.subarray(0, reader.offset + bodyLength), le, reader.offset).readAll(
|
|
87798
88692
|
message.signature
|
|
87799
88693
|
);
|
|
87800
88694
|
}
|
|
@@ -87845,7 +88739,7 @@ var DBusConnection = class _DBusConnection {
|
|
|
87845
88739
|
const path = busSocketPath(address);
|
|
87846
88740
|
if (!path) throw new Error("no session bus (DBUS_SESSION_BUS_ADDRESS is unset or not a unix socket)");
|
|
87847
88741
|
const socket = createConnection2(path);
|
|
87848
|
-
await new Promise((
|
|
88742
|
+
await new Promise((resolve5, reject) => {
|
|
87849
88743
|
let data = "";
|
|
87850
88744
|
const timer = setTimeout(() => fail(new Error("D-Bus authentication timed out")), timeoutMs);
|
|
87851
88745
|
const fail = (error63) => {
|
|
@@ -87861,7 +88755,7 @@ var DBusConnection = class _DBusConnection {
|
|
|
87861
88755
|
socket.off("error", fail);
|
|
87862
88756
|
if (!data.startsWith("OK ")) return fail(new Error(`D-Bus refused authentication: ${data.trim()}`));
|
|
87863
88757
|
socket.write("BEGIN\r\n");
|
|
87864
|
-
|
|
88758
|
+
resolve5();
|
|
87865
88759
|
};
|
|
87866
88760
|
socket.once("error", fail);
|
|
87867
88761
|
socket.on("data", onData);
|
|
@@ -87892,7 +88786,7 @@ var DBusConnection = class _DBusConnection {
|
|
|
87892
88786
|
if (this.closed) throw new Error("D-Bus connection closed");
|
|
87893
88787
|
const serial = this.nextSerial();
|
|
87894
88788
|
const timeoutMs = call.timeoutMs ?? this.callTimeoutMs;
|
|
87895
|
-
const reply2 = new Promise((
|
|
88789
|
+
const reply2 = new Promise((resolve5, reject) => {
|
|
87896
88790
|
const timer = setTimeout(() => {
|
|
87897
88791
|
this.pending.delete(serial);
|
|
87898
88792
|
reject(
|
|
@@ -87903,7 +88797,7 @@ var DBusConnection = class _DBusConnection {
|
|
|
87903
88797
|
}, timeoutMs);
|
|
87904
88798
|
timer.unref?.();
|
|
87905
88799
|
this.pending.set(serial, {
|
|
87906
|
-
resolve: (message2) => (clearTimeout(timer),
|
|
88800
|
+
resolve: (message2) => (clearTimeout(timer), resolve5(message2)),
|
|
87907
88801
|
reject: (error63) => (clearTimeout(timer), reject(error63))
|
|
87908
88802
|
});
|
|
87909
88803
|
});
|
|
@@ -88285,7 +89179,7 @@ init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
|
88285
89179
|
|
|
88286
89180
|
// src/tray-helper.ts
|
|
88287
89181
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
88288
|
-
import { spawn as
|
|
89182
|
+
import { spawn as spawn6 } from "node:child_process";
|
|
88289
89183
|
import { createInterface as createInterface2 } from "node:readline";
|
|
88290
89184
|
var HelperTray = class _HelperTray {
|
|
88291
89185
|
constructor(child2, options) {
|
|
@@ -88299,7 +89193,7 @@ var HelperTray = class _HelperTray {
|
|
|
88299
89193
|
last = "";
|
|
88300
89194
|
closed = false;
|
|
88301
89195
|
static start(path, options) {
|
|
88302
|
-
const child2 = (options.spawnHelper ?? ((file2) =>
|
|
89196
|
+
const child2 = (options.spawnHelper ?? ((file2) => spawn6(file2, [], { stdio: ["pipe", "pipe", "inherit"] })))(path);
|
|
88303
89197
|
const tray = new _HelperTray(child2, options);
|
|
88304
89198
|
child2.stdin?.on("error", () => void 0);
|
|
88305
89199
|
child2.on("error", (error63) => tray.gone(`cannot start the menu bar helper: ${error63.message}`));
|
|
@@ -88452,7 +89346,7 @@ function menuBarMenu(tray, facts, busy = /* @__PURE__ */ new Set()) {
|
|
|
88452
89346
|
items
|
|
88453
89347
|
};
|
|
88454
89348
|
}
|
|
88455
|
-
function startMenuBar(helper, host, initial,
|
|
89349
|
+
function startMenuBar(helper, host, initial, start2 = HelperTray.start) {
|
|
88456
89350
|
let tray = initial;
|
|
88457
89351
|
let facts;
|
|
88458
89352
|
const busy = /* @__PURE__ */ new Set();
|
|
@@ -88518,7 +89412,7 @@ function startMenuBar(helper, host, initial, start = HelperTray.start) {
|
|
|
88518
89412
|
return host.quit();
|
|
88519
89413
|
}
|
|
88520
89414
|
};
|
|
88521
|
-
const helperTray =
|
|
89415
|
+
const helperTray = start2(helper, {
|
|
88522
89416
|
onClick: click,
|
|
88523
89417
|
onMenuOpen: () => void refresh(),
|
|
88524
89418
|
onRestart: () => {
|
|
@@ -88627,14 +89521,14 @@ function startHelperLocalControls(options, platform) {
|
|
|
88627
89521
|
const actions = ownerActions(options);
|
|
88628
89522
|
const helper = options.menuBar?.helper;
|
|
88629
89523
|
const texts = HELPER_PROBLEMS[platform];
|
|
88630
|
-
const problem = !options.menuBar ? "no menu bar host" : !helper ? texts.outside : !
|
|
89524
|
+
const problem = !options.menuBar ? "no menu bar host" : !helper ? texts.outside : !existsSync6(helper) ? texts.missing : void 0;
|
|
88631
89525
|
const spawnHelper = options.menuBar?.spawnHelper;
|
|
88632
|
-
const
|
|
89526
|
+
const start2 = options.startHelperTray ?? HelperTray.start;
|
|
88633
89527
|
const menuBar = problem || !helper || !options.menuBar ? void 0 : startMenuBar(
|
|
88634
89528
|
helper,
|
|
88635
89529
|
{ ...options.menuBar.host, stop: () => actions.stop(TRAY_STOP_REASON), resume: actions.resume, log: log40 },
|
|
88636
89530
|
trayState(computer, options.refusal()),
|
|
88637
|
-
spawnHelper ? (path, helperOptions) =>
|
|
89531
|
+
spawnHelper ? (path, helperOptions) => start2(path, { ...helperOptions, spawnHelper }) : start2
|
|
88638
89532
|
);
|
|
88639
89533
|
return refreshing(
|
|
88640
89534
|
{
|
|
@@ -88734,31 +89628,31 @@ async function startLocalControls(options) {
|
|
|
88734
89628
|
// src/self.ts
|
|
88735
89629
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
88736
89630
|
import { execFile } from "node:child_process";
|
|
88737
|
-
import { dirname as
|
|
89631
|
+
import { dirname as dirname4, resolve as resolve3 } from "node:path";
|
|
88738
89632
|
function runSelf(args, timeoutMs) {
|
|
88739
89633
|
const argv = [process.argv[1], ...args];
|
|
88740
|
-
return new Promise((
|
|
89634
|
+
return new Promise((resolve5, reject) => {
|
|
88741
89635
|
execFile(
|
|
88742
89636
|
process.execPath,
|
|
88743
89637
|
argv,
|
|
88744
89638
|
{ timeout: timeoutMs, killSignal: "SIGKILL", windowsHide: true },
|
|
88745
89639
|
(error63, stdout) => (
|
|
88746
89640
|
// doctor exits 1 when a check fails but still prints its JSON.
|
|
88747
|
-
stdout.trim() ?
|
|
89641
|
+
stdout.trim() ? resolve5(stdout) : reject(error63 ?? new Error("no output"))
|
|
88748
89642
|
)
|
|
88749
89643
|
);
|
|
88750
89644
|
});
|
|
88751
89645
|
}
|
|
88752
89646
|
var appBundlePath = () => /^(.*\.app)\/Contents\/MacOS\/[^/]+$/.exec(process.execPath)?.[1];
|
|
88753
|
-
var menuBarHelperPath = () => appBundlePath() ?
|
|
89647
|
+
var menuBarHelperPath = () => appBundlePath() ? resolve3(dirname4(process.execPath), "agentconnect-computer-menubar") : void 0;
|
|
88754
89648
|
var selfCommand = () => process.env.AGENTCONNECT_COMPUTER_COMMAND?.trim() || "agentconnect-computer";
|
|
88755
89649
|
var SERVICE_ENTRY_ENV = "AGENTCONNECT_COMPUTER_SERVICE_ENTRY";
|
|
88756
89650
|
var managedEntry = () => process.env[SERVICE_ENTRY_ENV]?.trim() || void 0;
|
|
88757
|
-
var serviceEntry = () => managedEntry() ??
|
|
89651
|
+
var serviceEntry = () => managedEntry() ?? resolve3(process.argv[1]);
|
|
88758
89652
|
|
|
88759
89653
|
// src/version.ts
|
|
88760
89654
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
88761
|
-
var COMPUTER_DAEMON_VERSION = true ? "2.12.0-rc.
|
|
89655
|
+
var COMPUTER_DAEMON_VERSION = true ? "2.12.0-rc.10" : JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
|
|
88762
89656
|
|
|
88763
89657
|
// src/http-server.ts
|
|
88764
89658
|
var CONTROL_HEADER = "x-agentconnect-computer";
|
|
@@ -88819,7 +89713,7 @@ async function startHttpServer(options) {
|
|
|
88819
89713
|
}
|
|
88820
89714
|
};
|
|
88821
89715
|
}
|
|
88822
|
-
var closeServer = (server) => new Promise((
|
|
89716
|
+
var closeServer = (server) => new Promise((resolve5, reject) => server.close((error63) => error63 ? reject(error63) : resolve5()));
|
|
88823
89717
|
async function listenLocalControl(options, port) {
|
|
88824
89718
|
if (isLoopbackHost(options.host) || isWildcardHost(options.host)) return void 0;
|
|
88825
89719
|
const local = createServer2(async (req, res) => {
|
|
@@ -88890,14 +89784,14 @@ async function control(req, res, path, options) {
|
|
|
88890
89784
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
88891
89785
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
88892
89786
|
import { createHash as createHash5 } from "node:crypto";
|
|
88893
|
-
import { existsSync as
|
|
88894
|
-
import { join as
|
|
89787
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync7, mkdtempSync as mkdtempSync3, renameSync as renameSync3, rmSync as rmSync6, writeFileSync as writeFileSync7 } from "node:fs";
|
|
89788
|
+
import { join as join10 } from "node:path";
|
|
88895
89789
|
import { gunzipSync } from "node:zlib";
|
|
88896
89790
|
|
|
88897
89791
|
// src/stream/wayland-capture.ts
|
|
88898
89792
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
88899
|
-
import { mkdirSync as
|
|
88900
|
-
import { join as
|
|
89793
|
+
import { mkdirSync as mkdirSync6, writeFileSync as writeFileSync6 } from "node:fs";
|
|
89794
|
+
import { join as join9 } from "node:path";
|
|
88901
89795
|
var waylandSession = () => process.platform === "linux" && Boolean(process.env.WAYLAND_DISPLAY);
|
|
88902
89796
|
var HELPER = String.raw`#!/usr/bin/env python3
|
|
88903
89797
|
# Usage: screencast.py TOKEN_FILE FPS CURSOR(1|0) [FRAMES]. Asks the ScreenCast portal for the monitor (persisting a restore
|
|
@@ -88975,12 +89869,12 @@ signal.signal(signal.SIGTERM, lambda *_: child.terminate())
|
|
|
88975
89869
|
sys.exit(child.wait())
|
|
88976
89870
|
`;
|
|
88977
89871
|
function writeCaptureHelper(dataDir2) {
|
|
88978
|
-
|
|
88979
|
-
const path =
|
|
88980
|
-
|
|
89872
|
+
mkdirSync6(dataDir2, { recursive: true });
|
|
89873
|
+
const path = join9(dataDir2, "screencast.py");
|
|
89874
|
+
writeFileSync6(path, HELPER, { mode: 493 });
|
|
88981
89875
|
return path;
|
|
88982
89876
|
}
|
|
88983
|
-
var screencastTokenPath = (dataDir2) =>
|
|
89877
|
+
var screencastTokenPath = (dataDir2) => join9(dataDir2, "screencast.token");
|
|
88984
89878
|
|
|
88985
89879
|
// src/stream/ffmpeg.ts
|
|
88986
89880
|
var GYAN = "9.0.2";
|
|
@@ -89019,11 +89913,11 @@ var FFMPEG_BUILDS = {
|
|
|
89019
89913
|
var pinnedBuild = () => FFMPEG_BUILDS[process.platform] ?? FFMPEG_BUILDS[`${process.platform}-${process.arch}`];
|
|
89020
89914
|
var FFMPEG_VERSION = pinnedBuild()?.version ?? "system";
|
|
89021
89915
|
var binaryName2 = () => process.platform === "win32" ? "ffmpeg.exe" : "ffmpeg";
|
|
89022
|
-
var installedFfmpegPath = (dataDir2) =>
|
|
89916
|
+
var installedFfmpegPath = (dataDir2) => join10(dataDir2, "ffmpeg", FFMPEG_VERSION, binaryName2());
|
|
89023
89917
|
function resolveFfmpegPath(dataDir2, explicit) {
|
|
89024
89918
|
if (explicit) return explicit;
|
|
89025
89919
|
const installed = installedFfmpegPath(dataDir2);
|
|
89026
|
-
return
|
|
89920
|
+
return existsSync7(installed) ? installed : binaryName2();
|
|
89027
89921
|
}
|
|
89028
89922
|
function ffmpegAvailable(command) {
|
|
89029
89923
|
const probe = spawnSync3(command, ["-hide_banner", "-version"], { stdio: "ignore", windowsHide: true });
|
|
@@ -89041,7 +89935,7 @@ function installFfmpeg(dataDir2, log40 = console.log) {
|
|
|
89041
89935
|
return download;
|
|
89042
89936
|
}
|
|
89043
89937
|
async function downloadFfmpeg(dataDir2, target, log40) {
|
|
89044
|
-
if (
|
|
89938
|
+
if (existsSync7(target)) return target;
|
|
89045
89939
|
const build3 = pinnedBuild();
|
|
89046
89940
|
if (!build3) throw new Error("no pinned ffmpeg for this platform; install it with your package manager");
|
|
89047
89941
|
log40(`Downloading ${build3.url} (for the WebRTC viewer)`);
|
|
@@ -89050,28 +89944,28 @@ async function downloadFfmpeg(dataDir2, target, log40) {
|
|
|
89050
89944
|
const bytes = Buffer.from(await response.arrayBuffer());
|
|
89051
89945
|
const digest = createHash5("sha256").update(bytes).digest("hex");
|
|
89052
89946
|
if (digest !== build3.sha256) throw new Error(`checksum mismatch for ffmpeg ${build3.version}: ${digest}`);
|
|
89053
|
-
const parent =
|
|
89054
|
-
|
|
89055
|
-
const staging =
|
|
89947
|
+
const parent = join10(dataDir2, "ffmpeg");
|
|
89948
|
+
mkdirSync7(parent, { recursive: true });
|
|
89949
|
+
const staging = mkdtempSync3(join10(parent, ".staging-"));
|
|
89056
89950
|
try {
|
|
89057
|
-
const extracted =
|
|
89951
|
+
const extracted = join10(staging, binaryName2());
|
|
89058
89952
|
if (build3.member) {
|
|
89059
|
-
const archivePath =
|
|
89060
|
-
|
|
89061
|
-
const tarCommand =
|
|
89953
|
+
const archivePath = join10(staging, "ffmpeg.zip");
|
|
89954
|
+
writeFileSync7(archivePath, bytes);
|
|
89955
|
+
const tarCommand = join10(process.env.SystemRoot ?? "C:\\Windows", "System32", "tar.exe");
|
|
89062
89956
|
const tar = spawnSync3(tarCommand, ["-xf", archivePath, "-C", staging, build3.member], {
|
|
89063
89957
|
stdio: "inherit",
|
|
89064
89958
|
windowsHide: true
|
|
89065
89959
|
});
|
|
89066
89960
|
if (tar.status !== 0) throw new Error("tar failed to extract ffmpeg");
|
|
89067
|
-
renameSync3(
|
|
89961
|
+
renameSync3(join10(staging, ...build3.member.split("/")), extracted);
|
|
89068
89962
|
} else {
|
|
89069
|
-
|
|
89963
|
+
writeFileSync7(extracted, gunzipSync(bytes), { mode: 493 });
|
|
89070
89964
|
}
|
|
89071
|
-
|
|
89965
|
+
mkdirSync7(join10(parent, build3.version), { recursive: true });
|
|
89072
89966
|
renameSync3(extracted, target);
|
|
89073
89967
|
} finally {
|
|
89074
|
-
|
|
89968
|
+
rmSync6(staging, { recursive: true, force: true });
|
|
89075
89969
|
}
|
|
89076
89970
|
log40(`Installed ffmpeg ${build3.version} at ${target}`);
|
|
89077
89971
|
return target;
|
|
@@ -89219,6 +90113,7 @@ function encodeArgs(settings, filters, rtpPort) {
|
|
|
89219
90113
|
// src/stream/rtc.ts
|
|
89220
90114
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
89221
90115
|
import { randomUUID as randomUUID12 } from "node:crypto";
|
|
90116
|
+
import { isIPv4 as isIPv45 } from "node:net";
|
|
89222
90117
|
|
|
89223
90118
|
// ../../node_modules/.pnpm/werift@0.25.2_supports-color@7.2.0/node_modules/werift/lib/index.mjs
|
|
89224
90119
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
@@ -89840,14 +90735,14 @@ function Field(ORDER, bitLenOrOpts, isLE = false, opts = {}) {
|
|
|
89840
90735
|
}
|
|
89841
90736
|
if (bytes.length !== BYTES)
|
|
89842
90737
|
throw new Error("Field.fromBytes: expected " + BYTES + " bytes, got " + bytes.length);
|
|
89843
|
-
let
|
|
90738
|
+
let scalar2 = isLE ? bytesToNumberLE(bytes) : bytesToNumberBE(bytes);
|
|
89844
90739
|
if (modFromBytes)
|
|
89845
|
-
|
|
90740
|
+
scalar2 = mod(scalar2, ORDER);
|
|
89846
90741
|
if (!skipValidation) {
|
|
89847
|
-
if (!f.isValid(
|
|
90742
|
+
if (!f.isValid(scalar2))
|
|
89848
90743
|
throw new Error("invalid field element: outside of range 0..ORDER");
|
|
89849
90744
|
}
|
|
89850
|
-
return
|
|
90745
|
+
return scalar2;
|
|
89851
90746
|
},
|
|
89852
90747
|
// TODO: we don't need it here, move out to separate fn
|
|
89853
90748
|
invertBatch: (lst) => FpInvertBatch(f, lst),
|
|
@@ -90683,15 +91578,15 @@ var wNAF = class {
|
|
|
90683
91578
|
}
|
|
90684
91579
|
return comp;
|
|
90685
91580
|
}
|
|
90686
|
-
cached(point,
|
|
91581
|
+
cached(point, scalar2, transform2) {
|
|
90687
91582
|
const W = getW(point);
|
|
90688
|
-
return this.wNAF(W, this.getPrecomputes(W, point, transform2),
|
|
91583
|
+
return this.wNAF(W, this.getPrecomputes(W, point, transform2), scalar2);
|
|
90689
91584
|
}
|
|
90690
|
-
unsafe(point,
|
|
91585
|
+
unsafe(point, scalar2, transform2, prev) {
|
|
90691
91586
|
const W = getW(point);
|
|
90692
91587
|
if (W === 1)
|
|
90693
|
-
return this._unsafeLadder(point,
|
|
90694
|
-
return this.wNAFUnsafe(W, this.getPrecomputes(W, point, transform2),
|
|
91588
|
+
return this._unsafeLadder(point, scalar2, prev);
|
|
91589
|
+
return this.wNAFUnsafe(W, this.getPrecomputes(W, point, transform2), scalar2, prev);
|
|
90695
91590
|
}
|
|
90696
91591
|
// We calculate precomputes for elliptic curve point multiplication
|
|
90697
91592
|
// using windowed method. This specifies window size and
|
|
@@ -90743,8 +91638,8 @@ function pippenger(c, fieldN, points, scalars) {
|
|
|
90743
91638
|
for (let i = lastBits; i >= 0; i -= windowSize) {
|
|
90744
91639
|
buckets.fill(zero);
|
|
90745
91640
|
for (let j = 0; j < slength; j++) {
|
|
90746
|
-
const
|
|
90747
|
-
const wbits2 = Number(
|
|
91641
|
+
const scalar2 = scalars[j];
|
|
91642
|
+
const wbits2 = Number(scalar2 >> BigInt(i) & MASK);
|
|
90748
91643
|
buckets[wbits2] = buckets[wbits2].add(points[j]);
|
|
90749
91644
|
}
|
|
90750
91645
|
let resI = zero;
|
|
@@ -91277,20 +92172,20 @@ function weierstrassN(params, extraOpts = {}) {
|
|
|
91277
92172
|
* @param scalar by which the point would be multiplied
|
|
91278
92173
|
* @returns New point
|
|
91279
92174
|
*/
|
|
91280
|
-
multiply(
|
|
92175
|
+
multiply(scalar2) {
|
|
91281
92176
|
const { endo: endo2 } = extraOpts;
|
|
91282
|
-
if (!Fn.isValidNot0(
|
|
92177
|
+
if (!Fn.isValidNot0(scalar2))
|
|
91283
92178
|
throw new Error("invalid scalar: out of range");
|
|
91284
92179
|
let point, fake;
|
|
91285
92180
|
const mul = (n) => wnaf.cached(this, n, (p) => normalizeZ(Point3, p));
|
|
91286
92181
|
if (endo2) {
|
|
91287
|
-
const { k1neg, k1, k2neg, k2 } = splitEndoScalarN(
|
|
92182
|
+
const { k1neg, k1, k2neg, k2 } = splitEndoScalarN(scalar2);
|
|
91288
92183
|
const { p: k1p, f: k1f } = mul(k1);
|
|
91289
92184
|
const { p: k2p, f: k2f } = mul(k2);
|
|
91290
92185
|
fake = k1f.add(k2f);
|
|
91291
92186
|
point = finishEndo(endo2.beta, k1p, k2p, k1neg, k2neg);
|
|
91292
92187
|
} else {
|
|
91293
|
-
const { p, f } = mul(
|
|
92188
|
+
const { p, f } = mul(scalar2);
|
|
91294
92189
|
point = p;
|
|
91295
92190
|
fake = f;
|
|
91296
92191
|
}
|
|
@@ -92161,7 +93056,7 @@ function crc32(input2, seed = 0) {
|
|
|
92161
93056
|
}
|
|
92162
93057
|
return crcGenericString(input2, seed, table32);
|
|
92163
93058
|
}
|
|
92164
|
-
function
|
|
93059
|
+
function crc32c2(input2, seed = 0) {
|
|
92165
93060
|
if (isBufferLike(input2)) {
|
|
92166
93061
|
return crcBuffer(input2, seed, table32c, tables32cBy16);
|
|
92167
93062
|
}
|
|
@@ -92331,7 +93226,7 @@ var Event2 = class {
|
|
|
92331
93226
|
error63
|
|
92332
93227
|
);
|
|
92333
93228
|
};
|
|
92334
|
-
watch = (cb, timeLimit) => new Promise((
|
|
93229
|
+
watch = (cb, timeLimit) => new Promise((resolve5, reject) => {
|
|
92335
93230
|
const timeout = timeLimit && setTimeout(() => {
|
|
92336
93231
|
reject("Event watch timeout");
|
|
92337
93232
|
}, timeLimit);
|
|
@@ -92340,22 +93235,22 @@ var Event2 = class {
|
|
|
92340
93235
|
if (done) {
|
|
92341
93236
|
if (timeout) clearTimeout(timeout);
|
|
92342
93237
|
unSubscribe();
|
|
92343
|
-
|
|
93238
|
+
resolve5(args);
|
|
92344
93239
|
}
|
|
92345
93240
|
});
|
|
92346
93241
|
});
|
|
92347
|
-
asPromise = (timeLimit) => new Promise((
|
|
93242
|
+
asPromise = (timeLimit) => new Promise((resolve5, reject) => {
|
|
92348
93243
|
const timeout = timeLimit && setTimeout(() => {
|
|
92349
93244
|
reject("Event asPromise timeout");
|
|
92350
93245
|
}, timeLimit);
|
|
92351
93246
|
this.once(
|
|
92352
93247
|
(...args) => {
|
|
92353
93248
|
if (timeout) clearTimeout(timeout);
|
|
92354
|
-
|
|
93249
|
+
resolve5(args);
|
|
92355
93250
|
},
|
|
92356
93251
|
() => {
|
|
92357
93252
|
if (timeout) clearTimeout(timeout);
|
|
92358
|
-
|
|
93253
|
+
resolve5([]);
|
|
92359
93254
|
},
|
|
92360
93255
|
(err5) => {
|
|
92361
93256
|
if (timeout) clearTimeout(timeout);
|
|
@@ -92595,7 +93490,7 @@ var StreamTransport = class {
|
|
|
92595
93490
|
}
|
|
92596
93491
|
const client = this.createClient();
|
|
92597
93492
|
this.client = client;
|
|
92598
|
-
this.connecting = new Promise((
|
|
93493
|
+
this.connecting = new Promise((resolve5, reject) => {
|
|
92599
93494
|
let settled = false;
|
|
92600
93495
|
const settle2 = (error63) => {
|
|
92601
93496
|
if (settled) return;
|
|
@@ -92604,7 +93499,7 @@ var StreamTransport = class {
|
|
|
92604
93499
|
client.off(this.connectEvent, onConnect);
|
|
92605
93500
|
client.off("error", onConnectError);
|
|
92606
93501
|
this.rejectConnecting = void 0;
|
|
92607
|
-
error63 ? reject(error63) :
|
|
93502
|
+
error63 ? reject(error63) : resolve5();
|
|
92608
93503
|
};
|
|
92609
93504
|
const onConnect = () => {
|
|
92610
93505
|
settle2();
|
|
@@ -92651,13 +93546,13 @@ var StreamTransport = class {
|
|
|
92651
93546
|
send = async (data, addr) => {
|
|
92652
93547
|
void addr;
|
|
92653
93548
|
await this.connecting;
|
|
92654
|
-
await new Promise((
|
|
93549
|
+
await new Promise((resolve5, reject) => {
|
|
92655
93550
|
this.client.write(data, (err5) => {
|
|
92656
93551
|
if (err5) {
|
|
92657
93552
|
reject(err5);
|
|
92658
93553
|
return;
|
|
92659
93554
|
}
|
|
92660
|
-
|
|
93555
|
+
resolve5();
|
|
92661
93556
|
});
|
|
92662
93557
|
});
|
|
92663
93558
|
};
|
|
@@ -93387,7 +94282,7 @@ var FragmentedHandshake = class _FragmentedHandshake {
|
|
|
93387
94282
|
return encode32(this, _FragmentedHandshake.spec);
|
|
93388
94283
|
}
|
|
93389
94284
|
chunk(maxFragmentLength) {
|
|
93390
|
-
let
|
|
94285
|
+
let start2 = 0;
|
|
93391
94286
|
const totalLength = this.fragment.length;
|
|
93392
94287
|
if (totalLength === 0)
|
|
93393
94288
|
return [
|
|
@@ -93395,7 +94290,7 @@ var FragmentedHandshake = class _FragmentedHandshake {
|
|
|
93395
94290
|
this.msg_type,
|
|
93396
94291
|
totalLength,
|
|
93397
94292
|
this.message_seq,
|
|
93398
|
-
|
|
94293
|
+
start2,
|
|
93399
94294
|
0,
|
|
93400
94295
|
this.fragment
|
|
93401
94296
|
)
|
|
@@ -93404,10 +94299,10 @@ var FragmentedHandshake = class _FragmentedHandshake {
|
|
|
93404
94299
|
if (!maxFragmentLength) {
|
|
93405
94300
|
maxFragmentLength = 1280 - (20 + 8) - (1 + 3 + 2 + 3 + 3);
|
|
93406
94301
|
}
|
|
93407
|
-
while (
|
|
93408
|
-
const fragmentLength = Math.min(maxFragmentLength, totalLength -
|
|
94302
|
+
while (start2 < totalLength) {
|
|
94303
|
+
const fragmentLength = Math.min(maxFragmentLength, totalLength - start2);
|
|
93409
94304
|
const data = Buffer.from(
|
|
93410
|
-
this.fragment.slice(
|
|
94305
|
+
this.fragment.slice(start2, start2 + fragmentLength)
|
|
93411
94306
|
);
|
|
93412
94307
|
if (data.length <= 0) {
|
|
93413
94308
|
throw new Error(
|
|
@@ -93419,12 +94314,12 @@ var FragmentedHandshake = class _FragmentedHandshake {
|
|
|
93419
94314
|
this.msg_type,
|
|
93420
94315
|
totalLength,
|
|
93421
94316
|
this.message_seq,
|
|
93422
|
-
|
|
94317
|
+
start2,
|
|
93423
94318
|
data.length,
|
|
93424
94319
|
data
|
|
93425
94320
|
)
|
|
93426
94321
|
);
|
|
93427
|
-
|
|
94322
|
+
start2 += data.length;
|
|
93428
94323
|
}
|
|
93429
94324
|
return fragments;
|
|
93430
94325
|
}
|
|
@@ -94121,15 +95016,15 @@ function createCipher(cipher) {
|
|
|
94121
95016
|
}
|
|
94122
95017
|
return null;
|
|
94123
95018
|
}
|
|
94124
|
-
function createAEADCipher(id, name, block, kx,
|
|
95019
|
+
function createAEADCipher(id, name, block, kx, constants3, hash22 = "sha256") {
|
|
94125
95020
|
const cipher = new AEADCipher();
|
|
94126
95021
|
cipher.id = id;
|
|
94127
95022
|
cipher.name = name;
|
|
94128
95023
|
cipher.blockAlgorithm = block;
|
|
94129
95024
|
cipher.kx = kx;
|
|
94130
95025
|
cipher.hashAlgorithm = hash22;
|
|
94131
|
-
cipher.keyLength =
|
|
94132
|
-
cipher.nonceLength =
|
|
95026
|
+
cipher.keyLength = constants3.K_LEN;
|
|
95027
|
+
cipher.nonceLength = constants3.N_MAX;
|
|
94133
95028
|
cipher.nonceImplicitLength = 4;
|
|
94134
95029
|
cipher.nonceExplicitLength = 8;
|
|
94135
95030
|
cipher.ivLength = cipher.nonceImplicitLength;
|
|
@@ -97196,16 +98091,16 @@ var Alert = class _Alert {
|
|
|
97196
98091
|
var log11 = debug("werift-dtls : packages/dtls/record/receive.ts : log");
|
|
97197
98092
|
var err3 = debug("werift-dtls : packages/dtls/record/receive.ts : err");
|
|
97198
98093
|
var parsePacket = (data) => {
|
|
97199
|
-
let
|
|
98094
|
+
let start2 = 0;
|
|
97200
98095
|
const packets = [];
|
|
97201
|
-
while (data.length >
|
|
97202
|
-
const fragmentLength = data.readUInt16BE(
|
|
97203
|
-
if (data.length <
|
|
98096
|
+
while (data.length > start2) {
|
|
98097
|
+
const fragmentLength = data.readUInt16BE(start2 + 11);
|
|
98098
|
+
if (data.length < start2 + (12 + fragmentLength)) {
|
|
97204
98099
|
break;
|
|
97205
98100
|
}
|
|
97206
|
-
const packet = DtlsPlaintext.deSerialize(data.subarray(
|
|
98101
|
+
const packet = DtlsPlaintext.deSerialize(data.subarray(start2));
|
|
97207
98102
|
packets.push(packet);
|
|
97208
|
-
|
|
98103
|
+
start2 += 13 + fragmentLength;
|
|
97209
98104
|
}
|
|
97210
98105
|
return packets;
|
|
97211
98106
|
};
|
|
@@ -97233,14 +98128,14 @@ var parsePlainText = (dtls, cipher) => (plain) => {
|
|
|
97233
98128
|
throw error63;
|
|
97234
98129
|
}
|
|
97235
98130
|
try {
|
|
97236
|
-
let
|
|
98131
|
+
let start2 = 0;
|
|
97237
98132
|
const handshakes = [];
|
|
97238
|
-
while (raw.length >
|
|
98133
|
+
while (raw.length > start2) {
|
|
97239
98134
|
const handshake = FragmentedHandshake.deSerialize(
|
|
97240
|
-
raw.subarray(
|
|
98135
|
+
raw.subarray(start2)
|
|
97241
98136
|
);
|
|
97242
98137
|
handshakes.push({ type: 22, data: handshake });
|
|
97243
|
-
|
|
98138
|
+
start2 += handshake.fragment_length + 12;
|
|
97244
98139
|
}
|
|
97245
98140
|
return handshakes;
|
|
97246
98141
|
} catch (error63) {
|
|
@@ -98632,21 +99527,21 @@ var Transaction = class {
|
|
|
98632
99527
|
clearTimeout(this.waitTimer);
|
|
98633
99528
|
this.waitTimer = void 0;
|
|
98634
99529
|
}
|
|
98635
|
-
const
|
|
99530
|
+
const resolve5 = this.waitResolve;
|
|
98636
99531
|
this.waitResolve = void 0;
|
|
98637
|
-
|
|
99532
|
+
resolve5?.();
|
|
98638
99533
|
}
|
|
98639
99534
|
wait(ms) {
|
|
98640
|
-
return new Promise((
|
|
99535
|
+
return new Promise((resolve5) => {
|
|
98641
99536
|
if (this.ended || this.signal?.aborted) {
|
|
98642
|
-
|
|
99537
|
+
resolve5();
|
|
98643
99538
|
return;
|
|
98644
99539
|
}
|
|
98645
|
-
this.waitResolve =
|
|
99540
|
+
this.waitResolve = resolve5;
|
|
98646
99541
|
this.waitTimer = setTimeout(() => {
|
|
98647
99542
|
this.waitTimer = void 0;
|
|
98648
99543
|
this.waitResolve = void 0;
|
|
98649
|
-
|
|
99544
|
+
resolve5();
|
|
98650
99545
|
}, ms);
|
|
98651
99546
|
});
|
|
98652
99547
|
}
|
|
@@ -98704,14 +99599,14 @@ function addressFromSocket(socket) {
|
|
|
98704
99599
|
return [socket.remoteAddress, socket.remotePort];
|
|
98705
99600
|
}
|
|
98706
99601
|
async function waitForListening(server, host, port) {
|
|
98707
|
-
return await new Promise((
|
|
99602
|
+
return await new Promise((resolve5, reject) => {
|
|
98708
99603
|
const onError = (error63) => {
|
|
98709
99604
|
server.off("listening", onListening);
|
|
98710
99605
|
reject(error63);
|
|
98711
99606
|
};
|
|
98712
99607
|
const onListening = () => {
|
|
98713
99608
|
server.off("error", onError);
|
|
98714
|
-
|
|
99609
|
+
resolve5();
|
|
98715
99610
|
};
|
|
98716
99611
|
server.once("error", onError);
|
|
98717
99612
|
server.once("listening", onListening);
|
|
@@ -98835,13 +99730,13 @@ var BaseTcpProtocol = class _BaseTcpProtocol {
|
|
|
98835
99730
|
async sendFrame(data, addr) {
|
|
98836
99731
|
const entry = await this.getSocket(addr);
|
|
98837
99732
|
try {
|
|
98838
|
-
await new Promise((
|
|
99733
|
+
await new Promise((resolve5, reject) => {
|
|
98839
99734
|
entry.socket.write(encodeTcpFrame(data), (error63) => {
|
|
98840
99735
|
if (error63) {
|
|
98841
99736
|
reject(error63);
|
|
98842
99737
|
return;
|
|
98843
99738
|
}
|
|
98844
|
-
|
|
99739
|
+
resolve5();
|
|
98845
99740
|
});
|
|
98846
99741
|
});
|
|
98847
99742
|
} catch (error63) {
|
|
@@ -98922,7 +99817,7 @@ var TcpActiveProtocol = class extends BaseTcpProtocol {
|
|
|
98922
99817
|
if (pending) {
|
|
98923
99818
|
return await pending;
|
|
98924
99819
|
}
|
|
98925
|
-
const connecting = new Promise((
|
|
99820
|
+
const connecting = new Promise((resolve5, reject) => {
|
|
98926
99821
|
const socket = connect3({
|
|
98927
99822
|
host: addr[0],
|
|
98928
99823
|
port: addr[1],
|
|
@@ -98935,7 +99830,7 @@ var TcpActiveProtocol = class extends BaseTcpProtocol {
|
|
|
98935
99830
|
};
|
|
98936
99831
|
const onConnect = () => {
|
|
98937
99832
|
socket.off("error", onError);
|
|
98938
|
-
|
|
99833
|
+
resolve5(entry);
|
|
98939
99834
|
};
|
|
98940
99835
|
socket.once("error", onError);
|
|
98941
99836
|
socket.once("connect", onConnect);
|
|
@@ -98984,8 +99879,8 @@ var TcpPassiveProtocol = class extends BaseTcpProtocol {
|
|
|
98984
99879
|
}
|
|
98985
99880
|
async close() {
|
|
98986
99881
|
await super.close();
|
|
98987
|
-
await new Promise((
|
|
98988
|
-
this.server.close(() =>
|
|
99882
|
+
await new Promise((resolve5) => {
|
|
99883
|
+
this.server.close(() => resolve5());
|
|
98989
99884
|
});
|
|
98990
99885
|
}
|
|
98991
99886
|
};
|
|
@@ -99136,10 +100031,10 @@ var PQueue = class {
|
|
|
99136
100031
|
}
|
|
99137
100032
|
};
|
|
99138
100033
|
var cancelable = (ex) => {
|
|
99139
|
-
let
|
|
100034
|
+
let resolve5;
|
|
99140
100035
|
let reject;
|
|
99141
100036
|
const p = new Promise((r, f) => {
|
|
99142
|
-
|
|
100037
|
+
resolve5 = r;
|
|
99143
100038
|
reject = f;
|
|
99144
100039
|
});
|
|
99145
100040
|
p.then(() => {
|
|
@@ -99150,9 +100045,9 @@ var cancelable = (ex) => {
|
|
|
99150
100045
|
onCancel.complete();
|
|
99151
100046
|
});
|
|
99152
100047
|
const onCancel = new Event2();
|
|
99153
|
-
ex(
|
|
100048
|
+
ex(resolve5, reject, onCancel).catch(() => {
|
|
99154
100049
|
});
|
|
99155
|
-
return { awaitable: p, resolve:
|
|
100050
|
+
return { awaitable: p, resolve: resolve5, reject };
|
|
99156
100051
|
};
|
|
99157
100052
|
function isChannelData(data) {
|
|
99158
100053
|
return data.length >= 4 && (data[0] & 192) === 64;
|
|
@@ -100860,14 +101755,14 @@ var Connection = class {
|
|
|
100860
101755
|
return this.consentFresh;
|
|
100861
101756
|
}
|
|
100862
101757
|
abortableDelay(ms, signal) {
|
|
100863
|
-
return new Promise((
|
|
101758
|
+
return new Promise((resolve5, reject) => {
|
|
100864
101759
|
if (signal.aborted) {
|
|
100865
101760
|
reject(new DOMException("The operation was aborted", "AbortError"));
|
|
100866
101761
|
return;
|
|
100867
101762
|
}
|
|
100868
101763
|
const timer2 = setTimeout(() => {
|
|
100869
101764
|
signal.removeEventListener("abort", onAbort);
|
|
100870
|
-
|
|
101765
|
+
resolve5();
|
|
100871
101766
|
}, ms);
|
|
100872
101767
|
const onAbort = () => {
|
|
100873
101768
|
clearTimeout(timer2);
|
|
@@ -103988,7 +104883,7 @@ function parsePacket2(data) {
|
|
|
103988
104883
|
const destinationPort = data.readUInt16BE(2);
|
|
103989
104884
|
const verificationTag = data.readUInt32BE(4);
|
|
103990
104885
|
const checkSum = data.readUInt32LE(8);
|
|
103991
|
-
const expect =
|
|
104886
|
+
const expect = crc32c2(
|
|
103992
104887
|
Buffer.concat([
|
|
103993
104888
|
data.slice(0, 8),
|
|
103994
104889
|
Buffer.from("\0\0\0\0"),
|
|
@@ -104019,7 +104914,7 @@ function serializePacket(sourcePort, destinationPort, verificationTag, chunk) {
|
|
|
104019
104914
|
header.writeUInt16BE(destinationPort, 2);
|
|
104020
104915
|
header.writeUInt32BE(verificationTag, 4);
|
|
104021
104916
|
const body = chunk.bytes;
|
|
104022
|
-
const checksum =
|
|
104917
|
+
const checksum = crc32c2(
|
|
104023
104918
|
Buffer.concat([header, Buffer.from("\0\0\0\0"), body])
|
|
104024
104919
|
);
|
|
104025
104920
|
const checkSumBuf = Buffer.alloc(4);
|
|
@@ -107687,9 +108582,9 @@ var RTCRtpSender = class {
|
|
|
107687
108582
|
this.settlePendingRtp(item);
|
|
107688
108583
|
}
|
|
107689
108584
|
}
|
|
107690
|
-
enqueuePendingRtp(rtp,
|
|
108585
|
+
enqueuePendingRtp(rtp, resolve5, reject) {
|
|
107691
108586
|
const packet = Buffer.isBuffer(rtp) ? RtpPacket.deSerialize(rtp) : rtp.clone();
|
|
107692
|
-
this.pendingRtp.push({ packet, resolve:
|
|
108587
|
+
this.pendingRtp.push({ packet, resolve: resolve5, reject });
|
|
107693
108588
|
while (this.pendingRtp.length > this.pendingRtpMaxLength) {
|
|
107694
108589
|
const dropped = this.pendingRtp.shift();
|
|
107695
108590
|
if (dropped) {
|
|
@@ -107886,8 +108781,8 @@ var RTCRtpSender = class {
|
|
|
107886
108781
|
await this.dispatchRtp(rtp);
|
|
107887
108782
|
return;
|
|
107888
108783
|
}
|
|
107889
|
-
await new Promise((
|
|
107890
|
-
this.enqueuePendingRtp(rtp,
|
|
108784
|
+
await new Promise((resolve5, reject) => {
|
|
108785
|
+
this.enqueuePendingRtp(rtp, resolve5, reject);
|
|
107891
108786
|
void this.drainPendingRtp();
|
|
107892
108787
|
});
|
|
107893
108788
|
}
|
|
@@ -109047,7 +109942,7 @@ var SctpTransportManager = class {
|
|
|
109047
109942
|
async close() {
|
|
109048
109943
|
if (this.sctpTransport) {
|
|
109049
109944
|
await this.sctpTransport.stop();
|
|
109050
|
-
await new Promise((
|
|
109945
|
+
await new Promise((resolve5) => setImmediate(resolve5));
|
|
109051
109946
|
}
|
|
109052
109947
|
this.onDataChannel.allUnsubscribe();
|
|
109053
109948
|
}
|
|
@@ -111605,12 +112500,14 @@ var RtcSessions = class {
|
|
|
111605
112500
|
};
|
|
111606
112501
|
}
|
|
111607
112502
|
const address = advertiseAddress ?? offer.hostAddress?.replace(/^::ffff:/, "");
|
|
112503
|
+
const bound = !advertiseAddress && address && isIPv45(address) ? { iceInterfaceAddresses: { udp4: address } } : {};
|
|
111608
112504
|
return {
|
|
111609
112505
|
...base,
|
|
111610
112506
|
// ICE-lite host candidates only: no STUN round trip (werift would otherwise default to Google's), one transport.
|
|
111611
112507
|
iceLite: true,
|
|
111612
112508
|
iceServers: [],
|
|
111613
112509
|
...address ? { iceAdditionalHostAddresses: [address] } : {},
|
|
112510
|
+
...bound,
|
|
111614
112511
|
...portRange ? { icePortRange: portRange } : {}
|
|
111615
112512
|
};
|
|
111616
112513
|
}
|
|
@@ -111682,11 +112579,11 @@ var RtcSessions = class {
|
|
|
111682
112579
|
if (pc.iceGatheringState !== "complete") {
|
|
111683
112580
|
await Promise.race([
|
|
111684
112581
|
new Promise(
|
|
111685
|
-
(
|
|
112582
|
+
(resolve5) => pc.iceGatheringStateChange.subscribe((state) => state === "complete" ? resolve5() : void 0)
|
|
111686
112583
|
),
|
|
111687
112584
|
new Promise(
|
|
111688
|
-
(
|
|
111689
|
-
|
|
112585
|
+
(resolve5) => setTimeout(
|
|
112586
|
+
resolve5,
|
|
111690
112587
|
transport === "turn" ? TURN_GATHER_TIMEOUT_MS : transport === "stun" ? STUN_GATHER_TIMEOUT_MS : GATHER_TIMEOUT_MS
|
|
111691
112588
|
)
|
|
111692
112589
|
)
|
|
@@ -111806,7 +112703,7 @@ var onlyCandidatesFor = (sdp, address) => sdp.split("\r\n").filter((line) => !li
|
|
|
111806
112703
|
|
|
111807
112704
|
// src/stream/screen-stream.ts
|
|
111808
112705
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
111809
|
-
import { spawn as
|
|
112706
|
+
import { spawn as spawn7 } from "node:child_process";
|
|
111810
112707
|
import { createSocket as createSocket3 } from "node:dgram";
|
|
111811
112708
|
import { once as once2 } from "node:events";
|
|
111812
112709
|
var EARLY_EXIT_MS = 4e3;
|
|
@@ -111875,7 +112772,7 @@ var ScreenStream = class {
|
|
|
111875
112772
|
...encodeArgs(this.options, input2.filters, this.socket.address().port)
|
|
111876
112773
|
];
|
|
111877
112774
|
const startedAt = Date.now();
|
|
111878
|
-
const child2 =
|
|
112775
|
+
const child2 = spawn7(this.options.ffmpeg(), args, {
|
|
111879
112776
|
stdio: [input2.producer ? "pipe" : "ignore", "ignore", "pipe"],
|
|
111880
112777
|
windowsHide: true
|
|
111881
112778
|
});
|
|
@@ -111888,7 +112785,7 @@ var ScreenStream = class {
|
|
|
111888
112785
|
child2.stderr.on("data", collect);
|
|
111889
112786
|
let producer;
|
|
111890
112787
|
if (input2.producer) {
|
|
111891
|
-
const feeder =
|
|
112788
|
+
const feeder = spawn7(input2.producer.command, input2.producer.args, { stdio: ["ignore", "pipe", "pipe"] });
|
|
111892
112789
|
producer = feeder;
|
|
111893
112790
|
this.children.add(feeder);
|
|
111894
112791
|
feeder.stdout.pipe(child2.stdin);
|
|
@@ -112168,7 +113065,7 @@ function createComputerMcpServer(options) {
|
|
|
112168
113065
|
annotations: readOnly
|
|
112169
113066
|
},
|
|
112170
113067
|
scoped(async (args, ctx) => {
|
|
112171
|
-
await new Promise((
|
|
113068
|
+
await new Promise((resolve5) => setTimeout(resolve5, args.ms));
|
|
112172
113069
|
return asResult(await computer.screenshot(client, ctx.mcpReq.signal));
|
|
112173
113070
|
})
|
|
112174
113071
|
);
|
|
@@ -112790,22 +113687,22 @@ function createViewer(options) {
|
|
|
112790
113687
|
|
|
112791
113688
|
// src/keep-awake.ts
|
|
112792
113689
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
112793
|
-
import { spawn as
|
|
113690
|
+
import { spawn as spawn8, spawnSync as spawnSync4 } from "node:child_process";
|
|
112794
113691
|
function keepDisplayAwake(log40) {
|
|
112795
113692
|
let child2;
|
|
112796
113693
|
if (process.platform === "darwin") {
|
|
112797
113694
|
wakeDisplay();
|
|
112798
|
-
child2 =
|
|
113695
|
+
child2 = spawn8("caffeinate", ["-d", "-i", "-w", String(process.pid)], { stdio: "ignore" });
|
|
112799
113696
|
} else if (process.platform === "win32") {
|
|
112800
113697
|
const script = `$t = Add-Type -MemberDefinition '[DllImport("kernel32.dll")] public static extern uint SetThreadExecutionState(uint f);' -Name Power -Namespace AgentConnect -PassThru
|
|
112801
113698
|
[void]$t::SetThreadExecutionState([uint32]2147483651)
|
|
112802
113699
|
Wait-Process -Id ${process.pid}`;
|
|
112803
|
-
child2 =
|
|
113700
|
+
child2 = spawn8("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", script], {
|
|
112804
113701
|
stdio: "ignore",
|
|
112805
113702
|
windowsHide: true
|
|
112806
113703
|
});
|
|
112807
113704
|
} else if (process.platform === "linux" && gnomeSession() && hasCommand("gnome-session-inhibit")) {
|
|
112808
|
-
child2 =
|
|
113705
|
+
child2 = spawn8(
|
|
112809
113706
|
"gnome-session-inhibit",
|
|
112810
113707
|
[
|
|
112811
113708
|
"--inhibit",
|
|
@@ -112846,14 +113743,14 @@ function displaySleepMinutes() {
|
|
|
112846
113743
|
|
|
112847
113744
|
// src/macos-grants.ts
|
|
112848
113745
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
112849
|
-
import { readFileSync as
|
|
112850
|
-
import { join as
|
|
113746
|
+
import { readFileSync as readFileSync5, writeFileSync as writeFileSync8 } from "node:fs";
|
|
113747
|
+
import { join as join11 } from "node:path";
|
|
112851
113748
|
var APP_ID = "md.agentconnect.computer";
|
|
112852
113749
|
var TCC_SERVICE = { accessibility: "Accessibility", screenRecording: "ScreenCapture" };
|
|
112853
|
-
var grantRecordPath = (dir) =>
|
|
113750
|
+
var grantRecordPath = (dir) => join11(dir, "macos-grants.json");
|
|
112854
113751
|
function readGrantRecord(dir) {
|
|
112855
113752
|
try {
|
|
112856
|
-
const record2 = JSON.parse(
|
|
113753
|
+
const record2 = JSON.parse(readFileSync5(grantRecordPath(dir), "utf8"));
|
|
112857
113754
|
return { asked: record2.asked ?? {}, held: record2.held ?? {} };
|
|
112858
113755
|
} catch {
|
|
112859
113756
|
return { asked: {}, held: {} };
|
|
@@ -112867,7 +113764,7 @@ function recordGrants(dir, state, asked, now = /* @__PURE__ */ new Date()) {
|
|
|
112867
113764
|
else if (asked) record2.asked[grant2] ??= at;
|
|
112868
113765
|
}
|
|
112869
113766
|
try {
|
|
112870
|
-
|
|
113767
|
+
writeFileSync8(grantRecordPath(dir), `${JSON.stringify(record2, null, 2)}
|
|
112871
113768
|
`, { mode: 384 });
|
|
112872
113769
|
} catch {
|
|
112873
113770
|
}
|
|
@@ -112878,7 +113775,7 @@ function forgetGrant(dir, grant2) {
|
|
|
112878
113775
|
delete record2.asked[grant2];
|
|
112879
113776
|
delete record2.held[grant2];
|
|
112880
113777
|
try {
|
|
112881
|
-
|
|
113778
|
+
writeFileSync8(grantRecordPath(dir), `${JSON.stringify(record2, null, 2)}
|
|
112882
113779
|
`, { mode: 384 });
|
|
112883
113780
|
} catch {
|
|
112884
113781
|
}
|
|
@@ -113088,12 +113985,12 @@ var ReqRep = class {
|
|
|
113088
113985
|
pending = /* @__PURE__ */ new Map();
|
|
113089
113986
|
request(frame, write, opts = {}) {
|
|
113090
113987
|
const encoded2 = JSON.stringify(frame);
|
|
113091
|
-
return new Promise((
|
|
113988
|
+
return new Promise((resolve5, reject) => {
|
|
113092
113989
|
const entry = {
|
|
113093
113990
|
id: frame.id,
|
|
113094
113991
|
request: { type: frame.type, ...frame.orgId ? { orgId: frame.orgId } : {} },
|
|
113095
113992
|
encoded: encoded2,
|
|
113096
|
-
resolve:
|
|
113993
|
+
resolve: resolve5,
|
|
113097
113994
|
reject,
|
|
113098
113995
|
tries: 1,
|
|
113099
113996
|
maxTries: opts.maxTries ?? this.maxTries
|
|
@@ -113244,7 +114141,7 @@ var ClientTransport = class _ClientTransport {
|
|
|
113244
114141
|
const wsUrl = url2.endsWith(opts.path) ? url2 : url2.replace(/\/+$/, "") + opts.path;
|
|
113245
114142
|
const selfPingMs = opts.selfPingMs ?? DEFAULT_SELF_PING_MS;
|
|
113246
114143
|
const idleMs = opts.idleMs ?? DEFAULT_RX_IDLE_MS;
|
|
113247
|
-
return new Promise((
|
|
114144
|
+
return new Promise((resolve5, reject) => {
|
|
113248
114145
|
const ws = new wrapper_default(wsUrl, [opts.subprotocol], {
|
|
113249
114146
|
maxPayload: opts.maxPayload ?? MAX_FRAME_BYTES,
|
|
113250
114147
|
...opts.createConnection ? { createConnection: opts.createConnection } : {}
|
|
@@ -113268,7 +114165,7 @@ var ClientTransport = class _ClientTransport {
|
|
|
113268
114165
|
clearTimeout(timer);
|
|
113269
114166
|
ws.removeListener("error", onPreOpenError);
|
|
113270
114167
|
ws.on("error", () => ws.terminate());
|
|
113271
|
-
|
|
114168
|
+
resolve5(new _ClientTransport(ws, selfPingMs, idleMs, localAddress));
|
|
113272
114169
|
});
|
|
113273
114170
|
});
|
|
113274
114171
|
}
|
|
@@ -113576,19 +114473,19 @@ function consoleStopHandler(computer, changed) {
|
|
|
113576
114473
|
|
|
113577
114474
|
// src/menu-bar-host.ts
|
|
113578
114475
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
113579
|
-
import { spawn as
|
|
113580
|
-
import { chmodSync as chmodSync2, existsSync as
|
|
113581
|
-
import { tmpdir as
|
|
113582
|
-
import { join as
|
|
114476
|
+
import { spawn as spawn12, spawnSync as spawnSync8 } from "node:child_process";
|
|
114477
|
+
import { chmodSync as chmodSync2, existsSync as existsSync11, readFileSync as readFileSync8, rmSync as rmSync10, writeFileSync as writeFileSync12 } from "node:fs";
|
|
114478
|
+
import { tmpdir as tmpdir3 } from "node:os";
|
|
114479
|
+
import { join as join16 } from "node:path";
|
|
113583
114480
|
|
|
113584
114481
|
// src/service-macos.ts
|
|
113585
114482
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
113586
114483
|
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
113587
|
-
import { existsSync as
|
|
114484
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync8, rmSync as rmSync7, writeFileSync as writeFileSync9 } from "node:fs";
|
|
113588
114485
|
import { homedir as homedir4 } from "node:os";
|
|
113589
|
-
import { join as
|
|
114486
|
+
import { join as join12 } from "node:path";
|
|
113590
114487
|
var SERVICE_LABEL = "md.agentconnect.computer";
|
|
113591
|
-
var plistPath = () =>
|
|
114488
|
+
var plistPath = () => join12(homedir4(), "Library", "LaunchAgents", `${SERVICE_LABEL}.plist`);
|
|
113592
114489
|
var domain2 = () => `gui/${process.getuid()}`;
|
|
113593
114490
|
var xml = (value) => value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
113594
114491
|
function launchctl(...args) {
|
|
@@ -113616,9 +114513,9 @@ function servicePlist(program, logPath) {
|
|
|
113616
114513
|
`;
|
|
113617
114514
|
}
|
|
113618
114515
|
function installService(program, logPath) {
|
|
113619
|
-
|
|
114516
|
+
mkdirSync8(join12(homedir4(), "Library", "LaunchAgents"), { recursive: true });
|
|
113620
114517
|
stopService();
|
|
113621
|
-
|
|
114518
|
+
writeFileSync9(plistPath(), servicePlist(program, logPath));
|
|
113622
114519
|
if (!guiSession()) return false;
|
|
113623
114520
|
startService();
|
|
113624
114521
|
return true;
|
|
@@ -113647,10 +114544,10 @@ function restartService() {
|
|
|
113647
114544
|
}
|
|
113648
114545
|
function uninstallService() {
|
|
113649
114546
|
stopService();
|
|
113650
|
-
|
|
114547
|
+
rmSync7(plistPath(), { force: true });
|
|
113651
114548
|
}
|
|
113652
114549
|
function serviceStatus() {
|
|
113653
|
-
const installed =
|
|
114550
|
+
const installed = existsSync8(plistPath());
|
|
113654
114551
|
const result = launchctl("print", `${domain2()}/${SERVICE_LABEL}`);
|
|
113655
114552
|
if (!result.ok) return { installed, loaded: false };
|
|
113656
114553
|
const pid = /^\s*pid = (\d+)/m.exec(result.output)?.[1];
|
|
@@ -113658,7 +114555,7 @@ function serviceStatus() {
|
|
|
113658
114555
|
return { installed, loaded: true, ...pid ? { pid: Number(pid) } : {}, ...state ? { state } : {} };
|
|
113659
114556
|
}
|
|
113660
114557
|
function startsAtLogin() {
|
|
113661
|
-
if (!
|
|
114558
|
+
if (!existsSync8(plistPath())) return false;
|
|
113662
114559
|
const disabled = launchctl("print-disabled", domain2()).output;
|
|
113663
114560
|
return ![`"${SERVICE_LABEL}" => disabled`, `"${SERVICE_LABEL}" => true`].some((line) => disabled.includes(line));
|
|
113664
114561
|
}
|
|
@@ -113668,31 +114565,31 @@ function setStartAtLogin(on) {
|
|
|
113668
114565
|
|
|
113669
114566
|
// src/setup.ts
|
|
113670
114567
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
113671
|
-
import { spawn as
|
|
113672
|
-
import { existsSync as
|
|
113673
|
-
import { basename as
|
|
114568
|
+
import { spawn as spawn11, spawnSync as spawnSync7 } from "node:child_process";
|
|
114569
|
+
import { existsSync as existsSync10 } from "node:fs";
|
|
114570
|
+
import { basename as basename4, dirname as dirname6, isAbsolute as isAbsolute2, join as join15 } from "node:path";
|
|
113674
114571
|
import { createInterface as createInterface3 } from "node:readline";
|
|
113675
114572
|
|
|
113676
114573
|
// src/service-windows.ts
|
|
113677
114574
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
113678
|
-
import { spawn as
|
|
113679
|
-
import { copyFileSync, existsSync as
|
|
113680
|
-
import { tmpdir } from "node:os";
|
|
113681
|
-
import { dirname as
|
|
114575
|
+
import { spawn as spawn9, spawnSync as spawnSync6 } from "node:child_process";
|
|
114576
|
+
import { copyFileSync, existsSync as existsSync9, mkdirSync as mkdirSync9, mkdtempSync as mkdtempSync4, readFileSync as readFileSync6, rmSync as rmSync8, writeFileSync as writeFileSync10 } from "node:fs";
|
|
114577
|
+
import { tmpdir as tmpdir2 } from "node:os";
|
|
114578
|
+
import { dirname as dirname5, join as join13 } from "node:path";
|
|
113682
114579
|
var SERVICE_NAME = "AgentConnectComputer";
|
|
113683
114580
|
var DISPLAY_NAME = "AgentConnect Computer";
|
|
113684
114581
|
var SERVICE_HOST_ENV = "AGENTCONNECT_COMPUTER_WINDOWS_SERVICE";
|
|
113685
114582
|
var RESUME_CONTROL = "128";
|
|
113686
114583
|
var ADMINISTRATORS = "S-1-5-32-544";
|
|
113687
114584
|
var SYSTEM = "S-1-5-18";
|
|
113688
|
-
var csharp = (name) => typeof define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES_default === "object" ? define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES_default[name] :
|
|
114585
|
+
var csharp = (name) => typeof define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES_default === "object" ? define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES_default[name] : readFileSync6(new URL(`../windows/${name}`, import.meta.url), "utf8");
|
|
113689
114586
|
var programFiles = () => process.env.ProgramFiles ?? "C:\\Program Files";
|
|
113690
|
-
var installDir = () =>
|
|
113691
|
-
var trayHelperPath = () =>
|
|
113692
|
-
var adminPromptHelperPath = () =>
|
|
113693
|
-
var hostPath = () =>
|
|
113694
|
-
var installedNode = () =>
|
|
113695
|
-
var installedEntry = () =>
|
|
114587
|
+
var installDir = () => join13(programFiles(), "AgentConnect", "Computer");
|
|
114588
|
+
var trayHelperPath = () => join13(installDir(), "agentconnect-computer-tray.exe");
|
|
114589
|
+
var adminPromptHelperPath = () => join13(installDir(), "agentconnect-computer-admin-prompts.exe");
|
|
114590
|
+
var hostPath = () => join13(installDir(), "agentconnect-computer-service.exe");
|
|
114591
|
+
var installedNode = () => join13(installDir(), "node.exe");
|
|
114592
|
+
var installedEntry = () => join13(installDir(), "agentconnect-computer.mjs");
|
|
113696
114593
|
var MIGRATED = ["config.json", "computer-key.json", "client-token", "versions.json"];
|
|
113697
114594
|
var serviceHost = () => process.env[SERVICE_HOST_ENV]?.trim() || void 0;
|
|
113698
114595
|
function run(command, args) {
|
|
@@ -113712,12 +114609,12 @@ var cmdQuote = (value) => {
|
|
|
113712
114609
|
};
|
|
113713
114610
|
var encoded = (script) => Buffer.from(script, "utf16le").toString("base64");
|
|
113714
114611
|
async function runElevated(entry, args, env, write = (text) => process.stdout.write(text)) {
|
|
113715
|
-
const dir =
|
|
113716
|
-
const log40 =
|
|
113717
|
-
const code =
|
|
113718
|
-
const batch =
|
|
113719
|
-
|
|
113720
|
-
|
|
114612
|
+
const dir = mkdtempSync4(join13(tmpdir2(), "agentconnect-computer-"));
|
|
114613
|
+
const log40 = join13(dir, "elevated.log");
|
|
114614
|
+
const code = join13(dir, "exit-code");
|
|
114615
|
+
const batch = join13(dir, "elevated.cmd");
|
|
114616
|
+
writeFileSync10(log40, "");
|
|
114617
|
+
writeFileSync10(
|
|
113721
114618
|
batch,
|
|
113722
114619
|
`@${[process.execPath, entry, ...args].map(cmdQuote).join(" ")} >> ${cmdQuote(log40)} 2>&1\r
|
|
113723
114620
|
@exit /b %ERRORLEVEL%\r
|
|
@@ -113731,28 +114628,28 @@ async function runElevated(entry, args, env, write = (text) => process.stdout.wr
|
|
|
113731
114628
|
const outer = `$p = Start-Process powershell.exe -Verb RunAs -WindowStyle Hidden -PassThru -ArgumentList '-NoProfile','-NonInteractive','-EncodedCommand','${encoded(inner)}'
|
|
113732
114629
|
if (-not $p) { exit 1 }
|
|
113733
114630
|
$p.WaitForExit()`;
|
|
113734
|
-
const child2 =
|
|
114631
|
+
const child2 = spawn9("powershell.exe", ["-NoProfile", "-NonInteractive", "-EncodedCommand", encoded(outer)], {
|
|
113735
114632
|
stdio: "ignore",
|
|
113736
114633
|
windowsHide: true
|
|
113737
114634
|
});
|
|
113738
114635
|
let offset = 0;
|
|
113739
114636
|
const drain = () => {
|
|
113740
|
-
const text =
|
|
114637
|
+
const text = readFileSync6(log40);
|
|
113741
114638
|
if (text.length > offset) write(text.subarray(offset).toString("utf8"));
|
|
113742
114639
|
offset = text.length;
|
|
113743
114640
|
};
|
|
113744
114641
|
const timer = setInterval(drain, 500);
|
|
113745
|
-
await new Promise((
|
|
114642
|
+
await new Promise((resolve5) => child2.on("exit", () => resolve5()));
|
|
113746
114643
|
clearInterval(timer);
|
|
113747
114644
|
drain();
|
|
113748
|
-
const exit =
|
|
113749
|
-
|
|
114645
|
+
const exit = existsSync9(code) ? Number(readFileSync6(code, "utf8").trim()) : NaN;
|
|
114646
|
+
rmSync8(dir, { recursive: true, force: true });
|
|
113750
114647
|
if (Number.isNaN(exit)) throw new Error("the administrator prompt was declined, so nothing was changed");
|
|
113751
114648
|
return exit;
|
|
113752
114649
|
}
|
|
113753
114650
|
function compiler() {
|
|
113754
114651
|
const windir = process.env.SystemRoot ?? "C:\\Windows";
|
|
113755
|
-
const found = ["Framework64", "Framework"].map((framework) =>
|
|
114652
|
+
const found = ["Framework64", "Framework"].map((framework) => join13(windir, "Microsoft.NET", framework, "v4.0.30319", "csc.exe")).find(existsSync9);
|
|
113756
114653
|
if (!found)
|
|
113757
114654
|
throw new Error(
|
|
113758
114655
|
"the .NET Framework 4 compiler (csc.exe) is missing; turn on .NET Framework 4.8 in Windows Features"
|
|
@@ -113760,39 +114657,39 @@ function compiler() {
|
|
|
113760
114657
|
return found;
|
|
113761
114658
|
}
|
|
113762
114659
|
function compile2(source, out, target, references = []) {
|
|
113763
|
-
const dir =
|
|
114660
|
+
const dir = mkdtempSync4(join13(tmpdir2(), "agentconnect-computer-build-"));
|
|
113764
114661
|
try {
|
|
113765
|
-
const file2 =
|
|
113766
|
-
|
|
114662
|
+
const file2 = join13(dir, "source.cs");
|
|
114663
|
+
writeFileSync10(file2, source);
|
|
113767
114664
|
const result = run(compiler(), [
|
|
113768
114665
|
"/nologo",
|
|
113769
114666
|
"/optimize+",
|
|
113770
114667
|
`/target:${target}`,
|
|
113771
114668
|
// UI Automation ships with WPF, beside the compiler.
|
|
113772
|
-
`/lib:${
|
|
114669
|
+
`/lib:${join13(dirname5(compiler()), "WPF")}`,
|
|
113773
114670
|
...references.map((reference) => `/r:${reference}`),
|
|
113774
|
-
`/out:${
|
|
114671
|
+
`/out:${join13(dir, "out.exe")}`,
|
|
113775
114672
|
file2
|
|
113776
114673
|
]);
|
|
113777
114674
|
if (!result.ok) throw new Error(`csc failed to build ${out}: ${result.output}`);
|
|
113778
|
-
copyFileSync(
|
|
114675
|
+
copyFileSync(join13(dir, "out.exe"), out);
|
|
113779
114676
|
} finally {
|
|
113780
|
-
|
|
114677
|
+
rmSync8(dir, { recursive: true, force: true });
|
|
113781
114678
|
}
|
|
113782
114679
|
}
|
|
113783
114680
|
function secureHome(home, sid) {
|
|
113784
|
-
|
|
114681
|
+
mkdirSync9(home, { recursive: true });
|
|
113785
114682
|
const grants = [`*${SYSTEM}:(OI)(CI)F`, `*${ADMINISTRATORS}:(OI)(CI)F`, ...sid ? [`*${sid}:(OI)(CI)RX`] : []];
|
|
113786
114683
|
const result = run("icacls.exe", [home, "/inheritance:r", "/grant:r", ...grants, "/Q"]);
|
|
113787
114684
|
if (!result.ok) throw new Error(`icacls failed on ${home}: ${result.output}`);
|
|
113788
|
-
const children = run("icacls.exe", [
|
|
114685
|
+
const children = run("icacls.exe", [join13(home, "*"), "/reset", "/T", "/C", "/Q"]);
|
|
113789
114686
|
if (!children.ok) throw new Error(`icacls failed on ${home}\\*: ${children.output}`);
|
|
113790
114687
|
}
|
|
113791
114688
|
function migrateUserData(from, home, log40) {
|
|
113792
|
-
if (from === home || !
|
|
113793
|
-
|
|
113794
|
-
for (const name of MIGRATED.filter((file2) =>
|
|
113795
|
-
copyFileSync(
|
|
114689
|
+
if (from === home || !existsSync9(join13(from, "config.json")) || existsSync9(join13(home, "config.json"))) return;
|
|
114690
|
+
mkdirSync9(home, { recursive: true });
|
|
114691
|
+
for (const name of MIGRATED.filter((file2) => existsSync9(join13(from, file2))))
|
|
114692
|
+
copyFileSync(join13(from, name), join13(home, name));
|
|
113796
114693
|
log40(`Moved the configuration from ${from} to ${home}, where only administrators can change it.`);
|
|
113797
114694
|
}
|
|
113798
114695
|
function serviceStatus2() {
|
|
@@ -113843,7 +114740,7 @@ function installService2(plan) {
|
|
|
113843
114740
|
const { log: log40 } = plan;
|
|
113844
114741
|
stopService2();
|
|
113845
114742
|
const dir = installDir();
|
|
113846
|
-
|
|
114743
|
+
mkdirSync9(dir, { recursive: true });
|
|
113847
114744
|
log40(`Building the service, the taskbar helper and the administrator prompt helper in ${dir} (csc).`);
|
|
113848
114745
|
compile2(csharp("service.cs"), hostPath(), "exe", ["System.ServiceProcess.dll"]);
|
|
113849
114746
|
compile2(csharp("tray.cs"), trayHelperPath(), "winexe", [
|
|
@@ -113860,7 +114757,7 @@ function installService2(plan) {
|
|
|
113860
114757
|
if (plan.node !== installedNode()) copyFileSync(plan.node, installedNode());
|
|
113861
114758
|
if (plan.entry !== installedEntry()) copyFileSync(plan.entry, installedEntry());
|
|
113862
114759
|
const legal = `${plan.entry}.LEGAL.txt`;
|
|
113863
|
-
if (
|
|
114760
|
+
if (existsSync9(legal)) copyFileSync(legal, `${installedEntry()}.LEGAL.txt`);
|
|
113864
114761
|
const sid = userSid();
|
|
113865
114762
|
secureHome(plan.home, sid);
|
|
113866
114763
|
const binPath = [hostPath(), "--node", installedNode(), "--entry", installedEntry(), "--home", plan.home].map((arg) => `"${arg}"`).join(" ");
|
|
@@ -113899,14 +114796,14 @@ function uninstallService2(home, purge, log40) {
|
|
|
113899
114796
|
if (!result.ok) throw new Error(`sc delete failed: ${result.output}`);
|
|
113900
114797
|
log40(`Removed the ${SERVICE_NAME} service.`);
|
|
113901
114798
|
}
|
|
113902
|
-
|
|
113903
|
-
if (purge)
|
|
114799
|
+
rmSync8(installDir(), { recursive: true, force: true });
|
|
114800
|
+
if (purge) rmSync8(home, { recursive: true, force: true });
|
|
113904
114801
|
}
|
|
113905
114802
|
function spawnAsUser(command, args, options = {}) {
|
|
113906
114803
|
const host = serviceHost();
|
|
113907
114804
|
const stdio2 = options.detach ? "ignore" : ["pipe", "pipe", options.stderr ?? "inherit"];
|
|
113908
|
-
if (!host) return
|
|
113909
|
-
return
|
|
114805
|
+
if (!host) return spawn9(command, args, { stdio: stdio2, detached: options.detach, windowsHide: true });
|
|
114806
|
+
return spawn9(host, ["run-as-user", ...options.detach ? ["--detach"] : [], command, ...args], {
|
|
113910
114807
|
stdio: stdio2,
|
|
113911
114808
|
windowsHide: true
|
|
113912
114809
|
});
|
|
@@ -113937,12 +114834,12 @@ function launchAsUser(app, timeoutMs = 3e4) {
|
|
|
113937
114834
|
let stderr = "";
|
|
113938
114835
|
child2.stdout?.on("data", (chunk) => stdout += chunk.toString("utf8"));
|
|
113939
114836
|
child2.stderr?.on("data", (chunk) => stderr += chunk.toString("utf8"));
|
|
113940
|
-
return new Promise((
|
|
114837
|
+
return new Promise((resolve5, reject) => {
|
|
113941
114838
|
const timer = setTimeout(() => child2.kill(), timeoutMs);
|
|
113942
114839
|
child2.on("error", reject);
|
|
113943
114840
|
child2.on("exit", (code) => {
|
|
113944
114841
|
clearTimeout(timer);
|
|
113945
|
-
if (code === 0)
|
|
114842
|
+
if (code === 0) resolve5(stdout.trim());
|
|
113946
114843
|
else reject(new Error(withoutClixml(stderr) || stdout.trim() || `launch exited with code ${code}`));
|
|
113947
114844
|
});
|
|
113948
114845
|
});
|
|
@@ -113950,8 +114847,8 @@ function launchAsUser(app, timeoutMs = 3e4) {
|
|
|
113950
114847
|
|
|
113951
114848
|
// src/cp/registration.ts
|
|
113952
114849
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
113953
|
-
import { chmodSync, closeSync, mkdirSync as
|
|
113954
|
-
import { join as
|
|
114850
|
+
import { chmodSync, closeSync as closeSync2, mkdirSync as mkdirSync10, openSync as openSync2, readFileSync as readFileSync7, renameSync as renameSync4, rmSync as rmSync9, writeFileSync as writeFileSync11 } from "node:fs";
|
|
114851
|
+
import { join as join14 } from "node:path";
|
|
113955
114852
|
var Registration = external_exports.object({
|
|
113956
114853
|
cpUrl: external_exports.string().url(),
|
|
113957
114854
|
channelUrl: external_exports.string().url(),
|
|
@@ -113967,11 +114864,11 @@ var Registration = external_exports.object({
|
|
|
113967
114864
|
revokedAt: external_exports.string().datetime().optional(),
|
|
113968
114865
|
revokedReason: external_exports.string().optional()
|
|
113969
114866
|
});
|
|
113970
|
-
var registrationPath = (dir = dataDir()) =>
|
|
114867
|
+
var registrationPath = (dir = dataDir()) => join14(dir, "computer-key.json");
|
|
113971
114868
|
function loadRegistration(dir = dataDir()) {
|
|
113972
114869
|
let raw;
|
|
113973
114870
|
try {
|
|
113974
|
-
raw =
|
|
114871
|
+
raw = readFileSync7(registrationPath(dir), "utf8");
|
|
113975
114872
|
} catch (error63) {
|
|
113976
114873
|
if (error63.code === "ENOENT") return void 0;
|
|
113977
114874
|
throw error63;
|
|
@@ -113979,18 +114876,18 @@ function loadRegistration(dir = dataDir()) {
|
|
|
113979
114876
|
return Registration.parse(JSON.parse(raw));
|
|
113980
114877
|
}
|
|
113981
114878
|
function saveRegistration(registration, dir = dataDir()) {
|
|
113982
|
-
|
|
114879
|
+
mkdirSync10(dir, { recursive: true, mode: 448 });
|
|
113983
114880
|
if (process.platform !== "win32") chmodSync(dir, 448);
|
|
113984
114881
|
const path = registrationPath(dir);
|
|
113985
114882
|
const tmp = `${path}.tmp`;
|
|
113986
114883
|
const body = `${JSON.stringify(Registration.parse(registration), null, 2)}
|
|
113987
114884
|
`;
|
|
113988
|
-
|
|
113989
|
-
const fd =
|
|
114885
|
+
rmSync9(tmp, { force: true });
|
|
114886
|
+
const fd = openSync2(tmp, "wx", 384);
|
|
113990
114887
|
try {
|
|
113991
|
-
|
|
114888
|
+
writeFileSync11(fd, body);
|
|
113992
114889
|
} finally {
|
|
113993
|
-
|
|
114890
|
+
closeSync2(fd);
|
|
113994
114891
|
}
|
|
113995
114892
|
renameSync4(tmp, path);
|
|
113996
114893
|
}
|
|
@@ -114053,7 +114950,7 @@ async function registerOrKeep(dir, cpUrl, register3) {
|
|
|
114053
114950
|
|
|
114054
114951
|
// src/windows-firewall.ts
|
|
114055
114952
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
114056
|
-
import { spawn as
|
|
114953
|
+
import { spawn as spawn10 } from "node:child_process";
|
|
114057
114954
|
var FIREWALL_RULE = "AgentConnect Computer (Node.js)";
|
|
114058
114955
|
var psQuote2 = (value) => `'${value.replace(/'/g, "''")}'`;
|
|
114059
114956
|
var profileCovered = (profile, category) => profile === "Any" || profile.split(/,\s*/).includes(category === "DomainAuthenticated" ? "Domain" : category);
|
|
@@ -114089,18 +114986,18 @@ Get-NetFirewallRule -DisplayName ${psQuote2(FIREWALL_RULE)} -ErrorAction Silentl
|
|
|
114089
114986
|
Get-NetFirewallApplicationFilter | Where-Object { [Environment]::ExpandEnvironmentVariables($_.Program) -ieq $p } | Get-NetFirewallRule | Where-Object { "$($_.Action)" -eq 'Block' -and "$($_.Direction)" -eq 'Inbound' } | Disable-NetFirewallRule
|
|
114090
114987
|
New-NetFirewallRule -DisplayName ${psQuote2(FIREWALL_RULE)} -Direction Inbound -Program $p -Action Allow -Profile Any | Out-Null`;
|
|
114091
114988
|
function powershell(script, timeoutMs) {
|
|
114092
|
-
return new Promise((
|
|
114093
|
-
const child2 =
|
|
114989
|
+
return new Promise((resolve5) => {
|
|
114990
|
+
const child2 = spawn10("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", script], {
|
|
114094
114991
|
stdio: ["ignore", "pipe", "ignore"],
|
|
114095
114992
|
windowsHide: true
|
|
114096
114993
|
});
|
|
114097
114994
|
let stdout = "";
|
|
114098
114995
|
child2.stdout.setEncoding("utf8").on("data", (chunk) => stdout += chunk);
|
|
114099
114996
|
const timer = setTimeout(() => child2.kill(), timeoutMs);
|
|
114100
|
-
child2.on("error", () =>
|
|
114997
|
+
child2.on("error", () => resolve5({ ok: false, stdout }));
|
|
114101
114998
|
child2.on("close", (code) => {
|
|
114102
114999
|
clearTimeout(timer);
|
|
114103
|
-
|
|
115000
|
+
resolve5({ ok: code === 0, stdout });
|
|
114104
115001
|
});
|
|
114105
115002
|
});
|
|
114106
115003
|
}
|
|
@@ -114150,7 +115047,7 @@ All required checks passed (${warned} warning(s)).` : "\nAll checks passed."
|
|
|
114150
115047
|
}
|
|
114151
115048
|
var hostApp = () => {
|
|
114152
115049
|
const app = appBundlePath();
|
|
114153
|
-
return app ?
|
|
115050
|
+
return app ? basename4(app) : process.env.TERM_PROGRAM ?? process.env.__CFBundleIdentifier ?? "the launching app";
|
|
114154
115051
|
};
|
|
114155
115052
|
var overSsh = () => Boolean(process.env.SSH_CONNECTION || process.env.SSH_TTY) && !process.env.__CFBundleIdentifier && !process.env.TERM_PROGRAM;
|
|
114156
115053
|
async function macPermissions(driver, prompt = false) {
|
|
@@ -114177,7 +115074,7 @@ async function doctor(ctx, captureTimeoutMs = 15e3) {
|
|
|
114177
115074
|
checks.push(registration);
|
|
114178
115075
|
checks.push(sessionCheck());
|
|
114179
115076
|
wakeDisplay();
|
|
114180
|
-
if (isAbsolute2(ctx.driverCommand) && !
|
|
115077
|
+
if (isAbsolute2(ctx.driverCommand) && !existsSync10(ctx.driverCommand)) {
|
|
114181
115078
|
checks.push({
|
|
114182
115079
|
name: "cua-driver",
|
|
114183
115080
|
status: "fail",
|
|
@@ -114260,7 +115157,7 @@ function sessionCheck() {
|
|
|
114260
115157
|
if (process.platform === "win32") {
|
|
114261
115158
|
const session = process.env.SESSIONNAME;
|
|
114262
115159
|
if (serviceHost()) {
|
|
114263
|
-
return
|
|
115160
|
+
return existsSync10(adminPromptHelperPath()) ? {
|
|
114264
115161
|
name: "session",
|
|
114265
115162
|
status: "ok",
|
|
114266
115163
|
detail: `${SERVICE_NAME} service, as SYSTEM in the signed-in session; UAC prompts are answered as its administrator prompt setting says`
|
|
@@ -114421,7 +115318,7 @@ function ffmpegChecks(ctx, timeoutMs) {
|
|
|
114421
115318
|
}
|
|
114422
115319
|
];
|
|
114423
115320
|
}
|
|
114424
|
-
if (waylandSession() && !
|
|
115321
|
+
if (waylandSession() && !existsSync10(screencastTokenPath(ctx.dir))) {
|
|
114425
115322
|
return [
|
|
114426
115323
|
{ name: "ffmpeg", status: "ok", detail: ctx.ffmpeg },
|
|
114427
115324
|
{
|
|
@@ -114496,7 +115393,7 @@ async function setupLinux(ctx) {
|
|
|
114496
115393
|
if (gnomeWayland()) {
|
|
114497
115394
|
const state = gnomeHelperState();
|
|
114498
115395
|
if (state === "missing") {
|
|
114499
|
-
const installer =
|
|
115396
|
+
const installer = join15(dirname6(ctx.driverCommand), "wayland-helper", "install.sh");
|
|
114500
115397
|
const result = spawnSync7(installer, [], { encoding: "utf8" });
|
|
114501
115398
|
ctx.log(
|
|
114502
115399
|
result.status === 0 ? `Installed the ${GNOME_HELPER} GNOME extension.` : `Extension install failed: ${result.stderr}`
|
|
@@ -114568,7 +115465,7 @@ async function waitForGrants(ctx, app, initial) {
|
|
|
114568
115465
|
let openedScreenPane = state.accessibility;
|
|
114569
115466
|
try {
|
|
114570
115467
|
while (!skipped && Date.now() < deadline && !(state.accessibility && state.screenRecording)) {
|
|
114571
|
-
await new Promise((
|
|
115468
|
+
await new Promise((resolve5) => setTimeout(resolve5, 2e3));
|
|
114572
115469
|
const probe = new CuaDriver({ command: ctx.driverCommand, callTimeoutMs: 2e4 });
|
|
114573
115470
|
const next = await macPermissions(probe).catch(() => state).finally(() => probe.close());
|
|
114574
115471
|
if (next.accessibility && !state.accessibility) ctx.log(`Accessibility granted to ${app}.`);
|
|
@@ -114586,7 +115483,7 @@ async function waitForGrants(ctx, app, initial) {
|
|
|
114586
115483
|
return state;
|
|
114587
115484
|
}
|
|
114588
115485
|
function open3(url2) {
|
|
114589
|
-
|
|
115486
|
+
spawn11("open", [url2], { stdio: "ignore", detached: true }).unref();
|
|
114590
115487
|
}
|
|
114591
115488
|
async function setupWindowsFirewall(ctx, program = process.execPath) {
|
|
114592
115489
|
if ((await readFirewall(program))?.state === "allowed") {
|
|
@@ -114626,7 +115523,7 @@ function controlPlaneState(registration, client) {
|
|
|
114626
115523
|
var appVersion = (appPath) => {
|
|
114627
115524
|
if (!appPath) return void 0;
|
|
114628
115525
|
try {
|
|
114629
|
-
const plist =
|
|
115526
|
+
const plist = readFileSync8(join16(appPath, "Contents", "Info.plist"), "utf8");
|
|
114630
115527
|
return /<key>CFBundleShortVersionString<\/key>\s*<string>([^<]+)<\/string>/.exec(plist)?.[1];
|
|
114631
115528
|
} catch {
|
|
114632
115529
|
return void 0;
|
|
@@ -114681,11 +115578,11 @@ function macMenuBarHost(deps) {
|
|
|
114681
115578
|
if (!client) return false;
|
|
114682
115579
|
client.reconnectNow();
|
|
114683
115580
|
const deadline = Date.now() + RECONNECT_WAIT_MS;
|
|
114684
|
-
while (client.state !== "READY" && Date.now() < deadline) await new Promise((
|
|
115581
|
+
while (client.state !== "READY" && Date.now() < deadline) await new Promise((resolve5) => setTimeout(resolve5, 250));
|
|
114685
115582
|
return client.state === "READY";
|
|
114686
115583
|
},
|
|
114687
115584
|
async installDriver() {
|
|
114688
|
-
|
|
115585
|
+
rmSync10(installedDriverDir(dir), { recursive: true, force: true });
|
|
114689
115586
|
await installDriver(dir, log40);
|
|
114690
115587
|
deps.shutdown(1);
|
|
114691
115588
|
},
|
|
@@ -114708,21 +115605,21 @@ function macMenuBarHost(deps) {
|
|
|
114708
115605
|
log40(`start at login turned ${on ? "on" : "off"} from the menu bar`);
|
|
114709
115606
|
},
|
|
114710
115607
|
openLogs() {
|
|
114711
|
-
const file2 =
|
|
114712
|
-
|
|
115608
|
+
const file2 = join16(dir, "daemon.log");
|
|
115609
|
+
spawn12("open", existsSync11(file2) ? ["-a", "Console", file2] : [dir], { stdio: "ignore", detached: true }).unref();
|
|
114713
115610
|
},
|
|
114714
115611
|
uninstall() {
|
|
114715
115612
|
let channel;
|
|
114716
115613
|
try {
|
|
114717
|
-
channel = JSON.parse(
|
|
115614
|
+
channel = JSON.parse(readFileSync8(join16(dir, "versions.json"), "utf8")).channel;
|
|
114718
115615
|
} catch {
|
|
114719
115616
|
channel = void 0;
|
|
114720
115617
|
}
|
|
114721
|
-
const script =
|
|
114722
|
-
|
|
115618
|
+
const script = join16(tmpdir3(), "agentconnect-computer-uninstall.command");
|
|
115619
|
+
writeFileSync12(script, uninstallScript(channel));
|
|
114723
115620
|
chmodSync2(script, 493);
|
|
114724
115621
|
log40("uninstall requested from the menu bar; running it in Terminal");
|
|
114725
|
-
|
|
115622
|
+
spawn12("open", ["-a", "Terminal", script], { stdio: "ignore", detached: true }).unref();
|
|
114726
115623
|
},
|
|
114727
115624
|
quit() {
|
|
114728
115625
|
log40("quit from the menu bar; the service starts again at the next login");
|
|
@@ -114734,8 +115631,8 @@ function macMenuBarHost(deps) {
|
|
|
114734
115631
|
|
|
114735
115632
|
// src/menu-bar-host-windows.ts
|
|
114736
115633
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
114737
|
-
import { existsSync as
|
|
114738
|
-
import { join as
|
|
115634
|
+
import { existsSync as existsSync12, readFileSync as readFileSync9, rmSync as rmSync11 } from "node:fs";
|
|
115635
|
+
import { join as join17 } from "node:path";
|
|
114739
115636
|
var RECONNECT_WAIT_MS2 = 1e4;
|
|
114740
115637
|
var DRIVER_TIMEOUT_MS = 5e3;
|
|
114741
115638
|
var FIREWALL_TTL_MS = 5 * 6e4;
|
|
@@ -114786,11 +115683,11 @@ function windowsMenuBarHost(deps) {
|
|
|
114786
115683
|
if (!client) return false;
|
|
114787
115684
|
client.reconnectNow();
|
|
114788
115685
|
const deadline = Date.now() + RECONNECT_WAIT_MS2;
|
|
114789
|
-
while (client.state !== "READY" && Date.now() < deadline) await new Promise((
|
|
115686
|
+
while (client.state !== "READY" && Date.now() < deadline) await new Promise((resolve5) => setTimeout(resolve5, 250));
|
|
114790
115687
|
return client.state === "READY";
|
|
114791
115688
|
},
|
|
114792
115689
|
async installDriver() {
|
|
114793
|
-
|
|
115690
|
+
rmSync11(installedDriverDir(dir), { recursive: true, force: true });
|
|
114794
115691
|
await installDriver(dir, log40);
|
|
114795
115692
|
deps.shutdown(1);
|
|
114796
115693
|
},
|
|
@@ -114820,15 +115717,15 @@ function windowsMenuBarHost(deps) {
|
|
|
114820
115717
|
log40(`start at sign-in turned ${on ? "on" : "off"} from the taskbar`);
|
|
114821
115718
|
},
|
|
114822
115719
|
openLogs() {
|
|
114823
|
-
const file2 =
|
|
114824
|
-
spawnAsUser(
|
|
115720
|
+
const file2 = join17(dir, "daemon.log");
|
|
115721
|
+
spawnAsUser(existsSync12(file2) ? "notepad.exe" : "explorer.exe", [existsSync12(file2) ? file2 : dir], {
|
|
114825
115722
|
detach: true
|
|
114826
115723
|
}).unref();
|
|
114827
115724
|
},
|
|
114828
115725
|
uninstall() {
|
|
114829
115726
|
let channel;
|
|
114830
115727
|
try {
|
|
114831
|
-
channel = JSON.parse(
|
|
115728
|
+
channel = JSON.parse(readFileSync9(join17(dir, "versions.json"), "utf8")).channel;
|
|
114832
115729
|
} catch {
|
|
114833
115730
|
channel = void 0;
|
|
114834
115731
|
}
|
|
@@ -115135,7 +116032,7 @@ function createRelayedMcpHandler(deps) {
|
|
|
115135
116032
|
// src/cp/report.ts
|
|
115136
116033
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
115137
116034
|
import { spawnSync as spawnSync9 } from "node:child_process";
|
|
115138
|
-
import { existsSync as
|
|
116035
|
+
import { existsSync as existsSync13, readdirSync as readdirSync3, readFileSync as readFileSync10 } from "node:fs";
|
|
115139
116036
|
import { release as release2 } from "node:os";
|
|
115140
116037
|
var MAX_CHECKS = 64;
|
|
115141
116038
|
var MAX_TEXT = 1e3;
|
|
@@ -115143,7 +116040,7 @@ var computerOs = (platform = process.platform) => platform === "darwin" ? "macos
|
|
|
115143
116040
|
function osVersion(platform = process.platform) {
|
|
115144
116041
|
if (platform === "linux") {
|
|
115145
116042
|
try {
|
|
115146
|
-
const pretty = /^PRETTY_NAME="?([^"\n]+)"?$/m.exec(
|
|
116043
|
+
const pretty = /^PRETTY_NAME="?([^"\n]+)"?$/m.exec(readFileSync10("/etc/os-release", "utf8"))?.[1];
|
|
115147
116044
|
if (pretty) return pretty.slice(0, 120);
|
|
115148
116045
|
} catch {
|
|
115149
116046
|
}
|
|
@@ -115158,9 +116055,9 @@ function xvfbServes(display) {
|
|
|
115158
116055
|
const number4 = /^:(\d+)/.exec(display)?.[1];
|
|
115159
116056
|
if (number4 === void 0) return false;
|
|
115160
116057
|
try {
|
|
115161
|
-
for (const pid of
|
|
116058
|
+
for (const pid of readdirSync3("/proc")) {
|
|
115162
116059
|
if (!/^\d+$/.test(pid)) continue;
|
|
115163
|
-
const argv =
|
|
116060
|
+
const argv = readFileSync10(`/proc/${pid}/cmdline`, "utf8").split("\0");
|
|
115164
116061
|
if (/(^|\/)Xvfb$/.test(argv[0] ?? "") && argv.includes(`:${number4}`)) return true;
|
|
115165
116062
|
}
|
|
115166
116063
|
} catch {
|
|
@@ -115176,7 +116073,7 @@ function sessionKind(platform = process.platform, env = process.env) {
|
|
|
115176
116073
|
function isolationKind(env = process.env) {
|
|
115177
116074
|
const declared = env.AGENTCONNECT_COMPUTER_ISOLATION;
|
|
115178
116075
|
if (declared === "none" || declared === "container" || declared === "vm") return declared;
|
|
115179
|
-
return
|
|
116076
|
+
return existsSync13("/.dockerenv") || existsSync13("/run/.containerenv") ? "container" : "none";
|
|
115180
116077
|
}
|
|
115181
116078
|
var truncate = (text) => text.length > MAX_TEXT ? `${text.slice(0, MAX_TEXT - 1)}\u2026` : text;
|
|
115182
116079
|
function doctorReport(checks, at = /* @__PURE__ */ new Date()) {
|
|
@@ -115234,12 +116131,12 @@ function capabilitiesFrom(checks, display, options = {}) {
|
|
|
115234
116131
|
// src/cp/env-registration.ts
|
|
115235
116132
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
115236
116133
|
import { createHash as createHash7 } from "node:crypto";
|
|
115237
|
-
import { readFileSync as
|
|
116134
|
+
import { readFileSync as readFileSync11 } from "node:fs";
|
|
115238
116135
|
var REGISTER_TOKEN_ENV = "AGENTCONNECT_REGISTER_TOKEN";
|
|
115239
116136
|
var REGISTER_TOKEN_FILE_ENV = "AGENTCONNECT_REGISTER_TOKEN_FILE";
|
|
115240
116137
|
var CP_URL_ENV = "AGENTCONNECT_CP_URL";
|
|
115241
116138
|
var COMPUTER_NAME_ENV = "AGENTCONNECT_COMPUTER_NAME";
|
|
115242
|
-
function registrationFromEnv(env = process.env, read = (path) =>
|
|
116139
|
+
function registrationFromEnv(env = process.env, read = (path) => readFileSync11(path, "utf8")) {
|
|
115243
116140
|
let token = env[REGISTER_TOKEN_ENV]?.trim() ?? "";
|
|
115244
116141
|
const file2 = env[REGISTER_TOKEN_FILE_ENV]?.trim();
|
|
115245
116142
|
if (!token && file2) {
|
|
@@ -115308,7 +116205,7 @@ async function readBody2(req) {
|
|
|
115308
116205
|
}
|
|
115309
116206
|
async function startPoolBootstrap(options) {
|
|
115310
116207
|
let resolveRegistered;
|
|
115311
|
-
const registered = new Promise((
|
|
116208
|
+
const registered = new Promise((resolve5) => resolveRegistered = resolve5);
|
|
115312
116209
|
const existing = live(options.load());
|
|
115313
116210
|
if (existing) resolveRegistered(existing);
|
|
115314
116211
|
let registering;
|
|
@@ -115353,9 +116250,9 @@ async function startPoolBootstrap(options) {
|
|
|
115353
116250
|
return {
|
|
115354
116251
|
registered,
|
|
115355
116252
|
address,
|
|
115356
|
-
close: () => new Promise((
|
|
116253
|
+
close: () => new Promise((resolve5) => {
|
|
115357
116254
|
server.closeAllConnections();
|
|
115358
|
-
server.close(() =>
|
|
116255
|
+
server.close(() => resolve5());
|
|
115359
116256
|
})
|
|
115360
116257
|
};
|
|
115361
116258
|
}
|
|
@@ -115433,9 +116330,9 @@ var EgressForwarder = class {
|
|
|
115433
116330
|
socket.once("close", () => this.sockets.delete(socket));
|
|
115434
116331
|
});
|
|
115435
116332
|
server.on("clientError", (_err, socket) => socket.destroy());
|
|
115436
|
-
await new Promise((
|
|
116333
|
+
await new Promise((resolve5, reject) => {
|
|
115437
116334
|
server.once("error", reject);
|
|
115438
|
-
server.listen(this.opts.port, this.opts.host ?? "127.0.0.1", () =>
|
|
116335
|
+
server.listen(this.opts.port, this.opts.host ?? "127.0.0.1", () => resolve5());
|
|
115439
116336
|
});
|
|
115440
116337
|
this.server = server;
|
|
115441
116338
|
const address = server.address();
|
|
@@ -115443,7 +116340,7 @@ var EgressForwarder = class {
|
|
|
115443
116340
|
}
|
|
115444
116341
|
async stop() {
|
|
115445
116342
|
for (const socket of this.sockets) socket.destroy();
|
|
115446
|
-
await new Promise((
|
|
116343
|
+
await new Promise((resolve5) => this.server ? this.server.close(() => resolve5()) : resolve5());
|
|
115447
116344
|
this.server = void 0;
|
|
115448
116345
|
}
|
|
115449
116346
|
// A tunnel (HTTPS and WebSocket traffic): straight to the target, or a CONNECT through the organization's proxy.
|
|
@@ -115571,13 +116468,13 @@ function publicBaseUrl(config2) {
|
|
|
115571
116468
|
if (config2.rtcAddress) return `http://${urlHost(config2.rtcAddress)}:${config2.port}`;
|
|
115572
116469
|
return void 0;
|
|
115573
116470
|
}
|
|
115574
|
-
async function rtcAdvertiseAddress(config2,
|
|
116471
|
+
async function rtcAdvertiseAddress(config2, resolve5 = async (host) => (await lookup(host, { family: 4 })).address, log40 = () => void 0) {
|
|
115575
116472
|
if (config2.rtcAddress) return config2.rtcAddress;
|
|
115576
116473
|
if (!config2.publicUrl) return void 0;
|
|
115577
116474
|
const host = new URL(config2.publicUrl).hostname.replace(/^\[(.*)\]$/, "$1");
|
|
115578
116475
|
if (isIP5(host)) return host;
|
|
115579
116476
|
try {
|
|
115580
|
-
return await
|
|
116477
|
+
return await resolve5(host);
|
|
115581
116478
|
} catch (error63) {
|
|
115582
116479
|
log40(`cannot resolve ${host} for WebRTC (${error63.message}); set RTC_ADDRESS to the public IP`);
|
|
115583
116480
|
return void 0;
|
|
@@ -115617,11 +116514,11 @@ function scheduleDoctor(options) {
|
|
|
115617
116514
|
// src/service-linux.ts
|
|
115618
116515
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
115619
116516
|
import { execFile as execFile2, spawnSync as spawnSync10 } from "node:child_process";
|
|
115620
|
-
import { copyFileSync as copyFileSync2, mkdirSync as
|
|
116517
|
+
import { copyFileSync as copyFileSync2, mkdirSync as mkdirSync11, rmSync as rmSync12, writeFileSync as writeFileSync13 } from "node:fs";
|
|
115621
116518
|
import { homedir as homedir5 } from "node:os";
|
|
115622
|
-
import { join as
|
|
116519
|
+
import { join as join18 } from "node:path";
|
|
115623
116520
|
var UNIT = "agentconnect-computer.service";
|
|
115624
|
-
var unitPath = () =>
|
|
116521
|
+
var unitPath = () => join18(process.env.XDG_CONFIG_HOME ?? join18(homedir5(), ".config"), "systemd", "user", UNIT);
|
|
115625
116522
|
var SESSION_VARS = [
|
|
115626
116523
|
"DISPLAY",
|
|
115627
116524
|
"XAUTHORITY",
|
|
@@ -115634,7 +116531,7 @@ var SESSION_VARS = [
|
|
|
115634
116531
|
var SESSION_ENV = "AGENTCONNECT_COMPUTER_SESSION";
|
|
115635
116532
|
var SESSION_DISPLAY_VARS = ["DISPLAY", "XAUTHORITY", "WAYLAND_DISPLAY", SESSION_ENV];
|
|
115636
116533
|
var EXIT_NEW_SESSION = 75;
|
|
115637
|
-
var autostartPath = () =>
|
|
116534
|
+
var autostartPath = () => join18(process.env.XDG_CONFIG_HOME ?? join18(homedir5(), ".config"), "autostart", "agentconnect-computer.desktop");
|
|
115638
116535
|
function systemctl(...args) {
|
|
115639
116536
|
const result = spawnSync10("systemctl", ["--user", ...args], { encoding: "utf8" });
|
|
115640
116537
|
return { ok: result.status === 0, output: `${result.stdout ?? ""}${result.stderr ?? ""}`.trim() };
|
|
@@ -115677,15 +116574,15 @@ X-GNOME-Autostart-enabled=true
|
|
|
115677
116574
|
function installService3(dataDir2, script, managed = false) {
|
|
115678
116575
|
let target = script;
|
|
115679
116576
|
if (!managed) {
|
|
115680
|
-
const app =
|
|
115681
|
-
|
|
115682
|
-
target =
|
|
116577
|
+
const app = join18(dataDir2, "app");
|
|
116578
|
+
mkdirSync11(app, { recursive: true });
|
|
116579
|
+
target = join18(app, "agentconnect-computer.mjs");
|
|
115683
116580
|
if (script !== target) copyFileSync2(script, target);
|
|
115684
116581
|
}
|
|
115685
|
-
|
|
115686
|
-
|
|
115687
|
-
|
|
115688
|
-
|
|
116582
|
+
mkdirSync11(join18(unitPath(), ".."), { recursive: true });
|
|
116583
|
+
writeFileSync13(unitPath(), unitFile(process.execPath, target));
|
|
116584
|
+
mkdirSync11(join18(autostartPath(), ".."), { recursive: true });
|
|
116585
|
+
writeFileSync13(autostartPath(), autostartEntry());
|
|
115689
116586
|
systemctl("daemon-reload");
|
|
115690
116587
|
const enabled = systemctl("enable", UNIT);
|
|
115691
116588
|
if (!enabled.ok) throw new Error(`systemctl --user enable failed: ${enabled.output}`);
|
|
@@ -115717,8 +116614,8 @@ function restartService3() {
|
|
|
115717
116614
|
}
|
|
115718
116615
|
function uninstallService3() {
|
|
115719
116616
|
systemctl("disable", "--now", UNIT);
|
|
115720
|
-
|
|
115721
|
-
|
|
116617
|
+
rmSync12(unitPath(), { force: true });
|
|
116618
|
+
rmSync12(autostartPath(), { force: true });
|
|
115722
116619
|
systemctl("daemon-reload");
|
|
115723
116620
|
}
|
|
115724
116621
|
function serviceStatus3() {
|
|
@@ -115732,12 +116629,12 @@ function serviceStatus3() {
|
|
|
115732
116629
|
state: `${field("ActiveState")}/${field("SubState")}`
|
|
115733
116630
|
};
|
|
115734
116631
|
}
|
|
115735
|
-
var run2 = (command, args) => new Promise((
|
|
116632
|
+
var run2 = (command, args) => new Promise((resolve5) => {
|
|
115736
116633
|
execFile2(
|
|
115737
116634
|
command,
|
|
115738
116635
|
args,
|
|
115739
116636
|
{ encoding: "utf8", timeout: 1e4 },
|
|
115740
|
-
(error63, stdout, stderr) =>
|
|
116637
|
+
(error63, stdout, stderr) => resolve5({
|
|
115741
116638
|
ok: !error63,
|
|
115742
116639
|
exited: Boolean(error63) && typeof error63?.code === "number" && !error63.killed,
|
|
115743
116640
|
stdout: stdout ?? "",
|
|
@@ -115859,6 +116756,10 @@ Commands:
|
|
|
115859
116756
|
the permissions), Linux systemd user unit (graphical session),
|
|
115860
116757
|
Windows service running the daemon as SYSTEM in the signed-in
|
|
115861
116758
|
session, which can reach UAC prompts (asks for approval)
|
|
116759
|
+
browser --profile DIR [--master DIR] [--source DIR]... [--browser PATH] [-- ARGS]
|
|
116760
|
+
start a desktop's Chromium on its own profile, first merging the
|
|
116761
|
+
logins of the other profiles into it (or hand ARGS to the running one)
|
|
116762
|
+
browser-close --profile DIR [--display :N] close that browser the way a person would, so it saves its cookies
|
|
115862
116763
|
|
|
115863
116764
|
Data dir: ${dataDir()}`;
|
|
115864
116765
|
var parsePortRange = (value) => {
|
|
@@ -115887,6 +116788,12 @@ async function main() {
|
|
|
115887
116788
|
"cp-url": { type: "string" },
|
|
115888
116789
|
name: { type: "string" },
|
|
115889
116790
|
purge: { type: "boolean" },
|
|
116791
|
+
profile: { type: "string" },
|
|
116792
|
+
master: { type: "string" },
|
|
116793
|
+
source: { type: "string", multiple: true },
|
|
116794
|
+
browser: { type: "string" },
|
|
116795
|
+
display: { type: "string" },
|
|
116796
|
+
"skip-path": { type: "string", multiple: true },
|
|
115890
116797
|
help: { type: "boolean", short: "h" }
|
|
115891
116798
|
}
|
|
115892
116799
|
});
|
|
@@ -115904,7 +116811,7 @@ async function main() {
|
|
|
115904
116811
|
)
|
|
115905
116812
|
);
|
|
115906
116813
|
if (installing2) env.AGENTCONNECT_COMPUTER_HOME = windowsServiceHome();
|
|
115907
|
-
process.exitCode = await runElevated(
|
|
116814
|
+
process.exitCode = await runElevated(resolve4(process.argv[1]), process.argv.slice(2), env);
|
|
115908
116815
|
return;
|
|
115909
116816
|
}
|
|
115910
116817
|
if (installing2 && dir !== windowsServiceHome()) {
|
|
@@ -116015,6 +116922,10 @@ async function main() {
|
|
|
116015
116922
|
else throw new Error("usage: autostart enable | disable | start");
|
|
116016
116923
|
return void console.log(`autostart ${action}: ok`);
|
|
116017
116924
|
}
|
|
116925
|
+
case "browser":
|
|
116926
|
+
return browserCommand(values, rest, log39);
|
|
116927
|
+
case "browser-close":
|
|
116928
|
+
return browserCloseCommand(values, log39);
|
|
116018
116929
|
default:
|
|
116019
116930
|
throw new Error(`unknown command "${command}"
|
|
116020
116931
|
|
|
@@ -116023,12 +116934,12 @@ ${help()}`);
|
|
|
116023
116934
|
}
|
|
116024
116935
|
var lanAddresses = () => Object.values(networkInterfaces2()).flat().filter((net2) => net2 && net2.family === "IPv4" && !net2.internal).map((net2) => net2.address);
|
|
116025
116936
|
function printClientSetup(config2, client, token, tokenFile) {
|
|
116026
|
-
const host = urlHost(isWildcardHost(config2.host) ? lanAddresses()[0] ??
|
|
116937
|
+
const host = urlHost(isWildcardHost(config2.host) ? lanAddresses()[0] ?? hostname6() : config2.host);
|
|
116027
116938
|
const base = publicBaseUrl(config2) ?? `http://${host}:${config2.port}`;
|
|
116028
116939
|
let shown = token;
|
|
116029
116940
|
if (tokenFile) {
|
|
116030
|
-
|
|
116031
|
-
|
|
116941
|
+
rmSync13(tokenFile, { force: true });
|
|
116942
|
+
writeFileSync14(tokenFile, `${token}
|
|
116032
116943
|
`, { mode: 384, flag: "wx" });
|
|
116033
116944
|
shown = "<token>";
|
|
116034
116945
|
console.log(`
|
|
@@ -116075,7 +116986,7 @@ function tokenCommand(dir, args) {
|
|
|
116075
116986
|
}
|
|
116076
116987
|
}
|
|
116077
116988
|
var driverWrapper = () => process.platform === "linux" && process.env.INVOCATION_ID && hasCommand("systemd-run") ? ["systemd-run", "--user", "--scope", "--quiet", "--collect", "--"] : void 0;
|
|
116078
|
-
function buildComputer(dir, config2, onStatus, refusal, report, screenshots, adminPrompts, name = process.env[COMPUTER_NAME_ENV]?.trim() ||
|
|
116989
|
+
function buildComputer(dir, config2, onStatus, refusal, report, screenshots, adminPrompts, name = process.env[COMPUTER_NAME_ENV]?.trim() || hostname6(), onHalt) {
|
|
116079
116990
|
const wrapper = driverWrapper();
|
|
116080
116991
|
const driver = new CuaDriver({
|
|
116081
116992
|
command: resolveDriverPath(dir, config2.driverPath),
|
|
@@ -116086,7 +116997,7 @@ function buildComputer(dir, config2, onStatus, refusal, report, screenshots, adm
|
|
|
116086
116997
|
const computer = new Computer({
|
|
116087
116998
|
driver,
|
|
116088
116999
|
config: config2,
|
|
116089
|
-
audit: auditSinks(fileAuditSink(
|
|
117000
|
+
audit: auditSinks(fileAuditSink(join19(dir, "audit.log")), ...report ? [report] : []),
|
|
116090
117001
|
log: log39,
|
|
116091
117002
|
...onStatus ? { onStatus } : {},
|
|
116092
117003
|
...refusal ? { refusal } : {},
|
|
@@ -116102,7 +117013,7 @@ function buildComputer(dir, config2, onStatus, refusal, report, screenshots, adm
|
|
|
116102
117013
|
function exchangeFor(token, cpUrl, name) {
|
|
116103
117014
|
if (!cpUrl) throw new Error("--cp-url is required with a registration token (the console prints it)");
|
|
116104
117015
|
return exchangeRegistrationToken(cpUrl, token, {
|
|
116105
|
-
name: (name ?? (process.env[COMPUTER_NAME_ENV]?.trim() ||
|
|
117016
|
+
name: (name ?? (process.env[COMPUTER_NAME_ENV]?.trim() || hostname6())).slice(0, 120),
|
|
116106
117017
|
isolation: isolationKind(),
|
|
116107
117018
|
os: computerOs(),
|
|
116108
117019
|
osVersion: osVersion(),
|
|
@@ -116318,9 +117229,9 @@ async function run3(dir, initial, clientName) {
|
|
|
116318
117229
|
const issued = issueClientToken(config2, clientName);
|
|
116319
117230
|
config2 = issued.config;
|
|
116320
117231
|
saveConfig(config2, dir);
|
|
116321
|
-
printClientSetup(config2, clientName, issued.token, process.stdout.isTTY ? void 0 :
|
|
117232
|
+
printClientSetup(config2, clientName, issued.token, process.stdout.isTTY ? void 0 : join19(dir, "client-token"));
|
|
116322
117233
|
}
|
|
116323
|
-
if (!config2.driverPath && !
|
|
117234
|
+
if (!config2.driverPath && !existsSync14(installedDriverPath(dir))) await installDriver(dir);
|
|
116324
117235
|
const setTitle = (status) => {
|
|
116325
117236
|
process.title = `AgentConnect Computer \u2014 ${status}`;
|
|
116326
117237
|
};
|
|
@@ -116348,7 +117259,7 @@ async function run3(dir, initial, clientName) {
|
|
|
116348
117259
|
commit: (commit) => live2.channel?.client.commitScreenshot(commit) ?? Promise.resolve("retry"),
|
|
116349
117260
|
log: log39
|
|
116350
117261
|
}) : void 0;
|
|
116351
|
-
const adminPromptHelper = process.platform === "win32" && serviceHost() &&
|
|
117262
|
+
const adminPromptHelper = process.platform === "win32" && serviceHost() && existsSync14(adminPromptHelperPath()) ? AdminPromptHelper.start(adminPromptHelperPath(), {
|
|
116352
117263
|
onChange: () => {
|
|
116353
117264
|
void live2.computer?.adminPromptChanged();
|
|
116354
117265
|
live2.local?.update();
|
|
@@ -116356,7 +117267,7 @@ async function run3(dir, initial, clientName) {
|
|
|
116356
117267
|
log: log39
|
|
116357
117268
|
}) : void 0;
|
|
116358
117269
|
const commandLine = registration && !registration.revokedAt && commandLineSupported() ? new CommandLine({
|
|
116359
|
-
audit: auditSinks(fileAuditSink(
|
|
117270
|
+
audit: auditSinks(fileAuditSink(join19(dir, "audit.log")), ...auditReport ? [auditReport.sink] : []),
|
|
116360
117271
|
refusal: () => authority.refusal(),
|
|
116361
117272
|
halted: () => live2.computer?.haltReason(),
|
|
116362
117273
|
dataDir: dir,
|
|
@@ -116631,14 +117542,14 @@ async function waitForDaemon(config2, timeoutMs) {
|
|
|
116631
117542
|
while (Date.now() < deadline) {
|
|
116632
117543
|
const ok = await controlFetch(config2, "/control/status", 2e3).then((response) => response.ok).catch(() => false);
|
|
116633
117544
|
if (ok) return true;
|
|
116634
|
-
await new Promise((
|
|
117545
|
+
await new Promise((resolve5) => setTimeout(resolve5, 1e3));
|
|
116635
117546
|
}
|
|
116636
117547
|
return false;
|
|
116637
117548
|
}
|
|
116638
117549
|
var macServiceProgram = () => [process.execPath, serviceEntry()];
|
|
116639
117550
|
async function setupMacApp(dir, config2) {
|
|
116640
|
-
const app =
|
|
116641
|
-
if (!installService(macServiceProgram(),
|
|
117551
|
+
const app = basename5(appBundlePath());
|
|
117552
|
+
if (!installService(macServiceProgram(), join19(dir, "daemon.log"))) {
|
|
116642
117553
|
throw new Error(
|
|
116643
117554
|
`installed LaunchAgent ${plistPath()}, but nobody is logged in to this Mac's desktop: log in (in person or through Screen Sharing) to answer the permission prompts, then run: ${selfCommand()} setup`
|
|
116644
117555
|
);
|
|
@@ -116646,7 +117557,7 @@ async function setupMacApp(dir, config2) {
|
|
|
116646
117557
|
console.log(`Installed LaunchAgent ${plistPath()} and started ${app}.`);
|
|
116647
117558
|
if (overSsh()) console.log(`The permission prompts appear on the Mac's own screen; answer them there.`);
|
|
116648
117559
|
if (!await waitForDaemon(config2, 6e4))
|
|
116649
|
-
throw new Error(`the service did not come up; see ${
|
|
117560
|
+
throw new Error(`the service did not come up; see ${join19(dir, "daemon.log")}`);
|
|
116650
117561
|
const grants = async (prompt) => await (await controlFetch(config2, `/control/permissions${prompt ? "?prompt=1" : ""}`, 21e4)).json();
|
|
116651
117562
|
let state = await grants(false);
|
|
116652
117563
|
const initiallyMissingScreen = !state.screenRecording;
|
|
@@ -116667,7 +117578,7 @@ async function setupMacApp(dir, config2) {
|
|
|
116667
117578
|
let lastRestart = Date.now();
|
|
116668
117579
|
try {
|
|
116669
117580
|
while (!skipped && Date.now() < deadline && !(state.accessibility && state.screenRecording)) {
|
|
116670
|
-
await new Promise((
|
|
117581
|
+
await new Promise((resolve5) => setTimeout(resolve5, 2e3));
|
|
116671
117582
|
if (state.accessibility && Date.now() - lastRestart > 2e4) {
|
|
116672
117583
|
lastRestart = Date.now();
|
|
116673
117584
|
restartService();
|
|
@@ -116703,7 +117614,7 @@ async function serviceCommand(dir, config2, action, purge) {
|
|
|
116703
117614
|
if (!appBundlePath())
|
|
116704
117615
|
throw new Error("run this from the AgentConnect Computer.app binary (\u2026/Contents/MacOS/agentconnect-computer)");
|
|
116705
117616
|
}
|
|
116706
|
-
if (action === "install") installService(macServiceProgram(),
|
|
117617
|
+
if (action === "install") installService(macServiceProgram(), join19(dir, "daemon.log"));
|
|
116707
117618
|
else if (action === "uninstall") uninstallService();
|
|
116708
117619
|
else if (action === "start") startService();
|
|
116709
117620
|
else if (action === "stop") stopService();
|
|
@@ -116712,7 +117623,7 @@ async function serviceCommand(dir, config2, action, purge) {
|
|
|
116712
117623
|
const status = serviceStatus();
|
|
116713
117624
|
console.log(
|
|
116714
117625
|
JSON.stringify(
|
|
116715
|
-
{ ...status, plist: plistPath(), log:
|
|
117626
|
+
{ ...status, plist: plistPath(), log: join19(dir, "daemon.log"), port: config2.port, app: hostApp() },
|
|
116716
117627
|
null,
|
|
116717
117628
|
2
|
|
116718
117629
|
)
|
|
@@ -116753,7 +117664,7 @@ async function windowsServiceCommand(dir, config2, action, purge) {
|
|
|
116753
117664
|
...serviceStatus2(),
|
|
116754
117665
|
service: SERVICE_NAME,
|
|
116755
117666
|
home: dir,
|
|
116756
|
-
log:
|
|
117667
|
+
log: join19(dir, "daemon.log"),
|
|
116757
117668
|
port: config2.port
|
|
116758
117669
|
},
|
|
116759
117670
|
null,
|
|
@@ -116763,13 +117674,13 @@ async function windowsServiceCommand(dir, config2, action, purge) {
|
|
|
116763
117674
|
}
|
|
116764
117675
|
async function installWindowsService(dir, config2, log40) {
|
|
116765
117676
|
installService2({ entry: serviceEntry(), node: process.execPath, home: dir, log: log40 });
|
|
116766
|
-
const installedNode2 =
|
|
117677
|
+
const installedNode2 = join19(installDir(), "node.exe");
|
|
116767
117678
|
await setupWindowsFirewall({ ...setupContext(dir, config2), log: log40 }, installedNode2);
|
|
116768
117679
|
}
|
|
116769
117680
|
async function setupWindowsService(dir, config2) {
|
|
116770
117681
|
await installWindowsService(dir, config2, (line) => console.log(line));
|
|
116771
117682
|
if (!await waitForDaemon(config2, 9e4)) {
|
|
116772
|
-
console.log(`The service did not come up; see ${
|
|
117683
|
+
console.log(`The service did not come up; see ${join19(dir, "daemon.log")}`);
|
|
116773
117684
|
return doctor(setupContext(dir, config2));
|
|
116774
117685
|
}
|
|
116775
117686
|
console.log("\nChecking from inside the service:");
|