#!/usr/bin/env node import { Server } from '@modelcontextprotocol/sdk/server/index.js'; import { CortexStore } from '../db/store.js'; /** Engagement state lives next to the database; key=value so bash can grep it. */ export declare function deriveEngagementPath(dir: string): string; export declare function configureEngagementPath(dir: string): string; export declare function readEngagement(): Record; export declare function writeEngagement(key: string, value: string): void; export declare function renderCortexRoute(): string; export declare const TOOL_DEFINITIONS: readonly [{ readonly name: "cortex_route"; readonly description: "Cold-callable route/help entry point for Cortex ambient memory. Explains automatic capture, reflex whispers, and when to use recall, state, brief, note, engage, or disengage."; readonly inputSchema: { readonly type: "object"; readonly properties: {}; readonly required: readonly []; }; }, { readonly name: "cortex_state"; readonly description: "Load the broader Cortex working set when you explicitly need more context than the session brief and ambient reflex whispers provide, especially after context loss, dense resumptions, or unclear current direction. Returns current-valid notes first, recent decisions, branch snapshot, and the last-session tail, within a token budget (default 800)."; readonly inputSchema: { readonly type: "object"; readonly properties: { readonly budget: { readonly type: "number"; readonly description: "Optional output token budget (default 800); lower-priority sections drop first"; }; }; readonly required: readonly []; }; }, { readonly name: "cortex_note"; readonly description: "Save durable memory for future sessions only. Use it for decisions (include rejected alternatives), blockers, committed approaches, and non-obvious constraints or gotchas. Do not use it for acknowledgments, routine progress, or anything obvious from code or git. Notes compete for retrieval, so keep them load-bearing."; readonly inputSchema: { readonly type: "object"; readonly properties: { readonly kind: { readonly type: "string"; readonly enum: readonly ["insight", "decision", "intent", "blocker", "focus"]; readonly description: "Type of note"; }; readonly content: { readonly type: "string"; readonly description: "Note content"; }; readonly subject: { readonly type: "string"; readonly description: "Subject/topic the note concerns (required for decision, intent, blocker, focus)"; }; readonly alternatives: { readonly type: "array"; readonly items: { readonly type: "string"; }; readonly description: "Alternative options considered (optional)"; }; }; readonly required: readonly ["kind", "content"]; }; }, { readonly name: "cortex_resolve"; readonly description: "Close out a previously saved note: mark a decision/blocker/intent as resolved (done, no longer load-bearing) or superseded. Resolved notes go cold and stop appearing in briefs and default state. Pass replacement content to supersede with an updated note in one step."; readonly inputSchema: { readonly type: "object"; readonly properties: { readonly note_id: { readonly type: "string"; readonly description: "Exact note id to resolve (preferred when known)"; }; readonly subject: { readonly type: "string"; readonly description: "Subject of the active note to resolve (used when note_id is not given)"; }; readonly status: { readonly type: "string"; readonly enum: readonly ["resolved", "superseded"]; readonly description: "Default 'resolved'"; }; readonly replacement: { readonly type: "string"; readonly description: "Optional new content; writes a replacement note that supersedes the old one"; }; }; readonly required: readonly []; }; }, { readonly name: "cortex_recall"; readonly description: "Pull evidence from prior sessions on a topic before re-investigating familiar ground, revisiting recurring bugs or tests, proposing changes in an area with history, or touching a system where prior decisions may matter. Answer-shaped: a lead line naming the most relevant memory and its trust level, then timestamped evidence. Current-valid memories rank first; stale or moved file references are labeled because repo truth beats memory. Output stays within a token budget."; readonly inputSchema: { readonly type: "object"; readonly properties: { readonly topic: { readonly type: "string"; readonly description: "Topic to search for"; }; readonly budget: { readonly type: "number"; readonly description: "Optional output token budget (default 600); evidence drops from the bottom"; }; readonly detail: { readonly type: "string"; readonly enum: readonly ["none", "scores"]; readonly description: "Optional: 'scores' appends per-result rank breakdowns for debugging retrieval quality"; }; }; readonly required: readonly ["topic"]; }; }, { readonly name: "cortex_brief"; readonly description: "Compact topical context to paste into a subagent prompt, within a token budget (default 450). Call before dispatching an Agent on a non-trivial task in a topic with history in this repo. Returns a smaller, focused subset than cortex_state, decisions first. Paste the result into the agent prompt yourself; do not ask subagents to call cortex_brief because they do not share your session context reliably."; readonly inputSchema: { readonly type: "object"; readonly properties: { readonly topic: { readonly type: "string"; readonly description: "Topic to brief on"; }; readonly for: { readonly type: "string"; readonly description: "Name of the agent being briefed (optional)"; }; readonly budget: { readonly type: "number"; readonly description: "Optional output token budget (default 450)"; }; }; readonly required: readonly ["topic"]; }; }, { readonly name: "cortex_engage"; readonly description: "Activate Cortex capture for this session and immediately load the current working memory. Usually already engaged by `cortex inject-header` at session start. Call it after cortex_disengage or if startup wiring did not run."; readonly inputSchema: { readonly type: "object"; readonly properties: {}; readonly required: readonly []; }; }, { readonly name: "cortex_disengage"; readonly description: "Turn off Cortex capture and enforcement gates for this session. Use sparingly: when running throwaway or destructive work you do not want memorialized, or while debugging Cortex itself. Call cortex_engage to re-enable."; readonly inputSchema: { readonly type: "object"; readonly properties: {}; readonly required: readonly []; }; }, { readonly name: "cortex_summarize"; readonly description: "Checkpoint the session before it ends so the next one resumes gracefully. Call it after a meaningful unit of work, before a long break, or when the user explicitly stops for the day. Next-session inject-header uses this summary as the resume tail. Skip throwaway sessions."; readonly inputSchema: { readonly type: "object"; readonly properties: { readonly what: { readonly type: "string"; readonly description: "Brief description of what the session accomplished (optional; auto-inferred from events if omitted)"; }; }; readonly required: readonly []; }; }, { readonly name: "cortex_suggest_notes"; readonly description: "Suggest load-bearing Cortex notes from the current session without writing them. Use this to review possible decisions, blockers, intents, or insights before calling cortex_note explicitly."; readonly inputSchema: { readonly type: "object"; readonly properties: { readonly sessionId: { readonly type: "string"; readonly description: "Session id to inspect. Defaults to the current scoped session."; }; }; readonly required: readonly []; }; }, { readonly name: "cortex_validate_memory"; readonly description: "Audit Cortex memories against the current checkout without deleting notes. Use when retrieved memory mentions files, plans, or app state that may be stale; returns current/stale status and missing references."; readonly inputSchema: { readonly type: "object"; readonly properties: { readonly topic: { readonly type: "string"; readonly description: "Optional topic to validate. Defaults to recent memory."; }; }; readonly required: readonly []; }; }, { readonly name: "cortex_read_ledger"; readonly description: "Ask whether you have already read a file in this scope and whether it has changed since (FR-6). Returns one of exactly four verdicts per file — unread, unchanged-since, changed-since, edited-by-you-since — produced by re-hashing the current bytes, never by trusting mtime. A read recorded by a sibling or descendant session is reported as a change fact but attributed to that agent, never as \"you read it\"."; readonly inputSchema: { readonly type: "object"; readonly properties: { readonly paths: { readonly type: "array"; readonly items: { readonly type: "string"; }; readonly description: "File paths to ask about (max 20). Relative paths resolve against the current working directory."; }; }; readonly required: readonly ["paths"]; }; }, { readonly name: "cortex_search_ledger"; readonly description: "Ask whether a search already returned zero results and provably still would (FR-13). Per query: no-matches-at (the root re-fingerprints byte-identical to the recorded census — asserted from evidence, never mtime), miss (no record, or the tree changed), or unknown (cannot be established either way). Scope-bounded: a negative recorded on another branch is never asserted here."; readonly inputSchema: { readonly type: "object"; readonly properties: { readonly queries: { readonly type: "array"; readonly items: { readonly type: "object"; readonly properties: { readonly pattern: { readonly type: "string"; readonly description: "The search pattern, exactly as it would be run."; }; readonly path: { readonly type: "string"; readonly description: "Search root; relative resolves against the current working directory. Omit for the project root."; }; readonly glob: { readonly type: "string"; }; readonly type: { readonly type: "string"; }; readonly caseInsensitive: { readonly type: "boolean"; }; readonly multiline: { readonly type: "boolean"; }; }; readonly required: readonly ["pattern"]; }; readonly description: "Searches to ask about (max 16). A bare string is accepted as a pattern."; }; }; readonly required: readonly ["queries"]; }; }]; /** * `queries` arrives from a model. Accepted shapes, most tolerant first: an * array of query objects, an array of bare pattern strings, one query object, * or one bare pattern string. Entries with no usable pattern are dropped * rather than coerced — a query that is not a query cannot be looked up, and * inventing one would answer about a search nobody ran. */ export declare function normalizeSearchQueries(raw: unknown): Array<{ pattern: string; path?: string; glob?: string; type?: string; caseInsensitive?: boolean; multiline?: boolean; }>; /** * `paths` arrives from a model, so it is whatever the model emitted. A bare * string instead of an array is the common shape error and is accepted rather * than rejected — refusing it would return an error where the honest answer is * available. Non-string entries and blanks are dropped: a path that is not a * path cannot be looked up, and coercing `null` to `"null"` would answer * `unread` about a file named "null", which is a wrong answer rather than a * missing one. */ export declare function normalizeReadLedgerPaths(raw: unknown): string[]; /** * Every tool's rendered output, booked as `injected` — at the DISPATCH * BOUNDARY, not per case. * * AC #1 says *any* Cortex output surface books what it injected. Written per * case it was true of four tools out of twelve: `cortex_route`, `cortex_note`, * `cortex_resolve`, `cortex_suggest_notes`, `cortex_validate_memory`, * `cortex_disengage` and — most pointedly — `cortex_summarize`, which injects a * whole session summary and was the *only* prior producer on the credit side, * all rendered into the agent's context and recorded nothing. Measured on a * 120-note store: 2017 unbooked tokens against 866 booked, so ~70% of what * Cortex costs was invisible to the P&L that judges whether Cortex is worth it. * * Booking here makes the property structural: a tool added later cannot forget, * because it does not get a choice. That is the difference between an AC that * holds today and one that keeps holding. */ export declare function handleToolCall(store: CortexStore, toolName: string, args: Record, cwd?: string): string; export declare function createMcpServer(store: CortexStore, cwd?: string): Server; export declare function startServer(startDir?: string): Promise; //# sourceMappingURL=mcp.d.ts.map