@agentvalet/register 1.0.1 → 1.0.3

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 CHANGED
@@ -2283,16 +2283,22 @@ function injectCommand() {
2283
2283
  // src/commands/install.ts
2284
2284
  import { writeFile as writeFile9, mkdir as mkdir6 } from "fs/promises";
2285
2285
  import path7 from "path";
2286
+ import { generateKeyPairSync } from "crypto";
2286
2287
  import { Command as Command5 } from "commander";
2287
2288
  import chalk12 from "chalk";
2288
2289
  import prompts4 from "prompts";
2289
2290
  var API_URL3 = process.env.AGENTVALET_API_URL ?? "https://api.agentvalet.ai";
2290
- var CLAIM_URL = `${API_URL3}/functions/v1/cli-claim-agent`;
2291
- async function claimToken(installToken) {
2292
- const resp = await fetch(CLAIM_URL, {
2291
+ async function bindInstallToken(proxyUrl, bootstrapToken) {
2292
+ const { publicKey, privateKey } = generateKeyPairSync("rsa", {
2293
+ modulusLength: 2048,
2294
+ publicKeyEncoding: { type: "spki", format: "pem" },
2295
+ privateKeyEncoding: { type: "pkcs8", format: "pem" }
2296
+ });
2297
+ const url = `${proxyUrl.replace(/\/$/, "")}/v1/agents/bind`;
2298
+ const resp = await fetch(url, {
2293
2299
  method: "POST",
2294
2300
  headers: { "Content-Type": "application/json" },
2295
- body: JSON.stringify({ install_token: installToken })
2301
+ body: JSON.stringify({ bootstrap_token: bootstrapToken, public_key_pem: publicKey })
2296
2302
  });
2297
2303
  const text = await resp.text();
2298
2304
  let body = null;
@@ -2304,32 +2310,36 @@ async function claimToken(installToken) {
2304
2310
  const detail = body?.error ?? text ?? `HTTP ${resp.status}`;
2305
2311
  throw new Error(detail);
2306
2312
  }
2307
- if (!body || !body.agent_id || !body.private_key_pem) {
2313
+ if (!body || !body.agent_id || !body.owner_id || !body.proxy_url) {
2308
2314
  throw new Error("Server returned an unexpected response");
2309
2315
  }
2310
- return body;
2316
+ return { ...body, privateKeyPem: privateKey };
2311
2317
  }
2312
2318
  function installCommand() {
2313
- return new Command5("install").description("Claim an agent created in the dashboard using a one-time install token").argument("<token>", "install token (itok_...) from the dashboard").option("--no-frameworks", "skip IDE/framework configuration prompts").option("--project", "write project-scoped configs (.mcp.json, .cursor/mcp.json) instead of user-scoped (~/.claude.json, ~/.cursor/mcp.json)").action(async (token, opts) => {
2319
+ return new Command5("install").description("Install an agent on this machine using a one-time install token (generates the keypair locally and binds it)").argument("<token>", "install token (itok_...) from the dashboard").option("--no-frameworks", "skip IDE/framework configuration prompts").option("--project", "write project-scoped configs (.mcp.json, .cursor/mcp.json) instead of user-scoped (~/.claude.json, ~/.cursor/mcp.json)").action(async (token, opts) => {
2314
2320
  const scope = opts.project ? "project" : "user";
2315
2321
  if (!token.startsWith("itok_")) {
2316
2322
  console.error(chalk12.red('Invalid install token. Tokens start with "itok_".'));
2317
2323
  process.exit(3);
2318
2324
  }
2319
- console.log(chalk12.bold("\n Claiming agent\u2026"));
2325
+ console.log(chalk12.bold("\n Binding agent\u2026"));
2320
2326
  let claim;
2321
2327
  try {
2322
- claim = await claimToken(token);
2328
+ claim = await bindInstallToken(API_URL3, token);
2323
2329
  } catch (err) {
2324
2330
  const msg = err instanceof Error ? err.message : String(err);
2325
2331
  console.error(chalk12.red(`
2326
2332
  \u2717 ${msg}`));
2327
- if (msg.toLowerCase().includes("expired") || msg.toLowerCase().includes("not found")) {
2333
+ if (msg.toLowerCase().includes("expired") || msg.toLowerCase().includes("invalid") || msg.toLowerCase().includes("used")) {
2328
2334
  console.error(chalk12.dim(" Generate a fresh install command from app.agentvalet.ai/agents"));
2329
2335
  }
2330
2336
  process.exit(3);
2331
2337
  }
2332
- const { agent_id, agent_name, owner_id, private_key_pem, proxy_url } = claim;
2338
+ const agent_id = claim.agent_id;
2339
+ const owner_id = claim.owner_id;
2340
+ const private_key_pem = claim.privateKeyPem;
2341
+ const proxy_url = claim.proxy_url;
2342
+ const agent_name = claim.agent_id;
2333
2343
  try {
2334
2344
  await mkdir6(AGENT_DIR, { recursive: true });
2335
2345
  await writeFile9(AGENT_KEY_PATH, private_key_pem, { mode: 384 });
@@ -2467,7 +2477,7 @@ function installCommand() {
2467
2477
 
2468
2478
  // src/commands/claim.ts
2469
2479
  import { Command as Command6 } from "commander";
2470
- import { generateKeyPairSync } from "crypto";
2480
+ import { generateKeyPairSync as generateKeyPairSync2 } from "crypto";
2471
2481
  import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync4, existsSync as existsSync8 } from "fs";
2472
2482
  import { homedir as homedir3 } from "os";
2473
2483
  import { join as join3 } from "path";
@@ -2527,7 +2537,7 @@ function claimCommand() {
2527
2537
  process.exit(3);
2528
2538
  }
2529
2539
  const proxyUrl = opts.apiUrl.replace(/\/$/, "");
2530
- const { publicKey, privateKey } = generateKeyPairSync("rsa", {
2540
+ const { publicKey, privateKey } = generateKeyPairSync2("rsa", {
2531
2541
  modulusLength: 2048,
2532
2542
  publicKeyEncoding: { type: "spki", format: "pem" },
2533
2543
  privateKeyEncoding: { type: "pkcs8", format: "pem" }
@@ -2781,7 +2791,7 @@ program.command("refresh").description("Refresh approved permissions and update
2781
2791
  }
2782
2792
  });
2783
2793
  program.command("mcp-server").description("Start the AgentValet MCP server (stdio transport)").action(async () => {
2784
- const { mcpServerCommand } = await import("./mcp-server-R3LG4PNM.js");
2794
+ const { mcpServerCommand } = await import("./mcp-server-77VYWZUZ.js");
2785
2795
  await mcpServerCommand();
2786
2796
  });
2787
2797
  program.addCommand(listCommand());
@@ -2,35 +2,25 @@
2
2
  import { spawn } from "child_process";
3
3
  import { createRequire } from "module";
4
4
  function resolveMcpServerBin() {
5
+ const require2 = createRequire(import.meta.url);
5
6
  try {
6
- const require2 = createRequire(import.meta.url);
7
7
  return require2.resolve("@agentvalet/mcp-server/dist/index.js");
8
8
  } catch {
9
9
  try {
10
- const require2 = createRequire(import.meta.url);
11
10
  const pkgRoot = require2.resolve("@agentvalet/mcp-server/package.json");
12
11
  return pkgRoot.replace("package.json", "dist/index.js");
13
12
  } catch {
14
- throw new Error(
15
- "@agentvalet/mcp-server is not installed. Run: npx @agentvalet/register"
16
- );
13
+ return null;
17
14
  }
18
15
  }
19
16
  }
20
17
  async function mcpServerCommand() {
21
- let binPath;
22
- try {
23
- binPath = resolveMcpServerBin();
24
- } catch (err) {
25
- process.stderr.write(
26
- `[agentvalet] ${err instanceof Error ? err.message : String(err)}
27
- `
28
- );
29
- process.exit(1);
30
- }
31
- const child = spawn(process.execPath, [binPath], {
18
+ const binPath = resolveMcpServerBin();
19
+ const [cmd, args] = binPath ? [process.execPath, [binPath]] : ["npx", ["--yes", "@agentvalet/mcp-server"]];
20
+ const child = spawn(cmd, args, {
32
21
  stdio: "inherit",
33
- env: process.env
22
+ env: process.env,
23
+ shell: process.platform === "win32"
34
24
  });
35
25
  child.on("error", (err) => {
36
26
  process.stderr.write(`[agentvalet] Failed to start MCP server: ${err.message}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentvalet/register",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Self-register AI agents with AgentValet",
5
5
  "type": "module",
6
6
  "bin": {
@@ -16,12 +16,10 @@
16
16
  "chalk": "^5.3.0",
17
17
  "commander": "^12.0.0",
18
18
  "conf": "^13.0.0",
19
- "jose": "^6.2.2",
20
19
  "open": "^10.0.0",
21
20
  "ora": "^8.0.1",
22
21
  "prompts": "^2.4.2",
23
- "undici": "^6.0.0",
24
- "@agentvalet/mcp-server": "^1.0.0"
22
+ "undici": "^6.0.0"
25
23
  },
26
24
  "devDependencies": {
27
25
  "@types/node": "^20.0.0",
@@ -29,7 +27,8 @@
29
27
  "tsup": "^8.0.0",
30
28
  "tsx": "^4.0.0",
31
29
  "typescript": "^5.0.0",
32
- "vitest": "^1.5.0"
30
+ "vitest": "^1.5.0",
31
+ "@agentvalet/mcp-server": "^1.4.1"
33
32
  },
34
33
  "engines": {
35
34
  "node": ">=18"