@agentvalet/register 0.3.6 → 0.3.7
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 +89 -53
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -762,6 +762,48 @@ async function mergeJsonFile(filePath, key, value) {
|
|
|
762
762
|
existing.mcpServers = mcpServers;
|
|
763
763
|
await writeFile4(filePath, JSON.stringify(existing, null, 2) + "\n", "utf8");
|
|
764
764
|
}
|
|
765
|
+
function buildClaudeMd(agentId, ownerId, proxyUrl) {
|
|
766
|
+
return `# AgentValet \u2014 Credential Governance
|
|
767
|
+
|
|
768
|
+
Agent ID: \`${agentId}\`
|
|
769
|
+
Owner ID: \`${ownerId}\`
|
|
770
|
+
|
|
771
|
+
All external platform API calls **must** go through the AgentValet proxy.
|
|
772
|
+
Never call platform APIs (Slack, Stripe, Gmail, GitHub, etc.) directly.
|
|
773
|
+
|
|
774
|
+
## Making a platform call
|
|
775
|
+
|
|
776
|
+
Use the \`mcp__agent-authority__use_platform\` MCP tool:
|
|
777
|
+
|
|
778
|
+
\`\`\`
|
|
779
|
+
mcp__agent-authority__use_platform({
|
|
780
|
+
platform: "slack",
|
|
781
|
+
endpoint: "/api/chat.postMessage",
|
|
782
|
+
method: "POST",
|
|
783
|
+
scope: "slack:write",
|
|
784
|
+
data: { channel: "#general", text: "Hello" }
|
|
785
|
+
})
|
|
786
|
+
\`\`\`
|
|
787
|
+
|
|
788
|
+
## Before any platform session
|
|
789
|
+
|
|
790
|
+
1. Call \`mcp__agent-authority__list_platforms\` to see approved platforms and scopes
|
|
791
|
+
2. Call \`mcp__agent-authority__authzen_evaluate\` before destructive operations
|
|
792
|
+
3. If a call returns \`pending_approval\` \u2014 wait, do not retry
|
|
793
|
+
|
|
794
|
+
## Rules
|
|
795
|
+
|
|
796
|
+
- **NEVER** write inline JWT signing code, \`node -e\` scripts, or manual HTTP calls
|
|
797
|
+
- The MCP tool handles authentication automatically
|
|
798
|
+
- \`AGENT_PRIVATE_KEY_PATH\` points to your key \u2014 do not read or log it
|
|
799
|
+
|
|
800
|
+
## If AgentValet MCP is not connected
|
|
801
|
+
|
|
802
|
+
Tell the user: "AgentValet MCP is not connected. Run: npx @agentvalet/register"
|
|
803
|
+
|
|
804
|
+
Dashboard: ${proxyUrl.replace("api.", "app.")}
|
|
805
|
+
`;
|
|
806
|
+
}
|
|
765
807
|
async function writeGlobalFrameworkConfigs(params) {
|
|
766
808
|
const written = [];
|
|
767
809
|
const privateKeyEscaped = params.privateKeyPem.replace(/\n/g, "\\n");
|
|
@@ -788,57 +830,36 @@ AGENT_PRIVATE_KEY = "${privateKeyEscaped}"
|
|
|
788
830
|
console.warn(` Warning: could not write Codex CLI config: ${err.message}`);
|
|
789
831
|
}
|
|
790
832
|
}
|
|
791
|
-
const claudeConfigPath = path4.join(os.homedir(), ".claude", "claude_desktop_config.json");
|
|
792
|
-
if (existsSync4(claudeConfigPath)) {
|
|
793
|
-
try {
|
|
794
|
-
let config = {};
|
|
795
|
-
try {
|
|
796
|
-
const text = await readFile2(claudeConfigPath, "utf8");
|
|
797
|
-
config = JSON.parse(text);
|
|
798
|
-
} catch {
|
|
799
|
-
console.warn(" Warning: ~/.claude/claude_desktop_config.json is malformed \u2014 skipping");
|
|
800
|
-
config = null;
|
|
801
|
-
}
|
|
802
|
-
if (config !== null) {
|
|
803
|
-
if (config.mcpServers?.agentvalet) {
|
|
804
|
-
} else {
|
|
805
|
-
config.mcpServers = config.mcpServers ?? {};
|
|
806
|
-
config.mcpServers.agentvalet = {
|
|
807
|
-
command: "npx",
|
|
808
|
-
args: ["-y", "@agentvalet/mcp-server"],
|
|
809
|
-
env: {
|
|
810
|
-
AGENT_ID: params.agentId,
|
|
811
|
-
OWNER_ID: params.ownerId,
|
|
812
|
-
PROXY_URL: params.proxyUrl,
|
|
813
|
-
AGENT_PRIVATE_KEY: privateKeyEscaped
|
|
814
|
-
}
|
|
815
|
-
};
|
|
816
|
-
await writeFile4(claudeConfigPath, JSON.stringify(config, null, 2) + "\n", "utf8");
|
|
817
|
-
written.push("~/.claude/claude_desktop_config.json");
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
} catch (err) {
|
|
821
|
-
console.warn(` Warning: could not write Claude Code global config: ${err.message}`);
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
833
|
return written;
|
|
825
834
|
}
|
|
826
835
|
async function writeIdeConfigs(params) {
|
|
836
|
+
const { detected, ...mcpParams } = params;
|
|
827
837
|
const cwd = process.cwd();
|
|
828
838
|
const written = [];
|
|
829
|
-
const entry = buildMcpEntry(
|
|
830
|
-
|
|
831
|
-
|
|
839
|
+
const entry = buildMcpEntry(mcpParams);
|
|
840
|
+
if (detected.claudeCode) {
|
|
841
|
+
const claudeMcpPath = path4.join(cwd, ".mcp.json");
|
|
832
842
|
try {
|
|
833
843
|
await mergeJsonFile(claudeMcpPath, "agentvalet", entry);
|
|
834
844
|
written.push(".mcp.json");
|
|
835
845
|
} catch (err) {
|
|
836
846
|
console.warn(` Warning: could not write .mcp.json: ${err.message}`);
|
|
837
847
|
}
|
|
848
|
+
const claudeMdPath = path4.join(cwd, "CLAUDE.md");
|
|
849
|
+
if (!existsSync4(claudeMdPath)) {
|
|
850
|
+
try {
|
|
851
|
+
await writeFile4(claudeMdPath, buildClaudeMd(params.agentId, params.ownerId, params.proxyUrl), "utf8");
|
|
852
|
+
written.push("CLAUDE.md");
|
|
853
|
+
} catch (err) {
|
|
854
|
+
console.warn(` Warning: could not write CLAUDE.md: ${err.message}`);
|
|
855
|
+
}
|
|
856
|
+
} else {
|
|
857
|
+
written.push("CLAUDE.md (already exists \u2014 skipped)");
|
|
858
|
+
}
|
|
838
859
|
}
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
860
|
+
if (detected.cursor) {
|
|
861
|
+
const cursorDir = path4.join(cwd, ".cursor");
|
|
862
|
+
const cursorMcpPath = path4.join(cursorDir, "mcp.json");
|
|
842
863
|
try {
|
|
843
864
|
await mkdir3(cursorDir, { recursive: true });
|
|
844
865
|
await mergeJsonFile(cursorMcpPath, "agentvalet", entry);
|
|
@@ -856,35 +877,49 @@ import os2 from "os";
|
|
|
856
877
|
import path5 from "path";
|
|
857
878
|
import prompts2 from "prompts";
|
|
858
879
|
import chalk5 from "chalk";
|
|
880
|
+
function cursorInstalled() {
|
|
881
|
+
const home = os2.homedir();
|
|
882
|
+
const platform = process.platform;
|
|
883
|
+
if (platform === "win32") {
|
|
884
|
+
const appData = process.env.APPDATA ?? path5.join(home, "AppData", "Roaming");
|
|
885
|
+
const localAppData = process.env.LOCALAPPDATA ?? path5.join(home, "AppData", "Local");
|
|
886
|
+
return existsSync5(path5.join(appData, "Cursor")) || existsSync5(path5.join(localAppData, "Programs", "cursor"));
|
|
887
|
+
}
|
|
888
|
+
if (platform === "darwin") {
|
|
889
|
+
return existsSync5(path5.join(home, "Library", "Application Support", "Cursor")) || existsSync5("/Applications/Cursor.app");
|
|
890
|
+
}
|
|
891
|
+
return existsSync5(path5.join(home, ".config", "Cursor")) || existsSync5("/usr/share/applications/cursor.desktop");
|
|
892
|
+
}
|
|
859
893
|
function detectFrameworks() {
|
|
860
894
|
const home = os2.homedir();
|
|
861
895
|
return {
|
|
862
896
|
codex: existsSync5(path5.join(home, ".codex", "config.toml")),
|
|
863
897
|
claudeCode: existsSync5(path5.join(home, ".claude")),
|
|
864
|
-
cursor: existsSync5(path5.join(process.cwd(), ".cursor")),
|
|
898
|
+
cursor: existsSync5(path5.join(process.cwd(), ".cursor")) || cursorInstalled(),
|
|
865
899
|
openclaw: existsSync5(path5.join(home, ".openclaw"))
|
|
866
900
|
};
|
|
867
901
|
}
|
|
868
902
|
async function frameworkSetupConsent(detected) {
|
|
869
903
|
const items = [];
|
|
870
|
-
if (detected.codex) {
|
|
871
|
-
items.push("Codex CLI \u2192 add MCP server to ~/.codex/config.toml");
|
|
872
|
-
items.push(" \u2192 copy AGENTS.md to current directory");
|
|
873
|
-
}
|
|
874
|
-
if (detected.openclaw) {
|
|
875
|
-
items.push("OpenClaw \u2192 copy SKILL.md to current directory");
|
|
876
|
-
}
|
|
877
904
|
if (detected.claudeCode) {
|
|
878
|
-
items.push("Claude Code \u2192
|
|
905
|
+
items.push("Claude Code \u2192 .mcp.json (MCP server)");
|
|
906
|
+
items.push(" \u2192 CLAUDE.md (usage rules)");
|
|
879
907
|
}
|
|
880
908
|
if (detected.cursor) {
|
|
881
|
-
items.push("Cursor \u2192 .cursor/mcp.json");
|
|
909
|
+
items.push("Cursor \u2192 .cursor/mcp.json (MCP server)");
|
|
910
|
+
}
|
|
911
|
+
if (detected.codex) {
|
|
912
|
+
items.push("Codex CLI \u2192 ~/.codex/config.toml (MCP server)");
|
|
913
|
+
items.push(" \u2192 AGENTS.md (usage rules)");
|
|
914
|
+
}
|
|
915
|
+
if (detected.openclaw) {
|
|
916
|
+
items.push("OpenClaw \u2192 SKILL.md (usage rules)");
|
|
882
917
|
}
|
|
883
918
|
if (items.length === 0) return false;
|
|
884
919
|
console.log("");
|
|
885
|
-
console.log(chalk5.bold("
|
|
920
|
+
console.log(chalk5.bold(" Detected agent frameworks"));
|
|
886
921
|
for (const item of items) {
|
|
887
|
-
console.log(chalk5.dim(`
|
|
922
|
+
console.log(chalk5.dim(` ${item}`));
|
|
888
923
|
}
|
|
889
924
|
console.log("");
|
|
890
925
|
const { confirm } = await prompts2({
|
|
@@ -1090,7 +1125,8 @@ async function registerAgentFlow(apiKey, ownerId) {
|
|
|
1090
1125
|
agentId: agent.agent_id,
|
|
1091
1126
|
ownerId,
|
|
1092
1127
|
proxyUrl: getStoredConfig().proxyUrl,
|
|
1093
|
-
keyPath: path6.join(process.cwd(), ".agentvalet", "agent.key")
|
|
1128
|
+
keyPath: path6.join(process.cwd(), ".agentvalet", "agent.key"),
|
|
1129
|
+
detected
|
|
1094
1130
|
});
|
|
1095
1131
|
for (const r of ideResults) {
|
|
1096
1132
|
console.log(chalk6.green(` \u2713 ${r}`));
|
|
@@ -1152,7 +1188,7 @@ function collectScope(value, previous) {
|
|
|
1152
1188
|
return [...previous, value];
|
|
1153
1189
|
}
|
|
1154
1190
|
var program = new Command();
|
|
1155
|
-
program.name("agentvalet-register").description("Self-register an AI agent with AgentValet").version("0.3.
|
|
1191
|
+
program.name("agentvalet-register").description("Self-register an AI agent with AgentValet").version("0.3.7").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) => {
|
|
1156
1192
|
const isJson = !!opts.json;
|
|
1157
1193
|
let ownerId = opts.owner ?? process.env.AGENTVALET_OWNER ?? "";
|
|
1158
1194
|
let agentName = opts.name ?? "";
|