wolbarg 0.5.5 → 0.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/README.md +73 -292
- package/dist/cli.js +515 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.cjs +532 -116
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +145 -8
- package/dist/index.d.ts +145 -8
- package/dist/index.js +518 -119
- package/dist/index.js.map +1 -1
- package/package.json +5 -2
package/dist/index.d.cts
CHANGED
|
@@ -371,6 +371,10 @@ interface ConcurrencyConfig$1 {
|
|
|
371
371
|
baseBackoffMs?: number;
|
|
372
372
|
maxBackoffMs?: number;
|
|
373
373
|
lockTimeoutMs?: number;
|
|
374
|
+
/** Total lock-wait + retry budget in ms. */
|
|
375
|
+
lockDeadlineMs?: number;
|
|
376
|
+
/** Use multi-process-oriented defaults when many OS processes share one DB file. */
|
|
377
|
+
multiProcess?: boolean;
|
|
374
378
|
}
|
|
375
379
|
/** Transparent embedding cache configuration. */
|
|
376
380
|
interface EmbeddingCacheConfig {
|
|
@@ -2149,7 +2153,7 @@ interface WolbargOptionsBase {
|
|
|
2149
2153
|
organization: string;
|
|
2150
2154
|
/**
|
|
2151
2155
|
* Storage provider instance or config.
|
|
2152
|
-
* Prefer `
|
|
2156
|
+
* Prefer `storage: sqlite(...)` / `postgres(...)` in docs; `database` remains supported.
|
|
2153
2157
|
*/
|
|
2154
2158
|
storage?: StorageInput;
|
|
2155
2159
|
/**
|
|
@@ -2725,7 +2729,7 @@ declare class Wolbarg<HasLlm extends boolean = false> {
|
|
|
2725
2729
|
declare function wolbarg$1(options: WolbargOptions): Wolbarg;
|
|
2726
2730
|
|
|
2727
2731
|
/** Published SDK semver — keep in sync with `package.json` `version`. */
|
|
2728
|
-
declare const SDK_VERSION = "0.5.
|
|
2732
|
+
declare const SDK_VERSION = "0.5.6";
|
|
2729
2733
|
|
|
2730
2734
|
/**
|
|
2731
2735
|
* Operation-scoped errors with stable `code`, human `reason`, and actionable `suggestion`.
|
|
@@ -2896,10 +2900,6 @@ declare class GraphCheckpointNotSupportedError extends WolbargError {
|
|
|
2896
2900
|
*/
|
|
2897
2901
|
declare function wrapOperationError(operation: string, error: unknown): WolbargError;
|
|
2898
2902
|
|
|
2899
|
-
/**
|
|
2900
|
-
* Public factory helpers for storage, telemetry, checkpoints, and graph providers (v0.5.5).
|
|
2901
|
-
*/
|
|
2902
|
-
|
|
2903
2903
|
/**
|
|
2904
2904
|
* Create a SQLite {@link StorageProvider} from a filesystem path or `:memory:`.
|
|
2905
2905
|
*
|
|
@@ -2911,7 +2911,9 @@ declare function wrapOperationError(operation: string, error: unknown): WolbargE
|
|
|
2911
2911
|
* wolbarg({ organization: "acme", storage: sqlite("./memory.db"), embedding: ... })
|
|
2912
2912
|
* ```
|
|
2913
2913
|
*/
|
|
2914
|
-
declare function sqlite(connectionString: string
|
|
2914
|
+
declare function sqlite(connectionString: string, options?: {
|
|
2915
|
+
concurrency?: ConcurrencyConfig$1;
|
|
2916
|
+
}): StorageProvider;
|
|
2915
2917
|
/**
|
|
2916
2918
|
* Create a SQLite storage **config object** (for `database` / `init` options).
|
|
2917
2919
|
*
|
|
@@ -3046,6 +3048,16 @@ interface ConcurrencyConfig {
|
|
|
3046
3048
|
maxBackoffMs?: number;
|
|
3047
3049
|
/** SQLite busy_timeout pragma in ms. Default: 5000 */
|
|
3048
3050
|
lockTimeoutMs?: number;
|
|
3051
|
+
/**
|
|
3052
|
+
* Hard ceiling for total lock-wait + retry budget in ms.
|
|
3053
|
+
* Default: lockTimeoutMs * (maxRetries + 1).
|
|
3054
|
+
*/
|
|
3055
|
+
lockDeadlineMs?: number;
|
|
3056
|
+
/**
|
|
3057
|
+
* When true, use multi-process-oriented defaults (higher busy_timeout / retries)
|
|
3058
|
+
* unless the caller overrides individual fields.
|
|
3059
|
+
*/
|
|
3060
|
+
multiProcess?: boolean;
|
|
3049
3061
|
}
|
|
3050
3062
|
|
|
3051
3063
|
/**
|
|
@@ -3082,6 +3094,20 @@ declare class SqliteStorageProvider implements StorageProvider {
|
|
|
3082
3094
|
private transactionDepth;
|
|
3083
3095
|
/** Incrementing counter for deterministic savepoint names. */
|
|
3084
3096
|
private savepointCounter;
|
|
3097
|
+
/**
|
|
3098
|
+
* Serializes top-level write transactions on the single SQLite connection.
|
|
3099
|
+
* SQLite is single-writer; serializing in-process avoids SQLITE_BUSY churn
|
|
3100
|
+
* AND prevents interleaved BEGIN/SAVEPOINT state corruption when many async
|
|
3101
|
+
* callers share one connection (see "no such savepoint" class of bugs).
|
|
3102
|
+
*/
|
|
3103
|
+
private readonly writeMutex;
|
|
3104
|
+
/**
|
|
3105
|
+
* Async-context flag: true while executing inside a top-level write
|
|
3106
|
+
* transaction held by this provider. Used so writes issued from within an
|
|
3107
|
+
* ambient transaction (e.g. compress()) join that ACID unit, WITHOUT
|
|
3108
|
+
* mistaking the coalescer's own flush window for an ambient transaction.
|
|
3109
|
+
*/
|
|
3110
|
+
private readonly txContext;
|
|
3085
3111
|
/** Hot in-process ANN for blob backend (sqlite-vec unavailable platforms). */
|
|
3086
3112
|
private memoryIndex;
|
|
3087
3113
|
private memoryIndexDirty;
|
|
@@ -3115,6 +3141,8 @@ declare class SqliteStorageProvider implements StorageProvider {
|
|
|
3115
3141
|
setRetryLogger(fn: ((msg: string) => void) | null): void;
|
|
3116
3142
|
/** Open the database, run migrations, and prepare statements. */
|
|
3117
3143
|
open(): Promise<void>;
|
|
3144
|
+
/** Single open attempt — connect, apply pragmas, migrate, prepare. */
|
|
3145
|
+
private openOnce;
|
|
3118
3146
|
/** Drain pending inserts, optimize, and close the SQLite connection. */
|
|
3119
3147
|
close(): Promise<void>;
|
|
3120
3148
|
/**
|
|
@@ -3320,6 +3348,8 @@ declare class PostgresStorageProvider implements StorageProvider {
|
|
|
3320
3348
|
private insertFlushScheduled;
|
|
3321
3349
|
private insertFlushTimer;
|
|
3322
3350
|
private insertFlushInFlight;
|
|
3351
|
+
/** Per-provider TX context — never share across PostgresStorageProvider instances. */
|
|
3352
|
+
private readonly txStore;
|
|
3323
3353
|
/**
|
|
3324
3354
|
* @param options - Connection string, pool size, and durability flags.
|
|
3325
3355
|
*/
|
|
@@ -4119,4 +4149,111 @@ declare function runBenchmark(name: string, iterations: number, fn: () => Promis
|
|
|
4119
4149
|
*/
|
|
4120
4150
|
declare function summarizeBenchmark(samples: BenchmarkSample[], startedAt: string, finishedAt: string): BenchmarkReport;
|
|
4121
4151
|
|
|
4122
|
-
|
|
4152
|
+
/**
|
|
4153
|
+
* Embedding provider presets for `wolbarg init` and project config.
|
|
4154
|
+
*
|
|
4155
|
+
* Base URLs are defaults the user must see and may edit — never silently applied
|
|
4156
|
+
* without showing the field.
|
|
4157
|
+
*/
|
|
4158
|
+
type EmbeddingProviderId = "openai" | "ollama" | "openrouter" | "lmstudio" | "gemini" | "together" | "vllm" | "custom";
|
|
4159
|
+
interface EmbeddingProviderPreset {
|
|
4160
|
+
id: EmbeddingProviderId;
|
|
4161
|
+
label: string;
|
|
4162
|
+
/** Default OpenAI-compatible embeddings base URL (shown to the user). */
|
|
4163
|
+
defaultBaseUrl: string;
|
|
4164
|
+
/** Suggested default model id (shown to the user). */
|
|
4165
|
+
defaultModel: string;
|
|
4166
|
+
/** Env var name written into config / `.env`. */
|
|
4167
|
+
apiKeyEnv: string;
|
|
4168
|
+
/** Hint shown next to the API key prompt. */
|
|
4169
|
+
apiKeyHint?: string;
|
|
4170
|
+
}
|
|
4171
|
+
declare const EMBEDDING_PROVIDER_PRESETS: readonly EmbeddingProviderPreset[];
|
|
4172
|
+
declare function getEmbeddingProviderPreset(id: string): EmbeddingProviderPreset | undefined;
|
|
4173
|
+
declare const DEFAULT_SQLITE_DB_PATH = ".wolbarg/shared-memory/memory.db";
|
|
4174
|
+
declare const DEFAULT_ORGANIZATION = "default";
|
|
4175
|
+
declare const DEFAULT_CONFIG_PATH = ".wolbarg/config.json";
|
|
4176
|
+
declare const DEFAULT_ENV_PATH = ".wolbarg/.env";
|
|
4177
|
+
|
|
4178
|
+
/**
|
|
4179
|
+
* Project-level Wolbarg configuration written by `wolbarg init`.
|
|
4180
|
+
*/
|
|
4181
|
+
|
|
4182
|
+
interface WolbargProjectDatabaseConfig {
|
|
4183
|
+
provider: "sqlite" | "postgres";
|
|
4184
|
+
/** SQLite file path or Postgres connection URL. */
|
|
4185
|
+
url: string;
|
|
4186
|
+
}
|
|
4187
|
+
interface WolbargProjectEmbeddingConfig {
|
|
4188
|
+
/** Named provider preset id (or `custom`). */
|
|
4189
|
+
provider: EmbeddingProviderId;
|
|
4190
|
+
/** OpenAI-compatible embeddings base URL (always stored explicitly). */
|
|
4191
|
+
baseUrl: string;
|
|
4192
|
+
/** Embedding model id. */
|
|
4193
|
+
model: string;
|
|
4194
|
+
/** Env var that holds the API key (preferred over storing secrets). */
|
|
4195
|
+
apiKeyEnv: string;
|
|
4196
|
+
}
|
|
4197
|
+
interface WolbargProjectConfig {
|
|
4198
|
+
version: 1;
|
|
4199
|
+
organization: string;
|
|
4200
|
+
database: WolbargProjectDatabaseConfig;
|
|
4201
|
+
embedding?: WolbargProjectEmbeddingConfig;
|
|
4202
|
+
/** Relative paths written by init (informational). */
|
|
4203
|
+
paths?: {
|
|
4204
|
+
config: string;
|
|
4205
|
+
env?: string;
|
|
4206
|
+
};
|
|
4207
|
+
}
|
|
4208
|
+
interface SaveProjectConfigOptions {
|
|
4209
|
+
cwd?: string;
|
|
4210
|
+
configPath?: string;
|
|
4211
|
+
/** Absolute or cwd-relative path for `.env` (optional). */
|
|
4212
|
+
envPath?: string;
|
|
4213
|
+
/** Raw API key to write into the env file (optional). */
|
|
4214
|
+
apiKey?: string;
|
|
4215
|
+
/** When true, overwrite an existing config without merging. */
|
|
4216
|
+
overwrite?: boolean;
|
|
4217
|
+
}
|
|
4218
|
+
declare function defaultProjectConfig(): WolbargProjectConfig;
|
|
4219
|
+
declare function resolveConfigPath(cwd?: string, configPath?: string): string;
|
|
4220
|
+
declare function resolveEnvPath(cwd?: string, envPath?: string): string;
|
|
4221
|
+
declare function loadProjectConfig(cwd?: string, configPath?: string): WolbargProjectConfig | null;
|
|
4222
|
+
declare function saveProjectConfig(config: WolbargProjectConfig, options?: SaveProjectConfigOptions): {
|
|
4223
|
+
configPath: string;
|
|
4224
|
+
envPath?: string;
|
|
4225
|
+
};
|
|
4226
|
+
declare function upsertEnvVar(envPath: string, key: string, value: string): void;
|
|
4227
|
+
/**
|
|
4228
|
+
* Resolve the API key for a project config from process.env (and optional `.env` load).
|
|
4229
|
+
* Does not invent keys — returns empty string if unset.
|
|
4230
|
+
*/
|
|
4231
|
+
declare function resolveEmbeddingApiKey(config: WolbargProjectConfig, env?: NodeJS.ProcessEnv): string;
|
|
4232
|
+
declare function assertEmbeddingPreset(provider: string): EmbeddingProviderId;
|
|
4233
|
+
|
|
4234
|
+
/**
|
|
4235
|
+
* Build a Wolbarg instance from `.wolbarg/config.json` (+ env).
|
|
4236
|
+
*/
|
|
4237
|
+
|
|
4238
|
+
interface CreateFromProjectConfigOptions {
|
|
4239
|
+
cwd?: string;
|
|
4240
|
+
configPath?: string;
|
|
4241
|
+
/** Extra env overlay (defaults to process.env after optional .env load). */
|
|
4242
|
+
env?: NodeJS.ProcessEnv;
|
|
4243
|
+
/** Load `.wolbarg/.env` into the env overlay when present (default true). */
|
|
4244
|
+
loadEnvFile?: boolean;
|
|
4245
|
+
/** Override organization. */
|
|
4246
|
+
organization?: string;
|
|
4247
|
+
}
|
|
4248
|
+
/**
|
|
4249
|
+
* Load key=value pairs from a dotenv-style file into a shallow copy of `base`.
|
|
4250
|
+
* Does not mutate `process.env` unless `base` is `process.env`.
|
|
4251
|
+
*/
|
|
4252
|
+
declare function applyEnvFile(envPath: string, base?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
4253
|
+
declare function projectConfigToWolbargOptions(config: WolbargProjectConfig, env?: NodeJS.ProcessEnv): WolbargOptions;
|
|
4254
|
+
/**
|
|
4255
|
+
* Create a {@link Wolbarg} context from project config written by `wolbarg init`.
|
|
4256
|
+
*/
|
|
4257
|
+
declare function createWolbargFromProjectConfig(options?: CreateFromProjectConfigOptions): Wolbarg;
|
|
4258
|
+
|
|
4259
|
+
export { type BenchmarkReport, type BenchmarkSample, type ChatMessage, type CheckpointInfo, type CheckpointMeta, type CheckpointOptions, type CheckpointProvider, type Chunk, type ChunkingOptions, type ChunkingStrategy, type ClearOptions, type CompressOptions, type CompressResult, CompressionError, type CompressionProvider, type ConcurrencyConfig$1 as ConcurrencyConfig, ConfigurationError, type ConversationMessage, type CreateCheckpointOptions, type CreateFromProjectConfigOptions, DEFAULT_CONFIG_PATH, DEFAULT_ENV_PATH, DEFAULT_ORGANIZATION, DEFAULT_SQLITE_DB_PATH, type DatabaseConfig, DatabaseError, type DatabaseProvider, type DatabaseProviderName, EMBEDDING_PROVIDER_PRESETS, type EmbeddingCacheConfig, type EmbeddingConfig, EmbeddingError, type EmbeddingProvider, type EmbeddingProviderId, type EmbeddingProviderPreset, type EventDatabase, type ExportResult, FixedChunkingStrategy, type ForgetByFilterOptions, type ForgetByIdOptions, type ForgetOptions, type GetRelatedOptions, GraphCheckpointNotSupportedError, type GraphConfig, type GraphDirection, type GraphEntityInput, type GraphHealthResult, type GraphInput$1 as GraphInput, type GraphProvider, HeadingChunkingStrategy, type HistoryEvent, type HistoryOptions, type HistoryResult, type HybridConfig, type ImportResult, type IngestOptions, type IngestResult, type InitOptions, InitializationError, type KeywordDocument, type KeywordSearchHit, type KeywordSearchProvider, type LatencyBreakdown, LlmCompressionProvider, type LlmConfig, type LlmProvider, MarkdownChunkingStrategy, type MemoryChangeCallback, type MemoryChangeEvent, type MemoryContent, type MemoryDedupeConfig, type MemoryDedupeStrategy, type MemoryFilter, type MemoryMetadata, MemoryNotFoundError, type MemoryProvider, type MemoryRecord, type MetadataFilter as MetaFilter, type MetadataComparison, type MetadataFilter, type MmrConfig, Neo4jGraphProvider, NoopTelemetryProvider, type OCRProvider, type OcrResult, ParagraphChunkingStrategy, type PersistedRecallExplainPayload, type PostgresDatabaseConfig, PostgresStorageProvider, ProviderNotConfiguredError, type RecallExplainResponse, type RecallExplanationHit, type RecallOptions, type RecallResult, type RememberAction, type RememberFromMessagesOptions, type RememberFromMessagesRawStrategy, type RememberOptions, type RememberResult, type RerankDocument, type RerankHit, type RerankerProvider, type RetrievalConfig, SDK_VERSION, type SaveProjectConfigOptions, SentenceChunkingStrategy, SqliteCheckpointProvider, type SqliteDatabaseConfig, SqliteDatabaseProvider, SqliteEventDatabase, SqliteGraphProvider, SqliteStorageProvider, SqliteTelemetryProvider, type StageSpan, type StatsResult, type StorageConfig, StorageLockedError, type StorageProvider, type StorageProviderName, type SubscribableEvent, type SubscribeFilter, type TelemetryConfig, TelemetryEmitter, type TelemetryEvent, type TelemetryEventInput, type TelemetryLogLevel, type TelemetryOperation, type TelemetryProvider, type TelemetryQuery, type TelemetryQueryResult, type TelemetryStatus, type Unsubscribe, ValidationError, type VisionProvider, type VisionResult, Wolbarg, WolbargError, WolbargLogger, type WolbargOptions, type WolbargOptionsWithLlm, type WolbargOptionsWithoutLlm, type WolbargProjectConfig, type WolbargProjectDatabaseConfig, type WolbargProjectEmbeddingConfig, applyEnvFile, assertEmbeddingPreset, bgeReranker, bm25, cohereReranker, createChunkingStrategy, createCompressionProvider, createDatabaseProvider, createEmbeddingProvider, createLlmProvider, createStorageProvider, createTelemetryProvider, createWolbarg, createWolbargFromProjectConfig, crossEncoder, defaultProjectConfig, geminiEmbedding, geminiVision, getEmbeddingProviderPreset, jinaReranker, lmStudioEmbedding, loadProjectConfig, meta, neo4jGraph, ollamaEmbedding, ollamaLlm, openRouterEmbedding, openRouterLlm, openaiCompatibleEmbedding, openaiCompatibleLlm, openaiEmbedding, openaiLlm, openaiReranker, openaiVision, postgres, postgresConfig, projectConfigToWolbargOptions, resolveConfigPath, resolveEmbeddingApiKey, resolveEnvPath, runBenchmark, saveProjectConfig, sqlite, sqliteCheckpoint, sqliteConfig, sqliteGraph, sqliteTelemetry, summarizeBenchmark, tesseract, togetherEmbedding, upsertEnvVar, vllmEmbedding, wolbarg$1 as wolbarg, wrapOperationError };
|
package/dist/index.d.ts
CHANGED
|
@@ -371,6 +371,10 @@ interface ConcurrencyConfig$1 {
|
|
|
371
371
|
baseBackoffMs?: number;
|
|
372
372
|
maxBackoffMs?: number;
|
|
373
373
|
lockTimeoutMs?: number;
|
|
374
|
+
/** Total lock-wait + retry budget in ms. */
|
|
375
|
+
lockDeadlineMs?: number;
|
|
376
|
+
/** Use multi-process-oriented defaults when many OS processes share one DB file. */
|
|
377
|
+
multiProcess?: boolean;
|
|
374
378
|
}
|
|
375
379
|
/** Transparent embedding cache configuration. */
|
|
376
380
|
interface EmbeddingCacheConfig {
|
|
@@ -2149,7 +2153,7 @@ interface WolbargOptionsBase {
|
|
|
2149
2153
|
organization: string;
|
|
2150
2154
|
/**
|
|
2151
2155
|
* Storage provider instance or config.
|
|
2152
|
-
* Prefer `
|
|
2156
|
+
* Prefer `storage: sqlite(...)` / `postgres(...)` in docs; `database` remains supported.
|
|
2153
2157
|
*/
|
|
2154
2158
|
storage?: StorageInput;
|
|
2155
2159
|
/**
|
|
@@ -2725,7 +2729,7 @@ declare class Wolbarg<HasLlm extends boolean = false> {
|
|
|
2725
2729
|
declare function wolbarg$1(options: WolbargOptions): Wolbarg;
|
|
2726
2730
|
|
|
2727
2731
|
/** Published SDK semver — keep in sync with `package.json` `version`. */
|
|
2728
|
-
declare const SDK_VERSION = "0.5.
|
|
2732
|
+
declare const SDK_VERSION = "0.5.6";
|
|
2729
2733
|
|
|
2730
2734
|
/**
|
|
2731
2735
|
* Operation-scoped errors with stable `code`, human `reason`, and actionable `suggestion`.
|
|
@@ -2896,10 +2900,6 @@ declare class GraphCheckpointNotSupportedError extends WolbargError {
|
|
|
2896
2900
|
*/
|
|
2897
2901
|
declare function wrapOperationError(operation: string, error: unknown): WolbargError;
|
|
2898
2902
|
|
|
2899
|
-
/**
|
|
2900
|
-
* Public factory helpers for storage, telemetry, checkpoints, and graph providers (v0.5.5).
|
|
2901
|
-
*/
|
|
2902
|
-
|
|
2903
2903
|
/**
|
|
2904
2904
|
* Create a SQLite {@link StorageProvider} from a filesystem path or `:memory:`.
|
|
2905
2905
|
*
|
|
@@ -2911,7 +2911,9 @@ declare function wrapOperationError(operation: string, error: unknown): WolbargE
|
|
|
2911
2911
|
* wolbarg({ organization: "acme", storage: sqlite("./memory.db"), embedding: ... })
|
|
2912
2912
|
* ```
|
|
2913
2913
|
*/
|
|
2914
|
-
declare function sqlite(connectionString: string
|
|
2914
|
+
declare function sqlite(connectionString: string, options?: {
|
|
2915
|
+
concurrency?: ConcurrencyConfig$1;
|
|
2916
|
+
}): StorageProvider;
|
|
2915
2917
|
/**
|
|
2916
2918
|
* Create a SQLite storage **config object** (for `database` / `init` options).
|
|
2917
2919
|
*
|
|
@@ -3046,6 +3048,16 @@ interface ConcurrencyConfig {
|
|
|
3046
3048
|
maxBackoffMs?: number;
|
|
3047
3049
|
/** SQLite busy_timeout pragma in ms. Default: 5000 */
|
|
3048
3050
|
lockTimeoutMs?: number;
|
|
3051
|
+
/**
|
|
3052
|
+
* Hard ceiling for total lock-wait + retry budget in ms.
|
|
3053
|
+
* Default: lockTimeoutMs * (maxRetries + 1).
|
|
3054
|
+
*/
|
|
3055
|
+
lockDeadlineMs?: number;
|
|
3056
|
+
/**
|
|
3057
|
+
* When true, use multi-process-oriented defaults (higher busy_timeout / retries)
|
|
3058
|
+
* unless the caller overrides individual fields.
|
|
3059
|
+
*/
|
|
3060
|
+
multiProcess?: boolean;
|
|
3049
3061
|
}
|
|
3050
3062
|
|
|
3051
3063
|
/**
|
|
@@ -3082,6 +3094,20 @@ declare class SqliteStorageProvider implements StorageProvider {
|
|
|
3082
3094
|
private transactionDepth;
|
|
3083
3095
|
/** Incrementing counter for deterministic savepoint names. */
|
|
3084
3096
|
private savepointCounter;
|
|
3097
|
+
/**
|
|
3098
|
+
* Serializes top-level write transactions on the single SQLite connection.
|
|
3099
|
+
* SQLite is single-writer; serializing in-process avoids SQLITE_BUSY churn
|
|
3100
|
+
* AND prevents interleaved BEGIN/SAVEPOINT state corruption when many async
|
|
3101
|
+
* callers share one connection (see "no such savepoint" class of bugs).
|
|
3102
|
+
*/
|
|
3103
|
+
private readonly writeMutex;
|
|
3104
|
+
/**
|
|
3105
|
+
* Async-context flag: true while executing inside a top-level write
|
|
3106
|
+
* transaction held by this provider. Used so writes issued from within an
|
|
3107
|
+
* ambient transaction (e.g. compress()) join that ACID unit, WITHOUT
|
|
3108
|
+
* mistaking the coalescer's own flush window for an ambient transaction.
|
|
3109
|
+
*/
|
|
3110
|
+
private readonly txContext;
|
|
3085
3111
|
/** Hot in-process ANN for blob backend (sqlite-vec unavailable platforms). */
|
|
3086
3112
|
private memoryIndex;
|
|
3087
3113
|
private memoryIndexDirty;
|
|
@@ -3115,6 +3141,8 @@ declare class SqliteStorageProvider implements StorageProvider {
|
|
|
3115
3141
|
setRetryLogger(fn: ((msg: string) => void) | null): void;
|
|
3116
3142
|
/** Open the database, run migrations, and prepare statements. */
|
|
3117
3143
|
open(): Promise<void>;
|
|
3144
|
+
/** Single open attempt — connect, apply pragmas, migrate, prepare. */
|
|
3145
|
+
private openOnce;
|
|
3118
3146
|
/** Drain pending inserts, optimize, and close the SQLite connection. */
|
|
3119
3147
|
close(): Promise<void>;
|
|
3120
3148
|
/**
|
|
@@ -3320,6 +3348,8 @@ declare class PostgresStorageProvider implements StorageProvider {
|
|
|
3320
3348
|
private insertFlushScheduled;
|
|
3321
3349
|
private insertFlushTimer;
|
|
3322
3350
|
private insertFlushInFlight;
|
|
3351
|
+
/** Per-provider TX context — never share across PostgresStorageProvider instances. */
|
|
3352
|
+
private readonly txStore;
|
|
3323
3353
|
/**
|
|
3324
3354
|
* @param options - Connection string, pool size, and durability flags.
|
|
3325
3355
|
*/
|
|
@@ -4119,4 +4149,111 @@ declare function runBenchmark(name: string, iterations: number, fn: () => Promis
|
|
|
4119
4149
|
*/
|
|
4120
4150
|
declare function summarizeBenchmark(samples: BenchmarkSample[], startedAt: string, finishedAt: string): BenchmarkReport;
|
|
4121
4151
|
|
|
4122
|
-
|
|
4152
|
+
/**
|
|
4153
|
+
* Embedding provider presets for `wolbarg init` and project config.
|
|
4154
|
+
*
|
|
4155
|
+
* Base URLs are defaults the user must see and may edit — never silently applied
|
|
4156
|
+
* without showing the field.
|
|
4157
|
+
*/
|
|
4158
|
+
type EmbeddingProviderId = "openai" | "ollama" | "openrouter" | "lmstudio" | "gemini" | "together" | "vllm" | "custom";
|
|
4159
|
+
interface EmbeddingProviderPreset {
|
|
4160
|
+
id: EmbeddingProviderId;
|
|
4161
|
+
label: string;
|
|
4162
|
+
/** Default OpenAI-compatible embeddings base URL (shown to the user). */
|
|
4163
|
+
defaultBaseUrl: string;
|
|
4164
|
+
/** Suggested default model id (shown to the user). */
|
|
4165
|
+
defaultModel: string;
|
|
4166
|
+
/** Env var name written into config / `.env`. */
|
|
4167
|
+
apiKeyEnv: string;
|
|
4168
|
+
/** Hint shown next to the API key prompt. */
|
|
4169
|
+
apiKeyHint?: string;
|
|
4170
|
+
}
|
|
4171
|
+
declare const EMBEDDING_PROVIDER_PRESETS: readonly EmbeddingProviderPreset[];
|
|
4172
|
+
declare function getEmbeddingProviderPreset(id: string): EmbeddingProviderPreset | undefined;
|
|
4173
|
+
declare const DEFAULT_SQLITE_DB_PATH = ".wolbarg/shared-memory/memory.db";
|
|
4174
|
+
declare const DEFAULT_ORGANIZATION = "default";
|
|
4175
|
+
declare const DEFAULT_CONFIG_PATH = ".wolbarg/config.json";
|
|
4176
|
+
declare const DEFAULT_ENV_PATH = ".wolbarg/.env";
|
|
4177
|
+
|
|
4178
|
+
/**
|
|
4179
|
+
* Project-level Wolbarg configuration written by `wolbarg init`.
|
|
4180
|
+
*/
|
|
4181
|
+
|
|
4182
|
+
interface WolbargProjectDatabaseConfig {
|
|
4183
|
+
provider: "sqlite" | "postgres";
|
|
4184
|
+
/** SQLite file path or Postgres connection URL. */
|
|
4185
|
+
url: string;
|
|
4186
|
+
}
|
|
4187
|
+
interface WolbargProjectEmbeddingConfig {
|
|
4188
|
+
/** Named provider preset id (or `custom`). */
|
|
4189
|
+
provider: EmbeddingProviderId;
|
|
4190
|
+
/** OpenAI-compatible embeddings base URL (always stored explicitly). */
|
|
4191
|
+
baseUrl: string;
|
|
4192
|
+
/** Embedding model id. */
|
|
4193
|
+
model: string;
|
|
4194
|
+
/** Env var that holds the API key (preferred over storing secrets). */
|
|
4195
|
+
apiKeyEnv: string;
|
|
4196
|
+
}
|
|
4197
|
+
interface WolbargProjectConfig {
|
|
4198
|
+
version: 1;
|
|
4199
|
+
organization: string;
|
|
4200
|
+
database: WolbargProjectDatabaseConfig;
|
|
4201
|
+
embedding?: WolbargProjectEmbeddingConfig;
|
|
4202
|
+
/** Relative paths written by init (informational). */
|
|
4203
|
+
paths?: {
|
|
4204
|
+
config: string;
|
|
4205
|
+
env?: string;
|
|
4206
|
+
};
|
|
4207
|
+
}
|
|
4208
|
+
interface SaveProjectConfigOptions {
|
|
4209
|
+
cwd?: string;
|
|
4210
|
+
configPath?: string;
|
|
4211
|
+
/** Absolute or cwd-relative path for `.env` (optional). */
|
|
4212
|
+
envPath?: string;
|
|
4213
|
+
/** Raw API key to write into the env file (optional). */
|
|
4214
|
+
apiKey?: string;
|
|
4215
|
+
/** When true, overwrite an existing config without merging. */
|
|
4216
|
+
overwrite?: boolean;
|
|
4217
|
+
}
|
|
4218
|
+
declare function defaultProjectConfig(): WolbargProjectConfig;
|
|
4219
|
+
declare function resolveConfigPath(cwd?: string, configPath?: string): string;
|
|
4220
|
+
declare function resolveEnvPath(cwd?: string, envPath?: string): string;
|
|
4221
|
+
declare function loadProjectConfig(cwd?: string, configPath?: string): WolbargProjectConfig | null;
|
|
4222
|
+
declare function saveProjectConfig(config: WolbargProjectConfig, options?: SaveProjectConfigOptions): {
|
|
4223
|
+
configPath: string;
|
|
4224
|
+
envPath?: string;
|
|
4225
|
+
};
|
|
4226
|
+
declare function upsertEnvVar(envPath: string, key: string, value: string): void;
|
|
4227
|
+
/**
|
|
4228
|
+
* Resolve the API key for a project config from process.env (and optional `.env` load).
|
|
4229
|
+
* Does not invent keys — returns empty string if unset.
|
|
4230
|
+
*/
|
|
4231
|
+
declare function resolveEmbeddingApiKey(config: WolbargProjectConfig, env?: NodeJS.ProcessEnv): string;
|
|
4232
|
+
declare function assertEmbeddingPreset(provider: string): EmbeddingProviderId;
|
|
4233
|
+
|
|
4234
|
+
/**
|
|
4235
|
+
* Build a Wolbarg instance from `.wolbarg/config.json` (+ env).
|
|
4236
|
+
*/
|
|
4237
|
+
|
|
4238
|
+
interface CreateFromProjectConfigOptions {
|
|
4239
|
+
cwd?: string;
|
|
4240
|
+
configPath?: string;
|
|
4241
|
+
/** Extra env overlay (defaults to process.env after optional .env load). */
|
|
4242
|
+
env?: NodeJS.ProcessEnv;
|
|
4243
|
+
/** Load `.wolbarg/.env` into the env overlay when present (default true). */
|
|
4244
|
+
loadEnvFile?: boolean;
|
|
4245
|
+
/** Override organization. */
|
|
4246
|
+
organization?: string;
|
|
4247
|
+
}
|
|
4248
|
+
/**
|
|
4249
|
+
* Load key=value pairs from a dotenv-style file into a shallow copy of `base`.
|
|
4250
|
+
* Does not mutate `process.env` unless `base` is `process.env`.
|
|
4251
|
+
*/
|
|
4252
|
+
declare function applyEnvFile(envPath: string, base?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
4253
|
+
declare function projectConfigToWolbargOptions(config: WolbargProjectConfig, env?: NodeJS.ProcessEnv): WolbargOptions;
|
|
4254
|
+
/**
|
|
4255
|
+
* Create a {@link Wolbarg} context from project config written by `wolbarg init`.
|
|
4256
|
+
*/
|
|
4257
|
+
declare function createWolbargFromProjectConfig(options?: CreateFromProjectConfigOptions): Wolbarg;
|
|
4258
|
+
|
|
4259
|
+
export { type BenchmarkReport, type BenchmarkSample, type ChatMessage, type CheckpointInfo, type CheckpointMeta, type CheckpointOptions, type CheckpointProvider, type Chunk, type ChunkingOptions, type ChunkingStrategy, type ClearOptions, type CompressOptions, type CompressResult, CompressionError, type CompressionProvider, type ConcurrencyConfig$1 as ConcurrencyConfig, ConfigurationError, type ConversationMessage, type CreateCheckpointOptions, type CreateFromProjectConfigOptions, DEFAULT_CONFIG_PATH, DEFAULT_ENV_PATH, DEFAULT_ORGANIZATION, DEFAULT_SQLITE_DB_PATH, type DatabaseConfig, DatabaseError, type DatabaseProvider, type DatabaseProviderName, EMBEDDING_PROVIDER_PRESETS, type EmbeddingCacheConfig, type EmbeddingConfig, EmbeddingError, type EmbeddingProvider, type EmbeddingProviderId, type EmbeddingProviderPreset, type EventDatabase, type ExportResult, FixedChunkingStrategy, type ForgetByFilterOptions, type ForgetByIdOptions, type ForgetOptions, type GetRelatedOptions, GraphCheckpointNotSupportedError, type GraphConfig, type GraphDirection, type GraphEntityInput, type GraphHealthResult, type GraphInput$1 as GraphInput, type GraphProvider, HeadingChunkingStrategy, type HistoryEvent, type HistoryOptions, type HistoryResult, type HybridConfig, type ImportResult, type IngestOptions, type IngestResult, type InitOptions, InitializationError, type KeywordDocument, type KeywordSearchHit, type KeywordSearchProvider, type LatencyBreakdown, LlmCompressionProvider, type LlmConfig, type LlmProvider, MarkdownChunkingStrategy, type MemoryChangeCallback, type MemoryChangeEvent, type MemoryContent, type MemoryDedupeConfig, type MemoryDedupeStrategy, type MemoryFilter, type MemoryMetadata, MemoryNotFoundError, type MemoryProvider, type MemoryRecord, type MetadataFilter as MetaFilter, type MetadataComparison, type MetadataFilter, type MmrConfig, Neo4jGraphProvider, NoopTelemetryProvider, type OCRProvider, type OcrResult, ParagraphChunkingStrategy, type PersistedRecallExplainPayload, type PostgresDatabaseConfig, PostgresStorageProvider, ProviderNotConfiguredError, type RecallExplainResponse, type RecallExplanationHit, type RecallOptions, type RecallResult, type RememberAction, type RememberFromMessagesOptions, type RememberFromMessagesRawStrategy, type RememberOptions, type RememberResult, type RerankDocument, type RerankHit, type RerankerProvider, type RetrievalConfig, SDK_VERSION, type SaveProjectConfigOptions, SentenceChunkingStrategy, SqliteCheckpointProvider, type SqliteDatabaseConfig, SqliteDatabaseProvider, SqliteEventDatabase, SqliteGraphProvider, SqliteStorageProvider, SqliteTelemetryProvider, type StageSpan, type StatsResult, type StorageConfig, StorageLockedError, type StorageProvider, type StorageProviderName, type SubscribableEvent, type SubscribeFilter, type TelemetryConfig, TelemetryEmitter, type TelemetryEvent, type TelemetryEventInput, type TelemetryLogLevel, type TelemetryOperation, type TelemetryProvider, type TelemetryQuery, type TelemetryQueryResult, type TelemetryStatus, type Unsubscribe, ValidationError, type VisionProvider, type VisionResult, Wolbarg, WolbargError, WolbargLogger, type WolbargOptions, type WolbargOptionsWithLlm, type WolbargOptionsWithoutLlm, type WolbargProjectConfig, type WolbargProjectDatabaseConfig, type WolbargProjectEmbeddingConfig, applyEnvFile, assertEmbeddingPreset, bgeReranker, bm25, cohereReranker, createChunkingStrategy, createCompressionProvider, createDatabaseProvider, createEmbeddingProvider, createLlmProvider, createStorageProvider, createTelemetryProvider, createWolbarg, createWolbargFromProjectConfig, crossEncoder, defaultProjectConfig, geminiEmbedding, geminiVision, getEmbeddingProviderPreset, jinaReranker, lmStudioEmbedding, loadProjectConfig, meta, neo4jGraph, ollamaEmbedding, ollamaLlm, openRouterEmbedding, openRouterLlm, openaiCompatibleEmbedding, openaiCompatibleLlm, openaiEmbedding, openaiLlm, openaiReranker, openaiVision, postgres, postgresConfig, projectConfigToWolbargOptions, resolveConfigPath, resolveEmbeddingApiKey, resolveEnvPath, runBenchmark, saveProjectConfig, sqlite, sqliteCheckpoint, sqliteConfig, sqliteGraph, sqliteTelemetry, summarizeBenchmark, tesseract, togetherEmbedding, upsertEnvVar, vllmEmbedding, wolbarg$1 as wolbarg, wrapOperationError };
|