pluriply 0.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/LICENSE-HUB.md +38 -0
- package/LICENSE.md +32 -0
- package/README.md +76 -0
- package/bin/pluriply.js +189 -0
- package/package.json +26 -0
- package/src/connector/hub-client.js +327 -0
- package/src/connector/mcp-server.js +51 -0
- package/src/connector/tools.js +727 -0
- package/src/hub/index.js +11 -0
- package/src/setup/clients.js +202 -0
- package/src/setup/run-setup.js +82 -0
- package/src/shared/agy.js +17 -0
- package/src/shared/identity.js +55 -0
- package/src/shared/ids.js +27 -0
- package/src/shared/mcp-register.js +79 -0
- package/src/shared/paths.js +7 -0
- package/src/shared/probe.js +54 -0
- package/src/shared/version.js +18 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
+
import { isValidAgentName, resolveAgentName } from "../shared/identity.js";
|
|
4
|
+
import { HubClient } from "./hub-client.js";
|
|
5
|
+
import { registerTools, hello } from "./tools.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 허브 접속·정체성 확인·도구 등록까지 수행한다(stdio 연결은 하지 않는다 —
|
|
9
|
+
* 테스트가 StdioServerTransport 없이 재사용할 수 있도록 분리).
|
|
10
|
+
* @param {{agent: string, home?: string}} opts
|
|
11
|
+
* @returns {Promise<{hub: import('./hub-client.js').HubClient, instanceId: string|null, server: import('@modelcontextprotocol/sdk/server/mcp.js').McpServer}>}
|
|
12
|
+
*/
|
|
13
|
+
export async function buildConnector({ agent, home }) {
|
|
14
|
+
const hub = await HubClient.connect({ home });
|
|
15
|
+
// 구형 허브에는 agent.hello가 없다. 여기서 죽지 말고(unknown message type로
|
|
16
|
+
// 던지지 말고) 도구가 첫 호출마다 재시작 안내를 내게 둔다(tools.js:72, 131).
|
|
17
|
+
const instanceId = hub.stale
|
|
18
|
+
? null
|
|
19
|
+
: await hello(hub, {
|
|
20
|
+
agent,
|
|
21
|
+
worker: Boolean(process.env.PLURIPLY_WORKER_TASK),
|
|
22
|
+
});
|
|
23
|
+
const server = new McpServer({ name: "pluriply", version: "0.1.0" });
|
|
24
|
+
registerTools(server, hub, { agent, instanceId });
|
|
25
|
+
return { hub, instanceId, server };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** stdio MCP 커넥터를 시작한다. AI 도구가 이 프로세스를 MCP 서버로 실행한다. */
|
|
29
|
+
export async function startConnector({ agent, home }) {
|
|
30
|
+
if (!isValidAgentName(agent)) {
|
|
31
|
+
console.error(`invalid agent name: ${agent}`);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
const resolved = resolveAgentName(agent, process.env);
|
|
35
|
+
if (resolved !== agent) console.error(`pluriply: --agent ${agent} launched by Antigravity IDE, joining as ${resolved}`);
|
|
36
|
+
const { hub, server } = await buildConnector({ agent: resolved, home });
|
|
37
|
+
await server.connect(new StdioServerTransport());
|
|
38
|
+
// AI 도구(부모)가 죽거나 MCP 서버를 내리면 stdin 이 닫힌다. 허브 WebSocket 이 이벤트 루프를
|
|
39
|
+
// 붙잡고 있어 그대로 두면 커넥터가 고아로 남으므로(실측: 하루 넘게 살아남은 프로세스 다수),
|
|
40
|
+
// stdin 종료 시 허브 연결을 닫고 곧바로 끝낸다.
|
|
41
|
+
const shutdown = () => {
|
|
42
|
+
try {
|
|
43
|
+
hub.close();
|
|
44
|
+
} catch {
|
|
45
|
+
// 이미 닫힌 경우 등: 무시
|
|
46
|
+
}
|
|
47
|
+
process.exit(0);
|
|
48
|
+
};
|
|
49
|
+
process.stdin.once("end", shutdown);
|
|
50
|
+
process.stdin.once("close", shutdown);
|
|
51
|
+
}
|