import { Buffer } from "node:buffer"; /** * obsidian-vault-import — server-side parser + write orchestrator for * Obsidian vault ingestion. Two-phase by operator decision (CEO review): * * 1. mode='dry-run' — walks the extractedDir, parses, builds the * resolution plan, returns counts + ambiguities the operator must * disambiguate before the write commits. No writes happen. * * 2. mode='commit' — re-walks (parsing is deterministic + cheap on a * local fs), applies operator-supplied resolutions, runs the * content-hash idempotency check against the existing graph, * copies attachments to {accountDir}/archive/obsidian//, * and invokes memoryArchiveWrite with archiveType='obsidian-vault'. * * The agent never parses markdown. It supplies extractedDir + ownerNodeId * + operator-driven filter selection, runs the dry-run, surfaces * ambiguities to the operator interactively, then re-invokes commit with * the resolutions block. All schema decisions (label reuse, edge naming, * MERGE keys) are pinned in memory-archive-write's obsidian-vault handler. */ export type ObsidianImportMode = "dry-run" | "commit"; export interface VaultImportFilters { /** Only ingest pages whose obsidianPath starts with one of these prefixes. */ folderPrefixes?: string[]; /** Only ingest pages whose tags intersect this set (normalised, no `#`). */ tags?: string[]; /** Only ingest pages with mtime >= this ISO date or epoch-ms. */ modifiedSince?: string; } /** * Operator's disambiguation answers, keyed by the ambiguity id the dry-run * returned. Each entry tells the commit phase which candidate to write the * wikilink edge to. */ export type AmbiguityResolution = { kind: "page"; obsidianPath: string; } | { kind: "entity"; nodeId: string; } | { kind: "stub"; }; export interface VaultImportParams { accountId: string; ownerNodeId: string; /** Absolute path to the extracted vault directory. Caller validates it * lives under the account's archive area before invoking. */ extractedDir: string; /** Stable id for the import run. Generated by dry-run, passed back in * the commit call so observability lines tie together. */ importId?: string; mode: ObsidianImportMode; filters?: VaultImportFilters; /** Operator answers to dry-run ambiguities. Required when mode='commit' * AND the dry-run reported ambiguities; ignored otherwise. */ resolutions?: Record; /** Threshold above which the dry-run flags large vaults for the skill's * selective-ingest filter conversation. Default 100 — mirrors the * linkedin-connections threshold. */ selectiveIngestThreshold?: number; sessionId?: string; } export interface VaultImportAmbiguity { /** Stable id the operator quotes back in the resolutions map. */ id: string; /** The page that contains the wikilink. */ fromPath: string; /** Raw wikilink text (without `[[…]]`, before alias `|`). */ target: string; /** Candidate intra-vault pages by obsidianPath. */ pageCandidates: string[]; /** Candidate existing entities — `{nodeId, label, name, distance}`. */ entityCandidates: Array<{ nodeId: string; label: string; name: string; distance: number; }>; } export interface VaultImportPlan { importId: string; mode: ObsidianImportMode; /** Total pages discovered before filtering. */ pagesDiscovered: number; /** Pages surviving filters. */ pagesEligible: number; /** Pages whose contentHash already matches the existing graph (skipped on commit). */ pagesUnchanged: number; /** Wikilinks classified by resolution: intra-vault, fuzzy-entity, stub. */ wikilinks: { page: number; entity: number; stub: number; ambiguous: number; }; /** Tags discovered across eligible pages. */ tagCount: number; /** Distinct attachments referenced. */ attachmentCount: number; /** Operator must resolve these before commit will run. */ ambiguities: VaultImportAmbiguity[]; /** Set when pagesEligible > selectiveIngestThreshold and dry-run was the call. */ selectiveIngestSuggested: boolean; } export interface VaultImportCommitResult extends VaultImportPlan { written: { createdPages: number; mergedPages: number; createdTags: number; createdTagEdges: number; createdAttachments: number; createdAttachmentEdges: number; createdWikilinkEdges: number; }; attachmentsCopied: number; errors: Array<{ rowIndex: number; reason: string; }>; /** Server log line tag — the same string written to server.log. */ observabilityTag: string; } export declare function obsidianVaultImport(params: VaultImportParams): Promise; export type _BufferType = Buffer; //# sourceMappingURL=obsidian-vault-import.d.ts.map