@rk0429/agentic-relay 1.5.0 → 1.6.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 +52 -19
- package/package.json +1 -1
package/dist/relay.mjs
CHANGED
|
@@ -104,7 +104,7 @@ function validateMetadataValue(value, path2, depth) {
|
|
|
104
104
|
}
|
|
105
105
|
function validateMetadata(raw) {
|
|
106
106
|
if (raw === void 0 || raw === null) {
|
|
107
|
-
return {};
|
|
107
|
+
return { taskId: "TASK-000" };
|
|
108
108
|
}
|
|
109
109
|
if (!isPlainObject(raw)) {
|
|
110
110
|
throw new Error("metadata must be a plain object");
|
|
@@ -127,10 +127,13 @@ function validateMetadata(raw) {
|
|
|
127
127
|
validateMetadataValue(value, key, 1);
|
|
128
128
|
}
|
|
129
129
|
const typed = raw;
|
|
130
|
-
if (typed.taskId
|
|
130
|
+
if (typed.taskId === void 0) {
|
|
131
|
+
typed.taskId = "TASK-000";
|
|
132
|
+
}
|
|
133
|
+
if (typeof typed.taskId !== "string") {
|
|
131
134
|
throw new Error("metadata.taskId must be a string");
|
|
132
135
|
}
|
|
133
|
-
if (
|
|
136
|
+
if (!TASK_ID_PATTERN.test(typed.taskId)) {
|
|
134
137
|
throw new Error("metadata.taskId must match ^(TASK|GOAL)-\\d{3,}$");
|
|
135
138
|
}
|
|
136
139
|
if (typed.agentType !== void 0 && typeof typed.agentType !== "string") {
|
|
@@ -1012,6 +1015,13 @@ function buildChildMcpServers(parentMcpServers, childHttpUrl) {
|
|
|
1012
1015
|
return result;
|
|
1013
1016
|
}
|
|
1014
1017
|
function resolveValidatedSessionMetadata(input) {
|
|
1018
|
+
if (input.metadata === void 0 || input.metadata === null) {
|
|
1019
|
+
throw new Error("metadata is required");
|
|
1020
|
+
}
|
|
1021
|
+
const rawTaskId = input.metadata.taskId;
|
|
1022
|
+
if (typeof rawTaskId !== "string" || rawTaskId.trim().length === 0) {
|
|
1023
|
+
throw new Error("metadata.taskId is required");
|
|
1024
|
+
}
|
|
1015
1025
|
const validated = validateMetadata(input.metadata);
|
|
1016
1026
|
const mergedMetadata = { ...validated };
|
|
1017
1027
|
if (mergedMetadata.agentType === void 0 && input.agent !== void 0) {
|
|
@@ -1082,9 +1092,6 @@ async function executeSpawnAgent(input, registry2, sessionManager2, guard, hooks
|
|
|
1082
1092
|
const selectionResult = backendSelector.selectBackendWithReason(selectionContext);
|
|
1083
1093
|
effectiveBackend = selectionResult.backend;
|
|
1084
1094
|
selectionReason = selectionResult.reason;
|
|
1085
|
-
} else if (input.fallbackBackend) {
|
|
1086
|
-
effectiveBackend = input.fallbackBackend;
|
|
1087
|
-
selectionReason = "fallbackBackend";
|
|
1088
1095
|
} else {
|
|
1089
1096
|
effectiveBackend = "claude";
|
|
1090
1097
|
selectionReason = "default(no-selector)";
|
|
@@ -1226,6 +1233,24 @@ ${skillText}
|
|
|
1226
1233
|
|
|
1227
1234
|
${wrapped}` : wrapped;
|
|
1228
1235
|
}
|
|
1236
|
+
} else {
|
|
1237
|
+
const autoSkillPaths = [
|
|
1238
|
+
`.agents/skills/${input.agent}`,
|
|
1239
|
+
`.claude/skills/${input.agent}`
|
|
1240
|
+
];
|
|
1241
|
+
for (const skillPath of autoSkillPaths) {
|
|
1242
|
+
const skillText = readSkillContext({ skillPath });
|
|
1243
|
+
if (!skillText) {
|
|
1244
|
+
continue;
|
|
1245
|
+
}
|
|
1246
|
+
const wrapped = `<skill-context path="${skillPath}">
|
|
1247
|
+
${skillText}
|
|
1248
|
+
</skill-context>`;
|
|
1249
|
+
enhancedSystemPrompt = enhancedSystemPrompt ? `${enhancedSystemPrompt}
|
|
1250
|
+
|
|
1251
|
+
${wrapped}` : wrapped;
|
|
1252
|
+
break;
|
|
1253
|
+
}
|
|
1229
1254
|
}
|
|
1230
1255
|
if (input.agentDefinition) {
|
|
1231
1256
|
const defText = readAgentDefinition(input.agentDefinition.definitionPath);
|
|
@@ -1235,6 +1260,17 @@ ${defText}
|
|
|
1235
1260
|
</agent-definition>`;
|
|
1236
1261
|
enhancedSystemPrompt = enhancedSystemPrompt ? `${enhancedSystemPrompt}
|
|
1237
1262
|
|
|
1263
|
+
${wrapped}` : wrapped;
|
|
1264
|
+
}
|
|
1265
|
+
} else {
|
|
1266
|
+
const autoDefinitionPath = `.agents/agents/${input.agent}.md`;
|
|
1267
|
+
const defText = readAgentDefinition(autoDefinitionPath);
|
|
1268
|
+
if (defText) {
|
|
1269
|
+
const wrapped = `<agent-definition source="${autoDefinitionPath}">
|
|
1270
|
+
${defText}
|
|
1271
|
+
</agent-definition>`;
|
|
1272
|
+
enhancedSystemPrompt = enhancedSystemPrompt ? `${enhancedSystemPrompt}
|
|
1273
|
+
|
|
1238
1274
|
${wrapped}` : wrapped;
|
|
1239
1275
|
}
|
|
1240
1276
|
}
|
|
@@ -1632,9 +1668,6 @@ var init_spawn_agent = __esm({
|
|
|
1632
1668
|
init_logger();
|
|
1633
1669
|
init_metadata_validation();
|
|
1634
1670
|
spawnAgentInputSchema = z2.object({
|
|
1635
|
-
fallbackBackend: z2.enum(["claude", "codex", "gemini"]).optional().describe(
|
|
1636
|
-
"Optional fallback backend. Used only when BackendSelector is not active or cannot determine a backend. When BackendSelector is active, backend is auto-selected by priority: agentType mapping > taskType mapping > default (claude)."
|
|
1637
|
-
),
|
|
1638
1671
|
prompt: z2.string().describe(
|
|
1639
1672
|
"The task instruction for the sub-agent. Be specific and include all necessary context for autonomous execution."
|
|
1640
1673
|
),
|
|
@@ -1665,12 +1698,12 @@ var init_spawn_agent = __esm({
|
|
|
1665
1698
|
),
|
|
1666
1699
|
label: z2.string().optional().describe("Human-readable label for identifying this agent in parallel results and logs."),
|
|
1667
1700
|
metadata: z2.object({
|
|
1668
|
-
taskId: z2.string().regex(TASK_ID_PATTERN)
|
|
1701
|
+
taskId: z2.string().regex(TASK_ID_PATTERN),
|
|
1669
1702
|
agentType: z2.string().optional(),
|
|
1670
1703
|
label: z2.string().optional(),
|
|
1671
1704
|
parentTaskId: z2.string().optional(),
|
|
1672
1705
|
tags: z2.array(z2.string()).optional()
|
|
1673
|
-
}).catchall(z2.unknown()).
|
|
1706
|
+
}).catchall(z2.unknown()).describe("Session metadata for task linkage and orchestration context.")
|
|
1674
1707
|
});
|
|
1675
1708
|
}
|
|
1676
1709
|
});
|
|
@@ -2412,7 +2445,7 @@ var init_server = __esm({
|
|
|
2412
2445
|
this.agentEventStore
|
|
2413
2446
|
);
|
|
2414
2447
|
this.server = new McpServer(
|
|
2415
|
-
{ name: "agentic-relay", version: "1.
|
|
2448
|
+
{ name: "agentic-relay", version: "1.6.0" },
|
|
2416
2449
|
createMcpServerOptions()
|
|
2417
2450
|
);
|
|
2418
2451
|
this.registerTools(this.server);
|
|
@@ -2550,7 +2583,7 @@ var init_server = __esm({
|
|
|
2550
2583
|
server.experimental.tasks.registerToolTask(
|
|
2551
2584
|
"spawn_agent",
|
|
2552
2585
|
{
|
|
2553
|
-
description: "Spawn a sub-agent on a backend CLI (Claude Code, Codex CLI, or Gemini CLI). The agent executes the given prompt in non-interactive mode and returns the result. Backend is auto-selected by priority: agentType mapping (coder/researcher\u2192codex, documenter\u2192claude) > taskType mapping > default (claude). Use 'agentDefinition' to inject an agent .md file, 'skillContext' for a SKILL.md, or 'systemPrompt' for custom instructions.",
|
|
2586
|
+
description: "Spawn a sub-agent on a backend CLI (Claude Code, Codex CLI, or Gemini CLI). The agent executes the given prompt in non-interactive mode and returns the result. Backend is auto-selected by priority: agentType mapping (coder/researcher\u2192codex, documenter\u2192claude) > taskType mapping > default (claude). metadata with metadata.taskId is required for task-first delegation. Use 'agentDefinition' to inject an agent .md file, 'skillContext' for a SKILL.md, or 'systemPrompt' for custom instructions.",
|
|
2554
2587
|
inputSchema: spawnAgentInputSchema.shape,
|
|
2555
2588
|
execution: { taskSupport: "optional" }
|
|
2556
2589
|
},
|
|
@@ -2891,7 +2924,7 @@ var init_server = __esm({
|
|
|
2891
2924
|
sessionIdGenerator: () => randomUUID()
|
|
2892
2925
|
});
|
|
2893
2926
|
const server = new McpServer(
|
|
2894
|
-
{ name: "agentic-relay", version: "1.
|
|
2927
|
+
{ name: "agentic-relay", version: "1.6.0" },
|
|
2895
2928
|
createMcpServerOptions()
|
|
2896
2929
|
);
|
|
2897
2930
|
this.registerTools(server);
|
|
@@ -5574,7 +5607,7 @@ function fromSessionData(data) {
|
|
|
5574
5607
|
updatedAt,
|
|
5575
5608
|
lastHeartbeatAt: Number.isNaN(lastHeartbeatAt.getTime()) ? updatedAt : lastHeartbeatAt,
|
|
5576
5609
|
staleNotifiedAt: staleNotifiedAt && !Number.isNaN(staleNotifiedAt.getTime()) ? staleNotifiedAt : null,
|
|
5577
|
-
metadata: data.metadata && typeof data.metadata === "object" ? data.metadata : {}
|
|
5610
|
+
metadata: data.metadata && typeof data.metadata === "object" ? data.metadata : { taskId: "TASK-000" }
|
|
5578
5611
|
};
|
|
5579
5612
|
}
|
|
5580
5613
|
var SessionManager = class _SessionManager {
|
|
@@ -6643,7 +6676,7 @@ var ContextMonitor = class {
|
|
|
6643
6676
|
sessionId,
|
|
6644
6677
|
backendId,
|
|
6645
6678
|
parentSessionId: void 0,
|
|
6646
|
-
metadata: sessionMetadata ?? {},
|
|
6679
|
+
metadata: sessionMetadata ?? { taskId: "TASK-000" },
|
|
6647
6680
|
data: {
|
|
6648
6681
|
usagePercent,
|
|
6649
6682
|
currentTokens,
|
|
@@ -7330,7 +7363,7 @@ function createMCPCommand(configManager2, registry2, sessionManager2, hooksEngin
|
|
|
7330
7363
|
responseOutputDir,
|
|
7331
7364
|
relayConfig
|
|
7332
7365
|
);
|
|
7333
|
-
await server.start({ transport, port, currentVersion: "1.
|
|
7366
|
+
await server.start({ transport, port, currentVersion: "1.6.0" });
|
|
7334
7367
|
}
|
|
7335
7368
|
})
|
|
7336
7369
|
},
|
|
@@ -7490,7 +7523,7 @@ function createVersionCommand(registry2) {
|
|
|
7490
7523
|
description: "Show relay and backend versions"
|
|
7491
7524
|
},
|
|
7492
7525
|
async run() {
|
|
7493
|
-
const relayVersion = "1.
|
|
7526
|
+
const relayVersion = "1.6.0";
|
|
7494
7527
|
console.log(`agentic-relay v${relayVersion}`);
|
|
7495
7528
|
console.log("");
|
|
7496
7529
|
console.log("Backends:");
|
|
@@ -7887,7 +7920,7 @@ var subCommandNames = /* @__PURE__ */ new Set(["claude", "codex", "gemini", "upd
|
|
|
7887
7920
|
var main = defineCommand11({
|
|
7888
7921
|
meta: {
|
|
7889
7922
|
name: "relay",
|
|
7890
|
-
version: "1.
|
|
7923
|
+
version: "1.6.0",
|
|
7891
7924
|
description: "Unified CLI proxy for Claude Code, Codex CLI, and Gemini CLI"
|
|
7892
7925
|
},
|
|
7893
7926
|
args: {
|
package/package.json
CHANGED