import { type Database } from "../../data/database.js"; export type UpgradePhase = "checking" | "backing-up" | "importing" | "validating" | "cutover" | "retiring" | "ready"; export interface UpgradeProgress { phase: UpgradePhase; completed?: number; total?: number; } export interface UpgradeImportContext { readonly db: Database; readonly root: string; readonly sourceRoot: string; readonly previousDatabase: string | undefined; readonly sourceFiles: readonly string[]; readonly legacy: boolean; progress(completed: number, total?: number): void; stageAsset(relativePath: string, bytes: Uint8Array): void; } export interface UpgradeSource { path: string; retire: boolean; } export type LegacyKind = "config" | "model-credentials" | "catalog-remote" | "catalog-overlays" | "mcp-oauth" | "mcp-config" | "mcp-status" | "member-mcp" | "workspaces" | "ssh-private-key" | "ssh-public-key" | "ssh-config" | "member-metadata" | "member-profile-mixed" | "agent-template-mixed" | "room-metadata" | "topic-metadata" | "tasks" | "messages" | "message-sequence" | "member-cursors" | "dm-member-cursor" | "agent-events" | "derived-event-stats" | "message-archive" | "message-archive-summary" | "current-sessions" | "old-sessions" | "runtime-state" | "user-cursors" | "background-task" | "document-body" | "document-meta" | "document-history" | "document-snapshot" | "export-snapshot"; export type LegacyFormat = "json" | "jsonl" | "text"; export interface LegacySourceEntry { path: string; retire: boolean; kind: LegacyKind; format: LegacyFormat; mtimeMs: number; size: number; scopeId?: string; memberId?: string; ownerKey?: string; layer?: "persona" | "principles" | "mainline"; documentPath?: string; layout?: "member" | "room-memory" | "copy-forward"; taskId?: string; sessionDir?: string; slug?: string; archiveTimestamp?: string; serverKey?: string; archivePath?: string; snapshotKind?: Exclude | "archive-manifest"; } export interface LegacyDiagnostic { code: "unknown-metadata"; path: string; } export interface LegacyInventory { entries: LegacySourceEntry[]; diagnostics: LegacyDiagnostic[]; } export type LegacySourceErrorCode = "invalid-root" | "invalid-path" | "duplicate-path" | "symlink-source" | "not-directory" | "not-regular-file" | "unapproved-source" | "wrong-format" | "source-io" | "invalid-utf8" | "invalid-json" | "unterminated-jsonl-line"; export declare class LegacySourceError extends Error { readonly code: LegacySourceErrorCode; readonly path: string; readonly lineNumber?: number | undefined; constructor(code: LegacySourceErrorCode, path: string, lineNumber?: number | undefined); } /** Reject aliases as well as traversal; inventory and runner use the same path key. */ export declare function validateLegacyPath(path: string): void; /** Also usable on a parent-composed source list before snapshot creation. */ export declare function validateLegacySources(entries: readonly { path: string; retire: boolean; }[]): void; /** Deterministically sorted files, not a precedence decision. Does not read bodies, * referenced SSH keys, JSON metadata, SDK sessions, or arbitrary asset subtrees. * Unknown metadata siblings are diagnostic-only, and are never marked for retirement. */ export declare function discoverLegacyInventory(sourceRoot: string): LegacyInventory; /** Strict JSON syntax/UTF-8 only; domain shape/identity validation belongs to parent. */ export declare function readLegacyJson(sourceRoot: string, entry: Pick): unknown; export interface LegacyJsonlRecord { path: string; /** 1-based original nonblank-line ordinal, including non-activity events. */ ordinal: number; /** 1-based physical line, including preceding blank lines. */ lineNumber: number; value: unknown; } /** Streaming memory is bounded by the largest line plus a 64 KiB read buffer. * Nonblank unterminated tails are never yielded, even when valid JSON. Parent * must consume to successful EOF before accepting the import transaction. * Early return/throw closes the descriptor; no source is repaired. */ export interface InvalidLegacyEventLine { path: string; ordinal: number; lineNumber: number; raw: Buffer; } export declare function readLegacyJsonl(sourceRoot: string, entry: Pick): AsyncGenerator; /** The old runtime-event reader skipped corrupt JSON. Import retains those exact * terminated lines through the callback; all other sources and errors stay strict. */ export declare function readLegacyEventJsonl(sourceRoot: string, entry: LegacySourceEntry, preserveInvalid: (line: InvalidLegacyEventLine) => void): AsyncGenerator; export interface StartupSettingsSnapshot { configured: boolean; host?: string; port?: number; source: "empty" | "legacy" | "database"; } /** Legacy settings are visible only before a completed core authority marker. * An unreadable/incompatible authoritative DB never falls back to config.json. * This selects setup/display behavior only; the daemon imports and owns settings. */ export declare function inspectStartupSettings(root: string): StartupSettingsSnapshot; /** Any historical conversion journal can indicate lost authority, regardless of status or syntax. * Do not parse it into permission to create a new, empty database. Preserve the evidence. */ export declare function assertNoMissingMemberDatabase(root: string): void; /** Only for file-authoritative input, after parsing identity records. Empty/unknown asset * subtrees count too; discovery of recognized files alone cannot detect these orphans. */ export declare function assertLegacyMemberDirectories(root: string, memberIds: ReadonlySet): void; //# sourceMappingURL=inventory.d.ts.map