@soulcraft/brainy 5.3.5 → 5.4.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/CHANGELOG.md +72 -0
- package/dist/brainy.d.ts +61 -0
- package/dist/brainy.js +188 -24
- package/dist/storage/adapters/azureBlobStorage.d.ts +13 -64
- package/dist/storage/adapters/azureBlobStorage.js +78 -388
- package/dist/storage/adapters/fileSystemStorage.d.ts +12 -78
- package/dist/storage/adapters/fileSystemStorage.js +49 -395
- package/dist/storage/adapters/gcsStorage.d.ts +13 -134
- package/dist/storage/adapters/gcsStorage.js +79 -557
- package/dist/storage/adapters/historicalStorageAdapter.d.ts +181 -0
- package/dist/storage/adapters/historicalStorageAdapter.js +332 -0
- package/dist/storage/adapters/memoryStorage.d.ts +4 -113
- package/dist/storage/adapters/memoryStorage.js +34 -471
- package/dist/storage/adapters/opfsStorage.d.ts +14 -127
- package/dist/storage/adapters/opfsStorage.js +44 -693
- package/dist/storage/adapters/r2Storage.d.ts +8 -41
- package/dist/storage/adapters/r2Storage.js +49 -237
- package/dist/storage/adapters/s3CompatibleStorage.d.ts +13 -111
- package/dist/storage/adapters/s3CompatibleStorage.js +77 -596
- package/dist/storage/baseStorage.d.ts +78 -38
- package/dist/storage/baseStorage.js +699 -23
- package/dist/storage/cow/BlobStorage.d.ts +2 -2
- package/dist/storage/cow/BlobStorage.js +4 -4
- package/dist/storage/storageFactory.d.ts +2 -3
- package/dist/storage/storageFactory.js +114 -66
- package/dist/vfs/types.d.ts +6 -2
- package/package.json +1 -1
|
@@ -31,7 +31,7 @@ export interface BlobMetadata {
|
|
|
31
31
|
size: number;
|
|
32
32
|
compressedSize: number;
|
|
33
33
|
compression: 'none' | 'zstd';
|
|
34
|
-
type: 'vector' | 'metadata' | 'tree' | 'commit' | 'raw';
|
|
34
|
+
type: 'vector' | 'metadata' | 'tree' | 'commit' | 'blob' | 'raw';
|
|
35
35
|
createdAt: number;
|
|
36
36
|
refCount: number;
|
|
37
37
|
}
|
|
@@ -40,7 +40,7 @@ export interface BlobMetadata {
|
|
|
40
40
|
*/
|
|
41
41
|
export interface BlobWriteOptions {
|
|
42
42
|
compression?: 'none' | 'zstd' | 'auto';
|
|
43
|
-
type?: 'vector' | 'metadata' | 'tree' | 'commit' | 'raw';
|
|
43
|
+
type?: 'vector' | 'metadata' | 'tree' | 'commit' | 'blob' | 'raw';
|
|
44
44
|
skipVerification?: boolean;
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
@@ -122,7 +122,7 @@ export class BlobStorage {
|
|
|
122
122
|
size: data.length,
|
|
123
123
|
compressedSize,
|
|
124
124
|
compression,
|
|
125
|
-
type: options.type || '
|
|
125
|
+
type: options.type || 'blob', // CRITICAL FIX: Use 'blob' default to match storage prefix
|
|
126
126
|
createdAt: Date.now(),
|
|
127
127
|
refCount: 1
|
|
128
128
|
};
|
|
@@ -259,7 +259,7 @@ export class BlobStorage {
|
|
|
259
259
|
}
|
|
260
260
|
// Determine prefix by checking which one exists
|
|
261
261
|
let prefix = 'blob';
|
|
262
|
-
for (const tryPrefix of ['commit', 'tree', 'blob']) {
|
|
262
|
+
for (const tryPrefix of ['commit', 'tree', 'blob', 'metadata', 'vector', 'raw']) {
|
|
263
263
|
const exists = await this.adapter.get(`${tryPrefix}:${hash}`);
|
|
264
264
|
if (exists !== undefined) {
|
|
265
265
|
prefix = tryPrefix;
|
|
@@ -283,8 +283,8 @@ export class BlobStorage {
|
|
|
283
283
|
*/
|
|
284
284
|
async getMetadata(hash) {
|
|
285
285
|
// Try to read metadata with type-aware prefix (backward compatible)
|
|
286
|
-
//
|
|
287
|
-
for (const prefix of ['commit', 'tree', 'blob']) {
|
|
286
|
+
// Check all valid blob types: commit, tree, blob, metadata, vector, raw
|
|
287
|
+
for (const prefix of ['commit', 'tree', 'blob', 'metadata', 'vector', 'raw']) {
|
|
288
288
|
const data = await this.adapter.get(`${prefix}-meta:${hash}`);
|
|
289
289
|
if (data) {
|
|
290
290
|
return JSON.parse(data.toString());
|
|
@@ -9,7 +9,6 @@ import { S3CompatibleStorage } from './adapters/s3CompatibleStorage.js';
|
|
|
9
9
|
import { R2Storage } from './adapters/r2Storage.js';
|
|
10
10
|
import { GcsStorage } from './adapters/gcsStorage.js';
|
|
11
11
|
import { AzureBlobStorage } from './adapters/azureBlobStorage.js';
|
|
12
|
-
import { TypeAwareStorageAdapter } from './adapters/typeAwareStorageAdapter.js';
|
|
13
12
|
import { OperationConfig } from '../utils/operationUtils.js';
|
|
14
13
|
/**
|
|
15
14
|
* Options for creating a storage adapter
|
|
@@ -304,6 +303,6 @@ export interface StorageOptions {
|
|
|
304
303
|
*/
|
|
305
304
|
export declare function createStorage(options?: StorageOptions): Promise<StorageAdapter>;
|
|
306
305
|
/**
|
|
307
|
-
* Export storage adapters
|
|
306
|
+
* Export storage adapters (v5.4.0: TypeAware is now built-in, no separate export)
|
|
308
307
|
*/
|
|
309
|
-
export { MemoryStorage, OPFSStorage, S3CompatibleStorage, R2Storage, GcsStorage, AzureBlobStorage
|
|
308
|
+
export { MemoryStorage, OPFSStorage, S3CompatibleStorage, R2Storage, GcsStorage, AzureBlobStorage };
|
|
@@ -8,7 +8,7 @@ import { S3CompatibleStorage } from './adapters/s3CompatibleStorage.js';
|
|
|
8
8
|
import { R2Storage } from './adapters/r2Storage.js';
|
|
9
9
|
import { GcsStorage } from './adapters/gcsStorage.js';
|
|
10
10
|
import { AzureBlobStorage } from './adapters/azureBlobStorage.js';
|
|
11
|
-
|
|
11
|
+
// TypeAwareStorageAdapter removed in v5.4.0 - type-aware now built into BaseStorage
|
|
12
12
|
// FileSystemStorage is dynamically imported to avoid issues in browser environments
|
|
13
13
|
import { isBrowser } from '../utils/environment.js';
|
|
14
14
|
/**
|
|
@@ -25,29 +25,21 @@ function getFileSystemPath(options) {
|
|
|
25
25
|
);
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* This provides type-first organization, fixed-size type counts, and efficient type queries
|
|
28
|
+
* Configure COW (Copy-on-Write) options on a storage adapter (v5.4.0)
|
|
29
|
+
* TypeAware is now built-in to all adapters, no wrapper needed!
|
|
31
30
|
*
|
|
32
|
-
* @param
|
|
31
|
+
* @param storage - The storage adapter
|
|
33
32
|
* @param options - Storage options (for COW configuration)
|
|
34
|
-
* @param verbose - Optional verbose logging
|
|
35
|
-
* @returns TypeAwareStorageAdapter wrapping the underlying storage
|
|
36
33
|
*/
|
|
37
|
-
|
|
38
|
-
const wrapped = new TypeAwareStorageAdapter({
|
|
39
|
-
underlyingStorage: underlying,
|
|
40
|
-
verbose
|
|
41
|
-
});
|
|
34
|
+
function configureCOW(storage, options) {
|
|
42
35
|
// v5.0.1: COW will be initialized AFTER storage.init() in Brainy
|
|
43
36
|
// Store COW options for later initialization
|
|
44
|
-
if (typeof
|
|
45
|
-
|
|
37
|
+
if (typeof storage.initializeCOW === 'function') {
|
|
38
|
+
storage._cowOptions = {
|
|
46
39
|
branch: options?.branch || 'main',
|
|
47
40
|
enableCompression: options?.enableCompression !== false
|
|
48
41
|
};
|
|
49
42
|
}
|
|
50
|
-
return wrapped;
|
|
51
43
|
}
|
|
52
44
|
/**
|
|
53
45
|
* Create a storage adapter based on the environment and configuration
|
|
@@ -57,70 +49,89 @@ async function wrapWithTypeAware(underlying, options, verbose = false) {
|
|
|
57
49
|
export async function createStorage(options = {}) {
|
|
58
50
|
// If memory storage is forced, use it regardless of other options
|
|
59
51
|
if (options.forceMemoryStorage) {
|
|
60
|
-
console.log('Using memory storage (forced)
|
|
61
|
-
|
|
52
|
+
console.log('Using memory storage (forced) with built-in type-aware');
|
|
53
|
+
const storage = new MemoryStorage();
|
|
54
|
+
configureCOW(storage, options);
|
|
55
|
+
return storage;
|
|
62
56
|
}
|
|
63
57
|
// If file system storage is forced, use it regardless of other options
|
|
64
58
|
if (options.forceFileSystemStorage) {
|
|
65
59
|
if (isBrowser()) {
|
|
66
60
|
console.warn('FileSystemStorage is not available in browser environments, falling back to memory storage');
|
|
67
|
-
|
|
61
|
+
const storage = new MemoryStorage();
|
|
62
|
+
configureCOW(storage, options);
|
|
63
|
+
return storage;
|
|
68
64
|
}
|
|
69
65
|
const fsPath = getFileSystemPath(options);
|
|
70
|
-
console.log(`Using file system storage (forced): ${fsPath}
|
|
66
|
+
console.log(`Using file system storage (forced): ${fsPath} with built-in type-aware`);
|
|
71
67
|
try {
|
|
72
68
|
const { FileSystemStorage } = await import('./adapters/fileSystemStorage.js');
|
|
73
|
-
|
|
69
|
+
const storage = new FileSystemStorage(fsPath);
|
|
70
|
+
configureCOW(storage, options);
|
|
71
|
+
return storage;
|
|
74
72
|
}
|
|
75
73
|
catch (error) {
|
|
76
74
|
console.warn('Failed to load FileSystemStorage, falling back to memory storage:', error);
|
|
77
|
-
|
|
75
|
+
const storage = new MemoryStorage();
|
|
76
|
+
configureCOW(storage, options);
|
|
77
|
+
return storage;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
// If a specific storage type is specified, use it
|
|
81
81
|
if (options.type && options.type !== 'auto') {
|
|
82
82
|
switch (options.type) {
|
|
83
83
|
case 'memory':
|
|
84
|
-
console.log('Using memory storage
|
|
85
|
-
|
|
84
|
+
console.log('Using memory storage with built-in type-aware');
|
|
85
|
+
const memStorage = new MemoryStorage();
|
|
86
|
+
configureCOW(memStorage, options);
|
|
87
|
+
return memStorage;
|
|
86
88
|
case 'opfs': {
|
|
87
89
|
// Check if OPFS is available
|
|
88
90
|
const opfsStorage = new OPFSStorage();
|
|
89
91
|
if (opfsStorage.isOPFSAvailable()) {
|
|
90
|
-
console.log('Using OPFS storage
|
|
92
|
+
console.log('Using OPFS storage with built-in type-aware');
|
|
91
93
|
await opfsStorage.init();
|
|
92
94
|
// Request persistent storage if specified
|
|
93
95
|
if (options.requestPersistentStorage) {
|
|
94
96
|
const isPersistent = await opfsStorage.requestPersistentStorage();
|
|
95
97
|
console.log(`Persistent storage ${isPersistent ? 'granted' : 'denied'}`);
|
|
96
98
|
}
|
|
97
|
-
|
|
99
|
+
configureCOW(opfsStorage, options);
|
|
100
|
+
return opfsStorage;
|
|
98
101
|
}
|
|
99
102
|
else {
|
|
100
103
|
console.warn('OPFS storage is not available, falling back to memory storage');
|
|
101
|
-
|
|
104
|
+
const storage = new MemoryStorage();
|
|
105
|
+
configureCOW(storage, options);
|
|
106
|
+
return storage;
|
|
102
107
|
}
|
|
103
108
|
}
|
|
104
109
|
case 'filesystem': {
|
|
105
110
|
if (isBrowser()) {
|
|
106
111
|
console.warn('FileSystemStorage is not available in browser environments, falling back to memory storage');
|
|
107
|
-
|
|
112
|
+
const storage = new MemoryStorage();
|
|
113
|
+
configureCOW(storage, options);
|
|
114
|
+
return storage;
|
|
108
115
|
}
|
|
109
116
|
const fsPath = getFileSystemPath(options);
|
|
110
|
-
console.log(`Using file system storage: ${fsPath}
|
|
117
|
+
console.log(`Using file system storage: ${fsPath} with built-in type-aware`);
|
|
111
118
|
try {
|
|
112
119
|
const { FileSystemStorage } = await import('./adapters/fileSystemStorage.js');
|
|
113
|
-
|
|
120
|
+
const storage = new FileSystemStorage(fsPath);
|
|
121
|
+
configureCOW(storage, options);
|
|
122
|
+
return storage;
|
|
114
123
|
}
|
|
115
124
|
catch (error) {
|
|
116
125
|
console.warn('Failed to load FileSystemStorage, falling back to memory storage:', error);
|
|
117
|
-
|
|
126
|
+
const storage = new MemoryStorage();
|
|
127
|
+
configureCOW(storage, options);
|
|
128
|
+
return storage;
|
|
118
129
|
}
|
|
119
130
|
}
|
|
120
131
|
case 's3':
|
|
121
132
|
if (options.s3Storage) {
|
|
122
|
-
console.log('Using Amazon S3 storage
|
|
123
|
-
|
|
133
|
+
console.log('Using Amazon S3 storage with built-in type-aware');
|
|
134
|
+
const storage = new S3CompatibleStorage({
|
|
124
135
|
bucketName: options.s3Storage.bucketName,
|
|
125
136
|
region: options.s3Storage.region,
|
|
126
137
|
accessKeyId: options.s3Storage.accessKeyId,
|
|
@@ -129,26 +140,34 @@ export async function createStorage(options = {}) {
|
|
|
129
140
|
serviceType: 's3',
|
|
130
141
|
operationConfig: options.operationConfig,
|
|
131
142
|
cacheConfig: options.cacheConfig
|
|
132
|
-
})
|
|
143
|
+
});
|
|
144
|
+
configureCOW(storage, options);
|
|
145
|
+
return storage;
|
|
133
146
|
}
|
|
134
147
|
else {
|
|
135
148
|
console.warn('S3 storage configuration is missing, falling back to memory storage');
|
|
136
|
-
|
|
149
|
+
const storage = new MemoryStorage();
|
|
150
|
+
configureCOW(storage, options);
|
|
151
|
+
return storage;
|
|
137
152
|
}
|
|
138
153
|
case 'r2':
|
|
139
154
|
if (options.r2Storage) {
|
|
140
|
-
console.log('Using Cloudflare R2 storage (dedicated adapter)
|
|
141
|
-
|
|
155
|
+
console.log('Using Cloudflare R2 storage (dedicated adapter) with built-in type-aware');
|
|
156
|
+
const storage = new R2Storage({
|
|
142
157
|
bucketName: options.r2Storage.bucketName,
|
|
143
158
|
accountId: options.r2Storage.accountId,
|
|
144
159
|
accessKeyId: options.r2Storage.accessKeyId,
|
|
145
160
|
secretAccessKey: options.r2Storage.secretAccessKey,
|
|
146
161
|
cacheConfig: options.cacheConfig
|
|
147
|
-
})
|
|
162
|
+
});
|
|
163
|
+
configureCOW(storage, options);
|
|
164
|
+
return storage;
|
|
148
165
|
}
|
|
149
166
|
else {
|
|
150
167
|
console.warn('R2 storage configuration is missing, falling back to memory storage');
|
|
151
|
-
|
|
168
|
+
const storage = new MemoryStorage();
|
|
169
|
+
configureCOW(storage, options);
|
|
170
|
+
return storage;
|
|
152
171
|
}
|
|
153
172
|
case 'gcs-native':
|
|
154
173
|
// DEPRECATED: gcs-native is deprecated in favor of just 'gcs'
|
|
@@ -161,14 +180,16 @@ export async function createStorage(options = {}) {
|
|
|
161
180
|
const gcsLegacy = options.gcsStorage;
|
|
162
181
|
if (!gcsNative && !gcsLegacy) {
|
|
163
182
|
console.warn('GCS storage configuration is missing, falling back to memory storage');
|
|
164
|
-
|
|
183
|
+
const storage = new MemoryStorage();
|
|
184
|
+
configureCOW(storage, options);
|
|
185
|
+
return storage;
|
|
165
186
|
}
|
|
166
187
|
// If using legacy gcsStorage with HMAC keys, use S3-compatible adapter
|
|
167
188
|
if (gcsLegacy && gcsLegacy.accessKeyId && gcsLegacy.secretAccessKey) {
|
|
168
189
|
console.warn('⚠️ GCS with HMAC keys detected. Consider using gcsNativeStorage with ADC instead.');
|
|
169
190
|
console.warn(' Native GCS with Application Default Credentials is recommended for better performance and security.');
|
|
170
191
|
// Use S3-compatible storage for HMAC keys
|
|
171
|
-
|
|
192
|
+
const storage = new S3CompatibleStorage({
|
|
172
193
|
bucketName: gcsLegacy.bucketName,
|
|
173
194
|
region: gcsLegacy.region,
|
|
174
195
|
endpoint: gcsLegacy.endpoint || 'https://storage.googleapis.com',
|
|
@@ -176,12 +197,14 @@ export async function createStorage(options = {}) {
|
|
|
176
197
|
secretAccessKey: gcsLegacy.secretAccessKey,
|
|
177
198
|
serviceType: 'gcs',
|
|
178
199
|
cacheConfig: options.cacheConfig
|
|
179
|
-
})
|
|
200
|
+
});
|
|
201
|
+
configureCOW(storage, options);
|
|
202
|
+
return storage;
|
|
180
203
|
}
|
|
181
204
|
// Use native GCS SDK (the correct default!)
|
|
182
205
|
const config = gcsNative || gcsLegacy;
|
|
183
206
|
console.log('Using Google Cloud Storage (native SDK) + TypeAware wrapper');
|
|
184
|
-
|
|
207
|
+
const storage = new GcsStorage({
|
|
185
208
|
bucketName: config.bucketName,
|
|
186
209
|
keyFilename: gcsNative?.keyFilename,
|
|
187
210
|
credentials: gcsNative?.credentials,
|
|
@@ -190,23 +213,29 @@ export async function createStorage(options = {}) {
|
|
|
190
213
|
skipInitialScan: gcsNative?.skipInitialScan,
|
|
191
214
|
skipCountsFile: gcsNative?.skipCountsFile,
|
|
192
215
|
cacheConfig: options.cacheConfig
|
|
193
|
-
})
|
|
216
|
+
});
|
|
217
|
+
configureCOW(storage, options);
|
|
218
|
+
return storage;
|
|
194
219
|
}
|
|
195
220
|
case 'azure':
|
|
196
221
|
if (options.azureStorage) {
|
|
197
222
|
console.log('Using Azure Blob Storage (native SDK) + TypeAware wrapper');
|
|
198
|
-
|
|
223
|
+
const storage = new AzureBlobStorage({
|
|
199
224
|
containerName: options.azureStorage.containerName,
|
|
200
225
|
accountName: options.azureStorage.accountName,
|
|
201
226
|
accountKey: options.azureStorage.accountKey,
|
|
202
227
|
connectionString: options.azureStorage.connectionString,
|
|
203
228
|
sasToken: options.azureStorage.sasToken,
|
|
204
229
|
cacheConfig: options.cacheConfig
|
|
205
|
-
})
|
|
230
|
+
});
|
|
231
|
+
configureCOW(storage, options);
|
|
232
|
+
return storage;
|
|
206
233
|
}
|
|
207
234
|
else {
|
|
208
235
|
console.warn('Azure storage configuration is missing, falling back to memory storage');
|
|
209
|
-
|
|
236
|
+
const storage = new MemoryStorage();
|
|
237
|
+
configureCOW(storage, options);
|
|
238
|
+
return storage;
|
|
210
239
|
}
|
|
211
240
|
case 'type-aware':
|
|
212
241
|
// v5.0.0: TypeAware is now the default for ALL adapters
|
|
@@ -220,13 +249,15 @@ export async function createStorage(options = {}) {
|
|
|
220
249
|
});
|
|
221
250
|
default:
|
|
222
251
|
console.warn(`Unknown storage type: ${options.type}, falling back to memory storage`);
|
|
223
|
-
|
|
252
|
+
const storage = new MemoryStorage();
|
|
253
|
+
configureCOW(storage, options);
|
|
254
|
+
return storage;
|
|
224
255
|
}
|
|
225
256
|
}
|
|
226
257
|
// If custom S3-compatible storage is specified, use it
|
|
227
258
|
if (options.customS3Storage) {
|
|
228
259
|
console.log(`Using custom S3-compatible storage: ${options.customS3Storage.serviceType || 'custom'} + TypeAware wrapper`);
|
|
229
|
-
|
|
260
|
+
const storage = new S3CompatibleStorage({
|
|
230
261
|
bucketName: options.customS3Storage.bucketName,
|
|
231
262
|
region: options.customS3Storage.region,
|
|
232
263
|
endpoint: options.customS3Storage.endpoint,
|
|
@@ -234,23 +265,27 @@ export async function createStorage(options = {}) {
|
|
|
234
265
|
secretAccessKey: options.customS3Storage.secretAccessKey,
|
|
235
266
|
serviceType: options.customS3Storage.serviceType || 'custom',
|
|
236
267
|
cacheConfig: options.cacheConfig
|
|
237
|
-
})
|
|
268
|
+
});
|
|
269
|
+
configureCOW(storage, options);
|
|
270
|
+
return storage;
|
|
238
271
|
}
|
|
239
272
|
// If R2 storage is specified, use it
|
|
240
273
|
if (options.r2Storage) {
|
|
241
274
|
console.log('Using Cloudflare R2 storage (dedicated adapter) + TypeAware wrapper');
|
|
242
|
-
|
|
275
|
+
const storage = new R2Storage({
|
|
243
276
|
bucketName: options.r2Storage.bucketName,
|
|
244
277
|
accountId: options.r2Storage.accountId,
|
|
245
278
|
accessKeyId: options.r2Storage.accessKeyId,
|
|
246
279
|
secretAccessKey: options.r2Storage.secretAccessKey,
|
|
247
280
|
cacheConfig: options.cacheConfig
|
|
248
|
-
})
|
|
281
|
+
});
|
|
282
|
+
configureCOW(storage, options);
|
|
283
|
+
return storage;
|
|
249
284
|
}
|
|
250
285
|
// If S3 storage is specified, use it
|
|
251
286
|
if (options.s3Storage) {
|
|
252
287
|
console.log('Using Amazon S3 storage + TypeAware wrapper');
|
|
253
|
-
|
|
288
|
+
const storage = new S3CompatibleStorage({
|
|
254
289
|
bucketName: options.s3Storage.bucketName,
|
|
255
290
|
region: options.s3Storage.region,
|
|
256
291
|
accessKeyId: options.s3Storage.accessKeyId,
|
|
@@ -258,7 +293,9 @@ export async function createStorage(options = {}) {
|
|
|
258
293
|
sessionToken: options.s3Storage.sessionToken,
|
|
259
294
|
serviceType: 's3',
|
|
260
295
|
cacheConfig: options.cacheConfig
|
|
261
|
-
})
|
|
296
|
+
});
|
|
297
|
+
configureCOW(storage, options);
|
|
298
|
+
return storage;
|
|
262
299
|
}
|
|
263
300
|
// If GCS storage is specified (native or legacy S3-compatible)
|
|
264
301
|
// Prefer gcsNativeStorage, but also accept gcsStorage for backward compatibility
|
|
@@ -271,7 +308,7 @@ export async function createStorage(options = {}) {
|
|
|
271
308
|
console.warn(' Native GCS with Application Default Credentials is recommended for better performance and security.');
|
|
272
309
|
// Use S3-compatible storage for HMAC keys
|
|
273
310
|
console.log('Using Google Cloud Storage (S3-compatible with HMAC - auto-detected) + TypeAware wrapper');
|
|
274
|
-
|
|
311
|
+
const storage = new S3CompatibleStorage({
|
|
275
312
|
bucketName: gcsLegacy.bucketName,
|
|
276
313
|
region: gcsLegacy.region,
|
|
277
314
|
endpoint: gcsLegacy.endpoint || 'https://storage.googleapis.com',
|
|
@@ -279,12 +316,14 @@ export async function createStorage(options = {}) {
|
|
|
279
316
|
secretAccessKey: gcsLegacy.secretAccessKey,
|
|
280
317
|
serviceType: 'gcs',
|
|
281
318
|
cacheConfig: options.cacheConfig
|
|
282
|
-
})
|
|
319
|
+
});
|
|
320
|
+
configureCOW(storage, options);
|
|
321
|
+
return storage;
|
|
283
322
|
}
|
|
284
323
|
// Use native GCS SDK (the correct default!)
|
|
285
324
|
const config = gcsNative || gcsLegacy;
|
|
286
325
|
console.log('Using Google Cloud Storage (native SDK - auto-detected) + TypeAware wrapper');
|
|
287
|
-
|
|
326
|
+
const storage = new GcsStorage({
|
|
288
327
|
bucketName: config.bucketName,
|
|
289
328
|
keyFilename: gcsNative?.keyFilename,
|
|
290
329
|
credentials: gcsNative?.credentials,
|
|
@@ -293,19 +332,23 @@ export async function createStorage(options = {}) {
|
|
|
293
332
|
skipInitialScan: gcsNative?.skipInitialScan,
|
|
294
333
|
skipCountsFile: gcsNative?.skipCountsFile,
|
|
295
334
|
cacheConfig: options.cacheConfig
|
|
296
|
-
})
|
|
335
|
+
});
|
|
336
|
+
configureCOW(storage, options);
|
|
337
|
+
return storage;
|
|
297
338
|
}
|
|
298
339
|
// If Azure storage is specified, use it
|
|
299
340
|
if (options.azureStorage) {
|
|
300
341
|
console.log('Using Azure Blob Storage (native SDK) + TypeAware wrapper');
|
|
301
|
-
|
|
342
|
+
const storage = new AzureBlobStorage({
|
|
302
343
|
containerName: options.azureStorage.containerName,
|
|
303
344
|
accountName: options.azureStorage.accountName,
|
|
304
345
|
accountKey: options.azureStorage.accountKey,
|
|
305
346
|
connectionString: options.azureStorage.connectionString,
|
|
306
347
|
sasToken: options.azureStorage.sasToken,
|
|
307
348
|
cacheConfig: options.cacheConfig
|
|
308
|
-
})
|
|
349
|
+
});
|
|
350
|
+
configureCOW(storage, options);
|
|
351
|
+
return storage;
|
|
309
352
|
}
|
|
310
353
|
// Auto-detect the best storage adapter based on the environment
|
|
311
354
|
// First, check if we're in Node.js (prioritize for test environments)
|
|
@@ -316,10 +359,12 @@ export async function createStorage(options = {}) {
|
|
|
316
359
|
process.versions &&
|
|
317
360
|
process.versions.node) {
|
|
318
361
|
const fsPath = getFileSystemPath(options);
|
|
319
|
-
console.log(`Using file system storage (auto-detected): ${fsPath}
|
|
362
|
+
console.log(`Using file system storage (auto-detected): ${fsPath} with built-in type-aware`);
|
|
320
363
|
try {
|
|
321
364
|
const { FileSystemStorage } = await import('./adapters/fileSystemStorage.js');
|
|
322
|
-
|
|
365
|
+
const storage = new FileSystemStorage(fsPath);
|
|
366
|
+
configureCOW(storage, options);
|
|
367
|
+
return storage;
|
|
323
368
|
}
|
|
324
369
|
catch (fsError) {
|
|
325
370
|
console.warn('Failed to load FileSystemStorage, falling back to memory storage:', fsError);
|
|
@@ -342,17 +387,20 @@ export async function createStorage(options = {}) {
|
|
|
342
387
|
const isPersistent = await opfsStorage.requestPersistentStorage();
|
|
343
388
|
console.log(`Persistent storage ${isPersistent ? 'granted' : 'denied'}`);
|
|
344
389
|
}
|
|
345
|
-
|
|
390
|
+
configureCOW(opfsStorage, options);
|
|
391
|
+
return opfsStorage;
|
|
346
392
|
}
|
|
347
393
|
}
|
|
348
394
|
// Finally, fall back to memory storage
|
|
349
|
-
console.log('Using memory storage (auto-detected)
|
|
350
|
-
|
|
395
|
+
console.log('Using memory storage (auto-detected) with built-in type-aware');
|
|
396
|
+
const storage = new MemoryStorage();
|
|
397
|
+
configureCOW(storage, options);
|
|
398
|
+
return storage;
|
|
351
399
|
}
|
|
352
400
|
/**
|
|
353
|
-
* Export storage adapters
|
|
401
|
+
* Export storage adapters (v5.4.0: TypeAware is now built-in, no separate export)
|
|
354
402
|
*/
|
|
355
|
-
export { MemoryStorage, OPFSStorage, S3CompatibleStorage, R2Storage, GcsStorage, AzureBlobStorage
|
|
403
|
+
export { MemoryStorage, OPFSStorage, S3CompatibleStorage, R2Storage, GcsStorage, AzureBlobStorage };
|
|
356
404
|
// Export FileSystemStorage conditionally
|
|
357
405
|
// NOTE: FileSystemStorage is now only imported dynamically to avoid fs imports in browser builds
|
|
358
406
|
// export { FileSystemStorage } from './adapters/fileSystemStorage.js'
|
package/dist/vfs/types.d.ts
CHANGED
|
@@ -166,6 +166,10 @@ export interface ReaddirOptions {
|
|
|
166
166
|
sort?: 'name' | 'size' | 'modified' | 'created';
|
|
167
167
|
order?: 'asc' | 'desc';
|
|
168
168
|
}
|
|
169
|
+
export interface StatOptions {
|
|
170
|
+
}
|
|
171
|
+
export interface ExistsOptions {
|
|
172
|
+
}
|
|
169
173
|
export interface CopyOptions {
|
|
170
174
|
overwrite?: boolean;
|
|
171
175
|
preserveTimestamps?: boolean;
|
|
@@ -299,9 +303,9 @@ export interface IVirtualFileSystem {
|
|
|
299
303
|
parent: VFSEntity | null;
|
|
300
304
|
stats: VFSStats;
|
|
301
305
|
}>;
|
|
302
|
-
stat(path: string): Promise<VFSStats>;
|
|
306
|
+
stat(path: string, options?: StatOptions): Promise<VFSStats>;
|
|
303
307
|
lstat(path: string): Promise<VFSStats>;
|
|
304
|
-
exists(path: string): Promise<boolean>;
|
|
308
|
+
exists(path: string, options?: ExistsOptions): Promise<boolean>;
|
|
305
309
|
chmod(path: string, mode: number): Promise<void>;
|
|
306
310
|
chown(path: string, uid: number, gid: number): Promise<void>;
|
|
307
311
|
utimes(path: string, atime: Date, mtime: Date): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soulcraft/brainy",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.4.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",
|