agentapprove 0.1.46 → 0.1.56
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 +55 -0
- package/dist/cli.js +603 -492
- package/package.json +1 -2
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { createRequire } from "node:module";
|
|
3
2
|
var __create = Object.create;
|
|
4
3
|
var __getProtoOf = Object.getPrototypeOf;
|
|
5
4
|
var __defProp = Object.defineProperty;
|
|
@@ -19,22 +18,23 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
19
18
|
return cached;
|
|
20
19
|
}
|
|
21
20
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
22
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
const to = isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
22
|
+
if (mod && typeof mod === "object" || typeof mod === "function") {
|
|
23
|
+
for (let key of __getOwnPropNames(mod))
|
|
24
|
+
if (!__hasOwnProp.call(to, key))
|
|
25
|
+
__defProp(to, key, {
|
|
26
|
+
get: __accessProp.bind(mod, key),
|
|
27
|
+
enumerable: true
|
|
28
|
+
});
|
|
29
|
+
}
|
|
29
30
|
if (canCache)
|
|
30
31
|
cache.set(mod, to);
|
|
31
32
|
return to;
|
|
32
33
|
};
|
|
33
34
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
34
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
35
35
|
|
|
36
36
|
// ../../node_modules/.bun/sisteransi@1.0.5/node_modules/sisteransi/src/index.js
|
|
37
|
-
var require_src = __commonJS((exports, module)
|
|
37
|
+
var require_src = __commonJS(function(exports, module) {
|
|
38
38
|
var ESC = "\x1B";
|
|
39
39
|
var CSI = `${ESC}[`;
|
|
40
40
|
var beep = "\x07";
|
|
@@ -92,7 +92,7 @@ var require_src = __commonJS((exports, module) => {
|
|
|
92
92
|
});
|
|
93
93
|
|
|
94
94
|
// ../../node_modules/.bun/picocolors@1.1.1/node_modules/picocolors/picocolors.js
|
|
95
|
-
var require_picocolors = __commonJS((exports, module)
|
|
95
|
+
var require_picocolors = __commonJS(function(exports, module) {
|
|
96
96
|
var p = process || {};
|
|
97
97
|
var argv = p.argv || [];
|
|
98
98
|
var env = p.env || {};
|
|
@@ -162,7 +162,7 @@ var require_picocolors = __commonJS((exports, module) => {
|
|
|
162
162
|
});
|
|
163
163
|
|
|
164
164
|
// ../../node_modules/.bun/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRMode.js
|
|
165
|
-
var require_QRMode = __commonJS((exports, module)
|
|
165
|
+
var require_QRMode = __commonJS(function(exports, module) {
|
|
166
166
|
module.exports = {
|
|
167
167
|
MODE_NUMBER: 1 << 0,
|
|
168
168
|
MODE_ALPHA_NUM: 1 << 1,
|
|
@@ -172,7 +172,7 @@ var require_QRMode = __commonJS((exports, module) => {
|
|
|
172
172
|
});
|
|
173
173
|
|
|
174
174
|
// ../../node_modules/.bun/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QR8bitByte.js
|
|
175
|
-
var require_QR8bitByte = __commonJS((exports, module)
|
|
175
|
+
var require_QR8bitByte = __commonJS(function(exports, module) {
|
|
176
176
|
var QRMode = require_QRMode();
|
|
177
177
|
function QR8bitByte(data) {
|
|
178
178
|
this.mode = QRMode.MODE_8BIT_BYTE;
|
|
@@ -192,7 +192,7 @@ var require_QR8bitByte = __commonJS((exports, module) => {
|
|
|
192
192
|
});
|
|
193
193
|
|
|
194
194
|
// ../../node_modules/.bun/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRMath.js
|
|
195
|
-
var require_QRMath = __commonJS((exports, module)
|
|
195
|
+
var require_QRMath = __commonJS(function(exports, module) {
|
|
196
196
|
var QRMath = {
|
|
197
197
|
glog: function(n) {
|
|
198
198
|
if (n < 1) {
|
|
@@ -228,7 +228,7 @@ var require_QRMath = __commonJS((exports, module) => {
|
|
|
228
228
|
});
|
|
229
229
|
|
|
230
230
|
// ../../node_modules/.bun/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRPolynomial.js
|
|
231
|
-
var require_QRPolynomial = __commonJS((exports, module)
|
|
231
|
+
var require_QRPolynomial = __commonJS(function(exports, module) {
|
|
232
232
|
var QRMath = require_QRMath();
|
|
233
233
|
function QRPolynomial(num, shift) {
|
|
234
234
|
if (num.length === undefined) {
|
|
@@ -250,35 +250,35 @@ var require_QRPolynomial = __commonJS((exports, module) => {
|
|
|
250
250
|
getLength: function() {
|
|
251
251
|
return this.num.length;
|
|
252
252
|
},
|
|
253
|
-
multiply: function(
|
|
254
|
-
var num = new Array(this.getLength() +
|
|
253
|
+
multiply: function(e) {
|
|
254
|
+
var num = new Array(this.getLength() + e.getLength() - 1);
|
|
255
255
|
for (var i = 0;i < this.getLength(); i++) {
|
|
256
|
-
for (var
|
|
257
|
-
num[i +
|
|
256
|
+
for (var j = 0;j < e.getLength(); j++) {
|
|
257
|
+
num[i + j] ^= QRMath.gexp(QRMath.glog(this.get(i)) + QRMath.glog(e.get(j)));
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
260
|
return new QRPolynomial(num, 0);
|
|
261
261
|
},
|
|
262
|
-
mod: function(
|
|
263
|
-
if (this.getLength() -
|
|
262
|
+
mod: function(e) {
|
|
263
|
+
if (this.getLength() - e.getLength() < 0) {
|
|
264
264
|
return this;
|
|
265
265
|
}
|
|
266
|
-
var ratio = QRMath.glog(this.get(0)) - QRMath.glog(
|
|
266
|
+
var ratio = QRMath.glog(this.get(0)) - QRMath.glog(e.get(0));
|
|
267
267
|
var num = new Array(this.getLength());
|
|
268
268
|
for (var i = 0;i < this.getLength(); i++) {
|
|
269
269
|
num[i] = this.get(i);
|
|
270
270
|
}
|
|
271
|
-
for (var
|
|
272
|
-
num[
|
|
271
|
+
for (var x = 0;x < e.getLength(); x++) {
|
|
272
|
+
num[x] ^= QRMath.gexp(QRMath.glog(e.get(x)) + ratio);
|
|
273
273
|
}
|
|
274
|
-
return new QRPolynomial(num, 0).mod(
|
|
274
|
+
return new QRPolynomial(num, 0).mod(e);
|
|
275
275
|
}
|
|
276
276
|
};
|
|
277
277
|
module.exports = QRPolynomial;
|
|
278
278
|
});
|
|
279
279
|
|
|
280
280
|
// ../../node_modules/.bun/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRMaskPattern.js
|
|
281
|
-
var require_QRMaskPattern = __commonJS((exports, module)
|
|
281
|
+
var require_QRMaskPattern = __commonJS(function(exports, module) {
|
|
282
282
|
module.exports = {
|
|
283
283
|
PATTERN000: 0,
|
|
284
284
|
PATTERN001: 1,
|
|
@@ -292,7 +292,7 @@ var require_QRMaskPattern = __commonJS((exports, module) => {
|
|
|
292
292
|
});
|
|
293
293
|
|
|
294
294
|
// ../../node_modules/.bun/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRUtil.js
|
|
295
|
-
var require_QRUtil = __commonJS((exports, module)
|
|
295
|
+
var require_QRUtil = __commonJS(function(exports, module) {
|
|
296
296
|
var QRMode = require_QRMode();
|
|
297
297
|
var QRPolynomial = require_QRPolynomial();
|
|
298
298
|
var QRMath = require_QRMath();
|
|
@@ -344,18 +344,18 @@ var require_QRUtil = __commonJS((exports, module) => {
|
|
|
344
344
|
G18: 1 << 12 | 1 << 11 | 1 << 10 | 1 << 9 | 1 << 8 | 1 << 5 | 1 << 2 | 1 << 0,
|
|
345
345
|
G15_MASK: 1 << 14 | 1 << 12 | 1 << 10 | 1 << 4 | 1 << 1,
|
|
346
346
|
getBCHTypeInfo: function(data) {
|
|
347
|
-
var
|
|
348
|
-
while (QRUtil.getBCHDigit(
|
|
349
|
-
|
|
347
|
+
var d = data << 10;
|
|
348
|
+
while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) >= 0) {
|
|
349
|
+
d ^= QRUtil.G15 << QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15);
|
|
350
350
|
}
|
|
351
|
-
return (data << 10 |
|
|
351
|
+
return (data << 10 | d) ^ QRUtil.G15_MASK;
|
|
352
352
|
},
|
|
353
353
|
getBCHTypeNumber: function(data) {
|
|
354
|
-
var
|
|
355
|
-
while (QRUtil.getBCHDigit(
|
|
356
|
-
|
|
354
|
+
var d = data << 12;
|
|
355
|
+
while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) >= 0) {
|
|
356
|
+
d ^= QRUtil.G18 << QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18);
|
|
357
357
|
}
|
|
358
|
-
return data << 12 |
|
|
358
|
+
return data << 12 | d;
|
|
359
359
|
},
|
|
360
360
|
getBCHDigit: function(data) {
|
|
361
361
|
var digit = 0;
|
|
@@ -368,34 +368,34 @@ var require_QRUtil = __commonJS((exports, module) => {
|
|
|
368
368
|
getPatternPosition: function(typeNumber) {
|
|
369
369
|
return QRUtil.PATTERN_POSITION_TABLE[typeNumber - 1];
|
|
370
370
|
},
|
|
371
|
-
getMask: function(maskPattern, i,
|
|
371
|
+
getMask: function(maskPattern, i, j) {
|
|
372
372
|
switch (maskPattern) {
|
|
373
373
|
case QRMaskPattern.PATTERN000:
|
|
374
|
-
return (i +
|
|
374
|
+
return (i + j) % 2 === 0;
|
|
375
375
|
case QRMaskPattern.PATTERN001:
|
|
376
376
|
return i % 2 === 0;
|
|
377
377
|
case QRMaskPattern.PATTERN010:
|
|
378
|
-
return
|
|
378
|
+
return j % 3 === 0;
|
|
379
379
|
case QRMaskPattern.PATTERN011:
|
|
380
|
-
return (i +
|
|
380
|
+
return (i + j) % 3 === 0;
|
|
381
381
|
case QRMaskPattern.PATTERN100:
|
|
382
|
-
return (Math.floor(i / 2) + Math.floor(
|
|
382
|
+
return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0;
|
|
383
383
|
case QRMaskPattern.PATTERN101:
|
|
384
|
-
return i *
|
|
384
|
+
return i * j % 2 + i * j % 3 === 0;
|
|
385
385
|
case QRMaskPattern.PATTERN110:
|
|
386
|
-
return (i *
|
|
386
|
+
return (i * j % 2 + i * j % 3) % 2 === 0;
|
|
387
387
|
case QRMaskPattern.PATTERN111:
|
|
388
|
-
return (i *
|
|
388
|
+
return (i * j % 3 + (i + j) % 2) % 2 === 0;
|
|
389
389
|
default:
|
|
390
390
|
throw new Error("bad maskPattern:" + maskPattern);
|
|
391
391
|
}
|
|
392
392
|
},
|
|
393
393
|
getErrorCorrectPolynomial: function(errorCorrectLength) {
|
|
394
|
-
var
|
|
394
|
+
var a = new QRPolynomial([1], 0);
|
|
395
395
|
for (var i = 0;i < errorCorrectLength; i++) {
|
|
396
|
-
|
|
396
|
+
a = a.multiply(new QRPolynomial([1, QRMath.gexp(i)], 0));
|
|
397
397
|
}
|
|
398
|
-
return
|
|
398
|
+
return a;
|
|
399
399
|
},
|
|
400
400
|
getLengthInBits: function(mode, type) {
|
|
401
401
|
if (1 <= type && type < 10) {
|
|
@@ -450,18 +450,18 @@ var require_QRUtil = __commonJS((exports, module) => {
|
|
|
450
450
|
for (col = 0;col < moduleCount; col++) {
|
|
451
451
|
var sameCount = 0;
|
|
452
452
|
var dark = qrCode.isDark(row, col);
|
|
453
|
-
for (var
|
|
454
|
-
if (row +
|
|
453
|
+
for (var r = -1;r <= 1; r++) {
|
|
454
|
+
if (row + r < 0 || moduleCount <= row + r) {
|
|
455
455
|
continue;
|
|
456
456
|
}
|
|
457
457
|
for (var c = -1;c <= 1; c++) {
|
|
458
458
|
if (col + c < 0 || moduleCount <= col + c) {
|
|
459
459
|
continue;
|
|
460
460
|
}
|
|
461
|
-
if (
|
|
461
|
+
if (r === 0 && c === 0) {
|
|
462
462
|
continue;
|
|
463
463
|
}
|
|
464
|
-
if (dark === qrCode.isDark(row +
|
|
464
|
+
if (dark === qrCode.isDark(row + r, col + c)) {
|
|
465
465
|
sameCount++;
|
|
466
466
|
}
|
|
467
467
|
}
|
|
@@ -518,7 +518,7 @@ var require_QRUtil = __commonJS((exports, module) => {
|
|
|
518
518
|
});
|
|
519
519
|
|
|
520
520
|
// ../../node_modules/.bun/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRErrorCorrectLevel.js
|
|
521
|
-
var require_QRErrorCorrectLevel = __commonJS((exports, module)
|
|
521
|
+
var require_QRErrorCorrectLevel = __commonJS(function(exports, module) {
|
|
522
522
|
module.exports = {
|
|
523
523
|
L: 1,
|
|
524
524
|
M: 0,
|
|
@@ -528,7 +528,7 @@ var require_QRErrorCorrectLevel = __commonJS((exports, module) => {
|
|
|
528
528
|
});
|
|
529
529
|
|
|
530
530
|
// ../../node_modules/.bun/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRRSBlock.js
|
|
531
|
-
var require_QRRSBlock = __commonJS((exports, module)
|
|
531
|
+
var require_QRRSBlock = __commonJS(function(exports, module) {
|
|
532
532
|
var QRErrorCorrectLevel = require_QRErrorCorrectLevel();
|
|
533
533
|
function QRRSBlock(totalCount, dataCount) {
|
|
534
534
|
this.totalCount = totalCount;
|
|
@@ -707,7 +707,7 @@ var require_QRRSBlock = __commonJS((exports, module) => {
|
|
|
707
707
|
var count = rsBlock[i * 3 + 0];
|
|
708
708
|
var totalCount = rsBlock[i * 3 + 1];
|
|
709
709
|
var dataCount = rsBlock[i * 3 + 2];
|
|
710
|
-
for (var
|
|
710
|
+
for (var j = 0;j < count; j++) {
|
|
711
711
|
list.push(new QRRSBlock(totalCount, dataCount));
|
|
712
712
|
}
|
|
713
713
|
}
|
|
@@ -731,7 +731,7 @@ var require_QRRSBlock = __commonJS((exports, module) => {
|
|
|
731
731
|
});
|
|
732
732
|
|
|
733
733
|
// ../../node_modules/.bun/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/QRBitBuffer.js
|
|
734
|
-
var require_QRBitBuffer = __commonJS((exports, module)
|
|
734
|
+
var require_QRBitBuffer = __commonJS(function(exports, module) {
|
|
735
735
|
function QRBitBuffer() {
|
|
736
736
|
this.buffer = [];
|
|
737
737
|
this.length = 0;
|
|
@@ -764,7 +764,7 @@ var require_QRBitBuffer = __commonJS((exports, module) => {
|
|
|
764
764
|
});
|
|
765
765
|
|
|
766
766
|
// ../../node_modules/.bun/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/vendor/QRCode/index.js
|
|
767
|
-
var require_QRCode = __commonJS((exports, module)
|
|
767
|
+
var require_QRCode = __commonJS(function(exports, module) {
|
|
768
768
|
var QR8bitByte = require_QR8bitByte();
|
|
769
769
|
var QRUtil = require_QRUtil();
|
|
770
770
|
var QRPolynomial = require_QRPolynomial();
|
|
@@ -803,8 +803,8 @@ var require_QRCode = __commonJS((exports, module) => {
|
|
|
803
803
|
for (var i = 0;i < rsBlocks.length; i++) {
|
|
804
804
|
totalDataCount += rsBlocks[i].dataCount;
|
|
805
805
|
}
|
|
806
|
-
for (var
|
|
807
|
-
var data = this.dataList[
|
|
806
|
+
for (var x = 0;x < this.dataList.length; x++) {
|
|
807
|
+
var data = this.dataList[x];
|
|
808
808
|
buffer.put(data.mode, 4);
|
|
809
809
|
buffer.put(data.getLength(), QRUtil.getLengthInBits(data.mode, typeNumber));
|
|
810
810
|
data.write(buffer);
|
|
@@ -840,16 +840,16 @@ var require_QRCode = __commonJS((exports, module) => {
|
|
|
840
840
|
this.mapData(this.dataCache, maskPattern);
|
|
841
841
|
},
|
|
842
842
|
setupPositionProbePattern: function(row, col) {
|
|
843
|
-
for (var
|
|
844
|
-
if (row +
|
|
843
|
+
for (var r = -1;r <= 7; r++) {
|
|
844
|
+
if (row + r <= -1 || this.moduleCount <= row + r)
|
|
845
845
|
continue;
|
|
846
846
|
for (var c = -1;c <= 7; c++) {
|
|
847
847
|
if (col + c <= -1 || this.moduleCount <= col + c)
|
|
848
848
|
continue;
|
|
849
|
-
if (0 <=
|
|
850
|
-
this.modules[row +
|
|
849
|
+
if (0 <= r && r <= 6 && (c === 0 || c === 6) || 0 <= c && c <= 6 && (r === 0 || r === 6) || 2 <= r && r <= 4 && 2 <= c && c <= 4) {
|
|
850
|
+
this.modules[row + r][col + c] = true;
|
|
851
851
|
} else {
|
|
852
|
-
this.modules[row +
|
|
852
|
+
this.modules[row + r][col + c] = false;
|
|
853
853
|
}
|
|
854
854
|
}
|
|
855
855
|
}
|
|
@@ -872,16 +872,16 @@ var require_QRCode = __commonJS((exports, module) => {
|
|
|
872
872
|
var cs = 1;
|
|
873
873
|
this.make();
|
|
874
874
|
for (var row = 0;row < this.modules.length; row++) {
|
|
875
|
-
var
|
|
875
|
+
var y = row * cs;
|
|
876
876
|
for (var col = 0;col < this.modules[row].length; col++) {
|
|
877
|
-
var
|
|
877
|
+
var x = col * cs;
|
|
878
878
|
var dark = this.modules[row][col];
|
|
879
879
|
if (dark) {
|
|
880
880
|
qr_mc.beginFill(0, 100);
|
|
881
|
-
qr_mc.moveTo(
|
|
882
|
-
qr_mc.lineTo(
|
|
883
|
-
qr_mc.lineTo(
|
|
884
|
-
qr_mc.lineTo(
|
|
881
|
+
qr_mc.moveTo(x, y);
|
|
882
|
+
qr_mc.lineTo(x + cs, y);
|
|
883
|
+
qr_mc.lineTo(x + cs, y + cs);
|
|
884
|
+
qr_mc.lineTo(x, y + cs);
|
|
885
885
|
qr_mc.endFill();
|
|
886
886
|
}
|
|
887
887
|
}
|
|
@@ -889,11 +889,11 @@ var require_QRCode = __commonJS((exports, module) => {
|
|
|
889
889
|
return qr_mc;
|
|
890
890
|
},
|
|
891
891
|
setupTimingPattern: function() {
|
|
892
|
-
for (var
|
|
893
|
-
if (this.modules[
|
|
892
|
+
for (var r = 8;r < this.moduleCount - 8; r++) {
|
|
893
|
+
if (this.modules[r][6] !== null) {
|
|
894
894
|
continue;
|
|
895
895
|
}
|
|
896
|
-
this.modules[
|
|
896
|
+
this.modules[r][6] = r % 2 === 0;
|
|
897
897
|
}
|
|
898
898
|
for (var c = 8;c < this.moduleCount - 8; c++) {
|
|
899
899
|
if (this.modules[6][c] !== null) {
|
|
@@ -905,18 +905,18 @@ var require_QRCode = __commonJS((exports, module) => {
|
|
|
905
905
|
setupPositionAdjustPattern: function() {
|
|
906
906
|
var pos = QRUtil.getPatternPosition(this.typeNumber);
|
|
907
907
|
for (var i = 0;i < pos.length; i++) {
|
|
908
|
-
for (var
|
|
908
|
+
for (var j = 0;j < pos.length; j++) {
|
|
909
909
|
var row = pos[i];
|
|
910
|
-
var col = pos[
|
|
910
|
+
var col = pos[j];
|
|
911
911
|
if (this.modules[row][col] !== null) {
|
|
912
912
|
continue;
|
|
913
913
|
}
|
|
914
|
-
for (var
|
|
914
|
+
for (var r = -2;r <= 2; r++) {
|
|
915
915
|
for (var c = -2;c <= 2; c++) {
|
|
916
|
-
if (Math.abs(
|
|
917
|
-
this.modules[row +
|
|
916
|
+
if (Math.abs(r) === 2 || Math.abs(c) === 2 || r === 0 && c === 0) {
|
|
917
|
+
this.modules[row + r][col + c] = true;
|
|
918
918
|
} else {
|
|
919
|
-
this.modules[row +
|
|
919
|
+
this.modules[row + r][col + c] = false;
|
|
920
920
|
}
|
|
921
921
|
}
|
|
922
922
|
}
|
|
@@ -930,33 +930,33 @@ var require_QRCode = __commonJS((exports, module) => {
|
|
|
930
930
|
mod = !test && (bits >> i & 1) === 1;
|
|
931
931
|
this.modules[Math.floor(i / 3)][i % 3 + this.moduleCount - 8 - 3] = mod;
|
|
932
932
|
}
|
|
933
|
-
for (var
|
|
934
|
-
mod = !test && (bits >>
|
|
935
|
-
this.modules[
|
|
933
|
+
for (var x = 0;x < 18; x++) {
|
|
934
|
+
mod = !test && (bits >> x & 1) === 1;
|
|
935
|
+
this.modules[x % 3 + this.moduleCount - 8 - 3][Math.floor(x / 3)] = mod;
|
|
936
936
|
}
|
|
937
937
|
},
|
|
938
938
|
setupTypeInfo: function(test, maskPattern) {
|
|
939
939
|
var data = this.errorCorrectLevel << 3 | maskPattern;
|
|
940
940
|
var bits = QRUtil.getBCHTypeInfo(data);
|
|
941
941
|
var mod;
|
|
942
|
-
for (var
|
|
943
|
-
mod = !test && (bits >>
|
|
944
|
-
if (
|
|
945
|
-
this.modules[
|
|
946
|
-
} else if (
|
|
947
|
-
this.modules[
|
|
942
|
+
for (var v = 0;v < 15; v++) {
|
|
943
|
+
mod = !test && (bits >> v & 1) === 1;
|
|
944
|
+
if (v < 6) {
|
|
945
|
+
this.modules[v][8] = mod;
|
|
946
|
+
} else if (v < 8) {
|
|
947
|
+
this.modules[v + 1][8] = mod;
|
|
948
948
|
} else {
|
|
949
|
-
this.modules[this.moduleCount - 15 +
|
|
949
|
+
this.modules[this.moduleCount - 15 + v][8] = mod;
|
|
950
950
|
}
|
|
951
951
|
}
|
|
952
|
-
for (var
|
|
953
|
-
mod = !test && (bits >>
|
|
954
|
-
if (
|
|
955
|
-
this.modules[8][this.moduleCount -
|
|
956
|
-
} else if (
|
|
957
|
-
this.modules[8][15 -
|
|
952
|
+
for (var h = 0;h < 15; h++) {
|
|
953
|
+
mod = !test && (bits >> h & 1) === 1;
|
|
954
|
+
if (h < 8) {
|
|
955
|
+
this.modules[8][this.moduleCount - h - 1] = mod;
|
|
956
|
+
} else if (h < 9) {
|
|
957
|
+
this.modules[8][15 - h - 1 + 1] = mod;
|
|
958
958
|
} else {
|
|
959
|
-
this.modules[8][15 -
|
|
959
|
+
this.modules[8][15 - h - 1] = mod;
|
|
960
960
|
}
|
|
961
961
|
}
|
|
962
962
|
this.modules[this.moduleCount - 8][8] = !test;
|
|
@@ -1010,8 +1010,8 @@ var require_QRCode = __commonJS((exports, module) => {
|
|
|
1010
1010
|
data.write(buffer);
|
|
1011
1011
|
}
|
|
1012
1012
|
var totalDataCount = 0;
|
|
1013
|
-
for (var
|
|
1014
|
-
totalDataCount += rsBlocks[
|
|
1013
|
+
for (var x = 0;x < rsBlocks.length; x++) {
|
|
1014
|
+
totalDataCount += rsBlocks[x].dataCount;
|
|
1015
1015
|
}
|
|
1016
1016
|
if (buffer.getLengthInBits() > totalDataCount * 8) {
|
|
1017
1017
|
throw new Error("code length overflow. (" + buffer.getLengthInBits() + ">" + totalDataCount * 8 + ")");
|
|
@@ -1040,35 +1040,35 @@ var require_QRCode = __commonJS((exports, module) => {
|
|
|
1040
1040
|
var maxEcCount = 0;
|
|
1041
1041
|
var dcdata = new Array(rsBlocks.length);
|
|
1042
1042
|
var ecdata = new Array(rsBlocks.length);
|
|
1043
|
-
for (var
|
|
1044
|
-
var dcCount = rsBlocks[
|
|
1045
|
-
var ecCount = rsBlocks[
|
|
1043
|
+
for (var r = 0;r < rsBlocks.length; r++) {
|
|
1044
|
+
var dcCount = rsBlocks[r].dataCount;
|
|
1045
|
+
var ecCount = rsBlocks[r].totalCount - dcCount;
|
|
1046
1046
|
maxDcCount = Math.max(maxDcCount, dcCount);
|
|
1047
1047
|
maxEcCount = Math.max(maxEcCount, ecCount);
|
|
1048
|
-
dcdata[
|
|
1049
|
-
for (var i = 0;i < dcdata[
|
|
1050
|
-
dcdata[
|
|
1048
|
+
dcdata[r] = new Array(dcCount);
|
|
1049
|
+
for (var i = 0;i < dcdata[r].length; i++) {
|
|
1050
|
+
dcdata[r][i] = 255 & buffer.buffer[i + offset];
|
|
1051
1051
|
}
|
|
1052
1052
|
offset += dcCount;
|
|
1053
1053
|
var rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount);
|
|
1054
|
-
var rawPoly = new QRPolynomial(dcdata[
|
|
1054
|
+
var rawPoly = new QRPolynomial(dcdata[r], rsPoly.getLength() - 1);
|
|
1055
1055
|
var modPoly = rawPoly.mod(rsPoly);
|
|
1056
|
-
ecdata[
|
|
1057
|
-
for (var
|
|
1058
|
-
var modIndex =
|
|
1059
|
-
ecdata[
|
|
1056
|
+
ecdata[r] = new Array(rsPoly.getLength() - 1);
|
|
1057
|
+
for (var x = 0;x < ecdata[r].length; x++) {
|
|
1058
|
+
var modIndex = x + modPoly.getLength() - ecdata[r].length;
|
|
1059
|
+
ecdata[r][x] = modIndex >= 0 ? modPoly.get(modIndex) : 0;
|
|
1060
1060
|
}
|
|
1061
1061
|
}
|
|
1062
1062
|
var totalCodeCount = 0;
|
|
1063
|
-
for (var
|
|
1064
|
-
totalCodeCount += rsBlocks[
|
|
1063
|
+
for (var y = 0;y < rsBlocks.length; y++) {
|
|
1064
|
+
totalCodeCount += rsBlocks[y].totalCount;
|
|
1065
1065
|
}
|
|
1066
1066
|
var data = new Array(totalCodeCount);
|
|
1067
1067
|
var index = 0;
|
|
1068
|
-
for (var
|
|
1068
|
+
for (var z = 0;z < maxDcCount; z++) {
|
|
1069
1069
|
for (var s = 0;s < rsBlocks.length; s++) {
|
|
1070
|
-
if (
|
|
1071
|
-
data[index++] = dcdata[s][
|
|
1070
|
+
if (z < dcdata[s].length) {
|
|
1071
|
+
data[index++] = dcdata[s][z];
|
|
1072
1072
|
}
|
|
1073
1073
|
}
|
|
1074
1074
|
}
|
|
@@ -1085,7 +1085,7 @@ var require_QRCode = __commonJS((exports, module) => {
|
|
|
1085
1085
|
});
|
|
1086
1086
|
|
|
1087
1087
|
// ../../node_modules/.bun/qrcode-terminal@0.12.0/node_modules/qrcode-terminal/lib/main.js
|
|
1088
|
-
var require_main = __commonJS((exports, module)
|
|
1088
|
+
var require_main = __commonJS(function(exports, module) {
|
|
1089
1089
|
var QRCode = require_QRCode();
|
|
1090
1090
|
var QRErrorCorrectLevel = require_QRErrorCorrectLevel();
|
|
1091
1091
|
var black = "\x1B[40m \x1B[0m";
|
|
@@ -1159,9 +1159,9 @@ var require_main = __commonJS((exports, module) => {
|
|
|
1159
1159
|
var border = repeat(white).times(qrcode.getModuleCount() + 3);
|
|
1160
1160
|
output += border + `
|
|
1161
1161
|
`;
|
|
1162
|
-
qrcode.modules.forEach(function(
|
|
1162
|
+
qrcode.modules.forEach(function(row) {
|
|
1163
1163
|
output += white;
|
|
1164
|
-
output +=
|
|
1164
|
+
output += row.map(toCell).join("");
|
|
1165
1165
|
output += white + `
|
|
1166
1166
|
`;
|
|
1167
1167
|
});
|
|
@@ -1636,13 +1636,13 @@ var y2 = (s) => {
|
|
|
1636
1636
|
}
|
|
1637
1637
|
};
|
|
1638
1638
|
var E = (s) => {
|
|
1639
|
-
const { cursor: n, options: t, style: i } = s,
|
|
1640
|
-
let
|
|
1641
|
-
n >=
|
|
1642
|
-
const
|
|
1643
|
-
return t.slice(
|
|
1644
|
-
const
|
|
1645
|
-
return
|
|
1639
|
+
const { cursor: n, options: t, style: i } = s, r = s.maxItems ?? 1 / 0, o = Math.max(process.stdout.rows - 4, 0), c = Math.min(o, Math.max(r, 5));
|
|
1640
|
+
let l = 0;
|
|
1641
|
+
n >= l + c - 3 ? l = Math.max(Math.min(n - c + 3, t.length - c), 0) : n < l + 2 && (l = Math.max(n - 2, 0));
|
|
1642
|
+
const d = c < t.length && l > 0, p = c < t.length && l + c < t.length;
|
|
1643
|
+
return t.slice(l, l + c).map((S, f, x) => {
|
|
1644
|
+
const g = f === 0 && d, m = f === x.length - 1 && p;
|
|
1645
|
+
return g || m ? import_picocolors.default.dim("...") : i(S, f + l === n);
|
|
1646
1646
|
});
|
|
1647
1647
|
};
|
|
1648
1648
|
var ce = (s) => {
|
|
@@ -1650,12 +1650,12 @@ var ce = (s) => {
|
|
|
1650
1650
|
return new BD({ active: n, inactive: t, initialValue: s.initialValue ?? true, render() {
|
|
1651
1651
|
const i = `${import_picocolors.default.gray(a2)}
|
|
1652
1652
|
${y2(this.state)} ${s.message}
|
|
1653
|
-
`,
|
|
1653
|
+
`, r = this.value ? n : t;
|
|
1654
1654
|
switch (this.state) {
|
|
1655
1655
|
case "submit":
|
|
1656
|
-
return `${i}${import_picocolors.default.gray(a2)} ${import_picocolors.default.dim(
|
|
1656
|
+
return `${i}${import_picocolors.default.gray(a2)} ${import_picocolors.default.dim(r)}`;
|
|
1657
1657
|
case "cancel":
|
|
1658
|
-
return `${i}${import_picocolors.default.gray(a2)} ${import_picocolors.default.strikethrough(import_picocolors.default.dim(
|
|
1658
|
+
return `${i}${import_picocolors.default.gray(a2)} ${import_picocolors.default.strikethrough(import_picocolors.default.dim(r))}
|
|
1659
1659
|
${import_picocolors.default.gray(a2)}`;
|
|
1660
1660
|
default:
|
|
1661
1661
|
return `${i}${import_picocolors.default.cyan(a2)} ${this.value ? `${import_picocolors.default.green(I2)} ${n}` : `${import_picocolors.default.dim(T2)} ${import_picocolors.default.dim(n)}`} ${import_picocolors.default.dim("/")} ${this.value ? `${import_picocolors.default.dim(T2)} ${import_picocolors.default.dim(t)}` : `${import_picocolors.default.green(I2)} ${t}`}
|
|
@@ -1666,16 +1666,16 @@ ${import_picocolors.default.cyan($2)}
|
|
|
1666
1666
|
};
|
|
1667
1667
|
var le = (s) => {
|
|
1668
1668
|
const n = (t, i) => {
|
|
1669
|
-
const
|
|
1669
|
+
const r = t.label ?? String(t.value);
|
|
1670
1670
|
switch (i) {
|
|
1671
1671
|
case "selected":
|
|
1672
|
-
return `${import_picocolors.default.dim(
|
|
1672
|
+
return `${import_picocolors.default.dim(r)}`;
|
|
1673
1673
|
case "active":
|
|
1674
|
-
return `${import_picocolors.default.green(I2)} ${
|
|
1674
|
+
return `${import_picocolors.default.green(I2)} ${r} ${t.hint ? import_picocolors.default.dim(`(${t.hint})`) : ""}`;
|
|
1675
1675
|
case "cancelled":
|
|
1676
|
-
return `${import_picocolors.default.strikethrough(import_picocolors.default.dim(
|
|
1676
|
+
return `${import_picocolors.default.strikethrough(import_picocolors.default.dim(r))}`;
|
|
1677
1677
|
default:
|
|
1678
|
-
return `${import_picocolors.default.dim(T2)} ${import_picocolors.default.dim(
|
|
1678
|
+
return `${import_picocolors.default.dim(T2)} ${import_picocolors.default.dim(r)}`;
|
|
1679
1679
|
}
|
|
1680
1680
|
};
|
|
1681
1681
|
return new $D({ options: s.options, initialValue: s.initialValue, render() {
|
|
@@ -1689,7 +1689,7 @@ ${y2(this.state)} ${s.message}
|
|
|
1689
1689
|
return `${t}${import_picocolors.default.gray(a2)} ${n(this.options[this.cursor], "cancelled")}
|
|
1690
1690
|
${import_picocolors.default.gray(a2)}`;
|
|
1691
1691
|
default:
|
|
1692
|
-
return `${t}${import_picocolors.default.cyan(a2)} ${E({ cursor: this.cursor, options: this.options, maxItems: s.maxItems, style: (i,
|
|
1692
|
+
return `${t}${import_picocolors.default.cyan(a2)} ${E({ cursor: this.cursor, options: this.options, maxItems: s.maxItems, style: (i, r) => n(i, r ? "active" : "inactive") }).join(`
|
|
1693
1693
|
${import_picocolors.default.cyan(a2)} `)}
|
|
1694
1694
|
${import_picocolors.default.cyan($2)}
|
|
1695
1695
|
`;
|
|
@@ -1698,8 +1698,8 @@ ${import_picocolors.default.cyan($2)}
|
|
|
1698
1698
|
};
|
|
1699
1699
|
var $e = (s) => {
|
|
1700
1700
|
const n = (t, i) => {
|
|
1701
|
-
const
|
|
1702
|
-
return i === "active" ? `${import_picocolors.default.cyan(j2)} ${
|
|
1701
|
+
const r = t.label ?? String(t.value);
|
|
1702
|
+
return i === "active" ? `${import_picocolors.default.cyan(j2)} ${r} ${t.hint ? import_picocolors.default.dim(`(${t.hint})`) : ""}` : i === "selected" ? `${import_picocolors.default.green(b2)} ${import_picocolors.default.dim(r)}` : i === "cancelled" ? `${import_picocolors.default.strikethrough(import_picocolors.default.dim(r))}` : i === "active-selected" ? `${import_picocolors.default.green(b2)} ${r} ${t.hint ? import_picocolors.default.dim(`(${t.hint})`) : ""}` : i === "submitted" ? `${import_picocolors.default.dim(r)}` : `${import_picocolors.default.dim(B)} ${import_picocolors.default.dim(r)}`;
|
|
1703
1703
|
};
|
|
1704
1704
|
return new vD({ options: s.options, initialValues: s.initialValues, required: s.required ?? true, cursorAt: s.cursorAt, validate(t) {
|
|
1705
1705
|
if (this.required && t.length === 0)
|
|
@@ -1709,25 +1709,25 @@ ${import_picocolors.default.reset(import_picocolors.default.dim(`Press ${import_
|
|
|
1709
1709
|
let t = `${import_picocolors.default.gray(a2)}
|
|
1710
1710
|
${y2(this.state)} ${s.message}
|
|
1711
1711
|
`;
|
|
1712
|
-
const i = (
|
|
1713
|
-
const c = this.value.includes(
|
|
1714
|
-
return o && c ? n(
|
|
1712
|
+
const i = (r, o) => {
|
|
1713
|
+
const c = this.value.includes(r.value);
|
|
1714
|
+
return o && c ? n(r, "active-selected") : c ? n(r, "selected") : n(r, o ? "active" : "inactive");
|
|
1715
1715
|
};
|
|
1716
1716
|
switch (this.state) {
|
|
1717
1717
|
case "submit":
|
|
1718
|
-
return `${t}${import_picocolors.default.gray(a2)} ${this.options.filter(({ value:
|
|
1718
|
+
return `${t}${import_picocolors.default.gray(a2)} ${this.options.filter(({ value: r }) => this.value.includes(r)).map((r) => n(r, "submitted")).join(import_picocolors.default.dim(", ")) || import_picocolors.default.dim("none")}`;
|
|
1719
1719
|
case "cancel": {
|
|
1720
|
-
const
|
|
1721
|
-
return `${t}${import_picocolors.default.gray(a2)} ${
|
|
1720
|
+
const r = this.options.filter(({ value: o }) => this.value.includes(o)).map((o) => n(o, "cancelled")).join(import_picocolors.default.dim(", "));
|
|
1721
|
+
return `${t}${import_picocolors.default.gray(a2)} ${r.trim() ? `${r}
|
|
1722
1722
|
${import_picocolors.default.gray(a2)}` : ""}`;
|
|
1723
1723
|
}
|
|
1724
1724
|
case "error": {
|
|
1725
|
-
const
|
|
1725
|
+
const r = this.error.split(`
|
|
1726
1726
|
`).map((o, c) => c === 0 ? `${import_picocolors.default.yellow($2)} ${import_picocolors.default.yellow(o)}` : ` ${o}`).join(`
|
|
1727
1727
|
`);
|
|
1728
1728
|
return t + import_picocolors.default.yellow(a2) + " " + E({ options: this.options, cursor: this.cursor, maxItems: s.maxItems, style: i }).join(`
|
|
1729
1729
|
${import_picocolors.default.yellow(a2)} `) + `
|
|
1730
|
-
` +
|
|
1730
|
+
` + r + `
|
|
1731
1731
|
`;
|
|
1732
1732
|
}
|
|
1733
1733
|
default:
|
|
@@ -1743,12 +1743,12 @@ var me = (s = "", n = "") => {
|
|
|
1743
1743
|
const t = `
|
|
1744
1744
|
${s}
|
|
1745
1745
|
`.split(`
|
|
1746
|
-
`), i = R2(n).length,
|
|
1746
|
+
`), i = R2(n).length, r = Math.max(t.reduce((c, l) => (l = R2(l), l.length > c ? l.length : c), 0), i) + 2, o = t.map((c) => `${import_picocolors.default.gray(a2)} ${import_picocolors.default.dim(c)}${" ".repeat(r - R2(c).length)}${import_picocolors.default.gray(a2)}`).join(`
|
|
1747
1747
|
`);
|
|
1748
1748
|
process.stdout.write(`${import_picocolors.default.gray(a2)}
|
|
1749
|
-
${import_picocolors.default.green(M2)} ${import_picocolors.default.reset(n)} ${import_picocolors.default.gray(G.repeat(Math.max(
|
|
1749
|
+
${import_picocolors.default.green(M2)} ${import_picocolors.default.reset(n)} ${import_picocolors.default.gray(G.repeat(Math.max(r - i - 1, 1)) + H)}
|
|
1750
1750
|
${o}
|
|
1751
|
-
${import_picocolors.default.gray(ee + G.repeat(
|
|
1751
|
+
${import_picocolors.default.gray(ee + G.repeat(r + 2) + te)}
|
|
1752
1752
|
`);
|
|
1753
1753
|
};
|
|
1754
1754
|
var he = (s = "") => {
|
|
@@ -1769,9 +1769,9 @@ ${import_picocolors.default.gray($2)} ${s}
|
|
|
1769
1769
|
var v2 = { message: (s = "", { symbol: n = import_picocolors.default.gray(a2) } = {}) => {
|
|
1770
1770
|
const t = [`${import_picocolors.default.gray(a2)}`];
|
|
1771
1771
|
if (s) {
|
|
1772
|
-
const [i, ...
|
|
1772
|
+
const [i, ...r] = s.split(`
|
|
1773
1773
|
`);
|
|
1774
|
-
t.push(`${n} ${i}`, ...
|
|
1774
|
+
t.push(`${n} ${i}`, ...r.map((o) => `${import_picocolors.default.gray(a2)} ${o}`));
|
|
1775
1775
|
}
|
|
1776
1776
|
process.stdout.write(`${t.join(`
|
|
1777
1777
|
`)}
|
|
@@ -1791,30 +1791,30 @@ var v2 = { message: (s = "", { symbol: n = import_picocolors.default.gray(a2) }
|
|
|
1791
1791
|
} };
|
|
1792
1792
|
var _2 = () => {
|
|
1793
1793
|
const s = C ? ["◒", "◐", "◓", "◑"] : ["•", "o", "O", "0"], n = C ? 80 : 120;
|
|
1794
|
-
let t, i,
|
|
1795
|
-
const c = (
|
|
1796
|
-
const
|
|
1797
|
-
|
|
1798
|
-
},
|
|
1799
|
-
process.on("uncaughtExceptionMonitor",
|
|
1800
|
-
},
|
|
1801
|
-
process.removeListener("uncaughtExceptionMonitor",
|
|
1802
|
-
},
|
|
1803
|
-
|
|
1794
|
+
let t, i, r = false, o = "";
|
|
1795
|
+
const c = (g) => {
|
|
1796
|
+
const m = g > 1 ? "Something went wrong" : "Canceled";
|
|
1797
|
+
r && x(m, g);
|
|
1798
|
+
}, l = () => c(2), d = () => c(1), p = () => {
|
|
1799
|
+
process.on("uncaughtExceptionMonitor", l), process.on("unhandledRejection", l), process.on("SIGINT", d), process.on("SIGTERM", d), process.on("exit", c);
|
|
1800
|
+
}, S = () => {
|
|
1801
|
+
process.removeListener("uncaughtExceptionMonitor", l), process.removeListener("unhandledRejection", l), process.removeListener("SIGINT", d), process.removeListener("SIGTERM", d), process.removeListener("exit", c);
|
|
1802
|
+
}, f = (g = "") => {
|
|
1803
|
+
r = true, t = OD(), o = g.replace(/\.+$/, ""), process.stdout.write(`${import_picocolors.default.gray(a2)}
|
|
1804
1804
|
`);
|
|
1805
|
-
let
|
|
1805
|
+
let m = 0, w = 0;
|
|
1806
1806
|
p(), i = setInterval(() => {
|
|
1807
|
-
const
|
|
1808
|
-
process.stdout.write(import_sisteransi2.cursor.move(-999, 0)), process.stdout.write(import_sisteransi2.erase.down(1)), process.stdout.write(`${
|
|
1807
|
+
const L = import_picocolors.default.magenta(s[m]), O = ".".repeat(Math.floor(w)).slice(0, 3);
|
|
1808
|
+
process.stdout.write(import_sisteransi2.cursor.move(-999, 0)), process.stdout.write(import_sisteransi2.erase.down(1)), process.stdout.write(`${L} ${o}${O}`), m = m + 1 < s.length ? m + 1 : 0, w = w < s.length ? w + 0.125 : 0;
|
|
1809
1809
|
}, n);
|
|
1810
|
-
},
|
|
1811
|
-
o =
|
|
1812
|
-
const
|
|
1813
|
-
process.stdout.write(import_sisteransi2.cursor.move(-999, 0)), process.stdout.write(import_sisteransi2.erase.down(1)), process.stdout.write(`${
|
|
1814
|
-
`),
|
|
1810
|
+
}, x = (g = "", m = 0) => {
|
|
1811
|
+
o = g ?? o, r = false, clearInterval(i);
|
|
1812
|
+
const w = m === 0 ? import_picocolors.default.green(M2) : m === 1 ? import_picocolors.default.red(P2) : import_picocolors.default.red(V2);
|
|
1813
|
+
process.stdout.write(import_sisteransi2.cursor.move(-999, 0)), process.stdout.write(import_sisteransi2.erase.down(1)), process.stdout.write(`${w} ${o}
|
|
1814
|
+
`), S(), t();
|
|
1815
1815
|
};
|
|
1816
|
-
return { start:
|
|
1817
|
-
o =
|
|
1816
|
+
return { start: f, stop: x, message: (g = "") => {
|
|
1817
|
+
o = g ?? o;
|
|
1818
1818
|
} };
|
|
1819
1819
|
};
|
|
1820
1820
|
function ye() {
|
|
@@ -1822,6 +1822,90 @@ function ye() {
|
|
|
1822
1822
|
return new RegExp(s, "g");
|
|
1823
1823
|
}
|
|
1824
1824
|
|
|
1825
|
+
// src/cursor-hook-config.ts
|
|
1826
|
+
function cursorHookEntry(name, command, isApproval = false) {
|
|
1827
|
+
if (name === "stop" || name === "subagentStop")
|
|
1828
|
+
return { command, timeout: 600, loop_limit: 10 };
|
|
1829
|
+
if (isApproval)
|
|
1830
|
+
return { command, timeout: 300 };
|
|
1831
|
+
if (name === "sessionEnd")
|
|
1832
|
+
return { command, timeout: 10 };
|
|
1833
|
+
return { command };
|
|
1834
|
+
}
|
|
1835
|
+
function upsertCursorHook(existing, entry) {
|
|
1836
|
+
const entries = (Array.isArray(existing) ? existing : existing ? [existing] : []).map((value) => typeof value === "string" ? { command: value } : value);
|
|
1837
|
+
const index = entries.findIndex((value) => value && typeof value === "object" && ("command" in value) && typeof value.command === "string" && value.command.includes("agentapprove"));
|
|
1838
|
+
if (index < 0)
|
|
1839
|
+
entries.push(entry);
|
|
1840
|
+
else
|
|
1841
|
+
entries[index] = entry;
|
|
1842
|
+
return entries;
|
|
1843
|
+
}
|
|
1844
|
+
|
|
1845
|
+
// src/openclaw-install.ts
|
|
1846
|
+
import { spawnSync } from "node:child_process";
|
|
1847
|
+
var CONVERSATION_ACCESS_NOTICE = "OpenClaw setup includes access to prompts, responses, and completed conversations for monitoring and mobile follow-up. Your privacy and encryption settings still apply. OpenClaw will review any required plugin permissions during installation.";
|
|
1848
|
+
function runOpenClaw(args) {
|
|
1849
|
+
const result = spawnSync("openclaw", args, { stdio: "inherit", shell: process.platform === "win32" });
|
|
1850
|
+
return !result.error && result.status === 0;
|
|
1851
|
+
}
|
|
1852
|
+
function mergeOpenClawConfig(config, conversationAccess) {
|
|
1853
|
+
const plugins = config.plugins ?? {};
|
|
1854
|
+
const entries = plugins.entries ?? {};
|
|
1855
|
+
const entry = entries.openclaw ?? {};
|
|
1856
|
+
return {
|
|
1857
|
+
...config,
|
|
1858
|
+
plugins: {
|
|
1859
|
+
...plugins,
|
|
1860
|
+
entries: {
|
|
1861
|
+
...entries,
|
|
1862
|
+
openclaw: {
|
|
1863
|
+
...entry,
|
|
1864
|
+
hooks: { ...entry.hooks, allowConversationAccess: conversationAccess },
|
|
1865
|
+
config: { ...entry.config }
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
},
|
|
1869
|
+
hooks: { ...config.hooks, internal: { enabled: true, ...config.hooks?.internal } }
|
|
1870
|
+
};
|
|
1871
|
+
}
|
|
1872
|
+
async function installOpenClaw(options) {
|
|
1873
|
+
const run = options.run ?? runOpenClaw;
|
|
1874
|
+
const fail = (error) => ({ success: false, label: "Agent Approve plugin", error });
|
|
1875
|
+
try {
|
|
1876
|
+
options.readConfig();
|
|
1877
|
+
} catch {
|
|
1878
|
+
return fail("Could not read OpenClaw configuration as JSON. No plugin installation or permission changes were made. Check the config before retrying.");
|
|
1879
|
+
}
|
|
1880
|
+
const installed = options.readVersion();
|
|
1881
|
+
if (installed !== options.version) {
|
|
1882
|
+
const args = ["plugins", "install", options.spec];
|
|
1883
|
+
if (installed !== null) {
|
|
1884
|
+
if (!await options.confirmReplacement(`Replace Agent Approve ${installed} with ${options.spec}? This npm source is outside ClawHub review and trust metadata. Only continue if you trust this package. OpenClaw will separately review its capabilities.`)) {
|
|
1885
|
+
return fail("Plugin replacement declined; the existing install was kept.");
|
|
1886
|
+
}
|
|
1887
|
+
args.push("--force");
|
|
1888
|
+
}
|
|
1889
|
+
if (!run(args))
|
|
1890
|
+
return fail("OpenClaw installation was declined or failed. Review the host output above; no permissions were automatically accepted.");
|
|
1891
|
+
const actual = options.readVersion();
|
|
1892
|
+
if (actual !== options.version)
|
|
1893
|
+
return fail(`OpenClaw installed ${actual ?? "an unverified version"}, expected ${options.version}.`);
|
|
1894
|
+
}
|
|
1895
|
+
try {
|
|
1896
|
+
options.writeConfig(mergeOpenClawConfig(options.readConfig(), true));
|
|
1897
|
+
} catch {
|
|
1898
|
+
return fail("Could not read or save OpenClaw configuration. The plugin package is present; check the config and retry setup before using it.");
|
|
1899
|
+
}
|
|
1900
|
+
const action = options.mode === "approval" ? "enable" : "disable";
|
|
1901
|
+
if (!run(["plugins", action, "openclaw"]))
|
|
1902
|
+
return fail(`OpenClaw ${action} was declined or failed. Settings were saved; activation remains controlled by OpenClaw.`);
|
|
1903
|
+
return {
|
|
1904
|
+
success: true,
|
|
1905
|
+
label: `Agent Approve plugin v${options.version} (conversation access included)`
|
|
1906
|
+
};
|
|
1907
|
+
}
|
|
1908
|
+
|
|
1825
1909
|
// src/env-preserve.ts
|
|
1826
1910
|
var MANAGED_ENV_KEYS = new Set([
|
|
1827
1911
|
"AGENTAPPROVE_API",
|
|
@@ -1835,13 +1919,15 @@ var MANAGED_ENV_KEYS = new Set([
|
|
|
1835
1919
|
"AGENTAPPROVE_FAIL_BEHAVIOR"
|
|
1836
1920
|
]);
|
|
1837
1921
|
var ACCOUNT_SYNCED_UNMANAGED_KEYS = new Set([
|
|
1922
|
+
"AGENTAPPROVE_FILTER_BACKGROUND_ACTIVITY",
|
|
1923
|
+
"AGENTAPPROVE_BACKGROUND_FILTER_SYNC_PENDING",
|
|
1838
1924
|
"AGENTAPPROVE_QUESTION_INPUT_MODE",
|
|
1839
1925
|
"AGENTAPPROVE_TIMEOUT"
|
|
1840
1926
|
]);
|
|
1841
1927
|
var ENV_KEY_PATTERN = /^AGENTAPPROVE_[A-Z0-9_]+$/;
|
|
1842
1928
|
function isPreservedEnvKey(key) {
|
|
1843
|
-
const
|
|
1844
|
-
return ENV_KEY_PATTERN.test(
|
|
1929
|
+
const k = key.trim();
|
|
1930
|
+
return ENV_KEY_PATTERN.test(k) && !MANAGED_ENV_KEYS.has(k);
|
|
1845
1931
|
}
|
|
1846
1932
|
function renderPreservedEnvSection(preserved) {
|
|
1847
1933
|
if (!preserved)
|
|
@@ -1858,8 +1944,8 @@ ${lines.join(`
|
|
|
1858
1944
|
`;
|
|
1859
1945
|
}
|
|
1860
1946
|
function normalizeEmail(value) {
|
|
1861
|
-
const
|
|
1862
|
-
return
|
|
1947
|
+
const v = value?.trim().toLowerCase();
|
|
1948
|
+
return v ? v : undefined;
|
|
1863
1949
|
}
|
|
1864
1950
|
function resolvePreservation(input) {
|
|
1865
1951
|
const existing = input.existing ?? undefined;
|
|
@@ -1872,9 +1958,9 @@ function resolvePreservation(input) {
|
|
|
1872
1958
|
case "refresh":
|
|
1873
1959
|
case "repair":
|
|
1874
1960
|
case "pair": {
|
|
1875
|
-
const
|
|
1876
|
-
const
|
|
1877
|
-
if (
|
|
1961
|
+
const a = normalizeEmail(input.verifiedEmail);
|
|
1962
|
+
const b = normalizeEmail(input.pairedEmail);
|
|
1963
|
+
if (a && b && a === b) {
|
|
1878
1964
|
return { preserved: existing.preserved, letAccountWin: false };
|
|
1879
1965
|
}
|
|
1880
1966
|
return { preserved: machineLocalOnly(existing.preserved), letAccountWin: true };
|
|
@@ -2401,10 +2487,10 @@ var source_default = chalk;
|
|
|
2401
2487
|
|
|
2402
2488
|
// src/cli.ts
|
|
2403
2489
|
var import_qrcode_terminal = __toESM(require_main(), 1);
|
|
2404
|
-
import { existsSync as existsSync2, readFileSync, writeFileSync, mkdirSync, mkdtempSync, copyFileSync, renameSync, readdirSync as readdirSync2, statSync, lstatSync, realpathSync as realpathSync2, rmSync as rmSync2 } from "fs";
|
|
2490
|
+
import { existsSync as existsSync2, readFileSync, writeFileSync, mkdirSync, mkdtempSync, copyFileSync, renameSync as renameSync2, readdirSync as readdirSync2, statSync, lstatSync, realpathSync as realpathSync2, rmSync as rmSync2 } from "fs";
|
|
2405
2491
|
import { homedir, hostname, platform, tmpdir } from "os";
|
|
2406
2492
|
import { join, dirname as dirname2, sep as sep2 } from "path";
|
|
2407
|
-
import { execSync, spawnSync } from "child_process";
|
|
2493
|
+
import { execSync, spawnSync as spawnSync2 } from "child_process";
|
|
2408
2494
|
import { randomBytes, createHash } from "crypto";
|
|
2409
2495
|
|
|
2410
2496
|
// src/uninstall-utils.ts
|
|
@@ -2690,8 +2776,8 @@ function removeAgentApproveHookEntries(hooksConfig, hookNames) {
|
|
|
2690
2776
|
if (!hookEntry)
|
|
2691
2777
|
continue;
|
|
2692
2778
|
if (Array.isArray(hookEntry)) {
|
|
2693
|
-
const filtered = hookEntry.filter((
|
|
2694
|
-
const str = JSON.stringify(
|
|
2779
|
+
const filtered = hookEntry.filter((e) => {
|
|
2780
|
+
const str = JSON.stringify(e);
|
|
2695
2781
|
return !str.includes("agentapprove");
|
|
2696
2782
|
});
|
|
2697
2783
|
if (filtered.length !== hookEntry.length) {
|
|
@@ -2998,11 +3084,11 @@ async function validateExistingToken(token, apiUrl, apiVersion, options = {}) {
|
|
|
2998
3084
|
}
|
|
2999
3085
|
const status = response.status;
|
|
3000
3086
|
if (response.ok) {
|
|
3001
|
-
const
|
|
3087
|
+
const body = await safeReadText(response);
|
|
3002
3088
|
return {
|
|
3003
3089
|
kind: "valid",
|
|
3004
3090
|
summary: "verified - token is valid",
|
|
3005
|
-
cachedContent:
|
|
3091
|
+
cachedContent: body,
|
|
3006
3092
|
status
|
|
3007
3093
|
};
|
|
3008
3094
|
}
|
|
@@ -3068,6 +3154,8 @@ async function validateExistingToken(token, apiUrl, apiVersion, options = {}) {
|
|
|
3068
3154
|
function classifyHookDownloadFailure(status, body) {
|
|
3069
3155
|
const parsed = parseErrorBody(body);
|
|
3070
3156
|
const code = parsed?.code;
|
|
3157
|
+
if (status === 429)
|
|
3158
|
+
return "rate_limited";
|
|
3071
3159
|
if (status === 401 && code === "TOKEN_EXPIRED")
|
|
3072
3160
|
return "token_expired";
|
|
3073
3161
|
if (status === 401 && code === "INVALID_TOKEN")
|
|
@@ -3085,42 +3173,99 @@ function classifyHookDownloadFailure(status, body) {
|
|
|
3085
3173
|
|
|
3086
3174
|
// src/copy-hook-scripts.ts
|
|
3087
3175
|
import { writeFileSync as fsWriteFileSync } from "fs";
|
|
3176
|
+
import { renameSync } from "fs";
|
|
3177
|
+
import { randomUUID } from "crypto";
|
|
3178
|
+
|
|
3179
|
+
// src/background-filters.ts
|
|
3180
|
+
var BACKGROUND_FILTER_FILES = ["background-filter.js", "background-filters.json"];
|
|
3181
|
+
function validBackgroundFilters(content) {
|
|
3182
|
+
if (Buffer.byteLength(content) > 64 * 1024)
|
|
3183
|
+
return false;
|
|
3184
|
+
try {
|
|
3185
|
+
const c = JSON.parse(content);
|
|
3186
|
+
return c?.schemaVersion === 1 && typeof c.revision === "string" && c.revision.length <= 128 && Array.isArray(c.filters) && c.filters.length <= 100 && c.filters.every((f) => typeof f.id === "string" && /^[a-z0-9_-]{1,100}$/.test(f.id) && typeof f.agent === "string" && /^[a-z0-9_-]{1,40}$/.test(f.agent) && typeof f.promptPrefix === "string" && f.promptPrefix.trim().length >= 20 && f.promptPrefix.length <= 2000 && Array.isArray(f.promptContains) && f.promptContains.length >= 1 && f.promptContains.length <= 10 && f.promptContains.every((s) => typeof s === "string" && s.trim().length > 0 && s.length <= 2000));
|
|
3187
|
+
} catch {
|
|
3188
|
+
return false;
|
|
3189
|
+
}
|
|
3190
|
+
}
|
|
3191
|
+
|
|
3192
|
+
// src/copy-hook-scripts.ts
|
|
3088
3193
|
import { join as pathJoin } from "path";
|
|
3194
|
+
function retryDelay(response) {
|
|
3195
|
+
const value = response.headers.get("Retry-After")?.trim();
|
|
3196
|
+
if (!value)
|
|
3197
|
+
return 60250;
|
|
3198
|
+
const seconds = /^\d+(?:\.\d+)?$/.test(value) ? Number(value) : NaN;
|
|
3199
|
+
const delay = Number.isFinite(seconds) ? seconds * 1000 : Date.parse(value) - Date.now();
|
|
3200
|
+
return Number.isFinite(delay) ? Math.max(1000, delay) + 250 : 60250;
|
|
3201
|
+
}
|
|
3089
3202
|
async function copyHookScripts(hooksDir, token, files, options) {
|
|
3090
3203
|
const fetchImpl = options.fetchImpl || fetch;
|
|
3091
3204
|
const writeFile = options.writeFileSync || fsWriteFileSync;
|
|
3092
3205
|
const join = options.joinPath || pathJoin;
|
|
3206
|
+
const sleep = options.sleep || ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
3207
|
+
let retryBudgetMs = 125000;
|
|
3208
|
+
const staged = [];
|
|
3093
3209
|
let downloaded = 0;
|
|
3094
3210
|
const failed = [];
|
|
3211
|
+
const optionalFailed = [];
|
|
3212
|
+
const optional = new Set(options.optionalFiles || []);
|
|
3213
|
+
const recordFailure = (file, detail) => {
|
|
3214
|
+
(optional.has(file) ? optionalFailed : failed).push(`${file} (${detail})`);
|
|
3215
|
+
};
|
|
3095
3216
|
for (const file of files) {
|
|
3096
3217
|
if (!/^[a-z0-9._-]+\.(sh|js|json)$/i.test(file) || file.includes("..")) {
|
|
3097
|
-
|
|
3218
|
+
recordFailure(file, "invalid filename");
|
|
3098
3219
|
continue;
|
|
3099
3220
|
}
|
|
3100
3221
|
try {
|
|
3101
|
-
const
|
|
3222
|
+
const download = () => fetchImpl(`${options.apiUrl}/${options.apiVersion}/hooks/${file}?format=raw`, {
|
|
3102
3223
|
headers: {
|
|
3103
3224
|
Authorization: `Bearer ${token}`
|
|
3104
3225
|
}
|
|
3105
3226
|
});
|
|
3227
|
+
let response = await download();
|
|
3228
|
+
for (let retry = 0;response.status === 429 && retry < 2; retry++) {
|
|
3229
|
+
const delay = retryDelay(response);
|
|
3230
|
+
if (delay > retryBudgetMs)
|
|
3231
|
+
break;
|
|
3232
|
+
retryBudgetMs -= delay;
|
|
3233
|
+
await response.body?.cancel();
|
|
3234
|
+
options.onRateLimit?.(file, Math.ceil(delay / 1000));
|
|
3235
|
+
await sleep(delay);
|
|
3236
|
+
response = await download();
|
|
3237
|
+
}
|
|
3106
3238
|
if (response.ok) {
|
|
3107
3239
|
const content = await response.text();
|
|
3240
|
+
if (file === "background-filters.json") {
|
|
3241
|
+
if (!validBackgroundFilters(content)) {
|
|
3242
|
+
recordFailure(file, "invalid catalog; previous copy retained");
|
|
3243
|
+
continue;
|
|
3244
|
+
}
|
|
3245
|
+
staged.push({ file, content, mode: 384 });
|
|
3246
|
+
downloaded++;
|
|
3247
|
+
continue;
|
|
3248
|
+
}
|
|
3108
3249
|
const isShellScript = content.startsWith("#!/") || content.startsWith("# ");
|
|
3109
3250
|
const isJsBundle = file.endsWith(".js") && (content.startsWith("//") || content.startsWith("import ") || content.startsWith("var ") || content.startsWith("const ") || content.startsWith("export "));
|
|
3110
3251
|
if (isShellScript || isJsBundle) {
|
|
3111
|
-
|
|
3112
|
-
writeFile(filePath, content, { mode: isShellScript ? 493 : 420 });
|
|
3252
|
+
staged.push({ file, content, mode: isShellScript ? 493 : 420 });
|
|
3113
3253
|
downloaded++;
|
|
3114
3254
|
} else {
|
|
3115
|
-
|
|
3255
|
+
recordFailure(file, "invalid content");
|
|
3116
3256
|
}
|
|
3117
3257
|
} else {
|
|
3118
3258
|
const body = await response.text().catch(() => "");
|
|
3119
3259
|
const failureKind = classifyHookDownloadFailure(response.status, body);
|
|
3260
|
+
if (optional.has(file) && (failureKind === "rate_limited" || failureKind === "validation_unavailable")) {
|
|
3261
|
+
recordFailure(file, String(response.status));
|
|
3262
|
+
continue;
|
|
3263
|
+
}
|
|
3120
3264
|
if (failureKind !== "recoverable") {
|
|
3121
3265
|
return {
|
|
3122
3266
|
downloaded,
|
|
3123
3267
|
failed,
|
|
3268
|
+
optionalFailed,
|
|
3124
3269
|
terminalFailure: {
|
|
3125
3270
|
kind: failureKind,
|
|
3126
3271
|
file,
|
|
@@ -3128,13 +3273,58 @@ async function copyHookScripts(hooksDir, token, files, options) {
|
|
|
3128
3273
|
}
|
|
3129
3274
|
};
|
|
3130
3275
|
}
|
|
3131
|
-
|
|
3276
|
+
recordFailure(file, String(response.status));
|
|
3132
3277
|
}
|
|
3133
3278
|
} catch (err) {
|
|
3134
|
-
|
|
3279
|
+
recordFailure(file, err instanceof Error ? err.message : "network error");
|
|
3135
3280
|
}
|
|
3136
3281
|
}
|
|
3137
|
-
|
|
3282
|
+
if (failed.length === 0) {
|
|
3283
|
+
const replacements = [];
|
|
3284
|
+
for (const { file, content, mode } of staged) {
|
|
3285
|
+
if (optionalFailed.length && optional.has(file))
|
|
3286
|
+
continue;
|
|
3287
|
+
try {
|
|
3288
|
+
const filePath = join(hooksDir, file);
|
|
3289
|
+
if (options.writeFileSync)
|
|
3290
|
+
writeFile(filePath, content, { mode });
|
|
3291
|
+
else {
|
|
3292
|
+
const temporary = `${filePath}.${randomUUID()}.tmp`;
|
|
3293
|
+
writeFile(temporary, content, { mode });
|
|
3294
|
+
replacements.push({ temporary, filePath, file });
|
|
3295
|
+
}
|
|
3296
|
+
} catch {
|
|
3297
|
+
failed.push(`${file} (could not save hook file)`);
|
|
3298
|
+
break;
|
|
3299
|
+
}
|
|
3300
|
+
}
|
|
3301
|
+
if (failed.length === 0) {
|
|
3302
|
+
for (const { temporary, filePath, file } of replacements) {
|
|
3303
|
+
try {
|
|
3304
|
+
renameSync(temporary, filePath);
|
|
3305
|
+
} catch {
|
|
3306
|
+
failed.push(`${file} (could not replace hook file)`);
|
|
3307
|
+
break;
|
|
3308
|
+
}
|
|
3309
|
+
}
|
|
3310
|
+
}
|
|
3311
|
+
}
|
|
3312
|
+
return { downloaded, failed, optionalFailed };
|
|
3313
|
+
}
|
|
3314
|
+
|
|
3315
|
+
// src/hermes-follow-up.ts
|
|
3316
|
+
import { execFileSync } from "child_process";
|
|
3317
|
+
function enableHermesFollowUp(profile, run = (file, args) => execFileSync(file, args, { stdio: "pipe", timeout: 30000 })) {
|
|
3318
|
+
if (!/^[a-z0-9][a-z0-9_-]{0,63}$/.test(profile)) {
|
|
3319
|
+
throw new Error("Invalid Hermes profile name");
|
|
3320
|
+
}
|
|
3321
|
+
run("hermes", [
|
|
3322
|
+
...profile === "default" ? [] : ["-p", profile],
|
|
3323
|
+
"config",
|
|
3324
|
+
"set",
|
|
3325
|
+
"plugins.entries.agentapprove.allow_gateway_injection",
|
|
3326
|
+
"true"
|
|
3327
|
+
]);
|
|
3138
3328
|
}
|
|
3139
3329
|
|
|
3140
3330
|
// src/pairing-api-url.ts
|
|
@@ -3161,7 +3351,7 @@ function resolvePairingApiBaseUrl(options) {
|
|
|
3161
3351
|
// src/setup-check.ts
|
|
3162
3352
|
function checkHookConfiguration(agent, config, hooksKey, hooks, mode, fileReady, expectedCommand = (file) => `~/.agentapprove/hooks/${file}`) {
|
|
3163
3353
|
const result = (status, reason) => ({ agent, status, reason });
|
|
3164
|
-
const expected = hooks.filter((
|
|
3354
|
+
const expected = hooks.filter((h) => !h.isPlugin && !(mode === "observe" && h.isApprovalHook));
|
|
3165
3355
|
if (!expected.length)
|
|
3166
3356
|
return result("manual", "manual_step");
|
|
3167
3357
|
const map = hooksKey ? config[hooksKey] : config;
|
|
@@ -3218,7 +3408,7 @@ Configured on this computer: ${ready.join(", ")}. Nothing was changed.`);
|
|
|
3218
3408
|
}
|
|
3219
3409
|
|
|
3220
3410
|
// src/cli.ts
|
|
3221
|
-
var VERSION = "0.1.
|
|
3411
|
+
var VERSION = "0.1.56";
|
|
3222
3412
|
function getApiUrl() {
|
|
3223
3413
|
return process.env.AGENTAPPROVE_API || "https://api.agentapprove.com";
|
|
3224
3414
|
}
|
|
@@ -3290,14 +3480,14 @@ function getCommand() {
|
|
|
3290
3480
|
}
|
|
3291
3481
|
return filtered[0] || "install";
|
|
3292
3482
|
}
|
|
3293
|
-
var OPENCODE_PLUGIN_VERSION = "0.1.
|
|
3483
|
+
var OPENCODE_PLUGIN_VERSION = "0.1.26";
|
|
3294
3484
|
var OPENCODE_PLUGIN_SPEC = `@agentapprove/opencode@${OPENCODE_PLUGIN_VERSION}`;
|
|
3295
|
-
var OPENCLAW_PLUGIN_VERSION = "0.2.
|
|
3485
|
+
var OPENCLAW_PLUGIN_VERSION = "0.2.21";
|
|
3296
3486
|
var OPENCLAW_PLUGIN_SPEC = `@agentapprove/openclaw@${OPENCLAW_PLUGIN_VERSION}`;
|
|
3297
|
-
var PI_PLUGIN_VERSION = "0.1.
|
|
3487
|
+
var PI_PLUGIN_VERSION = "0.1.14";
|
|
3298
3488
|
var PI_PLUGIN_SPEC = `npm:@agentapprove/pi@${PI_PLUGIN_VERSION}`;
|
|
3299
3489
|
var PI_STATUS_TIMEOUT_MS = 5000;
|
|
3300
|
-
var HERMES_PLUGIN_VERSION = "0.1.
|
|
3490
|
+
var HERMES_PLUGIN_VERSION = "0.1.16";
|
|
3301
3491
|
var HERMES_PIP_DEPS = ["cryptography>=44.0,<46", "httpx>=0.27,<0.29"];
|
|
3302
3492
|
var AGENTS = {
|
|
3303
3493
|
"claude-code": {
|
|
@@ -3311,6 +3501,8 @@ var AGENTS = {
|
|
|
3311
3501
|
{ name: "PermissionRequest", file: "notify-hook.sh", description: "Permission requests", hasMatcher: true, isApprovalHook: true, timeout: 300 },
|
|
3312
3502
|
{ name: "UserPromptSubmit", file: "claude-user-prompt.sh", description: "User prompt submitted", hasMatcher: false },
|
|
3313
3503
|
{ name: "Stop", file: "claude-stop.sh", description: "Session/task completed", hasMatcher: false, timeout: 600 },
|
|
3504
|
+
{ name: "SubagentStart", file: "claude-subagent-start.sh", description: "Subagent started", hasMatcher: true },
|
|
3505
|
+
{ name: "SubagentStop", file: "claude-subagent-stop.sh", description: "Subagent completed", hasMatcher: true },
|
|
3314
3506
|
{ name: "SessionStart", file: "claude-session-start.sh", description: "Session started", hasMatcher: false },
|
|
3315
3507
|
{ name: "SessionEnd", file: "claude-session-end.sh", description: "Session ended", hasMatcher: false }
|
|
3316
3508
|
]
|
|
@@ -3435,6 +3627,8 @@ var AGENTS = {
|
|
|
3435
3627
|
configPath: join(homedir(), ".codex", "hooks.json"),
|
|
3436
3628
|
hooksKey: "hooks",
|
|
3437
3629
|
hooks: [
|
|
3630
|
+
{ name: "SubagentStart", file: "codex-subagent-start.sh", description: "Subagent started", hasMatcher: true },
|
|
3631
|
+
{ name: "SubagentStop", file: "codex-subagent-stop.sh", description: "Subagent completed", hasMatcher: true },
|
|
3438
3632
|
{ name: "SessionStart", file: "codex-session-start.sh", description: "Session started", hasMatcher: true },
|
|
3439
3633
|
{ name: "PreToolUse", file: "codex-pre-tool.sh", description: "Tool approval", hasMatcher: true, isApprovalHook: true, timeout: 300 },
|
|
3440
3634
|
{ name: "PostToolUse", file: "codex-post-tool.sh", description: "Tool completion logging", hasMatcher: true },
|
|
@@ -3513,7 +3707,7 @@ var SUPPORTED_AGENT_COPY = [
|
|
|
3513
3707
|
"Windsurf"
|
|
3514
3708
|
].join(", ");
|
|
3515
3709
|
var HIGHLIGHTED_AGENT_COPY = "Antigravity, Hermes, Pi, OpenClaw, OpenCode, and OpenHands";
|
|
3516
|
-
var SHARED_HOOK_FILES = ["common.sh"];
|
|
3710
|
+
var SHARED_HOOK_FILES = ["common.sh", ...BACKGROUND_FILTER_FILES];
|
|
3517
3711
|
var STATUS_FIELD_LABELS = {
|
|
3518
3712
|
AGENTAPPROVE_API: "API URL",
|
|
3519
3713
|
AGENTAPPROVE_TOKEN: "Token",
|
|
@@ -3606,7 +3800,7 @@ function findGitBash() {
|
|
|
3606
3800
|
}
|
|
3607
3801
|
function toGitBashPath(windowsPath) {
|
|
3608
3802
|
let result = windowsPath.replace(/\\/g, "/");
|
|
3609
|
-
result = result.replace(/^([A-Za-z]):\//, (
|
|
3803
|
+
result = result.replace(/^([A-Za-z]):\//, (_, drive) => `/${drive.toLowerCase()}/`);
|
|
3610
3804
|
return result;
|
|
3611
3805
|
}
|
|
3612
3806
|
function buildHookCommand(hookScriptPath, agentId) {
|
|
@@ -3640,7 +3834,7 @@ function getAntigravityPluginManifest() {
|
|
|
3640
3834
|
}
|
|
3641
3835
|
function buildAntigravityHooksJson(agentId, hooksDir, mode) {
|
|
3642
3836
|
const agent = AGENTS[agentId];
|
|
3643
|
-
const hooksToInstall = mode === "observe" ? agent.hooks.filter((
|
|
3837
|
+
const hooksToInstall = mode === "observe" ? agent.hooks.filter((h) => h.name !== "Stop") : agent.hooks;
|
|
3644
3838
|
const bundle = { enabled: true };
|
|
3645
3839
|
for (const hook of hooksToInstall) {
|
|
3646
3840
|
const hookPath = join(hooksDir, hook.file);
|
|
@@ -3682,7 +3876,7 @@ function installAntigravityPluginBundle(agentId, hooksDir, mode) {
|
|
|
3682
3876
|
error: err instanceof Error ? err.message : String(err)
|
|
3683
3877
|
};
|
|
3684
3878
|
}
|
|
3685
|
-
const installedHooks = (mode === "observe" ? agent.hooks.filter((
|
|
3879
|
+
const installedHooks = (mode === "observe" ? agent.hooks.filter((h) => h.name !== "Stop") : agent.hooks).map((hook) => hook.name);
|
|
3686
3880
|
return { success: true, backupPath, hooks: installedHooks };
|
|
3687
3881
|
}
|
|
3688
3882
|
function getVSCodeSettingsPaths() {
|
|
@@ -3981,7 +4175,7 @@ function describeFailBehavior(value) {
|
|
|
3981
4175
|
return "Block all commands until the service is restored.";
|
|
3982
4176
|
case "ask":
|
|
3983
4177
|
default:
|
|
3984
|
-
return "
|
|
4178
|
+
return "Use the agent's approval dialog when supported; otherwise block until approval is available.";
|
|
3985
4179
|
}
|
|
3986
4180
|
}
|
|
3987
4181
|
function describeInstallMode(value) {
|
|
@@ -4220,7 +4414,7 @@ function discoverE2EKeys() {
|
|
|
4220
4414
|
} catch {}
|
|
4221
4415
|
}
|
|
4222
4416
|
try {
|
|
4223
|
-
const files = readdirSync2(dir).filter((
|
|
4417
|
+
const files = readdirSync2(dir).filter((f) => f.startsWith("e2e-key.") && f.endsWith(".bak"));
|
|
4224
4418
|
for (const file of files) {
|
|
4225
4419
|
const fullPath = join(dir, file);
|
|
4226
4420
|
try {
|
|
@@ -4502,16 +4696,16 @@ function copyToClipboard(text) {
|
|
|
4502
4696
|
{ cmd: "xclip", args: ["-selection", "clipboard"] },
|
|
4503
4697
|
{ cmd: "xsel", args: ["--clipboard", "--input"] }
|
|
4504
4698
|
]) {
|
|
4505
|
-
const
|
|
4699
|
+
const result = spawnSync2(candidate.cmd, candidate.args, {
|
|
4506
4700
|
input: text,
|
|
4507
4701
|
stdio: ["pipe", "ignore", "ignore"]
|
|
4508
4702
|
});
|
|
4509
|
-
if (
|
|
4703
|
+
if (result.status === 0 && !result.error)
|
|
4510
4704
|
return true;
|
|
4511
4705
|
}
|
|
4512
4706
|
return false;
|
|
4513
4707
|
}
|
|
4514
|
-
const result =
|
|
4708
|
+
const result = spawnSync2(cmd, args, {
|
|
4515
4709
|
input: text,
|
|
4516
4710
|
stdio: ["pipe", "ignore", "ignore"]
|
|
4517
4711
|
});
|
|
@@ -4571,6 +4765,12 @@ async function showPairingPresentation(params) {
|
|
|
4571
4765
|
function saveEnvConfig(config) {
|
|
4572
4766
|
const envPath = join(getAgentApproveDir(), "env");
|
|
4573
4767
|
const configSetAt = config.configSetAt ?? Math.floor(Date.now() / 1000);
|
|
4768
|
+
const hasBackgroundPreference = config.preserved?.AGENTAPPROVE_FILTER_BACKGROUND_ACTIVITY !== undefined;
|
|
4769
|
+
const preserved = {
|
|
4770
|
+
AGENTAPPROVE_FILTER_BACKGROUND_ACTIVITY: "true",
|
|
4771
|
+
...!hasBackgroundPreference ? { AGENTAPPROVE_BACKGROUND_FILTER_SYNC_PENDING: "true" } : {},
|
|
4772
|
+
...config.preserved
|
|
4773
|
+
};
|
|
4574
4774
|
const retentionDisplay = `${config.retentionDays ?? 30}`;
|
|
4575
4775
|
const e2eEnabled = config.e2eEnabled !== false;
|
|
4576
4776
|
const content = `# Agent Approve Configuration
|
|
@@ -4600,7 +4800,7 @@ AGENTAPPROVE_E2E_ENABLED=${e2eEnabled ? "true" : "false"}
|
|
|
4600
4800
|
|
|
4601
4801
|
# Hook behavior when API is unreachable: "allow" | "deny" | "ask"
|
|
4602
4802
|
AGENTAPPROVE_FAIL_BEHAVIOR=${config.failBehavior || "ask"}
|
|
4603
|
-
${renderPreservedEnvSection(
|
|
4803
|
+
${renderPreservedEnvSection(preserved)}
|
|
4604
4804
|
# Settings in this file sync from your Agent Approve account settings, so
|
|
4605
4805
|
# manual edits here are overwritten on the next config sync.
|
|
4606
4806
|
# To change settings, run: npx agentapprove install
|
|
@@ -4629,14 +4829,14 @@ function isCredentialManagerAvailable() {
|
|
|
4629
4829
|
async function storeTokenInKeychain(token, options) {
|
|
4630
4830
|
if (isKeychainAvailable()) {
|
|
4631
4831
|
try {
|
|
4632
|
-
|
|
4832
|
+
spawnSync2("security", [
|
|
4633
4833
|
"delete-generic-password",
|
|
4634
4834
|
"-s",
|
|
4635
4835
|
KEYCHAIN_SERVICE,
|
|
4636
4836
|
"-a",
|
|
4637
4837
|
KEYCHAIN_ACCOUNT
|
|
4638
4838
|
], { stdio: "ignore" });
|
|
4639
|
-
const addResult =
|
|
4839
|
+
const addResult = spawnSync2("security", [
|
|
4640
4840
|
"add-generic-password",
|
|
4641
4841
|
"-s",
|
|
4642
4842
|
KEYCHAIN_SERVICE,
|
|
@@ -4660,8 +4860,8 @@ async function storeTokenInKeychain(token, options) {
|
|
|
4660
4860
|
}
|
|
4661
4861
|
if (isCredentialManagerAvailable()) {
|
|
4662
4862
|
try {
|
|
4663
|
-
|
|
4664
|
-
const addResult =
|
|
4863
|
+
spawnSync2("cmdkey", [`/delete:${CREDENTIAL_TARGET}`], { stdio: "ignore" });
|
|
4864
|
+
const addResult = spawnSync2("cmdkey", [
|
|
4665
4865
|
`/generic:${CREDENTIAL_TARGET}`,
|
|
4666
4866
|
"/user:agentapprove",
|
|
4667
4867
|
`/pass:${token}`
|
|
@@ -4684,7 +4884,7 @@ function readTokenFromKeychain() {
|
|
|
4684
4884
|
if (!isKeychainAvailable())
|
|
4685
4885
|
return null;
|
|
4686
4886
|
try {
|
|
4687
|
-
const result =
|
|
4887
|
+
const result = spawnSync2("security", [
|
|
4688
4888
|
"find-generic-password",
|
|
4689
4889
|
"-s",
|
|
4690
4890
|
KEYCHAIN_SERVICE,
|
|
@@ -4767,39 +4967,27 @@ async function installHooksForAgent(agentId, hooksDir, mode = "approval") {
|
|
|
4767
4967
|
const hooksConfig = useTopLevelHooks ? config : config[agent.hooksKey];
|
|
4768
4968
|
const installedHooks = [];
|
|
4769
4969
|
if (agentId === "openclaw") {
|
|
4770
|
-
const
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
failBehavior: "ask",
|
|
4789
|
-
privacyTier: "full"
|
|
4970
|
+
const result = await installOpenClaw({
|
|
4971
|
+
spec: OPENCLAW_PLUGIN_SPEC,
|
|
4972
|
+
version: OPENCLAW_PLUGIN_VERSION,
|
|
4973
|
+
mode,
|
|
4974
|
+
readVersion: readOpenClawInstalledVersion,
|
|
4975
|
+
readConfig: () => {
|
|
4976
|
+
if (!existsSync2(agent.configPath))
|
|
4977
|
+
return {};
|
|
4978
|
+
const current = JSON.parse(readFileSync(agent.configPath, "utf8"));
|
|
4979
|
+
if (!current || typeof current !== "object" || Array.isArray(current)) {
|
|
4980
|
+
throw new Error("OpenClaw configuration must be a JSON object; no settings were overwritten.");
|
|
4981
|
+
}
|
|
4982
|
+
return current;
|
|
4983
|
+
},
|
|
4984
|
+
writeConfig: (updated) => writeJsonConfig(agent.configPath, updated),
|
|
4985
|
+
confirmReplacement: async (message) => {
|
|
4986
|
+
const answer = await ce({ message, initialValue: false });
|
|
4987
|
+
return !lD(answer) && answer === true;
|
|
4790
4988
|
}
|
|
4791
|
-
};
|
|
4792
|
-
|
|
4793
|
-
config.hooks = {};
|
|
4794
|
-
}
|
|
4795
|
-
const hooks = config.hooks;
|
|
4796
|
-
if (!hooks.internal) {
|
|
4797
|
-
hooks.internal = {};
|
|
4798
|
-
}
|
|
4799
|
-
hooks.internal.enabled = true;
|
|
4800
|
-
writeJsonConfig(agent.configPath, config);
|
|
4801
|
-
installedHooks.push(installResult.label);
|
|
4802
|
-
return { success: true, backupPath, hooks: installedHooks };
|
|
4989
|
+
});
|
|
4990
|
+
return { ...result, backupPath, hooks: result.success ? [result.label] : [] };
|
|
4803
4991
|
}
|
|
4804
4992
|
if (agentId === "opencode") {
|
|
4805
4993
|
const installResult = installOpenCodePluginViaCli();
|
|
@@ -4839,7 +5027,7 @@ async function installHooksForAgent(agentId, hooksDir, mode = "approval") {
|
|
|
4839
5027
|
installedHooks.push(installResult.label);
|
|
4840
5028
|
return { success: true, backupPath, hooks: installedHooks };
|
|
4841
5029
|
}
|
|
4842
|
-
const hooksToInstall = mode === "observe" ? agent.hooks.filter((
|
|
5030
|
+
const hooksToInstall = mode === "observe" ? agent.hooks.filter((h) => !h.isApprovalHook) : agent.hooks;
|
|
4843
5031
|
for (const hook of hooksToInstall) {
|
|
4844
5032
|
const hookPath = join(hooksDir, hook.file);
|
|
4845
5033
|
const hookCommand = buildHookCommand(hookPath, agentId);
|
|
@@ -4850,7 +5038,7 @@ async function installHooksForAgent(agentId, hooksDir, mode = "approval") {
|
|
|
4850
5038
|
const hookArray = hooksConfig[hook.name];
|
|
4851
5039
|
const hasMatcher = hook.hasMatcher ?? true;
|
|
4852
5040
|
const hookTimeout = hook.timeout;
|
|
4853
|
-
const existingIdx = hookArray.findIndex((
|
|
5041
|
+
const existingIdx = hookArray.findIndex((h) => h.hooks?.some((hookScript) => {
|
|
4854
5042
|
if (typeof hookScript === "string")
|
|
4855
5043
|
return hookScript.includes("agentapprove");
|
|
4856
5044
|
if (typeof hookScript === "object" && hookScript.command)
|
|
@@ -4874,7 +5062,7 @@ async function installHooksForAgent(agentId, hooksDir, mode = "approval") {
|
|
|
4874
5062
|
const hookArray = hooksConfig[hook.name];
|
|
4875
5063
|
const hasMatcher = hook.hasMatcher ?? true;
|
|
4876
5064
|
const hookTimeout = hook.timeout;
|
|
4877
|
-
const existingIdx = hookArray.findIndex((
|
|
5065
|
+
const existingIdx = hookArray.findIndex((h) => h.hooks?.some((hookScript) => {
|
|
4878
5066
|
if (typeof hookScript === "string")
|
|
4879
5067
|
return hookScript.includes("agentapprove");
|
|
4880
5068
|
if (typeof hookScript === "object" && hookScript.command)
|
|
@@ -4899,56 +5087,13 @@ async function installHooksForAgent(agentId, hooksDir, mode = "approval") {
|
|
|
4899
5087
|
if (typeof config["version"] !== "number") {
|
|
4900
5088
|
config["version"] = 1;
|
|
4901
5089
|
}
|
|
4902
|
-
|
|
4903
|
-
const needsStopTimeout = hook.name === "stop" || hook.name === "subagentStop";
|
|
4904
|
-
const isApproval = hook.isApprovalHook;
|
|
4905
|
-
const hookEntry = { command: hookCommand };
|
|
4906
|
-
if (needsStopTimeout) {
|
|
4907
|
-
hookEntry.timeout = 600;
|
|
4908
|
-
hookEntry.loop_limit = 10;
|
|
4909
|
-
} else if (isApproval) {
|
|
4910
|
-
hookEntry.timeout = 300;
|
|
4911
|
-
}
|
|
4912
|
-
if (!existing) {
|
|
4913
|
-
hooksConfig[hook.name] = [hookEntry];
|
|
4914
|
-
} else if (Array.isArray(existing)) {
|
|
4915
|
-
const ourIdx = existing.findIndex((h2) => {
|
|
4916
|
-
if (typeof h2 === "object" && h2 !== null && "command" in h2) {
|
|
4917
|
-
return h2.command.includes("agentapprove");
|
|
4918
|
-
}
|
|
4919
|
-
if (typeof h2 === "string")
|
|
4920
|
-
return h2.includes("agentapprove");
|
|
4921
|
-
return false;
|
|
4922
|
-
});
|
|
4923
|
-
if (ourIdx >= 0) {
|
|
4924
|
-
existing[ourIdx] = hookEntry;
|
|
4925
|
-
} else {
|
|
4926
|
-
existing.push(hookEntry);
|
|
4927
|
-
}
|
|
4928
|
-
hooksConfig[hook.name] = existing.map((h2) => {
|
|
4929
|
-
if (typeof h2 === "string")
|
|
4930
|
-
return { command: h2 };
|
|
4931
|
-
return h2;
|
|
4932
|
-
});
|
|
4933
|
-
} else if (typeof existing === "object" && existing !== null) {
|
|
4934
|
-
if ("command" in existing && existing.command.includes("agentapprove")) {
|
|
4935
|
-
hooksConfig[hook.name] = [hookEntry];
|
|
4936
|
-
} else {
|
|
4937
|
-
hooksConfig[hook.name] = [existing, hookEntry];
|
|
4938
|
-
}
|
|
4939
|
-
} else if (typeof existing === "string") {
|
|
4940
|
-
if (existing.includes("agentapprove")) {
|
|
4941
|
-
hooksConfig[hook.name] = [hookEntry];
|
|
4942
|
-
} else {
|
|
4943
|
-
hooksConfig[hook.name] = [{ command: existing }, hookEntry];
|
|
4944
|
-
}
|
|
4945
|
-
}
|
|
5090
|
+
hooksConfig[hook.name] = upsertCursorHook(hooksConfig[hook.name], cursorHookEntry(hook.name, hookCommand, hook.isApprovalHook));
|
|
4946
5091
|
installedHooks.push(hook.name);
|
|
4947
5092
|
} else if (agentId === "windsurf") {
|
|
4948
5093
|
const existing = hooksConfig[hook.name];
|
|
4949
5094
|
const existingArray = Array.isArray(existing) ? existing : existing && typeof existing === "object" ? [existing] : typeof existing === "string" ? [{ command: existing }] : [];
|
|
4950
|
-
const cleanedArray = existingArray.filter((
|
|
4951
|
-
const command =
|
|
5095
|
+
const cleanedArray = existingArray.filter((h) => {
|
|
5096
|
+
const command = h.command || h.powershell || "";
|
|
4952
5097
|
return !command.includes("agentapprove");
|
|
4953
5098
|
});
|
|
4954
5099
|
cleanedArray.push({
|
|
@@ -4962,10 +5107,10 @@ async function installHooksForAgent(agentId, hooksDir, mode = "approval") {
|
|
|
4962
5107
|
hooksConfig[hook.name] = [];
|
|
4963
5108
|
}
|
|
4964
5109
|
const hookArray = hooksConfig[hook.name];
|
|
4965
|
-
const cleanedArray = hookArray.filter((
|
|
4966
|
-
if (!
|
|
5110
|
+
const cleanedArray = hookArray.filter((h) => {
|
|
5111
|
+
if (!h.hooks || !Array.isArray(h.hooks))
|
|
4967
5112
|
return true;
|
|
4968
|
-
return !
|
|
5113
|
+
return !h.hooks.some((hookScript) => {
|
|
4969
5114
|
if (typeof hookScript === "string")
|
|
4970
5115
|
return hookScript.includes("agentapprove");
|
|
4971
5116
|
if (typeof hookScript === "object" && hookScript !== null && "command" in hookScript) {
|
|
@@ -4985,8 +5130,8 @@ async function installHooksForAgent(agentId, hooksDir, mode = "approval") {
|
|
|
4985
5130
|
hooksConfig[hook.name] = [];
|
|
4986
5131
|
}
|
|
4987
5132
|
const hookArray = hooksConfig[hook.name];
|
|
4988
|
-
const cleanedArray = hookArray.filter((
|
|
4989
|
-
return !(
|
|
5133
|
+
const cleanedArray = hookArray.filter((h) => {
|
|
5134
|
+
return !(h.command || "").includes("agentapprove");
|
|
4990
5135
|
});
|
|
4991
5136
|
const hookEntry = {
|
|
4992
5137
|
type: "command",
|
|
@@ -5012,7 +5157,7 @@ async function installHooksForAgent(agentId, hooksDir, mode = "approval") {
|
|
|
5012
5157
|
const hookArray = hooksConfig[hook.name];
|
|
5013
5158
|
const hookTimeout = hook.timeout;
|
|
5014
5159
|
const isApproval = hook.isApprovalHook;
|
|
5015
|
-
const existingIdx = hookArray.findIndex((
|
|
5160
|
+
const existingIdx = hookArray.findIndex((h) => h.hooks?.some((hookScript) => {
|
|
5016
5161
|
if (typeof hookScript === "string")
|
|
5017
5162
|
return hookScript.includes("agentapprove");
|
|
5018
5163
|
if (typeof hookScript === "object" && hookScript.command)
|
|
@@ -5048,8 +5193,8 @@ async function installHooksForAgent(agentId, hooksDir, mode = "approval") {
|
|
|
5048
5193
|
hooksConfig[hook.name] = [];
|
|
5049
5194
|
}
|
|
5050
5195
|
const hookArray = hooksConfig[hook.name];
|
|
5051
|
-
const cleanedArray = hookArray.filter((
|
|
5052
|
-
const cmd =
|
|
5196
|
+
const cleanedArray = hookArray.filter((h) => {
|
|
5197
|
+
const cmd = h.bash || h.command || "";
|
|
5053
5198
|
return !cmd.includes("agentapprove");
|
|
5054
5199
|
});
|
|
5055
5200
|
const hookEntry = {
|
|
@@ -5069,16 +5214,16 @@ async function installHooksForAgent(agentId, hooksDir, mode = "approval") {
|
|
|
5069
5214
|
}
|
|
5070
5215
|
}
|
|
5071
5216
|
if (mode === "observe") {
|
|
5072
|
-
const approvalHooks = agent.hooks.filter((
|
|
5217
|
+
const approvalHooks = agent.hooks.filter((h) => h.isApprovalHook);
|
|
5073
5218
|
for (const hook of approvalHooks) {
|
|
5074
5219
|
if (hooksConfig[hook.name]) {
|
|
5075
5220
|
if (agentId === "claude-code" || agentId === "gemini-cli" || agentId === "codex" || agentId === "openhands") {
|
|
5076
5221
|
const hookArray = hooksConfig[hook.name];
|
|
5077
5222
|
if (Array.isArray(hookArray)) {
|
|
5078
|
-
const cleaned = hookArray.filter((
|
|
5079
|
-
if (!
|
|
5223
|
+
const cleaned = hookArray.filter((h) => {
|
|
5224
|
+
if (!h.hooks || !Array.isArray(h.hooks))
|
|
5080
5225
|
return true;
|
|
5081
|
-
return !
|
|
5226
|
+
return !h.hooks.some((hs) => {
|
|
5082
5227
|
if (typeof hs === "string")
|
|
5083
5228
|
return hs.includes("agentapprove");
|
|
5084
5229
|
if (typeof hs === "object" && hs !== null && "command" in hs) {
|
|
@@ -5096,7 +5241,7 @@ async function installHooksForAgent(agentId, hooksDir, mode = "approval") {
|
|
|
5096
5241
|
} else if (agentId === "vscode-agent") {
|
|
5097
5242
|
const hookArray = hooksConfig[hook.name];
|
|
5098
5243
|
if (Array.isArray(hookArray)) {
|
|
5099
|
-
const cleaned = hookArray.filter((
|
|
5244
|
+
const cleaned = hookArray.filter((h) => !(h.command || "").includes("agentapprove"));
|
|
5100
5245
|
if (cleaned.length === 0) {
|
|
5101
5246
|
delete hooksConfig[hook.name];
|
|
5102
5247
|
} else {
|
|
@@ -5106,8 +5251,8 @@ async function installHooksForAgent(agentId, hooksDir, mode = "approval") {
|
|
|
5106
5251
|
} else if (agentId === "copilot-cli") {
|
|
5107
5252
|
const hookArray = hooksConfig[hook.name];
|
|
5108
5253
|
if (Array.isArray(hookArray)) {
|
|
5109
|
-
const cleaned = hookArray.filter((
|
|
5110
|
-
const cmd =
|
|
5254
|
+
const cleaned = hookArray.filter((h) => {
|
|
5255
|
+
const cmd = h.bash || h.command || "";
|
|
5111
5256
|
return !cmd.includes("agentapprove");
|
|
5112
5257
|
});
|
|
5113
5258
|
if (cleaned.length === 0) {
|
|
@@ -5119,12 +5264,12 @@ async function installHooksForAgent(agentId, hooksDir, mode = "approval") {
|
|
|
5119
5264
|
} else if (agentId === "cursor") {
|
|
5120
5265
|
const existing = hooksConfig[hook.name];
|
|
5121
5266
|
if (Array.isArray(existing)) {
|
|
5122
|
-
const cleaned = existing.filter((
|
|
5123
|
-
if (typeof
|
|
5124
|
-
return !
|
|
5267
|
+
const cleaned = existing.filter((h) => {
|
|
5268
|
+
if (typeof h === "object" && h !== null && "command" in h) {
|
|
5269
|
+
return !h.command.includes("agentapprove");
|
|
5125
5270
|
}
|
|
5126
|
-
if (typeof
|
|
5127
|
-
return !
|
|
5271
|
+
if (typeof h === "string")
|
|
5272
|
+
return !h.includes("agentapprove");
|
|
5128
5273
|
return true;
|
|
5129
5274
|
});
|
|
5130
5275
|
if (cleaned.length === 0) {
|
|
@@ -5136,13 +5281,13 @@ async function installHooksForAgent(agentId, hooksDir, mode = "approval") {
|
|
|
5136
5281
|
} else if (agentId === "windsurf") {
|
|
5137
5282
|
const existing = hooksConfig[hook.name];
|
|
5138
5283
|
if (Array.isArray(existing)) {
|
|
5139
|
-
const cleaned = existing.filter((
|
|
5140
|
-
if (typeof
|
|
5141
|
-
const cmd =
|
|
5284
|
+
const cleaned = existing.filter((h) => {
|
|
5285
|
+
if (typeof h === "object" && h !== null) {
|
|
5286
|
+
const cmd = h.command || h.powershell || "";
|
|
5142
5287
|
return !cmd.includes("agentapprove");
|
|
5143
5288
|
}
|
|
5144
|
-
if (typeof
|
|
5145
|
-
return !
|
|
5289
|
+
if (typeof h === "string")
|
|
5290
|
+
return !h.includes("agentapprove");
|
|
5146
5291
|
return true;
|
|
5147
5292
|
});
|
|
5148
5293
|
if (cleaned.length === 0) {
|
|
@@ -5223,15 +5368,7 @@ codex_hooks = true`;
|
|
|
5223
5368
|
for (const hook of agent.hooks) {
|
|
5224
5369
|
const hookPath = join(hooksDir, hook.file);
|
|
5225
5370
|
const hookCmd = buildHookCommand(hookPath, agentId);
|
|
5226
|
-
const
|
|
5227
|
-
const isApproval = hook.isApprovalHook;
|
|
5228
|
-
const entry = { command: hookCmd };
|
|
5229
|
-
if (needsStopTimeout) {
|
|
5230
|
-
entry.timeout = 600;
|
|
5231
|
-
entry.loop_limit = 10;
|
|
5232
|
-
} else if (isApproval) {
|
|
5233
|
-
entry.timeout = 300;
|
|
5234
|
-
}
|
|
5371
|
+
const entry = cursorHookEntry(hook.name, hookCmd, hook.isApprovalHook);
|
|
5235
5372
|
hooksObj[hook.name] = [entry];
|
|
5236
5373
|
}
|
|
5237
5374
|
return JSON.stringify({ version: 1, hooks: hooksObj }, null, 2);
|
|
@@ -5324,14 +5461,8 @@ codex_hooks = true`;
|
|
|
5324
5461
|
plugins: {
|
|
5325
5462
|
entries: {
|
|
5326
5463
|
openclaw: {
|
|
5327
|
-
|
|
5328
|
-
config: {
|
|
5329
|
-
apiUrl: API_URL,
|
|
5330
|
-
apiVersion: "v001",
|
|
5331
|
-
timeout: 300,
|
|
5332
|
-
failBehavior: "ask",
|
|
5333
|
-
privacyTier: "full"
|
|
5334
|
-
}
|
|
5464
|
+
hooks: { allowConversationAccess: true },
|
|
5465
|
+
config: {}
|
|
5335
5466
|
}
|
|
5336
5467
|
}
|
|
5337
5468
|
},
|
|
@@ -5344,10 +5475,15 @@ codex_hooks = true`;
|
|
|
5344
5475
|
"",
|
|
5345
5476
|
` openclaw plugins install ${OPENCLAW_PLUGIN_SPEC}`,
|
|
5346
5477
|
"",
|
|
5347
|
-
"
|
|
5478
|
+
"Review the source and capabilities in the terminal; declining stops installation.",
|
|
5479
|
+
"Merge the following settings into your OpenClaw config, preserving existing entries and permissions:",
|
|
5348
5480
|
"",
|
|
5349
5481
|
configJson,
|
|
5350
5482
|
"",
|
|
5483
|
+
CONVERSATION_ACCESS_NOTICE,
|
|
5484
|
+
"Then run: openclaw plugins enable openclaw (review any capabilities requested).",
|
|
5485
|
+
"",
|
|
5486
|
+
"Settings follow ~/.agentapprove/env. Existing explicit OpenClaw config overrides take precedence and are preserved.",
|
|
5351
5487
|
'Hosted installs can also set config.token/config.apiUrl/etc. with OpenClaw env substitution such as "${AGENTAPPROVE_TOKEN}".',
|
|
5352
5488
|
"",
|
|
5353
5489
|
"Restart the OpenClaw gateway to activate."
|
|
@@ -5397,6 +5533,7 @@ codex_hooks = true`;
|
|
|
5397
5533
|
" pip install --user cryptography httpx",
|
|
5398
5534
|
" # On uv-managed Python (PEP 668 EXTERNALLY-MANAGED): instead run",
|
|
5399
5535
|
" # uv pip install --system --break-system-packages --python $(which python3.12) cryptography httpx",
|
|
5536
|
+
" hermes config set plugins.entries.agentapprove.allow_gateway_injection true",
|
|
5400
5537
|
" hermes plugins enable agentapprove",
|
|
5401
5538
|
"",
|
|
5402
5539
|
"The plugin reads your existing Agent Approve config from ~/.agentapprove/env.",
|
|
@@ -5409,6 +5546,8 @@ codex_hooks = true`;
|
|
|
5409
5546
|
}
|
|
5410
5547
|
function describeDownloadTerminalFailure(kind) {
|
|
5411
5548
|
switch (kind) {
|
|
5549
|
+
case "rate_limited":
|
|
5550
|
+
return "Hook download limit reached. Please wait a few minutes, then rerun the installer. Existing hook files were kept.";
|
|
5412
5551
|
case "token_expired":
|
|
5413
5552
|
return "Hook download stopped: your saved token has expired. Run `npx agentapprove refresh` to re-pair, or run the installer again to choose Refresh / Re-pair.";
|
|
5414
5553
|
case "token_invalid":
|
|
@@ -5426,95 +5565,37 @@ function describeDownloadTerminalFailure(kind) {
|
|
|
5426
5565
|
async function copyHookScripts2(hooksDir, token, files, options = {}) {
|
|
5427
5566
|
return copyHookScripts(hooksDir, token, files, {
|
|
5428
5567
|
apiUrl: options.apiUrl || API_URL,
|
|
5429
|
-
apiVersion: API_VERSION
|
|
5568
|
+
apiVersion: API_VERSION,
|
|
5569
|
+
onRateLimit: options.onRateLimit,
|
|
5570
|
+
optionalFiles: options.optionalFiles
|
|
5430
5571
|
});
|
|
5431
5572
|
}
|
|
5432
5573
|
function readOpenClawInstalledVersion() {
|
|
5433
|
-
|
|
5574
|
+
try {
|
|
5575
|
+
const result = spawnSync2("openclaw", ["plugins", "inspect", "openclaw", "--json"], {
|
|
5576
|
+
encoding: "utf8",
|
|
5577
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
5578
|
+
timeout: 30000,
|
|
5579
|
+
shell: process.platform === "win32"
|
|
5580
|
+
});
|
|
5581
|
+
if (result.status === 0) {
|
|
5582
|
+
const metadata = JSON.parse(result.stdout);
|
|
5583
|
+
if (metadata.plugin?.packageName === "@agentapprove/openclaw" && typeof metadata.plugin.rootDir === "string") {
|
|
5584
|
+
return readJsonPackageVersion(join(metadata.plugin.rootDir, "package.json"));
|
|
5585
|
+
}
|
|
5586
|
+
return null;
|
|
5587
|
+
}
|
|
5588
|
+
} catch {}
|
|
5589
|
+
for (const packagePath of [
|
|
5434
5590
|
join(homedir(), ".openclaw", "npm", "node_modules", "@agentapprove", "openclaw", "package.json"),
|
|
5435
5591
|
join(homedir(), ".openclaw", "extensions", "openclaw", "package.json")
|
|
5436
|
-
]
|
|
5437
|
-
|
|
5438
|
-
if (
|
|
5439
|
-
|
|
5440
|
-
}
|
|
5441
|
-
try {
|
|
5442
|
-
const pkg = JSON.parse(readFileSync(packagePath, "utf-8"));
|
|
5443
|
-
if (typeof pkg.version === "string") {
|
|
5444
|
-
return pkg.version;
|
|
5445
|
-
}
|
|
5446
|
-
} catch {}
|
|
5592
|
+
]) {
|
|
5593
|
+
const version = readJsonPackageVersion(packagePath);
|
|
5594
|
+
if (version)
|
|
5595
|
+
return version;
|
|
5447
5596
|
}
|
|
5448
5597
|
return null;
|
|
5449
5598
|
}
|
|
5450
|
-
function isOpenClawAlreadyExistsError(err) {
|
|
5451
|
-
if (!err || typeof err !== "object")
|
|
5452
|
-
return false;
|
|
5453
|
-
const e2 = err;
|
|
5454
|
-
const blob = [
|
|
5455
|
-
Buffer.isBuffer(e2.stderr) ? e2.stderr.toString() : String(e2.stderr || ""),
|
|
5456
|
-
Buffer.isBuffer(e2.stdout) ? e2.stdout.toString() : String(e2.stdout || ""),
|
|
5457
|
-
String(e2.message || "")
|
|
5458
|
-
].join(`
|
|
5459
|
-
`);
|
|
5460
|
-
return /plugin already exists|delete it first|use .*plugins update/i.test(blob);
|
|
5461
|
-
}
|
|
5462
|
-
function installOpenClawPluginViaCli() {
|
|
5463
|
-
const installCmd = (force) => `openclaw plugins install ${OPENCLAW_PLUGIN_SPEC}${force ? " --force" : ""}`;
|
|
5464
|
-
const tryInstall = (force) => {
|
|
5465
|
-
try {
|
|
5466
|
-
execSync(installCmd(force), { stdio: "pipe" });
|
|
5467
|
-
return { ok: true };
|
|
5468
|
-
} catch (err) {
|
|
5469
|
-
return { ok: false, err };
|
|
5470
|
-
}
|
|
5471
|
-
};
|
|
5472
|
-
let firstAttempt = tryInstall(false);
|
|
5473
|
-
if (!firstAttempt.ok && isOpenClawAlreadyExistsError(firstAttempt.err)) {
|
|
5474
|
-
const existingVersion = readOpenClawInstalledVersion();
|
|
5475
|
-
if (existingVersion === OPENCLAW_PLUGIN_VERSION) {
|
|
5476
|
-
return {
|
|
5477
|
-
success: true,
|
|
5478
|
-
version: existingVersion,
|
|
5479
|
-
label: `Agent Approve plugin v${existingVersion} (already installed)`
|
|
5480
|
-
};
|
|
5481
|
-
}
|
|
5482
|
-
const forceAttempt = tryInstall(true);
|
|
5483
|
-
if (!forceAttempt.ok) {
|
|
5484
|
-
const message = forceAttempt.err instanceof Error ? forceAttempt.err.message : "unknown error";
|
|
5485
|
-
return { success: false, error: message, label: "Agent Approve plugin" };
|
|
5486
|
-
}
|
|
5487
|
-
firstAttempt = { ok: true };
|
|
5488
|
-
}
|
|
5489
|
-
if (!firstAttempt.ok) {
|
|
5490
|
-
const message = firstAttempt.err instanceof Error ? firstAttempt.err.message : "unknown error";
|
|
5491
|
-
return { success: false, error: message, label: "Agent Approve plugin" };
|
|
5492
|
-
}
|
|
5493
|
-
try {
|
|
5494
|
-
const installedVersion = readOpenClawInstalledVersion();
|
|
5495
|
-
if (!installedVersion) {
|
|
5496
|
-
return {
|
|
5497
|
-
success: true,
|
|
5498
|
-
label: "Agent Approve plugin (version not verified)"
|
|
5499
|
-
};
|
|
5500
|
-
}
|
|
5501
|
-
if (installedVersion !== OPENCLAW_PLUGIN_VERSION) {
|
|
5502
|
-
return {
|
|
5503
|
-
success: false,
|
|
5504
|
-
error: `OpenClaw installed ${installedVersion}, expected ${OPENCLAW_PLUGIN_VERSION}. Re-run after updating the published installer package.`,
|
|
5505
|
-
label: "Agent Approve plugin"
|
|
5506
|
-
};
|
|
5507
|
-
}
|
|
5508
|
-
return {
|
|
5509
|
-
success: true,
|
|
5510
|
-
version: installedVersion,
|
|
5511
|
-
label: `Agent Approve plugin v${installedVersion}`
|
|
5512
|
-
};
|
|
5513
|
-
} catch (err) {
|
|
5514
|
-
const message = err instanceof Error ? err.message : "unknown error";
|
|
5515
|
-
return { success: false, error: message, label: "Agent Approve plugin" };
|
|
5516
|
-
}
|
|
5517
|
-
}
|
|
5518
5599
|
function readJsonPackageVersion(packagePath) {
|
|
5519
5600
|
if (!existsSync2(packagePath)) {
|
|
5520
5601
|
return null;
|
|
@@ -5550,7 +5631,7 @@ function readOpenCodeInstalledVersion() {
|
|
|
5550
5631
|
}
|
|
5551
5632
|
function installOpenCodePluginViaCli() {
|
|
5552
5633
|
try {
|
|
5553
|
-
const result =
|
|
5634
|
+
const result = spawnSync2("opencode", ["plugin", OPENCODE_PLUGIN_SPEC, "--global", "--force"], {
|
|
5554
5635
|
encoding: "utf8",
|
|
5555
5636
|
stdio: ["ignore", "pipe", "pipe"]
|
|
5556
5637
|
});
|
|
@@ -5657,7 +5738,7 @@ function removePiPluginViaCli() {
|
|
|
5657
5738
|
};
|
|
5658
5739
|
}
|
|
5659
5740
|
}
|
|
5660
|
-
var HERMES_BUNDLE_SHA256 = "
|
|
5741
|
+
var HERMES_BUNDLE_SHA256 = "7a4b063c78bbbb9e5b60f34c7ac6eddf4715df47ef474e98367706947b3bd1db";
|
|
5661
5742
|
var HERMES_BUNDLE_FILENAME = `agentapprove-hermes-${HERMES_PLUGIN_VERSION}.tar.gz`;
|
|
5662
5743
|
var HERMES_PLUGIN_DIR = join(homedir(), ".hermes", "plugins", "agentapprove");
|
|
5663
5744
|
function findPython() {
|
|
@@ -5821,17 +5902,17 @@ function uvAvailable() {
|
|
|
5821
5902
|
function isExternallyManagedError(err) {
|
|
5822
5903
|
if (!err || typeof err !== "object")
|
|
5823
5904
|
return false;
|
|
5824
|
-
const
|
|
5825
|
-
const stderr = Buffer.isBuffer(
|
|
5826
|
-
const stdout = Buffer.isBuffer(
|
|
5827
|
-
const message = String(
|
|
5905
|
+
const e = err;
|
|
5906
|
+
const stderr = Buffer.isBuffer(e.stderr) ? e.stderr.toString() : String(e.stderr || "");
|
|
5907
|
+
const stdout = Buffer.isBuffer(e.stdout) ? e.stdout.toString() : String(e.stdout || "");
|
|
5908
|
+
const message = String(e.message || "");
|
|
5828
5909
|
const blob = `${stderr}
|
|
5829
5910
|
${stdout}
|
|
5830
5911
|
${message}`;
|
|
5831
5912
|
return /externally-managed-environment|PEP 668|managed by uv/i.test(blob);
|
|
5832
5913
|
}
|
|
5833
5914
|
function installHermesDepsAdaptive(pythonCommand, deps) {
|
|
5834
|
-
const depsArg = deps.map((
|
|
5915
|
+
const depsArg = deps.map((d) => `"${d}"`).join(" ");
|
|
5835
5916
|
try {
|
|
5836
5917
|
execSync(`${pythonCommand} -m pip install --user --quiet ${depsArg}`, { stdio: "pipe" });
|
|
5837
5918
|
return { ok: true };
|
|
@@ -5901,14 +5982,14 @@ function stageHermesBundle(bytes, targetDir) {
|
|
|
5901
5982
|
mkdirSync(dirname2(targetDir), { recursive: true });
|
|
5902
5983
|
if (existsSync2(targetDir)) {
|
|
5903
5984
|
backupPath = `${targetDir}.bak-${Date.now()}`;
|
|
5904
|
-
|
|
5985
|
+
renameSync2(targetDir, backupPath);
|
|
5905
5986
|
}
|
|
5906
5987
|
try {
|
|
5907
|
-
|
|
5988
|
+
renameSync2(stagedDir, targetDir);
|
|
5908
5989
|
} catch (err) {
|
|
5909
5990
|
if (backupPath) {
|
|
5910
5991
|
try {
|
|
5911
|
-
|
|
5992
|
+
renameSync2(backupPath, targetDir);
|
|
5912
5993
|
backupPath = null;
|
|
5913
5994
|
} catch {}
|
|
5914
5995
|
}
|
|
@@ -5924,7 +6005,7 @@ function stageHermesBundle(bytes, targetDir) {
|
|
|
5924
6005
|
if (backupPath) {
|
|
5925
6006
|
try {
|
|
5926
6007
|
rmSync2(targetDir, { recursive: true, force: true });
|
|
5927
|
-
|
|
6008
|
+
renameSync2(backupPath, targetDir);
|
|
5928
6009
|
backupPath = null;
|
|
5929
6010
|
} catch {}
|
|
5930
6011
|
}
|
|
@@ -5939,6 +6020,7 @@ function stageHermesBundle(bytes, targetDir) {
|
|
|
5939
6020
|
}
|
|
5940
6021
|
function enableHermesPluginForProfile(profile) {
|
|
5941
6022
|
try {
|
|
6023
|
+
enableHermesFollowUp(profile);
|
|
5942
6024
|
execSync(hermesEnableCmd(profile), { stdio: "pipe" });
|
|
5943
6025
|
return { success: true };
|
|
5944
6026
|
} catch (err) {
|
|
@@ -6010,10 +6092,10 @@ async function installHermesPluginViaCli() {
|
|
|
6010
6092
|
function isHermesDisableNoOp(err) {
|
|
6011
6093
|
if (!err || typeof err !== "object")
|
|
6012
6094
|
return false;
|
|
6013
|
-
const
|
|
6014
|
-
const stderr = Buffer.isBuffer(
|
|
6015
|
-
const stdout = Buffer.isBuffer(
|
|
6016
|
-
const haystack = `${
|
|
6095
|
+
const e = err;
|
|
6096
|
+
const stderr = Buffer.isBuffer(e.stderr) ? e.stderr.toString() : String(e.stderr || "");
|
|
6097
|
+
const stdout = Buffer.isBuffer(e.stdout) ? e.stdout.toString() : String(e.stdout || "");
|
|
6098
|
+
const haystack = `${e.message || ""}
|
|
6017
6099
|
${stderr}
|
|
6018
6100
|
${stdout}`.toLowerCase();
|
|
6019
6101
|
return haystack.includes("not enabled") || haystack.includes("not installed") || haystack.includes("is not enabled") || haystack.includes("plugin agentapprove not found") || haystack.includes("plugin 'agentapprove' not found");
|
|
@@ -6054,8 +6136,8 @@ function hermesProfilePluginStatus(profile) {
|
|
|
6054
6136
|
if (installed) {
|
|
6055
6137
|
try {
|
|
6056
6138
|
const configPy = readFileSync(join(dir, "config.py"), "utf-8");
|
|
6057
|
-
const
|
|
6058
|
-
version =
|
|
6139
|
+
const m = configPy.match(/^PLUGIN_VERSION\s*=\s*["']([^"']+)["']/m);
|
|
6140
|
+
version = m ? m[1] : null;
|
|
6059
6141
|
} catch {}
|
|
6060
6142
|
}
|
|
6061
6143
|
return { name: profile, isDefault: profile === HERMES_DEFAULT_PROFILE, installed, version };
|
|
@@ -6072,7 +6154,7 @@ function listHermesProfiles() {
|
|
|
6072
6154
|
}
|
|
6073
6155
|
}
|
|
6074
6156
|
} catch {}
|
|
6075
|
-
return [...names].sort((
|
|
6157
|
+
return [...names].sort((a, b) => a === HERMES_DEFAULT_PROFILE ? -1 : b === HERMES_DEFAULT_PROFILE ? 1 : a.localeCompare(b)).map(hermesProfilePluginStatus);
|
|
6076
6158
|
}
|
|
6077
6159
|
async function syncHermesProfiles(targetProfiles) {
|
|
6078
6160
|
try {
|
|
@@ -6120,7 +6202,7 @@ async function syncHermesProfiles(targetProfiles) {
|
|
|
6120
6202
|
const enabled = enableHermesPluginForProfile(profile);
|
|
6121
6203
|
results.push({ profile, success: enabled.success, error: enabled.error });
|
|
6122
6204
|
}
|
|
6123
|
-
return { ok: results.every((
|
|
6205
|
+
return { ok: results.every((r) => r.success), results };
|
|
6124
6206
|
}
|
|
6125
6207
|
var SYSTEM_DEPS = [
|
|
6126
6208
|
{
|
|
@@ -6253,7 +6335,7 @@ async function checkSystemDependencies() {
|
|
|
6253
6335
|
return true;
|
|
6254
6336
|
const pm = detectPackageManager();
|
|
6255
6337
|
const pmLabel = pm === "macos" ? "macOS (Homebrew)" : pm === "windows" ? "Windows" : pm === "apt" ? "apt (Debian/Ubuntu)" : pm === "dnf" ? "dnf (Fedora/RHEL)" : "apk (Alpine)";
|
|
6256
|
-
const requiredMissing = missing.filter((
|
|
6338
|
+
const requiredMissing = missing.filter((d) => d.required);
|
|
6257
6339
|
const lines = missing.map((dep) => {
|
|
6258
6340
|
const cmd = dep.install[pm];
|
|
6259
6341
|
return `${source_default.red("x")} ${source_default.bold(dep.name)} - ${dep.description}
|
|
@@ -6275,18 +6357,18 @@ async function checkSystemDependencies() {
|
|
|
6275
6357
|
const allSamePrefix = uniqueCommands.every((c) => c.startsWith("sudo apt-get") || c.startsWith("sudo dnf") || c.startsWith("apk") || c.startsWith("brew") || c.startsWith("winget"));
|
|
6276
6358
|
let combinedCommand = "";
|
|
6277
6359
|
if (allSamePrefix && pm === "apt") {
|
|
6278
|
-
combinedCommand = `sudo apt-get install -y ${requiredMissing.map((
|
|
6360
|
+
combinedCommand = `sudo apt-get install -y ${requiredMissing.map((d) => d.name === "base64" ? "coreutils" : d.name === "xxd" ? "xxd" : d.name).join(" ")}`;
|
|
6279
6361
|
} else if (allSamePrefix && pm === "dnf") {
|
|
6280
|
-
combinedCommand = `sudo dnf install -y ${requiredMissing.map((
|
|
6362
|
+
combinedCommand = `sudo dnf install -y ${requiredMissing.map((d) => d.name === "base64" ? "coreutils" : d.name === "xxd" ? "vim-common" : d.name).join(" ")}`;
|
|
6281
6363
|
} else if (allSamePrefix && pm === "alpine") {
|
|
6282
|
-
combinedCommand = `apk add ${requiredMissing.map((
|
|
6364
|
+
combinedCommand = `apk add ${requiredMissing.map((d) => d.name === "base64" ? "coreutils" : d.name === "xxd" ? "vim" : d.name).join(" ")}`;
|
|
6283
6365
|
} else if (allSamePrefix && pm === "macos") {
|
|
6284
|
-
const brewPkgs = requiredMissing.filter((
|
|
6366
|
+
const brewPkgs = requiredMissing.filter((d) => d.install.macos !== "included with macOS").map((d) => d.name === "xxd" ? "vim" : d.name);
|
|
6285
6367
|
if (brewPkgs.length > 0) {
|
|
6286
6368
|
combinedCommand = `brew install ${brewPkgs.join(" ")}`;
|
|
6287
6369
|
}
|
|
6288
6370
|
} else if (pm === "windows") {
|
|
6289
|
-
const winPkgs = requiredMissing.filter((
|
|
6371
|
+
const winPkgs = requiredMissing.filter((d) => d.install.windows !== "included with Git Bash").map((d) => d.install.windows);
|
|
6290
6372
|
if (winPkgs.length > 0) {
|
|
6291
6373
|
combinedCommand = winPkgs.join(" && ");
|
|
6292
6374
|
}
|
|
@@ -6309,9 +6391,9 @@ async function checkSystemDependencies() {
|
|
|
6309
6391
|
try {
|
|
6310
6392
|
execSync(combinedCommand, { stdio: "pipe" });
|
|
6311
6393
|
installSpinner.stop("Dependencies installed");
|
|
6312
|
-
const stillMissing = requiredMissing.filter((
|
|
6394
|
+
const stillMissing = requiredMissing.filter((d) => !checkCommand(d.name));
|
|
6313
6395
|
if (stillMissing.length > 0) {
|
|
6314
|
-
v2.warn(`Could not verify: ${stillMissing.map((
|
|
6396
|
+
v2.warn(`Could not verify: ${stillMissing.map((d) => d.name).join(", ")}. Continuing anyway.`);
|
|
6315
6397
|
}
|
|
6316
6398
|
} catch (err) {
|
|
6317
6399
|
installSpinner.stop("Installation failed");
|
|
@@ -6392,7 +6474,7 @@ function describeExistingTokenStatus(preflight) {
|
|
|
6392
6474
|
}
|
|
6393
6475
|
async function promptTokenRecoveryAction(preflight) {
|
|
6394
6476
|
if (preflight.kind === "expired") {
|
|
6395
|
-
const
|
|
6477
|
+
const choice = await le({
|
|
6396
6478
|
message: "Your saved token has expired. How would you like to continue?",
|
|
6397
6479
|
options: [
|
|
6398
6480
|
{ value: "refresh", label: "Refresh token", hint: "Keeps the existing encryption key; settings resync from your account on the next event" },
|
|
@@ -6400,9 +6482,9 @@ async function promptTokenRecoveryAction(preflight) {
|
|
|
6400
6482
|
{ value: "cancel", label: "Cancel", hint: "Exit the installer" }
|
|
6401
6483
|
]
|
|
6402
6484
|
});
|
|
6403
|
-
if (lD(
|
|
6485
|
+
if (lD(choice))
|
|
6404
6486
|
return "cancel";
|
|
6405
|
-
return
|
|
6487
|
+
return choice;
|
|
6406
6488
|
}
|
|
6407
6489
|
const choice = await le({
|
|
6408
6490
|
message: "Your saved token is no longer valid. How would you like to continue?",
|
|
@@ -6435,9 +6517,9 @@ async function installCommand() {
|
|
|
6435
6517
|
let existingKeyId = null;
|
|
6436
6518
|
if (existingConfig) {
|
|
6437
6519
|
existingTokenPreview = hasExistingToken ? existingConfig.token.slice(0, 15) + "..." : "Not set";
|
|
6438
|
-
const
|
|
6439
|
-
if (existsSync2(
|
|
6440
|
-
const keyHex = readFileSync(
|
|
6520
|
+
const e2eKeyPath = join(getAgentApproveDir(), "e2e-key");
|
|
6521
|
+
if (existsSync2(e2eKeyPath)) {
|
|
6522
|
+
const keyHex = readFileSync(e2eKeyPath, "utf-8").trim();
|
|
6441
6523
|
existingKeyId = createHash("sha256").update(Buffer.from(keyHex, "hex")).digest("hex").slice(0, 8);
|
|
6442
6524
|
}
|
|
6443
6525
|
}
|
|
@@ -6465,6 +6547,9 @@ Monitor activity, enforce policy, and approve with a tap.`, "About");
|
|
|
6465
6547
|
he("Installation cancelled");
|
|
6466
6548
|
process.exit(0);
|
|
6467
6549
|
}
|
|
6550
|
+
if (selectedAgents.includes("openclaw")) {
|
|
6551
|
+
v2.info(CONVERSATION_ACCESS_NOTICE);
|
|
6552
|
+
}
|
|
6468
6553
|
const setupProfileSummary = existingConfig ? formatSetupProfileBlock("Existing config", getInitialInstallConfig("existing-config", existingConfig), [
|
|
6469
6554
|
`Connection token: ${existingTokenPreview} - ${describeExistingTokenStatus(existingTokenPreflight)}.`,
|
|
6470
6555
|
...existingKeyId ? [`Encryption key ID: ${existingKeyId} - already installed for this computer.`] : []
|
|
@@ -6534,7 +6619,7 @@ Monitor activity, enforce policy, and approve with a tap.`, "About");
|
|
|
6534
6619
|
message: "If Agent Approve is unreachable, hooks should:",
|
|
6535
6620
|
initialValue: failBehavior,
|
|
6536
6621
|
options: [
|
|
6537
|
-
{ value: "ask", label: "Ask", hint: "
|
|
6622
|
+
{ value: "ask", label: "Ask", hint: "Ask locally when supported; otherwise block (recommended)" },
|
|
6538
6623
|
{ value: "deny", label: "Deny", hint: "Block all commands until service is restored" },
|
|
6539
6624
|
{ value: "allow", label: "Allow", hint: "Allow all commands to proceed without approval" }
|
|
6540
6625
|
]
|
|
@@ -6700,7 +6785,7 @@ Monitor activity, enforce policy, and approve with a tap.`, "About");
|
|
|
6700
6785
|
} else if (shouldCreateFreshPairing(connectionMethod)) {
|
|
6701
6786
|
const pairingMethod = connectionMethod;
|
|
6702
6787
|
if (backupOldKeyTo) {
|
|
6703
|
-
|
|
6788
|
+
renameSync2(existingKeyPath, backupOldKeyTo);
|
|
6704
6789
|
v2.success(`Old key backed up to ${backupOldKeyTo}`);
|
|
6705
6790
|
backupOldKeyTo = null;
|
|
6706
6791
|
}
|
|
@@ -6807,19 +6892,28 @@ Monitor activity, enforce policy, and approve with a tap.`, "About");
|
|
|
6807
6892
|
if (hookDownloadPlan.files.length > 0) {
|
|
6808
6893
|
const downloadSpinner = _2();
|
|
6809
6894
|
downloadSpinner.start("Downloading hook scripts");
|
|
6810
|
-
const downloadResult = await copyHookScripts2(hooksDir, token, hookDownloadPlan.files, {
|
|
6895
|
+
const downloadResult = await copyHookScripts2(hooksDir, token, hookDownloadPlan.files, {
|
|
6896
|
+
apiUrl,
|
|
6897
|
+
optionalFiles: BACKGROUND_FILTER_FILES,
|
|
6898
|
+
onRateLimit: (_file, seconds) => downloadSpinner.message(`Download limit reached. Retrying in ${seconds}s…`)
|
|
6899
|
+
});
|
|
6811
6900
|
const summary = formatHookDownloadSummary(hookDownloadPlan);
|
|
6812
6901
|
if (downloadResult.terminalFailure) {
|
|
6813
|
-
downloadSpinner.stop(`
|
|
6902
|
+
downloadSpinner.stop(`Fetched ${downloadResult.downloaded} of ${hookDownloadPlan.files.length} hook files; no changes saved`);
|
|
6814
6903
|
const message = describeDownloadTerminalFailure(downloadResult.terminalFailure.kind);
|
|
6815
6904
|
v2.error(message);
|
|
6816
6905
|
he("Hook download stopped before completion.");
|
|
6817
6906
|
process.exit(1);
|
|
6818
6907
|
} else if (downloadResult.failed.length > 0) {
|
|
6819
|
-
downloadSpinner.stop(`
|
|
6820
|
-
v2.warn(`
|
|
6908
|
+
downloadSpinner.stop(`Hook installation incomplete (${downloadResult.downloaded} files fetched)`);
|
|
6909
|
+
v2.warn(`Could not install: ${downloadResult.failed.join(", ")}`);
|
|
6910
|
+
he("Required hook downloads are incomplete. Please rerun the installer.");
|
|
6911
|
+
process.exit(1);
|
|
6821
6912
|
} else {
|
|
6822
|
-
downloadSpinner.stop(`Hook
|
|
6913
|
+
downloadSpinner.stop(`Hook files fetched (${downloadResult.downloaded} files: ${summary})`);
|
|
6914
|
+
if (downloadResult.optionalFailed.length) {
|
|
6915
|
+
v2.warn("Background activity filters could not be refreshed. Any previous copy is retained; required hooks are ready.");
|
|
6916
|
+
}
|
|
6823
6917
|
}
|
|
6824
6918
|
} else {
|
|
6825
6919
|
v2.success("No hook scripts needed for the selected agents");
|
|
@@ -6872,16 +6966,16 @@ AGENTAPPROVE_E2E_MODE=${installMode}
|
|
|
6872
6966
|
filesToModify.push(join(homedir(), ".codex", "config.toml"));
|
|
6873
6967
|
}
|
|
6874
6968
|
if (agentId === "opencode") {
|
|
6875
|
-
filesToModify.push(
|
|
6969
|
+
filesToModify.push("OpenCode plugin cache");
|
|
6876
6970
|
}
|
|
6877
6971
|
if (agentId === "openclaw") {
|
|
6878
|
-
filesToModify.push(
|
|
6972
|
+
filesToModify.push("OpenClaw plugin registry");
|
|
6879
6973
|
}
|
|
6880
6974
|
if (agentId === "pi") {
|
|
6881
|
-
filesToModify.push("Pi package registry
|
|
6975
|
+
filesToModify.push("Pi package registry");
|
|
6882
6976
|
}
|
|
6883
6977
|
if (agentId === "hermes") {
|
|
6884
|
-
filesToModify.push(
|
|
6978
|
+
filesToModify.push("~/.hermes/plugins/agentapprove/ (plugin update; mobile follow-up enabled)");
|
|
6885
6979
|
}
|
|
6886
6980
|
if (agentId === "vscode-agent") {
|
|
6887
6981
|
const vsCodeVariants = findInstalledVSCodeVariants();
|
|
@@ -6890,10 +6984,13 @@ AGENTAPPROVE_E2E_MODE=${installMode}
|
|
|
6890
6984
|
}
|
|
6891
6985
|
}
|
|
6892
6986
|
}
|
|
6893
|
-
|
|
6987
|
+
const homePrefix = `${homedir()}/`;
|
|
6988
|
+
const fileSummary = filesToModify.map((path) => path.startsWith(homePrefix) ? `~/${path.slice(homePrefix.length)}` : path);
|
|
6989
|
+
v2.step("Files to be modified");
|
|
6990
|
+
v2.message(`${fileSummary.join(`
|
|
6894
6991
|
`)}
|
|
6895
6992
|
|
|
6896
|
-
|
|
6993
|
+
Timestamped backups will be created.`);
|
|
6897
6994
|
const confirm = await ce({
|
|
6898
6995
|
message: "Proceed with automatic installation?"
|
|
6899
6996
|
});
|
|
@@ -6905,13 +7002,17 @@ Backups will be created with timestamp`, "Files to be modified");
|
|
|
6905
7002
|
const agent = AGENTS[agentId];
|
|
6906
7003
|
const spinner = _2();
|
|
6907
7004
|
const spinnerMsg = agentId === "pi" ? `Installing ${agent.name} extension` : agentId === "openclaw" || agentId === "hermes" ? `Installing ${agent.name} plugin` : `Configuring ${agent.name}`;
|
|
6908
|
-
|
|
7005
|
+
if (agentId !== "openclaw")
|
|
7006
|
+
spinner.start(spinnerMsg);
|
|
6909
7007
|
const result = await installHooksForAgent(agentId, hooksDir, installMode);
|
|
6910
7008
|
if (result.success) {
|
|
6911
7009
|
const installedHookNames = result.hooks.join(", ");
|
|
6912
7010
|
const backupMsg = result.backupPath ? source_default.dim(` (backup created)`) : "";
|
|
6913
7011
|
const agentName = source_default.cyan(agent.name);
|
|
6914
|
-
|
|
7012
|
+
if (agentId === "openclaw")
|
|
7013
|
+
v2.success(`${agentName}: ${installedHookNames}${backupMsg}`);
|
|
7014
|
+
else
|
|
7015
|
+
spinner.stop(`${agentName}: ${installedHookNames}${backupMsg}`);
|
|
6915
7016
|
if (agentId === "vscode-agent") {
|
|
6916
7017
|
const vsCodeSpinner = _2();
|
|
6917
7018
|
vsCodeSpinner.start("Registering hook path in VS Code settings");
|
|
@@ -6950,7 +7051,10 @@ Backups will be created with timestamp`, "Files to be modified");
|
|
|
6950
7051
|
}
|
|
6951
7052
|
} else {
|
|
6952
7053
|
failedSetupAgents.add(agentId);
|
|
6953
|
-
|
|
7054
|
+
if (agentId === "openclaw")
|
|
7055
|
+
v2.error(`${agent.name} configuration failed`);
|
|
7056
|
+
else
|
|
7057
|
+
spinner.stop(`${agent.name} configuration failed`);
|
|
6954
7058
|
if (agentId === "openclaw") {
|
|
6955
7059
|
v2.warn(`Could not install ${OPENCLAW_PLUGIN_SPEC} via OpenClaw CLI.
|
|
6956
7060
|
` + ` Error: ${result.error || "unknown"}
|
|
@@ -6971,7 +7075,8 @@ Backups will be created with timestamp`, "Files to be modified");
|
|
|
6971
7075
|
` + ` 4. Write the SHA-256 to ~/.hermes/plugins/agentapprove/.bundle-hash
|
|
6972
7076
|
` + ` 5. pip install --user cryptography httpx
|
|
6973
7077
|
` + ` (uv-managed Python: uv pip install --system --break-system-packages --python $(which python3.12) cryptography httpx)
|
|
6974
|
-
` + ` 6. hermes
|
|
7078
|
+
` + ` 6. hermes config set plugins.entries.agentapprove.allow_gateway_injection true
|
|
7079
|
+
` + ` 7. hermes plugins enable agentapprove
|
|
6975
7080
|
` + ` Then re-run: npx agentapprove`);
|
|
6976
7081
|
}
|
|
6977
7082
|
}
|
|
@@ -7053,17 +7158,17 @@ function inspectSetup(agentIds) {
|
|
|
7053
7158
|
return result("failed", "not_configured");
|
|
7054
7159
|
const filesReady = (file) => {
|
|
7055
7160
|
const path = join(getAgentApproveDir(), "hooks", file);
|
|
7056
|
-
return existsSync2(path) && statSync(path).size > 0 && (statSync(path).mode & 73) !== 0;
|
|
7161
|
+
return existsSync2(path) && statSync(path).size > 0 && (!file.endsWith(".sh") || (statSync(path).mode & 73) !== 0);
|
|
7057
7162
|
};
|
|
7058
|
-
if (!SHARED_HOOK_FILES.every(filesReady))
|
|
7163
|
+
if (!SHARED_HOOK_FILES.filter((file) => !BACKGROUND_FILTER_FILES.includes(file)).every(filesReady))
|
|
7059
7164
|
return result("failed", "missing_files");
|
|
7060
|
-
if (
|
|
7165
|
+
if (spawnSync2("bash", ["-c", "command -v curl >/dev/null && command -v jq >/dev/null && command -v openssl >/dev/null"], { timeout: 5000 }).status !== 0)
|
|
7061
7166
|
return result("failed", "missing_dependency");
|
|
7062
7167
|
if (isAntigravityAgent(agentId)) {
|
|
7063
7168
|
if (!existsSync2(join(getAntigravityPluginRoot(agentId), "plugin.json")))
|
|
7064
7169
|
return result("failed", "missing_files");
|
|
7065
7170
|
const mode = existing.e2eMode ?? "approval";
|
|
7066
|
-
const hooks = mode === "observe" ? agent.hooks.filter((
|
|
7171
|
+
const hooks = mode === "observe" ? agent.hooks.filter((h) => h.name !== "Stop") : agent.hooks;
|
|
7067
7172
|
return checkHookConfiguration(agentId, config, "agentapprove", hooks, "approval", filesReady, (file, name) => buildAntigravityHookCommand(join(getAgentApproveDir(), "hooks", file), agentId, name, mode));
|
|
7068
7173
|
}
|
|
7069
7174
|
return checkHookConfiguration(agentId, config, agent.hooksKey, agent.hooks, existing.e2eMode ?? "approval", filesReady, (file) => buildHookCommand(join(getAgentApproveDir(), "hooks", file), agentId));
|
|
@@ -7146,6 +7251,8 @@ async function profilesCommand() {
|
|
|
7146
7251
|
toUpdate.length ? `Update to v${HERMES_PLUGIN_VERSION}: ${toUpdate.join(", ")}` : null,
|
|
7147
7252
|
toRemove.length ? `Remove from: ${toRemove.join(", ")}` : null
|
|
7148
7253
|
].filter(Boolean);
|
|
7254
|
+
if (toSync.length)
|
|
7255
|
+
planLines.push("Allow mobile follow-up replies in the selected Hermes profiles.");
|
|
7149
7256
|
me(planLines.join(`
|
|
7150
7257
|
`), "Planned changes");
|
|
7151
7258
|
const confirm = await ce({ message: "Apply these changes?" });
|
|
@@ -7164,20 +7271,20 @@ async function profilesCommand() {
|
|
|
7164
7271
|
process.exit(1);
|
|
7165
7272
|
}
|
|
7166
7273
|
s.stop(sync.ok ? "Done" : "Done (some profiles failed)");
|
|
7167
|
-
for (const
|
|
7168
|
-
const action = toUpdate.includes(
|
|
7169
|
-
if (
|
|
7170
|
-
v2.success(`${
|
|
7274
|
+
for (const r of sync.results) {
|
|
7275
|
+
const action = toUpdate.includes(r.profile) ? "updated to" : "installed";
|
|
7276
|
+
if (r.success)
|
|
7277
|
+
v2.success(`${r.profile}: Agent Approve ${action} v${HERMES_PLUGIN_VERSION}`);
|
|
7171
7278
|
else
|
|
7172
|
-
v2.error(`${
|
|
7279
|
+
v2.error(`${r.profile}: ${r.error ?? "failed"}`);
|
|
7173
7280
|
}
|
|
7174
7281
|
}
|
|
7175
7282
|
for (const profile of toRemove) {
|
|
7176
|
-
const
|
|
7177
|
-
if (
|
|
7283
|
+
const r = removeHermesPluginFromProfile(profile);
|
|
7284
|
+
if (r.success)
|
|
7178
7285
|
v2.success(`${profile}: Agent Approve removed`);
|
|
7179
7286
|
else
|
|
7180
|
-
v2.warn(`${profile}: removal partial (${
|
|
7287
|
+
v2.warn(`${profile}: removal partial (${r.error ?? "unknown"})`);
|
|
7181
7288
|
}
|
|
7182
7289
|
ge("Hermes profiles updated.");
|
|
7183
7290
|
}
|
|
@@ -7276,27 +7383,27 @@ async function statusCommand() {
|
|
|
7276
7383
|
if (isAntigravityAgent(agentId)) {
|
|
7277
7384
|
const bundle = config.agentapprove;
|
|
7278
7385
|
if (bundle) {
|
|
7279
|
-
const installedHooks = agent.hooks.filter((
|
|
7280
|
-
const hookEntry = bundle[
|
|
7386
|
+
const installedHooks = agent.hooks.filter((h) => {
|
|
7387
|
+
const hookEntry = bundle[h.name];
|
|
7281
7388
|
return !!hookEntry && JSON.stringify(hookEntry).includes("agentapprove");
|
|
7282
7389
|
});
|
|
7283
7390
|
if (installedHooks.length > 0) {
|
|
7284
|
-
console.log(` ${source_default.green("✓")} ${agent.name}: ${installedHooks.map((
|
|
7391
|
+
console.log(` ${source_default.green("✓")} ${agent.name}: ${installedHooks.map((h) => formatHookStatusLabel(h.name)).join(", ")}`);
|
|
7285
7392
|
}
|
|
7286
7393
|
}
|
|
7287
7394
|
continue;
|
|
7288
7395
|
}
|
|
7289
7396
|
const hooksConfig = agent.hooksKey === "" ? config : config[agent.hooksKey];
|
|
7290
7397
|
if (hooksConfig) {
|
|
7291
|
-
const installedHooks = agent.hooks.filter((
|
|
7292
|
-
const hookEntry = hooksConfig[
|
|
7398
|
+
const installedHooks = agent.hooks.filter((h) => {
|
|
7399
|
+
const hookEntry = hooksConfig[h.name];
|
|
7293
7400
|
if (!hookEntry)
|
|
7294
7401
|
return false;
|
|
7295
7402
|
const str = JSON.stringify(hookEntry);
|
|
7296
7403
|
return str.includes("agentapprove");
|
|
7297
7404
|
});
|
|
7298
7405
|
if (installedHooks.length > 0) {
|
|
7299
|
-
console.log(` ${source_default.green("✓")} ${agent.name}: ${installedHooks.map((
|
|
7406
|
+
console.log(` ${source_default.green("✓")} ${agent.name}: ${installedHooks.map((h) => formatHookStatusLabel(h.name)).join(", ")}`);
|
|
7300
7407
|
}
|
|
7301
7408
|
}
|
|
7302
7409
|
}
|
|
@@ -7390,7 +7497,7 @@ async function disableCommand() {
|
|
|
7390
7497
|
const tmpPath = `${statePath}.tmp-${process.pid}`;
|
|
7391
7498
|
writeFileSync(tmpPath, JSON.stringify(merged, null, 2) + `
|
|
7392
7499
|
`, { mode: 384 });
|
|
7393
|
-
|
|
7500
|
+
renameSync2(tmpPath, statePath);
|
|
7394
7501
|
failed = false;
|
|
7395
7502
|
} catch {
|
|
7396
7503
|
failed = true;
|
|
@@ -7530,7 +7637,7 @@ async function enableCommand() {
|
|
|
7530
7637
|
const legacyDisabledPath = join(aaDir, "env.disabled");
|
|
7531
7638
|
const statePath = join(aaDir, DISABLED_STATE_FILENAME);
|
|
7532
7639
|
if (!existsSync2(envPath) && existsSync2(legacyDisabledPath)) {
|
|
7533
|
-
|
|
7640
|
+
renameSync2(legacyDisabledPath, envPath);
|
|
7534
7641
|
console.log(source_default.green(`
|
|
7535
7642
|
✓ Restored ~/.agentapprove/env (legacy disable).`));
|
|
7536
7643
|
}
|
|
@@ -7817,16 +7924,16 @@ async function restoreCommand() {
|
|
|
7817
7924
|
console.log(source_default.cyan(`
|
|
7818
7925
|
Restoring original configurations...
|
|
7819
7926
|
`));
|
|
7820
|
-
const { readdirSync
|
|
7927
|
+
const { readdirSync, copyFileSync } = await import("fs");
|
|
7821
7928
|
for (const [agentId, agent] of Object.entries(AGENTS)) {
|
|
7822
7929
|
const configDir = dirname2(agent.configPath);
|
|
7823
7930
|
if (!existsSync2(configDir))
|
|
7824
7931
|
continue;
|
|
7825
|
-
const files =
|
|
7826
|
-
const backups = files.filter((
|
|
7932
|
+
const files = readdirSync(configDir);
|
|
7933
|
+
const backups = files.filter((f) => f.startsWith(agent.configPath.split("/").pop()) && f.includes(".backup.")).sort().reverse();
|
|
7827
7934
|
if (backups.length > 0) {
|
|
7828
7935
|
const latestBackup = join(configDir, backups[0]);
|
|
7829
|
-
|
|
7936
|
+
copyFileSync(latestBackup, agent.configPath);
|
|
7830
7937
|
console.log(` ${source_default.green("✓")} ${agent.name} restored from ${backups[0]}`);
|
|
7831
7938
|
}
|
|
7832
7939
|
}
|
|
@@ -8096,11 +8203,11 @@ async function pairCommand() {
|
|
|
8096
8203
|
v2.info("E2E encryption disabled — event content will be visible on the web dashboard");
|
|
8097
8204
|
updateEnvValue("AGENTAPPROVE_E2E_ENABLED", "false");
|
|
8098
8205
|
} else if (selectedKeyId === "__generate__") {
|
|
8099
|
-
const currentKey = keys.find((
|
|
8206
|
+
const currentKey = keys.find((k) => k.isCurrent);
|
|
8100
8207
|
if (currentKey) {
|
|
8101
|
-
const
|
|
8102
|
-
const backupPath = join(
|
|
8103
|
-
|
|
8208
|
+
const agentApproveDir = getAgentApproveDir();
|
|
8209
|
+
const backupPath = join(agentApproveDir, `e2e-key.${currentKey.keyId}.bak`);
|
|
8210
|
+
renameSync2(currentKey.path, backupPath);
|
|
8104
8211
|
v2.info(`Previous key backed up (${currentKey.keyId})`);
|
|
8105
8212
|
}
|
|
8106
8213
|
e2eUserKey = randomBytes(32).toString("hex");
|
|
@@ -8117,7 +8224,7 @@ async function pairCommand() {
|
|
|
8117
8224
|
});
|
|
8118
8225
|
v2.success(`New key generated (${e2eKeyId})`);
|
|
8119
8226
|
} else {
|
|
8120
|
-
const selectedKey = keys.find((
|
|
8227
|
+
const selectedKey = keys.find((k) => k.keyId === selectedKeyId);
|
|
8121
8228
|
if (!selectedKey) {
|
|
8122
8229
|
v2.error("Selected key not found.");
|
|
8123
8230
|
process.exit(1);
|
|
@@ -8233,6 +8340,10 @@ async function updateHookScriptsWithToken(token, apiUrl) {
|
|
|
8233
8340
|
if (!existsSync2(hooksDir)) {
|
|
8234
8341
|
throw new Error("Hooks directory not found");
|
|
8235
8342
|
}
|
|
8343
|
+
const filters = await copyHookScripts2(hooksDir, token, BACKGROUND_FILTER_FILES, { apiUrl });
|
|
8344
|
+
if (filters.failed.length || filters.terminalFailure) {
|
|
8345
|
+
v2.warn("Background activity filters could not be refreshed. The previous copy is retained.");
|
|
8346
|
+
}
|
|
8236
8347
|
const hookFiles = [
|
|
8237
8348
|
"claude-pre-tool.sh",
|
|
8238
8349
|
"claude-post-tool.sh",
|