@solongate/proxy 0.30.2 → 0.31.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 CHANGED
@@ -1,11 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  var __getOwnPropNames = Object.getOwnPropertyNames;
3
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
4
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
5
- }) : x)(function(x) {
6
- if (typeof require !== "undefined") return require.apply(this, arguments);
7
- throw Error('Dynamic require of "' + x + '" is not supported');
8
- });
9
3
  var __esm = (fn, res) => function __init() {
10
4
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
11
5
  };
@@ -540,13 +534,16 @@ function isAlreadyProtected(server) {
540
534
  }
541
535
  return false;
542
536
  }
543
- function wrapServer(serverName, server, policy) {
537
+ function wrapServer(serverName, server, policy, agentName) {
544
538
  const env = { ...server.env ?? {} };
545
539
  env.SOLONGATE_API_KEY = "${SOLONGATE_API_KEY}";
546
540
  const proxyArgs = ["-y", "@solongate/proxy@latest"];
547
541
  if (policy) {
548
542
  proxyArgs.push("--policy", policy);
549
543
  }
544
+ if (agentName) {
545
+ proxyArgs.push("--agent-name", agentName);
546
+ }
550
547
  proxyArgs.push("--verbose", "--", server.command, ...server.args ?? []);
551
548
  return {
552
549
  command: "npx",
@@ -820,8 +817,22 @@ function installCursorConfig(clientDir, guardCmd, auditCmd, _stopCmd, wrappedMcp
820
817
  changed = true;
821
818
  }
822
819
  if (wrappedMcpConfig) {
820
+ const cursorMcpConfig = { mcpServers: {} };
821
+ for (const [name, server] of Object.entries(wrappedMcpConfig.mcpServers)) {
822
+ const args = [...server.args ?? []];
823
+ const agentIdx = args.indexOf("--agent-name");
824
+ if (agentIdx >= 0 && agentIdx + 1 < args.length) {
825
+ args[agentIdx + 1] = "cursor";
826
+ } else {
827
+ const sepIdx = args.indexOf("--");
828
+ if (sepIdx >= 0) {
829
+ args.splice(sepIdx, 0, "--agent-name", "cursor");
830
+ }
831
+ }
832
+ cursorMcpConfig.mcpServers[name] = { ...server, args };
833
+ }
823
834
  const mcpPath = join(clientDir, "mcp.json");
824
- const mcpStr = JSON.stringify(wrappedMcpConfig, null, 2) + "\n";
835
+ const mcpStr = JSON.stringify(cursorMcpConfig, null, 2) + "\n";
825
836
  const existingMcp = existsSync4(mcpPath) ? readFileSync4(mcpPath, "utf-8") : "";
826
837
  if (mcpStr !== existingMcp) {
827
838
  writeFileSync2(mcpPath, mcpStr);
@@ -852,7 +863,19 @@ function installGeminiConfig(clientDir, guardCmd, auditCmd, _stopCmd, wrappedMcp
852
863
  }
853
864
  const merged = { ...existing };
854
865
  if (wrappedMcpConfig) {
855
- merged.mcpServers = wrappedMcpConfig.mcpServers;
866
+ const geminiMcp = {};
867
+ for (const [name, server] of Object.entries(wrappedMcpConfig.mcpServers)) {
868
+ const args = [...server.args ?? []];
869
+ const agentIdx = args.indexOf("--agent-name");
870
+ if (agentIdx >= 0 && agentIdx + 1 < args.length) {
871
+ args[agentIdx + 1] = "gemini-cli";
872
+ } else {
873
+ const sepIdx = args.indexOf("--");
874
+ if (sepIdx >= 0) args.splice(sepIdx, 0, "--agent-name", "gemini-cli");
875
+ }
876
+ geminiMcp[name] = { ...server, args };
877
+ }
878
+ merged.mcpServers = geminiMcp;
856
879
  }
857
880
  merged.hooks = {
858
881
  BeforeTool: [
@@ -6226,24 +6249,13 @@ var SolonGateProxy = class {
6226
6249
  if (this.server) {
6227
6250
  const clientVersion = this.server.getClientVersion();
6228
6251
  log2(`MCP clientInfo raw: ${JSON.stringify(clientVersion)}`);
6229
- try {
6230
- const fs = __require("fs");
6231
- const path = __require("path");
6232
- const debugDir = path.resolve(".solongate");
6233
- fs.mkdirSync(debugDir, { recursive: true });
6234
- fs.writeFileSync(path.join(debugDir, ".debug-clientinfo"), JSON.stringify({
6235
- clientVersion,
6236
- agentIdBefore: this.agentId,
6237
- agentNameBefore: this.agentName,
6238
- ts: Date.now()
6239
- }, null, 2));
6240
- } catch {
6241
- }
6242
- if (clientVersion?.name) {
6252
+ if (clientVersion?.name && !this.config.agentName) {
6243
6253
  const normalized = this.normalizeAgentName(clientVersion.name);
6244
6254
  this.agentId = normalized.id;
6245
6255
  this.agentName = normalized.name;
6246
6256
  log2(`Agent identified from MCP clientInfo: ${this.agentName} (raw: ${clientVersion.name})`);
6257
+ } else if (this.config.agentName) {
6258
+ log2(`Agent identity from --agent-name flag: ${this.agentName} (clientInfo: ${clientVersion?.name || "none"})`);
6247
6259
  }
6248
6260
  }
6249
6261
  };
package/dist/init.js CHANGED
@@ -118,13 +118,16 @@ function isAlreadyProtected(server) {
118
118
  }
119
119
  return false;
120
120
  }
121
- function wrapServer(serverName, server, policy) {
121
+ function wrapServer(serverName, server, policy, agentName) {
122
122
  const env = { ...server.env ?? {} };
123
123
  env.SOLONGATE_API_KEY = "${SOLONGATE_API_KEY}";
124
124
  const proxyArgs = ["-y", "@solongate/proxy@latest"];
125
125
  if (policy) {
126
126
  proxyArgs.push("--policy", policy);
127
127
  }
128
+ if (agentName) {
129
+ proxyArgs.push("--agent-name", agentName);
130
+ }
128
131
  proxyArgs.push("--verbose", "--", server.command, ...server.args ?? []);
129
132
  return {
130
133
  command: "npx",
@@ -400,8 +403,22 @@ function installCursorConfig(clientDir, guardCmd, auditCmd, _stopCmd, wrappedMcp
400
403
  changed = true;
401
404
  }
402
405
  if (wrappedMcpConfig) {
406
+ const cursorMcpConfig = { mcpServers: {} };
407
+ for (const [name, server] of Object.entries(wrappedMcpConfig.mcpServers)) {
408
+ const args = [...server.args ?? []];
409
+ const agentIdx = args.indexOf("--agent-name");
410
+ if (agentIdx >= 0 && agentIdx + 1 < args.length) {
411
+ args[agentIdx + 1] = "cursor";
412
+ } else {
413
+ const sepIdx = args.indexOf("--");
414
+ if (sepIdx >= 0) {
415
+ args.splice(sepIdx, 0, "--agent-name", "cursor");
416
+ }
417
+ }
418
+ cursorMcpConfig.mcpServers[name] = { ...server, args };
419
+ }
403
420
  const mcpPath = join(clientDir, "mcp.json");
404
- const mcpStr = JSON.stringify(wrappedMcpConfig, null, 2) + "\n";
421
+ const mcpStr = JSON.stringify(cursorMcpConfig, null, 2) + "\n";
405
422
  const existingMcp = existsSync(mcpPath) ? readFileSync(mcpPath, "utf-8") : "";
406
423
  if (mcpStr !== existingMcp) {
407
424
  writeFileSync(mcpPath, mcpStr);
@@ -432,7 +449,19 @@ function installGeminiConfig(clientDir, guardCmd, auditCmd, _stopCmd, wrappedMcp
432
449
  }
433
450
  const merged = { ...existing };
434
451
  if (wrappedMcpConfig) {
435
- merged.mcpServers = wrappedMcpConfig.mcpServers;
452
+ const geminiMcp = {};
453
+ for (const [name, server] of Object.entries(wrappedMcpConfig.mcpServers)) {
454
+ const args = [...server.args ?? []];
455
+ const agentIdx = args.indexOf("--agent-name");
456
+ if (agentIdx >= 0 && agentIdx + 1 < args.length) {
457
+ args[agentIdx + 1] = "gemini-cli";
458
+ } else {
459
+ const sepIdx = args.indexOf("--");
460
+ if (sepIdx >= 0) args.splice(sepIdx, 0, "--agent-name", "gemini-cli");
461
+ }
462
+ geminiMcp[name] = { ...server, args };
463
+ }
464
+ merged.mcpServers = geminiMcp;
436
465
  }
437
466
  merged.hooks = {
438
467
  BeforeTool: [
package/dist/lib.js CHANGED
@@ -1,10 +1,3 @@
1
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined") return require.apply(this, arguments);
5
- throw Error('Dynamic require of "' + x + '" is not supported');
6
- });
7
-
8
1
  // ../core/dist/index.js
9
2
  import { z } from "zod";
10
3
  var __defProp = Object.defineProperty;
@@ -4467,24 +4460,13 @@ var SolonGateProxy = class {
4467
4460
  if (this.server) {
4468
4461
  const clientVersion = this.server.getClientVersion();
4469
4462
  log2(`MCP clientInfo raw: ${JSON.stringify(clientVersion)}`);
4470
- try {
4471
- const fs = __require("fs");
4472
- const path = __require("path");
4473
- const debugDir = path.resolve(".solongate");
4474
- fs.mkdirSync(debugDir, { recursive: true });
4475
- fs.writeFileSync(path.join(debugDir, ".debug-clientinfo"), JSON.stringify({
4476
- clientVersion,
4477
- agentIdBefore: this.agentId,
4478
- agentNameBefore: this.agentName,
4479
- ts: Date.now()
4480
- }, null, 2));
4481
- } catch {
4482
- }
4483
- if (clientVersion?.name) {
4463
+ if (clientVersion?.name && !this.config.agentName) {
4484
4464
  const normalized = this.normalizeAgentName(clientVersion.name);
4485
4465
  this.agentId = normalized.id;
4486
4466
  this.agentName = normalized.name;
4487
4467
  log2(`Agent identified from MCP clientInfo: ${this.agentName} (raw: ${clientVersion.name})`);
4468
+ } else if (this.config.agentName) {
4469
+ log2(`Agent identity from --agent-name flag: ${this.agentName} (clientInfo: ${clientVersion?.name || "none"})`);
4488
4470
  }
4489
4471
  }
4490
4472
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solongate/proxy",
3
- "version": "0.30.2",
3
+ "version": "0.31.0",
4
4
  "description": "AI tool security proxy — protect any AI tool server with customizable policies, path/command constraints, rate limiting, and audit logging. Zero code changes required.",
5
5
  "type": "module",
6
6
  "bin": {