@agentvalet/register 1.1.0 → 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 +146 -107
- package/dist/{mcp-server-77VYWZUZ.js → mcp-server-MFHDR2TL.js} +1 -1
- 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 {
|
|
@@ -983,7 +1067,9 @@ function ensureMcpJson() {
|
|
|
983
1067
|
const { agentId, ownerId, apiUrl, keyPath } = creds;
|
|
984
1068
|
servers["agentvalet"] = {
|
|
985
1069
|
command: "npx",
|
|
986
|
-
|
|
1070
|
+
// Pin @latest — unversioned lets npx reuse a stale global install that
|
|
1071
|
+
// shadows the current build (see apps/cli/src/config/ide.ts).
|
|
1072
|
+
args: ["-y", "@agentvalet/register@latest", "mcp-server"],
|
|
987
1073
|
env: {
|
|
988
1074
|
AGENT_ID: agentId,
|
|
989
1075
|
OWNER_ID: ownerId,
|
|
@@ -1185,7 +1271,11 @@ import os2 from "os";
|
|
|
1185
1271
|
function buildMcpEntry(params) {
|
|
1186
1272
|
return {
|
|
1187
1273
|
command: "npx",
|
|
1188
|
-
|
|
1274
|
+
// Pin @latest so npx always resolves the published version from the registry.
|
|
1275
|
+
// Unversioned `@agentvalet/register` lets npx silently reuse a stale global
|
|
1276
|
+
// install (e.g. an old 0.5.0 bundling mcp-server@0.2.1), which shadows the
|
|
1277
|
+
// current build and drops newer tool params like use_platform's connection_id.
|
|
1278
|
+
args: ["-y", "@agentvalet/register@latest", "mcp-server"],
|
|
1189
1279
|
env: {
|
|
1190
1280
|
AGENT_ID: params.agentId,
|
|
1191
1281
|
OWNER_ID: params.ownerId,
|
|
@@ -1224,53 +1314,11 @@ async function mergeJsonFile(filePath, key, value) {
|
|
|
1224
1314
|
existing.mcpServers = mcpServers;
|
|
1225
1315
|
await writeFile4(filePath, JSON.stringify(existing, null, 2) + "\n", "utf8");
|
|
1226
1316
|
}
|
|
1227
|
-
function buildClaudeMd(agentId, ownerId, proxyUrl) {
|
|
1228
|
-
return `# AgentValet \u2014 Credential Governance
|
|
1229
|
-
|
|
1230
|
-
Agent ID: \`${agentId}\`
|
|
1231
|
-
Owner ID: \`${ownerId}\`
|
|
1232
|
-
|
|
1233
|
-
All external platform API calls **must** go through the AgentValet proxy.
|
|
1234
|
-
Never call platform APIs (Slack, Stripe, Gmail, GitHub, etc.) directly.
|
|
1235
|
-
|
|
1236
|
-
## Making a platform call
|
|
1237
|
-
|
|
1238
|
-
Use the \`mcp__agentvalet__use_platform\` MCP tool:
|
|
1239
|
-
|
|
1240
|
-
\`\`\`
|
|
1241
|
-
mcp__agentvalet__use_platform({
|
|
1242
|
-
platform: "slack",
|
|
1243
|
-
endpoint: "/api/chat.postMessage",
|
|
1244
|
-
method: "POST",
|
|
1245
|
-
scope: "slack:write",
|
|
1246
|
-
data: { channel: "#general", text: "Hello" }
|
|
1247
|
-
})
|
|
1248
|
-
\`\`\`
|
|
1249
|
-
|
|
1250
|
-
## Before any platform session
|
|
1251
|
-
|
|
1252
|
-
1. Call \`mcp__agentvalet__list_platforms\` to see approved platforms and scopes
|
|
1253
|
-
2. Call \`mcp__agentvalet__authzen_evaluate\` before destructive operations
|
|
1254
|
-
3. If a call returns \`pending_approval\` \u2014 wait, do not retry
|
|
1255
|
-
|
|
1256
|
-
## Rules
|
|
1257
|
-
|
|
1258
|
-
- **NEVER** write inline JWT signing code, \`node -e\` scripts, or manual HTTP calls
|
|
1259
|
-
- The MCP tool handles authentication automatically
|
|
1260
|
-
- \`AGENT_PRIVATE_KEY_PATH\` points to your key \u2014 do not read or log it
|
|
1261
|
-
|
|
1262
|
-
## If AgentValet MCP is not connected
|
|
1263
|
-
|
|
1264
|
-
Tell the user: "AgentValet MCP is not connected. Run: npx @agentvalet/register"
|
|
1265
|
-
|
|
1266
|
-
Dashboard: ${proxyUrl.replace("api.", "app.")}
|
|
1267
|
-
`;
|
|
1268
|
-
}
|
|
1269
1317
|
function buildCodexTomlBlock(params) {
|
|
1270
1318
|
return `
|
|
1271
1319
|
[mcp_servers.agentvalet]
|
|
1272
1320
|
command = "npx"
|
|
1273
|
-
args = ["-y", "@agentvalet/register", "mcp-server"]
|
|
1321
|
+
args = ["-y", "@agentvalet/register@latest", "mcp-server"]
|
|
1274
1322
|
env = { AGENT_ID = "${params.agentId}", OWNER_ID = "${params.ownerId}", PROXY_URL = "${params.proxyUrl}", AGENT_PRIVATE_KEY_PATH = "${params.keyPath.replace(/\\/g, "/")}" }
|
|
1275
1323
|
`;
|
|
1276
1324
|
}
|
|
@@ -1401,17 +1449,6 @@ async function writeIdeConfigs(params) {
|
|
|
1401
1449
|
} catch (err) {
|
|
1402
1450
|
console.warn(` Warning: could not write .mcp.json: ${err.message}`);
|
|
1403
1451
|
}
|
|
1404
|
-
const claudeMdPath = path5.join(cwd, "CLAUDE.md");
|
|
1405
|
-
if (!existsSync6(claudeMdPath)) {
|
|
1406
|
-
try {
|
|
1407
|
-
await writeFile4(claudeMdPath, buildClaudeMd(params.agentId, params.ownerId, params.proxyUrl), "utf8");
|
|
1408
|
-
written.push("CLAUDE.md");
|
|
1409
|
-
} catch (err) {
|
|
1410
|
-
console.warn(` Warning: could not write CLAUDE.md: ${err.message}`);
|
|
1411
|
-
}
|
|
1412
|
-
} else {
|
|
1413
|
-
written.push("CLAUDE.md (already exists \u2014 skipped)");
|
|
1414
|
-
}
|
|
1415
1452
|
}
|
|
1416
1453
|
if (detected.cursor || detected.cursorCli) {
|
|
1417
1454
|
const cursorDir = path5.join(cwd, ".cursor");
|
|
@@ -1670,6 +1707,7 @@ async function registerAgentFlow(apiKey, ownerId, scope = "user", presetName) {
|
|
|
1670
1707
|
detected
|
|
1671
1708
|
});
|
|
1672
1709
|
}
|
|
1710
|
+
await writeGovernanceInstructions(agent.agent_id, ownerId);
|
|
1673
1711
|
ensureMcpServer();
|
|
1674
1712
|
} else if (shouldSetup === false) {
|
|
1675
1713
|
console.log("");
|
|
@@ -1833,7 +1871,7 @@ import chalk10 from "chalk";
|
|
|
1833
1871
|
import { Command as Command2 } from "commander";
|
|
1834
1872
|
import chalk9 from "chalk";
|
|
1835
1873
|
import { existsSync as existsSync7, readFileSync as readFileSync4, writeFileSync as writeFileSync3, rmSync } from "fs";
|
|
1836
|
-
import { resolve as resolve3, join } from "path";
|
|
1874
|
+
import { resolve as resolve3, join as join2 } from "path";
|
|
1837
1875
|
import { homedir } from "os";
|
|
1838
1876
|
var CLAUDE_START2 = "<!-- agentvalet:start -->";
|
|
1839
1877
|
var CLAUDE_END2 = "<!-- agentvalet:end -->";
|
|
@@ -1965,12 +2003,12 @@ function cleanLocally() {
|
|
|
1965
2003
|
if (stripMcpJson(resolve3(".cursor/mcp.json"))) stripped.push(".cursor/mcp.json");
|
|
1966
2004
|
if (stripMcpJson(resolve3(".factory/mcp.json"), { wrapped: false })) stripped.push(".factory/mcp.json");
|
|
1967
2005
|
const home = homedir();
|
|
1968
|
-
if (stripMcpJson(
|
|
1969
|
-
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");
|
|
1970
2008
|
if (stripMcpJson(claudeDesktopConfig)) stripped.push("claude_desktop_config.json");
|
|
1971
|
-
if (stripMcpJson(
|
|
1972
|
-
if (stripMcpJson(
|
|
1973
|
-
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");
|
|
1974
2012
|
if (stripCodexTomlAt(resolve3(".codex/config.toml"))) stripped.push(".codex/config.toml");
|
|
1975
2013
|
stripClaudeMd();
|
|
1976
2014
|
stripSettingsJson();
|
|
@@ -2196,9 +2234,9 @@ import { dirname as dirname2 } from "path";
|
|
|
2196
2234
|
|
|
2197
2235
|
// src/lib/claude-config.ts
|
|
2198
2236
|
import { homedir as homedir2 } from "os";
|
|
2199
|
-
import { join as
|
|
2237
|
+
import { join as join3 } from "path";
|
|
2200
2238
|
import { readFile as readFile3, writeFile as writeFile6, mkdir as mkdir4, access } from "fs/promises";
|
|
2201
|
-
var CLAUDE_CONFIG_PATH =
|
|
2239
|
+
var CLAUDE_CONFIG_PATH = join3(homedir2(), ".claude", "config");
|
|
2202
2240
|
async function writeKeyToClaudeConfig(agentId, privateKeyPem) {
|
|
2203
2241
|
let config = {};
|
|
2204
2242
|
try {
|
|
@@ -2209,7 +2247,7 @@ async function writeKeyToClaudeConfig(agentId, privateKeyPem) {
|
|
|
2209
2247
|
}
|
|
2210
2248
|
config.agent_keys = config.agent_keys ?? {};
|
|
2211
2249
|
config.agent_keys[agentId] = Buffer.from(privateKeyPem).toString("base64");
|
|
2212
|
-
await mkdir4(
|
|
2250
|
+
await mkdir4(join3(homedir2(), ".claude"), { recursive: true });
|
|
2213
2251
|
await writeFile6(CLAUDE_CONFIG_PATH, JSON.stringify(config, null, 2), "utf-8");
|
|
2214
2252
|
}
|
|
2215
2253
|
|
|
@@ -2454,6 +2492,7 @@ function installCommand() {
|
|
|
2454
2492
|
detected
|
|
2455
2493
|
});
|
|
2456
2494
|
}
|
|
2495
|
+
await writeGovernanceInstructions(agent_id, owner_id);
|
|
2457
2496
|
ensureMcpServer();
|
|
2458
2497
|
}
|
|
2459
2498
|
}
|
|
@@ -2526,12 +2565,12 @@ import { Command as Command6 } from "commander";
|
|
|
2526
2565
|
import { generateKeyPairSync as generateKeyPairSync2 } from "crypto";
|
|
2527
2566
|
import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync4, existsSync as existsSync8 } from "fs";
|
|
2528
2567
|
import { homedir as homedir3 } from "os";
|
|
2529
|
-
import { join as
|
|
2568
|
+
import { join as join4 } from "path";
|
|
2530
2569
|
import chalk13 from "chalk";
|
|
2531
2570
|
var DEFAULT_PROXY_URL = "https://api.agentvalet.ai";
|
|
2532
2571
|
function resolveAgentDir(label) {
|
|
2533
|
-
const root =
|
|
2534
|
-
return label ?
|
|
2572
|
+
const root = join4(homedir3(), ".agentvalet");
|
|
2573
|
+
return label ? join4(root, label) : root;
|
|
2535
2574
|
}
|
|
2536
2575
|
function sanitiseLabel(label) {
|
|
2537
2576
|
return label.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -2575,8 +2614,8 @@ function claimCommand() {
|
|
|
2575
2614
|
process.exit(3);
|
|
2576
2615
|
}
|
|
2577
2616
|
const agentDir = resolveAgentDir(label);
|
|
2578
|
-
const keyPath =
|
|
2579
|
-
const identityPath =
|
|
2617
|
+
const keyPath = join4(agentDir, "agent.key");
|
|
2618
|
+
const identityPath = join4(agentDir, "agent.json");
|
|
2580
2619
|
if (existsSync8(keyPath)) {
|
|
2581
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.`;
|
|
2582
2621
|
console.error(isJson ? JSON.stringify({ error: msg }) : chalk13.red(msg));
|
|
@@ -2837,7 +2876,7 @@ program.command("refresh").description("Refresh approved permissions and update
|
|
|
2837
2876
|
}
|
|
2838
2877
|
});
|
|
2839
2878
|
program.command("mcp-server").description("Start the AgentValet MCP server (stdio transport)").action(async () => {
|
|
2840
|
-
const { mcpServerCommand } = await import("./mcp-server-
|
|
2879
|
+
const { mcpServerCommand } = await import("./mcp-server-MFHDR2TL.js");
|
|
2841
2880
|
await mcpServerCommand();
|
|
2842
2881
|
});
|
|
2843
2882
|
program.addCommand(listCommand());
|
|
@@ -16,7 +16,7 @@ function resolveMcpServerBin() {
|
|
|
16
16
|
}
|
|
17
17
|
async function mcpServerCommand() {
|
|
18
18
|
const binPath = resolveMcpServerBin();
|
|
19
|
-
const [cmd, args] = binPath ? [process.execPath, [binPath]] : ["npx", ["--yes", "@agentvalet/mcp-server"]];
|
|
19
|
+
const [cmd, args] = binPath ? [process.execPath, [binPath]] : ["npx", ["--yes", "@agentvalet/mcp-server@latest"]];
|
|
20
20
|
const child = spawn(cmd, args, {
|
|
21
21
|
stdio: "inherit",
|
|
22
22
|
env: process.env,
|
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
|
+
}
|