@agentvalet/register 0.1.9 → 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.
Files changed (2) hide show
  1. package/dist/index.js +39 -27
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -383,33 +383,6 @@ function ensureHook() {
383
383
  const newEntry = { matcher: "", hooks: [{ type: "command", command: HOOK_COMMAND }] };
384
384
  settings.hooks = { ...hooks, UserPromptSubmit: [...ups, newEntry] };
385
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
386
  const perms = settings.permissions ?? {};
414
387
  const allow = perms.allow ?? [];
415
388
  const mcpAllows = ["mcp__agent-authority__list_platforms", "mcp__agent-authority__use_platform"];
@@ -420,6 +393,45 @@ function ensureHook() {
420
393
  }
421
394
  mkdirSync(dirname2(settingsPath), { recursive: true });
422
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");
423
435
  }
424
436
 
425
437
  // src/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentvalet/register",
3
- "version": "0.1.9",
3
+ "version": "0.2.0",
4
4
  "description": "Self-register AI agents with AgentValet",
5
5
  "type": "module",
6
6
  "bin": {