wolbarg 0.5.5 → 0.5.6
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 +14 -0
- package/README.md +31 -1
- package/dist/cli.js +515 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.cjs +290 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +109 -2
- package/dist/index.d.ts +109 -2
- package/dist/index.js +276 -11
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
package/dist/index.d.cts
CHANGED
|
@@ -2725,7 +2725,7 @@ declare class Wolbarg<HasLlm extends boolean = false> {
|
|
|
2725
2725
|
declare function wolbarg$1(options: WolbargOptions): Wolbarg;
|
|
2726
2726
|
|
|
2727
2727
|
/** Published SDK semver — keep in sync with `package.json` `version`. */
|
|
2728
|
-
declare const SDK_VERSION = "0.5.
|
|
2728
|
+
declare const SDK_VERSION = "0.5.6";
|
|
2729
2729
|
|
|
2730
2730
|
/**
|
|
2731
2731
|
* Operation-scoped errors with stable `code`, human `reason`, and actionable `suggestion`.
|
|
@@ -4119,4 +4119,111 @@ declare function runBenchmark(name: string, iterations: number, fn: () => Promis
|
|
|
4119
4119
|
*/
|
|
4120
4120
|
declare function summarizeBenchmark(samples: BenchmarkSample[], startedAt: string, finishedAt: string): BenchmarkReport;
|
|
4121
4121
|
|
|
4122
|
-
|
|
4122
|
+
/**
|
|
4123
|
+
* Embedding provider presets for `wolbarg init` and project config.
|
|
4124
|
+
*
|
|
4125
|
+
* Base URLs are defaults the user must see and may edit — never silently applied
|
|
4126
|
+
* without showing the field.
|
|
4127
|
+
*/
|
|
4128
|
+
type EmbeddingProviderId = "openai" | "ollama" | "openrouter" | "lmstudio" | "gemini" | "together" | "vllm" | "custom";
|
|
4129
|
+
interface EmbeddingProviderPreset {
|
|
4130
|
+
id: EmbeddingProviderId;
|
|
4131
|
+
label: string;
|
|
4132
|
+
/** Default OpenAI-compatible embeddings base URL (shown to the user). */
|
|
4133
|
+
defaultBaseUrl: string;
|
|
4134
|
+
/** Suggested default model id (shown to the user). */
|
|
4135
|
+
defaultModel: string;
|
|
4136
|
+
/** Env var name written into config / `.env`. */
|
|
4137
|
+
apiKeyEnv: string;
|
|
4138
|
+
/** Hint shown next to the API key prompt. */
|
|
4139
|
+
apiKeyHint?: string;
|
|
4140
|
+
}
|
|
4141
|
+
declare const EMBEDDING_PROVIDER_PRESETS: readonly EmbeddingProviderPreset[];
|
|
4142
|
+
declare function getEmbeddingProviderPreset(id: string): EmbeddingProviderPreset | undefined;
|
|
4143
|
+
declare const DEFAULT_SQLITE_DB_PATH = ".wolbarg/shared-memory/memory.db";
|
|
4144
|
+
declare const DEFAULT_ORGANIZATION = "default";
|
|
4145
|
+
declare const DEFAULT_CONFIG_PATH = ".wolbarg/config.json";
|
|
4146
|
+
declare const DEFAULT_ENV_PATH = ".wolbarg/.env";
|
|
4147
|
+
|
|
4148
|
+
/**
|
|
4149
|
+
* Project-level Wolbarg configuration written by `wolbarg init`.
|
|
4150
|
+
*/
|
|
4151
|
+
|
|
4152
|
+
interface WolbargProjectDatabaseConfig {
|
|
4153
|
+
provider: "sqlite" | "postgres";
|
|
4154
|
+
/** SQLite file path or Postgres connection URL. */
|
|
4155
|
+
url: string;
|
|
4156
|
+
}
|
|
4157
|
+
interface WolbargProjectEmbeddingConfig {
|
|
4158
|
+
/** Named provider preset id (or `custom`). */
|
|
4159
|
+
provider: EmbeddingProviderId;
|
|
4160
|
+
/** OpenAI-compatible embeddings base URL (always stored explicitly). */
|
|
4161
|
+
baseUrl: string;
|
|
4162
|
+
/** Embedding model id. */
|
|
4163
|
+
model: string;
|
|
4164
|
+
/** Env var that holds the API key (preferred over storing secrets). */
|
|
4165
|
+
apiKeyEnv: string;
|
|
4166
|
+
}
|
|
4167
|
+
interface WolbargProjectConfig {
|
|
4168
|
+
version: 1;
|
|
4169
|
+
organization: string;
|
|
4170
|
+
database: WolbargProjectDatabaseConfig;
|
|
4171
|
+
embedding?: WolbargProjectEmbeddingConfig;
|
|
4172
|
+
/** Relative paths written by init (informational). */
|
|
4173
|
+
paths?: {
|
|
4174
|
+
config: string;
|
|
4175
|
+
env?: string;
|
|
4176
|
+
};
|
|
4177
|
+
}
|
|
4178
|
+
interface SaveProjectConfigOptions {
|
|
4179
|
+
cwd?: string;
|
|
4180
|
+
configPath?: string;
|
|
4181
|
+
/** Absolute or cwd-relative path for `.env` (optional). */
|
|
4182
|
+
envPath?: string;
|
|
4183
|
+
/** Raw API key to write into the env file (optional). */
|
|
4184
|
+
apiKey?: string;
|
|
4185
|
+
/** When true, overwrite an existing config without merging. */
|
|
4186
|
+
overwrite?: boolean;
|
|
4187
|
+
}
|
|
4188
|
+
declare function defaultProjectConfig(): WolbargProjectConfig;
|
|
4189
|
+
declare function resolveConfigPath(cwd?: string, configPath?: string): string;
|
|
4190
|
+
declare function resolveEnvPath(cwd?: string, envPath?: string): string;
|
|
4191
|
+
declare function loadProjectConfig(cwd?: string, configPath?: string): WolbargProjectConfig | null;
|
|
4192
|
+
declare function saveProjectConfig(config: WolbargProjectConfig, options?: SaveProjectConfigOptions): {
|
|
4193
|
+
configPath: string;
|
|
4194
|
+
envPath?: string;
|
|
4195
|
+
};
|
|
4196
|
+
declare function upsertEnvVar(envPath: string, key: string, value: string): void;
|
|
4197
|
+
/**
|
|
4198
|
+
* Resolve the API key for a project config from process.env (and optional `.env` load).
|
|
4199
|
+
* Does not invent keys — returns empty string if unset.
|
|
4200
|
+
*/
|
|
4201
|
+
declare function resolveEmbeddingApiKey(config: WolbargProjectConfig, env?: NodeJS.ProcessEnv): string;
|
|
4202
|
+
declare function assertEmbeddingPreset(provider: string): EmbeddingProviderId;
|
|
4203
|
+
|
|
4204
|
+
/**
|
|
4205
|
+
* Build a Wolbarg instance from `.wolbarg/config.json` (+ env).
|
|
4206
|
+
*/
|
|
4207
|
+
|
|
4208
|
+
interface CreateFromProjectConfigOptions {
|
|
4209
|
+
cwd?: string;
|
|
4210
|
+
configPath?: string;
|
|
4211
|
+
/** Extra env overlay (defaults to process.env after optional .env load). */
|
|
4212
|
+
env?: NodeJS.ProcessEnv;
|
|
4213
|
+
/** Load `.wolbarg/.env` into the env overlay when present (default true). */
|
|
4214
|
+
loadEnvFile?: boolean;
|
|
4215
|
+
/** Override organization. */
|
|
4216
|
+
organization?: string;
|
|
4217
|
+
}
|
|
4218
|
+
/**
|
|
4219
|
+
* Load key=value pairs from a dotenv-style file into a shallow copy of `base`.
|
|
4220
|
+
* Does not mutate `process.env` unless `base` is `process.env`.
|
|
4221
|
+
*/
|
|
4222
|
+
declare function applyEnvFile(envPath: string, base?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
4223
|
+
declare function projectConfigToWolbargOptions(config: WolbargProjectConfig, env?: NodeJS.ProcessEnv): WolbargOptions;
|
|
4224
|
+
/**
|
|
4225
|
+
* Create a {@link Wolbarg} context from project config written by `wolbarg init`.
|
|
4226
|
+
*/
|
|
4227
|
+
declare function createWolbargFromProjectConfig(options?: CreateFromProjectConfigOptions): Wolbarg;
|
|
4228
|
+
|
|
4229
|
+
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
|
@@ -2725,7 +2725,7 @@ declare class Wolbarg<HasLlm extends boolean = false> {
|
|
|
2725
2725
|
declare function wolbarg$1(options: WolbargOptions): Wolbarg;
|
|
2726
2726
|
|
|
2727
2727
|
/** Published SDK semver — keep in sync with `package.json` `version`. */
|
|
2728
|
-
declare const SDK_VERSION = "0.5.
|
|
2728
|
+
declare const SDK_VERSION = "0.5.6";
|
|
2729
2729
|
|
|
2730
2730
|
/**
|
|
2731
2731
|
* Operation-scoped errors with stable `code`, human `reason`, and actionable `suggestion`.
|
|
@@ -4119,4 +4119,111 @@ declare function runBenchmark(name: string, iterations: number, fn: () => Promis
|
|
|
4119
4119
|
*/
|
|
4120
4120
|
declare function summarizeBenchmark(samples: BenchmarkSample[], startedAt: string, finishedAt: string): BenchmarkReport;
|
|
4121
4121
|
|
|
4122
|
-
|
|
4122
|
+
/**
|
|
4123
|
+
* Embedding provider presets for `wolbarg init` and project config.
|
|
4124
|
+
*
|
|
4125
|
+
* Base URLs are defaults the user must see and may edit — never silently applied
|
|
4126
|
+
* without showing the field.
|
|
4127
|
+
*/
|
|
4128
|
+
type EmbeddingProviderId = "openai" | "ollama" | "openrouter" | "lmstudio" | "gemini" | "together" | "vllm" | "custom";
|
|
4129
|
+
interface EmbeddingProviderPreset {
|
|
4130
|
+
id: EmbeddingProviderId;
|
|
4131
|
+
label: string;
|
|
4132
|
+
/** Default OpenAI-compatible embeddings base URL (shown to the user). */
|
|
4133
|
+
defaultBaseUrl: string;
|
|
4134
|
+
/** Suggested default model id (shown to the user). */
|
|
4135
|
+
defaultModel: string;
|
|
4136
|
+
/** Env var name written into config / `.env`. */
|
|
4137
|
+
apiKeyEnv: string;
|
|
4138
|
+
/** Hint shown next to the API key prompt. */
|
|
4139
|
+
apiKeyHint?: string;
|
|
4140
|
+
}
|
|
4141
|
+
declare const EMBEDDING_PROVIDER_PRESETS: readonly EmbeddingProviderPreset[];
|
|
4142
|
+
declare function getEmbeddingProviderPreset(id: string): EmbeddingProviderPreset | undefined;
|
|
4143
|
+
declare const DEFAULT_SQLITE_DB_PATH = ".wolbarg/shared-memory/memory.db";
|
|
4144
|
+
declare const DEFAULT_ORGANIZATION = "default";
|
|
4145
|
+
declare const DEFAULT_CONFIG_PATH = ".wolbarg/config.json";
|
|
4146
|
+
declare const DEFAULT_ENV_PATH = ".wolbarg/.env";
|
|
4147
|
+
|
|
4148
|
+
/**
|
|
4149
|
+
* Project-level Wolbarg configuration written by `wolbarg init`.
|
|
4150
|
+
*/
|
|
4151
|
+
|
|
4152
|
+
interface WolbargProjectDatabaseConfig {
|
|
4153
|
+
provider: "sqlite" | "postgres";
|
|
4154
|
+
/** SQLite file path or Postgres connection URL. */
|
|
4155
|
+
url: string;
|
|
4156
|
+
}
|
|
4157
|
+
interface WolbargProjectEmbeddingConfig {
|
|
4158
|
+
/** Named provider preset id (or `custom`). */
|
|
4159
|
+
provider: EmbeddingProviderId;
|
|
4160
|
+
/** OpenAI-compatible embeddings base URL (always stored explicitly). */
|
|
4161
|
+
baseUrl: string;
|
|
4162
|
+
/** Embedding model id. */
|
|
4163
|
+
model: string;
|
|
4164
|
+
/** Env var that holds the API key (preferred over storing secrets). */
|
|
4165
|
+
apiKeyEnv: string;
|
|
4166
|
+
}
|
|
4167
|
+
interface WolbargProjectConfig {
|
|
4168
|
+
version: 1;
|
|
4169
|
+
organization: string;
|
|
4170
|
+
database: WolbargProjectDatabaseConfig;
|
|
4171
|
+
embedding?: WolbargProjectEmbeddingConfig;
|
|
4172
|
+
/** Relative paths written by init (informational). */
|
|
4173
|
+
paths?: {
|
|
4174
|
+
config: string;
|
|
4175
|
+
env?: string;
|
|
4176
|
+
};
|
|
4177
|
+
}
|
|
4178
|
+
interface SaveProjectConfigOptions {
|
|
4179
|
+
cwd?: string;
|
|
4180
|
+
configPath?: string;
|
|
4181
|
+
/** Absolute or cwd-relative path for `.env` (optional). */
|
|
4182
|
+
envPath?: string;
|
|
4183
|
+
/** Raw API key to write into the env file (optional). */
|
|
4184
|
+
apiKey?: string;
|
|
4185
|
+
/** When true, overwrite an existing config without merging. */
|
|
4186
|
+
overwrite?: boolean;
|
|
4187
|
+
}
|
|
4188
|
+
declare function defaultProjectConfig(): WolbargProjectConfig;
|
|
4189
|
+
declare function resolveConfigPath(cwd?: string, configPath?: string): string;
|
|
4190
|
+
declare function resolveEnvPath(cwd?: string, envPath?: string): string;
|
|
4191
|
+
declare function loadProjectConfig(cwd?: string, configPath?: string): WolbargProjectConfig | null;
|
|
4192
|
+
declare function saveProjectConfig(config: WolbargProjectConfig, options?: SaveProjectConfigOptions): {
|
|
4193
|
+
configPath: string;
|
|
4194
|
+
envPath?: string;
|
|
4195
|
+
};
|
|
4196
|
+
declare function upsertEnvVar(envPath: string, key: string, value: string): void;
|
|
4197
|
+
/**
|
|
4198
|
+
* Resolve the API key for a project config from process.env (and optional `.env` load).
|
|
4199
|
+
* Does not invent keys — returns empty string if unset.
|
|
4200
|
+
*/
|
|
4201
|
+
declare function resolveEmbeddingApiKey(config: WolbargProjectConfig, env?: NodeJS.ProcessEnv): string;
|
|
4202
|
+
declare function assertEmbeddingPreset(provider: string): EmbeddingProviderId;
|
|
4203
|
+
|
|
4204
|
+
/**
|
|
4205
|
+
* Build a Wolbarg instance from `.wolbarg/config.json` (+ env).
|
|
4206
|
+
*/
|
|
4207
|
+
|
|
4208
|
+
interface CreateFromProjectConfigOptions {
|
|
4209
|
+
cwd?: string;
|
|
4210
|
+
configPath?: string;
|
|
4211
|
+
/** Extra env overlay (defaults to process.env after optional .env load). */
|
|
4212
|
+
env?: NodeJS.ProcessEnv;
|
|
4213
|
+
/** Load `.wolbarg/.env` into the env overlay when present (default true). */
|
|
4214
|
+
loadEnvFile?: boolean;
|
|
4215
|
+
/** Override organization. */
|
|
4216
|
+
organization?: string;
|
|
4217
|
+
}
|
|
4218
|
+
/**
|
|
4219
|
+
* Load key=value pairs from a dotenv-style file into a shallow copy of `base`.
|
|
4220
|
+
* Does not mutate `process.env` unless `base` is `process.env`.
|
|
4221
|
+
*/
|
|
4222
|
+
declare function applyEnvFile(envPath: string, base?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
4223
|
+
declare function projectConfigToWolbargOptions(config: WolbargProjectConfig, env?: NodeJS.ProcessEnv): WolbargOptions;
|
|
4224
|
+
/**
|
|
4225
|
+
* Create a {@link Wolbarg} context from project config written by `wolbarg init`.
|
|
4226
|
+
*/
|
|
4227
|
+
declare function createWolbargFromProjectConfig(options?: CreateFromProjectConfigOptions): Wolbarg;
|
|
4228
|
+
|
|
4229
|
+
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.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import fs6 from "node:fs";
|
|
2
|
-
import path7 from "node:path";
|
|
1
|
+
import fs6, { existsSync, readFileSync, mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
+
import path7, { isAbsolute, resolve, dirname, join } from "node:path";
|
|
3
3
|
import { createHash } from 'crypto';
|
|
4
4
|
import fs from 'fs/promises';
|
|
5
5
|
import { DatabaseSync } from "node:sqlite";
|
|
@@ -445,8 +445,8 @@ var AsyncMutex = class {
|
|
|
445
445
|
*/
|
|
446
446
|
async runExclusive(fn) {
|
|
447
447
|
let release;
|
|
448
|
-
const next = new Promise((
|
|
449
|
-
release =
|
|
448
|
+
const next = new Promise((resolve3) => {
|
|
449
|
+
release = resolve3;
|
|
450
450
|
});
|
|
451
451
|
const previous = this.chain;
|
|
452
452
|
this.chain = previous.then(() => next);
|
|
@@ -2276,7 +2276,7 @@ function isSqliteBusyError(error) {
|
|
|
2276
2276
|
return lower.includes("database is locked") || lower.includes("sqlite_busy") || lower.includes("busy");
|
|
2277
2277
|
}
|
|
2278
2278
|
function sleep(ms) {
|
|
2279
|
-
return new Promise((
|
|
2279
|
+
return new Promise((resolve3) => setTimeout(resolve3, ms));
|
|
2280
2280
|
}
|
|
2281
2281
|
function backoffDelay(attempt, config) {
|
|
2282
2282
|
const exp = Math.min(
|
|
@@ -2549,8 +2549,8 @@ var SqliteStorageProvider = class _SqliteStorageProvider {
|
|
|
2549
2549
|
/** Insert a single memory row (coalesced under concurrent writers). */
|
|
2550
2550
|
async insertMemory(input) {
|
|
2551
2551
|
this.requireVectorReady();
|
|
2552
|
-
return new Promise((
|
|
2553
|
-
this.insertQueue.push({ input, resolve, reject });
|
|
2552
|
+
return new Promise((resolve3, reject) => {
|
|
2553
|
+
this.insertQueue.push({ input, resolve: resolve3, reject });
|
|
2554
2554
|
if (this.insertQueue.length >= INSERT_COALESCE_THRESHOLD) {
|
|
2555
2555
|
this.insertFlushScheduled = false;
|
|
2556
2556
|
void this.flushInsertQueue();
|
|
@@ -4611,8 +4611,8 @@ var PostgresStorageProvider = class _PostgresStorageProvider {
|
|
|
4611
4611
|
/** Insert a single memory row (coalesced under concurrent writers). */
|
|
4612
4612
|
async insertMemory(input) {
|
|
4613
4613
|
this.requireVectorReady();
|
|
4614
|
-
return new Promise((
|
|
4615
|
-
this.insertQueue.push({ input, resolve, reject });
|
|
4614
|
+
return new Promise((resolve3, reject) => {
|
|
4615
|
+
this.insertQueue.push({ input, resolve: resolve3, reject });
|
|
4616
4616
|
if (this.insertQueue.length >= COALESCE_FLUSH_THRESHOLD) {
|
|
4617
4617
|
this.clearInsertFlushTimer();
|
|
4618
4618
|
void this.flushInsertQueue();
|
|
@@ -5627,7 +5627,7 @@ function createDatabaseProvider(config) {
|
|
|
5627
5627
|
}
|
|
5628
5628
|
|
|
5629
5629
|
// src/version.ts
|
|
5630
|
-
var SDK_VERSION = "0.5.
|
|
5630
|
+
var SDK_VERSION = "0.5.6";
|
|
5631
5631
|
|
|
5632
5632
|
// src/memory/transfer.ts
|
|
5633
5633
|
var warnedMissingExportManifest = false;
|
|
@@ -11118,6 +11118,271 @@ function percentile(sorted, p) {
|
|
|
11118
11118
|
return sorted[idx];
|
|
11119
11119
|
}
|
|
11120
11120
|
|
|
11121
|
-
|
|
11121
|
+
// src/config/providers.ts
|
|
11122
|
+
var EMBEDDING_PROVIDER_PRESETS = [
|
|
11123
|
+
{
|
|
11124
|
+
id: "openai",
|
|
11125
|
+
label: "OpenAI",
|
|
11126
|
+
defaultBaseUrl: "https://api.openai.com/v1",
|
|
11127
|
+
defaultModel: "text-embedding-3-small",
|
|
11128
|
+
apiKeyEnv: "OPENAI_API_KEY"
|
|
11129
|
+
},
|
|
11130
|
+
{
|
|
11131
|
+
id: "ollama",
|
|
11132
|
+
label: "Ollama (local)",
|
|
11133
|
+
defaultBaseUrl: "http://127.0.0.1:11434/v1",
|
|
11134
|
+
defaultModel: "nomic-embed-text",
|
|
11135
|
+
apiKeyEnv: "OLLAMA_API_KEY",
|
|
11136
|
+
apiKeyHint: "Any non-empty value works locally (e.g. ollama)"
|
|
11137
|
+
},
|
|
11138
|
+
{
|
|
11139
|
+
id: "openrouter",
|
|
11140
|
+
label: "OpenRouter",
|
|
11141
|
+
defaultBaseUrl: "https://openrouter.ai/api/v1",
|
|
11142
|
+
defaultModel: "openai/text-embedding-3-small",
|
|
11143
|
+
apiKeyEnv: "OPENROUTER_API_KEY"
|
|
11144
|
+
},
|
|
11145
|
+
{
|
|
11146
|
+
id: "lmstudio",
|
|
11147
|
+
label: "LM Studio (local)",
|
|
11148
|
+
defaultBaseUrl: "http://127.0.0.1:1234/v1",
|
|
11149
|
+
defaultModel: "text-embedding-nomic-embed-text-v1.5",
|
|
11150
|
+
apiKeyEnv: "LM_STUDIO_API_KEY",
|
|
11151
|
+
apiKeyHint: "Often unused locally \u2014 any non-empty value is fine"
|
|
11152
|
+
},
|
|
11153
|
+
{
|
|
11154
|
+
id: "gemini",
|
|
11155
|
+
label: "Google Gemini",
|
|
11156
|
+
defaultBaseUrl: "https://generativelanguage.googleapis.com/v1beta/openai",
|
|
11157
|
+
defaultModel: "text-embedding-004",
|
|
11158
|
+
apiKeyEnv: "GEMINI_API_KEY"
|
|
11159
|
+
},
|
|
11160
|
+
{
|
|
11161
|
+
id: "together",
|
|
11162
|
+
label: "Together AI",
|
|
11163
|
+
defaultBaseUrl: "https://api.together.xyz/v1",
|
|
11164
|
+
defaultModel: "togethercomputer/m2-bert-80M-8k-retrieval",
|
|
11165
|
+
apiKeyEnv: "TOGETHER_API_KEY"
|
|
11166
|
+
},
|
|
11167
|
+
{
|
|
11168
|
+
id: "vllm",
|
|
11169
|
+
label: "vLLM (local/server)",
|
|
11170
|
+
defaultBaseUrl: "http://127.0.0.1:8000/v1",
|
|
11171
|
+
defaultModel: "text-embedding-ada-002",
|
|
11172
|
+
apiKeyEnv: "VLLM_API_KEY",
|
|
11173
|
+
apiKeyHint: "Only if your server requires auth"
|
|
11174
|
+
},
|
|
11175
|
+
{
|
|
11176
|
+
id: "custom",
|
|
11177
|
+
label: "Custom OpenAI-compatible",
|
|
11178
|
+
defaultBaseUrl: "https://api.openai.com/v1",
|
|
11179
|
+
defaultModel: "text-embedding-3-small",
|
|
11180
|
+
apiKeyEnv: "WOLBARG_EMBEDDING_API_KEY"
|
|
11181
|
+
}
|
|
11182
|
+
];
|
|
11183
|
+
function getEmbeddingProviderPreset(id) {
|
|
11184
|
+
return EMBEDDING_PROVIDER_PRESETS.find((p) => p.id === id);
|
|
11185
|
+
}
|
|
11186
|
+
var DEFAULT_SQLITE_DB_PATH = ".wolbarg/shared-memory/memory.db";
|
|
11187
|
+
var DEFAULT_ORGANIZATION = "default";
|
|
11188
|
+
var DEFAULT_CONFIG_PATH = ".wolbarg/config.json";
|
|
11189
|
+
var DEFAULT_ENV_PATH = ".wolbarg/.env";
|
|
11190
|
+
function defaultProjectConfig() {
|
|
11191
|
+
return {
|
|
11192
|
+
version: 1,
|
|
11193
|
+
organization: DEFAULT_ORGANIZATION,
|
|
11194
|
+
database: {
|
|
11195
|
+
provider: "sqlite",
|
|
11196
|
+
url: DEFAULT_SQLITE_DB_PATH
|
|
11197
|
+
},
|
|
11198
|
+
paths: {
|
|
11199
|
+
config: DEFAULT_CONFIG_PATH
|
|
11200
|
+
}
|
|
11201
|
+
};
|
|
11202
|
+
}
|
|
11203
|
+
function resolveConfigPath(cwd = process.cwd(), configPath) {
|
|
11204
|
+
const rel = configPath ?? DEFAULT_CONFIG_PATH;
|
|
11205
|
+
return isAbsolute(rel) ? rel : resolve(cwd, rel);
|
|
11206
|
+
}
|
|
11207
|
+
function resolveEnvPath(cwd = process.cwd(), envPath) {
|
|
11208
|
+
const rel = envPath ?? DEFAULT_ENV_PATH;
|
|
11209
|
+
return isAbsolute(rel) ? rel : resolve(cwd, rel);
|
|
11210
|
+
}
|
|
11211
|
+
function loadProjectConfig(cwd = process.cwd(), configPath) {
|
|
11212
|
+
const full = resolveConfigPath(cwd, configPath);
|
|
11213
|
+
if (!existsSync(full)) return null;
|
|
11214
|
+
const raw = JSON.parse(readFileSync(full, "utf8"));
|
|
11215
|
+
if (!raw || raw.version !== 1 || !raw.database?.url) {
|
|
11216
|
+
throw new Error(`Invalid Wolbarg config at ${full}`);
|
|
11217
|
+
}
|
|
11218
|
+
return raw;
|
|
11219
|
+
}
|
|
11220
|
+
function saveProjectConfig(config, options = {}) {
|
|
11221
|
+
const cwd = options.cwd ?? process.cwd();
|
|
11222
|
+
const configPath = resolveConfigPath(cwd, options.configPath);
|
|
11223
|
+
const dir = dirname(configPath);
|
|
11224
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
11225
|
+
if (existsSync(configPath) && options.overwrite === false) {
|
|
11226
|
+
throw new Error(`Config already exists: ${configPath} (pass --force to overwrite)`);
|
|
11227
|
+
}
|
|
11228
|
+
const toWrite = {
|
|
11229
|
+
...config,
|
|
11230
|
+
paths: {
|
|
11231
|
+
config: options.configPath ?? DEFAULT_CONFIG_PATH,
|
|
11232
|
+
...options.envPath || options.apiKey ? { env: options.envPath ?? DEFAULT_ENV_PATH } : config.paths?.env ? { env: config.paths.env } : {}
|
|
11233
|
+
}
|
|
11234
|
+
};
|
|
11235
|
+
writeFileSync(configPath, `${JSON.stringify(toWrite, null, 2)}
|
|
11236
|
+
`, "utf8");
|
|
11237
|
+
let envPath;
|
|
11238
|
+
if (options.apiKey && config.embedding?.apiKeyEnv) {
|
|
11239
|
+
envPath = resolveEnvPath(cwd, options.envPath);
|
|
11240
|
+
ensureParent(envPath);
|
|
11241
|
+
upsertEnvVar(envPath, config.embedding.apiKeyEnv, options.apiKey);
|
|
11242
|
+
ensureGitignore(cwd, [DEFAULT_ENV_PATH, ".env"]);
|
|
11243
|
+
}
|
|
11244
|
+
if (config.database.provider === "sqlite" && !config.database.url.includes("://")) {
|
|
11245
|
+
const dbPath = isAbsolute(config.database.url) ? config.database.url : resolve(cwd, config.database.url);
|
|
11246
|
+
ensureParent(dbPath);
|
|
11247
|
+
}
|
|
11248
|
+
return { configPath, envPath };
|
|
11249
|
+
}
|
|
11250
|
+
function ensureParent(filePath) {
|
|
11251
|
+
const dir = dirname(filePath);
|
|
11252
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
11253
|
+
}
|
|
11254
|
+
function upsertEnvVar(envPath, key, value) {
|
|
11255
|
+
ensureParent(envPath);
|
|
11256
|
+
let text = existsSync(envPath) ? readFileSync(envPath, "utf8") : "";
|
|
11257
|
+
const line = `${key}=${shellQuoteEnv(value)}`;
|
|
11258
|
+
const re = new RegExp(`^${escapeRegExp(key)}=.*$`, "m");
|
|
11259
|
+
if (re.test(text)) {
|
|
11260
|
+
text = text.replace(re, line);
|
|
11261
|
+
} else {
|
|
11262
|
+
if (text && !text.endsWith("\n")) text += "\n";
|
|
11263
|
+
text += `${line}
|
|
11264
|
+
`;
|
|
11265
|
+
}
|
|
11266
|
+
writeFileSync(envPath, text, "utf8");
|
|
11267
|
+
}
|
|
11268
|
+
function shellQuoteEnv(value) {
|
|
11269
|
+
if (/[\s#"']/.test(value)) {
|
|
11270
|
+
return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
11271
|
+
}
|
|
11272
|
+
return value;
|
|
11273
|
+
}
|
|
11274
|
+
function escapeRegExp(s) {
|
|
11275
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
11276
|
+
}
|
|
11277
|
+
function ensureGitignore(cwd, entries) {
|
|
11278
|
+
const gi = join(cwd, ".gitignore");
|
|
11279
|
+
let text = existsSync(gi) ? readFileSync(gi, "utf8") : "";
|
|
11280
|
+
let changed = false;
|
|
11281
|
+
for (const entry of entries) {
|
|
11282
|
+
if (text.split(/\r?\n/).some((l) => l.trim() === entry)) continue;
|
|
11283
|
+
if (text && !text.endsWith("\n")) text += "\n";
|
|
11284
|
+
text += `${entry}
|
|
11285
|
+
`;
|
|
11286
|
+
changed = true;
|
|
11287
|
+
}
|
|
11288
|
+
if (changed) writeFileSync(gi, text, "utf8");
|
|
11289
|
+
}
|
|
11290
|
+
function resolveEmbeddingApiKey(config, env = process.env) {
|
|
11291
|
+
const name = config.embedding?.apiKeyEnv;
|
|
11292
|
+
if (!name) return "";
|
|
11293
|
+
return env[name] ?? "";
|
|
11294
|
+
}
|
|
11295
|
+
function assertEmbeddingPreset(provider) {
|
|
11296
|
+
const preset = getEmbeddingProviderPreset(provider);
|
|
11297
|
+
if (!preset) {
|
|
11298
|
+
throw new Error(
|
|
11299
|
+
`Unknown embedding provider "${provider}". Choose one of: ${[
|
|
11300
|
+
"openai",
|
|
11301
|
+
"ollama",
|
|
11302
|
+
"openrouter",
|
|
11303
|
+
"lmstudio",
|
|
11304
|
+
"gemini",
|
|
11305
|
+
"together",
|
|
11306
|
+
"vllm",
|
|
11307
|
+
"custom"
|
|
11308
|
+
].join(", ")}`
|
|
11309
|
+
);
|
|
11310
|
+
}
|
|
11311
|
+
return preset.id;
|
|
11312
|
+
}
|
|
11313
|
+
function applyEnvFile(envPath, base = {}) {
|
|
11314
|
+
const out = { ...base };
|
|
11315
|
+
if (!existsSync(envPath)) return out;
|
|
11316
|
+
const text = readFileSync(envPath, "utf8");
|
|
11317
|
+
for (const rawLine of text.split(/\r?\n/)) {
|
|
11318
|
+
const line = rawLine.trim();
|
|
11319
|
+
if (!line || line.startsWith("#")) continue;
|
|
11320
|
+
const eq = line.indexOf("=");
|
|
11321
|
+
if (eq <= 0) continue;
|
|
11322
|
+
const key = line.slice(0, eq).trim();
|
|
11323
|
+
let value = line.slice(eq + 1).trim();
|
|
11324
|
+
if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
|
|
11325
|
+
value = value.slice(1, -1);
|
|
11326
|
+
}
|
|
11327
|
+
if (out[key] === void 0) out[key] = value;
|
|
11328
|
+
}
|
|
11329
|
+
return out;
|
|
11330
|
+
}
|
|
11331
|
+
function projectConfigToWolbargOptions(config, env = process.env) {
|
|
11332
|
+
if (!config.embedding) {
|
|
11333
|
+
throw new Error(
|
|
11334
|
+
"Project config has no embedding section. Re-run `wolbarg init` and configure an embedding provider, or pass embedding explicitly to wolbarg()."
|
|
11335
|
+
);
|
|
11336
|
+
}
|
|
11337
|
+
const apiKey = resolveEmbeddingApiKey(config, env);
|
|
11338
|
+
if (!apiKey) {
|
|
11339
|
+
throw new Error(
|
|
11340
|
+
`Missing API key. Set ${config.embedding.apiKeyEnv} in the environment or in .wolbarg/.env (from wolbarg init).`
|
|
11341
|
+
);
|
|
11342
|
+
}
|
|
11343
|
+
const dbUrl = config.database.url;
|
|
11344
|
+
return {
|
|
11345
|
+
organization: config.organization,
|
|
11346
|
+
database: {
|
|
11347
|
+
provider: config.database.provider,
|
|
11348
|
+
url: dbUrl,
|
|
11349
|
+
connectionString: dbUrl
|
|
11350
|
+
},
|
|
11351
|
+
embedding: {
|
|
11352
|
+
baseUrl: config.embedding.baseUrl,
|
|
11353
|
+
apiKey,
|
|
11354
|
+
model: config.embedding.model
|
|
11355
|
+
}
|
|
11356
|
+
};
|
|
11357
|
+
}
|
|
11358
|
+
function createWolbargFromProjectConfig(options = {}) {
|
|
11359
|
+
const cwd = options.cwd ?? process.cwd();
|
|
11360
|
+
const config = loadProjectConfig(cwd, options.configPath);
|
|
11361
|
+
if (!config) {
|
|
11362
|
+
throw new Error(
|
|
11363
|
+
`No Wolbarg config found. Run \`wolbarg init\` in ${cwd} (expected .wolbarg/config.json).`
|
|
11364
|
+
);
|
|
11365
|
+
}
|
|
11366
|
+
let env = options.env ?? { ...process.env };
|
|
11367
|
+
if (options.loadEnvFile !== false) {
|
|
11368
|
+
const envFile = resolveEnvPath(
|
|
11369
|
+
cwd,
|
|
11370
|
+
config.paths?.env ?? DEFAULT_ENV_PATH
|
|
11371
|
+
);
|
|
11372
|
+
env = applyEnvFile(envFile, env);
|
|
11373
|
+
}
|
|
11374
|
+
if (options.organization) {
|
|
11375
|
+
config.organization = options.organization;
|
|
11376
|
+
}
|
|
11377
|
+
if (config.database.provider === "sqlite" && !config.database.url.includes("://") && !isAbsolute(config.database.url)) {
|
|
11378
|
+
config.database = {
|
|
11379
|
+
...config.database,
|
|
11380
|
+
url: resolve(cwd, config.database.url)
|
|
11381
|
+
};
|
|
11382
|
+
}
|
|
11383
|
+
return wolbarg(projectConfigToWolbargOptions(config, env));
|
|
11384
|
+
}
|
|
11385
|
+
|
|
11386
|
+
export { CompressionError, ConfigurationError, DEFAULT_CONFIG_PATH, DEFAULT_ENV_PATH, DEFAULT_ORGANIZATION, DEFAULT_SQLITE_DB_PATH, DatabaseError, EMBEDDING_PROVIDER_PRESETS, EmbeddingError, FixedChunkingStrategy, GraphCheckpointNotSupportedError, HeadingChunkingStrategy, InitializationError, LlmCompressionProvider, MarkdownChunkingStrategy, MemoryNotFoundError, Neo4jGraphProvider, NoopTelemetryProvider, ParagraphChunkingStrategy, PostgresStorageProvider, ProviderNotConfiguredError, SDK_VERSION, SentenceChunkingStrategy, SqliteCheckpointProvider, SqliteDatabaseProvider, SqliteEventDatabase, SqliteGraphProvider, SqliteStorageProvider, SqliteTelemetryProvider, StorageLockedError, TelemetryEmitter, ValidationError, Wolbarg, WolbargError, WolbargLogger, 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, wrapOperationError };
|
|
11122
11387
|
//# sourceMappingURL=index.js.map
|
|
11123
11388
|
//# sourceMappingURL=index.js.map
|