@agentvalet/register 0.3.0 → 0.3.1
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 +73 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -610,8 +610,66 @@ function formatEnvBlock(vars) {
|
|
|
610
610
|
}).join("\n");
|
|
611
611
|
}
|
|
612
612
|
|
|
613
|
+
// src/config/ide.ts
|
|
614
|
+
import { mkdir as mkdir3, writeFile as writeFile4, readFile as readFile2 } from "fs/promises";
|
|
615
|
+
import { existsSync as existsSync3 } from "fs";
|
|
616
|
+
import path3 from "path";
|
|
617
|
+
function buildMcpEntry(params) {
|
|
618
|
+
return {
|
|
619
|
+
command: "npx",
|
|
620
|
+
args: ["-y", "@agentvalet/register", "mcp-server"],
|
|
621
|
+
env: {
|
|
622
|
+
AGENT_ID: params.agentId,
|
|
623
|
+
OWNER_ID: params.ownerId,
|
|
624
|
+
PROXY_URL: params.proxyUrl,
|
|
625
|
+
AGENT_PRIVATE_KEY_PATH: params.keyPath
|
|
626
|
+
}
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
async function mergeJsonFile(filePath, key, value) {
|
|
630
|
+
let existing = {};
|
|
631
|
+
if (existsSync3(filePath)) {
|
|
632
|
+
try {
|
|
633
|
+
const text = await readFile2(filePath, "utf8");
|
|
634
|
+
existing = JSON.parse(text);
|
|
635
|
+
} catch {
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
const mcpServers = existing.mcpServers ?? {};
|
|
639
|
+
mcpServers[key] = value;
|
|
640
|
+
existing.mcpServers = mcpServers;
|
|
641
|
+
await writeFile4(filePath, JSON.stringify(existing, null, 2) + "\n", "utf8");
|
|
642
|
+
}
|
|
643
|
+
async function writeIdeConfigs(params) {
|
|
644
|
+
const cwd = process.cwd();
|
|
645
|
+
const written = [];
|
|
646
|
+
const entry = buildMcpEntry(params);
|
|
647
|
+
const claudeMcpPath = path3.join(cwd, ".mcp.json");
|
|
648
|
+
if (existsSync3(claudeMcpPath) || existsSync3(path3.join(cwd, "CLAUDE.md"))) {
|
|
649
|
+
try {
|
|
650
|
+
await mergeJsonFile(claudeMcpPath, "agentvalet", entry);
|
|
651
|
+
written.push(".mcp.json");
|
|
652
|
+
} catch (err) {
|
|
653
|
+
console.warn(` Warning: could not write .mcp.json: ${err.message}`);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
const cursorDir = path3.join(cwd, ".cursor");
|
|
657
|
+
const cursorMcpPath = path3.join(cursorDir, "mcp.json");
|
|
658
|
+
if (existsSync3(cursorDir)) {
|
|
659
|
+
try {
|
|
660
|
+
await mkdir3(cursorDir, { recursive: true });
|
|
661
|
+
await mergeJsonFile(cursorMcpPath, "agentvalet", entry);
|
|
662
|
+
written.push(".cursor/mcp.json");
|
|
663
|
+
} catch (err) {
|
|
664
|
+
console.warn(` Warning: could not write .cursor/mcp.json: ${err.message}`);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
return written;
|
|
668
|
+
}
|
|
669
|
+
|
|
613
670
|
// src/commands/onboard.ts
|
|
614
671
|
import os from "os";
|
|
672
|
+
import path4 from "path";
|
|
615
673
|
async function runOnboard() {
|
|
616
674
|
console.log("");
|
|
617
675
|
console.log(chalk4.bold(" AgentValet \u2014 Agent Registration"));
|
|
@@ -744,15 +802,27 @@ async function registerAgentFlow(apiKey, ownerId) {
|
|
|
744
802
|
console.log(chalk4.dim(" Agent was registered \u2014 run again to save config locally."));
|
|
745
803
|
process.exit(1);
|
|
746
804
|
}
|
|
805
|
+
const ideResults = await writeIdeConfigs({
|
|
806
|
+
agentId: agent.agent_id,
|
|
807
|
+
ownerId,
|
|
808
|
+
proxyUrl: getStoredConfig().proxyUrl,
|
|
809
|
+
keyPath: path4.join(process.cwd(), ".agentvalet", "agent.key")
|
|
810
|
+
});
|
|
811
|
+
if (ideResults.length > 0) {
|
|
812
|
+
for (const r of ideResults) {
|
|
813
|
+
console.log(chalk4.dim(` MCP config written: ${r}`));
|
|
814
|
+
}
|
|
815
|
+
}
|
|
747
816
|
console.log("");
|
|
748
817
|
console.log(chalk4.bold.green(" \u2713 All done!"));
|
|
749
818
|
console.log("");
|
|
750
819
|
console.log(" Set these in your environment:");
|
|
751
820
|
console.log("");
|
|
752
821
|
console.log(formatEnvBlock({
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
822
|
+
AGENT_ID: agent.agent_id,
|
|
823
|
+
OWNER_ID: ownerId,
|
|
824
|
+
PROXY_URL: getStoredConfig().proxyUrl,
|
|
825
|
+
AGENT_PRIVATE_KEY_PATH: path4.join(process.cwd(), ".agentvalet", "agent.key")
|
|
756
826
|
}));
|
|
757
827
|
console.log("");
|
|
758
828
|
console.log(chalk4.dim(" Private key also saved to: .agentvalet/agent.key"));
|