@agentvalet/register 0.4.8 → 0.4.10

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 +12 -50
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -448,55 +448,6 @@ function parseEnvFile(content) {
448
448
  }
449
449
  return result;
450
450
  }
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)) {
458
- try {
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;
491
- } catch {
492
- }
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
451
  function tryResolveAgent(envFile = ".env.agentvalet") {
501
452
  let agentId;
502
453
  let ownerId;
@@ -586,7 +537,12 @@ async function runRefresh(options) {
586
537
  } catch {
587
538
  }
588
539
  }
589
- const { agentId, ownerId, keyPath, apiUrl } = resolveAgent(options.envFile);
540
+ const creds = tryResolveAgent(options.envFile);
541
+ if (!creds || !existsSync3(resolve3(creds.keyPath))) {
542
+ console.error(" \u2717 No agent registered.\n Run the following command first to register an agent in this directory:\n\n npx @agentvalet/register\n");
543
+ process.exit(1);
544
+ }
545
+ const { agentId, ownerId, keyPath, apiUrl } = creds;
590
546
  let privateKeyPem;
591
547
  try {
592
548
  privateKeyPem = readFileSync3(keyPath, "utf-8");
@@ -1753,6 +1709,12 @@ function uninstallCommand() {
1753
1709
  body: JSON.stringify({ reason: "CLI uninstall" })
1754
1710
  });
1755
1711
  const body = await res.json();
1712
+ if (res.status === 404 || res.status === 409) {
1713
+ console.log(chalk11.yellow(` \u26A0 Agent not found on server (already revoked?) \u2014 cleaning local files.`));
1714
+ cleanLocally();
1715
+ console.log(chalk11.dim("\n To register a new agent: npx @agentvalet/register"));
1716
+ return;
1717
+ }
1756
1718
  if (!res.ok || !body.revocation_token) {
1757
1719
  throw new Error(body.error ?? `HTTP ${res.status}`);
1758
1720
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentvalet/register",
3
- "version": "0.4.8",
3
+ "version": "0.4.10",
4
4
  "description": "Self-register AI agents with AgentValet",
5
5
  "type": "module",
6
6
  "bin": {