agentapprove 0.1.44 → 0.1.46
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/dist/cli.js +170 -11
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2577,6 +2577,7 @@ function getManagedStateTargets(agentApproveDir) {
|
|
|
2577
2577
|
const reversible = [
|
|
2578
2578
|
safeJoinWithinBase(agentApproveDir, "env"),
|
|
2579
2579
|
safeJoinWithinBase(agentApproveDir, "env.disabled"),
|
|
2580
|
+
safeJoinWithinBase(agentApproveDir, "setup-agents.json"),
|
|
2580
2581
|
safeJoinWithinBase(agentApproveDir, "hook-debug.log"),
|
|
2581
2582
|
safeJoinWithinBase(agentApproveDir, "hooks"),
|
|
2582
2583
|
safeJoinWithinBase(agentApproveDir, "install.sh"),
|
|
@@ -3157,8 +3158,67 @@ function resolvePairingApiBaseUrl(options) {
|
|
|
3157
3158
|
return options.processDefaultApiUrl;
|
|
3158
3159
|
}
|
|
3159
3160
|
|
|
3161
|
+
// src/setup-check.ts
|
|
3162
|
+
function checkHookConfiguration(agent, config, hooksKey, hooks, mode, fileReady, expectedCommand = (file) => `~/.agentapprove/hooks/${file}`) {
|
|
3163
|
+
const result = (status, reason) => ({ agent, status, reason });
|
|
3164
|
+
const expected = hooks.filter((h2) => !h2.isPlugin && !(mode === "observe" && h2.isApprovalHook));
|
|
3165
|
+
if (!expected.length)
|
|
3166
|
+
return result("manual", "manual_step");
|
|
3167
|
+
const map = hooksKey ? config[hooksKey] : config;
|
|
3168
|
+
if (!map || typeof map !== "object")
|
|
3169
|
+
return result("failed", "not_configured");
|
|
3170
|
+
if (map.enabled === false)
|
|
3171
|
+
return result("failed", "disabled");
|
|
3172
|
+
for (const hook of expected) {
|
|
3173
|
+
if (!hookCommands(map[hook.name]).includes(expectedCommand(hook.file, hook.name)))
|
|
3174
|
+
return result("failed", "not_configured");
|
|
3175
|
+
if (!fileReady(hook.file))
|
|
3176
|
+
return result("failed", "missing_files");
|
|
3177
|
+
}
|
|
3178
|
+
return result("ready", "verified");
|
|
3179
|
+
}
|
|
3180
|
+
function hookCommands(value) {
|
|
3181
|
+
if (typeof value === "string")
|
|
3182
|
+
return [value];
|
|
3183
|
+
if (Array.isArray(value))
|
|
3184
|
+
return value.flatMap(hookCommands);
|
|
3185
|
+
if (!value || typeof value !== "object")
|
|
3186
|
+
return [];
|
|
3187
|
+
const item = value;
|
|
3188
|
+
if (item.enabled === false || item.disabled === true)
|
|
3189
|
+
return [];
|
|
3190
|
+
return [...hookCommands(item.command), ...hookCommands(item.bash), ...hookCommands(item.hooks)];
|
|
3191
|
+
}
|
|
3192
|
+
function installOutro(integrations) {
|
|
3193
|
+
const ready = integrations.filter((item) => item.status === "ready").map((item) => item.agent);
|
|
3194
|
+
if (!ready.length) {
|
|
3195
|
+
return "No integration is ready yet. Fix the problems listed above, then run npx agentapprove again. Nothing on your phone is waiting on this.";
|
|
3196
|
+
}
|
|
3197
|
+
return "";
|
|
3198
|
+
}
|
|
3199
|
+
function formatNextSteps(steps) {
|
|
3200
|
+
return steps.map((step, index) => `${index + 1}. ${step}`).join(`
|
|
3201
|
+
|
|
3202
|
+
`);
|
|
3203
|
+
}
|
|
3204
|
+
function checkSummary(integrations) {
|
|
3205
|
+
if (!integrations.length) {
|
|
3206
|
+
return { lines: ["No integrations found. Run npx agentapprove to install one."], failed: true };
|
|
3207
|
+
}
|
|
3208
|
+
const lines = integrations.map((item) => ` ${item.agent}: ${item.status} (${item.reason})`);
|
|
3209
|
+
const ready = integrations.filter((item) => item.status === "ready").map((item) => item.agent);
|
|
3210
|
+
if (!ready.length) {
|
|
3211
|
+
lines.push("No integration is ready. Repair the problems above with npx agentapprove, then run this again.");
|
|
3212
|
+
return { lines, failed: true };
|
|
3213
|
+
}
|
|
3214
|
+
lines.push(`
|
|
3215
|
+
Configured on this computer: ${ready.join(", ")}. Nothing was changed.`);
|
|
3216
|
+
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.");
|
|
3217
|
+
return { lines, failed: false };
|
|
3218
|
+
}
|
|
3219
|
+
|
|
3160
3220
|
// src/cli.ts
|
|
3161
|
-
var VERSION = "0.1.
|
|
3221
|
+
var VERSION = "0.1.46";
|
|
3162
3222
|
function getApiUrl() {
|
|
3163
3223
|
return process.env.AGENTAPPROVE_API || "https://api.agentapprove.com";
|
|
3164
3224
|
}
|
|
@@ -3230,14 +3290,14 @@ function getCommand() {
|
|
|
3230
3290
|
}
|
|
3231
3291
|
return filtered[0] || "install";
|
|
3232
3292
|
}
|
|
3233
|
-
var OPENCODE_PLUGIN_VERSION = "0.1.
|
|
3293
|
+
var OPENCODE_PLUGIN_VERSION = "0.1.25";
|
|
3234
3294
|
var OPENCODE_PLUGIN_SPEC = `@agentapprove/opencode@${OPENCODE_PLUGIN_VERSION}`;
|
|
3235
3295
|
var OPENCLAW_PLUGIN_VERSION = "0.2.17";
|
|
3236
3296
|
var OPENCLAW_PLUGIN_SPEC = `@agentapprove/openclaw@${OPENCLAW_PLUGIN_VERSION}`;
|
|
3237
3297
|
var PI_PLUGIN_VERSION = "0.1.13";
|
|
3238
3298
|
var PI_PLUGIN_SPEC = `npm:@agentapprove/pi@${PI_PLUGIN_VERSION}`;
|
|
3239
3299
|
var PI_STATUS_TIMEOUT_MS = 5000;
|
|
3240
|
-
var HERMES_PLUGIN_VERSION = "0.1.
|
|
3300
|
+
var HERMES_PLUGIN_VERSION = "0.1.13";
|
|
3241
3301
|
var HERMES_PIP_DEPS = ["cryptography>=44.0,<46", "httpx>=0.27,<0.29"];
|
|
3242
3302
|
var AGENTS = {
|
|
3243
3303
|
"claude-code": {
|
|
@@ -5597,7 +5657,7 @@ function removePiPluginViaCli() {
|
|
|
5597
5657
|
};
|
|
5598
5658
|
}
|
|
5599
5659
|
}
|
|
5600
|
-
var HERMES_BUNDLE_SHA256 = "
|
|
5660
|
+
var HERMES_BUNDLE_SHA256 = "4f197f366b8d7d5a8bde20106c58b4ae2abc258ac6c88d725791f50325e76f51";
|
|
5601
5661
|
var HERMES_BUNDLE_FILENAME = `agentapprove-hermes-${HERMES_PLUGIN_VERSION}.tar.gz`;
|
|
5602
5662
|
var HERMES_PLUGIN_DIR = join(homedir(), ".hermes", "plugins", "agentapprove");
|
|
5603
5663
|
function findPython() {
|
|
@@ -6685,7 +6745,9 @@ Monitor activity, enforce policy, and approve with a tap.`, "About");
|
|
|
6685
6745
|
process.exit(0);
|
|
6686
6746
|
} else if (result) {
|
|
6687
6747
|
token = result.token;
|
|
6688
|
-
|
|
6748
|
+
if (["minimal", "summary", "full"].includes(result.privacy)) {
|
|
6749
|
+
finalPrivacy = result.privacy;
|
|
6750
|
+
}
|
|
6689
6751
|
email = result.email;
|
|
6690
6752
|
apiUrl = result.apiUrl || pairingApiBase;
|
|
6691
6753
|
if (e2eUserKey && e2eKeyId) {
|
|
@@ -6797,6 +6859,8 @@ AGENTAPPROVE_E2E_MODE=${installMode}
|
|
|
6797
6859
|
he("Installation cancelled");
|
|
6798
6860
|
process.exit(0);
|
|
6799
6861
|
}
|
|
6862
|
+
const failedSetupAgents = new Set;
|
|
6863
|
+
const nextSteps = [];
|
|
6800
6864
|
if (installMethod === "auto") {
|
|
6801
6865
|
const filesToModify = [];
|
|
6802
6866
|
for (const agentId of selectedAgents) {
|
|
@@ -6865,10 +6929,12 @@ Backups will be created with timestamp`, "Files to be modified");
|
|
|
6865
6929
|
}
|
|
6866
6930
|
if (agentId === "codex") {
|
|
6867
6931
|
v2.info(source_default.dim(" Updated ~/.codex/config.toml to enable codex_hooks"));
|
|
6932
|
+
nextSteps.push(`Turn on the Codex hooks in ChatGPT settings. Codex leaves each one off until you do.
|
|
6933
|
+
` + ` https://www.agentapprove.com/docs/integrations/setup-by-agent`);
|
|
6868
6934
|
}
|
|
6869
6935
|
if (agentId === "copilot-cli") {
|
|
6870
|
-
|
|
6871
|
-
` + `
|
|
6936
|
+
nextSteps.push(`Copy the GitHub Copilot CLI hooks into each repository you want covered.
|
|
6937
|
+
` + ` cp ${agent.configPath} .github/hooks/agentapprove.json`);
|
|
6872
6938
|
}
|
|
6873
6939
|
if (agentId === "hermes") {
|
|
6874
6940
|
try {
|
|
@@ -6876,13 +6942,14 @@ Backups will be created with timestamp`, "Files to be modified");
|
|
|
6876
6942
|
if (others.length > 0) {
|
|
6877
6943
|
const lines = others.map((pr) => ` ${pr.name.padEnd(20)} ${pr.installed ? `installed v${pr.version ?? "?"}` : "not installed"}`).join(`
|
|
6878
6944
|
`);
|
|
6879
|
-
|
|
6945
|
+
nextSteps.push(`Add Agent Approve to your other Hermes profiles. Only the default one was set up.
|
|
6880
6946
|
` + `${lines}
|
|
6881
|
-
` + `
|
|
6947
|
+
` + ` Run: npx agentapprove profiles`);
|
|
6882
6948
|
}
|
|
6883
6949
|
} catch {}
|
|
6884
6950
|
}
|
|
6885
6951
|
} else {
|
|
6952
|
+
failedSetupAgents.add(agentId);
|
|
6886
6953
|
spinner.stop(`${agent.name} configuration failed`);
|
|
6887
6954
|
if (agentId === "openclaw") {
|
|
6888
6955
|
v2.warn(`Could not install ${OPENCLAW_PLUGIN_SPEC} via OpenClaw CLI.
|
|
@@ -6919,17 +6986,105 @@ Backups will be created with timestamp`, "Files to be modified");
|
|
|
6919
6986
|
message: "Press Enter when done"
|
|
6920
6987
|
});
|
|
6921
6988
|
}
|
|
6989
|
+
const integrationChecks = inspectSetup(selectedAgents).map((item) => failedSetupAgents.has(item.agent) ? { ...item, status: "failed", reason: "invalid_config" } : item);
|
|
6990
|
+
writeFileSync(join(getAgentApproveDir(), "setup-agents.json"), JSON.stringify(selectedAgents), { mode: 384 });
|
|
6922
6991
|
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)";
|
|
6923
6992
|
me(`Mode: ${modeDesc}
|
|
6924
6993
|
|
|
6925
6994
|
npx agentapprove pair Link a new iOS device
|
|
6995
|
+
npx agentapprove check Re-check this computer's configuration (local only, changes nothing)
|
|
6926
6996
|
npx agentapprove status Show current configuration
|
|
6927
6997
|
npx agentapprove profiles Manage Agent Approve across Hermes profiles
|
|
6928
6998
|
npx agentapprove disable Deregister hooks/plugins, keep local state
|
|
6929
6999
|
npx agentapprove uninstall Remove hooks/plugins and keep local state
|
|
6930
7000
|
npx agentapprove purge Remove hooks/plugins and delete local state
|
|
6931
7001
|
npx agentapprove restore Restore original configs`, "Useful commands");
|
|
6932
|
-
|
|
7002
|
+
if (nextSteps.length > 0) {
|
|
7003
|
+
me(formatNextSteps(nextSteps), "Next steps");
|
|
7004
|
+
}
|
|
7005
|
+
ge(installOutro(integrationChecks) || "Open Agent Approve on your iPhone and finish setting up.");
|
|
7006
|
+
}
|
|
7007
|
+
function inspectSetup(agentIds) {
|
|
7008
|
+
const existing = readExistingConfig();
|
|
7009
|
+
return agentIds.map((agentId) => {
|
|
7010
|
+
const agent = AGENTS[agentId];
|
|
7011
|
+
const result = (status, reason) => ({ agent: agentId, status, reason });
|
|
7012
|
+
if (!agent)
|
|
7013
|
+
return result("manual", "manual_step");
|
|
7014
|
+
if (!existing?.token)
|
|
7015
|
+
return result("failed", "not_configured");
|
|
7016
|
+
if (existsSync2(join(getAgentApproveDir(), DISABLED_STATE_FILENAME)))
|
|
7017
|
+
return result("failed", "disabled");
|
|
7018
|
+
try {
|
|
7019
|
+
if (existing.e2eEnabled !== false) {
|
|
7020
|
+
const keyPath = join(getAgentApproveDir(), "e2e-key");
|
|
7021
|
+
if (!existsSync2(keyPath))
|
|
7022
|
+
return result("failed", "missing_files");
|
|
7023
|
+
if (!/^[a-fA-F0-9]{64}$/.test(readFileSync(keyPath, "utf8").trim()))
|
|
7024
|
+
return result("failed", "invalid_config");
|
|
7025
|
+
}
|
|
7026
|
+
if (agentId === "pi" || agentId === "hermes") {
|
|
7027
|
+
const output = execSync(agentId === "pi" ? "pi list" : "hermes plugins list", { encoding: "utf8", timeout: 5000, stdio: ["ignore", "pipe", "ignore"] });
|
|
7028
|
+
const ready = agentId === "pi" ? output.includes("@agentapprove/pi") : /^.*agentapprove.*enabled/im.test(output);
|
|
7029
|
+
return result(ready ? "ready" : "failed", ready ? "verified" : "not_configured");
|
|
7030
|
+
}
|
|
7031
|
+
const configPath = agentId === "copilot-cli" ? join(process.cwd(), ".github/hooks/agentapprove.json") : agent.configPath;
|
|
7032
|
+
if (agentId === "copilot-cli" && !existsSync2(configPath))
|
|
7033
|
+
return result("manual", "manual_step");
|
|
7034
|
+
const config = readJsonConfig(configPath);
|
|
7035
|
+
if (agentId === "opencode") {
|
|
7036
|
+
const ready = Array.isArray(config.plugin) && config.plugin.some((p) => typeof p === "string" && p.includes("@agentapprove/opencode"));
|
|
7037
|
+
return result(ready ? "ready" : "failed", ready ? "verified" : "not_configured");
|
|
7038
|
+
}
|
|
7039
|
+
if (agentId === "openclaw") {
|
|
7040
|
+
const plugins = config.plugins;
|
|
7041
|
+
const ready = plugins?.enabled !== false && plugins?.entries?.openclaw?.enabled === true;
|
|
7042
|
+
return result(ready ? "ready" : "failed", ready ? "verified" : "not_configured");
|
|
7043
|
+
}
|
|
7044
|
+
if (agentId === "vscode-agent") {
|
|
7045
|
+
const registered = findInstalledVSCodeVariants().some(({ path }) => {
|
|
7046
|
+
const locations = readJsoncConfig(path)["chat.hookFilesLocations"];
|
|
7047
|
+
return locations?.["~/.agentapprove/hooks"] === true || locations?.[join(getAgentApproveDir(), "hooks")] === true;
|
|
7048
|
+
});
|
|
7049
|
+
if (!registered)
|
|
7050
|
+
return result("manual", "manual_step");
|
|
7051
|
+
}
|
|
7052
|
+
if (agentId === "codex" && !/codex_hooks\s*=\s*true/.test(readFileSync(join(homedir(), ".codex/config.toml"), "utf8")))
|
|
7053
|
+
return result("failed", "not_configured");
|
|
7054
|
+
const filesReady = (file) => {
|
|
7055
|
+
const path = join(getAgentApproveDir(), "hooks", file);
|
|
7056
|
+
return existsSync2(path) && statSync(path).size > 0 && (statSync(path).mode & 73) !== 0;
|
|
7057
|
+
};
|
|
7058
|
+
if (!SHARED_HOOK_FILES.every(filesReady))
|
|
7059
|
+
return result("failed", "missing_files");
|
|
7060
|
+
if (spawnSync("bash", ["-c", "command -v curl >/dev/null && command -v jq >/dev/null && command -v openssl >/dev/null"], { timeout: 5000 }).status !== 0)
|
|
7061
|
+
return result("failed", "missing_dependency");
|
|
7062
|
+
if (isAntigravityAgent(agentId)) {
|
|
7063
|
+
if (!existsSync2(join(getAntigravityPluginRoot(agentId), "plugin.json")))
|
|
7064
|
+
return result("failed", "missing_files");
|
|
7065
|
+
const mode = existing.e2eMode ?? "approval";
|
|
7066
|
+
const hooks = mode === "observe" ? agent.hooks.filter((h2) => h2.name !== "Stop") : agent.hooks;
|
|
7067
|
+
return checkHookConfiguration(agentId, config, "agentapprove", hooks, "approval", filesReady, (file, name) => buildAntigravityHookCommand(join(getAgentApproveDir(), "hooks", file), agentId, name, mode));
|
|
7068
|
+
}
|
|
7069
|
+
return checkHookConfiguration(agentId, config, agent.hooksKey, agent.hooks, existing.e2eMode ?? "approval", filesReady, (file) => buildHookCommand(join(getAgentApproveDir(), "hooks", file), agentId));
|
|
7070
|
+
} catch {
|
|
7071
|
+
return result("failed", "invalid_config");
|
|
7072
|
+
}
|
|
7073
|
+
});
|
|
7074
|
+
}
|
|
7075
|
+
async function checkSetupCommand() {
|
|
7076
|
+
const selectionFile = join(getAgentApproveDir(), "setup-agents.json");
|
|
7077
|
+
let agents;
|
|
7078
|
+
try {
|
|
7079
|
+
agents = JSON.parse(readFileSync(selectionFile, "utf8")).filter((id) => typeof id === "string" && (id in AGENTS));
|
|
7080
|
+
} catch {
|
|
7081
|
+
agents = detectInstalledAgents();
|
|
7082
|
+
}
|
|
7083
|
+
const { lines, failed } = checkSummary(inspectSetup(agents));
|
|
7084
|
+
for (const line of lines)
|
|
7085
|
+
(failed ? console.error : console.log)(line);
|
|
7086
|
+
if (failed)
|
|
7087
|
+
process.exitCode = 1;
|
|
6933
7088
|
}
|
|
6934
7089
|
async function profilesCommand() {
|
|
6935
7090
|
console.clear();
|
|
@@ -7745,6 +7900,7 @@ ${source_default.yellow("Commands:")}
|
|
|
7745
7900
|
${source_default.green("pair")} Link a new iOS device or repair E2E pairing
|
|
7746
7901
|
${source_default.green("refresh")} Generate a new token and reuse current pairing context
|
|
7747
7902
|
${source_default.green("init-repo")} Add GitHub Copilot CLI hooks to current repo (.github/hooks/)
|
|
7903
|
+
${source_default.green("check")} Re-check this computer's configuration (local only, changes nothing)
|
|
7748
7904
|
${source_default.green("status")} Show current configuration and installed hooks
|
|
7749
7905
|
${source_default.green("profiles")} Install/remove Agent Approve across Hermes profiles
|
|
7750
7906
|
${source_default.green("disable")} Deregister hooks/plugins from all agents, keep local state
|
|
@@ -8120,6 +8276,9 @@ async function main() {
|
|
|
8120
8276
|
case "pair":
|
|
8121
8277
|
await pairCommand();
|
|
8122
8278
|
break;
|
|
8279
|
+
case "check":
|
|
8280
|
+
await checkSetupCommand();
|
|
8281
|
+
break;
|
|
8123
8282
|
case "status":
|
|
8124
8283
|
await statusCommand();
|
|
8125
8284
|
break;
|
|
@@ -8158,7 +8317,7 @@ async function main() {
|
|
|
8158
8317
|
}
|
|
8159
8318
|
}
|
|
8160
8319
|
main().then(() => {
|
|
8161
|
-
process.exit(0);
|
|
8320
|
+
process.exit(process.exitCode ?? 0);
|
|
8162
8321
|
}).catch((error) => {
|
|
8163
8322
|
console.error(source_default.red("Error:"), error.message);
|
|
8164
8323
|
process.exit(1);
|