agentapprove 0.1.46 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -0
- package/dist/cli.js +669 -528
- 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,94 @@ 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
|
+
import { isDeepStrictEqual } from "node:util";
|
|
1848
|
+
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.";
|
|
1849
|
+
function runOpenClaw(args) {
|
|
1850
|
+
const result = spawnSync("openclaw", args, { stdio: "inherit", shell: process.platform === "win32" });
|
|
1851
|
+
return !result.error && result.status === 0;
|
|
1852
|
+
}
|
|
1853
|
+
function mergeOpenClawConfig(config, conversationAccess) {
|
|
1854
|
+
const plugins = config.plugins ?? {};
|
|
1855
|
+
const entries = plugins.entries ?? {};
|
|
1856
|
+
const entry = entries.openclaw ?? {};
|
|
1857
|
+
return {
|
|
1858
|
+
...config,
|
|
1859
|
+
plugins: {
|
|
1860
|
+
...plugins,
|
|
1861
|
+
entries: {
|
|
1862
|
+
...entries,
|
|
1863
|
+
openclaw: {
|
|
1864
|
+
...entry,
|
|
1865
|
+
hooks: { ...entry.hooks, allowConversationAccess: conversationAccess },
|
|
1866
|
+
...entry.config === undefined ? {} : { config: { ...entry.config } }
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
},
|
|
1870
|
+
hooks: { ...config.hooks, internal: { enabled: true, ...config.hooks?.internal } }
|
|
1871
|
+
};
|
|
1872
|
+
}
|
|
1873
|
+
async function installOpenClaw(options) {
|
|
1874
|
+
const run = options.run ?? runOpenClaw;
|
|
1875
|
+
const fail = (error) => ({ success: false, label: "Agent Approve plugin", error });
|
|
1876
|
+
try {
|
|
1877
|
+
options.readConfig();
|
|
1878
|
+
} catch {
|
|
1879
|
+
return fail("Could not read OpenClaw configuration as JSON. No plugin installation or permission changes were made. Check the config before retrying.");
|
|
1880
|
+
}
|
|
1881
|
+
const installed = options.readVersion();
|
|
1882
|
+
if (installed !== options.version) {
|
|
1883
|
+
const args = ["plugins", "install", options.spec];
|
|
1884
|
+
if (installed !== null) {
|
|
1885
|
+
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.`)) {
|
|
1886
|
+
return fail("Plugin replacement declined; the existing install was kept.");
|
|
1887
|
+
}
|
|
1888
|
+
args.push("--force");
|
|
1889
|
+
}
|
|
1890
|
+
if (!run(args))
|
|
1891
|
+
return fail("OpenClaw installation was declined or failed. Review the host output above; no permissions were automatically accepted.");
|
|
1892
|
+
const actual = options.readVersion();
|
|
1893
|
+
if (actual !== options.version)
|
|
1894
|
+
return fail(`OpenClaw installed ${actual ?? "an unverified version"}, expected ${options.version}.`);
|
|
1895
|
+
}
|
|
1896
|
+
try {
|
|
1897
|
+
const current = options.readConfig();
|
|
1898
|
+
const updated = mergeOpenClawConfig(current, true);
|
|
1899
|
+
if (!isDeepStrictEqual(current, updated))
|
|
1900
|
+
options.writeConfig(updated);
|
|
1901
|
+
} catch {
|
|
1902
|
+
return fail("Could not read or save OpenClaw configuration. The plugin package is present; check the config and retry setup before using it.");
|
|
1903
|
+
}
|
|
1904
|
+
const action = options.mode === "approval" ? "enable" : "disable";
|
|
1905
|
+
if (!run(["plugins", action, "openclaw"]))
|
|
1906
|
+
return fail(`Agent Approve v${options.version} is installed, but OpenClaw ${action} did not complete. Review the host output above. If the Gateway is still reloading, wait for it to finish, then run: openclaw plugins ${action} openclaw. Activation remains controlled by OpenClaw.`);
|
|
1907
|
+
return {
|
|
1908
|
+
success: true,
|
|
1909
|
+
label: `Agent Approve plugin v${options.version} (conversation access included)`
|
|
1910
|
+
};
|
|
1911
|
+
}
|
|
1912
|
+
|
|
1825
1913
|
// src/env-preserve.ts
|
|
1826
1914
|
var MANAGED_ENV_KEYS = new Set([
|
|
1827
1915
|
"AGENTAPPROVE_API",
|
|
@@ -1835,13 +1923,15 @@ var MANAGED_ENV_KEYS = new Set([
|
|
|
1835
1923
|
"AGENTAPPROVE_FAIL_BEHAVIOR"
|
|
1836
1924
|
]);
|
|
1837
1925
|
var ACCOUNT_SYNCED_UNMANAGED_KEYS = new Set([
|
|
1926
|
+
"AGENTAPPROVE_FILTER_BACKGROUND_ACTIVITY",
|
|
1927
|
+
"AGENTAPPROVE_BACKGROUND_FILTER_SYNC_PENDING",
|
|
1838
1928
|
"AGENTAPPROVE_QUESTION_INPUT_MODE",
|
|
1839
1929
|
"AGENTAPPROVE_TIMEOUT"
|
|
1840
1930
|
]);
|
|
1841
1931
|
var ENV_KEY_PATTERN = /^AGENTAPPROVE_[A-Z0-9_]+$/;
|
|
1842
1932
|
function isPreservedEnvKey(key) {
|
|
1843
|
-
const
|
|
1844
|
-
return ENV_KEY_PATTERN.test(
|
|
1933
|
+
const k = key.trim();
|
|
1934
|
+
return ENV_KEY_PATTERN.test(k) && !MANAGED_ENV_KEYS.has(k);
|
|
1845
1935
|
}
|
|
1846
1936
|
function renderPreservedEnvSection(preserved) {
|
|
1847
1937
|
if (!preserved)
|
|
@@ -1858,8 +1948,8 @@ ${lines.join(`
|
|
|
1858
1948
|
`;
|
|
1859
1949
|
}
|
|
1860
1950
|
function normalizeEmail(value) {
|
|
1861
|
-
const
|
|
1862
|
-
return
|
|
1951
|
+
const v = value?.trim().toLowerCase();
|
|
1952
|
+
return v ? v : undefined;
|
|
1863
1953
|
}
|
|
1864
1954
|
function resolvePreservation(input) {
|
|
1865
1955
|
const existing = input.existing ?? undefined;
|
|
@@ -1872,9 +1962,9 @@ function resolvePreservation(input) {
|
|
|
1872
1962
|
case "refresh":
|
|
1873
1963
|
case "repair":
|
|
1874
1964
|
case "pair": {
|
|
1875
|
-
const
|
|
1876
|
-
const
|
|
1877
|
-
if (
|
|
1965
|
+
const a = normalizeEmail(input.verifiedEmail);
|
|
1966
|
+
const b = normalizeEmail(input.pairedEmail);
|
|
1967
|
+
if (a && b && a === b) {
|
|
1878
1968
|
return { preserved: existing.preserved, letAccountWin: false };
|
|
1879
1969
|
}
|
|
1880
1970
|
return { preserved: machineLocalOnly(existing.preserved), letAccountWin: true };
|
|
@@ -2401,10 +2491,10 @@ var source_default = chalk;
|
|
|
2401
2491
|
|
|
2402
2492
|
// src/cli.ts
|
|
2403
2493
|
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";
|
|
2494
|
+
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
2495
|
import { homedir, hostname, platform, tmpdir } from "os";
|
|
2406
2496
|
import { join, dirname as dirname2, sep as sep2 } from "path";
|
|
2407
|
-
import { execSync, spawnSync } from "child_process";
|
|
2497
|
+
import { execSync, spawnSync as spawnSync2 } from "child_process";
|
|
2408
2498
|
import { randomBytes, createHash } from "crypto";
|
|
2409
2499
|
|
|
2410
2500
|
// src/uninstall-utils.ts
|
|
@@ -2690,8 +2780,8 @@ function removeAgentApproveHookEntries(hooksConfig, hookNames) {
|
|
|
2690
2780
|
if (!hookEntry)
|
|
2691
2781
|
continue;
|
|
2692
2782
|
if (Array.isArray(hookEntry)) {
|
|
2693
|
-
const filtered = hookEntry.filter((
|
|
2694
|
-
const str = JSON.stringify(
|
|
2783
|
+
const filtered = hookEntry.filter((e) => {
|
|
2784
|
+
const str = JSON.stringify(e);
|
|
2695
2785
|
return !str.includes("agentapprove");
|
|
2696
2786
|
});
|
|
2697
2787
|
if (filtered.length !== hookEntry.length) {
|
|
@@ -2998,11 +3088,11 @@ async function validateExistingToken(token, apiUrl, apiVersion, options = {}) {
|
|
|
2998
3088
|
}
|
|
2999
3089
|
const status = response.status;
|
|
3000
3090
|
if (response.ok) {
|
|
3001
|
-
const
|
|
3091
|
+
const body = await safeReadText(response);
|
|
3002
3092
|
return {
|
|
3003
3093
|
kind: "valid",
|
|
3004
3094
|
summary: "verified - token is valid",
|
|
3005
|
-
cachedContent:
|
|
3095
|
+
cachedContent: body,
|
|
3006
3096
|
status
|
|
3007
3097
|
};
|
|
3008
3098
|
}
|
|
@@ -3068,6 +3158,8 @@ async function validateExistingToken(token, apiUrl, apiVersion, options = {}) {
|
|
|
3068
3158
|
function classifyHookDownloadFailure(status, body) {
|
|
3069
3159
|
const parsed = parseErrorBody(body);
|
|
3070
3160
|
const code = parsed?.code;
|
|
3161
|
+
if (status === 429)
|
|
3162
|
+
return "rate_limited";
|
|
3071
3163
|
if (status === 401 && code === "TOKEN_EXPIRED")
|
|
3072
3164
|
return "token_expired";
|
|
3073
3165
|
if (status === 401 && code === "INVALID_TOKEN")
|
|
@@ -3085,42 +3177,99 @@ function classifyHookDownloadFailure(status, body) {
|
|
|
3085
3177
|
|
|
3086
3178
|
// src/copy-hook-scripts.ts
|
|
3087
3179
|
import { writeFileSync as fsWriteFileSync } from "fs";
|
|
3180
|
+
import { renameSync } from "fs";
|
|
3181
|
+
import { randomUUID } from "crypto";
|
|
3182
|
+
|
|
3183
|
+
// src/background-filters.ts
|
|
3184
|
+
var BACKGROUND_FILTER_FILES = ["background-filter.js", "background-filters.json"];
|
|
3185
|
+
function validBackgroundFilters(content) {
|
|
3186
|
+
if (Buffer.byteLength(content) > 64 * 1024)
|
|
3187
|
+
return false;
|
|
3188
|
+
try {
|
|
3189
|
+
const c = JSON.parse(content);
|
|
3190
|
+
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));
|
|
3191
|
+
} catch {
|
|
3192
|
+
return false;
|
|
3193
|
+
}
|
|
3194
|
+
}
|
|
3195
|
+
|
|
3196
|
+
// src/copy-hook-scripts.ts
|
|
3088
3197
|
import { join as pathJoin } from "path";
|
|
3198
|
+
function retryDelay(response) {
|
|
3199
|
+
const value = response.headers.get("Retry-After")?.trim();
|
|
3200
|
+
if (!value)
|
|
3201
|
+
return 60250;
|
|
3202
|
+
const seconds = /^\d+(?:\.\d+)?$/.test(value) ? Number(value) : NaN;
|
|
3203
|
+
const delay = Number.isFinite(seconds) ? seconds * 1000 : Date.parse(value) - Date.now();
|
|
3204
|
+
return Number.isFinite(delay) ? Math.max(1000, delay) + 250 : 60250;
|
|
3205
|
+
}
|
|
3089
3206
|
async function copyHookScripts(hooksDir, token, files, options) {
|
|
3090
3207
|
const fetchImpl = options.fetchImpl || fetch;
|
|
3091
3208
|
const writeFile = options.writeFileSync || fsWriteFileSync;
|
|
3092
3209
|
const join = options.joinPath || pathJoin;
|
|
3210
|
+
const sleep = options.sleep || ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
3211
|
+
let retryBudgetMs = 125000;
|
|
3212
|
+
const staged = [];
|
|
3093
3213
|
let downloaded = 0;
|
|
3094
3214
|
const failed = [];
|
|
3215
|
+
const optionalFailed = [];
|
|
3216
|
+
const optional = new Set(options.optionalFiles || []);
|
|
3217
|
+
const recordFailure = (file, detail) => {
|
|
3218
|
+
(optional.has(file) ? optionalFailed : failed).push(`${file} (${detail})`);
|
|
3219
|
+
};
|
|
3095
3220
|
for (const file of files) {
|
|
3096
3221
|
if (!/^[a-z0-9._-]+\.(sh|js|json)$/i.test(file) || file.includes("..")) {
|
|
3097
|
-
|
|
3222
|
+
recordFailure(file, "invalid filename");
|
|
3098
3223
|
continue;
|
|
3099
3224
|
}
|
|
3100
3225
|
try {
|
|
3101
|
-
const
|
|
3226
|
+
const download = () => fetchImpl(`${options.apiUrl}/${options.apiVersion}/hooks/${file}?format=raw`, {
|
|
3102
3227
|
headers: {
|
|
3103
3228
|
Authorization: `Bearer ${token}`
|
|
3104
3229
|
}
|
|
3105
3230
|
});
|
|
3231
|
+
let response = await download();
|
|
3232
|
+
for (let retry = 0;response.status === 429 && retry < 2; retry++) {
|
|
3233
|
+
const delay = retryDelay(response);
|
|
3234
|
+
if (delay > retryBudgetMs)
|
|
3235
|
+
break;
|
|
3236
|
+
retryBudgetMs -= delay;
|
|
3237
|
+
await response.body?.cancel();
|
|
3238
|
+
options.onRateLimit?.(file, Math.ceil(delay / 1000));
|
|
3239
|
+
await sleep(delay);
|
|
3240
|
+
response = await download();
|
|
3241
|
+
}
|
|
3106
3242
|
if (response.ok) {
|
|
3107
3243
|
const content = await response.text();
|
|
3244
|
+
if (file === "background-filters.json") {
|
|
3245
|
+
if (!validBackgroundFilters(content)) {
|
|
3246
|
+
recordFailure(file, "invalid catalog; previous copy retained");
|
|
3247
|
+
continue;
|
|
3248
|
+
}
|
|
3249
|
+
staged.push({ file, content, mode: 384 });
|
|
3250
|
+
downloaded++;
|
|
3251
|
+
continue;
|
|
3252
|
+
}
|
|
3108
3253
|
const isShellScript = content.startsWith("#!/") || content.startsWith("# ");
|
|
3109
3254
|
const isJsBundle = file.endsWith(".js") && (content.startsWith("//") || content.startsWith("import ") || content.startsWith("var ") || content.startsWith("const ") || content.startsWith("export "));
|
|
3110
3255
|
if (isShellScript || isJsBundle) {
|
|
3111
|
-
|
|
3112
|
-
writeFile(filePath, content, { mode: isShellScript ? 493 : 420 });
|
|
3256
|
+
staged.push({ file, content, mode: isShellScript ? 493 : 420 });
|
|
3113
3257
|
downloaded++;
|
|
3114
3258
|
} else {
|
|
3115
|
-
|
|
3259
|
+
recordFailure(file, "invalid content");
|
|
3116
3260
|
}
|
|
3117
3261
|
} else {
|
|
3118
3262
|
const body = await response.text().catch(() => "");
|
|
3119
3263
|
const failureKind = classifyHookDownloadFailure(response.status, body);
|
|
3264
|
+
if (optional.has(file) && (failureKind === "rate_limited" || failureKind === "validation_unavailable")) {
|
|
3265
|
+
recordFailure(file, String(response.status));
|
|
3266
|
+
continue;
|
|
3267
|
+
}
|
|
3120
3268
|
if (failureKind !== "recoverable") {
|
|
3121
3269
|
return {
|
|
3122
3270
|
downloaded,
|
|
3123
3271
|
failed,
|
|
3272
|
+
optionalFailed,
|
|
3124
3273
|
terminalFailure: {
|
|
3125
3274
|
kind: failureKind,
|
|
3126
3275
|
file,
|
|
@@ -3128,13 +3277,80 @@ async function copyHookScripts(hooksDir, token, files, options) {
|
|
|
3128
3277
|
}
|
|
3129
3278
|
};
|
|
3130
3279
|
}
|
|
3131
|
-
|
|
3280
|
+
recordFailure(file, String(response.status));
|
|
3132
3281
|
}
|
|
3133
3282
|
} catch (err) {
|
|
3134
|
-
|
|
3283
|
+
recordFailure(file, err instanceof Error ? err.message : "network error");
|
|
3135
3284
|
}
|
|
3136
3285
|
}
|
|
3137
|
-
|
|
3286
|
+
if (failed.length === 0) {
|
|
3287
|
+
const replacements = [];
|
|
3288
|
+
for (const { file, content, mode } of staged) {
|
|
3289
|
+
if (optionalFailed.length && optional.has(file))
|
|
3290
|
+
continue;
|
|
3291
|
+
try {
|
|
3292
|
+
const filePath = join(hooksDir, file);
|
|
3293
|
+
if (options.writeFileSync)
|
|
3294
|
+
writeFile(filePath, content, { mode });
|
|
3295
|
+
else {
|
|
3296
|
+
const temporary = `${filePath}.${randomUUID()}.tmp`;
|
|
3297
|
+
writeFile(temporary, content, { mode });
|
|
3298
|
+
replacements.push({ temporary, filePath, file });
|
|
3299
|
+
}
|
|
3300
|
+
} catch {
|
|
3301
|
+
failed.push(`${file} (could not save hook file)`);
|
|
3302
|
+
break;
|
|
3303
|
+
}
|
|
3304
|
+
}
|
|
3305
|
+
if (failed.length === 0) {
|
|
3306
|
+
for (const { temporary, filePath, file } of replacements) {
|
|
3307
|
+
try {
|
|
3308
|
+
renameSync(temporary, filePath);
|
|
3309
|
+
} catch {
|
|
3310
|
+
failed.push(`${file} (could not replace hook file)`);
|
|
3311
|
+
break;
|
|
3312
|
+
}
|
|
3313
|
+
}
|
|
3314
|
+
}
|
|
3315
|
+
}
|
|
3316
|
+
return { downloaded, failed, optionalFailed };
|
|
3317
|
+
}
|
|
3318
|
+
|
|
3319
|
+
// src/host-command.ts
|
|
3320
|
+
import { execFileSync } from "node:child_process";
|
|
3321
|
+
var HOST_COMMAND_TIMEOUT_MS = 30000;
|
|
3322
|
+
var PACKAGE_INSTALL_TIMEOUT_MS = 180000;
|
|
3323
|
+
function runHostCommand(file, args, options = {}) {
|
|
3324
|
+
const timeout = options.timeoutMs ?? HOST_COMMAND_TIMEOUT_MS;
|
|
3325
|
+
const interactive = options.interactive === true && process.stdin.isTTY === true && process.stdout.isTTY === true;
|
|
3326
|
+
try {
|
|
3327
|
+
return execFileSync(file, args, {
|
|
3328
|
+
encoding: "utf8",
|
|
3329
|
+
stdio: interactive ? "inherit" : ["ignore", "pipe", "pipe"],
|
|
3330
|
+
timeout: interactive ? undefined : timeout,
|
|
3331
|
+
killSignal: "SIGTERM",
|
|
3332
|
+
shell: process.platform === "win32" && file === "pi"
|
|
3333
|
+
}) ?? "";
|
|
3334
|
+
} catch (error) {
|
|
3335
|
+
if (error.code === "ETIMEDOUT") {
|
|
3336
|
+
throw new Error(`${file} ${args.slice(0, 3).join(" ")} timed out after ${timeout / 1000}s. Setup may be partial; check the host before retrying.`);
|
|
3337
|
+
}
|
|
3338
|
+
throw error;
|
|
3339
|
+
}
|
|
3340
|
+
}
|
|
3341
|
+
|
|
3342
|
+
// src/hermes-follow-up.ts
|
|
3343
|
+
function enableHermesFollowUp(profile, run = (file, args) => runHostCommand(file, args)) {
|
|
3344
|
+
if (!/^[a-z0-9][a-z0-9_-]{0,63}$/.test(profile)) {
|
|
3345
|
+
throw new Error("Invalid Hermes profile name");
|
|
3346
|
+
}
|
|
3347
|
+
run("hermes", [
|
|
3348
|
+
...profile === "default" ? [] : ["-p", profile],
|
|
3349
|
+
"config",
|
|
3350
|
+
"set",
|
|
3351
|
+
"plugins.entries.agentapprove.allow_gateway_injection",
|
|
3352
|
+
"true"
|
|
3353
|
+
]);
|
|
3138
3354
|
}
|
|
3139
3355
|
|
|
3140
3356
|
// src/pairing-api-url.ts
|
|
@@ -3161,7 +3377,7 @@ function resolvePairingApiBaseUrl(options) {
|
|
|
3161
3377
|
// src/setup-check.ts
|
|
3162
3378
|
function checkHookConfiguration(agent, config, hooksKey, hooks, mode, fileReady, expectedCommand = (file) => `~/.agentapprove/hooks/${file}`) {
|
|
3163
3379
|
const result = (status, reason) => ({ agent, status, reason });
|
|
3164
|
-
const expected = hooks.filter((
|
|
3380
|
+
const expected = hooks.filter((h) => !h.isPlugin && !(mode === "observe" && h.isApprovalHook));
|
|
3165
3381
|
if (!expected.length)
|
|
3166
3382
|
return result("manual", "manual_step");
|
|
3167
3383
|
const map = hooksKey ? config[hooksKey] : config;
|
|
@@ -3218,7 +3434,7 @@ Configured on this computer: ${ready.join(", ")}. Nothing was changed.`);
|
|
|
3218
3434
|
}
|
|
3219
3435
|
|
|
3220
3436
|
// src/cli.ts
|
|
3221
|
-
var VERSION = "0.
|
|
3437
|
+
var VERSION = "0.2.0";
|
|
3222
3438
|
function getApiUrl() {
|
|
3223
3439
|
return process.env.AGENTAPPROVE_API || "https://api.agentapprove.com";
|
|
3224
3440
|
}
|
|
@@ -3290,14 +3506,14 @@ function getCommand() {
|
|
|
3290
3506
|
}
|
|
3291
3507
|
return filtered[0] || "install";
|
|
3292
3508
|
}
|
|
3293
|
-
var OPENCODE_PLUGIN_VERSION = "0.1.
|
|
3509
|
+
var OPENCODE_PLUGIN_VERSION = "0.1.26";
|
|
3294
3510
|
var OPENCODE_PLUGIN_SPEC = `@agentapprove/opencode@${OPENCODE_PLUGIN_VERSION}`;
|
|
3295
|
-
var OPENCLAW_PLUGIN_VERSION = "0.2.
|
|
3511
|
+
var OPENCLAW_PLUGIN_VERSION = "0.2.21";
|
|
3296
3512
|
var OPENCLAW_PLUGIN_SPEC = `@agentapprove/openclaw@${OPENCLAW_PLUGIN_VERSION}`;
|
|
3297
|
-
var PI_PLUGIN_VERSION = "0.1.
|
|
3513
|
+
var PI_PLUGIN_VERSION = "0.1.14";
|
|
3298
3514
|
var PI_PLUGIN_SPEC = `npm:@agentapprove/pi@${PI_PLUGIN_VERSION}`;
|
|
3299
3515
|
var PI_STATUS_TIMEOUT_MS = 5000;
|
|
3300
|
-
var HERMES_PLUGIN_VERSION = "0.1.
|
|
3516
|
+
var HERMES_PLUGIN_VERSION = "0.1.16";
|
|
3301
3517
|
var HERMES_PIP_DEPS = ["cryptography>=44.0,<46", "httpx>=0.27,<0.29"];
|
|
3302
3518
|
var AGENTS = {
|
|
3303
3519
|
"claude-code": {
|
|
@@ -3311,6 +3527,8 @@ var AGENTS = {
|
|
|
3311
3527
|
{ name: "PermissionRequest", file: "notify-hook.sh", description: "Permission requests", hasMatcher: true, isApprovalHook: true, timeout: 300 },
|
|
3312
3528
|
{ name: "UserPromptSubmit", file: "claude-user-prompt.sh", description: "User prompt submitted", hasMatcher: false },
|
|
3313
3529
|
{ name: "Stop", file: "claude-stop.sh", description: "Session/task completed", hasMatcher: false, timeout: 600 },
|
|
3530
|
+
{ name: "SubagentStart", file: "claude-subagent-start.sh", description: "Subagent started", hasMatcher: true },
|
|
3531
|
+
{ name: "SubagentStop", file: "claude-subagent-stop.sh", description: "Subagent completed", hasMatcher: true },
|
|
3314
3532
|
{ name: "SessionStart", file: "claude-session-start.sh", description: "Session started", hasMatcher: false },
|
|
3315
3533
|
{ name: "SessionEnd", file: "claude-session-end.sh", description: "Session ended", hasMatcher: false }
|
|
3316
3534
|
]
|
|
@@ -3435,6 +3653,8 @@ var AGENTS = {
|
|
|
3435
3653
|
configPath: join(homedir(), ".codex", "hooks.json"),
|
|
3436
3654
|
hooksKey: "hooks",
|
|
3437
3655
|
hooks: [
|
|
3656
|
+
{ name: "SubagentStart", file: "codex-subagent-start.sh", description: "Subagent started", hasMatcher: true },
|
|
3657
|
+
{ name: "SubagentStop", file: "codex-subagent-stop.sh", description: "Subagent completed", hasMatcher: true },
|
|
3438
3658
|
{ name: "SessionStart", file: "codex-session-start.sh", description: "Session started", hasMatcher: true },
|
|
3439
3659
|
{ name: "PreToolUse", file: "codex-pre-tool.sh", description: "Tool approval", hasMatcher: true, isApprovalHook: true, timeout: 300 },
|
|
3440
3660
|
{ name: "PostToolUse", file: "codex-post-tool.sh", description: "Tool completion logging", hasMatcher: true },
|
|
@@ -3513,7 +3733,7 @@ var SUPPORTED_AGENT_COPY = [
|
|
|
3513
3733
|
"Windsurf"
|
|
3514
3734
|
].join(", ");
|
|
3515
3735
|
var HIGHLIGHTED_AGENT_COPY = "Antigravity, Hermes, Pi, OpenClaw, OpenCode, and OpenHands";
|
|
3516
|
-
var SHARED_HOOK_FILES = ["common.sh"];
|
|
3736
|
+
var SHARED_HOOK_FILES = ["common.sh", ...BACKGROUND_FILTER_FILES];
|
|
3517
3737
|
var STATUS_FIELD_LABELS = {
|
|
3518
3738
|
AGENTAPPROVE_API: "API URL",
|
|
3519
3739
|
AGENTAPPROVE_TOKEN: "Token",
|
|
@@ -3606,7 +3826,7 @@ function findGitBash() {
|
|
|
3606
3826
|
}
|
|
3607
3827
|
function toGitBashPath(windowsPath) {
|
|
3608
3828
|
let result = windowsPath.replace(/\\/g, "/");
|
|
3609
|
-
result = result.replace(/^([A-Za-z]):\//, (
|
|
3829
|
+
result = result.replace(/^([A-Za-z]):\//, (_, drive) => `/${drive.toLowerCase()}/`);
|
|
3610
3830
|
return result;
|
|
3611
3831
|
}
|
|
3612
3832
|
function buildHookCommand(hookScriptPath, agentId) {
|
|
@@ -3640,7 +3860,7 @@ function getAntigravityPluginManifest() {
|
|
|
3640
3860
|
}
|
|
3641
3861
|
function buildAntigravityHooksJson(agentId, hooksDir, mode) {
|
|
3642
3862
|
const agent = AGENTS[agentId];
|
|
3643
|
-
const hooksToInstall = mode === "observe" ? agent.hooks.filter((
|
|
3863
|
+
const hooksToInstall = mode === "observe" ? agent.hooks.filter((h) => h.name !== "Stop") : agent.hooks;
|
|
3644
3864
|
const bundle = { enabled: true };
|
|
3645
3865
|
for (const hook of hooksToInstall) {
|
|
3646
3866
|
const hookPath = join(hooksDir, hook.file);
|
|
@@ -3682,7 +3902,7 @@ function installAntigravityPluginBundle(agentId, hooksDir, mode) {
|
|
|
3682
3902
|
error: err instanceof Error ? err.message : String(err)
|
|
3683
3903
|
};
|
|
3684
3904
|
}
|
|
3685
|
-
const installedHooks = (mode === "observe" ? agent.hooks.filter((
|
|
3905
|
+
const installedHooks = (mode === "observe" ? agent.hooks.filter((h) => h.name !== "Stop") : agent.hooks).map((hook) => hook.name);
|
|
3686
3906
|
return { success: true, backupPath, hooks: installedHooks };
|
|
3687
3907
|
}
|
|
3688
3908
|
function getVSCodeSettingsPaths() {
|
|
@@ -3838,7 +4058,7 @@ function detectInstalledAgents() {
|
|
|
3838
4058
|
installed.push(id);
|
|
3839
4059
|
} else {
|
|
3840
4060
|
try {
|
|
3841
|
-
|
|
4061
|
+
runHostCommand("pi", ["--version"], { timeoutMs: 5000 });
|
|
3842
4062
|
installed.push(id);
|
|
3843
4063
|
} catch {}
|
|
3844
4064
|
}
|
|
@@ -3847,7 +4067,7 @@ function detectInstalledAgents() {
|
|
|
3847
4067
|
installed.push(id);
|
|
3848
4068
|
} else {
|
|
3849
4069
|
try {
|
|
3850
|
-
|
|
4070
|
+
runHostCommand("hermes", ["--version"], { timeoutMs: 5000 });
|
|
3851
4071
|
installed.push(id);
|
|
3852
4072
|
} catch {}
|
|
3853
4073
|
}
|
|
@@ -3981,7 +4201,7 @@ function describeFailBehavior(value) {
|
|
|
3981
4201
|
return "Block all commands until the service is restored.";
|
|
3982
4202
|
case "ask":
|
|
3983
4203
|
default:
|
|
3984
|
-
return "
|
|
4204
|
+
return "Use the agent's approval dialog when supported; otherwise block until approval is available.";
|
|
3985
4205
|
}
|
|
3986
4206
|
}
|
|
3987
4207
|
function describeInstallMode(value) {
|
|
@@ -4220,7 +4440,7 @@ function discoverE2EKeys() {
|
|
|
4220
4440
|
} catch {}
|
|
4221
4441
|
}
|
|
4222
4442
|
try {
|
|
4223
|
-
const files = readdirSync2(dir).filter((
|
|
4443
|
+
const files = readdirSync2(dir).filter((f) => f.startsWith("e2e-key.") && f.endsWith(".bak"));
|
|
4224
4444
|
for (const file of files) {
|
|
4225
4445
|
const fullPath = join(dir, file);
|
|
4226
4446
|
try {
|
|
@@ -4502,16 +4722,16 @@ function copyToClipboard(text) {
|
|
|
4502
4722
|
{ cmd: "xclip", args: ["-selection", "clipboard"] },
|
|
4503
4723
|
{ cmd: "xsel", args: ["--clipboard", "--input"] }
|
|
4504
4724
|
]) {
|
|
4505
|
-
const
|
|
4725
|
+
const result = spawnSync2(candidate.cmd, candidate.args, {
|
|
4506
4726
|
input: text,
|
|
4507
4727
|
stdio: ["pipe", "ignore", "ignore"]
|
|
4508
4728
|
});
|
|
4509
|
-
if (
|
|
4729
|
+
if (result.status === 0 && !result.error)
|
|
4510
4730
|
return true;
|
|
4511
4731
|
}
|
|
4512
4732
|
return false;
|
|
4513
4733
|
}
|
|
4514
|
-
const result =
|
|
4734
|
+
const result = spawnSync2(cmd, args, {
|
|
4515
4735
|
input: text,
|
|
4516
4736
|
stdio: ["pipe", "ignore", "ignore"]
|
|
4517
4737
|
});
|
|
@@ -4571,6 +4791,12 @@ async function showPairingPresentation(params) {
|
|
|
4571
4791
|
function saveEnvConfig(config) {
|
|
4572
4792
|
const envPath = join(getAgentApproveDir(), "env");
|
|
4573
4793
|
const configSetAt = config.configSetAt ?? Math.floor(Date.now() / 1000);
|
|
4794
|
+
const hasBackgroundPreference = config.preserved?.AGENTAPPROVE_FILTER_BACKGROUND_ACTIVITY !== undefined;
|
|
4795
|
+
const preserved = {
|
|
4796
|
+
AGENTAPPROVE_FILTER_BACKGROUND_ACTIVITY: "true",
|
|
4797
|
+
...!hasBackgroundPreference ? { AGENTAPPROVE_BACKGROUND_FILTER_SYNC_PENDING: "true" } : {},
|
|
4798
|
+
...config.preserved
|
|
4799
|
+
};
|
|
4574
4800
|
const retentionDisplay = `${config.retentionDays ?? 30}`;
|
|
4575
4801
|
const e2eEnabled = config.e2eEnabled !== false;
|
|
4576
4802
|
const content = `# Agent Approve Configuration
|
|
@@ -4600,7 +4826,7 @@ AGENTAPPROVE_E2E_ENABLED=${e2eEnabled ? "true" : "false"}
|
|
|
4600
4826
|
|
|
4601
4827
|
# Hook behavior when API is unreachable: "allow" | "deny" | "ask"
|
|
4602
4828
|
AGENTAPPROVE_FAIL_BEHAVIOR=${config.failBehavior || "ask"}
|
|
4603
|
-
${renderPreservedEnvSection(
|
|
4829
|
+
${renderPreservedEnvSection(preserved)}
|
|
4604
4830
|
# Settings in this file sync from your Agent Approve account settings, so
|
|
4605
4831
|
# manual edits here are overwritten on the next config sync.
|
|
4606
4832
|
# To change settings, run: npx agentapprove install
|
|
@@ -4629,14 +4855,14 @@ function isCredentialManagerAvailable() {
|
|
|
4629
4855
|
async function storeTokenInKeychain(token, options) {
|
|
4630
4856
|
if (isKeychainAvailable()) {
|
|
4631
4857
|
try {
|
|
4632
|
-
|
|
4858
|
+
spawnSync2("security", [
|
|
4633
4859
|
"delete-generic-password",
|
|
4634
4860
|
"-s",
|
|
4635
4861
|
KEYCHAIN_SERVICE,
|
|
4636
4862
|
"-a",
|
|
4637
4863
|
KEYCHAIN_ACCOUNT
|
|
4638
4864
|
], { stdio: "ignore" });
|
|
4639
|
-
const addResult =
|
|
4865
|
+
const addResult = spawnSync2("security", [
|
|
4640
4866
|
"add-generic-password",
|
|
4641
4867
|
"-s",
|
|
4642
4868
|
KEYCHAIN_SERVICE,
|
|
@@ -4660,8 +4886,8 @@ async function storeTokenInKeychain(token, options) {
|
|
|
4660
4886
|
}
|
|
4661
4887
|
if (isCredentialManagerAvailable()) {
|
|
4662
4888
|
try {
|
|
4663
|
-
|
|
4664
|
-
const addResult =
|
|
4889
|
+
spawnSync2("cmdkey", [`/delete:${CREDENTIAL_TARGET}`], { stdio: "ignore" });
|
|
4890
|
+
const addResult = spawnSync2("cmdkey", [
|
|
4665
4891
|
`/generic:${CREDENTIAL_TARGET}`,
|
|
4666
4892
|
"/user:agentapprove",
|
|
4667
4893
|
`/pass:${token}`
|
|
@@ -4684,7 +4910,7 @@ function readTokenFromKeychain() {
|
|
|
4684
4910
|
if (!isKeychainAvailable())
|
|
4685
4911
|
return null;
|
|
4686
4912
|
try {
|
|
4687
|
-
const result =
|
|
4913
|
+
const result = spawnSync2("security", [
|
|
4688
4914
|
"find-generic-password",
|
|
4689
4915
|
"-s",
|
|
4690
4916
|
KEYCHAIN_SERVICE,
|
|
@@ -4767,39 +4993,27 @@ async function installHooksForAgent(agentId, hooksDir, mode = "approval") {
|
|
|
4767
4993
|
const hooksConfig = useTopLevelHooks ? config : config[agent.hooksKey];
|
|
4768
4994
|
const installedHooks = [];
|
|
4769
4995
|
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"
|
|
4996
|
+
const result = await installOpenClaw({
|
|
4997
|
+
spec: OPENCLAW_PLUGIN_SPEC,
|
|
4998
|
+
version: OPENCLAW_PLUGIN_VERSION,
|
|
4999
|
+
mode,
|
|
5000
|
+
readVersion: readOpenClawInstalledVersion,
|
|
5001
|
+
readConfig: () => {
|
|
5002
|
+
if (!existsSync2(agent.configPath))
|
|
5003
|
+
return {};
|
|
5004
|
+
const current = JSON.parse(readFileSync(agent.configPath, "utf8"));
|
|
5005
|
+
if (!current || typeof current !== "object" || Array.isArray(current)) {
|
|
5006
|
+
throw new Error("OpenClaw configuration must be a JSON object; no settings were overwritten.");
|
|
5007
|
+
}
|
|
5008
|
+
return current;
|
|
5009
|
+
},
|
|
5010
|
+
writeConfig: (updated) => writeJsonConfig(agent.configPath, updated),
|
|
5011
|
+
confirmReplacement: async (message) => {
|
|
5012
|
+
const answer = await ce({ message, initialValue: false });
|
|
5013
|
+
return !lD(answer) && answer === true;
|
|
4790
5014
|
}
|
|
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 };
|
|
5015
|
+
});
|
|
5016
|
+
return { ...result, backupPath, hooks: result.success ? [result.label] : [] };
|
|
4803
5017
|
}
|
|
4804
5018
|
if (agentId === "opencode") {
|
|
4805
5019
|
const installResult = installOpenCodePluginViaCli();
|
|
@@ -4839,7 +5053,7 @@ async function installHooksForAgent(agentId, hooksDir, mode = "approval") {
|
|
|
4839
5053
|
installedHooks.push(installResult.label);
|
|
4840
5054
|
return { success: true, backupPath, hooks: installedHooks };
|
|
4841
5055
|
}
|
|
4842
|
-
const hooksToInstall = mode === "observe" ? agent.hooks.filter((
|
|
5056
|
+
const hooksToInstall = mode === "observe" ? agent.hooks.filter((h) => !h.isApprovalHook) : agent.hooks;
|
|
4843
5057
|
for (const hook of hooksToInstall) {
|
|
4844
5058
|
const hookPath = join(hooksDir, hook.file);
|
|
4845
5059
|
const hookCommand = buildHookCommand(hookPath, agentId);
|
|
@@ -4850,7 +5064,7 @@ async function installHooksForAgent(agentId, hooksDir, mode = "approval") {
|
|
|
4850
5064
|
const hookArray = hooksConfig[hook.name];
|
|
4851
5065
|
const hasMatcher = hook.hasMatcher ?? true;
|
|
4852
5066
|
const hookTimeout = hook.timeout;
|
|
4853
|
-
const existingIdx = hookArray.findIndex((
|
|
5067
|
+
const existingIdx = hookArray.findIndex((h) => h.hooks?.some((hookScript) => {
|
|
4854
5068
|
if (typeof hookScript === "string")
|
|
4855
5069
|
return hookScript.includes("agentapprove");
|
|
4856
5070
|
if (typeof hookScript === "object" && hookScript.command)
|
|
@@ -4874,7 +5088,7 @@ async function installHooksForAgent(agentId, hooksDir, mode = "approval") {
|
|
|
4874
5088
|
const hookArray = hooksConfig[hook.name];
|
|
4875
5089
|
const hasMatcher = hook.hasMatcher ?? true;
|
|
4876
5090
|
const hookTimeout = hook.timeout;
|
|
4877
|
-
const existingIdx = hookArray.findIndex((
|
|
5091
|
+
const existingIdx = hookArray.findIndex((h) => h.hooks?.some((hookScript) => {
|
|
4878
5092
|
if (typeof hookScript === "string")
|
|
4879
5093
|
return hookScript.includes("agentapprove");
|
|
4880
5094
|
if (typeof hookScript === "object" && hookScript.command)
|
|
@@ -4899,56 +5113,13 @@ async function installHooksForAgent(agentId, hooksDir, mode = "approval") {
|
|
|
4899
5113
|
if (typeof config["version"] !== "number") {
|
|
4900
5114
|
config["version"] = 1;
|
|
4901
5115
|
}
|
|
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
|
-
}
|
|
5116
|
+
hooksConfig[hook.name] = upsertCursorHook(hooksConfig[hook.name], cursorHookEntry(hook.name, hookCommand, hook.isApprovalHook));
|
|
4946
5117
|
installedHooks.push(hook.name);
|
|
4947
5118
|
} else if (agentId === "windsurf") {
|
|
4948
5119
|
const existing = hooksConfig[hook.name];
|
|
4949
5120
|
const existingArray = Array.isArray(existing) ? existing : existing && typeof existing === "object" ? [existing] : typeof existing === "string" ? [{ command: existing }] : [];
|
|
4950
|
-
const cleanedArray = existingArray.filter((
|
|
4951
|
-
const command =
|
|
5121
|
+
const cleanedArray = existingArray.filter((h) => {
|
|
5122
|
+
const command = h.command || h.powershell || "";
|
|
4952
5123
|
return !command.includes("agentapprove");
|
|
4953
5124
|
});
|
|
4954
5125
|
cleanedArray.push({
|
|
@@ -4962,10 +5133,10 @@ async function installHooksForAgent(agentId, hooksDir, mode = "approval") {
|
|
|
4962
5133
|
hooksConfig[hook.name] = [];
|
|
4963
5134
|
}
|
|
4964
5135
|
const hookArray = hooksConfig[hook.name];
|
|
4965
|
-
const cleanedArray = hookArray.filter((
|
|
4966
|
-
if (!
|
|
5136
|
+
const cleanedArray = hookArray.filter((h) => {
|
|
5137
|
+
if (!h.hooks || !Array.isArray(h.hooks))
|
|
4967
5138
|
return true;
|
|
4968
|
-
return !
|
|
5139
|
+
return !h.hooks.some((hookScript) => {
|
|
4969
5140
|
if (typeof hookScript === "string")
|
|
4970
5141
|
return hookScript.includes("agentapprove");
|
|
4971
5142
|
if (typeof hookScript === "object" && hookScript !== null && "command" in hookScript) {
|
|
@@ -4985,8 +5156,8 @@ async function installHooksForAgent(agentId, hooksDir, mode = "approval") {
|
|
|
4985
5156
|
hooksConfig[hook.name] = [];
|
|
4986
5157
|
}
|
|
4987
5158
|
const hookArray = hooksConfig[hook.name];
|
|
4988
|
-
const cleanedArray = hookArray.filter((
|
|
4989
|
-
return !(
|
|
5159
|
+
const cleanedArray = hookArray.filter((h) => {
|
|
5160
|
+
return !(h.command || "").includes("agentapprove");
|
|
4990
5161
|
});
|
|
4991
5162
|
const hookEntry = {
|
|
4992
5163
|
type: "command",
|
|
@@ -5012,7 +5183,7 @@ async function installHooksForAgent(agentId, hooksDir, mode = "approval") {
|
|
|
5012
5183
|
const hookArray = hooksConfig[hook.name];
|
|
5013
5184
|
const hookTimeout = hook.timeout;
|
|
5014
5185
|
const isApproval = hook.isApprovalHook;
|
|
5015
|
-
const existingIdx = hookArray.findIndex((
|
|
5186
|
+
const existingIdx = hookArray.findIndex((h) => h.hooks?.some((hookScript) => {
|
|
5016
5187
|
if (typeof hookScript === "string")
|
|
5017
5188
|
return hookScript.includes("agentapprove");
|
|
5018
5189
|
if (typeof hookScript === "object" && hookScript.command)
|
|
@@ -5048,8 +5219,8 @@ async function installHooksForAgent(agentId, hooksDir, mode = "approval") {
|
|
|
5048
5219
|
hooksConfig[hook.name] = [];
|
|
5049
5220
|
}
|
|
5050
5221
|
const hookArray = hooksConfig[hook.name];
|
|
5051
|
-
const cleanedArray = hookArray.filter((
|
|
5052
|
-
const cmd =
|
|
5222
|
+
const cleanedArray = hookArray.filter((h) => {
|
|
5223
|
+
const cmd = h.bash || h.command || "";
|
|
5053
5224
|
return !cmd.includes("agentapprove");
|
|
5054
5225
|
});
|
|
5055
5226
|
const hookEntry = {
|
|
@@ -5069,16 +5240,16 @@ async function installHooksForAgent(agentId, hooksDir, mode = "approval") {
|
|
|
5069
5240
|
}
|
|
5070
5241
|
}
|
|
5071
5242
|
if (mode === "observe") {
|
|
5072
|
-
const approvalHooks = agent.hooks.filter((
|
|
5243
|
+
const approvalHooks = agent.hooks.filter((h) => h.isApprovalHook);
|
|
5073
5244
|
for (const hook of approvalHooks) {
|
|
5074
5245
|
if (hooksConfig[hook.name]) {
|
|
5075
5246
|
if (agentId === "claude-code" || agentId === "gemini-cli" || agentId === "codex" || agentId === "openhands") {
|
|
5076
5247
|
const hookArray = hooksConfig[hook.name];
|
|
5077
5248
|
if (Array.isArray(hookArray)) {
|
|
5078
|
-
const cleaned = hookArray.filter((
|
|
5079
|
-
if (!
|
|
5249
|
+
const cleaned = hookArray.filter((h) => {
|
|
5250
|
+
if (!h.hooks || !Array.isArray(h.hooks))
|
|
5080
5251
|
return true;
|
|
5081
|
-
return !
|
|
5252
|
+
return !h.hooks.some((hs) => {
|
|
5082
5253
|
if (typeof hs === "string")
|
|
5083
5254
|
return hs.includes("agentapprove");
|
|
5084
5255
|
if (typeof hs === "object" && hs !== null && "command" in hs) {
|
|
@@ -5096,7 +5267,7 @@ async function installHooksForAgent(agentId, hooksDir, mode = "approval") {
|
|
|
5096
5267
|
} else if (agentId === "vscode-agent") {
|
|
5097
5268
|
const hookArray = hooksConfig[hook.name];
|
|
5098
5269
|
if (Array.isArray(hookArray)) {
|
|
5099
|
-
const cleaned = hookArray.filter((
|
|
5270
|
+
const cleaned = hookArray.filter((h) => !(h.command || "").includes("agentapprove"));
|
|
5100
5271
|
if (cleaned.length === 0) {
|
|
5101
5272
|
delete hooksConfig[hook.name];
|
|
5102
5273
|
} else {
|
|
@@ -5106,8 +5277,8 @@ async function installHooksForAgent(agentId, hooksDir, mode = "approval") {
|
|
|
5106
5277
|
} else if (agentId === "copilot-cli") {
|
|
5107
5278
|
const hookArray = hooksConfig[hook.name];
|
|
5108
5279
|
if (Array.isArray(hookArray)) {
|
|
5109
|
-
const cleaned = hookArray.filter((
|
|
5110
|
-
const cmd =
|
|
5280
|
+
const cleaned = hookArray.filter((h) => {
|
|
5281
|
+
const cmd = h.bash || h.command || "";
|
|
5111
5282
|
return !cmd.includes("agentapprove");
|
|
5112
5283
|
});
|
|
5113
5284
|
if (cleaned.length === 0) {
|
|
@@ -5119,12 +5290,12 @@ async function installHooksForAgent(agentId, hooksDir, mode = "approval") {
|
|
|
5119
5290
|
} else if (agentId === "cursor") {
|
|
5120
5291
|
const existing = hooksConfig[hook.name];
|
|
5121
5292
|
if (Array.isArray(existing)) {
|
|
5122
|
-
const cleaned = existing.filter((
|
|
5123
|
-
if (typeof
|
|
5124
|
-
return !
|
|
5293
|
+
const cleaned = existing.filter((h) => {
|
|
5294
|
+
if (typeof h === "object" && h !== null && "command" in h) {
|
|
5295
|
+
return !h.command.includes("agentapprove");
|
|
5125
5296
|
}
|
|
5126
|
-
if (typeof
|
|
5127
|
-
return !
|
|
5297
|
+
if (typeof h === "string")
|
|
5298
|
+
return !h.includes("agentapprove");
|
|
5128
5299
|
return true;
|
|
5129
5300
|
});
|
|
5130
5301
|
if (cleaned.length === 0) {
|
|
@@ -5136,13 +5307,13 @@ async function installHooksForAgent(agentId, hooksDir, mode = "approval") {
|
|
|
5136
5307
|
} else if (agentId === "windsurf") {
|
|
5137
5308
|
const existing = hooksConfig[hook.name];
|
|
5138
5309
|
if (Array.isArray(existing)) {
|
|
5139
|
-
const cleaned = existing.filter((
|
|
5140
|
-
if (typeof
|
|
5141
|
-
const cmd =
|
|
5310
|
+
const cleaned = existing.filter((h) => {
|
|
5311
|
+
if (typeof h === "object" && h !== null) {
|
|
5312
|
+
const cmd = h.command || h.powershell || "";
|
|
5142
5313
|
return !cmd.includes("agentapprove");
|
|
5143
5314
|
}
|
|
5144
|
-
if (typeof
|
|
5145
|
-
return !
|
|
5315
|
+
if (typeof h === "string")
|
|
5316
|
+
return !h.includes("agentapprove");
|
|
5146
5317
|
return true;
|
|
5147
5318
|
});
|
|
5148
5319
|
if (cleaned.length === 0) {
|
|
@@ -5223,15 +5394,7 @@ codex_hooks = true`;
|
|
|
5223
5394
|
for (const hook of agent.hooks) {
|
|
5224
5395
|
const hookPath = join(hooksDir, hook.file);
|
|
5225
5396
|
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
|
-
}
|
|
5397
|
+
const entry = cursorHookEntry(hook.name, hookCmd, hook.isApprovalHook);
|
|
5235
5398
|
hooksObj[hook.name] = [entry];
|
|
5236
5399
|
}
|
|
5237
5400
|
return JSON.stringify({ version: 1, hooks: hooksObj }, null, 2);
|
|
@@ -5324,14 +5487,8 @@ codex_hooks = true`;
|
|
|
5324
5487
|
plugins: {
|
|
5325
5488
|
entries: {
|
|
5326
5489
|
openclaw: {
|
|
5327
|
-
|
|
5328
|
-
config: {
|
|
5329
|
-
apiUrl: API_URL,
|
|
5330
|
-
apiVersion: "v001",
|
|
5331
|
-
timeout: 300,
|
|
5332
|
-
failBehavior: "ask",
|
|
5333
|
-
privacyTier: "full"
|
|
5334
|
-
}
|
|
5490
|
+
hooks: { allowConversationAccess: true },
|
|
5491
|
+
config: {}
|
|
5335
5492
|
}
|
|
5336
5493
|
}
|
|
5337
5494
|
},
|
|
@@ -5344,10 +5501,15 @@ codex_hooks = true`;
|
|
|
5344
5501
|
"",
|
|
5345
5502
|
` openclaw plugins install ${OPENCLAW_PLUGIN_SPEC}`,
|
|
5346
5503
|
"",
|
|
5347
|
-
"
|
|
5504
|
+
"Review the source and capabilities in the terminal; declining stops installation.",
|
|
5505
|
+
"Merge the following settings into your OpenClaw config, preserving existing entries and permissions:",
|
|
5348
5506
|
"",
|
|
5349
5507
|
configJson,
|
|
5350
5508
|
"",
|
|
5509
|
+
CONVERSATION_ACCESS_NOTICE,
|
|
5510
|
+
"Then run: openclaw plugins enable openclaw (review any capabilities requested).",
|
|
5511
|
+
"",
|
|
5512
|
+
"Settings follow ~/.agentapprove/env. Existing explicit OpenClaw config overrides take precedence and are preserved.",
|
|
5351
5513
|
'Hosted installs can also set config.token/config.apiUrl/etc. with OpenClaw env substitution such as "${AGENTAPPROVE_TOKEN}".',
|
|
5352
5514
|
"",
|
|
5353
5515
|
"Restart the OpenClaw gateway to activate."
|
|
@@ -5397,6 +5559,7 @@ codex_hooks = true`;
|
|
|
5397
5559
|
" pip install --user cryptography httpx",
|
|
5398
5560
|
" # On uv-managed Python (PEP 668 EXTERNALLY-MANAGED): instead run",
|
|
5399
5561
|
" # uv pip install --system --break-system-packages --python $(which python3.12) cryptography httpx",
|
|
5562
|
+
" hermes config set plugins.entries.agentapprove.allow_gateway_injection true",
|
|
5400
5563
|
" hermes plugins enable agentapprove",
|
|
5401
5564
|
"",
|
|
5402
5565
|
"The plugin reads your existing Agent Approve config from ~/.agentapprove/env.",
|
|
@@ -5409,6 +5572,8 @@ codex_hooks = true`;
|
|
|
5409
5572
|
}
|
|
5410
5573
|
function describeDownloadTerminalFailure(kind) {
|
|
5411
5574
|
switch (kind) {
|
|
5575
|
+
case "rate_limited":
|
|
5576
|
+
return "Hook download limit reached. Please wait a few minutes, then rerun the installer. Existing hook files were kept.";
|
|
5412
5577
|
case "token_expired":
|
|
5413
5578
|
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
5579
|
case "token_invalid":
|
|
@@ -5426,95 +5591,37 @@ function describeDownloadTerminalFailure(kind) {
|
|
|
5426
5591
|
async function copyHookScripts2(hooksDir, token, files, options = {}) {
|
|
5427
5592
|
return copyHookScripts(hooksDir, token, files, {
|
|
5428
5593
|
apiUrl: options.apiUrl || API_URL,
|
|
5429
|
-
apiVersion: API_VERSION
|
|
5594
|
+
apiVersion: API_VERSION,
|
|
5595
|
+
onRateLimit: options.onRateLimit,
|
|
5596
|
+
optionalFiles: options.optionalFiles
|
|
5430
5597
|
});
|
|
5431
5598
|
}
|
|
5432
5599
|
function readOpenClawInstalledVersion() {
|
|
5433
|
-
|
|
5600
|
+
try {
|
|
5601
|
+
const result = spawnSync2("openclaw", ["plugins", "inspect", "openclaw", "--json"], {
|
|
5602
|
+
encoding: "utf8",
|
|
5603
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
5604
|
+
timeout: 30000,
|
|
5605
|
+
shell: process.platform === "win32"
|
|
5606
|
+
});
|
|
5607
|
+
if (result.status === 0) {
|
|
5608
|
+
const metadata = JSON.parse(result.stdout);
|
|
5609
|
+
if (metadata.plugin?.packageName === "@agentapprove/openclaw" && typeof metadata.plugin.rootDir === "string") {
|
|
5610
|
+
return readJsonPackageVersion(join(metadata.plugin.rootDir, "package.json"));
|
|
5611
|
+
}
|
|
5612
|
+
return null;
|
|
5613
|
+
}
|
|
5614
|
+
} catch {}
|
|
5615
|
+
for (const packagePath of [
|
|
5434
5616
|
join(homedir(), ".openclaw", "npm", "node_modules", "@agentapprove", "openclaw", "package.json"),
|
|
5435
5617
|
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 {}
|
|
5618
|
+
]) {
|
|
5619
|
+
const version = readJsonPackageVersion(packagePath);
|
|
5620
|
+
if (version)
|
|
5621
|
+
return version;
|
|
5447
5622
|
}
|
|
5448
5623
|
return null;
|
|
5449
5624
|
}
|
|
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
5625
|
function readJsonPackageVersion(packagePath) {
|
|
5519
5626
|
if (!existsSync2(packagePath)) {
|
|
5520
5627
|
return null;
|
|
@@ -5550,7 +5657,7 @@ function readOpenCodeInstalledVersion() {
|
|
|
5550
5657
|
}
|
|
5551
5658
|
function installOpenCodePluginViaCli() {
|
|
5552
5659
|
try {
|
|
5553
|
-
const result =
|
|
5660
|
+
const result = spawnSync2("opencode", ["plugin", OPENCODE_PLUGIN_SPEC, "--global", "--force"], {
|
|
5554
5661
|
encoding: "utf8",
|
|
5555
5662
|
stdio: ["ignore", "pipe", "pipe"]
|
|
5556
5663
|
});
|
|
@@ -5614,13 +5721,13 @@ function readPiPinnedSpec() {
|
|
|
5614
5721
|
}
|
|
5615
5722
|
function installPiPluginViaCli() {
|
|
5616
5723
|
try {
|
|
5617
|
-
|
|
5724
|
+
runHostCommand("pi", ["install", PI_PLUGIN_SPEC], { timeoutMs: PACKAGE_INSTALL_TIMEOUT_MS });
|
|
5618
5725
|
const pinnedSpec = readPiPinnedSpec();
|
|
5619
5726
|
if (pinnedSpec !== null && pinnedSpec !== PI_PLUGIN_SPEC) {
|
|
5620
5727
|
const manualFix = `Fix manually with: pi remove npm:@agentapprove/pi && pi install ${PI_PLUGIN_SPEC}`;
|
|
5621
5728
|
try {
|
|
5622
|
-
|
|
5623
|
-
|
|
5729
|
+
runHostCommand("pi", ["remove", "npm:@agentapprove/pi"]);
|
|
5730
|
+
runHostCommand("pi", ["install", PI_PLUGIN_SPEC], { timeoutMs: PACKAGE_INSTALL_TIMEOUT_MS });
|
|
5624
5731
|
} catch (err) {
|
|
5625
5732
|
return {
|
|
5626
5733
|
success: false,
|
|
@@ -5648,7 +5755,7 @@ function installPiPluginViaCli() {
|
|
|
5648
5755
|
}
|
|
5649
5756
|
function removePiPluginViaCli() {
|
|
5650
5757
|
try {
|
|
5651
|
-
|
|
5758
|
+
runHostCommand("pi", ["remove", "npm:@agentapprove/pi"]);
|
|
5652
5759
|
return { success: true };
|
|
5653
5760
|
} catch (err) {
|
|
5654
5761
|
return {
|
|
@@ -5657,16 +5764,13 @@ function removePiPluginViaCli() {
|
|
|
5657
5764
|
};
|
|
5658
5765
|
}
|
|
5659
5766
|
}
|
|
5660
|
-
var HERMES_BUNDLE_SHA256 = "
|
|
5767
|
+
var HERMES_BUNDLE_SHA256 = "7a4b063c78bbbb9e5b60f34c7ac6eddf4715df47ef474e98367706947b3bd1db";
|
|
5661
5768
|
var HERMES_BUNDLE_FILENAME = `agentapprove-hermes-${HERMES_PLUGIN_VERSION}.tar.gz`;
|
|
5662
5769
|
var HERMES_PLUGIN_DIR = join(homedir(), ".hermes", "plugins", "agentapprove");
|
|
5663
5770
|
function findPython() {
|
|
5664
5771
|
for (const candidate of ["python3.12", "python3.11", "python3.10", "python3"]) {
|
|
5665
5772
|
try {
|
|
5666
|
-
const out =
|
|
5667
|
-
encoding: "utf-8",
|
|
5668
|
-
stdio: ["pipe", "pipe", "ignore"]
|
|
5669
|
-
}).trim();
|
|
5773
|
+
const out = runHostCommand(candidate, ["-c", "import sys; print('%d.%d' % sys.version_info[:2])"], { timeoutMs: 5000 }).trim();
|
|
5670
5774
|
const [major, minor] = out.split(".").map(Number);
|
|
5671
5775
|
if (major === 3 && minor >= 10) {
|
|
5672
5776
|
return { command: candidate, version: out };
|
|
@@ -5742,7 +5846,8 @@ async function downloadHermesBundle(apiUrl, apiVersion, token) {
|
|
|
5742
5846
|
let response;
|
|
5743
5847
|
try {
|
|
5744
5848
|
response = await fetch(url.toString(), {
|
|
5745
|
-
headers: { Authorization: `Bearer ${token}` }
|
|
5849
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
5850
|
+
signal: AbortSignal.timeout(90000)
|
|
5746
5851
|
});
|
|
5747
5852
|
} catch (err) {
|
|
5748
5853
|
return { ok: false, error: `Network error downloading ${HERMES_BUNDLE_FILENAME}: ${err instanceof Error ? err.message : String(err)}` };
|
|
@@ -5801,10 +5906,7 @@ function validateExtractedTree(root) {
|
|
|
5801
5906
|
}
|
|
5802
5907
|
function hermesDepsAlreadyInstalled(pythonCommand) {
|
|
5803
5908
|
try {
|
|
5804
|
-
|
|
5805
|
-
stdio: "pipe",
|
|
5806
|
-
timeout: 5000
|
|
5807
|
-
});
|
|
5909
|
+
runHostCommand(pythonCommand, ["-c", "import cryptography, httpx"], { timeoutMs: 5000 });
|
|
5808
5910
|
return true;
|
|
5809
5911
|
} catch {
|
|
5810
5912
|
return false;
|
|
@@ -5812,7 +5914,7 @@ function hermesDepsAlreadyInstalled(pythonCommand) {
|
|
|
5812
5914
|
}
|
|
5813
5915
|
function uvAvailable() {
|
|
5814
5916
|
try {
|
|
5815
|
-
|
|
5917
|
+
runHostCommand("uv", ["--version"], { timeoutMs: 5000 });
|
|
5816
5918
|
return true;
|
|
5817
5919
|
} catch {
|
|
5818
5920
|
return false;
|
|
@@ -5821,19 +5923,19 @@ function uvAvailable() {
|
|
|
5821
5923
|
function isExternallyManagedError(err) {
|
|
5822
5924
|
if (!err || typeof err !== "object")
|
|
5823
5925
|
return false;
|
|
5824
|
-
const
|
|
5825
|
-
const stderr = Buffer.isBuffer(
|
|
5826
|
-
const stdout = Buffer.isBuffer(
|
|
5827
|
-
const message = String(
|
|
5926
|
+
const e = err;
|
|
5927
|
+
const stderr = Buffer.isBuffer(e.stderr) ? e.stderr.toString() : String(e.stderr || "");
|
|
5928
|
+
const stdout = Buffer.isBuffer(e.stdout) ? e.stdout.toString() : String(e.stdout || "");
|
|
5929
|
+
const message = String(e.message || "");
|
|
5828
5930
|
const blob = `${stderr}
|
|
5829
5931
|
${stdout}
|
|
5830
5932
|
${message}`;
|
|
5831
5933
|
return /externally-managed-environment|PEP 668|managed by uv/i.test(blob);
|
|
5832
5934
|
}
|
|
5833
5935
|
function installHermesDepsAdaptive(pythonCommand, deps) {
|
|
5834
|
-
const depsArg = deps.map((
|
|
5936
|
+
const depsArg = deps.map((d) => `"${d}"`).join(" ");
|
|
5835
5937
|
try {
|
|
5836
|
-
|
|
5938
|
+
runHostCommand(pythonCommand, ["-m", "pip", "install", "--user", "--quiet", ...deps], { timeoutMs: PACKAGE_INSTALL_TIMEOUT_MS });
|
|
5837
5939
|
return { ok: true };
|
|
5838
5940
|
} catch (pipErr) {
|
|
5839
5941
|
if (!isExternallyManagedError(pipErr)) {
|
|
@@ -5850,7 +5952,7 @@ function installHermesDepsAdaptive(pythonCommand, deps) {
|
|
|
5850
5952
|
}
|
|
5851
5953
|
const uvCmd = `uv pip install --system --break-system-packages --python ${pythonCommand} --quiet ${depsArg}`;
|
|
5852
5954
|
try {
|
|
5853
|
-
|
|
5955
|
+
runHostCommand("uv", ["pip", "install", "--system", "--break-system-packages", "--python", pythonCommand, "--quiet", ...deps], { timeoutMs: PACKAGE_INSTALL_TIMEOUT_MS });
|
|
5854
5956
|
return { ok: true };
|
|
5855
5957
|
} catch (uvErr) {
|
|
5856
5958
|
return {
|
|
@@ -5886,7 +5988,7 @@ function stageHermesBundle(bytes, targetDir) {
|
|
|
5886
5988
|
try {
|
|
5887
5989
|
writeFileSync(tarballPath, bytes);
|
|
5888
5990
|
try {
|
|
5889
|
-
|
|
5991
|
+
runHostCommand("tar", ["-xzf", tarballPath, "-C", tmpDir, "--no-same-owner", "--no-same-permissions"]);
|
|
5890
5992
|
} catch (err) {
|
|
5891
5993
|
return { success: false, error: `tar extract failed: ${err instanceof Error ? err.message : String(err)}` };
|
|
5892
5994
|
}
|
|
@@ -5901,14 +6003,14 @@ function stageHermesBundle(bytes, targetDir) {
|
|
|
5901
6003
|
mkdirSync(dirname2(targetDir), { recursive: true });
|
|
5902
6004
|
if (existsSync2(targetDir)) {
|
|
5903
6005
|
backupPath = `${targetDir}.bak-${Date.now()}`;
|
|
5904
|
-
|
|
6006
|
+
renameSync2(targetDir, backupPath);
|
|
5905
6007
|
}
|
|
5906
6008
|
try {
|
|
5907
|
-
|
|
6009
|
+
renameSync2(stagedDir, targetDir);
|
|
5908
6010
|
} catch (err) {
|
|
5909
6011
|
if (backupPath) {
|
|
5910
6012
|
try {
|
|
5911
|
-
|
|
6013
|
+
renameSync2(backupPath, targetDir);
|
|
5912
6014
|
backupPath = null;
|
|
5913
6015
|
} catch {}
|
|
5914
6016
|
}
|
|
@@ -5924,7 +6026,7 @@ function stageHermesBundle(bytes, targetDir) {
|
|
|
5924
6026
|
if (backupPath) {
|
|
5925
6027
|
try {
|
|
5926
6028
|
rmSync2(targetDir, { recursive: true, force: true });
|
|
5927
|
-
|
|
6029
|
+
renameSync2(backupPath, targetDir);
|
|
5928
6030
|
backupPath = null;
|
|
5929
6031
|
} catch {}
|
|
5930
6032
|
}
|
|
@@ -5939,20 +6041,22 @@ function stageHermesBundle(bytes, targetDir) {
|
|
|
5939
6041
|
}
|
|
5940
6042
|
function enableHermesPluginForProfile(profile) {
|
|
5941
6043
|
try {
|
|
5942
|
-
|
|
6044
|
+
enableHermesFollowUp(profile);
|
|
6045
|
+
runHostCommand("hermes", [...profile === HERMES_DEFAULT_PROFILE ? [] : ["-p", profile], "plugins", "enable", "agentapprove"], { interactive: true, timeoutMs: PACKAGE_INSTALL_TIMEOUT_MS });
|
|
5943
6046
|
return { success: true };
|
|
5944
6047
|
} catch (err) {
|
|
5945
6048
|
return { success: false, error: err instanceof Error ? err.message : String(err) };
|
|
5946
6049
|
}
|
|
5947
6050
|
}
|
|
5948
6051
|
async function installHermesPluginViaCli() {
|
|
6052
|
+
v2.info("Hermes: checking CLI and Python");
|
|
5949
6053
|
try {
|
|
5950
|
-
|
|
5951
|
-
} catch {
|
|
6054
|
+
runHostCommand("hermes", ["--version"]);
|
|
6055
|
+
} catch (err) {
|
|
5952
6056
|
return {
|
|
5953
6057
|
success: false,
|
|
5954
6058
|
label: "Agent Approve plugin",
|
|
5955
|
-
error:
|
|
6059
|
+
error: `Could not check Hermes CLI: ${err instanceof Error ? err.message : String(err)}. Run hermes --version to diagnose, then retry setup.`
|
|
5956
6060
|
};
|
|
5957
6061
|
}
|
|
5958
6062
|
const python = findPython();
|
|
@@ -5971,6 +6075,7 @@ async function installHermesPluginViaCli() {
|
|
|
5971
6075
|
error: "Missing API token. Pair your phone first by running `npx agentapprove` and completing the QR scan."
|
|
5972
6076
|
};
|
|
5973
6077
|
}
|
|
6078
|
+
v2.info("Hermes: downloading and verifying the plugin (up to 90 seconds)");
|
|
5974
6079
|
const download = await downloadHermesBundle(cfg.apiUrl, cfg.apiVersion, cfg.token);
|
|
5975
6080
|
if (!download.ok) {
|
|
5976
6081
|
return { success: false, label: "Agent Approve plugin", error: download.error };
|
|
@@ -5987,7 +6092,9 @@ async function installHermesPluginViaCli() {
|
|
|
5987
6092
|
if (!staged.success) {
|
|
5988
6093
|
return { success: false, label: "Agent Approve plugin", error: staged.error };
|
|
5989
6094
|
}
|
|
6095
|
+
v2.info("Hermes: checking Python dependencies");
|
|
5990
6096
|
if (!hermesDepsAlreadyInstalled(python.command)) {
|
|
6097
|
+
v2.info("Hermes: installing Python dependencies (up to 3 minutes per attempt)");
|
|
5991
6098
|
const depsResult = installHermesDepsAdaptive(python.command, HERMES_PIP_DEPS);
|
|
5992
6099
|
if (!depsResult.ok) {
|
|
5993
6100
|
return {
|
|
@@ -5997,6 +6104,7 @@ async function installHermesPluginViaCli() {
|
|
|
5997
6104
|
};
|
|
5998
6105
|
}
|
|
5999
6106
|
}
|
|
6107
|
+
v2.info("Hermes: enabling the plugin; review any permissions requested by Hermes");
|
|
6000
6108
|
const enabled = enableHermesPluginForProfile(HERMES_DEFAULT_PROFILE);
|
|
6001
6109
|
if (!enabled.success) {
|
|
6002
6110
|
return {
|
|
@@ -6010,17 +6118,17 @@ async function installHermesPluginViaCli() {
|
|
|
6010
6118
|
function isHermesDisableNoOp(err) {
|
|
6011
6119
|
if (!err || typeof err !== "object")
|
|
6012
6120
|
return false;
|
|
6013
|
-
const
|
|
6014
|
-
const stderr = Buffer.isBuffer(
|
|
6015
|
-
const stdout = Buffer.isBuffer(
|
|
6016
|
-
const haystack = `${
|
|
6121
|
+
const e = err;
|
|
6122
|
+
const stderr = Buffer.isBuffer(e.stderr) ? e.stderr.toString() : String(e.stderr || "");
|
|
6123
|
+
const stdout = Buffer.isBuffer(e.stdout) ? e.stdout.toString() : String(e.stdout || "");
|
|
6124
|
+
const haystack = `${e.message || ""}
|
|
6017
6125
|
${stderr}
|
|
6018
6126
|
${stdout}`.toLowerCase();
|
|
6019
6127
|
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");
|
|
6020
6128
|
}
|
|
6021
6129
|
function disableHermesPluginForProfile(profile) {
|
|
6022
6130
|
try {
|
|
6023
|
-
|
|
6131
|
+
runHostCommand("hermes", [...profile === HERMES_DEFAULT_PROFILE ? [] : ["-p", profile], "plugins", "disable", "agentapprove"]);
|
|
6024
6132
|
return { success: true };
|
|
6025
6133
|
} catch (err) {
|
|
6026
6134
|
if (isHermesDisableNoOp(err)) {
|
|
@@ -6054,8 +6162,8 @@ function hermesProfilePluginStatus(profile) {
|
|
|
6054
6162
|
if (installed) {
|
|
6055
6163
|
try {
|
|
6056
6164
|
const configPy = readFileSync(join(dir, "config.py"), "utf-8");
|
|
6057
|
-
const
|
|
6058
|
-
version =
|
|
6165
|
+
const m = configPy.match(/^PLUGIN_VERSION\s*=\s*["']([^"']+)["']/m);
|
|
6166
|
+
version = m ? m[1] : null;
|
|
6059
6167
|
} catch {}
|
|
6060
6168
|
}
|
|
6061
6169
|
return { name: profile, isDefault: profile === HERMES_DEFAULT_PROFILE, installed, version };
|
|
@@ -6072,13 +6180,13 @@ function listHermesProfiles() {
|
|
|
6072
6180
|
}
|
|
6073
6181
|
}
|
|
6074
6182
|
} catch {}
|
|
6075
|
-
return [...names].sort((
|
|
6183
|
+
return [...names].sort((a, b) => a === HERMES_DEFAULT_PROFILE ? -1 : b === HERMES_DEFAULT_PROFILE ? 1 : a.localeCompare(b)).map(hermesProfilePluginStatus);
|
|
6076
6184
|
}
|
|
6077
6185
|
async function syncHermesProfiles(targetProfiles) {
|
|
6078
6186
|
try {
|
|
6079
|
-
|
|
6080
|
-
} catch {
|
|
6081
|
-
return { ok: false, results: [], error:
|
|
6187
|
+
runHostCommand("hermes", ["--version"]);
|
|
6188
|
+
} catch (err) {
|
|
6189
|
+
return { ok: false, results: [], error: `Could not check Hermes CLI: ${err instanceof Error ? err.message : String(err)}. Run hermes --version to diagnose, then retry setup.` };
|
|
6082
6190
|
}
|
|
6083
6191
|
const python = findPython();
|
|
6084
6192
|
if (!python) {
|
|
@@ -6101,6 +6209,7 @@ async function syncHermesProfiles(targetProfiles) {
|
|
|
6101
6209
|
};
|
|
6102
6210
|
}
|
|
6103
6211
|
if (!hermesDepsAlreadyInstalled(python.command)) {
|
|
6212
|
+
v2.info("Hermes: installing Python dependencies (up to 3 minutes per attempt)");
|
|
6104
6213
|
const depsResult = installHermesDepsAdaptive(python.command, HERMES_PIP_DEPS);
|
|
6105
6214
|
if (!depsResult.ok) {
|
|
6106
6215
|
return { ok: false, results: [], error: `Could not install Python runtime deps: ${depsResult.error}` };
|
|
@@ -6120,7 +6229,7 @@ async function syncHermesProfiles(targetProfiles) {
|
|
|
6120
6229
|
const enabled = enableHermesPluginForProfile(profile);
|
|
6121
6230
|
results.push({ profile, success: enabled.success, error: enabled.error });
|
|
6122
6231
|
}
|
|
6123
|
-
return { ok: results.every((
|
|
6232
|
+
return { ok: results.every((r) => r.success), results };
|
|
6124
6233
|
}
|
|
6125
6234
|
var SYSTEM_DEPS = [
|
|
6126
6235
|
{
|
|
@@ -6253,7 +6362,7 @@ async function checkSystemDependencies() {
|
|
|
6253
6362
|
return true;
|
|
6254
6363
|
const pm = detectPackageManager();
|
|
6255
6364
|
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((
|
|
6365
|
+
const requiredMissing = missing.filter((d) => d.required);
|
|
6257
6366
|
const lines = missing.map((dep) => {
|
|
6258
6367
|
const cmd = dep.install[pm];
|
|
6259
6368
|
return `${source_default.red("x")} ${source_default.bold(dep.name)} - ${dep.description}
|
|
@@ -6275,18 +6384,18 @@ async function checkSystemDependencies() {
|
|
|
6275
6384
|
const allSamePrefix = uniqueCommands.every((c) => c.startsWith("sudo apt-get") || c.startsWith("sudo dnf") || c.startsWith("apk") || c.startsWith("brew") || c.startsWith("winget"));
|
|
6276
6385
|
let combinedCommand = "";
|
|
6277
6386
|
if (allSamePrefix && pm === "apt") {
|
|
6278
|
-
combinedCommand = `sudo apt-get install -y ${requiredMissing.map((
|
|
6387
|
+
combinedCommand = `sudo apt-get install -y ${requiredMissing.map((d) => d.name === "base64" ? "coreutils" : d.name === "xxd" ? "xxd" : d.name).join(" ")}`;
|
|
6279
6388
|
} else if (allSamePrefix && pm === "dnf") {
|
|
6280
|
-
combinedCommand = `sudo dnf install -y ${requiredMissing.map((
|
|
6389
|
+
combinedCommand = `sudo dnf install -y ${requiredMissing.map((d) => d.name === "base64" ? "coreutils" : d.name === "xxd" ? "vim-common" : d.name).join(" ")}`;
|
|
6281
6390
|
} else if (allSamePrefix && pm === "alpine") {
|
|
6282
|
-
combinedCommand = `apk add ${requiredMissing.map((
|
|
6391
|
+
combinedCommand = `apk add ${requiredMissing.map((d) => d.name === "base64" ? "coreutils" : d.name === "xxd" ? "vim" : d.name).join(" ")}`;
|
|
6283
6392
|
} else if (allSamePrefix && pm === "macos") {
|
|
6284
|
-
const brewPkgs = requiredMissing.filter((
|
|
6393
|
+
const brewPkgs = requiredMissing.filter((d) => d.install.macos !== "included with macOS").map((d) => d.name === "xxd" ? "vim" : d.name);
|
|
6285
6394
|
if (brewPkgs.length > 0) {
|
|
6286
6395
|
combinedCommand = `brew install ${brewPkgs.join(" ")}`;
|
|
6287
6396
|
}
|
|
6288
6397
|
} else if (pm === "windows") {
|
|
6289
|
-
const winPkgs = requiredMissing.filter((
|
|
6398
|
+
const winPkgs = requiredMissing.filter((d) => d.install.windows !== "included with Git Bash").map((d) => d.install.windows);
|
|
6290
6399
|
if (winPkgs.length > 0) {
|
|
6291
6400
|
combinedCommand = winPkgs.join(" && ");
|
|
6292
6401
|
}
|
|
@@ -6309,9 +6418,9 @@ async function checkSystemDependencies() {
|
|
|
6309
6418
|
try {
|
|
6310
6419
|
execSync(combinedCommand, { stdio: "pipe" });
|
|
6311
6420
|
installSpinner.stop("Dependencies installed");
|
|
6312
|
-
const stillMissing = requiredMissing.filter((
|
|
6421
|
+
const stillMissing = requiredMissing.filter((d) => !checkCommand(d.name));
|
|
6313
6422
|
if (stillMissing.length > 0) {
|
|
6314
|
-
v2.warn(`Could not verify: ${stillMissing.map((
|
|
6423
|
+
v2.warn(`Could not verify: ${stillMissing.map((d) => d.name).join(", ")}. Continuing anyway.`);
|
|
6315
6424
|
}
|
|
6316
6425
|
} catch (err) {
|
|
6317
6426
|
installSpinner.stop("Installation failed");
|
|
@@ -6392,7 +6501,7 @@ function describeExistingTokenStatus(preflight) {
|
|
|
6392
6501
|
}
|
|
6393
6502
|
async function promptTokenRecoveryAction(preflight) {
|
|
6394
6503
|
if (preflight.kind === "expired") {
|
|
6395
|
-
const
|
|
6504
|
+
const choice = await le({
|
|
6396
6505
|
message: "Your saved token has expired. How would you like to continue?",
|
|
6397
6506
|
options: [
|
|
6398
6507
|
{ value: "refresh", label: "Refresh token", hint: "Keeps the existing encryption key; settings resync from your account on the next event" },
|
|
@@ -6400,9 +6509,9 @@ async function promptTokenRecoveryAction(preflight) {
|
|
|
6400
6509
|
{ value: "cancel", label: "Cancel", hint: "Exit the installer" }
|
|
6401
6510
|
]
|
|
6402
6511
|
});
|
|
6403
|
-
if (lD(
|
|
6512
|
+
if (lD(choice))
|
|
6404
6513
|
return "cancel";
|
|
6405
|
-
return
|
|
6514
|
+
return choice;
|
|
6406
6515
|
}
|
|
6407
6516
|
const choice = await le({
|
|
6408
6517
|
message: "Your saved token is no longer valid. How would you like to continue?",
|
|
@@ -6435,9 +6544,9 @@ async function installCommand() {
|
|
|
6435
6544
|
let existingKeyId = null;
|
|
6436
6545
|
if (existingConfig) {
|
|
6437
6546
|
existingTokenPreview = hasExistingToken ? existingConfig.token.slice(0, 15) + "..." : "Not set";
|
|
6438
|
-
const
|
|
6439
|
-
if (existsSync2(
|
|
6440
|
-
const keyHex = readFileSync(
|
|
6547
|
+
const e2eKeyPath = join(getAgentApproveDir(), "e2e-key");
|
|
6548
|
+
if (existsSync2(e2eKeyPath)) {
|
|
6549
|
+
const keyHex = readFileSync(e2eKeyPath, "utf-8").trim();
|
|
6441
6550
|
existingKeyId = createHash("sha256").update(Buffer.from(keyHex, "hex")).digest("hex").slice(0, 8);
|
|
6442
6551
|
}
|
|
6443
6552
|
}
|
|
@@ -6465,6 +6574,9 @@ Monitor activity, enforce policy, and approve with a tap.`, "About");
|
|
|
6465
6574
|
he("Installation cancelled");
|
|
6466
6575
|
process.exit(0);
|
|
6467
6576
|
}
|
|
6577
|
+
if (selectedAgents.includes("openclaw")) {
|
|
6578
|
+
v2.info(CONVERSATION_ACCESS_NOTICE);
|
|
6579
|
+
}
|
|
6468
6580
|
const setupProfileSummary = existingConfig ? formatSetupProfileBlock("Existing config", getInitialInstallConfig("existing-config", existingConfig), [
|
|
6469
6581
|
`Connection token: ${existingTokenPreview} - ${describeExistingTokenStatus(existingTokenPreflight)}.`,
|
|
6470
6582
|
...existingKeyId ? [`Encryption key ID: ${existingKeyId} - already installed for this computer.`] : []
|
|
@@ -6534,7 +6646,7 @@ Monitor activity, enforce policy, and approve with a tap.`, "About");
|
|
|
6534
6646
|
message: "If Agent Approve is unreachable, hooks should:",
|
|
6535
6647
|
initialValue: failBehavior,
|
|
6536
6648
|
options: [
|
|
6537
|
-
{ value: "ask", label: "Ask", hint: "
|
|
6649
|
+
{ value: "ask", label: "Ask", hint: "Ask locally when supported; otherwise block (recommended)" },
|
|
6538
6650
|
{ value: "deny", label: "Deny", hint: "Block all commands until service is restored" },
|
|
6539
6651
|
{ value: "allow", label: "Allow", hint: "Allow all commands to proceed without approval" }
|
|
6540
6652
|
]
|
|
@@ -6700,7 +6812,7 @@ Monitor activity, enforce policy, and approve with a tap.`, "About");
|
|
|
6700
6812
|
} else if (shouldCreateFreshPairing(connectionMethod)) {
|
|
6701
6813
|
const pairingMethod = connectionMethod;
|
|
6702
6814
|
if (backupOldKeyTo) {
|
|
6703
|
-
|
|
6815
|
+
renameSync2(existingKeyPath, backupOldKeyTo);
|
|
6704
6816
|
v2.success(`Old key backed up to ${backupOldKeyTo}`);
|
|
6705
6817
|
backupOldKeyTo = null;
|
|
6706
6818
|
}
|
|
@@ -6807,19 +6919,28 @@ Monitor activity, enforce policy, and approve with a tap.`, "About");
|
|
|
6807
6919
|
if (hookDownloadPlan.files.length > 0) {
|
|
6808
6920
|
const downloadSpinner = _2();
|
|
6809
6921
|
downloadSpinner.start("Downloading hook scripts");
|
|
6810
|
-
const downloadResult = await copyHookScripts2(hooksDir, token, hookDownloadPlan.files, {
|
|
6922
|
+
const downloadResult = await copyHookScripts2(hooksDir, token, hookDownloadPlan.files, {
|
|
6923
|
+
apiUrl,
|
|
6924
|
+
optionalFiles: BACKGROUND_FILTER_FILES,
|
|
6925
|
+
onRateLimit: (_file, seconds) => downloadSpinner.message(`Download limit reached. Retrying in ${seconds}s…`)
|
|
6926
|
+
});
|
|
6811
6927
|
const summary = formatHookDownloadSummary(hookDownloadPlan);
|
|
6812
6928
|
if (downloadResult.terminalFailure) {
|
|
6813
|
-
downloadSpinner.stop(`
|
|
6929
|
+
downloadSpinner.stop(`Fetched ${downloadResult.downloaded} of ${hookDownloadPlan.files.length} hook files; no changes saved`);
|
|
6814
6930
|
const message = describeDownloadTerminalFailure(downloadResult.terminalFailure.kind);
|
|
6815
6931
|
v2.error(message);
|
|
6816
6932
|
he("Hook download stopped before completion.");
|
|
6817
6933
|
process.exit(1);
|
|
6818
6934
|
} else if (downloadResult.failed.length > 0) {
|
|
6819
|
-
downloadSpinner.stop(`
|
|
6820
|
-
v2.warn(`
|
|
6935
|
+
downloadSpinner.stop(`Hook installation incomplete (${downloadResult.downloaded} files fetched)`);
|
|
6936
|
+
v2.warn(`Could not install: ${downloadResult.failed.join(", ")}`);
|
|
6937
|
+
he("Required hook downloads are incomplete. Please rerun the installer.");
|
|
6938
|
+
process.exit(1);
|
|
6821
6939
|
} else {
|
|
6822
|
-
downloadSpinner.stop(`Hook
|
|
6940
|
+
downloadSpinner.stop(`Hook files fetched (${downloadResult.downloaded} files: ${summary})`);
|
|
6941
|
+
if (downloadResult.optionalFailed.length) {
|
|
6942
|
+
v2.warn("Background activity filters could not be refreshed. Any previous copy is retained; required hooks are ready.");
|
|
6943
|
+
}
|
|
6823
6944
|
}
|
|
6824
6945
|
} else {
|
|
6825
6946
|
v2.success("No hook scripts needed for the selected agents");
|
|
@@ -6872,16 +6993,16 @@ AGENTAPPROVE_E2E_MODE=${installMode}
|
|
|
6872
6993
|
filesToModify.push(join(homedir(), ".codex", "config.toml"));
|
|
6873
6994
|
}
|
|
6874
6995
|
if (agentId === "opencode") {
|
|
6875
|
-
filesToModify.push(
|
|
6996
|
+
filesToModify.push("OpenCode plugin cache");
|
|
6876
6997
|
}
|
|
6877
6998
|
if (agentId === "openclaw") {
|
|
6878
|
-
filesToModify.push(
|
|
6999
|
+
filesToModify.push("OpenClaw plugin registry");
|
|
6879
7000
|
}
|
|
6880
7001
|
if (agentId === "pi") {
|
|
6881
|
-
filesToModify.push("Pi package registry
|
|
7002
|
+
filesToModify.push("Pi package registry");
|
|
6882
7003
|
}
|
|
6883
7004
|
if (agentId === "hermes") {
|
|
6884
|
-
filesToModify.push(
|
|
7005
|
+
filesToModify.push("~/.hermes/plugins/agentapprove/ (plugin update; mobile follow-up enabled)");
|
|
6885
7006
|
}
|
|
6886
7007
|
if (agentId === "vscode-agent") {
|
|
6887
7008
|
const vsCodeVariants = findInstalledVSCodeVariants();
|
|
@@ -6890,10 +7011,13 @@ AGENTAPPROVE_E2E_MODE=${installMode}
|
|
|
6890
7011
|
}
|
|
6891
7012
|
}
|
|
6892
7013
|
}
|
|
6893
|
-
|
|
7014
|
+
const homePrefix = `${homedir()}/`;
|
|
7015
|
+
const fileSummary = filesToModify.map((path) => path.startsWith(homePrefix) ? `~/${path.slice(homePrefix.length)}` : path);
|
|
7016
|
+
v2.step("Files to be modified");
|
|
7017
|
+
v2.message(`${fileSummary.join(`
|
|
6894
7018
|
`)}
|
|
6895
7019
|
|
|
6896
|
-
|
|
7020
|
+
Timestamped backups will be created.`);
|
|
6897
7021
|
const confirm = await ce({
|
|
6898
7022
|
message: "Proceed with automatic installation?"
|
|
6899
7023
|
});
|
|
@@ -6905,13 +7029,20 @@ Backups will be created with timestamp`, "Files to be modified");
|
|
|
6905
7029
|
const agent = AGENTS[agentId];
|
|
6906
7030
|
const spinner = _2();
|
|
6907
7031
|
const spinnerMsg = agentId === "pi" ? `Installing ${agent.name} extension` : agentId === "openclaw" || agentId === "hermes" ? `Installing ${agent.name} plugin` : `Configuring ${agent.name}`;
|
|
6908
|
-
|
|
7032
|
+
const hostSetup = ["openclaw", "pi", "hermes"].includes(agentId);
|
|
7033
|
+
if (hostSetup)
|
|
7034
|
+
v2.step(spinnerMsg);
|
|
7035
|
+
else
|
|
7036
|
+
spinner.start(spinnerMsg);
|
|
6909
7037
|
const result = await installHooksForAgent(agentId, hooksDir, installMode);
|
|
6910
7038
|
if (result.success) {
|
|
6911
7039
|
const installedHookNames = result.hooks.join(", ");
|
|
6912
7040
|
const backupMsg = result.backupPath ? source_default.dim(` (backup created)`) : "";
|
|
6913
7041
|
const agentName = source_default.cyan(agent.name);
|
|
6914
|
-
|
|
7042
|
+
if (hostSetup)
|
|
7043
|
+
v2.success(`${agentName}: ${installedHookNames}${backupMsg}`);
|
|
7044
|
+
else
|
|
7045
|
+
spinner.stop(`${agentName}: ${installedHookNames}${backupMsg}`);
|
|
6915
7046
|
if (agentId === "vscode-agent") {
|
|
6916
7047
|
const vsCodeSpinner = _2();
|
|
6917
7048
|
vsCodeSpinner.start("Registering hook path in VS Code settings");
|
|
@@ -6950,11 +7081,15 @@ Backups will be created with timestamp`, "Files to be modified");
|
|
|
6950
7081
|
}
|
|
6951
7082
|
} else {
|
|
6952
7083
|
failedSetupAgents.add(agentId);
|
|
6953
|
-
|
|
7084
|
+
if (hostSetup)
|
|
7085
|
+
v2.error(`${agent.name} configuration failed`);
|
|
7086
|
+
else
|
|
7087
|
+
spinner.stop(`${agent.name} configuration failed`);
|
|
6954
7088
|
if (agentId === "openclaw") {
|
|
6955
|
-
v2.warn(`
|
|
7089
|
+
v2.warn(`OpenClaw setup did not finish.
|
|
6956
7090
|
` + ` Error: ${result.error || "unknown"}
|
|
6957
|
-
` + `
|
|
7091
|
+
` + ` Check plugin status: openclaw plugins inspect openclaw
|
|
7092
|
+
` + ` If the package is missing: openclaw plugins install ${OPENCLAW_PLUGIN_SPEC}
|
|
6958
7093
|
` + ` Then re-run: npx agentapprove`);
|
|
6959
7094
|
} else if (agentId === "pi") {
|
|
6960
7095
|
v2.warn(`Could not install ${PI_PLUGIN_SPEC} via Pi.
|
|
@@ -6971,7 +7106,8 @@ Backups will be created with timestamp`, "Files to be modified");
|
|
|
6971
7106
|
` + ` 4. Write the SHA-256 to ~/.hermes/plugins/agentapprove/.bundle-hash
|
|
6972
7107
|
` + ` 5. pip install --user cryptography httpx
|
|
6973
7108
|
` + ` (uv-managed Python: uv pip install --system --break-system-packages --python $(which python3.12) cryptography httpx)
|
|
6974
|
-
` + ` 6. hermes
|
|
7109
|
+
` + ` 6. hermes config set plugins.entries.agentapprove.allow_gateway_injection true
|
|
7110
|
+
` + ` 7. hermes plugins enable agentapprove
|
|
6975
7111
|
` + ` Then re-run: npx agentapprove`);
|
|
6976
7112
|
}
|
|
6977
7113
|
}
|
|
@@ -7053,17 +7189,17 @@ function inspectSetup(agentIds) {
|
|
|
7053
7189
|
return result("failed", "not_configured");
|
|
7054
7190
|
const filesReady = (file) => {
|
|
7055
7191
|
const path = join(getAgentApproveDir(), "hooks", file);
|
|
7056
|
-
return existsSync2(path) && statSync(path).size > 0 && (statSync(path).mode & 73) !== 0;
|
|
7192
|
+
return existsSync2(path) && statSync(path).size > 0 && (!file.endsWith(".sh") || (statSync(path).mode & 73) !== 0);
|
|
7057
7193
|
};
|
|
7058
|
-
if (!SHARED_HOOK_FILES.every(filesReady))
|
|
7194
|
+
if (!SHARED_HOOK_FILES.filter((file) => !BACKGROUND_FILTER_FILES.includes(file)).every(filesReady))
|
|
7059
7195
|
return result("failed", "missing_files");
|
|
7060
|
-
if (
|
|
7196
|
+
if (spawnSync2("bash", ["-c", "command -v curl >/dev/null && command -v jq >/dev/null && command -v openssl >/dev/null"], { timeout: 5000 }).status !== 0)
|
|
7061
7197
|
return result("failed", "missing_dependency");
|
|
7062
7198
|
if (isAntigravityAgent(agentId)) {
|
|
7063
7199
|
if (!existsSync2(join(getAntigravityPluginRoot(agentId), "plugin.json")))
|
|
7064
7200
|
return result("failed", "missing_files");
|
|
7065
7201
|
const mode = existing.e2eMode ?? "approval";
|
|
7066
|
-
const hooks = mode === "observe" ? agent.hooks.filter((
|
|
7202
|
+
const hooks = mode === "observe" ? agent.hooks.filter((h) => h.name !== "Stop") : agent.hooks;
|
|
7067
7203
|
return checkHookConfiguration(agentId, config, "agentapprove", hooks, "approval", filesReady, (file, name) => buildAntigravityHookCommand(join(getAgentApproveDir(), "hooks", file), agentId, name, mode));
|
|
7068
7204
|
}
|
|
7069
7205
|
return checkHookConfiguration(agentId, config, agent.hooksKey, agent.hooks, existing.e2eMode ?? "approval", filesReady, (file) => buildHookCommand(join(getAgentApproveDir(), "hooks", file), agentId));
|
|
@@ -7090,9 +7226,9 @@ async function profilesCommand() {
|
|
|
7090
7226
|
console.clear();
|
|
7091
7227
|
pe(source_default.bgCyan.black(" Agent Approve ") + source_default.gray(" Hermes Profiles"));
|
|
7092
7228
|
try {
|
|
7093
|
-
|
|
7094
|
-
} catch {
|
|
7095
|
-
v2.error(
|
|
7229
|
+
runHostCommand("hermes", ["--version"]);
|
|
7230
|
+
} catch (err) {
|
|
7231
|
+
v2.error(`Could not check Hermes CLI: ${err instanceof Error ? err.message : String(err)}. Run hermes --version to diagnose, then retry setup.`);
|
|
7096
7232
|
ge("No changes made.");
|
|
7097
7233
|
process.exit(1);
|
|
7098
7234
|
}
|
|
@@ -7146,6 +7282,8 @@ async function profilesCommand() {
|
|
|
7146
7282
|
toUpdate.length ? `Update to v${HERMES_PLUGIN_VERSION}: ${toUpdate.join(", ")}` : null,
|
|
7147
7283
|
toRemove.length ? `Remove from: ${toRemove.join(", ")}` : null
|
|
7148
7284
|
].filter(Boolean);
|
|
7285
|
+
if (toSync.length)
|
|
7286
|
+
planLines.push("Allow mobile follow-up replies in the selected Hermes profiles.");
|
|
7149
7287
|
me(planLines.join(`
|
|
7150
7288
|
`), "Planned changes");
|
|
7151
7289
|
const confirm = await ce({ message: "Apply these changes?" });
|
|
@@ -7154,30 +7292,29 @@ async function profilesCommand() {
|
|
|
7154
7292
|
process.exit(0);
|
|
7155
7293
|
}
|
|
7156
7294
|
if (toSync.length > 0) {
|
|
7157
|
-
const s = _2();
|
|
7158
7295
|
const verb = toInstall.length && toUpdate.length ? "Installing/updating" : toUpdate.length ? "Updating" : "Installing";
|
|
7159
|
-
|
|
7296
|
+
v2.step(`${verb} Agent Approve in ${toSync.length} profile(s)…`);
|
|
7160
7297
|
const sync = await syncHermesProfiles(toSync);
|
|
7161
7298
|
if (sync.results.length === 0) {
|
|
7162
|
-
|
|
7299
|
+
v2.error(`Failed: ${sync.error ?? "unknown error"}`);
|
|
7163
7300
|
ge("No changes made.");
|
|
7164
7301
|
process.exit(1);
|
|
7165
7302
|
}
|
|
7166
|
-
|
|
7167
|
-
for (const
|
|
7168
|
-
const action = toUpdate.includes(
|
|
7169
|
-
if (
|
|
7170
|
-
v2.success(`${
|
|
7303
|
+
v2.info(sync.ok ? "Done" : "Done (some profiles failed)");
|
|
7304
|
+
for (const r of sync.results) {
|
|
7305
|
+
const action = toUpdate.includes(r.profile) ? "updated to" : "installed";
|
|
7306
|
+
if (r.success)
|
|
7307
|
+
v2.success(`${r.profile}: Agent Approve ${action} v${HERMES_PLUGIN_VERSION}`);
|
|
7171
7308
|
else
|
|
7172
|
-
v2.error(`${
|
|
7309
|
+
v2.error(`${r.profile}: ${r.error ?? "failed"}`);
|
|
7173
7310
|
}
|
|
7174
7311
|
}
|
|
7175
7312
|
for (const profile of toRemove) {
|
|
7176
|
-
const
|
|
7177
|
-
if (
|
|
7313
|
+
const r = removeHermesPluginFromProfile(profile);
|
|
7314
|
+
if (r.success)
|
|
7178
7315
|
v2.success(`${profile}: Agent Approve removed`);
|
|
7179
7316
|
else
|
|
7180
|
-
v2.warn(`${profile}: removal partial (${
|
|
7317
|
+
v2.warn(`${profile}: removal partial (${r.error ?? "unknown"})`);
|
|
7181
7318
|
}
|
|
7182
7319
|
ge("Hermes profiles updated.");
|
|
7183
7320
|
}
|
|
@@ -7276,27 +7413,27 @@ async function statusCommand() {
|
|
|
7276
7413
|
if (isAntigravityAgent(agentId)) {
|
|
7277
7414
|
const bundle = config.agentapprove;
|
|
7278
7415
|
if (bundle) {
|
|
7279
|
-
const installedHooks = agent.hooks.filter((
|
|
7280
|
-
const hookEntry = bundle[
|
|
7416
|
+
const installedHooks = agent.hooks.filter((h) => {
|
|
7417
|
+
const hookEntry = bundle[h.name];
|
|
7281
7418
|
return !!hookEntry && JSON.stringify(hookEntry).includes("agentapprove");
|
|
7282
7419
|
});
|
|
7283
7420
|
if (installedHooks.length > 0) {
|
|
7284
|
-
console.log(` ${source_default.green("✓")} ${agent.name}: ${installedHooks.map((
|
|
7421
|
+
console.log(` ${source_default.green("✓")} ${agent.name}: ${installedHooks.map((h) => formatHookStatusLabel(h.name)).join(", ")}`);
|
|
7285
7422
|
}
|
|
7286
7423
|
}
|
|
7287
7424
|
continue;
|
|
7288
7425
|
}
|
|
7289
7426
|
const hooksConfig = agent.hooksKey === "" ? config : config[agent.hooksKey];
|
|
7290
7427
|
if (hooksConfig) {
|
|
7291
|
-
const installedHooks = agent.hooks.filter((
|
|
7292
|
-
const hookEntry = hooksConfig[
|
|
7428
|
+
const installedHooks = agent.hooks.filter((h) => {
|
|
7429
|
+
const hookEntry = hooksConfig[h.name];
|
|
7293
7430
|
if (!hookEntry)
|
|
7294
7431
|
return false;
|
|
7295
7432
|
const str = JSON.stringify(hookEntry);
|
|
7296
7433
|
return str.includes("agentapprove");
|
|
7297
7434
|
});
|
|
7298
7435
|
if (installedHooks.length > 0) {
|
|
7299
|
-
console.log(` ${source_default.green("✓")} ${agent.name}: ${installedHooks.map((
|
|
7436
|
+
console.log(` ${source_default.green("✓")} ${agent.name}: ${installedHooks.map((h) => formatHookStatusLabel(h.name)).join(", ")}`);
|
|
7300
7437
|
}
|
|
7301
7438
|
}
|
|
7302
7439
|
}
|
|
@@ -7390,7 +7527,7 @@ async function disableCommand() {
|
|
|
7390
7527
|
const tmpPath = `${statePath}.tmp-${process.pid}`;
|
|
7391
7528
|
writeFileSync(tmpPath, JSON.stringify(merged, null, 2) + `
|
|
7392
7529
|
`, { mode: 384 });
|
|
7393
|
-
|
|
7530
|
+
renameSync2(tmpPath, statePath);
|
|
7394
7531
|
failed = false;
|
|
7395
7532
|
} catch {
|
|
7396
7533
|
failed = true;
|
|
@@ -7530,7 +7667,7 @@ async function enableCommand() {
|
|
|
7530
7667
|
const legacyDisabledPath = join(aaDir, "env.disabled");
|
|
7531
7668
|
const statePath = join(aaDir, DISABLED_STATE_FILENAME);
|
|
7532
7669
|
if (!existsSync2(envPath) && existsSync2(legacyDisabledPath)) {
|
|
7533
|
-
|
|
7670
|
+
renameSync2(legacyDisabledPath, envPath);
|
|
7534
7671
|
console.log(source_default.green(`
|
|
7535
7672
|
✓ Restored ~/.agentapprove/env (legacy disable).`));
|
|
7536
7673
|
}
|
|
@@ -7817,16 +7954,16 @@ async function restoreCommand() {
|
|
|
7817
7954
|
console.log(source_default.cyan(`
|
|
7818
7955
|
Restoring original configurations...
|
|
7819
7956
|
`));
|
|
7820
|
-
const { readdirSync
|
|
7957
|
+
const { readdirSync, copyFileSync } = await import("fs");
|
|
7821
7958
|
for (const [agentId, agent] of Object.entries(AGENTS)) {
|
|
7822
7959
|
const configDir = dirname2(agent.configPath);
|
|
7823
7960
|
if (!existsSync2(configDir))
|
|
7824
7961
|
continue;
|
|
7825
|
-
const files =
|
|
7826
|
-
const backups = files.filter((
|
|
7962
|
+
const files = readdirSync(configDir);
|
|
7963
|
+
const backups = files.filter((f) => f.startsWith(agent.configPath.split("/").pop()) && f.includes(".backup.")).sort().reverse();
|
|
7827
7964
|
if (backups.length > 0) {
|
|
7828
7965
|
const latestBackup = join(configDir, backups[0]);
|
|
7829
|
-
|
|
7966
|
+
copyFileSync(latestBackup, agent.configPath);
|
|
7830
7967
|
console.log(` ${source_default.green("✓")} ${agent.name} restored from ${backups[0]}`);
|
|
7831
7968
|
}
|
|
7832
7969
|
}
|
|
@@ -8096,11 +8233,11 @@ async function pairCommand() {
|
|
|
8096
8233
|
v2.info("E2E encryption disabled — event content will be visible on the web dashboard");
|
|
8097
8234
|
updateEnvValue("AGENTAPPROVE_E2E_ENABLED", "false");
|
|
8098
8235
|
} else if (selectedKeyId === "__generate__") {
|
|
8099
|
-
const currentKey = keys.find((
|
|
8236
|
+
const currentKey = keys.find((k) => k.isCurrent);
|
|
8100
8237
|
if (currentKey) {
|
|
8101
|
-
const
|
|
8102
|
-
const backupPath = join(
|
|
8103
|
-
|
|
8238
|
+
const agentApproveDir = getAgentApproveDir();
|
|
8239
|
+
const backupPath = join(agentApproveDir, `e2e-key.${currentKey.keyId}.bak`);
|
|
8240
|
+
renameSync2(currentKey.path, backupPath);
|
|
8104
8241
|
v2.info(`Previous key backed up (${currentKey.keyId})`);
|
|
8105
8242
|
}
|
|
8106
8243
|
e2eUserKey = randomBytes(32).toString("hex");
|
|
@@ -8117,7 +8254,7 @@ async function pairCommand() {
|
|
|
8117
8254
|
});
|
|
8118
8255
|
v2.success(`New key generated (${e2eKeyId})`);
|
|
8119
8256
|
} else {
|
|
8120
|
-
const selectedKey = keys.find((
|
|
8257
|
+
const selectedKey = keys.find((k) => k.keyId === selectedKeyId);
|
|
8121
8258
|
if (!selectedKey) {
|
|
8122
8259
|
v2.error("Selected key not found.");
|
|
8123
8260
|
process.exit(1);
|
|
@@ -8233,6 +8370,10 @@ async function updateHookScriptsWithToken(token, apiUrl) {
|
|
|
8233
8370
|
if (!existsSync2(hooksDir)) {
|
|
8234
8371
|
throw new Error("Hooks directory not found");
|
|
8235
8372
|
}
|
|
8373
|
+
const filters = await copyHookScripts2(hooksDir, token, BACKGROUND_FILTER_FILES, { apiUrl });
|
|
8374
|
+
if (filters.failed.length || filters.terminalFailure) {
|
|
8375
|
+
v2.warn("Background activity filters could not be refreshed. The previous copy is retained.");
|
|
8376
|
+
}
|
|
8236
8377
|
const hookFiles = [
|
|
8237
8378
|
"claude-pre-tool.sh",
|
|
8238
8379
|
"claude-post-tool.sh",
|