import type { LinkType, MemoryKind } from "./constants.js"; export interface ProjectRecord { id: number; name: string; org: string; repo: string; source: string; created_at: string; updated_at: string; } export interface FrontmatterLink { to: string; type: LinkType; } export interface MemoryFrontmatter { kind: MemoryKind; project: string; name: string; tags: string[]; links: FrontmatterLink[]; created_at: string; updated_at: string; /** True once a sleep/dream apply has folded this memory into a consolidated * durable memory and archived it. Omitted from written frontmatter when false so * ordinary (never-archived) memories don't churn on every write. */ archived?: boolean; /** Relative path of the durable memory this memory was consolidated into. Only set * once `archived` is true. */ consolidated_into?: string; /** Relative paths of the source memories a consolidated memory was built * from (provenance). Only set on consolidated memories. */ derived_from?: string[]; } export interface ParsedMemory { frontmatter: MemoryFrontmatter; body: string; relativePath: string; absolutePath: string; contentHash: string; frontmatterHash: string; size: number; density: number; mtime: number; } export interface MemoryRecord { id: number; project_id: number; project_name: string; kind: MemoryKind; name: string; relative_path: string; content_hash: string; frontmatter_hash: string; size: number; density: number; mtime: number; tags: string[]; links: FrontmatterLink[]; body: string; created_at: string; updated_at: string; archived: boolean; consolidated_into?: string; derived_from?: string[]; } export interface LinkRecord { id: number; from_memory_id: number; to_memory_id: number; from_relative_path: string; to_relative_path: string; type: LinkType; created_at: string; } export interface SearchInput { project_name?: string; query: string; limit?: number; max_chars?: number; kinds?: MemoryKind[]; include_linked?: boolean; /** * Minimum blended relevance score (0..1) a result must reach. Defaults to * DEFAULT_SEARCH_MIN_SCORE. Set 0 to disable the floor and return whatever * ranks highest; raise it to demand a stronger match. */ min_score?: number; /** * Which injection surface issued this search (user-prompt-submit, * pre-tool-use, mcp-search, cli-recall). Recorded in the per-search recall * log only — never affects ranking. */ surface?: string; } export interface SearchResult { memory: MemoryRecord; score: number; semanticScore: number; lexicalScore: number; linkScore: number; metadataScore: number; linkedFrom?: number; linkType?: LinkType; } export interface ProjectGraph { project: ProjectRecord; memories: MemoryRecord[]; links: LinkRecord[]; } export interface UpsertInput { project_id: number; memory_id?: number; kind?: MemoryKind; name: string; content: string; tags?: string[]; /** Provenance for a consolidated memory (sleep/dream apply only — * the MCP `upsert` tool does not expose this field). */ derived_from?: string[]; /** Skip the similarity fold on the new-record branch of upsertCore, forcing * the write to land at the deterministic `memoryRelativePath` for * (project, kind, name) instead of a lexically-similar existing record * (sleep/dream apply only — the MCP `upsert` tool does not expose this * field). The approved sleep/dream target's identity must win exactly as * proposed; folding into an unrelated same-kind record would silently * divert the write and could inherit that record's archived state. */ skip_similarity_fold?: boolean; } export interface DaemonInfo { pid: number; endpoint: string; /** * Canonical stateDir this daemon owns through its lifetime writer lock. The * index.db lives under this directory, so ownership is authoritative here, not * on memoryRoot — one global store per stateDir, projects partitioned by name. */ stateDir: string; memoryRoot: string; model: string; startedAt: string; }