@agentvalet/register 0.4.0 → 0.4.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.
- package/dist/index.js +87 -42
- 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";
|
|
@@ -332,6 +332,24 @@ To refresh this file: \`agentvalet-register refresh\`
|
|
|
332
332
|
`;
|
|
333
333
|
}
|
|
334
334
|
|
|
335
|
+
// src/config/store.ts
|
|
336
|
+
import Conf from "conf";
|
|
337
|
+
var store = new Conf({
|
|
338
|
+
projectName: "agentvalet"
|
|
339
|
+
});
|
|
340
|
+
function getStoredConfig() {
|
|
341
|
+
return store.store;
|
|
342
|
+
}
|
|
343
|
+
function saveConfig(config) {
|
|
344
|
+
store.set(config);
|
|
345
|
+
}
|
|
346
|
+
function clearConfig() {
|
|
347
|
+
store.clear();
|
|
348
|
+
}
|
|
349
|
+
function isAuthenticated() {
|
|
350
|
+
return !!store.get("apiKey");
|
|
351
|
+
}
|
|
352
|
+
|
|
335
353
|
// src/commands/refresh.ts
|
|
336
354
|
var CLAUDE_START = "<!-- agentvalet:start -->";
|
|
337
355
|
var CLAUDE_END = "<!-- agentvalet:end -->";
|
|
@@ -385,20 +403,44 @@ async function runRefresh(options) {
|
|
|
385
403
|
} catch {
|
|
386
404
|
}
|
|
387
405
|
}
|
|
406
|
+
let agentId;
|
|
407
|
+
let ownerId;
|
|
408
|
+
let apiUrl = "https://api.agentvalet.ai";
|
|
409
|
+
let keyPath;
|
|
388
410
|
const envPath = resolve2(options.envFile);
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
411
|
+
if (existsSync2(envPath)) {
|
|
412
|
+
try {
|
|
413
|
+
const envVars = parseEnvFile(readFileSync2(envPath, "utf-8"));
|
|
414
|
+
agentId = envVars["AGENTVALET_AGENT_ID"];
|
|
415
|
+
ownerId = envVars["AGENTVALET_OWNER_ID"];
|
|
416
|
+
apiUrl = envVars["AGENTVALET_API_URL"] ?? apiUrl;
|
|
417
|
+
keyPath = envVars["AGENTVALET_PRIVATE_KEY_PATH"];
|
|
418
|
+
} catch {
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
if (!agentId || !ownerId || !keyPath) {
|
|
422
|
+
const localConfigPath = join(process.cwd(), ".agentvalet", "config.json");
|
|
423
|
+
if (existsSync2(localConfigPath)) {
|
|
424
|
+
try {
|
|
425
|
+
const local = JSON.parse(readFileSync2(localConfigPath, "utf-8"));
|
|
426
|
+
agentId = agentId ?? local["agent_id"];
|
|
427
|
+
apiUrl = local["proxy_url"] ?? apiUrl;
|
|
428
|
+
keyPath = keyPath ?? join(process.cwd(), ".agentvalet", "agent.key");
|
|
429
|
+
} catch {
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
if (!ownerId) {
|
|
433
|
+
try {
|
|
434
|
+
ownerId = getStoredConfig().ownerId ?? void 0;
|
|
435
|
+
} catch {
|
|
436
|
+
}
|
|
437
|
+
}
|
|
395
438
|
}
|
|
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
439
|
if (!agentId || !ownerId || !keyPath) {
|
|
401
|
-
throw new Error(
|
|
440
|
+
throw new Error(
|
|
441
|
+
`Cannot find agent credentials.
|
|
442
|
+
Run 'npx @agentvalet/register' in this directory first.`
|
|
443
|
+
);
|
|
402
444
|
}
|
|
403
445
|
let privateKeyPem;
|
|
404
446
|
try {
|
|
@@ -498,22 +540,43 @@ function ensureMcpJson() {
|
|
|
498
540
|
}
|
|
499
541
|
const servers = mcpConfig.mcpServers ?? {};
|
|
500
542
|
if (servers["agent-authority"]) return;
|
|
543
|
+
let agentId;
|
|
544
|
+
let ownerId;
|
|
545
|
+
let apiUrl = "https://api.agentvalet.ai";
|
|
546
|
+
let keyPath;
|
|
501
547
|
const envPath = resolve2(".env.agentvalet");
|
|
502
|
-
if (
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
548
|
+
if (existsSync2(envPath)) {
|
|
549
|
+
try {
|
|
550
|
+
const envVars = parseEnvFile(readFileSync2(envPath, "utf-8"));
|
|
551
|
+
agentId = envVars["AGENTVALET_AGENT_ID"];
|
|
552
|
+
ownerId = envVars["AGENTVALET_OWNER_ID"];
|
|
553
|
+
apiUrl = envVars["AGENTVALET_API_URL"] ?? apiUrl;
|
|
554
|
+
keyPath = envVars["AGENTVALET_PRIVATE_KEY_PATH"];
|
|
555
|
+
} catch {
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
if (!agentId || !keyPath) {
|
|
559
|
+
const localConfigPath = join(process.cwd(), ".agentvalet", "config.json");
|
|
560
|
+
if (existsSync2(localConfigPath)) {
|
|
561
|
+
try {
|
|
562
|
+
const local = JSON.parse(readFileSync2(localConfigPath, "utf-8"));
|
|
563
|
+
agentId = agentId ?? local["agent_id"];
|
|
564
|
+
apiUrl = local["proxy_url"] ?? apiUrl;
|
|
565
|
+
keyPath = keyPath ?? join(process.cwd(), ".agentvalet", "agent.key");
|
|
566
|
+
} catch {
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
if (!ownerId) {
|
|
570
|
+
try {
|
|
571
|
+
ownerId = getStoredConfig().ownerId ?? void 0;
|
|
572
|
+
} catch {
|
|
573
|
+
}
|
|
574
|
+
}
|
|
508
575
|
}
|
|
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
576
|
if (!agentId || !ownerId || !keyPath) return;
|
|
514
577
|
servers["agent-authority"] = {
|
|
515
578
|
command: "npx",
|
|
516
|
-
args: ["-y", "@agentvalet/register
|
|
579
|
+
args: ["-y", "@agentvalet/register", "mcp-server"],
|
|
517
580
|
env: {
|
|
518
581
|
AGENT_ID: agentId,
|
|
519
582
|
OWNER_ID: ownerId,
|
|
@@ -667,24 +730,6 @@ async function getAccount(apiKey) {
|
|
|
667
730
|
}
|
|
668
731
|
}
|
|
669
732
|
|
|
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
733
|
// src/config/local.ts
|
|
689
734
|
import { mkdir as mkdir2, writeFile as writeFile2, appendFile, readFile } from "fs/promises";
|
|
690
735
|
import path2 from "path";
|
|
@@ -1206,7 +1251,7 @@ function collectScope(value, previous) {
|
|
|
1206
1251
|
return [...previous, value];
|
|
1207
1252
|
}
|
|
1208
1253
|
var program = new Command();
|
|
1209
|
-
program.name("agentvalet-register").description("Self-register an AI agent with AgentValet").version("0.4.
|
|
1254
|
+
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
1255
|
const isJson = !!opts.json;
|
|
1211
1256
|
let ownerId = opts.owner ?? process.env.AGENTVALET_OWNER ?? "";
|
|
1212
1257
|
let agentName = opts.name ?? "";
|