@rk0429/agentic-relay 1.0.0 → 1.1.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.
Files changed (2) hide show
  1. package/dist/relay.mjs +40 -37
  2. package/package.json +1 -1
package/dist/relay.mjs CHANGED
@@ -654,9 +654,7 @@ ${input.prompt}`;
654
654
  } else {
655
655
  effectiveNativeSessionId = input.resumeSessionId;
656
656
  }
657
- return adapter.continueSession(effectiveNativeSessionId, effectivePrompt, {
658
- ...input.maxTurns !== void 0 ? { maxTurns: input.maxTurns } : {}
659
- });
657
+ return adapter.continueSession(effectiveNativeSessionId, effectivePrompt);
660
658
  } else {
661
659
  let mcpServers;
662
660
  if (childHttpUrl) {
@@ -670,7 +668,6 @@ ${input.prompt}`;
670
668
  agent: input.agent,
671
669
  systemPrompt: enhancedSystemPrompt,
672
670
  model: input.model,
673
- maxTurns: input.maxTurns,
674
671
  mcpContext: {
675
672
  parentSessionId: session.relaySessionId,
676
673
  depth: envContext.depth + 1,
@@ -798,9 +795,6 @@ var init_spawn_agent = __esm({
798
795
  model: z2.string().optional().describe(
799
796
  "Model to use (e.g., 'opus', 'sonnet', 'o3'). Passed to the backend CLI. Model availability varies by backend."
800
797
  ),
801
- maxTurns: z2.number().optional().describe(
802
- "Maximum agentic turns (tool-use cycles). Limits execution depth to prevent runaway agents."
803
- ),
804
798
  skillContext: z2.object({
805
799
  skillPath: z2.string().describe("Path to the skill directory (e.g., '.agents/skills/software-engineer/')"),
806
800
  subskill: z2.string().optional().describe("Specific subskill to activate within the skill")
@@ -1210,16 +1204,20 @@ var init_types = __esm({
1210
1204
  // src/mcp-server/response-formatter.ts
1211
1205
  import * as fs from "fs";
1212
1206
  import * as path from "path";
1213
- import * as os from "os";
1214
- function saveFullResponse(content, sessionId) {
1207
+ function resolveResponseDir(dir) {
1208
+ const target = dir ?? DEFAULT_RESPONSE_OUTPUT_DIR;
1209
+ return path.isAbsolute(target) ? target : path.resolve(process.cwd(), target);
1210
+ }
1211
+ function saveFullResponse(content, sessionId, responseOutputDir) {
1215
1212
  try {
1216
- const dir = sessionId ? path.join(RESPONSE_DIR, sessionId) : path.join(RESPONSE_DIR, `anonymous-${Date.now()}`);
1213
+ const baseDir = resolveResponseDir(responseOutputDir);
1214
+ const dir = sessionId ? path.join(baseDir, sessionId) : path.join(baseDir, `anonymous-${Date.now()}`);
1217
1215
  fs.mkdirSync(dir, { recursive: true });
1218
1216
  const filePath = path.join(dir, "response.txt");
1219
1217
  fs.writeFileSync(filePath, content, "utf-8");
1220
1218
  try {
1221
- const entries = fs.readdirSync(RESPONSE_DIR).map((name) => {
1222
- const fullPath = path.join(RESPONSE_DIR, name);
1219
+ const entries = fs.readdirSync(baseDir).map((name) => {
1220
+ const fullPath = path.join(baseDir, name);
1223
1221
  try {
1224
1222
  const stat = fs.statSync(fullPath);
1225
1223
  return { name, fullPath, mtimeMs: stat.mtimeMs };
@@ -1245,7 +1243,7 @@ async function processStdout(stdout, options) {
1245
1243
  if (stdout.length <= inlineSummaryLength) {
1246
1244
  return { text: stdout, truncated: false };
1247
1245
  }
1248
- const savedFilePath = saveFullResponse(stdout, options?.sessionId);
1246
+ const savedFilePath = saveFullResponse(stdout, options?.sessionId, options?.responseOutputDir);
1249
1247
  const summary = stdout.slice(0, inlineSummaryLength);
1250
1248
  const fileRef = savedFilePath ?? "(file save failed)";
1251
1249
  const footer = `...
@@ -1346,14 +1344,14 @@ ${JSON.stringify(sanitizedResult, null, 2)}
1346
1344
  </metadata>`);
1347
1345
  return { text: parts.join("\n"), isError };
1348
1346
  }
1349
- var STDERR_MAX_LENGTH, DEFAULT_INLINE_SUMMARY_LENGTH, MAX_SAVED_RESPONSES, RESPONSE_DIR;
1347
+ var STDERR_MAX_LENGTH, DEFAULT_INLINE_SUMMARY_LENGTH, MAX_SAVED_RESPONSES, DEFAULT_RESPONSE_OUTPUT_DIR;
1350
1348
  var init_response_formatter = __esm({
1351
1349
  "src/mcp-server/response-formatter.ts"() {
1352
1350
  "use strict";
1353
1351
  STDERR_MAX_LENGTH = 2e3;
1354
1352
  DEFAULT_INLINE_SUMMARY_LENGTH = 500;
1355
1353
  MAX_SAVED_RESPONSES = 100;
1356
- RESPONSE_DIR = path.join(os.tmpdir(), "agentic-relay-responses");
1354
+ DEFAULT_RESPONSE_OUTPUT_DIR = ".relay/responses";
1357
1355
  }
1358
1356
  });
1359
1357
 
@@ -1400,16 +1398,17 @@ var init_server = __esm({
1400
1398
  };
1401
1399
  MAX_CHILD_HTTP_SESSIONS = 100;
1402
1400
  RelayMCPServer = class {
1403
- constructor(registry2, sessionManager2, guardConfig, hooksEngine2, contextMonitor2, inlineSummaryLength) {
1401
+ constructor(registry2, sessionManager2, guardConfig, hooksEngine2, contextMonitor2, inlineSummaryLength, responseOutputDir) {
1404
1402
  this.registry = registry2;
1405
1403
  this.sessionManager = sessionManager2;
1406
1404
  this.hooksEngine = hooksEngine2;
1407
1405
  this.contextMonitor = contextMonitor2;
1408
1406
  this.inlineSummaryLength = inlineSummaryLength;
1407
+ this.responseOutputDir = responseOutputDir;
1409
1408
  this.guard = new RecursionGuard(guardConfig);
1410
1409
  this.backendSelector = new BackendSelector();
1411
1410
  this.server = new McpServer(
1412
- { name: "agentic-relay", version: "1.0.0" },
1411
+ { name: "agentic-relay", version: "1.1.1" },
1413
1412
  createMcpServerOptions()
1414
1413
  );
1415
1414
  this.registerTools(this.server);
@@ -1446,7 +1445,8 @@ var init_server = __esm({
1446
1445
  );
1447
1446
  const controlOptions = {
1448
1447
  inlineSummaryLength: this.inlineSummaryLength ?? DEFAULT_INLINE_SUMMARY_LENGTH,
1449
- sessionId: result.sessionId
1448
+ sessionId: result.sessionId,
1449
+ responseOutputDir: this.responseOutputDir
1450
1450
  };
1451
1451
  const { text, isError } = await formatSpawnAgentResponse(result, controlOptions);
1452
1452
  const callToolResult = {
@@ -1496,7 +1496,8 @@ var init_server = __esm({
1496
1496
  this._childHttpUrl
1497
1497
  );
1498
1498
  const controlOptions = {
1499
- inlineSummaryLength: this.inlineSummaryLength ?? DEFAULT_INLINE_SUMMARY_LENGTH
1499
+ inlineSummaryLength: this.inlineSummaryLength ?? DEFAULT_INLINE_SUMMARY_LENGTH,
1500
+ responseOutputDir: this.responseOutputDir
1500
1501
  };
1501
1502
  const { text, isError } = await formatParallelResponse(result, controlOptions);
1502
1503
  const callToolResult = {
@@ -1590,7 +1591,6 @@ var init_server = __esm({
1590
1591
  originalInput: spawnAgentInputSchema
1591
1592
  })).min(1).describe("Array of failed results with their original input configurations"),
1592
1593
  overrides: z5.object({
1593
- maxTurns: z5.number().optional(),
1594
1594
  preferredBackend: z5.enum(["claude", "codex", "gemini"]).optional()
1595
1595
  }).optional().describe("Parameter overrides applied to all retried agents")
1596
1596
  },
@@ -1599,7 +1599,6 @@ var init_server = __esm({
1599
1599
  const agents = params.failedResults.map((r) => {
1600
1600
  const input = { ...r.originalInput };
1601
1601
  if (params.overrides) {
1602
- if (params.overrides.maxTurns !== void 0) input.maxTurns = params.overrides.maxTurns;
1603
1602
  if (params.overrides.preferredBackend !== void 0) input.preferredBackend = params.overrides.preferredBackend;
1604
1603
  }
1605
1604
  return input;
@@ -1615,7 +1614,8 @@ var init_server = __esm({
1615
1614
  this._childHttpUrl
1616
1615
  );
1617
1616
  const controlOptions = {
1618
- inlineSummaryLength: this.inlineSummaryLength ?? DEFAULT_INLINE_SUMMARY_LENGTH
1617
+ inlineSummaryLength: this.inlineSummaryLength ?? DEFAULT_INLINE_SUMMARY_LENGTH,
1618
+ responseOutputDir: this.responseOutputDir
1619
1619
  };
1620
1620
  const { text, isError } = await formatParallelResponse(result, controlOptions);
1621
1621
  return {
@@ -1744,14 +1744,14 @@ var init_server = __esm({
1744
1744
  });
1745
1745
  this._httpServer = httpServer;
1746
1746
  await this.server.connect(httpTransport);
1747
- await new Promise((resolve2) => {
1747
+ await new Promise((resolve3) => {
1748
1748
  httpServer.listen(port, "127.0.0.1", () => {
1749
1749
  logger.info(`MCP server listening on http://localhost:${port}/mcp`);
1750
- resolve2();
1750
+ resolve3();
1751
1751
  });
1752
1752
  });
1753
- await new Promise((resolve2) => {
1754
- httpServer.on("close", resolve2);
1753
+ await new Promise((resolve3) => {
1754
+ httpServer.on("close", resolve3);
1755
1755
  });
1756
1756
  }
1757
1757
  /**
@@ -1781,7 +1781,7 @@ var init_server = __esm({
1781
1781
  sessionIdGenerator: () => randomUUID()
1782
1782
  });
1783
1783
  const server = new McpServer(
1784
- { name: "agentic-relay", version: "1.0.0" },
1784
+ { name: "agentic-relay", version: "1.1.1" },
1785
1785
  createMcpServerOptions()
1786
1786
  );
1787
1787
  this.registerTools(server);
@@ -1817,12 +1817,12 @@ var init_server = __esm({
1817
1817
  }
1818
1818
  });
1819
1819
  this._childHttpServer = httpServer;
1820
- await new Promise((resolve2) => {
1820
+ await new Promise((resolve3) => {
1821
1821
  httpServer.listen(0, "127.0.0.1", () => {
1822
1822
  const addr = httpServer.address();
1823
1823
  this._childHttpUrl = `http://127.0.0.1:${addr.port}/mcp`;
1824
1824
  logger.info(`Child MCP server listening on ${this._childHttpUrl}`);
1825
- resolve2();
1825
+ resolve3();
1826
1826
  });
1827
1827
  });
1828
1828
  }
@@ -1998,7 +1998,7 @@ var BaseAdapter = class _BaseAdapter {
1998
1998
  }
1999
1999
  return result.stdout.trim();
2000
2000
  }
2001
- async continueSession(_nativeSessionId, _prompt, _options) {
2001
+ async continueSession(_nativeSessionId, _prompt) {
2002
2002
  return {
2003
2003
  exitCode: 1,
2004
2004
  stdout: "",
@@ -2377,7 +2377,7 @@ var ClaudeAdapter = class extends BaseAdapter {
2377
2377
  if (timer !== void 0) clearTimeout(timer);
2378
2378
  }
2379
2379
  }
2380
- async continueSession(nativeSessionId, prompt, options) {
2380
+ async continueSession(nativeSessionId, prompt) {
2381
2381
  const timeoutMs = resolveClaudeSdkTimeoutMs();
2382
2382
  const abortController = new AbortController();
2383
2383
  const timer = timeoutMs !== void 0 ? setTimeout(() => abortController.abort(), timeoutMs) : void 0;
@@ -2387,7 +2387,6 @@ var ClaudeAdapter = class extends BaseAdapter {
2387
2387
  const queryOptions = {
2388
2388
  abortController,
2389
2389
  resume: nativeSessionId,
2390
- maxTurns: options?.maxTurns ?? 1,
2391
2390
  cwd: process.cwd(),
2392
2391
  strictMcpConfig: true
2393
2392
  };
@@ -2843,7 +2842,7 @@ ${prompt}`;
2843
2842
  };
2844
2843
  }
2845
2844
  }
2846
- async continueSession(nativeSessionId, prompt, _options) {
2845
+ async continueSession(nativeSessionId, prompt) {
2847
2846
  try {
2848
2847
  const { Codex } = await loadCodexSDK();
2849
2848
  const codex = new Codex();
@@ -3382,7 +3381,8 @@ var relayConfigSchema = z.object({
3382
3381
  maxDepth: z.number().int().positive(),
3383
3382
  maxCallsPerSession: z.number().int().positive(),
3384
3383
  timeoutSec: z.number().positive(),
3385
- inlineSummaryLength: z.number().int().positive().optional()
3384
+ inlineSummaryLength: z.number().int().positive().optional(),
3385
+ responseOutputDir: z.string().optional()
3386
3386
  }).optional(),
3387
3387
  telemetry: z.object({
3388
3388
  enabled: z.boolean()
@@ -4614,6 +4614,7 @@ function createMCPCommand(configManager2, registry2, sessionManager2, hooksEngin
4614
4614
  }
4615
4615
  let guardConfig;
4616
4616
  let inlineSummaryLength;
4617
+ let responseOutputDir;
4617
4618
  try {
4618
4619
  const config = await configManager2.getConfig();
4619
4620
  if (config.mcpServerMode) {
@@ -4623,6 +4624,7 @@ function createMCPCommand(configManager2, registry2, sessionManager2, hooksEngin
4623
4624
  timeoutSec: config.mcpServerMode.timeoutSec ?? 86400
4624
4625
  };
4625
4626
  inlineSummaryLength = config.mcpServerMode.inlineSummaryLength;
4627
+ responseOutputDir = config.mcpServerMode.responseOutputDir;
4626
4628
  }
4627
4629
  } catch {
4628
4630
  }
@@ -4634,7 +4636,8 @@ function createMCPCommand(configManager2, registry2, sessionManager2, hooksEngin
4634
4636
  guardConfig,
4635
4637
  hooksEngine2,
4636
4638
  contextMonitor2,
4637
- inlineSummaryLength
4639
+ inlineSummaryLength,
4640
+ responseOutputDir
4638
4641
  );
4639
4642
  await server.start({ transport, port });
4640
4643
  }
@@ -4796,7 +4799,7 @@ function createVersionCommand(registry2) {
4796
4799
  description: "Show relay and backend versions"
4797
4800
  },
4798
4801
  async run() {
4799
- const relayVersion = "1.0.0";
4802
+ const relayVersion = "1.1.1";
4800
4803
  console.log(`agentic-relay v${relayVersion}`);
4801
4804
  console.log("");
4802
4805
  console.log("Backends:");
@@ -5146,7 +5149,7 @@ void configManager.getConfig().then((config) => {
5146
5149
  var main = defineCommand10({
5147
5150
  meta: {
5148
5151
  name: "relay",
5149
- version: "1.0.0",
5152
+ version: "1.1.1",
5150
5153
  description: "Unified CLI proxy for Claude Code, Codex CLI, and Gemini CLI"
5151
5154
  },
5152
5155
  subCommands: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rk0429/agentic-relay",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
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",