agentapprove 0.1.26 → 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.
Files changed (3) hide show
  1. package/README.md +16 -0
  2. package/dist/cli.js +355 -104
  3. 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.22";
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.0";
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": {
@@ -4812,6 +4816,8 @@ codex_hooks = true`;
4812
4816
  "in that directory, then:",
4813
4817
  "",
4814
4818
  " pip install --user cryptography httpx",
4819
+ " # On uv-managed Python (PEP 668 EXTERNALLY-MANAGED): instead run",
4820
+ " # uv pip install --system --break-system-packages --python $(which python3.12) cryptography httpx",
4815
4821
  " hermes plugins enable agentapprove",
4816
4822
  "",
4817
4823
  "The plugin reads your existing Agent Approve config from ~/.agentapprove/env.",
@@ -4856,9 +4862,50 @@ function readOpenClawInstalledVersion() {
4856
4862
  return null;
4857
4863
  }
4858
4864
  }
4865
+ function isOpenClawAlreadyExistsError(err) {
4866
+ if (!err || typeof err !== "object")
4867
+ return false;
4868
+ const e2 = err;
4869
+ const blob = [
4870
+ Buffer.isBuffer(e2.stderr) ? e2.stderr.toString() : String(e2.stderr || ""),
4871
+ Buffer.isBuffer(e2.stdout) ? e2.stdout.toString() : String(e2.stdout || ""),
4872
+ String(e2.message || "")
4873
+ ].join(`
4874
+ `);
4875
+ return /plugin already exists|delete it first|use .*plugins update/i.test(blob);
4876
+ }
4859
4877
  function installOpenClawPluginViaCli() {
4878
+ const installCmd = (force) => `openclaw plugins install ${OPENCLAW_PLUGIN_SPEC}${force ? " --force" : ""}`;
4879
+ const tryInstall = (force) => {
4880
+ try {
4881
+ execSync(installCmd(force), { stdio: "pipe" });
4882
+ return { ok: true };
4883
+ } catch (err) {
4884
+ return { ok: false, err };
4885
+ }
4886
+ };
4887
+ let firstAttempt = tryInstall(false);
4888
+ if (!firstAttempt.ok && isOpenClawAlreadyExistsError(firstAttempt.err)) {
4889
+ const existingVersion = readOpenClawInstalledVersion();
4890
+ if (existingVersion === OPENCLAW_PLUGIN_VERSION) {
4891
+ return {
4892
+ success: true,
4893
+ version: existingVersion,
4894
+ label: `Agent Approve plugin v${existingVersion} (already installed)`
4895
+ };
4896
+ }
4897
+ const forceAttempt = tryInstall(true);
4898
+ if (!forceAttempt.ok) {
4899
+ const message = forceAttempt.err instanceof Error ? forceAttempt.err.message : "unknown error";
4900
+ return { success: false, error: message, label: "Agent Approve plugin" };
4901
+ }
4902
+ firstAttempt = { ok: true };
4903
+ }
4904
+ if (!firstAttempt.ok) {
4905
+ const message = firstAttempt.err instanceof Error ? firstAttempt.err.message : "unknown error";
4906
+ return { success: false, error: message, label: "Agent Approve plugin" };
4907
+ }
4860
4908
  try {
4861
- execSync(`openclaw plugins install ${OPENCLAW_PLUGIN_SPEC}`, { stdio: "pipe" });
4862
4909
  const installedVersion = readOpenClawInstalledVersion();
4863
4910
  if (!installedVersion) {
4864
4911
  return {
@@ -4989,7 +5036,7 @@ function removePiPluginViaCli() {
4989
5036
  };
4990
5037
  }
4991
5038
  }
4992
- var HERMES_BUNDLE_SHA256 = "2572cec0a2d8467e9ffc2000e5c52cf652265d20638244a8a70e2e3a6c9d2734";
5039
+ var HERMES_BUNDLE_SHA256 = "e315544be0a01b21c1557f4a9dd17f35e4165bd4608da42007566be1560f355d";
4993
5040
  var HERMES_BUNDLE_FILENAME = `agentapprove-hermes-${HERMES_PLUGIN_VERSION}.tar.gz`;
4994
5041
  var HERMES_PLUGIN_DIR = join(homedir(), ".hermes", "plugins", "agentapprove");
4995
5042
  function findPython() {
@@ -5142,105 +5189,112 @@ function hermesDepsAlreadyInstalled(pythonCommand) {
5142
5189
  return false;
5143
5190
  }
5144
5191
  }
5145
- async function installHermesPluginViaCli() {
5192
+ function uvAvailable() {
5146
5193
  try {
5147
- execSync("hermes --version", { stdio: "pipe" });
5194
+ execSync("uv --version", { stdio: "pipe", timeout: 5000 });
5195
+ return true;
5148
5196
  } catch {
5149
- return {
5150
- success: false,
5151
- label: "Agent Approve plugin",
5152
- error: "Hermes CLI not found on PATH. Install Hermes from https://hermes-agent.nousresearch.com first, then re-run npx agentapprove."
5153
- };
5154
- }
5155
- const python = findPython();
5156
- if (!python) {
5157
- return {
5158
- success: false,
5159
- label: "Agent Approve plugin",
5160
- 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."
5161
- };
5162
- }
5163
- const cfg = readInstallerConfig();
5164
- if (!cfg.token) {
5165
- return {
5166
- success: false,
5167
- label: "Agent Approve plugin",
5168
- error: "Missing API token. Pair your phone first by running `npx agentapprove` and completing the QR scan."
5169
- };
5170
- }
5171
- const download = await downloadHermesBundle(cfg.apiUrl, cfg.apiVersion, cfg.token);
5172
- if (!download.ok) {
5173
- return { success: false, label: "Agent Approve plugin", error: download.error };
5197
+ return false;
5174
5198
  }
5175
- const actualHash = verifyBundleHash(download.bytes);
5176
- if (actualHash !== HERMES_BUNDLE_SHA256) {
5177
- return {
5178
- success: false,
5179
- label: "Agent Approve plugin",
5180
- error: `Bundle integrity check failed: expected ${HERMES_BUNDLE_SHA256.slice(0, 16)}…, got ${actualHash.slice(0, 16)}…. Refusing to install.`
5181
- };
5199
+ }
5200
+ function isExternallyManagedError(err) {
5201
+ if (!err || typeof err !== "object")
5202
+ return false;
5203
+ const e2 = err;
5204
+ const stderr = Buffer.isBuffer(e2.stderr) ? e2.stderr.toString() : String(e2.stderr || "");
5205
+ const stdout = Buffer.isBuffer(e2.stdout) ? e2.stdout.toString() : String(e2.stdout || "");
5206
+ const message = String(e2.message || "");
5207
+ const blob = `${stderr}
5208
+ ${stdout}
5209
+ ${message}`;
5210
+ return /externally-managed-environment|PEP 668|managed by uv/i.test(blob);
5211
+ }
5212
+ function installHermesDepsAdaptive(pythonCommand, deps) {
5213
+ const depsArg = deps.map((d2) => `"${d2}"`).join(" ");
5214
+ try {
5215
+ execSync(`${pythonCommand} -m pip install --user --quiet ${depsArg}`, { stdio: "pipe" });
5216
+ return { ok: true };
5217
+ } catch (pipErr) {
5218
+ if (!isExternallyManagedError(pipErr)) {
5219
+ return {
5220
+ ok: false,
5221
+ error: `pip install failed: ${pipErr instanceof Error ? pipErr.message : String(pipErr)}. ` + `Try manually: ${pythonCommand} -m pip install --user ${depsArg}`
5222
+ };
5223
+ }
5224
+ if (!uvAvailable()) {
5225
+ return {
5226
+ ok: false,
5227
+ error: "Python is externally managed (PEP 668) and `uv` is not installed. " + `Install uv (https://docs.astral.sh/uv/) and re-run, or run manually: uv pip install --system --python ${pythonCommand} ${depsArg}`
5228
+ };
5229
+ }
5230
+ const uvCmd = `uv pip install --system --break-system-packages --python ${pythonCommand} --quiet ${depsArg}`;
5231
+ try {
5232
+ execSync(uvCmd, { stdio: "pipe" });
5233
+ return { ok: true };
5234
+ } catch (uvErr) {
5235
+ return {
5236
+ ok: false,
5237
+ error: `uv pip install failed: ${uvErr instanceof Error ? uvErr.message : String(uvErr)}. ` + `Try manually: ${uvCmd}`
5238
+ };
5239
+ }
5182
5240
  }
5241
+ }
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) {
5183
5257
  let tmpDir;
5184
5258
  try {
5185
5259
  tmpDir = mkdtempSync(join(tmpdir(), "aa-hermes-"));
5186
5260
  } catch (err) {
5187
- return {
5188
- success: false,
5189
- label: "Agent Approve plugin",
5190
- error: `Could not create temp directory for bundle staging: ${err instanceof Error ? err.message : String(err)}`
5191
- };
5261
+ return { success: false, error: `Could not create temp directory for bundle staging: ${err instanceof Error ? err.message : String(err)}` };
5192
5262
  }
5193
5263
  const tarballPath = join(tmpDir, HERMES_BUNDLE_FILENAME);
5194
5264
  let backupPath = null;
5195
5265
  try {
5196
- writeFileSync(tarballPath, download.bytes);
5266
+ writeFileSync(tarballPath, bytes);
5197
5267
  try {
5198
5268
  execSync(`tar -xzf "${tarballPath}" -C "${tmpDir}" --no-same-owner --no-same-permissions`, { stdio: "pipe" });
5199
5269
  } catch (err) {
5200
- return {
5201
- success: false,
5202
- label: "Agent Approve plugin",
5203
- error: `tar extract failed: ${err instanceof Error ? err.message : String(err)}`
5204
- };
5270
+ return { success: false, error: `tar extract failed: ${err instanceof Error ? err.message : String(err)}` };
5205
5271
  }
5206
5272
  const stagedDir = join(tmpDir, "agentapprove");
5207
5273
  if (!existsSync2(stagedDir)) {
5208
- return {
5209
- success: false,
5210
- label: "Agent Approve plugin",
5211
- error: "Bundle did not contain expected `agentapprove/` directory."
5212
- };
5274
+ return { success: false, error: "Bundle did not contain expected `agentapprove/` directory." };
5213
5275
  }
5214
5276
  const validation = validateExtractedTree(stagedDir);
5215
5277
  if (!validation.ok) {
5216
- return {
5217
- success: false,
5218
- label: "Agent Approve plugin",
5219
- error: `Bundle integrity violation: ${validation.error}`
5220
- };
5278
+ return { success: false, error: `Bundle integrity violation: ${validation.error}` };
5221
5279
  }
5222
- mkdirSync(dirname2(HERMES_PLUGIN_DIR), { recursive: true });
5223
- if (existsSync2(HERMES_PLUGIN_DIR)) {
5224
- backupPath = `${HERMES_PLUGIN_DIR}.bak-${Date.now()}`;
5225
- renameSync(HERMES_PLUGIN_DIR, backupPath);
5280
+ mkdirSync(dirname2(targetDir), { recursive: true });
5281
+ if (existsSync2(targetDir)) {
5282
+ backupPath = `${targetDir}.bak-${Date.now()}`;
5283
+ renameSync(targetDir, backupPath);
5226
5284
  }
5227
5285
  try {
5228
- renameSync(stagedDir, HERMES_PLUGIN_DIR);
5286
+ renameSync(stagedDir, targetDir);
5229
5287
  } catch (err) {
5230
5288
  if (backupPath) {
5231
5289
  try {
5232
- renameSync(backupPath, HERMES_PLUGIN_DIR);
5290
+ renameSync(backupPath, targetDir);
5233
5291
  backupPath = null;
5234
5292
  } catch {}
5235
5293
  }
5236
- const restoreNote = backupPath ? ` Your previous install was preserved at ${backupPath} — recover with: mv "${backupPath}" "${HERMES_PLUGIN_DIR}"` : "";
5237
- return {
5238
- success: false,
5239
- label: "Agent Approve plugin",
5240
- error: `Could not install bundle to ${HERMES_PLUGIN_DIR}: ${err instanceof Error ? err.message : String(err)}.${restoreNote}`
5241
- };
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}` };
5242
5296
  }
5243
- writeFileSync(join(HERMES_PLUGIN_DIR, ".bundle-hash"), HERMES_BUNDLE_SHA256, { mode: 420 });
5297
+ writeFileSync(join(targetDir, ".bundle-hash"), HERMES_BUNDLE_SHA256, { mode: 420 });
5244
5298
  if (backupPath) {
5245
5299
  rmSync2(backupPath, { recursive: true, force: true });
5246
5300
  backupPath = null;
@@ -5248,46 +5302,86 @@ async function installHermesPluginViaCli() {
5248
5302
  } catch (err) {
5249
5303
  if (backupPath) {
5250
5304
  try {
5251
- rmSync2(HERMES_PLUGIN_DIR, { recursive: true, force: true });
5252
- renameSync(backupPath, HERMES_PLUGIN_DIR);
5305
+ rmSync2(targetDir, { recursive: true, force: true });
5306
+ renameSync(backupPath, targetDir);
5253
5307
  backupPath = null;
5254
5308
  } catch {}
5255
5309
  }
5256
- const restoreNote = backupPath ? ` Your previous install was preserved at ${backupPath} — recover with: mv "${backupPath}" "${HERMES_PLUGIN_DIR}"` : "";
5257
- return {
5258
- success: false,
5259
- label: "Agent Approve plugin",
5260
- error: `Bundle install failed: ${err instanceof Error ? err.message : String(err)}.${restoreNote}`
5261
- };
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}` };
5262
5312
  } finally {
5263
5313
  try {
5264
5314
  rmSync2(tmpDir, { recursive: true, force: true });
5265
5315
  } catch {}
5266
- if (backupPath && existsSync2(HERMES_PLUGIN_DIR)) {
5267
- try {
5268
- rmSync2(backupPath, { recursive: true, force: true });
5269
- } catch {}
5270
- }
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 };
5271
5368
  }
5272
5369
  if (!hermesDepsAlreadyInstalled(python.command)) {
5273
- const depsArg = HERMES_PIP_DEPS.map((d2) => `"${d2}"`).join(" ");
5274
- try {
5275
- execSync(`${python.command} -m pip install --user --quiet ${depsArg}`, { stdio: "pipe" });
5276
- } catch (err) {
5370
+ const depsResult = installHermesDepsAdaptive(python.command, HERMES_PIP_DEPS);
5371
+ if (!depsResult.ok) {
5277
5372
  return {
5278
5373
  success: false,
5279
5374
  label: "Agent Approve plugin",
5280
- error: `Installed bundle but could not install Python runtime deps: ${err instanceof Error ? err.message : String(err)}. ` + `Try manually: ${python.command} -m pip install --user ${HERMES_PIP_DEPS.join(" ")}`
5375
+ error: `Installed bundle but could not install Python runtime deps: ${depsResult.error}`
5281
5376
  };
5282
5377
  }
5283
5378
  }
5284
- try {
5285
- execSync("hermes plugins enable agentapprove", { stdio: "pipe" });
5286
- } catch (err) {
5379
+ const enabled = enableHermesPluginForProfile(HERMES_DEFAULT_PROFILE);
5380
+ if (!enabled.success) {
5287
5381
  return {
5288
5382
  success: false,
5289
5383
  label: "Agent Approve plugin",
5290
- error: `Installed bundle but could not enable plugin in Hermes: ${err instanceof Error ? err.message : String(err)}. ` + `Try manually: hermes plugins enable agentapprove`
5384
+ error: `Installed bundle but could not enable plugin in Hermes: ${enabled.error}. ` + `Try manually: hermes plugins enable agentapprove`
5291
5385
  };
5292
5386
  }
5293
5387
  return { success: true, label: `Agent Approve plugin ${HERMES_PLUGIN_VERSION}` };
@@ -5303,9 +5397,9 @@ ${stderr}
5303
5397
  ${stdout}`.toLowerCase();
5304
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");
5305
5399
  }
5306
- function disableHermesPluginViaCli() {
5400
+ function disableHermesPluginForProfile(profile) {
5307
5401
  try {
5308
- execSync("hermes plugins disable agentapprove", { stdio: "pipe" });
5402
+ execSync(hermesDisableCmd(profile), { stdio: "pipe" });
5309
5403
  return { success: true };
5310
5404
  } catch (err) {
5311
5405
  if (isHermesDisableNoOp(err)) {
@@ -5317,10 +5411,13 @@ function disableHermesPluginViaCli() {
5317
5411
  };
5318
5412
  }
5319
5413
  }
5320
- function removeHermesPlugin() {
5321
- const disabled = disableHermesPluginViaCli();
5414
+ function disableHermesPluginViaCli() {
5415
+ return disableHermesPluginForProfile(HERMES_DEFAULT_PROFILE);
5416
+ }
5417
+ function removeHermesPluginFromProfile(profile) {
5418
+ const disabled = disableHermesPluginForProfile(profile);
5322
5419
  try {
5323
- rmSync2(HERMES_PLUGIN_DIR, { recursive: true, force: true });
5420
+ rmSync2(hermesProfilePluginDir(profile), { recursive: true, force: true });
5324
5421
  return disabled.success ? { success: true } : { success: false, error: `disable failed: ${disabled.error || "unknown"}` };
5325
5422
  } catch (err) {
5326
5423
  return {
@@ -5329,6 +5426,81 @@ function removeHermesPlugin() {
5329
5426
  };
5330
5427
  }
5331
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
+ }
5332
5504
  var SYSTEM_DEPS = [
5333
5505
  {
5334
5506
  name: "curl",
@@ -6144,6 +6316,7 @@ Backups will be created with timestamp`, "Files to be modified");
6144
6316
  ` + ` 3. Extract into ~/.hermes/plugins/agentapprove/
6145
6317
  ` + ` 4. Write the SHA-256 to ~/.hermes/plugins/agentapprove/.bundle-hash
6146
6318
  ` + ` 5. pip install --user cryptography httpx
6319
+ ` + ` (uv-managed Python: uv pip install --system --break-system-packages --python $(which python3.12) cryptography httpx)
6147
6320
  ` + ` 6. hermes plugins enable agentapprove
6148
6321
  ` + ` Then re-run: npx agentapprove`);
6149
6322
  }
@@ -6170,6 +6343,77 @@ npx agentapprove purge Remove hooks/plugins and delete local state
6170
6343
  npx agentapprove restore Restore original configs`, "Useful commands");
6171
6344
  ge(`${source_default.green("Agent Approve is ready!")} ${source_default.dim("Learn more at")} ${source_default.cyan("agentapprove.com")}`);
6172
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
+ }
6173
6417
  async function statusCommand() {
6174
6418
  console.log(source_default.cyan(`
6175
6419
  Agent Approve Status
@@ -6333,11 +6577,14 @@ async function performUninstall(mode) {
6333
6577
  continue;
6334
6578
  }
6335
6579
  if (agentId === "hermes") {
6336
- const result = removeHermesPlugin();
6337
- if (result.success) {
6338
- console.log(` ${source_default.green("✓")} Hermes plugin disabled and removed`);
6339
- } else {
6340
- console.log(` ${source_default.yellow("⚠")} Hermes plugin removal partial (${result.error || "unknown error"})`);
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
+ }
6341
6588
  }
6342
6589
  continue;
6343
6590
  }
@@ -6561,6 +6808,7 @@ ${source_default.yellow("Commands:")}
6561
6808
  ${source_default.green("refresh")} Generate a new token and reuse current pairing context
6562
6809
  ${source_default.green("init-repo")} Add GitHub Copilot CLI hooks to current repo (.github/hooks/)
6563
6810
  ${source_default.green("status")} Show current configuration and installed hooks
6811
+ ${source_default.green("profiles")} Install/remove Agent Approve across Hermes profiles
6564
6812
  ${source_default.green("disable")} Temporarily disable hooks
6565
6813
  ${source_default.green("enable")} Re-enable hooks after disabling
6566
6814
  ${source_default.green("uninstall")} ${INSTALLER_COMMAND_DESCRIPTIONS.uninstall}
@@ -6923,6 +7171,9 @@ async function main() {
6923
7171
  case "status":
6924
7172
  await statusCommand();
6925
7173
  break;
7174
+ case "profiles":
7175
+ await profilesCommand();
7176
+ break;
6926
7177
  case "disable":
6927
7178
  await disableCommand();
6928
7179
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentapprove",
3
- "version": "0.1.26",
3
+ "version": "0.1.27",
4
4
  "description": "Approve AI agent actions from your iPhone or Apple Watch",
5
5
  "type": "module",
6
6
  "bin": {