@agentvalet/register 0.4.6 → 0.4.7

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 +26 -39
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1378,33 +1378,20 @@ function showCredentials(config) {
1378
1378
  import { Command } from "commander";
1379
1379
  import chalk8 from "chalk";
1380
1380
 
1381
- // src/lib/config.ts
1382
- import { homedir } from "os";
1383
- import { join as join2 } from "path";
1384
- import { readFile as readFile3, writeFile as writeFile6, mkdir as mkdir4 } from "fs/promises";
1385
- var CONFIG_PATH = join2(homedir(), ".agentvalet", "config.json");
1386
- var DEFAULTS = {
1387
- apiUrl: "https://app.agentvalet.ai",
1388
- token: null
1389
- };
1390
- async function loadConfig() {
1391
- try {
1392
- const raw = await readFile3(CONFIG_PATH, "utf-8");
1393
- return { ...DEFAULTS, ...JSON.parse(raw) };
1394
- } catch (err) {
1395
- if (err.code === "ENOENT") return { ...DEFAULTS };
1396
- throw err;
1397
- }
1398
- }
1399
-
1400
1381
  // src/lib/api.ts
1401
1382
  async function request(path7, options) {
1402
- const config = await loadConfig();
1403
- if (!config.token) throw new Error("Not authenticated. Run: agentvalet login");
1404
- const response = await fetch(`${config.apiUrl}/functions/v1${path7}`, {
1383
+ const config = getStoredConfig();
1384
+ const token = config.cliToken;
1385
+ if (!token) {
1386
+ throw new Error(
1387
+ "Not authenticated.\nRun 'npx @agentvalet/register' to register and authenticate."
1388
+ );
1389
+ }
1390
+ const proxyUrl = config.proxyUrl ?? "https://api.agentvalet.ai";
1391
+ const response = await fetch(`${proxyUrl}/functions/v1${path7}`, {
1405
1392
  method: options.method,
1406
1393
  headers: {
1407
- "Authorization": `Bearer ${config.token}`,
1394
+ "Authorization": `Bearer ${token}`,
1408
1395
  "Content-Type": "application/json"
1409
1396
  },
1410
1397
  body: options.body ? JSON.stringify(options.body) : void 0
@@ -1426,7 +1413,7 @@ async function listAgents() {
1426
1413
  function listCommand() {
1427
1414
  return new Command("list").description("List all registered agents").action(async () => {
1428
1415
  const config = getStoredConfig();
1429
- if (!config.ownerId) {
1416
+ if (!config.cliToken) {
1430
1417
  process.stderr.write(
1431
1418
  chalk8.red("\n \u2717 No agent registered.\n") + chalk8.dim(" Run the following command first:\n\n npx @agentvalet/register\n\n")
1432
1419
  );
@@ -1460,7 +1447,7 @@ import * as readline from "readline";
1460
1447
  function revokeCommand() {
1461
1448
  return new Command2("revoke").description("Revoke an agent (cascades to all child agents)").requiredOption("--agent-id <agentId>", "Agent ID to revoke (agt_...)").action(async (opts) => {
1462
1449
  const config = getStoredConfig();
1463
- if (!config.ownerId) {
1450
+ if (!config.cliToken) {
1464
1451
  process.stderr.write(
1465
1452
  chalk9.red("\n \u2717 No agent registered.\n") + chalk9.dim(" Run the following command first:\n\n npx @agentvalet/register\n\n")
1466
1453
  );
@@ -1496,29 +1483,29 @@ function revokeCommand() {
1496
1483
  // src/commands/inject.ts
1497
1484
  import { Command as Command3 } from "commander";
1498
1485
  import chalk10 from "chalk";
1499
- import { readFile as readFile6 } from "fs/promises";
1486
+ import { readFile as readFile5 } from "fs/promises";
1500
1487
 
1501
1488
  // src/lib/claude-config.ts
1502
- import { homedir as homedir2 } from "os";
1503
- import { join as join3 } from "path";
1504
- import { readFile as readFile4, writeFile as writeFile7, mkdir as mkdir5, access } from "fs/promises";
1505
- var CLAUDE_CONFIG_PATH = join3(homedir2(), ".claude", "config");
1489
+ import { homedir } from "os";
1490
+ import { join as join2 } from "path";
1491
+ import { readFile as readFile3, writeFile as writeFile6, mkdir as mkdir4, access } from "fs/promises";
1492
+ var CLAUDE_CONFIG_PATH = join2(homedir(), ".claude", "config");
1506
1493
  async function writeKeyToClaudeConfig(agentId, privateKeyPem) {
1507
1494
  let config = {};
1508
1495
  try {
1509
1496
  await access(CLAUDE_CONFIG_PATH);
1510
- const raw = await readFile4(CLAUDE_CONFIG_PATH, "utf-8");
1497
+ const raw = await readFile3(CLAUDE_CONFIG_PATH, "utf-8");
1511
1498
  config = JSON.parse(raw);
1512
1499
  } catch {
1513
1500
  }
1514
1501
  config.agent_keys = config.agent_keys ?? {};
1515
1502
  config.agent_keys[agentId] = Buffer.from(privateKeyPem).toString("base64");
1516
- await mkdir5(join3(homedir2(), ".claude"), { recursive: true });
1517
- await writeFile7(CLAUDE_CONFIG_PATH, JSON.stringify(config, null, 2), "utf-8");
1503
+ await mkdir4(join2(homedir(), ".claude"), { recursive: true });
1504
+ await writeFile6(CLAUDE_CONFIG_PATH, JSON.stringify(config, null, 2), "utf-8");
1518
1505
  }
1519
1506
 
1520
1507
  // src/lib/env-writer.ts
1521
- import { readFile as readFile5, writeFile as writeFile8, access as access2 } from "fs/promises";
1508
+ import { readFile as readFile4, writeFile as writeFile7, access as access2 } from "fs/promises";
1522
1509
  var ENV_VAR_NAME = (agentId) => `AGENTVALET_PRIVATE_KEY_${agentId.replace(/-/g, "_").toUpperCase()}`;
1523
1510
  async function writeKeyToEnvLocal(agentId, privateKeyPem) {
1524
1511
  const varName = ENV_VAR_NAME(agentId);
@@ -1530,15 +1517,15 @@ ${varName}=${b64Key}
1530
1517
  let existing = "";
1531
1518
  try {
1532
1519
  await access2(".env.local");
1533
- existing = await readFile5(".env.local", "utf-8");
1520
+ existing = await readFile4(".env.local", "utf-8");
1534
1521
  } catch {
1535
1522
  }
1536
1523
  if (existing.includes(varName)) {
1537
1524
  const lines = existing.split("\n");
1538
1525
  const filtered = lines.filter((l) => !l.startsWith(`${varName}=`));
1539
- await writeFile8(".env.local", filtered.join("\n") + line, "utf-8");
1526
+ await writeFile7(".env.local", filtered.join("\n") + line, "utf-8");
1540
1527
  } else {
1541
- await writeFile8(".env.local", existing + line, "utf-8");
1528
+ await writeFile7(".env.local", existing + line, "utf-8");
1542
1529
  }
1543
1530
  }
1544
1531
 
@@ -1547,7 +1534,7 @@ function injectCommand() {
1547
1534
  return new Command3("inject").description("Inject agent private key into Claude Code config or .env.local").requiredOption("--agent-id <agentId>", "Agent ID (agt_...)").requiredOption("--key-file <path>", "Path to the private key PEM file").option("--target <target>", "Injection target: claude-code or env-local", "claude-code").action(async (opts) => {
1548
1535
  let privateKeyPem;
1549
1536
  try {
1550
- privateKeyPem = await readFile6(opts.keyFile, "utf-8");
1537
+ privateKeyPem = await readFile5(opts.keyFile, "utf-8");
1551
1538
  } catch {
1552
1539
  console.error(chalk10.red(`Could not read key file: ${opts.keyFile}`));
1553
1540
  process.exit(1);
@@ -1585,7 +1572,7 @@ function collectScope(value, previous) {
1585
1572
  return [...previous, value];
1586
1573
  }
1587
1574
  var program = new Command4();
1588
- program.name("agentvalet-register").description("Self-register an AI agent with AgentValet").version("0.4.6").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) => {
1575
+ program.name("agentvalet-register").description("Self-register an AI agent with AgentValet").version("0.4.7").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) => {
1589
1576
  const isJson = !!opts.json;
1590
1577
  let ownerId = opts.owner ?? process.env.AGENTVALET_OWNER ?? "";
1591
1578
  let agentName = opts.name ?? "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentvalet/register",
3
- "version": "0.4.6",
3
+ "version": "0.4.7",
4
4
  "description": "Self-register AI agents with AgentValet",
5
5
  "type": "module",
6
6
  "bin": {