@agentvalet/register 0.3.4 → 0.3.6

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.
Files changed (2) hide show
  1. package/dist/index.js +74 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -642,6 +642,30 @@ async function registerAgent2(params, apiKey) {
642
642
  clearTimeout(timeout);
643
643
  }
644
644
  }
645
+ async function getAccount(apiKey) {
646
+ const controller = new AbortController();
647
+ const timeout = setTimeout(() => controller.abort(), 1e4);
648
+ try {
649
+ const response = await fetch(`${FUNCTIONS_URL}/cli-account`, {
650
+ headers: {
651
+ ...baseHeaders,
652
+ "Authorization": `Bearer ${apiKey}`
653
+ },
654
+ signal: controller.signal
655
+ });
656
+ if (!response.ok) {
657
+ const error = await response.json().catch(() => ({}));
658
+ throw new Error(`Failed to fetch account: ${response.status} ${error.error ?? ""}`);
659
+ }
660
+ return response.json();
661
+ } catch (err) {
662
+ clearTimeout(timeout);
663
+ if (err?.name === "AbortError") throw new Error("Request timed out \u2014 is the AgentValet API reachable?");
664
+ throw err;
665
+ } finally {
666
+ clearTimeout(timeout);
667
+ }
668
+ }
645
669
 
646
670
  // src/config/store.ts
647
671
  import Conf from "conf";
@@ -910,6 +934,23 @@ async function runOnboard() {
910
934
  await registerAgentFlow(stored.apiKey, stored.ownerId);
911
935
  return;
912
936
  }
937
+ const { authMethod } = await prompts3({
938
+ type: "select",
939
+ name: "authMethod",
940
+ message: "How would you like to sign in?",
941
+ choices: [
942
+ { title: "Sign in with GitHub (opens browser)", value: "github" },
943
+ { title: "Paste Owner ID from app.agentvalet.ai/settings", value: "ownerid" }
944
+ ],
945
+ hint: "No GitHub account? Choose the second option after signing up at app.agentvalet.ai"
946
+ });
947
+ if (authMethod === void 0) {
948
+ process.exit(0);
949
+ }
950
+ if (authMethod === "ownerid") {
951
+ await ownerIdFlow();
952
+ return;
953
+ }
913
954
  let spinner = ora();
914
955
  let githubToken;
915
956
  try {
@@ -969,6 +1010,38 @@ async function runOnboard() {
969
1010
  });
970
1011
  await registerAgentFlow(account.owner_id, account.owner_id);
971
1012
  }
1013
+ async function ownerIdFlow() {
1014
+ console.log("");
1015
+ console.log(chalk6.dim(" Find your Owner ID at: ") + chalk6.cyan.underline("https://app.agentvalet.ai/settings"));
1016
+ console.log("");
1017
+ const { ownerId } = await prompts3({
1018
+ type: "text",
1019
+ name: "ownerId",
1020
+ message: "Paste your Owner ID:",
1021
+ validate: (v) => v.trim().length > 10 || "Owner ID looks too short"
1022
+ });
1023
+ if (ownerId === void 0) {
1024
+ process.exit(0);
1025
+ }
1026
+ const spinner = ora(" Verifying Owner ID...").start();
1027
+ let account;
1028
+ try {
1029
+ account = await getAccount(ownerId.trim());
1030
+ spinner.succeed(` Account verified \u2014 plan: ${chalk6.bold(account.plan)}`);
1031
+ } catch (err) {
1032
+ spinner.fail(` Could not verify Owner ID: ${err.message}`);
1033
+ console.log(chalk6.dim(" Make sure you copied the full Owner ID from app.agentvalet.ai/settings"));
1034
+ process.exit(1);
1035
+ }
1036
+ saveConfig({
1037
+ apiKey: account.owner_id,
1038
+ ownerId: account.owner_id,
1039
+ orgId: account.org_id,
1040
+ proxyUrl: "https://api.agentvalet.ai",
1041
+ email: account.email ?? ""
1042
+ });
1043
+ await registerAgentFlow(account.owner_id, account.owner_id);
1044
+ }
972
1045
  async function registerAgentFlow(apiKey, ownerId) {
973
1046
  const hostname = os3.hostname().split(".")[0];
974
1047
  const dirName = process.cwd().split("/").pop() ?? process.cwd().split("\\").pop() ?? "agent";
@@ -1079,7 +1152,7 @@ function collectScope(value, previous) {
1079
1152
  return [...previous, value];
1080
1153
  }
1081
1154
  var program = new Command();
1082
- program.name("agentvalet-register").description("Self-register an AI agent with AgentValet").version("0.1.0").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) => {
1155
+ program.name("agentvalet-register").description("Self-register an AI agent with AgentValet").version("0.3.6").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) => {
1083
1156
  const isJson = !!opts.json;
1084
1157
  let ownerId = opts.owner ?? process.env.AGENTVALET_OWNER ?? "";
1085
1158
  let agentName = opts.name ?? "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentvalet/register",
3
- "version": "0.3.4",
3
+ "version": "0.3.6",
4
4
  "description": "Self-register AI agents with AgentValet",
5
5
  "type": "module",
6
6
  "bin": {