agent-gate-installer 1.1.1 → 1.2.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.
Files changed (2) hide show
  1. package/bin/install.mjs +40 -3
  2. 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, writeFileSync, rmSync } from "node:fs";
4
+ import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync, rmSync } from "node:fs";
5
5
  import { createInterface } from "node:readline";
6
6
  import { join } from "node:path";
7
- import { homedir, platform } from "node:os";
7
+ import { homedir, platform, tmpdir } from "node:os";
8
8
 
9
9
  const CLAUDE_HOME = join(homedir(), ".claude");
10
10
  const INSTALL_DIR = join(CLAUDE_HOME, "agent-gate");
@@ -129,7 +129,39 @@ function registerMcpServer(settings, venvPython) {
129
129
  command: venvPython,
130
130
  args: [join(INSTALL_DIR, "src", "agent_gate", "server.py")],
131
131
  };
132
- log(" + Registered agent-gate MCP server");
132
+ log(" + Registered agent-gate MCP server in settings.json");
133
+ }
134
+
135
+ function patchWebMcpConfigs(venvPython) {
136
+ const tmp = tmpdir();
137
+ let patched = 0;
138
+ let files;
139
+ try {
140
+ files = readdirSync(tmp);
141
+ } catch {
142
+ return patched;
143
+ }
144
+
145
+ for (const file of files) {
146
+ if (!file.startsWith("mcp-config-") || !file.endsWith(".json")) continue;
147
+ const filePath = join(tmp, file);
148
+ try {
149
+ const raw = readFileSync(filePath, "utf8");
150
+ const config = JSON.parse(raw);
151
+ if (config.mcpServers?.["agent-gate"]) continue;
152
+ config.mcpServers = config.mcpServers || {};
153
+ config.mcpServers["agent-gate"] = {
154
+ type: "stdio",
155
+ command: venvPython,
156
+ args: [join(INSTALL_DIR, "src", "agent_gate", "server.py")],
157
+ };
158
+ writeFileSync(filePath, JSON.stringify(config) + "\n", "utf8");
159
+ patched++;
160
+ } catch {
161
+ continue;
162
+ }
163
+ }
164
+ return patched;
133
165
  }
134
166
 
135
167
  async function promptForToken() {
@@ -221,6 +253,11 @@ async function install() {
221
253
  registerMcpServer(settings, venvPython);
222
254
  writeSettings(settings);
223
255
 
256
+ const webPatched = patchWebMcpConfigs(venvPython);
257
+ if (webPatched > 0) {
258
+ log(` + Patched ${webPatched} web session MCP config(s) in ${tmpdir()}`);
259
+ }
260
+
224
261
  log(" + Verifying installation...");
225
262
  try {
226
263
  run(`"${venvPython}" -c "from agent_gate.server import create_mcp; print('OK')"`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-gate-installer",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "One-command installer for agent-gate prompt evaluation gate",
5
5
  "type": "module",
6
6
  "bin": {