agentapprove 0.1.56 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.js +75 -45
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1844,6 +1844,7 @@ function upsertCursorHook(existing, entry) {
1844
1844
 
1845
1845
  // src/openclaw-install.ts
1846
1846
  import { spawnSync } from "node:child_process";
1847
+ import { isDeepStrictEqual } from "node:util";
1847
1848
  var CONVERSATION_ACCESS_NOTICE = "OpenClaw setup includes access to prompts, responses, and completed conversations for monitoring and mobile follow-up. Your privacy and encryption settings still apply. OpenClaw will review any required plugin permissions during installation.";
1848
1849
  function runOpenClaw(args) {
1849
1850
  const result = spawnSync("openclaw", args, { stdio: "inherit", shell: process.platform === "win32" });
@@ -1862,7 +1863,7 @@ function mergeOpenClawConfig(config, conversationAccess) {
1862
1863
  openclaw: {
1863
1864
  ...entry,
1864
1865
  hooks: { ...entry.hooks, allowConversationAccess: conversationAccess },
1865
- config: { ...entry.config }
1866
+ ...entry.config === undefined ? {} : { config: { ...entry.config } }
1866
1867
  }
1867
1868
  }
1868
1869
  },
@@ -1893,13 +1894,16 @@ async function installOpenClaw(options) {
1893
1894
  return fail(`OpenClaw installed ${actual ?? "an unverified version"}, expected ${options.version}.`);
1894
1895
  }
1895
1896
  try {
1896
- options.writeConfig(mergeOpenClawConfig(options.readConfig(), true));
1897
+ const current = options.readConfig();
1898
+ const updated = mergeOpenClawConfig(current, true);
1899
+ if (!isDeepStrictEqual(current, updated))
1900
+ options.writeConfig(updated);
1897
1901
  } catch {
1898
1902
  return fail("Could not read or save OpenClaw configuration. The plugin package is present; check the config and retry setup before using it.");
1899
1903
  }
1900
1904
  const action = options.mode === "approval" ? "enable" : "disable";
1901
1905
  if (!run(["plugins", action, "openclaw"]))
1902
- return fail(`OpenClaw ${action} was declined or failed. Settings were saved; activation remains controlled by OpenClaw.`);
1906
+ return fail(`Agent Approve v${options.version} is installed, but OpenClaw ${action} did not complete. Review the host output above. If the Gateway is still reloading, wait for it to finish, then run: openclaw plugins ${action} openclaw. Activation remains controlled by OpenClaw.`);
1903
1907
  return {
1904
1908
  success: true,
1905
1909
  label: `Agent Approve plugin v${options.version} (conversation access included)`
@@ -3312,9 +3316,31 @@ async function copyHookScripts(hooksDir, token, files, options) {
3312
3316
  return { downloaded, failed, optionalFailed };
3313
3317
  }
3314
3318
 
3319
+ // src/host-command.ts
3320
+ import { execFileSync } from "node:child_process";
3321
+ var HOST_COMMAND_TIMEOUT_MS = 30000;
3322
+ var PACKAGE_INSTALL_TIMEOUT_MS = 180000;
3323
+ function runHostCommand(file, args, options = {}) {
3324
+ const timeout = options.timeoutMs ?? HOST_COMMAND_TIMEOUT_MS;
3325
+ const interactive = options.interactive === true && process.stdin.isTTY === true && process.stdout.isTTY === true;
3326
+ try {
3327
+ return execFileSync(file, args, {
3328
+ encoding: "utf8",
3329
+ stdio: interactive ? "inherit" : ["ignore", "pipe", "pipe"],
3330
+ timeout: interactive ? undefined : timeout,
3331
+ killSignal: "SIGTERM",
3332
+ shell: process.platform === "win32" && file === "pi"
3333
+ }) ?? "";
3334
+ } catch (error) {
3335
+ if (error.code === "ETIMEDOUT") {
3336
+ throw new Error(`${file} ${args.slice(0, 3).join(" ")} timed out after ${timeout / 1000}s. Setup may be partial; check the host before retrying.`);
3337
+ }
3338
+ throw error;
3339
+ }
3340
+ }
3341
+
3315
3342
  // src/hermes-follow-up.ts
3316
- import { execFileSync } from "child_process";
3317
- function enableHermesFollowUp(profile, run = (file, args) => execFileSync(file, args, { stdio: "pipe", timeout: 30000 })) {
3343
+ function enableHermesFollowUp(profile, run = (file, args) => runHostCommand(file, args)) {
3318
3344
  if (!/^[a-z0-9][a-z0-9_-]{0,63}$/.test(profile)) {
3319
3345
  throw new Error("Invalid Hermes profile name");
3320
3346
  }
@@ -3408,7 +3434,7 @@ Configured on this computer: ${ready.join(", ")}. Nothing was changed.`);
3408
3434
  }
3409
3435
 
3410
3436
  // src/cli.ts
3411
- var VERSION = "0.1.56";
3437
+ var VERSION = "0.2.0";
3412
3438
  function getApiUrl() {
3413
3439
  return process.env.AGENTAPPROVE_API || "https://api.agentapprove.com";
3414
3440
  }
@@ -4032,7 +4058,7 @@ function detectInstalledAgents() {
4032
4058
  installed.push(id);
4033
4059
  } else {
4034
4060
  try {
4035
- execSync("pi --version", { stdio: "ignore" });
4061
+ runHostCommand("pi", ["--version"], { timeoutMs: 5000 });
4036
4062
  installed.push(id);
4037
4063
  } catch {}
4038
4064
  }
@@ -4041,7 +4067,7 @@ function detectInstalledAgents() {
4041
4067
  installed.push(id);
4042
4068
  } else {
4043
4069
  try {
4044
- execSync("hermes --version", { stdio: "ignore" });
4070
+ runHostCommand("hermes", ["--version"], { timeoutMs: 5000 });
4045
4071
  installed.push(id);
4046
4072
  } catch {}
4047
4073
  }
@@ -5695,13 +5721,13 @@ function readPiPinnedSpec() {
5695
5721
  }
5696
5722
  function installPiPluginViaCli() {
5697
5723
  try {
5698
- execSync(`pi install ${PI_PLUGIN_SPEC}`, { stdio: "pipe" });
5724
+ runHostCommand("pi", ["install", PI_PLUGIN_SPEC], { timeoutMs: PACKAGE_INSTALL_TIMEOUT_MS });
5699
5725
  const pinnedSpec = readPiPinnedSpec();
5700
5726
  if (pinnedSpec !== null && pinnedSpec !== PI_PLUGIN_SPEC) {
5701
5727
  const manualFix = `Fix manually with: pi remove npm:@agentapprove/pi && pi install ${PI_PLUGIN_SPEC}`;
5702
5728
  try {
5703
- execSync("pi remove npm:@agentapprove/pi", { stdio: "pipe" });
5704
- execSync(`pi install ${PI_PLUGIN_SPEC}`, { stdio: "pipe" });
5729
+ runHostCommand("pi", ["remove", "npm:@agentapprove/pi"]);
5730
+ runHostCommand("pi", ["install", PI_PLUGIN_SPEC], { timeoutMs: PACKAGE_INSTALL_TIMEOUT_MS });
5705
5731
  } catch (err) {
5706
5732
  return {
5707
5733
  success: false,
@@ -5729,7 +5755,7 @@ function installPiPluginViaCli() {
5729
5755
  }
5730
5756
  function removePiPluginViaCli() {
5731
5757
  try {
5732
- execSync("pi remove npm:@agentapprove/pi", { stdio: "pipe" });
5758
+ runHostCommand("pi", ["remove", "npm:@agentapprove/pi"]);
5733
5759
  return { success: true };
5734
5760
  } catch (err) {
5735
5761
  return {
@@ -5744,10 +5770,7 @@ var HERMES_PLUGIN_DIR = join(homedir(), ".hermes", "plugins", "agentapprove");
5744
5770
  function findPython() {
5745
5771
  for (const candidate of ["python3.12", "python3.11", "python3.10", "python3"]) {
5746
5772
  try {
5747
- const out = execSync(`${candidate} -c "import sys; print('%d.%d' % sys.version_info[:2])"`, {
5748
- encoding: "utf-8",
5749
- stdio: ["pipe", "pipe", "ignore"]
5750
- }).trim();
5773
+ const out = runHostCommand(candidate, ["-c", "import sys; print('%d.%d' % sys.version_info[:2])"], { timeoutMs: 5000 }).trim();
5751
5774
  const [major, minor] = out.split(".").map(Number);
5752
5775
  if (major === 3 && minor >= 10) {
5753
5776
  return { command: candidate, version: out };
@@ -5823,7 +5846,8 @@ async function downloadHermesBundle(apiUrl, apiVersion, token) {
5823
5846
  let response;
5824
5847
  try {
5825
5848
  response = await fetch(url.toString(), {
5826
- headers: { Authorization: `Bearer ${token}` }
5849
+ headers: { Authorization: `Bearer ${token}` },
5850
+ signal: AbortSignal.timeout(90000)
5827
5851
  });
5828
5852
  } catch (err) {
5829
5853
  return { ok: false, error: `Network error downloading ${HERMES_BUNDLE_FILENAME}: ${err instanceof Error ? err.message : String(err)}` };
@@ -5882,10 +5906,7 @@ function validateExtractedTree(root) {
5882
5906
  }
5883
5907
  function hermesDepsAlreadyInstalled(pythonCommand) {
5884
5908
  try {
5885
- execSync(`${pythonCommand} -c "import cryptography, httpx"`, {
5886
- stdio: "pipe",
5887
- timeout: 5000
5888
- });
5909
+ runHostCommand(pythonCommand, ["-c", "import cryptography, httpx"], { timeoutMs: 5000 });
5889
5910
  return true;
5890
5911
  } catch {
5891
5912
  return false;
@@ -5893,7 +5914,7 @@ function hermesDepsAlreadyInstalled(pythonCommand) {
5893
5914
  }
5894
5915
  function uvAvailable() {
5895
5916
  try {
5896
- execSync("uv --version", { stdio: "pipe", timeout: 5000 });
5917
+ runHostCommand("uv", ["--version"], { timeoutMs: 5000 });
5897
5918
  return true;
5898
5919
  } catch {
5899
5920
  return false;
@@ -5914,7 +5935,7 @@ ${message}`;
5914
5935
  function installHermesDepsAdaptive(pythonCommand, deps) {
5915
5936
  const depsArg = deps.map((d) => `"${d}"`).join(" ");
5916
5937
  try {
5917
- execSync(`${pythonCommand} -m pip install --user --quiet ${depsArg}`, { stdio: "pipe" });
5938
+ runHostCommand(pythonCommand, ["-m", "pip", "install", "--user", "--quiet", ...deps], { timeoutMs: PACKAGE_INSTALL_TIMEOUT_MS });
5918
5939
  return { ok: true };
5919
5940
  } catch (pipErr) {
5920
5941
  if (!isExternallyManagedError(pipErr)) {
@@ -5931,7 +5952,7 @@ function installHermesDepsAdaptive(pythonCommand, deps) {
5931
5952
  }
5932
5953
  const uvCmd = `uv pip install --system --break-system-packages --python ${pythonCommand} --quiet ${depsArg}`;
5933
5954
  try {
5934
- execSync(uvCmd, { stdio: "pipe" });
5955
+ runHostCommand("uv", ["pip", "install", "--system", "--break-system-packages", "--python", pythonCommand, "--quiet", ...deps], { timeoutMs: PACKAGE_INSTALL_TIMEOUT_MS });
5935
5956
  return { ok: true };
5936
5957
  } catch (uvErr) {
5937
5958
  return {
@@ -5967,7 +5988,7 @@ function stageHermesBundle(bytes, targetDir) {
5967
5988
  try {
5968
5989
  writeFileSync(tarballPath, bytes);
5969
5990
  try {
5970
- execSync(`tar -xzf "${tarballPath}" -C "${tmpDir}" --no-same-owner --no-same-permissions`, { stdio: "pipe" });
5991
+ runHostCommand("tar", ["-xzf", tarballPath, "-C", tmpDir, "--no-same-owner", "--no-same-permissions"]);
5971
5992
  } catch (err) {
5972
5993
  return { success: false, error: `tar extract failed: ${err instanceof Error ? err.message : String(err)}` };
5973
5994
  }
@@ -6021,20 +6042,21 @@ function stageHermesBundle(bytes, targetDir) {
6021
6042
  function enableHermesPluginForProfile(profile) {
6022
6043
  try {
6023
6044
  enableHermesFollowUp(profile);
6024
- execSync(hermesEnableCmd(profile), { stdio: "pipe" });
6045
+ runHostCommand("hermes", [...profile === HERMES_DEFAULT_PROFILE ? [] : ["-p", profile], "plugins", "enable", "agentapprove"], { interactive: true, timeoutMs: PACKAGE_INSTALL_TIMEOUT_MS });
6025
6046
  return { success: true };
6026
6047
  } catch (err) {
6027
6048
  return { success: false, error: err instanceof Error ? err.message : String(err) };
6028
6049
  }
6029
6050
  }
6030
6051
  async function installHermesPluginViaCli() {
6052
+ v2.info("Hermes: checking CLI and Python");
6031
6053
  try {
6032
- execSync("hermes --version", { stdio: "pipe" });
6033
- } catch {
6054
+ runHostCommand("hermes", ["--version"]);
6055
+ } catch (err) {
6034
6056
  return {
6035
6057
  success: false,
6036
6058
  label: "Agent Approve plugin",
6037
- error: "Hermes CLI not found on PATH. Install Hermes from https://hermes-agent.nousresearch.com first, then re-run npx agentapprove."
6059
+ error: `Could not check Hermes CLI: ${err instanceof Error ? err.message : String(err)}. Run hermes --version to diagnose, then retry setup.`
6038
6060
  };
6039
6061
  }
6040
6062
  const python = findPython();
@@ -6053,6 +6075,7 @@ async function installHermesPluginViaCli() {
6053
6075
  error: "Missing API token. Pair your phone first by running `npx agentapprove` and completing the QR scan."
6054
6076
  };
6055
6077
  }
6078
+ v2.info("Hermes: downloading and verifying the plugin (up to 90 seconds)");
6056
6079
  const download = await downloadHermesBundle(cfg.apiUrl, cfg.apiVersion, cfg.token);
6057
6080
  if (!download.ok) {
6058
6081
  return { success: false, label: "Agent Approve plugin", error: download.error };
@@ -6069,7 +6092,9 @@ async function installHermesPluginViaCli() {
6069
6092
  if (!staged.success) {
6070
6093
  return { success: false, label: "Agent Approve plugin", error: staged.error };
6071
6094
  }
6095
+ v2.info("Hermes: checking Python dependencies");
6072
6096
  if (!hermesDepsAlreadyInstalled(python.command)) {
6097
+ v2.info("Hermes: installing Python dependencies (up to 3 minutes per attempt)");
6073
6098
  const depsResult = installHermesDepsAdaptive(python.command, HERMES_PIP_DEPS);
6074
6099
  if (!depsResult.ok) {
6075
6100
  return {
@@ -6079,6 +6104,7 @@ async function installHermesPluginViaCli() {
6079
6104
  };
6080
6105
  }
6081
6106
  }
6107
+ v2.info("Hermes: enabling the plugin; review any permissions requested by Hermes");
6082
6108
  const enabled = enableHermesPluginForProfile(HERMES_DEFAULT_PROFILE);
6083
6109
  if (!enabled.success) {
6084
6110
  return {
@@ -6102,7 +6128,7 @@ ${stdout}`.toLowerCase();
6102
6128
  }
6103
6129
  function disableHermesPluginForProfile(profile) {
6104
6130
  try {
6105
- execSync(hermesDisableCmd(profile), { stdio: "pipe" });
6131
+ runHostCommand("hermes", [...profile === HERMES_DEFAULT_PROFILE ? [] : ["-p", profile], "plugins", "disable", "agentapprove"]);
6106
6132
  return { success: true };
6107
6133
  } catch (err) {
6108
6134
  if (isHermesDisableNoOp(err)) {
@@ -6158,9 +6184,9 @@ function listHermesProfiles() {
6158
6184
  }
6159
6185
  async function syncHermesProfiles(targetProfiles) {
6160
6186
  try {
6161
- execSync("hermes --version", { stdio: "pipe" });
6162
- } catch {
6163
- return { ok: false, results: [], error: "Hermes CLI not found on PATH. Install Hermes first, then re-run." };
6187
+ runHostCommand("hermes", ["--version"]);
6188
+ } catch (err) {
6189
+ return { ok: false, results: [], error: `Could not check Hermes CLI: ${err instanceof Error ? err.message : String(err)}. Run hermes --version to diagnose, then retry setup.` };
6164
6190
  }
6165
6191
  const python = findPython();
6166
6192
  if (!python) {
@@ -6183,6 +6209,7 @@ async function syncHermesProfiles(targetProfiles) {
6183
6209
  };
6184
6210
  }
6185
6211
  if (!hermesDepsAlreadyInstalled(python.command)) {
6212
+ v2.info("Hermes: installing Python dependencies (up to 3 minutes per attempt)");
6186
6213
  const depsResult = installHermesDepsAdaptive(python.command, HERMES_PIP_DEPS);
6187
6214
  if (!depsResult.ok) {
6188
6215
  return { ok: false, results: [], error: `Could not install Python runtime deps: ${depsResult.error}` };
@@ -7002,14 +7029,17 @@ Timestamped backups will be created.`);
7002
7029
  const agent = AGENTS[agentId];
7003
7030
  const spinner = _2();
7004
7031
  const spinnerMsg = agentId === "pi" ? `Installing ${agent.name} extension` : agentId === "openclaw" || agentId === "hermes" ? `Installing ${agent.name} plugin` : `Configuring ${agent.name}`;
7005
- if (agentId !== "openclaw")
7032
+ const hostSetup = ["openclaw", "pi", "hermes"].includes(agentId);
7033
+ if (hostSetup)
7034
+ v2.step(spinnerMsg);
7035
+ else
7006
7036
  spinner.start(spinnerMsg);
7007
7037
  const result = await installHooksForAgent(agentId, hooksDir, installMode);
7008
7038
  if (result.success) {
7009
7039
  const installedHookNames = result.hooks.join(", ");
7010
7040
  const backupMsg = result.backupPath ? source_default.dim(` (backup created)`) : "";
7011
7041
  const agentName = source_default.cyan(agent.name);
7012
- if (agentId === "openclaw")
7042
+ if (hostSetup)
7013
7043
  v2.success(`${agentName}: ${installedHookNames}${backupMsg}`);
7014
7044
  else
7015
7045
  spinner.stop(`${agentName}: ${installedHookNames}${backupMsg}`);
@@ -7051,14 +7081,15 @@ Timestamped backups will be created.`);
7051
7081
  }
7052
7082
  } else {
7053
7083
  failedSetupAgents.add(agentId);
7054
- if (agentId === "openclaw")
7084
+ if (hostSetup)
7055
7085
  v2.error(`${agent.name} configuration failed`);
7056
7086
  else
7057
7087
  spinner.stop(`${agent.name} configuration failed`);
7058
7088
  if (agentId === "openclaw") {
7059
- v2.warn(`Could not install ${OPENCLAW_PLUGIN_SPEC} via OpenClaw CLI.
7089
+ v2.warn(`OpenClaw setup did not finish.
7060
7090
  ` + ` Error: ${result.error || "unknown"}
7061
- ` + ` Install manually: openclaw plugins install ${OPENCLAW_PLUGIN_SPEC}
7091
+ ` + ` Check plugin status: openclaw plugins inspect openclaw
7092
+ ` + ` If the package is missing: openclaw plugins install ${OPENCLAW_PLUGIN_SPEC}
7062
7093
  ` + ` Then re-run: npx agentapprove`);
7063
7094
  } else if (agentId === "pi") {
7064
7095
  v2.warn(`Could not install ${PI_PLUGIN_SPEC} via Pi.
@@ -7195,9 +7226,9 @@ async function profilesCommand() {
7195
7226
  console.clear();
7196
7227
  pe(source_default.bgCyan.black(" Agent Approve ") + source_default.gray(" Hermes Profiles"));
7197
7228
  try {
7198
- execSync("hermes --version", { stdio: "pipe" });
7199
- } catch {
7200
- v2.error("Hermes CLI not found on PATH. Install Hermes first, then re-run.");
7229
+ runHostCommand("hermes", ["--version"]);
7230
+ } catch (err) {
7231
+ v2.error(`Could not check Hermes CLI: ${err instanceof Error ? err.message : String(err)}. Run hermes --version to diagnose, then retry setup.`);
7201
7232
  ge("No changes made.");
7202
7233
  process.exit(1);
7203
7234
  }
@@ -7261,16 +7292,15 @@ async function profilesCommand() {
7261
7292
  process.exit(0);
7262
7293
  }
7263
7294
  if (toSync.length > 0) {
7264
- const s = _2();
7265
7295
  const verb = toInstall.length && toUpdate.length ? "Installing/updating" : toUpdate.length ? "Updating" : "Installing";
7266
- s.start(`${verb} Agent Approve in ${toSync.length} profile(s)…`);
7296
+ v2.step(`${verb} Agent Approve in ${toSync.length} profile(s)…`);
7267
7297
  const sync = await syncHermesProfiles(toSync);
7268
7298
  if (sync.results.length === 0) {
7269
- s.stop(source_default.red(`Failed: ${sync.error ?? "unknown error"}`));
7299
+ v2.error(`Failed: ${sync.error ?? "unknown error"}`);
7270
7300
  ge("No changes made.");
7271
7301
  process.exit(1);
7272
7302
  }
7273
- s.stop(sync.ok ? "Done" : "Done (some profiles failed)");
7303
+ v2.info(sync.ok ? "Done" : "Done (some profiles failed)");
7274
7304
  for (const r of sync.results) {
7275
7305
  const action = toUpdate.includes(r.profile) ? "updated to" : "installed";
7276
7306
  if (r.success)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentapprove",
3
- "version": "0.1.56",
3
+ "version": "0.2.0",
4
4
  "description": "AI agent observability and control from your iPhone or Apple Watch",
5
5
  "type": "module",
6
6
  "bin": {