@agentvalet/register 0.1.8 → 0.1.9
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/index.js +40 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -376,12 +376,48 @@ function ensureHook() {
|
|
|
376
376
|
}
|
|
377
377
|
const hooks = settings.hooks ?? {};
|
|
378
378
|
const ups = hooks.UserPromptSubmit ?? [];
|
|
379
|
-
const
|
|
379
|
+
const hookAlreadyWired = ups.some(
|
|
380
380
|
(entry) => entry.hooks?.some((h) => h.command?.includes(HOOK_MARKER))
|
|
381
381
|
);
|
|
382
|
-
if (
|
|
383
|
-
|
|
384
|
-
|
|
382
|
+
if (!hookAlreadyWired) {
|
|
383
|
+
const newEntry = { matcher: "", hooks: [{ type: "command", command: HOOK_COMMAND }] };
|
|
384
|
+
settings.hooks = { ...hooks, UserPromptSubmit: [...ups, newEntry] };
|
|
385
|
+
}
|
|
386
|
+
const mcpServers = settings.mcpServers ?? {};
|
|
387
|
+
if (!mcpServers["agent-authority"]) {
|
|
388
|
+
const envPath = resolve2(".env.agentvalet");
|
|
389
|
+
if (existsSync(envPath)) {
|
|
390
|
+
try {
|
|
391
|
+
const envVars = parseEnvFile(readFileSync(envPath, "utf-8"));
|
|
392
|
+
const agentId = envVars["AGENTVALET_AGENT_ID"];
|
|
393
|
+
const ownerId = envVars["AGENTVALET_OWNER_ID"];
|
|
394
|
+
const apiUrl = envVars["AGENTVALET_API_URL"] ?? "https://api.agentvalet.ai";
|
|
395
|
+
const keyPath = envVars["AGENTVALET_PRIVATE_KEY_PATH"];
|
|
396
|
+
if (agentId && ownerId && keyPath) {
|
|
397
|
+
mcpServers["agent-authority"] = {
|
|
398
|
+
command: "npx",
|
|
399
|
+
args: ["-y", "@agentvalet/mcp-server"],
|
|
400
|
+
env: {
|
|
401
|
+
AGENT_ID: agentId,
|
|
402
|
+
OWNER_ID: ownerId,
|
|
403
|
+
PROXY_URL: apiUrl,
|
|
404
|
+
AGENT_PRIVATE_KEY_PATH: keyPath
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
settings.mcpServers = mcpServers;
|
|
408
|
+
}
|
|
409
|
+
} catch {
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
const perms = settings.permissions ?? {};
|
|
414
|
+
const allow = perms.allow ?? [];
|
|
415
|
+
const mcpAllows = ["mcp__agent-authority__list_platforms", "mcp__agent-authority__use_platform"];
|
|
416
|
+
const missing = mcpAllows.filter((e) => !allow.includes(e));
|
|
417
|
+
if (missing.length > 0) {
|
|
418
|
+
perms.allow = [...allow, ...missing];
|
|
419
|
+
settings.permissions = perms;
|
|
420
|
+
}
|
|
385
421
|
mkdirSync(dirname2(settingsPath), { recursive: true });
|
|
386
422
|
writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf-8");
|
|
387
423
|
}
|