@agentvalet/register 0.3.6 → 0.3.8

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.
Files changed (2) hide show
  1. package/dist/index.js +101 -54
  2. 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(params);
830
- const claudeMcpPath = path4.join(cwd, ".mcp.json");
831
- if (existsSync4(claudeMcpPath) || existsSync4(path4.join(cwd, "CLAUDE.md"))) {
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
- const cursorDir = path4.join(cwd, ".cursor");
840
- const cursorMcpPath = path4.join(cursorDir, "mcp.json");
841
- if (existsSync4(cursorDir)) {
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);
@@ -852,39 +873,64 @@ async function writeIdeConfigs(params) {
852
873
 
853
874
  // src/config/frameworks.ts
854
875
  import { existsSync as existsSync5 } from "fs";
876
+ import { execSync as execSync2 } from "child_process";
855
877
  import os2 from "os";
856
878
  import path5 from "path";
857
879
  import prompts2 from "prompts";
858
880
  import chalk5 from "chalk";
881
+ function cursorInstalled() {
882
+ const home = os2.homedir();
883
+ const platform = process.platform;
884
+ if (platform === "win32") {
885
+ const appData = process.env.APPDATA ?? path5.join(home, "AppData", "Roaming");
886
+ const localAppData = process.env.LOCALAPPDATA ?? path5.join(home, "AppData", "Local");
887
+ return existsSync5(path5.join(appData, "Cursor")) || existsSync5(path5.join(localAppData, "Programs", "cursor"));
888
+ }
889
+ if (platform === "darwin") {
890
+ return existsSync5(path5.join(home, "Library", "Application Support", "Cursor")) || existsSync5("/Applications/Cursor.app");
891
+ }
892
+ return existsSync5(path5.join(home, ".config", "Cursor")) || existsSync5("/usr/share/applications/cursor.desktop");
893
+ }
894
+ function claudeCodeInstalled() {
895
+ const home = os2.homedir();
896
+ if (existsSync5(path5.join(home, ".claude"))) return true;
897
+ try {
898
+ execSync2("claude --version", { stdio: "ignore", timeout: 3e3 });
899
+ return true;
900
+ } catch {
901
+ return false;
902
+ }
903
+ }
859
904
  function detectFrameworks() {
860
905
  const home = os2.homedir();
861
906
  return {
862
907
  codex: existsSync5(path5.join(home, ".codex", "config.toml")),
863
- claudeCode: existsSync5(path5.join(home, ".claude")),
864
- cursor: existsSync5(path5.join(process.cwd(), ".cursor")),
908
+ claudeCode: claudeCodeInstalled(),
909
+ cursor: existsSync5(path5.join(process.cwd(), ".cursor")) || cursorInstalled(),
865
910
  openclaw: existsSync5(path5.join(home, ".openclaw"))
866
911
  };
867
912
  }
868
913
  async function frameworkSetupConsent(detected) {
869
914
  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
915
  if (detected.claudeCode) {
878
- items.push("Claude Code \u2192 ~/.claude/claude_desktop_config.json");
916
+ items.push("Claude Code \u2192 .mcp.json (MCP server)");
917
+ items.push(" \u2192 CLAUDE.md (usage rules)");
879
918
  }
880
919
  if (detected.cursor) {
881
- items.push("Cursor \u2192 .cursor/mcp.json");
920
+ items.push("Cursor \u2192 .cursor/mcp.json (MCP server)");
921
+ }
922
+ if (detected.codex) {
923
+ items.push("Codex CLI \u2192 ~/.codex/config.toml (MCP server)");
924
+ items.push(" \u2192 AGENTS.md (usage rules)");
925
+ }
926
+ if (detected.openclaw) {
927
+ items.push("OpenClaw \u2192 SKILL.md (usage rules)");
882
928
  }
883
929
  if (items.length === 0) return false;
884
930
  console.log("");
885
- console.log(chalk5.bold(" Agent framework setup"));
931
+ console.log(chalk5.bold(" Detected agent frameworks"));
886
932
  for (const item of items) {
887
- console.log(chalk5.dim(` ${item}`));
933
+ console.log(chalk5.dim(` ${item}`));
888
934
  }
889
935
  console.log("");
890
936
  const { confirm } = await prompts2({
@@ -1090,7 +1136,8 @@ async function registerAgentFlow(apiKey, ownerId) {
1090
1136
  agentId: agent.agent_id,
1091
1137
  ownerId,
1092
1138
  proxyUrl: getStoredConfig().proxyUrl,
1093
- keyPath: path6.join(process.cwd(), ".agentvalet", "agent.key")
1139
+ keyPath: path6.join(process.cwd(), ".agentvalet", "agent.key"),
1140
+ detected
1094
1141
  });
1095
1142
  for (const r of ideResults) {
1096
1143
  console.log(chalk6.green(` \u2713 ${r}`));
@@ -1152,7 +1199,7 @@ function collectScope(value, previous) {
1152
1199
  return [...previous, value];
1153
1200
  }
1154
1201
  var program = new Command();
1155
- program.name("agentvalet-register").description("Self-register an AI agent with AgentValet").version("0.3.6").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) => {
1202
+ program.name("agentvalet-register").description("Self-register an AI agent with AgentValet").version("0.3.8").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
1203
  const isJson = !!opts.json;
1157
1204
  let ownerId = opts.owner ?? process.env.AGENTVALET_OWNER ?? "";
1158
1205
  let agentName = opts.name ?? "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentvalet/register",
3
- "version": "0.3.6",
3
+ "version": "0.3.8",
4
4
  "description": "Self-register AI agents with AgentValet",
5
5
  "type": "module",
6
6
  "bin": {