@agentvalet/register 0.4.16 → 0.4.18
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 +79 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -952,7 +952,8 @@ async function registerAgent2(params, apiKey) {
|
|
|
952
952
|
});
|
|
953
953
|
if (!response.ok) {
|
|
954
954
|
const error = await response.json().catch(() => ({}));
|
|
955
|
-
|
|
955
|
+
const detail = error.detail ? ` \u2014 ${error.detail}` : "";
|
|
956
|
+
throw new Error(`Agent registration failed: ${response.status} ${error.error ?? ""}${detail}`);
|
|
956
957
|
}
|
|
957
958
|
return response.json();
|
|
958
959
|
} catch (err) {
|
|
@@ -1763,7 +1764,8 @@ function injectCommand() {
|
|
|
1763
1764
|
import { Command as Command4 } from "commander";
|
|
1764
1765
|
import chalk11 from "chalk";
|
|
1765
1766
|
import { existsSync as existsSync7, readFileSync as readFileSync4, writeFileSync as writeFileSync3, rmSync } from "fs";
|
|
1766
|
-
import { resolve as resolve3 } from "path";
|
|
1767
|
+
import { resolve as resolve3, join as join2 } from "path";
|
|
1768
|
+
import { homedir as homedir2 } from "os";
|
|
1767
1769
|
var CLAUDE_START2 = "<!-- agentvalet:start -->";
|
|
1768
1770
|
var CLAUDE_END2 = "<!-- agentvalet:end -->";
|
|
1769
1771
|
var HOOK_MARKER2 = "agentvalet/register refresh";
|
|
@@ -1795,20 +1797,61 @@ function stripSettingsJson() {
|
|
|
1795
1797
|
} catch {
|
|
1796
1798
|
}
|
|
1797
1799
|
}
|
|
1798
|
-
function stripMcpJson() {
|
|
1799
|
-
|
|
1800
|
-
if (!existsSync7(path8)) return;
|
|
1800
|
+
function stripMcpJson(filePath, options = {}) {
|
|
1801
|
+
if (!existsSync7(filePath)) return false;
|
|
1801
1802
|
try {
|
|
1802
|
-
const config = JSON.parse(readFileSync4(
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1803
|
+
const config = JSON.parse(readFileSync4(filePath, "utf-8"));
|
|
1804
|
+
let removed = false;
|
|
1805
|
+
if (options.wrapped === false) {
|
|
1806
|
+
if (config["agentvalet"] !== void 0) {
|
|
1807
|
+
delete config["agentvalet"];
|
|
1808
|
+
removed = true;
|
|
1809
|
+
}
|
|
1810
|
+
} else {
|
|
1811
|
+
const servers = config.mcpServers ?? {};
|
|
1812
|
+
if (servers["agentvalet"] !== void 0) {
|
|
1813
|
+
delete servers["agentvalet"];
|
|
1814
|
+
config.mcpServers = servers;
|
|
1815
|
+
removed = true;
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
if (removed) {
|
|
1819
|
+
writeFileSync3(filePath, JSON.stringify(config, null, 2) + "\n", "utf-8");
|
|
1820
|
+
}
|
|
1821
|
+
return removed;
|
|
1807
1822
|
} catch {
|
|
1823
|
+
return false;
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1826
|
+
function stripCodexToml() {
|
|
1827
|
+
const path8 = join2(homedir2(), ".codex", "config.toml");
|
|
1828
|
+
if (!existsSync7(path8)) return false;
|
|
1829
|
+
try {
|
|
1830
|
+
const content = readFileSync4(path8, "utf-8");
|
|
1831
|
+
if (!content.includes("[mcp_servers.agentvalet]")) return false;
|
|
1832
|
+
const stripped = content.replace(
|
|
1833
|
+
/\r?\n?\[mcp_servers\.agentvalet\][\s\S]*?(?=\r?\n\[|\r?\n*$)/,
|
|
1834
|
+
""
|
|
1835
|
+
);
|
|
1836
|
+
writeFileSync3(path8, stripped.replace(/(\r?\n){3,}/g, "\n\n").trimEnd() + "\n", "utf-8");
|
|
1837
|
+
return true;
|
|
1838
|
+
} catch {
|
|
1839
|
+
return false;
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
function isAgentValetGeneratedDoc(filePath, markers) {
|
|
1843
|
+
if (!existsSync7(filePath)) return false;
|
|
1844
|
+
try {
|
|
1845
|
+
const content = readFileSync4(filePath, "utf-8");
|
|
1846
|
+
const firstLine = content.split(/\r?\n/).find((l) => l.trim().length > 0) ?? "";
|
|
1847
|
+
return markers.some((m) => firstLine.startsWith(m));
|
|
1848
|
+
} catch {
|
|
1849
|
+
return false;
|
|
1808
1850
|
}
|
|
1809
1851
|
}
|
|
1810
1852
|
function cleanLocally() {
|
|
1811
1853
|
const removed = [];
|
|
1854
|
+
const stripped = [];
|
|
1812
1855
|
const r = (p) => {
|
|
1813
1856
|
const abs = resolve3(p);
|
|
1814
1857
|
if (existsSync7(abs)) {
|
|
@@ -1816,6 +1859,12 @@ function cleanLocally() {
|
|
|
1816
1859
|
removed.push(abs);
|
|
1817
1860
|
}
|
|
1818
1861
|
};
|
|
1862
|
+
const rAbs = (abs) => {
|
|
1863
|
+
if (existsSync7(abs)) {
|
|
1864
|
+
rmSync(abs, { recursive: true, force: true });
|
|
1865
|
+
removed.push(abs);
|
|
1866
|
+
}
|
|
1867
|
+
};
|
|
1819
1868
|
if (existsSync7(AGENT_KEY_PATH)) {
|
|
1820
1869
|
rmSync(AGENT_KEY_PATH, { force: true });
|
|
1821
1870
|
removed.push(AGENT_KEY_PATH);
|
|
@@ -1828,14 +1877,32 @@ function cleanLocally() {
|
|
|
1828
1877
|
r(".agentvalet");
|
|
1829
1878
|
r("agentvalet.key");
|
|
1830
1879
|
r(".claude/agentvalet-permissions.md");
|
|
1880
|
+
r("AGENTVALET.md");
|
|
1881
|
+
r(".factory/droids/agentvalet.yaml");
|
|
1882
|
+
r(".factory/droids/agentvalet-reliability.yaml");
|
|
1883
|
+
r(".factory/commands/av-status.md");
|
|
1884
|
+
r(".factory/commands/av-register.md");
|
|
1885
|
+
const agentsMd = resolve3("AGENTS.md");
|
|
1886
|
+
if (isAgentValetGeneratedDoc(agentsMd, ["# AgentValet"])) rAbs(agentsMd);
|
|
1887
|
+
const skillMd = resolve3("SKILL.md");
|
|
1888
|
+
if (isAgentValetGeneratedDoc(skillMd, ["# AgentValet"])) rAbs(skillMd);
|
|
1889
|
+
if (stripMcpJson(resolve3(".mcp.json"))) stripped.push(".mcp.json");
|
|
1890
|
+
if (stripMcpJson(resolve3(".cursor/mcp.json"))) stripped.push(".cursor/mcp.json");
|
|
1891
|
+
if (stripMcpJson(resolve3(".factory/mcp.json"), { wrapped: false })) stripped.push(".factory/mcp.json");
|
|
1892
|
+
const homeFactoryMcp = join2(homedir2(), ".factory", "mcp.json");
|
|
1893
|
+
if (stripMcpJson(homeFactoryMcp, { wrapped: false })) stripped.push("~/.factory/mcp.json");
|
|
1894
|
+
if (stripCodexToml()) stripped.push("~/.codex/config.toml");
|
|
1831
1895
|
stripClaudeMd();
|
|
1832
1896
|
stripSettingsJson();
|
|
1833
|
-
|
|
1897
|
+
stripped.push("CLAUDE.md", ".claude/settings.local.json");
|
|
1834
1898
|
if (removed.length > 0) {
|
|
1835
1899
|
console.log(chalk11.green(" \u2713 Removed files:"));
|
|
1836
1900
|
for (const f of removed) console.log(chalk11.dim(` ${f}`));
|
|
1837
1901
|
}
|
|
1838
|
-
|
|
1902
|
+
if (stripped.length > 0) {
|
|
1903
|
+
console.log(chalk11.green(" \u2713 Stripped agentvalet entries from:"));
|
|
1904
|
+
for (const f of stripped) console.log(chalk11.dim(` ${f}`));
|
|
1905
|
+
}
|
|
1839
1906
|
}
|
|
1840
1907
|
var SSE_READ_TIMEOUT_MS = 25e3;
|
|
1841
1908
|
async function pollForApproval(apiUrl, revocationToken, timeoutMs) {
|