@agentvalet/register 0.5.1 → 0.5.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 +40 -16
- package/package.json +9 -10
package/dist/index.js
CHANGED
|
@@ -874,9 +874,18 @@ async function callCliAuth(body) {
|
|
|
874
874
|
},
|
|
875
875
|
body: JSON.stringify(body)
|
|
876
876
|
});
|
|
877
|
-
const
|
|
878
|
-
|
|
879
|
-
|
|
877
|
+
const text = await res.text();
|
|
878
|
+
let json = null;
|
|
879
|
+
try {
|
|
880
|
+
json = text ? JSON.parse(text) : null;
|
|
881
|
+
} catch {
|
|
882
|
+
}
|
|
883
|
+
if (!res.ok) {
|
|
884
|
+
const err = json?.error ?? text ?? `HTTP ${res.status}`;
|
|
885
|
+
const detail = json?.detail ?? "";
|
|
886
|
+
throw new Error(detail ? `${err}: ${detail}` : err);
|
|
887
|
+
}
|
|
888
|
+
return json ?? {};
|
|
880
889
|
}
|
|
881
890
|
async function browserLogin() {
|
|
882
891
|
const state = crypto.randomUUID();
|
|
@@ -1360,6 +1369,7 @@ import path6 from "path";
|
|
|
1360
1369
|
import { writeFile as writeFile5 } from "fs/promises";
|
|
1361
1370
|
async function runOnboard(opts = {}) {
|
|
1362
1371
|
const scope = opts.scope ?? "user";
|
|
1372
|
+
const presetName = opts.name?.trim() || void 0;
|
|
1363
1373
|
console.log("");
|
|
1364
1374
|
console.log(chalk7.bold(" AgentValet \u2014 Agent Registration"));
|
|
1365
1375
|
console.log(chalk7.dim(" app.agentvalet.ai"));
|
|
@@ -1391,7 +1401,7 @@ async function runOnboard(opts = {}) {
|
|
|
1391
1401
|
console.log(chalk7.dim(" Signed out. Run again to re-authenticate."));
|
|
1392
1402
|
return;
|
|
1393
1403
|
}
|
|
1394
|
-
await registerAgentFlow(stored.cliToken, stored.ownerId, scope);
|
|
1404
|
+
await registerAgentFlow(stored.cliToken, stored.ownerId, scope, presetName);
|
|
1395
1405
|
return;
|
|
1396
1406
|
}
|
|
1397
1407
|
let credentials;
|
|
@@ -1411,20 +1421,27 @@ async function runOnboard(opts = {}) {
|
|
|
1411
1421
|
email: credentials.email ?? "",
|
|
1412
1422
|
cliToken: credentials.cliToken
|
|
1413
1423
|
});
|
|
1414
|
-
await registerAgentFlow(credentials.cliToken, credentials.ownerId, scope);
|
|
1424
|
+
await registerAgentFlow(credentials.cliToken, credentials.ownerId, scope, presetName);
|
|
1415
1425
|
}
|
|
1416
|
-
async function registerAgentFlow(apiKey, ownerId, scope = "user") {
|
|
1426
|
+
async function registerAgentFlow(apiKey, ownerId, scope = "user", presetName) {
|
|
1417
1427
|
const hostname = os3.hostname().split(".")[0];
|
|
1418
1428
|
const dirName = process.cwd().split("/").pop() ?? process.cwd().split("\\").pop() ?? "agent";
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1429
|
+
let agentName;
|
|
1430
|
+
if (presetName) {
|
|
1431
|
+
agentName = presetName;
|
|
1432
|
+
console.log(chalk7.dim(` Agent name: ${chalk7.bold(agentName)}`));
|
|
1433
|
+
} else {
|
|
1434
|
+
const answer = await prompts3({
|
|
1435
|
+
type: "text",
|
|
1436
|
+
name: "agentName",
|
|
1437
|
+
message: "Name for this agent:",
|
|
1438
|
+
initial: `${hostname} \u2014 ${dirName}`,
|
|
1439
|
+
validate: (v) => v.trim().length > 0 || "Agent name is required"
|
|
1440
|
+
});
|
|
1441
|
+
if (answer.agentName === void 0) {
|
|
1442
|
+
process.exit(0);
|
|
1443
|
+
}
|
|
1444
|
+
agentName = answer.agentName;
|
|
1428
1445
|
}
|
|
1429
1446
|
const spinner = ora(" Registering agent...").start();
|
|
1430
1447
|
let agent;
|
|
@@ -2257,9 +2274,16 @@ program.name("agentvalet-register").description("Self-register an AI agent with
|
|
|
2257
2274
|
let description = opts.description ?? "";
|
|
2258
2275
|
let scopes = opts.scope;
|
|
2259
2276
|
if (!ownerId && !isAuthenticated()) {
|
|
2260
|
-
await runOnboard({ scope: opts.project ? "project" : "user" });
|
|
2277
|
+
await runOnboard({ scope: opts.project ? "project" : "user", name: agentName || void 0 });
|
|
2261
2278
|
return;
|
|
2262
2279
|
}
|
|
2280
|
+
if (!ownerId && isAuthenticated()) {
|
|
2281
|
+
const stored = getStoredConfig();
|
|
2282
|
+
if (stored.ownerId && stored.cliToken) {
|
|
2283
|
+
await runOnboard({ scope: opts.project ? "project" : "user", name: agentName || void 0 });
|
|
2284
|
+
return;
|
|
2285
|
+
}
|
|
2286
|
+
}
|
|
2263
2287
|
if (!agentName) {
|
|
2264
2288
|
if (isJson) {
|
|
2265
2289
|
console.error(JSON.stringify({ error: "--name is required in non-interactive mode" }));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentvalet/register",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "Self-register AI agents with AgentValet",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -10,13 +10,6 @@
|
|
|
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": "pnpm build"
|
|
19
|
-
},
|
|
20
13
|
"dependencies": {
|
|
21
14
|
"@agentvalet/mcp-server": "^0.2.0",
|
|
22
15
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
@@ -55,5 +48,11 @@
|
|
|
55
48
|
"valet",
|
|
56
49
|
"agentvalet"
|
|
57
50
|
],
|
|
58
|
-
"license": "MIT"
|
|
59
|
-
|
|
51
|
+
"license": "MIT",
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsup src/index.ts --format esm --dts --clean --shims",
|
|
54
|
+
"dev": "tsx src/index.ts",
|
|
55
|
+
"test": "vitest run",
|
|
56
|
+
"typecheck": "tsc --noEmit"
|
|
57
|
+
}
|
|
58
|
+
}
|