@agentvalet/register 0.1.8 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +52 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -376,14 +376,62 @@ 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 perms = settings.permissions ?? {};
|
|
387
|
+
const allow = perms.allow ?? [];
|
|
388
|
+
const mcpAllows = ["mcp__agent-authority__list_platforms", "mcp__agent-authority__use_platform"];
|
|
389
|
+
const missing = mcpAllows.filter((e) => !allow.includes(e));
|
|
390
|
+
if (missing.length > 0) {
|
|
391
|
+
perms.allow = [...allow, ...missing];
|
|
392
|
+
settings.permissions = perms;
|
|
393
|
+
}
|
|
385
394
|
mkdirSync(dirname2(settingsPath), { recursive: true });
|
|
386
395
|
writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf-8");
|
|
396
|
+
ensureMcpJson();
|
|
397
|
+
}
|
|
398
|
+
function ensureMcpJson() {
|
|
399
|
+
const mcpJsonPath = resolve2(".mcp.json");
|
|
400
|
+
let mcpConfig = {};
|
|
401
|
+
if (existsSync(mcpJsonPath)) {
|
|
402
|
+
try {
|
|
403
|
+
mcpConfig = JSON.parse(readFileSync(mcpJsonPath, "utf-8"));
|
|
404
|
+
} catch {
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
const servers = mcpConfig.mcpServers ?? {};
|
|
409
|
+
if (servers["agent-authority"]) return;
|
|
410
|
+
const envPath = resolve2(".env.agentvalet");
|
|
411
|
+
if (!existsSync(envPath)) return;
|
|
412
|
+
let envVars;
|
|
413
|
+
try {
|
|
414
|
+
envVars = parseEnvFile(readFileSync(envPath, "utf-8"));
|
|
415
|
+
} catch {
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
const agentId = envVars["AGENTVALET_AGENT_ID"];
|
|
419
|
+
const ownerId = envVars["AGENTVALET_OWNER_ID"];
|
|
420
|
+
const apiUrl = envVars["AGENTVALET_API_URL"] ?? "https://api.agentvalet.ai";
|
|
421
|
+
const keyPath = envVars["AGENTVALET_PRIVATE_KEY_PATH"];
|
|
422
|
+
if (!agentId || !ownerId || !keyPath) return;
|
|
423
|
+
servers["agent-authority"] = {
|
|
424
|
+
command: "npx",
|
|
425
|
+
args: ["-y", "@agentvalet/mcp-server"],
|
|
426
|
+
env: {
|
|
427
|
+
AGENT_ID: agentId,
|
|
428
|
+
OWNER_ID: ownerId,
|
|
429
|
+
PROXY_URL: apiUrl,
|
|
430
|
+
AGENT_PRIVATE_KEY_PATH: keyPath
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
mcpConfig.mcpServers = servers;
|
|
434
|
+
writeFileSync(mcpJsonPath, JSON.stringify(mcpConfig, null, 2) + "\n", "utf-8");
|
|
387
435
|
}
|
|
388
436
|
|
|
389
437
|
// src/index.ts
|