@rk0429/agentic-relay 1.0.0 → 1.1.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/relay.mjs +36 -24
- package/package.json +1 -1
package/dist/relay.mjs
CHANGED
|
@@ -1210,16 +1210,20 @@ var init_types = __esm({
|
|
|
1210
1210
|
// src/mcp-server/response-formatter.ts
|
|
1211
1211
|
import * as fs from "fs";
|
|
1212
1212
|
import * as path from "path";
|
|
1213
|
-
|
|
1214
|
-
|
|
1213
|
+
function resolveResponseDir(dir) {
|
|
1214
|
+
const target = dir ?? DEFAULT_RESPONSE_OUTPUT_DIR;
|
|
1215
|
+
return path.isAbsolute(target) ? target : path.resolve(process.cwd(), target);
|
|
1216
|
+
}
|
|
1217
|
+
function saveFullResponse(content, sessionId, responseOutputDir) {
|
|
1215
1218
|
try {
|
|
1216
|
-
const
|
|
1219
|
+
const baseDir = resolveResponseDir(responseOutputDir);
|
|
1220
|
+
const dir = sessionId ? path.join(baseDir, sessionId) : path.join(baseDir, `anonymous-${Date.now()}`);
|
|
1217
1221
|
fs.mkdirSync(dir, { recursive: true });
|
|
1218
1222
|
const filePath = path.join(dir, "response.txt");
|
|
1219
1223
|
fs.writeFileSync(filePath, content, "utf-8");
|
|
1220
1224
|
try {
|
|
1221
|
-
const entries = fs.readdirSync(
|
|
1222
|
-
const fullPath = path.join(
|
|
1225
|
+
const entries = fs.readdirSync(baseDir).map((name) => {
|
|
1226
|
+
const fullPath = path.join(baseDir, name);
|
|
1223
1227
|
try {
|
|
1224
1228
|
const stat = fs.statSync(fullPath);
|
|
1225
1229
|
return { name, fullPath, mtimeMs: stat.mtimeMs };
|
|
@@ -1245,7 +1249,7 @@ async function processStdout(stdout, options) {
|
|
|
1245
1249
|
if (stdout.length <= inlineSummaryLength) {
|
|
1246
1250
|
return { text: stdout, truncated: false };
|
|
1247
1251
|
}
|
|
1248
|
-
const savedFilePath = saveFullResponse(stdout, options?.sessionId);
|
|
1252
|
+
const savedFilePath = saveFullResponse(stdout, options?.sessionId, options?.responseOutputDir);
|
|
1249
1253
|
const summary = stdout.slice(0, inlineSummaryLength);
|
|
1250
1254
|
const fileRef = savedFilePath ?? "(file save failed)";
|
|
1251
1255
|
const footer = `...
|
|
@@ -1346,14 +1350,14 @@ ${JSON.stringify(sanitizedResult, null, 2)}
|
|
|
1346
1350
|
</metadata>`);
|
|
1347
1351
|
return { text: parts.join("\n"), isError };
|
|
1348
1352
|
}
|
|
1349
|
-
var STDERR_MAX_LENGTH, DEFAULT_INLINE_SUMMARY_LENGTH, MAX_SAVED_RESPONSES,
|
|
1353
|
+
var STDERR_MAX_LENGTH, DEFAULT_INLINE_SUMMARY_LENGTH, MAX_SAVED_RESPONSES, DEFAULT_RESPONSE_OUTPUT_DIR;
|
|
1350
1354
|
var init_response_formatter = __esm({
|
|
1351
1355
|
"src/mcp-server/response-formatter.ts"() {
|
|
1352
1356
|
"use strict";
|
|
1353
1357
|
STDERR_MAX_LENGTH = 2e3;
|
|
1354
1358
|
DEFAULT_INLINE_SUMMARY_LENGTH = 500;
|
|
1355
1359
|
MAX_SAVED_RESPONSES = 100;
|
|
1356
|
-
|
|
1360
|
+
DEFAULT_RESPONSE_OUTPUT_DIR = ".relay/responses";
|
|
1357
1361
|
}
|
|
1358
1362
|
});
|
|
1359
1363
|
|
|
@@ -1400,16 +1404,17 @@ var init_server = __esm({
|
|
|
1400
1404
|
};
|
|
1401
1405
|
MAX_CHILD_HTTP_SESSIONS = 100;
|
|
1402
1406
|
RelayMCPServer = class {
|
|
1403
|
-
constructor(registry2, sessionManager2, guardConfig, hooksEngine2, contextMonitor2, inlineSummaryLength) {
|
|
1407
|
+
constructor(registry2, sessionManager2, guardConfig, hooksEngine2, contextMonitor2, inlineSummaryLength, responseOutputDir) {
|
|
1404
1408
|
this.registry = registry2;
|
|
1405
1409
|
this.sessionManager = sessionManager2;
|
|
1406
1410
|
this.hooksEngine = hooksEngine2;
|
|
1407
1411
|
this.contextMonitor = contextMonitor2;
|
|
1408
1412
|
this.inlineSummaryLength = inlineSummaryLength;
|
|
1413
|
+
this.responseOutputDir = responseOutputDir;
|
|
1409
1414
|
this.guard = new RecursionGuard(guardConfig);
|
|
1410
1415
|
this.backendSelector = new BackendSelector();
|
|
1411
1416
|
this.server = new McpServer(
|
|
1412
|
-
{ name: "agentic-relay", version: "1.
|
|
1417
|
+
{ name: "agentic-relay", version: "1.1.0" },
|
|
1413
1418
|
createMcpServerOptions()
|
|
1414
1419
|
);
|
|
1415
1420
|
this.registerTools(this.server);
|
|
@@ -1446,7 +1451,8 @@ var init_server = __esm({
|
|
|
1446
1451
|
);
|
|
1447
1452
|
const controlOptions = {
|
|
1448
1453
|
inlineSummaryLength: this.inlineSummaryLength ?? DEFAULT_INLINE_SUMMARY_LENGTH,
|
|
1449
|
-
sessionId: result.sessionId
|
|
1454
|
+
sessionId: result.sessionId,
|
|
1455
|
+
responseOutputDir: this.responseOutputDir
|
|
1450
1456
|
};
|
|
1451
1457
|
const { text, isError } = await formatSpawnAgentResponse(result, controlOptions);
|
|
1452
1458
|
const callToolResult = {
|
|
@@ -1496,7 +1502,8 @@ var init_server = __esm({
|
|
|
1496
1502
|
this._childHttpUrl
|
|
1497
1503
|
);
|
|
1498
1504
|
const controlOptions = {
|
|
1499
|
-
inlineSummaryLength: this.inlineSummaryLength ?? DEFAULT_INLINE_SUMMARY_LENGTH
|
|
1505
|
+
inlineSummaryLength: this.inlineSummaryLength ?? DEFAULT_INLINE_SUMMARY_LENGTH,
|
|
1506
|
+
responseOutputDir: this.responseOutputDir
|
|
1500
1507
|
};
|
|
1501
1508
|
const { text, isError } = await formatParallelResponse(result, controlOptions);
|
|
1502
1509
|
const callToolResult = {
|
|
@@ -1615,7 +1622,8 @@ var init_server = __esm({
|
|
|
1615
1622
|
this._childHttpUrl
|
|
1616
1623
|
);
|
|
1617
1624
|
const controlOptions = {
|
|
1618
|
-
inlineSummaryLength: this.inlineSummaryLength ?? DEFAULT_INLINE_SUMMARY_LENGTH
|
|
1625
|
+
inlineSummaryLength: this.inlineSummaryLength ?? DEFAULT_INLINE_SUMMARY_LENGTH,
|
|
1626
|
+
responseOutputDir: this.responseOutputDir
|
|
1619
1627
|
};
|
|
1620
1628
|
const { text, isError } = await formatParallelResponse(result, controlOptions);
|
|
1621
1629
|
return {
|
|
@@ -1744,14 +1752,14 @@ var init_server = __esm({
|
|
|
1744
1752
|
});
|
|
1745
1753
|
this._httpServer = httpServer;
|
|
1746
1754
|
await this.server.connect(httpTransport);
|
|
1747
|
-
await new Promise((
|
|
1755
|
+
await new Promise((resolve3) => {
|
|
1748
1756
|
httpServer.listen(port, "127.0.0.1", () => {
|
|
1749
1757
|
logger.info(`MCP server listening on http://localhost:${port}/mcp`);
|
|
1750
|
-
|
|
1758
|
+
resolve3();
|
|
1751
1759
|
});
|
|
1752
1760
|
});
|
|
1753
|
-
await new Promise((
|
|
1754
|
-
httpServer.on("close",
|
|
1761
|
+
await new Promise((resolve3) => {
|
|
1762
|
+
httpServer.on("close", resolve3);
|
|
1755
1763
|
});
|
|
1756
1764
|
}
|
|
1757
1765
|
/**
|
|
@@ -1781,7 +1789,7 @@ var init_server = __esm({
|
|
|
1781
1789
|
sessionIdGenerator: () => randomUUID()
|
|
1782
1790
|
});
|
|
1783
1791
|
const server = new McpServer(
|
|
1784
|
-
{ name: "agentic-relay", version: "1.
|
|
1792
|
+
{ name: "agentic-relay", version: "1.1.0" },
|
|
1785
1793
|
createMcpServerOptions()
|
|
1786
1794
|
);
|
|
1787
1795
|
this.registerTools(server);
|
|
@@ -1817,12 +1825,12 @@ var init_server = __esm({
|
|
|
1817
1825
|
}
|
|
1818
1826
|
});
|
|
1819
1827
|
this._childHttpServer = httpServer;
|
|
1820
|
-
await new Promise((
|
|
1828
|
+
await new Promise((resolve3) => {
|
|
1821
1829
|
httpServer.listen(0, "127.0.0.1", () => {
|
|
1822
1830
|
const addr = httpServer.address();
|
|
1823
1831
|
this._childHttpUrl = `http://127.0.0.1:${addr.port}/mcp`;
|
|
1824
1832
|
logger.info(`Child MCP server listening on ${this._childHttpUrl}`);
|
|
1825
|
-
|
|
1833
|
+
resolve3();
|
|
1826
1834
|
});
|
|
1827
1835
|
});
|
|
1828
1836
|
}
|
|
@@ -3382,7 +3390,8 @@ var relayConfigSchema = z.object({
|
|
|
3382
3390
|
maxDepth: z.number().int().positive(),
|
|
3383
3391
|
maxCallsPerSession: z.number().int().positive(),
|
|
3384
3392
|
timeoutSec: z.number().positive(),
|
|
3385
|
-
inlineSummaryLength: z.number().int().positive().optional()
|
|
3393
|
+
inlineSummaryLength: z.number().int().positive().optional(),
|
|
3394
|
+
responseOutputDir: z.string().optional()
|
|
3386
3395
|
}).optional(),
|
|
3387
3396
|
telemetry: z.object({
|
|
3388
3397
|
enabled: z.boolean()
|
|
@@ -4614,6 +4623,7 @@ function createMCPCommand(configManager2, registry2, sessionManager2, hooksEngin
|
|
|
4614
4623
|
}
|
|
4615
4624
|
let guardConfig;
|
|
4616
4625
|
let inlineSummaryLength;
|
|
4626
|
+
let responseOutputDir;
|
|
4617
4627
|
try {
|
|
4618
4628
|
const config = await configManager2.getConfig();
|
|
4619
4629
|
if (config.mcpServerMode) {
|
|
@@ -4623,6 +4633,7 @@ function createMCPCommand(configManager2, registry2, sessionManager2, hooksEngin
|
|
|
4623
4633
|
timeoutSec: config.mcpServerMode.timeoutSec ?? 86400
|
|
4624
4634
|
};
|
|
4625
4635
|
inlineSummaryLength = config.mcpServerMode.inlineSummaryLength;
|
|
4636
|
+
responseOutputDir = config.mcpServerMode.responseOutputDir;
|
|
4626
4637
|
}
|
|
4627
4638
|
} catch {
|
|
4628
4639
|
}
|
|
@@ -4634,7 +4645,8 @@ function createMCPCommand(configManager2, registry2, sessionManager2, hooksEngin
|
|
|
4634
4645
|
guardConfig,
|
|
4635
4646
|
hooksEngine2,
|
|
4636
4647
|
contextMonitor2,
|
|
4637
|
-
inlineSummaryLength
|
|
4648
|
+
inlineSummaryLength,
|
|
4649
|
+
responseOutputDir
|
|
4638
4650
|
);
|
|
4639
4651
|
await server.start({ transport, port });
|
|
4640
4652
|
}
|
|
@@ -4796,7 +4808,7 @@ function createVersionCommand(registry2) {
|
|
|
4796
4808
|
description: "Show relay and backend versions"
|
|
4797
4809
|
},
|
|
4798
4810
|
async run() {
|
|
4799
|
-
const relayVersion = "1.
|
|
4811
|
+
const relayVersion = "1.1.0";
|
|
4800
4812
|
console.log(`agentic-relay v${relayVersion}`);
|
|
4801
4813
|
console.log("");
|
|
4802
4814
|
console.log("Backends:");
|
|
@@ -5146,7 +5158,7 @@ void configManager.getConfig().then((config) => {
|
|
|
5146
5158
|
var main = defineCommand10({
|
|
5147
5159
|
meta: {
|
|
5148
5160
|
name: "relay",
|
|
5149
|
-
version: "1.
|
|
5161
|
+
version: "1.1.0",
|
|
5150
5162
|
description: "Unified CLI proxy for Claude Code, Codex CLI, and Gemini CLI"
|
|
5151
5163
|
},
|
|
5152
5164
|
subCommands: {
|
package/package.json
CHANGED