@agentvalet/register 0.4.4 → 0.4.5

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 +204 -178
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  // src/index.ts
4
4
  import { Command } from "commander";
5
- import chalk7 from "chalk";
5
+ import chalk8 from "chalk";
6
6
 
7
7
  // src/wizard.ts
8
8
  import prompts from "prompts";
@@ -166,7 +166,7 @@ function parseEvent(data) {
166
166
  return null;
167
167
  }
168
168
  function sleep(ms) {
169
- return new Promise((resolve3) => setTimeout(resolve3, ms));
169
+ return new Promise((resolve4) => setTimeout(resolve4, ms));
170
170
  }
171
171
 
172
172
  // src/save.ts
@@ -191,9 +191,9 @@ async function saveOutput(opts) {
191
191
  }
192
192
 
193
193
  // src/commands/refresh.ts
194
- import { readFileSync as readFileSync2, writeFileSync as writeFileSync2, existsSync as existsSync2, mkdirSync, statSync } from "fs";
194
+ import { readFileSync as readFileSync3, writeFileSync as writeFileSync2, existsSync as existsSync3, mkdirSync, statSync } from "fs";
195
195
  import { createSign, createPrivateKey } from "crypto";
196
- import { dirname as dirname2, resolve as resolve2, join } from "path";
196
+ import { dirname as dirname2, resolve as resolve3 } from "path";
197
197
 
198
198
  // src/lib/skill-writer.ts
199
199
  import { existsSync, writeFileSync } from "fs";
@@ -410,6 +410,10 @@ To refresh this file: \`npx @agentvalet/register refresh\`
410
410
  `;
411
411
  }
412
412
 
413
+ // src/lib/require-agent.ts
414
+ import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
415
+ import { resolve as resolve2, join } from "path";
416
+
413
417
  // src/config/store.ts
414
418
  import Conf from "conf";
415
419
  var store = new Conf({
@@ -428,24 +432,11 @@ function isAuthenticated() {
428
432
  return !!store.get("apiKey");
429
433
  }
430
434
 
431
- // src/commands/refresh.ts
432
- var CLAUDE_START = "<!-- agentvalet:start -->";
433
- var CLAUDE_END = "<!-- agentvalet:end -->";
434
- var HOOK_COMMAND = "npx @agentvalet/register refresh --if-stale --quiet 2>/dev/null || true";
435
- var HOOK_MARKER = "agentvalet/register refresh";
436
- function base64url(input) {
437
- return Buffer.from(input).toString("base64url");
438
- }
439
- function signJwt(agentId, ownerId, privateKeyPem) {
440
- const now = Math.floor(Date.now() / 1e3);
441
- const header = base64url(JSON.stringify({ alg: "RS256", typ: "JWT" }));
442
- const payload = base64url(JSON.stringify({ agent_id: agentId, owner_id: ownerId, iat: now, exp: now + 300 }));
443
- const signingInput = `${header}.${payload}`;
444
- const sign = createSign("RSA-SHA256");
445
- sign.update(signingInput);
446
- const signature = sign.sign(createPrivateKey(privateKeyPem), "base64url");
447
- return `${signingInput}.${signature}`;
448
- }
435
+ // src/lib/require-agent.ts
436
+ import chalk3 from "chalk";
437
+ var NO_AGENT_MSG = chalk3.red("\n \u2717 No agent registered.\n") + chalk3.dim(
438
+ " Run the following command first to register an agent in this directory:\n\n npx @agentvalet/register\n"
439
+ );
449
440
  function parseEnvFile(content) {
450
441
  const result = {};
451
442
  for (const line of content.split("\n")) {
@@ -457,42 +448,68 @@ function parseEnvFile(content) {
457
448
  }
458
449
  return result;
459
450
  }
460
- function writePermissionsFromEvent(agentId, ownerId, platforms, outputPath = "./.claude/agentvalet-permissions.md") {
461
- const content = generatePermissionsFile(agentId, ownerId, platforms);
462
- const resolvedPath = resolve2(outputPath);
463
- mkdirSync(dirname2(resolvedPath), { recursive: true });
464
- writeFileSync2(resolvedPath, content, "utf-8");
465
- embedInClaudeMd(content);
466
- ensureHook();
467
- }
468
- async function runRefresh(options) {
469
- const outputPath = resolve2(options.outputPath);
470
- if (options.ifStale) {
451
+ function resolveAgent(envFile = ".env.agentvalet") {
452
+ let agentId;
453
+ let ownerId;
454
+ let apiUrl = "https://api.agentvalet.ai";
455
+ let keyPath;
456
+ const envPath = resolve2(envFile);
457
+ if (existsSync2(envPath)) {
471
458
  try {
472
- const stat = statSync(outputPath);
473
- const fileIsFresh = Date.now() - stat.mtimeMs < 36e5;
474
- const claudeMdPath = resolve2("CLAUDE.md");
475
- const claudeMd = existsSync2(claudeMdPath) ? readFileSync2(claudeMdPath, "utf-8") : "";
476
- const blockStart = claudeMd.indexOf(CLAUDE_START);
477
- const blockEnd = claudeMd.indexOf(CLAUDE_END);
478
- const blockContent = blockStart !== -1 && blockEnd !== -1 ? claudeMd.slice(blockStart, blockEnd) : "";
479
- const blockHasPlatforms = blockContent.includes("### ");
480
- if (fileIsFresh && blockHasPlatforms) return;
459
+ const vars = parseEnvFile(readFileSync2(envPath, "utf-8"));
460
+ agentId = vars["AGENTVALET_AGENT_ID"];
461
+ ownerId = vars["AGENTVALET_OWNER_ID"];
462
+ apiUrl = vars["AGENTVALET_API_URL"] ?? apiUrl;
463
+ keyPath = vars["AGENTVALET_PRIVATE_KEY_PATH"];
464
+ } catch {
465
+ }
466
+ }
467
+ if (!agentId || !ownerId || !keyPath) {
468
+ const localConfigPath = join(process.cwd(), ".agentvalet", "config.json");
469
+ if (existsSync2(localConfigPath)) {
470
+ try {
471
+ const local = JSON.parse(readFileSync2(localConfigPath, "utf-8"));
472
+ agentId = agentId ?? local["agent_id"];
473
+ apiUrl = local["proxy_url"] ?? apiUrl;
474
+ keyPath = keyPath ?? join(process.cwd(), ".agentvalet", "agent.key");
475
+ } catch {
476
+ }
477
+ }
478
+ try {
479
+ const global = getStoredConfig();
480
+ if (!ownerId) ownerId = global.ownerId ?? void 0;
481
+ } catch {
482
+ }
483
+ }
484
+ if (!agentId || !ownerId || !keyPath) {
485
+ try {
486
+ const global = getStoredConfig();
487
+ agentId = agentId ?? global.lastAgentId ?? void 0;
488
+ ownerId = ownerId ?? global.ownerId ?? void 0;
489
+ keyPath = keyPath ?? global.lastKeyPath ?? void 0;
490
+ apiUrl = global.proxyUrl ?? apiUrl;
481
491
  } catch {
482
492
  }
483
493
  }
494
+ if (!agentId || !ownerId || !keyPath) {
495
+ process.stderr.write(NO_AGENT_MSG + "\n");
496
+ process.exit(1);
497
+ }
498
+ return { agentId, ownerId, keyPath, apiUrl };
499
+ }
500
+ function tryResolveAgent(envFile = ".env.agentvalet") {
484
501
  let agentId;
485
502
  let ownerId;
486
503
  let apiUrl = "https://api.agentvalet.ai";
487
504
  let keyPath;
488
- const envPath = resolve2(options.envFile);
505
+ const envPath = resolve2(envFile);
489
506
  if (existsSync2(envPath)) {
490
507
  try {
491
- const envVars = parseEnvFile(readFileSync2(envPath, "utf-8"));
492
- agentId = envVars["AGENTVALET_AGENT_ID"];
493
- ownerId = envVars["AGENTVALET_OWNER_ID"];
494
- apiUrl = envVars["AGENTVALET_API_URL"] ?? apiUrl;
495
- keyPath = envVars["AGENTVALET_PRIVATE_KEY_PATH"];
508
+ const vars = parseEnvFile(readFileSync2(envPath, "utf-8"));
509
+ agentId = vars["AGENTVALET_AGENT_ID"];
510
+ ownerId = vars["AGENTVALET_OWNER_ID"];
511
+ apiUrl = vars["AGENTVALET_API_URL"] ?? apiUrl;
512
+ keyPath = vars["AGENTVALET_PRIVATE_KEY_PATH"];
496
513
  } catch {
497
514
  }
498
515
  }
@@ -507,32 +524,72 @@ async function runRefresh(options) {
507
524
  } catch {
508
525
  }
509
526
  }
510
- if (!ownerId) {
511
- try {
512
- ownerId = getStoredConfig().ownerId ?? void 0;
513
- } catch {
514
- }
527
+ try {
528
+ const global = getStoredConfig();
529
+ if (!ownerId) ownerId = global.ownerId ?? void 0;
530
+ } catch {
515
531
  }
516
532
  }
517
533
  if (!agentId || !ownerId || !keyPath) {
518
534
  try {
519
535
  const global = getStoredConfig();
520
- if (!agentId && global.lastAgentId) agentId = global.lastAgentId;
521
- if (!ownerId && global.ownerId) ownerId = global.ownerId;
522
- if (!keyPath && global.lastKeyPath) keyPath = global.lastKeyPath;
523
- if (!apiUrl && global.proxyUrl) apiUrl = global.proxyUrl;
536
+ agentId = agentId ?? global.lastAgentId ?? void 0;
537
+ ownerId = ownerId ?? global.ownerId ?? void 0;
538
+ keyPath = keyPath ?? global.lastKeyPath ?? void 0;
539
+ apiUrl = global.proxyUrl ?? apiUrl;
524
540
  } catch {
525
541
  }
526
542
  }
527
- if (!agentId || !ownerId || !keyPath) {
528
- throw new Error(
529
- `Cannot find agent credentials.
530
- Run 'npx @agentvalet/register' in this directory first.`
531
- );
543
+ if (!agentId || !ownerId || !keyPath) return null;
544
+ return { agentId, ownerId, keyPath, apiUrl };
545
+ }
546
+
547
+ // src/commands/refresh.ts
548
+ var CLAUDE_START = "<!-- agentvalet:start -->";
549
+ var CLAUDE_END = "<!-- agentvalet:end -->";
550
+ var HOOK_COMMAND = "npx @agentvalet/register refresh --if-stale --quiet 2>/dev/null || true";
551
+ var HOOK_MARKER = "agentvalet/register refresh";
552
+ function base64url(input) {
553
+ return Buffer.from(input).toString("base64url");
554
+ }
555
+ function signJwt(agentId, ownerId, privateKeyPem) {
556
+ const now = Math.floor(Date.now() / 1e3);
557
+ const header = base64url(JSON.stringify({ alg: "RS256", typ: "JWT" }));
558
+ const payload = base64url(JSON.stringify({ agent_id: agentId, owner_id: ownerId, iat: now, exp: now + 300 }));
559
+ const signingInput = `${header}.${payload}`;
560
+ const sign = createSign("RSA-SHA256");
561
+ sign.update(signingInput);
562
+ const signature = sign.sign(createPrivateKey(privateKeyPem), "base64url");
563
+ return `${signingInput}.${signature}`;
564
+ }
565
+ function writePermissionsFromEvent(agentId, ownerId, platforms, outputPath = "./.claude/agentvalet-permissions.md") {
566
+ const content = generatePermissionsFile(agentId, ownerId, platforms);
567
+ const resolvedPath = resolve3(outputPath);
568
+ mkdirSync(dirname2(resolvedPath), { recursive: true });
569
+ writeFileSync2(resolvedPath, content, "utf-8");
570
+ embedInClaudeMd(content);
571
+ ensureHook();
572
+ }
573
+ async function runRefresh(options) {
574
+ const outputPath = resolve3(options.outputPath);
575
+ if (options.ifStale) {
576
+ try {
577
+ const stat = statSync(outputPath);
578
+ const fileIsFresh = Date.now() - stat.mtimeMs < 36e5;
579
+ const claudeMdPath = resolve3("CLAUDE.md");
580
+ const claudeMd = existsSync3(claudeMdPath) ? readFileSync3(claudeMdPath, "utf-8") : "";
581
+ const blockStart = claudeMd.indexOf(CLAUDE_START);
582
+ const blockEnd = claudeMd.indexOf(CLAUDE_END);
583
+ const blockContent = blockStart !== -1 && blockEnd !== -1 ? claudeMd.slice(blockStart, blockEnd) : "";
584
+ const blockHasPlatforms = blockContent.includes("### ");
585
+ if (fileIsFresh && blockHasPlatforms) return;
586
+ } catch {
587
+ }
532
588
  }
589
+ const { agentId, ownerId, keyPath, apiUrl } = resolveAgent(options.envFile);
533
590
  let privateKeyPem;
534
591
  try {
535
- privateKeyPem = readFileSync2(keyPath, "utf-8");
592
+ privateKeyPem = readFileSync3(keyPath, "utf-8");
536
593
  } catch {
537
594
  throw new Error(`Cannot read private key: ${keyPath}`);
538
595
  }
@@ -559,18 +616,18 @@ Run 'npx @agentvalet/register' in this directory first.`
559
616
  }
560
617
  }
561
618
  function embedInClaudeMd(permissionsContent) {
562
- const claudeMdPath = resolve2("CLAUDE.md");
619
+ const claudeMdPath = resolve3("CLAUDE.md");
563
620
  const block = `${CLAUDE_START}
564
621
  ${permissionsContent.trimEnd()}
565
622
  ${CLAUDE_END}`;
566
- if (!existsSync2(claudeMdPath)) {
623
+ if (!existsSync3(claudeMdPath)) {
567
624
  writeFileSync2(claudeMdPath, `# Agent Instructions
568
625
 
569
626
  ${block}
570
627
  `, "utf-8");
571
628
  return;
572
629
  }
573
- const existing = readFileSync2(claudeMdPath, "utf-8");
630
+ const existing = readFileSync3(claudeMdPath, "utf-8");
574
631
  if (existing.includes(CLAUDE_START)) {
575
632
  const replaced = existing.replace(
576
633
  new RegExp(`${CLAUDE_START}[\\s\\S]*?${CLAUDE_END}`, "m"),
@@ -586,11 +643,11 @@ ${block}
586
643
  }
587
644
  }
588
645
  function ensureHook() {
589
- const settingsPath = resolve2(".claude/settings.local.json");
646
+ const settingsPath = resolve3(".claude/settings.local.json");
590
647
  let settings = {};
591
- if (existsSync2(settingsPath)) {
648
+ if (existsSync3(settingsPath)) {
592
649
  try {
593
- settings = JSON.parse(readFileSync2(settingsPath, "utf-8"));
650
+ settings = JSON.parse(readFileSync3(settingsPath, "utf-8"));
594
651
  } catch {
595
652
  return;
596
653
  }
@@ -617,51 +674,20 @@ function ensureHook() {
617
674
  ensureMcpJson();
618
675
  }
619
676
  function ensureMcpJson() {
620
- const mcpJsonPath = resolve2(".mcp.json");
677
+ const mcpJsonPath = resolve3(".mcp.json");
621
678
  let mcpConfig = {};
622
- if (existsSync2(mcpJsonPath)) {
679
+ if (existsSync3(mcpJsonPath)) {
623
680
  try {
624
- mcpConfig = JSON.parse(readFileSync2(mcpJsonPath, "utf-8"));
681
+ mcpConfig = JSON.parse(readFileSync3(mcpJsonPath, "utf-8"));
625
682
  } catch {
626
683
  return;
627
684
  }
628
685
  }
629
686
  const servers = mcpConfig.mcpServers ?? {};
630
687
  if (servers["agentvalet"]) return;
631
- let agentId;
632
- let ownerId;
633
- let apiUrl = "https://api.agentvalet.ai";
634
- let keyPath;
635
- const envPath = resolve2(".env.agentvalet");
636
- if (existsSync2(envPath)) {
637
- try {
638
- const envVars = parseEnvFile(readFileSync2(envPath, "utf-8"));
639
- agentId = envVars["AGENTVALET_AGENT_ID"];
640
- ownerId = envVars["AGENTVALET_OWNER_ID"];
641
- apiUrl = envVars["AGENTVALET_API_URL"] ?? apiUrl;
642
- keyPath = envVars["AGENTVALET_PRIVATE_KEY_PATH"];
643
- } catch {
644
- }
645
- }
646
- if (!agentId || !keyPath) {
647
- const localConfigPath = join(process.cwd(), ".agentvalet", "config.json");
648
- if (existsSync2(localConfigPath)) {
649
- try {
650
- const local = JSON.parse(readFileSync2(localConfigPath, "utf-8"));
651
- agentId = agentId ?? local["agent_id"];
652
- apiUrl = local["proxy_url"] ?? apiUrl;
653
- keyPath = keyPath ?? join(process.cwd(), ".agentvalet", "agent.key");
654
- } catch {
655
- }
656
- }
657
- if (!ownerId) {
658
- try {
659
- ownerId = getStoredConfig().ownerId ?? void 0;
660
- } catch {
661
- }
662
- }
663
- }
664
- if (!agentId || !ownerId || !keyPath) return;
688
+ const creds = tryResolveAgent();
689
+ if (!creds) return;
690
+ const { agentId, ownerId, apiUrl, keyPath } = creds;
665
691
  servers["agentvalet"] = {
666
692
  command: "npx",
667
693
  args: ["-y", "@agentvalet/register", "mcp-server"],
@@ -677,14 +703,14 @@ function ensureMcpJson() {
677
703
  }
678
704
 
679
705
  // src/commands/onboard.ts
680
- import chalk6 from "chalk";
706
+ import chalk7 from "chalk";
681
707
  import ora from "ora";
682
708
  import prompts3 from "prompts";
683
709
 
684
710
  // src/auth/github-device-flow.ts
685
711
  import { createOAuthDeviceAuth } from "@octokit/auth-oauth-device";
686
712
  import open from "open";
687
- import chalk3 from "chalk";
713
+ import chalk4 from "chalk";
688
714
  var GITHUB_CLIENT_ID = process.env.AGENTVALET_GITHUB_CLIENT_ID ?? "Ov23liQcaW0HcqJxmLfF";
689
715
  async function authenticateWithGitHub() {
690
716
  const auth = createOAuthDeviceAuth({
@@ -693,15 +719,15 @@ async function authenticateWithGitHub() {
693
719
  scopes: ["user:email", "read:user"],
694
720
  onVerification(verification) {
695
721
  console.log("");
696
- console.log(chalk3.bold(" Authenticate with GitHub"));
722
+ console.log(chalk4.bold(" Authenticate with GitHub"));
697
723
  console.log("");
698
- console.log(` 1. Open: ${chalk3.cyan.underline(verification.verification_uri)}`);
699
- console.log(` 2. Enter code: ${chalk3.bold.yellow(verification.user_code)}`);
724
+ console.log(` 1. Open: ${chalk4.cyan.underline(verification.verification_uri)}`);
725
+ console.log(` 2. Enter code: ${chalk4.bold.yellow(verification.user_code)}`);
700
726
  console.log("");
701
727
  open(verification.verification_uri).catch(() => {
702
- console.log(chalk3.dim(" (Could not open browser \u2014 navigate to the URL above manually)"));
728
+ console.log(chalk4.dim(" (Could not open browser \u2014 navigate to the URL above manually)"));
703
729
  });
704
- console.log(chalk3.dim(" Waiting for authorisation..."));
730
+ console.log(chalk4.dim(" Waiting for authorisation..."));
705
731
  }
706
732
  });
707
733
  const tokenAuth = await auth({ type: "oauth" });
@@ -853,20 +879,20 @@ async function writeLocalConfig(config) {
853
879
  }
854
880
 
855
881
  // src/output/env.ts
856
- import chalk4 from "chalk";
882
+ import chalk5 from "chalk";
857
883
  import { appendFile as appendFile2, writeFile as writeFile3 } from "fs/promises";
858
- import { existsSync as existsSync3 } from "fs";
884
+ import { existsSync as existsSync4 } from "fs";
859
885
  import path3 from "path";
860
886
  function formatEnvBlock(vars) {
861
887
  return Object.entries(vars).map(([key, value]) => {
862
888
  const truncated = value.length > 60 ? value.substring(0, 40) + "..." + value.substring(value.length - 10) : value;
863
- return ` ${chalk4.dim(key + "=")}${chalk4.white(truncated)}`;
889
+ return ` ${chalk5.dim(key + "=")}${chalk5.white(truncated)}`;
864
890
  }).join("\n");
865
891
  }
866
892
 
867
893
  // src/config/ide.ts
868
894
  import { mkdir as mkdir3, writeFile as writeFile4, readFile as readFile2, appendFile as appendFile3 } from "fs/promises";
869
- import { existsSync as existsSync4 } from "fs";
895
+ import { existsSync as existsSync5 } from "fs";
870
896
  import path4 from "path";
871
897
  import os from "os";
872
898
  function buildMcpEntry(params) {
@@ -883,7 +909,7 @@ function buildMcpEntry(params) {
883
909
  }
884
910
  async function mergeJsonFile(filePath, key, value) {
885
911
  let existing = {};
886
- if (existsSync4(filePath)) {
912
+ if (existsSync5(filePath)) {
887
913
  try {
888
914
  const text = await readFile2(filePath, "utf8");
889
915
  existing = JSON.parse(text);
@@ -941,9 +967,9 @@ async function writeGlobalFrameworkConfigs(params) {
941
967
  const written = [];
942
968
  const codexDir = path4.join(os.homedir(), ".codex");
943
969
  const codexConfigPath = path4.join(codexDir, "config.toml");
944
- if (existsSync4(codexDir)) {
970
+ if (existsSync5(codexDir)) {
945
971
  try {
946
- const existing = existsSync4(codexConfigPath) ? await readFile2(codexConfigPath, "utf8") : "";
972
+ const existing = existsSync5(codexConfigPath) ? await readFile2(codexConfigPath, "utf8") : "";
947
973
  if (!existing.includes("[mcp_servers.agentvalet]")) {
948
974
  const addition = `
949
975
  [mcp_servers.agentvalet]
@@ -974,7 +1000,7 @@ async function writeIdeConfigs(params) {
974
1000
  console.warn(` Warning: could not write .mcp.json: ${err.message}`);
975
1001
  }
976
1002
  const claudeMdPath = path4.join(cwd, "CLAUDE.md");
977
- if (!existsSync4(claudeMdPath)) {
1003
+ if (!existsSync5(claudeMdPath)) {
978
1004
  try {
979
1005
  await writeFile4(claudeMdPath, buildClaudeMd(params.agentId, params.ownerId, params.proxyUrl), "utf8");
980
1006
  written.push("CLAUDE.md");
@@ -1000,12 +1026,12 @@ async function writeIdeConfigs(params) {
1000
1026
  }
1001
1027
 
1002
1028
  // src/config/frameworks.ts
1003
- import { existsSync as existsSync5 } from "fs";
1029
+ import { existsSync as existsSync6 } from "fs";
1004
1030
  import { execSync as execSync2 } from "child_process";
1005
1031
  import os2 from "os";
1006
1032
  import path5 from "path";
1007
1033
  import prompts2 from "prompts";
1008
- import chalk5 from "chalk";
1034
+ import chalk6 from "chalk";
1009
1035
  function tryBinary(cmd) {
1010
1036
  try {
1011
1037
  execSync2(`${cmd} --version`, { stdio: "ignore", timeout: 3e3 });
@@ -1020,20 +1046,20 @@ function cursorInstalled() {
1020
1046
  if (platform === "win32") {
1021
1047
  const appData = process.env.APPDATA ?? path5.join(home, "AppData", "Roaming");
1022
1048
  const localAppData = process.env.LOCALAPPDATA ?? path5.join(home, "AppData", "Local");
1023
- return existsSync5(path5.join(appData, "Cursor")) || existsSync5(path5.join(localAppData, "Programs", "cursor"));
1049
+ return existsSync6(path5.join(appData, "Cursor")) || existsSync6(path5.join(localAppData, "Programs", "cursor"));
1024
1050
  }
1025
1051
  if (platform === "darwin") {
1026
- return existsSync5(path5.join(home, "Library", "Application Support", "Cursor")) || existsSync5("/Applications/Cursor.app");
1052
+ return existsSync6(path5.join(home, "Library", "Application Support", "Cursor")) || existsSync6("/Applications/Cursor.app");
1027
1053
  }
1028
- return existsSync5(path5.join(home, ".config", "Cursor")) || existsSync5("/usr/share/applications/cursor.desktop");
1054
+ return existsSync6(path5.join(home, ".config", "Cursor")) || existsSync6("/usr/share/applications/cursor.desktop");
1029
1055
  }
1030
1056
  function detectFrameworks() {
1031
1057
  const home = os2.homedir();
1032
1058
  return {
1033
- codex: existsSync5(path5.join(home, ".codex")) || tryBinary("codex"),
1034
- claudeCode: existsSync5(path5.join(home, ".claude")) || tryBinary("claude"),
1035
- cursor: existsSync5(path5.join(process.cwd(), ".cursor")) || cursorInstalled(),
1036
- openclaw: existsSync5(path5.join(home, ".openclaw"))
1059
+ codex: existsSync6(path5.join(home, ".codex")) || tryBinary("codex"),
1060
+ claudeCode: existsSync6(path5.join(home, ".claude")) || tryBinary("claude"),
1061
+ cursor: existsSync6(path5.join(process.cwd(), ".cursor")) || cursorInstalled(),
1062
+ openclaw: existsSync6(path5.join(home, ".openclaw"))
1037
1063
  };
1038
1064
  }
1039
1065
  async function frameworkSetupConsent(detected) {
@@ -1054,9 +1080,9 @@ async function frameworkSetupConsent(detected) {
1054
1080
  }
1055
1081
  if (items.length === 0) return false;
1056
1082
  console.log("");
1057
- console.log(chalk5.bold(" Detected agent frameworks"));
1083
+ console.log(chalk6.bold(" Detected agent frameworks"));
1058
1084
  for (const item of items) {
1059
- console.log(chalk5.dim(` ${item}`));
1085
+ console.log(chalk6.dim(` ${item}`));
1060
1086
  }
1061
1087
  console.log("");
1062
1088
  const { confirm } = await prompts2({
@@ -1074,13 +1100,13 @@ import path6 from "path";
1074
1100
  import { writeFile as writeFile5 } from "fs/promises";
1075
1101
  async function runOnboard() {
1076
1102
  console.log("");
1077
- console.log(chalk6.bold(" AgentValet \u2014 Agent Registration"));
1078
- console.log(chalk6.dim(" app.agentvalet.ai"));
1103
+ console.log(chalk7.bold(" AgentValet \u2014 Agent Registration"));
1104
+ console.log(chalk7.dim(" app.agentvalet.ai"));
1079
1105
  console.log("");
1080
1106
  if (isAuthenticated()) {
1081
1107
  const stored = getStoredConfig();
1082
1108
  console.log(
1083
- chalk6.green(" \u2713 Already authenticated as") + chalk6.bold(` ${stored.email}`)
1109
+ chalk7.green(" \u2713 Already authenticated as") + chalk7.bold(` ${stored.email}`)
1084
1110
  );
1085
1111
  const { action } = await prompts3({
1086
1112
  type: "select",
@@ -1101,7 +1127,7 @@ async function runOnboard() {
1101
1127
  }
1102
1128
  if (action === "signout") {
1103
1129
  clearConfig();
1104
- console.log(chalk6.dim(" Signed out. Run again to re-authenticate."));
1130
+ console.log(chalk7.dim(" Signed out. Run again to re-authenticate."));
1105
1131
  return;
1106
1132
  }
1107
1133
  await registerAgentFlow(stored.cliToken, stored.ownerId);
@@ -1130,14 +1156,14 @@ async function runOnboard() {
1130
1156
  const result = await authenticateWithGitHub();
1131
1157
  githubToken = result.token;
1132
1158
  } catch (err) {
1133
- console.error(chalk6.red(` \u2717 Authentication failed: ${err.message}`));
1159
+ console.error(chalk7.red(` \u2717 Authentication failed: ${err.message}`));
1134
1160
  process.exit(1);
1135
1161
  }
1136
1162
  spinner = ora(" Fetching your GitHub profile...").start();
1137
1163
  let githubUser;
1138
1164
  try {
1139
1165
  githubUser = await getGitHubUser(githubToken);
1140
- spinner.succeed(` GitHub: ${chalk6.bold("@" + githubUser.login)}`);
1166
+ spinner.succeed(` GitHub: ${chalk7.bold("@" + githubUser.login)}`);
1141
1167
  } catch (err) {
1142
1168
  spinner.fail(` Failed to fetch GitHub profile: ${err.message}`);
1143
1169
  process.exit(1);
@@ -1186,7 +1212,7 @@ async function runOnboard() {
1186
1212
  }
1187
1213
  async function ownerIdFlow() {
1188
1214
  console.log("");
1189
- console.log(chalk6.dim(" Find your Owner ID at: ") + chalk6.cyan.underline("https://app.agentvalet.ai/settings"));
1215
+ console.log(chalk7.dim(" Find your Owner ID at: ") + chalk7.cyan.underline("https://app.agentvalet.ai/settings"));
1190
1216
  console.log("");
1191
1217
  const { ownerId } = await prompts3({
1192
1218
  type: "text",
@@ -1201,10 +1227,10 @@ async function ownerIdFlow() {
1201
1227
  let account;
1202
1228
  try {
1203
1229
  account = await getAccount(ownerId.trim());
1204
- spinner.succeed(` Account verified \u2014 plan: ${chalk6.bold(account.plan)}`);
1230
+ spinner.succeed(` Account verified \u2014 plan: ${chalk7.bold(account.plan)}`);
1205
1231
  } catch (err) {
1206
1232
  spinner.fail(` Could not verify Owner ID: ${err.message}`);
1207
- console.log(chalk6.dim(" Make sure you copied the full Owner ID from app.agentvalet.ai/settings"));
1233
+ console.log(chalk7.dim(" Make sure you copied the full Owner ID from app.agentvalet.ai/settings"));
1208
1234
  process.exit(1);
1209
1235
  }
1210
1236
  saveConfig({
@@ -1238,7 +1264,7 @@ async function registerAgentFlow(apiKey, ownerId) {
1238
1264
  name: agentName.trim(),
1239
1265
  source: "cli"
1240
1266
  }, apiKey);
1241
- spinner.succeed(` Agent registered: ${chalk6.bold(agent.agent_id)}`);
1267
+ spinner.succeed(` Agent registered: ${chalk7.bold(agent.agent_id)}`);
1242
1268
  } catch (err) {
1243
1269
  spinner.fail(` Registration failed: ${err.message}`);
1244
1270
  process.exit(1);
@@ -1254,8 +1280,8 @@ async function registerAgentFlow(apiKey, ownerId) {
1254
1280
  });
1255
1281
  saveConfig({ lastAgentId: agent.agent_id, lastKeyPath: keyPath });
1256
1282
  } catch (err) {
1257
- console.error(chalk6.red(` \u2717 Failed to write local config: ${err.message}`));
1258
- console.log(chalk6.dim(" Agent was registered \u2014 run again to save config locally."));
1283
+ console.error(chalk7.red(` \u2717 Failed to write local config: ${err.message}`));
1284
+ console.log(chalk7.dim(" Agent was registered \u2014 run again to save config locally."));
1259
1285
  process.exit(1);
1260
1286
  }
1261
1287
  try {
@@ -1273,7 +1299,7 @@ async function registerAgentFlow(apiKey, ownerId) {
1273
1299
  const shouldSetup = await frameworkSetupConsent(detected);
1274
1300
  if (shouldSetup) {
1275
1301
  console.log("");
1276
- console.log(chalk6.bold(" Configuring agent frameworks..."));
1302
+ console.log(chalk7.bold(" Configuring agent frameworks..."));
1277
1303
  console.log("");
1278
1304
  const ideResults = await writeIdeConfigs({
1279
1305
  agentId: agent.agent_id,
@@ -1283,7 +1309,7 @@ async function registerAgentFlow(apiKey, ownerId) {
1283
1309
  detected
1284
1310
  });
1285
1311
  for (const r of ideResults) {
1286
- console.log(chalk6.green(` \u2713 ${r}`));
1312
+ console.log(chalk7.green(` \u2713 ${r}`));
1287
1313
  }
1288
1314
  const globalResults = await writeGlobalFrameworkConfigs({
1289
1315
  agentId: agent.agent_id,
@@ -1292,7 +1318,7 @@ async function registerAgentFlow(apiKey, ownerId) {
1292
1318
  keyPath
1293
1319
  });
1294
1320
  for (const r of globalResults) {
1295
- console.log(chalk6.green(` \u2713 ${r}`));
1321
+ console.log(chalk7.green(` \u2713 ${r}`));
1296
1322
  }
1297
1323
  if (detected.codex) {
1298
1324
  writeAgentsMd();
@@ -1310,11 +1336,11 @@ async function registerAgentFlow(apiKey, ownerId) {
1310
1336
  ensureMcpServer();
1311
1337
  } else if (shouldSetup === false) {
1312
1338
  console.log("");
1313
- console.log(chalk6.dim(" To configure agent frameworks manually:"));
1314
- console.log(chalk6.dim(" https://docs.agentvalet.ai/setup"));
1339
+ console.log(chalk7.dim(" To configure agent frameworks manually:"));
1340
+ console.log(chalk7.dim(" https://docs.agentvalet.ai/setup"));
1315
1341
  }
1316
1342
  console.log("");
1317
- console.log(chalk6.bold.green(" \u2713 All done!"));
1343
+ console.log(chalk7.bold.green(" \u2713 All done!"));
1318
1344
  console.log("");
1319
1345
  console.log(" Set these in your environment:");
1320
1346
  console.log("");
@@ -1325,26 +1351,26 @@ async function registerAgentFlow(apiKey, ownerId) {
1325
1351
  AGENT_PRIVATE_KEY_PATH: path6.join(process.cwd(), ".agentvalet", "agent.key")
1326
1352
  }));
1327
1353
  console.log("");
1328
- console.log(chalk6.dim(" Private key also saved to: .agentvalet/agent.key"));
1329
- console.log(chalk6.dim(" Add .agentvalet/ to your .gitignore"));
1354
+ console.log(chalk7.dim(" Private key also saved to: .agentvalet/agent.key"));
1355
+ console.log(chalk7.dim(" Add .agentvalet/ to your .gitignore"));
1330
1356
  console.log("");
1331
1357
  console.log(
1332
- ` Dashboard: ${chalk6.cyan.underline("https://app.agentvalet.ai")}`
1358
+ ` Dashboard: ${chalk7.cyan.underline("https://app.agentvalet.ai")}`
1333
1359
  );
1334
- console.log(chalk6.dim(" Approve this agent in your dashboard to activate it."));
1360
+ console.log(chalk7.dim(" Approve this agent in your dashboard to activate it."));
1335
1361
  console.log("");
1336
1362
  console.log(" Useful commands:");
1337
- console.log(chalk6.dim(" npx @agentvalet/register \u2014 register another agent"));
1338
- console.log(chalk6.dim(" npx @agentvalet/register refresh \u2014 refresh approved permissions"));
1363
+ console.log(chalk7.dim(" npx @agentvalet/register \u2014 register another agent"));
1364
+ console.log(chalk7.dim(" npx @agentvalet/register refresh \u2014 refresh approved permissions"));
1339
1365
  console.log("");
1340
1366
  }
1341
1367
  function showCredentials(config) {
1342
1368
  console.log("");
1343
1369
  console.log(" Your AgentValet credentials:");
1344
1370
  console.log("");
1345
- console.log(` Owner ID: ${chalk6.bold(config.ownerId)}`);
1346
- console.log(` Proxy URL: ${chalk6.bold(config.proxyUrl)}`);
1347
- console.log(` Email: ${chalk6.bold(config.email)}`);
1371
+ console.log(` Owner ID: ${chalk7.bold(config.ownerId)}`);
1372
+ console.log(` Proxy URL: ${chalk7.bold(config.proxyUrl)}`);
1373
+ console.log(` Email: ${chalk7.bold(config.email)}`);
1348
1374
  console.log("");
1349
1375
  }
1350
1376
 
@@ -1353,7 +1379,7 @@ function collectScope(value, previous) {
1353
1379
  return [...previous, value];
1354
1380
  }
1355
1381
  var program = new Command();
1356
- program.name("agentvalet-register").description("Self-register an AI agent with AgentValet").version("0.4.4").option("--owner <uuid>", "Owner ID (or set AGENTVALET_OWNER env var)").option("--name <name>", "Agent name").option("--description <desc>", "Agent description").option("--scope <platform:scope>", "Requested scope, repeatable", collectScope, []).option("--api-url <url>", "AgentValet API base URL", "https://api.agentvalet.ai").option("--output <path>", "Path to write .env file", "./.env.agentvalet").option("--key-path <path>", "Path to write private key", "./agentvalet.key").option("--json", "Machine-readable JSON output").option("--no-wait", "Register only, do not wait for approval").option("--timeout <seconds>", "Approval wait timeout in seconds", "300").action(async (opts) => {
1382
+ program.name("agentvalet-register").description("Self-register an AI agent with AgentValet").version("0.4.5").option("--owner <uuid>", "Owner ID (or set AGENTVALET_OWNER env var)").option("--name <name>", "Agent name").option("--description <desc>", "Agent description").option("--scope <platform:scope>", "Requested scope, repeatable", collectScope, []).option("--api-url <url>", "AgentValet API base URL", "https://api.agentvalet.ai").option("--output <path>", "Path to write .env file", "./.env.agentvalet").option("--key-path <path>", "Path to write private key", "./agentvalet.key").option("--json", "Machine-readable JSON output").option("--no-wait", "Register only, do not wait for approval").option("--timeout <seconds>", "Approval wait timeout in seconds", "300").action(async (opts) => {
1357
1383
  const isJson = !!opts.json;
1358
1384
  let ownerId = opts.owner ?? process.env.AGENTVALET_OWNER ?? "";
1359
1385
  let agentName = opts.name ?? "";
@@ -1379,7 +1405,7 @@ program.name("agentvalet-register").description("Self-register an AI agent with
1379
1405
  console.error(JSON.stringify({ error: "--owner or AGENTVALET_OWNER is required" }));
1380
1406
  process.exit(3);
1381
1407
  }
1382
- console.error(chalk7.red("Error: --owner or AGENTVALET_OWNER environment variable is required"));
1408
+ console.error(chalk8.red("Error: --owner or AGENTVALET_OWNER environment variable is required"));
1383
1409
  process.exit(3);
1384
1410
  }
1385
1411
  const scopeMap = /* @__PURE__ */ new Map();
@@ -1387,7 +1413,7 @@ program.name("agentvalet-register").description("Self-register an AI agent with
1387
1413
  const colon = s.indexOf(":");
1388
1414
  if (colon === -1) {
1389
1415
  console.error(
1390
- isJson ? JSON.stringify({ error: `Invalid scope format: ${s} (expected platform:scope)` }) : chalk7.red(`Invalid scope format: ${s} (expected platform:scope)`)
1416
+ isJson ? JSON.stringify({ error: `Invalid scope format: ${s} (expected platform:scope)` }) : chalk8.red(`Invalid scope format: ${s} (expected platform:scope)`)
1391
1417
  );
1392
1418
  process.exit(3);
1393
1419
  }
@@ -1410,11 +1436,11 @@ program.name("agentvalet-register").description("Self-register an AI agent with
1410
1436
  });
1411
1437
  } catch (err) {
1412
1438
  const msg = err instanceof Error ? err.message : String(err);
1413
- console.error(isJson ? JSON.stringify({ error: msg }) : chalk7.red(`Registration failed: ${msg}`));
1439
+ console.error(isJson ? JSON.stringify({ error: msg }) : chalk8.red(`Registration failed: ${msg}`));
1414
1440
  process.exit(3);
1415
1441
  }
1416
1442
  if (!isJson) {
1417
- console.log(chalk7.cyan(`
1443
+ console.log(chalk8.cyan(`
1418
1444
  Approve at: https://app.agentvalet.ai/agents
1419
1445
  `));
1420
1446
  }
@@ -1422,7 +1448,7 @@ Approve at: https://app.agentvalet.ai/agents
1422
1448
  if (isJson) {
1423
1449
  console.log(JSON.stringify({ status: "pending", token }));
1424
1450
  } else {
1425
- console.log(chalk7.yellow("Registration submitted (--no-wait). Token:"), token);
1451
+ console.log(chalk8.yellow("Registration submitted (--no-wait). Token:"), token);
1426
1452
  }
1427
1453
  process.exit(0);
1428
1454
  }
@@ -1433,14 +1459,14 @@ Approve at: https://app.agentvalet.ai/agents
1433
1459
  });
1434
1460
  } catch (err) {
1435
1461
  const msg = err instanceof Error ? err.message : String(err);
1436
- console.error(isJson ? JSON.stringify({ error: msg }) : chalk7.red(`Wait failed: ${msg}`));
1462
+ console.error(isJson ? JSON.stringify({ error: msg }) : chalk8.red(`Wait failed: ${msg}`));
1437
1463
  process.exit(3);
1438
1464
  }
1439
1465
  if (result.status === "rejected") {
1440
1466
  if (isJson) {
1441
1467
  console.log(JSON.stringify({ status: "rejected" }));
1442
1468
  } else {
1443
- console.log(chalk7.red("\nRegistration denied by owner."));
1469
+ console.log(chalk8.red("\nRegistration denied by owner."));
1444
1470
  }
1445
1471
  process.exit(1);
1446
1472
  }
@@ -1448,7 +1474,7 @@ Approve at: https://app.agentvalet.ai/agents
1448
1474
  if (isJson) {
1449
1475
  console.log(JSON.stringify({ status: "timeout" }));
1450
1476
  } else {
1451
- console.log(chalk7.yellow("\nTimed out waiting for approval."));
1477
+ console.log(chalk8.yellow("\nTimed out waiting for approval."));
1452
1478
  }
1453
1479
  process.exit(2);
1454
1480
  }
@@ -1467,7 +1493,7 @@ Approve at: https://app.agentvalet.ai/agents
1467
1493
  }));
1468
1494
  } catch (err) {
1469
1495
  const msg = err instanceof Error ? err.message : String(err);
1470
- console.error(isJson ? JSON.stringify({ error: msg }) : chalk7.red(`Failed to save output: ${msg}`));
1496
+ console.error(isJson ? JSON.stringify({ error: msg }) : chalk8.red(`Failed to save output: ${msg}`));
1471
1497
  process.exit(3);
1472
1498
  }
1473
1499
  const keyWritten = !!privateKey;
@@ -1477,23 +1503,23 @@ Approve at: https://app.agentvalet.ai/agents
1477
1503
  if (isJson) {
1478
1504
  console.log(JSON.stringify({ status: "approved", agentId, keyPath: keyWritten ? keyPath : null, envPath }));
1479
1505
  } else {
1480
- console.log(chalk7.green(`
1506
+ console.log(chalk8.green(`
1481
1507
  Approved! Agent ID: ${agentId}`));
1482
1508
  if (keyWritten) {
1483
- console.log(chalk7.gray(`Key: ${keyPath}`));
1509
+ console.log(chalk8.gray(`Key: ${keyPath}`));
1484
1510
  } else {
1485
- console.log(chalk7.yellow(`Key: not written \u2014 copy it from the dashboard and paste into ${keyPath}`));
1511
+ console.log(chalk8.yellow(`Key: not written \u2014 copy it from the dashboard and paste into ${keyPath}`));
1486
1512
  }
1487
- console.log(chalk7.gray(`Env file: ${envPath}`));
1513
+ console.log(chalk8.gray(`Env file: ${envPath}`));
1488
1514
  console.log(`
1489
1515
  Source the env file before calling any tool:`);
1490
- console.log(chalk7.cyan(` source ${envPath}`));
1516
+ console.log(chalk8.cyan(` source ${envPath}`));
1491
1517
  }
1492
1518
  if (keyWritten) {
1493
1519
  try {
1494
1520
  if (grantedPlatforms && grantedPlatforms.length > 0) {
1495
1521
  writePermissionsFromEvent(agentId, resolvedOwnerId, grantedPlatforms);
1496
- if (!isJson) console.log(chalk7.gray(`Permissions: .claude/agentvalet-permissions.md`));
1522
+ if (!isJson) console.log(chalk8.gray(`Permissions: .claude/agentvalet-permissions.md`));
1497
1523
  } else {
1498
1524
  await runRefresh({
1499
1525
  envFile: opts.output,
@@ -1501,10 +1527,10 @@ Source the env file before calling any tool:`);
1501
1527
  ifStale: false,
1502
1528
  quiet: isJson
1503
1529
  });
1504
- if (!isJson) console.log(chalk7.gray(`Permissions: .claude/agentvalet-permissions.md`));
1530
+ if (!isJson) console.log(chalk8.gray(`Permissions: .claude/agentvalet-permissions.md`));
1505
1531
  }
1506
1532
  } catch {
1507
- if (!isJson) console.log(chalk7.yellow(`Permissions: run 'agentvalet-register refresh' to generate`));
1533
+ if (!isJson) console.log(chalk8.yellow(`Permissions: run 'agentvalet-register refresh' to generate`));
1508
1534
  }
1509
1535
  }
1510
1536
  process.exit(0);
@@ -1519,7 +1545,7 @@ program.command("refresh").description("Refresh approved permissions and update
1519
1545
  });
1520
1546
  } catch (err) {
1521
1547
  const msg = err instanceof Error ? err.message : String(err);
1522
- console.error(chalk7.red(`Refresh failed: ${msg}`));
1548
+ console.error(chalk8.red(`Refresh failed: ${msg}`));
1523
1549
  process.exit(3);
1524
1550
  }
1525
1551
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentvalet/register",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "description": "Self-register AI agents with AgentValet",
5
5
  "type": "module",
6
6
  "bin": {