@rk0429/agentic-relay 2.0.5 → 2.0.6

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/dist/relay.mjs +87 -26
  2. package/package.json +1 -1
package/dist/relay.mjs CHANGED
@@ -8442,7 +8442,7 @@ var init_server = __esm({
8442
8442
  this.agentEventStore
8443
8443
  );
8444
8444
  this.server = new McpServer(
8445
- { name: "agentic-relay", version: "2.0.5" },
8445
+ { name: "agentic-relay", version: "2.0.6" },
8446
8446
  createMcpServerOptions()
8447
8447
  );
8448
8448
  this.registerTools(this.server);
@@ -8460,6 +8460,8 @@ var init_server = __esm({
8460
8460
  purgeTimer;
8461
8461
  _childHttpServer;
8462
8462
  _childHttpUrl;
8463
+ _closePromise;
8464
+ _isClosed = false;
8463
8465
  /** URL for child agents to connect via HTTP. Available after start() in stdio mode. */
8464
8466
  get childHttpUrl() {
8465
8467
  return this._childHttpUrl;
@@ -8870,7 +8872,29 @@ var init_server = __esm({
8870
8872
  redirectToStderr();
8871
8873
  logger.info("Starting agentic-relay MCP server (stdio transport)...");
8872
8874
  const transport = new StdioServerTransport();
8873
- await this.server.connect(transport);
8875
+ const handleStdioDisconnect = () => {
8876
+ void transport.close().catch((error) => {
8877
+ const message = error instanceof Error ? error.message : String(error);
8878
+ logger.debug(`Failed to close stdio transport: ${message}`);
8879
+ void this.close();
8880
+ });
8881
+ };
8882
+ const cleanupStdioListeners = () => {
8883
+ process.stdin.off("end", handleStdioDisconnect);
8884
+ process.stdin.off("close", handleStdioDisconnect);
8885
+ };
8886
+ transport.onclose = () => {
8887
+ cleanupStdioListeners();
8888
+ void this.close();
8889
+ };
8890
+ process.stdin.once("end", handleStdioDisconnect);
8891
+ process.stdin.once("close", handleStdioDisconnect);
8892
+ try {
8893
+ await this.server.connect(transport);
8894
+ } catch (error) {
8895
+ cleanupStdioListeners();
8896
+ throw error;
8897
+ }
8874
8898
  await this.startChildHttpServer();
8875
8899
  return;
8876
8900
  }
@@ -8932,7 +8956,7 @@ var init_server = __esm({
8932
8956
  sessionIdGenerator: () => randomUUID()
8933
8957
  });
8934
8958
  const server = new McpServer(
8935
- { name: "agentic-relay", version: "2.0.5" },
8959
+ { name: "agentic-relay", version: "2.0.6" },
8936
8960
  createMcpServerOptions()
8937
8961
  );
8938
8962
  this.registerTools(server, childRelayContext);
@@ -8978,16 +9002,27 @@ var init_server = __esm({
8978
9002
  });
8979
9003
  }
8980
9004
  async close() {
8981
- this.sessionHealthMonitor.stop();
8982
- this.agentEventStore.cleanup();
8983
- clearInterval(this.purgeTimer);
8984
- if (this._childHttpServer) {
8985
- await new Promise((resolve3) => {
8986
- this._childHttpServer.close(() => resolve3());
8987
- });
8988
- this._childHttpServer = void 0;
8989
- this._childHttpUrl = void 0;
9005
+ if (this._isClosed) {
9006
+ return;
8990
9007
  }
9008
+ if (this._closePromise) {
9009
+ await this._closePromise;
9010
+ return;
9011
+ }
9012
+ this._closePromise = (async () => {
9013
+ this.sessionHealthMonitor.stop();
9014
+ this.agentEventStore.cleanup();
9015
+ clearInterval(this.purgeTimer);
9016
+ if (this._childHttpServer) {
9017
+ await new Promise((resolve3) => {
9018
+ this._childHttpServer.close(() => resolve3());
9019
+ });
9020
+ this._childHttpServer = void 0;
9021
+ this._childHttpUrl = void 0;
9022
+ }
9023
+ this._isClosed = true;
9024
+ })();
9025
+ await this._closePromise;
8991
9026
  }
8992
9027
  /** Exposed for testing and graceful shutdown */
8993
9028
  get httpServer() {
@@ -11061,20 +11096,46 @@ var CodexAdapter = class extends BaseAdapter {
11061
11096
  ...!authenticated ? { message: "codex authentication not configured" } : {}
11062
11097
  };
11063
11098
  }
11064
- buildCodexOptions(flags) {
11065
- if (!flags.mcpContext) {
11066
- return {};
11099
+ buildCodexMcpConfig(mcpServers) {
11100
+ if (!mcpServers || Object.keys(mcpServers).length === 0) {
11101
+ return void 0;
11067
11102
  }
11068
- const env = {};
11069
- for (const [key, value] of Object.entries(process.env)) {
11070
- if (value !== void 0) {
11071
- env[key] = value;
11103
+ const configServers = {};
11104
+ for (const [name, server] of Object.entries(mcpServers)) {
11105
+ if ("url" in server) {
11106
+ configServers[name] = {
11107
+ url: server.url,
11108
+ ...server.headers ? { headers: server.headers } : {}
11109
+ };
11110
+ } else {
11111
+ configServers[name] = {
11112
+ command: server.command,
11113
+ ...server.args ? { args: server.args } : {},
11114
+ ...server.env ? { env: server.env } : {}
11115
+ };
11072
11116
  }
11073
11117
  }
11074
- env.RELAY_TRACE_ID = flags.mcpContext.traceId;
11075
- env.RELAY_PARENT_SESSION_ID = flags.mcpContext.parentSessionId;
11076
- env.RELAY_DEPTH = String(flags.mcpContext.depth);
11077
- return { env };
11118
+ return { mcp_servers: configServers };
11119
+ }
11120
+ buildCodexOptions(flags) {
11121
+ const options = {};
11122
+ if (flags.mcpContext) {
11123
+ const env = {};
11124
+ for (const [key, value] of Object.entries(process.env)) {
11125
+ if (value !== void 0) {
11126
+ env[key] = value;
11127
+ }
11128
+ }
11129
+ env.RELAY_TRACE_ID = flags.mcpContext.traceId;
11130
+ env.RELAY_PARENT_SESSION_ID = flags.mcpContext.parentSessionId;
11131
+ env.RELAY_DEPTH = String(flags.mcpContext.depth);
11132
+ options.env = env;
11133
+ }
11134
+ const config = this.buildCodexMcpConfig(flags.mcpServers);
11135
+ if (config) {
11136
+ options.config = config;
11137
+ }
11138
+ return options;
11078
11139
  }
11079
11140
  mapFlags(flags) {
11080
11141
  const args = mapCommonToNative("codex", flags);
@@ -13372,7 +13433,7 @@ function createMCPCommand(configManager2, registry2, sessionManager2, hooksEngin
13372
13433
  responseOutputDir,
13373
13434
  relayConfig
13374
13435
  );
13375
- await server.start({ transport, port, currentVersion: "2.0.5" });
13436
+ await server.start({ transport, port, currentVersion: "2.0.6" });
13376
13437
  }
13377
13438
  })
13378
13439
  },
@@ -13532,7 +13593,7 @@ function createVersionCommand(registry2) {
13532
13593
  description: "Show relay and backend versions"
13533
13594
  },
13534
13595
  async run() {
13535
- const relayVersion = "2.0.5";
13596
+ const relayVersion = "2.0.6";
13536
13597
  console.log(`agentic-relay v${relayVersion}`);
13537
13598
  console.log("");
13538
13599
  console.log("Backends:");
@@ -13929,7 +13990,7 @@ var subCommandNames = /* @__PURE__ */ new Set(["claude", "codex", "gemini", "upd
13929
13990
  var main = defineCommand11({
13930
13991
  meta: {
13931
13992
  name: "relay",
13932
- version: "2.0.5",
13993
+ version: "2.0.6",
13933
13994
  description: "Unified CLI proxy for Claude Code, Codex CLI, and Gemini CLI"
13934
13995
  },
13935
13996
  args: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rk0429/agentic-relay",
3
- "version": "2.0.5",
3
+ "version": "2.0.6",
4
4
  "description": "Unified CLI proxy for Claude Code, Codex CLI, and Gemini CLI with MCP-based multi-layer sub-agent orchestration",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",