agentapprove 0.1.40 → 0.1.41
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 +2 -2
- package/dist/cli.js +641 -97
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -73,8 +73,8 @@ agentapprove status # Show configuration
|
|
|
73
73
|
agentapprove profiles # Install/remove across Hermes profiles
|
|
74
74
|
agentapprove pair # Pair with a new iOS device
|
|
75
75
|
agentapprove refresh # Refresh token and hooks
|
|
76
|
-
agentapprove disable #
|
|
77
|
-
agentapprove enable # Re-
|
|
76
|
+
agentapprove disable # Deregister hooks/plugins, keep local state
|
|
77
|
+
agentapprove enable # Re-register hooks/plugins after disable
|
|
78
78
|
agentapprove uninstall # Remove hooks
|
|
79
79
|
agentapprove restore # Restore from backup
|
|
80
80
|
agentapprove help # Show help
|
package/dist/cli.js
CHANGED
|
@@ -2423,9 +2423,11 @@ function removeRemovalTarget(target) {
|
|
|
2423
2423
|
}
|
|
2424
2424
|
function getOpenClawPluginTargets(openclawConfigPath) {
|
|
2425
2425
|
const configDir = dirname(openclawConfigPath);
|
|
2426
|
+
const npmPath = safeJoinWithinBase(configDir, "npm", "node_modules", "@agentapprove", "openclaw");
|
|
2426
2427
|
const openclawPath = safeJoinWithinBase(configDir, "extensions", "openclaw");
|
|
2427
2428
|
const legacyPath = safeJoinWithinBase(configDir, "extensions", "agentapprove");
|
|
2428
2429
|
return [
|
|
2430
|
+
npmPath ? createRemovalTarget(npmPath, "plugin_artifact", true) : null,
|
|
2429
2431
|
openclawPath ? createRemovalTarget(openclawPath, "plugin_artifact", true) : null,
|
|
2430
2432
|
legacyPath ? createRemovalTarget(legacyPath, "plugin_artifact", true) : null
|
|
2431
2433
|
].filter((target) => target !== null);
|
|
@@ -2516,6 +2518,235 @@ function shouldDeleteCryptoMaterial(purgeConfirmed, firstKeyConfirmation, second
|
|
|
2516
2518
|
return purgeConfirmed && firstKeyConfirmation && secondKeyConfirmation;
|
|
2517
2519
|
}
|
|
2518
2520
|
|
|
2521
|
+
// src/disable-utils.ts
|
|
2522
|
+
var DISABLED_STATE_FILENAME = "disabled.json";
|
|
2523
|
+
function isStringArray(value) {
|
|
2524
|
+
return Array.isArray(value) && value.every((entry) => typeof entry === "string");
|
|
2525
|
+
}
|
|
2526
|
+
function parseDisabledState(raw) {
|
|
2527
|
+
let parsed;
|
|
2528
|
+
try {
|
|
2529
|
+
parsed = JSON.parse(raw);
|
|
2530
|
+
} catch {
|
|
2531
|
+
return null;
|
|
2532
|
+
}
|
|
2533
|
+
if (!parsed || typeof parsed !== "object") {
|
|
2534
|
+
return null;
|
|
2535
|
+
}
|
|
2536
|
+
const candidate = parsed;
|
|
2537
|
+
if (candidate.version !== 1) {
|
|
2538
|
+
return null;
|
|
2539
|
+
}
|
|
2540
|
+
if (candidate.mode !== "observe" && candidate.mode !== "approval") {
|
|
2541
|
+
return null;
|
|
2542
|
+
}
|
|
2543
|
+
if (!Array.isArray(candidate.agents)) {
|
|
2544
|
+
return null;
|
|
2545
|
+
}
|
|
2546
|
+
const agents = [];
|
|
2547
|
+
for (const entry of candidate.agents) {
|
|
2548
|
+
if (!entry || typeof entry !== "object") {
|
|
2549
|
+
return null;
|
|
2550
|
+
}
|
|
2551
|
+
const record = entry;
|
|
2552
|
+
if (typeof record.agentId !== "string" || record.agentId.length === 0) {
|
|
2553
|
+
return null;
|
|
2554
|
+
}
|
|
2555
|
+
if (typeof record.kind !== "string" || record.kind.length === 0) {
|
|
2556
|
+
return null;
|
|
2557
|
+
}
|
|
2558
|
+
if (record.entryKeys !== undefined && !isStringArray(record.entryKeys)) {
|
|
2559
|
+
return null;
|
|
2560
|
+
}
|
|
2561
|
+
if (record.specs !== undefined && !isStringArray(record.specs)) {
|
|
2562
|
+
return null;
|
|
2563
|
+
}
|
|
2564
|
+
if (record.profiles !== undefined && !isStringArray(record.profiles)) {
|
|
2565
|
+
return null;
|
|
2566
|
+
}
|
|
2567
|
+
if (record.legacyDependency !== undefined && typeof record.legacyDependency !== "string") {
|
|
2568
|
+
return null;
|
|
2569
|
+
}
|
|
2570
|
+
agents.push({
|
|
2571
|
+
agentId: record.agentId,
|
|
2572
|
+
kind: record.kind,
|
|
2573
|
+
...record.entryKeys !== undefined ? { entryKeys: record.entryKeys } : {},
|
|
2574
|
+
...record.specs !== undefined ? { specs: record.specs } : {},
|
|
2575
|
+
...record.profiles !== undefined ? { profiles: record.profiles } : {},
|
|
2576
|
+
...record.legacyDependency !== undefined ? { legacyDependency: record.legacyDependency } : {}
|
|
2577
|
+
});
|
|
2578
|
+
}
|
|
2579
|
+
return {
|
|
2580
|
+
version: 1,
|
|
2581
|
+
disabledAt: typeof candidate.disabledAt === "string" ? candidate.disabledAt : "",
|
|
2582
|
+
cliVersion: typeof candidate.cliVersion === "string" ? candidate.cliVersion : "",
|
|
2583
|
+
mode: candidate.mode,
|
|
2584
|
+
agents
|
|
2585
|
+
};
|
|
2586
|
+
}
|
|
2587
|
+
function mergeDisabledStates(existing, incoming) {
|
|
2588
|
+
const known = new Set(existing.agents.map((agent) => `${agent.agentId}\x00${agent.kind}`));
|
|
2589
|
+
return {
|
|
2590
|
+
...existing,
|
|
2591
|
+
agents: [
|
|
2592
|
+
...existing.agents,
|
|
2593
|
+
...incoming.agents.filter((agent) => !known.has(`${agent.agentId}\x00${agent.kind}`))
|
|
2594
|
+
]
|
|
2595
|
+
};
|
|
2596
|
+
}
|
|
2597
|
+
function removeAgentApproveHookEntries(hooksConfig, hookNames) {
|
|
2598
|
+
let modified = false;
|
|
2599
|
+
for (const hookName of hookNames) {
|
|
2600
|
+
const hookEntry = hooksConfig[hookName];
|
|
2601
|
+
if (!hookEntry)
|
|
2602
|
+
continue;
|
|
2603
|
+
if (Array.isArray(hookEntry)) {
|
|
2604
|
+
const filtered = hookEntry.filter((e2) => {
|
|
2605
|
+
const str = JSON.stringify(e2);
|
|
2606
|
+
return !str.includes("agentapprove");
|
|
2607
|
+
});
|
|
2608
|
+
if (filtered.length !== hookEntry.length) {
|
|
2609
|
+
if (filtered.length === 0) {
|
|
2610
|
+
delete hooksConfig[hookName];
|
|
2611
|
+
} else {
|
|
2612
|
+
hooksConfig[hookName] = filtered;
|
|
2613
|
+
}
|
|
2614
|
+
modified = true;
|
|
2615
|
+
}
|
|
2616
|
+
} else if (typeof hookEntry === "string" && hookEntry.includes("agentapprove")) {
|
|
2617
|
+
delete hooksConfig[hookName];
|
|
2618
|
+
modified = true;
|
|
2619
|
+
}
|
|
2620
|
+
}
|
|
2621
|
+
if (hooksConfig.Prompt) {
|
|
2622
|
+
delete hooksConfig.Prompt;
|
|
2623
|
+
modified = true;
|
|
2624
|
+
}
|
|
2625
|
+
return modified;
|
|
2626
|
+
}
|
|
2627
|
+
function removeOpenCodePluginEntries(config) {
|
|
2628
|
+
const pluginArray = config.plugin;
|
|
2629
|
+
if (!Array.isArray(pluginArray)) {
|
|
2630
|
+
return { modified: false, removedSpecs: [] };
|
|
2631
|
+
}
|
|
2632
|
+
const removedSpecs = [];
|
|
2633
|
+
const filtered = pluginArray.filter((p) => {
|
|
2634
|
+
if (typeof p !== "string")
|
|
2635
|
+
return true;
|
|
2636
|
+
if (!p.includes("agentapprove"))
|
|
2637
|
+
return true;
|
|
2638
|
+
removedSpecs.push(p);
|
|
2639
|
+
return false;
|
|
2640
|
+
});
|
|
2641
|
+
if (removedSpecs.length === 0) {
|
|
2642
|
+
return { modified: false, removedSpecs: [] };
|
|
2643
|
+
}
|
|
2644
|
+
config.plugin = filtered;
|
|
2645
|
+
return { modified: true, removedSpecs };
|
|
2646
|
+
}
|
|
2647
|
+
function addOpenCodePluginEntries(config, specs) {
|
|
2648
|
+
const pluginArray = Array.isArray(config.plugin) ? [...config.plugin] : [];
|
|
2649
|
+
let modified = false;
|
|
2650
|
+
for (const spec of specs) {
|
|
2651
|
+
if (!pluginArray.includes(spec)) {
|
|
2652
|
+
pluginArray.push(spec);
|
|
2653
|
+
modified = true;
|
|
2654
|
+
}
|
|
2655
|
+
}
|
|
2656
|
+
if (modified || !Array.isArray(config.plugin)) {
|
|
2657
|
+
config.plugin = pluginArray;
|
|
2658
|
+
}
|
|
2659
|
+
return modified;
|
|
2660
|
+
}
|
|
2661
|
+
function removeOpenClawEntries(pluginsConfig) {
|
|
2662
|
+
const entries = pluginsConfig.entries;
|
|
2663
|
+
const installs = pluginsConfig.installs;
|
|
2664
|
+
let modified = false;
|
|
2665
|
+
for (const key of ["openclaw", "agentapprove"]) {
|
|
2666
|
+
if (entries && entries[key]) {
|
|
2667
|
+
delete entries[key];
|
|
2668
|
+
modified = true;
|
|
2669
|
+
}
|
|
2670
|
+
if (installs && installs[key]) {
|
|
2671
|
+
delete installs[key];
|
|
2672
|
+
modified = true;
|
|
2673
|
+
}
|
|
2674
|
+
}
|
|
2675
|
+
return modified;
|
|
2676
|
+
}
|
|
2677
|
+
function disableOpenClawEntries(config) {
|
|
2678
|
+
const plugins = config.plugins;
|
|
2679
|
+
const entries = plugins?.entries;
|
|
2680
|
+
if (!entries) {
|
|
2681
|
+
return { modified: false, disabledKeys: [] };
|
|
2682
|
+
}
|
|
2683
|
+
const disabledKeys = [];
|
|
2684
|
+
for (const key of ["openclaw", "agentapprove"]) {
|
|
2685
|
+
const entry = entries[key];
|
|
2686
|
+
if (!entry || typeof entry !== "object")
|
|
2687
|
+
continue;
|
|
2688
|
+
const entryRecord = entry;
|
|
2689
|
+
if (entryRecord.enabled === false)
|
|
2690
|
+
continue;
|
|
2691
|
+
entryRecord.enabled = false;
|
|
2692
|
+
disabledKeys.push(key);
|
|
2693
|
+
}
|
|
2694
|
+
return { modified: disabledKeys.length > 0, disabledKeys };
|
|
2695
|
+
}
|
|
2696
|
+
function enableOpenClawEntries(config, entryKeys) {
|
|
2697
|
+
const plugins = config.plugins;
|
|
2698
|
+
const entries = plugins?.entries;
|
|
2699
|
+
if (!entries) {
|
|
2700
|
+
return false;
|
|
2701
|
+
}
|
|
2702
|
+
let modified = false;
|
|
2703
|
+
for (const key of entryKeys) {
|
|
2704
|
+
const entry = entries[key];
|
|
2705
|
+
if (!entry || typeof entry !== "object")
|
|
2706
|
+
continue;
|
|
2707
|
+
const entryRecord = entry;
|
|
2708
|
+
if (entryRecord.enabled === true)
|
|
2709
|
+
continue;
|
|
2710
|
+
entryRecord.enabled = true;
|
|
2711
|
+
modified = true;
|
|
2712
|
+
}
|
|
2713
|
+
return modified;
|
|
2714
|
+
}
|
|
2715
|
+
function removePiPackageEntries(settings) {
|
|
2716
|
+
const packages = settings.packages;
|
|
2717
|
+
if (!Array.isArray(packages)) {
|
|
2718
|
+
return { modified: false, removedSpecs: [] };
|
|
2719
|
+
}
|
|
2720
|
+
const removedSpecs = [];
|
|
2721
|
+
const filtered = packages.filter((entry) => {
|
|
2722
|
+
if (typeof entry !== "string")
|
|
2723
|
+
return true;
|
|
2724
|
+
if (!entry.startsWith("npm:@agentapprove/pi"))
|
|
2725
|
+
return true;
|
|
2726
|
+
removedSpecs.push(entry);
|
|
2727
|
+
return false;
|
|
2728
|
+
});
|
|
2729
|
+
if (removedSpecs.length === 0) {
|
|
2730
|
+
return { modified: false, removedSpecs: [] };
|
|
2731
|
+
}
|
|
2732
|
+
settings.packages = filtered;
|
|
2733
|
+
return { modified: true, removedSpecs };
|
|
2734
|
+
}
|
|
2735
|
+
function addPiPackageEntries(settings, specs) {
|
|
2736
|
+
const packages = Array.isArray(settings.packages) ? settings.packages : [];
|
|
2737
|
+
let modified = false;
|
|
2738
|
+
for (const spec of specs) {
|
|
2739
|
+
if (!packages.includes(spec)) {
|
|
2740
|
+
packages.push(spec);
|
|
2741
|
+
modified = true;
|
|
2742
|
+
}
|
|
2743
|
+
}
|
|
2744
|
+
if (modified || !Array.isArray(settings.packages)) {
|
|
2745
|
+
settings.packages = packages;
|
|
2746
|
+
}
|
|
2747
|
+
return modified;
|
|
2748
|
+
}
|
|
2749
|
+
|
|
2519
2750
|
// src/pairing-artifact.ts
|
|
2520
2751
|
var PAIRING_ARTIFACT_PREFIX = "AAP1.";
|
|
2521
2752
|
function encodePairingArtifact(artifact) {
|
|
@@ -2839,7 +3070,7 @@ function resolvePairingApiBaseUrl(options) {
|
|
|
2839
3070
|
}
|
|
2840
3071
|
|
|
2841
3072
|
// src/cli.ts
|
|
2842
|
-
var VERSION = "0.1.
|
|
3073
|
+
var VERSION = "0.1.41";
|
|
2843
3074
|
function getApiUrl() {
|
|
2844
3075
|
return process.env.AGENTAPPROVE_API || "https://api.agentapprove.com";
|
|
2845
3076
|
}
|
|
@@ -2918,7 +3149,7 @@ var OPENCLAW_PLUGIN_SPEC = `@agentapprove/openclaw@${OPENCLAW_PLUGIN_VERSION}`;
|
|
|
2918
3149
|
var PI_PLUGIN_VERSION = "0.1.12";
|
|
2919
3150
|
var PI_PLUGIN_SPEC = `npm:@agentapprove/pi@${PI_PLUGIN_VERSION}`;
|
|
2920
3151
|
var PI_STATUS_TIMEOUT_MS = 5000;
|
|
2921
|
-
var HERMES_PLUGIN_VERSION = "0.1.
|
|
3152
|
+
var HERMES_PLUGIN_VERSION = "0.1.11";
|
|
2922
3153
|
var HERMES_PIP_DEPS = ["cryptography>=44.0,<46", "httpx>=0.27,<0.29"];
|
|
2923
3154
|
var AGENTS = {
|
|
2924
3155
|
"claude-code": {
|
|
@@ -4214,6 +4445,8 @@ AGENTAPPROVE_E2E_ENABLED=${e2eEnabled ? "true" : "false"}
|
|
|
4214
4445
|
# Hook behavior when API is unreachable: "allow" | "deny" | "ask"
|
|
4215
4446
|
AGENTAPPROVE_FAIL_BEHAVIOR=${config.failBehavior || "ask"}
|
|
4216
4447
|
|
|
4448
|
+
# Settings in this file sync from your Agent Approve account settings, so
|
|
4449
|
+
# manual edits here are overwritten on the next config sync.
|
|
4217
4450
|
# To change settings, run: npx agentapprove install
|
|
4218
4451
|
`;
|
|
4219
4452
|
writeFileSync(envPath, content, { mode: 384 });
|
|
@@ -5041,16 +5274,22 @@ async function copyHookScripts2(hooksDir, token, files, options = {}) {
|
|
|
5041
5274
|
});
|
|
5042
5275
|
}
|
|
5043
5276
|
function readOpenClawInstalledVersion() {
|
|
5044
|
-
const
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5277
|
+
const candidatePaths = [
|
|
5278
|
+
join(homedir(), ".openclaw", "npm", "node_modules", "@agentapprove", "openclaw", "package.json"),
|
|
5279
|
+
join(homedir(), ".openclaw", "extensions", "openclaw", "package.json")
|
|
5280
|
+
];
|
|
5281
|
+
for (const packagePath of candidatePaths) {
|
|
5282
|
+
if (!existsSync2(packagePath)) {
|
|
5283
|
+
continue;
|
|
5284
|
+
}
|
|
5285
|
+
try {
|
|
5286
|
+
const pkg = JSON.parse(readFileSync(packagePath, "utf-8"));
|
|
5287
|
+
if (typeof pkg.version === "string") {
|
|
5288
|
+
return pkg.version;
|
|
5289
|
+
}
|
|
5290
|
+
} catch {}
|
|
5053
5291
|
}
|
|
5292
|
+
return null;
|
|
5054
5293
|
}
|
|
5055
5294
|
function isOpenClawAlreadyExistsError(err) {
|
|
5056
5295
|
if (!err || typeof err !== "object")
|
|
@@ -5262,7 +5501,7 @@ function removePiPluginViaCli() {
|
|
|
5262
5501
|
};
|
|
5263
5502
|
}
|
|
5264
5503
|
}
|
|
5265
|
-
var HERMES_BUNDLE_SHA256 = "
|
|
5504
|
+
var HERMES_BUNDLE_SHA256 = "1b25d4119d3e54ee7fe809b42c1e189351a524c48b7097db683317fdec4ef585";
|
|
5266
5505
|
var HERMES_BUNDLE_FILENAME = `agentapprove-hermes-${HERMES_PLUGIN_VERSION}.tar.gz`;
|
|
5267
5506
|
var HERMES_PLUGIN_DIR = join(homedir(), ".hermes", "plugins", "agentapprove");
|
|
5268
5507
|
function findPython() {
|
|
@@ -6576,7 +6815,7 @@ Backups will be created with timestamp`, "Files to be modified");
|
|
|
6576
6815
|
npx agentapprove pair Link a new iOS device
|
|
6577
6816
|
npx agentapprove status Show current configuration
|
|
6578
6817
|
npx agentapprove profiles Manage Agent Approve across Hermes profiles
|
|
6579
|
-
npx agentapprove disable
|
|
6818
|
+
npx agentapprove disable Deregister hooks/plugins, keep local state
|
|
6580
6819
|
npx agentapprove uninstall Remove hooks/plugins and keep local state
|
|
6581
6820
|
npx agentapprove purge Remove hooks/plugins and delete local state
|
|
6582
6821
|
npx agentapprove restore Restore original configs`, "Useful commands");
|
|
@@ -6681,6 +6920,10 @@ async function statusCommand() {
|
|
|
6681
6920
|
console.log(source_default.cyan(`
|
|
6682
6921
|
Agent Approve Status
|
|
6683
6922
|
`));
|
|
6923
|
+
if (existsSync2(join(getAgentApproveDir(), DISABLED_STATE_FILENAME))) {
|
|
6924
|
+
console.log(source_default.yellow(" Disabled: hooks and plugins are deregistered from your agents."));
|
|
6925
|
+
console.log(source_default.dim(" Run `npx agentapprove enable` to restore them.\n"));
|
|
6926
|
+
}
|
|
6684
6927
|
const envPath = join(getAgentApproveDir(), "env");
|
|
6685
6928
|
if (!existsSync2(envPath)) {
|
|
6686
6929
|
console.log(source_default.yellow(" Not configured. Run `npx agentapprove` to set up.\n"));
|
|
@@ -6795,45 +7038,394 @@ async function statusCommand() {
|
|
|
6795
7038
|
}
|
|
6796
7039
|
console.log();
|
|
6797
7040
|
}
|
|
7041
|
+
function sleepMsSync(ms) {
|
|
7042
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
7043
|
+
}
|
|
7044
|
+
function acquireDisabledStateMergeLock(lockPath) {
|
|
7045
|
+
for (let attempt = 0;attempt < 40; attempt++) {
|
|
7046
|
+
try {
|
|
7047
|
+
mkdirSync(lockPath);
|
|
7048
|
+
return true;
|
|
7049
|
+
} catch {
|
|
7050
|
+
try {
|
|
7051
|
+
if (Date.now() - statSync(lockPath).mtimeMs > 1e4) {
|
|
7052
|
+
rmSync2(lockPath, { recursive: true, force: true });
|
|
7053
|
+
continue;
|
|
7054
|
+
}
|
|
7055
|
+
} catch {
|
|
7056
|
+
continue;
|
|
7057
|
+
}
|
|
7058
|
+
sleepMsSync(25);
|
|
7059
|
+
}
|
|
7060
|
+
}
|
|
7061
|
+
return false;
|
|
7062
|
+
}
|
|
6798
7063
|
async function disableCommand() {
|
|
6799
|
-
const
|
|
6800
|
-
const
|
|
6801
|
-
|
|
6802
|
-
|
|
6803
|
-
|
|
6804
|
-
|
|
7064
|
+
const aaDir = getAgentApproveDir();
|
|
7065
|
+
const statePath = join(aaDir, DISABLED_STATE_FILENAME);
|
|
7066
|
+
let hasExistingRecord = false;
|
|
7067
|
+
try {
|
|
7068
|
+
readFileSync(statePath);
|
|
7069
|
+
hasExistingRecord = true;
|
|
7070
|
+
} catch {
|
|
7071
|
+
hasExistingRecord = false;
|
|
7072
|
+
}
|
|
7073
|
+
if (hasExistingRecord) {
|
|
7074
|
+
console.log(source_default.yellow(`
|
|
7075
|
+
Already disabled.`));
|
|
7076
|
+
console.log(source_default.dim(" Run `npx agentapprove enable` to re-register hooks and plugins.\n"));
|
|
7077
|
+
return;
|
|
7078
|
+
}
|
|
7079
|
+
const existingConfig = readExistingConfig();
|
|
7080
|
+
const legacyDisabledEnv = existsSync2(join(aaDir, "env.disabled"));
|
|
7081
|
+
console.log(source_default.cyan(`
|
|
7082
|
+
Disabling Agent Approve...
|
|
6805
7083
|
`));
|
|
7084
|
+
const records = [];
|
|
7085
|
+
const warnings = [];
|
|
7086
|
+
for (const [agentId, agent] of Object.entries(AGENTS)) {
|
|
7087
|
+
try {
|
|
7088
|
+
disableAgent(agentId, agent, records, warnings);
|
|
7089
|
+
} catch (err) {
|
|
7090
|
+
warnings.push(`${agent.name}: could not update its configuration (${err instanceof Error ? err.message : String(err)})`);
|
|
7091
|
+
}
|
|
7092
|
+
}
|
|
7093
|
+
for (const warning of warnings) {
|
|
7094
|
+
console.log(` ${source_default.yellow("⚠")} ${warning}`);
|
|
7095
|
+
}
|
|
7096
|
+
if (records.length === 0) {
|
|
7097
|
+
if (warnings.length > 0) {
|
|
7098
|
+
console.log(source_default.yellow("\n Disable incomplete. Fix the warnings above and re-run `npx agentapprove disable`.\n"));
|
|
7099
|
+
} else if (!existingConfig && !legacyDisabledEnv) {
|
|
7100
|
+
console.log(source_default.yellow(" Not configured. Run `npx agentapprove` to set up.\n"));
|
|
6806
7101
|
} else {
|
|
6807
|
-
console.log(source_default.yellow("
|
|
7102
|
+
console.log(source_default.yellow(" No Agent Approve hooks or plugins are registered."));
|
|
7103
|
+
console.log(source_default.dim(" Nothing to disable. Run `npx agentapprove install` to set up agents.\n"));
|
|
6808
7104
|
}
|
|
6809
7105
|
return;
|
|
6810
7106
|
}
|
|
6811
|
-
const
|
|
6812
|
-
|
|
7107
|
+
const state = {
|
|
7108
|
+
version: 1,
|
|
7109
|
+
disabledAt: new Date().toISOString(),
|
|
7110
|
+
cliVersion: VERSION,
|
|
7111
|
+
mode: existingConfig?.e2eMode === "observe" ? "observe" : "approval",
|
|
7112
|
+
agents: records
|
|
7113
|
+
};
|
|
7114
|
+
try {
|
|
7115
|
+
writeFileSync(statePath, JSON.stringify(state, null, 2) + `
|
|
7116
|
+
`, { mode: 384, flag: "wx" });
|
|
7117
|
+
} catch (err) {
|
|
7118
|
+
let failed = true;
|
|
7119
|
+
if (err.code === "EEXIST") {
|
|
7120
|
+
const lockPath = `${statePath}.lock`;
|
|
7121
|
+
if (acquireDisabledStateMergeLock(lockPath)) {
|
|
7122
|
+
try {
|
|
7123
|
+
const existing = parseDisabledState(readFileSync(statePath, "utf-8"));
|
|
7124
|
+
const merged = existing ? mergeDisabledStates(existing, state) : state;
|
|
7125
|
+
const tmpPath = `${statePath}.tmp-${process.pid}`;
|
|
7126
|
+
writeFileSync(tmpPath, JSON.stringify(merged, null, 2) + `
|
|
7127
|
+
`, { mode: 384 });
|
|
7128
|
+
renameSync(tmpPath, statePath);
|
|
7129
|
+
failed = false;
|
|
7130
|
+
} catch {
|
|
7131
|
+
failed = true;
|
|
7132
|
+
} finally {
|
|
7133
|
+
try {
|
|
7134
|
+
rmSync2(lockPath, { recursive: true, force: true });
|
|
7135
|
+
} catch {}
|
|
7136
|
+
}
|
|
7137
|
+
}
|
|
7138
|
+
}
|
|
7139
|
+
if (failed) {
|
|
7140
|
+
console.log(source_default.red(`
|
|
7141
|
+
✗ Hooks and plugins were deregistered, but the restoration record could not be written:`));
|
|
7142
|
+
console.log(source_default.red(` ${err instanceof Error ? err.message : String(err)}`));
|
|
7143
|
+
console.log(source_default.yellow(" `npx agentapprove enable` will not be able to restore this disable."));
|
|
7144
|
+
console.log(source_default.yellow(" Run `npx agentapprove install` when you want to re-register hooks and plugins.\n"));
|
|
7145
|
+
return;
|
|
7146
|
+
}
|
|
7147
|
+
}
|
|
6813
7148
|
console.log(source_default.green(`
|
|
6814
7149
|
✓ Agent Approve disabled.`));
|
|
6815
|
-
console.log(source_default.dim(" Hooks
|
|
6816
|
-
console.log(source_default.dim("
|
|
7150
|
+
console.log(source_default.dim(" Hooks and plugins are deregistered from your agents, so Agent Approve no longer runs."));
|
|
7151
|
+
console.log(source_default.dim(" Local state (pairing, settings, E2E keys, hook scripts) is kept in ~/.agentapprove."));
|
|
7152
|
+
if (existsSync2(join(aaDir, "copilot-cli-hooks.json"))) {
|
|
7153
|
+
console.log(source_default.yellow(" Note: per-repo GitHub Copilot hooks (.github/hooks/agentapprove.json, added with `init-repo`)"));
|
|
7154
|
+
console.log(source_default.yellow(" cannot be reached from here and stay active until you remove them in each repo."));
|
|
7155
|
+
}
|
|
7156
|
+
if (warnings.length > 0) {
|
|
7157
|
+
console.log(source_default.yellow(" Some agents could not be fully disabled; see the warnings above."));
|
|
7158
|
+
}
|
|
7159
|
+
console.log(source_default.dim(" Run `npx agentapprove enable` to restore everything.\n"));
|
|
7160
|
+
}
|
|
7161
|
+
function disableAgent(agentId, agent, records, warnings) {
|
|
7162
|
+
if (agentId === "pi") {
|
|
7163
|
+
if (!existsSync2(agent.configPath))
|
|
7164
|
+
return;
|
|
7165
|
+
const settings = readJsonConfig(agent.configPath);
|
|
7166
|
+
const removal = removePiPackageEntries(settings);
|
|
7167
|
+
if (removal.modified) {
|
|
7168
|
+
writeJsonConfig(agent.configPath, settings);
|
|
7169
|
+
records.push({ agentId, kind: "pi_packages", specs: removal.removedSpecs });
|
|
7170
|
+
console.log(` ${source_default.green("✓")} ${agent.name}: extension deregistered`);
|
|
7171
|
+
}
|
|
7172
|
+
return;
|
|
7173
|
+
}
|
|
7174
|
+
if (agentId === "hermes") {
|
|
7175
|
+
const installedProfiles = listHermesProfiles().filter((pr) => pr.installed);
|
|
7176
|
+
const disabledProfiles = [];
|
|
7177
|
+
for (const pr of installedProfiles) {
|
|
7178
|
+
const label = pr.isDefault ? "default profile" : `profile "${pr.name}"`;
|
|
7179
|
+
const result = disableHermesPluginForProfile(pr.name);
|
|
7180
|
+
if (result.success && !result.alreadyDisabled) {
|
|
7181
|
+
disabledProfiles.push(pr.name);
|
|
7182
|
+
console.log(` ${source_default.green("✓")} ${agent.name}: plugin disabled in ${label}`);
|
|
7183
|
+
} else if (!result.success) {
|
|
7184
|
+
warnings.push(`${agent.name}: could not disable the plugin in ${label} (${result.error || "unknown error"}). ` + `Run manually: ${hermesDisableCmd(pr.name)}`);
|
|
7185
|
+
}
|
|
7186
|
+
}
|
|
7187
|
+
if (disabledProfiles.length > 0) {
|
|
7188
|
+
records.push({ agentId, kind: "hermes_profiles", profiles: disabledProfiles });
|
|
7189
|
+
}
|
|
7190
|
+
return;
|
|
7191
|
+
}
|
|
7192
|
+
if (isAntigravityAgent(agentId)) {
|
|
7193
|
+
const pluginRoot = getAntigravityPluginRoot(agentId);
|
|
7194
|
+
if (!existsSync2(pluginRoot))
|
|
7195
|
+
return;
|
|
7196
|
+
try {
|
|
7197
|
+
rmSync2(pluginRoot, { recursive: true, force: true });
|
|
7198
|
+
records.push({ agentId, kind: "hooks" });
|
|
7199
|
+
console.log(` ${source_default.green("✓")} ${agent.name}: plugin deregistered`);
|
|
7200
|
+
} catch (err) {
|
|
7201
|
+
warnings.push(`${agent.name}: could not remove the plugin at ${pluginRoot} (${err instanceof Error ? err.message : String(err)})`);
|
|
7202
|
+
}
|
|
7203
|
+
return;
|
|
7204
|
+
}
|
|
7205
|
+
if (agentId === "vscode-agent") {
|
|
7206
|
+
const removedVSCode = removeFromVSCodeHookLocations();
|
|
7207
|
+
if (removedVSCode.length > 0) {
|
|
7208
|
+
records.push({ agentId, kind: "vscode_hook_location" });
|
|
7209
|
+
for (const path of removedVSCode) {
|
|
7210
|
+
console.log(` ${source_default.green("✓")} ${agent.name}: hook path removed from ${path}`);
|
|
7211
|
+
}
|
|
7212
|
+
}
|
|
7213
|
+
return;
|
|
7214
|
+
}
|
|
7215
|
+
if (agentId === "copilot-cli") {
|
|
7216
|
+
return;
|
|
7217
|
+
}
|
|
7218
|
+
if (!existsSync2(agent.configPath))
|
|
7219
|
+
return;
|
|
7220
|
+
const config = readJsonConfig(agent.configPath);
|
|
7221
|
+
if (agentId === "openclaw") {
|
|
7222
|
+
const flip = disableOpenClawEntries(config);
|
|
7223
|
+
if (flip.modified) {
|
|
7224
|
+
writeJsonConfig(agent.configPath, config);
|
|
7225
|
+
records.push({ agentId, kind: "openclaw_entries", entryKeys: flip.disabledKeys });
|
|
7226
|
+
console.log(` ${source_default.green("✓")} ${agent.name}: plugin disabled (kept installed)`);
|
|
7227
|
+
}
|
|
7228
|
+
return;
|
|
7229
|
+
}
|
|
7230
|
+
if (agentId === "opencode") {
|
|
7231
|
+
const removal = removeOpenCodePluginEntries(config);
|
|
7232
|
+
if (removal.modified) {
|
|
7233
|
+
writeJsonConfig(agent.configPath, config);
|
|
7234
|
+
}
|
|
7235
|
+
const removedLegacyDep = removeOpenCodeLegacyDependency();
|
|
7236
|
+
if (removal.modified || removedLegacyDep !== null) {
|
|
7237
|
+
records.push({
|
|
7238
|
+
agentId,
|
|
7239
|
+
kind: "opencode_plugin",
|
|
7240
|
+
specs: removal.removedSpecs,
|
|
7241
|
+
...removedLegacyDep !== null ? { legacyDependency: removedLegacyDep } : {}
|
|
7242
|
+
});
|
|
7243
|
+
console.log(` ${source_default.green("✓")} ${agent.name}: plugin deregistered`);
|
|
7244
|
+
}
|
|
7245
|
+
return;
|
|
7246
|
+
}
|
|
7247
|
+
const useTopLevelHooks = agent.hooksKey === "";
|
|
7248
|
+
const hooksConfig = useTopLevelHooks ? config : config[agent.hooksKey] ?? {};
|
|
7249
|
+
const modified = removeAgentApproveHookEntries(hooksConfig, agent.hooks.map((hook) => hook.name));
|
|
7250
|
+
if (modified) {
|
|
7251
|
+
writeJsonConfig(agent.configPath, config);
|
|
7252
|
+
records.push({ agentId, kind: "hooks" });
|
|
7253
|
+
console.log(` ${source_default.green("✓")} ${agent.name}: hooks deregistered`);
|
|
7254
|
+
if (agentId === "codex" && Object.keys(hooksConfig).length === 0) {
|
|
7255
|
+
const codexFlag = disableCodexFeatureFlag();
|
|
7256
|
+
if (codexFlag.updated) {
|
|
7257
|
+
console.log(` ${source_default.green("✓")} Disabled codex_hooks in ~/.codex/config.toml`);
|
|
7258
|
+
}
|
|
7259
|
+
}
|
|
7260
|
+
}
|
|
6817
7261
|
}
|
|
6818
7262
|
async function enableCommand() {
|
|
6819
|
-
const
|
|
6820
|
-
const
|
|
6821
|
-
|
|
6822
|
-
|
|
7263
|
+
const aaDir = getAgentApproveDir();
|
|
7264
|
+
const envPath = join(aaDir, "env");
|
|
7265
|
+
const legacyDisabledPath = join(aaDir, "env.disabled");
|
|
7266
|
+
const statePath = join(aaDir, DISABLED_STATE_FILENAME);
|
|
7267
|
+
if (!existsSync2(envPath) && existsSync2(legacyDisabledPath)) {
|
|
7268
|
+
renameSync(legacyDisabledPath, envPath);
|
|
7269
|
+
console.log(source_default.green(`
|
|
7270
|
+
✓ Restored ~/.agentapprove/env (legacy disable).`));
|
|
7271
|
+
}
|
|
7272
|
+
let stateRaw = null;
|
|
7273
|
+
try {
|
|
7274
|
+
stateRaw = readFileSync(statePath, "utf-8");
|
|
7275
|
+
} catch {
|
|
7276
|
+
stateRaw = null;
|
|
7277
|
+
}
|
|
7278
|
+
if (stateRaw === null) {
|
|
7279
|
+
if (existsSync2(envPath)) {
|
|
7280
|
+
console.log(source_default.yellow(`
|
|
6823
7281
|
Already enabled.
|
|
6824
7282
|
`));
|
|
7283
|
+
} else {
|
|
7284
|
+
console.log(source_default.yellow("\n Not configured. Run `npx agentapprove` to set up.\n"));
|
|
7285
|
+
}
|
|
6825
7286
|
return;
|
|
6826
7287
|
}
|
|
6827
|
-
|
|
6828
|
-
|
|
7288
|
+
const state = parseDisabledState(stateRaw);
|
|
7289
|
+
if (!state) {
|
|
7290
|
+
rmSync2(statePath, { force: true });
|
|
7291
|
+
console.log(source_default.yellow(`
|
|
7292
|
+
The disable record was unreadable, so registrations were not restored automatically.`));
|
|
7293
|
+
console.log(source_default.dim(" Run `npx agentapprove install` to re-register hooks and plugins (your pairing is kept).\n"));
|
|
6829
7294
|
return;
|
|
6830
7295
|
}
|
|
6831
|
-
|
|
6832
|
-
|
|
7296
|
+
console.log(source_default.cyan(`
|
|
7297
|
+
Re-enabling Agent Approve...
|
|
7298
|
+
`));
|
|
7299
|
+
const hooksDir = join(aaDir, "hooks");
|
|
7300
|
+
const failures = [];
|
|
7301
|
+
for (const record of state.agents) {
|
|
7302
|
+
const agent = AGENTS[record.agentId];
|
|
7303
|
+
if (!agent) {
|
|
7304
|
+
failures.push(record);
|
|
7305
|
+
console.log(` ${source_default.yellow("⚠")} ${record.agentId}: this installer build does not know this agent. ` + "Re-run with the latest installer: npx agentapprove@latest enable");
|
|
7306
|
+
continue;
|
|
7307
|
+
}
|
|
7308
|
+
switch (record.kind) {
|
|
7309
|
+
case "hooks": {
|
|
7310
|
+
if (!existsSync2(hooksDir)) {
|
|
7311
|
+
failures.push(record);
|
|
7312
|
+
console.log(` ${source_default.yellow("⚠")} ${agent.name}: ~/.agentapprove/hooks is missing. Run \`npx agentapprove install\` to re-download hook scripts.`);
|
|
7313
|
+
break;
|
|
7314
|
+
}
|
|
7315
|
+
const result = await installHooksForAgent(record.agentId, hooksDir, state.mode);
|
|
7316
|
+
if (result.success) {
|
|
7317
|
+
console.log(` ${source_default.green("✓")} ${agent.name}: hooks re-registered`);
|
|
7318
|
+
} else {
|
|
7319
|
+
failures.push(record);
|
|
7320
|
+
console.log(` ${source_default.yellow("⚠")} ${agent.name}: could not re-register hooks (${result.error || "unknown error"})`);
|
|
7321
|
+
}
|
|
7322
|
+
break;
|
|
7323
|
+
}
|
|
7324
|
+
case "vscode_hook_location": {
|
|
7325
|
+
const modifiedPaths = addToVSCodeHookLocations();
|
|
7326
|
+
if (modifiedPaths.length > 0) {
|
|
7327
|
+
console.log(` ${source_default.green("✓")} ${agent.name}: hook path re-registered in ${modifiedPaths.join(", ")}`);
|
|
7328
|
+
} else {
|
|
7329
|
+
console.log(` ${source_default.green("✓")} ${agent.name}: hook path already registered`);
|
|
7330
|
+
}
|
|
7331
|
+
break;
|
|
7332
|
+
}
|
|
7333
|
+
case "openclaw_entries": {
|
|
7334
|
+
if (!existsSync2(agent.configPath)) {
|
|
7335
|
+
console.log(` ${source_default.yellow("⚠")} ${agent.name}: config not found; skipping`);
|
|
7336
|
+
break;
|
|
7337
|
+
}
|
|
7338
|
+
const config = readJsonConfig(agent.configPath);
|
|
7339
|
+
if (enableOpenClawEntries(config, record.entryKeys ?? [])) {
|
|
7340
|
+
writeJsonConfig(agent.configPath, config);
|
|
7341
|
+
}
|
|
7342
|
+
console.log(` ${source_default.green("✓")} ${agent.name}: plugin re-enabled`);
|
|
7343
|
+
break;
|
|
7344
|
+
}
|
|
7345
|
+
case "opencode_plugin": {
|
|
7346
|
+
const config = readJsonConfig(agent.configPath);
|
|
7347
|
+
if (addOpenCodePluginEntries(config, record.specs ?? [])) {
|
|
7348
|
+
writeJsonConfig(agent.configPath, config);
|
|
7349
|
+
}
|
|
7350
|
+
if (record.legacyDependency) {
|
|
7351
|
+
restoreOpenCodeLegacyDependency(record.legacyDependency);
|
|
7352
|
+
}
|
|
7353
|
+
console.log(` ${source_default.green("✓")} ${agent.name}: plugin re-registered`);
|
|
7354
|
+
break;
|
|
7355
|
+
}
|
|
7356
|
+
case "pi_packages": {
|
|
7357
|
+
const settings = readJsonConfig(agent.configPath);
|
|
7358
|
+
if (addPiPackageEntries(settings, record.specs ?? [])) {
|
|
7359
|
+
writeJsonConfig(agent.configPath, settings);
|
|
7360
|
+
}
|
|
7361
|
+
console.log(` ${source_default.green("✓")} ${agent.name}: extension re-registered`);
|
|
7362
|
+
break;
|
|
7363
|
+
}
|
|
7364
|
+
case "hermes_profiles": {
|
|
7365
|
+
const failedProfiles = [];
|
|
7366
|
+
for (const profile of record.profiles ?? []) {
|
|
7367
|
+
const label = profile === HERMES_DEFAULT_PROFILE ? "default profile" : `profile "${profile}"`;
|
|
7368
|
+
const result = enableHermesPluginForProfile(profile);
|
|
7369
|
+
if (result.success) {
|
|
7370
|
+
console.log(` ${source_default.green("✓")} ${agent.name}: plugin re-enabled in ${label}`);
|
|
7371
|
+
} else {
|
|
7372
|
+
failedProfiles.push(profile);
|
|
7373
|
+
console.log(` ${source_default.yellow("⚠")} ${agent.name}: could not re-enable the plugin in ${label} ` + `(${result.error || "unknown error"}). Run manually: ${hermesEnableCmd(profile)}`);
|
|
7374
|
+
}
|
|
7375
|
+
}
|
|
7376
|
+
if (failedProfiles.length > 0) {
|
|
7377
|
+
failures.push({ ...record, profiles: failedProfiles });
|
|
7378
|
+
}
|
|
7379
|
+
break;
|
|
7380
|
+
}
|
|
7381
|
+
default: {
|
|
7382
|
+
failures.push(record);
|
|
7383
|
+
console.log(` ${source_default.yellow("⚠")} ${agent.name}: this installer build does not know how to restore this registration (kind "${record.kind}"). ` + "Re-run with the latest installer: npx agentapprove@latest enable");
|
|
7384
|
+
break;
|
|
7385
|
+
}
|
|
7386
|
+
}
|
|
7387
|
+
}
|
|
7388
|
+
if (failures.length > 0) {
|
|
7389
|
+
const remaining = { ...state, agents: failures };
|
|
7390
|
+
writeFileSync(statePath, JSON.stringify(remaining, null, 2) + `
|
|
7391
|
+
`, { mode: 384 });
|
|
7392
|
+
console.log(source_default.yellow("\n Agent Approve is partially re-enabled. Fix the warnings above and re-run `npx agentapprove enable`.\n"));
|
|
7393
|
+
return;
|
|
7394
|
+
}
|
|
7395
|
+
rmSync2(statePath, { force: true });
|
|
6833
7396
|
console.log(source_default.green(`
|
|
6834
7397
|
✓ Agent Approve enabled.
|
|
6835
7398
|
`));
|
|
6836
7399
|
}
|
|
7400
|
+
function removeOpenCodeLegacyDependency() {
|
|
7401
|
+
const opencodePkgPath = join(getOpenCodeConfigDir(), "package.json");
|
|
7402
|
+
try {
|
|
7403
|
+
const pkgJson = JSON.parse(readFileSync(opencodePkgPath, "utf-8"));
|
|
7404
|
+
const deps = pkgJson.dependencies;
|
|
7405
|
+
const version = deps?.["@agentapprove/opencode"];
|
|
7406
|
+
if (deps && version) {
|
|
7407
|
+
delete deps["@agentapprove/opencode"];
|
|
7408
|
+
writeFileSync(opencodePkgPath, JSON.stringify(pkgJson, null, 2) + `
|
|
7409
|
+
`);
|
|
7410
|
+
return version;
|
|
7411
|
+
}
|
|
7412
|
+
} catch {}
|
|
7413
|
+
return null;
|
|
7414
|
+
}
|
|
7415
|
+
function restoreOpenCodeLegacyDependency(version) {
|
|
7416
|
+
const opencodePkgPath = join(getOpenCodeConfigDir(), "package.json");
|
|
7417
|
+
let pkgJson = {};
|
|
7418
|
+
try {
|
|
7419
|
+
pkgJson = JSON.parse(readFileSync(opencodePkgPath, "utf-8"));
|
|
7420
|
+
} catch {
|
|
7421
|
+
pkgJson = {};
|
|
7422
|
+
}
|
|
7423
|
+
const deps = pkgJson.dependencies ?? {};
|
|
7424
|
+
deps["@agentapprove/opencode"] = version;
|
|
7425
|
+
pkgJson.dependencies = deps;
|
|
7426
|
+
writeFileSync(opencodePkgPath, JSON.stringify(pkgJson, null, 2) + `
|
|
7427
|
+
`);
|
|
7428
|
+
}
|
|
6837
7429
|
async function performUninstall(mode) {
|
|
6838
7430
|
const plan = buildUninstallPlan();
|
|
6839
7431
|
if (!hasUninstallWork(mode, plan)) {
|
|
@@ -6876,71 +7468,13 @@ async function performUninstall(mode) {
|
|
|
6876
7468
|
const hooksConfig = agent.hooksKey === "" ? config : config[agent.hooksKey] ?? {};
|
|
6877
7469
|
let modified = false;
|
|
6878
7470
|
if (agentId === "opencode") {
|
|
6879
|
-
const
|
|
6880
|
-
|
|
6881
|
-
|
|
6882
|
-
if (typeof p !== "string")
|
|
6883
|
-
return true;
|
|
6884
|
-
return !p.includes("agentapprove");
|
|
6885
|
-
});
|
|
6886
|
-
if (filtered.length !== pluginArray.length) {
|
|
6887
|
-
config.plugin = filtered;
|
|
6888
|
-
modified = true;
|
|
6889
|
-
}
|
|
6890
|
-
}
|
|
6891
|
-
const opencodePkgPath = join(getOpenCodeConfigDir(), "package.json");
|
|
6892
|
-
try {
|
|
6893
|
-
if (existsSync2(opencodePkgPath)) {
|
|
6894
|
-
const pkgJson = JSON.parse(readFileSync(opencodePkgPath, "utf-8"));
|
|
6895
|
-
const deps = pkgJson.dependencies;
|
|
6896
|
-
if (deps && deps["@agentapprove/opencode"]) {
|
|
6897
|
-
delete deps["@agentapprove/opencode"];
|
|
6898
|
-
writeFileSync(opencodePkgPath, JSON.stringify(pkgJson, null, 2) + `
|
|
6899
|
-
`);
|
|
6900
|
-
}
|
|
6901
|
-
}
|
|
6902
|
-
} catch {}
|
|
7471
|
+
const removal = removeOpenCodePluginEntries(config);
|
|
7472
|
+
modified = removal.modified;
|
|
7473
|
+
removeOpenCodeLegacyDependency();
|
|
6903
7474
|
} else if (agentId === "openclaw") {
|
|
6904
|
-
|
|
6905
|
-
const entries = pluginsConfig.entries;
|
|
6906
|
-
const installs = pluginsConfig.installs;
|
|
6907
|
-
for (const key of ["openclaw", "agentapprove"]) {
|
|
6908
|
-
if (entries && entries[key]) {
|
|
6909
|
-
delete entries[key];
|
|
6910
|
-
modified = true;
|
|
6911
|
-
}
|
|
6912
|
-
if (installs && installs[key]) {
|
|
6913
|
-
delete installs[key];
|
|
6914
|
-
modified = true;
|
|
6915
|
-
}
|
|
6916
|
-
}
|
|
7475
|
+
modified = removeOpenClawEntries(hooksConfig);
|
|
6917
7476
|
} else {
|
|
6918
|
-
|
|
6919
|
-
const hookEntry = hooksConfig[hook.name];
|
|
6920
|
-
if (!hookEntry)
|
|
6921
|
-
continue;
|
|
6922
|
-
if (Array.isArray(hookEntry)) {
|
|
6923
|
-
const filtered = hookEntry.filter((e2) => {
|
|
6924
|
-
const str = JSON.stringify(e2);
|
|
6925
|
-
return !str.includes("agentapprove");
|
|
6926
|
-
});
|
|
6927
|
-
if (filtered.length !== hookEntry.length) {
|
|
6928
|
-
if (filtered.length === 0) {
|
|
6929
|
-
delete hooksConfig[hook.name];
|
|
6930
|
-
} else {
|
|
6931
|
-
hooksConfig[hook.name] = filtered;
|
|
6932
|
-
}
|
|
6933
|
-
modified = true;
|
|
6934
|
-
}
|
|
6935
|
-
} else if (typeof hookEntry === "string" && hookEntry.includes("agentapprove")) {
|
|
6936
|
-
delete hooksConfig[hook.name];
|
|
6937
|
-
modified = true;
|
|
6938
|
-
}
|
|
6939
|
-
}
|
|
6940
|
-
if (hooksConfig.Prompt) {
|
|
6941
|
-
delete hooksConfig.Prompt;
|
|
6942
|
-
modified = true;
|
|
6943
|
-
}
|
|
7477
|
+
modified = removeAgentApproveHookEntries(hooksConfig, agent.hooks.map((hook) => hook.name));
|
|
6944
7478
|
}
|
|
6945
7479
|
if (modified) {
|
|
6946
7480
|
writeJsonConfig(agent.configPath, config);
|
|
@@ -6972,6 +7506,11 @@ async function performUninstall(mode) {
|
|
|
6972
7506
|
pruneEmptyDir(dirname2(target.actualPath));
|
|
6973
7507
|
}
|
|
6974
7508
|
}
|
|
7509
|
+
const disabledStatePath = join(getAgentApproveDir(), DISABLED_STATE_FILENAME);
|
|
7510
|
+
if (existsSync2(disabledStatePath)) {
|
|
7511
|
+
rmSync2(disabledStatePath, { force: true });
|
|
7512
|
+
console.log(` ${source_default.green("✓")} Removed the disable restore record (superseded by ${mode})`);
|
|
7513
|
+
}
|
|
6975
7514
|
if (mode === "purge") {
|
|
6976
7515
|
for (const target of plan.backupTargets) {
|
|
6977
7516
|
if (removeRemovalTarget(target)) {
|
|
@@ -7030,6 +7569,11 @@ async function restoreCommand() {
|
|
|
7030
7569
|
}
|
|
7031
7570
|
async function initRepoCommand() {
|
|
7032
7571
|
const cliHooksPath = join(getAgentApproveDir(), "copilot-cli-hooks.json");
|
|
7572
|
+
if (existsSync2(join(getAgentApproveDir(), DISABLED_STATE_FILENAME))) {
|
|
7573
|
+
console.log(source_default.yellow(`
|
|
7574
|
+
Agent Approve is currently disabled. Hooks copied into this repo will be active.`));
|
|
7575
|
+
console.log(source_default.dim(" Run `npx agentapprove enable` first if that is not what you want."));
|
|
7576
|
+
}
|
|
7033
7577
|
if (!existsSync2(cliHooksPath)) {
|
|
7034
7578
|
console.log(source_default.yellow(`
|
|
7035
7579
|
GitHub Copilot CLI hooks not found. Run the installer first with GitHub Copilot CLI selected.`));
|
|
@@ -7093,8 +7637,8 @@ ${source_default.yellow("Commands:")}
|
|
|
7093
7637
|
${source_default.green("init-repo")} Add GitHub Copilot CLI hooks to current repo (.github/hooks/)
|
|
7094
7638
|
${source_default.green("status")} Show current configuration and installed hooks
|
|
7095
7639
|
${source_default.green("profiles")} Install/remove Agent Approve across Hermes profiles
|
|
7096
|
-
${source_default.green("disable")}
|
|
7097
|
-
${source_default.green("enable")} Re-
|
|
7640
|
+
${source_default.green("disable")} Deregister hooks/plugins from all agents, keep local state
|
|
7641
|
+
${source_default.green("enable")} Re-register hooks/plugins removed by disable
|
|
7098
7642
|
${source_default.green("uninstall")} ${INSTALLER_COMMAND_DESCRIPTIONS.uninstall}
|
|
7099
7643
|
${source_default.green("purge")} ${INSTALLER_COMMAND_DESCRIPTIONS.purge}
|
|
7100
7644
|
${source_default.green("restore")} Restore original configs from backups
|