@rk0429/agentic-relay 0.16.3 → 1.0.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/dist/relay.mjs +27 -142
  2. package/package.json +1 -1
package/dist/relay.mjs CHANGED
@@ -817,13 +817,7 @@ var init_spawn_agent = __esm({
817
817
  taskInstructionPath: z2.string().optional().describe(
818
818
  "Path to a file containing task instructions. Content is prepended to the prompt. Path is resolved relative to the project root and validated against path traversal."
819
819
  ),
820
- label: z2.string().optional().describe("Human-readable label for identifying this agent in parallel results and logs."),
821
- maxResponseLength: z2.number().int().positive().optional().describe(
822
- "Maximum response length in characters. When exceeded, response is truncated or summarized based on responseMode."
823
- ),
824
- responseMode: z2.enum(["truncate", "summarize"]).optional().describe(
825
- "How to handle responses exceeding maxResponseLength. 'truncate' (default) cuts at limit with file save. 'summarize' uses AI to condense."
826
- )
820
+ label: z2.string().optional().describe("Human-readable label for identifying this agent in parallel results and logs.")
827
821
  });
828
822
  }
829
823
  });
@@ -1213,70 +1207,6 @@ var init_types = __esm({
1213
1207
  }
1214
1208
  });
1215
1209
 
1216
- // src/mcp-server/response-summarizer.ts
1217
- async function loadClaudeSDK2() {
1218
- return await import("@anthropic-ai/claude-agent-sdk");
1219
- }
1220
- function buildCleanEnv() {
1221
- const env = {};
1222
- for (const [key, value] of Object.entries(process.env)) {
1223
- if (value !== void 0 && !CLAUDE_NESTING_ENV_VARS2.includes(key)) {
1224
- env[key] = value;
1225
- }
1226
- }
1227
- return env;
1228
- }
1229
- async function summarizeResponse(text, targetLength) {
1230
- const { query } = await loadClaudeSDK2();
1231
- const prompt = `Summarize the following text in ${targetLength} characters or less. Prioritize:
1232
- 1. Key deliverables, artifacts, and file changes
1233
- 2. Important decisions and conclusions
1234
- 3. Action items and next steps
1235
-
1236
- Preserve technical details (file paths, function names, error messages) when possible.
1237
-
1238
- <text>
1239
- ${text}
1240
- </text>`;
1241
- const q = query({
1242
- prompt,
1243
- options: {
1244
- model: "haiku",
1245
- maxTurns: 1,
1246
- env: buildCleanEnv(),
1247
- cwd: process.cwd(),
1248
- permissionMode: "bypassPermissions",
1249
- allowDangerouslySkipPermissions: true
1250
- }
1251
- });
1252
- let resultText = "";
1253
- for await (const message of q) {
1254
- if (message.type === "result") {
1255
- if (message.subtype === "success") {
1256
- resultText = message.result;
1257
- } else {
1258
- const errors = message.errors;
1259
- throw new Error(`Summarization failed: ${errors?.join("; ") ?? "unknown error"}`);
1260
- }
1261
- }
1262
- }
1263
- if (!resultText) {
1264
- throw new Error("No result from summarization");
1265
- }
1266
- return resultText;
1267
- }
1268
- var CLAUDE_NESTING_ENV_VARS2;
1269
- var init_response_summarizer = __esm({
1270
- "src/mcp-server/response-summarizer.ts"() {
1271
- "use strict";
1272
- CLAUDE_NESTING_ENV_VARS2 = [
1273
- "CLAUDECODE",
1274
- "CLAUDE_CODE_SSE_PORT",
1275
- "CLAUDE_CODE_ENTRYPOINT"
1276
- ];
1277
- }
1278
- });
1279
-
1280
1210
  // src/mcp-server/response-formatter.ts
1281
1211
  import * as fs from "fs";
1282
1212
  import * as path from "path";
@@ -1311,28 +1241,17 @@ function saveFullResponse(content, sessionId) {
1311
1241
  }
1312
1242
  }
1313
1243
  async function processStdout(stdout, options) {
1314
- const maxLength = options?.maxLength ?? STDOUT_DEFAULT_MAX_LENGTH;
1315
- const mode = options?.mode ?? "truncate";
1316
- if (stdout.length <= maxLength) {
1244
+ const inlineSummaryLength = options?.inlineSummaryLength ?? DEFAULT_INLINE_SUMMARY_LENGTH;
1245
+ if (stdout.length <= inlineSummaryLength) {
1317
1246
  return { text: stdout, truncated: false };
1318
1247
  }
1319
1248
  const savedFilePath = saveFullResponse(stdout, options?.sessionId);
1320
- const savedInfo = savedFilePath ? ` Full response saved to: ${savedFilePath}` : "";
1321
- if (mode === "summarize") {
1322
- try {
1323
- const summary = await summarizeResponse(stdout, maxLength);
1324
- const footer2 = `
1325
-
1326
- [RESPONSE SUMMARIZED: original ${stdout.length} chars exceeded limit ${maxLength} chars.${savedInfo}]`;
1327
- return { text: summary + footer2, truncated: true, savedFilePath };
1328
- } catch {
1329
- }
1330
- }
1331
- const truncated = stdout.slice(0, maxLength);
1332
- const footer = `
1249
+ const summary = stdout.slice(0, inlineSummaryLength);
1250
+ const fileRef = savedFilePath ?? "(file save failed)";
1251
+ const footer = `...
1333
1252
 
1334
- [RESPONSE TRUNCATED: original ${stdout.length} chars exceeded limit ${maxLength} chars.${savedInfo}]`;
1335
- return { text: truncated + footer, truncated: true, savedFilePath };
1253
+ [FULL RESPONSE: ${stdout.length} chars \u2192 ${fileRef}]`;
1254
+ return { text: summary + footer, truncated: true, savedFilePath };
1336
1255
  }
1337
1256
  function truncateStderr(stderr) {
1338
1257
  if (!stderr) return stderr;
@@ -1388,7 +1307,7 @@ ${JSON.stringify(result.metadata, null, 2)}
1388
1307
  }
1389
1308
  return { text, isError };
1390
1309
  }
1391
- async function formatParallelResponse(result, options, perAgentOptions) {
1310
+ async function formatParallelResponse(result, options) {
1392
1311
  const isError = result.failureCount === result.totalCount;
1393
1312
  const parts = [];
1394
1313
  if (result.hasConflicts && result.conflicts) {
@@ -1408,7 +1327,7 @@ async function formatParallelResponse(result, options, perAgentOptions) {
1408
1327
  const duration = r.metadata?.durationMs !== void 0 ? `${(r.metadata.durationMs / 1e3).toFixed(1)}s` : "?s";
1409
1328
  if (r.exitCode === 0) {
1410
1329
  parts.push(`--- Agent ${r.index}${labelPart} (${backend}, ${duration}) SUCCESS ---`);
1411
- const agentOptions = perAgentOptions?.get(r.index) ?? options;
1330
+ const agentOptions = { ...options, sessionId: r.sessionId };
1412
1331
  const processed = await processStdout(r.stdout || "", agentOptions);
1413
1332
  parts.push(processed.text || "(no output)");
1414
1333
  } else {
@@ -1427,13 +1346,12 @@ ${JSON.stringify(sanitizedResult, null, 2)}
1427
1346
  </metadata>`);
1428
1347
  return { text: parts.join("\n"), isError };
1429
1348
  }
1430
- var STDERR_MAX_LENGTH, STDOUT_DEFAULT_MAX_LENGTH, MAX_SAVED_RESPONSES, RESPONSE_DIR;
1349
+ var STDERR_MAX_LENGTH, DEFAULT_INLINE_SUMMARY_LENGTH, MAX_SAVED_RESPONSES, RESPONSE_DIR;
1431
1350
  var init_response_formatter = __esm({
1432
1351
  "src/mcp-server/response-formatter.ts"() {
1433
1352
  "use strict";
1434
- init_response_summarizer();
1435
1353
  STDERR_MAX_LENGTH = 2e3;
1436
- STDOUT_DEFAULT_MAX_LENGTH = 2e4;
1354
+ DEFAULT_INLINE_SUMMARY_LENGTH = 500;
1437
1355
  MAX_SAVED_RESPONSES = 100;
1438
1356
  RESPONSE_DIR = path.join(os.tmpdir(), "agentic-relay-responses");
1439
1357
  }
@@ -1482,16 +1400,16 @@ var init_server = __esm({
1482
1400
  };
1483
1401
  MAX_CHILD_HTTP_SESSIONS = 100;
1484
1402
  RelayMCPServer = class {
1485
- constructor(registry2, sessionManager2, guardConfig, hooksEngine2, contextMonitor2, defaultMaxResponseLength) {
1403
+ constructor(registry2, sessionManager2, guardConfig, hooksEngine2, contextMonitor2, inlineSummaryLength) {
1486
1404
  this.registry = registry2;
1487
1405
  this.sessionManager = sessionManager2;
1488
1406
  this.hooksEngine = hooksEngine2;
1489
1407
  this.contextMonitor = contextMonitor2;
1490
- this.defaultMaxResponseLength = defaultMaxResponseLength;
1408
+ this.inlineSummaryLength = inlineSummaryLength;
1491
1409
  this.guard = new RecursionGuard(guardConfig);
1492
1410
  this.backendSelector = new BackendSelector();
1493
1411
  this.server = new McpServer(
1494
- { name: "agentic-relay", version: "0.16.3" },
1412
+ { name: "agentic-relay", version: "1.0.0" },
1495
1413
  createMcpServerOptions()
1496
1414
  );
1497
1415
  this.registerTools(this.server);
@@ -1527,8 +1445,7 @@ var init_server = __esm({
1527
1445
  this._childHttpUrl
1528
1446
  );
1529
1447
  const controlOptions = {
1530
- maxLength: params.maxResponseLength ?? this.defaultMaxResponseLength ?? STDOUT_DEFAULT_MAX_LENGTH,
1531
- mode: params.responseMode ?? "truncate",
1448
+ inlineSummaryLength: this.inlineSummaryLength ?? DEFAULT_INLINE_SUMMARY_LENGTH,
1532
1449
  sessionId: result.sessionId
1533
1450
  };
1534
1451
  const { text, isError } = await formatSpawnAgentResponse(result, controlOptions);
@@ -1579,25 +1496,9 @@ var init_server = __esm({
1579
1496
  this._childHttpUrl
1580
1497
  );
1581
1498
  const controlOptions = {
1582
- maxLength: this.defaultMaxResponseLength ?? STDOUT_DEFAULT_MAX_LENGTH,
1583
- mode: "truncate"
1499
+ inlineSummaryLength: this.inlineSummaryLength ?? DEFAULT_INLINE_SUMMARY_LENGTH
1584
1500
  };
1585
- const perAgentOptions = /* @__PURE__ */ new Map();
1586
- for (let i = 0; i < agents.length; i++) {
1587
- const agent = agents[i];
1588
- if (agent.maxResponseLength !== void 0 || agent.responseMode !== void 0) {
1589
- perAgentOptions.set(i, {
1590
- maxLength: agent.maxResponseLength ?? controlOptions.maxLength,
1591
- mode: agent.responseMode ?? controlOptions.mode,
1592
- sessionId: result.results[i]?.sessionId
1593
- });
1594
- }
1595
- }
1596
- const { text, isError } = await formatParallelResponse(
1597
- result,
1598
- controlOptions,
1599
- perAgentOptions.size > 0 ? perAgentOptions : void 0
1600
- );
1501
+ const { text, isError } = await formatParallelResponse(result, controlOptions);
1601
1502
  const callToolResult = {
1602
1503
  content: [{ type: "text", text }],
1603
1504
  isError
@@ -1714,25 +1615,9 @@ var init_server = __esm({
1714
1615
  this._childHttpUrl
1715
1616
  );
1716
1617
  const controlOptions = {
1717
- maxLength: this.defaultMaxResponseLength ?? STDOUT_DEFAULT_MAX_LENGTH,
1718
- mode: "truncate"
1618
+ inlineSummaryLength: this.inlineSummaryLength ?? DEFAULT_INLINE_SUMMARY_LENGTH
1719
1619
  };
1720
- const perAgentOptions = /* @__PURE__ */ new Map();
1721
- for (let i = 0; i < agents.length; i++) {
1722
- const agent = agents[i];
1723
- if (agent.maxResponseLength !== void 0 || agent.responseMode !== void 0) {
1724
- perAgentOptions.set(i, {
1725
- maxLength: agent.maxResponseLength ?? controlOptions.maxLength,
1726
- mode: agent.responseMode ?? controlOptions.mode,
1727
- sessionId: result.results[i]?.sessionId
1728
- });
1729
- }
1730
- }
1731
- const { text, isError } = await formatParallelResponse(
1732
- result,
1733
- controlOptions,
1734
- perAgentOptions.size > 0 ? perAgentOptions : void 0
1735
- );
1620
+ const { text, isError } = await formatParallelResponse(result, controlOptions);
1736
1621
  return {
1737
1622
  content: [{ type: "text", text }],
1738
1623
  isError
@@ -1896,7 +1781,7 @@ var init_server = __esm({
1896
1781
  sessionIdGenerator: () => randomUUID()
1897
1782
  });
1898
1783
  const server = new McpServer(
1899
- { name: "agentic-relay", version: "0.16.3" },
1784
+ { name: "agentic-relay", version: "1.0.0" },
1900
1785
  createMcpServerOptions()
1901
1786
  );
1902
1787
  this.registerTools(server);
@@ -3497,7 +3382,7 @@ var relayConfigSchema = z.object({
3497
3382
  maxDepth: z.number().int().positive(),
3498
3383
  maxCallsPerSession: z.number().int().positive(),
3499
3384
  timeoutSec: z.number().positive(),
3500
- maxResponseLength: z.number().int().positive().optional()
3385
+ inlineSummaryLength: z.number().int().positive().optional()
3501
3386
  }).optional(),
3502
3387
  telemetry: z.object({
3503
3388
  enabled: z.boolean()
@@ -4728,7 +4613,7 @@ function createMCPCommand(configManager2, registry2, sessionManager2, hooksEngin
4728
4613
  return;
4729
4614
  }
4730
4615
  let guardConfig;
4731
- let defaultMaxResponseLength;
4616
+ let inlineSummaryLength;
4732
4617
  try {
4733
4618
  const config = await configManager2.getConfig();
4734
4619
  if (config.mcpServerMode) {
@@ -4737,7 +4622,7 @@ function createMCPCommand(configManager2, registry2, sessionManager2, hooksEngin
4737
4622
  maxCallsPerSession: config.mcpServerMode.maxCallsPerSession ?? 20,
4738
4623
  timeoutSec: config.mcpServerMode.timeoutSec ?? 86400
4739
4624
  };
4740
- defaultMaxResponseLength = config.mcpServerMode.maxResponseLength;
4625
+ inlineSummaryLength = config.mcpServerMode.inlineSummaryLength;
4741
4626
  }
4742
4627
  } catch {
4743
4628
  }
@@ -4749,7 +4634,7 @@ function createMCPCommand(configManager2, registry2, sessionManager2, hooksEngin
4749
4634
  guardConfig,
4750
4635
  hooksEngine2,
4751
4636
  contextMonitor2,
4752
- defaultMaxResponseLength
4637
+ inlineSummaryLength
4753
4638
  );
4754
4639
  await server.start({ transport, port });
4755
4640
  }
@@ -4911,7 +4796,7 @@ function createVersionCommand(registry2) {
4911
4796
  description: "Show relay and backend versions"
4912
4797
  },
4913
4798
  async run() {
4914
- const relayVersion = "0.16.3";
4799
+ const relayVersion = "1.0.0";
4915
4800
  console.log(`agentic-relay v${relayVersion}`);
4916
4801
  console.log("");
4917
4802
  console.log("Backends:");
@@ -5261,7 +5146,7 @@ void configManager.getConfig().then((config) => {
5261
5146
  var main = defineCommand10({
5262
5147
  meta: {
5263
5148
  name: "relay",
5264
- version: "0.16.3",
5149
+ version: "1.0.0",
5265
5150
  description: "Unified CLI proxy for Claude Code, Codex CLI, and Gemini CLI"
5266
5151
  },
5267
5152
  subCommands: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rk0429/agentic-relay",
3
- "version": "0.16.3",
3
+ "version": "1.0.0",
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",