replicas-engine 0.1.958 → 0.1.960
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/src/{asp-host-QI7MAWDJ.js → asp-host-F7IOQ6EZ.js} +5 -5
- package/dist/src/{chunk-LI5QEJBB.js → chunk-3TPGWE3O.js} +6 -6
- package/dist/src/{chunk-YNVHVJQR.js → chunk-E4WKHWCM.js} +1 -1
- package/dist/src/{chunk-YEIV5OYO.js → chunk-F47TKGB5.js} +3 -3
- package/dist/src/{chunk-NHEZTD3X.js → chunk-QSVTOKZY.js} +4 -5
- package/dist/src/{chunk-FHP2MB2M.js → chunk-SYJMIBRY.js} +3 -3
- package/dist/src/{chunk-7GWXM2H5.js → chunk-T2TXUSX7.js} +69 -90
- package/dist/src/{chunk-UQ3N4FNZ.js → chunk-VY7WH777.js} +1 -1
- package/dist/src/command-protection-hook.js +4 -4
- package/dist/src/headless-agent.js +3 -3
- package/dist/src/index.js +388 -385
- package/dist/src/post-tool-pr-hook.js +2 -2
- package/dist/src/{relay-mcp.js → subagent-mcp.js} +38 -39
- package/package.json +2 -2
- package/dist/src/chunk-SJ6BDSN3.js +0 -45
|
@@ -3,13 +3,13 @@ import { createRequire as __createRequire } from 'node:module';
|
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
publishedPullRequestUrls
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-VY7WH777.js";
|
|
7
7
|
import {
|
|
8
8
|
isRecord
|
|
9
9
|
} from "./chunk-UZSNFLDQ.js";
|
|
10
10
|
import {
|
|
11
11
|
shouldRefreshPullRequests
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-T2TXUSX7.js";
|
|
13
13
|
import "./chunk-VEQXQN22.js";
|
|
14
14
|
|
|
15
15
|
// src/services/post-tool-pr-notifier.ts
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __createRequire } from 'node:module';
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
|
-
import "./chunk-SJ6BDSN3.js";
|
|
5
4
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
SUBAGENT_MCP_SERVER_NAME,
|
|
6
|
+
SUBAGENT_MCP_TOOLS,
|
|
7
|
+
messageSubagentRequestSchema,
|
|
9
8
|
readSseStream,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} from "./chunk-
|
|
9
|
+
spawnSubagentRequestSchema,
|
|
10
|
+
subagentResponseSchema,
|
|
11
|
+
waitSubagentRequestSchema
|
|
12
|
+
} from "./chunk-T2TXUSX7.js";
|
|
14
13
|
import "./chunk-VEQXQN22.js";
|
|
15
14
|
|
|
16
|
-
// src/
|
|
15
|
+
// src/subagent-mcp.ts
|
|
17
16
|
import { parseArgs } from "util";
|
|
18
17
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
19
18
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
@@ -39,7 +38,7 @@ async function request(path, method, body) {
|
|
|
39
38
|
body: body === void 0 ? void 0 : JSON.stringify(body)
|
|
40
39
|
});
|
|
41
40
|
const text = await response.text();
|
|
42
|
-
if (!response.ok) throw new Error(text || `
|
|
41
|
+
if (!response.ok) throw new Error(text || `Subagent request failed (${response.status})`);
|
|
43
42
|
return text || JSON.stringify({ success: true });
|
|
44
43
|
}
|
|
45
44
|
async function waitForAgent(chatId, timeoutMinutes) {
|
|
@@ -50,38 +49,38 @@ async function waitForAgent(chatId, timeoutMinutes) {
|
|
|
50
49
|
"X-Replicas-Engine-Secret": engineSecret
|
|
51
50
|
}
|
|
52
51
|
});
|
|
53
|
-
if (!response.ok || !response.body) throw new Error(await response.text() || `
|
|
52
|
+
if (!response.ok || !response.body) throw new Error(await response.text() || `Subagent wait failed (${response.status})`);
|
|
54
53
|
let result;
|
|
55
54
|
await readSseStream(response.body, (event) => {
|
|
56
|
-
const parsed =
|
|
55
|
+
const parsed = subagentResponseSchema.safeParse(event);
|
|
57
56
|
if (parsed.success) {
|
|
58
57
|
result = JSON.stringify(parsed.data);
|
|
59
58
|
return;
|
|
60
59
|
}
|
|
61
60
|
const failure = z.object({ error: z.string(), details: z.string().optional() }).safeParse(event);
|
|
62
61
|
if (failure.success) throw new Error(failure.data.details || failure.data.error);
|
|
63
|
-
throw new Error("
|
|
62
|
+
throw new Error("Subagent wait stream returned an invalid response");
|
|
64
63
|
});
|
|
65
|
-
if (!result) throw new Error("
|
|
64
|
+
if (!result) throw new Error("Subagent wait stream ended without a result");
|
|
66
65
|
return result;
|
|
67
66
|
}
|
|
68
|
-
var server = new McpServer({ name:
|
|
69
|
-
server.registerTool(
|
|
70
|
-
description: "List the agent providers
|
|
67
|
+
var server = new McpServer({ name: SUBAGENT_MCP_SERVER_NAME, version: "1.0.0" });
|
|
68
|
+
server.registerTool(SUBAGENT_MCP_TOOLS.getProviders, {
|
|
69
|
+
description: "List the agent providers allowed for subagents."
|
|
71
70
|
}, async () => ({
|
|
72
71
|
content: [{ type: "text", text: await request(`/chats/${parentChatId}/subagents`, "GET") }]
|
|
73
72
|
}));
|
|
74
|
-
server.registerTool(
|
|
73
|
+
server.registerTool(SUBAGENT_MCP_TOOLS.spawnAgent, {
|
|
75
74
|
description: "Spawn a child agent with all, none, or the latest N turns of parent context. Blocks by default; set blocking to false to return its chat ID immediately.",
|
|
76
75
|
inputSchema: {
|
|
77
|
-
provider:
|
|
78
|
-
prompt:
|
|
79
|
-
fork_turns:
|
|
80
|
-
model:
|
|
81
|
-
thinking_level:
|
|
82
|
-
title:
|
|
76
|
+
provider: spawnSubagentRequestSchema.shape.provider.describe("Provider returned by get_providers."),
|
|
77
|
+
prompt: spawnSubagentRequestSchema.shape.prompt.describe("The child\u2019s assigned task, scope, and expected result. Include all necessary context when fork_turns is none."),
|
|
78
|
+
fork_turns: spawnSubagentRequestSchema.shape.forkTurns.describe("Parent context to inherit: all (default), none, or a positive integer string such as 3 for the latest 3 user-led turns, including the current turn."),
|
|
79
|
+
model: spawnSubagentRequestSchema.shape.model,
|
|
80
|
+
thinking_level: spawnSubagentRequestSchema.shape.thinkingLevel,
|
|
81
|
+
title: spawnSubagentRequestSchema.shape.title,
|
|
83
82
|
blocking: z.boolean().optional().describe("Wait for the child to finish. Defaults to true."),
|
|
84
|
-
timeout_minutes:
|
|
83
|
+
timeout_minutes: waitSubagentRequestSchema.shape.timeoutMinutes.describe("Maximum time to wait without interrupting the child.")
|
|
85
84
|
}
|
|
86
85
|
}, async ({ provider, prompt, fork_turns, model, thinking_level, title, blocking, timeout_minutes }) => {
|
|
87
86
|
const created = await request(`/chats/${parentChatId}/subagents`, "POST", {
|
|
@@ -92,33 +91,33 @@ server.registerTool(RELAY_MCP_TOOLS.spawnAgent, {
|
|
|
92
91
|
...thinking_level ? { thinkingLevel: thinking_level } : {},
|
|
93
92
|
...title ? { title } : {}
|
|
94
93
|
});
|
|
95
|
-
const createdAgent =
|
|
94
|
+
const createdAgent = subagentResponseSchema.parse(JSON.parse(created));
|
|
96
95
|
return { content: [{ type: "text", text: blocking === false ? created : await waitForAgent(createdAgent.chatId, timeout_minutes) }] };
|
|
97
96
|
});
|
|
98
|
-
server.registerTool(
|
|
99
|
-
description: "Get the current status and final response, if available, for one of this
|
|
97
|
+
server.registerTool(SUBAGENT_MCP_TOOLS.getAgent, {
|
|
98
|
+
description: "Get the current status and final response, if available, for one of this chat\u2019s subagents.",
|
|
100
99
|
inputSchema: { chat_id: z.string().uuid() }
|
|
101
100
|
}, async ({ chat_id }) => ({
|
|
102
101
|
content: [{ type: "text", text: await request(`/chats/${parentChatId}/subagents/${chat_id}`, "GET") }]
|
|
103
102
|
}));
|
|
104
|
-
server.registerTool(
|
|
105
|
-
description: "Wait for one of this
|
|
103
|
+
server.registerTool(SUBAGENT_MCP_TOOLS.waitAgent, {
|
|
104
|
+
description: "Wait for one of this chat\u2019s subagents to finish over a heartbeat stream. A timeout stops waiting without interrupting the child.",
|
|
106
105
|
inputSchema: {
|
|
107
106
|
chat_id: z.string().uuid(),
|
|
108
|
-
timeout_minutes:
|
|
107
|
+
timeout_minutes: waitSubagentRequestSchema.shape.timeoutMinutes
|
|
109
108
|
}
|
|
110
109
|
}, async ({ chat_id, timeout_minutes }) => ({
|
|
111
110
|
content: [{ type: "text", text: await waitForAgent(chat_id, timeout_minutes) }]
|
|
112
111
|
}));
|
|
113
|
-
server.registerTool(
|
|
114
|
-
description: "Send a follow-up to one of this
|
|
112
|
+
server.registerTool(SUBAGENT_MCP_TOOLS.messageAgent, {
|
|
113
|
+
description: "Send a follow-up to one of this chat\u2019s subagents. Blocks by default; set blocking to false to return immediately.",
|
|
115
114
|
inputSchema: {
|
|
116
115
|
chat_id: z.string().uuid(),
|
|
117
|
-
message:
|
|
118
|
-
model:
|
|
119
|
-
thinking_level:
|
|
116
|
+
message: messageSubagentRequestSchema.shape.message,
|
|
117
|
+
model: messageSubagentRequestSchema.shape.model,
|
|
118
|
+
thinking_level: messageSubagentRequestSchema.shape.thinkingLevel,
|
|
120
119
|
blocking: z.boolean().optional().describe("Wait for the child to finish. Defaults to true."),
|
|
121
|
-
timeout_minutes:
|
|
120
|
+
timeout_minutes: waitSubagentRequestSchema.shape.timeoutMinutes.describe("Maximum time to wait without interrupting the child.")
|
|
122
121
|
}
|
|
123
122
|
}, async ({ chat_id, message, model, thinking_level, blocking, timeout_minutes }) => {
|
|
124
123
|
const accepted = await request(`/chats/${parentChatId}/subagents/${chat_id}/messages`, "POST", {
|
|
@@ -128,8 +127,8 @@ server.registerTool(RELAY_MCP_TOOLS.messageAgent, {
|
|
|
128
127
|
});
|
|
129
128
|
return { content: [{ type: "text", text: blocking === false ? accepted : await waitForAgent(chat_id, timeout_minutes) }] };
|
|
130
129
|
});
|
|
131
|
-
server.registerTool(
|
|
132
|
-
description: "Delete one of this
|
|
130
|
+
server.registerTool(SUBAGENT_MCP_TOOLS.deleteAgent, {
|
|
131
|
+
description: "Delete one of this chat\u2019s subagents.",
|
|
133
132
|
inputSchema: { chat_id: z.string().uuid() }
|
|
134
133
|
}, async ({ chat_id }) => ({
|
|
135
134
|
content: [{ type: "text", text: await request(`/chats/${parentChatId}/subagents/${chat_id}`, "DELETE") }]
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "replicas-engine",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.960",
|
|
4
4
|
"description": "Lightweight API server for Replicas workspaces",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
7
7
|
"bin": {
|
|
8
8
|
"replicas-engine": "./dist/src/index.js",
|
|
9
|
-
"replicas-
|
|
9
|
+
"replicas-subagent-mcp": "./dist/src/subagent-mcp.js",
|
|
10
10
|
"replicas-headless-agent": "./dist/src/headless-agent.js",
|
|
11
11
|
"replicas-command-protection-hook": "./dist/src/command-protection-hook.js",
|
|
12
12
|
"replicas-post-tool-pr-hook": "./dist/src/post-tool-pr-hook.js",
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
3
|
-
const require = __createRequire(import.meta.url);
|
|
4
|
-
import {
|
|
5
|
-
RELAY_MCP_TOOL_NAMES
|
|
6
|
-
} from "./chunk-7GWXM2H5.js";
|
|
7
|
-
|
|
8
|
-
// src/managers/relay-mcp-config.ts
|
|
9
|
-
import { existsSync } from "fs";
|
|
10
|
-
import { dirname, join } from "path";
|
|
11
|
-
import { fileURLToPath } from "url";
|
|
12
|
-
import { createRequire } from "module";
|
|
13
|
-
var RELAY_MCP_TOOL_TIMEOUT_MS = 24 * 60 * 60 * 1e3 + 6e4;
|
|
14
|
-
function relayMcpProcessConfig(parentChatId) {
|
|
15
|
-
const directory = dirname(fileURLToPath(import.meta.url));
|
|
16
|
-
const builtEntry = join(directory, "relay-mcp.js");
|
|
17
|
-
const sourceEntry = join(directory, "..", "relay-mcp.ts");
|
|
18
|
-
const entry = existsSync(builtEntry) ? builtEntry : sourceEntry;
|
|
19
|
-
return {
|
|
20
|
-
command: process.execPath,
|
|
21
|
-
args: [
|
|
22
|
-
...entry.endsWith(".ts") ? ["--import", createRequire(import.meta.url).resolve("tsx/esm")] : [],
|
|
23
|
-
entry,
|
|
24
|
-
"--parent",
|
|
25
|
-
parentChatId
|
|
26
|
-
]
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
function relayCodexMcpConfig(parentChatId) {
|
|
30
|
-
return {
|
|
31
|
-
...relayMcpProcessConfig(parentChatId),
|
|
32
|
-
env_vars: ["REPLICAS_ENGINE_PORT", "REPLICAS_ENGINE_SECRET"],
|
|
33
|
-
enabled_tools: [...RELAY_MCP_TOOL_NAMES],
|
|
34
|
-
required: true,
|
|
35
|
-
default_tools_approval_mode: "approve",
|
|
36
|
-
startup_timeout_sec: 10,
|
|
37
|
-
tool_timeout_sec: Math.ceil(RELAY_MCP_TOOL_TIMEOUT_MS / 1e3)
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export {
|
|
42
|
-
RELAY_MCP_TOOL_TIMEOUT_MS,
|
|
43
|
-
relayMcpProcessConfig,
|
|
44
|
-
relayCodexMcpConfig
|
|
45
|
-
};
|