@agentvalet/register 0.4.3 → 0.4.4
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 +22 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -514,6 +514,16 @@ async function runRefresh(options) {
|
|
|
514
514
|
}
|
|
515
515
|
}
|
|
516
516
|
}
|
|
517
|
+
if (!agentId || !ownerId || !keyPath) {
|
|
518
|
+
try {
|
|
519
|
+
const global = getStoredConfig();
|
|
520
|
+
if (!agentId && global.lastAgentId) agentId = global.lastAgentId;
|
|
521
|
+
if (!ownerId && global.ownerId) ownerId = global.ownerId;
|
|
522
|
+
if (!keyPath && global.lastKeyPath) keyPath = global.lastKeyPath;
|
|
523
|
+
if (!apiUrl && global.proxyUrl) apiUrl = global.proxyUrl;
|
|
524
|
+
} catch {
|
|
525
|
+
}
|
|
526
|
+
}
|
|
517
527
|
if (!agentId || !ownerId || !keyPath) {
|
|
518
528
|
throw new Error(
|
|
519
529
|
`Cannot find agent credentials.
|
|
@@ -1094,7 +1104,7 @@ async function runOnboard() {
|
|
|
1094
1104
|
console.log(chalk6.dim(" Signed out. Run again to re-authenticate."));
|
|
1095
1105
|
return;
|
|
1096
1106
|
}
|
|
1097
|
-
await registerAgentFlow(stored.
|
|
1107
|
+
await registerAgentFlow(stored.cliToken, stored.ownerId);
|
|
1098
1108
|
return;
|
|
1099
1109
|
}
|
|
1100
1110
|
const { authMethod } = await prompts3({
|
|
@@ -1169,9 +1179,10 @@ async function runOnboard() {
|
|
|
1169
1179
|
orgId: account.org_id,
|
|
1170
1180
|
proxyUrl: account.proxy_url,
|
|
1171
1181
|
githubUsername: githubUser.login,
|
|
1172
|
-
email: githubUser.email
|
|
1182
|
+
email: githubUser.email,
|
|
1183
|
+
cliToken: account.cli_token
|
|
1173
1184
|
});
|
|
1174
|
-
await registerAgentFlow(account.
|
|
1185
|
+
await registerAgentFlow(account.cli_token, account.owner_id);
|
|
1175
1186
|
}
|
|
1176
1187
|
async function ownerIdFlow() {
|
|
1177
1188
|
console.log("");
|
|
@@ -1201,9 +1212,10 @@ async function ownerIdFlow() {
|
|
|
1201
1212
|
ownerId: account.owner_id,
|
|
1202
1213
|
orgId: account.org_id,
|
|
1203
1214
|
proxyUrl: "https://api.agentvalet.ai",
|
|
1204
|
-
email: account.email ?? ""
|
|
1215
|
+
email: account.email ?? "",
|
|
1216
|
+
cliToken: account.cli_token
|
|
1205
1217
|
});
|
|
1206
|
-
await registerAgentFlow(account.
|
|
1218
|
+
await registerAgentFlow(account.cli_token, account.owner_id);
|
|
1207
1219
|
}
|
|
1208
1220
|
async function registerAgentFlow(apiKey, ownerId) {
|
|
1209
1221
|
const hostname = os3.hostname().split(".")[0];
|
|
@@ -1240,6 +1252,7 @@ async function registerAgentFlow(apiKey, ownerId) {
|
|
|
1240
1252
|
proxyUrl,
|
|
1241
1253
|
privateKeyPem: agent.private_key_pem
|
|
1242
1254
|
});
|
|
1255
|
+
saveConfig({ lastAgentId: agent.agent_id, lastKeyPath: keyPath });
|
|
1243
1256
|
} catch (err) {
|
|
1244
1257
|
console.error(chalk6.red(` \u2717 Failed to write local config: ${err.message}`));
|
|
1245
1258
|
console.log(chalk6.dim(" Agent was registered \u2014 run again to save config locally."));
|
|
@@ -1340,7 +1353,7 @@ function collectScope(value, previous) {
|
|
|
1340
1353
|
return [...previous, value];
|
|
1341
1354
|
}
|
|
1342
1355
|
var program = new Command();
|
|
1343
|
-
program.name("agentvalet-register").description("Self-register an AI agent with AgentValet").version("0.4.
|
|
1356
|
+
program.name("agentvalet-register").description("Self-register an AI agent with AgentValet").version("0.4.4").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) => {
|
|
1344
1357
|
const isJson = !!opts.json;
|
|
1345
1358
|
let ownerId = opts.owner ?? process.env.AGENTVALET_OWNER ?? "";
|
|
1346
1359
|
let agentName = opts.name ?? "";
|
|
@@ -1458,6 +1471,9 @@ Approve at: https://app.agentvalet.ai/agents
|
|
|
1458
1471
|
process.exit(3);
|
|
1459
1472
|
}
|
|
1460
1473
|
const keyWritten = !!privateKey;
|
|
1474
|
+
if (keyWritten) {
|
|
1475
|
+
saveConfig({ lastAgentId: agentId, lastKeyPath: keyPath, ownerId: resolvedOwnerId });
|
|
1476
|
+
}
|
|
1461
1477
|
if (isJson) {
|
|
1462
1478
|
console.log(JSON.stringify({ status: "approved", agentId, keyPath: keyWritten ? keyPath : null, envPath }));
|
|
1463
1479
|
} else {
|