replicas-engine 0.1.957 → 0.1.959

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.
@@ -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-4HVJFYXK.js";
6
+ } from "./chunk-XFGXRH7Q.js";
7
7
  import {
8
8
  isRecord
9
9
  } from "./chunk-UZSNFLDQ.js";
10
10
  import {
11
11
  shouldRefreshPullRequests
12
- } from "./chunk-FK3P6B55.js";
12
+ } from "./chunk-QXISBAH5.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-YUMGTIR3.js";
5
4
  import {
6
- RELAY_MCP_SERVER_NAME,
7
- RELAY_MCP_TOOLS,
8
- messageRelaySubagentRequestSchema,
5
+ SUBAGENT_MCP_SERVER_NAME,
6
+ SUBAGENT_MCP_TOOLS,
7
+ messageSubagentRequestSchema,
9
8
  readSseStream,
10
- relaySubagentResponseSchema,
11
- spawnRelaySubagentRequestSchema,
12
- waitRelaySubagentRequestSchema
13
- } from "./chunk-FK3P6B55.js";
9
+ spawnSubagentRequestSchema,
10
+ subagentResponseSchema,
11
+ waitSubagentRequestSchema
12
+ } from "./chunk-QXISBAH5.js";
14
13
  import "./chunk-VEQXQN22.js";
15
14
 
16
- // src/relay-mcp.ts
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 || `Relay request failed (${response.status})`);
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() || `Relay wait failed (${response.status})`);
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 = relaySubagentResponseSchema.safeParse(event);
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("Relay wait stream returned an invalid response");
62
+ throw new Error("Subagent wait stream returned an invalid response");
64
63
  });
65
- if (!result) throw new Error("Relay wait stream ended without a result");
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: RELAY_MCP_SERVER_NAME, version: "1.0.0" });
69
- server.registerTool(RELAY_MCP_TOOLS.getProviders, {
70
- description: "List the agent providers Relay is allowed to use and the configured Relay base provider."
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(RELAY_MCP_TOOLS.spawnAgent, {
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: spawnRelaySubagentRequestSchema.shape.provider.describe("Provider returned by get_providers."),
78
- prompt: spawnRelaySubagentRequestSchema.shape.prompt.describe("The child\u2019s assigned task, scope, and expected result. Include all necessary context when fork_turns is none."),
79
- fork_turns: spawnRelaySubagentRequestSchema.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."),
80
- model: spawnRelaySubagentRequestSchema.shape.model,
81
- thinking_level: spawnRelaySubagentRequestSchema.shape.thinkingLevel,
82
- title: spawnRelaySubagentRequestSchema.shape.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: waitRelaySubagentRequestSchema.shape.timeoutMinutes.describe("Maximum time to wait without interrupting the child.")
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 = relaySubagentResponseSchema.parse(JSON.parse(created));
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(RELAY_MCP_TOOLS.getAgent, {
99
- description: "Get the current status and final response, if available, for one of this Relay chat\u2019s child agents.",
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(RELAY_MCP_TOOLS.waitAgent, {
105
- description: "Wait for one of this Relay chat\u2019s child agents to finish over a heartbeat stream. A timeout stops waiting without interrupting the child.",
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: waitRelaySubagentRequestSchema.shape.timeoutMinutes
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(RELAY_MCP_TOOLS.messageAgent, {
114
- description: "Send a follow-up to one of this Relay chat\u2019s child agents. Blocks by default; set blocking to false to return immediately.",
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: messageRelaySubagentRequestSchema.shape.message,
118
- model: messageRelaySubagentRequestSchema.shape.model,
119
- thinking_level: messageRelaySubagentRequestSchema.shape.thinkingLevel,
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: waitRelaySubagentRequestSchema.shape.timeoutMinutes.describe("Maximum time to wait without interrupting the child.")
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(RELAY_MCP_TOOLS.deleteAgent, {
132
- description: "Delete one of this Relay chat\u2019s child agents.",
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.957",
3
+ "version": "0.1.959",
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-relay-mcp": "./dist/src/relay-mcp.js",
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-FK3P6B55.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
- };