agentapprove 0.1.43 → 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 +266 -25
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1834,6 +1834,10 @@ var MANAGED_ENV_KEYS = new Set([
|
|
|
1834
1834
|
"AGENTAPPROVE_E2E_ENABLED",
|
|
1835
1835
|
"AGENTAPPROVE_FAIL_BEHAVIOR"
|
|
1836
1836
|
]);
|
|
1837
|
+
var ACCOUNT_SYNCED_UNMANAGED_KEYS = new Set([
|
|
1838
|
+
"AGENTAPPROVE_QUESTION_INPUT_MODE",
|
|
1839
|
+
"AGENTAPPROVE_TIMEOUT"
|
|
1840
|
+
]);
|
|
1837
1841
|
var ENV_KEY_PATTERN = /^AGENTAPPROVE_[A-Z0-9_]+$/;
|
|
1838
1842
|
function isPreservedEnvKey(key) {
|
|
1839
1843
|
const k3 = key.trim();
|
|
@@ -1853,6 +1857,58 @@ ${lines.join(`
|
|
|
1853
1857
|
`)}
|
|
1854
1858
|
`;
|
|
1855
1859
|
}
|
|
1860
|
+
function normalizeEmail(value) {
|
|
1861
|
+
const v3 = value?.trim().toLowerCase();
|
|
1862
|
+
return v3 ? v3 : undefined;
|
|
1863
|
+
}
|
|
1864
|
+
function resolvePreservation(input) {
|
|
1865
|
+
const existing = input.existing ?? undefined;
|
|
1866
|
+
if (input.continuity === "fresh" || !existing) {
|
|
1867
|
+
return { preserved: undefined, letAccountWin: false };
|
|
1868
|
+
}
|
|
1869
|
+
switch (input.continuity) {
|
|
1870
|
+
case "same-token":
|
|
1871
|
+
return { preserved: existing.preserved, letAccountWin: false };
|
|
1872
|
+
case "refresh":
|
|
1873
|
+
case "repair":
|
|
1874
|
+
case "pair": {
|
|
1875
|
+
const a3 = normalizeEmail(input.verifiedEmail);
|
|
1876
|
+
const b3 = normalizeEmail(input.pairedEmail);
|
|
1877
|
+
if (a3 && b3 && a3 === b3) {
|
|
1878
|
+
return { preserved: existing.preserved, letAccountWin: false };
|
|
1879
|
+
}
|
|
1880
|
+
return { preserved: machineLocalOnly(existing.preserved), letAccountWin: true };
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
function machineLocalOnly(preserved) {
|
|
1885
|
+
if (!preserved)
|
|
1886
|
+
return;
|
|
1887
|
+
const out = {};
|
|
1888
|
+
for (const [key, value] of Object.entries(preserved)) {
|
|
1889
|
+
if (!ACCOUNT_SYNCED_UNMANAGED_KEYS.has(key.trim()))
|
|
1890
|
+
out[key] = value;
|
|
1891
|
+
}
|
|
1892
|
+
return Object.keys(out).length > 0 ? out : undefined;
|
|
1893
|
+
}
|
|
1894
|
+
function parseConfigSetAt(value) {
|
|
1895
|
+
if (value === undefined)
|
|
1896
|
+
return;
|
|
1897
|
+
const n = Number.parseInt(value.trim(), 10);
|
|
1898
|
+
if (!Number.isFinite(n) || n < 0)
|
|
1899
|
+
return;
|
|
1900
|
+
return n;
|
|
1901
|
+
}
|
|
1902
|
+
function carryConfigSetAt(existing, now) {
|
|
1903
|
+
return existing === undefined ? now : existing;
|
|
1904
|
+
}
|
|
1905
|
+
function nextConfigSetAt(input) {
|
|
1906
|
+
if (input.existing === 0)
|
|
1907
|
+
return 0;
|
|
1908
|
+
if (input.profile === "existing-config")
|
|
1909
|
+
return carryConfigSetAt(input.existing, input.now);
|
|
1910
|
+
return input.now;
|
|
1911
|
+
}
|
|
1856
1912
|
|
|
1857
1913
|
// ../../node_modules/.bun/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
1858
1914
|
var ANSI_BACKGROUND_OFFSET = 10;
|
|
@@ -2521,6 +2577,7 @@ function getManagedStateTargets(agentApproveDir) {
|
|
|
2521
2577
|
const reversible = [
|
|
2522
2578
|
safeJoinWithinBase(agentApproveDir, "env"),
|
|
2523
2579
|
safeJoinWithinBase(agentApproveDir, "env.disabled"),
|
|
2580
|
+
safeJoinWithinBase(agentApproveDir, "setup-agents.json"),
|
|
2524
2581
|
safeJoinWithinBase(agentApproveDir, "hook-debug.log"),
|
|
2525
2582
|
safeJoinWithinBase(agentApproveDir, "hooks"),
|
|
2526
2583
|
safeJoinWithinBase(agentApproveDir, "install.sh"),
|
|
@@ -3101,8 +3158,67 @@ function resolvePairingApiBaseUrl(options) {
|
|
|
3101
3158
|
return options.processDefaultApiUrl;
|
|
3102
3159
|
}
|
|
3103
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
|
+
|
|
3104
3220
|
// src/cli.ts
|
|
3105
|
-
var VERSION = "0.1.
|
|
3221
|
+
var VERSION = "0.1.46";
|
|
3106
3222
|
function getApiUrl() {
|
|
3107
3223
|
return process.env.AGENTAPPROVE_API || "https://api.agentapprove.com";
|
|
3108
3224
|
}
|
|
@@ -3174,14 +3290,14 @@ function getCommand() {
|
|
|
3174
3290
|
}
|
|
3175
3291
|
return filtered[0] || "install";
|
|
3176
3292
|
}
|
|
3177
|
-
var OPENCODE_PLUGIN_VERSION = "0.1.
|
|
3293
|
+
var OPENCODE_PLUGIN_VERSION = "0.1.25";
|
|
3178
3294
|
var OPENCODE_PLUGIN_SPEC = `@agentapprove/opencode@${OPENCODE_PLUGIN_VERSION}`;
|
|
3179
3295
|
var OPENCLAW_PLUGIN_VERSION = "0.2.17";
|
|
3180
3296
|
var OPENCLAW_PLUGIN_SPEC = `@agentapprove/openclaw@${OPENCLAW_PLUGIN_VERSION}`;
|
|
3181
3297
|
var PI_PLUGIN_VERSION = "0.1.13";
|
|
3182
3298
|
var PI_PLUGIN_SPEC = `npm:@agentapprove/pi@${PI_PLUGIN_VERSION}`;
|
|
3183
3299
|
var PI_STATUS_TIMEOUT_MS = 5000;
|
|
3184
|
-
var HERMES_PLUGIN_VERSION = "0.1.
|
|
3300
|
+
var HERMES_PLUGIN_VERSION = "0.1.13";
|
|
3185
3301
|
var HERMES_PIP_DEPS = ["cryptography>=44.0,<46", "httpx>=0.27,<0.29"];
|
|
3186
3302
|
var AGENTS = {
|
|
3187
3303
|
"claude-code": {
|
|
@@ -3819,8 +3935,11 @@ function formatStatusValue(key, value) {
|
|
|
3819
3935
|
case "AGENTAPPROVE_RETENTION_DAYS":
|
|
3820
3936
|
return `${value} days`;
|
|
3821
3937
|
case "AGENTAPPROVE_CONFIG_SET_AT": {
|
|
3822
|
-
const timestamp =
|
|
3823
|
-
if (
|
|
3938
|
+
const timestamp = parseConfigSetAt(value);
|
|
3939
|
+
if (timestamp === 0) {
|
|
3940
|
+
return "pending account sync (applies on the next agent event)";
|
|
3941
|
+
}
|
|
3942
|
+
if (timestamp !== undefined) {
|
|
3824
3943
|
return new Date(timestamp * 1000).toLocaleString();
|
|
3825
3944
|
}
|
|
3826
3945
|
return value;
|
|
@@ -4055,8 +4174,8 @@ function readExistingConfig() {
|
|
|
4055
4174
|
config.retentionDays = value === "forever" ? 365 : parseInt(value, 10);
|
|
4056
4175
|
break;
|
|
4057
4176
|
case "AGENTAPPROVE_CONFIG_SET_AT": {
|
|
4058
|
-
const parsed =
|
|
4059
|
-
if (
|
|
4177
|
+
const parsed = parseConfigSetAt(value);
|
|
4178
|
+
if (parsed !== undefined) {
|
|
4060
4179
|
config.configSetAt = parsed;
|
|
4061
4180
|
}
|
|
4062
4181
|
break;
|
|
@@ -4451,7 +4570,7 @@ async function showPairingPresentation(params) {
|
|
|
4451
4570
|
}
|
|
4452
4571
|
function saveEnvConfig(config) {
|
|
4453
4572
|
const envPath = join(getAgentApproveDir(), "env");
|
|
4454
|
-
const configSetAt = config.configSetAt
|
|
4573
|
+
const configSetAt = config.configSetAt ?? Math.floor(Date.now() / 1000);
|
|
4455
4574
|
const retentionDisplay = `${config.retentionDays ?? 30}`;
|
|
4456
4575
|
const e2eEnabled = config.e2eEnabled !== false;
|
|
4457
4576
|
const content = `# Agent Approve Configuration
|
|
@@ -5538,7 +5657,7 @@ function removePiPluginViaCli() {
|
|
|
5538
5657
|
};
|
|
5539
5658
|
}
|
|
5540
5659
|
}
|
|
5541
|
-
var HERMES_BUNDLE_SHA256 = "
|
|
5660
|
+
var HERMES_BUNDLE_SHA256 = "4f197f366b8d7d5a8bde20106c58b4ae2abc258ac6c88d725791f50325e76f51";
|
|
5542
5661
|
var HERMES_BUNDLE_FILENAME = `agentapprove-hermes-${HERMES_PLUGIN_VERSION}.tar.gz`;
|
|
5543
5662
|
var HERMES_PLUGIN_DIR = join(homedir(), ".hermes", "plugins", "agentapprove");
|
|
5544
5663
|
function findPython() {
|
|
@@ -6276,7 +6395,7 @@ async function promptTokenRecoveryAction(preflight) {
|
|
|
6276
6395
|
const choice2 = await le({
|
|
6277
6396
|
message: "Your saved token has expired. How would you like to continue?",
|
|
6278
6397
|
options: [
|
|
6279
|
-
{ value: "refresh", label: "Refresh token", hint: "Keeps the existing encryption key
|
|
6398
|
+
{ value: "refresh", label: "Refresh token", hint: "Keeps the existing encryption key; settings resync from your account on the next event" },
|
|
6280
6399
|
{ value: "repair", label: "Pair this computer again", hint: "You can rotate the encryption key" },
|
|
6281
6400
|
{ value: "cancel", label: "Cancel", hint: "Exit the installer" }
|
|
6282
6401
|
]
|
|
@@ -6381,7 +6500,14 @@ Monitor activity, enforce policy, and approve with a tap.`, "About");
|
|
|
6381
6500
|
let failBehavior = selectedInstallConfig.failBehavior;
|
|
6382
6501
|
let installMode = selectedInstallConfig.installMode;
|
|
6383
6502
|
let useE2E = selectedInstallConfig.e2eEnabled;
|
|
6384
|
-
let configSetAt =
|
|
6503
|
+
let configSetAt = nextConfigSetAt({
|
|
6504
|
+
existing: existingConfig?.configSetAt,
|
|
6505
|
+
profile: setupProfile,
|
|
6506
|
+
now: Math.floor(Date.now() / 1000)
|
|
6507
|
+
});
|
|
6508
|
+
if (configSetAt === 0 && setupProfile !== "existing-config") {
|
|
6509
|
+
v2.info("Settings from your last pairing are still pending and will apply on the next agent event; they may replace the values chosen here.");
|
|
6510
|
+
}
|
|
6385
6511
|
if (setupProfile === "customize") {
|
|
6386
6512
|
const modeChoice = await le({
|
|
6387
6513
|
message: "Choose your security mode:",
|
|
@@ -6619,7 +6745,9 @@ Monitor activity, enforce policy, and approve with a tap.`, "About");
|
|
|
6619
6745
|
process.exit(0);
|
|
6620
6746
|
} else if (result) {
|
|
6621
6747
|
token = result.token;
|
|
6622
|
-
|
|
6748
|
+
if (["minimal", "summary", "full"].includes(result.privacy)) {
|
|
6749
|
+
finalPrivacy = result.privacy;
|
|
6750
|
+
}
|
|
6623
6751
|
email = result.email;
|
|
6624
6752
|
apiUrl = result.apiUrl || pairingApiBase;
|
|
6625
6753
|
if (e2eUserKey && e2eKeyId) {
|
|
@@ -6654,16 +6782,22 @@ Monitor activity, enforce policy, and approve with a tap.`, "About");
|
|
|
6654
6782
|
he("Cannot continue without token");
|
|
6655
6783
|
process.exit(1);
|
|
6656
6784
|
}
|
|
6785
|
+
const installPreservation = resolvePreservation({
|
|
6786
|
+
continuity: !existingConfig ? "fresh" : pendingRecoveryAction === "refresh" ? "refresh" : pendingRecoveryAction === "repair" ? "repair" : token === existingConfig.token ? "same-token" : "pair",
|
|
6787
|
+
existing: existingConfig,
|
|
6788
|
+
verifiedEmail: undefined,
|
|
6789
|
+
pairedEmail: email || undefined
|
|
6790
|
+
});
|
|
6657
6791
|
saveEnvConfig({
|
|
6658
6792
|
apiUrl,
|
|
6659
6793
|
token,
|
|
6660
6794
|
privacy: finalPrivacy,
|
|
6661
6795
|
retentionDays,
|
|
6662
6796
|
debugLog,
|
|
6663
|
-
configSetAt,
|
|
6797
|
+
configSetAt: installPreservation.letAccountWin ? 0 : configSetAt,
|
|
6664
6798
|
e2eEnabled: useE2E,
|
|
6665
6799
|
failBehavior,
|
|
6666
|
-
preserved:
|
|
6800
|
+
preserved: installPreservation.preserved
|
|
6667
6801
|
});
|
|
6668
6802
|
if (!silentlyReuseExistingToken) {
|
|
6669
6803
|
v2.success("Configuration saved to ~/.agentapprove/env");
|
|
@@ -6725,6 +6859,8 @@ AGENTAPPROVE_E2E_MODE=${installMode}
|
|
|
6725
6859
|
he("Installation cancelled");
|
|
6726
6860
|
process.exit(0);
|
|
6727
6861
|
}
|
|
6862
|
+
const failedSetupAgents = new Set;
|
|
6863
|
+
const nextSteps = [];
|
|
6728
6864
|
if (installMethod === "auto") {
|
|
6729
6865
|
const filesToModify = [];
|
|
6730
6866
|
for (const agentId of selectedAgents) {
|
|
@@ -6793,10 +6929,12 @@ Backups will be created with timestamp`, "Files to be modified");
|
|
|
6793
6929
|
}
|
|
6794
6930
|
if (agentId === "codex") {
|
|
6795
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`);
|
|
6796
6934
|
}
|
|
6797
6935
|
if (agentId === "copilot-cli") {
|
|
6798
|
-
|
|
6799
|
-
` + `
|
|
6936
|
+
nextSteps.push(`Copy the GitHub Copilot CLI hooks into each repository you want covered.
|
|
6937
|
+
` + ` cp ${agent.configPath} .github/hooks/agentapprove.json`);
|
|
6800
6938
|
}
|
|
6801
6939
|
if (agentId === "hermes") {
|
|
6802
6940
|
try {
|
|
@@ -6804,13 +6942,14 @@ Backups will be created with timestamp`, "Files to be modified");
|
|
|
6804
6942
|
if (others.length > 0) {
|
|
6805
6943
|
const lines = others.map((pr) => ` ${pr.name.padEnd(20)} ${pr.installed ? `installed v${pr.version ?? "?"}` : "not installed"}`).join(`
|
|
6806
6944
|
`);
|
|
6807
|
-
|
|
6945
|
+
nextSteps.push(`Add Agent Approve to your other Hermes profiles. Only the default one was set up.
|
|
6808
6946
|
` + `${lines}
|
|
6809
|
-
` + `
|
|
6947
|
+
` + ` Run: npx agentapprove profiles`);
|
|
6810
6948
|
}
|
|
6811
6949
|
} catch {}
|
|
6812
6950
|
}
|
|
6813
6951
|
} else {
|
|
6952
|
+
failedSetupAgents.add(agentId);
|
|
6814
6953
|
spinner.stop(`${agent.name} configuration failed`);
|
|
6815
6954
|
if (agentId === "openclaw") {
|
|
6816
6955
|
v2.warn(`Could not install ${OPENCLAW_PLUGIN_SPEC} via OpenClaw CLI.
|
|
@@ -6847,17 +6986,105 @@ Backups will be created with timestamp`, "Files to be modified");
|
|
|
6847
6986
|
message: "Press Enter when done"
|
|
6848
6987
|
});
|
|
6849
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 });
|
|
6850
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)";
|
|
6851
6992
|
me(`Mode: ${modeDesc}
|
|
6852
6993
|
|
|
6853
6994
|
npx agentapprove pair Link a new iOS device
|
|
6995
|
+
npx agentapprove check Re-check this computer's configuration (local only, changes nothing)
|
|
6854
6996
|
npx agentapprove status Show current configuration
|
|
6855
6997
|
npx agentapprove profiles Manage Agent Approve across Hermes profiles
|
|
6856
6998
|
npx agentapprove disable Deregister hooks/plugins, keep local state
|
|
6857
6999
|
npx agentapprove uninstall Remove hooks/plugins and keep local state
|
|
6858
7000
|
npx agentapprove purge Remove hooks/plugins and delete local state
|
|
6859
7001
|
npx agentapprove restore Restore original configs`, "Useful commands");
|
|
6860
|
-
|
|
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;
|
|
6861
7088
|
}
|
|
6862
7089
|
async function profilesCommand() {
|
|
6863
7090
|
console.clear();
|
|
@@ -7673,6 +7900,7 @@ ${source_default.yellow("Commands:")}
|
|
|
7673
7900
|
${source_default.green("pair")} Link a new iOS device or repair E2E pairing
|
|
7674
7901
|
${source_default.green("refresh")} Generate a new token and reuse current pairing context
|
|
7675
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)
|
|
7676
7904
|
${source_default.green("status")} Show current configuration and installed hooks
|
|
7677
7905
|
${source_default.green("profiles")} Install/remove Agent Approve across Hermes profiles
|
|
7678
7906
|
${source_default.green("disable")} Deregister hooks/plugins from all agents, keep local state
|
|
@@ -7727,7 +7955,7 @@ but if unused for 30 days they expire. Get a new one below.`, "Token Expired");
|
|
|
7727
7955
|
} else {
|
|
7728
7956
|
v2.info('Refresh updates the token only. Use "npx agentapprove pair" if you need to repair or change E2E pairing.');
|
|
7729
7957
|
}
|
|
7730
|
-
const configSetAt = existingConfig.configSetAt
|
|
7958
|
+
const configSetAt = carryConfigSetAt(existingConfig.configSetAt, Math.floor(Date.now() / 1000));
|
|
7731
7959
|
const privacy = existingConfig.privacy || "full";
|
|
7732
7960
|
const retentionDays = existingConfig.retentionDays ?? 30;
|
|
7733
7961
|
const failBehavior = existingConfig.failBehavior || "ask";
|
|
@@ -7778,6 +8006,11 @@ but if unused for 30 days they expire. Get a new one below.`, "Token Expired");
|
|
|
7778
8006
|
v2.error('Session expired. Run "npx agentapprove refresh" to try again.');
|
|
7779
8007
|
process.exit(1);
|
|
7780
8008
|
}
|
|
8009
|
+
const refreshPreservation = resolvePreservation({
|
|
8010
|
+
continuity: "refresh",
|
|
8011
|
+
existing: existingConfig,
|
|
8012
|
+
pairedEmail: result.email || undefined
|
|
8013
|
+
});
|
|
7781
8014
|
saveEnvConfig({
|
|
7782
8015
|
apiUrl,
|
|
7783
8016
|
token,
|
|
@@ -7787,8 +8020,8 @@ but if unused for 30 days they expire. Get a new one below.`, "Token Expired");
|
|
|
7787
8020
|
e2eMode: existingConfig.e2eMode,
|
|
7788
8021
|
e2eEnabled,
|
|
7789
8022
|
failBehavior,
|
|
7790
|
-
configSetAt,
|
|
7791
|
-
preserved:
|
|
8023
|
+
configSetAt: refreshPreservation.letAccountWin ? 0 : configSetAt,
|
|
8024
|
+
preserved: refreshPreservation.preserved
|
|
7792
8025
|
});
|
|
7793
8026
|
await storeTokenInKeychain(token);
|
|
7794
8027
|
if (e2eEnabled && result.e2eServerKey) {
|
|
@@ -7963,6 +8196,11 @@ async function pairCommand() {
|
|
|
7963
8196
|
}
|
|
7964
8197
|
const apiUrl = result.apiUrl || pairingApiBase;
|
|
7965
8198
|
const configSetAt = Math.floor(Date.now() / 1000);
|
|
8199
|
+
const pairPreservation = resolvePreservation({
|
|
8200
|
+
continuity: "pair",
|
|
8201
|
+
existing: existingConfig,
|
|
8202
|
+
pairedEmail: result.email || undefined
|
|
8203
|
+
});
|
|
7966
8204
|
saveEnvConfig({
|
|
7967
8205
|
apiUrl,
|
|
7968
8206
|
token: result.token,
|
|
@@ -7972,8 +8210,8 @@ async function pairCommand() {
|
|
|
7972
8210
|
e2eMode: existingConfig?.e2eMode,
|
|
7973
8211
|
e2eEnabled: !!e2eUserKey,
|
|
7974
8212
|
failBehavior: existingConfig?.failBehavior || "ask",
|
|
7975
|
-
configSetAt,
|
|
7976
|
-
preserved:
|
|
8213
|
+
configSetAt: pairPreservation.letAccountWin ? 0 : configSetAt,
|
|
8214
|
+
preserved: pairPreservation.preserved
|
|
7977
8215
|
});
|
|
7978
8216
|
await storeTokenInKeychain(result.token);
|
|
7979
8217
|
const hooksDir = join(getAgentApproveDir(), "hooks");
|
|
@@ -8038,6 +8276,9 @@ async function main() {
|
|
|
8038
8276
|
case "pair":
|
|
8039
8277
|
await pairCommand();
|
|
8040
8278
|
break;
|
|
8279
|
+
case "check":
|
|
8280
|
+
await checkSetupCommand();
|
|
8281
|
+
break;
|
|
8041
8282
|
case "status":
|
|
8042
8283
|
await statusCommand();
|
|
8043
8284
|
break;
|
|
@@ -8076,7 +8317,7 @@ async function main() {
|
|
|
8076
8317
|
}
|
|
8077
8318
|
}
|
|
8078
8319
|
main().then(() => {
|
|
8079
|
-
process.exit(0);
|
|
8320
|
+
process.exit(process.exitCode ?? 0);
|
|
8080
8321
|
}).catch((error) => {
|
|
8081
8322
|
console.error(source_default.red("Error:"), error.message);
|
|
8082
8323
|
process.exit(1);
|