@soulcraft/brainy 3.7.0 → 3.8.0
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 +4 -4
- package/dist/types/brainy.types.d.ts +1 -1
- package/dist/universal/fs.js +32 -1
- package/package.json +1 -1
package/dist/brainy.js
CHANGED
|
@@ -1399,7 +1399,7 @@ export class Brainy {
|
|
|
1399
1399
|
*/
|
|
1400
1400
|
async setupStorage() {
|
|
1401
1401
|
const storage = await createStorage({
|
|
1402
|
-
type: this.config.storage?.type || '
|
|
1402
|
+
type: this.config.storage?.type || 'auto',
|
|
1403
1403
|
...this.config.storage?.options
|
|
1404
1404
|
});
|
|
1405
1405
|
return storage;
|
|
@@ -1445,8 +1445,8 @@ export class Brainy {
|
|
|
1445
1445
|
*/
|
|
1446
1446
|
normalizeConfig(config) {
|
|
1447
1447
|
// Validate storage configuration
|
|
1448
|
-
if (config?.storage?.type && !['memory', 'filesystem', 'opfs', 'remote'].includes(config.storage.type)) {
|
|
1449
|
-
throw new Error(`Invalid storage type: ${config.storage.type}. Must be one of: memory, filesystem, opfs, remote`);
|
|
1448
|
+
if (config?.storage?.type && !['auto', 'memory', 'filesystem', 'opfs', 'remote', 's3', 'r2', 'gcs'].includes(config.storage.type)) {
|
|
1449
|
+
throw new Error(`Invalid storage type: ${config.storage.type}. Must be one of: auto, memory, filesystem, opfs, remote, s3, r2, gcs`);
|
|
1450
1450
|
}
|
|
1451
1451
|
// Validate model configuration
|
|
1452
1452
|
if (config?.model?.type && !['fast', 'accurate', 'custom'].includes(config.model.type)) {
|
|
@@ -1463,7 +1463,7 @@ export class Brainy {
|
|
|
1463
1463
|
throw new Error(`Invalid index efSearch: ${config.index.efSearch}. Must be between 1 and 1000`);
|
|
1464
1464
|
}
|
|
1465
1465
|
return {
|
|
1466
|
-
storage: config?.storage || { type: '
|
|
1466
|
+
storage: config?.storage || { type: 'auto' },
|
|
1467
1467
|
model: config?.model || { type: 'fast' },
|
|
1468
1468
|
index: config?.index || {},
|
|
1469
1469
|
cache: config?.cache ?? true,
|
|
@@ -251,7 +251,7 @@ export type AggregateMetric = 'count' | 'sum' | 'avg' | 'min' | 'max' | 'stddev'
|
|
|
251
251
|
*/
|
|
252
252
|
export interface BrainyConfig {
|
|
253
253
|
storage?: {
|
|
254
|
-
type: 'memory' | 'filesystem' | 's3' | 'r2' | 'opfs';
|
|
254
|
+
type: 'auto' | 'memory' | 'filesystem' | 's3' | 'r2' | 'opfs' | 'gcs';
|
|
255
255
|
options?: any;
|
|
256
256
|
};
|
|
257
257
|
model?: {
|
package/dist/universal/fs.js
CHANGED
|
@@ -59,13 +59,44 @@ class NodeFS {
|
|
|
59
59
|
await nodeFs.access(path, mode);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
+
// Browser-safe no-op implementation
|
|
63
|
+
class BrowserFS {
|
|
64
|
+
async readFile(path, encoding = 'utf-8') {
|
|
65
|
+
throw new Error('File system operations not available in browser. Use OPFS, Memory, or S3 storage adapters instead.');
|
|
66
|
+
}
|
|
67
|
+
async writeFile(path, data, encoding = 'utf-8') {
|
|
68
|
+
throw new Error('File system operations not available in browser. Use OPFS, Memory, or S3 storage adapters instead.');
|
|
69
|
+
}
|
|
70
|
+
async mkdir(path, options = { recursive: true }) {
|
|
71
|
+
throw new Error('File system operations not available in browser. Use OPFS, Memory, or S3 storage adapters instead.');
|
|
72
|
+
}
|
|
73
|
+
async exists(path) {
|
|
74
|
+
return false; // Always return false in browser
|
|
75
|
+
}
|
|
76
|
+
async readdir(path, options) {
|
|
77
|
+
if (options?.withFileTypes) {
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
async unlink(path) {
|
|
83
|
+
throw new Error('File system operations not available in browser. Use OPFS, Memory, or S3 storage adapters instead.');
|
|
84
|
+
}
|
|
85
|
+
async stat(path) {
|
|
86
|
+
throw new Error('File system operations not available in browser. Use OPFS, Memory, or S3 storage adapters instead.');
|
|
87
|
+
}
|
|
88
|
+
async access(path, mode) {
|
|
89
|
+
throw new Error('File system operations not available in browser. Use OPFS, Memory, or S3 storage adapters instead.');
|
|
90
|
+
}
|
|
91
|
+
}
|
|
62
92
|
// Create the appropriate filesystem implementation
|
|
63
93
|
let fsImpl;
|
|
64
94
|
if (isNode() && nodeFs) {
|
|
65
95
|
fsImpl = new NodeFS();
|
|
66
96
|
}
|
|
67
97
|
else {
|
|
68
|
-
|
|
98
|
+
// Use browser-safe no-op implementation instead of throwing
|
|
99
|
+
fsImpl = new BrowserFS();
|
|
69
100
|
}
|
|
70
101
|
// Export the filesystem operations
|
|
71
102
|
export const readFile = fsImpl.readFile.bind(fsImpl);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soulcraft/brainy",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"description": "Universal Knowledge Protocol™ - World's first Triple Intelligence database unifying vector, graph, and document search in one API. 31 nouns × 40 verbs for infinite expressiveness.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|