agentapprove 0.1.25 → 0.1.27
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 +16 -0
- package/dist/cli.js +261 -102
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,6 +33,7 @@ agentapprove
|
|
|
33
33
|
```bash
|
|
34
34
|
agentapprove # Install wizard (default)
|
|
35
35
|
agentapprove status # Show configuration
|
|
36
|
+
agentapprove profiles # Install/remove across Hermes profiles
|
|
36
37
|
agentapprove pair # Pair with a new iOS device
|
|
37
38
|
agentapprove refresh # Refresh token and hooks
|
|
38
39
|
agentapprove disable # Temporarily disable hooks
|
|
@@ -42,6 +43,21 @@ agentapprove restore # Restore from backup
|
|
|
42
43
|
agentapprove help # Show help
|
|
43
44
|
```
|
|
44
45
|
|
|
46
|
+
### Hermes profiles
|
|
47
|
+
|
|
48
|
+
Hermes profiles are isolated instances — each has its own plugins and config —
|
|
49
|
+
so Agent Approve must be installed into each profile you want governed. Run:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
agentapprove profiles
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
to see every profile and its current Agent Approve status, then check the
|
|
56
|
+
profiles it should govern (your current set is pre-selected). The command
|
|
57
|
+
installs into newly-checked profiles and removes it from unchecked ones.
|
|
58
|
+
Run it again any time you add a profile. `agentapprove uninstall` removes the
|
|
59
|
+
plugin from **all** profiles.
|
|
60
|
+
|
|
45
61
|
### Options
|
|
46
62
|
|
|
47
63
|
```bash
|
package/dist/cli.js
CHANGED
|
@@ -2765,6 +2765,10 @@ async function copyHookScripts(hooksDir, token, files, options) {
|
|
|
2765
2765
|
let downloaded = 0;
|
|
2766
2766
|
const failed = [];
|
|
2767
2767
|
for (const file of files) {
|
|
2768
|
+
if (!/^[a-z0-9._-]+\.(sh|js|json)$/i.test(file) || file.includes("..")) {
|
|
2769
|
+
failed.push(`${file} (invalid filename)`);
|
|
2770
|
+
continue;
|
|
2771
|
+
}
|
|
2768
2772
|
try {
|
|
2769
2773
|
const response = await fetchImpl(`${options.apiUrl}/${options.apiVersion}/hooks/${file}?format=raw`, {
|
|
2770
2774
|
headers: {
|
|
@@ -2827,7 +2831,7 @@ function resolvePairingApiBaseUrl(options) {
|
|
|
2827
2831
|
}
|
|
2828
2832
|
|
|
2829
2833
|
// src/cli.ts
|
|
2830
|
-
var VERSION = "0.1.
|
|
2834
|
+
var VERSION = "0.1.27";
|
|
2831
2835
|
function getApiUrl() {
|
|
2832
2836
|
return process.env.AGENTAPPROVE_API || "https://api.agentapprove.com";
|
|
2833
2837
|
}
|
|
@@ -2906,7 +2910,7 @@ var OPENCLAW_PLUGIN_SPEC = `@agentapprove/openclaw@${OPENCLAW_PLUGIN_VERSION}`;
|
|
|
2906
2910
|
var PI_PLUGIN_VERSION = "0.1.7";
|
|
2907
2911
|
var PI_PLUGIN_SPEC = `npm:@agentapprove/pi@${PI_PLUGIN_VERSION}`;
|
|
2908
2912
|
var PI_STATUS_TIMEOUT_MS = 5000;
|
|
2909
|
-
var HERMES_PLUGIN_VERSION = "0.1.
|
|
2913
|
+
var HERMES_PLUGIN_VERSION = "0.1.4";
|
|
2910
2914
|
var HERMES_PIP_DEPS = ["cryptography>=44.0,<46", "httpx>=0.27,<0.29"];
|
|
2911
2915
|
var AGENTS = {
|
|
2912
2916
|
"claude-code": {
|
|
@@ -5032,7 +5036,7 @@ function removePiPluginViaCli() {
|
|
|
5032
5036
|
};
|
|
5033
5037
|
}
|
|
5034
5038
|
}
|
|
5035
|
-
var HERMES_BUNDLE_SHA256 = "
|
|
5039
|
+
var HERMES_BUNDLE_SHA256 = "e315544be0a01b21c1557f4a9dd17f35e4165bd4608da42007566be1560f355d";
|
|
5036
5040
|
var HERMES_BUNDLE_FILENAME = `agentapprove-hermes-${HERMES_PLUGIN_VERSION}.tar.gz`;
|
|
5037
5041
|
var HERMES_PLUGIN_DIR = join(homedir(), ".hermes", "plugins", "agentapprove");
|
|
5038
5042
|
function findPython() {
|
|
@@ -5235,105 +5239,62 @@ function installHermesDepsAdaptive(pythonCommand, deps) {
|
|
|
5235
5239
|
}
|
|
5236
5240
|
}
|
|
5237
5241
|
}
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
}
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
error: "Python 3.10+ not found on PATH. Install Python 3.10 or newer (e.g. `brew install python@3.12`) and re-run npx agentapprove."
|
|
5254
|
-
};
|
|
5255
|
-
}
|
|
5256
|
-
const cfg = readInstallerConfig();
|
|
5257
|
-
if (!cfg.token) {
|
|
5258
|
-
return {
|
|
5259
|
-
success: false,
|
|
5260
|
-
label: "Agent Approve plugin",
|
|
5261
|
-
error: "Missing API token. Pair your phone first by running `npx agentapprove` and completing the QR scan."
|
|
5262
|
-
};
|
|
5263
|
-
}
|
|
5264
|
-
const download = await downloadHermesBundle(cfg.apiUrl, cfg.apiVersion, cfg.token);
|
|
5265
|
-
if (!download.ok) {
|
|
5266
|
-
return { success: false, label: "Agent Approve plugin", error: download.error };
|
|
5267
|
-
}
|
|
5268
|
-
const actualHash = verifyBundleHash(download.bytes);
|
|
5269
|
-
if (actualHash !== HERMES_BUNDLE_SHA256) {
|
|
5270
|
-
return {
|
|
5271
|
-
success: false,
|
|
5272
|
-
label: "Agent Approve plugin",
|
|
5273
|
-
error: `Bundle integrity check failed: expected ${HERMES_BUNDLE_SHA256.slice(0, 16)}…, got ${actualHash.slice(0, 16)}…. Refusing to install.`
|
|
5274
|
-
};
|
|
5275
|
-
}
|
|
5242
|
+
var HERMES_DEFAULT_PROFILE = "default";
|
|
5243
|
+
var HERMES_PROFILE_ID_RE = /^[a-z0-9][a-z0-9_-]{0,63}$/;
|
|
5244
|
+
function isValidHermesProfileName(name) {
|
|
5245
|
+
return name === HERMES_DEFAULT_PROFILE || HERMES_PROFILE_ID_RE.test(name);
|
|
5246
|
+
}
|
|
5247
|
+
function hermesProfilePluginDir(profile) {
|
|
5248
|
+
return profile === HERMES_DEFAULT_PROFILE ? HERMES_PLUGIN_DIR : join(homedir(), ".hermes", "profiles", profile, "plugins", "agentapprove");
|
|
5249
|
+
}
|
|
5250
|
+
function hermesEnableCmd(profile) {
|
|
5251
|
+
return profile === HERMES_DEFAULT_PROFILE ? "hermes plugins enable agentapprove" : `hermes -p ${profile} plugins enable agentapprove`;
|
|
5252
|
+
}
|
|
5253
|
+
function hermesDisableCmd(profile) {
|
|
5254
|
+
return profile === HERMES_DEFAULT_PROFILE ? "hermes plugins disable agentapprove" : `hermes -p ${profile} plugins disable agentapprove`;
|
|
5255
|
+
}
|
|
5256
|
+
function stageHermesBundle(bytes, targetDir) {
|
|
5276
5257
|
let tmpDir;
|
|
5277
5258
|
try {
|
|
5278
5259
|
tmpDir = mkdtempSync(join(tmpdir(), "aa-hermes-"));
|
|
5279
5260
|
} catch (err) {
|
|
5280
|
-
return {
|
|
5281
|
-
success: false,
|
|
5282
|
-
label: "Agent Approve plugin",
|
|
5283
|
-
error: `Could not create temp directory for bundle staging: ${err instanceof Error ? err.message : String(err)}`
|
|
5284
|
-
};
|
|
5261
|
+
return { success: false, error: `Could not create temp directory for bundle staging: ${err instanceof Error ? err.message : String(err)}` };
|
|
5285
5262
|
}
|
|
5286
5263
|
const tarballPath = join(tmpDir, HERMES_BUNDLE_FILENAME);
|
|
5287
5264
|
let backupPath = null;
|
|
5288
5265
|
try {
|
|
5289
|
-
writeFileSync(tarballPath,
|
|
5266
|
+
writeFileSync(tarballPath, bytes);
|
|
5290
5267
|
try {
|
|
5291
5268
|
execSync(`tar -xzf "${tarballPath}" -C "${tmpDir}" --no-same-owner --no-same-permissions`, { stdio: "pipe" });
|
|
5292
5269
|
} catch (err) {
|
|
5293
|
-
return {
|
|
5294
|
-
success: false,
|
|
5295
|
-
label: "Agent Approve plugin",
|
|
5296
|
-
error: `tar extract failed: ${err instanceof Error ? err.message : String(err)}`
|
|
5297
|
-
};
|
|
5270
|
+
return { success: false, error: `tar extract failed: ${err instanceof Error ? err.message : String(err)}` };
|
|
5298
5271
|
}
|
|
5299
5272
|
const stagedDir = join(tmpDir, "agentapprove");
|
|
5300
5273
|
if (!existsSync2(stagedDir)) {
|
|
5301
|
-
return {
|
|
5302
|
-
success: false,
|
|
5303
|
-
label: "Agent Approve plugin",
|
|
5304
|
-
error: "Bundle did not contain expected `agentapprove/` directory."
|
|
5305
|
-
};
|
|
5274
|
+
return { success: false, error: "Bundle did not contain expected `agentapprove/` directory." };
|
|
5306
5275
|
}
|
|
5307
5276
|
const validation = validateExtractedTree(stagedDir);
|
|
5308
5277
|
if (!validation.ok) {
|
|
5309
|
-
return {
|
|
5310
|
-
success: false,
|
|
5311
|
-
label: "Agent Approve plugin",
|
|
5312
|
-
error: `Bundle integrity violation: ${validation.error}`
|
|
5313
|
-
};
|
|
5278
|
+
return { success: false, error: `Bundle integrity violation: ${validation.error}` };
|
|
5314
5279
|
}
|
|
5315
|
-
mkdirSync(dirname2(
|
|
5316
|
-
if (existsSync2(
|
|
5317
|
-
backupPath = `${
|
|
5318
|
-
renameSync(
|
|
5280
|
+
mkdirSync(dirname2(targetDir), { recursive: true });
|
|
5281
|
+
if (existsSync2(targetDir)) {
|
|
5282
|
+
backupPath = `${targetDir}.bak-${Date.now()}`;
|
|
5283
|
+
renameSync(targetDir, backupPath);
|
|
5319
5284
|
}
|
|
5320
5285
|
try {
|
|
5321
|
-
renameSync(stagedDir,
|
|
5286
|
+
renameSync(stagedDir, targetDir);
|
|
5322
5287
|
} catch (err) {
|
|
5323
5288
|
if (backupPath) {
|
|
5324
5289
|
try {
|
|
5325
|
-
renameSync(backupPath,
|
|
5290
|
+
renameSync(backupPath, targetDir);
|
|
5326
5291
|
backupPath = null;
|
|
5327
5292
|
} catch {}
|
|
5328
5293
|
}
|
|
5329
|
-
const restoreNote = backupPath ? ` Your previous install was preserved at ${backupPath} — recover with: mv "${backupPath}" "${
|
|
5330
|
-
return {
|
|
5331
|
-
success: false,
|
|
5332
|
-
label: "Agent Approve plugin",
|
|
5333
|
-
error: `Could not install bundle to ${HERMES_PLUGIN_DIR}: ${err instanceof Error ? err.message : String(err)}.${restoreNote}`
|
|
5334
|
-
};
|
|
5294
|
+
const restoreNote = backupPath ? ` Your previous install was preserved at ${backupPath} — recover with: mv "${backupPath}" "${targetDir}"` : "";
|
|
5295
|
+
return { success: false, error: `Could not install bundle to ${targetDir}: ${err instanceof Error ? err.message : String(err)}.${restoreNote}` };
|
|
5335
5296
|
}
|
|
5336
|
-
writeFileSync(join(
|
|
5297
|
+
writeFileSync(join(targetDir, ".bundle-hash"), HERMES_BUNDLE_SHA256, { mode: 420 });
|
|
5337
5298
|
if (backupPath) {
|
|
5338
5299
|
rmSync2(backupPath, { recursive: true, force: true });
|
|
5339
5300
|
backupPath = null;
|
|
@@ -5341,26 +5302,69 @@ async function installHermesPluginViaCli() {
|
|
|
5341
5302
|
} catch (err) {
|
|
5342
5303
|
if (backupPath) {
|
|
5343
5304
|
try {
|
|
5344
|
-
rmSync2(
|
|
5345
|
-
renameSync(backupPath,
|
|
5305
|
+
rmSync2(targetDir, { recursive: true, force: true });
|
|
5306
|
+
renameSync(backupPath, targetDir);
|
|
5346
5307
|
backupPath = null;
|
|
5347
5308
|
} catch {}
|
|
5348
5309
|
}
|
|
5349
|
-
const restoreNote = backupPath ? ` Your previous install was preserved at ${backupPath} — recover with: mv "${backupPath}" "${
|
|
5350
|
-
return {
|
|
5351
|
-
success: false,
|
|
5352
|
-
label: "Agent Approve plugin",
|
|
5353
|
-
error: `Bundle install failed: ${err instanceof Error ? err.message : String(err)}.${restoreNote}`
|
|
5354
|
-
};
|
|
5310
|
+
const restoreNote = backupPath ? ` Your previous install was preserved at ${backupPath} — recover with: mv "${backupPath}" "${targetDir}"` : "";
|
|
5311
|
+
return { success: false, error: `Bundle install failed: ${err instanceof Error ? err.message : String(err)}.${restoreNote}` };
|
|
5355
5312
|
} finally {
|
|
5356
5313
|
try {
|
|
5357
5314
|
rmSync2(tmpDir, { recursive: true, force: true });
|
|
5358
5315
|
} catch {}
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
|
|
5316
|
+
}
|
|
5317
|
+
return { success: true };
|
|
5318
|
+
}
|
|
5319
|
+
function enableHermesPluginForProfile(profile) {
|
|
5320
|
+
try {
|
|
5321
|
+
execSync(hermesEnableCmd(profile), { stdio: "pipe" });
|
|
5322
|
+
return { success: true };
|
|
5323
|
+
} catch (err) {
|
|
5324
|
+
return { success: false, error: err instanceof Error ? err.message : String(err) };
|
|
5325
|
+
}
|
|
5326
|
+
}
|
|
5327
|
+
async function installHermesPluginViaCli() {
|
|
5328
|
+
try {
|
|
5329
|
+
execSync("hermes --version", { stdio: "pipe" });
|
|
5330
|
+
} catch {
|
|
5331
|
+
return {
|
|
5332
|
+
success: false,
|
|
5333
|
+
label: "Agent Approve plugin",
|
|
5334
|
+
error: "Hermes CLI not found on PATH. Install Hermes from https://hermes-agent.nousresearch.com first, then re-run npx agentapprove."
|
|
5335
|
+
};
|
|
5336
|
+
}
|
|
5337
|
+
const python = findPython();
|
|
5338
|
+
if (!python) {
|
|
5339
|
+
return {
|
|
5340
|
+
success: false,
|
|
5341
|
+
label: "Agent Approve plugin",
|
|
5342
|
+
error: "Python 3.10+ not found on PATH. Install Python 3.10 or newer (e.g. `brew install python@3.12`) and re-run npx agentapprove."
|
|
5343
|
+
};
|
|
5344
|
+
}
|
|
5345
|
+
const cfg = readInstallerConfig();
|
|
5346
|
+
if (!cfg.token) {
|
|
5347
|
+
return {
|
|
5348
|
+
success: false,
|
|
5349
|
+
label: "Agent Approve plugin",
|
|
5350
|
+
error: "Missing API token. Pair your phone first by running `npx agentapprove` and completing the QR scan."
|
|
5351
|
+
};
|
|
5352
|
+
}
|
|
5353
|
+
const download = await downloadHermesBundle(cfg.apiUrl, cfg.apiVersion, cfg.token);
|
|
5354
|
+
if (!download.ok) {
|
|
5355
|
+
return { success: false, label: "Agent Approve plugin", error: download.error };
|
|
5356
|
+
}
|
|
5357
|
+
const actualHash = verifyBundleHash(download.bytes);
|
|
5358
|
+
if (actualHash !== HERMES_BUNDLE_SHA256) {
|
|
5359
|
+
return {
|
|
5360
|
+
success: false,
|
|
5361
|
+
label: "Agent Approve plugin",
|
|
5362
|
+
error: `Bundle integrity check failed: expected ${HERMES_BUNDLE_SHA256.slice(0, 16)}…, got ${actualHash.slice(0, 16)}…. Refusing to install.`
|
|
5363
|
+
};
|
|
5364
|
+
}
|
|
5365
|
+
const staged = stageHermesBundle(download.bytes, HERMES_PLUGIN_DIR);
|
|
5366
|
+
if (!staged.success) {
|
|
5367
|
+
return { success: false, label: "Agent Approve plugin", error: staged.error };
|
|
5364
5368
|
}
|
|
5365
5369
|
if (!hermesDepsAlreadyInstalled(python.command)) {
|
|
5366
5370
|
const depsResult = installHermesDepsAdaptive(python.command, HERMES_PIP_DEPS);
|
|
@@ -5372,13 +5376,12 @@ async function installHermesPluginViaCli() {
|
|
|
5372
5376
|
};
|
|
5373
5377
|
}
|
|
5374
5378
|
}
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
} catch (err) {
|
|
5379
|
+
const enabled = enableHermesPluginForProfile(HERMES_DEFAULT_PROFILE);
|
|
5380
|
+
if (!enabled.success) {
|
|
5378
5381
|
return {
|
|
5379
5382
|
success: false,
|
|
5380
5383
|
label: "Agent Approve plugin",
|
|
5381
|
-
error: `Installed bundle but could not enable plugin in Hermes: ${
|
|
5384
|
+
error: `Installed bundle but could not enable plugin in Hermes: ${enabled.error}. ` + `Try manually: hermes plugins enable agentapprove`
|
|
5382
5385
|
};
|
|
5383
5386
|
}
|
|
5384
5387
|
return { success: true, label: `Agent Approve plugin ${HERMES_PLUGIN_VERSION}` };
|
|
@@ -5394,9 +5397,9 @@ ${stderr}
|
|
|
5394
5397
|
${stdout}`.toLowerCase();
|
|
5395
5398
|
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");
|
|
5396
5399
|
}
|
|
5397
|
-
function
|
|
5400
|
+
function disableHermesPluginForProfile(profile) {
|
|
5398
5401
|
try {
|
|
5399
|
-
execSync(
|
|
5402
|
+
execSync(hermesDisableCmd(profile), { stdio: "pipe" });
|
|
5400
5403
|
return { success: true };
|
|
5401
5404
|
} catch (err) {
|
|
5402
5405
|
if (isHermesDisableNoOp(err)) {
|
|
@@ -5408,10 +5411,13 @@ function disableHermesPluginViaCli() {
|
|
|
5408
5411
|
};
|
|
5409
5412
|
}
|
|
5410
5413
|
}
|
|
5411
|
-
function
|
|
5412
|
-
|
|
5414
|
+
function disableHermesPluginViaCli() {
|
|
5415
|
+
return disableHermesPluginForProfile(HERMES_DEFAULT_PROFILE);
|
|
5416
|
+
}
|
|
5417
|
+
function removeHermesPluginFromProfile(profile) {
|
|
5418
|
+
const disabled = disableHermesPluginForProfile(profile);
|
|
5413
5419
|
try {
|
|
5414
|
-
rmSync2(
|
|
5420
|
+
rmSync2(hermesProfilePluginDir(profile), { recursive: true, force: true });
|
|
5415
5421
|
return disabled.success ? { success: true } : { success: false, error: `disable failed: ${disabled.error || "unknown"}` };
|
|
5416
5422
|
} catch (err) {
|
|
5417
5423
|
return {
|
|
@@ -5420,6 +5426,81 @@ function removeHermesPlugin() {
|
|
|
5420
5426
|
};
|
|
5421
5427
|
}
|
|
5422
5428
|
}
|
|
5429
|
+
function hermesProfilePluginStatus(profile) {
|
|
5430
|
+
const dir = hermesProfilePluginDir(profile);
|
|
5431
|
+
const installed = existsSync2(join(dir, ".bundle-hash"));
|
|
5432
|
+
let version = null;
|
|
5433
|
+
if (installed) {
|
|
5434
|
+
try {
|
|
5435
|
+
const configPy = readFileSync(join(dir, "config.py"), "utf-8");
|
|
5436
|
+
const m2 = configPy.match(/^PLUGIN_VERSION\s*=\s*["']([^"']+)["']/m);
|
|
5437
|
+
version = m2 ? m2[1] : null;
|
|
5438
|
+
} catch {}
|
|
5439
|
+
}
|
|
5440
|
+
return { name: profile, isDefault: profile === HERMES_DEFAULT_PROFILE, installed, version };
|
|
5441
|
+
}
|
|
5442
|
+
function listHermesProfiles() {
|
|
5443
|
+
const names = new Set([HERMES_DEFAULT_PROFILE]);
|
|
5444
|
+
try {
|
|
5445
|
+
const profilesRoot = join(homedir(), ".hermes", "profiles");
|
|
5446
|
+
if (existsSync2(profilesRoot)) {
|
|
5447
|
+
for (const entry of readdirSync2(profilesRoot, { withFileTypes: true })) {
|
|
5448
|
+
if (entry.isDirectory() && isValidHermesProfileName(entry.name)) {
|
|
5449
|
+
names.add(entry.name);
|
|
5450
|
+
}
|
|
5451
|
+
}
|
|
5452
|
+
}
|
|
5453
|
+
} catch {}
|
|
5454
|
+
return [...names].sort((a3, b3) => a3 === HERMES_DEFAULT_PROFILE ? -1 : b3 === HERMES_DEFAULT_PROFILE ? 1 : a3.localeCompare(b3)).map(hermesProfilePluginStatus);
|
|
5455
|
+
}
|
|
5456
|
+
async function syncHermesProfiles(targetProfiles) {
|
|
5457
|
+
try {
|
|
5458
|
+
execSync("hermes --version", { stdio: "pipe" });
|
|
5459
|
+
} catch {
|
|
5460
|
+
return { ok: false, results: [], error: "Hermes CLI not found on PATH. Install Hermes first, then re-run." };
|
|
5461
|
+
}
|
|
5462
|
+
const python = findPython();
|
|
5463
|
+
if (!python) {
|
|
5464
|
+
return { ok: false, results: [], error: "Python 3.10+ not found on PATH." };
|
|
5465
|
+
}
|
|
5466
|
+
const cfg = readInstallerConfig();
|
|
5467
|
+
if (!cfg.token) {
|
|
5468
|
+
return { ok: false, results: [], error: "Missing API token. Run `npx agentapprove` to pair first." };
|
|
5469
|
+
}
|
|
5470
|
+
const download = await downloadHermesBundle(cfg.apiUrl, cfg.apiVersion, cfg.token);
|
|
5471
|
+
if (!download.ok) {
|
|
5472
|
+
return { ok: false, results: [], error: download.error };
|
|
5473
|
+
}
|
|
5474
|
+
const actualHash = verifyBundleHash(download.bytes);
|
|
5475
|
+
if (actualHash !== HERMES_BUNDLE_SHA256) {
|
|
5476
|
+
return {
|
|
5477
|
+
ok: false,
|
|
5478
|
+
results: [],
|
|
5479
|
+
error: `Bundle integrity check failed: expected ${HERMES_BUNDLE_SHA256.slice(0, 16)}…, got ${actualHash.slice(0, 16)}…. Refusing to install.`
|
|
5480
|
+
};
|
|
5481
|
+
}
|
|
5482
|
+
if (!hermesDepsAlreadyInstalled(python.command)) {
|
|
5483
|
+
const depsResult = installHermesDepsAdaptive(python.command, HERMES_PIP_DEPS);
|
|
5484
|
+
if (!depsResult.ok) {
|
|
5485
|
+
return { ok: false, results: [], error: `Could not install Python runtime deps: ${depsResult.error}` };
|
|
5486
|
+
}
|
|
5487
|
+
}
|
|
5488
|
+
const results = [];
|
|
5489
|
+
for (const profile of targetProfiles) {
|
|
5490
|
+
if (!isValidHermesProfileName(profile)) {
|
|
5491
|
+
results.push({ profile, success: false, error: "invalid profile name" });
|
|
5492
|
+
continue;
|
|
5493
|
+
}
|
|
5494
|
+
const staged = stageHermesBundle(download.bytes, hermesProfilePluginDir(profile));
|
|
5495
|
+
if (!staged.success) {
|
|
5496
|
+
results.push({ profile, success: false, error: staged.error });
|
|
5497
|
+
continue;
|
|
5498
|
+
}
|
|
5499
|
+
const enabled = enableHermesPluginForProfile(profile);
|
|
5500
|
+
results.push({ profile, success: enabled.success, error: enabled.error });
|
|
5501
|
+
}
|
|
5502
|
+
return { ok: results.every((r2) => r2.success), results };
|
|
5503
|
+
}
|
|
5423
5504
|
var SYSTEM_DEPS = [
|
|
5424
5505
|
{
|
|
5425
5506
|
name: "curl",
|
|
@@ -6262,6 +6343,77 @@ npx agentapprove purge Remove hooks/plugins and delete local state
|
|
|
6262
6343
|
npx agentapprove restore Restore original configs`, "Useful commands");
|
|
6263
6344
|
ge(`${source_default.green("Agent Approve is ready!")} ${source_default.dim("Learn more at")} ${source_default.cyan("agentapprove.com")}`);
|
|
6264
6345
|
}
|
|
6346
|
+
async function profilesCommand() {
|
|
6347
|
+
console.clear();
|
|
6348
|
+
pe(source_default.bgCyan.black(" Agent Approve ") + source_default.gray(" Hermes Profiles"));
|
|
6349
|
+
try {
|
|
6350
|
+
execSync("hermes --version", { stdio: "pipe" });
|
|
6351
|
+
} catch {
|
|
6352
|
+
v2.error("Hermes CLI not found on PATH. Install Hermes first, then re-run.");
|
|
6353
|
+
ge("No changes made.");
|
|
6354
|
+
process.exit(1);
|
|
6355
|
+
}
|
|
6356
|
+
const cfg = readInstallerConfig();
|
|
6357
|
+
if (!cfg.token) {
|
|
6358
|
+
v2.error("Missing API token. Run `npx agentapprove` to pair your phone first.");
|
|
6359
|
+
ge("No changes made.");
|
|
6360
|
+
process.exit(1);
|
|
6361
|
+
}
|
|
6362
|
+
const profiles = listHermesProfiles();
|
|
6363
|
+
const currentlyInstalled = profiles.filter((pr) => pr.installed).map((pr) => pr.name);
|
|
6364
|
+
me(profiles.map((pr) => {
|
|
6365
|
+
const label = (pr.isDefault ? `${pr.name} (default)` : pr.name).padEnd(22);
|
|
6366
|
+
const state = pr.installed ? `installed v${pr.version ?? "?"}` : "not installed";
|
|
6367
|
+
return `${label} ${state}`;
|
|
6368
|
+
}).join(`
|
|
6369
|
+
`), "Hermes profiles");
|
|
6370
|
+
const picked = await $e({
|
|
6371
|
+
message: "Select the profiles that should have Agent Approve",
|
|
6372
|
+
options: profiles.map((pr) => ({
|
|
6373
|
+
value: pr.name,
|
|
6374
|
+
label: pr.isDefault ? `${pr.name} (default)` : pr.name,
|
|
6375
|
+
hint: pr.installed ? `installed v${pr.version ?? "?"}` : "not installed"
|
|
6376
|
+
})),
|
|
6377
|
+
initialValues: currentlyInstalled,
|
|
6378
|
+
required: false
|
|
6379
|
+
});
|
|
6380
|
+
if (lD(picked)) {
|
|
6381
|
+
he("Cancelled — no changes made.");
|
|
6382
|
+
process.exit(0);
|
|
6383
|
+
}
|
|
6384
|
+
const target = picked;
|
|
6385
|
+
const toInstall = target.filter((n) => !currentlyInstalled.includes(n));
|
|
6386
|
+
const toRemove = currentlyInstalled.filter((n) => !target.includes(n));
|
|
6387
|
+
if (toInstall.length === 0 && toRemove.length === 0) {
|
|
6388
|
+
ge("No changes — every profile already matches your selection.");
|
|
6389
|
+
return;
|
|
6390
|
+
}
|
|
6391
|
+
if (toInstall.length > 0) {
|
|
6392
|
+
const s = _2();
|
|
6393
|
+
s.start(`Installing Agent Approve into ${toInstall.length} profile(s)…`);
|
|
6394
|
+
const sync = await syncHermesProfiles(toInstall);
|
|
6395
|
+
if (sync.results.length === 0) {
|
|
6396
|
+
s.stop(source_default.red(`Install failed: ${sync.error ?? "unknown error"}`));
|
|
6397
|
+
ge("No changes made.");
|
|
6398
|
+
process.exit(1);
|
|
6399
|
+
}
|
|
6400
|
+
s.stop(sync.ok ? "Install step complete" : "Install step done (some profiles failed)");
|
|
6401
|
+
for (const r2 of sync.results) {
|
|
6402
|
+
if (r2.success)
|
|
6403
|
+
v2.success(`${r2.profile}: Agent Approve ${HERMES_PLUGIN_VERSION} installed + enabled`);
|
|
6404
|
+
else
|
|
6405
|
+
v2.error(`${r2.profile}: ${r2.error ?? "failed"}`);
|
|
6406
|
+
}
|
|
6407
|
+
}
|
|
6408
|
+
for (const profile of toRemove) {
|
|
6409
|
+
const r2 = removeHermesPluginFromProfile(profile);
|
|
6410
|
+
if (r2.success)
|
|
6411
|
+
v2.success(`${profile}: Agent Approve removed`);
|
|
6412
|
+
else
|
|
6413
|
+
v2.warn(`${profile}: removal partial (${r2.error ?? "unknown"})`);
|
|
6414
|
+
}
|
|
6415
|
+
ge("Hermes profiles updated.");
|
|
6416
|
+
}
|
|
6265
6417
|
async function statusCommand() {
|
|
6266
6418
|
console.log(source_default.cyan(`
|
|
6267
6419
|
Agent Approve Status
|
|
@@ -6425,11 +6577,14 @@ async function performUninstall(mode) {
|
|
|
6425
6577
|
continue;
|
|
6426
6578
|
}
|
|
6427
6579
|
if (agentId === "hermes") {
|
|
6428
|
-
const
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6580
|
+
for (const pr of listHermesProfiles().filter((p) => p.installed)) {
|
|
6581
|
+
const label = pr.isDefault ? "default" : `profile "${pr.name}"`;
|
|
6582
|
+
const result = removeHermesPluginFromProfile(pr.name);
|
|
6583
|
+
if (result.success) {
|
|
6584
|
+
console.log(` ${source_default.green("✓")} Hermes plugin removed from ${label}`);
|
|
6585
|
+
} else {
|
|
6586
|
+
console.log(` ${source_default.yellow("⚠")} Hermes plugin removal partial for ${label} (${result.error || "unknown error"})`);
|
|
6587
|
+
}
|
|
6433
6588
|
}
|
|
6434
6589
|
continue;
|
|
6435
6590
|
}
|
|
@@ -6653,6 +6808,7 @@ ${source_default.yellow("Commands:")}
|
|
|
6653
6808
|
${source_default.green("refresh")} Generate a new token and reuse current pairing context
|
|
6654
6809
|
${source_default.green("init-repo")} Add GitHub Copilot CLI hooks to current repo (.github/hooks/)
|
|
6655
6810
|
${source_default.green("status")} Show current configuration and installed hooks
|
|
6811
|
+
${source_default.green("profiles")} Install/remove Agent Approve across Hermes profiles
|
|
6656
6812
|
${source_default.green("disable")} Temporarily disable hooks
|
|
6657
6813
|
${source_default.green("enable")} Re-enable hooks after disabling
|
|
6658
6814
|
${source_default.green("uninstall")} ${INSTALLER_COMMAND_DESCRIPTIONS.uninstall}
|
|
@@ -7015,6 +7171,9 @@ async function main() {
|
|
|
7015
7171
|
case "status":
|
|
7016
7172
|
await statusCommand();
|
|
7017
7173
|
break;
|
|
7174
|
+
case "profiles":
|
|
7175
|
+
await profilesCommand();
|
|
7176
|
+
break;
|
|
7018
7177
|
case "disable":
|
|
7019
7178
|
await disableCommand();
|
|
7020
7179
|
break;
|