@beeuni/agent-tunnel 0.1.4 → 0.1.5
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/agent-cli.js +85 -86
- package/package.json +1 -1
package/dist/agent-cli.js
CHANGED
|
@@ -19,13 +19,15 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
19
19
|
return cached;
|
|
20
20
|
}
|
|
21
21
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
22
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
const to = isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
23
|
+
if (mod && typeof mod === "object" || typeof mod === "function") {
|
|
24
|
+
for (let key of __getOwnPropNames(mod))
|
|
25
|
+
if (!__hasOwnProp.call(to, key))
|
|
26
|
+
__defProp(to, key, {
|
|
27
|
+
get: __accessProp.bind(mod, key),
|
|
28
|
+
enumerable: true
|
|
29
|
+
});
|
|
30
|
+
}
|
|
29
31
|
if (canCache)
|
|
30
32
|
cache.set(mod, to);
|
|
31
33
|
return to;
|
|
@@ -44,11 +46,21 @@ var __export = (target, all) => {
|
|
|
44
46
|
set: __exportSetter.bind(all, name)
|
|
45
47
|
});
|
|
46
48
|
};
|
|
47
|
-
var __esm = (fn, res) => () =>
|
|
49
|
+
var __esm = (fn, res, err) => () => {
|
|
50
|
+
if (fn)
|
|
51
|
+
try {
|
|
52
|
+
res = fn(fn = 0);
|
|
53
|
+
} catch (e) {
|
|
54
|
+
err = [e];
|
|
55
|
+
}
|
|
56
|
+
if (err)
|
|
57
|
+
throw err[0];
|
|
58
|
+
return res;
|
|
59
|
+
};
|
|
48
60
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
49
61
|
|
|
50
62
|
// ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/constants.js
|
|
51
|
-
var require_constants = __commonJS((exports, module)
|
|
63
|
+
var require_constants = __commonJS(function(exports, module) {
|
|
52
64
|
var BINARY_TYPES = ["nodebuffer", "arraybuffer", "fragments"];
|
|
53
65
|
var hasBlob = typeof Blob !== "undefined";
|
|
54
66
|
if (hasBlob)
|
|
@@ -68,7 +80,7 @@ var require_constants = __commonJS((exports, module) => {
|
|
|
68
80
|
});
|
|
69
81
|
|
|
70
82
|
// ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/buffer-util.js
|
|
71
|
-
var require_buffer_util = __commonJS((exports, module)
|
|
83
|
+
var require_buffer_util = __commonJS(function(exports, module) {
|
|
72
84
|
var { EMPTY_BUFFER } = require_constants();
|
|
73
85
|
var FastBuffer = Buffer[Symbol.species];
|
|
74
86
|
function concat(list, totalLength) {
|
|
@@ -129,11 +141,11 @@ var require_buffer_util = __commonJS((exports, module) => {
|
|
|
129
141
|
if (!process.env.WS_NO_BUFFER_UTIL) {
|
|
130
142
|
try {
|
|
131
143
|
const bufferUtil = (()=>{throw new Error("Cannot require module "+"bufferutil");})();
|
|
132
|
-
module.exports.mask = function(source,
|
|
144
|
+
module.exports.mask = function(source, mask2, output, offset, length) {
|
|
133
145
|
if (length < 48)
|
|
134
|
-
_mask(source,
|
|
146
|
+
_mask(source, mask2, output, offset, length);
|
|
135
147
|
else
|
|
136
|
-
bufferUtil.mask(source,
|
|
148
|
+
bufferUtil.mask(source, mask2, output, offset, length);
|
|
137
149
|
};
|
|
138
150
|
module.exports.unmask = function(buffer, mask) {
|
|
139
151
|
if (buffer.length < 32)
|
|
@@ -146,7 +158,7 @@ var require_buffer_util = __commonJS((exports, module) => {
|
|
|
146
158
|
});
|
|
147
159
|
|
|
148
160
|
// ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/limiter.js
|
|
149
|
-
var require_limiter = __commonJS((exports, module)
|
|
161
|
+
var require_limiter = __commonJS(function(exports, module) {
|
|
150
162
|
var kDone = Symbol("kDone");
|
|
151
163
|
var kRun = Symbol("kRun");
|
|
152
164
|
|
|
@@ -178,7 +190,7 @@ var require_limiter = __commonJS((exports, module) => {
|
|
|
178
190
|
});
|
|
179
191
|
|
|
180
192
|
// ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/permessage-deflate.js
|
|
181
|
-
var require_permessage_deflate = __commonJS((exports, module)
|
|
193
|
+
var require_permessage_deflate = __commonJS(function(exports, module) {
|
|
182
194
|
var zlib = __require("zlib");
|
|
183
195
|
var bufferUtil = require_buffer_util();
|
|
184
196
|
var Limiter = require_limiter();
|
|
@@ -366,7 +378,7 @@ var require_permessage_deflate = __commonJS((exports, module) => {
|
|
|
366
378
|
callback(err);
|
|
367
379
|
return;
|
|
368
380
|
}
|
|
369
|
-
const
|
|
381
|
+
const data = bufferUtil.concat(this._inflate[kBuffers], this._inflate[kTotalLength]);
|
|
370
382
|
if (this._inflate._readableState.endEmitted) {
|
|
371
383
|
this._inflate.close();
|
|
372
384
|
this._inflate = null;
|
|
@@ -377,7 +389,7 @@ var require_permessage_deflate = __commonJS((exports, module) => {
|
|
|
377
389
|
this._inflate.reset();
|
|
378
390
|
}
|
|
379
391
|
}
|
|
380
|
-
callback(null,
|
|
392
|
+
callback(null, data);
|
|
381
393
|
});
|
|
382
394
|
}
|
|
383
395
|
_compress(data, fin, callback) {
|
|
@@ -399,9 +411,9 @@ var require_permessage_deflate = __commonJS((exports, module) => {
|
|
|
399
411
|
if (!this._deflate) {
|
|
400
412
|
return;
|
|
401
413
|
}
|
|
402
|
-
let
|
|
414
|
+
let data = bufferUtil.concat(this._deflate[kBuffers], this._deflate[kTotalLength]);
|
|
403
415
|
if (fin) {
|
|
404
|
-
|
|
416
|
+
data = new FastBuffer(data.buffer, data.byteOffset, data.length - 4);
|
|
405
417
|
}
|
|
406
418
|
this._deflate[kCallback] = null;
|
|
407
419
|
this._deflate[kTotalLength] = 0;
|
|
@@ -409,7 +421,7 @@ var require_permessage_deflate = __commonJS((exports, module) => {
|
|
|
409
421
|
if (fin && this.params[`${endpoint}_no_context_takeover`]) {
|
|
410
422
|
this._deflate.reset();
|
|
411
423
|
}
|
|
412
|
-
callback(null,
|
|
424
|
+
callback(null, data);
|
|
413
425
|
});
|
|
414
426
|
}
|
|
415
427
|
}
|
|
@@ -442,7 +454,7 @@ var require_permessage_deflate = __commonJS((exports, module) => {
|
|
|
442
454
|
});
|
|
443
455
|
|
|
444
456
|
// ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/validation.js
|
|
445
|
-
var require_validation = __commonJS((exports, module)
|
|
457
|
+
var require_validation = __commonJS(function(exports, module) {
|
|
446
458
|
var { isUtf8 } = __require("buffer");
|
|
447
459
|
var { hasBlob } = require_constants();
|
|
448
460
|
var tokenChars = [
|
|
@@ -629,7 +641,7 @@ var require_validation = __commonJS((exports, module) => {
|
|
|
629
641
|
});
|
|
630
642
|
|
|
631
643
|
// ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/receiver.js
|
|
632
|
-
var require_receiver = __commonJS((exports, module)
|
|
644
|
+
var require_receiver = __commonJS(function(exports, module) {
|
|
633
645
|
var { Writable } = __require("stream");
|
|
634
646
|
var PerMessageDeflate = require_permessage_deflate();
|
|
635
647
|
var {
|
|
@@ -1023,7 +1035,7 @@ var require_receiver = __commonJS((exports, module) => {
|
|
|
1023
1035
|
});
|
|
1024
1036
|
|
|
1025
1037
|
// ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/sender.js
|
|
1026
|
-
var require_sender = __commonJS((exports, module)
|
|
1038
|
+
var require_sender = __commonJS(function(exports, module) {
|
|
1027
1039
|
var { Duplex } = __require("stream");
|
|
1028
1040
|
var { randomFillSync } = __require("crypto");
|
|
1029
1041
|
var {
|
|
@@ -1382,7 +1394,7 @@ var require_sender = __commonJS((exports, module) => {
|
|
|
1382
1394
|
});
|
|
1383
1395
|
|
|
1384
1396
|
// ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/event-target.js
|
|
1385
|
-
var require_event_target = __commonJS((exports, module)
|
|
1397
|
+
var require_event_target = __commonJS(function(exports, module) {
|
|
1386
1398
|
var { kForOnEventAttribute, kListener } = require_constants();
|
|
1387
1399
|
var kCode = Symbol("kCode");
|
|
1388
1400
|
var kData = Symbol("kData");
|
|
@@ -1533,7 +1545,7 @@ var require_event_target = __commonJS((exports, module) => {
|
|
|
1533
1545
|
});
|
|
1534
1546
|
|
|
1535
1547
|
// ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/extension.js
|
|
1536
|
-
var require_extension = __commonJS((exports, module)
|
|
1548
|
+
var require_extension = __commonJS(function(exports, module) {
|
|
1537
1549
|
var { tokenChars } = require_validation();
|
|
1538
1550
|
function push(dest, name, elem) {
|
|
1539
1551
|
if (dest[name] === undefined)
|
|
@@ -1698,7 +1710,7 @@ var require_extension = __commonJS((exports, module) => {
|
|
|
1698
1710
|
});
|
|
1699
1711
|
|
|
1700
1712
|
// ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/websocket.js
|
|
1701
|
-
var require_websocket = __commonJS((exports, module)
|
|
1713
|
+
var require_websocket = __commonJS(function(exports, module) {
|
|
1702
1714
|
var EventEmitter = __require("events");
|
|
1703
1715
|
var https = __require("https");
|
|
1704
1716
|
var http = __require("http");
|
|
@@ -2121,7 +2133,7 @@ var require_websocket = __commonJS((exports, module) => {
|
|
|
2121
2133
|
}
|
|
2122
2134
|
const defaultPort = isSecure ? 443 : 80;
|
|
2123
2135
|
const key = randomBytes(16).toString("base64");
|
|
2124
|
-
const
|
|
2136
|
+
const request3 = isSecure ? https.request : http.request;
|
|
2125
2137
|
const protocolSet = new Set;
|
|
2126
2138
|
let perMessageDeflate;
|
|
2127
2139
|
opts.createConnection = opts.createConnection || (isSecure ? tlsConnect : netConnect);
|
|
@@ -2180,8 +2192,8 @@ var require_websocket = __commonJS((exports, module) => {
|
|
|
2180
2192
|
const headers = options && options.headers;
|
|
2181
2193
|
options = { ...options, headers: {} };
|
|
2182
2194
|
if (headers) {
|
|
2183
|
-
for (const [
|
|
2184
|
-
options.headers[
|
|
2195
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
2196
|
+
options.headers[key.toLowerCase()] = value;
|
|
2185
2197
|
}
|
|
2186
2198
|
}
|
|
2187
2199
|
} else if (websocket.listenerCount("redirect") === 0) {
|
|
@@ -2197,12 +2209,12 @@ var require_websocket = __commonJS((exports, module) => {
|
|
|
2197
2209
|
if (opts.auth && !options.headers.authorization) {
|
|
2198
2210
|
options.headers.authorization = "Basic " + Buffer.from(opts.auth).toString("base64");
|
|
2199
2211
|
}
|
|
2200
|
-
req = websocket._req =
|
|
2212
|
+
req = websocket._req = request3(opts);
|
|
2201
2213
|
if (websocket._redirects) {
|
|
2202
2214
|
websocket.emit("redirect", websocket.url, req);
|
|
2203
2215
|
}
|
|
2204
2216
|
} else {
|
|
2205
|
-
req = websocket._req =
|
|
2217
|
+
req = websocket._req = request3(opts);
|
|
2206
2218
|
}
|
|
2207
2219
|
if (opts.timeout) {
|
|
2208
2220
|
req.on("timeout", () => {
|
|
@@ -2470,7 +2482,7 @@ var require_websocket = __commonJS((exports, module) => {
|
|
|
2470
2482
|
});
|
|
2471
2483
|
|
|
2472
2484
|
// ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/stream.js
|
|
2473
|
-
var require_stream = __commonJS((exports, module)
|
|
2485
|
+
var require_stream = __commonJS(function(exports, module) {
|
|
2474
2486
|
var WebSocket2 = require_websocket();
|
|
2475
2487
|
var { Duplex } = __require("stream");
|
|
2476
2488
|
function emitClose(stream) {
|
|
@@ -2520,9 +2532,9 @@ var require_stream = __commonJS((exports, module) => {
|
|
|
2520
2532
|
return;
|
|
2521
2533
|
}
|
|
2522
2534
|
let called = false;
|
|
2523
|
-
ws.once("error", function error(
|
|
2535
|
+
ws.once("error", function error(err) {
|
|
2524
2536
|
called = true;
|
|
2525
|
-
callback(
|
|
2537
|
+
callback(err);
|
|
2526
2538
|
});
|
|
2527
2539
|
ws.once("close", function close() {
|
|
2528
2540
|
if (!called)
|
|
@@ -2573,7 +2585,7 @@ var require_stream = __commonJS((exports, module) => {
|
|
|
2573
2585
|
});
|
|
2574
2586
|
|
|
2575
2587
|
// ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/subprotocol.js
|
|
2576
|
-
var require_subprotocol = __commonJS((exports, module)
|
|
2588
|
+
var require_subprotocol = __commonJS(function(exports, module) {
|
|
2577
2589
|
var { tokenChars } = require_validation();
|
|
2578
2590
|
function parse(header) {
|
|
2579
2591
|
const protocols = new Set;
|
|
@@ -2594,11 +2606,11 @@ var require_subprotocol = __commonJS((exports, module) => {
|
|
|
2594
2606
|
}
|
|
2595
2607
|
if (end === -1)
|
|
2596
2608
|
end = i;
|
|
2597
|
-
const
|
|
2598
|
-
if (protocols.has(
|
|
2599
|
-
throw new SyntaxError(`The "${
|
|
2609
|
+
const protocol = header.slice(start, end);
|
|
2610
|
+
if (protocols.has(protocol)) {
|
|
2611
|
+
throw new SyntaxError(`The "${protocol}" subprotocol is duplicated`);
|
|
2600
2612
|
}
|
|
2601
|
-
protocols.add(
|
|
2613
|
+
protocols.add(protocol);
|
|
2602
2614
|
start = end = -1;
|
|
2603
2615
|
} else {
|
|
2604
2616
|
throw new SyntaxError(`Unexpected character at index ${i}`);
|
|
@@ -2618,7 +2630,7 @@ var require_subprotocol = __commonJS((exports, module) => {
|
|
|
2618
2630
|
});
|
|
2619
2631
|
|
|
2620
2632
|
// ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/websocket-server.js
|
|
2621
|
-
var require_websocket_server = __commonJS((exports, module)
|
|
2633
|
+
var require_websocket_server = __commonJS(function(exports, module) {
|
|
2622
2634
|
var EventEmitter = __require("events");
|
|
2623
2635
|
var http = __require("http");
|
|
2624
2636
|
var { Duplex } = __require("stream");
|
|
@@ -2930,15 +2942,8 @@ var require_websocket_server = __commonJS((exports, module) => {
|
|
|
2930
2942
|
// ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/wrapper.mjs
|
|
2931
2943
|
var exports_wrapper = {};
|
|
2932
2944
|
__export(exports_wrapper, {
|
|
2933
|
-
subprotocol: () => import_subprotocol.default,
|
|
2934
|
-
extension: () => import_extension.default,
|
|
2935
|
-
default: () => wrapper_default,
|
|
2936
|
-
createWebSocketStream: () => import_stream.default,
|
|
2937
|
-
WebSocketServer: () => import_websocket_server.default,
|
|
2938
2945
|
WebSocket: () => import_websocket.default,
|
|
2939
|
-
|
|
2940
|
-
Receiver: () => import_receiver.default,
|
|
2941
|
-
PerMessageDeflate: () => import_permessage_deflate.default
|
|
2946
|
+
default: () => wrapper_default
|
|
2942
2947
|
});
|
|
2943
2948
|
var import_stream, import_extension, import_permessage_deflate, import_receiver, import_sender, import_subprotocol, import_websocket, import_websocket_server, wrapper_default;
|
|
2944
2949
|
var init_wrapper = __esm(() => {
|
|
@@ -2957,7 +2962,7 @@ var init_wrapper = __esm(() => {
|
|
|
2957
2962
|
if (typeof globalThis.WebSocket === "undefined") {
|
|
2958
2963
|
try {
|
|
2959
2964
|
const ws = await Promise.resolve().then(() => (init_wrapper(), exports_wrapper));
|
|
2960
|
-
const WebSocketImpl = ws.WebSocket ??
|
|
2965
|
+
const WebSocketImpl = ws.WebSocket ?? wrapper_default;
|
|
2961
2966
|
globalThis.WebSocket = WebSocketImpl;
|
|
2962
2967
|
} catch {
|
|
2963
2968
|
console.error('[agent-tunnel] WebSocket is not available. Install the "ws" package or use Node.js 22+.');
|
|
@@ -3473,6 +3478,20 @@ import { randomUUID } from "crypto";
|
|
|
3473
3478
|
import { chmodSync as chmodSync2, existsSync as existsSync2, mkdirSync, readFileSync as readFileSync3, renameSync, rmSync, statSync, writeFileSync as writeFileSync2 } from "fs";
|
|
3474
3479
|
import { platform } from "os";
|
|
3475
3480
|
import { isAbsolute, join as join3 } from "path";
|
|
3481
|
+
|
|
3482
|
+
// src/agent/process-liveness.ts
|
|
3483
|
+
function isAlive(pid) {
|
|
3484
|
+
if (typeof pid !== "number" || !Number.isSafeInteger(pid) || pid <= 0)
|
|
3485
|
+
return false;
|
|
3486
|
+
try {
|
|
3487
|
+
process.kill(pid, 0);
|
|
3488
|
+
return true;
|
|
3489
|
+
} catch (error) {
|
|
3490
|
+
return error.code === "EPERM";
|
|
3491
|
+
}
|
|
3492
|
+
}
|
|
3493
|
+
|
|
3494
|
+
// src/agent/access.ts
|
|
3476
3495
|
var ACCESS_HOLD_MS = 20000;
|
|
3477
3496
|
var DESKTOP_APP_HEARTBEAT_MS = 30000;
|
|
3478
3497
|
var MAX_GRANT_MS = 24 * 3600000;
|
|
@@ -3646,16 +3665,6 @@ function clearAccessRequest(id, home = agentTunnelHome()) {
|
|
|
3646
3665
|
if (readAccessRequest(home)?.id === id)
|
|
3647
3666
|
rmSync(accessRequestPath(home), { force: true });
|
|
3648
3667
|
}
|
|
3649
|
-
function isAlive(pid) {
|
|
3650
|
-
if (typeof pid !== "number" || !Number.isSafeInteger(pid) || pid <= 0)
|
|
3651
|
-
return false;
|
|
3652
|
-
try {
|
|
3653
|
-
process.kill(pid, 0);
|
|
3654
|
-
return true;
|
|
3655
|
-
} catch (error) {
|
|
3656
|
-
return error.code === "EPERM";
|
|
3657
|
-
}
|
|
3658
|
-
}
|
|
3659
3668
|
function wakeDesktopApp(home = agentTunnelHome(), now = Date.now()) {
|
|
3660
3669
|
let app;
|
|
3661
3670
|
let touchedAt = 0;
|
|
@@ -3686,10 +3695,10 @@ function wakeDesktopApp(home = agentTunnelHome(), now = Date.now()) {
|
|
|
3686
3695
|
return "no-app";
|
|
3687
3696
|
}
|
|
3688
3697
|
}
|
|
3689
|
-
function keepAwakeCommand(
|
|
3690
|
-
if (
|
|
3698
|
+
function keepAwakeCommand(platform, pid) {
|
|
3699
|
+
if (platform === "darwin")
|
|
3691
3700
|
return { command: "caffeinate", args: ["-s", "-w", String(pid)] };
|
|
3692
|
-
if (
|
|
3701
|
+
if (platform === "linux") {
|
|
3693
3702
|
return {
|
|
3694
3703
|
command: "systemd-inhibit",
|
|
3695
3704
|
args: ["--what=sleep", "--who=Beeuni", "--why=Keep this computer reachable", "--mode=block", "tail", `--pid=${pid}`, "-f", "/dev/null"]
|
|
@@ -3956,7 +3965,7 @@ function visibleLength(value) {
|
|
|
3956
3965
|
function clearScreen() {
|
|
3957
3966
|
process.stdout.write("\x1B[2J\x1B[3J\x1B[H");
|
|
3958
3967
|
}
|
|
3959
|
-
var sleep = (ms) => new Promise((
|
|
3968
|
+
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
3960
3969
|
var glyph = {
|
|
3961
3970
|
on: `${c.green}●${c.reset}`,
|
|
3962
3971
|
off: `${c.gray}○${c.reset}`,
|
|
@@ -4495,7 +4504,7 @@ class TunnelAgent {
|
|
|
4495
4504
|
} catch {}
|
|
4496
4505
|
const deadline = Date.now() + hold;
|
|
4497
4506
|
while (Date.now() < deadline) {
|
|
4498
|
-
await new Promise((
|
|
4507
|
+
await new Promise((resolve) => setTimeout(resolve, Math.min(100, hold / 4)));
|
|
4499
4508
|
const decision = decideAccess(readAccess(this.home));
|
|
4500
4509
|
if (decision === "ask")
|
|
4501
4510
|
continue;
|
|
@@ -4537,7 +4546,7 @@ class TunnelAgent {
|
|
|
4537
4546
|
const hold = this.options.accessHoldMs ?? ACCESS_HOLD_MS;
|
|
4538
4547
|
const deadline = Date.now() + hold;
|
|
4539
4548
|
while (Date.now() < deadline) {
|
|
4540
|
-
await new Promise((
|
|
4549
|
+
await new Promise((resolve) => setTimeout(resolve, Math.min(100, hold / 4)));
|
|
4541
4550
|
if (!accessWidens(readAccess(this.home), target, this.now())) {
|
|
4542
4551
|
clearAccessRequest(asked.id, this.home);
|
|
4543
4552
|
return accessView(this.home, platform3(), this.now());
|
|
@@ -4876,7 +4885,7 @@ function hostBundleId() {
|
|
|
4876
4885
|
}
|
|
4877
4886
|
}
|
|
4878
4887
|
function execFile(cmd, args, timeoutMs = 30000, env = driverEnvironment()) {
|
|
4879
|
-
return new Promise((
|
|
4888
|
+
return new Promise((resolve, reject) => {
|
|
4880
4889
|
const proc = spawn4(cmd, args, {
|
|
4881
4890
|
stdio: ["ignore", "pipe", "pipe"],
|
|
4882
4891
|
env,
|
|
@@ -4922,7 +4931,7 @@ function execFile(cmd, args, timeoutMs = 30000, env = driverEnvironment()) {
|
|
|
4922
4931
|
const detail = stderr.trim() || stdout.trim();
|
|
4923
4932
|
reject(new Error(`${basename2(cmd)} failed (${code})${detail ? `: ${detail}` : ""}`));
|
|
4924
4933
|
} else {
|
|
4925
|
-
|
|
4934
|
+
resolve({ stdout, stderr });
|
|
4926
4935
|
}
|
|
4927
4936
|
});
|
|
4928
4937
|
proc.on("error", (err) => {
|
|
@@ -4944,7 +4953,7 @@ function isDaemonProxyFallback(message) {
|
|
|
4944
4953
|
return message.includes("daemon proxy") && message.includes("Resource temporarily unavailable");
|
|
4945
4954
|
}
|
|
4946
4955
|
async function sleep2(ms) {
|
|
4947
|
-
await new Promise((
|
|
4956
|
+
await new Promise((resolve) => setTimeout(resolve, ms));
|
|
4948
4957
|
}
|
|
4949
4958
|
function sanitizeArgs(args) {
|
|
4950
4959
|
const sanitized = {};
|
|
@@ -5584,7 +5593,7 @@ function createShellCapability(config) {
|
|
|
5584
5593
|
safeEnv[key] = process.env[key];
|
|
5585
5594
|
}
|
|
5586
5595
|
}
|
|
5587
|
-
return new Promise((
|
|
5596
|
+
return new Promise((resolve, reject) => {
|
|
5588
5597
|
const proc = spawn5(executable, args, {
|
|
5589
5598
|
cwd,
|
|
5590
5599
|
shell: false,
|
|
@@ -5628,7 +5637,7 @@ function createShellCapability(config) {
|
|
|
5628
5637
|
reject(new Error(`Command failed to start: ${err.message}`));
|
|
5629
5638
|
});
|
|
5630
5639
|
proc.on("close", (code, signal) => {
|
|
5631
|
-
|
|
5640
|
+
resolve({
|
|
5632
5641
|
exitCode: code,
|
|
5633
5642
|
signal,
|
|
5634
5643
|
stdout,
|
|
@@ -5729,17 +5738,17 @@ function clearSavedCredentials() {
|
|
|
5729
5738
|
// src/agent/credential-probe.ts
|
|
5730
5739
|
var DEFAULT_PROBE_TIMEOUT_MS = 1e4;
|
|
5731
5740
|
function probeCredentials(config, options = {}) {
|
|
5732
|
-
return new Promise((
|
|
5741
|
+
return new Promise((resolve) => {
|
|
5733
5742
|
let socket;
|
|
5734
5743
|
try {
|
|
5735
5744
|
socket = openRelaySocket(new URL(buildTunnelWsUrl(config)).href);
|
|
5736
5745
|
} catch {
|
|
5737
|
-
|
|
5746
|
+
resolve("unreachable");
|
|
5738
5747
|
return;
|
|
5739
5748
|
}
|
|
5740
5749
|
const settle = (result) => {
|
|
5741
5750
|
clearTimeout(timer);
|
|
5742
|
-
|
|
5751
|
+
resolve(result);
|
|
5743
5752
|
try {
|
|
5744
5753
|
socket.close(1000, "probe complete");
|
|
5745
5754
|
} catch {}
|
|
@@ -6314,8 +6323,8 @@ import { statSync as statSync3 } from "fs";
|
|
|
6314
6323
|
function runtimeFingerprint(files) {
|
|
6315
6324
|
return files.map((file) => {
|
|
6316
6325
|
try {
|
|
6317
|
-
const
|
|
6318
|
-
return `${
|
|
6326
|
+
const stat = statSync3(file);
|
|
6327
|
+
return `${stat.ino}:${stat.mtimeMs}:${stat.size}`;
|
|
6319
6328
|
} catch {
|
|
6320
6329
|
return "missing";
|
|
6321
6330
|
}
|
|
@@ -6364,22 +6373,12 @@ function writeAgentState(status, tunnel, home = agentTunnelHome()) {
|
|
|
6364
6373
|
renameSync3(tmp, stateFilePath(home));
|
|
6365
6374
|
} catch {}
|
|
6366
6375
|
}
|
|
6367
|
-
function isAlive2(pid) {
|
|
6368
|
-
if (typeof pid !== "number" || !Number.isSafeInteger(pid) || pid <= 0)
|
|
6369
|
-
return false;
|
|
6370
|
-
try {
|
|
6371
|
-
process.kill(pid, 0);
|
|
6372
|
-
return true;
|
|
6373
|
-
} catch (error) {
|
|
6374
|
-
return error.code === "EPERM";
|
|
6375
|
-
}
|
|
6376
|
-
}
|
|
6377
6376
|
function readAgentState(home = agentTunnelHome()) {
|
|
6378
6377
|
try {
|
|
6379
6378
|
const parsed = JSON.parse(readFileSync10(stateFilePath(home), "utf8"));
|
|
6380
6379
|
if (!parsed || typeof parsed !== "object" || typeof parsed.status !== "string")
|
|
6381
6380
|
return null;
|
|
6382
|
-
return parsed.status !== "offline" && !
|
|
6381
|
+
return parsed.status !== "offline" && !isAlive(parsed.pid) ? { ...parsed, status: "offline" } : parsed;
|
|
6383
6382
|
} catch {
|
|
6384
6383
|
return null;
|
|
6385
6384
|
}
|
package/package.json
CHANGED