|
| 1 | +// Exercise every v0.9.0 YantrikDB capability Chronicler does NOT yet use, |
| 2 | +// against the live server, so we recommend from evidence not from docs. |
| 3 | + |
| 4 | +import { Client } from "@modelcontextprotocol/sdk/client/index.js"; |
| 5 | +import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"; |
| 6 | + |
| 7 | +const STACK = process.env.CHRONICLER_URL ?? "http://127.0.0.1:3001/api/mcp"; |
| 8 | +const NS = `v09probe-${Date.now().toString(36)}`; |
| 9 | + |
| 10 | +let client: Client; |
| 11 | + |
| 12 | +async function call(tool: string, args: Record<string, unknown>): Promise<unknown> { |
| 13 | + const res = await client.callTool({ name: tool, arguments: args }); |
| 14 | + const content = (res as { content?: Array<{ type?: string; text?: string }> }).content ?? []; |
| 15 | + const text = content.filter((c) => c.type === "text").map((c) => c.text ?? "").join(""); |
| 16 | + if (text.startsWith("Error executing tool")) throw new Error(text); |
| 17 | + try { return JSON.parse(text); } catch { return text; } |
| 18 | +} |
| 19 | + |
| 20 | +function show(label: string, v: unknown, chars = 500): void { |
| 21 | + const s = typeof v === "string" ? v : JSON.stringify(v, null, 2); |
| 22 | + console.log(`${label}:\n${s.slice(0, chars)}${s.length > chars ? "\n …(truncated)" : ""}\n`); |
| 23 | +} |
| 24 | + |
| 25 | +async function section(name: string, fn: () => Promise<void>): Promise<boolean> { |
| 26 | + console.log(`\n${"█".repeat(70)}\n██ ${name}\n${"█".repeat(70)}`); |
| 27 | + try { await fn(); console.log(`✓ ${name} WORKS`); return true; } |
| 28 | + catch (e) { console.log(`✗ ${name} FAILED: ${e instanceof Error ? e.message.slice(0, 300) : String(e)}`); return false; } |
| 29 | +} |
| 30 | + |
| 31 | +async function main(): Promise<void> { |
| 32 | + client = new Client({ name: "v09probe", version: "0.1.0" }, { capabilities: {} }); |
| 33 | + await client.connect(new StreamableHTTPClientTransport(new URL(STACK))); |
| 34 | + console.log(`namespace: ${NS}\n`); |
| 35 | + const results: Record<string, boolean> = {}; |
| 36 | + |
| 37 | + // ── 1. session digest — one-call boot briefing ──────────────────── |
| 38 | + results["session digest"] = await section("session digest (boot-time briefing)", async () => { |
| 39 | + const d = await call("session", { action: "digest", namespace: NS, max_decisions: 3, max_conflicts: 3, max_triggers: 3, snippet_chars: 120 }); |
| 40 | + show("digest", d, 900); |
| 41 | + }); |
| 42 | + |
| 43 | + // ── 2. knowledge gaps — the substrate's known unknowns ──────────── |
| 44 | + results["gaps"] = await section("gaps (known unknowns / demand log)", async () => { |
| 45 | + // Ask the same unanswerable question repeatedly to create a gap. |
| 46 | + for (let i = 0; i < 4; i++) { |
| 47 | + await call("recall", { query: "what is Ren's mother's name", top_k: 3, namespace: NS }); |
| 48 | + } |
| 49 | + const g = await call("gaps", { min_count: 1, max_avg_top_score: 0.9, limit: 10 }); |
| 50 | + show("gaps", g, 900); |
| 51 | + }); |
| 52 | + |
| 53 | + // ── 3. conversation ring buffer ─────────────────────────────────── |
| 54 | + results["conversation"] = await section("conversation (verbatim working-memory ring)", async () => { |
| 55 | + await call("conversation", { action: "record", namespace: NS, role: "user", content: "Do you remember the lighthouse?", max_turns: 6 }); |
| 56 | + await call("conversation", { action: "record", namespace: NS, role: "assistant", content: "Ren nods. 'Saturday, at dusk.'", max_turns: 6 }); |
| 57 | + const recent = await call("conversation", { action: "recent", namespace: NS, limit: 5 }); |
| 58 | + show("recent turns", recent, 600); |
| 59 | + }); |
| 60 | + |
| 61 | + // ── 4. task store — deferred follow-through ─────────────────────── |
| 62 | + results["task"] = await section("task (substrate-backed commitments)", async () => { |
| 63 | + const added = await call("task", { action: "add", namespace: NS, title: "Meet Pranab at the lighthouse Saturday at dusk", priority: "high" }); |
| 64 | + show("added", added, 300); |
| 65 | + const list = await call("task", { action: "list", namespace: NS, status: "open" }); |
| 66 | + show("open tasks", list, 600); |
| 67 | + }); |
| 68 | + |
| 69 | + // ── 5. record-to-record links + link-expanded recall ────────────── |
| 70 | + results["record links"] = await section("graph record_link + recall_with_links", async () => { |
| 71 | + const a = (await call("remember", { text: "Ren promised to meet Pranab at the lighthouse on Saturday at dusk.", namespace: NS, importance: 0.8 })) as { rid: string }; |
| 72 | + const b = (await call("remember", { text: "The lighthouse at Port Lyra has been unmanned since the storm.", namespace: NS, importance: 0.6 })) as { rid: string }; |
| 73 | + show("rids", { a: a.rid, b: b.rid }, 200); |
| 74 | + const linked = await call("graph", { action: "record_link", source_rid: a.rid, target_rid: b.rid, link_type: "concerns" }); |
| 75 | + show("record_link", linked, 300); |
| 76 | + const traversed = await call("graph", { action: "linked_records", rid: a.rid, direction: "both" }); |
| 77 | + show("linked_records", traversed, 600); |
| 78 | + const expanded = await call("graph", { action: "recall_with_links", query: "lighthouse meeting", top_k: 3, expand_links: 2, namespace: NS }); |
| 79 | + show("recall_with_links", expanded, 800); |
| 80 | + }); |
| 81 | + |
| 82 | + // ── 6. autonomous maintenance cycle (dry run) ───────────────────── |
| 83 | + results["maintenance_cycle"] = await section("think maintenance_cycle (dry run)", async () => { |
| 84 | + const m = await call("think", { maintenance_cycle: true, dry_run: true }); |
| 85 | + show("cycle preview", m, 900); |
| 86 | + }); |
| 87 | + |
| 88 | + // ── 7. skill outcomes telemetry ─────────────────────────────────── |
| 89 | + results["stats skill_outcomes"] = await section("stats skill_outcomes", async () => { |
| 90 | + const s = await call("stats", { action: "skill_outcomes" }); |
| 91 | + show("skill outcomes", s, 400); |
| 92 | + }); |
| 93 | + |
| 94 | + console.log(`\n${"═".repeat(70)}\nSUMMARY\n${"═".repeat(70)}`); |
| 95 | + for (const [k, v] of Object.entries(results)) console.log(` ${v ? "✓" : "✗"} ${k}`); |
| 96 | + const working = Object.values(results).filter(Boolean).length; |
| 97 | + console.log(`\n${working}/${Object.keys(results).length} v0.9.0 capabilities verified working`); |
| 98 | + await client.close(); |
| 99 | +} |
| 100 | + |
| 101 | +main().catch((e) => { console.error(e); process.exit(1); }); |
0 commit comments