@agentvalet/register 0.4.14 → 0.4.16

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.
@@ -13,7 +13,11 @@ function getStoredConfig() {
13
13
  return store.store;
14
14
  }
15
15
  function saveConfig(config) {
16
- store.set(config);
16
+ const filtered = {};
17
+ for (const [k, v] of Object.entries(config)) {
18
+ if (v !== void 0) filtered[k] = v;
19
+ }
20
+ store.set(filtered);
17
21
  }
18
22
  function clearConfig() {
19
23
  store.clear();
package/dist/index.js CHANGED
@@ -6,12 +6,12 @@ import {
6
6
  getStoredConfig,
7
7
  isAuthenticated,
8
8
  saveConfig
9
- } from "./chunk-2EFPJNYK.js";
9
+ } from "./chunk-CSOYDHNO.js";
10
10
 
11
11
  // src/index.ts
12
- import { createRequire } from "module";
13
- import { Command as Command5 } from "commander";
14
- import chalk12 from "chalk";
12
+ import { createRequire as createRequire2 } from "module";
13
+ import { Command as Command6 } from "commander";
14
+ import chalk13 from "chalk";
15
15
 
16
16
  // src/wizard.ts
17
17
  import prompts from "prompts";
@@ -840,97 +840,108 @@ import chalk7 from "chalk";
840
840
  import ora from "ora";
841
841
  import prompts3 from "prompts";
842
842
 
843
- // src/auth/github-device-flow.ts
844
- import { createOAuthDeviceAuth } from "@octokit/auth-oauth-device";
843
+ // src/auth/browser-flow.ts
844
+ import { createServer } from "http";
845
+ import { createRequire } from "module";
845
846
  import open from "open";
846
847
  import chalk4 from "chalk";
847
- var GITHUB_CLIENT_ID = process.env.AGENTVALET_GITHUB_CLIENT_ID ?? "Ov23liQcaW0HcqJxmLfF";
848
- async function authenticateWithGitHub() {
849
- const auth = createOAuthDeviceAuth({
850
- clientType: "oauth-app",
851
- clientId: GITHUB_CLIENT_ID,
852
- scopes: ["user:email", "read:user"],
853
- onVerification(verification) {
854
- console.log("");
855
- console.log(chalk4.bold(" Authenticate with GitHub"));
856
- console.log("");
857
- console.log(` 1. Open: ${chalk4.cyan.underline(verification.verification_uri)}`);
858
- console.log(` 2. Enter code: ${chalk4.bold.yellow(verification.user_code)}`);
859
- console.log("");
860
- open(verification.verification_uri).catch(() => {
861
- console.log(chalk4.dim(" (Could not open browser \u2014 navigate to the URL above manually)"));
862
- });
863
- console.log(chalk4.dim(" Waiting for authorisation..."));
864
- }
848
+ var _require = createRequire(import.meta.url);
849
+ var FUNCTIONS_URL = "https://jmodblrolfoavrxqgbps.supabase.co/functions/v1";
850
+ var SUPABASE_ANON_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imptb2RibHJvbGZvYXZyeHFnYnBzIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzQwODIzNzYsImV4cCI6MjA4OTY1ODM3Nn0.xQQiYHXbDsHyiTd5TsAfXtNWBUGkT4eO7Ew9UH8n6UE";
851
+ var APP_URL = "https://app.agentvalet.ai";
852
+ var CALLBACK_TIMEOUT_MS = 12e4;
853
+ async function findFreePort() {
854
+ return new Promise((resolve4, reject) => {
855
+ const server = createServer();
856
+ server.listen(0, "127.0.0.1", () => {
857
+ const addr = server.address();
858
+ if (!addr || typeof addr === "string") {
859
+ reject(new Error("Could not bind port"));
860
+ return;
861
+ }
862
+ const port = addr.port;
863
+ server.close(() => resolve4(port));
864
+ });
865
+ server.on("error", reject);
865
866
  });
866
- const tokenAuth = await auth({ type: "oauth" });
867
- return {
868
- token: tokenAuth.token,
869
- scopes: tokenAuth.scopes ?? []
870
- };
871
867
  }
872
- async function getGitHubUser(token) {
873
- const response = await fetch("https://api.github.com/user", {
868
+ async function callCliAuth(body) {
869
+ const res = await fetch(`${FUNCTIONS_URL}/cli-auth`, {
870
+ method: "POST",
874
871
  headers: {
875
- Authorization: `Bearer ${token}`,
876
- Accept: "application/vnd.github.v3+json"
877
- }
872
+ "Content-Type": "application/json",
873
+ "apikey": SUPABASE_ANON_KEY
874
+ },
875
+ body: JSON.stringify(body)
878
876
  });
879
- if (!response.ok) {
880
- throw new Error(`GitHub API error: ${response.status}`);
881
- }
882
- const user = await response.json();
883
- if (!user.email) {
884
- const emailsResponse = await fetch("https://api.github.com/user/emails", {
885
- headers: {
886
- Authorization: `Bearer ${token}`,
887
- Accept: "application/vnd.github.v3+json"
877
+ const json = await res.json();
878
+ if (!res.ok) throw new Error(json.error ?? `HTTP ${res.status}`);
879
+ return json;
880
+ }
881
+ async function browserLogin() {
882
+ const state = crypto.randomUUID();
883
+ const port = await findFreePort();
884
+ await callCliAuth({ action: "init", state, port });
885
+ const codePromise = new Promise((resolve4, reject) => {
886
+ const server = createServer((req, res) => {
887
+ const url = new URL(req.url ?? "/", `http://127.0.0.1:${port}`);
888
+ if (url.pathname !== "/callback") {
889
+ res.writeHead(404);
890
+ res.end();
891
+ return;
888
892
  }
893
+ const code2 = url.searchParams.get("code");
894
+ res.writeHead(200, { "Content-Type": "text/html" });
895
+ res.end(
896
+ "<!doctype html><html><head><title>AgentValet CLI</title><style>body{font-family:system-ui,sans-serif;display:flex;align-items:center;justify-content:center;min-height:100vh;margin:0;background:#060e1a;color:rgba(255,255,255,.87)}h2{margin:0 0 8px}p{margin:0;color:rgba(255,255,255,.45);font-size:14px}</style></head><body><div style='text-align:center'><h2 style='color:#34c97b'>&#10003; Authorized</h2><p>You can close this tab and return to your terminal.</p></div></body></html>"
897
+ );
898
+ server.close();
899
+ if (code2) resolve4(code2);
900
+ else reject(new Error("No code in callback URL"));
889
901
  });
890
- if (emailsResponse.ok) {
891
- const emails = await emailsResponse.json();
892
- user.email = emails.find((e) => e.primary && e.verified)?.email ?? emails[0]?.email ?? null;
893
- }
894
- }
895
- return user;
902
+ server.listen(port, "127.0.0.1");
903
+ server.on("error", (err) => reject(err));
904
+ setTimeout(() => {
905
+ server.close();
906
+ reject(new Error("Timed out waiting for browser authorization (2 min)"));
907
+ }, CALLBACK_TIMEOUT_MS);
908
+ });
909
+ const authUrl = `${APP_URL}/cli-auth?state=${state}&port=${port}`;
910
+ console.log(chalk4.dim(`
911
+ Opening browser to authorize...`));
912
+ console.log(chalk4.dim(` URL: ${authUrl}
913
+ `));
914
+ await open(authUrl).catch(() => {
915
+ console.log(chalk4.yellow(` Could not open browser automatically.`));
916
+ console.log(chalk4.yellow(` Please open this URL in your browser:
917
+ `));
918
+ console.log(` ${authUrl}
919
+ `);
920
+ });
921
+ const code = await codePromise;
922
+ const result = await callCliAuth({ action: "exchange", state, code });
923
+ return {
924
+ ownerId: result.owner_id,
925
+ orgId: result.org_id ?? null,
926
+ cliToken: result.cli_token,
927
+ email: result.email ?? null,
928
+ proxyUrl: result.proxy_url ?? "https://api.agentvalet.ai"
929
+ };
896
930
  }
897
931
 
898
932
  // src/api/agentvalet.ts
899
933
  var SUPABASE_URL = "https://jmodblrolfoavrxqgbps.supabase.co";
900
- var SUPABASE_ANON_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imptb2RibHJvbGZvYXZyeHFnYnBzIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzQwODIzNzYsImV4cCI6MjA4OTY1ODM3Nn0.xQQiYHXbDsHyiTd5TsAfXtNWBUGkT4eO7Ew9UH8n6UE";
901
- var FUNCTIONS_URL = `${SUPABASE_URL}/functions/v1`;
934
+ var SUPABASE_ANON_KEY2 = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imptb2RibHJvbGZvYXZyeHFnYnBzIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzQwODIzNzYsImV4cCI6MjA4OTY1ODM3Nn0.xQQiYHXbDsHyiTd5TsAfXtNWBUGkT4eO7Ew9UH8n6UE";
935
+ var FUNCTIONS_URL2 = `${SUPABASE_URL}/functions/v1`;
902
936
  var baseHeaders = {
903
937
  "Content-Type": "application/json",
904
- "apikey": SUPABASE_ANON_KEY
938
+ "apikey": SUPABASE_ANON_KEY2
905
939
  };
906
- async function createOrFindAccount(params) {
907
- const controller = new AbortController();
908
- const timeout = setTimeout(() => controller.abort(), 1e4);
909
- try {
910
- const response = await fetch(`${FUNCTIONS_URL}/cli-account`, {
911
- method: "POST",
912
- headers: baseHeaders,
913
- body: JSON.stringify(params),
914
- signal: controller.signal
915
- });
916
- if (!response.ok) {
917
- const error = await response.json().catch(() => ({}));
918
- throw new Error(`Account setup failed: ${response.status} ${error.error ?? ""}`);
919
- }
920
- return response.json();
921
- } catch (err) {
922
- clearTimeout(timeout);
923
- if (err?.name === "AbortError") throw new Error("Request timed out \u2014 is the AgentValet API reachable?");
924
- throw err;
925
- } finally {
926
- clearTimeout(timeout);
927
- }
928
- }
929
940
  async function registerAgent2(params, apiKey) {
930
941
  const controller = new AbortController();
931
942
  const timeout = setTimeout(() => controller.abort(), 1e4);
932
943
  try {
933
- const response = await fetch(`${FUNCTIONS_URL}/cli-register-agent`, {
944
+ const response = await fetch(`${FUNCTIONS_URL2}/cli-register-agent`, {
934
945
  method: "POST",
935
946
  headers: {
936
947
  ...baseHeaders,
@@ -956,7 +967,7 @@ async function getAccount(apiKey) {
956
967
  const controller = new AbortController();
957
968
  const timeout = setTimeout(() => controller.abort(), 1e4);
958
969
  try {
959
- const response = await fetch(`${FUNCTIONS_URL}/cli-account`, {
970
+ const response = await fetch(`${FUNCTIONS_URL2}/cli-account`, {
960
971
  headers: {
961
972
  ...baseHeaders,
962
973
  "Authorization": `Bearer ${apiKey}`
@@ -1343,10 +1354,10 @@ async function runOnboard() {
1343
1354
  name: "authMethod",
1344
1355
  message: "How would you like to sign in?",
1345
1356
  choices: [
1346
- { title: "Sign in with GitHub (opens browser)", value: "github" },
1357
+ { title: "Sign in with your browser (opens app.agentvalet.ai)", value: "browser" },
1347
1358
  { title: "Paste Owner ID from app.agentvalet.ai/settings", value: "ownerid" }
1348
1359
  ],
1349
- hint: "No GitHub account? Choose the second option after signing up at app.agentvalet.ai"
1360
+ hint: "No account yet? Visit app.agentvalet.ai to sign up first"
1350
1361
  });
1351
1362
  if (authMethod === void 0) {
1352
1363
  process.exit(0);
@@ -1355,65 +1366,24 @@ async function runOnboard() {
1355
1366
  await ownerIdFlow();
1356
1367
  return;
1357
1368
  }
1358
- let spinner = ora();
1359
- let githubToken;
1360
- try {
1361
- const result = await authenticateWithGitHub();
1362
- githubToken = result.token;
1363
- } catch (err) {
1364
- console.error(chalk7.red(` \u2717 Authentication failed: ${err.message}`));
1365
- process.exit(1);
1366
- }
1367
- spinner = ora(" Fetching your GitHub profile...").start();
1368
- let githubUser;
1369
- try {
1370
- githubUser = await getGitHubUser(githubToken);
1371
- spinner.succeed(` GitHub: ${chalk7.bold("@" + githubUser.login)}`);
1372
- } catch (err) {
1373
- spinner.fail(` Failed to fetch GitHub profile: ${err.message}`);
1374
- process.exit(1);
1375
- }
1376
- if (!githubUser.email) {
1377
- const { email } = await prompts3({
1378
- type: "text",
1379
- name: "email",
1380
- message: "Your email address (not visible on GitHub):",
1381
- validate: (v) => v.includes("@") || "Please enter a valid email"
1382
- });
1383
- if (email === void 0) {
1384
- process.exit(0);
1385
- }
1386
- githubUser.email = email;
1387
- }
1388
- spinner = ora(" Setting up your AgentValet account...").start();
1389
- let account;
1369
+ let credentials;
1390
1370
  try {
1391
- account = await createOrFindAccount({
1392
- github_token: githubToken,
1393
- github_username: githubUser.login,
1394
- email: githubUser.email,
1395
- display_name: githubUser.name ?? githubUser.login,
1396
- avatar_url: githubUser.avatar_url
1397
- });
1398
- if (account.is_new_account) {
1399
- spinner.succeed(" AgentValet account created");
1400
- } else {
1401
- spinner.succeed(" Existing AgentValet account found");
1402
- }
1371
+ credentials = await browserLogin();
1403
1372
  } catch (err) {
1404
- spinner.fail(` Account setup failed: ${err.message}`);
1373
+ console.error(chalk7.red(`
1374
+ \u2717 Authentication failed: ${err.message}`));
1405
1375
  process.exit(1);
1406
1376
  }
1377
+ console.log(chalk7.green(` \u2713 Signed in${credentials.email ? " as " + chalk7.bold(credentials.email) : ""}`));
1407
1378
  saveConfig({
1408
- apiKey: account.owner_id,
1409
- ownerId: account.owner_id,
1410
- orgId: account.org_id,
1411
- proxyUrl: account.proxy_url,
1412
- githubUsername: githubUser.login,
1413
- email: githubUser.email,
1414
- cliToken: account.cli_token
1379
+ apiKey: credentials.ownerId,
1380
+ ownerId: credentials.ownerId,
1381
+ orgId: credentials.orgId ?? void 0,
1382
+ proxyUrl: credentials.proxyUrl,
1383
+ email: credentials.email ?? "",
1384
+ cliToken: credentials.cliToken
1415
1385
  });
1416
- await registerAgentFlow(account.cli_token, account.owner_id);
1386
+ await registerAgentFlow(credentials.cliToken, credentials.ownerId);
1417
1387
  }
1418
1388
  async function ownerIdFlow() {
1419
1389
  console.log("");
@@ -1601,7 +1571,7 @@ import { Command } from "commander";
1601
1571
  import chalk8 from "chalk";
1602
1572
 
1603
1573
  // src/lib/api.ts
1604
- async function request(path7, options) {
1574
+ async function request(path8, options) {
1605
1575
  const config = getStoredConfig();
1606
1576
  const token = config.cliToken;
1607
1577
  if (!token) {
@@ -1610,7 +1580,7 @@ async function request(path7, options) {
1610
1580
  );
1611
1581
  }
1612
1582
  const proxyUrl = config.proxyUrl ?? "https://api.agentvalet.ai";
1613
- const response = await fetch(`${proxyUrl}/functions/v1${path7}`, {
1583
+ const response = await fetch(`${proxyUrl}/functions/v1${path8}`, {
1614
1584
  method: options.method,
1615
1585
  headers: {
1616
1586
  "Authorization": `Bearer ${token}`,
@@ -1798,19 +1768,19 @@ var CLAUDE_START2 = "<!-- agentvalet:start -->";
1798
1768
  var CLAUDE_END2 = "<!-- agentvalet:end -->";
1799
1769
  var HOOK_MARKER2 = "agentvalet/register refresh";
1800
1770
  function stripClaudeMd() {
1801
- const path7 = resolve3("CLAUDE.md");
1802
- if (!existsSync7(path7)) return;
1803
- let content = readFileSync4(path7, "utf-8");
1771
+ const path8 = resolve3("CLAUDE.md");
1772
+ if (!existsSync7(path8)) return;
1773
+ let content = readFileSync4(path8, "utf-8");
1804
1774
  content = content.replace(new RegExp(`${CLAUDE_START2}[\\s\\S]*?${CLAUDE_END2}`, "m"), "");
1805
1775
  content = content.replace(/^@\.claude\/agentvalet-permissions\.md\s*$/m, "");
1806
1776
  content = content.replace(/(\r?\n){3,}/g, "\n\n").trim();
1807
- writeFileSync3(path7, content ? content + "\n" : "", "utf-8");
1777
+ writeFileSync3(path8, content ? content + "\n" : "", "utf-8");
1808
1778
  }
1809
1779
  function stripSettingsJson() {
1810
- const path7 = resolve3(".claude/settings.local.json");
1811
- if (!existsSync7(path7)) return;
1780
+ const path8 = resolve3(".claude/settings.local.json");
1781
+ if (!existsSync7(path8)) return;
1812
1782
  try {
1813
- const settings = JSON.parse(readFileSync4(path7, "utf-8"));
1783
+ const settings = JSON.parse(readFileSync4(path8, "utf-8"));
1814
1784
  const hooks = settings.hooks ?? {};
1815
1785
  const ups = hooks.UserPromptSubmit ?? [];
1816
1786
  hooks.UserPromptSubmit = ups.filter(
@@ -1821,19 +1791,19 @@ function stripSettingsJson() {
1821
1791
  const allow = perms.allow ?? [];
1822
1792
  perms.allow = allow.filter((e) => !e.startsWith("mcp__agentvalet__"));
1823
1793
  settings.permissions = perms;
1824
- writeFileSync3(path7, JSON.stringify(settings, null, 2) + "\n", "utf-8");
1794
+ writeFileSync3(path8, JSON.stringify(settings, null, 2) + "\n", "utf-8");
1825
1795
  } catch {
1826
1796
  }
1827
1797
  }
1828
1798
  function stripMcpJson() {
1829
- const path7 = resolve3(".mcp.json");
1830
- if (!existsSync7(path7)) return;
1799
+ const path8 = resolve3(".mcp.json");
1800
+ if (!existsSync7(path8)) return;
1831
1801
  try {
1832
- const config = JSON.parse(readFileSync4(path7, "utf-8"));
1802
+ const config = JSON.parse(readFileSync4(path8, "utf-8"));
1833
1803
  const servers = config.mcpServers ?? {};
1834
1804
  delete servers["agentvalet"];
1835
1805
  config.mcpServers = servers;
1836
- writeFileSync3(path7, JSON.stringify(config, null, 2) + "\n", "utf-8");
1806
+ writeFileSync3(path8, JSON.stringify(config, null, 2) + "\n", "utf-8");
1837
1807
  } catch {
1838
1808
  }
1839
1809
  }
@@ -2012,13 +1982,155 @@ function uninstallCommand() {
2012
1982
  });
2013
1983
  }
2014
1984
 
1985
+ // src/commands/install.ts
1986
+ import { writeFile as writeFile8, mkdir as mkdir5 } from "fs/promises";
1987
+ import path7 from "path";
1988
+ import { Command as Command5 } from "commander";
1989
+ import chalk12 from "chalk";
1990
+ import prompts4 from "prompts";
1991
+ var SUPABASE_URL2 = "https://jmodblrolfoavrxqgbps.supabase.co";
1992
+ var CLAIM_URL = `${SUPABASE_URL2}/functions/v1/cli-claim-agent`;
1993
+ async function claimToken(installToken) {
1994
+ const resp = await fetch(CLAIM_URL, {
1995
+ method: "POST",
1996
+ headers: { "Content-Type": "application/json" },
1997
+ body: JSON.stringify({ install_token: installToken })
1998
+ });
1999
+ const text = await resp.text();
2000
+ let body = null;
2001
+ try {
2002
+ body = text ? JSON.parse(text) : null;
2003
+ } catch {
2004
+ }
2005
+ if (!resp.ok) {
2006
+ const detail = body?.error ?? text ?? `HTTP ${resp.status}`;
2007
+ throw new Error(detail);
2008
+ }
2009
+ if (!body || !body.agent_id || !body.private_key_pem) {
2010
+ throw new Error("Server returned an unexpected response");
2011
+ }
2012
+ return body;
2013
+ }
2014
+ function installCommand() {
2015
+ return new Command5("install").description("Claim an agent created in the dashboard using a one-time install token").argument("<token>", "install token (itok_...) from the dashboard").option("--no-frameworks", "skip IDE/framework configuration prompts").action(async (token, opts) => {
2016
+ if (!token.startsWith("itok_")) {
2017
+ console.error(chalk12.red('Invalid install token. Tokens start with "itok_".'));
2018
+ process.exit(3);
2019
+ }
2020
+ console.log(chalk12.bold("\n Claiming agent\u2026"));
2021
+ let claim;
2022
+ try {
2023
+ claim = await claimToken(token);
2024
+ } catch (err) {
2025
+ const msg = err instanceof Error ? err.message : String(err);
2026
+ console.error(chalk12.red(`
2027
+ \u2717 ${msg}`));
2028
+ if (msg.toLowerCase().includes("expired") || msg.toLowerCase().includes("not found")) {
2029
+ console.error(chalk12.dim(" Generate a fresh install command from app.agentvalet.ai/agents"));
2030
+ }
2031
+ process.exit(3);
2032
+ }
2033
+ const { agent_id, agent_name, owner_id, private_key_pem, proxy_url } = claim;
2034
+ try {
2035
+ await mkdir5(AGENT_DIR, { recursive: true });
2036
+ await writeFile8(AGENT_KEY_PATH, private_key_pem, { mode: 384 });
2037
+ } catch (err) {
2038
+ console.error(chalk12.red(`
2039
+ \u2717 Failed to write key: ${err instanceof Error ? err.message : err}`));
2040
+ process.exit(3);
2041
+ }
2042
+ saveConfig({
2043
+ agentId: agent_id,
2044
+ ownerId: owner_id,
2045
+ apiUrl: proxy_url,
2046
+ keyPath: AGENT_KEY_PATH,
2047
+ proxyUrl: proxy_url,
2048
+ lastAgentId: agent_id,
2049
+ lastKeyPath: AGENT_KEY_PATH
2050
+ });
2051
+ console.log(chalk12.green(` \u2713 Agent claimed: ${chalk12.bold(agent_name)} (${agent_id})`));
2052
+ console.log(chalk12.dim(` Key written to ${AGENT_KEY_PATH}`));
2053
+ if (opts.frameworks !== false) {
2054
+ const detected = detectFrameworks();
2055
+ const shouldSetup = await frameworkSetupConsent(detected);
2056
+ let installReliabilityDroid = false;
2057
+ if (detected.factoryDroid && shouldSetup) {
2058
+ const { reliability } = await prompts4({
2059
+ type: "confirm",
2060
+ name: "reliability",
2061
+ message: "Also install AgentValet Reliability Droid for Factory Droid? (monitors agent governance)",
2062
+ initial: false
2063
+ });
2064
+ installReliabilityDroid = reliability ?? false;
2065
+ }
2066
+ if (shouldSetup) {
2067
+ console.log("");
2068
+ console.log(chalk12.bold(" Configuring agent frameworks..."));
2069
+ console.log("");
2070
+ const ideResults = await writeIdeConfigs({
2071
+ agentId: agent_id,
2072
+ ownerId: owner_id,
2073
+ proxyUrl: proxy_url,
2074
+ keyPath: AGENT_KEY_PATH,
2075
+ detected
2076
+ });
2077
+ for (const r of ideResults) console.log(chalk12.green(` \u2713 ${r}`));
2078
+ const globalResults = await writeGlobalFrameworkConfigs({
2079
+ agentId: agent_id,
2080
+ ownerId: owner_id,
2081
+ proxyUrl: proxy_url,
2082
+ keyPath: AGENT_KEY_PATH
2083
+ });
2084
+ for (const r of globalResults) console.log(chalk12.green(` \u2713 ${r}`));
2085
+ if (detected.codex) writeAgentsMd();
2086
+ if (detected.openclaw) writeSkillMd();
2087
+ if (detected.factoryDroid) {
2088
+ writeFactoryDroidDroid();
2089
+ writeFactoryDroidCommand();
2090
+ if (installReliabilityDroid) writeFactoryDroidReliabilityDroid();
2091
+ }
2092
+ writeQuickstartDoc({
2093
+ agentId: agent_id,
2094
+ ownerId: owner_id,
2095
+ proxyUrl: proxy_url,
2096
+ keyPath: AGENT_KEY_PATH,
2097
+ detected
2098
+ });
2099
+ ensureMcpServer();
2100
+ }
2101
+ }
2102
+ try {
2103
+ const envContent = [
2104
+ "# AgentValet \u2014 generated by agentvalet-register install",
2105
+ `AGENTVALET_AGENT_ID=${agent_id}`,
2106
+ `AGENTVALET_OWNER_ID=${owner_id}`,
2107
+ `AGENTVALET_API_URL=${proxy_url}`,
2108
+ `AGENTVALET_PRIVATE_KEY_PATH=${AGENT_KEY_PATH}`,
2109
+ ""
2110
+ ].join("\n");
2111
+ await writeFile8(path7.join(process.cwd(), ".env.agentvalet"), envContent, { encoding: "utf8", mode: 384 });
2112
+ } catch {
2113
+ }
2114
+ console.log("");
2115
+ console.log(chalk12.bold.green(" \u2713 All done!"));
2116
+ console.log("");
2117
+ console.log(` Agent ID: ${chalk12.cyan(agent_id)}`);
2118
+ console.log(` Key path: ${chalk12.dim(AGENT_KEY_PATH)}`);
2119
+ console.log(` Proxy: ${chalk12.dim(proxy_url)}`);
2120
+ console.log("");
2121
+ console.log(` Dashboard: ${chalk12.cyan.underline("https://app.agentvalet.ai/agents/" + agent_id)}`);
2122
+ console.log("");
2123
+ process.exit(0);
2124
+ });
2125
+ }
2126
+
2015
2127
  // src/index.ts
2016
- var require2 = createRequire(import.meta.url);
2128
+ var require2 = createRequire2(import.meta.url);
2017
2129
  var { version } = require2("../package.json");
2018
2130
  function collectScope(value, previous) {
2019
2131
  return [...previous, value];
2020
2132
  }
2021
- var program = new Command5();
2133
+ var program = new Command6();
2022
2134
  program.name("agentvalet-register").description("Self-register an AI agent with AgentValet").version(version).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("--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) => {
2023
2135
  const isJson = !!opts.json;
2024
2136
  let ownerId = opts.owner ?? process.env.AGENTVALET_OWNER ?? "";
@@ -2045,7 +2157,7 @@ program.name("agentvalet-register").description("Self-register an AI agent with
2045
2157
  console.error(JSON.stringify({ error: "--owner or AGENTVALET_OWNER is required" }));
2046
2158
  process.exit(3);
2047
2159
  }
2048
- console.error(chalk12.red("Error: --owner or AGENTVALET_OWNER environment variable is required"));
2160
+ console.error(chalk13.red("Error: --owner or AGENTVALET_OWNER environment variable is required"));
2049
2161
  process.exit(3);
2050
2162
  }
2051
2163
  const scopeMap = /* @__PURE__ */ new Map();
@@ -2053,7 +2165,7 @@ program.name("agentvalet-register").description("Self-register an AI agent with
2053
2165
  const colon = s.indexOf(":");
2054
2166
  if (colon === -1) {
2055
2167
  console.error(
2056
- isJson ? JSON.stringify({ error: `Invalid scope format: ${s} (expected platform:scope)` }) : chalk12.red(`Invalid scope format: ${s} (expected platform:scope)`)
2168
+ isJson ? JSON.stringify({ error: `Invalid scope format: ${s} (expected platform:scope)` }) : chalk13.red(`Invalid scope format: ${s} (expected platform:scope)`)
2057
2169
  );
2058
2170
  process.exit(3);
2059
2171
  }
@@ -2076,11 +2188,11 @@ program.name("agentvalet-register").description("Self-register an AI agent with
2076
2188
  });
2077
2189
  } catch (err) {
2078
2190
  const msg = err instanceof Error ? err.message : String(err);
2079
- console.error(isJson ? JSON.stringify({ error: msg }) : chalk12.red(`Registration failed: ${msg}`));
2191
+ console.error(isJson ? JSON.stringify({ error: msg }) : chalk13.red(`Registration failed: ${msg}`));
2080
2192
  process.exit(3);
2081
2193
  }
2082
2194
  if (!isJson) {
2083
- console.log(chalk12.cyan(`
2195
+ console.log(chalk13.cyan(`
2084
2196
  Approve at: https://app.agentvalet.ai/agents
2085
2197
  `));
2086
2198
  }
@@ -2088,7 +2200,7 @@ Approve at: https://app.agentvalet.ai/agents
2088
2200
  if (isJson) {
2089
2201
  console.log(JSON.stringify({ status: "pending", token }));
2090
2202
  } else {
2091
- console.log(chalk12.yellow("Registration submitted (--no-wait). Token:"), token);
2203
+ console.log(chalk13.yellow("Registration submitted (--no-wait). Token:"), token);
2092
2204
  }
2093
2205
  process.exit(0);
2094
2206
  }
@@ -2099,14 +2211,14 @@ Approve at: https://app.agentvalet.ai/agents
2099
2211
  });
2100
2212
  } catch (err) {
2101
2213
  const msg = err instanceof Error ? err.message : String(err);
2102
- console.error(isJson ? JSON.stringify({ error: msg }) : chalk12.red(`Wait failed: ${msg}`));
2214
+ console.error(isJson ? JSON.stringify({ error: msg }) : chalk13.red(`Wait failed: ${msg}`));
2103
2215
  process.exit(3);
2104
2216
  }
2105
2217
  if (result.status === "rejected") {
2106
2218
  if (isJson) {
2107
2219
  console.log(JSON.stringify({ status: "rejected" }));
2108
2220
  } else {
2109
- console.log(chalk12.red("\nRegistration denied by owner."));
2221
+ console.log(chalk13.red("\nRegistration denied by owner."));
2110
2222
  }
2111
2223
  process.exit(1);
2112
2224
  }
@@ -2114,7 +2226,7 @@ Approve at: https://app.agentvalet.ai/agents
2114
2226
  if (isJson) {
2115
2227
  console.log(JSON.stringify({ status: "timeout" }));
2116
2228
  } else {
2117
- console.log(chalk12.yellow("\nTimed out waiting for approval."));
2229
+ console.log(chalk13.yellow("\nTimed out waiting for approval."));
2118
2230
  }
2119
2231
  process.exit(2);
2120
2232
  }
@@ -2132,35 +2244,35 @@ Approve at: https://app.agentvalet.ai/agents
2132
2244
  }));
2133
2245
  } catch (err) {
2134
2246
  const msg = err instanceof Error ? err.message : String(err);
2135
- console.error(isJson ? JSON.stringify({ error: msg }) : chalk12.red(`Failed to save output: ${msg}`));
2247
+ console.error(isJson ? JSON.stringify({ error: msg }) : chalk13.red(`Failed to save output: ${msg}`));
2136
2248
  process.exit(3);
2137
2249
  }
2138
2250
  } else {
2139
- const { AGENT_KEY_PATH: AGENT_KEY_PATH2 } = await import("./store-JYJXDBYX.js");
2251
+ const { AGENT_KEY_PATH: AGENT_KEY_PATH2 } = await import("./store-ZVZMF6GW.js");
2140
2252
  keyPath = AGENT_KEY_PATH2;
2141
2253
  }
2142
2254
  if (isJson) {
2143
2255
  console.log(JSON.stringify({ status: "approved", agentId, keyPath: keyWritten ? keyPath : null }));
2144
2256
  } else {
2145
- console.log(chalk12.green(`
2257
+ console.log(chalk13.green(`
2146
2258
  Approved! Agent ID: ${agentId}`));
2147
2259
  if (keyWritten) {
2148
- console.log(chalk12.gray(`Key: ${keyPath}`));
2260
+ console.log(chalk13.gray(`Key: ${keyPath}`));
2149
2261
  } else {
2150
- console.log(chalk12.yellow(`Key: not written \u2014 copy it from the dashboard and paste into ${keyPath}`));
2262
+ console.log(chalk13.yellow(`Key: not written \u2014 copy it from the dashboard and paste into ${keyPath}`));
2151
2263
  }
2152
2264
  }
2153
2265
  if (keyWritten) {
2154
2266
  try {
2155
2267
  if (grantedPlatforms && grantedPlatforms.length > 0) {
2156
2268
  writePermissionsFromEvent(agentId, resolvedOwnerId, grantedPlatforms);
2157
- if (!isJson) console.log(chalk12.gray(`Permissions: .claude/agentvalet-permissions.md`));
2269
+ if (!isJson) console.log(chalk13.gray(`Permissions: .claude/agentvalet-permissions.md`));
2158
2270
  } else {
2159
2271
  await runRefresh({ envFile: ".env.agentvalet", outputPath: ".claude/agentvalet-permissions.md", ifStale: false, quiet: isJson });
2160
- if (!isJson) console.log(chalk12.gray(`Permissions: .claude/agentvalet-permissions.md`));
2272
+ if (!isJson) console.log(chalk13.gray(`Permissions: .claude/agentvalet-permissions.md`));
2161
2273
  }
2162
2274
  } catch {
2163
- if (!isJson) console.log(chalk12.yellow(`Permissions: run 'agentvalet-register refresh' to generate`));
2275
+ if (!isJson) console.log(chalk13.yellow(`Permissions: run 'agentvalet-register refresh' to generate`));
2164
2276
  }
2165
2277
  }
2166
2278
  process.exit(0);
@@ -2175,7 +2287,7 @@ program.command("refresh").description("Refresh approved permissions and update
2175
2287
  });
2176
2288
  } catch (err) {
2177
2289
  const msg = err instanceof Error ? err.message : String(err);
2178
- console.error(chalk12.red(`Refresh failed: ${msg}`));
2290
+ console.error(chalk13.red(`Refresh failed: ${msg}`));
2179
2291
  process.exit(3);
2180
2292
  }
2181
2293
  });
@@ -2187,6 +2299,7 @@ program.addCommand(listCommand());
2187
2299
  program.addCommand(revokeCommand());
2188
2300
  program.addCommand(injectCommand());
2189
2301
  program.addCommand(uninstallCommand());
2302
+ program.addCommand(installCommand());
2190
2303
  program.parseAsync().catch((err) => {
2191
2304
  console.error(err);
2192
2305
  process.exit(3);
@@ -5,7 +5,7 @@ import {
5
5
  getStoredConfig,
6
6
  isAuthenticated,
7
7
  saveConfig
8
- } from "./chunk-2EFPJNYK.js";
8
+ } from "./chunk-CSOYDHNO.js";
9
9
  export {
10
10
  AGENT_DIR,
11
11
  AGENT_KEY_PATH,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentvalet/register",
3
- "version": "0.4.14",
3
+ "version": "0.4.16",
4
4
  "description": "Self-register AI agents with AgentValet",
5
5
  "type": "module",
6
6
  "bin": {
@@ -18,7 +18,7 @@
18
18
  "prepublishOnly": "pnpm build"
19
19
  },
20
20
  "dependencies": {
21
- "@agentvalet/mcp-server": "*",
21
+ "@agentvalet/mcp-server": "^0.2.0",
22
22
  "@modelcontextprotocol/sdk": "^1.29.0",
23
23
  "@octokit/auth-oauth-device": "^7.0.0",
24
24
  "chalk": "^5.3.0",