import { resolveStorageClient } from "@hasna/contracts/client/storage"; import { type Machine, type Message, type Session, type SessionContentImport, type SessionLookupOptions, type ToolCall } from "../types/index.js"; import type { SessionContentImportResult, UpsertSessionInput } from "./cloud/store.js"; import type { SearchHit, ToolCallHit } from "../lib/search.js"; import type { Entity, EntityType, RelatedSession, SessionGraph } from "../lib/graph.js"; import type { RecallOptions, RecallResponse } from "../lib/recall.js"; import type { EmbedResult } from "../lib/embeddings.js"; import type { MergeResult } from "./merge.js"; import type { IngestResult } from "../lib/ingest/index.js"; export interface IngestStoreOptions { /** Ingest only this provider (claude | codex | codewith | gemini). */ source?: string; /** Ingest only these providers. Ignored when `source` is set. */ sources?: string[]; /** Re-ingest even files unchanged since the last run. */ force?: boolean; /** Progress callback (one line per event). */ onProgress?: (message: string) => void; } export type Env = Record; export interface ListOptions { source?: string; project_path?: string; machine?: string; limit?: number; } export interface SearchHitDto { session: Session; match: string; snippet?: string; } export interface StoreStats { session_count: number; message_count: number; tool_call_count: number; by_source: { source: string; sessions: number; }[]; projects: { project_name: string | null; project_path: string | null; session_count: number; }[]; } export interface SessionStore { readonly mode: "local" | "cloud"; list(opts: ListOptions): Promise; recent(limit: number): Promise; get(idOrPrefix: string, opts?: SessionLookupOptions): Promise; create(input: UpsertSessionInput): Promise; /** Idempotently import/upsert a session with messages and tool calls. */ importContent(input: SessionContentImport): Promise; remove(id: string): Promise; /** * Set a session's title (the "rename" operation), resolving by full id or a * unique id/source_id prefix. Local mode updates the on-box SQLite index; * self_hosted mode PATCHes `/v1/sessions/{id}` so the shared cloud registry is * what actually changes. Returns the updated session, or null if not found. */ rename(idOrPrefix: string, title: string, opts?: SessionLookupOptions): Promise; /** * Rewrite session paths after a project directory move (old -> new): updates * project_path / source_path in the active index. Local mode touches the * on-box SQLite index; self_hosted mode hits `/v1/relocate` so the shared * cloud registry is what actually changes (never a split-brain no-op). */ relocatePaths(oldPath: string, newPath: string): Promise<{ rowsUpdated: number; }>; search(query: string, opts: ListOptions): Promise; machines(): Promise; stats(): Promise; /** Message bodies for a session (local index only; cloud /v1 does not serve blobs). */ messages(sessionId: string): Promise; /** Tool-call records for a session (local index only; cloud /v1 does not serve blobs). */ toolCalls(sessionId: string): Promise; /** Full content search (message bodies + metadata), one hit per session. */ searchContent(query: string, opts: ListOptions): Promise; /** Tool-call search (name / input / output). */ searchToolCalls(query: string, opts: ListOptions): Promise; /** Semantic (embedding) search. */ semanticSearch(query: string, opts: ListOptions): Promise; /** Hybrid full-text + semantic search (RRF). */ hybridSearch(query: string, opts: ListOptions): Promise; /** Natural-language recall with evidence, touched files, and resume metadata. */ recall(query: string, opts: RecallOptions): Promise; /** Knowledge-graph entities (projects/tools/models/providers/repos). */ graphEntities(type?: EntityType): Promise; /** Sessions related to a graph entity. */ graphRelated(type: EntityType, name: string, limit: number): Promise; /** The entity neighborhood of a single session. */ graphSession(idOrPrefix: string, opts?: SessionLookupOptions): Promise; /** Generate embeddings for indexed messages (index maintenance). */ embed(opts: { limit?: number; }): Promise; /** Merge another machine's local sessions DB into this one (local-to-local sync). */ mergeFromDb(path: string): Promise; /** * Index local transcript files into the on-box session index. This is an * inherently LOCAL maintenance operation: even on a flipped (self_hosted) * machine, `sync` ingests into the on-box index first and then pushes the * metadata to the shared cloud `/v1` registry. The cloud transport has no * local index, so it throws rather than pretending to ingest. */ ingest(opts?: IngestStoreOptions): Promise; /** Recompute per-machine session counts in the index (index maintenance). */ recomputeMachines(): Promise; } /** * Resolve the active session store. Hosted /v1 when the API URL + API key pair * is set (the contracts resolver throws if only one of the pair is set — no * silent local drift); local SQLite otherwise. */ export declare function resolveSessionStore(env?: Env, overrides?: Parameters[2]): SessionStore; /** * The LocalStore transport, resolved unconditionally (independent of env). * * Used only by the inherently-local index path: `ingest`/`reindex`/`ingest-watch` * populate the on-box index, and `sync` reads the on-box index to push it to the * shared cloud `/v1` registry even when the resolved store is `cloud`. This is * NOT a per-command local read fallback — the split-brain bug where reads * silently drifted to the local SQLite island stays deleted; those paths go * through `resolveSessionStore()`. */ export declare function getLocalStore(): SessionStore; //# sourceMappingURL=session-store.d.ts.map