import { i as OpenClawConfig } from "./types.openclaw-fYj4Ft14.js"; import { B as MemoryProviderStatus, G as MemorySyncProgressUpdate, H as MemorySearchManager, W as MemorySearchRuntimeDebug } from "./memory-state-DpGtozKN.js"; import { c as MemoryEmbeddingProviderRuntime, o as MemoryEmbeddingProviderCreateOptions, r as MemoryEmbeddingProvider } from "./memory-embedding-providers-BY9xFify.js"; import { a as ResolvedMemorySearchConfig } from "./openclaw-runtime-CRooRKpH.js"; import { m as EmbeddingInput } from "./internal-BdqTjAl0.js"; import { n as MemorySearchResult, r as MemorySource, t as MemoryEmbeddingProbeResult } from "./memory-core-host-engine-storage-CYirFJnT.js"; import { FSWatcher } from "chokidar"; import { DatabaseSync } from "node:sqlite"; //#region extensions/memory-core/src/memory/embeddings.d.ts type EmbeddingProvider = MemoryEmbeddingProvider; type EmbeddingProviderId = string; type EmbeddingProviderRequest = string; type EmbeddingProviderFallback = string; type EmbeddingProviderRuntime = MemoryEmbeddingProviderRuntime; type EmbeddingProviderResult = { provider: EmbeddingProvider | null; requestedProvider: EmbeddingProviderRequest; fallbackFrom?: string; fallbackReason?: string; providerUnavailableReason?: string; runtime?: EmbeddingProviderRuntime; }; type CreateEmbeddingProviderOptions = MemoryEmbeddingProviderCreateOptions & { provider: EmbeddingProviderRequest; fallback: EmbeddingProviderFallback; }; declare function createEmbeddingProvider(options: CreateEmbeddingProviderOptions): Promise; //#endregion //#region extensions/memory-core/src/memory/manager-provider-state.d.ts type MemoryProviderLifecycleState = { mode: "pending"; requestedProvider: string; } | { mode: "active"; providerId: string; } | { mode: "degraded"; providerId: string; reason: string; code?: string; } | { mode: "fallback-active"; providerId: string; fallbackFrom: string; reason: string; } | { mode: "fts-only"; reason: string; attemptedProviderId?: string; }; //#endregion //#region extensions/memory-core/src/memory/manager-reindex-state.d.ts type MemoryIndexMeta = { model: string; provider: string; providerKey?: string; sources?: MemorySource[]; scopeHash?: string; chunkTokens: number; chunkOverlap: number; vectorDims?: number; ftsTokenizer?: string; }; type MemoryIndexIdentityState = { status: "valid"; } | { status: "missing"; reason: string; } | { status: "mismatched"; reason: string; }; //#endregion //#region extensions/memory-core/src/memory/watch-settle.d.ts type MemoryWatchEventStats = { isDirectory?: () => boolean; size?: number; mtimeMs?: number; }; type WatchPathSnapshot = { size: number; mtimeMs: number; }; type MemoryWatchSettleQueue = Map; //#endregion //#region extensions/memory-core/src/memory/manager-sync-ops.d.ts type MemorySyncProgressState = { completed: number; total: number; label?: string; report: (update: MemorySyncProgressUpdate) => void; }; type MemoryIndexEntry$1 = { path: string; absPath: string; mtimeMs: number; size: number; hash: string; content?: string; }; declare abstract class MemoryManagerSyncOps { protected abstract readonly cfg: OpenClawConfig; protected abstract readonly agentId: string; protected abstract readonly workspaceDir: string; protected abstract readonly settings: ResolvedMemorySearchConfig; protected provider: EmbeddingProvider | null; protected fallbackFrom?: EmbeddingProviderId; protected abstract providerUnavailableReason?: string; protected abstract providerLifecycle: MemoryProviderLifecycleState; protected providerRuntime?: EmbeddingProviderRuntime; protected abstract batch: { enabled: boolean; wait: boolean; concurrency: number; pollIntervalMs: number; timeoutMs: number; }; protected readonly sources: Set; protected providerKey: string | null; protected abstract readonly vector: { enabled: boolean; available: boolean | null; semanticAvailable?: boolean; extensionPath?: string; loadError?: string; dims?: number; }; protected readonly fts: { enabled: boolean; available: boolean; loadError?: string; }; protected vectorReady: Promise | null; protected watcher: FSWatcher | null; private nativeMemoryWatchPairs; protected watchTimer: NodeJS.Timeout | null; protected sessionWatchTimer: NodeJS.Timeout | null; protected sessionUnsubscribe: (() => void) | null; protected fallbackReason?: string; protected intervalTimer: NodeJS.Timeout | null; protected memoryWatchPressureStartupTimer: NodeJS.Timeout | null; protected closed: boolean; protected dirty: boolean; protected pendingWatchPaths: MemoryWatchSettleQueue; protected sessionsDirty: boolean; private readonly memoryWatchPressureWarning; protected sessionsDirtyFiles: Set; protected sessionPendingFiles: Set; protected sessionDeltas: Map; protected vectorDegradedWriteWarningShown: boolean; private lastMetaSerialized; protected abstract readonly cache: { enabled: boolean; maxEntries?: number; }; protected abstract db: DatabaseSync; protected abstract computeProviderKey(): string; protected abstract sync(params?: { reason?: string; force?: boolean; forceSessions?: boolean; sessionFile?: string; progress?: (update: MemorySyncProgressUpdate) => void; }): Promise; protected abstract withTimeout(promise: Promise, timeoutMs: number, message: string): Promise; protected abstract getIndexConcurrency(): number; protected abstract pruneEmbeddingCacheIfNeeded(): void; protected abstract resetProviderInitializationForRetry(): void; protected abstract assertRequiredProviderAvailable(operation: "search" | "sync"): void; protected abstract indexFile(entry: MemoryIndexEntry$1, options: { source: MemorySource; content?: string; }): Promise; protected hasIndexedChunks(): boolean; protected resolveCurrentIndexIdentityState(params?: { meta?: MemoryIndexMeta | null; provider?: { id: string; model: string; } | null; providerKeyKnown?: boolean; vectorReady?: boolean; hasIndexedChunks?: boolean; }): MemoryIndexIdentityState; protected resetVectorState(): void; protected ensureVectorReady(dimensions?: number): Promise; private loadVectorExtension; private ensureVectorTable; private dropVectorTable; protected buildSourceFilter(alias?: string, sourcesOverride?: MemorySource[]): { sql: string; params: MemorySource[]; }; protected openDatabase(): DatabaseSync; private seedEmbeddingCache; protected ensureSchema(): void; protected ensureWatcher(): void; private scheduleMemoryWatchPressureStartupCheck; private warnIfMemoryWatchPressure; private currentMemoryChokidarWatcher; protected attachNativeMemoryWatchForDir(dir: string, markDirty: (watchPath?: string, stats?: MemoryWatchEventStats) => void): boolean; protected attachLinuxMemoryDirectoryTreeWatchForDir(dir: string, markDirty: (watchPath?: string, stats?: MemoryWatchEventStats) => void): boolean; private attachLinuxMemoryDirectoryTreeSubtree; private closeNativeMemoryWatchPair; protected closeNativeMemoryWatchPairs(): void; private removeNativeMemoryParentWatch; private removeNativeMemoryWatchPair; protected attachMemoryChokidarFallback(dir: string, markDirty: (watchPath?: string, stats?: MemoryWatchEventStats) => void): void; protected ensureSessionListener(): void; protected ensureSessionStartupCatchup(): void; protected markSessionStartupCatchupDirtyFiles(): Promise; protected runSessionStartupCatchup(): Promise; private scheduleSessionDirty; private processSessionDeltaBatch; private updateSessionDelta; private countNewlines; private resetSessionDelta; private isSessionFileForAgent; private normalizeTargetSessionFiles; protected ensureIntervalSync(): void; private scheduleWatchSync; private shouldSyncSessions; private syncMemoryFiles; private syncSessionFiles; private createSyncProgress; private assertFtsOnlySyncAllowed; protected runSync(params?: { reason?: string; force?: boolean; sessionFiles?: string[]; progress?: (update: MemorySyncProgressUpdate) => void; }): Promise; protected shouldFallbackOnError(err: unknown): boolean; protected resolveBatchConfig(): { enabled: boolean; wait: boolean; concurrency: number; pollIntervalMs: number; timeoutMs: number; }; protected activateFallbackProvider(reason: string): Promise; protected runSafeReindex(params: { reason?: string; force?: boolean; progress?: MemorySyncProgressState; }): Promise; private runUnsafeReindex; private resetIndex; protected readMeta(): MemoryIndexMeta | null; protected writeMeta(meta: MemoryIndexMeta): void; } //#endregion //#region extensions/memory-core/src/memory/manager-embedding-ops.d.ts type MemoryIndexEntry = { path: string; absPath: string; mtimeMs: number; size: number; hash: string; kind?: "markdown" | "multimodal"; contentText?: string; lineMap?: number[]; }; declare abstract class MemoryManagerEmbeddingOps extends MemoryManagerSyncOps { protected abstract batchFailureCount: number; protected abstract batchFailureLastError?: string; protected abstract batchFailureLastProvider?: string; protected abstract batchFailureLock: Promise; protected abstract markLocalEmbeddingProviderDegraded(err: unknown): void; protected pruneEmbeddingCacheIfNeeded(): void; private embedChunksInBatches; protected computeProviderKey(): string; private buildBatchDebug; private embedChunksWithBatch; private collectCachedEmbeddings; protected embedBatchWithRetry(texts: string[]): Promise; protected embedBatchInputsWithRetry(inputs: EmbeddingInput[]): Promise; private waitForEmbeddingRetry; private resolveEmbeddingTimeout; protected embedQueryWithRetry(text: string): Promise; protected withTimeout(promise: Promise, timeoutMs: number, message: string): Promise; private withBatchFailureLock; private resetBatchFailureCount; private recordBatchFailure; private isBatchTimeoutError; private runBatchWithTimeoutRetry; private runBatchWithFallback; protected getIndexConcurrency(): number; private clearIndexedFileData; private upsertFileRecord; private deleteFileRecord; /** * Write chunks (and optional embeddings) for a file into the index. * Handles both the chunks table, the vector table, and the FTS table. * Pass an empty embeddings array to skip vector writes (FTS-only mode). */ private writeChunks; protected indexFile(entry: MemoryIndexEntry, options: { source: MemorySource; content?: string; }): Promise; } //#endregion //#region extensions/memory-core/src/memory/manager.d.ts type MemoryIndexManagerPurpose = "default" | "status" | "cli"; declare function closeAllMemoryIndexManagers(): Promise; declare function closeMemoryIndexManagersForAgent(params: { cfg: OpenClawConfig; agentId: string; }): Promise; declare class MemoryIndexManager extends MemoryManagerEmbeddingOps implements MemorySearchManager { private readonly cacheKey; private readonly purpose; protected readonly cfg: OpenClawConfig; protected readonly agentId: string; protected readonly workspaceDir: string; protected readonly settings: ResolvedMemorySearchConfig; private readonly providerRequirement; protected provider: EmbeddingProvider | null; private readonly requestedProvider; private providerInitPromise; private providerInitialized; protected fallbackFrom?: EmbeddingProviderId; protected fallbackReason?: string; protected providerUnavailableReason?: string; protected providerLifecycle: MemoryProviderLifecycleState; protected providerRuntime?: EmbeddingProviderRuntime; protected batch: { enabled: boolean; wait: boolean; concurrency: number; pollIntervalMs: number; timeoutMs: number; }; protected batchFailureCount: number; protected batchFailureLastError?: string; protected batchFailureLastProvider?: string; protected batchFailureLock: Promise; protected db: DatabaseSync; protected readonly sources: Set; protected providerKey: string; protected readonly cache: { enabled: boolean; maxEntries?: number; }; protected readonly vector: { enabled: boolean; available: boolean | null; semanticAvailable?: boolean; extensionPath?: string; loadError?: string; dims?: number; }; protected readonly fts: { enabled: boolean; available: boolean; loadError?: string; }; protected vectorReady: Promise | null; protected watcher: FSWatcher | null; protected watchTimer: NodeJS.Timeout | null; protected sessionWatchTimer: NodeJS.Timeout | null; protected sessionUnsubscribe: (() => void) | null; protected intervalTimer: NodeJS.Timeout | null; protected memoryWatchPressureStartupTimer: NodeJS.Timeout | null; protected closed: boolean; protected dirty: boolean; protected sessionsDirty: boolean; protected sessionsDirtyFiles: Set; protected sessionPendingFiles: Set; private indexIdentityDirty; protected sessionDeltas: Map; private sessionWarm; private syncing; private queuedSessionFiles; private queuedSessionSync; private readonlyRecoveryAttempts; private readonlyRecoverySuccesses; private readonlyRecoveryFailures; private readonlyRecoveryLastError?; private indexIdentityState; private static loadProviderResult; static get(params: { cfg: OpenClawConfig; agentId: string; purpose?: MemoryIndexManagerPurpose; }): Promise; private constructor(); private applyProviderResult; private ensureProviderInitialized; protected resetProviderInitializationForRetry(): void; protected markLocalEmbeddingProviderDegraded(err: unknown): void; protected isRequiredProviderUnavailable(): boolean; protected buildRequiredProviderUnavailableError(operation: "search" | "sync"): Error; protected assertRequiredProviderAvailable(operation: "search" | "sync"): void; warmSession(sessionKey?: string): Promise; private refreshIndexIdentityDirty; search(query: string, opts?: { maxResults?: number; minScore?: number; sessionKey?: string; qmdSearchModeOverride?: "query" | "search" | "vsearch"; onDebug?: (debug: MemorySearchRuntimeDebug) => void; /** When set, only these chunk sources are considered (must be enabled for this manager). */ sources?: MemorySource[]; }): Promise; private selectScoredResults; private hasIndexedContent; private searchVector; private buildFtsQuery; private searchKeyword; private mergeHybridResults; sync(params?: { reason?: string; force?: boolean; sessionFiles?: string[]; progress?: (update: MemorySyncProgressUpdate) => void; }): Promise; private enqueueTargetedSessionSync; private runSyncWithReadonlyRecovery; readFile(params: { relPath: string; from?: number; lines?: number; }): Promise<{ text: string; path: string; }>; status(): MemoryProviderStatus; probeVectorAvailability(): Promise; probeVectorStoreAvailability(): Promise; private cacheProbeResult; getCachedEmbeddingAvailability(): MemoryEmbeddingProbeResult | null; probeEmbeddingAvailability(): Promise; close(): Promise; } //#endregion export { createEmbeddingProvider as i, closeAllMemoryIndexManagers as n, closeMemoryIndexManagersForAgent as r, MemoryIndexManager as t };