@agentvalet/register 0.4.13 → 0.4.14
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/chunk-2EFPJNYK.js +32 -0
- package/dist/index.js +101 -145
- package/dist/store-JYJXDBYX.js +16 -0
- package/package.json +10 -9
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// src/config/store.ts
|
|
2
|
+
import Conf from "conf";
|
|
3
|
+
import { homedir } from "os";
|
|
4
|
+
import { join } from "path";
|
|
5
|
+
var AGENT_DIR = join(homedir(), ".agentvalet");
|
|
6
|
+
var AGENT_KEY_PATH = join(AGENT_DIR, "agent.key");
|
|
7
|
+
var store = new Conf({
|
|
8
|
+
projectName: "agentvalet",
|
|
9
|
+
cwd: AGENT_DIR,
|
|
10
|
+
configName: "config"
|
|
11
|
+
});
|
|
12
|
+
function getStoredConfig() {
|
|
13
|
+
return store.store;
|
|
14
|
+
}
|
|
15
|
+
function saveConfig(config) {
|
|
16
|
+
store.set(config);
|
|
17
|
+
}
|
|
18
|
+
function clearConfig() {
|
|
19
|
+
store.clear();
|
|
20
|
+
}
|
|
21
|
+
function isAuthenticated() {
|
|
22
|
+
return !!store.get("apiKey");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
AGENT_DIR,
|
|
27
|
+
AGENT_KEY_PATH,
|
|
28
|
+
getStoredConfig,
|
|
29
|
+
saveConfig,
|
|
30
|
+
clearConfig,
|
|
31
|
+
isAuthenticated
|
|
32
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
AGENT_DIR,
|
|
4
|
+
AGENT_KEY_PATH,
|
|
5
|
+
clearConfig,
|
|
6
|
+
getStoredConfig,
|
|
7
|
+
isAuthenticated,
|
|
8
|
+
saveConfig
|
|
9
|
+
} from "./chunk-2EFPJNYK.js";
|
|
2
10
|
|
|
3
11
|
// src/index.ts
|
|
4
12
|
import { createRequire } from "module";
|
|
@@ -167,33 +175,29 @@ function parseEvent(data) {
|
|
|
167
175
|
return null;
|
|
168
176
|
}
|
|
169
177
|
function sleep(ms) {
|
|
170
|
-
return new Promise((
|
|
178
|
+
return new Promise((resolve4) => setTimeout(resolve4, ms));
|
|
171
179
|
}
|
|
172
180
|
|
|
173
181
|
// src/save.ts
|
|
174
182
|
import { writeFile, mkdir } from "fs/promises";
|
|
175
|
-
import { dirname, resolve } from "path";
|
|
176
183
|
async function saveOutput(opts) {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
].join("\n");
|
|
190
|
-
await writeFile(envPath, envContent, "utf-8");
|
|
191
|
-
return { keyPath, envPath };
|
|
184
|
+
await mkdir(AGENT_DIR, { recursive: true });
|
|
185
|
+
await writeFile(AGENT_KEY_PATH, opts.privateKey, { mode: 384 });
|
|
186
|
+
saveConfig({
|
|
187
|
+
agentId: opts.agentId,
|
|
188
|
+
ownerId: opts.ownerId,
|
|
189
|
+
apiUrl: opts.apiUrl,
|
|
190
|
+
keyPath: AGENT_KEY_PATH,
|
|
191
|
+
// keep legacy fields in sync
|
|
192
|
+
lastAgentId: opts.agentId,
|
|
193
|
+
lastKeyPath: AGENT_KEY_PATH
|
|
194
|
+
});
|
|
195
|
+
return { keyPath: AGENT_KEY_PATH };
|
|
192
196
|
}
|
|
193
197
|
|
|
194
198
|
// src/commands/refresh.ts
|
|
195
199
|
import { readFileSync as readFileSync3, writeFileSync as writeFileSync2, existsSync as existsSync3, mkdirSync as mkdirSync2, statSync } from "fs";
|
|
196
|
-
import { dirname
|
|
200
|
+
import { dirname, resolve as resolve2 } from "path";
|
|
197
201
|
|
|
198
202
|
// src/lib/jwt.ts
|
|
199
203
|
import { createSign, createPrivateKey } from "crypto";
|
|
@@ -629,27 +633,7 @@ To refresh this file: \`npx @agentvalet/register refresh\`
|
|
|
629
633
|
|
|
630
634
|
// src/lib/require-agent.ts
|
|
631
635
|
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
632
|
-
import { resolve
|
|
633
|
-
|
|
634
|
-
// src/config/store.ts
|
|
635
|
-
import Conf from "conf";
|
|
636
|
-
var store = new Conf({
|
|
637
|
-
projectName: "agentvalet"
|
|
638
|
-
});
|
|
639
|
-
function getStoredConfig() {
|
|
640
|
-
return store.store;
|
|
641
|
-
}
|
|
642
|
-
function saveConfig(config) {
|
|
643
|
-
store.set(config);
|
|
644
|
-
}
|
|
645
|
-
function clearConfig() {
|
|
646
|
-
store.clear();
|
|
647
|
-
}
|
|
648
|
-
function isAuthenticated() {
|
|
649
|
-
return !!store.get("apiKey");
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
// src/lib/require-agent.ts
|
|
636
|
+
import { resolve } from "path";
|
|
653
637
|
import chalk3 from "chalk";
|
|
654
638
|
var NO_AGENT_MSG = chalk3.red("\n \u2717 No agent registered.\n") + chalk3.dim(
|
|
655
639
|
" Run the following command first to register an agent in this directory:\n\n npx @agentvalet/register\n"
|
|
@@ -670,45 +654,34 @@ function tryResolveAgent(envFile = ".env.agentvalet") {
|
|
|
670
654
|
let ownerId;
|
|
671
655
|
let apiUrl = "https://api.agentvalet.ai";
|
|
672
656
|
let keyPath;
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
keyPath = vars["AGENTVALET_PRIVATE_KEY_PATH"];
|
|
681
|
-
} catch {
|
|
682
|
-
}
|
|
657
|
+
try {
|
|
658
|
+
const stored = getStoredConfig();
|
|
659
|
+
agentId = stored.agentId ?? stored.lastAgentId ?? void 0;
|
|
660
|
+
ownerId = stored.ownerId ?? void 0;
|
|
661
|
+
apiUrl = stored.apiUrl ?? stored.proxyUrl ?? apiUrl;
|
|
662
|
+
keyPath = stored.keyPath ?? stored.lastKeyPath ?? void 0;
|
|
663
|
+
} catch {
|
|
683
664
|
}
|
|
684
|
-
if (!
|
|
685
|
-
|
|
686
|
-
|
|
665
|
+
if (!keyPath) keyPath = AGENT_KEY_PATH;
|
|
666
|
+
if (!agentId || !ownerId) {
|
|
667
|
+
const envPath = resolve(envFile);
|
|
668
|
+
if (existsSync2(envPath)) {
|
|
687
669
|
try {
|
|
688
|
-
const
|
|
689
|
-
agentId = agentId ??
|
|
690
|
-
|
|
691
|
-
|
|
670
|
+
const vars = parseEnvFile(readFileSync2(envPath, "utf-8"));
|
|
671
|
+
agentId = agentId ?? vars["AGENTVALET_AGENT_ID"];
|
|
672
|
+
ownerId = ownerId ?? vars["AGENTVALET_OWNER_ID"];
|
|
673
|
+
apiUrl = vars["AGENTVALET_API_URL"] ?? apiUrl;
|
|
674
|
+
keyPath = vars["AGENTVALET_PRIVATE_KEY_PATH"] ?? keyPath;
|
|
692
675
|
} catch {
|
|
693
676
|
}
|
|
694
677
|
}
|
|
695
|
-
try {
|
|
696
|
-
const global = getStoredConfig();
|
|
697
|
-
if (!ownerId) ownerId = global.ownerId ?? void 0;
|
|
698
|
-
} catch {
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
if (!agentId || !ownerId || !keyPath) {
|
|
702
|
-
try {
|
|
703
|
-
const global = getStoredConfig();
|
|
704
|
-
agentId = agentId ?? global.lastAgentId ?? void 0;
|
|
705
|
-
ownerId = ownerId ?? global.ownerId ?? void 0;
|
|
706
|
-
keyPath = keyPath ?? global.lastKeyPath ?? void 0;
|
|
707
|
-
apiUrl = global.proxyUrl ?? apiUrl;
|
|
708
|
-
} catch {
|
|
709
|
-
}
|
|
710
678
|
}
|
|
679
|
+
agentId = agentId ?? process.env["AGENTVALET_AGENT_ID"];
|
|
680
|
+
ownerId = ownerId ?? process.env["AGENTVALET_OWNER_ID"];
|
|
681
|
+
if (process.env["AGENTVALET_API_URL"]) apiUrl = process.env["AGENTVALET_API_URL"];
|
|
682
|
+
if (process.env["AGENTVALET_PRIVATE_KEY_PATH"]) keyPath = process.env["AGENTVALET_PRIVATE_KEY_PATH"];
|
|
711
683
|
if (!agentId || !ownerId || !keyPath) return null;
|
|
684
|
+
if (!existsSync2(resolve(keyPath))) return null;
|
|
712
685
|
return { agentId, ownerId, keyPath, apiUrl };
|
|
713
686
|
}
|
|
714
687
|
|
|
@@ -719,19 +692,19 @@ var HOOK_COMMAND = "npx @agentvalet/register refresh --if-stale --quiet 2>/dev/n
|
|
|
719
692
|
var HOOK_MARKER = "agentvalet/register refresh";
|
|
720
693
|
function writePermissionsFromEvent(agentId, ownerId, platforms, outputPath = "./.claude/agentvalet-permissions.md") {
|
|
721
694
|
const content = generatePermissionsFile(agentId, ownerId, platforms);
|
|
722
|
-
const resolvedPath =
|
|
723
|
-
mkdirSync2(
|
|
695
|
+
const resolvedPath = resolve2(outputPath);
|
|
696
|
+
mkdirSync2(dirname(resolvedPath), { recursive: true });
|
|
724
697
|
writeFileSync2(resolvedPath, content, "utf-8");
|
|
725
698
|
embedInClaudeMd(content);
|
|
726
699
|
ensureHook();
|
|
727
700
|
}
|
|
728
701
|
async function runRefresh(options) {
|
|
729
|
-
const outputPath =
|
|
702
|
+
const outputPath = resolve2(options.outputPath);
|
|
730
703
|
if (options.ifStale) {
|
|
731
704
|
try {
|
|
732
705
|
const stat = statSync(outputPath);
|
|
733
706
|
const fileIsFresh = Date.now() - stat.mtimeMs < 36e5;
|
|
734
|
-
const claudeMdPath =
|
|
707
|
+
const claudeMdPath = resolve2("CLAUDE.md");
|
|
735
708
|
const claudeMd = existsSync3(claudeMdPath) ? readFileSync3(claudeMdPath, "utf-8") : "";
|
|
736
709
|
const blockStart = claudeMd.indexOf(CLAUDE_START);
|
|
737
710
|
const blockEnd = claudeMd.indexOf(CLAUDE_END);
|
|
@@ -742,7 +715,7 @@ async function runRefresh(options) {
|
|
|
742
715
|
}
|
|
743
716
|
}
|
|
744
717
|
const creds = tryResolveAgent(options.envFile);
|
|
745
|
-
if (!creds || !existsSync3(
|
|
718
|
+
if (!creds || !existsSync3(resolve2(creds.keyPath))) {
|
|
746
719
|
console.error(" \u2717 No agent registered.\n Run the following command first to register an agent in this directory:\n\n npx @agentvalet/register\n");
|
|
747
720
|
process.exit(1);
|
|
748
721
|
}
|
|
@@ -767,7 +740,7 @@ async function runRefresh(options) {
|
|
|
767
740
|
const json = await res.json();
|
|
768
741
|
const platforms = json.data?.platforms ?? [];
|
|
769
742
|
const content = generatePermissionsFile(agentId, ownerId, platforms);
|
|
770
|
-
mkdirSync2(
|
|
743
|
+
mkdirSync2(dirname(outputPath), { recursive: true });
|
|
771
744
|
writeFileSync2(outputPath, content, "utf-8");
|
|
772
745
|
embedInClaudeMd(content);
|
|
773
746
|
ensureHook();
|
|
@@ -776,7 +749,7 @@ async function runRefresh(options) {
|
|
|
776
749
|
}
|
|
777
750
|
}
|
|
778
751
|
function embedInClaudeMd(permissionsContent) {
|
|
779
|
-
const claudeMdPath =
|
|
752
|
+
const claudeMdPath = resolve2("CLAUDE.md");
|
|
780
753
|
const block = `${CLAUDE_START}
|
|
781
754
|
${permissionsContent.trimEnd()}
|
|
782
755
|
${CLAUDE_END}`;
|
|
@@ -803,7 +776,7 @@ ${block}
|
|
|
803
776
|
}
|
|
804
777
|
}
|
|
805
778
|
function ensureHook() {
|
|
806
|
-
const settingsPath =
|
|
779
|
+
const settingsPath = resolve2(".claude/settings.local.json");
|
|
807
780
|
let settings = {};
|
|
808
781
|
if (existsSync3(settingsPath)) {
|
|
809
782
|
try {
|
|
@@ -829,12 +802,12 @@ function ensureHook() {
|
|
|
829
802
|
perms.allow = [...allow, ...missing];
|
|
830
803
|
settings.permissions = perms;
|
|
831
804
|
}
|
|
832
|
-
mkdirSync2(
|
|
805
|
+
mkdirSync2(dirname(settingsPath), { recursive: true });
|
|
833
806
|
writeFileSync2(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf-8");
|
|
834
807
|
ensureMcpJson();
|
|
835
808
|
}
|
|
836
809
|
function ensureMcpJson() {
|
|
837
|
-
const mcpJsonPath =
|
|
810
|
+
const mcpJsonPath = resolve2(".mcp.json");
|
|
838
811
|
let mcpConfig = {};
|
|
839
812
|
if (existsSync3(mcpJsonPath)) {
|
|
840
813
|
try {
|
|
@@ -1703,12 +1676,12 @@ function revokeCommand() {
|
|
|
1703
1676
|
process.exit(1);
|
|
1704
1677
|
}
|
|
1705
1678
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
1706
|
-
const confirmed = await new Promise((
|
|
1679
|
+
const confirmed = await new Promise((resolve4) => {
|
|
1707
1680
|
rl.question(
|
|
1708
1681
|
chalk9.yellow(`Revoke ${opts.agentId}? This cascades to all child agents and cannot be undone. (y/N) `),
|
|
1709
1682
|
(ans) => {
|
|
1710
1683
|
rl.close();
|
|
1711
|
-
|
|
1684
|
+
resolve4(ans.trim().toLowerCase() === "y");
|
|
1712
1685
|
}
|
|
1713
1686
|
);
|
|
1714
1687
|
});
|
|
@@ -1736,9 +1709,9 @@ import { readFile as readFile5 } from "fs/promises";
|
|
|
1736
1709
|
|
|
1737
1710
|
// src/lib/claude-config.ts
|
|
1738
1711
|
import { homedir } from "os";
|
|
1739
|
-
import { join
|
|
1712
|
+
import { join } from "path";
|
|
1740
1713
|
import { readFile as readFile3, writeFile as writeFile6, mkdir as mkdir4, access } from "fs/promises";
|
|
1741
|
-
var CLAUDE_CONFIG_PATH =
|
|
1714
|
+
var CLAUDE_CONFIG_PATH = join(homedir(), ".claude", "config");
|
|
1742
1715
|
async function writeKeyToClaudeConfig(agentId, privateKeyPem) {
|
|
1743
1716
|
let config = {};
|
|
1744
1717
|
try {
|
|
@@ -1749,7 +1722,7 @@ async function writeKeyToClaudeConfig(agentId, privateKeyPem) {
|
|
|
1749
1722
|
}
|
|
1750
1723
|
config.agent_keys = config.agent_keys ?? {};
|
|
1751
1724
|
config.agent_keys[agentId] = Buffer.from(privateKeyPem).toString("base64");
|
|
1752
|
-
await mkdir4(
|
|
1725
|
+
await mkdir4(join(homedir(), ".claude"), { recursive: true });
|
|
1753
1726
|
await writeFile6(CLAUDE_CONFIG_PATH, JSON.stringify(config, null, 2), "utf-8");
|
|
1754
1727
|
}
|
|
1755
1728
|
|
|
@@ -1820,13 +1793,12 @@ function injectCommand() {
|
|
|
1820
1793
|
import { Command as Command4 } from "commander";
|
|
1821
1794
|
import chalk11 from "chalk";
|
|
1822
1795
|
import { existsSync as existsSync7, readFileSync as readFileSync4, writeFileSync as writeFileSync3, rmSync } from "fs";
|
|
1823
|
-
import { resolve as
|
|
1824
|
-
import { homedir as homedir2 } from "os";
|
|
1796
|
+
import { resolve as resolve3 } from "path";
|
|
1825
1797
|
var CLAUDE_START2 = "<!-- agentvalet:start -->";
|
|
1826
1798
|
var CLAUDE_END2 = "<!-- agentvalet:end -->";
|
|
1827
1799
|
var HOOK_MARKER2 = "agentvalet/register refresh";
|
|
1828
1800
|
function stripClaudeMd() {
|
|
1829
|
-
const path7 =
|
|
1801
|
+
const path7 = resolve3("CLAUDE.md");
|
|
1830
1802
|
if (!existsSync7(path7)) return;
|
|
1831
1803
|
let content = readFileSync4(path7, "utf-8");
|
|
1832
1804
|
content = content.replace(new RegExp(`${CLAUDE_START2}[\\s\\S]*?${CLAUDE_END2}`, "m"), "");
|
|
@@ -1835,7 +1807,7 @@ function stripClaudeMd() {
|
|
|
1835
1807
|
writeFileSync3(path7, content ? content + "\n" : "", "utf-8");
|
|
1836
1808
|
}
|
|
1837
1809
|
function stripSettingsJson() {
|
|
1838
|
-
const path7 =
|
|
1810
|
+
const path7 = resolve3(".claude/settings.local.json");
|
|
1839
1811
|
if (!existsSync7(path7)) return;
|
|
1840
1812
|
try {
|
|
1841
1813
|
const settings = JSON.parse(readFileSync4(path7, "utf-8"));
|
|
@@ -1854,7 +1826,7 @@ function stripSettingsJson() {
|
|
|
1854
1826
|
}
|
|
1855
1827
|
}
|
|
1856
1828
|
function stripMcpJson() {
|
|
1857
|
-
const path7 =
|
|
1829
|
+
const path7 = resolve3(".mcp.json");
|
|
1858
1830
|
if (!existsSync7(path7)) return;
|
|
1859
1831
|
try {
|
|
1860
1832
|
const config = JSON.parse(readFileSync4(path7, "utf-8"));
|
|
@@ -1865,20 +1837,23 @@ function stripMcpJson() {
|
|
|
1865
1837
|
} catch {
|
|
1866
1838
|
}
|
|
1867
1839
|
}
|
|
1868
|
-
function deleteIfExists(p) {
|
|
1869
|
-
const abs = resolve4(p);
|
|
1870
|
-
if (existsSync7(abs)) {
|
|
1871
|
-
rmSync(abs, { recursive: true, force: true });
|
|
1872
|
-
return abs;
|
|
1873
|
-
}
|
|
1874
|
-
return null;
|
|
1875
|
-
}
|
|
1876
1840
|
function cleanLocally() {
|
|
1877
1841
|
const removed = [];
|
|
1878
1842
|
const r = (p) => {
|
|
1879
|
-
const
|
|
1880
|
-
if (
|
|
1843
|
+
const abs = resolve3(p);
|
|
1844
|
+
if (existsSync7(abs)) {
|
|
1845
|
+
rmSync(abs, { recursive: true, force: true });
|
|
1846
|
+
removed.push(abs);
|
|
1847
|
+
}
|
|
1881
1848
|
};
|
|
1849
|
+
if (existsSync7(AGENT_KEY_PATH)) {
|
|
1850
|
+
rmSync(AGENT_KEY_PATH, { force: true });
|
|
1851
|
+
removed.push(AGENT_KEY_PATH);
|
|
1852
|
+
}
|
|
1853
|
+
try {
|
|
1854
|
+
clearConfig();
|
|
1855
|
+
} catch {
|
|
1856
|
+
}
|
|
1882
1857
|
r(".env.agentvalet");
|
|
1883
1858
|
r(".agentvalet");
|
|
1884
1859
|
r("agentvalet.key");
|
|
@@ -1886,17 +1861,8 @@ function cleanLocally() {
|
|
|
1886
1861
|
stripClaudeMd();
|
|
1887
1862
|
stripSettingsJson();
|
|
1888
1863
|
stripMcpJson();
|
|
1889
|
-
try {
|
|
1890
|
-
saveConfig({ lastAgentId: "", lastKeyPath: "" });
|
|
1891
|
-
} catch {
|
|
1892
|
-
}
|
|
1893
|
-
const oldConfig = join3(homedir2(), ".agentvalet", "config.json");
|
|
1894
|
-
if (existsSync7(oldConfig)) {
|
|
1895
|
-
rmSync(oldConfig, { force: true });
|
|
1896
|
-
removed.push(oldConfig);
|
|
1897
|
-
}
|
|
1898
1864
|
if (removed.length > 0) {
|
|
1899
|
-
console.log(chalk11.green(" \u2713 Removed
|
|
1865
|
+
console.log(chalk11.green(" \u2713 Removed files:"));
|
|
1900
1866
|
for (const f of removed) console.log(chalk11.dim(` ${f}`));
|
|
1901
1867
|
}
|
|
1902
1868
|
console.log(chalk11.green(" \u2713 Cleaned CLAUDE.md, .mcp.json, .claude/settings.local.json"));
|
|
@@ -1905,12 +1871,12 @@ var SSE_READ_TIMEOUT_MS = 25e3;
|
|
|
1905
1871
|
async function pollForApproval(apiUrl, revocationToken, timeoutMs) {
|
|
1906
1872
|
const streamUrl = `${apiUrl}/v1/revoke-request/stream/${revocationToken}`;
|
|
1907
1873
|
const deadline = Date.now() + timeoutMs;
|
|
1908
|
-
return new Promise((
|
|
1874
|
+
return new Promise((resolve4) => {
|
|
1909
1875
|
let settled = false;
|
|
1910
1876
|
function done(result) {
|
|
1911
1877
|
if (!settled) {
|
|
1912
1878
|
settled = true;
|
|
1913
|
-
|
|
1879
|
+
resolve4(result);
|
|
1914
1880
|
}
|
|
1915
1881
|
}
|
|
1916
1882
|
function connect() {
|
|
@@ -2053,7 +2019,7 @@ function collectScope(value, previous) {
|
|
|
2053
2019
|
return [...previous, value];
|
|
2054
2020
|
}
|
|
2055
2021
|
var program = new Command5();
|
|
2056
|
-
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("--
|
|
2022
|
+
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) => {
|
|
2057
2023
|
const isJson = !!opts.json;
|
|
2058
2024
|
let ownerId = opts.owner ?? process.env.AGENTVALET_OWNER ?? "";
|
|
2059
2025
|
let agentName = opts.name ?? "";
|
|
@@ -2155,39 +2121,34 @@ Approve at: https://app.agentvalet.ai/agents
|
|
|
2155
2121
|
const { agentId, privateKey, grantedPlatforms } = result;
|
|
2156
2122
|
const resolvedOwnerId = result.ownerId || ownerId;
|
|
2157
2123
|
let keyPath;
|
|
2158
|
-
let envPath;
|
|
2159
|
-
try {
|
|
2160
|
-
({ keyPath, envPath } = await saveOutput({
|
|
2161
|
-
agentId,
|
|
2162
|
-
ownerId: resolvedOwnerId,
|
|
2163
|
-
privateKey: privateKey ?? "",
|
|
2164
|
-
apiUrl: opts.apiUrl,
|
|
2165
|
-
keyFilePath: opts.keyPath,
|
|
2166
|
-
envFilePath: opts.output
|
|
2167
|
-
}));
|
|
2168
|
-
} catch (err) {
|
|
2169
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
2170
|
-
console.error(isJson ? JSON.stringify({ error: msg }) : chalk12.red(`Failed to save output: ${msg}`));
|
|
2171
|
-
process.exit(3);
|
|
2172
|
-
}
|
|
2173
2124
|
const keyWritten = !!privateKey;
|
|
2174
2125
|
if (keyWritten) {
|
|
2175
|
-
|
|
2126
|
+
try {
|
|
2127
|
+
({ keyPath } = await saveOutput({
|
|
2128
|
+
agentId,
|
|
2129
|
+
ownerId: resolvedOwnerId,
|
|
2130
|
+
privateKey,
|
|
2131
|
+
apiUrl: opts.apiUrl
|
|
2132
|
+
}));
|
|
2133
|
+
} catch (err) {
|
|
2134
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
2135
|
+
console.error(isJson ? JSON.stringify({ error: msg }) : chalk12.red(`Failed to save output: ${msg}`));
|
|
2136
|
+
process.exit(3);
|
|
2137
|
+
}
|
|
2138
|
+
} else {
|
|
2139
|
+
const { AGENT_KEY_PATH: AGENT_KEY_PATH2 } = await import("./store-JYJXDBYX.js");
|
|
2140
|
+
keyPath = AGENT_KEY_PATH2;
|
|
2176
2141
|
}
|
|
2177
2142
|
if (isJson) {
|
|
2178
|
-
console.log(JSON.stringify({ status: "approved", agentId, keyPath: keyWritten ? keyPath : null
|
|
2143
|
+
console.log(JSON.stringify({ status: "approved", agentId, keyPath: keyWritten ? keyPath : null }));
|
|
2179
2144
|
} else {
|
|
2180
2145
|
console.log(chalk12.green(`
|
|
2181
2146
|
Approved! Agent ID: ${agentId}`));
|
|
2182
2147
|
if (keyWritten) {
|
|
2183
|
-
console.log(chalk12.gray(`Key:
|
|
2148
|
+
console.log(chalk12.gray(`Key: ${keyPath}`));
|
|
2184
2149
|
} else {
|
|
2185
|
-
console.log(chalk12.yellow(`Key:
|
|
2150
|
+
console.log(chalk12.yellow(`Key: not written \u2014 copy it from the dashboard and paste into ${keyPath}`));
|
|
2186
2151
|
}
|
|
2187
|
-
console.log(chalk12.gray(`Env file: ${envPath}`));
|
|
2188
|
-
console.log(`
|
|
2189
|
-
Source the env file before calling any tool:`);
|
|
2190
|
-
console.log(chalk12.cyan(` source ${envPath}`));
|
|
2191
2152
|
}
|
|
2192
2153
|
if (keyWritten) {
|
|
2193
2154
|
try {
|
|
@@ -2195,12 +2156,7 @@ Source the env file before calling any tool:`);
|
|
|
2195
2156
|
writePermissionsFromEvent(agentId, resolvedOwnerId, grantedPlatforms);
|
|
2196
2157
|
if (!isJson) console.log(chalk12.gray(`Permissions: .claude/agentvalet-permissions.md`));
|
|
2197
2158
|
} else {
|
|
2198
|
-
await runRefresh({
|
|
2199
|
-
envFile: opts.output,
|
|
2200
|
-
outputPath: ".claude/agentvalet-permissions.md",
|
|
2201
|
-
ifStale: false,
|
|
2202
|
-
quiet: isJson
|
|
2203
|
-
});
|
|
2159
|
+
await runRefresh({ envFile: ".env.agentvalet", outputPath: ".claude/agentvalet-permissions.md", ifStale: false, quiet: isJson });
|
|
2204
2160
|
if (!isJson) console.log(chalk12.gray(`Permissions: .claude/agentvalet-permissions.md`));
|
|
2205
2161
|
}
|
|
2206
2162
|
} catch {
|
|
@@ -2209,10 +2165,10 @@ Source the env file before calling any tool:`);
|
|
|
2209
2165
|
}
|
|
2210
2166
|
process.exit(0);
|
|
2211
2167
|
});
|
|
2212
|
-
program.command("refresh").description("Refresh approved permissions and update .claude/agentvalet-permissions.md").option("--
|
|
2168
|
+
program.command("refresh").description("Refresh approved permissions and update .claude/agentvalet-permissions.md").option("--output <path>", "Path to write permissions file", "./.claude/agentvalet-permissions.md").option("--if-stale", "Skip if file is less than 1 hour old").option("--quiet", "Suppress output").action(async (opts) => {
|
|
2213
2169
|
try {
|
|
2214
2170
|
await runRefresh({
|
|
2215
|
-
envFile:
|
|
2171
|
+
envFile: ".env.agentvalet",
|
|
2216
2172
|
outputPath: opts.output,
|
|
2217
2173
|
ifStale: !!opts.ifStale,
|
|
2218
2174
|
quiet: !!opts.quiet
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AGENT_DIR,
|
|
3
|
+
AGENT_KEY_PATH,
|
|
4
|
+
clearConfig,
|
|
5
|
+
getStoredConfig,
|
|
6
|
+
isAuthenticated,
|
|
7
|
+
saveConfig
|
|
8
|
+
} from "./chunk-2EFPJNYK.js";
|
|
9
|
+
export {
|
|
10
|
+
AGENT_DIR,
|
|
11
|
+
AGENT_KEY_PATH,
|
|
12
|
+
clearConfig,
|
|
13
|
+
getStoredConfig,
|
|
14
|
+
isAuthenticated,
|
|
15
|
+
saveConfig
|
|
16
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentvalet/register",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.14",
|
|
4
4
|
"description": "Self-register AI agents with AgentValet",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -10,6 +10,13 @@
|
|
|
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
21
|
"@agentvalet/mcp-server": "*",
|
|
15
22
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
@@ -48,11 +55,5 @@
|
|
|
48
55
|
"valet",
|
|
49
56
|
"agentvalet"
|
|
50
57
|
],
|
|
51
|
-
"license": "MIT"
|
|
52
|
-
|
|
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
|
+
}
|