@agentvalet/register 0.3.8 → 0.4.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 +38 -31
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -806,22 +806,17 @@ Dashboard: ${proxyUrl.replace("api.", "app.")}
|
|
|
806
806
|
}
|
|
807
807
|
async function writeGlobalFrameworkConfigs(params) {
|
|
808
808
|
const written = [];
|
|
809
|
-
const
|
|
810
|
-
const codexConfigPath = path4.join(
|
|
811
|
-
if (existsSync4(
|
|
809
|
+
const codexDir = path4.join(os.homedir(), ".codex");
|
|
810
|
+
const codexConfigPath = path4.join(codexDir, "config.toml");
|
|
811
|
+
if (existsSync4(codexDir)) {
|
|
812
812
|
try {
|
|
813
|
-
const existing = await readFile2(codexConfigPath, "utf8");
|
|
814
|
-
if (!existing.includes("[
|
|
813
|
+
const existing = existsSync4(codexConfigPath) ? await readFile2(codexConfigPath, "utf8") : "";
|
|
814
|
+
if (!existing.includes("[mcp_servers.agentvalet]")) {
|
|
815
815
|
const addition = `
|
|
816
|
-
[
|
|
816
|
+
[mcp_servers.agentvalet]
|
|
817
817
|
command = "npx"
|
|
818
|
-
args = ["-y", "@agentvalet/mcp-server"]
|
|
819
|
-
|
|
820
|
-
[mcp.servers.agentvalet.env]
|
|
821
|
-
AGENT_ID = "${params.agentId}"
|
|
822
|
-
OWNER_ID = "${params.ownerId}"
|
|
823
|
-
PROXY_URL = "${params.proxyUrl}"
|
|
824
|
-
AGENT_PRIVATE_KEY = "${privateKeyEscaped}"
|
|
818
|
+
args = ["-y", "@agentvalet/register", "mcp-server"]
|
|
819
|
+
env = { AGENT_ID = "${params.agentId}", OWNER_ID = "${params.ownerId}", PROXY_URL = "${params.proxyUrl}", AGENT_PRIVATE_KEY_PATH = "${params.keyPath.replace(/\\/g, "/")}" }
|
|
825
820
|
`;
|
|
826
821
|
await appendFile3(codexConfigPath, addition, "utf8");
|
|
827
822
|
written.push("~/.codex/config.toml");
|
|
@@ -878,6 +873,14 @@ import os2 from "os";
|
|
|
878
873
|
import path5 from "path";
|
|
879
874
|
import prompts2 from "prompts";
|
|
880
875
|
import chalk5 from "chalk";
|
|
876
|
+
function tryBinary(cmd) {
|
|
877
|
+
try {
|
|
878
|
+
execSync2(`${cmd} --version`, { stdio: "ignore", timeout: 3e3 });
|
|
879
|
+
return true;
|
|
880
|
+
} catch {
|
|
881
|
+
return false;
|
|
882
|
+
}
|
|
883
|
+
}
|
|
881
884
|
function cursorInstalled() {
|
|
882
885
|
const home = os2.homedir();
|
|
883
886
|
const platform = process.platform;
|
|
@@ -891,21 +894,11 @@ function cursorInstalled() {
|
|
|
891
894
|
}
|
|
892
895
|
return existsSync5(path5.join(home, ".config", "Cursor")) || existsSync5("/usr/share/applications/cursor.desktop");
|
|
893
896
|
}
|
|
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
|
-
}
|
|
904
897
|
function detectFrameworks() {
|
|
905
898
|
const home = os2.homedir();
|
|
906
899
|
return {
|
|
907
|
-
codex: existsSync5(path5.join(home, ".codex"
|
|
908
|
-
claudeCode:
|
|
900
|
+
codex: existsSync5(path5.join(home, ".codex")) || tryBinary("codex"),
|
|
901
|
+
claudeCode: existsSync5(path5.join(home, ".claude")) || tryBinary("claude"),
|
|
909
902
|
cursor: existsSync5(path5.join(process.cwd(), ".cursor")) || cursorInstalled(),
|
|
910
903
|
openclaw: existsSync5(path5.join(home, ".openclaw"))
|
|
911
904
|
};
|
|
@@ -945,6 +938,7 @@ async function frameworkSetupConsent(detected) {
|
|
|
945
938
|
// src/commands/onboard.ts
|
|
946
939
|
import os3 from "os";
|
|
947
940
|
import path6 from "path";
|
|
941
|
+
import { writeFile as writeFile5 } from "fs/promises";
|
|
948
942
|
async function runOnboard() {
|
|
949
943
|
console.log("");
|
|
950
944
|
console.log(chalk6.bold(" AgentValet \u2014 Agent Registration"));
|
|
@@ -1114,11 +1108,13 @@ async function registerAgentFlow(apiKey, ownerId) {
|
|
|
1114
1108
|
spinner.fail(` Registration failed: ${err.message}`);
|
|
1115
1109
|
process.exit(1);
|
|
1116
1110
|
}
|
|
1111
|
+
const keyPath = path6.join(process.cwd(), ".agentvalet", "agent.key");
|
|
1112
|
+
const proxyUrl = getStoredConfig().proxyUrl;
|
|
1117
1113
|
try {
|
|
1118
1114
|
await writeLocalConfig({
|
|
1119
1115
|
agentId: agent.agent_id,
|
|
1120
1116
|
agentName: agent.agent_name,
|
|
1121
|
-
proxyUrl
|
|
1117
|
+
proxyUrl,
|
|
1122
1118
|
privateKeyPem: agent.private_key_pem
|
|
1123
1119
|
});
|
|
1124
1120
|
} catch (err) {
|
|
@@ -1126,6 +1122,17 @@ async function registerAgentFlow(apiKey, ownerId) {
|
|
|
1126
1122
|
console.log(chalk6.dim(" Agent was registered \u2014 run again to save config locally."));
|
|
1127
1123
|
process.exit(1);
|
|
1128
1124
|
}
|
|
1125
|
+
try {
|
|
1126
|
+
const envContent = [
|
|
1127
|
+
"# AgentValet \u2014 generated by agentvalet-register",
|
|
1128
|
+
`AGENTVALET_AGENT_ID=${agent.agent_id}`,
|
|
1129
|
+
`AGENTVALET_OWNER_ID=${ownerId}`,
|
|
1130
|
+
`AGENTVALET_API_URL=${proxyUrl}`,
|
|
1131
|
+
`AGENTVALET_PRIVATE_KEY_PATH=${keyPath}`
|
|
1132
|
+
].join("\n") + "\n";
|
|
1133
|
+
await writeFile5(path6.join(process.cwd(), ".env.agentvalet"), envContent, { encoding: "utf8", mode: 384 });
|
|
1134
|
+
} catch {
|
|
1135
|
+
}
|
|
1129
1136
|
const detected = detectFrameworks();
|
|
1130
1137
|
const shouldSetup = await frameworkSetupConsent(detected);
|
|
1131
1138
|
if (shouldSetup) {
|
|
@@ -1135,8 +1142,8 @@ async function registerAgentFlow(apiKey, ownerId) {
|
|
|
1135
1142
|
const ideResults = await writeIdeConfigs({
|
|
1136
1143
|
agentId: agent.agent_id,
|
|
1137
1144
|
ownerId,
|
|
1138
|
-
proxyUrl
|
|
1139
|
-
keyPath
|
|
1145
|
+
proxyUrl,
|
|
1146
|
+
keyPath,
|
|
1140
1147
|
detected
|
|
1141
1148
|
});
|
|
1142
1149
|
for (const r of ideResults) {
|
|
@@ -1145,8 +1152,8 @@ async function registerAgentFlow(apiKey, ownerId) {
|
|
|
1145
1152
|
const globalResults = await writeGlobalFrameworkConfigs({
|
|
1146
1153
|
agentId: agent.agent_id,
|
|
1147
1154
|
ownerId,
|
|
1148
|
-
proxyUrl
|
|
1149
|
-
|
|
1155
|
+
proxyUrl,
|
|
1156
|
+
keyPath
|
|
1150
1157
|
});
|
|
1151
1158
|
for (const r of globalResults) {
|
|
1152
1159
|
console.log(chalk6.green(` \u2713 ${r}`));
|
|
@@ -1199,7 +1206,7 @@ function collectScope(value, previous) {
|
|
|
1199
1206
|
return [...previous, value];
|
|
1200
1207
|
}
|
|
1201
1208
|
var program = new Command();
|
|
1202
|
-
program.name("agentvalet-register").description("Self-register an AI agent with AgentValet").version("0.
|
|
1209
|
+
program.name("agentvalet-register").description("Self-register an AI agent with AgentValet").version("0.4.0").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) => {
|
|
1203
1210
|
const isJson = !!opts.json;
|
|
1204
1211
|
let ownerId = opts.owner ?? process.env.AGENTVALET_OWNER ?? "";
|
|
1205
1212
|
let agentName = opts.name ?? "";
|