-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-durable-delta.js
More file actions
69 lines (57 loc) · 2.66 KB
/
Copy pathtest-durable-delta.js
File metadata and controls
69 lines (57 loc) · 2.66 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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 1 (durable preference) ===");
const c1 = await callTool("cosmos_capture_turn", {
user_text: "I deeply value having an autonomous cognitive layer that updates after every conversation. This is a core preference for how I want AI to work in my life.",
assistant_text: "Noted as a durable preference. The autonomous frontal lobe is now the default architecture for your Cosmos graph.",
source: "kimi-code"
});
console.log(c1.result.content[0].text);
console.log("\n=== Wait 5s for refresh ===");
await new Promise(r => setTimeout(r, 5000));
console.log("\n=== Query delta after turn 1 ===");
const d1 = await callTool("cosmos_delta", {});
console.log(d1.result.content[0].text);
console.log("\n=== Capture turn 2 (durable preference) ===");
const c2 = await callTool("cosmos_capture_turn", {
user_text: "I also want my path tree to track how my desires shift over time. What I consider probable today might become preferable tomorrow as I make decisions.",
assistant_text: "Tracking path dynamics as a durable preference. The path system will monitor categorization shifts and evidence accumulation.",
source: "kimi-code"
});
console.log(c2.result.content[0].text);
console.log("\n=== Wait 5s for refresh ===");
await new Promise(r => setTimeout(r, 5000));
console.log("\n=== Query delta after turn 2 ===");
const d2 = await callTool("cosmos_delta", {});
console.log(d2.result.content[0].text);
}
main().catch(console.error);