@agentvalet/register 0.4.15 → 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
12
  import { createRequire as createRequire2 } from "module";
13
- import { Command as Command5 } from "commander";
14
- import chalk12 from "chalk";
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";
@@ -1571,7 +1571,7 @@ import { Command } from "commander";
1571
1571
  import chalk8 from "chalk";
1572
1572
 
1573
1573
  // src/lib/api.ts
1574
- async function request(path7, options) {
1574
+ async function request(path8, options) {
1575
1575
  const config = getStoredConfig();
1576
1576
  const token = config.cliToken;
1577
1577
  if (!token) {
@@ -1580,7 +1580,7 @@ async function request(path7, options) {
1580
1580
  );
1581
1581
  }
1582
1582
  const proxyUrl = config.proxyUrl ?? "https://api.agentvalet.ai";
1583
- const response = await fetch(`${proxyUrl}/functions/v1${path7}`, {
1583
+ const response = await fetch(`${proxyUrl}/functions/v1${path8}`, {
1584
1584
  method: options.method,
1585
1585
  headers: {
1586
1586
  "Authorization": `Bearer ${token}`,
@@ -1768,19 +1768,19 @@ var CLAUDE_START2 = "<!-- agentvalet:start -->";
1768
1768
  var CLAUDE_END2 = "<!-- agentvalet:end -->";
1769
1769
  var HOOK_MARKER2 = "agentvalet/register refresh";
1770
1770
  function stripClaudeMd() {
1771
- const path7 = resolve3("CLAUDE.md");
1772
- if (!existsSync7(path7)) return;
1773
- let content = readFileSync4(path7, "utf-8");
1771
+ const path8 = resolve3("CLAUDE.md");
1772
+ if (!existsSync7(path8)) return;
1773
+ let content = readFileSync4(path8, "utf-8");
1774
1774
  content = content.replace(new RegExp(`${CLAUDE_START2}[\\s\\S]*?${CLAUDE_END2}`, "m"), "");
1775
1775
  content = content.replace(/^@\.claude\/agentvalet-permissions\.md\s*$/m, "");
1776
1776
  content = content.replace(/(\r?\n){3,}/g, "\n\n").trim();
1777
- writeFileSync3(path7, content ? content + "\n" : "", "utf-8");
1777
+ writeFileSync3(path8, content ? content + "\n" : "", "utf-8");
1778
1778
  }
1779
1779
  function stripSettingsJson() {
1780
- const path7 = resolve3(".claude/settings.local.json");
1781
- if (!existsSync7(path7)) return;
1780
+ const path8 = resolve3(".claude/settings.local.json");
1781
+ if (!existsSync7(path8)) return;
1782
1782
  try {
1783
- const settings = JSON.parse(readFileSync4(path7, "utf-8"));
1783
+ const settings = JSON.parse(readFileSync4(path8, "utf-8"));
1784
1784
  const hooks = settings.hooks ?? {};
1785
1785
  const ups = hooks.UserPromptSubmit ?? [];
1786
1786
  hooks.UserPromptSubmit = ups.filter(
@@ -1791,19 +1791,19 @@ function stripSettingsJson() {
1791
1791
  const allow = perms.allow ?? [];
1792
1792
  perms.allow = allow.filter((e) => !e.startsWith("mcp__agentvalet__"));
1793
1793
  settings.permissions = perms;
1794
- writeFileSync3(path7, JSON.stringify(settings, null, 2) + "\n", "utf-8");
1794
+ writeFileSync3(path8, JSON.stringify(settings, null, 2) + "\n", "utf-8");
1795
1795
  } catch {
1796
1796
  }
1797
1797
  }
1798
1798
  function stripMcpJson() {
1799
- const path7 = resolve3(".mcp.json");
1800
- if (!existsSync7(path7)) return;
1799
+ const path8 = resolve3(".mcp.json");
1800
+ if (!existsSync7(path8)) return;
1801
1801
  try {
1802
- const config = JSON.parse(readFileSync4(path7, "utf-8"));
1802
+ const config = JSON.parse(readFileSync4(path8, "utf-8"));
1803
1803
  const servers = config.mcpServers ?? {};
1804
1804
  delete servers["agentvalet"];
1805
1805
  config.mcpServers = servers;
1806
- writeFileSync3(path7, JSON.stringify(config, null, 2) + "\n", "utf-8");
1806
+ writeFileSync3(path8, JSON.stringify(config, null, 2) + "\n", "utf-8");
1807
1807
  } catch {
1808
1808
  }
1809
1809
  }
@@ -1982,13 +1982,155 @@ function uninstallCommand() {
1982
1982
  });
1983
1983
  }
1984
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
+
1985
2127
  // src/index.ts
1986
2128
  var require2 = createRequire2(import.meta.url);
1987
2129
  var { version } = require2("../package.json");
1988
2130
  function collectScope(value, previous) {
1989
2131
  return [...previous, value];
1990
2132
  }
1991
- var program = new Command5();
2133
+ var program = new Command6();
1992
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) => {
1993
2135
  const isJson = !!opts.json;
1994
2136
  let ownerId = opts.owner ?? process.env.AGENTVALET_OWNER ?? "";
@@ -2015,7 +2157,7 @@ program.name("agentvalet-register").description("Self-register an AI agent with
2015
2157
  console.error(JSON.stringify({ error: "--owner or AGENTVALET_OWNER is required" }));
2016
2158
  process.exit(3);
2017
2159
  }
2018
- 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"));
2019
2161
  process.exit(3);
2020
2162
  }
2021
2163
  const scopeMap = /* @__PURE__ */ new Map();
@@ -2023,7 +2165,7 @@ program.name("agentvalet-register").description("Self-register an AI agent with
2023
2165
  const colon = s.indexOf(":");
2024
2166
  if (colon === -1) {
2025
2167
  console.error(
2026
- 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)`)
2027
2169
  );
2028
2170
  process.exit(3);
2029
2171
  }
@@ -2046,11 +2188,11 @@ program.name("agentvalet-register").description("Self-register an AI agent with
2046
2188
  });
2047
2189
  } catch (err) {
2048
2190
  const msg = err instanceof Error ? err.message : String(err);
2049
- 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}`));
2050
2192
  process.exit(3);
2051
2193
  }
2052
2194
  if (!isJson) {
2053
- console.log(chalk12.cyan(`
2195
+ console.log(chalk13.cyan(`
2054
2196
  Approve at: https://app.agentvalet.ai/agents
2055
2197
  `));
2056
2198
  }
@@ -2058,7 +2200,7 @@ Approve at: https://app.agentvalet.ai/agents
2058
2200
  if (isJson) {
2059
2201
  console.log(JSON.stringify({ status: "pending", token }));
2060
2202
  } else {
2061
- console.log(chalk12.yellow("Registration submitted (--no-wait). Token:"), token);
2203
+ console.log(chalk13.yellow("Registration submitted (--no-wait). Token:"), token);
2062
2204
  }
2063
2205
  process.exit(0);
2064
2206
  }
@@ -2069,14 +2211,14 @@ Approve at: https://app.agentvalet.ai/agents
2069
2211
  });
2070
2212
  } catch (err) {
2071
2213
  const msg = err instanceof Error ? err.message : String(err);
2072
- 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}`));
2073
2215
  process.exit(3);
2074
2216
  }
2075
2217
  if (result.status === "rejected") {
2076
2218
  if (isJson) {
2077
2219
  console.log(JSON.stringify({ status: "rejected" }));
2078
2220
  } else {
2079
- console.log(chalk12.red("\nRegistration denied by owner."));
2221
+ console.log(chalk13.red("\nRegistration denied by owner."));
2080
2222
  }
2081
2223
  process.exit(1);
2082
2224
  }
@@ -2084,7 +2226,7 @@ Approve at: https://app.agentvalet.ai/agents
2084
2226
  if (isJson) {
2085
2227
  console.log(JSON.stringify({ status: "timeout" }));
2086
2228
  } else {
2087
- console.log(chalk12.yellow("\nTimed out waiting for approval."));
2229
+ console.log(chalk13.yellow("\nTimed out waiting for approval."));
2088
2230
  }
2089
2231
  process.exit(2);
2090
2232
  }
@@ -2102,35 +2244,35 @@ Approve at: https://app.agentvalet.ai/agents
2102
2244
  }));
2103
2245
  } catch (err) {
2104
2246
  const msg = err instanceof Error ? err.message : String(err);
2105
- 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}`));
2106
2248
  process.exit(3);
2107
2249
  }
2108
2250
  } else {
2109
- 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");
2110
2252
  keyPath = AGENT_KEY_PATH2;
2111
2253
  }
2112
2254
  if (isJson) {
2113
2255
  console.log(JSON.stringify({ status: "approved", agentId, keyPath: keyWritten ? keyPath : null }));
2114
2256
  } else {
2115
- console.log(chalk12.green(`
2257
+ console.log(chalk13.green(`
2116
2258
  Approved! Agent ID: ${agentId}`));
2117
2259
  if (keyWritten) {
2118
- console.log(chalk12.gray(`Key: ${keyPath}`));
2260
+ console.log(chalk13.gray(`Key: ${keyPath}`));
2119
2261
  } else {
2120
- 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}`));
2121
2263
  }
2122
2264
  }
2123
2265
  if (keyWritten) {
2124
2266
  try {
2125
2267
  if (grantedPlatforms && grantedPlatforms.length > 0) {
2126
2268
  writePermissionsFromEvent(agentId, resolvedOwnerId, grantedPlatforms);
2127
- if (!isJson) console.log(chalk12.gray(`Permissions: .claude/agentvalet-permissions.md`));
2269
+ if (!isJson) console.log(chalk13.gray(`Permissions: .claude/agentvalet-permissions.md`));
2128
2270
  } else {
2129
2271
  await runRefresh({ envFile: ".env.agentvalet", outputPath: ".claude/agentvalet-permissions.md", ifStale: false, quiet: isJson });
2130
- if (!isJson) console.log(chalk12.gray(`Permissions: .claude/agentvalet-permissions.md`));
2272
+ if (!isJson) console.log(chalk13.gray(`Permissions: .claude/agentvalet-permissions.md`));
2131
2273
  }
2132
2274
  } catch {
2133
- 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`));
2134
2276
  }
2135
2277
  }
2136
2278
  process.exit(0);
@@ -2145,7 +2287,7 @@ program.command("refresh").description("Refresh approved permissions and update
2145
2287
  });
2146
2288
  } catch (err) {
2147
2289
  const msg = err instanceof Error ? err.message : String(err);
2148
- console.error(chalk12.red(`Refresh failed: ${msg}`));
2290
+ console.error(chalk13.red(`Refresh failed: ${msg}`));
2149
2291
  process.exit(3);
2150
2292
  }
2151
2293
  });
@@ -2157,6 +2299,7 @@ program.addCommand(listCommand());
2157
2299
  program.addCommand(revokeCommand());
2158
2300
  program.addCommand(injectCommand());
2159
2301
  program.addCommand(uninstallCommand());
2302
+ program.addCommand(installCommand());
2160
2303
  program.parseAsync().catch((err) => {
2161
2304
  console.error(err);
2162
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.15",
3
+ "version": "0.4.16",
4
4
  "description": "Self-register AI agents with AgentValet",
5
5
  "type": "module",
6
6
  "bin": {
@@ -10,8 +10,15 @@
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
+ },
13
20
  "dependencies": {
14
- "@agentvalet/mcp-server": "*",
21
+ "@agentvalet/mcp-server": "^0.2.0",
15
22
  "@modelcontextprotocol/sdk": "^1.29.0",
16
23
  "@octokit/auth-oauth-device": "^7.0.0",
17
24
  "chalk": "^5.3.0",
@@ -48,11 +55,5 @@
48
55
  "valet",
49
56
  "agentvalet"
50
57
  ],
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
- }
58
+ "license": "MIT"
59
+ }