-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-visibility.js
More file actions
51 lines (43 loc) · 1.74 KB
/
Copy pathtest-visibility.js
File metadata and controls
51 lines (43 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const { spawn } = require("child_process");
const KEY = process.env.COSMOS_MCP_KEY;
function callTool(name, args) {
return new Promise((resolve, reject) => {
const proc = spawn("node", ["index.js"], {
env: { ...process.env, COSMOS_MCP_KEY: KEY }
});
let buffer = "";
proc.stdout.on("data", (d) => {
buffer += d.toString();
const lines = buffer.split("\n");
buffer = lines.pop();
for (const line of lines) {
if (!line.trim()) continue;
try {
const msg = JSON.parse(line);
if (msg.id === 2) resolve(msg);
} catch {}
}
});
proc.stderr.on("data", (d) => {});
const send = (obj) => proc.stdin.write(JSON.stringify(obj) + "\n");
send({ jsonrpc: "2.0", id: 1, method: "initialize", params: { protocolVersion: "2024-11-05", capabilities: {}, clientInfo: { name: "kimi-cli", version: "1.0.0" } } });
setTimeout(() => send({ jsonrpc: "2.0", method: "notifications/initialized" }), 300);
setTimeout(() => {
send({ jsonrpc: "2.0", id: 2, method: "tools/call", params: { name, arguments: args } });
}, 600);
setTimeout(() => proc.kill(), 15000);
});
}
async function main() {
console.log("=== Capture turn ===");
const c1 = await callTool("cosmos_capture_turn", {
user_text: "Visibility test. Can the backend see this node immediately after capture?",
assistant_text: "Testing immediate visibility of captured nodes in the graph.",
source: "kimi-code"
});
console.log(c1.result.content[0].text);
console.log("\n=== Query for the node immediately ===");
const q1 = await callTool("cosmos_query", { query: "visibility test captured node" });
console.log(q1.result.content[0].text.slice(0, 500));
}
main().catch(console.error);