@rk0429/agentic-relay 2.0.2 → 2.0.4
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 +60 -22
- package/package.json +1 -1
package/dist/relay.mjs
CHANGED
|
@@ -992,11 +992,20 @@ function isRelayEntry(name, config) {
|
|
|
992
992
|
if (config.command?.includes("relay.mjs") || config.command?.includes("agentic-relay")) return true;
|
|
993
993
|
return false;
|
|
994
994
|
}
|
|
995
|
-
function buildChildMcpServers(parentMcpServers, childHttpUrl) {
|
|
995
|
+
function buildChildMcpServers(parentMcpServers, childHttpUrl, relayContext) {
|
|
996
996
|
const result = {};
|
|
997
997
|
for (const [name, config] of Object.entries(parentMcpServers)) {
|
|
998
998
|
if (isRelayEntry(name, config)) {
|
|
999
|
-
|
|
999
|
+
let url = childHttpUrl;
|
|
1000
|
+
if (relayContext) {
|
|
1001
|
+
const params = new URLSearchParams({
|
|
1002
|
+
relay_depth: String(relayContext.depth),
|
|
1003
|
+
relay_parent_session_id: relayContext.parentSessionId,
|
|
1004
|
+
relay_trace_id: relayContext.traceId
|
|
1005
|
+
});
|
|
1006
|
+
url = `${childHttpUrl}?${params.toString()}`;
|
|
1007
|
+
}
|
|
1008
|
+
result[name] = { type: "http", url };
|
|
1000
1009
|
} else if (config.type === "http" || config.type === "sse") {
|
|
1001
1010
|
result[name] = {
|
|
1002
1011
|
type: config.type,
|
|
@@ -1076,7 +1085,7 @@ function buildContextFromEnv() {
|
|
|
1076
1085
|
const depth = Number(process.env["RELAY_DEPTH"] ?? "0");
|
|
1077
1086
|
return { traceId, parentSessionId, depth };
|
|
1078
1087
|
}
|
|
1079
|
-
async function executeSpawnAgent(input, registry2, sessionManager2, guard, hooksEngine2, contextMonitor2, backendSelector, childHttpUrl, onProgress, agentEventStore, hookMemoryDir = "./memory", taskCompleter, taskLifecycleManager) {
|
|
1088
|
+
async function executeSpawnAgent(input, registry2, sessionManager2, guard, hooksEngine2, contextMonitor2, backendSelector, childHttpUrl, onProgress, agentEventStore, hookMemoryDir = "./memory", taskCompleter, taskLifecycleManager, relayContext) {
|
|
1080
1089
|
onProgress?.({ stage: "initializing", percent: 0 });
|
|
1081
1090
|
let inlineTaskId;
|
|
1082
1091
|
if (input.title && taskLifecycleManager) {
|
|
@@ -1119,7 +1128,7 @@ async function executeSpawnAgent(input, registry2, sessionManager2, guard, hooks
|
|
|
1119
1128
|
effectiveBackend = "claude";
|
|
1120
1129
|
selectionReason = "default(no-selector)";
|
|
1121
1130
|
}
|
|
1122
|
-
const envContext = buildContextFromEnv();
|
|
1131
|
+
const envContext = relayContext ?? buildContextFromEnv();
|
|
1123
1132
|
const promptHash = RecursionGuard.hashPrompt(input.prompt);
|
|
1124
1133
|
const context = {
|
|
1125
1134
|
traceId: envContext.traceId,
|
|
@@ -1378,7 +1387,11 @@ ${input.prompt}`;
|
|
|
1378
1387
|
if (childHttpUrl) {
|
|
1379
1388
|
const parentMcpServers = readProjectMcpJson();
|
|
1380
1389
|
if (Object.keys(parentMcpServers).length > 0) {
|
|
1381
|
-
mcpServers = buildChildMcpServers(parentMcpServers, childHttpUrl
|
|
1390
|
+
mcpServers = buildChildMcpServers(parentMcpServers, childHttpUrl, {
|
|
1391
|
+
depth: envContext.depth + 1,
|
|
1392
|
+
parentSessionId: session.relaySessionId,
|
|
1393
|
+
traceId: envContext.traceId
|
|
1394
|
+
});
|
|
1382
1395
|
}
|
|
1383
1396
|
}
|
|
1384
1397
|
return adapter.execute({
|
|
@@ -1840,7 +1853,7 @@ var init_conflict_detector = __esm({
|
|
|
1840
1853
|
});
|
|
1841
1854
|
|
|
1842
1855
|
// src/mcp-server/tools/spawn-agents-parallel.ts
|
|
1843
|
-
async function executeSpawnAgentsParallel(agents, registry2, sessionManager2, guard, hooksEngine2, contextMonitor2, backendSelector, childHttpUrl, onProgress, agentEventStore, hookMemoryDir = "./memory", taskCompleter, taskLifecycleManager) {
|
|
1856
|
+
async function executeSpawnAgentsParallel(agents, registry2, sessionManager2, guard, hooksEngine2, contextMonitor2, backendSelector, childHttpUrl, onProgress, agentEventStore, hookMemoryDir = "./memory", taskCompleter, taskLifecycleManager, relayContext) {
|
|
1844
1857
|
for (let index = 0; index < agents.length; index += 1) {
|
|
1845
1858
|
try {
|
|
1846
1859
|
resolveValidatedSessionMetadata(agents[index]);
|
|
@@ -1865,7 +1878,7 @@ async function executeSpawnAgentsParallel(agents, registry2, sessionManager2, gu
|
|
|
1865
1878
|
};
|
|
1866
1879
|
}
|
|
1867
1880
|
}
|
|
1868
|
-
const envContext = buildContextFromEnv();
|
|
1881
|
+
const envContext = relayContext ?? buildContextFromEnv();
|
|
1869
1882
|
if (envContext.depth >= guard.getConfig().maxDepth) {
|
|
1870
1883
|
const reason = `Max depth exceeded: ${envContext.depth} >= ${guard.getConfig().maxDepth}`;
|
|
1871
1884
|
logger.warn(`Batch spawn blocked by RecursionGuard: ${reason}`);
|
|
@@ -1925,7 +1938,8 @@ async function executeSpawnAgentsParallel(agents, registry2, sessionManager2, gu
|
|
|
1925
1938
|
agentEventStore,
|
|
1926
1939
|
hookMemoryDir,
|
|
1927
1940
|
taskCompleter,
|
|
1928
|
-
taskLifecycleManager
|
|
1941
|
+
taskLifecycleManager,
|
|
1942
|
+
relayContext
|
|
1929
1943
|
).then((result) => {
|
|
1930
1944
|
completedCount++;
|
|
1931
1945
|
onProgress?.({
|
|
@@ -5183,6 +5197,9 @@ var init_tasks_runtime = __esm({
|
|
|
5183
5197
|
const skip_review = task.metadata?.skip_review === true;
|
|
5184
5198
|
const nextStatus = skip_review ? "done" : "review";
|
|
5185
5199
|
if (nextStatus === "done") {
|
|
5200
|
+
if (requiredGateCount > 0) {
|
|
5201
|
+
this.qualityGateManager.assert_review_to_done_allowed(task.id, input.agent_id);
|
|
5202
|
+
}
|
|
5186
5203
|
this.ensureChildTasksDone(task.id);
|
|
5187
5204
|
}
|
|
5188
5205
|
const lock = this.lockManager.get_lock(task.id);
|
|
@@ -8267,6 +8284,23 @@ import { mkdirSync as mkdirSync3 } from "fs";
|
|
|
8267
8284
|
import path2 from "path";
|
|
8268
8285
|
import { randomUUID } from "crypto";
|
|
8269
8286
|
import { z as z8 } from "zod";
|
|
8287
|
+
function extractRelayContextFromUrl(url) {
|
|
8288
|
+
try {
|
|
8289
|
+
const parsed = new URL(url, "http://localhost");
|
|
8290
|
+
const depth = parsed.searchParams.get("relay_depth");
|
|
8291
|
+
const parentSessionId = parsed.searchParams.get("relay_parent_session_id");
|
|
8292
|
+
const traceId = parsed.searchParams.get("relay_trace_id");
|
|
8293
|
+
if (depth !== null && parentSessionId !== null) {
|
|
8294
|
+
return {
|
|
8295
|
+
depth: Number(depth),
|
|
8296
|
+
parentSessionId,
|
|
8297
|
+
traceId: traceId ?? `trace-${randomUUID()}`
|
|
8298
|
+
};
|
|
8299
|
+
}
|
|
8300
|
+
} catch {
|
|
8301
|
+
}
|
|
8302
|
+
return void 0;
|
|
8303
|
+
}
|
|
8270
8304
|
function createMcpServerOptions() {
|
|
8271
8305
|
const taskStore = new DeferredCleanupTaskStore();
|
|
8272
8306
|
return {
|
|
@@ -8403,7 +8437,7 @@ var init_server = __esm({
|
|
|
8403
8437
|
this.agentEventStore
|
|
8404
8438
|
);
|
|
8405
8439
|
this.server = new McpServer(
|
|
8406
|
-
{ name: "agentic-relay", version: "2.0.
|
|
8440
|
+
{ name: "agentic-relay", version: "2.0.4" },
|
|
8407
8441
|
createMcpServerOptions()
|
|
8408
8442
|
);
|
|
8409
8443
|
this.registerTools(this.server);
|
|
@@ -8433,7 +8467,7 @@ var init_server = __esm({
|
|
|
8433
8467
|
* Run spawn_agent in the background and store the result in taskStore.
|
|
8434
8468
|
* Fire-and-forget: errors are caught and stored as failed task results.
|
|
8435
8469
|
*/
|
|
8436
|
-
runSpawnAgentInBackground(taskId, params, extra) {
|
|
8470
|
+
runSpawnAgentInBackground(taskId, params, extra, relayContext) {
|
|
8437
8471
|
const run = async () => {
|
|
8438
8472
|
try {
|
|
8439
8473
|
const result = await executeSpawnAgent(
|
|
@@ -8449,7 +8483,8 @@ var init_server = __esm({
|
|
|
8449
8483
|
this.agentEventStore,
|
|
8450
8484
|
this.hookMemoryDir,
|
|
8451
8485
|
void 0,
|
|
8452
|
-
this.taskLifecycleManager
|
|
8486
|
+
this.taskLifecycleManager,
|
|
8487
|
+
relayContext
|
|
8453
8488
|
);
|
|
8454
8489
|
const controlOptions = {
|
|
8455
8490
|
inlineSummaryLength: this.inlineSummaryLength ?? DEFAULT_INLINE_SUMMARY_LENGTH,
|
|
@@ -8490,7 +8525,7 @@ var init_server = __esm({
|
|
|
8490
8525
|
* Run spawn_agents_parallel in the background and store the result in taskStore.
|
|
8491
8526
|
* Fire-and-forget: errors are caught and stored as failed task results.
|
|
8492
8527
|
*/
|
|
8493
|
-
runSpawnAgentsParallelInBackground(taskId, agents, extra) {
|
|
8528
|
+
runSpawnAgentsParallelInBackground(taskId, agents, extra, relayContext) {
|
|
8494
8529
|
const run = async () => {
|
|
8495
8530
|
try {
|
|
8496
8531
|
const result = await executeSpawnAgentsParallel(
|
|
@@ -8506,7 +8541,8 @@ var init_server = __esm({
|
|
|
8506
8541
|
this.agentEventStore,
|
|
8507
8542
|
this.hookMemoryDir,
|
|
8508
8543
|
void 0,
|
|
8509
|
-
this.taskLifecycleManager
|
|
8544
|
+
this.taskLifecycleManager,
|
|
8545
|
+
relayContext
|
|
8510
8546
|
);
|
|
8511
8547
|
const controlOptions = {
|
|
8512
8548
|
inlineSummaryLength: this.inlineSummaryLength ?? DEFAULT_INLINE_SUMMARY_LENGTH,
|
|
@@ -8542,7 +8578,7 @@ var init_server = __esm({
|
|
|
8542
8578
|
};
|
|
8543
8579
|
void run();
|
|
8544
8580
|
}
|
|
8545
|
-
registerTools(server) {
|
|
8581
|
+
registerTools(server, relayContext) {
|
|
8546
8582
|
server.experimental.tasks.registerToolTask(
|
|
8547
8583
|
"spawn_agent",
|
|
8548
8584
|
{
|
|
@@ -8556,7 +8592,7 @@ var init_server = __esm({
|
|
|
8556
8592
|
ttl: DEFAULT_TASK_TTL,
|
|
8557
8593
|
pollInterval: DEFAULT_POLL_INTERVAL
|
|
8558
8594
|
});
|
|
8559
|
-
this.runSpawnAgentInBackground(task.taskId, params, extra);
|
|
8595
|
+
this.runSpawnAgentInBackground(task.taskId, params, extra, relayContext);
|
|
8560
8596
|
return { task };
|
|
8561
8597
|
},
|
|
8562
8598
|
getTask: async (_params, extra) => {
|
|
@@ -8582,7 +8618,7 @@ var init_server = __esm({
|
|
|
8582
8618
|
ttl: DEFAULT_TASK_TTL,
|
|
8583
8619
|
pollInterval: DEFAULT_POLL_INTERVAL
|
|
8584
8620
|
});
|
|
8585
|
-
this.runSpawnAgentsParallelInBackground(task.taskId, params.agents, extra);
|
|
8621
|
+
this.runSpawnAgentsParallelInBackground(task.taskId, params.agents, extra, relayContext);
|
|
8586
8622
|
return { task };
|
|
8587
8623
|
},
|
|
8588
8624
|
getTask: async (_params, extra) => {
|
|
@@ -8620,7 +8656,8 @@ var init_server = __esm({
|
|
|
8620
8656
|
this.agentEventStore,
|
|
8621
8657
|
this.hookMemoryDir,
|
|
8622
8658
|
void 0,
|
|
8623
|
-
this.taskLifecycleManager
|
|
8659
|
+
this.taskLifecycleManager,
|
|
8660
|
+
relayContext
|
|
8624
8661
|
);
|
|
8625
8662
|
const controlOptions = {
|
|
8626
8663
|
inlineSummaryLength: this.inlineSummaryLength ?? DEFAULT_INLINE_SUMMARY_LENGTH,
|
|
@@ -8885,14 +8922,15 @@ var init_server = __esm({
|
|
|
8885
8922
|
return;
|
|
8886
8923
|
}
|
|
8887
8924
|
}
|
|
8925
|
+
const childRelayContext = extractRelayContextFromUrl(url);
|
|
8888
8926
|
const transport = new StreamableHTTPServerTransport({
|
|
8889
8927
|
sessionIdGenerator: () => randomUUID()
|
|
8890
8928
|
});
|
|
8891
8929
|
const server = new McpServer(
|
|
8892
|
-
{ name: "agentic-relay", version: "2.0.
|
|
8930
|
+
{ name: "agentic-relay", version: "2.0.4" },
|
|
8893
8931
|
createMcpServerOptions()
|
|
8894
8932
|
);
|
|
8895
|
-
this.registerTools(server);
|
|
8933
|
+
this.registerTools(server, childRelayContext);
|
|
8896
8934
|
transport.onclose = () => {
|
|
8897
8935
|
const sid2 = transport.sessionId;
|
|
8898
8936
|
if (sid2) {
|
|
@@ -13329,7 +13367,7 @@ function createMCPCommand(configManager2, registry2, sessionManager2, hooksEngin
|
|
|
13329
13367
|
responseOutputDir,
|
|
13330
13368
|
relayConfig
|
|
13331
13369
|
);
|
|
13332
|
-
await server.start({ transport, port, currentVersion: "2.0.
|
|
13370
|
+
await server.start({ transport, port, currentVersion: "2.0.4" });
|
|
13333
13371
|
}
|
|
13334
13372
|
})
|
|
13335
13373
|
},
|
|
@@ -13489,7 +13527,7 @@ function createVersionCommand(registry2) {
|
|
|
13489
13527
|
description: "Show relay and backend versions"
|
|
13490
13528
|
},
|
|
13491
13529
|
async run() {
|
|
13492
|
-
const relayVersion = "2.0.
|
|
13530
|
+
const relayVersion = "2.0.4";
|
|
13493
13531
|
console.log(`agentic-relay v${relayVersion}`);
|
|
13494
13532
|
console.log("");
|
|
13495
13533
|
console.log("Backends:");
|
|
@@ -13886,7 +13924,7 @@ var subCommandNames = /* @__PURE__ */ new Set(["claude", "codex", "gemini", "upd
|
|
|
13886
13924
|
var main = defineCommand11({
|
|
13887
13925
|
meta: {
|
|
13888
13926
|
name: "relay",
|
|
13889
|
-
version: "2.0.
|
|
13927
|
+
version: "2.0.4",
|
|
13890
13928
|
description: "Unified CLI proxy for Claude Code, Codex CLI, and Gemini CLI"
|
|
13891
13929
|
},
|
|
13892
13930
|
args: {
|
package/package.json
CHANGED