@agentvalet/register 1.6.0 → 1.7.1
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 +29 -11
- package/package.json +12 -11
package/dist/index.js
CHANGED
|
@@ -265,12 +265,13 @@ import { dirname as dirname2, join as join2, resolve as resolve2 } from "path";
|
|
|
265
265
|
|
|
266
266
|
// src/lib/jwt.ts
|
|
267
267
|
import { createSign, createPrivateKey } from "crypto";
|
|
268
|
+
var AGENT_JWT_LIFETIME_SECONDS = 240;
|
|
268
269
|
function signJwt(agentId, ownerId, privateKeyPem) {
|
|
269
270
|
const now = Math.floor(Date.now() / 1e3);
|
|
270
271
|
const b64 = (s) => Buffer.from(s).toString("base64url");
|
|
271
272
|
const header = b64(JSON.stringify({ alg: "RS256", typ: "JWT" }));
|
|
272
273
|
const payload = b64(
|
|
273
|
-
JSON.stringify({ agent_id: agentId, owner_id: ownerId, iat: now, exp: now +
|
|
274
|
+
JSON.stringify({ agent_id: agentId, owner_id: ownerId, iat: now, exp: now + AGENT_JWT_LIFETIME_SECONDS })
|
|
274
275
|
);
|
|
275
276
|
const signingInput = `${header}.${payload}`;
|
|
276
277
|
const sign = createSign("RSA-SHA256");
|
|
@@ -1263,6 +1264,7 @@ async function browserLogin() {
|
|
|
1263
1264
|
}
|
|
1264
1265
|
|
|
1265
1266
|
// src/api/agentvalet.ts
|
|
1267
|
+
import { generateKeyPairSync } from "crypto";
|
|
1266
1268
|
var API_URL2 = process.env.AGENTVALET_API_URL ?? "https://api.agentvalet.ai";
|
|
1267
1269
|
var FUNCTIONS_URL2 = `${API_URL2}/functions/v1`;
|
|
1268
1270
|
var baseHeaders = {
|
|
@@ -1295,6 +1297,20 @@ async function registerAgent2(params, apiKey) {
|
|
|
1295
1297
|
clearTimeout(timeout);
|
|
1296
1298
|
}
|
|
1297
1299
|
}
|
|
1300
|
+
async function registerAgentWithLocalKey(params, apiKey) {
|
|
1301
|
+
const { publicKey, privateKey } = generateKeyPairSync("rsa", {
|
|
1302
|
+
modulusLength: 2048,
|
|
1303
|
+
publicKeyEncoding: { type: "spki", format: "pem" },
|
|
1304
|
+
privateKeyEncoding: { type: "pkcs8", format: "pem" }
|
|
1305
|
+
});
|
|
1306
|
+
const agent = await registerAgent2({ ...params, public_key_pem: publicKey }, apiKey);
|
|
1307
|
+
if (agent.private_key_pem || agent.public_key_pem?.trim() !== publicKey.trim()) {
|
|
1308
|
+
throw new Error(
|
|
1309
|
+
`The server did not accept this machine's public key, so agent ${agent.agent_id} cannot use it. Delete that agent in the dashboard and try again later, or report this to AgentValet support.`
|
|
1310
|
+
);
|
|
1311
|
+
}
|
|
1312
|
+
return { agent, privateKeyPem: privateKey };
|
|
1313
|
+
}
|
|
1298
1314
|
|
|
1299
1315
|
// src/config/local.ts
|
|
1300
1316
|
import { mkdir as mkdir2, writeFile as writeFile2, appendFile, readFile } from "fs/promises";
|
|
@@ -1696,13 +1712,14 @@ async function registerAgentFlow(apiKey, ownerId, scope = "user", presetName) {
|
|
|
1696
1712
|
const agentType = resolveAgentType(detectedAtRegister);
|
|
1697
1713
|
const spinner = ora(" Registering agent...").start();
|
|
1698
1714
|
let agent;
|
|
1715
|
+
let privateKeyPem;
|
|
1699
1716
|
try {
|
|
1700
|
-
agent = await
|
|
1717
|
+
({ agent, privateKeyPem } = await registerAgentWithLocalKey({
|
|
1701
1718
|
owner_id: ownerId,
|
|
1702
1719
|
name: agentName.trim(),
|
|
1703
1720
|
source: "cli",
|
|
1704
1721
|
agent_type: agentType
|
|
1705
|
-
}, apiKey);
|
|
1722
|
+
}, apiKey));
|
|
1706
1723
|
spinner.succeed(` Agent registered: ${chalk7.bold(agent.agent_id)}`);
|
|
1707
1724
|
} catch (err) {
|
|
1708
1725
|
spinner.fail(` Registration failed: ${err.message}`);
|
|
@@ -1715,7 +1732,7 @@ async function registerAgentFlow(apiKey, ownerId, scope = "user", presetName) {
|
|
|
1715
1732
|
agentId: agent.agent_id,
|
|
1716
1733
|
agentName: agent.agent_name,
|
|
1717
1734
|
proxyUrl,
|
|
1718
|
-
privateKeyPem
|
|
1735
|
+
privateKeyPem
|
|
1719
1736
|
});
|
|
1720
1737
|
saveConfig({ lastAgentId: agent.agent_id, lastKeyPath: keyPath });
|
|
1721
1738
|
} catch (err) {
|
|
@@ -1811,7 +1828,7 @@ async function registerAgentFlow(apiKey, ownerId, scope = "user", presetName) {
|
|
|
1811
1828
|
console.log(
|
|
1812
1829
|
` Dashboard: ${chalk7.cyan.underline("https://app.agentvalet.ai")}`
|
|
1813
1830
|
);
|
|
1814
|
-
console.log(chalk7.dim("
|
|
1831
|
+
console.log(chalk7.dim(" The agent is active but has no access yet. Grant it platforms on its page in the dashboard."));
|
|
1815
1832
|
console.log("");
|
|
1816
1833
|
if (shouldSetup) {
|
|
1817
1834
|
if (scope === "user") {
|
|
@@ -2447,13 +2464,13 @@ function injectCommand() {
|
|
|
2447
2464
|
// src/commands/install.ts
|
|
2448
2465
|
import { writeFile as writeFile9, mkdir as mkdir6 } from "fs/promises";
|
|
2449
2466
|
import path7 from "path";
|
|
2450
|
-
import { generateKeyPairSync } from "crypto";
|
|
2467
|
+
import { generateKeyPairSync as generateKeyPairSync2 } from "crypto";
|
|
2451
2468
|
import { Command as Command5 } from "commander";
|
|
2452
2469
|
import chalk12 from "chalk";
|
|
2453
2470
|
import prompts4 from "prompts";
|
|
2454
2471
|
var API_URL3 = process.env.AGENTVALET_API_URL ?? "https://api.agentvalet.ai";
|
|
2455
2472
|
async function bindInstallToken(proxyUrl, bootstrapToken) {
|
|
2456
|
-
const { publicKey, privateKey } =
|
|
2473
|
+
const { publicKey, privateKey } = generateKeyPairSync2("rsa", {
|
|
2457
2474
|
modulusLength: 2048,
|
|
2458
2475
|
publicKeyEncoding: { type: "spki", format: "pem" },
|
|
2459
2476
|
privateKeyEncoding: { type: "pkcs8", format: "pem" }
|
|
@@ -2648,7 +2665,7 @@ function installCommand() {
|
|
|
2648
2665
|
|
|
2649
2666
|
// src/commands/claim.ts
|
|
2650
2667
|
import { Command as Command6 } from "commander";
|
|
2651
|
-
import { generateKeyPairSync as
|
|
2668
|
+
import { generateKeyPairSync as generateKeyPairSync3 } from "crypto";
|
|
2652
2669
|
import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync4, existsSync as existsSync9 } from "fs";
|
|
2653
2670
|
import { homedir as homedir3 } from "os";
|
|
2654
2671
|
import { join as join5 } from "path";
|
|
@@ -2708,7 +2725,7 @@ function claimCommand() {
|
|
|
2708
2725
|
process.exit(3);
|
|
2709
2726
|
}
|
|
2710
2727
|
const proxyUrl = opts.apiUrl.replace(/\/$/, "");
|
|
2711
|
-
const { publicKey, privateKey } =
|
|
2728
|
+
const { publicKey, privateKey } = generateKeyPairSync3("rsa", {
|
|
2712
2729
|
modulusLength: 2048,
|
|
2713
2730
|
publicKeyEncoding: { type: "spki", format: "pem" },
|
|
2714
2731
|
privateKeyEncoding: { type: "pkcs8", format: "pem" }
|
|
@@ -2818,9 +2835,10 @@ function respondToCredentialRequest(action, request2, creds, privateKeyPem) {
|
|
|
2818
2835
|
password=${jwt}
|
|
2819
2836
|
`;
|
|
2820
2837
|
}
|
|
2838
|
+
var GIT_HELPER_COMMAND = "npx --yes @agentvalet/register git-credential";
|
|
2821
2839
|
function gitConfigLine(apiUrl) {
|
|
2822
2840
|
const origin = new URL(apiUrl).origin;
|
|
2823
|
-
return [`credential.${origin}.helper`,
|
|
2841
|
+
return [`credential.${origin}.helper`, `!${GIT_HELPER_COMMAND}`];
|
|
2824
2842
|
}
|
|
2825
2843
|
async function readStdin() {
|
|
2826
2844
|
const chunks = [];
|
|
@@ -2828,7 +2846,7 @@ async function readStdin() {
|
|
|
2828
2846
|
return Buffer.concat(chunks).toString("utf8");
|
|
2829
2847
|
}
|
|
2830
2848
|
function gitCredentialCommand() {
|
|
2831
|
-
return new Command7("git-credential").description("git credential helper: answers the AgentValet proxy with this agent's JWT (used via `agentvalet git-setup`)").argument("<action>", "get | store | erase (supplied by git)").action(async (action) => {
|
|
2849
|
+
return new Command7("git-credential").description("git credential helper: answers the AgentValet proxy with this agent's JWT (used via `npx @agentvalet/register git-setup`)").argument("<action>", "get | store | erase (supplied by git)").action(async (action) => {
|
|
2832
2850
|
const creds = resolveAgent();
|
|
2833
2851
|
const request2 = parseCredentialInput(await readStdin());
|
|
2834
2852
|
if (action !== "get") return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentvalet/register",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "Self-register AI agents with AgentValet",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -10,6 +10,13 @@
|
|
|
10
10
|
"dist",
|
|
11
11
|
"README.md"
|
|
12
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": "node ../../scripts/no-secrets.mjs && pnpm build && node ../../scripts/no-workspace-protocol.mjs"
|
|
19
|
+
},
|
|
13
20
|
"dependencies": {
|
|
14
21
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
15
22
|
"@octokit/auth-oauth-device": "^7.0.0",
|
|
@@ -22,13 +29,13 @@
|
|
|
22
29
|
"undici": "^6.0.0"
|
|
23
30
|
},
|
|
24
31
|
"devDependencies": {
|
|
32
|
+
"@agentvalet/mcp-server": "workspace:^",
|
|
25
33
|
"@types/node": "^20.0.0",
|
|
26
34
|
"@types/prompts": "^2.4.0",
|
|
27
35
|
"tsup": "^8.0.0",
|
|
28
36
|
"tsx": "^4.0.0",
|
|
29
37
|
"typescript": "^5.0.0",
|
|
30
|
-
"vitest": "^1.5.0"
|
|
31
|
-
"@agentvalet/mcp-server": "^1.14.0"
|
|
38
|
+
"vitest": "^1.5.0"
|
|
32
39
|
},
|
|
33
40
|
"engines": {
|
|
34
41
|
"node": ">=18"
|
|
@@ -54,11 +61,5 @@
|
|
|
54
61
|
"valet",
|
|
55
62
|
"agentvalet"
|
|
56
63
|
],
|
|
57
|
-
"license": "MIT"
|
|
58
|
-
|
|
59
|
-
"build": "tsup src/index.ts --format esm --dts --clean --shims",
|
|
60
|
-
"dev": "tsx src/index.ts",
|
|
61
|
-
"test": "vitest run",
|
|
62
|
-
"typecheck": "tsc --noEmit"
|
|
63
|
-
}
|
|
64
|
-
}
|
|
64
|
+
"license": "MIT"
|
|
65
|
+
}
|