import { i as OpenClawConfig } from "./types.openclaw-CpnoYlBx.js"; import { d as SecretInput } from "./types.secrets-rAcqRhcN.js"; import { a as MemoryEmbeddingProviderCallOptions, c as MemoryEmbeddingProviderRuntime, d as registerMemoryEmbeddingProvider, i as MemoryEmbeddingProviderAdapter, l as clearMemoryEmbeddingProviders, n as MemoryEmbeddingBatchOptions, o as MemoryEmbeddingProviderCreateOptions, r as MemoryEmbeddingProvider, s as MemoryEmbeddingProviderCreateResult, t as MemoryEmbeddingBatchChunk, u as listRegisteredMemoryEmbeddingProviders } from "./memory-embedding-providers-BnuRkvUl.js"; import { a as fetchWithSsrFGuard } from "./fetch-guard-BKvfwdRa.js"; import { l as shouldUseEnvHttpProxyForUrl } from "./proxy-env-CRHrWZla.js"; import { h as hasNonTextEmbeddingParts, m as EmbeddingInput, t as MemoryChunk } from "./internal-BdqTjAl0.js"; import { a as getMemoryMultimodalExtensions, i as classifyMemoryMultimodalPath, r as buildCaseInsensitiveExtensionGlob } from "./multimodal-BsQqRgQh.js"; import { n as listMemoryEmbeddingProviders, r as listRegisteredMemoryEmbeddingProviderAdapters, t as getMemoryEmbeddingProvider } from "./memory-embedding-provider-runtime-C3NQyjNu.js"; import { t as DEFAULT_LOCAL_MODEL } from "./embedding-defaults-XlI8aDUR.js"; //#region packages/memory-host-sdk/src/host/embeddings.types.d.ts type EmbeddingProvider = { id: string; model: string; maxInputTokens?: number; embedQuery: (text: string, options?: EmbeddingProviderCallOptions) => Promise; embedBatch: (texts: string[], options?: EmbeddingProviderCallOptions) => Promise; embedBatchInputs?: (inputs: EmbeddingInput[], options?: EmbeddingProviderCallOptions) => Promise; close?: () => Promise | void; }; type EmbeddingProviderCallOptions = { signal?: AbortSignal; }; type EmbeddingProviderRequest = string; type EmbeddingProviderFallback = string; type GeminiTaskType = "RETRIEVAL_QUERY" | "RETRIEVAL_DOCUMENT" | "SEMANTIC_SIMILARITY" | "CLASSIFICATION" | "CLUSTERING" | "QUESTION_ANSWERING" | "FACT_VERIFICATION"; type EmbeddingProviderOptions = { config: OpenClawConfig; agentDir?: string; provider?: EmbeddingProviderRequest; remote?: { baseUrl?: string; apiKey?: SecretInput; headers?: Record; }; model: string; inputType?: string; queryInputType?: string; documentInputType?: string; fallback?: EmbeddingProviderFallback; local?: { modelPath?: string; modelCacheDir?: string; /** * Context size passed to node-llama-cpp `createEmbeddingContext`. * Default: 4096, chosen to cover typical memory-search chunks (128–512 tokens) * while keeping non-weight VRAM bounded. * Set `"auto"` to let node-llama-cpp use the model's trained maximum — not * recommended for 8B+ models (e.g. Qwen3-Embedding-8B: up to 40 960 tokens → ~32 GB VRAM). */ contextSize?: number | "auto"; }; /** Provider-specific output vector dimensions for supported embedding families. */ outputDimensionality?: number; /** Gemini: override the default task type sent with embedding requests. */ taskType?: GeminiTaskType; }; //#endregion //#region packages/memory-host-sdk/src/host/embeddings.d.ts declare function createLocalEmbeddingProvider(options: EmbeddingProviderOptions): Promise; //#endregion //#region packages/memory-host-sdk/src/host/batch-error-utils.d.ts /** Minimal batch output line shape that can carry provider error messages. */ type BatchOutputErrorLike = { error?: { message?: string; }; response?: { body?: string | { error?: { message?: string; }; }; }; }; /** Return the first useful error message from batch output lines. */ declare function extractBatchErrorMessage(lines: BatchOutputErrorLike[]): string | undefined; /** Format a failed error-file read without hiding the underlying read problem. */ declare function formatUnavailableBatchError(err: unknown): string | undefined; //#endregion //#region packages/memory-host-sdk/src/host/retry-utils.d.ts /** Retry timing configuration with optional jitter. */ type RetryConfig = { attempts?: number; minDelayMs?: number; maxDelayMs?: number; jitter?: number; }; /** Retry callback payload. */ type RetryInfo = { attempt: number; maxAttempts: number; delayMs: number; err: unknown; label?: string; }; /** Retry options for retryAsync. */ type RetryOptions = RetryConfig & { label?: string; shouldRetry?: (err: unknown, attempt: number) => boolean; retryAfterMs?: (err: unknown) => number | undefined; onRetry?: (info: RetryInfo) => void; }; /** Run an async operation with exponential backoff retry handling. */ declare function retryAsync(fn: () => Promise, attemptsOrOptions?: number | RetryOptions, initialDelayMs?: number): Promise; //#endregion //#region packages/memory-host-sdk/src/host/ssrf-policy.d.ts /** Host/network allowlist policy forwarded to the runtime SSRF guard. */ type SsrFPolicy = { allowPrivateNetwork?: boolean; dangerouslyAllowPrivateNetwork?: boolean; allowRfc2544BenchmarkRange?: boolean; allowIpv6UniqueLocalRange?: boolean; allowedHostnames?: string[]; hostnameAllowlist?: string[]; }; //#endregion //#region packages/memory-host-sdk/src/host/batch-http.d.ts /** POST JSON and retry provider 429/5xx failures with bounded backoff. */ declare function postJsonWithRetry(params: { url: string; headers: Record; ssrfPolicy?: SsrFPolicy; fetchImpl?: typeof fetch; retryImpl?: typeof retryAsync; body: unknown; errorPrefix: string; }): Promise; //#endregion //#region packages/memory-host-sdk/src/host/batch-output.d.ts /** Minimal OpenAI-compatible embedding batch output line. */ type EmbeddingBatchOutputLine = { custom_id?: string; error?: { message?: string; }; response?: { status_code?: number; body?: { data?: Array<{ embedding?: number[]; }>; error?: { message?: string; }; } | string; }; }; /** Apply one output line, collecting errors and successful embeddings by custom id. */ declare function applyEmbeddingBatchOutputLine(params: { line: EmbeddingBatchOutputLine; remaining: Set; errors: string[]; byCustomId: Map; }): void; //#endregion //#region packages/memory-host-sdk/src/host/batch-provider-common.d.ts /** Provider output line after an embedding batch file is read. */ type ProviderBatchOutputLine = EmbeddingBatchOutputLine; /** OpenAI-compatible endpoint used inside embedding batch request lines. */ declare const EMBEDDING_BATCH_ENDPOINT = "/v1/embeddings"; //#endregion //#region packages/memory-host-sdk/src/host/batch-runner.d.ts /** Execution controls for provider embedding batch submissions and polling. */ type EmbeddingBatchExecutionParams = { wait: boolean; pollIntervalMs: number; timeoutMs: number; concurrency: number; debug?: (message: string, data?: Record) => void; }; /** Run request groups with bounded concurrency and return embeddings by custom id. */ declare function runEmbeddingBatchGroups(params: { requests: TRequest[]; maxRequests: number; wait: EmbeddingBatchExecutionParams["wait"]; pollIntervalMs: EmbeddingBatchExecutionParams["pollIntervalMs"]; timeoutMs: EmbeddingBatchExecutionParams["timeoutMs"]; concurrency: EmbeddingBatchExecutionParams["concurrency"]; debugLabel: string; debug?: EmbeddingBatchExecutionParams["debug"]; runGroup: (args: { group: TRequest[]; groupIndex: number; groups: number; byCustomId: Map; pollIntervalMs: number; timeoutMs: number; }) => Promise; }): Promise>; /** Build normalized batch-group options for provider-specific runners. */ declare function buildEmbeddingBatchGroupOptions(params: { requests: TRequest[]; } & EmbeddingBatchExecutionParams, options: { maxRequests: number; debugLabel: string; }): { requests: TRequest[]; maxRequests: number; wait: boolean; pollIntervalMs: number; timeoutMs: number; concurrency: number; debug: ((message: string, data?: Record) => void) | undefined; debugLabel: string; }; //#endregion //#region packages/memory-host-sdk/src/host/batch-status.d.ts /** Minimal provider batch status used for completion and terminal-failure checks. */ type BatchStatusLike = { id?: string; status?: string; output_file_id?: string | null; error_file_id?: string | null; }; /** File ids returned once a batch has completed. */ type BatchCompletionResult = { outputFileId: string; errorFileId?: string; }; /** Convert a completed provider status payload into output/error file ids. */ declare function resolveBatchCompletionFromStatus(params: { provider: string; batchId: string; status: BatchStatusLike; }): BatchCompletionResult; /** Throw when a provider reports a terminal failure, including error-file detail if available. */ declare function throwIfBatchTerminalFailure(params: { provider: string; status: BatchStatusLike; readError: (errorFileId: string) => Promise; }): Promise; /** Resolve the completed batch files, optionally waiting according to caller policy. */ declare function resolveCompletedBatchResult(params: { provider: string; status: BatchStatusLike; wait: boolean; waitForBatch: () => Promise; }): Promise; //#endregion //#region packages/memory-host-sdk/src/host/batch-utils.d.ts /** Minimal HTTP client config needed by batch providers. */ type BatchHttpClientConfig = { baseUrl?: string; headers?: Record; ssrfPolicy?: SsrFPolicy; }; /** Normalize batch API base URLs by removing one trailing slash. */ declare function normalizeBatchBaseUrl(client: BatchHttpClientConfig): string; /** Build request headers, preserving caller auth and controlling JSON/form content type. */ declare function buildBatchHeaders(client: Pick, params: { json: boolean; }): Record; //#endregion //#region packages/memory-host-sdk/src/host/batch-upload.d.ts /** Upload embedding batch requests and return the provider file id. */ declare function uploadBatchJsonlFile(params: { client: BatchHttpClientConfig; requests: unknown[]; errorPrefix: string; maxResponseBytes?: number; }): Promise; //#endregion //#region packages/memory-host-sdk/src/host/embedding-chunk-limits.d.ts /** * Split text-only chunks to the provider's effective input limit. * * Structured multimodal chunks are preserved because only the provider can decide how to count * non-text parts. */ declare function enforceEmbeddingMaxInputTokens(provider: EmbeddingProvider, chunks: MemoryChunk[], hardMaxInputTokens?: number): MemoryChunk[]; //#endregion //#region packages/memory-host-sdk/src/host/embedding-provider-adapter-utils.d.ts /** Detect missing API key errors from provider auth resolution. */ declare function isMissingEmbeddingApiKeyError(err: unknown): boolean; /** Return stable cache headers after removing provider-specific secret headers. */ declare function sanitizeEmbeddingCacheHeaders(headers: Record, excludedHeaderNames: string[]): Array<[string, string]>; /** Convert custom-id keyed batch embeddings back to request-index order. */ declare function mapBatchEmbeddingsByIndex(byCustomId: Map, count: number): number[][]; //#endregion //#region packages/memory-host-sdk/src/host/embedding-vectors.d.ts /** Replace invalid coordinates and L2-normalize non-empty vectors. */ declare function sanitizeAndNormalizeEmbedding(vec: number[]): number[]; //#endregion //#region packages/memory-host-sdk/src/host/embeddings-debug.d.ts /** Write embedding debug metadata when OPENCLAW_DEBUG_MEMORY_EMBEDDINGS is enabled. */ declare function debugEmbeddingsLog(message: string, meta?: Record): void; //#endregion //#region packages/memory-host-sdk/src/host/embeddings-model-normalize.d.ts /** Trim a configured model id, fall back when empty, and strip known prefixes. */ declare function normalizeEmbeddingModelWithPrefixes(params: { model: string; defaultModel: string; prefixes: string[]; }): string; //#endregion //#region packages/memory-host-sdk/src/host/embeddings-remote-client.d.ts /** Provider id used for remote embedding auth and config lookup. */ type RemoteEmbeddingProviderId = string; /** Resolve base URL, bearer headers, header overrides, and SSRF policy for remote embeddings. */ declare function resolveRemoteEmbeddingBearerClient(params: { provider: RemoteEmbeddingProviderId; options: EmbeddingProviderOptions; defaultBaseUrl: string; }): Promise<{ baseUrl: string; headers: Record; ssrfPolicy?: SsrFPolicy; }>; //#endregion //#region packages/memory-host-sdk/src/host/embeddings-remote-provider.d.ts /** HTTP client details required by a remote embedding provider. */ type RemoteEmbeddingClient = { baseUrl: string; headers: Record; ssrfPolicy?: SsrFPolicy; fetchImpl?: typeof fetch; model: string; }; /** Create an EmbeddingProvider backed by a remote embeddings endpoint. */ declare function createRemoteEmbeddingProvider(params: { id: string; client: RemoteEmbeddingClient; errorPrefix: string; maxInputTokens?: number; }): EmbeddingProvider; /** Resolve a normalized remote embedding client from provider config and model options. */ declare function resolveRemoteEmbeddingClient(params: { provider: RemoteEmbeddingProviderId; options: EmbeddingProviderOptions; defaultBaseUrl: string; normalizeModel: (model: string) => string; }): Promise; //#endregion //#region packages/memory-host-sdk/src/host/embeddings-remote-fetch.d.ts /** POST an embedding request and return validated vectors in provider response order. */ declare function fetchRemoteEmbeddingVectors(params: { url: string; headers: Record; ssrfPolicy?: SsrFPolicy; fetchImpl?: typeof fetch; signal?: AbortSignal; body: unknown; errorPrefix: string; }): Promise; //#endregion //#region packages/memory-host-sdk/src/host/embedding-input-limits.d.ts declare function estimateUtf8Bytes(text: string): number; declare function estimateStructuredEmbeddingInputBytes(input: EmbeddingInput): number; //#endregion //#region packages/memory-host-sdk/src/host/remote-http.d.ts /** Build an SSRF allow policy from a configured remote base URL. */ declare const buildRemoteBaseUrlPolicy: (baseUrl: string) => SsrFPolicy | undefined; /** Execute a remote HTTP request under SSRF guard and always release the response handle. */ declare function withRemoteHttpResponse(params: { url: string; init?: RequestInit; signal?: AbortSignal; ssrfPolicy?: SsrFPolicy; fetchImpl?: typeof fetch; fetchWithSsrFGuardImpl?: typeof fetchWithSsrFGuard; shouldUseEnvHttpProxyForUrlImpl?: typeof shouldUseEnvHttpProxyForUrl; auditContext?: string; onResponse: (response: Response) => Promise; }): Promise; //#endregion //#region src/plugin-sdk/memory-core-host-engine-embeddings.d.ts /** Provider batch status payload shared by memory embedding batch helpers. */ type EmbeddingBatchStatus = { id?: string; status?: string; output_file_id?: string | null; error_file_id?: string | null; }; //#endregion export { type BatchCompletionResult, type BatchHttpClientConfig, DEFAULT_LOCAL_MODEL, EMBEDDING_BATCH_ENDPOINT, type EmbeddingBatchExecutionParams, EmbeddingBatchStatus, type EmbeddingInput, type MemoryEmbeddingBatchChunk, type MemoryEmbeddingBatchOptions, type MemoryEmbeddingProvider, type MemoryEmbeddingProviderAdapter, type MemoryEmbeddingProviderCallOptions, type MemoryEmbeddingProviderCreateOptions, type MemoryEmbeddingProviderCreateResult, type MemoryEmbeddingProviderRuntime, type ProviderBatchOutputLine, type RemoteEmbeddingClient, type RemoteEmbeddingProviderId, applyEmbeddingBatchOutputLine, buildBatchHeaders, buildCaseInsensitiveExtensionGlob, buildEmbeddingBatchGroupOptions, buildRemoteBaseUrlPolicy, classifyMemoryMultimodalPath, clearMemoryEmbeddingProviders, createLocalEmbeddingProvider, createRemoteEmbeddingProvider, debugEmbeddingsLog, enforceEmbeddingMaxInputTokens, estimateStructuredEmbeddingInputBytes, estimateUtf8Bytes, extractBatchErrorMessage, fetchRemoteEmbeddingVectors, formatUnavailableBatchError, getMemoryEmbeddingProvider, getMemoryMultimodalExtensions, hasNonTextEmbeddingParts, isMissingEmbeddingApiKeyError, listMemoryEmbeddingProviders, listRegisteredMemoryEmbeddingProviderAdapters, listRegisteredMemoryEmbeddingProviders, mapBatchEmbeddingsByIndex, normalizeBatchBaseUrl, normalizeEmbeddingModelWithPrefixes, postJsonWithRetry, registerMemoryEmbeddingProvider, resolveBatchCompletionFromStatus, resolveCompletedBatchResult, resolveRemoteEmbeddingBearerClient, resolveRemoteEmbeddingClient, runEmbeddingBatchGroups, sanitizeAndNormalizeEmbedding, sanitizeEmbeddingCacheHeaders, throwIfBatchTerminalFailure, uploadBatchJsonlFile, withRemoteHttpResponse };