@agentvalet/register 1.0.1 → 1.0.2
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 +23 -13
- package/package.json +65 -64
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
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
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({
|
|
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.
|
|
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("
|
|
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
|
|
2325
|
+
console.log(chalk12.bold("\n Binding agent\u2026"));
|
|
2320
2326
|
let claim;
|
|
2321
2327
|
try {
|
|
2322
|
-
claim = await
|
|
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("
|
|
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
|
|
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 } =
|
|
2540
|
+
const { publicKey, privateKey } = generateKeyPairSync2("rsa", {
|
|
2531
2541
|
modulusLength: 2048,
|
|
2532
2542
|
publicKeyEncoding: { type: "spki", format: "pem" },
|
|
2533
2543
|
privateKeyEncoding: { type: "pkcs8", format: "pem" }
|
package/package.json
CHANGED
|
@@ -1,64 +1,65 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@agentvalet/register",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Self-register AI agents with AgentValet",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"bin": {
|
|
7
|
-
"agentvalet-register": "dist/index.js"
|
|
8
|
-
},
|
|
9
|
-
"files": [
|
|
10
|
-
"dist",
|
|
11
|
-
"README.md"
|
|
12
|
-
],
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
},
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"
|
|
47
|
-
},
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
|
|
64
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@agentvalet/register",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "Self-register AI agents with AgentValet",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"agentvalet-register": "dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsup src/index.ts --format esm --dts --clean --shims",
|
|
15
|
+
"dev": "tsx src/index.ts",
|
|
16
|
+
"test": "vitest run",
|
|
17
|
+
"typecheck": "tsc --noEmit",
|
|
18
|
+
"prepublishOnly": "pnpm build"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@agentvalet/mcp-server": "workspace:^",
|
|
22
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
23
|
+
"@octokit/auth-oauth-device": "^7.0.0",
|
|
24
|
+
"chalk": "^5.3.0",
|
|
25
|
+
"commander": "^12.0.0",
|
|
26
|
+
"conf": "^13.0.0",
|
|
27
|
+
"jose": "^6.2.2",
|
|
28
|
+
"open": "^10.0.0",
|
|
29
|
+
"ora": "^8.0.1",
|
|
30
|
+
"prompts": "^2.4.2",
|
|
31
|
+
"undici": "^6.0.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/node": "^20.0.0",
|
|
35
|
+
"@types/prompts": "^2.4.0",
|
|
36
|
+
"tsup": "^8.0.0",
|
|
37
|
+
"tsx": "^4.0.0",
|
|
38
|
+
"typescript": "^5.0.0",
|
|
39
|
+
"vitest": "^1.5.0"
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=18"
|
|
43
|
+
},
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "git+https://github.com/agentvalet/agentvalet.git"
|
|
47
|
+
},
|
|
48
|
+
"homepage": "https://agentvalet.ai",
|
|
49
|
+
"bugs": {
|
|
50
|
+
"url": "https://github.com/agentvalet/agentvalet/issues"
|
|
51
|
+
},
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"access": "public"
|
|
54
|
+
},
|
|
55
|
+
"keywords": [
|
|
56
|
+
"ai",
|
|
57
|
+
"agents",
|
|
58
|
+
"auth",
|
|
59
|
+
"credentials",
|
|
60
|
+
"mcp",
|
|
61
|
+
"valet",
|
|
62
|
+
"agentvalet"
|
|
63
|
+
],
|
|
64
|
+
"license": "MIT"
|
|
65
|
+
}
|