remotelink 0.4.8 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -4
- package/dist/go-binaries.json +11 -0
- package/dist/index.js +644 -381
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -59,54 +59,54 @@ var require_polyfills = __commonJS({
|
|
|
59
59
|
}
|
|
60
60
|
var chdir;
|
|
61
61
|
module.exports = patch;
|
|
62
|
-
function patch(
|
|
62
|
+
function patch(fs9) {
|
|
63
63
|
if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
|
|
64
|
-
patchLchmod(
|
|
65
|
-
}
|
|
66
|
-
if (!
|
|
67
|
-
patchLutimes(
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (
|
|
88
|
-
|
|
64
|
+
patchLchmod(fs9);
|
|
65
|
+
}
|
|
66
|
+
if (!fs9.lutimes) {
|
|
67
|
+
patchLutimes(fs9);
|
|
68
|
+
}
|
|
69
|
+
fs9.chown = chownFix(fs9.chown);
|
|
70
|
+
fs9.fchown = chownFix(fs9.fchown);
|
|
71
|
+
fs9.lchown = chownFix(fs9.lchown);
|
|
72
|
+
fs9.chmod = chmodFix(fs9.chmod);
|
|
73
|
+
fs9.fchmod = chmodFix(fs9.fchmod);
|
|
74
|
+
fs9.lchmod = chmodFix(fs9.lchmod);
|
|
75
|
+
fs9.chownSync = chownFixSync(fs9.chownSync);
|
|
76
|
+
fs9.fchownSync = chownFixSync(fs9.fchownSync);
|
|
77
|
+
fs9.lchownSync = chownFixSync(fs9.lchownSync);
|
|
78
|
+
fs9.chmodSync = chmodFixSync(fs9.chmodSync);
|
|
79
|
+
fs9.fchmodSync = chmodFixSync(fs9.fchmodSync);
|
|
80
|
+
fs9.lchmodSync = chmodFixSync(fs9.lchmodSync);
|
|
81
|
+
fs9.stat = statFix(fs9.stat);
|
|
82
|
+
fs9.fstat = statFix(fs9.fstat);
|
|
83
|
+
fs9.lstat = statFix(fs9.lstat);
|
|
84
|
+
fs9.statSync = statFixSync(fs9.statSync);
|
|
85
|
+
fs9.fstatSync = statFixSync(fs9.fstatSync);
|
|
86
|
+
fs9.lstatSync = statFixSync(fs9.lstatSync);
|
|
87
|
+
if (fs9.chmod && !fs9.lchmod) {
|
|
88
|
+
fs9.lchmod = function(path9, mode, cb) {
|
|
89
89
|
if (cb) process.nextTick(cb);
|
|
90
90
|
};
|
|
91
|
-
|
|
91
|
+
fs9.lchmodSync = function() {
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
|
-
if (
|
|
95
|
-
|
|
94
|
+
if (fs9.chown && !fs9.lchown) {
|
|
95
|
+
fs9.lchown = function(path9, uid, gid, cb) {
|
|
96
96
|
if (cb) process.nextTick(cb);
|
|
97
97
|
};
|
|
98
|
-
|
|
98
|
+
fs9.lchownSync = function() {
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
101
|
if (platform === "win32") {
|
|
102
|
-
|
|
102
|
+
fs9.rename = typeof fs9.rename !== "function" ? fs9.rename : (function(fs$rename) {
|
|
103
103
|
function rename(from, to, cb) {
|
|
104
104
|
var start = Date.now();
|
|
105
105
|
var backoff = 0;
|
|
106
106
|
fs$rename(from, to, function CB(er) {
|
|
107
107
|
if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) {
|
|
108
108
|
setTimeout(function() {
|
|
109
|
-
|
|
109
|
+
fs9.stat(to, function(stater, st) {
|
|
110
110
|
if (stater && stater.code === "ENOENT")
|
|
111
111
|
fs$rename(from, to, CB);
|
|
112
112
|
else
|
|
@@ -122,9 +122,9 @@ var require_polyfills = __commonJS({
|
|
|
122
122
|
}
|
|
123
123
|
if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename);
|
|
124
124
|
return rename;
|
|
125
|
-
})(
|
|
125
|
+
})(fs9.rename);
|
|
126
126
|
}
|
|
127
|
-
|
|
127
|
+
fs9.read = typeof fs9.read !== "function" ? fs9.read : (function(fs$read) {
|
|
128
128
|
function read(fd, buffer, offset, length, position, callback_) {
|
|
129
129
|
var callback;
|
|
130
130
|
if (callback_ && typeof callback_ === "function") {
|
|
@@ -132,22 +132,22 @@ var require_polyfills = __commonJS({
|
|
|
132
132
|
callback = function(er, _, __) {
|
|
133
133
|
if (er && er.code === "EAGAIN" && eagCounter < 10) {
|
|
134
134
|
eagCounter++;
|
|
135
|
-
return fs$read.call(
|
|
135
|
+
return fs$read.call(fs9, fd, buffer, offset, length, position, callback);
|
|
136
136
|
}
|
|
137
137
|
callback_.apply(this, arguments);
|
|
138
138
|
};
|
|
139
139
|
}
|
|
140
|
-
return fs$read.call(
|
|
140
|
+
return fs$read.call(fs9, fd, buffer, offset, length, position, callback);
|
|
141
141
|
}
|
|
142
142
|
if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
|
|
143
143
|
return read;
|
|
144
|
-
})(
|
|
145
|
-
|
|
144
|
+
})(fs9.read);
|
|
145
|
+
fs9.readSync = typeof fs9.readSync !== "function" ? fs9.readSync : /* @__PURE__ */ (function(fs$readSync) {
|
|
146
146
|
return function(fd, buffer, offset, length, position) {
|
|
147
147
|
var eagCounter = 0;
|
|
148
148
|
while (true) {
|
|
149
149
|
try {
|
|
150
|
-
return fs$readSync.call(
|
|
150
|
+
return fs$readSync.call(fs9, fd, buffer, offset, length, position);
|
|
151
151
|
} catch (er) {
|
|
152
152
|
if (er.code === "EAGAIN" && eagCounter < 10) {
|
|
153
153
|
eagCounter++;
|
|
@@ -157,11 +157,11 @@ var require_polyfills = __commonJS({
|
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
};
|
|
160
|
-
})(
|
|
161
|
-
function patchLchmod(
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
160
|
+
})(fs9.readSync);
|
|
161
|
+
function patchLchmod(fs10) {
|
|
162
|
+
fs10.lchmod = function(path9, mode, callback) {
|
|
163
|
+
fs10.open(
|
|
164
|
+
path9,
|
|
165
165
|
constants.O_WRONLY | constants.O_SYMLINK,
|
|
166
166
|
mode,
|
|
167
167
|
function(err, fd) {
|
|
@@ -169,80 +169,80 @@ var require_polyfills = __commonJS({
|
|
|
169
169
|
if (callback) callback(err);
|
|
170
170
|
return;
|
|
171
171
|
}
|
|
172
|
-
|
|
173
|
-
|
|
172
|
+
fs10.fchmod(fd, mode, function(err2) {
|
|
173
|
+
fs10.close(fd, function(err22) {
|
|
174
174
|
if (callback) callback(err2 || err22);
|
|
175
175
|
});
|
|
176
176
|
});
|
|
177
177
|
}
|
|
178
178
|
);
|
|
179
179
|
};
|
|
180
|
-
|
|
181
|
-
var fd =
|
|
180
|
+
fs10.lchmodSync = function(path9, mode) {
|
|
181
|
+
var fd = fs10.openSync(path9, constants.O_WRONLY | constants.O_SYMLINK, mode);
|
|
182
182
|
var threw = true;
|
|
183
183
|
var ret;
|
|
184
184
|
try {
|
|
185
|
-
ret =
|
|
185
|
+
ret = fs10.fchmodSync(fd, mode);
|
|
186
186
|
threw = false;
|
|
187
187
|
} finally {
|
|
188
188
|
if (threw) {
|
|
189
189
|
try {
|
|
190
|
-
|
|
190
|
+
fs10.closeSync(fd);
|
|
191
191
|
} catch (er) {
|
|
192
192
|
}
|
|
193
193
|
} else {
|
|
194
|
-
|
|
194
|
+
fs10.closeSync(fd);
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
197
|
return ret;
|
|
198
198
|
};
|
|
199
199
|
}
|
|
200
|
-
function patchLutimes(
|
|
201
|
-
if (constants.hasOwnProperty("O_SYMLINK") &&
|
|
202
|
-
|
|
203
|
-
|
|
200
|
+
function patchLutimes(fs10) {
|
|
201
|
+
if (constants.hasOwnProperty("O_SYMLINK") && fs10.futimes) {
|
|
202
|
+
fs10.lutimes = function(path9, at, mt, cb) {
|
|
203
|
+
fs10.open(path9, constants.O_SYMLINK, function(er, fd) {
|
|
204
204
|
if (er) {
|
|
205
205
|
if (cb) cb(er);
|
|
206
206
|
return;
|
|
207
207
|
}
|
|
208
|
-
|
|
209
|
-
|
|
208
|
+
fs10.futimes(fd, at, mt, function(er2) {
|
|
209
|
+
fs10.close(fd, function(er22) {
|
|
210
210
|
if (cb) cb(er2 || er22);
|
|
211
211
|
});
|
|
212
212
|
});
|
|
213
213
|
});
|
|
214
214
|
};
|
|
215
|
-
|
|
216
|
-
var fd =
|
|
215
|
+
fs10.lutimesSync = function(path9, at, mt) {
|
|
216
|
+
var fd = fs10.openSync(path9, constants.O_SYMLINK);
|
|
217
217
|
var ret;
|
|
218
218
|
var threw = true;
|
|
219
219
|
try {
|
|
220
|
-
ret =
|
|
220
|
+
ret = fs10.futimesSync(fd, at, mt);
|
|
221
221
|
threw = false;
|
|
222
222
|
} finally {
|
|
223
223
|
if (threw) {
|
|
224
224
|
try {
|
|
225
|
-
|
|
225
|
+
fs10.closeSync(fd);
|
|
226
226
|
} catch (er) {
|
|
227
227
|
}
|
|
228
228
|
} else {
|
|
229
|
-
|
|
229
|
+
fs10.closeSync(fd);
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
return ret;
|
|
233
233
|
};
|
|
234
|
-
} else if (
|
|
235
|
-
|
|
234
|
+
} else if (fs10.futimes) {
|
|
235
|
+
fs10.lutimes = function(_a, _b, _c, cb) {
|
|
236
236
|
if (cb) process.nextTick(cb);
|
|
237
237
|
};
|
|
238
|
-
|
|
238
|
+
fs10.lutimesSync = function() {
|
|
239
239
|
};
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
242
|
function chmodFix(orig) {
|
|
243
243
|
if (!orig) return orig;
|
|
244
244
|
return function(target, mode, cb) {
|
|
245
|
-
return orig.call(
|
|
245
|
+
return orig.call(fs9, target, mode, function(er) {
|
|
246
246
|
if (chownErOk(er)) er = null;
|
|
247
247
|
if (cb) cb.apply(this, arguments);
|
|
248
248
|
});
|
|
@@ -252,7 +252,7 @@ var require_polyfills = __commonJS({
|
|
|
252
252
|
if (!orig) return orig;
|
|
253
253
|
return function(target, mode) {
|
|
254
254
|
try {
|
|
255
|
-
return orig.call(
|
|
255
|
+
return orig.call(fs9, target, mode);
|
|
256
256
|
} catch (er) {
|
|
257
257
|
if (!chownErOk(er)) throw er;
|
|
258
258
|
}
|
|
@@ -261,7 +261,7 @@ var require_polyfills = __commonJS({
|
|
|
261
261
|
function chownFix(orig) {
|
|
262
262
|
if (!orig) return orig;
|
|
263
263
|
return function(target, uid, gid, cb) {
|
|
264
|
-
return orig.call(
|
|
264
|
+
return orig.call(fs9, target, uid, gid, function(er) {
|
|
265
265
|
if (chownErOk(er)) er = null;
|
|
266
266
|
if (cb) cb.apply(this, arguments);
|
|
267
267
|
});
|
|
@@ -271,7 +271,7 @@ var require_polyfills = __commonJS({
|
|
|
271
271
|
if (!orig) return orig;
|
|
272
272
|
return function(target, uid, gid) {
|
|
273
273
|
try {
|
|
274
|
-
return orig.call(
|
|
274
|
+
return orig.call(fs9, target, uid, gid);
|
|
275
275
|
} catch (er) {
|
|
276
276
|
if (!chownErOk(er)) throw er;
|
|
277
277
|
}
|
|
@@ -291,13 +291,13 @@ var require_polyfills = __commonJS({
|
|
|
291
291
|
}
|
|
292
292
|
if (cb) cb.apply(this, arguments);
|
|
293
293
|
}
|
|
294
|
-
return options ? orig.call(
|
|
294
|
+
return options ? orig.call(fs9, target, options, callback) : orig.call(fs9, target, callback);
|
|
295
295
|
};
|
|
296
296
|
}
|
|
297
297
|
function statFixSync(orig) {
|
|
298
298
|
if (!orig) return orig;
|
|
299
299
|
return function(target, options) {
|
|
300
|
-
var stats = options ? orig.call(
|
|
300
|
+
var stats = options ? orig.call(fs9, target, options) : orig.call(fs9, target);
|
|
301
301
|
if (stats) {
|
|
302
302
|
if (stats.uid < 0) stats.uid += 4294967296;
|
|
303
303
|
if (stats.gid < 0) stats.gid += 4294967296;
|
|
@@ -327,16 +327,16 @@ var require_legacy_streams = __commonJS({
|
|
|
327
327
|
"use strict";
|
|
328
328
|
var Stream = __require("stream").Stream;
|
|
329
329
|
module.exports = legacy;
|
|
330
|
-
function legacy(
|
|
330
|
+
function legacy(fs9) {
|
|
331
331
|
return {
|
|
332
332
|
ReadStream,
|
|
333
333
|
WriteStream
|
|
334
334
|
};
|
|
335
|
-
function ReadStream(
|
|
336
|
-
if (!(this instanceof ReadStream)) return new ReadStream(
|
|
335
|
+
function ReadStream(path9, options) {
|
|
336
|
+
if (!(this instanceof ReadStream)) return new ReadStream(path9, options);
|
|
337
337
|
Stream.call(this);
|
|
338
338
|
var self = this;
|
|
339
|
-
this.path =
|
|
339
|
+
this.path = path9;
|
|
340
340
|
this.fd = null;
|
|
341
341
|
this.readable = true;
|
|
342
342
|
this.paused = false;
|
|
@@ -370,7 +370,7 @@ var require_legacy_streams = __commonJS({
|
|
|
370
370
|
});
|
|
371
371
|
return;
|
|
372
372
|
}
|
|
373
|
-
|
|
373
|
+
fs9.open(this.path, this.flags, this.mode, function(err, fd) {
|
|
374
374
|
if (err) {
|
|
375
375
|
self.emit("error", err);
|
|
376
376
|
self.readable = false;
|
|
@@ -381,10 +381,10 @@ var require_legacy_streams = __commonJS({
|
|
|
381
381
|
self._read();
|
|
382
382
|
});
|
|
383
383
|
}
|
|
384
|
-
function WriteStream(
|
|
385
|
-
if (!(this instanceof WriteStream)) return new WriteStream(
|
|
384
|
+
function WriteStream(path9, options) {
|
|
385
|
+
if (!(this instanceof WriteStream)) return new WriteStream(path9, options);
|
|
386
386
|
Stream.call(this);
|
|
387
|
-
this.path =
|
|
387
|
+
this.path = path9;
|
|
388
388
|
this.fd = null;
|
|
389
389
|
this.writable = true;
|
|
390
390
|
this.flags = "w";
|
|
@@ -409,7 +409,7 @@ var require_legacy_streams = __commonJS({
|
|
|
409
409
|
this.busy = false;
|
|
410
410
|
this._queue = [];
|
|
411
411
|
if (this.fd === null) {
|
|
412
|
-
this._open =
|
|
412
|
+
this._open = fs9.open;
|
|
413
413
|
this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
|
|
414
414
|
this.flush();
|
|
415
415
|
}
|
|
@@ -445,7 +445,7 @@ var require_clone = __commonJS({
|
|
|
445
445
|
var require_graceful_fs = __commonJS({
|
|
446
446
|
"../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js"(exports, module) {
|
|
447
447
|
"use strict";
|
|
448
|
-
var
|
|
448
|
+
var fs9 = __require("fs");
|
|
449
449
|
var polyfills = require_polyfills();
|
|
450
450
|
var legacy = require_legacy_streams();
|
|
451
451
|
var clone = require_clone();
|
|
@@ -477,12 +477,12 @@ var require_graceful_fs = __commonJS({
|
|
|
477
477
|
m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
|
|
478
478
|
console.error(m);
|
|
479
479
|
};
|
|
480
|
-
if (!
|
|
480
|
+
if (!fs9[gracefulQueue]) {
|
|
481
481
|
queue = global[gracefulQueue] || [];
|
|
482
|
-
publishQueue(
|
|
483
|
-
|
|
482
|
+
publishQueue(fs9, queue);
|
|
483
|
+
fs9.close = (function(fs$close) {
|
|
484
484
|
function close(fd, cb) {
|
|
485
|
-
return fs$close.call(
|
|
485
|
+
return fs$close.call(fs9, fd, function(err) {
|
|
486
486
|
if (!err) {
|
|
487
487
|
resetQueue();
|
|
488
488
|
}
|
|
@@ -494,48 +494,48 @@ var require_graceful_fs = __commonJS({
|
|
|
494
494
|
value: fs$close
|
|
495
495
|
});
|
|
496
496
|
return close;
|
|
497
|
-
})(
|
|
498
|
-
|
|
497
|
+
})(fs9.close);
|
|
498
|
+
fs9.closeSync = (function(fs$closeSync) {
|
|
499
499
|
function closeSync2(fd) {
|
|
500
|
-
fs$closeSync.apply(
|
|
500
|
+
fs$closeSync.apply(fs9, arguments);
|
|
501
501
|
resetQueue();
|
|
502
502
|
}
|
|
503
503
|
Object.defineProperty(closeSync2, previousSymbol, {
|
|
504
504
|
value: fs$closeSync
|
|
505
505
|
});
|
|
506
506
|
return closeSync2;
|
|
507
|
-
})(
|
|
507
|
+
})(fs9.closeSync);
|
|
508
508
|
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
|
|
509
509
|
process.on("exit", function() {
|
|
510
|
-
debug(
|
|
511
|
-
__require("assert").equal(
|
|
510
|
+
debug(fs9[gracefulQueue]);
|
|
511
|
+
__require("assert").equal(fs9[gracefulQueue].length, 0);
|
|
512
512
|
});
|
|
513
513
|
}
|
|
514
514
|
}
|
|
515
515
|
var queue;
|
|
516
516
|
if (!global[gracefulQueue]) {
|
|
517
|
-
publishQueue(global,
|
|
518
|
-
}
|
|
519
|
-
module.exports = patch(clone(
|
|
520
|
-
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !
|
|
521
|
-
module.exports = patch(
|
|
522
|
-
|
|
523
|
-
}
|
|
524
|
-
function patch(
|
|
525
|
-
polyfills(
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
var fs$readFile =
|
|
530
|
-
|
|
531
|
-
function readFile(
|
|
517
|
+
publishQueue(global, fs9[gracefulQueue]);
|
|
518
|
+
}
|
|
519
|
+
module.exports = patch(clone(fs9));
|
|
520
|
+
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs9.__patched) {
|
|
521
|
+
module.exports = patch(fs9);
|
|
522
|
+
fs9.__patched = true;
|
|
523
|
+
}
|
|
524
|
+
function patch(fs10) {
|
|
525
|
+
polyfills(fs10);
|
|
526
|
+
fs10.gracefulify = patch;
|
|
527
|
+
fs10.createReadStream = createReadStream2;
|
|
528
|
+
fs10.createWriteStream = createWriteStream;
|
|
529
|
+
var fs$readFile = fs10.readFile;
|
|
530
|
+
fs10.readFile = readFile;
|
|
531
|
+
function readFile(path9, options, cb) {
|
|
532
532
|
if (typeof options === "function")
|
|
533
533
|
cb = options, options = null;
|
|
534
|
-
return go$readFile(
|
|
535
|
-
function go$readFile(
|
|
536
|
-
return fs$readFile(
|
|
534
|
+
return go$readFile(path9, options, cb);
|
|
535
|
+
function go$readFile(path10, options2, cb2, startTime) {
|
|
536
|
+
return fs$readFile(path10, options2, function(err) {
|
|
537
537
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
538
|
-
enqueue([go$readFile, [
|
|
538
|
+
enqueue([go$readFile, [path10, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
539
539
|
else {
|
|
540
540
|
if (typeof cb2 === "function")
|
|
541
541
|
cb2.apply(this, arguments);
|
|
@@ -543,16 +543,16 @@ var require_graceful_fs = __commonJS({
|
|
|
543
543
|
});
|
|
544
544
|
}
|
|
545
545
|
}
|
|
546
|
-
var fs$writeFile =
|
|
547
|
-
|
|
548
|
-
function writeFile(
|
|
546
|
+
var fs$writeFile = fs10.writeFile;
|
|
547
|
+
fs10.writeFile = writeFile;
|
|
548
|
+
function writeFile(path9, data, options, cb) {
|
|
549
549
|
if (typeof options === "function")
|
|
550
550
|
cb = options, options = null;
|
|
551
|
-
return go$writeFile(
|
|
552
|
-
function go$writeFile(
|
|
553
|
-
return fs$writeFile(
|
|
551
|
+
return go$writeFile(path9, data, options, cb);
|
|
552
|
+
function go$writeFile(path10, data2, options2, cb2, startTime) {
|
|
553
|
+
return fs$writeFile(path10, data2, options2, function(err) {
|
|
554
554
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
555
|
-
enqueue([go$writeFile, [
|
|
555
|
+
enqueue([go$writeFile, [path10, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
556
556
|
else {
|
|
557
557
|
if (typeof cb2 === "function")
|
|
558
558
|
cb2.apply(this, arguments);
|
|
@@ -560,17 +560,17 @@ var require_graceful_fs = __commonJS({
|
|
|
560
560
|
});
|
|
561
561
|
}
|
|
562
562
|
}
|
|
563
|
-
var fs$appendFile =
|
|
563
|
+
var fs$appendFile = fs10.appendFile;
|
|
564
564
|
if (fs$appendFile)
|
|
565
|
-
|
|
566
|
-
function appendFile(
|
|
565
|
+
fs10.appendFile = appendFile;
|
|
566
|
+
function appendFile(path9, data, options, cb) {
|
|
567
567
|
if (typeof options === "function")
|
|
568
568
|
cb = options, options = null;
|
|
569
|
-
return go$appendFile(
|
|
570
|
-
function go$appendFile(
|
|
571
|
-
return fs$appendFile(
|
|
569
|
+
return go$appendFile(path9, data, options, cb);
|
|
570
|
+
function go$appendFile(path10, data2, options2, cb2, startTime) {
|
|
571
|
+
return fs$appendFile(path10, data2, options2, function(err) {
|
|
572
572
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
573
|
-
enqueue([go$appendFile, [
|
|
573
|
+
enqueue([go$appendFile, [path10, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
574
574
|
else {
|
|
575
575
|
if (typeof cb2 === "function")
|
|
576
576
|
cb2.apply(this, arguments);
|
|
@@ -578,9 +578,9 @@ var require_graceful_fs = __commonJS({
|
|
|
578
578
|
});
|
|
579
579
|
}
|
|
580
580
|
}
|
|
581
|
-
var fs$copyFile =
|
|
581
|
+
var fs$copyFile = fs10.copyFile;
|
|
582
582
|
if (fs$copyFile)
|
|
583
|
-
|
|
583
|
+
fs10.copyFile = copyFile;
|
|
584
584
|
function copyFile(src, dest, flags, cb) {
|
|
585
585
|
if (typeof flags === "function") {
|
|
586
586
|
cb = flags;
|
|
@@ -598,34 +598,34 @@ var require_graceful_fs = __commonJS({
|
|
|
598
598
|
});
|
|
599
599
|
}
|
|
600
600
|
}
|
|
601
|
-
var fs$readdir =
|
|
602
|
-
|
|
601
|
+
var fs$readdir = fs10.readdir;
|
|
602
|
+
fs10.readdir = readdir;
|
|
603
603
|
var noReaddirOptionVersions = /^v[0-5]\./;
|
|
604
|
-
function readdir(
|
|
604
|
+
function readdir(path9, options, cb) {
|
|
605
605
|
if (typeof options === "function")
|
|
606
606
|
cb = options, options = null;
|
|
607
|
-
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(
|
|
608
|
-
return fs$readdir(
|
|
609
|
-
|
|
607
|
+
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path10, options2, cb2, startTime) {
|
|
608
|
+
return fs$readdir(path10, fs$readdirCallback(
|
|
609
|
+
path10,
|
|
610
610
|
options2,
|
|
611
611
|
cb2,
|
|
612
612
|
startTime
|
|
613
613
|
));
|
|
614
|
-
} : function go$readdir2(
|
|
615
|
-
return fs$readdir(
|
|
616
|
-
|
|
614
|
+
} : function go$readdir2(path10, options2, cb2, startTime) {
|
|
615
|
+
return fs$readdir(path10, options2, fs$readdirCallback(
|
|
616
|
+
path10,
|
|
617
617
|
options2,
|
|
618
618
|
cb2,
|
|
619
619
|
startTime
|
|
620
620
|
));
|
|
621
621
|
};
|
|
622
|
-
return go$readdir(
|
|
623
|
-
function fs$readdirCallback(
|
|
622
|
+
return go$readdir(path9, options, cb);
|
|
623
|
+
function fs$readdirCallback(path10, options2, cb2, startTime) {
|
|
624
624
|
return function(err, files) {
|
|
625
625
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
626
626
|
enqueue([
|
|
627
627
|
go$readdir,
|
|
628
|
-
[
|
|
628
|
+
[path10, options2, cb2],
|
|
629
629
|
err,
|
|
630
630
|
startTime || Date.now(),
|
|
631
631
|
Date.now()
|
|
@@ -640,21 +640,21 @@ var require_graceful_fs = __commonJS({
|
|
|
640
640
|
}
|
|
641
641
|
}
|
|
642
642
|
if (process.version.substr(0, 4) === "v0.8") {
|
|
643
|
-
var legStreams = legacy(
|
|
643
|
+
var legStreams = legacy(fs10);
|
|
644
644
|
ReadStream = legStreams.ReadStream;
|
|
645
645
|
WriteStream = legStreams.WriteStream;
|
|
646
646
|
}
|
|
647
|
-
var fs$ReadStream =
|
|
647
|
+
var fs$ReadStream = fs10.ReadStream;
|
|
648
648
|
if (fs$ReadStream) {
|
|
649
649
|
ReadStream.prototype = Object.create(fs$ReadStream.prototype);
|
|
650
650
|
ReadStream.prototype.open = ReadStream$open;
|
|
651
651
|
}
|
|
652
|
-
var fs$WriteStream =
|
|
652
|
+
var fs$WriteStream = fs10.WriteStream;
|
|
653
653
|
if (fs$WriteStream) {
|
|
654
654
|
WriteStream.prototype = Object.create(fs$WriteStream.prototype);
|
|
655
655
|
WriteStream.prototype.open = WriteStream$open;
|
|
656
656
|
}
|
|
657
|
-
Object.defineProperty(
|
|
657
|
+
Object.defineProperty(fs10, "ReadStream", {
|
|
658
658
|
get: function() {
|
|
659
659
|
return ReadStream;
|
|
660
660
|
},
|
|
@@ -664,7 +664,7 @@ var require_graceful_fs = __commonJS({
|
|
|
664
664
|
enumerable: true,
|
|
665
665
|
configurable: true
|
|
666
666
|
});
|
|
667
|
-
Object.defineProperty(
|
|
667
|
+
Object.defineProperty(fs10, "WriteStream", {
|
|
668
668
|
get: function() {
|
|
669
669
|
return WriteStream;
|
|
670
670
|
},
|
|
@@ -675,7 +675,7 @@ var require_graceful_fs = __commonJS({
|
|
|
675
675
|
configurable: true
|
|
676
676
|
});
|
|
677
677
|
var FileReadStream = ReadStream;
|
|
678
|
-
Object.defineProperty(
|
|
678
|
+
Object.defineProperty(fs10, "FileReadStream", {
|
|
679
679
|
get: function() {
|
|
680
680
|
return FileReadStream;
|
|
681
681
|
},
|
|
@@ -686,7 +686,7 @@ var require_graceful_fs = __commonJS({
|
|
|
686
686
|
configurable: true
|
|
687
687
|
});
|
|
688
688
|
var FileWriteStream = WriteStream;
|
|
689
|
-
Object.defineProperty(
|
|
689
|
+
Object.defineProperty(fs10, "FileWriteStream", {
|
|
690
690
|
get: function() {
|
|
691
691
|
return FileWriteStream;
|
|
692
692
|
},
|
|
@@ -696,7 +696,7 @@ var require_graceful_fs = __commonJS({
|
|
|
696
696
|
enumerable: true,
|
|
697
697
|
configurable: true
|
|
698
698
|
});
|
|
699
|
-
function ReadStream(
|
|
699
|
+
function ReadStream(path9, options) {
|
|
700
700
|
if (this instanceof ReadStream)
|
|
701
701
|
return fs$ReadStream.apply(this, arguments), this;
|
|
702
702
|
else
|
|
@@ -716,7 +716,7 @@ var require_graceful_fs = __commonJS({
|
|
|
716
716
|
}
|
|
717
717
|
});
|
|
718
718
|
}
|
|
719
|
-
function WriteStream(
|
|
719
|
+
function WriteStream(path9, options) {
|
|
720
720
|
if (this instanceof WriteStream)
|
|
721
721
|
return fs$WriteStream.apply(this, arguments), this;
|
|
722
722
|
else
|
|
@@ -734,22 +734,22 @@ var require_graceful_fs = __commonJS({
|
|
|
734
734
|
}
|
|
735
735
|
});
|
|
736
736
|
}
|
|
737
|
-
function createReadStream2(
|
|
738
|
-
return new
|
|
737
|
+
function createReadStream2(path9, options) {
|
|
738
|
+
return new fs10.ReadStream(path9, options);
|
|
739
739
|
}
|
|
740
|
-
function createWriteStream(
|
|
741
|
-
return new
|
|
740
|
+
function createWriteStream(path9, options) {
|
|
741
|
+
return new fs10.WriteStream(path9, options);
|
|
742
742
|
}
|
|
743
|
-
var fs$open =
|
|
744
|
-
|
|
745
|
-
function open(
|
|
743
|
+
var fs$open = fs10.open;
|
|
744
|
+
fs10.open = open;
|
|
745
|
+
function open(path9, flags, mode, cb) {
|
|
746
746
|
if (typeof mode === "function")
|
|
747
747
|
cb = mode, mode = null;
|
|
748
|
-
return go$open(
|
|
749
|
-
function go$open(
|
|
750
|
-
return fs$open(
|
|
748
|
+
return go$open(path9, flags, mode, cb);
|
|
749
|
+
function go$open(path10, flags2, mode2, cb2, startTime) {
|
|
750
|
+
return fs$open(path10, flags2, mode2, function(err, fd) {
|
|
751
751
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
752
|
-
enqueue([go$open, [
|
|
752
|
+
enqueue([go$open, [path10, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
753
753
|
else {
|
|
754
754
|
if (typeof cb2 === "function")
|
|
755
755
|
cb2.apply(this, arguments);
|
|
@@ -757,20 +757,20 @@ var require_graceful_fs = __commonJS({
|
|
|
757
757
|
});
|
|
758
758
|
}
|
|
759
759
|
}
|
|
760
|
-
return
|
|
760
|
+
return fs10;
|
|
761
761
|
}
|
|
762
762
|
function enqueue(elem) {
|
|
763
763
|
debug("ENQUEUE", elem[0].name, elem[1]);
|
|
764
|
-
|
|
764
|
+
fs9[gracefulQueue].push(elem);
|
|
765
765
|
retry();
|
|
766
766
|
}
|
|
767
767
|
var retryTimer;
|
|
768
768
|
function resetQueue() {
|
|
769
769
|
var now = Date.now();
|
|
770
|
-
for (var i = 0; i <
|
|
771
|
-
if (
|
|
772
|
-
|
|
773
|
-
|
|
770
|
+
for (var i = 0; i < fs9[gracefulQueue].length; ++i) {
|
|
771
|
+
if (fs9[gracefulQueue][i].length > 2) {
|
|
772
|
+
fs9[gracefulQueue][i][3] = now;
|
|
773
|
+
fs9[gracefulQueue][i][4] = now;
|
|
774
774
|
}
|
|
775
775
|
}
|
|
776
776
|
retry();
|
|
@@ -778,9 +778,9 @@ var require_graceful_fs = __commonJS({
|
|
|
778
778
|
function retry() {
|
|
779
779
|
clearTimeout(retryTimer);
|
|
780
780
|
retryTimer = void 0;
|
|
781
|
-
if (
|
|
781
|
+
if (fs9[gracefulQueue].length === 0)
|
|
782
782
|
return;
|
|
783
|
-
var elem =
|
|
783
|
+
var elem = fs9[gracefulQueue].shift();
|
|
784
784
|
var fn = elem[0];
|
|
785
785
|
var args = elem[1];
|
|
786
786
|
var err = elem[2];
|
|
@@ -802,7 +802,7 @@ var require_graceful_fs = __commonJS({
|
|
|
802
802
|
debug("RETRY", fn.name, args);
|
|
803
803
|
fn.apply(null, args.concat([startTime]));
|
|
804
804
|
} else {
|
|
805
|
-
|
|
805
|
+
fs9[gracefulQueue].push(elem);
|
|
806
806
|
}
|
|
807
807
|
}
|
|
808
808
|
if (retryTimer === void 0) {
|
|
@@ -1242,10 +1242,10 @@ var require_mtime_precision = __commonJS({
|
|
|
1242
1242
|
"../../node_modules/.pnpm/proper-lockfile@4.1.2/node_modules/proper-lockfile/lib/mtime-precision.js"(exports, module) {
|
|
1243
1243
|
"use strict";
|
|
1244
1244
|
var cacheSymbol = /* @__PURE__ */ Symbol();
|
|
1245
|
-
function probe(file,
|
|
1246
|
-
const cachedPrecision =
|
|
1245
|
+
function probe(file, fs9, callback) {
|
|
1246
|
+
const cachedPrecision = fs9[cacheSymbol];
|
|
1247
1247
|
if (cachedPrecision) {
|
|
1248
|
-
return
|
|
1248
|
+
return fs9.stat(file, (err, stat) => {
|
|
1249
1249
|
if (err) {
|
|
1250
1250
|
return callback(err);
|
|
1251
1251
|
}
|
|
@@ -1253,16 +1253,16 @@ var require_mtime_precision = __commonJS({
|
|
|
1253
1253
|
});
|
|
1254
1254
|
}
|
|
1255
1255
|
const mtime = new Date(Math.ceil(Date.now() / 1e3) * 1e3 + 5);
|
|
1256
|
-
|
|
1256
|
+
fs9.utimes(file, mtime, mtime, (err) => {
|
|
1257
1257
|
if (err) {
|
|
1258
1258
|
return callback(err);
|
|
1259
1259
|
}
|
|
1260
|
-
|
|
1260
|
+
fs9.stat(file, (err2, stat) => {
|
|
1261
1261
|
if (err2) {
|
|
1262
1262
|
return callback(err2);
|
|
1263
1263
|
}
|
|
1264
1264
|
const precision = stat.mtime.getTime() % 1e3 === 0 ? "s" : "ms";
|
|
1265
|
-
Object.defineProperty(
|
|
1265
|
+
Object.defineProperty(fs9, cacheSymbol, { value: precision });
|
|
1266
1266
|
callback(null, stat.mtime, precision);
|
|
1267
1267
|
});
|
|
1268
1268
|
});
|
|
@@ -1283,8 +1283,8 @@ var require_mtime_precision = __commonJS({
|
|
|
1283
1283
|
var require_lockfile = __commonJS({
|
|
1284
1284
|
"../../node_modules/.pnpm/proper-lockfile@4.1.2/node_modules/proper-lockfile/lib/lockfile.js"(exports, module) {
|
|
1285
1285
|
"use strict";
|
|
1286
|
-
var
|
|
1287
|
-
var
|
|
1286
|
+
var path9 = __require("path");
|
|
1287
|
+
var fs9 = require_graceful_fs();
|
|
1288
1288
|
var retry = require_retry2();
|
|
1289
1289
|
var onExit = require_signal_exit();
|
|
1290
1290
|
var mtimePrecision = require_mtime_precision();
|
|
@@ -1294,7 +1294,7 @@ var require_lockfile = __commonJS({
|
|
|
1294
1294
|
}
|
|
1295
1295
|
function resolveCanonicalPath(file, options, callback) {
|
|
1296
1296
|
if (!options.realpath) {
|
|
1297
|
-
return callback(null,
|
|
1297
|
+
return callback(null, path9.resolve(file));
|
|
1298
1298
|
}
|
|
1299
1299
|
options.fs.realpath(file, callback);
|
|
1300
1300
|
}
|
|
@@ -1415,7 +1415,7 @@ var require_lockfile = __commonJS({
|
|
|
1415
1415
|
update: null,
|
|
1416
1416
|
realpath: true,
|
|
1417
1417
|
retries: 0,
|
|
1418
|
-
fs:
|
|
1418
|
+
fs: fs9,
|
|
1419
1419
|
onCompromised: (err) => {
|
|
1420
1420
|
throw err;
|
|
1421
1421
|
},
|
|
@@ -1459,7 +1459,7 @@ var require_lockfile = __commonJS({
|
|
|
1459
1459
|
}
|
|
1460
1460
|
function unlock(file, options, callback) {
|
|
1461
1461
|
options = {
|
|
1462
|
-
fs:
|
|
1462
|
+
fs: fs9,
|
|
1463
1463
|
realpath: true,
|
|
1464
1464
|
...options
|
|
1465
1465
|
};
|
|
@@ -1481,7 +1481,7 @@ var require_lockfile = __commonJS({
|
|
|
1481
1481
|
options = {
|
|
1482
1482
|
stale: 1e4,
|
|
1483
1483
|
realpath: true,
|
|
1484
|
-
fs:
|
|
1484
|
+
fs: fs9,
|
|
1485
1485
|
...options
|
|
1486
1486
|
};
|
|
1487
1487
|
options.stale = Math.max(options.stale || 0, 2e3);
|
|
@@ -1520,16 +1520,16 @@ var require_lockfile = __commonJS({
|
|
|
1520
1520
|
var require_adapter = __commonJS({
|
|
1521
1521
|
"../../node_modules/.pnpm/proper-lockfile@4.1.2/node_modules/proper-lockfile/lib/adapter.js"(exports, module) {
|
|
1522
1522
|
"use strict";
|
|
1523
|
-
var
|
|
1524
|
-
function createSyncFs(
|
|
1523
|
+
var fs9 = require_graceful_fs();
|
|
1524
|
+
function createSyncFs(fs10) {
|
|
1525
1525
|
const methods = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
|
|
1526
|
-
const newFs = { ...
|
|
1526
|
+
const newFs = { ...fs10 };
|
|
1527
1527
|
methods.forEach((method) => {
|
|
1528
1528
|
newFs[method] = (...args) => {
|
|
1529
1529
|
const callback = args.pop();
|
|
1530
1530
|
let ret;
|
|
1531
1531
|
try {
|
|
1532
|
-
ret =
|
|
1532
|
+
ret = fs10[`${method}Sync`](...args);
|
|
1533
1533
|
} catch (err) {
|
|
1534
1534
|
return callback(err);
|
|
1535
1535
|
}
|
|
@@ -1567,7 +1567,7 @@ var require_adapter = __commonJS({
|
|
|
1567
1567
|
}
|
|
1568
1568
|
function toSyncOptions(options) {
|
|
1569
1569
|
options = { ...options };
|
|
1570
|
-
options.fs = createSyncFs(options.fs ||
|
|
1570
|
+
options.fs = createSyncFs(options.fs || fs9);
|
|
1571
1571
|
if (typeof options.retries === "number" && options.retries > 0 || options.retries && typeof options.retries.retries === "number" && options.retries.retries > 0) {
|
|
1572
1572
|
throw Object.assign(new Error("Cannot use retries with the sync api"), { code: "ESYNC" });
|
|
1573
1573
|
}
|
|
@@ -3856,7 +3856,7 @@ var require_websocket = __commonJS({
|
|
|
3856
3856
|
var http = __require("http");
|
|
3857
3857
|
var net = __require("net");
|
|
3858
3858
|
var tls = __require("tls");
|
|
3859
|
-
var { randomBytes, createHash } = __require("crypto");
|
|
3859
|
+
var { randomBytes, createHash: createHash2 } = __require("crypto");
|
|
3860
3860
|
var { Duplex, Readable } = __require("stream");
|
|
3861
3861
|
var { URL: URL2 } = __require("url");
|
|
3862
3862
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
@@ -4524,8 +4524,8 @@ var require_websocket = __commonJS({
|
|
|
4524
4524
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
4525
4525
|
return;
|
|
4526
4526
|
}
|
|
4527
|
-
const
|
|
4528
|
-
if (res.headers["sec-websocket-accept"] !==
|
|
4527
|
+
const digest2 = createHash2("sha1").update(key + GUID).digest("base64");
|
|
4528
|
+
if (res.headers["sec-websocket-accept"] !== digest2) {
|
|
4529
4529
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
4530
4530
|
return;
|
|
4531
4531
|
}
|
|
@@ -4893,7 +4893,7 @@ var require_websocket_server = __commonJS({
|
|
|
4893
4893
|
var EventEmitter = __require("events");
|
|
4894
4894
|
var http = __require("http");
|
|
4895
4895
|
var { Duplex } = __require("stream");
|
|
4896
|
-
var { createHash } = __require("crypto");
|
|
4896
|
+
var { createHash: createHash2 } = __require("crypto");
|
|
4897
4897
|
var extension2 = require_extension();
|
|
4898
4898
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
4899
4899
|
var subprotocol2 = require_subprotocol();
|
|
@@ -5200,12 +5200,12 @@ var require_websocket_server = __commonJS({
|
|
|
5200
5200
|
);
|
|
5201
5201
|
}
|
|
5202
5202
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
5203
|
-
const
|
|
5203
|
+
const digest2 = createHash2("sha1").update(key + GUID).digest("base64");
|
|
5204
5204
|
const headers = [
|
|
5205
5205
|
"HTTP/1.1 101 Switching Protocols",
|
|
5206
5206
|
"Upgrade: websocket",
|
|
5207
5207
|
"Connection: Upgrade",
|
|
5208
|
-
`Sec-WebSocket-Accept: ${
|
|
5208
|
+
`Sec-WebSocket-Accept: ${digest2}`
|
|
5209
5209
|
];
|
|
5210
5210
|
const ws = new this.options.WebSocket(null, void 0, this.options);
|
|
5211
5211
|
if (protocols.size) {
|
|
@@ -5287,8 +5287,252 @@ var require_websocket_server = __commonJS({
|
|
|
5287
5287
|
}
|
|
5288
5288
|
});
|
|
5289
5289
|
|
|
5290
|
+
// src/go-launcher.ts
|
|
5291
|
+
import os from "os";
|
|
5292
|
+
import path from "path";
|
|
5293
|
+
import fs from "fs/promises";
|
|
5294
|
+
import { createHash, randomUUID } from "crypto";
|
|
5295
|
+
import { spawn, spawnSync } from "child_process";
|
|
5296
|
+
import { fileURLToPath } from "url";
|
|
5297
|
+
|
|
5298
|
+
// package.json
|
|
5299
|
+
var package_default = {
|
|
5300
|
+
name: "remotelink",
|
|
5301
|
+
version: "0.5.0",
|
|
5302
|
+
description: "Controlled remote computer access for AI across computers you own.",
|
|
5303
|
+
type: "module",
|
|
5304
|
+
bin: {
|
|
5305
|
+
remotelink: "dist/index.js",
|
|
5306
|
+
"remote-link": "dist/index.js",
|
|
5307
|
+
"remote-arc": "dist/index.js"
|
|
5308
|
+
},
|
|
5309
|
+
files: [
|
|
5310
|
+
"dist",
|
|
5311
|
+
"README.md",
|
|
5312
|
+
"LICENSE"
|
|
5313
|
+
],
|
|
5314
|
+
engines: {
|
|
5315
|
+
node: ">=20"
|
|
5316
|
+
},
|
|
5317
|
+
scripts: {
|
|
5318
|
+
build: "tsup",
|
|
5319
|
+
typecheck: "tsc --noEmit",
|
|
5320
|
+
prepublishOnly: "node ../../scripts/sync-release-docs.mjs --write && pnpm build && node ../../scripts/build-device.mjs --release"
|
|
5321
|
+
},
|
|
5322
|
+
dependencies: {
|
|
5323
|
+
"proper-lockfile": "^4.1.2",
|
|
5324
|
+
ws: "^8.18.3"
|
|
5325
|
+
},
|
|
5326
|
+
devDependencies: {
|
|
5327
|
+
"@remotearc/execution-core": "workspace:*",
|
|
5328
|
+
"@types/node": "^24.13.6",
|
|
5329
|
+
"@types/proper-lockfile": "^4.1.4",
|
|
5330
|
+
"@types/ws": "^8.18.1",
|
|
5331
|
+
tsup: "^8.5.0",
|
|
5332
|
+
typescript: "^6.0.3"
|
|
5333
|
+
},
|
|
5334
|
+
license: "UNLICENSED",
|
|
5335
|
+
homepage: "https://remotearc.app",
|
|
5336
|
+
repository: {
|
|
5337
|
+
type: "git",
|
|
5338
|
+
url: "git+https://github.com/yaohuangguan/remote-arc.git",
|
|
5339
|
+
directory: "packages/cli"
|
|
5340
|
+
},
|
|
5341
|
+
bugs: {
|
|
5342
|
+
url: "https://github.com/yaohuangguan/remote-arc/issues"
|
|
5343
|
+
},
|
|
5344
|
+
keywords: [
|
|
5345
|
+
"mcp",
|
|
5346
|
+
"chatgpt",
|
|
5347
|
+
"claude",
|
|
5348
|
+
"codex",
|
|
5349
|
+
"remote-computer",
|
|
5350
|
+
"developer-tools"
|
|
5351
|
+
]
|
|
5352
|
+
};
|
|
5353
|
+
|
|
5354
|
+
// src/go-launcher.ts
|
|
5355
|
+
var GO_VERSION = package_default.version;
|
|
5356
|
+
var platforms = {
|
|
5357
|
+
win32: "windows",
|
|
5358
|
+
darwin: "darwin",
|
|
5359
|
+
linux: "linux"
|
|
5360
|
+
};
|
|
5361
|
+
var architectures = { x64: "amd64", arm64: "arm64" };
|
|
5362
|
+
function goAsset(platform = process.platform, arch = process.arch) {
|
|
5363
|
+
const target = platforms[platform], cpu = architectures[arch];
|
|
5364
|
+
if (!target || !cpu)
|
|
5365
|
+
throw new Error(
|
|
5366
|
+
`Go agent binaries are unavailable for ${platform}/${arch}.`
|
|
5367
|
+
);
|
|
5368
|
+
return `remotelink-go-v${GO_VERSION}-${target}-${cpu}${platform === "win32" ? ".exe" : ""}`;
|
|
5369
|
+
}
|
|
5370
|
+
function digest(b) {
|
|
5371
|
+
return createHash("sha256").update(b).digest("hex");
|
|
5372
|
+
}
|
|
5373
|
+
async function exists(file) {
|
|
5374
|
+
try {
|
|
5375
|
+
return (await fs.stat(file)).isFile();
|
|
5376
|
+
} catch {
|
|
5377
|
+
return false;
|
|
5378
|
+
}
|
|
5379
|
+
}
|
|
5380
|
+
function verifyVersion(binary) {
|
|
5381
|
+
const child = spawnSync(binary, ["--version"], {
|
|
5382
|
+
windowsHide: true,
|
|
5383
|
+
encoding: "utf8",
|
|
5384
|
+
timeout: 1e4,
|
|
5385
|
+
maxBuffer: 4096
|
|
5386
|
+
});
|
|
5387
|
+
if (child.error || child.status !== 0 || child.stdout.trim() !== GO_VERSION)
|
|
5388
|
+
throw new Error(
|
|
5389
|
+
`The Go agent must match remotelink ${GO_VERSION}. Build the matching binary or reinstall this release.`
|
|
5390
|
+
);
|
|
5391
|
+
}
|
|
5392
|
+
async function resolveGoBinary() {
|
|
5393
|
+
const explicit = process.env.REMOTEARC_GO_BINARY;
|
|
5394
|
+
if (explicit) {
|
|
5395
|
+
if (!path.isAbsolute(explicit) || !await exists(explicit))
|
|
5396
|
+
throw new Error(
|
|
5397
|
+
"REMOTEARC_GO_BINARY must be an absolute path to a Go agent binary."
|
|
5398
|
+
);
|
|
5399
|
+
verifyVersion(explicit);
|
|
5400
|
+
return explicit;
|
|
5401
|
+
}
|
|
5402
|
+
const asset = goAsset();
|
|
5403
|
+
const manifestPath = fileURLToPath(
|
|
5404
|
+
new URL("./go-binaries.json", import.meta.url)
|
|
5405
|
+
);
|
|
5406
|
+
let manifest;
|
|
5407
|
+
try {
|
|
5408
|
+
manifest = JSON.parse(await fs.readFile(manifestPath, "utf8"));
|
|
5409
|
+
} catch {
|
|
5410
|
+
throw new Error(
|
|
5411
|
+
"This npm release has no Go binary manifest. Use REMOTEARC_GO_BINARY with a matching local build, or install a native Go release."
|
|
5412
|
+
);
|
|
5413
|
+
}
|
|
5414
|
+
const checksum = manifest.version === GO_VERSION ? manifest.checksums[asset] : void 0;
|
|
5415
|
+
if (!checksum || !/^[a-f0-9]{64}$/.test(checksum))
|
|
5416
|
+
throw new Error(
|
|
5417
|
+
"No verified Go binary is listed for this platform in the installed release."
|
|
5418
|
+
);
|
|
5419
|
+
const home = process.env.REMOTEARC_HOME || os.homedir();
|
|
5420
|
+
const dir = path.join(home, ".remotearc", "agent", "downloads", GO_VERSION);
|
|
5421
|
+
const binary = path.join(dir, asset);
|
|
5422
|
+
const bundled = fileURLToPath(new URL(`./bin/${asset}`, import.meta.url));
|
|
5423
|
+
for (const candidate of [bundled, binary]) {
|
|
5424
|
+
if (await exists(candidate) && digest(await fs.readFile(candidate)) === checksum) {
|
|
5425
|
+
verifyVersion(candidate);
|
|
5426
|
+
return candidate;
|
|
5427
|
+
}
|
|
5428
|
+
}
|
|
5429
|
+
const releaseURL = `https://github.com/yaohuangguan/remote-arc/releases/download/go-agent-v${GO_VERSION}/${asset}`;
|
|
5430
|
+
const response = await fetch(releaseURL, {
|
|
5431
|
+
signal: AbortSignal.timeout(12e4)
|
|
5432
|
+
});
|
|
5433
|
+
if (!response.ok || !response.body)
|
|
5434
|
+
throw new Error(
|
|
5435
|
+
`Cannot download the Go agent (HTTP ${response.status}). The TS agent remains available with --ts.`
|
|
5436
|
+
);
|
|
5437
|
+
const reader = response.body.getReader();
|
|
5438
|
+
const chunks = [];
|
|
5439
|
+
let size = 0;
|
|
5440
|
+
for (; ; ) {
|
|
5441
|
+
const { value, done } = await reader.read();
|
|
5442
|
+
if (done) break;
|
|
5443
|
+
size += value.length;
|
|
5444
|
+
if (size > 100 * 1024 * 1024) {
|
|
5445
|
+
await reader.cancel();
|
|
5446
|
+
throw new Error("Go binary exceeds the download size limit.");
|
|
5447
|
+
}
|
|
5448
|
+
chunks.push(Buffer.from(value));
|
|
5449
|
+
}
|
|
5450
|
+
const bytes = Buffer.concat(chunks);
|
|
5451
|
+
if (digest(bytes) !== checksum)
|
|
5452
|
+
throw new Error(
|
|
5453
|
+
"Go binary checksum does not match the installed npm release."
|
|
5454
|
+
);
|
|
5455
|
+
await fs.mkdir(dir, { recursive: true, mode: 448 });
|
|
5456
|
+
const temporary = binary + "." + randomUUID() + ".tmp";
|
|
5457
|
+
try {
|
|
5458
|
+
await fs.writeFile(temporary, bytes, { mode: 448, flag: "wx" });
|
|
5459
|
+
verifyVersion(temporary);
|
|
5460
|
+
try {
|
|
5461
|
+
await fs.rename(temporary, binary);
|
|
5462
|
+
} catch (error) {
|
|
5463
|
+
if (!await exists(binary) || digest(await fs.readFile(binary)) !== checksum)
|
|
5464
|
+
throw error;
|
|
5465
|
+
}
|
|
5466
|
+
} finally {
|
|
5467
|
+
await fs.rm(temporary, { force: true });
|
|
5468
|
+
}
|
|
5469
|
+
verifyVersion(binary);
|
|
5470
|
+
return binary;
|
|
5471
|
+
}
|
|
5472
|
+
async function launchGo(args) {
|
|
5473
|
+
const binary = await resolveGoBinary();
|
|
5474
|
+
const child = spawn(binary, args, { stdio: "inherit", windowsHide: true });
|
|
5475
|
+
const stop = (signal) => {
|
|
5476
|
+
if (process.platform === "win32") {
|
|
5477
|
+
void localGoControl("POST", "/stop", child.pid).catch(() => void 0);
|
|
5478
|
+
} else child.kill(signal);
|
|
5479
|
+
};
|
|
5480
|
+
const interrupt = () => stop("SIGINT"), terminate = () => stop("SIGTERM");
|
|
5481
|
+
process.on("SIGINT", interrupt);
|
|
5482
|
+
process.on("SIGTERM", terminate);
|
|
5483
|
+
try {
|
|
5484
|
+
const code = await new Promise((resolve, reject) => {
|
|
5485
|
+
child.once("error", reject);
|
|
5486
|
+
child.once("exit", (code2, signal) => resolve(code2 ?? (signal ? 1 : 0)));
|
|
5487
|
+
});
|
|
5488
|
+
process.exitCode = code;
|
|
5489
|
+
} finally {
|
|
5490
|
+
process.off("SIGINT", interrupt);
|
|
5491
|
+
process.off("SIGTERM", terminate);
|
|
5492
|
+
}
|
|
5493
|
+
}
|
|
5494
|
+
async function localGoControl(method, endpoint, expectedPid) {
|
|
5495
|
+
const home = process.env.REMOTEARC_HOME || os.homedir();
|
|
5496
|
+
const config = JSON.parse(
|
|
5497
|
+
await fs.readFile(
|
|
5498
|
+
path.join(home, ".remotearc", "agent", "control.json"),
|
|
5499
|
+
"utf8"
|
|
5500
|
+
)
|
|
5501
|
+
);
|
|
5502
|
+
const url = new URL(config.url);
|
|
5503
|
+
if (config.engine !== "go" || url.protocol !== "http:" || url.hostname !== "127.0.0.1" || !url.port || url.username || url.password || url.pathname !== "/" || url.search || url.hash || !/^[a-f0-9]{64}$/.test(config.token) || expectedPid !== void 0 && config.pid !== expectedPid)
|
|
5504
|
+
throw new Error("Invalid local Go control endpoint.");
|
|
5505
|
+
const response = await fetch(new URL(endpoint, url), {
|
|
5506
|
+
method,
|
|
5507
|
+
headers: { Authorization: "Bearer " + config.token },
|
|
5508
|
+
signal: AbortSignal.timeout(3e3),
|
|
5509
|
+
redirect: "error"
|
|
5510
|
+
});
|
|
5511
|
+
if (!response.ok) throw new Error("Local Go agent control request failed.");
|
|
5512
|
+
return response.json();
|
|
5513
|
+
}
|
|
5514
|
+
async function assertTSOwnership(args) {
|
|
5515
|
+
if (args.some((arg) => ["--help", "-h", "--version", "-v"].includes(arg)))
|
|
5516
|
+
return;
|
|
5517
|
+
const home = process.env.REMOTEARC_HOME || os.homedir();
|
|
5518
|
+
try {
|
|
5519
|
+
const lock2 = await fs.stat(
|
|
5520
|
+
path.join(home, ".remotearc", "agent", "execution.lock")
|
|
5521
|
+
);
|
|
5522
|
+
if (Date.now() - lock2.mtimeMs > 15e3) return;
|
|
5523
|
+
const status = await localGoControl("GET", "/status").catch(() => null);
|
|
5524
|
+
if (status?.engine === "go")
|
|
5525
|
+
throw new Error(
|
|
5526
|
+
"A Go agent owns execution. Use --go --stop before launching --ts; pairing and active operations have been preserved."
|
|
5527
|
+
);
|
|
5528
|
+
} catch (error) {
|
|
5529
|
+
if (error.code === "ENOENT") return;
|
|
5530
|
+
throw error;
|
|
5531
|
+
}
|
|
5532
|
+
}
|
|
5533
|
+
|
|
5290
5534
|
// src/keep-awake.ts
|
|
5291
|
-
import { spawn } from "child_process";
|
|
5535
|
+
import { spawn as spawn2 } from "child_process";
|
|
5292
5536
|
var HELPER_SECONDS = 210;
|
|
5293
5537
|
var windowsScript = `
|
|
5294
5538
|
Add-Type -TypeDefinition 'using System; using System.Runtime.InteropServices; public static class RemoteArcPower { [DllImport("kernel32.dll")] public static extern uint SetThreadExecutionState(uint flags); }'
|
|
@@ -5298,7 +5542,7 @@ try { Start-Sleep -Seconds ${HELPER_SECONDS} } finally { [RemoteArcPower]::SetTh
|
|
|
5298
5542
|
function createTaskKeepAwakeManager(options = {}) {
|
|
5299
5543
|
const platform = options.platform || process.platform;
|
|
5300
5544
|
const clock = options.now || Date.now;
|
|
5301
|
-
const launch = options.spawn ||
|
|
5545
|
+
const launch = options.spawn || spawn2;
|
|
5302
5546
|
const leases = /* @__PURE__ */ new Map();
|
|
5303
5547
|
let helper = null;
|
|
5304
5548
|
let helperUntil = 0;
|
|
@@ -5365,15 +5609,15 @@ function createTaskKeepAwakeManager(options = {}) {
|
|
|
5365
5609
|
}
|
|
5366
5610
|
|
|
5367
5611
|
// src/goal-workspace.ts
|
|
5368
|
-
import
|
|
5369
|
-
import
|
|
5612
|
+
import fs5 from "fs/promises";
|
|
5613
|
+
import path5 from "path";
|
|
5370
5614
|
import { execFile as execFile2 } from "child_process";
|
|
5371
5615
|
import { promisify } from "util";
|
|
5372
5616
|
|
|
5373
5617
|
// ../execution-core/src/filesystem.ts
|
|
5374
5618
|
import crypto from "crypto";
|
|
5375
|
-
import
|
|
5376
|
-
import
|
|
5619
|
+
import fs2 from "fs/promises";
|
|
5620
|
+
import path2 from "path";
|
|
5377
5621
|
var MAX_DIRECTORY_ENTRIES = 2e3;
|
|
5378
5622
|
var DEFAULT_READ_LINES = 240;
|
|
5379
5623
|
var MAX_TEXT_FILE_BYTES = 20 * 1024 * 1024;
|
|
@@ -5389,14 +5633,14 @@ async function listDirectory(targetPath, depth = 2, canReveal) {
|
|
|
5389
5633
|
let protectedEntries = 0;
|
|
5390
5634
|
async function walk(directory, level, prefix) {
|
|
5391
5635
|
if (entriesSeen >= MAX_DIRECTORY_ENTRIES) return;
|
|
5392
|
-
const entries = await
|
|
5636
|
+
const entries = await fs2.readdir(directory, { withFileTypes: true });
|
|
5393
5637
|
entries.sort((a, b) => {
|
|
5394
5638
|
if (a.isDirectory() !== b.isDirectory()) return a.isDirectory() ? -1 : 1;
|
|
5395
5639
|
return a.name.localeCompare(b.name);
|
|
5396
5640
|
});
|
|
5397
5641
|
for (const entry of entries) {
|
|
5398
5642
|
if (entriesSeen >= MAX_DIRECTORY_ENTRIES) break;
|
|
5399
|
-
const absolute =
|
|
5643
|
+
const absolute = path2.join(directory, entry.name);
|
|
5400
5644
|
if (canReveal && !await canReveal(absolute)) {
|
|
5401
5645
|
protectedEntries += 1;
|
|
5402
5646
|
continue;
|
|
@@ -5409,7 +5653,7 @@ async function listDirectory(targetPath, depth = 2, canReveal) {
|
|
|
5409
5653
|
}
|
|
5410
5654
|
}
|
|
5411
5655
|
}
|
|
5412
|
-
const stat = await
|
|
5656
|
+
const stat = await fs2.stat(targetPath);
|
|
5413
5657
|
if (!stat.isDirectory()) throw new Error("Path is not a directory: " + targetPath);
|
|
5414
5658
|
await walk(targetPath, 1, "");
|
|
5415
5659
|
if (entriesSeen >= MAX_DIRECTORY_ENTRIES) {
|
|
@@ -5424,14 +5668,14 @@ Depth: ${maxDepth}
|
|
|
5424
5668
|
${lines.join("\n") || "(empty)"}${protectionNote}`;
|
|
5425
5669
|
}
|
|
5426
5670
|
async function readTextFile(targetPath, offset, length) {
|
|
5427
|
-
const stat = await
|
|
5671
|
+
const stat = await fs2.stat(targetPath);
|
|
5428
5672
|
if (!stat.isFile()) throw new Error("Path is not a file: " + targetPath);
|
|
5429
5673
|
if (stat.size > MAX_TEXT_FILE_BYTES) {
|
|
5430
5674
|
throw new Error(
|
|
5431
5675
|
`File is too large for read_file (${printableSize(stat.size)} > 20 MB). Use a terminal command or a more targeted tool instead.`
|
|
5432
5676
|
);
|
|
5433
5677
|
}
|
|
5434
|
-
const buffer = await
|
|
5678
|
+
const buffer = await fs2.readFile(targetPath);
|
|
5435
5679
|
const sample = buffer.subarray(0, Math.min(buffer.length, 8192));
|
|
5436
5680
|
if (sample.includes(0)) {
|
|
5437
5681
|
throw new Error("Binary file detected. read_file currently supports text files only.");
|
|
@@ -5461,7 +5705,7 @@ function assertBinaryRevision(expected, actual) {
|
|
|
5461
5705
|
}
|
|
5462
5706
|
}
|
|
5463
5707
|
function binaryMimeType(targetPath, header) {
|
|
5464
|
-
const extension2 =
|
|
5708
|
+
const extension2 = path2.extname(targetPath).toLowerCase();
|
|
5465
5709
|
const office = {
|
|
5466
5710
|
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
5467
5711
|
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
@@ -5502,7 +5746,7 @@ function binaryMimeType(targetPath, header) {
|
|
|
5502
5746
|
return known[extension2] || "application/octet-stream";
|
|
5503
5747
|
}
|
|
5504
5748
|
async function readBinaryFile(targetPath, offset = 0, length = BINARY_DEFAULT_BYTES, expectedRevision) {
|
|
5505
|
-
const stat = await
|
|
5749
|
+
const stat = await fs2.stat(targetPath);
|
|
5506
5750
|
if (!stat.isFile()) throw new Error("Path is not a file: " + targetPath);
|
|
5507
5751
|
const fileRevision = binaryFileRevision(stat);
|
|
5508
5752
|
assertBinaryRevision(expectedRevision, fileRevision);
|
|
@@ -5527,7 +5771,7 @@ async function readBinaryFile(targetPath, offset = 0, length = BINARY_DEFAULT_BY
|
|
|
5527
5771
|
};
|
|
5528
5772
|
}
|
|
5529
5773
|
const toRead = Math.min(requested, stat.size - byteOffset);
|
|
5530
|
-
const handle = await
|
|
5774
|
+
const handle = await fs2.open(targetPath, "r");
|
|
5531
5775
|
try {
|
|
5532
5776
|
const headerBuffer = Buffer.allocUnsafe(Math.min(16, stat.size));
|
|
5533
5777
|
const headerResult = await handle.read(
|
|
@@ -5540,7 +5784,7 @@ async function readBinaryFile(targetPath, offset = 0, length = BINARY_DEFAULT_BY
|
|
|
5540
5784
|
const buffer = Buffer.allocUnsafe(toRead);
|
|
5541
5785
|
const result = await handle.read(buffer, 0, toRead, byteOffset);
|
|
5542
5786
|
const chunk = buffer.subarray(0, result.bytesRead);
|
|
5543
|
-
const afterStat = await
|
|
5787
|
+
const afterStat = await fs2.stat(targetPath);
|
|
5544
5788
|
const afterRevision = binaryFileRevision(afterStat);
|
|
5545
5789
|
if (afterRevision !== fileRevision) {
|
|
5546
5790
|
throw new Error(
|
|
@@ -5564,7 +5808,7 @@ async function readBinaryFile(targetPath, offset = 0, length = BINARY_DEFAULT_BY
|
|
|
5564
5808
|
}
|
|
5565
5809
|
}
|
|
5566
5810
|
async function getFileInfo(targetPath) {
|
|
5567
|
-
const stat = await
|
|
5811
|
+
const stat = await fs2.lstat(targetPath);
|
|
5568
5812
|
return {
|
|
5569
5813
|
path: targetPath,
|
|
5570
5814
|
type: stat.isFile() ? "file" : stat.isDirectory() ? "directory" : stat.isSymbolicLink() ? "symlink" : "other",
|
|
@@ -5577,27 +5821,27 @@ async function getFileInfo(targetPath) {
|
|
|
5577
5821
|
};
|
|
5578
5822
|
}
|
|
5579
5823
|
async function atomicWriteText(targetPath, content) {
|
|
5580
|
-
const directory =
|
|
5581
|
-
await
|
|
5582
|
-
const temporary =
|
|
5824
|
+
const directory = path2.dirname(targetPath);
|
|
5825
|
+
await fs2.mkdir(directory, { recursive: true });
|
|
5826
|
+
const temporary = path2.join(
|
|
5583
5827
|
directory,
|
|
5584
|
-
"." +
|
|
5828
|
+
"." + path2.basename(targetPath) + ".remotearc-" + crypto.randomUUID() + ".tmp"
|
|
5585
5829
|
);
|
|
5586
5830
|
try {
|
|
5587
|
-
await
|
|
5588
|
-
await
|
|
5831
|
+
await fs2.writeFile(temporary, content, "utf8");
|
|
5832
|
+
await fs2.rename(temporary, targetPath);
|
|
5589
5833
|
} finally {
|
|
5590
|
-
await
|
|
5834
|
+
await fs2.rm(temporary, { force: true }).catch(() => void 0);
|
|
5591
5835
|
}
|
|
5592
5836
|
}
|
|
5593
5837
|
async function writeTextFile(targetPath, content, mode = "rewrite") {
|
|
5594
|
-
await
|
|
5838
|
+
await fs2.mkdir(path2.dirname(targetPath), { recursive: true });
|
|
5595
5839
|
if (mode === "append") {
|
|
5596
|
-
await
|
|
5840
|
+
await fs2.appendFile(targetPath, content, "utf8");
|
|
5597
5841
|
} else {
|
|
5598
5842
|
await atomicWriteText(targetPath, content);
|
|
5599
5843
|
}
|
|
5600
|
-
const stat = await
|
|
5844
|
+
const stat = await fs2.stat(targetPath);
|
|
5601
5845
|
return {
|
|
5602
5846
|
path: targetPath,
|
|
5603
5847
|
mode,
|
|
@@ -5608,7 +5852,7 @@ async function writeTextFile(targetPath, content, mode = "rewrite") {
|
|
|
5608
5852
|
}
|
|
5609
5853
|
async function editTextBlock(filePath, oldString, newString, expectedReplacements = 1) {
|
|
5610
5854
|
if (!oldString) throw new Error("old_string cannot be empty.");
|
|
5611
|
-
const current = await
|
|
5855
|
+
const current = await fs2.readFile(filePath, "utf8");
|
|
5612
5856
|
const parts = current.split(oldString);
|
|
5613
5857
|
const replacements = parts.length - 1;
|
|
5614
5858
|
if (replacements !== expectedReplacements) {
|
|
@@ -5627,14 +5871,14 @@ async function editTextBlock(filePath, oldString, newString, expectedReplacement
|
|
|
5627
5871
|
};
|
|
5628
5872
|
}
|
|
5629
5873
|
async function browseDirectories(targetPath, canReveal) {
|
|
5630
|
-
const stat = await
|
|
5874
|
+
const stat = await fs2.stat(targetPath);
|
|
5631
5875
|
if (!stat.isDirectory()) throw new Error("Path is not a directory: " + targetPath);
|
|
5632
|
-
const entries = await
|
|
5876
|
+
const entries = await fs2.readdir(targetPath, { withFileTypes: true });
|
|
5633
5877
|
const directories = [];
|
|
5634
5878
|
let protectedEntries = 0;
|
|
5635
5879
|
for (const entry of entries) {
|
|
5636
5880
|
if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;
|
|
5637
|
-
const absolute =
|
|
5881
|
+
const absolute = path2.join(targetPath, entry.name);
|
|
5638
5882
|
if (canReveal && !await canReveal(absolute)) {
|
|
5639
5883
|
protectedEntries += 1;
|
|
5640
5884
|
continue;
|
|
@@ -5649,7 +5893,7 @@ async function browseDirectories(targetPath, canReveal) {
|
|
|
5649
5893
|
directories.sort((a, b) => a.name.localeCompare(b.name));
|
|
5650
5894
|
return {
|
|
5651
5895
|
path: targetPath,
|
|
5652
|
-
parent:
|
|
5896
|
+
parent: path2.dirname(targetPath) === targetPath ? null : path2.dirname(targetPath),
|
|
5653
5897
|
directories,
|
|
5654
5898
|
protected_entries_omitted: protectedEntries,
|
|
5655
5899
|
truncated: directories.length >= 300
|
|
@@ -5657,7 +5901,7 @@ async function browseDirectories(targetPath, canReveal) {
|
|
|
5657
5901
|
}
|
|
5658
5902
|
|
|
5659
5903
|
// ../execution-core/src/process.ts
|
|
5660
|
-
import { execFile, spawn as
|
|
5904
|
+
import { execFile, spawn as spawn3 } from "child_process";
|
|
5661
5905
|
import crypto2 from "crypto";
|
|
5662
5906
|
import process2 from "process";
|
|
5663
5907
|
var MAX_CAPTURE_BYTES = 2 * 1024 * 1024;
|
|
@@ -5687,7 +5931,7 @@ async function terminateTree(child) {
|
|
|
5687
5931
|
if (!child.pid) return;
|
|
5688
5932
|
if (process2.platform === "win32") {
|
|
5689
5933
|
await new Promise((resolve) => {
|
|
5690
|
-
const killer =
|
|
5934
|
+
const killer = spawn3(
|
|
5691
5935
|
"taskkill.exe",
|
|
5692
5936
|
["/PID", String(child.pid), "/T", "/F"],
|
|
5693
5937
|
{ windowsHide: true, stdio: "ignore" }
|
|
@@ -5713,7 +5957,7 @@ async function runShellCommand(command, timeoutMs = 5e3, cwd) {
|
|
|
5713
5957
|
const timeout = Math.max(100, Math.min(12e4, Math.trunc(timeoutMs || 5e3)));
|
|
5714
5958
|
const startedAt = Date.now();
|
|
5715
5959
|
return await new Promise((resolve, reject) => {
|
|
5716
|
-
const child =
|
|
5960
|
+
const child = spawn3(command, {
|
|
5717
5961
|
shell: true,
|
|
5718
5962
|
cwd,
|
|
5719
5963
|
windowsHide: true,
|
|
@@ -5782,7 +6026,7 @@ async function startBackgroundProcess(command, cwd, maxDurationSeconds) {
|
|
|
5782
6026
|
"Remote Arc already has the maximum number of managed background processes on this device."
|
|
5783
6027
|
);
|
|
5784
6028
|
}
|
|
5785
|
-
const child =
|
|
6029
|
+
const child = spawn3(command, {
|
|
5786
6030
|
shell: true,
|
|
5787
6031
|
cwd,
|
|
5788
6032
|
windowsHide: true,
|
|
@@ -5916,20 +6160,20 @@ function listManagedProcesses() {
|
|
|
5916
6160
|
// ../execution-core/src/safety.ts
|
|
5917
6161
|
import crypto3 from "crypto";
|
|
5918
6162
|
import { createReadStream } from "fs";
|
|
5919
|
-
import
|
|
5920
|
-
import
|
|
5921
|
-
import
|
|
6163
|
+
import fs3 from "fs/promises";
|
|
6164
|
+
import os2 from "os";
|
|
6165
|
+
import path3 from "path";
|
|
5922
6166
|
var RETENTION_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
5923
6167
|
var MAX_SNAPSHOT_BYTES = 20 * 1024 * 1024;
|
|
5924
6168
|
var MAX_UNDO_BYTES = 200 * 1024 * 1024;
|
|
5925
|
-
var undoRoot = () => process.env.REMOTEARC_UNDO_ROOT ||
|
|
6169
|
+
var undoRoot = () => process.env.REMOTEARC_UNDO_ROOT || path3.join(os2.homedir(), ".remotearc", "undo");
|
|
5926
6170
|
async function ensureUndoRoot() {
|
|
5927
|
-
await
|
|
6171
|
+
await fs3.mkdir(undoRoot(), { recursive: true, mode: 448 });
|
|
5928
6172
|
}
|
|
5929
6173
|
async function readManifest(directory) {
|
|
5930
6174
|
try {
|
|
5931
6175
|
return JSON.parse(
|
|
5932
|
-
await
|
|
6176
|
+
await fs3.readFile(path3.join(directory, "manifest.json"), "utf8")
|
|
5933
6177
|
);
|
|
5934
6178
|
} catch {
|
|
5935
6179
|
return null;
|
|
@@ -5937,8 +6181,8 @@ async function readManifest(directory) {
|
|
|
5937
6181
|
}
|
|
5938
6182
|
async function snapshotDirectories() {
|
|
5939
6183
|
await ensureUndoRoot();
|
|
5940
|
-
const entries = await
|
|
5941
|
-
return entries.filter((entry) => entry.isDirectory()).map((entry) =>
|
|
6184
|
+
const entries = await fs3.readdir(undoRoot(), { withFileTypes: true });
|
|
6185
|
+
return entries.filter((entry) => entry.isDirectory()).map((entry) => path3.join(undoRoot(), entry.name));
|
|
5942
6186
|
}
|
|
5943
6187
|
async function cleanupUndoStore() {
|
|
5944
6188
|
const now = Date.now();
|
|
@@ -5946,12 +6190,12 @@ async function cleanupUndoStore() {
|
|
|
5946
6190
|
for (const directory of await snapshotDirectories()) {
|
|
5947
6191
|
const manifest = await readManifest(directory);
|
|
5948
6192
|
if (!manifest) {
|
|
5949
|
-
await
|
|
6193
|
+
await fs3.rm(directory, { recursive: true, force: true }).catch(() => void 0);
|
|
5950
6194
|
continue;
|
|
5951
6195
|
}
|
|
5952
6196
|
const created = Date.parse(manifest.createdAt);
|
|
5953
6197
|
if (!Number.isFinite(created) || now - created > RETENTION_MS) {
|
|
5954
|
-
await
|
|
6198
|
+
await fs3.rm(directory, { recursive: true, force: true }).catch(() => void 0);
|
|
5955
6199
|
continue;
|
|
5956
6200
|
}
|
|
5957
6201
|
snapshots.push({ directory, manifest });
|
|
@@ -5962,7 +6206,7 @@ async function cleanupUndoStore() {
|
|
|
5962
6206
|
let total = snapshots.reduce((sum, item) => sum + item.manifest.bytes, 0);
|
|
5963
6207
|
for (const item of snapshots) {
|
|
5964
6208
|
if (total <= MAX_UNDO_BYTES) break;
|
|
5965
|
-
await
|
|
6209
|
+
await fs3.rm(item.directory, { recursive: true, force: true }).catch(() => void 0);
|
|
5966
6210
|
total -= item.manifest.bytes;
|
|
5967
6211
|
}
|
|
5968
6212
|
}
|
|
@@ -5979,22 +6223,22 @@ async function createUndoSnapshot(tool, args) {
|
|
|
5979
6223
|
let bytes = 0;
|
|
5980
6224
|
let original = null;
|
|
5981
6225
|
try {
|
|
5982
|
-
const stat = await
|
|
6226
|
+
const stat = await fs3.stat(targetPath);
|
|
5983
6227
|
if (!stat.isFile()) return null;
|
|
5984
6228
|
existed = true;
|
|
5985
6229
|
mode = stat.mode;
|
|
5986
6230
|
bytes = stat.size;
|
|
5987
6231
|
if (bytes > MAX_SNAPSHOT_BYTES) return null;
|
|
5988
|
-
original = await
|
|
6232
|
+
original = await fs3.readFile(targetPath);
|
|
5989
6233
|
} catch (error) {
|
|
5990
6234
|
const code = error && typeof error === "object" && "code" in error ? String(error.code) : "";
|
|
5991
6235
|
if (code !== "ENOENT") throw error;
|
|
5992
6236
|
}
|
|
5993
6237
|
const id = `${Date.now()}-${crypto3.randomUUID().slice(0, 8)}`;
|
|
5994
|
-
const directory =
|
|
5995
|
-
await
|
|
6238
|
+
const directory = path3.join(undoRoot(), id);
|
|
6239
|
+
await fs3.mkdir(directory, { recursive: true, mode: 448 });
|
|
5996
6240
|
if (original) {
|
|
5997
|
-
await
|
|
6241
|
+
await fs3.writeFile(path3.join(directory, "content.bin"), original, { mode: 384 });
|
|
5998
6242
|
}
|
|
5999
6243
|
const manifest = {
|
|
6000
6244
|
id,
|
|
@@ -6005,8 +6249,8 @@ async function createUndoSnapshot(tool, args) {
|
|
|
6005
6249
|
...mode !== void 0 ? { mode } : {},
|
|
6006
6250
|
bytes
|
|
6007
6251
|
};
|
|
6008
|
-
await
|
|
6009
|
-
|
|
6252
|
+
await fs3.writeFile(
|
|
6253
|
+
path3.join(directory, "manifest.json"),
|
|
6010
6254
|
JSON.stringify(manifest, null, 2) + "\n",
|
|
6011
6255
|
{ mode: 384 }
|
|
6012
6256
|
);
|
|
@@ -6022,8 +6266,8 @@ async function finalizeUndoSnapshot(snapshot) {
|
|
|
6022
6266
|
if (!snapshot) return false;
|
|
6023
6267
|
try {
|
|
6024
6268
|
snapshot.manifest.postChangeHash = await hashFile(snapshot.manifest.targetPath);
|
|
6025
|
-
await
|
|
6026
|
-
|
|
6269
|
+
await fs3.writeFile(
|
|
6270
|
+
path3.join(snapshot.directory, "manifest.json"),
|
|
6027
6271
|
JSON.stringify(snapshot.manifest, null, 2) + "\n",
|
|
6028
6272
|
{ mode: 384 }
|
|
6029
6273
|
);
|
|
@@ -6035,7 +6279,7 @@ async function finalizeUndoSnapshot(snapshot) {
|
|
|
6035
6279
|
}
|
|
6036
6280
|
async function discardUndoSnapshot(snapshot) {
|
|
6037
6281
|
if (!snapshot) return;
|
|
6038
|
-
await
|
|
6282
|
+
await fs3.rm(snapshot.directory, { recursive: true, force: true }).catch(() => void 0);
|
|
6039
6283
|
}
|
|
6040
6284
|
async function undoCandidates() {
|
|
6041
6285
|
await cleanupUndoStore();
|
|
@@ -6100,16 +6344,16 @@ async function restoreUndoCandidate(candidate) {
|
|
|
6100
6344
|
);
|
|
6101
6345
|
}
|
|
6102
6346
|
if (manifest.existed) {
|
|
6103
|
-
const original = await
|
|
6104
|
-
await
|
|
6105
|
-
await
|
|
6347
|
+
const original = await fs3.readFile(path3.join(directory, "content.bin"));
|
|
6348
|
+
await fs3.mkdir(path3.dirname(manifest.targetPath), { recursive: true });
|
|
6349
|
+
await fs3.writeFile(manifest.targetPath, original);
|
|
6106
6350
|
if (manifest.mode !== void 0) {
|
|
6107
|
-
await
|
|
6351
|
+
await fs3.chmod(manifest.targetPath, manifest.mode).catch(() => void 0);
|
|
6108
6352
|
}
|
|
6109
6353
|
} else {
|
|
6110
|
-
await
|
|
6354
|
+
await fs3.rm(manifest.targetPath, { force: true });
|
|
6111
6355
|
}
|
|
6112
|
-
await
|
|
6356
|
+
await fs3.rm(directory, { recursive: true, force: true });
|
|
6113
6357
|
return {
|
|
6114
6358
|
restored: true,
|
|
6115
6359
|
action_id: manifest.id,
|
|
@@ -6175,9 +6419,9 @@ function assertCommandAllowed(command) {
|
|
|
6175
6419
|
}
|
|
6176
6420
|
|
|
6177
6421
|
// ../execution-core/src/policy.ts
|
|
6178
|
-
import
|
|
6179
|
-
import
|
|
6180
|
-
import
|
|
6422
|
+
import fs4 from "fs/promises";
|
|
6423
|
+
import os3 from "os";
|
|
6424
|
+
import path4 from "path";
|
|
6181
6425
|
var SENSITIVE_BASENAMES = /* @__PURE__ */ new Set([
|
|
6182
6426
|
".npmrc",
|
|
6183
6427
|
".pypirc",
|
|
@@ -6189,75 +6433,75 @@ var SENSITIVE_BASENAMES = /* @__PURE__ */ new Set([
|
|
|
6189
6433
|
]);
|
|
6190
6434
|
var expandPath = (value) => {
|
|
6191
6435
|
const trimmed = value.trim();
|
|
6192
|
-
if (trimmed === "~") return
|
|
6436
|
+
if (trimmed === "~") return os3.homedir();
|
|
6193
6437
|
if (trimmed.startsWith("~/") || trimmed.startsWith("~\\")) {
|
|
6194
|
-
return
|
|
6438
|
+
return path4.join(os3.homedir(), trimmed.slice(2));
|
|
6195
6439
|
}
|
|
6196
|
-
return trimmed.replace(/%USERPROFILE%/gi,
|
|
6440
|
+
return trimmed.replace(/%USERPROFILE%/gi, os3.homedir()).replace(/\$HOME\b/g, os3.homedir());
|
|
6197
6441
|
};
|
|
6198
6442
|
var comparePath = (value) => {
|
|
6199
|
-
const resolved =
|
|
6443
|
+
const resolved = path4.resolve(expandPath(value));
|
|
6200
6444
|
return process.platform === "win32" ? resolved.toLowerCase() : resolved;
|
|
6201
6445
|
};
|
|
6202
6446
|
async function canonicalTarget(targetPath) {
|
|
6203
|
-
const expanded =
|
|
6447
|
+
const expanded = path4.resolve(expandPath(targetPath));
|
|
6204
6448
|
try {
|
|
6205
|
-
return comparePath(await
|
|
6449
|
+
return comparePath(await fs4.realpath(expanded));
|
|
6206
6450
|
} catch {
|
|
6207
6451
|
const missing = [];
|
|
6208
6452
|
let cursor = expanded;
|
|
6209
6453
|
while (true) {
|
|
6210
6454
|
try {
|
|
6211
|
-
const realParent = await
|
|
6212
|
-
return comparePath(
|
|
6455
|
+
const realParent = await fs4.realpath(cursor);
|
|
6456
|
+
return comparePath(path4.join(realParent, ...missing.reverse()));
|
|
6213
6457
|
} catch {
|
|
6214
|
-
const parent =
|
|
6458
|
+
const parent = path4.dirname(cursor);
|
|
6215
6459
|
if (parent === cursor) return comparePath(expanded);
|
|
6216
|
-
missing.push(
|
|
6460
|
+
missing.push(path4.basename(cursor));
|
|
6217
6461
|
cursor = parent;
|
|
6218
6462
|
}
|
|
6219
6463
|
}
|
|
6220
6464
|
}
|
|
6221
6465
|
}
|
|
6222
6466
|
var isInside = (target, root) => {
|
|
6223
|
-
const relative =
|
|
6224
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
6467
|
+
const relative = path4.relative(root, target);
|
|
6468
|
+
return relative === "" || !relative.startsWith("..") && !path4.isAbsolute(relative);
|
|
6225
6469
|
};
|
|
6226
6470
|
function defaultSensitiveRoots() {
|
|
6227
|
-
const home =
|
|
6471
|
+
const home = os3.homedir();
|
|
6228
6472
|
const roots = [
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6473
|
+
path4.join(home, ".ssh"),
|
|
6474
|
+
path4.join(home, ".aws"),
|
|
6475
|
+
path4.join(home, ".gnupg"),
|
|
6476
|
+
path4.join(home, ".azure"),
|
|
6477
|
+
path4.join(home, ".kube"),
|
|
6478
|
+
path4.join(home, ".docker"),
|
|
6479
|
+
path4.join(home, ".config", "gcloud")
|
|
6236
6480
|
];
|
|
6237
6481
|
if (process.platform === "darwin") {
|
|
6238
6482
|
roots.push(
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6483
|
+
path4.join(home, "Library", "Application Support", "Google", "Chrome"),
|
|
6484
|
+
path4.join(home, "Library", "Application Support", "Microsoft Edge"),
|
|
6485
|
+
path4.join(home, "Library", "Application Support", "Firefox")
|
|
6242
6486
|
);
|
|
6243
6487
|
}
|
|
6244
6488
|
if (process.platform === "win32") {
|
|
6245
6489
|
const appData = process.env.APPDATA;
|
|
6246
6490
|
const localAppData = process.env.LOCALAPPDATA;
|
|
6247
6491
|
if (appData) {
|
|
6248
|
-
roots.push(
|
|
6492
|
+
roots.push(path4.join(appData, "Mozilla", "Firefox"));
|
|
6249
6493
|
}
|
|
6250
6494
|
if (localAppData) {
|
|
6251
6495
|
roots.push(
|
|
6252
|
-
|
|
6253
|
-
|
|
6496
|
+
path4.join(localAppData, "Google", "Chrome", "User Data"),
|
|
6497
|
+
path4.join(localAppData, "Microsoft", "Edge", "User Data")
|
|
6254
6498
|
);
|
|
6255
6499
|
}
|
|
6256
6500
|
}
|
|
6257
6501
|
return roots;
|
|
6258
6502
|
}
|
|
6259
6503
|
function looksLikeSensitiveFile(target) {
|
|
6260
|
-
const basename =
|
|
6504
|
+
const basename = path4.basename(target).toLowerCase();
|
|
6261
6505
|
if (basename === ".env" || basename.startsWith(".env.")) return true;
|
|
6262
6506
|
if (SENSITIVE_BASENAMES.has(basename)) return true;
|
|
6263
6507
|
const normalized = target.replace(/\\/g, "/").toLowerCase();
|
|
@@ -6752,7 +6996,7 @@ var RemoteArcExecutionCore = class {
|
|
|
6752
6996
|
// src/goal-workspace.ts
|
|
6753
6997
|
var run = promisify(execFile2);
|
|
6754
6998
|
var pending = /* @__PURE__ */ new Map();
|
|
6755
|
-
var samePath = (a, b) => process.platform === "win32" ?
|
|
6999
|
+
var samePath = (a, b) => process.platform === "win32" ? path5.resolve(a).toLowerCase() === path5.resolve(b).toLowerCase() : path5.resolve(a) === path5.resolve(b);
|
|
6756
7000
|
var git = async (cwd, args) => (await run("git", ["-c", "core.hooksPath=", "-c", "commit.gpgSign=false", "-C", cwd, ...args], { windowsHide: true, timeout: 2e4, maxBuffer: 1e6, env: { ...process.env, GIT_TERMINAL_PROMPT: "0", GIT_AUTHOR_NAME: "Remote Arc", GIT_AUTHOR_EMAIL: "task@remotearc.local", GIT_COMMITTER_NAME: "Remote Arc", GIT_COMMITTER_EMAIL: "task@remotearc.local" } })).stdout.trim();
|
|
6757
7001
|
async function goalWorkspace(args, policy = {}) {
|
|
6758
7002
|
const id = String(args.task_id || ""), operation = String(args.operation_id || ""), action = String(args.action || "");
|
|
@@ -6760,12 +7004,12 @@ async function goalWorkspace(args, policy = {}) {
|
|
|
6760
7004
|
const prior = pending.get(id) || Promise.resolve();
|
|
6761
7005
|
const next = prior.catch(() => void 0).then(async () => {
|
|
6762
7006
|
const root = await enforcePathPolicy(String(args.workspace || ""), policy);
|
|
6763
|
-
const canonical = await
|
|
6764
|
-
const directory = await enforcePathPolicy(
|
|
6765
|
-
const file =
|
|
7007
|
+
const canonical = await fs5.realpath(root);
|
|
7008
|
+
const directory = await enforcePathPolicy(path5.join(canonical, ".remotearc-goals", id), policy);
|
|
7009
|
+
const file = path5.join(directory, "state.json");
|
|
6766
7010
|
let state;
|
|
6767
7011
|
try {
|
|
6768
|
-
state = JSON.parse(await
|
|
7012
|
+
state = JSON.parse(await fs5.readFile(file, "utf8"));
|
|
6769
7013
|
} catch (e) {
|
|
6770
7014
|
if (e.code !== "ENOENT") throw e;
|
|
6771
7015
|
}
|
|
@@ -6773,28 +7017,28 @@ async function goalWorkspace(args, policy = {}) {
|
|
|
6773
7017
|
const result = (s) => ({ root: s.root, path: s.path, frontier: s.frontier, generation: s.generation });
|
|
6774
7018
|
const save = async (s) => {
|
|
6775
7019
|
const temp = file + ".next";
|
|
6776
|
-
await
|
|
6777
|
-
await
|
|
7020
|
+
await fs5.writeFile(temp, JSON.stringify(s), { encoding: "utf8", mode: 384 });
|
|
7021
|
+
await fs5.rename(temp, file);
|
|
6778
7022
|
};
|
|
6779
7023
|
if (state?.operations[operation] && !["status", "fingerprint"].includes(action)) return state.operations[operation];
|
|
6780
7024
|
if (!state) {
|
|
6781
7025
|
if (action !== "create") throw new Error("No owned goal workspace. Update the device CLI if this tool is unavailable.");
|
|
6782
|
-
const top = await
|
|
7026
|
+
const top = await fs5.realpath(await git(canonical, ["rev-parse", "--show-toplevel"]));
|
|
6783
7027
|
if (!samePath(top, canonical)) throw new Error("Quality isolation requires the repository root.");
|
|
6784
7028
|
if (await git(canonical, ["status", "--porcelain", "--", ".", ":!.remotearc-goals"])) throw new Error("Quality baseline requires a clean checkout; preserve user edits before starting.");
|
|
6785
7029
|
const frontier = await git(canonical, ["rev-parse", "HEAD"]);
|
|
6786
|
-
await
|
|
6787
|
-
const candidate = await enforcePathPolicy(
|
|
7030
|
+
await fs5.mkdir(directory, { recursive: true });
|
|
7031
|
+
const candidate = await enforcePathPolicy(path5.join(directory, "candidate-0"), policy);
|
|
6788
7032
|
await git(canonical, ["worktree", "add", "--detach", candidate, frontier]);
|
|
6789
7033
|
state = { version: 1, task_id: id, root: canonical, path: candidate, frontier, generation: 0, operations: {} };
|
|
6790
7034
|
} else {
|
|
6791
|
-
const expected =
|
|
6792
|
-
if (!samePath(state.path, expected) || !samePath(await
|
|
7035
|
+
const expected = path5.join(directory, "candidate-" + state.generation);
|
|
7036
|
+
if (!samePath(state.path, expected) || !samePath(await fs5.realpath(state.path), expected)) throw new Error("Candidate ownership path changed.");
|
|
6793
7037
|
await enforcePathPolicy(state.path, policy);
|
|
6794
|
-
const marker = await
|
|
7038
|
+
const marker = await fs5.lstat(path5.join(state.path, ".git"));
|
|
6795
7039
|
if (!marker.isFile() || marker.isSymbolicLink()) throw new Error("Candidate Git identity changed.");
|
|
6796
|
-
const common = await
|
|
6797
|
-
const original = await
|
|
7040
|
+
const common = await fs5.realpath(await git(state.path, ["rev-parse", "--path-format=absolute", "--git-common-dir"]));
|
|
7041
|
+
const original = await fs5.realpath(await git(canonical, ["rev-parse", "--path-format=absolute", "--git-common-dir"]));
|
|
6798
7042
|
if (!samePath(common, original)) throw new Error("Candidate belongs to another repository.");
|
|
6799
7043
|
if (action === "capture") {
|
|
6800
7044
|
if (args.expected_frontier !== state.frontier) throw new Error("Accepted checkpoint changed. Read context again.");
|
|
@@ -6808,7 +7052,7 @@ async function goalWorkspace(args, policy = {}) {
|
|
|
6808
7052
|
}
|
|
6809
7053
|
if (action === "reject") {
|
|
6810
7054
|
if (args.expected_frontier !== state.frontier) throw new Error("Accepted checkpoint changed. Read context again.");
|
|
6811
|
-
const candidate = await enforcePathPolicy(
|
|
7055
|
+
const candidate = await enforcePathPolicy(path5.join(directory, "candidate-" + (state.generation + 1)), policy);
|
|
6812
7056
|
await git(canonical, ["worktree", "add", "--detach", candidate, state.frontier]);
|
|
6813
7057
|
state.generation++;
|
|
6814
7058
|
state.path = candidate;
|
|
@@ -6834,21 +7078,21 @@ async function goalWorkspace(args, policy = {}) {
|
|
|
6834
7078
|
|
|
6835
7079
|
// src/agent-runtime.ts
|
|
6836
7080
|
var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
|
|
6837
|
-
import
|
|
7081
|
+
import fs6 from "fs/promises";
|
|
6838
7082
|
import { appendFileSync, mkdirSync, renameSync, statSync, openSync, closeSync } from "fs";
|
|
6839
|
-
import
|
|
6840
|
-
import { spawn as
|
|
7083
|
+
import path6 from "path";
|
|
7084
|
+
import { spawn as spawn4 } from "child_process";
|
|
6841
7085
|
var AGENT_LEASE_STALE_MS = 15e3;
|
|
6842
7086
|
async function agentLeaseActive(directory) {
|
|
6843
|
-
return (0, import_proper_lockfile.check)(
|
|
7087
|
+
return (0, import_proper_lockfile.check)(path6.join(directory, "execution"), {
|
|
6844
7088
|
realpath: false,
|
|
6845
7089
|
stale: AGENT_LEASE_STALE_MS
|
|
6846
7090
|
});
|
|
6847
7091
|
}
|
|
6848
7092
|
async function tryAgentLease(directory, role = "execution") {
|
|
6849
|
-
await
|
|
7093
|
+
await fs6.mkdir(directory, { recursive: true, mode: 448 });
|
|
6850
7094
|
try {
|
|
6851
|
-
return await (0, import_proper_lockfile.lock)(
|
|
7095
|
+
return await (0, import_proper_lockfile.lock)(path6.join(directory, role), {
|
|
6852
7096
|
realpath: false,
|
|
6853
7097
|
stale: AGENT_LEASE_STALE_MS,
|
|
6854
7098
|
update: 3e3,
|
|
@@ -6862,7 +7106,7 @@ async function tryAgentLease(directory, role = "execution") {
|
|
|
6862
7106
|
function appendAgentEvent(directory, line) {
|
|
6863
7107
|
try {
|
|
6864
7108
|
mkdirSync(directory, { recursive: true, mode: 448 });
|
|
6865
|
-
const file =
|
|
7109
|
+
const file = path6.join(directory, "events.log");
|
|
6866
7110
|
if ((statSync(file, { throwIfNoEntry: false })?.size ?? 0) > 5 * 1024 * 1024) {
|
|
6867
7111
|
renameSync(file, file + ".1");
|
|
6868
7112
|
}
|
|
@@ -6871,10 +7115,10 @@ function appendAgentEvent(directory, line) {
|
|
|
6871
7115
|
}
|
|
6872
7116
|
}
|
|
6873
7117
|
async function readAgentEvents(directory, cursor) {
|
|
6874
|
-
const file =
|
|
7118
|
+
const file = path6.join(directory, "events.log");
|
|
6875
7119
|
let handle;
|
|
6876
7120
|
try {
|
|
6877
|
-
handle = await
|
|
7121
|
+
handle = await fs6.open(file, "r");
|
|
6878
7122
|
const size = (await handle.stat()).size;
|
|
6879
7123
|
const start = cursor === null ? Math.max(0, size - 16384) : cursor > size ? 0 : cursor;
|
|
6880
7124
|
const buffer = Buffer.alloc(Math.min(size - start, 64 * 1024));
|
|
@@ -6892,10 +7136,10 @@ async function readAgentEvents(directory, cursor) {
|
|
|
6892
7136
|
}
|
|
6893
7137
|
async function readAgentEventTail(directory, requestedLimit = 100) {
|
|
6894
7138
|
const limit = Math.max(20, Math.min(200, Math.trunc(requestedLimit || 100)));
|
|
6895
|
-
const file =
|
|
7139
|
+
const file = path6.join(directory, "events.log");
|
|
6896
7140
|
let handle;
|
|
6897
7141
|
try {
|
|
6898
|
-
handle = await
|
|
7142
|
+
handle = await fs6.open(file, "r");
|
|
6899
7143
|
const stat = await handle.stat();
|
|
6900
7144
|
const start = Math.max(0, stat.size - 128 * 1024);
|
|
6901
7145
|
const buffer = Buffer.alloc(Math.min(stat.size - start, 128 * 1024));
|
|
@@ -6950,28 +7194,28 @@ async function superviseAgent(options) {
|
|
|
6950
7194
|
}
|
|
6951
7195
|
}
|
|
6952
7196
|
function startSupervisedAgent(node, bundle, logs) {
|
|
6953
|
-
if (!logs) return
|
|
7197
|
+
if (!logs) return spawn4(node, [bundle, "--agent"], { stdio: "inherit", windowsHide: true });
|
|
6954
7198
|
mkdirSync(logs, { recursive: true, mode: 448 });
|
|
6955
|
-
const out = openSync(
|
|
7199
|
+
const out = openSync(path6.join(logs, "agent.log"), "a", 384);
|
|
6956
7200
|
let err;
|
|
6957
7201
|
try {
|
|
6958
|
-
err = openSync(
|
|
6959
|
-
return
|
|
7202
|
+
err = openSync(path6.join(logs, "agent-error.log"), "a", 384);
|
|
7203
|
+
return spawn4(node, [bundle, "--agent"], { stdio: ["ignore", out, err], windowsHide: true });
|
|
6960
7204
|
} finally {
|
|
6961
7205
|
closeSync(out);
|
|
6962
7206
|
if (err !== void 0) closeSync(err);
|
|
6963
7207
|
}
|
|
6964
7208
|
}
|
|
6965
7209
|
|
|
6966
|
-
// src/
|
|
6967
|
-
import
|
|
6968
|
-
import
|
|
6969
|
-
import
|
|
6970
|
-
import { spawn as
|
|
6971
|
-
import { randomUUID } from "crypto";
|
|
7210
|
+
// src/legacy.ts
|
|
7211
|
+
import os5 from "os";
|
|
7212
|
+
import path8 from "path";
|
|
7213
|
+
import fs8 from "fs/promises";
|
|
7214
|
+
import { spawn as spawn6 } from "child_process";
|
|
7215
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
6972
7216
|
import process3 from "process";
|
|
6973
7217
|
import { createInterface } from "readline/promises";
|
|
6974
|
-
import { fileURLToPath } from "url";
|
|
7218
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
6975
7219
|
|
|
6976
7220
|
// ../../node_modules/.pnpm/ws@8.21.3/node_modules/ws/wrapper.mjs
|
|
6977
7221
|
var import_stream = __toESM(require_stream(), 1);
|
|
@@ -6985,10 +7229,10 @@ var import_websocket_server = __toESM(require_websocket_server(), 1);
|
|
|
6985
7229
|
var wrapper_default = import_websocket.default;
|
|
6986
7230
|
|
|
6987
7231
|
// src/background.ts
|
|
6988
|
-
import
|
|
6989
|
-
import
|
|
6990
|
-
import
|
|
6991
|
-
import { spawn as
|
|
7232
|
+
import os4 from "os";
|
|
7233
|
+
import path7 from "path";
|
|
7234
|
+
import fs7 from "fs/promises";
|
|
7235
|
+
import { spawn as spawn5 } from "child_process";
|
|
6992
7236
|
var LegacyBackgroundAgentError = class extends Error {
|
|
6993
7237
|
};
|
|
6994
7238
|
function parseReleaseVersion(value) {
|
|
@@ -7011,7 +7255,7 @@ function windowsSupervisorLaunchScript(node, bundle) {
|
|
|
7011
7255
|
}
|
|
7012
7256
|
async function run2(command, args, options = {}) {
|
|
7013
7257
|
return new Promise((resolve, reject) => {
|
|
7014
|
-
const child =
|
|
7258
|
+
const child = spawn5(command, args, {
|
|
7015
7259
|
stdio: ["ignore", "pipe", "pipe"],
|
|
7016
7260
|
windowsHide: true
|
|
7017
7261
|
});
|
|
@@ -7054,17 +7298,17 @@ async function run2(command, args, options = {}) {
|
|
|
7054
7298
|
}
|
|
7055
7299
|
function createBackgroundController(options = {}) {
|
|
7056
7300
|
const platform = options.platform ?? process.platform;
|
|
7057
|
-
const home = options.home ??
|
|
7301
|
+
const home = options.home ?? os4.homedir();
|
|
7058
7302
|
const nodePath = options.nodePath ?? process.execPath;
|
|
7059
|
-
const uid = options.uid ?? process.getuid?.() ??
|
|
7303
|
+
const uid = options.uid ?? process.getuid?.() ?? os4.userInfo().uid;
|
|
7060
7304
|
const runCommand = options.run ?? run2;
|
|
7061
7305
|
const wait = options.wait ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
7062
7306
|
const leaseActive = options.leaseActive ?? agentLeaseActive;
|
|
7063
|
-
const CONFIG_DIR2 =
|
|
7064
|
-
const AGENT_DIR =
|
|
7065
|
-
const LOG_DIR =
|
|
7066
|
-
const AGENT_BUNDLE =
|
|
7067
|
-
const AGENT_VERSION_FILE =
|
|
7307
|
+
const CONFIG_DIR2 = path7.join(home, ".remotearc");
|
|
7308
|
+
const AGENT_DIR = path7.join(CONFIG_DIR2, "agent");
|
|
7309
|
+
const LOG_DIR = path7.join(CONFIG_DIR2, "logs");
|
|
7310
|
+
const AGENT_BUNDLE = path7.join(AGENT_DIR, "remotelink.mjs");
|
|
7311
|
+
const AGENT_VERSION_FILE = path7.join(AGENT_DIR, "version");
|
|
7068
7312
|
const MAC_LABEL = "app.remotearc.agent";
|
|
7069
7313
|
const WINDOWS_RUN_KEY = "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run";
|
|
7070
7314
|
const WINDOWS_RUN_VALUE = "Remote Arc Agent";
|
|
@@ -7079,35 +7323,35 @@ function createBackgroundController(options = {}) {
|
|
|
7079
7323
|
return JSON.stringify(value).replaceAll("%", "%%");
|
|
7080
7324
|
}
|
|
7081
7325
|
async function ensureBundle(sourcePath, version) {
|
|
7082
|
-
await
|
|
7083
|
-
await
|
|
7084
|
-
if (
|
|
7326
|
+
await fs7.mkdir(AGENT_DIR, { recursive: true });
|
|
7327
|
+
await fs7.mkdir(LOG_DIR, { recursive: true });
|
|
7328
|
+
if (path7.resolve(sourcePath) !== path7.resolve(AGENT_BUNDLE)) {
|
|
7085
7329
|
const staging = AGENT_BUNDLE + "." + process.pid + ".tmp";
|
|
7086
|
-
await
|
|
7087
|
-
await
|
|
7330
|
+
await fs7.copyFile(sourcePath, staging);
|
|
7331
|
+
await fs7.rename(staging, AGENT_BUNDLE);
|
|
7088
7332
|
if (platform !== "win32") {
|
|
7089
|
-
await
|
|
7333
|
+
await fs7.chmod(AGENT_BUNDLE, 448).catch(() => void 0);
|
|
7090
7334
|
}
|
|
7091
7335
|
}
|
|
7092
7336
|
if (version) {
|
|
7093
|
-
await
|
|
7337
|
+
await fs7.writeFile(AGENT_VERSION_FILE, version + "\n", { mode: 384 });
|
|
7094
7338
|
}
|
|
7095
7339
|
}
|
|
7096
7340
|
async function backgroundBundleVersion() {
|
|
7097
|
-
return
|
|
7341
|
+
return fs7.readFile(AGENT_VERSION_FILE, "utf8").then((value) => value.trim() || null).catch(() => null);
|
|
7098
7342
|
}
|
|
7099
7343
|
function macPlistPath() {
|
|
7100
|
-
return
|
|
7344
|
+
return path7.join(home, "Library", "LaunchAgents", MAC_LABEL + ".plist");
|
|
7101
7345
|
}
|
|
7102
7346
|
function linuxUnitPath() {
|
|
7103
|
-
return
|
|
7347
|
+
return path7.join(home, ".config", "systemd", "user", LINUX_UNIT);
|
|
7104
7348
|
}
|
|
7105
7349
|
async function enableMac(sourcePath, preserveCurrent, version) {
|
|
7106
7350
|
await ensureBundle(sourcePath, version);
|
|
7107
7351
|
const plistPath = macPlistPath();
|
|
7108
|
-
await
|
|
7109
|
-
const stdoutPath =
|
|
7110
|
-
const stderrPath =
|
|
7352
|
+
await fs7.mkdir(path7.dirname(plistPath), { recursive: true });
|
|
7353
|
+
const stdoutPath = path7.join(LOG_DIR, "agent.log");
|
|
7354
|
+
const stderrPath = path7.join(LOG_DIR, "agent-error.log");
|
|
7111
7355
|
const plist = `<?xml version="1.0" encoding="UTF-8"?>
|
|
7112
7356
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
7113
7357
|
<plist version="1.0">
|
|
@@ -7136,7 +7380,7 @@ function createBackgroundController(options = {}) {
|
|
|
7136
7380
|
</dict>
|
|
7137
7381
|
</plist>
|
|
7138
7382
|
`;
|
|
7139
|
-
await
|
|
7383
|
+
await fs7.writeFile(plistPath, plist, { mode: 384 });
|
|
7140
7384
|
const domain = `gui/${uid}`;
|
|
7141
7385
|
const loaded = await runCommand(
|
|
7142
7386
|
"launchctl",
|
|
@@ -7176,7 +7420,7 @@ function createBackgroundController(options = {}) {
|
|
|
7176
7420
|
await runCommand("launchctl", ["disable", domain + "/" + MAC_LABEL], {
|
|
7177
7421
|
ignoreFailure: true
|
|
7178
7422
|
});
|
|
7179
|
-
await
|
|
7423
|
+
await fs7.rm(plistPath, { force: true });
|
|
7180
7424
|
if (stopCurrent) {
|
|
7181
7425
|
await runCommand("launchctl", ["bootout", domain + "/" + MAC_LABEL], {
|
|
7182
7426
|
ignoreFailure: true
|
|
@@ -7186,7 +7430,7 @@ function createBackgroundController(options = {}) {
|
|
|
7186
7430
|
}
|
|
7187
7431
|
async function statusMac() {
|
|
7188
7432
|
const plistPath = macPlistPath();
|
|
7189
|
-
const installed = await
|
|
7433
|
+
const installed = await fs7.access(plistPath).then(() => true).catch(() => false);
|
|
7190
7434
|
const domain = "gui/" + uid;
|
|
7191
7435
|
const result = await runCommand(
|
|
7192
7436
|
"launchctl",
|
|
@@ -7214,7 +7458,7 @@ function createBackgroundController(options = {}) {
|
|
|
7214
7458
|
async function enableLinux(sourcePath, preserveCurrent, version) {
|
|
7215
7459
|
await ensureBundle(sourcePath, version);
|
|
7216
7460
|
const unitPath = linuxUnitPath();
|
|
7217
|
-
await
|
|
7461
|
+
await fs7.mkdir(path7.dirname(unitPath), { recursive: true });
|
|
7218
7462
|
const unit = `[Unit]
|
|
7219
7463
|
Description=Remote Arc background agent
|
|
7220
7464
|
After=network-online.target
|
|
@@ -7232,7 +7476,7 @@ Environment=${unitQuote("HOME=" + home)}
|
|
|
7232
7476
|
[Install]
|
|
7233
7477
|
WantedBy=default.target
|
|
7234
7478
|
`;
|
|
7235
|
-
await
|
|
7479
|
+
await fs7.writeFile(unitPath, unit, { mode: 384 });
|
|
7236
7480
|
await runCommand("systemctl", ["--user", "daemon-reload"]);
|
|
7237
7481
|
await runCommand("systemctl", ["--user", "enable", "--now", LINUX_UNIT]);
|
|
7238
7482
|
return backgroundAgentStatus2();
|
|
@@ -7243,7 +7487,7 @@ WantedBy=default.target
|
|
|
7243
7487
|
stopCurrent ? ["--user", "disable", "--now", LINUX_UNIT] : ["--user", "disable", LINUX_UNIT],
|
|
7244
7488
|
{ ignoreFailure: true }
|
|
7245
7489
|
);
|
|
7246
|
-
await
|
|
7490
|
+
await fs7.rm(linuxUnitPath(), { force: true });
|
|
7247
7491
|
if (stopCurrent) {
|
|
7248
7492
|
await runCommand("systemctl", ["--user", "daemon-reload"], {
|
|
7249
7493
|
ignoreFailure: true
|
|
@@ -7464,13 +7708,13 @@ var {
|
|
|
7464
7708
|
disableBackgroundAgent
|
|
7465
7709
|
} = createBackgroundController();
|
|
7466
7710
|
|
|
7467
|
-
// src/
|
|
7468
|
-
var VERSION =
|
|
7711
|
+
// src/legacy.ts
|
|
7712
|
+
var VERSION = package_default.version;
|
|
7469
7713
|
var DEFAULT_ORIGIN = "https://mcp.remotearc.app";
|
|
7470
|
-
var CONFIG_DIR =
|
|
7471
|
-
var CONFIG_PATH =
|
|
7472
|
-
var LEGACY_CONFIG_PATH =
|
|
7473
|
-
var SELF_PATH =
|
|
7714
|
+
var CONFIG_DIR = path8.join(os5.homedir(), ".remotearc");
|
|
7715
|
+
var CONFIG_PATH = path8.join(CONFIG_DIR, "config.json");
|
|
7716
|
+
var LEGACY_CONFIG_PATH = path8.join(os5.homedir(), ".remote-link", "config.json");
|
|
7717
|
+
var SELF_PATH = fileURLToPath2(import.meta.url);
|
|
7474
7718
|
var RevokedDeviceCredentialError = class extends Error {
|
|
7475
7719
|
constructor() {
|
|
7476
7720
|
super("Saved device credential has been revoked.");
|
|
@@ -7584,7 +7828,7 @@ function logLine(level, message) {
|
|
|
7584
7828
|
const icon = level === "success" ? green("\u2713") : level === "warn" ? yellow("!") : level === "error" ? red("\xD7") : level === "event" ? cyan("\u2192") : cyan("\u2022");
|
|
7585
7829
|
process3.stdout.write(`${dim(nowTime())} ${icon} ${message}
|
|
7586
7830
|
`);
|
|
7587
|
-
appendAgentEvent(
|
|
7831
|
+
appendAgentEvent(path8.join(CONFIG_DIR, "logs"), `${nowTime()} ${level} ${message}
|
|
7588
7832
|
`);
|
|
7589
7833
|
}
|
|
7590
7834
|
function banner() {
|
|
@@ -7607,11 +7851,11 @@ function modeLabel(mode) {
|
|
|
7607
7851
|
}
|
|
7608
7852
|
async function readConfig() {
|
|
7609
7853
|
try {
|
|
7610
|
-
return JSON.parse(await
|
|
7854
|
+
return JSON.parse(await fs8.readFile(CONFIG_PATH, "utf8"));
|
|
7611
7855
|
} catch {
|
|
7612
7856
|
try {
|
|
7613
7857
|
const legacy = JSON.parse(
|
|
7614
|
-
await
|
|
7858
|
+
await fs8.readFile(LEGACY_CONFIG_PATH, "utf8")
|
|
7615
7859
|
);
|
|
7616
7860
|
await writeConfig(legacy);
|
|
7617
7861
|
logLine("success", "Migrated existing Remote Link pairing to Remote Arc.");
|
|
@@ -7622,33 +7866,33 @@ async function readConfig() {
|
|
|
7622
7866
|
}
|
|
7623
7867
|
}
|
|
7624
7868
|
async function writeConfig(config) {
|
|
7625
|
-
await
|
|
7626
|
-
const staging = CONFIG_PATH + "." +
|
|
7869
|
+
await fs8.mkdir(CONFIG_DIR, { recursive: true, mode: 448 });
|
|
7870
|
+
const staging = CONFIG_PATH + "." + randomUUID2() + ".tmp";
|
|
7627
7871
|
try {
|
|
7628
|
-
await
|
|
7629
|
-
await
|
|
7872
|
+
await fs8.writeFile(staging, JSON.stringify(config, null, 2) + "\n", { mode: 384 });
|
|
7873
|
+
await fs8.rename(staging, CONFIG_PATH);
|
|
7630
7874
|
} finally {
|
|
7631
|
-
await
|
|
7875
|
+
await fs8.rm(staging, { force: true });
|
|
7632
7876
|
}
|
|
7633
7877
|
}
|
|
7634
7878
|
async function resetConfig() {
|
|
7635
7879
|
await Promise.all([
|
|
7636
|
-
|
|
7637
|
-
|
|
7880
|
+
fs8.rm(CONFIG_PATH, { force: true }),
|
|
7881
|
+
fs8.rm(LEGACY_CONFIG_PATH, { force: true })
|
|
7638
7882
|
]);
|
|
7639
7883
|
logLine("success", "Removed saved device credentials.");
|
|
7640
7884
|
}
|
|
7641
7885
|
function openBrowser(url) {
|
|
7642
7886
|
const command = process3.platform === "win32" ? "cmd" : process3.platform === "darwin" ? "open" : "xdg-open";
|
|
7643
7887
|
const args = process3.platform === "win32" ? ["/c", "start", "", url] : [url];
|
|
7644
|
-
const child =
|
|
7888
|
+
const child = spawn6(command, args, {
|
|
7645
7889
|
detached: true,
|
|
7646
7890
|
stdio: "ignore"
|
|
7647
7891
|
});
|
|
7648
7892
|
child.unref();
|
|
7649
7893
|
}
|
|
7650
7894
|
async function pair(origin, mode) {
|
|
7651
|
-
const deviceName =
|
|
7895
|
+
const deviceName = os5.hostname();
|
|
7652
7896
|
const response = await fetch(origin + "/api/device/start", {
|
|
7653
7897
|
method: "POST",
|
|
7654
7898
|
headers: { "content-type": "application/json" },
|
|
@@ -7656,7 +7900,7 @@ async function pair(origin, mode) {
|
|
|
7656
7900
|
device_name: deviceName,
|
|
7657
7901
|
platform: process3.platform,
|
|
7658
7902
|
arch: process3.arch,
|
|
7659
|
-
hostname:
|
|
7903
|
+
hostname: os5.hostname()
|
|
7660
7904
|
})
|
|
7661
7905
|
});
|
|
7662
7906
|
if (!response.ok) {
|
|
@@ -7830,7 +8074,7 @@ async function connectAgent(config) {
|
|
|
7830
8074
|
name: config.deviceName,
|
|
7831
8075
|
platform: process3.platform,
|
|
7832
8076
|
arch: process3.arch,
|
|
7833
|
-
hostname:
|
|
8077
|
+
hostname: os5.hostname(),
|
|
7834
8078
|
agentVersion: VERSION,
|
|
7835
8079
|
pid: process3.pid,
|
|
7836
8080
|
backgroundProcess: argFlag("--agent"),
|
|
@@ -7934,7 +8178,7 @@ async function connectAgent(config) {
|
|
|
7934
8178
|
};
|
|
7935
8179
|
} else if (message.tool === "agent_execution_log") {
|
|
7936
8180
|
result = await readAgentEventTail(
|
|
7937
|
-
|
|
8181
|
+
path8.join(CONFIG_DIR, "logs"),
|
|
7938
8182
|
Number(message.arguments?.limit || 100)
|
|
7939
8183
|
);
|
|
7940
8184
|
} else if (message.tool === "set_background_agent") {
|
|
@@ -8058,6 +8302,8 @@ async function main() {
|
|
|
8058
8302
|
" npx remotelink",
|
|
8059
8303
|
"",
|
|
8060
8304
|
"Options:",
|
|
8305
|
+
" --go Select the complete native Go device runtime",
|
|
8306
|
+
" --ts Select the TS device runtime (transition default)",
|
|
8061
8307
|
" --safe Hard local read-only cap; dashboard cannot enable write tools",
|
|
8062
8308
|
" --developer Legacy alias for dashboard-managed capabilities",
|
|
8063
8309
|
" --foreground Stay attached without installing or repairing recovery",
|
|
@@ -8120,7 +8366,7 @@ async function main() {
|
|
|
8120
8366
|
}
|
|
8121
8367
|
logLine("info", `Using paired device identity ${dim(config.deviceId.slice(0, 8))}\u2026`);
|
|
8122
8368
|
if (supervisorMode) {
|
|
8123
|
-
const release2 = await tryAgentLease(
|
|
8369
|
+
const release2 = await tryAgentLease(path8.join(CONFIG_DIR, "agent"), "supervisor");
|
|
8124
8370
|
if (!release2) return;
|
|
8125
8371
|
const abort2 = new AbortController();
|
|
8126
8372
|
const stop = () => abort2.abort();
|
|
@@ -8130,7 +8376,7 @@ async function main() {
|
|
|
8130
8376
|
await superviseAgent({
|
|
8131
8377
|
enabled: async () => (await readConfig())?.backgroundEnabled === true,
|
|
8132
8378
|
signal: abort2.signal,
|
|
8133
|
-
start: () => startSupervisedAgent(process3.execPath, SELF_PATH,
|
|
8379
|
+
start: () => startSupervisedAgent(process3.execPath, SELF_PATH, path8.join(CONFIG_DIR, "logs"))
|
|
8134
8380
|
});
|
|
8135
8381
|
} finally {
|
|
8136
8382
|
process3.off("SIGINT", stop);
|
|
@@ -8191,7 +8437,7 @@ async function main() {
|
|
|
8191
8437
|
try {
|
|
8192
8438
|
while (!abort.signal.aborted && !release) {
|
|
8193
8439
|
if (agentMode && (await readConfig())?.backgroundEnabled !== true) return;
|
|
8194
|
-
release = await tryAgentLease(
|
|
8440
|
+
release = await tryAgentLease(path8.join(CONFIG_DIR, "agent"));
|
|
8195
8441
|
if (release) break;
|
|
8196
8442
|
if (!agentMode && (argFlag("--safe") || argFlag("--developer"))) {
|
|
8197
8443
|
logLine("error", "Another Agent owns execution. Stop it locally before changing the local permission profile.");
|
|
@@ -8203,7 +8449,7 @@ async function main() {
|
|
|
8203
8449
|
logLine("info", "An Agent already owns execution. Following its operation log; Ctrl+C closes this viewer.");
|
|
8204
8450
|
announced = true;
|
|
8205
8451
|
}
|
|
8206
|
-
const events = await readAgentEvents(
|
|
8452
|
+
const events = await readAgentEvents(path8.join(CONFIG_DIR, "logs"), cursor);
|
|
8207
8453
|
cursor = events.cursor;
|
|
8208
8454
|
if (events.text) process3.stdout.write(events.text);
|
|
8209
8455
|
if (Date.now() - lastApprovalPoll >= 4e3) {
|
|
@@ -8233,11 +8479,28 @@ async function main() {
|
|
|
8233
8479
|
config = null;
|
|
8234
8480
|
}
|
|
8235
8481
|
}
|
|
8236
|
-
|
|
8237
|
-
|
|
8238
|
-
|
|
8239
|
-
|
|
8482
|
+
async function runLegacy() {
|
|
8483
|
+
await main();
|
|
8484
|
+
}
|
|
8485
|
+
|
|
8486
|
+
// src/index.ts
|
|
8487
|
+
async function main2() {
|
|
8488
|
+
const args = process.argv.slice(2);
|
|
8489
|
+
if (args.includes("--go") && args.includes("--ts"))
|
|
8490
|
+
throw new Error("Choose one agent runtime: --go or --ts.");
|
|
8491
|
+
const go = args.includes("--go");
|
|
8492
|
+
const forwarded = args.filter(
|
|
8493
|
+
(argument) => argument !== "--go" && argument !== "--ts"
|
|
8494
|
+
);
|
|
8495
|
+
if (go) return launchGo(forwarded);
|
|
8496
|
+
await assertTSOwnership(forwarded);
|
|
8497
|
+
process.argv = [...process.argv.slice(0, 2), ...forwarded];
|
|
8498
|
+
await runLegacy();
|
|
8499
|
+
}
|
|
8500
|
+
main2().catch((error) => {
|
|
8501
|
+
process.stderr.write(
|
|
8502
|
+
"Remote Arc: " + (error instanceof Error ? error.message : String(error)) + "\n"
|
|
8240
8503
|
);
|
|
8241
|
-
|
|
8504
|
+
process.exitCode = 1;
|
|
8242
8505
|
});
|
|
8243
8506
|
//# sourceMappingURL=index.js.map
|