@agentvalet/register 1.1.1 → 1.3.0
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 +136 -103
- package/package.json +15 -13
package/dist/index.js
CHANGED
|
@@ -197,7 +197,7 @@ async function saveOutput(opts) {
|
|
|
197
197
|
|
|
198
198
|
// src/commands/refresh.ts
|
|
199
199
|
import { readFileSync as readFileSync3, writeFileSync as writeFileSync2, existsSync as existsSync4, mkdirSync as mkdirSync2, statSync } from "fs";
|
|
200
|
-
import { dirname, resolve as resolve2 } from "path";
|
|
200
|
+
import { dirname, join, resolve as resolve2 } from "path";
|
|
201
201
|
|
|
202
202
|
// src/lib/jwt.ts
|
|
203
203
|
import { createSign, createPrivateKey } from "crypto";
|
|
@@ -232,15 +232,18 @@ Never call platform APIs (Slack, Stripe, Gmail, GitHub, etc.) directly.
|
|
|
232
232
|
|
|
233
233
|
## Making a platform call
|
|
234
234
|
|
|
235
|
-
|
|
235
|
+
Pick the tool that matches what you are doing:
|
|
236
|
+
|
|
237
|
+
- \`read_platform\` to read (always GET)
|
|
238
|
+
- \`write_platform\` to create or update (POST, PUT or PATCH)
|
|
239
|
+
- \`delete_platform\` to remove (always DELETE)
|
|
236
240
|
|
|
237
241
|
\`\`\`
|
|
238
|
-
|
|
242
|
+
write_platform({
|
|
239
243
|
platform: "slack",
|
|
240
244
|
endpoint: "/api/chat.postMessage",
|
|
241
|
-
method: "POST",
|
|
242
245
|
scope: "slack:write",
|
|
243
|
-
|
|
246
|
+
body: { channel: "#general", text: "Hello" }
|
|
244
247
|
})
|
|
245
248
|
\`\`\`
|
|
246
249
|
|
|
@@ -271,15 +274,16 @@ Routes all platform API calls through AgentValet's credential proxy.
|
|
|
271
274
|
|
|
272
275
|
## Making platform calls
|
|
273
276
|
|
|
274
|
-
Use
|
|
277
|
+
Use \`read_platform\`, \`write_platform\` or \`delete_platform\` instead of
|
|
278
|
+
calling APIs directly. Reads use read_platform; creates and updates use
|
|
279
|
+
write_platform; deletions use delete_platform.
|
|
275
280
|
|
|
276
281
|
\`\`\`
|
|
277
|
-
|
|
282
|
+
write_platform({
|
|
278
283
|
platform: "slack",
|
|
279
284
|
endpoint: "/api/chat.postMessage",
|
|
280
|
-
method: "POST",
|
|
281
285
|
scope: "slack:write",
|
|
282
|
-
|
|
286
|
+
body: { channel: "#general", text: "Hello" }
|
|
283
287
|
})
|
|
284
288
|
\`\`\`
|
|
285
289
|
|
|
@@ -410,7 +414,8 @@ instructions: |
|
|
|
410
414
|
## Rules \u2014 read before every platform call
|
|
411
415
|
|
|
412
416
|
1. NEVER call platform APIs (Slack, Stripe, Gmail, GitHub, etc.) directly.
|
|
413
|
-
Always use
|
|
417
|
+
Always use \`read_platform\` (reads), \`write_platform\` (creates and
|
|
418
|
+
updates) or \`delete_platform\` (deletions).
|
|
414
419
|
|
|
415
420
|
2. Call \`list_platforms\` at the start of any session that involves
|
|
416
421
|
platform calls. Do not assume platforms are available.
|
|
@@ -418,7 +423,7 @@ instructions: |
|
|
|
418
423
|
3. Call \`authzen_evaluate\` before any destructive operation
|
|
419
424
|
(delete, send, charge, publish). Do not proceed if decision=false.
|
|
420
425
|
|
|
421
|
-
4. If
|
|
426
|
+
4. If a platform call returns \`{ status: "pending_approval" }\`,
|
|
422
427
|
wait for human approval. Do not retry the call.
|
|
423
428
|
|
|
424
429
|
5. If AgentValet MCP tools are unavailable, stop and tell the user:
|
|
@@ -428,12 +433,11 @@ instructions: |
|
|
|
428
433
|
## Making a platform call
|
|
429
434
|
|
|
430
435
|
\`\`\`
|
|
431
|
-
|
|
436
|
+
write_platform({
|
|
432
437
|
platform: "slack",
|
|
433
438
|
endpoint: "/api/chat.postMessage",
|
|
434
|
-
method: "POST",
|
|
435
439
|
scope: "slack:write",
|
|
436
|
-
|
|
440
|
+
body: { channel: "#general", text: "Hello" }
|
|
437
441
|
})
|
|
438
442
|
\`\`\`
|
|
439
443
|
|
|
@@ -540,7 +544,8 @@ instructions: |
|
|
|
540
544
|
- If decision=false: block the call, explain why, suggest alternatives
|
|
541
545
|
- If decision=true: allow, but log it
|
|
542
546
|
|
|
543
|
-
2. WHEN a droid calls \`
|
|
547
|
+
2. WHEN a droid calls \`read_platform\`, \`write_platform\` or
|
|
548
|
+
\`delete_platform\`, verify:
|
|
544
549
|
- The platform is in the approved list from \`list_platforms\`
|
|
545
550
|
- The scope matches what was approved
|
|
546
551
|
- The call hasn't exceeded rate limits
|
|
@@ -589,7 +594,8 @@ function ensureMcpServer() {
|
|
|
589
594
|
function generatePermissionsFile(agentId, ownerId, permissions) {
|
|
590
595
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
591
596
|
const platformSections = permissions.length === 0 ? "_No platforms approved yet. Visit https://app.agentvalet.ai to connect platforms._" : permissions.map((p) => {
|
|
592
|
-
const
|
|
597
|
+
const gated = new Set(p.approvalScopes ?? []);
|
|
598
|
+
const scopeList = p.scopes.map((s) => ` - \`${s}\`${gated.has(s) ? " \u2014 requires human approval" : ""}`).join("\n");
|
|
593
599
|
const approvalNote = p.requireApproval ? "\n > Requires human approval before executing.\n" : "";
|
|
594
600
|
return `### ${p.platformName} (\`${p.platformId}\`)
|
|
595
601
|
|
|
@@ -611,19 +617,58 @@ ${platformSections}
|
|
|
611
617
|
|
|
612
618
|
---
|
|
613
619
|
|
|
620
|
+
## Before any platform call
|
|
621
|
+
|
|
622
|
+
1. **Check AgentValet first.** For any action on an external platform (Slack,
|
|
623
|
+
GitHub, Stripe, Gmail, Outlook, Notion, Linear, Jira, HubSpot, Salesforce,
|
|
624
|
+
or any other SaaS), call \`mcp__agentvalet__list_platforms\` **before** you
|
|
625
|
+
assume the platform is unavailable or reach for another route.
|
|
626
|
+
2. **If the platform is listed here, you must use it.** Do not call the
|
|
627
|
+
platform's API directly, and do not use another MCP server's tool for a
|
|
628
|
+
platform AgentValet covers \u2014 that bypasses the audit log, the approval
|
|
629
|
+
flow, and the scope limits the owner configured.
|
|
630
|
+
3. **If it is not listed**, say so: "AgentValet doesn't cover <platform> yet."
|
|
631
|
+
Ask the user whether to request the integration from their AgentValet
|
|
632
|
+
owner. Do not silently fall back to direct API calls or raw keys found in
|
|
633
|
+
the environment.
|
|
634
|
+
4. **Destructive scopes** (\`*.delete\`, \`stripe:charge\`, \`mail:send\`) need
|
|
635
|
+
human approval. Warn the user before invoking them.
|
|
636
|
+
5. **On \`pending_approval\`** \u2014 the action is queued and runs when the owner
|
|
637
|
+
approves. Tell the user and **do not retry**; a retry queues a duplicate.
|
|
638
|
+
6. **If the AgentValet MCP tools are unavailable**, stop. Tell the user
|
|
639
|
+
"AgentValet MCP is not connected. Run: npx @agentvalet/register". Do not
|
|
640
|
+
attempt the platform call without governance.
|
|
641
|
+
|
|
642
|
+
Read scopes are auto-approved. Write scopes may require approval. Destructive
|
|
643
|
+
scopes always require approval.
|
|
644
|
+
|
|
645
|
+
---
|
|
646
|
+
|
|
614
647
|
## How to call a platform
|
|
615
648
|
|
|
616
|
-
All platform calls **must** go through the
|
|
649
|
+
All platform calls **must** go through the AgentValet MCP tools. Pick the one
|
|
650
|
+
that matches the operation:
|
|
651
|
+
|
|
652
|
+
| Operation | Tool | Method |
|
|
653
|
+
|---|---|---|
|
|
654
|
+
| Read | \`mcp__agentvalet__read_platform\` | always GET |
|
|
655
|
+
| Create or update | \`mcp__agentvalet__write_platform\` | POST (default), PUT or PATCH |
|
|
656
|
+
| Delete | \`mcp__agentvalet__delete_platform\` | always DELETE |
|
|
617
657
|
|
|
618
|
-
**NEVER** write inline JWT signing code, \`node -e\` scripts, or manual HTTP calls. The MCP
|
|
658
|
+
**NEVER** write inline JWT signing code, \`node -e\` scripts, or manual HTTP calls. The MCP tools handle all authentication internally.
|
|
619
659
|
|
|
620
660
|
\`\`\`
|
|
621
|
-
|
|
661
|
+
mcp__agentvalet__read_platform({
|
|
662
|
+
platform: "<platformId>",
|
|
663
|
+
endpoint: "<endpoint>",
|
|
664
|
+
scope: "<scope>"
|
|
665
|
+
})
|
|
666
|
+
|
|
667
|
+
mcp__agentvalet__write_platform({
|
|
622
668
|
platform: "<platformId>",
|
|
623
669
|
endpoint: "<endpoint>",
|
|
624
|
-
method: "POST",
|
|
625
670
|
scope: "<scope>",
|
|
626
|
-
|
|
671
|
+
body: { ... }
|
|
627
672
|
})
|
|
628
673
|
\`\`\`
|
|
629
674
|
|
|
@@ -816,21 +861,54 @@ var CLAUDE_START = "<!-- agentvalet:start -->";
|
|
|
816
861
|
var CLAUDE_END = "<!-- agentvalet:end -->";
|
|
817
862
|
var HOOK_COMMAND = "npx @agentvalet/register refresh --if-stale --quiet 2>/dev/null || true";
|
|
818
863
|
var HOOK_MARKER = "agentvalet/register refresh";
|
|
864
|
+
function projectRootFor(outputPath) {
|
|
865
|
+
return dirname(dirname(resolve2(outputPath)));
|
|
866
|
+
}
|
|
819
867
|
function writePermissionsFromEvent(agentId, ownerId, platforms, outputPath = "./.claude/agentvalet-permissions.md") {
|
|
820
868
|
const content = generatePermissionsFile(agentId, ownerId, platforms);
|
|
821
869
|
const resolvedPath = resolve2(outputPath);
|
|
870
|
+
const projectRoot = projectRootFor(resolvedPath);
|
|
822
871
|
mkdirSync2(dirname(resolvedPath), { recursive: true });
|
|
823
872
|
writeFileSync2(resolvedPath, content, "utf-8");
|
|
824
|
-
embedInClaudeMd(content);
|
|
825
|
-
ensureHook();
|
|
873
|
+
embedInClaudeMd(content, projectRoot);
|
|
874
|
+
ensureHook(projectRoot);
|
|
875
|
+
}
|
|
876
|
+
async function writeGovernanceInstructions(agentId, ownerId) {
|
|
877
|
+
const writeRulesOnly = () => {
|
|
878
|
+
try {
|
|
879
|
+
writePermissionsFromEvent(agentId, ownerId, []);
|
|
880
|
+
console.log(" \u2713 CLAUDE.md \u2014 AgentValet governance rules");
|
|
881
|
+
return true;
|
|
882
|
+
} catch {
|
|
883
|
+
return false;
|
|
884
|
+
}
|
|
885
|
+
};
|
|
886
|
+
if (!tryResolveAgent()) {
|
|
887
|
+
writeRulesOnly();
|
|
888
|
+
return;
|
|
889
|
+
}
|
|
890
|
+
try {
|
|
891
|
+
await runRefresh({
|
|
892
|
+
envFile: ".env.agentvalet",
|
|
893
|
+
outputPath: ".claude/agentvalet-permissions.md",
|
|
894
|
+
ifStale: false,
|
|
895
|
+
quiet: true
|
|
896
|
+
});
|
|
897
|
+
console.log(" \u2713 CLAUDE.md \u2014 AgentValet governance rules and approved platforms");
|
|
898
|
+
} catch {
|
|
899
|
+
if (writeRulesOnly()) {
|
|
900
|
+
console.log(" Run `npx @agentvalet/register refresh` once approved to fill in platforms");
|
|
901
|
+
}
|
|
902
|
+
}
|
|
826
903
|
}
|
|
827
904
|
async function runRefresh(options) {
|
|
828
905
|
const outputPath = resolve2(options.outputPath);
|
|
906
|
+
const projectRoot = projectRootFor(outputPath);
|
|
829
907
|
if (options.ifStale) {
|
|
830
908
|
try {
|
|
831
909
|
const stat = statSync(outputPath);
|
|
832
910
|
const fileIsFresh = Date.now() - stat.mtimeMs < 36e5;
|
|
833
|
-
const claudeMdPath =
|
|
911
|
+
const claudeMdPath = join(projectRoot, "CLAUDE.md");
|
|
834
912
|
const claudeMd = existsSync4(claudeMdPath) ? readFileSync3(claudeMdPath, "utf-8") : "";
|
|
835
913
|
const blockStart = claudeMd.indexOf(CLAUDE_START);
|
|
836
914
|
const blockEnd = claudeMd.indexOf(CLAUDE_END);
|
|
@@ -868,15 +946,15 @@ async function runRefresh(options) {
|
|
|
868
946
|
const content = generatePermissionsFile(agentId, ownerId, platforms);
|
|
869
947
|
mkdirSync2(dirname(outputPath), { recursive: true });
|
|
870
948
|
writeFileSync2(outputPath, content, "utf-8");
|
|
871
|
-
embedInClaudeMd(content);
|
|
872
|
-
ensureHook();
|
|
949
|
+
embedInClaudeMd(content, projectRoot);
|
|
950
|
+
ensureHook(projectRoot);
|
|
873
951
|
const detected = detectFrameworks();
|
|
874
952
|
const refreshed = [];
|
|
875
953
|
if (detected.codex || detected.codexDesktop) {
|
|
876
|
-
if (embedPermissionsBlock(
|
|
954
|
+
if (embedPermissionsBlock(join(projectRoot, "AGENTS.md"), content)) refreshed.push("AGENTS.md");
|
|
877
955
|
}
|
|
878
956
|
if (detected.openclaw) {
|
|
879
|
-
if (embedPermissionsBlock(
|
|
957
|
+
if (embedPermissionsBlock(join(projectRoot, "SKILL.md"), content)) refreshed.push("SKILL.md");
|
|
880
958
|
}
|
|
881
959
|
if (!options.quiet) {
|
|
882
960
|
const extras = refreshed.length > 0 ? ` (also: ${refreshed.join(", ")})` : "";
|
|
@@ -908,8 +986,8 @@ ${block}
|
|
|
908
986
|
return false;
|
|
909
987
|
}
|
|
910
988
|
}
|
|
911
|
-
function embedInClaudeMd(permissionsContent) {
|
|
912
|
-
const claudeMdPath =
|
|
989
|
+
function embedInClaudeMd(permissionsContent, projectRoot) {
|
|
990
|
+
const claudeMdPath = join(projectRoot, "CLAUDE.md");
|
|
913
991
|
const block = `${CLAUDE_START}
|
|
914
992
|
${permissionsContent.trimEnd()}
|
|
915
993
|
${CLAUDE_END}`;
|
|
@@ -935,8 +1013,8 @@ ${block}
|
|
|
935
1013
|
`, "utf-8");
|
|
936
1014
|
}
|
|
937
1015
|
}
|
|
938
|
-
function ensureHook() {
|
|
939
|
-
const settingsPath =
|
|
1016
|
+
function ensureHook(projectRoot) {
|
|
1017
|
+
const settingsPath = join(projectRoot, ".claude", "settings.local.json");
|
|
940
1018
|
let settings = {};
|
|
941
1019
|
if (existsSync4(settingsPath)) {
|
|
942
1020
|
try {
|
|
@@ -956,7 +1034,13 @@ function ensureHook() {
|
|
|
956
1034
|
}
|
|
957
1035
|
const perms = settings.permissions ?? {};
|
|
958
1036
|
const allow = perms.allow ?? [];
|
|
959
|
-
const mcpAllows = [
|
|
1037
|
+
const mcpAllows = [
|
|
1038
|
+
"mcp__agentvalet__list_platforms",
|
|
1039
|
+
"mcp__agentvalet__read_platform",
|
|
1040
|
+
"mcp__agentvalet__write_platform",
|
|
1041
|
+
"mcp__agentvalet__delete_platform",
|
|
1042
|
+
"mcp__agentvalet__use_platform"
|
|
1043
|
+
];
|
|
960
1044
|
const missing = mcpAllows.filter((e) => !allow.includes(e));
|
|
961
1045
|
if (missing.length > 0) {
|
|
962
1046
|
perms.allow = [...allow, ...missing];
|
|
@@ -964,10 +1048,10 @@ function ensureHook() {
|
|
|
964
1048
|
}
|
|
965
1049
|
mkdirSync2(dirname(settingsPath), { recursive: true });
|
|
966
1050
|
writeFileSync2(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf-8");
|
|
967
|
-
ensureMcpJson();
|
|
1051
|
+
ensureMcpJson(projectRoot);
|
|
968
1052
|
}
|
|
969
|
-
function ensureMcpJson() {
|
|
970
|
-
const mcpJsonPath =
|
|
1053
|
+
function ensureMcpJson(projectRoot) {
|
|
1054
|
+
const mcpJsonPath = join(projectRoot, ".mcp.json");
|
|
971
1055
|
let mcpConfig = {};
|
|
972
1056
|
if (existsSync4(mcpJsonPath)) {
|
|
973
1057
|
try {
|
|
@@ -1230,48 +1314,6 @@ async function mergeJsonFile(filePath, key, value) {
|
|
|
1230
1314
|
existing.mcpServers = mcpServers;
|
|
1231
1315
|
await writeFile4(filePath, JSON.stringify(existing, null, 2) + "\n", "utf8");
|
|
1232
1316
|
}
|
|
1233
|
-
function buildClaudeMd(agentId, ownerId, proxyUrl) {
|
|
1234
|
-
return `# AgentValet \u2014 Credential Governance
|
|
1235
|
-
|
|
1236
|
-
Agent ID: \`${agentId}\`
|
|
1237
|
-
Owner ID: \`${ownerId}\`
|
|
1238
|
-
|
|
1239
|
-
All external platform API calls **must** go through the AgentValet proxy.
|
|
1240
|
-
Never call platform APIs (Slack, Stripe, Gmail, GitHub, etc.) directly.
|
|
1241
|
-
|
|
1242
|
-
## Making a platform call
|
|
1243
|
-
|
|
1244
|
-
Use the \`mcp__agentvalet__use_platform\` MCP tool:
|
|
1245
|
-
|
|
1246
|
-
\`\`\`
|
|
1247
|
-
mcp__agentvalet__use_platform({
|
|
1248
|
-
platform: "slack",
|
|
1249
|
-
endpoint: "/api/chat.postMessage",
|
|
1250
|
-
method: "POST",
|
|
1251
|
-
scope: "slack:write",
|
|
1252
|
-
data: { channel: "#general", text: "Hello" }
|
|
1253
|
-
})
|
|
1254
|
-
\`\`\`
|
|
1255
|
-
|
|
1256
|
-
## Before any platform session
|
|
1257
|
-
|
|
1258
|
-
1. Call \`mcp__agentvalet__list_platforms\` to see approved platforms and scopes
|
|
1259
|
-
2. Call \`mcp__agentvalet__authzen_evaluate\` before destructive operations
|
|
1260
|
-
3. If a call returns \`pending_approval\` \u2014 wait, do not retry
|
|
1261
|
-
|
|
1262
|
-
## Rules
|
|
1263
|
-
|
|
1264
|
-
- **NEVER** write inline JWT signing code, \`node -e\` scripts, or manual HTTP calls
|
|
1265
|
-
- The MCP tool handles authentication automatically
|
|
1266
|
-
- \`AGENT_PRIVATE_KEY_PATH\` points to your key \u2014 do not read or log it
|
|
1267
|
-
|
|
1268
|
-
## If AgentValet MCP is not connected
|
|
1269
|
-
|
|
1270
|
-
Tell the user: "AgentValet MCP is not connected. Run: npx @agentvalet/register"
|
|
1271
|
-
|
|
1272
|
-
Dashboard: ${proxyUrl.replace("api.", "app.")}
|
|
1273
|
-
`;
|
|
1274
|
-
}
|
|
1275
1317
|
function buildCodexTomlBlock(params) {
|
|
1276
1318
|
return `
|
|
1277
1319
|
[mcp_servers.agentvalet]
|
|
@@ -1407,17 +1449,6 @@ async function writeIdeConfigs(params) {
|
|
|
1407
1449
|
} catch (err) {
|
|
1408
1450
|
console.warn(` Warning: could not write .mcp.json: ${err.message}`);
|
|
1409
1451
|
}
|
|
1410
|
-
const claudeMdPath = path5.join(cwd, "CLAUDE.md");
|
|
1411
|
-
if (!existsSync6(claudeMdPath)) {
|
|
1412
|
-
try {
|
|
1413
|
-
await writeFile4(claudeMdPath, buildClaudeMd(params.agentId, params.ownerId, params.proxyUrl), "utf8");
|
|
1414
|
-
written.push("CLAUDE.md");
|
|
1415
|
-
} catch (err) {
|
|
1416
|
-
console.warn(` Warning: could not write CLAUDE.md: ${err.message}`);
|
|
1417
|
-
}
|
|
1418
|
-
} else {
|
|
1419
|
-
written.push("CLAUDE.md (already exists \u2014 skipped)");
|
|
1420
|
-
}
|
|
1421
1452
|
}
|
|
1422
1453
|
if (detected.cursor || detected.cursorCli) {
|
|
1423
1454
|
const cursorDir = path5.join(cwd, ".cursor");
|
|
@@ -1676,6 +1707,7 @@ async function registerAgentFlow(apiKey, ownerId, scope = "user", presetName) {
|
|
|
1676
1707
|
detected
|
|
1677
1708
|
});
|
|
1678
1709
|
}
|
|
1710
|
+
await writeGovernanceInstructions(agent.agent_id, ownerId);
|
|
1679
1711
|
ensureMcpServer();
|
|
1680
1712
|
} else if (shouldSetup === false) {
|
|
1681
1713
|
console.log("");
|
|
@@ -1839,7 +1871,7 @@ import chalk10 from "chalk";
|
|
|
1839
1871
|
import { Command as Command2 } from "commander";
|
|
1840
1872
|
import chalk9 from "chalk";
|
|
1841
1873
|
import { existsSync as existsSync7, readFileSync as readFileSync4, writeFileSync as writeFileSync3, rmSync } from "fs";
|
|
1842
|
-
import { resolve as resolve3, join } from "path";
|
|
1874
|
+
import { resolve as resolve3, join as join2 } from "path";
|
|
1843
1875
|
import { homedir } from "os";
|
|
1844
1876
|
var CLAUDE_START2 = "<!-- agentvalet:start -->";
|
|
1845
1877
|
var CLAUDE_END2 = "<!-- agentvalet:end -->";
|
|
@@ -1971,12 +2003,12 @@ function cleanLocally() {
|
|
|
1971
2003
|
if (stripMcpJson(resolve3(".cursor/mcp.json"))) stripped.push(".cursor/mcp.json");
|
|
1972
2004
|
if (stripMcpJson(resolve3(".factory/mcp.json"), { wrapped: false })) stripped.push(".factory/mcp.json");
|
|
1973
2005
|
const home = homedir();
|
|
1974
|
-
if (stripMcpJson(
|
|
1975
|
-
const claudeDesktopConfig = process.platform === "darwin" ?
|
|
2006
|
+
if (stripMcpJson(join2(home, ".claude.json"))) stripped.push("~/.claude.json");
|
|
2007
|
+
const claudeDesktopConfig = process.platform === "darwin" ? join2(home, "Library", "Application Support", "Claude", "claude_desktop_config.json") : process.platform === "win32" ? join2(process.env.APPDATA ?? join2(home, "AppData", "Roaming"), "Claude", "claude_desktop_config.json") : join2(home, ".config", "Claude", "claude_desktop_config.json");
|
|
1976
2008
|
if (stripMcpJson(claudeDesktopConfig)) stripped.push("claude_desktop_config.json");
|
|
1977
|
-
if (stripMcpJson(
|
|
1978
|
-
if (stripMcpJson(
|
|
1979
|
-
if (stripCodexTomlAt(
|
|
2009
|
+
if (stripMcpJson(join2(home, ".cursor", "mcp.json"))) stripped.push("~/.cursor/mcp.json");
|
|
2010
|
+
if (stripMcpJson(join2(home, ".factory", "mcp.json"), { wrapped: false })) stripped.push("~/.factory/mcp.json");
|
|
2011
|
+
if (stripCodexTomlAt(join2(home, ".codex", "config.toml"))) stripped.push("~/.codex/config.toml");
|
|
1980
2012
|
if (stripCodexTomlAt(resolve3(".codex/config.toml"))) stripped.push(".codex/config.toml");
|
|
1981
2013
|
stripClaudeMd();
|
|
1982
2014
|
stripSettingsJson();
|
|
@@ -2202,9 +2234,9 @@ import { dirname as dirname2 } from "path";
|
|
|
2202
2234
|
|
|
2203
2235
|
// src/lib/claude-config.ts
|
|
2204
2236
|
import { homedir as homedir2 } from "os";
|
|
2205
|
-
import { join as
|
|
2237
|
+
import { join as join3 } from "path";
|
|
2206
2238
|
import { readFile as readFile3, writeFile as writeFile6, mkdir as mkdir4, access } from "fs/promises";
|
|
2207
|
-
var CLAUDE_CONFIG_PATH =
|
|
2239
|
+
var CLAUDE_CONFIG_PATH = join3(homedir2(), ".claude", "config");
|
|
2208
2240
|
async function writeKeyToClaudeConfig(agentId, privateKeyPem) {
|
|
2209
2241
|
let config = {};
|
|
2210
2242
|
try {
|
|
@@ -2215,7 +2247,7 @@ async function writeKeyToClaudeConfig(agentId, privateKeyPem) {
|
|
|
2215
2247
|
}
|
|
2216
2248
|
config.agent_keys = config.agent_keys ?? {};
|
|
2217
2249
|
config.agent_keys[agentId] = Buffer.from(privateKeyPem).toString("base64");
|
|
2218
|
-
await mkdir4(
|
|
2250
|
+
await mkdir4(join3(homedir2(), ".claude"), { recursive: true });
|
|
2219
2251
|
await writeFile6(CLAUDE_CONFIG_PATH, JSON.stringify(config, null, 2), "utf-8");
|
|
2220
2252
|
}
|
|
2221
2253
|
|
|
@@ -2460,6 +2492,7 @@ function installCommand() {
|
|
|
2460
2492
|
detected
|
|
2461
2493
|
});
|
|
2462
2494
|
}
|
|
2495
|
+
await writeGovernanceInstructions(agent_id, owner_id);
|
|
2463
2496
|
ensureMcpServer();
|
|
2464
2497
|
}
|
|
2465
2498
|
}
|
|
@@ -2532,12 +2565,12 @@ import { Command as Command6 } from "commander";
|
|
|
2532
2565
|
import { generateKeyPairSync as generateKeyPairSync2 } from "crypto";
|
|
2533
2566
|
import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync4, existsSync as existsSync8 } from "fs";
|
|
2534
2567
|
import { homedir as homedir3 } from "os";
|
|
2535
|
-
import { join as
|
|
2568
|
+
import { join as join4 } from "path";
|
|
2536
2569
|
import chalk13 from "chalk";
|
|
2537
2570
|
var DEFAULT_PROXY_URL = "https://api.agentvalet.ai";
|
|
2538
2571
|
function resolveAgentDir(label) {
|
|
2539
|
-
const root =
|
|
2540
|
-
return label ?
|
|
2572
|
+
const root = join4(homedir3(), ".agentvalet");
|
|
2573
|
+
return label ? join4(root, label) : root;
|
|
2541
2574
|
}
|
|
2542
2575
|
function sanitiseLabel(label) {
|
|
2543
2576
|
return label.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -2581,8 +2614,8 @@ function claimCommand() {
|
|
|
2581
2614
|
process.exit(3);
|
|
2582
2615
|
}
|
|
2583
2616
|
const agentDir = resolveAgentDir(label);
|
|
2584
|
-
const keyPath =
|
|
2585
|
-
const identityPath =
|
|
2617
|
+
const keyPath = join4(agentDir, "agent.key");
|
|
2618
|
+
const identityPath = join4(agentDir, "agent.json");
|
|
2586
2619
|
if (existsSync8(keyPath)) {
|
|
2587
2620
|
const msg = label ? `An agent already exists at ${keyPath}. Pick a different --label or remove the directory first.` : `A default agent already exists at ${keyPath}. Pass --label <name> to claim alongside it without overwriting.`;
|
|
2588
2621
|
console.error(isJson ? JSON.stringify({ error: msg }) : chalk13.red(msg));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentvalet/register",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
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": "node ../../scripts/no-secrets.mjs && pnpm build && node ../../scripts/no-workspace-protocol.mjs"
|
|
19
|
+
},
|
|
13
20
|
"dependencies": {
|
|
14
21
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
15
22
|
"@octokit/auth-oauth-device": "^7.0.0",
|
|
@@ -22,22 +29,23 @@
|
|
|
22
29
|
"undici": "^6.0.0"
|
|
23
30
|
},
|
|
24
31
|
"devDependencies": {
|
|
32
|
+
"@agentvalet/mcp-server": "workspace:^",
|
|
25
33
|
"@types/node": "^20.0.0",
|
|
26
34
|
"@types/prompts": "^2.4.0",
|
|
27
35
|
"tsup": "^8.0.0",
|
|
28
36
|
"tsx": "^4.0.0",
|
|
29
37
|
"typescript": "^5.0.0",
|
|
30
|
-
"vitest": "^1.5.0"
|
|
31
|
-
"@agentvalet/mcp-server": "^1.4.1"
|
|
38
|
+
"vitest": "^1.5.0"
|
|
32
39
|
},
|
|
33
40
|
"engines": {
|
|
34
41
|
"node": ">=18"
|
|
35
42
|
},
|
|
36
43
|
"repository": {
|
|
37
44
|
"type": "git",
|
|
38
|
-
"url": "git+https://github.com/
|
|
45
|
+
"url": "git+https://github.com/AgentValet/AgentValet.git",
|
|
46
|
+
"directory": "packages/cli"
|
|
39
47
|
},
|
|
40
|
-
"homepage": "https://
|
|
48
|
+
"homepage": "https://github.com/AgentValet/AgentValet#readme",
|
|
41
49
|
"bugs": {
|
|
42
50
|
"url": "https://github.com/agentvalet/agentvalet/issues"
|
|
43
51
|
},
|
|
@@ -53,11 +61,5 @@
|
|
|
53
61
|
"valet",
|
|
54
62
|
"agentvalet"
|
|
55
63
|
],
|
|
56
|
-
"license": "MIT"
|
|
57
|
-
|
|
58
|
-
"build": "tsup src/index.ts --format esm --dts --clean --shims",
|
|
59
|
-
"dev": "tsx src/index.ts",
|
|
60
|
-
"test": "vitest run",
|
|
61
|
-
"typecheck": "tsc --noEmit"
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
+
"license": "MIT"
|
|
65
|
+
}
|