@agentvalet/register 0.4.0 → 0.4.2
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 +177 -43
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -193,7 +193,7 @@ async function saveOutput(opts) {
|
|
|
193
193
|
// src/commands/refresh.ts
|
|
194
194
|
import { readFileSync as readFileSync2, writeFileSync as writeFileSync2, existsSync as existsSync2, mkdirSync, statSync } from "fs";
|
|
195
195
|
import { createSign, createPrivateKey } from "crypto";
|
|
196
|
-
import { dirname as dirname2, resolve as resolve2 } from "path";
|
|
196
|
+
import { dirname as dirname2, resolve as resolve2, join } from "path";
|
|
197
197
|
|
|
198
198
|
// src/lib/skill-writer.ts
|
|
199
199
|
import { existsSync, writeFileSync } from "fs";
|
|
@@ -277,6 +277,84 @@ Dashboard: https://app.agentvalet.ai
|
|
|
277
277
|
console.log(chalk2.green(" \u2713 SKILL.md created in current directory"));
|
|
278
278
|
console.log(chalk2.dim(" Commit this file to your repo"));
|
|
279
279
|
}
|
|
280
|
+
function writeQuickstartDoc(opts) {
|
|
281
|
+
const dest = path.join(process.cwd(), "AGENTVALET.md");
|
|
282
|
+
if (existsSync(dest)) {
|
|
283
|
+
console.log(chalk2.dim(" AGENTVALET.md already exists \u2014 skipping"));
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
const { agentId, ownerId, proxyUrl, keyPath, detected } = opts;
|
|
287
|
+
const ideSection = (() => {
|
|
288
|
+
const lines = [];
|
|
289
|
+
if (detected.cursor) {
|
|
290
|
+
lines.push(`### Cursor
|
|
291
|
+
The \`.mcp.json\` in this directory has been configured. Restart Cursor and the AgentValet MCP server will start automatically.`);
|
|
292
|
+
}
|
|
293
|
+
if (detected.claudeCode) {
|
|
294
|
+
lines.push(`### Claude Code
|
|
295
|
+
The \`.mcp.json\` in this directory has been configured. Run \`/mcp\` in Claude Code to verify \`agentvalet\` appears in the list.`);
|
|
296
|
+
}
|
|
297
|
+
if (detected.codex) {
|
|
298
|
+
lines.push(`### Codex
|
|
299
|
+
\`~/.codex/config.toml\` has been updated with the MCP server block. See \`AGENTS.md\` for platform call instructions.`);
|
|
300
|
+
}
|
|
301
|
+
if (detected.openclaw) {
|
|
302
|
+
lines.push(`### OpenClaw
|
|
303
|
+
See \`SKILL.md\` for platform call instructions.`);
|
|
304
|
+
}
|
|
305
|
+
if (lines.length === 0) {
|
|
306
|
+
lines.push(`Add the MCP server to your IDE manually. See: https://docs.agentvalet.ai/setup`);
|
|
307
|
+
}
|
|
308
|
+
return lines.join("\n\n");
|
|
309
|
+
})();
|
|
310
|
+
const content = `# AgentValet \u2014 Quick Reference
|
|
311
|
+
|
|
312
|
+
## This agent
|
|
313
|
+
|
|
314
|
+
| | |
|
|
315
|
+
|---|---|
|
|
316
|
+
| Agent ID | \`${agentId}\` |
|
|
317
|
+
| Owner ID | \`${ownerId}\` |
|
|
318
|
+
| Proxy URL | \`${proxyUrl}\` |
|
|
319
|
+
| Private key | \`${keyPath}\` |
|
|
320
|
+
|
|
321
|
+
Dashboard: https://app.agentvalet.ai
|
|
322
|
+
Activate or manage this agent at: https://app.agentvalet.ai/agents
|
|
323
|
+
|
|
324
|
+
---
|
|
325
|
+
|
|
326
|
+
## CLI commands
|
|
327
|
+
|
|
328
|
+
| Command | What it does |
|
|
329
|
+
|---|---|
|
|
330
|
+
| \`npx @agentvalet/register\` | Register a new agent or re-run setup |
|
|
331
|
+
| \`npx @agentvalet/register refresh\` | Refresh approved platform permissions |
|
|
332
|
+
|
|
333
|
+
> These commands use \`npx\` \u2014 you do not need to install the package globally.
|
|
334
|
+
|
|
335
|
+
---
|
|
336
|
+
|
|
337
|
+
## IDE setup
|
|
338
|
+
|
|
339
|
+
${ideSection}
|
|
340
|
+
|
|
341
|
+
---
|
|
342
|
+
|
|
343
|
+
## Environment variables
|
|
344
|
+
|
|
345
|
+
Set these wherever your IDE agent reads environment from:
|
|
346
|
+
|
|
347
|
+
\`\`\`
|
|
348
|
+
AGENT_ID=${agentId}
|
|
349
|
+
OWNER_ID=${ownerId}
|
|
350
|
+
PROXY_URL=${proxyUrl}
|
|
351
|
+
AGENT_PRIVATE_KEY_PATH=${keyPath}
|
|
352
|
+
\`\`\`
|
|
353
|
+
`;
|
|
354
|
+
writeFileSync(dest, content, "utf8");
|
|
355
|
+
console.log(chalk2.green(" \u2713 AGENTVALET.md created \u2014 quick reference for this agent"));
|
|
356
|
+
console.log(chalk2.dim(" Add to .gitignore if it contains sensitive paths"));
|
|
357
|
+
}
|
|
280
358
|
function ensureMcpServer() {
|
|
281
359
|
try {
|
|
282
360
|
execSync("npx --yes @agentvalet/mcp-server --version", {
|
|
@@ -328,10 +406,28 @@ mcp__agent-authority__use_platform({
|
|
|
328
406
|
})
|
|
329
407
|
\`\`\`
|
|
330
408
|
|
|
331
|
-
To refresh this file: \`agentvalet
|
|
409
|
+
To refresh this file: \`npx @agentvalet/register refresh\`
|
|
332
410
|
`;
|
|
333
411
|
}
|
|
334
412
|
|
|
413
|
+
// src/config/store.ts
|
|
414
|
+
import Conf from "conf";
|
|
415
|
+
var store = new Conf({
|
|
416
|
+
projectName: "agentvalet"
|
|
417
|
+
});
|
|
418
|
+
function getStoredConfig() {
|
|
419
|
+
return store.store;
|
|
420
|
+
}
|
|
421
|
+
function saveConfig(config) {
|
|
422
|
+
store.set(config);
|
|
423
|
+
}
|
|
424
|
+
function clearConfig() {
|
|
425
|
+
store.clear();
|
|
426
|
+
}
|
|
427
|
+
function isAuthenticated() {
|
|
428
|
+
return !!store.get("apiKey");
|
|
429
|
+
}
|
|
430
|
+
|
|
335
431
|
// src/commands/refresh.ts
|
|
336
432
|
var CLAUDE_START = "<!-- agentvalet:start -->";
|
|
337
433
|
var CLAUDE_END = "<!-- agentvalet:end -->";
|
|
@@ -385,20 +481,44 @@ async function runRefresh(options) {
|
|
|
385
481
|
} catch {
|
|
386
482
|
}
|
|
387
483
|
}
|
|
484
|
+
let agentId;
|
|
485
|
+
let ownerId;
|
|
486
|
+
let apiUrl = "https://api.agentvalet.ai";
|
|
487
|
+
let keyPath;
|
|
388
488
|
const envPath = resolve2(options.envFile);
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
489
|
+
if (existsSync2(envPath)) {
|
|
490
|
+
try {
|
|
491
|
+
const envVars = parseEnvFile(readFileSync2(envPath, "utf-8"));
|
|
492
|
+
agentId = envVars["AGENTVALET_AGENT_ID"];
|
|
493
|
+
ownerId = envVars["AGENTVALET_OWNER_ID"];
|
|
494
|
+
apiUrl = envVars["AGENTVALET_API_URL"] ?? apiUrl;
|
|
495
|
+
keyPath = envVars["AGENTVALET_PRIVATE_KEY_PATH"];
|
|
496
|
+
} catch {
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
if (!agentId || !ownerId || !keyPath) {
|
|
500
|
+
const localConfigPath = join(process.cwd(), ".agentvalet", "config.json");
|
|
501
|
+
if (existsSync2(localConfigPath)) {
|
|
502
|
+
try {
|
|
503
|
+
const local = JSON.parse(readFileSync2(localConfigPath, "utf-8"));
|
|
504
|
+
agentId = agentId ?? local["agent_id"];
|
|
505
|
+
apiUrl = local["proxy_url"] ?? apiUrl;
|
|
506
|
+
keyPath = keyPath ?? join(process.cwd(), ".agentvalet", "agent.key");
|
|
507
|
+
} catch {
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
if (!ownerId) {
|
|
511
|
+
try {
|
|
512
|
+
ownerId = getStoredConfig().ownerId ?? void 0;
|
|
513
|
+
} catch {
|
|
514
|
+
}
|
|
515
|
+
}
|
|
395
516
|
}
|
|
396
|
-
const agentId = envVars["AGENTVALET_AGENT_ID"];
|
|
397
|
-
const ownerId = envVars["AGENTVALET_OWNER_ID"];
|
|
398
|
-
const apiUrl = envVars["AGENTVALET_API_URL"] ?? "https://api.agentvalet.ai";
|
|
399
|
-
const keyPath = envVars["AGENTVALET_PRIVATE_KEY_PATH"];
|
|
400
517
|
if (!agentId || !ownerId || !keyPath) {
|
|
401
|
-
throw new Error(
|
|
518
|
+
throw new Error(
|
|
519
|
+
`Cannot find agent credentials.
|
|
520
|
+
Run 'npx @agentvalet/register' in this directory first.`
|
|
521
|
+
);
|
|
402
522
|
}
|
|
403
523
|
let privateKeyPem;
|
|
404
524
|
try {
|
|
@@ -498,22 +618,43 @@ function ensureMcpJson() {
|
|
|
498
618
|
}
|
|
499
619
|
const servers = mcpConfig.mcpServers ?? {};
|
|
500
620
|
if (servers["agent-authority"]) return;
|
|
621
|
+
let agentId;
|
|
622
|
+
let ownerId;
|
|
623
|
+
let apiUrl = "https://api.agentvalet.ai";
|
|
624
|
+
let keyPath;
|
|
501
625
|
const envPath = resolve2(".env.agentvalet");
|
|
502
|
-
if (
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
626
|
+
if (existsSync2(envPath)) {
|
|
627
|
+
try {
|
|
628
|
+
const envVars = parseEnvFile(readFileSync2(envPath, "utf-8"));
|
|
629
|
+
agentId = envVars["AGENTVALET_AGENT_ID"];
|
|
630
|
+
ownerId = envVars["AGENTVALET_OWNER_ID"];
|
|
631
|
+
apiUrl = envVars["AGENTVALET_API_URL"] ?? apiUrl;
|
|
632
|
+
keyPath = envVars["AGENTVALET_PRIVATE_KEY_PATH"];
|
|
633
|
+
} catch {
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
if (!agentId || !keyPath) {
|
|
637
|
+
const localConfigPath = join(process.cwd(), ".agentvalet", "config.json");
|
|
638
|
+
if (existsSync2(localConfigPath)) {
|
|
639
|
+
try {
|
|
640
|
+
const local = JSON.parse(readFileSync2(localConfigPath, "utf-8"));
|
|
641
|
+
agentId = agentId ?? local["agent_id"];
|
|
642
|
+
apiUrl = local["proxy_url"] ?? apiUrl;
|
|
643
|
+
keyPath = keyPath ?? join(process.cwd(), ".agentvalet", "agent.key");
|
|
644
|
+
} catch {
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
if (!ownerId) {
|
|
648
|
+
try {
|
|
649
|
+
ownerId = getStoredConfig().ownerId ?? void 0;
|
|
650
|
+
} catch {
|
|
651
|
+
}
|
|
652
|
+
}
|
|
508
653
|
}
|
|
509
|
-
const agentId = envVars["AGENTVALET_AGENT_ID"];
|
|
510
|
-
const ownerId = envVars["AGENTVALET_OWNER_ID"];
|
|
511
|
-
const apiUrl = envVars["AGENTVALET_API_URL"] ?? "https://api.agentvalet.ai";
|
|
512
|
-
const keyPath = envVars["AGENTVALET_PRIVATE_KEY_PATH"];
|
|
513
654
|
if (!agentId || !ownerId || !keyPath) return;
|
|
514
655
|
servers["agent-authority"] = {
|
|
515
656
|
command: "npx",
|
|
516
|
-
args: ["-y", "@agentvalet/register
|
|
657
|
+
args: ["-y", "@agentvalet/register", "mcp-server"],
|
|
517
658
|
env: {
|
|
518
659
|
AGENT_ID: agentId,
|
|
519
660
|
OWNER_ID: ownerId,
|
|
@@ -667,24 +808,6 @@ async function getAccount(apiKey) {
|
|
|
667
808
|
}
|
|
668
809
|
}
|
|
669
810
|
|
|
670
|
-
// src/config/store.ts
|
|
671
|
-
import Conf from "conf";
|
|
672
|
-
var store = new Conf({
|
|
673
|
-
projectName: "agentvalet"
|
|
674
|
-
});
|
|
675
|
-
function getStoredConfig() {
|
|
676
|
-
return store.store;
|
|
677
|
-
}
|
|
678
|
-
function saveConfig(config) {
|
|
679
|
-
store.set(config);
|
|
680
|
-
}
|
|
681
|
-
function clearConfig() {
|
|
682
|
-
store.clear();
|
|
683
|
-
}
|
|
684
|
-
function isAuthenticated() {
|
|
685
|
-
return !!store.get("apiKey");
|
|
686
|
-
}
|
|
687
|
-
|
|
688
811
|
// src/config/local.ts
|
|
689
812
|
import { mkdir as mkdir2, writeFile as writeFile2, appendFile, readFile } from "fs/promises";
|
|
690
813
|
import path2 from "path";
|
|
@@ -1164,6 +1287,13 @@ async function registerAgentFlow(apiKey, ownerId) {
|
|
|
1164
1287
|
if (detected.openclaw) {
|
|
1165
1288
|
writeSkillMd();
|
|
1166
1289
|
}
|
|
1290
|
+
writeQuickstartDoc({
|
|
1291
|
+
agentId: agent.agent_id,
|
|
1292
|
+
ownerId,
|
|
1293
|
+
proxyUrl,
|
|
1294
|
+
keyPath,
|
|
1295
|
+
detected
|
|
1296
|
+
});
|
|
1167
1297
|
ensureMcpServer();
|
|
1168
1298
|
} else if (shouldSetup === false) {
|
|
1169
1299
|
console.log("");
|
|
@@ -1190,6 +1320,10 @@ async function registerAgentFlow(apiKey, ownerId) {
|
|
|
1190
1320
|
);
|
|
1191
1321
|
console.log(chalk6.dim(" Approve this agent in your dashboard to activate it."));
|
|
1192
1322
|
console.log("");
|
|
1323
|
+
console.log(" Useful commands:");
|
|
1324
|
+
console.log(chalk6.dim(" npx @agentvalet/register \u2014 register another agent"));
|
|
1325
|
+
console.log(chalk6.dim(" npx @agentvalet/register refresh \u2014 refresh approved permissions"));
|
|
1326
|
+
console.log("");
|
|
1193
1327
|
}
|
|
1194
1328
|
function showCredentials(config) {
|
|
1195
1329
|
console.log("");
|
|
@@ -1206,7 +1340,7 @@ function collectScope(value, previous) {
|
|
|
1206
1340
|
return [...previous, value];
|
|
1207
1341
|
}
|
|
1208
1342
|
var program = new Command();
|
|
1209
|
-
program.name("agentvalet-register").description("Self-register an AI agent with AgentValet").version("0.4.
|
|
1343
|
+
program.name("agentvalet-register").description("Self-register an AI agent with AgentValet").version("0.4.1").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) => {
|
|
1210
1344
|
const isJson = !!opts.json;
|
|
1211
1345
|
let ownerId = opts.owner ?? process.env.AGENTVALET_OWNER ?? "";
|
|
1212
1346
|
let agentName = opts.name ?? "";
|