@soulcraft/brainy 6.6.0 → 6.6.1

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/dist/brainy.js CHANGED
@@ -80,7 +80,6 @@ export class Brainy {
80
80
  ...this.config,
81
81
  ...configOverrides,
82
82
  storage: { ...this.config.storage, ...configOverrides.storage },
83
- model: { ...this.config.model, ...configOverrides.model },
84
83
  index: { ...this.config.index, ...configOverrides.index },
85
84
  augmentations: { ...this.config.augmentations, ...configOverrides.augmentations },
86
85
  verbose: configOverrides.verbose ?? this.config.verbose,
@@ -4146,10 +4145,6 @@ export class Brainy {
4146
4145
  // No longer throw errors for mismatches - storageFactory now handles this intelligently
4147
4146
  // Both 'gcs' and 'gcs-native' can now use either gcsStorage or gcsNativeStorage
4148
4147
  }
4149
- // Validate model configuration
4150
- if (config?.model?.type && !['fast', 'accurate', 'custom'].includes(config.model.type)) {
4151
- throw new Error(`Invalid model type: ${config.model.type}. Must be one of: fast, accurate, custom`);
4152
- }
4153
4148
  // Validate numeric configurations
4154
4149
  if (config?.index?.m && (config.index.m < 1 || config.index.m > 128)) {
4155
4150
  throw new Error(`Invalid index m parameter: ${config.index.m}. Must be between 1 and 128`);
@@ -4164,7 +4159,6 @@ export class Brainy {
4164
4159
  const distributedConfig = this.autoDetectDistributed(config?.distributed);
4165
4160
  return {
4166
4161
  storage: config?.storage || { type: 'auto' },
4167
- model: config?.model || { type: 'fast' },
4168
4162
  index: config?.index || {},
4169
4163
  cache: config?.cache ?? true,
4170
4164
  augmentations: config?.augmentations || {},
@@ -2,9 +2,7 @@
2
2
  * Zero-Configuration System
3
3
  * Main entry point for all auto-configuration features
4
4
  */
5
- export { autoSelectModelPrecision, ModelPrecision as ModelPrecisionType, // Avoid conflict
6
- ModelPreset, shouldAutoDownloadModels, getModelPath, logModelConfig } from './modelAutoConfig.js';
7
- export declare const getModelPrecision: () => "q8";
5
+ export { getModelPrecision, shouldAutoDownloadModels, getModelPath } from './modelAutoConfig.js';
8
6
  export { autoDetectStorage, StorageType, StoragePreset, StorageConfigResult, logStorageConfig, type StorageTypeString, type StoragePresetString } from './storageAutoConfig.js';
9
7
  export { SharedConfig, SharedConfigManager } from './sharedConfigManager.js';
10
8
  export { BrainyZeroConfig, processZeroConfig, createEmbeddingFunctionWithPrecision } from './zeroConfig.js';
@@ -2,10 +2,8 @@
2
2
  * Zero-Configuration System
3
3
  * Main entry point for all auto-configuration features
4
4
  */
5
- // Model configuration
6
- export { autoSelectModelPrecision, shouldAutoDownloadModels, getModelPath, logModelConfig } from './modelAutoConfig.js';
7
- // Model precision - Always Q8 now (99% accuracy, 75% smaller)
8
- export const getModelPrecision = () => 'q8';
5
+ // Model configuration (simplified - always Q8 WASM)
6
+ export { getModelPrecision, shouldAutoDownloadModels, getModelPath } from './modelAutoConfig.js';
9
7
  // Storage configuration
10
8
  export { autoDetectStorage, StorageType, StoragePreset, logStorageConfig } from './storageAutoConfig.js';
11
9
  // Shared configuration for multi-instance
@@ -1,32 +1,25 @@
1
1
  /**
2
- * Model Configuration Auto-Selection
3
- * Always uses Q8 for optimal size/performance balance (99% accuracy, 75% smaller)
2
+ * Model Configuration
3
+ * Brainy uses Q8 WASM embeddings - no configuration needed (zero-config)
4
4
  */
5
- export type ModelPrecision = 'q8';
6
- export type ModelPreset = 'small' | 'auto';
7
5
  interface ModelConfigResult {
8
- precision: ModelPrecision;
6
+ precision: 'q8';
9
7
  reason: string;
10
8
  autoSelected: boolean;
11
9
  }
12
10
  /**
13
- * Auto-select model precision - Always returns Q8
14
- * Q8 provides 99% accuracy with 75% smaller size
15
- * @param override - For backward compatibility, ignored
11
+ * Get model precision configuration
12
+ * Always returns Q8 - the optimal balance of size and accuracy
16
13
  */
17
- export declare function autoSelectModelPrecision(override?: ModelPrecision | ModelPreset): ModelConfigResult;
14
+ export declare function getModelPrecision(): ModelConfigResult;
18
15
  /**
19
- * Convenience function to check if models need to be downloaded
20
- * This replaces the need for BRAINY_ALLOW_REMOTE_MODELS
16
+ * Check if models need to be downloaded
17
+ * With bundled WASM model, this is rarely needed
21
18
  */
22
19
  export declare function shouldAutoDownloadModels(): boolean;
23
20
  /**
24
- * Get the model path with intelligent defaults
25
- * This replaces the need for BRAINY_MODELS_PATH env var
21
+ * Get the model path
22
+ * With bundled WASM model, this points to the package assets
26
23
  */
27
24
  export declare function getModelPath(): string;
28
- /**
29
- * Log model configuration decision (only in verbose mode)
30
- */
31
- export declare function logModelConfig(config: ModelConfigResult, verbose?: boolean): void;
32
25
  export {};
@@ -1,35 +1,16 @@
1
1
  /**
2
- * Model Configuration Auto-Selection
3
- * Always uses Q8 for optimal size/performance balance (99% accuracy, 75% smaller)
2
+ * Model Configuration
3
+ * Brainy uses Q8 WASM embeddings - no configuration needed (zero-config)
4
4
  */
5
5
  import { isBrowser, isNode } from '../utils/environment.js';
6
6
  /**
7
- * Auto-select model precision - Always returns Q8
8
- * Q8 provides 99% accuracy with 75% smaller size
9
- * @param override - For backward compatibility, ignored
7
+ * Get model precision configuration
8
+ * Always returns Q8 - the optimal balance of size and accuracy
10
9
  */
11
- export function autoSelectModelPrecision(override) {
12
- // Always use Q8 regardless of override for simplicity
13
- // Q8 is optimal: 33MB vs 130MB, 99% accuracy retained
14
- // Log deprecation notice if FP32 was requested
15
- if (typeof override === 'string' && override.toLowerCase().includes('fp32')) {
16
- console.log('Note: FP32 precision is deprecated. Using Q8 (99% accuracy, 75% smaller).');
17
- }
18
- return {
19
- precision: 'q8',
20
- reason: 'Q8 precision (99% accuracy, 75% smaller)',
21
- autoSelected: true
22
- };
23
- }
24
- /**
25
- * Automatically detect the best model precision for the environment
26
- * DEPRECATED: Always returns Q8 now
27
- */
28
- function autoDetectBestPrecision() {
29
- // Always return Q8 - deprecated function kept for backward compatibility
10
+ export function getModelPrecision() {
30
11
  return {
31
12
  precision: 'q8',
32
- reason: 'Q8 precision (99% accuracy, 75% smaller)',
13
+ reason: 'Q8 WASM (23MB bundled, no downloads)',
33
14
  autoSelected: true
34
15
  };
35
16
  }
@@ -48,68 +29,25 @@ function isServerlessEnvironment() {
48
29
  );
49
30
  }
50
31
  /**
51
- * Get available memory in MB
52
- */
53
- function getAvailableMemoryMB() {
54
- if (isBrowser()) {
55
- // @ts-ignore - navigator.deviceMemory is experimental
56
- if (navigator.deviceMemory) {
57
- // @ts-ignore
58
- return navigator.deviceMemory * 1024; // Device memory in GB
59
- }
60
- return 256; // Conservative default for browsers
61
- }
62
- if (isNode()) {
63
- try {
64
- // Try to get memory info synchronously for Node.js
65
- // This will be available in Node.js environments
66
- if (typeof process !== 'undefined' && process.memoryUsage) {
67
- // Use RSS (Resident Set Size) as a proxy for available memory
68
- const rss = process.memoryUsage().rss;
69
- // Assume we can use up to 4GB or 50% more than current usage
70
- return Math.min(4096, Math.floor(rss / (1024 * 1024) * 1.5));
71
- }
72
- }
73
- catch {
74
- // Fall through to default
75
- }
76
- return 1024; // Default 1GB for Node.js
77
- }
78
- return 512; // Conservative default
79
- }
80
- /**
81
- * Convenience function to check if models need to be downloaded
82
- * This replaces the need for BRAINY_ALLOW_REMOTE_MODELS
32
+ * Check if models need to be downloaded
33
+ * With bundled WASM model, this is rarely needed
83
34
  */
84
35
  export function shouldAutoDownloadModels() {
85
- // Always allow downloads unless explicitly disabled
86
- // This eliminates the need for BRAINY_ALLOW_REMOTE_MODELS
36
+ // Model is bundled - no downloads needed in normal operation
37
+ // This flag exists for edge cases only
87
38
  const explicitlyDisabled = process.env.BRAINY_ALLOW_REMOTE_MODELS === 'false';
88
- if (explicitlyDisabled) {
89
- console.warn('Model downloads disabled via BRAINY_ALLOW_REMOTE_MODELS=false');
90
- return false;
91
- }
92
- // In production, always allow downloads for seamless operation
93
- if (process.env.NODE_ENV === 'production') {
94
- return true;
95
- }
96
- // In development, allow downloads with a one-time notice
97
- if (process.env.NODE_ENV === 'development') {
98
- return true;
99
- }
100
- // Default: allow downloads
101
- return true;
39
+ return !explicitlyDisabled;
102
40
  }
103
41
  /**
104
- * Get the model path with intelligent defaults
105
- * This replaces the need for BRAINY_MODELS_PATH env var
42
+ * Get the model path
43
+ * With bundled WASM model, this points to the package assets
106
44
  */
107
45
  export function getModelPath() {
108
- // Check if user explicitly set a path (keeping this for advanced users)
46
+ // Check if user explicitly set a path (for advanced users)
109
47
  if (process.env.BRAINY_MODELS_PATH) {
110
48
  return process.env.BRAINY_MODELS_PATH;
111
49
  }
112
- // Browser - use cache API or IndexedDB (handled by transformers.js)
50
+ // Browser - use cache API or IndexedDB
113
51
  if (isBrowser()) {
114
52
  return 'browser-cache';
115
53
  }
@@ -119,21 +57,10 @@ export function getModelPath() {
119
57
  }
120
58
  // Node.js - use home directory for persistent storage
121
59
  if (isNode()) {
122
- // Use process.env.HOME as a fallback
123
60
  const homeDir = process.env.HOME || process.env.USERPROFILE || '~';
124
61
  return `${homeDir}/.brainy/models`;
125
62
  }
126
63
  // Fallback
127
64
  return './.brainy/models';
128
65
  }
129
- /**
130
- * Log model configuration decision (only in verbose mode)
131
- */
132
- export function logModelConfig(config, verbose = false) {
133
- if (!verbose && process.env.NODE_ENV === 'production') {
134
- return; // Silent in production unless verbose
135
- }
136
- const icon = config.autoSelected ? '🤖' : '👤';
137
- console.log(`${icon} Model: ${config.precision.toUpperCase()} - ${config.reason}`);
138
- }
139
66
  //# sourceMappingURL=modelAutoConfig.js.map
@@ -2,10 +2,9 @@
2
2
  * Shared Configuration Manager
3
3
  * Ensures configuration consistency across multiple instances using shared storage
4
4
  */
5
- import { ModelPrecision } from './modelAutoConfig.js';
6
5
  export interface SharedConfig {
7
6
  version: string;
8
- precision: ModelPrecision;
7
+ precision: 'q8';
9
8
  dimensions: number;
10
9
  hnswM: number;
11
10
  hnswEfConstruction: number;
@@ -2,7 +2,6 @@
2
2
  * Zero-Configuration System for Brainy
3
3
  * Provides intelligent defaults while preserving full control
4
4
  */
5
- import { ModelPrecision, ModelPreset } from './modelAutoConfig.js';
6
5
  import { StorageType, StoragePreset } from './storageAutoConfig.js';
7
6
  /**
8
7
  * Simplified configuration interface
@@ -19,15 +18,6 @@ export interface BrainyZeroConfig {
19
18
  * - 'reader': Read-only instance for distributed setups (no write operations)
20
19
  */
21
20
  mode?: 'production' | 'development' | 'minimal' | 'zero' | 'writer' | 'reader';
22
- /**
23
- * Model precision configuration
24
- * - 'fp32': Full precision (best quality, larger size)
25
- * - 'q8': Quantized 8-bit (smaller size, slightly lower quality)
26
- * - 'fast': Alias for fp32
27
- * - 'small': Alias for q8
28
- * - 'auto': Auto-detect based on environment (default)
29
- */
30
- model?: ModelPrecision | ModelPreset;
31
21
  /**
32
22
  * Storage configuration
33
23
  * - 'memory': In-memory only (no persistence)
@@ -62,7 +52,6 @@ export interface BrainyZeroConfig {
62
52
  */
63
53
  export declare function processZeroConfig(input?: string | BrainyZeroConfig): Promise<any>;
64
54
  /**
65
- * Create embedding function with specified precision
66
- * This ensures the model precision is respected
55
+ * Create embedding function (always Q8 WASM)
67
56
  */
68
- export declare function createEmbeddingFunctionWithPrecision(precision: ModelPrecision): Promise<any>;
57
+ export declare function createEmbeddingFunctionWithPrecision(): Promise<any>;
@@ -2,7 +2,7 @@
2
2
  * Zero-Configuration System for Brainy
3
3
  * Provides intelligent defaults while preserving full control
4
4
  */
5
- import { autoSelectModelPrecision, getModelPath, shouldAutoDownloadModels } from './modelAutoConfig.js';
5
+ import { getModelPrecision, getModelPath, shouldAutoDownloadModels } from './modelAutoConfig.js';
6
6
  import { autoDetectStorage } from './storageAutoConfig.js';
7
7
  import { AutoConfiguration } from '../utils/autoConfiguration.js';
8
8
  /**
@@ -11,31 +11,26 @@ import { AutoConfiguration } from '../utils/autoConfiguration.js';
11
11
  const PRESETS = {
12
12
  production: {
13
13
  storage: 'disk',
14
- model: 'auto',
15
14
  features: 'default',
16
15
  verbose: false
17
16
  },
18
17
  development: {
19
18
  storage: 'memory',
20
- model: 'q8', // Q8 is now the default for all presets
21
19
  features: 'full',
22
20
  verbose: true
23
21
  },
24
22
  minimal: {
25
23
  storage: 'memory',
26
- model: 'q8',
27
24
  features: 'minimal',
28
25
  verbose: false
29
26
  },
30
27
  zero: {
31
28
  storage: 'auto',
32
- model: 'auto',
33
29
  features: 'default',
34
30
  verbose: false
35
31
  },
36
32
  writer: {
37
33
  storage: 'auto',
38
- model: 'auto',
39
34
  features: 'minimal',
40
35
  verbose: false,
41
36
  // Writer-specific settings
@@ -46,7 +41,6 @@ const PRESETS = {
46
41
  },
47
42
  reader: {
48
43
  storage: 'auto',
49
- model: 'auto',
50
44
  features: 'default',
51
45
  verbose: false,
52
46
  // Reader-specific settings
@@ -117,7 +111,6 @@ export async function processZeroConfig(input) {
117
111
  ...preset,
118
112
  ...config,
119
113
  // Preserve explicit overrides
120
- model: config.model ?? preset.model,
121
114
  storage: config.storage ?? preset.storage,
122
115
  features: config.features ?? preset.features,
123
116
  verbose: config.verbose ?? preset.verbose
@@ -125,8 +118,8 @@ export async function processZeroConfig(input) {
125
118
  }
126
119
  // Auto-detect environment if not in preset mode
127
120
  const environment = detectEnvironmentMode();
128
- // Process model configuration
129
- const modelConfig = autoSelectModelPrecision(config.model);
121
+ // Get model configuration (always Q8 WASM)
122
+ const modelConfig = getModelPrecision();
130
123
  // Process storage configuration
131
124
  const storageConfig = await autoDetectStorage(config.storage);
132
125
  // Process features configuration
@@ -287,14 +280,13 @@ function logConfigurationSummary(config) {
287
280
  console.log('================================\n');
288
281
  }
289
282
  /**
290
- * Create embedding function with specified precision
291
- * This ensures the model precision is respected
283
+ * Create embedding function (always Q8 WASM)
292
284
  */
293
- export async function createEmbeddingFunctionWithPrecision(precision) {
285
+ export async function createEmbeddingFunctionWithPrecision() {
294
286
  const { createEmbeddingFunction } = await import('../utils/embedding.js');
295
- // Create embedding function with specified precision
287
+ // Create embedding function - always Q8 WASM
296
288
  return createEmbeddingFunction({
297
- precision: precision,
289
+ precision: 'q8',
298
290
  verbose: false // Silent by default in zero-config
299
291
  });
300
292
  }
@@ -518,11 +518,6 @@ export interface BrainyConfig {
518
518
  options?: any;
519
519
  branch?: string;
520
520
  };
521
- model?: {
522
- type: 'fast' | 'accurate' | 'balanced' | 'custom';
523
- name?: string;
524
- precision?: 'q8';
525
- };
526
521
  index?: {
527
522
  m?: number;
528
523
  efConstruction?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soulcraft/brainy",
3
- "version": "6.6.0",
3
+ "version": "6.6.1",
4
4
  "description": "Universal Knowledge Protocol™ - World's first Triple Intelligence database unifying vector, graph, and document search in one API. Stage 3 CANONICAL: 42 nouns × 127 verbs covering 96-97% of all human knowledge.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",