agent-gate-installer 1.3.0 → 1.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/bin/install.mjs +3 -61
- package/package.json +1 -1
package/bin/install.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { execSync } from "node:child_process";
|
|
4
|
-
import { existsSync, mkdirSync, readFileSync,
|
|
4
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync, rmSync } from "node:fs";
|
|
5
5
|
import { createInterface } from "node:readline";
|
|
6
6
|
import { join } from "node:path";
|
|
7
|
-
import { homedir, platform
|
|
7
|
+
import { homedir, platform } from "node:os";
|
|
8
8
|
|
|
9
9
|
const CLAUDE_HOME = join(homedir(), ".claude");
|
|
10
10
|
const INSTALL_DIR = join(CLAUDE_HOME, "agent-gate");
|
|
@@ -122,21 +122,6 @@ function mergeHooks(settings, venvPython) {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
function writeMcpJson(venvPython, directory) {
|
|
126
|
-
const mcpJsonPath = join(directory, ".mcp.json");
|
|
127
|
-
const config = {
|
|
128
|
-
mcpServers: {
|
|
129
|
-
"agent-gate": {
|
|
130
|
-
type: "stdio",
|
|
131
|
-
command: venvPython,
|
|
132
|
-
args: [join(INSTALL_DIR, "src", "agent_gate", "server.py")],
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
};
|
|
136
|
-
writeFileSync(mcpJsonPath, JSON.stringify(config, null, 4) + "\n", "utf8");
|
|
137
|
-
log(` + Wrote .mcp.json to ${directory}`);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
125
|
function registerMcpServer(settings, venvPython) {
|
|
141
126
|
settings.mcpServers = settings.mcpServers || {};
|
|
142
127
|
settings.mcpServers["agent-gate"] = {
|
|
@@ -144,39 +129,7 @@ function registerMcpServer(settings, venvPython) {
|
|
|
144
129
|
command: venvPython,
|
|
145
130
|
args: [join(INSTALL_DIR, "src", "agent_gate", "server.py")],
|
|
146
131
|
};
|
|
147
|
-
log(" + Registered agent-gate MCP server
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function patchWebMcpConfigs(venvPython) {
|
|
151
|
-
const tmp = tmpdir();
|
|
152
|
-
let patched = 0;
|
|
153
|
-
let files;
|
|
154
|
-
try {
|
|
155
|
-
files = readdirSync(tmp);
|
|
156
|
-
} catch {
|
|
157
|
-
return patched;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
for (const file of files) {
|
|
161
|
-
if (!file.startsWith("mcp-config-") || !file.endsWith(".json")) continue;
|
|
162
|
-
const filePath = join(tmp, file);
|
|
163
|
-
try {
|
|
164
|
-
const raw = readFileSync(filePath, "utf8");
|
|
165
|
-
const config = JSON.parse(raw);
|
|
166
|
-
if (config.mcpServers?.["agent-gate"]) continue;
|
|
167
|
-
config.mcpServers = config.mcpServers || {};
|
|
168
|
-
config.mcpServers["agent-gate"] = {
|
|
169
|
-
type: "stdio",
|
|
170
|
-
command: venvPython,
|
|
171
|
-
args: [join(INSTALL_DIR, "src", "agent_gate", "server.py")],
|
|
172
|
-
};
|
|
173
|
-
writeFileSync(filePath, JSON.stringify(config) + "\n", "utf8");
|
|
174
|
-
patched++;
|
|
175
|
-
} catch {
|
|
176
|
-
continue;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
return patched;
|
|
132
|
+
log(" + Registered agent-gate MCP server");
|
|
180
133
|
}
|
|
181
134
|
|
|
182
135
|
async function promptForToken() {
|
|
@@ -268,17 +221,6 @@ async function install() {
|
|
|
268
221
|
registerMcpServer(settings, venvPython);
|
|
269
222
|
writeSettings(settings);
|
|
270
223
|
|
|
271
|
-
writeMcpJson(venvPython, INSTALL_DIR);
|
|
272
|
-
const cwd = process.cwd();
|
|
273
|
-
if (cwd !== INSTALL_DIR && existsSync(join(cwd, "src", "agent_gate"))) {
|
|
274
|
-
writeMcpJson(venvPython, cwd);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
const webPatched = patchWebMcpConfigs(venvPython);
|
|
278
|
-
if (webPatched > 0) {
|
|
279
|
-
log(` + Patched ${webPatched} web session MCP config(s) in ${tmpdir()}`);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
224
|
log(" + Verifying installation...");
|
|
283
225
|
try {
|
|
284
226
|
run(`"${venvPython}" -c "from agent_gate.server import create_mcp; print('OK')"`);
|