agentapprove 0.2.5 → 0.2.6
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 +11 -1
- package/dist/cli.js +263 -107
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -149,7 +149,7 @@ agentapprove --no-e2e # Skip end-to-end encryption setup
|
|
|
149
149
|
|
|
150
150
|
- Node.js 18+
|
|
151
151
|
- macOS, Linux, or Windows (with Git Bash / Git for Windows)
|
|
152
|
-
- System tools: `curl`, `jq`, `openssl` (
|
|
152
|
+
- System tools: `curl`, `jq`, `openssl` (Git Bash includes curl and openssl; the installer offers to install jq separately with Winget)
|
|
153
153
|
- Agent Approve iOS app and active subscription ($14.99/month, 7-day free trial)
|
|
154
154
|
|
|
155
155
|
## Links
|
|
@@ -201,3 +201,13 @@ Rerun the Agent Approve installer and select OpenClaw. Confirm that
|
|
|
201
201
|
`before_tool_call`. Restart your running gateway to load the updated plugin.
|
|
202
202
|
Keep existing settings and data while repairing; removing the plugin's config
|
|
203
203
|
entry does not complete its pending migration.
|
|
204
|
+
|
|
205
|
+
### Windows PowerShell
|
|
206
|
+
|
|
207
|
+
Install Node.js LTS and Git for Windows, then close all Terminal windows and reopen PowerShell. Use a normal terminal in the same Windows account as your coding agents; individual package installers may request administrator approval.
|
|
208
|
+
|
|
209
|
+
```powershell
|
|
210
|
+
npx.cmd agentapprove@latest
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Use `npx.cmd` for the commands in this guide on Windows. It works without changing PowerShell's execution policy. If the wizard installs a dependency, restart your coding agent apps before testing hooks so they inherit the updated PATH.
|
package/dist/cli.js
CHANGED
|
@@ -2204,13 +2204,62 @@ function applyPairKeyPlan(plan, agentApproveDir, deps) {
|
|
|
2204
2204
|
return { backedUp };
|
|
2205
2205
|
}
|
|
2206
2206
|
|
|
2207
|
+
// src/platform-command.ts
|
|
2208
|
+
import { statSync as statSync2 } from "node:fs";
|
|
2209
|
+
import { win32 } from "node:path";
|
|
2210
|
+
function hostInvocation(file, args, platform = process.platform, env = process.env) {
|
|
2211
|
+
if (platform !== "win32")
|
|
2212
|
+
return { file, args };
|
|
2213
|
+
const value = (key) => Object.entries(env).find(([k]) => k.toLowerCase() === key.toLowerCase())?.[1] ?? "";
|
|
2214
|
+
const directories = win32.isAbsolute(file) ? [""] : value("PATH").split(";").filter(Boolean);
|
|
2215
|
+
const extensions = win32.extname(file) ? [""] : (value("PATHEXT") || ".COM;.EXE;.BAT;.CMD").split(";");
|
|
2216
|
+
let resolved;
|
|
2217
|
+
for (const directory of directories) {
|
|
2218
|
+
for (const extension of extensions) {
|
|
2219
|
+
const candidate = directory ? win32.join(directory.replace(/^"|"$/g, ""), file + extension) : file + extension;
|
|
2220
|
+
try {
|
|
2221
|
+
if (statSync2(candidate).isFile()) {
|
|
2222
|
+
resolved = candidate;
|
|
2223
|
+
break;
|
|
2224
|
+
}
|
|
2225
|
+
} catch {}
|
|
2226
|
+
}
|
|
2227
|
+
if (resolved)
|
|
2228
|
+
break;
|
|
2229
|
+
}
|
|
2230
|
+
if (!resolved)
|
|
2231
|
+
return { file, args };
|
|
2232
|
+
if (!/\.(cmd|bat)$/i.test(resolved))
|
|
2233
|
+
return { file: resolved, args };
|
|
2234
|
+
const quote = (part) => {
|
|
2235
|
+
if (/[&|<>^%"!\r\n\0]/.test(part) || part.endsWith("\\"))
|
|
2236
|
+
throw new Error("Unsupported shell character in Windows host command.");
|
|
2237
|
+
return `"${part}"`;
|
|
2238
|
+
};
|
|
2239
|
+
const command = [resolved, ...args].map(quote).join(" ");
|
|
2240
|
+
return {
|
|
2241
|
+
file: win32.join(value("SystemRoot") || "C:\\Windows", "System32", "cmd.exe"),
|
|
2242
|
+
args: ["/d", "/s", "/c", `"${command}"`],
|
|
2243
|
+
windowsVerbatimArguments: true
|
|
2244
|
+
};
|
|
2245
|
+
}
|
|
2246
|
+
function cliInvocation(platform = process.platform) {
|
|
2247
|
+
return `${platform === "win32" ? "npx.cmd" : "npx"} agentapprove`;
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2207
2250
|
// src/openclaw-install.ts
|
|
2208
2251
|
import { spawnSync } from "node:child_process";
|
|
2209
2252
|
import { isDeepStrictEqual } from "node:util";
|
|
2210
2253
|
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.";
|
|
2211
2254
|
function runOpenClaw(args) {
|
|
2212
|
-
|
|
2213
|
-
|
|
2255
|
+
try {
|
|
2256
|
+
const command = hostInvocation("openclaw", args);
|
|
2257
|
+
const result = spawnSync(command.file, command.args, { stdio: "inherit", windowsVerbatimArguments: command.windowsVerbatimArguments });
|
|
2258
|
+
return !result.error && result.status === 0;
|
|
2259
|
+
} catch (error) {
|
|
2260
|
+
console.error(`Could not launch OpenClaw: ${error instanceof Error ? error.message : String(error)}`);
|
|
2261
|
+
return false;
|
|
2262
|
+
}
|
|
2214
2263
|
}
|
|
2215
2264
|
function isExpectedOpenClawActive(report, version) {
|
|
2216
2265
|
if (!report || typeof report !== "object")
|
|
@@ -2223,11 +2272,12 @@ function isExpectedOpenClawActive(report, version) {
|
|
|
2223
2272
|
}
|
|
2224
2273
|
function readOpenClawActive(version) {
|
|
2225
2274
|
try {
|
|
2226
|
-
const
|
|
2275
|
+
const command = hostInvocation("openclaw", ["gateway", "call", "plugins.list", "--json"]);
|
|
2276
|
+
const result = spawnSync(command.file, command.args, {
|
|
2227
2277
|
encoding: "utf8",
|
|
2228
2278
|
stdio: ["ignore", "pipe", "pipe"],
|
|
2229
2279
|
timeout: 15000,
|
|
2230
|
-
|
|
2280
|
+
windowsVerbatimArguments: command.windowsVerbatimArguments
|
|
2231
2281
|
});
|
|
2232
2282
|
return !result.error && result.status === 0 && isExpectedOpenClawActive(JSON.parse(result.stdout), version);
|
|
2233
2283
|
} catch {
|
|
@@ -2880,7 +2930,7 @@ var source_default = chalk;
|
|
|
2880
2930
|
|
|
2881
2931
|
// src/cli.ts
|
|
2882
2932
|
var import_qrcode_terminal = __toESM(require_main(), 1);
|
|
2883
|
-
import { existsSync as existsSync5, readFileSync as readFileSync3, writeFileSync as writeFileSync2, mkdirSync as mkdirSync3, mkdtempSync, copyFileSync as copyFileSync2, renameSync as renameSync4, readdirSync as readdirSync2, statSync as
|
|
2933
|
+
import { existsSync as existsSync5, readFileSync as readFileSync3, writeFileSync as writeFileSync2, mkdirSync as mkdirSync3, mkdtempSync, copyFileSync as copyFileSync2, renameSync as renameSync4, readdirSync as readdirSync2, statSync as statSync4, lstatSync as lstatSync2, realpathSync as realpathSync2, rmSync as rmSync3 } from "fs";
|
|
2884
2934
|
import { homedir, hostname, platform, tmpdir } from "os";
|
|
2885
2935
|
import { join as join3, dirname as dirname4, sep as sep2 } from "path";
|
|
2886
2936
|
import { execSync, spawnSync as spawnSync2 } from "child_process";
|
|
@@ -3427,8 +3477,7 @@ function getExistingKeyActionOptions(e2eRequired) {
|
|
|
3427
3477
|
if (!e2eRequired) {
|
|
3428
3478
|
options.push({
|
|
3429
3479
|
value: "disable",
|
|
3430
|
-
label: "Disable E2E encryption"
|
|
3431
|
-
hint: "events visible on web dashboard"
|
|
3480
|
+
label: "Disable E2E encryption"
|
|
3432
3481
|
});
|
|
3433
3482
|
}
|
|
3434
3483
|
return options;
|
|
@@ -3584,7 +3633,7 @@ function validBackgroundFilters(content) {
|
|
|
3584
3633
|
|
|
3585
3634
|
// src/copy-hook-scripts.ts
|
|
3586
3635
|
import { join as pathJoin } from "path";
|
|
3587
|
-
var HOOK_INTEGRITY_FAILURE = "integrity check failed; run the latest installer:
|
|
3636
|
+
var HOOK_INTEGRITY_FAILURE = "integrity check failed; run the latest installer: " + cliInvocation() + "@latest";
|
|
3588
3637
|
function retryDelay(response) {
|
|
3589
3638
|
const value = response.headers.get("Retry-After")?.trim();
|
|
3590
3639
|
if (!value)
|
|
@@ -3718,6 +3767,7 @@ async function copyHookScripts(hooksDir, token, files, options) {
|
|
|
3718
3767
|
// src/hook-manifest.generated.ts
|
|
3719
3768
|
var HOOK_SCRIPT_SHA256 = {
|
|
3720
3769
|
"antigravity-hook.sh": [
|
|
3770
|
+
"79793d7b262ada35ca5767d3fe9cddd2feb705b5f992baa5f2f7d870a3addb05",
|
|
3721
3771
|
"1f096235ba308087ad578aabdf2217f3e4f8ba336626ef2b70188f8dd2f24ac9"
|
|
3722
3772
|
],
|
|
3723
3773
|
"background-filter.js": [
|
|
@@ -3746,6 +3796,7 @@ var HOOK_SCRIPT_SHA256 = {
|
|
|
3746
3796
|
"dc2d906e448d277be0f9b5e1cd1b0bddadd9d5d86f6a0012ffa6e63cb38fb906"
|
|
3747
3797
|
],
|
|
3748
3798
|
"claude-stop.sh": [
|
|
3799
|
+
"867cd434a63a8eb36c29518e1f1f285afe5213843be302fab62ef30ace66f02e",
|
|
3749
3800
|
"158629503c11d44d3864c6a4ea5448e5743b4cacc11f0246ef604ce5a4c27830"
|
|
3750
3801
|
],
|
|
3751
3802
|
"claude-subagent-start.sh": [
|
|
@@ -3767,6 +3818,7 @@ var HOOK_SCRIPT_SHA256 = {
|
|
|
3767
3818
|
"b14351394abeab95d047d6843e34d52e33758eef1f4f129a31efe6334858db53"
|
|
3768
3819
|
],
|
|
3769
3820
|
"codex-stop.sh": [
|
|
3821
|
+
"e030dbba31533855bb69fef0328fcb07ca9f7e33aadd01aa289adaa346a489d7",
|
|
3770
3822
|
"6c46b605b482a474205d850cec28f35ced74796beedf1f2647a1268fcfa7d45e"
|
|
3771
3823
|
],
|
|
3772
3824
|
"codex-subagent-start.sh": [
|
|
@@ -3779,6 +3831,7 @@ var HOOK_SCRIPT_SHA256 = {
|
|
|
3779
3831
|
"0e8886fa08e6c5529721f6e94907c9bad6c32e97c1f4827e2ef5270f349cce4f"
|
|
3780
3832
|
],
|
|
3781
3833
|
"common.sh": [
|
|
3834
|
+
"6a69bce9934ca60b523298387f07f1159958c112d2897a2c1011326e3235ace3",
|
|
3782
3835
|
"2c0407f51dfe95cf1bcc6c705a268ea461ab044e2808539339ad222a2b5ade2b",
|
|
3783
3836
|
"e9878d93113337bd49ccfbc34f57aed38f0f93dad77eebe5b981adfe10ef82f2"
|
|
3784
3837
|
],
|
|
@@ -3819,6 +3872,7 @@ var HOOK_SCRIPT_SHA256 = {
|
|
|
3819
3872
|
"23895ab6d2ecaa9fe278b3fb9d53b21418edd7cfac5116d53bd659d4ecbabae3"
|
|
3820
3873
|
],
|
|
3821
3874
|
"cursor-stop.sh": [
|
|
3875
|
+
"7c699d07b577b66683aea7602c9008186ec5c62ddc2ee5fa6a70c0534e408b34",
|
|
3822
3876
|
"052c9de32572aeb8b5c9d27313cd20a27790a2250ce3c9aeb8e7356a755c5de3"
|
|
3823
3877
|
],
|
|
3824
3878
|
"cursor-subagent-start.sh": [
|
|
@@ -3858,6 +3912,7 @@ var HOOK_SCRIPT_SHA256 = {
|
|
|
3858
3912
|
"5d1113f25accd644c82e21bbc7efc56739f549b6b8227bd8874afc6500112b46"
|
|
3859
3913
|
],
|
|
3860
3914
|
"gemini-stop.sh": [
|
|
3915
|
+
"6460c3e132244224ca3900ef52538feea3c25adcfc2d1f243894cff95394cda2",
|
|
3861
3916
|
"da82707cd945b2307efa0a137e54f3dc9a630b2d02a5056d676ad49712f8534f"
|
|
3862
3917
|
],
|
|
3863
3918
|
"github-error.sh": [
|
|
@@ -3879,6 +3934,7 @@ var HOOK_SCRIPT_SHA256 = {
|
|
|
3879
3934
|
"505f44ed4ca6345b8e9ff8a328198ed6141d4774a630821b984ab5cf4c3954ff"
|
|
3880
3935
|
],
|
|
3881
3936
|
"github-stop.sh": [
|
|
3937
|
+
"a27d04f42a80503a3b6b0c86894a1934cb769fd2d74dc44d57a00aa69e8a7f9c",
|
|
3882
3938
|
"07f2d802700cf7ace009207aaa3f9c96e4e5943c022faa9601d9b85277e50fa4"
|
|
3883
3939
|
],
|
|
3884
3940
|
"github-subagent-start.sh": [
|
|
@@ -3894,9 +3950,11 @@ var HOOK_SCRIPT_SHA256 = {
|
|
|
3894
3950
|
"a222c9f656da5c9b0c6cb9998ddb6dd07608cabacef2931d542d68b04075632b"
|
|
3895
3951
|
],
|
|
3896
3952
|
"openhands-hook.sh": [
|
|
3953
|
+
"43f92e40dccca1ad9770274395e4c02f72f4d8fedff741f74efba72077ba1b45",
|
|
3897
3954
|
"28cacd77360c53fdb7b095403dfc43c7b7cf83ff718ac85f7f1a9042652bd8c0"
|
|
3898
3955
|
],
|
|
3899
3956
|
"windsurf-hook.sh": [
|
|
3957
|
+
"03514b6ad9e5af38d66c4c1d3a66d6131fade4e171699d699a13a9de7ef822fb",
|
|
3900
3958
|
"b7e85df3b6188cd1dfd6b2eb904185e41b627e077a265eaa6bb88a804323b47d"
|
|
3901
3959
|
]
|
|
3902
3960
|
};
|
|
@@ -3909,13 +3967,15 @@ function runHostCommand(file, args, options = {}) {
|
|
|
3909
3967
|
const timeout = options.timeoutMs ?? HOST_COMMAND_TIMEOUT_MS;
|
|
3910
3968
|
const interactive = options.interactive === true && process.stdin.isTTY === true && process.stdout.isTTY === true;
|
|
3911
3969
|
try {
|
|
3912
|
-
|
|
3970
|
+
const command = hostInvocation(file, args);
|
|
3971
|
+
const spawnOptions = {
|
|
3972
|
+
windowsVerbatimArguments: command.windowsVerbatimArguments,
|
|
3913
3973
|
encoding: "utf8",
|
|
3914
3974
|
stdio: interactive ? "inherit" : ["ignore", "pipe", "pipe"],
|
|
3915
3975
|
timeout: interactive ? undefined : timeout,
|
|
3916
|
-
killSignal: "SIGTERM"
|
|
3917
|
-
|
|
3918
|
-
|
|
3976
|
+
killSignal: "SIGTERM"
|
|
3977
|
+
};
|
|
3978
|
+
return execFileSync(command.file, command.args, spawnOptions) ?? "";
|
|
3919
3979
|
} catch (error) {
|
|
3920
3980
|
if (error.code === "ETIMEDOUT") {
|
|
3921
3981
|
throw new Error(`${file} ${args.slice(0, 3).join(" ")} timed out after ${timeout / 1000}s. Setup may be partial; check the host before retrying.`);
|
|
@@ -3964,6 +4024,52 @@ function ensureHermesHookTimeout(profile, run = runHostCommand) {
|
|
|
3964
4024
|
run("hermes", [...prefix, "config", "set", TIMEOUT_KEY, String(HERMES_HOST_HOOK_TIMEOUT_SECONDS)]);
|
|
3965
4025
|
}
|
|
3966
4026
|
|
|
4027
|
+
// src/dependency-recovery.ts
|
|
4028
|
+
async function verifyDependencies(options) {
|
|
4029
|
+
while (true) {
|
|
4030
|
+
options.refresh();
|
|
4031
|
+
const missing = options.missing();
|
|
4032
|
+
if (!missing.length)
|
|
4033
|
+
return "verified";
|
|
4034
|
+
const choice = await options.choose(missing);
|
|
4035
|
+
if (choice !== "retry")
|
|
4036
|
+
return choice;
|
|
4037
|
+
}
|
|
4038
|
+
}
|
|
4039
|
+
|
|
4040
|
+
// src/windows-path.ts
|
|
4041
|
+
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
4042
|
+
import { win32 as win322 } from "node:path";
|
|
4043
|
+
function mergeWindowsPath(current, additions, env = process.env) {
|
|
4044
|
+
const expand = (text) => text.replace(/%([^%]+)%/g, (match, key) => Object.entries(env).find(([name]) => name.toLowerCase() === key.toLowerCase())?.[1] ?? match);
|
|
4045
|
+
const entries = current.split(";").filter(Boolean);
|
|
4046
|
+
const normalized = (entry) => entry.replace(/^"|"$/g, "").replace(/[\\/]+$/, "").toLowerCase();
|
|
4047
|
+
const seen = new Set(entries.map(normalized));
|
|
4048
|
+
for (const entry of additions.flatMap((value) => expand(value).split(";")).map((s) => s.trim()).filter(Boolean)) {
|
|
4049
|
+
if (/%[^%]+%/.test(entry) || seen.has(normalized(entry)))
|
|
4050
|
+
continue;
|
|
4051
|
+
entries.push(entry);
|
|
4052
|
+
seen.add(normalized(entry));
|
|
4053
|
+
}
|
|
4054
|
+
return entries.join(";");
|
|
4055
|
+
}
|
|
4056
|
+
function refreshWindowsPath() {
|
|
4057
|
+
if (process.platform !== "win32")
|
|
4058
|
+
return;
|
|
4059
|
+
const additions = [];
|
|
4060
|
+
try {
|
|
4061
|
+
const script = "$paths = @([Environment]::GetEnvironmentVariable('Path', 'Machine'), [Environment]::GetEnvironmentVariable('Path', 'User')); [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes((ConvertTo-Json -Compress -InputObject $paths)))";
|
|
4062
|
+
const output = execFileSync2(win322.join(process.env.SystemRoot || "C:\\Windows", "System32", "WindowsPowerShell", "v1.0", "powershell.exe"), ["-NoProfile", "-NonInteractive", "-Command", script], { encoding: "utf8", timeout: 1e4, stdio: ["ignore", "pipe", "ignore"] });
|
|
4063
|
+
const paths = JSON.parse(Buffer.from(output.trim(), "base64").toString("utf8"));
|
|
4064
|
+
if (Array.isArray(paths))
|
|
4065
|
+
additions.push(...paths.filter((path) => typeof path === "string"));
|
|
4066
|
+
} catch {}
|
|
4067
|
+
if (process.env.LOCALAPPDATA)
|
|
4068
|
+
additions.push(`${process.env.LOCALAPPDATA}\\Microsoft\\WinGet\\Links`);
|
|
4069
|
+
const key = Object.keys(process.env).find((key) => key.toLowerCase() === "path") || "Path";
|
|
4070
|
+
process.env[key] = mergeWindowsPath(process.env[key] || "", additions);
|
|
4071
|
+
}
|
|
4072
|
+
|
|
3967
4073
|
// src/pairing-api-url.ts
|
|
3968
4074
|
function looksLikeHostedAgentApproveApi(baseUrl) {
|
|
3969
4075
|
try {
|
|
@@ -3986,6 +4092,7 @@ function resolvePairingApiBaseUrl(options) {
|
|
|
3986
4092
|
}
|
|
3987
4093
|
|
|
3988
4094
|
// src/setup-check.ts
|
|
4095
|
+
import { accessSync, constants, statSync as statSync3 } from "node:fs";
|
|
3989
4096
|
function checkHookConfiguration(agent, config, hooksKey, hooks, mode, fileReady, expectedCommand = (file) => `~/.agentapprove/hooks/${file}`) {
|
|
3990
4097
|
const result = (status, reason) => ({ agent, status, reason });
|
|
3991
4098
|
const expected = hooks.filter((h) => !h.isPlugin && !(mode === "observe" && h.isApprovalHook));
|
|
@@ -4019,7 +4126,7 @@ function hookCommands(value) {
|
|
|
4019
4126
|
function installOutro(integrations) {
|
|
4020
4127
|
const ready = integrations.filter((item) => item.status === "ready").map((item) => item.agent);
|
|
4021
4128
|
if (!ready.length) {
|
|
4022
|
-
return
|
|
4129
|
+
return `No integration is ready yet. Fix the problems listed above, then run ${cliInvocation()} again. Nothing on your phone is waiting on this.`;
|
|
4023
4130
|
}
|
|
4024
4131
|
return "";
|
|
4025
4132
|
}
|
|
@@ -4030,12 +4137,14 @@ function formatNextSteps(steps) {
|
|
|
4030
4137
|
}
|
|
4031
4138
|
function checkSummary(integrations) {
|
|
4032
4139
|
if (!integrations.length) {
|
|
4033
|
-
return { lines: [
|
|
4140
|
+
return { lines: [`No integrations found. Run ${cliInvocation()} to install one.`], failed: true };
|
|
4034
4141
|
}
|
|
4035
4142
|
const lines = integrations.map((item) => ` ${item.agent}: ${item.status} (${item.reason})`);
|
|
4143
|
+
for (const item of integrations.filter((item) => item.status !== "ready"))
|
|
4144
|
+
lines.push(integrationDiagnostic(item));
|
|
4036
4145
|
const ready = integrations.filter((item) => item.status === "ready").map((item) => item.agent);
|
|
4037
4146
|
if (!ready.length) {
|
|
4038
|
-
lines.push(
|
|
4147
|
+
lines.push(`No integration is ready. Repair the problems above with ${cliInvocation()}, then run this again.`);
|
|
4039
4148
|
return { lines, failed: true };
|
|
4040
4149
|
}
|
|
4041
4150
|
lines.push(`
|
|
@@ -4043,9 +4152,31 @@ Configured on this computer: ${ready.join(", ")}. Nothing was changed.`);
|
|
|
4043
4152
|
lines.push("This checks configuration on this computer only. Open a new session in one of these agents and give it a normal task to see activity on your phone.");
|
|
4044
4153
|
return { lines, failed: false };
|
|
4045
4154
|
}
|
|
4155
|
+
function hookFileReady(path, platform = process.platform) {
|
|
4156
|
+
try {
|
|
4157
|
+
const stat = statSync3(path);
|
|
4158
|
+
if (!stat.isFile() || stat.size === 0)
|
|
4159
|
+
return false;
|
|
4160
|
+
accessSync(path, constants.R_OK);
|
|
4161
|
+
return platform === "win32" || !path.endsWith(".sh") || (stat.mode & 73) !== 0;
|
|
4162
|
+
} catch {
|
|
4163
|
+
return false;
|
|
4164
|
+
}
|
|
4165
|
+
}
|
|
4166
|
+
function integrationDiagnostic(item, invocation = cliInvocation()) {
|
|
4167
|
+
const reasons = {
|
|
4168
|
+
missing_files: "A required hook or encryption key file is missing, empty, or unreadable. Run setup again to repair it.",
|
|
4169
|
+
missing_dependency: "A required shell dependency (curl, jq, or openssl) could not be found. Install the missing dependency, restart Terminal and your agent app, then retry.",
|
|
4170
|
+
not_configured: "The required hooks or plugin are not registered. Run setup again and select this agent.",
|
|
4171
|
+
invalid_config: "The configuration could not be read or setup did not finish. Review the setup errors above and retry.",
|
|
4172
|
+
disabled: "This integration is disabled. Run setup when you want to enable it.",
|
|
4173
|
+
manual_step: "A manual setup step remains. Follow the instructions for this agent above."
|
|
4174
|
+
};
|
|
4175
|
+
return `${item.agent}: ${reasons[item.reason] ?? item.reason} Check again with ${invocation} check.`;
|
|
4176
|
+
}
|
|
4046
4177
|
|
|
4047
4178
|
// src/cli.ts
|
|
4048
|
-
var VERSION = "0.2.
|
|
4179
|
+
var VERSION = "0.2.6";
|
|
4049
4180
|
function getApiUrl() {
|
|
4050
4181
|
return process.env.AGENTAPPROVE_API || "https://api.agentapprove.com";
|
|
4051
4182
|
}
|
|
@@ -4755,7 +4886,7 @@ function describeE2EEnabled(enabled) {
|
|
|
4755
4886
|
if (enabled) {
|
|
4756
4887
|
return "Event content is encrypted between this computer and your devices.";
|
|
4757
4888
|
}
|
|
4758
|
-
return "Event content
|
|
4889
|
+
return "Event content is not end-to-end encrypted.";
|
|
4759
4890
|
}
|
|
4760
4891
|
function describeDebugLogging(enabled) {
|
|
4761
4892
|
if (enabled) {
|
|
@@ -4862,14 +4993,14 @@ async function confirmUninstallPlan(mode, plan) {
|
|
|
4862
4993
|
message: "Delete E2E keys and rotation metadata? You may lose access to encrypted local history on this machine."
|
|
4863
4994
|
});
|
|
4864
4995
|
if (lD(firstKeyConfirm) || !firstKeyConfirm) {
|
|
4865
|
-
v2.warn("Purge cancelled. Run `
|
|
4996
|
+
v2.warn("Purge cancelled. Run `" + cliInvocation() + " uninstall` if you want to keep local keys and config.");
|
|
4866
4997
|
return false;
|
|
4867
4998
|
}
|
|
4868
4999
|
const secondKeyConfirm = await ce({
|
|
4869
5000
|
message: "Final confirmation: permanently delete the E2E keys and rotation metadata?"
|
|
4870
5001
|
});
|
|
4871
5002
|
if (lD(secondKeyConfirm) || !shouldDeleteCryptoMaterial(true, firstKeyConfirm === true, secondKeyConfirm === true)) {
|
|
4872
|
-
v2.warn("Purge cancelled. Run `
|
|
5003
|
+
v2.warn("Purge cancelled. Run `" + cliInvocation() + " uninstall` if you want to keep local keys and config.");
|
|
4873
5004
|
return false;
|
|
4874
5005
|
}
|
|
4875
5006
|
}
|
|
@@ -4973,7 +5104,7 @@ function discoverE2EKeys() {
|
|
|
4973
5104
|
const hex = readFileSync3(currentPath, "utf-8").trim();
|
|
4974
5105
|
if (hex.length === 64) {
|
|
4975
5106
|
const keyId = createHash3("sha256").update(Buffer.from(hex, "hex")).digest("hex").slice(0, 8);
|
|
4976
|
-
keys.push({ keyId, keyHex: hex, path: currentPath, isCurrent: true, modifiedAt:
|
|
5107
|
+
keys.push({ keyId, keyHex: hex, path: currentPath, isCurrent: true, modifiedAt: statSync4(currentPath).mtime });
|
|
4977
5108
|
}
|
|
4978
5109
|
} catch {}
|
|
4979
5110
|
}
|
|
@@ -4985,7 +5116,7 @@ function discoverE2EKeys() {
|
|
|
4985
5116
|
const hex = readFileSync3(fullPath, "utf-8").trim();
|
|
4986
5117
|
if (hex.length === 64) {
|
|
4987
5118
|
const keyId = createHash3("sha256").update(Buffer.from(hex, "hex")).digest("hex").slice(0, 8);
|
|
4988
|
-
keys.push({ keyId, keyHex: hex, path: fullPath, isCurrent: false, modifiedAt:
|
|
5119
|
+
keys.push({ keyId, keyHex: hex, path: fullPath, isCurrent: false, modifiedAt: statSync4(fullPath).mtime });
|
|
4989
5120
|
}
|
|
4990
5121
|
} catch {}
|
|
4991
5122
|
}
|
|
@@ -5334,7 +5465,7 @@ AGENTAPPROVE_FAIL_BEHAVIOR=${config.failBehavior || "ask"}
|
|
|
5334
5465
|
${renderPreservedEnvSection(preserved)}
|
|
5335
5466
|
# Settings in this file sync from your Agent Approve account settings, so
|
|
5336
5467
|
# manual edits here are overwritten on the next config sync.
|
|
5337
|
-
# To change settings, run:
|
|
5468
|
+
# To change settings, run: ${cliInvocation()} install
|
|
5338
5469
|
`;
|
|
5339
5470
|
writePrivateFile(envPath, content);
|
|
5340
5471
|
}
|
|
@@ -6065,7 +6196,7 @@ codex_hooks = true`;
|
|
|
6065
6196
|
return [
|
|
6066
6197
|
"Install the Agent Approve plugin for Hermes:",
|
|
6067
6198
|
"",
|
|
6068
|
-
"
|
|
6199
|
+
" " + cliInvocation() + " # automatic: download + verify + extract + enable",
|
|
6069
6200
|
"",
|
|
6070
6201
|
`Manual: download ${HERMES_BUNDLE_FILENAME} from your Agent Approve API,`,
|
|
6071
6202
|
`verify SHA-256 matches ${HERMES_BUNDLE_SHA256.slice(0, 16)}…, extract into`,
|
|
@@ -6091,11 +6222,11 @@ function describeDownloadTerminalFailure(kind) {
|
|
|
6091
6222
|
case "rate_limited":
|
|
6092
6223
|
return "Hook download limit reached. Please wait a few minutes, then rerun the installer. Existing hook files were kept.";
|
|
6093
6224
|
case "token_expired":
|
|
6094
|
-
return "Hook download stopped: your saved token has expired. Run `
|
|
6225
|
+
return "Hook download stopped: your saved token has expired. Run `" + cliInvocation() + " refresh` to re-pair, or run the installer again to choose Refresh / Re-pair.";
|
|
6095
6226
|
case "token_invalid":
|
|
6096
|
-
return "Hook download stopped: your saved token is no longer valid. Run `
|
|
6227
|
+
return "Hook download stopped: your saved token is no longer valid. Run `" + cliInvocation() + " pair` to pair this computer again.";
|
|
6097
6228
|
case "scope_denied":
|
|
6098
|
-
return "Hook download stopped: your saved token cannot download hooks. Run `
|
|
6229
|
+
return "Hook download stopped: your saved token cannot download hooks. Run `" + cliInvocation() + " pair` to pair this computer again.";
|
|
6099
6230
|
case "validation_unavailable":
|
|
6100
6231
|
return "Hook download stopped: Agent Approve could not validate your token right now. Please try again in a few minutes.";
|
|
6101
6232
|
case "network_blocked":
|
|
@@ -6115,11 +6246,12 @@ async function copyHookScripts2(hooksDir, token, files, options = {}) {
|
|
|
6115
6246
|
}
|
|
6116
6247
|
function readOpenClawInstalledVersion() {
|
|
6117
6248
|
try {
|
|
6118
|
-
const
|
|
6249
|
+
const command = hostInvocation("openclaw", ["plugins", "inspect", "openclaw", "--json"]);
|
|
6250
|
+
const result = spawnSync2(command.file, command.args, {
|
|
6119
6251
|
encoding: "utf8",
|
|
6120
6252
|
stdio: ["ignore", "pipe", "pipe"],
|
|
6121
6253
|
timeout: 30000,
|
|
6122
|
-
|
|
6254
|
+
windowsVerbatimArguments: command.windowsVerbatimArguments
|
|
6123
6255
|
});
|
|
6124
6256
|
if (result.status === 0) {
|
|
6125
6257
|
const metadata = JSON.parse(result.stdout);
|
|
@@ -6174,7 +6306,9 @@ function readOpenCodeInstalledVersion() {
|
|
|
6174
6306
|
}
|
|
6175
6307
|
function installOpenCodePluginViaCli() {
|
|
6176
6308
|
try {
|
|
6177
|
-
const
|
|
6309
|
+
const command = hostInvocation("opencode", ["plugin", OPENCODE_PLUGIN_SPEC, "--global", "--force"]);
|
|
6310
|
+
const result = spawnSync2(command.file, command.args, {
|
|
6311
|
+
windowsVerbatimArguments: command.windowsVerbatimArguments,
|
|
6178
6312
|
encoding: "utf8",
|
|
6179
6313
|
stdio: ["ignore", "pipe", "pipe"]
|
|
6180
6314
|
});
|
|
@@ -6582,7 +6716,7 @@ async function installHermesPluginViaCli() {
|
|
|
6582
6716
|
return {
|
|
6583
6717
|
success: false,
|
|
6584
6718
|
label: "Agent Approve plugin",
|
|
6585
|
-
error: "Python 3.10+ not found on PATH. Install Python 3.10 or newer (e.g. `brew install python@3.12`) and re-run
|
|
6719
|
+
error: "Python 3.10+ not found on PATH. Install Python 3.10 or newer (e.g. `brew install python@3.12`) and re-run " + cliInvocation() + "."
|
|
6586
6720
|
};
|
|
6587
6721
|
}
|
|
6588
6722
|
const cfg = readInstallerConfig();
|
|
@@ -6590,7 +6724,7 @@ async function installHermesPluginViaCli() {
|
|
|
6590
6724
|
return {
|
|
6591
6725
|
success: false,
|
|
6592
6726
|
label: "Agent Approve plugin",
|
|
6593
|
-
error: "Missing API token. Pair your phone first by running `
|
|
6727
|
+
error: "Missing API token. Pair your phone first by running `" + cliInvocation() + "` and completing the QR scan."
|
|
6594
6728
|
};
|
|
6595
6729
|
}
|
|
6596
6730
|
v2.info("Hermes: downloading and verifying the plugin (up to 90 seconds)");
|
|
@@ -6712,7 +6846,7 @@ async function syncHermesProfiles(targetProfiles) {
|
|
|
6712
6846
|
}
|
|
6713
6847
|
const cfg = readInstallerConfig();
|
|
6714
6848
|
if (!cfg.token) {
|
|
6715
|
-
return { ok: false, results: [], error: "Missing API token. Run `
|
|
6849
|
+
return { ok: false, results: [], error: "Missing API token. Run `" + cliInvocation() + "` to pair first." };
|
|
6716
6850
|
}
|
|
6717
6851
|
const download = await downloadHermesBundle(cfg.apiUrl, cfg.apiVersion, cfg.token);
|
|
6718
6852
|
if (!download.ok) {
|
|
@@ -6932,25 +7066,45 @@ async function checkSystemDependencies() {
|
|
|
6932
7066
|
}
|
|
6933
7067
|
if (action === "install" && combinedCommand) {
|
|
6934
7068
|
const installSpinner = _2();
|
|
6935
|
-
|
|
7069
|
+
if (process.platform === "win32")
|
|
7070
|
+
v2.info("Installing dependencies. Follow any package-manager prompts below.");
|
|
7071
|
+
else
|
|
7072
|
+
installSpinner.start("Installing dependencies");
|
|
6936
7073
|
try {
|
|
6937
|
-
execSync(combinedCommand, { stdio: "pipe" });
|
|
6938
|
-
|
|
6939
|
-
|
|
6940
|
-
if (stillMissing.length > 0) {
|
|
6941
|
-
v2.warn(`Could not verify: ${stillMissing.map((d) => d.name).join(", ")}. Continuing anyway.`);
|
|
6942
|
-
}
|
|
7074
|
+
execSync(combinedCommand, { stdio: process.platform === "win32" ? "inherit" : "pipe" });
|
|
7075
|
+
if (process.platform !== "win32")
|
|
7076
|
+
installSpinner.stop("Package manager finished");
|
|
6943
7077
|
} catch (err) {
|
|
6944
|
-
|
|
6945
|
-
|
|
6946
|
-
v2.
|
|
6947
|
-
|
|
6948
|
-
|
|
6949
|
-
|
|
6950
|
-
|
|
6951
|
-
|
|
6952
|
-
|
|
7078
|
+
if (process.platform !== "win32")
|
|
7079
|
+
installSpinner.stop("Package manager did not complete");
|
|
7080
|
+
v2.error(`Dependency installation did not complete: ${err instanceof Error ? err.message : "unknown error"}`);
|
|
7081
|
+
}
|
|
7082
|
+
const verification = await verifyDependencies({
|
|
7083
|
+
refresh: refreshWindowsPath,
|
|
7084
|
+
missing: () => requiredMissing.filter((d) => !checkCommand(d.name)).map((d) => d.name),
|
|
7085
|
+
choose: async (missing) => {
|
|
7086
|
+
v2.warn(`Still unavailable to hook scripts: ${missing.join(", ")}.`);
|
|
7087
|
+
if (process.platform === "win32")
|
|
7088
|
+
v2.info(`If installation succeeded, close all Terminal windows, reopen PowerShell, and run ${cliInvocation()} again. Restart your coding agent app too.`);
|
|
7089
|
+
const choice = await le({
|
|
7090
|
+
message: "How would you like to continue?",
|
|
7091
|
+
options: [
|
|
7092
|
+
{ value: "retry", label: "Retry dependency check" },
|
|
7093
|
+
{ value: "continue", label: "Continue anyway", hint: "hooks may not work correctly" },
|
|
7094
|
+
{ value: "exit", label: "Exit and fix dependencies" }
|
|
7095
|
+
]
|
|
7096
|
+
});
|
|
7097
|
+
return lD(choice) ? "exit" : choice;
|
|
6953
7098
|
}
|
|
7099
|
+
});
|
|
7100
|
+
if (verification === "exit") {
|
|
7101
|
+
he("Install the missing dependencies and try again.");
|
|
7102
|
+
process.exit(1);
|
|
7103
|
+
}
|
|
7104
|
+
if (verification === "verified") {
|
|
7105
|
+
v2.success("Required dependencies verified.");
|
|
7106
|
+
if (process.platform === "win32")
|
|
7107
|
+
v2.info("Restart your coding agent apps before testing hooks so they can find the newly installed dependencies.");
|
|
6954
7108
|
}
|
|
6955
7109
|
}
|
|
6956
7110
|
}
|
|
@@ -7248,7 +7402,7 @@ Monitor activity, enforce policy, and approve with a tap.`, "About");
|
|
|
7248
7402
|
}
|
|
7249
7403
|
}
|
|
7250
7404
|
if (!useE2E) {
|
|
7251
|
-
v2.info("E2E encryption disabled
|
|
7405
|
+
v2.info("E2E encryption disabled.");
|
|
7252
7406
|
}
|
|
7253
7407
|
const e2eKeyId = e2eUserKey ? createHash3("sha256").update(Buffer.from(e2eUserKey, "hex")).digest("hex").slice(0, 8) : undefined;
|
|
7254
7408
|
if (setupProfile === "customize") {
|
|
@@ -7603,7 +7757,7 @@ Timestamped backups will be created.`);
|
|
|
7603
7757
|
`);
|
|
7604
7758
|
nextSteps.push(`Add Agent Approve to your other Hermes profiles. Only the default one was set up.
|
|
7605
7759
|
` + `${lines}
|
|
7606
|
-
` +
|
|
7760
|
+
` + (" Run: " + cliInvocation() + " profiles"));
|
|
7607
7761
|
}
|
|
7608
7762
|
} catch {}
|
|
7609
7763
|
}
|
|
@@ -7618,12 +7772,12 @@ Timestamped backups will be created.`);
|
|
|
7618
7772
|
` + ` Error: ${result.error || "unknown"}
|
|
7619
7773
|
` + ` Check plugin status: openclaw plugins inspect openclaw
|
|
7620
7774
|
` + ` If the package is missing: openclaw plugins install ${OPENCLAW_PLUGIN_SPEC}
|
|
7621
|
-
` +
|
|
7775
|
+
` + (" Then re-run: " + cliInvocation() + ""));
|
|
7622
7776
|
} else if (agentId === "pi") {
|
|
7623
7777
|
v2.warn(`Could not install ${PI_PLUGIN_SPEC} via Pi.
|
|
7624
7778
|
` + ` Error: ${result.error || "unknown"}
|
|
7625
7779
|
` + ` Install manually: pi install ${PI_PLUGIN_SPEC}
|
|
7626
|
-
` +
|
|
7780
|
+
` + (" Then re-run: " + cliInvocation() + ""));
|
|
7627
7781
|
} else if (agentId === "hermes") {
|
|
7628
7782
|
v2.warn(`Could not install Agent Approve plugin for Hermes.
|
|
7629
7783
|
` + ` Error: ${result.error || "unknown"}
|
|
@@ -7638,7 +7792,7 @@ Timestamped backups will be created.`);
|
|
|
7638
7792
|
` + ` 7. hermes config set plugins.hook_callback_timeout 600
|
|
7639
7793
|
` + ` (For a named profile add -p <profile> after hermes; skip if already 0/unlimited.)
|
|
7640
7794
|
` + ` 8. hermes plugins enable agentapprove
|
|
7641
|
-
` +
|
|
7795
|
+
` + (" Then re-run: " + cliInvocation() + ""));
|
|
7642
7796
|
} else if (result.error) {
|
|
7643
7797
|
v2.warn(`${agent.name} was not set up.
|
|
7644
7798
|
` + ` ${result.error}`);
|
|
@@ -7655,22 +7809,28 @@ Timestamped backups will be created.`);
|
|
|
7655
7809
|
message: "Press Enter when done"
|
|
7656
7810
|
});
|
|
7657
7811
|
}
|
|
7658
|
-
const integrationChecks = inspectSetup(selectedAgents).map((item) => failedSetupAgents.has(item.agent) ? { ...item, status: "failed", reason: "invalid_config" } : item);
|
|
7812
|
+
const integrationChecks = inspectSetup(selectedAgents).map((item) => failedSetupAgents.has(item.agent) ? { ...item, status: "failed", reason: item.status === "ready" ? "invalid_config" : item.reason } : item);
|
|
7659
7813
|
writePrivateFile(join3(getAgentApproveDir(), "setup-agents.json"), JSON.stringify(selectedAgents));
|
|
7660
7814
|
const modeDesc = hasE2EKey ? installMode === "observe" ? source_default.cyan("E2E Observe Mode") + " - All events encrypted, no approval hooks" : source_default.green("E2E Approval Mode") + " - Commands sent via encrypted channel for policy evaluation" : "Standard mode (no E2E keys found)";
|
|
7661
7815
|
me(`Mode: ${modeDesc}
|
|
7662
7816
|
|
|
7663
|
-
|
|
7664
|
-
|
|
7665
|
-
|
|
7666
|
-
|
|
7667
|
-
|
|
7668
|
-
|
|
7669
|
-
|
|
7670
|
-
|
|
7817
|
+
${cliInvocation()} pair Link a new iOS device
|
|
7818
|
+
${cliInvocation()} check Re-check this computer's configuration (local only, changes nothing)
|
|
7819
|
+
${cliInvocation()} status Show current configuration
|
|
7820
|
+
${cliInvocation()} profiles Manage Agent Approve across Hermes profiles
|
|
7821
|
+
${cliInvocation()} disable Deregister hooks/plugins, keep local state
|
|
7822
|
+
${cliInvocation()} uninstall Remove hooks/plugins and keep local state
|
|
7823
|
+
${cliInvocation()} purge Remove hooks/plugins and delete local state
|
|
7824
|
+
${cliInvocation()} restore Restore original configs`, "Useful commands");
|
|
7671
7825
|
if (nextSteps.length > 0) {
|
|
7672
7826
|
me(formatNextSteps(nextSteps), "Next steps");
|
|
7673
7827
|
}
|
|
7828
|
+
for (const item of integrationChecks) {
|
|
7829
|
+
if (item.status === "ready")
|
|
7830
|
+
v2.success(`${item.agent}: configuration verified on this computer.`);
|
|
7831
|
+
else
|
|
7832
|
+
v2.warn(integrationDiagnostic(item));
|
|
7833
|
+
}
|
|
7674
7834
|
ge(installOutro(integrationChecks) || "Open Agent Approve on your iPhone and finish setting up.");
|
|
7675
7835
|
}
|
|
7676
7836
|
function inspectSetup(agentIds) {
|
|
@@ -7725,13 +7885,10 @@ function inspectSetup(agentIds) {
|
|
|
7725
7885
|
}
|
|
7726
7886
|
if (agentId === "codex" && !/codex_hooks\s*=\s*true/.test(readFileSync3(join3(homedir(), ".codex/config.toml"), "utf8")))
|
|
7727
7887
|
return result("failed", "not_configured");
|
|
7728
|
-
const filesReady = (file) =>
|
|
7729
|
-
const path = join3(getAgentApproveDir(), "hooks", file);
|
|
7730
|
-
return existsSync5(path) && statSync2(path).size > 0 && (!file.endsWith(".sh") || (statSync2(path).mode & 73) !== 0);
|
|
7731
|
-
};
|
|
7888
|
+
const filesReady = (file) => hookFileReady(join3(getAgentApproveDir(), "hooks", file));
|
|
7732
7889
|
if (!SHARED_HOOK_FILES.filter((file) => !BACKGROUND_FILTER_FILES.includes(file)).every(filesReady))
|
|
7733
7890
|
return result("failed", "missing_files");
|
|
7734
|
-
if (spawnSync2("bash", ["-c", "command -v curl >/dev/null && command -v jq >/dev/null && command -v openssl >/dev/null"], { timeout: 5000 }).status !== 0)
|
|
7891
|
+
if (spawnSync2(process.platform === "win32" ? findGitBash() || "bash" : "bash", ["-c", "command -v curl >/dev/null && command -v jq >/dev/null && command -v openssl >/dev/null"], { timeout: 5000 }).status !== 0)
|
|
7735
7892
|
return result("failed", "missing_dependency");
|
|
7736
7893
|
if (isAntigravityAgent(agentId)) {
|
|
7737
7894
|
if (!existsSync5(join3(getAntigravityPluginRoot(agentId), "plugin.json")))
|
|
@@ -7772,7 +7929,7 @@ async function profilesCommand() {
|
|
|
7772
7929
|
}
|
|
7773
7930
|
const cfg = readInstallerConfig();
|
|
7774
7931
|
if (!cfg.token) {
|
|
7775
|
-
v2.error("Missing API token. Run `
|
|
7932
|
+
v2.error("Missing API token. Run `" + cliInvocation() + "` to pair your phone first.");
|
|
7776
7933
|
ge("No changes made.");
|
|
7777
7934
|
process.exit(1);
|
|
7778
7935
|
}
|
|
@@ -7862,11 +8019,11 @@ async function statusCommand() {
|
|
|
7862
8019
|
`));
|
|
7863
8020
|
if (existsSync5(join3(getAgentApproveDir(), DISABLED_STATE_FILENAME))) {
|
|
7864
8021
|
console.log(source_default.yellow(" Disabled: hooks and plugins are deregistered from your agents."));
|
|
7865
|
-
console.log(source_default.dim(" Run `
|
|
8022
|
+
console.log(source_default.dim(" Run `" + cliInvocation() + " enable` to restore them.\n"));
|
|
7866
8023
|
}
|
|
7867
8024
|
const envPath = join3(getAgentApproveDir(), "env");
|
|
7868
8025
|
if (!existsSync5(envPath)) {
|
|
7869
|
-
console.log(source_default.yellow(" Not configured. Run `
|
|
8026
|
+
console.log(source_default.yellow(" Not configured. Run `" + cliInvocation() + "` to set up.\n"));
|
|
7870
8027
|
return;
|
|
7871
8028
|
}
|
|
7872
8029
|
const envContent = readFileSync3(envPath, "utf-8");
|
|
@@ -7994,7 +8151,7 @@ function acquireDisabledStateMergeLock(lockPath) {
|
|
|
7994
8151
|
return true;
|
|
7995
8152
|
} catch {
|
|
7996
8153
|
try {
|
|
7997
|
-
if (Date.now() -
|
|
8154
|
+
if (Date.now() - statSync4(lockPath).mtimeMs > 1e4) {
|
|
7998
8155
|
rmSync3(lockPath, { recursive: true, force: true });
|
|
7999
8156
|
continue;
|
|
8000
8157
|
}
|
|
@@ -8019,7 +8176,7 @@ async function disableCommand() {
|
|
|
8019
8176
|
if (hasExistingRecord) {
|
|
8020
8177
|
console.log(source_default.yellow(`
|
|
8021
8178
|
Already disabled.`));
|
|
8022
|
-
console.log(source_default.dim(" Run `
|
|
8179
|
+
console.log(source_default.dim(" Run `" + cliInvocation() + " enable` to re-register hooks and plugins.\n"));
|
|
8023
8180
|
return;
|
|
8024
8181
|
}
|
|
8025
8182
|
const existingConfig = readExistingConfig();
|
|
@@ -8041,12 +8198,12 @@ async function disableCommand() {
|
|
|
8041
8198
|
}
|
|
8042
8199
|
if (records.length === 0) {
|
|
8043
8200
|
if (warnings.length > 0) {
|
|
8044
|
-
console.log(source_default.yellow("\n Disable incomplete. Fix the warnings above and re-run `
|
|
8201
|
+
console.log(source_default.yellow("\n Disable incomplete. Fix the warnings above and re-run `" + cliInvocation() + " disable`.\n"));
|
|
8045
8202
|
} else if (!existingConfig && !legacyDisabledEnv) {
|
|
8046
|
-
console.log(source_default.yellow(" Not configured. Run `
|
|
8203
|
+
console.log(source_default.yellow(" Not configured. Run `" + cliInvocation() + "` to set up.\n"));
|
|
8047
8204
|
} else {
|
|
8048
8205
|
console.log(source_default.yellow(" No Agent Approve hooks or plugins are registered."));
|
|
8049
|
-
console.log(source_default.dim(" Nothing to disable. Run `
|
|
8206
|
+
console.log(source_default.dim(" Nothing to disable. Run `" + cliInvocation() + " install` to set up agents.\n"));
|
|
8050
8207
|
}
|
|
8051
8208
|
return;
|
|
8052
8209
|
}
|
|
@@ -8086,8 +8243,8 @@ async function disableCommand() {
|
|
|
8086
8243
|
console.log(source_default.red(`
|
|
8087
8244
|
✗ Hooks and plugins were deregistered, but the restoration record could not be written:`));
|
|
8088
8245
|
console.log(source_default.red(` ${err instanceof Error ? err.message : String(err)}`));
|
|
8089
|
-
console.log(source_default.yellow(" `
|
|
8090
|
-
console.log(source_default.yellow(" Run `
|
|
8246
|
+
console.log(source_default.yellow(" `" + cliInvocation() + " enable` will not be able to restore this disable."));
|
|
8247
|
+
console.log(source_default.yellow(" Run `" + cliInvocation() + " install` when you want to re-register hooks and plugins.\n"));
|
|
8091
8248
|
return;
|
|
8092
8249
|
}
|
|
8093
8250
|
}
|
|
@@ -8102,7 +8259,7 @@ async function disableCommand() {
|
|
|
8102
8259
|
if (warnings.length > 0) {
|
|
8103
8260
|
console.log(source_default.yellow(" Some agents could not be fully disabled; see the warnings above."));
|
|
8104
8261
|
}
|
|
8105
|
-
console.log(source_default.dim(" Run `
|
|
8262
|
+
console.log(source_default.dim(" Run `" + cliInvocation() + " enable` to restore everything.\n"));
|
|
8106
8263
|
}
|
|
8107
8264
|
function disableAgent(agentId, agent, records, warnings) {
|
|
8108
8265
|
if (agentId === "pi") {
|
|
@@ -8253,7 +8410,7 @@ async function enableCommand() {
|
|
|
8253
8410
|
Already enabled.
|
|
8254
8411
|
`));
|
|
8255
8412
|
} else {
|
|
8256
|
-
console.log(source_default.yellow("\n Not configured. Run `
|
|
8413
|
+
console.log(source_default.yellow("\n Not configured. Run `" + cliInvocation() + "` to set up.\n"));
|
|
8257
8414
|
}
|
|
8258
8415
|
return;
|
|
8259
8416
|
}
|
|
@@ -8262,7 +8419,7 @@ async function enableCommand() {
|
|
|
8262
8419
|
rmSync3(statePath, { force: true });
|
|
8263
8420
|
console.log(source_default.yellow(`
|
|
8264
8421
|
The disable record was unreadable, so registrations were not restored automatically.`));
|
|
8265
|
-
console.log(source_default.dim(" Run `
|
|
8422
|
+
console.log(source_default.dim(" Run `" + cliInvocation() + " install` to re-register hooks and plugins (your pairing is kept).\n"));
|
|
8266
8423
|
return;
|
|
8267
8424
|
}
|
|
8268
8425
|
console.log(source_default.cyan(`
|
|
@@ -8274,14 +8431,14 @@ async function enableCommand() {
|
|
|
8274
8431
|
const agent = AGENTS[record.agentId];
|
|
8275
8432
|
if (!agent) {
|
|
8276
8433
|
failures.push(record);
|
|
8277
|
-
console.log(` ${source_default.yellow("⚠")} ${record.agentId}: this installer build does not know this agent. ` + "Re-run with the latest installer:
|
|
8434
|
+
console.log(` ${source_default.yellow("⚠")} ${record.agentId}: this installer build does not know this agent. ` + ("Re-run with the latest installer: " + cliInvocation() + "@latest enable"));
|
|
8278
8435
|
continue;
|
|
8279
8436
|
}
|
|
8280
8437
|
switch (record.kind) {
|
|
8281
8438
|
case "hooks": {
|
|
8282
8439
|
if (!existsSync5(hooksDir)) {
|
|
8283
8440
|
failures.push(record);
|
|
8284
|
-
console.log(` ${source_default.yellow("⚠")} ${agent.name}: ~/.agentapprove/hooks is missing. Run
|
|
8441
|
+
console.log(` ${source_default.yellow("⚠")} ${agent.name}: ~/.agentapprove/hooks is missing. Run \`${cliInvocation()} install\` to re-download hook scripts.`);
|
|
8285
8442
|
break;
|
|
8286
8443
|
}
|
|
8287
8444
|
const result = await installHooksForAgent(record.agentId, hooksDir, state.mode);
|
|
@@ -8366,7 +8523,7 @@ async function enableCommand() {
|
|
|
8366
8523
|
}
|
|
8367
8524
|
default: {
|
|
8368
8525
|
failures.push(record);
|
|
8369
|
-
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:
|
|
8526
|
+
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: " + cliInvocation() + "@latest enable"));
|
|
8370
8527
|
break;
|
|
8371
8528
|
}
|
|
8372
8529
|
}
|
|
@@ -8375,7 +8532,7 @@ async function enableCommand() {
|
|
|
8375
8532
|
const remaining = { ...state, agents: failures };
|
|
8376
8533
|
writePrivateFile(statePath, JSON.stringify(remaining, null, 2) + `
|
|
8377
8534
|
`);
|
|
8378
|
-
console.log(source_default.yellow("\n Agent Approve is partially re-enabled. Fix the warnings above and re-run `
|
|
8535
|
+
console.log(source_default.yellow("\n Agent Approve is partially re-enabled. Fix the warnings above and re-run `" + cliInvocation() + " enable`.\n"));
|
|
8379
8536
|
return;
|
|
8380
8537
|
}
|
|
8381
8538
|
rmSync3(statePath, { force: true });
|
|
@@ -8417,7 +8574,7 @@ async function performUninstall(mode) {
|
|
|
8417
8574
|
const plan = buildUninstallPlan();
|
|
8418
8575
|
if (!hasUninstallWork(mode, plan)) {
|
|
8419
8576
|
console.log(source_default.yellow(`
|
|
8420
|
-
Nothing to ${mode}. Run
|
|
8577
|
+
Nothing to ${mode}. Run \`${cliInvocation()} install\` to set up Agent Approve.
|
|
8421
8578
|
`));
|
|
8422
8579
|
return;
|
|
8423
8580
|
}
|
|
@@ -8538,7 +8695,7 @@ async function performUninstall(mode) {
|
|
|
8538
8695
|
return;
|
|
8539
8696
|
}
|
|
8540
8697
|
console.log(source_default.dim(" Local Agent Approve config, logs, hooks, backups, and E2E keys were kept."));
|
|
8541
|
-
console.log(source_default.dim(" Run `
|
|
8698
|
+
console.log(source_default.dim(" Run `" + cliInvocation() + " purge` if you want to remove all local Agent Approve traces.\n"));
|
|
8542
8699
|
}
|
|
8543
8700
|
async function uninstallCommand() {
|
|
8544
8701
|
await performUninstall("uninstall");
|
|
@@ -8570,12 +8727,12 @@ async function initRepoCommand() {
|
|
|
8570
8727
|
if (existsSync5(join3(getAgentApproveDir(), DISABLED_STATE_FILENAME))) {
|
|
8571
8728
|
console.log(source_default.yellow(`
|
|
8572
8729
|
Agent Approve is currently disabled. Hooks copied into this repo will be active.`));
|
|
8573
|
-
console.log(source_default.dim(" Run `
|
|
8730
|
+
console.log(source_default.dim(" Run `" + cliInvocation() + " enable` first if that is not what you want."));
|
|
8574
8731
|
}
|
|
8575
8732
|
if (!existsSync5(cliHooksPath)) {
|
|
8576
8733
|
console.log(source_default.yellow(`
|
|
8577
8734
|
GitHub Copilot CLI hooks not found. Run the installer first with GitHub Copilot CLI selected.`));
|
|
8578
|
-
console.log(source_default.dim(
|
|
8735
|
+
console.log(source_default.dim(" " + cliInvocation() + ` install
|
|
8579
8736
|
`));
|
|
8580
8737
|
process.exit(1);
|
|
8581
8738
|
}
|
|
@@ -8626,7 +8783,7 @@ ${source_default.dim(`Supported agents: ${SUPPORTED_AGENT_COPY}`)}
|
|
|
8626
8783
|
${source_default.dim(`Especially useful for autonomous agents like ${HIGHLIGHTED_AGENT_COPY}.`)}
|
|
8627
8784
|
|
|
8628
8785
|
${source_default.yellow("Usage:")}
|
|
8629
|
-
|
|
8786
|
+
${cliInvocation()} [command] [options]
|
|
8630
8787
|
|
|
8631
8788
|
${source_default.yellow("Commands:")}
|
|
8632
8789
|
${source_default.green("install")} Run the installation wizard (default)
|
|
@@ -8644,14 +8801,14 @@ ${source_default.yellow("Commands:")}
|
|
|
8644
8801
|
${source_default.green("help")} Show this help message
|
|
8645
8802
|
|
|
8646
8803
|
${source_default.yellow("Options:")}
|
|
8647
|
-
--no-e2e Skip
|
|
8804
|
+
--no-e2e Skip end-to-end encryption
|
|
8648
8805
|
|
|
8649
8806
|
${source_default.yellow("Examples:")}
|
|
8650
|
-
|
|
8651
|
-
|
|
8652
|
-
|
|
8653
|
-
|
|
8654
|
-
|
|
8807
|
+
${cliInvocation()} # Run installer
|
|
8808
|
+
${cliInvocation()} pair # Link a new iOS device
|
|
8809
|
+
${cliInvocation()} refresh # Get new token
|
|
8810
|
+
${cliInvocation()} status # Check status
|
|
8811
|
+
${cliInvocation()} profiles # Manage Hermes profiles
|
|
8655
8812
|
|
|
8656
8813
|
${source_default.dim("Learn more at")} ${source_default.cyan("https://agentapprove.com")}
|
|
8657
8814
|
`);
|
|
@@ -8661,7 +8818,7 @@ async function refreshCommand() {
|
|
|
8661
8818
|
pe(source_default.bgCyan.black(" Agent Approve ") + source_default.gray(" Token Refresh"));
|
|
8662
8819
|
const existingConfig = readExistingConfig();
|
|
8663
8820
|
if (!existingConfig) {
|
|
8664
|
-
v2.error('No existing configuration found. Run "
|
|
8821
|
+
v2.error('No existing configuration found. Run "' + cliInvocation() + ' install" first.');
|
|
8665
8822
|
process.exit(1);
|
|
8666
8823
|
}
|
|
8667
8824
|
const pairingApiBase = resolvePairingApiBaseUrl({
|
|
@@ -8683,10 +8840,10 @@ but if unused for 30 days they expire. Get a new one below.`, "Token Expired");
|
|
|
8683
8840
|
if (existingKey.length === 64) {
|
|
8684
8841
|
e2eUserKey = existingKey;
|
|
8685
8842
|
e2eKeyId = createHash3("sha256").update(Buffer.from(existingKey, "hex")).digest("hex").slice(0, 8);
|
|
8686
|
-
v2.info(`Refresh will reuse E2E key ${e2eKeyId}. Use "
|
|
8843
|
+
v2.info(`Refresh will reuse E2E key ${e2eKeyId}. Use "${cliInvocation()} pair" if you need to choose a different key or repair pairing on another device.`);
|
|
8687
8844
|
}
|
|
8688
8845
|
} else {
|
|
8689
|
-
v2.info('Refresh updates the token only. Use "
|
|
8846
|
+
v2.info('Refresh updates the token only. Use "' + cliInvocation() + ' pair" if you need to repair or change E2E pairing.');
|
|
8690
8847
|
}
|
|
8691
8848
|
const configSetAt = carryConfigSetAt(existingConfig.configSetAt, Math.floor(Date.now() / 1000));
|
|
8692
8849
|
const privacy = existingConfig.privacy || "full";
|
|
@@ -8736,7 +8893,7 @@ but if unused for 30 days they expire. Get a new one below.`, "Token Expired");
|
|
|
8736
8893
|
pairingSpinner.stop(`Connected! ${result.email ? `Account: ${result.email}` : ""}`);
|
|
8737
8894
|
} else {
|
|
8738
8895
|
pairingSpinner.stop("Session expired");
|
|
8739
|
-
v2.error('Session expired. Run "
|
|
8896
|
+
v2.error('Session expired. Run "' + cliInvocation() + ' refresh" to try again.');
|
|
8740
8897
|
process.exit(1);
|
|
8741
8898
|
}
|
|
8742
8899
|
const refreshPreservation = resolvePreservation({
|
|
@@ -8768,7 +8925,7 @@ but if unused for 30 days they expire. Get a new one below.`, "Token Expired");
|
|
|
8768
8925
|
updateSpinner.stop("Hooks will use the new token on their next run");
|
|
8769
8926
|
} catch (error) {
|
|
8770
8927
|
updateSpinner.stop("Warning: Could not refresh the installed hooks");
|
|
8771
|
-
v2.warn('You may need to run "
|
|
8928
|
+
v2.warn('You may need to run "' + cliInvocation() + ' install" to reconfigure hooks.');
|
|
8772
8929
|
}
|
|
8773
8930
|
ge(source_default.green("Token refreshed successfully!"));
|
|
8774
8931
|
}
|
|
@@ -8784,7 +8941,7 @@ async function pairCommand() {
|
|
|
8784
8941
|
const keys = discoverE2EKeys();
|
|
8785
8942
|
if (keys.length === 0 && !existingConfig) {
|
|
8786
8943
|
v2.error("No E2E keys or configuration found.");
|
|
8787
|
-
v2.info('Run "
|
|
8944
|
+
v2.info('Run "' + cliInvocation() + ' install" to set up Agent Approve first.');
|
|
8788
8945
|
process.exit(1);
|
|
8789
8946
|
}
|
|
8790
8947
|
const keyOptions = [];
|
|
@@ -8811,8 +8968,7 @@ async function pairCommand() {
|
|
|
8811
8968
|
});
|
|
8812
8969
|
keyOptions.push({
|
|
8813
8970
|
value: PAIR_KEY_DISABLE,
|
|
8814
|
-
label: "Disable E2E encryption"
|
|
8815
|
-
hint: "events visible on web dashboard"
|
|
8971
|
+
label: "Disable E2E encryption"
|
|
8816
8972
|
});
|
|
8817
8973
|
const skipE2E = hasFlag2("--no-e2e");
|
|
8818
8974
|
const selectedKeyId = skipE2E ? PAIR_KEY_DISABLE : await le({
|
|
@@ -8831,7 +8987,7 @@ async function pairCommand() {
|
|
|
8831
8987
|
const e2eUserKey = keyPlan.e2eUserKey;
|
|
8832
8988
|
const e2eKeyId = keyPlan.kind === "disable" ? undefined : keyPlan.e2eKeyId;
|
|
8833
8989
|
if (keyPlan.kind === "disable") {
|
|
8834
|
-
v2.info("E2E encryption will be disabled when pairing completes.
|
|
8990
|
+
v2.info("E2E encryption will be disabled when pairing completes.");
|
|
8835
8991
|
} else if (keyPlan.kind === "generate") {
|
|
8836
8992
|
v2.info(`A new key (${e2eKeyId}) will be saved when pairing completes.`);
|
|
8837
8993
|
} else {
|
|
@@ -8881,7 +9037,7 @@ async function pairCommand() {
|
|
|
8881
9037
|
}
|
|
8882
9038
|
if (!result) {
|
|
8883
9039
|
pairingSpinner.stop("Session expired");
|
|
8884
|
-
v2.error('Session expired. Run "
|
|
9040
|
+
v2.error('Session expired. Run "' + cliInvocation() + ' pair" to try again.');
|
|
8885
9041
|
process.exit(1);
|
|
8886
9042
|
}
|
|
8887
9043
|
pairingSpinner.stop(`Paired! ${result.email ? `Account: ${result.email}` : ""}`);
|
|
@@ -8925,7 +9081,7 @@ async function pairCommand() {
|
|
|
8925
9081
|
updateSpinner.stop("Hooks will use the new token on their next run");
|
|
8926
9082
|
} catch {
|
|
8927
9083
|
updateSpinner.stop("Warning: Could not refresh the installed hooks");
|
|
8928
|
-
v2.warn('You may need to run "
|
|
9084
|
+
v2.warn('You may need to run "' + cliInvocation() + ' install" to reconfigure hooks.');
|
|
8929
9085
|
}
|
|
8930
9086
|
}
|
|
8931
9087
|
ge(source_default.green(`Device paired with key ${e2eKeyId}`));
|
|
@@ -8986,7 +9142,7 @@ async function main() {
|
|
|
8986
9142
|
default:
|
|
8987
9143
|
console.log(source_default.red(`
|
|
8988
9144
|
Unknown command: ${command}`));
|
|
8989
|
-
console.log(source_default.dim(
|
|
9145
|
+
console.log(source_default.dim(" Run '" + cliInvocation() + ` help' for usage.
|
|
8990
9146
|
`));
|
|
8991
9147
|
process.exit(1);
|
|
8992
9148
|
}
|