@agentvalet/register 0.5.0 → 0.5.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 +0 -74
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -964,30 +964,6 @@ async function registerAgent2(params, apiKey) {
|
|
|
964
964
|
clearTimeout(timeout);
|
|
965
965
|
}
|
|
966
966
|
}
|
|
967
|
-
async function getAccount(apiKey) {
|
|
968
|
-
const controller = new AbortController();
|
|
969
|
-
const timeout = setTimeout(() => controller.abort(), 1e4);
|
|
970
|
-
try {
|
|
971
|
-
const response = await fetch(`${FUNCTIONS_URL2}/cli-account`, {
|
|
972
|
-
headers: {
|
|
973
|
-
...baseHeaders,
|
|
974
|
-
"Authorization": `Bearer ${apiKey}`
|
|
975
|
-
},
|
|
976
|
-
signal: controller.signal
|
|
977
|
-
});
|
|
978
|
-
if (!response.ok) {
|
|
979
|
-
const error = await response.json().catch(() => ({}));
|
|
980
|
-
throw new Error(`Failed to fetch account: ${response.status} ${error.error ?? ""}`);
|
|
981
|
-
}
|
|
982
|
-
return response.json();
|
|
983
|
-
} catch (err) {
|
|
984
|
-
clearTimeout(timeout);
|
|
985
|
-
if (err?.name === "AbortError") throw new Error("Request timed out \u2014 is the AgentValet API reachable?");
|
|
986
|
-
throw err;
|
|
987
|
-
} finally {
|
|
988
|
-
clearTimeout(timeout);
|
|
989
|
-
}
|
|
990
|
-
}
|
|
991
967
|
|
|
992
968
|
// src/config/local.ts
|
|
993
969
|
import { mkdir as mkdir2, writeFile as writeFile2, appendFile, readFile } from "fs/promises";
|
|
@@ -1418,23 +1394,6 @@ async function runOnboard(opts = {}) {
|
|
|
1418
1394
|
await registerAgentFlow(stored.cliToken, stored.ownerId, scope);
|
|
1419
1395
|
return;
|
|
1420
1396
|
}
|
|
1421
|
-
const { authMethod } = await prompts3({
|
|
1422
|
-
type: "select",
|
|
1423
|
-
name: "authMethod",
|
|
1424
|
-
message: "How would you like to sign in?",
|
|
1425
|
-
choices: [
|
|
1426
|
-
{ title: "Sign in with your browser (opens app.agentvalet.ai)", value: "browser" },
|
|
1427
|
-
{ title: "Paste Owner ID from app.agentvalet.ai/settings", value: "ownerid" }
|
|
1428
|
-
],
|
|
1429
|
-
hint: "No account yet? Visit app.agentvalet.ai to sign up first"
|
|
1430
|
-
});
|
|
1431
|
-
if (authMethod === void 0) {
|
|
1432
|
-
process.exit(0);
|
|
1433
|
-
}
|
|
1434
|
-
if (authMethod === "ownerid") {
|
|
1435
|
-
await ownerIdFlow(scope);
|
|
1436
|
-
return;
|
|
1437
|
-
}
|
|
1438
1397
|
let credentials;
|
|
1439
1398
|
try {
|
|
1440
1399
|
credentials = await browserLogin();
|
|
@@ -1454,39 +1413,6 @@ async function runOnboard(opts = {}) {
|
|
|
1454
1413
|
});
|
|
1455
1414
|
await registerAgentFlow(credentials.cliToken, credentials.ownerId, scope);
|
|
1456
1415
|
}
|
|
1457
|
-
async function ownerIdFlow(scope) {
|
|
1458
|
-
console.log("");
|
|
1459
|
-
console.log(chalk7.dim(" Find your Owner ID at: ") + chalk7.cyan.underline("https://app.agentvalet.ai/settings"));
|
|
1460
|
-
console.log("");
|
|
1461
|
-
const { ownerId } = await prompts3({
|
|
1462
|
-
type: "text",
|
|
1463
|
-
name: "ownerId",
|
|
1464
|
-
message: "Paste your Owner ID:",
|
|
1465
|
-
validate: (v) => v.trim().length > 10 || "Owner ID looks too short"
|
|
1466
|
-
});
|
|
1467
|
-
if (ownerId === void 0) {
|
|
1468
|
-
process.exit(0);
|
|
1469
|
-
}
|
|
1470
|
-
const spinner = ora(" Verifying Owner ID...").start();
|
|
1471
|
-
let account;
|
|
1472
|
-
try {
|
|
1473
|
-
account = await getAccount(ownerId.trim());
|
|
1474
|
-
spinner.succeed(` Account verified \u2014 plan: ${chalk7.bold(account.plan)}`);
|
|
1475
|
-
} catch (err) {
|
|
1476
|
-
spinner.fail(` Could not verify Owner ID: ${err.message}`);
|
|
1477
|
-
console.log(chalk7.dim(" Make sure you copied the full Owner ID from app.agentvalet.ai/settings"));
|
|
1478
|
-
process.exit(1);
|
|
1479
|
-
}
|
|
1480
|
-
saveConfig({
|
|
1481
|
-
apiKey: account.owner_id,
|
|
1482
|
-
ownerId: account.owner_id,
|
|
1483
|
-
orgId: account.org_id,
|
|
1484
|
-
proxyUrl: "https://api.agentvalet.ai",
|
|
1485
|
-
email: account.email ?? "",
|
|
1486
|
-
cliToken: account.cli_token
|
|
1487
|
-
});
|
|
1488
|
-
await registerAgentFlow(account.cli_token, account.owner_id, scope);
|
|
1489
|
-
}
|
|
1490
1416
|
async function registerAgentFlow(apiKey, ownerId, scope = "user") {
|
|
1491
1417
|
const hostname = os3.hostname().split(".")[0];
|
|
1492
1418
|
const dirName = process.cwd().split("/").pop() ?? process.cwd().split("\\").pop() ?? "agent";
|