@agentvalet/register 0.4.20 → 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.
Files changed (2) hide show
  1. package/dist/index.js +203 -180
  2. 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";
@@ -1131,45 +1107,114 @@ env = { AGENT_ID = "${params.agentId}", OWNER_ID = "${params.ownerId}", PROXY_UR
1131
1107
  }
1132
1108
  return written;
1133
1109
  }
1110
+ async function stripAgentvaletFromMcpJson(filePath) {
1111
+ if (!existsSync5(filePath)) return false;
1112
+ try {
1113
+ const text = await readFile2(filePath, "utf8");
1114
+ const config = JSON.parse(text);
1115
+ const servers = config.mcpServers ?? {};
1116
+ if (!servers.agentvalet) return false;
1117
+ delete servers.agentvalet;
1118
+ config.mcpServers = servers;
1119
+ await writeFile4(filePath, JSON.stringify(config, null, 2) + "\n", "utf8");
1120
+ return true;
1121
+ } catch {
1122
+ return false;
1123
+ }
1124
+ }
1125
+ async function cleanProjectScopedEntries() {
1126
+ const cleaned = [];
1127
+ const cwd = process.cwd();
1128
+ if (await stripAgentvaletFromMcpJson(path4.join(cwd, ".mcp.json"))) {
1129
+ cleaned.push(".mcp.json (project entry removed)");
1130
+ }
1131
+ if (await stripAgentvaletFromMcpJson(path4.join(cwd, ".cursor/mcp.json"))) {
1132
+ cleaned.push(".cursor/mcp.json (project entry removed)");
1133
+ }
1134
+ const factoryProjectMcp = path4.join(cwd, ".factory/mcp.json");
1135
+ if (existsSync5(factoryProjectMcp)) {
1136
+ try {
1137
+ const text = await readFile2(factoryProjectMcp, "utf8");
1138
+ const config = JSON.parse(text);
1139
+ if (config.agentvalet) {
1140
+ delete config.agentvalet;
1141
+ await writeFile4(factoryProjectMcp, JSON.stringify(config, null, 2) + "\n", "utf8");
1142
+ cleaned.push(".factory/mcp.json (project entry removed)");
1143
+ }
1144
+ } catch {
1145
+ }
1146
+ }
1147
+ return cleaned;
1148
+ }
1134
1149
  async function writeIdeConfigs(params) {
1135
- const { detected, ...mcpParams } = params;
1150
+ const { detected, scope = "user", ...mcpParams } = params;
1136
1151
  const cwd = process.cwd();
1152
+ const home = os.homedir();
1137
1153
  const written = [];
1138
1154
  const entry = buildMcpEntry(mcpParams);
1139
- if (detected.claudeCode) {
1140
- const claudeMcpPath = path4.join(cwd, ".mcp.json");
1141
- try {
1142
- await mergeJsonFile(claudeMcpPath, "agentvalet", entry);
1143
- written.push(".mcp.json");
1144
- } catch (err) {
1145
- console.warn(` Warning: could not write .mcp.json: ${err.message}`);
1155
+ if (scope === "user") {
1156
+ if (detected.claudeCode) {
1157
+ const claudeUserConfig = path4.join(home, ".claude.json");
1158
+ try {
1159
+ await mergeJsonFile(claudeUserConfig, "agentvalet", entry);
1160
+ written.push("~/.claude.json");
1161
+ } catch (err) {
1162
+ console.warn(` Warning: could not write ~/.claude.json: ${err.message}`);
1163
+ }
1146
1164
  }
1147
- const claudeMdPath = path4.join(cwd, "CLAUDE.md");
1148
- if (!existsSync5(claudeMdPath)) {
1165
+ if (detected.cursor) {
1166
+ const cursorUserDir = path4.join(home, ".cursor");
1167
+ const cursorUserMcp = path4.join(cursorUserDir, "mcp.json");
1149
1168
  try {
1150
- await writeFile4(claudeMdPath, buildClaudeMd(params.agentId, params.ownerId, params.proxyUrl), "utf8");
1151
- written.push("CLAUDE.md");
1169
+ await mkdir3(cursorUserDir, { recursive: true });
1170
+ await mergeJsonFile(cursorUserMcp, "agentvalet", entry);
1171
+ written.push("~/.cursor/mcp.json");
1152
1172
  } catch (err) {
1153
- console.warn(` Warning: could not write CLAUDE.md: ${err.message}`);
1173
+ console.warn(` Warning: could not write ~/.cursor/mcp.json: ${err.message}`);
1154
1174
  }
1155
- } else {
1156
- written.push("CLAUDE.md (already exists \u2014 skipped)");
1157
1175
  }
1158
- }
1159
- if (detected.cursor) {
1160
- const cursorDir = path4.join(cwd, ".cursor");
1161
- const cursorMcpPath = path4.join(cursorDir, "mcp.json");
1162
- try {
1163
- await mkdir3(cursorDir, { recursive: true });
1164
- await mergeJsonFile(cursorMcpPath, "agentvalet", entry);
1165
- written.push(".cursor/mcp.json");
1166
- } catch (err) {
1167
- console.warn(` Warning: could not write .cursor/mcp.json: ${err.message}`);
1176
+ if (detected.factoryDroid) {
1177
+ const fdResults = await writeFactoryDroidConfig({ ...mcpParams, scope: "user" });
1178
+ written.push(...fdResults);
1179
+ }
1180
+ const cleaned = await cleanProjectScopedEntries();
1181
+ written.push(...cleaned);
1182
+ } else {
1183
+ if (detected.claudeCode) {
1184
+ const claudeMcpPath = path4.join(cwd, ".mcp.json");
1185
+ try {
1186
+ await mergeJsonFile(claudeMcpPath, "agentvalet", entry);
1187
+ written.push(".mcp.json");
1188
+ } catch (err) {
1189
+ console.warn(` Warning: could not write .mcp.json: ${err.message}`);
1190
+ }
1191
+ const claudeMdPath = path4.join(cwd, "CLAUDE.md");
1192
+ if (!existsSync5(claudeMdPath)) {
1193
+ try {
1194
+ await writeFile4(claudeMdPath, buildClaudeMd(params.agentId, params.ownerId, params.proxyUrl), "utf8");
1195
+ written.push("CLAUDE.md");
1196
+ } catch (err) {
1197
+ console.warn(` Warning: could not write CLAUDE.md: ${err.message}`);
1198
+ }
1199
+ } else {
1200
+ written.push("CLAUDE.md (already exists \u2014 skipped)");
1201
+ }
1202
+ }
1203
+ if (detected.cursor) {
1204
+ const cursorDir = path4.join(cwd, ".cursor");
1205
+ const cursorMcpPath = path4.join(cursorDir, "mcp.json");
1206
+ try {
1207
+ await mkdir3(cursorDir, { recursive: true });
1208
+ await mergeJsonFile(cursorMcpPath, "agentvalet", entry);
1209
+ written.push(".cursor/mcp.json");
1210
+ } catch (err) {
1211
+ console.warn(` Warning: could not write .cursor/mcp.json: ${err.message}`);
1212
+ }
1213
+ }
1214
+ if (detected.factoryDroid) {
1215
+ const fdResults = await writeFactoryDroidConfig({ ...mcpParams, scope: "project" });
1216
+ written.push(...fdResults);
1168
1217
  }
1169
- }
1170
- if (detected.factoryDroid) {
1171
- const fdResults = await writeFactoryDroidConfig(mcpParams);
1172
- written.push(...fdResults);
1173
1218
  }
1174
1219
  return written;
1175
1220
  }
@@ -1207,27 +1252,25 @@ async function writeFactoryDroidConfig(params) {
1207
1252
  const home = os.homedir();
1208
1253
  const written = [];
1209
1254
  const entry = buildMcpEntry(params);
1255
+ const scope = params.scope ?? "user";
1210
1256
  const globalDir = path4.join(home, ".factory");
1211
1257
  const projectDir = path4.join(process.cwd(), ".factory");
1212
- const globalDirExists = existsSync5(globalDir);
1213
- const projectDirExists = existsSync5(projectDir);
1214
- if (globalDirExists) {
1258
+ if (scope === "user") {
1215
1259
  try {
1260
+ await mkdir3(globalDir, { recursive: true });
1216
1261
  await mergeFactoryDroidMcpJson(path4.join(globalDir, "mcp.json"), "agentvalet", entry);
1217
1262
  written.push("~/.factory/mcp.json");
1218
1263
  } catch (err) {
1219
1264
  console.warn(` Warning: could not write ~/.factory/mcp.json: ${err.message}`);
1220
1265
  }
1221
- }
1222
- if (projectDirExists && !globalDirExists) {
1266
+ } else {
1223
1267
  try {
1268
+ await mkdir3(projectDir, { recursive: true });
1224
1269
  await mergeFactoryDroidMcpJson(path4.join(projectDir, "mcp.json"), "agentvalet", entry);
1225
1270
  written.push(".factory/mcp.json");
1226
1271
  } catch (err) {
1227
1272
  console.warn(` Warning: could not write .factory/mcp.json: ${err.message}`);
1228
1273
  }
1229
- }
1230
- if (written.length > 0) {
1231
1274
  try {
1232
1275
  await updateGitignoreForFactoryDroid();
1233
1276
  } catch {
@@ -1315,7 +1358,8 @@ async function frameworkSetupConsent(detected) {
1315
1358
  import os3 from "os";
1316
1359
  import path6 from "path";
1317
1360
  import { writeFile as writeFile5 } from "fs/promises";
1318
- async function runOnboard() {
1361
+ async function runOnboard(opts = {}) {
1362
+ const scope = opts.scope ?? "user";
1319
1363
  console.log("");
1320
1364
  console.log(chalk7.bold(" AgentValet \u2014 Agent Registration"));
1321
1365
  console.log(chalk7.dim(" app.agentvalet.ai"));
@@ -1347,24 +1391,7 @@ async function runOnboard() {
1347
1391
  console.log(chalk7.dim(" Signed out. Run again to re-authenticate."));
1348
1392
  return;
1349
1393
  }
1350
- await registerAgentFlow(stored.cliToken, stored.ownerId);
1351
- return;
1352
- }
1353
- const { authMethod } = await prompts3({
1354
- type: "select",
1355
- name: "authMethod",
1356
- message: "How would you like to sign in?",
1357
- choices: [
1358
- { title: "Sign in with your browser (opens app.agentvalet.ai)", value: "browser" },
1359
- { title: "Paste Owner ID from app.agentvalet.ai/settings", value: "ownerid" }
1360
- ],
1361
- hint: "No account yet? Visit app.agentvalet.ai to sign up first"
1362
- });
1363
- if (authMethod === void 0) {
1364
- process.exit(0);
1365
- }
1366
- if (authMethod === "ownerid") {
1367
- await ownerIdFlow();
1394
+ await registerAgentFlow(stored.cliToken, stored.ownerId, scope);
1368
1395
  return;
1369
1396
  }
1370
1397
  let credentials;
@@ -1384,42 +1411,9 @@ async function runOnboard() {
1384
1411
  email: credentials.email ?? "",
1385
1412
  cliToken: credentials.cliToken
1386
1413
  });
1387
- await registerAgentFlow(credentials.cliToken, credentials.ownerId);
1388
- }
1389
- async function ownerIdFlow() {
1390
- console.log("");
1391
- console.log(chalk7.dim(" Find your Owner ID at: ") + chalk7.cyan.underline("https://app.agentvalet.ai/settings"));
1392
- console.log("");
1393
- const { ownerId } = await prompts3({
1394
- type: "text",
1395
- name: "ownerId",
1396
- message: "Paste your Owner ID:",
1397
- validate: (v) => v.trim().length > 10 || "Owner ID looks too short"
1398
- });
1399
- if (ownerId === void 0) {
1400
- process.exit(0);
1401
- }
1402
- const spinner = ora(" Verifying Owner ID...").start();
1403
- let account;
1404
- try {
1405
- account = await getAccount(ownerId.trim());
1406
- spinner.succeed(` Account verified \u2014 plan: ${chalk7.bold(account.plan)}`);
1407
- } catch (err) {
1408
- spinner.fail(` Could not verify Owner ID: ${err.message}`);
1409
- console.log(chalk7.dim(" Make sure you copied the full Owner ID from app.agentvalet.ai/settings"));
1410
- process.exit(1);
1411
- }
1412
- saveConfig({
1413
- apiKey: account.owner_id,
1414
- ownerId: account.owner_id,
1415
- orgId: account.org_id,
1416
- proxyUrl: "https://api.agentvalet.ai",
1417
- email: account.email ?? "",
1418
- cliToken: account.cli_token
1419
- });
1420
- await registerAgentFlow(account.cli_token, account.owner_id);
1414
+ await registerAgentFlow(credentials.cliToken, credentials.ownerId, scope);
1421
1415
  }
1422
- async function registerAgentFlow(apiKey, ownerId) {
1416
+ async function registerAgentFlow(apiKey, ownerId, scope = "user") {
1423
1417
  const hostname = os3.hostname().split(".")[0];
1424
1418
  const dirName = process.cwd().split("/").pop() ?? process.cwd().split("\\").pop() ?? "agent";
1425
1419
  const { agentName } = await prompts3({
@@ -1492,7 +1486,8 @@ async function registerAgentFlow(apiKey, ownerId) {
1492
1486
  ownerId,
1493
1487
  proxyUrl,
1494
1488
  keyPath,
1495
- detected
1489
+ detected,
1490
+ scope
1496
1491
  });
1497
1492
  for (const r of ideResults) {
1498
1493
  console.log(chalk7.green(` \u2713 ${r}`));
@@ -1506,26 +1501,22 @@ async function registerAgentFlow(apiKey, ownerId) {
1506
1501
  for (const r of globalResults) {
1507
1502
  console.log(chalk7.green(` \u2713 ${r}`));
1508
1503
  }
1509
- if (detected.codex) {
1510
- writeAgentsMd();
1511
- }
1512
- if (detected.openclaw) {
1513
- writeSkillMd();
1514
- }
1515
- if (detected.factoryDroid) {
1516
- writeFactoryDroidDroid();
1517
- writeFactoryDroidCommand();
1518
- if (installReliabilityDroid) {
1519
- writeFactoryDroidReliabilityDroid();
1504
+ if (scope === "project") {
1505
+ if (detected.codex) writeAgentsMd();
1506
+ if (detected.openclaw) writeSkillMd();
1507
+ if (detected.factoryDroid) {
1508
+ writeFactoryDroidDroid();
1509
+ writeFactoryDroidCommand();
1510
+ if (installReliabilityDroid) writeFactoryDroidReliabilityDroid();
1520
1511
  }
1512
+ writeQuickstartDoc({
1513
+ agentId: agent.agent_id,
1514
+ ownerId,
1515
+ proxyUrl,
1516
+ keyPath,
1517
+ detected
1518
+ });
1521
1519
  }
1522
- writeQuickstartDoc({
1523
- agentId: agent.agent_id,
1524
- ownerId,
1525
- proxyUrl,
1526
- keyPath,
1527
- detected
1528
- });
1529
1520
  ensureMcpServer();
1530
1521
  } else if (shouldSetup === false) {
1531
1522
  console.log("");
@@ -1553,22 +1544,35 @@ async function registerAgentFlow(apiKey, ownerId) {
1553
1544
  console.log(chalk7.dim(" Approve this agent in your dashboard to activate it."));
1554
1545
  console.log("");
1555
1546
  if (shouldSetup) {
1556
- if (detected.claudeCode) {
1557
- console.log(chalk7.yellow(" \u26A0 Claude Code: project MCPs require trust on first run."));
1558
- console.log(chalk7.dim(" In your Claude Code session, run: /mcp"));
1559
- console.log(chalk7.dim(' Approve "agentvalet" to load the tools.'));
1547
+ if (scope === "user") {
1548
+ const restartList = [];
1549
+ if (detected.claudeCode) restartList.push("Claude Code");
1550
+ if (detected.cursor) restartList.push("Cursor");
1551
+ if (detected.factoryDroid) restartList.push("Factory Droid");
1552
+ if (detected.codex) restartList.push("Codex CLI");
1553
+ if (restartList.length > 0) {
1554
+ console.log(chalk7.dim(" Restart these to pick up the new MCP server (no trust prompt \u2014 user-scoped):"));
1555
+ for (const r of restartList) console.log(chalk7.dim(` ${r}`));
1556
+ console.log("");
1557
+ }
1558
+ } else {
1559
+ if (detected.claudeCode) {
1560
+ console.log(chalk7.yellow(" \u26A0 Claude Code: project MCPs require trust on first run."));
1561
+ console.log(chalk7.dim(" In your Claude Code session, run: /mcp"));
1562
+ console.log(chalk7.dim(' Approve "agentvalet" to load the tools.'));
1563
+ console.log("");
1564
+ }
1565
+ if (detected.cursor) {
1566
+ console.log(chalk7.dim(" Cursor: restart Cursor (or reopen the workspace) to pick up the MCP."));
1567
+ }
1568
+ if (detected.factoryDroid) {
1569
+ console.log(chalk7.dim(" Factory Droid: restart Factory to pick up the MCP."));
1570
+ }
1571
+ if (detected.codex) {
1572
+ console.log(chalk7.dim(" Codex CLI: start a new codex session to pick up the MCP."));
1573
+ }
1560
1574
  console.log("");
1561
1575
  }
1562
- if (detected.cursor) {
1563
- console.log(chalk7.dim(" Cursor: restart Cursor (or reopen the workspace) to pick up the MCP."));
1564
- }
1565
- if (detected.factoryDroid) {
1566
- console.log(chalk7.dim(" Factory Droid: restart Factory to pick up the MCP."));
1567
- }
1568
- if (detected.codex) {
1569
- console.log(chalk7.dim(" Codex CLI: start a new codex session to pick up the MCP."));
1570
- }
1571
- console.log("");
1572
1576
  }
1573
1577
  console.log(" Useful commands:");
1574
1578
  console.log(chalk7.dim(" npx @agentvalet/register \u2014 register another agent"));
@@ -1900,8 +1904,10 @@ function cleanLocally() {
1900
1904
  if (stripMcpJson(resolve3(".mcp.json"))) stripped.push(".mcp.json");
1901
1905
  if (stripMcpJson(resolve3(".cursor/mcp.json"))) stripped.push(".cursor/mcp.json");
1902
1906
  if (stripMcpJson(resolve3(".factory/mcp.json"), { wrapped: false })) stripped.push(".factory/mcp.json");
1903
- const homeFactoryMcp = join2(homedir2(), ".factory", "mcp.json");
1904
- if (stripMcpJson(homeFactoryMcp, { wrapped: false })) stripped.push("~/.factory/mcp.json");
1907
+ const home = homedir2();
1908
+ if (stripMcpJson(join2(home, ".claude.json"))) stripped.push("~/.claude.json");
1909
+ if (stripMcpJson(join2(home, ".cursor", "mcp.json"))) stripped.push("~/.cursor/mcp.json");
1910
+ if (stripMcpJson(join2(home, ".factory", "mcp.json"), { wrapped: false })) stripped.push("~/.factory/mcp.json");
1905
1911
  if (stripCodexToml()) stripped.push("~/.codex/config.toml");
1906
1912
  stripClaudeMd();
1907
1913
  stripSettingsJson();
@@ -2090,7 +2096,8 @@ async function claimToken(installToken) {
2090
2096
  return body;
2091
2097
  }
2092
2098
  function installCommand() {
2093
- 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) => {
2099
+ 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").option("--project", "write project-scoped configs (.mcp.json, .cursor/mcp.json) instead of user-scoped (~/.claude.json, ~/.cursor/mcp.json)").action(async (token, opts) => {
2100
+ const scope = opts.project ? "project" : "user";
2094
2101
  if (!token.startsWith("itok_")) {
2095
2102
  console.error(chalk12.red('Invalid install token. Tokens start with "itok_".'));
2096
2103
  process.exit(3);
@@ -2150,7 +2157,8 @@ function installCommand() {
2150
2157
  ownerId: owner_id,
2151
2158
  proxyUrl: proxy_url,
2152
2159
  keyPath: AGENT_KEY_PATH,
2153
- detected
2160
+ detected,
2161
+ scope
2154
2162
  });
2155
2163
  for (const r of ideResults) console.log(chalk12.green(` \u2713 ${r}`));
2156
2164
  const globalResults = await writeGlobalFrameworkConfigs({
@@ -2160,20 +2168,22 @@ function installCommand() {
2160
2168
  keyPath: AGENT_KEY_PATH
2161
2169
  });
2162
2170
  for (const r of globalResults) console.log(chalk12.green(` \u2713 ${r}`));
2163
- if (detected.codex) writeAgentsMd();
2164
- if (detected.openclaw) writeSkillMd();
2165
- if (detected.factoryDroid) {
2166
- writeFactoryDroidDroid();
2167
- writeFactoryDroidCommand();
2168
- if (installReliabilityDroid) writeFactoryDroidReliabilityDroid();
2171
+ if (scope === "project") {
2172
+ if (detected.codex) writeAgentsMd();
2173
+ if (detected.openclaw) writeSkillMd();
2174
+ if (detected.factoryDroid) {
2175
+ writeFactoryDroidDroid();
2176
+ writeFactoryDroidCommand();
2177
+ if (installReliabilityDroid) writeFactoryDroidReliabilityDroid();
2178
+ }
2179
+ writeQuickstartDoc({
2180
+ agentId: agent_id,
2181
+ ownerId: owner_id,
2182
+ proxyUrl: proxy_url,
2183
+ keyPath: AGENT_KEY_PATH,
2184
+ detected
2185
+ });
2169
2186
  }
2170
- writeQuickstartDoc({
2171
- agentId: agent_id,
2172
- ownerId: owner_id,
2173
- proxyUrl: proxy_url,
2174
- keyPath: AGENT_KEY_PATH,
2175
- detected
2176
- });
2177
2187
  ensureMcpServer();
2178
2188
  }
2179
2189
  }
@@ -2198,20 +2208,33 @@ function installCommand() {
2198
2208
  console.log("");
2199
2209
  if (opts.frameworks !== false) {
2200
2210
  const detected = detectFrameworks();
2201
- if (detected.claudeCode) {
2202
- console.log(chalk12.yellow(" \u26A0 Claude Code: project MCPs require trust on first run."));
2203
- console.log(chalk12.dim(" In your Claude Code session, run: /mcp"));
2204
- console.log(chalk12.dim(' Approve "agentvalet" to load the tools.'));
2205
- console.log("");
2206
- }
2207
- if (detected.cursor) {
2208
- console.log(chalk12.dim(" Cursor: restart Cursor (or reopen the workspace) to pick up the MCP."));
2209
- }
2210
- if (detected.factoryDroid) {
2211
- console.log(chalk12.dim(" Factory Droid: restart Factory to pick up the MCP."));
2212
- }
2213
- if (detected.codex) {
2214
- console.log(chalk12.dim(" Codex CLI: start a new codex session to pick up the MCP."));
2211
+ if (scope === "user") {
2212
+ const restartList = [];
2213
+ if (detected.claudeCode) restartList.push("Claude Code");
2214
+ if (detected.cursor) restartList.push("Cursor");
2215
+ if (detected.factoryDroid) restartList.push("Factory Droid");
2216
+ if (detected.codex) restartList.push("Codex CLI");
2217
+ if (restartList.length > 0) {
2218
+ console.log(chalk12.dim(" Restart these to pick up the new MCP server (no trust prompt \u2014 user-scoped):"));
2219
+ for (const r of restartList) console.log(chalk12.dim(` ${r}`));
2220
+ console.log("");
2221
+ }
2222
+ } else {
2223
+ if (detected.claudeCode) {
2224
+ console.log(chalk12.yellow(" \u26A0 Claude Code: project MCPs require trust on first run."));
2225
+ console.log(chalk12.dim(" In your Claude Code session, run: /mcp"));
2226
+ console.log(chalk12.dim(' Approve "agentvalet" to load the tools.'));
2227
+ console.log("");
2228
+ }
2229
+ if (detected.cursor) {
2230
+ console.log(chalk12.dim(" Cursor: restart Cursor (or reopen the workspace) to pick up the MCP."));
2231
+ }
2232
+ if (detected.factoryDroid) {
2233
+ console.log(chalk12.dim(" Factory Droid: restart Factory to pick up the MCP."));
2234
+ }
2235
+ if (detected.codex) {
2236
+ console.log(chalk12.dim(" Codex CLI: start a new codex session to pick up the MCP."));
2237
+ }
2215
2238
  }
2216
2239
  }
2217
2240
  console.log(` Dashboard: ${chalk12.cyan.underline("https://app.agentvalet.ai/agents/" + agent_id)}`);
@@ -2227,14 +2250,14 @@ function collectScope(value, previous) {
2227
2250
  return [...previous, value];
2228
2251
  }
2229
2252
  var program = new Command6();
2230
- 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) => {
2253
+ 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").option("--project", "Write project-scoped MCP configs (.mcp.json, .cursor/mcp.json) instead of user-scoped (~/.claude.json, ~/.cursor/mcp.json)").action(async (opts) => {
2231
2254
  const isJson = !!opts.json;
2232
2255
  let ownerId = opts.owner ?? process.env.AGENTVALET_OWNER ?? "";
2233
2256
  let agentName = opts.name ?? "";
2234
2257
  let description = opts.description ?? "";
2235
2258
  let scopes = opts.scope;
2236
2259
  if (!ownerId && !isAuthenticated()) {
2237
- await runOnboard();
2260
+ await runOnboard({ scope: opts.project ? "project" : "user" });
2238
2261
  return;
2239
2262
  }
2240
2263
  if (!agentName) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentvalet/register",
3
- "version": "0.4.20",
3
+ "version": "0.5.1",
4
4
  "description": "Self-register AI agents with AgentValet",
5
5
  "type": "module",
6
6
  "bin": {