2026-08-21 21:37:28 +03:00
|
|
|
import path from "node:path";
|
|
|
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
|
|
|
|
|
|
/** Repository root (this file is at <root>/config.ts). */
|
|
|
|
|
export const ROOT = path.dirname(fileURLToPath(import.meta.url));
|
|
|
|
|
|
|
|
|
|
export const PATHS = {
|
|
|
|
|
root: ROOT,
|
2026-08-22 02:18:27 +03:00
|
|
|
/** Teacher system prompt — the agent's instructions (src/agent/). */
|
|
|
|
|
teacherPrompt: path.join(ROOT, "src", "agent", "system-prompt.md"),
|
2026-08-21 21:37:28 +03:00
|
|
|
data: path.join(ROOT, "data"),
|
2026-08-22 02:18:27 +03:00
|
|
|
/** Chat sessions (AI SDK UIMessage transcripts, one JSON file per chat). */
|
|
|
|
|
chats: path.join(ROOT, "data", "chats"),
|
2026-08-21 21:37:28 +03:00
|
|
|
graph: path.join(ROOT, "data", "graph"),
|
|
|
|
|
} as const;
|
|
|
|
|
|
2026-09-01 01:47:47 +03:00
|
|
|
// ─── Models ────────────────────────────────────────────────────────────────
|
|
|
|
|
// THE single place every LLM is chosen and tuned. .env stays for secrets
|
|
|
|
|
// (API keys) only — model choice and thinking budget are product tuning,
|
|
|
|
|
// not deployment environment, and this section is the one place they grow.
|
2026-09-12 06:02:40 +03:00
|
|
|
// `effort` is pi's thinking-level scale (off|minimal|low|medium|high|xhigh
|
|
|
|
|
// |max): the per-model truth lives in pi-ai's catalog (thinkingLevelMap) —
|
|
|
|
|
// getSupportedThinkingLevels(model) lists what a model actually accepts,
|
|
|
|
|
// and streamSimple clamps any other value to the nearest supported one
|
|
|
|
|
// (e.g. GLM-5.3-flash supports exactly low|high|max).
|
2026-09-01 01:47:47 +03:00
|
|
|
|
2026-09-12 06:02:40 +03:00
|
|
|
export type ThinkingLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
|
2026-09-01 01:47:47 +03:00
|
|
|
|
|
|
|
|
export interface ModelSpec {
|
2026-09-12 06:02:40 +03:00
|
|
|
/** OpenRouter model id (e.g. "z-ai/glm-5.3-flash") — must exist in pi-ai's catalog. */
|
2026-09-01 01:47:47 +03:00
|
|
|
model: string;
|
|
|
|
|
/** Thinking budget — what the model may spend on reasoning tokens. */
|
2026-09-12 06:02:40 +03:00
|
|
|
effort: ThinkingLevel;
|
2026-09-01 01:47:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const MODELS = {
|
2026-09-11 06:44:20 +03:00
|
|
|
/** The prober (agent A) — edge-bracketing questions; keep it lively and adaptive. */
|
2026-09-12 06:02:40 +03:00
|
|
|
prober: { model: "z-ai/glm-5.3-flash", effort: "low" },
|
2026-09-11 06:44:20 +03:00
|
|
|
/** The teacher (agent B) — planning + streaming, lesson-facing: smart, but keep it lively. */
|
2026-09-12 06:02:40 +03:00
|
|
|
teacher: { model: "z-ai/glm-5.3-flash", effort: "low" },
|
2026-09-01 01:47:47 +03:00
|
|
|
/** Background sub-agents: fast and cheap beats deep thought. */
|
2026-09-12 06:02:40 +03:00
|
|
|
researcher: { model: "z-ai/glm-5.3-flash", effort: "low" },
|
|
|
|
|
demoBuilder: { model: "z-ai/glm-5.3-flash", effort: "low" },
|
2026-09-01 01:47:47 +03:00
|
|
|
/** Must be vision-capable: it looks at rendered SVGs. */
|
2026-09-12 06:02:40 +03:00
|
|
|
visualMaker: { model: "qwen/qwen3.8-flash", effort: "low" },
|
2026-09-01 01:47:47 +03:00
|
|
|
/** Extraction is judgment over given evidence — light thinking suffices. */
|
2026-09-12 06:02:40 +03:00
|
|
|
extractor: { model: "z-ai/glm-5.3-flash", effort: "low" },
|
2026-09-01 01:47:47 +03:00
|
|
|
/** The auditor verifies evidence exists; keep it cheap. */
|
2026-09-12 06:02:40 +03:00
|
|
|
auditor: { model: "z-ai/glm-5.3-flash", effort: "low" },
|
2026-09-13 03:59:48 +03:00
|
|
|
/** Names detected communities — one singular call, given member names
|
|
|
|
|
* + statements. Purely a labeling flourish; keep it cheap. */
|
|
|
|
|
labeler: { model: "z-ai/glm-5.3-flash", effort: "low" },
|
2026-09-01 01:47:47 +03:00
|
|
|
} satisfies Record<string, ModelSpec>;
|
|
|
|
|
|
|
|
|
|
export type ModelRole = keyof typeof MODELS;
|
|
|
|
|
|
2026-08-22 10:11:58 +03:00
|
|
|
/**
|
2026-08-31 22:36:41 +03:00
|
|
|
* The extraction pipeline (vision §1 construction): the sole graph writer.
|
|
|
|
|
* Triggered per chat once this many NEW quiz answers have landed since the
|
2026-09-01 01:47:47 +03:00
|
|
|
* chat's last extraction checkpoint. The trigger mechanism is a v1
|
|
|
|
|
* placeholder — deliberately isolated behind one seam
|
2026-08-31 22:36:41 +03:00
|
|
|
* (server/turn-service.ts) so it can be swapped without touching the
|
|
|
|
|
* pipeline.
|
|
|
|
|
*/
|
2026-09-01 01:47:47 +03:00
|
|
|
export const EXTRACTION = { everyNQuizAnswers: 3 } as const;
|
2026-08-31 22:36:41 +03:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The LIVE graph store (src/store/graph.ts) — owned by the app's extraction
|
2026-08-22 10:11:58 +03:00
|
|
|
* pipeline. Line shapes: src/core/contracts.ts.
|
|
|
|
|
*/
|
2026-08-21 21:37:28 +03:00
|
|
|
export const LEDGER_FILES = {
|
|
|
|
|
nodes: path.join(PATHS.graph, "nodes.jsonl"),
|
|
|
|
|
edges: path.join(PATHS.graph, "edges.jsonl"),
|
|
|
|
|
events: path.join(PATHS.graph, "events.jsonl"),
|
|
|
|
|
mappings: path.join(PATHS.graph, "mappings.jsonl"),
|
|
|
|
|
sessions: path.join(PATHS.graph, "sessions.jsonl"),
|
2026-09-13 03:59:48 +03:00
|
|
|
/** LLM-named community records (contracts/graph.ts ClusterLabeling). */
|
|
|
|
|
clusterLabels: path.join(PATHS.graph, "cluster-labels.jsonl"),
|
2026-08-21 21:37:28 +03:00
|
|
|
} as const;
|
2026-09-13 02:08:55 +03:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Notes-import bookkeeping (NOT a ledger): one JSON map, src-id → NotesSource
|
|
|
|
|
* record (contracts/graph.ts) — the file path + import time + the run's usage
|
|
|
|
|
* log. Read-modify-write like a chat file, not append-only like the ledgers.
|
|
|
|
|
*/
|
|
|
|
|
export const SOURCES_FILE = path.join(PATHS.graph, "sources.json");
|
2026-09-13 05:56:27 +03:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Graph render settings (the settings-panel controls): one small JSON blob,
|
|
|
|
|
* read-modify-write. Shared shape/sanitizer: src/core/render-settings.ts.
|
|
|
|
|
*/
|
|
|
|
|
export const RENDER_SETTINGS_FILE = path.join(PATHS.graph, "render-settings.json");
|