@soulcraft/brainy 3.25.2 → 3.27.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.
@@ -6,6 +6,7 @@ import { StorageAdapter } from '../coreTypes.js';
6
6
  import { MemoryStorage } from './adapters/memoryStorage.js';
7
7
  import { OPFSStorage } from './adapters/opfsStorage.js';
8
8
  import { S3CompatibleStorage, R2Storage } from './adapters/s3CompatibleStorage.js';
9
+ import { GcsStorage } from './adapters/gcsStorage.js';
9
10
  import { OperationConfig } from '../utils/operationUtils.js';
10
11
  /**
11
12
  * Options for creating a storage adapter
@@ -19,9 +20,10 @@ export interface StorageOptions {
19
20
  * - 'filesystem': Use file system storage (Node.js only)
20
21
  * - 's3': Use Amazon S3 storage
21
22
  * - 'r2': Use Cloudflare R2 storage
22
- * - 'gcs': Use Google Cloud Storage
23
+ * - 'gcs': Use Google Cloud Storage (S3-compatible with HMAC keys)
24
+ * - 'gcs-native': Use Google Cloud Storage (native SDK with ADC)
23
25
  */
24
- type?: 'auto' | 'memory' | 'opfs' | 'filesystem' | 's3' | 'r2' | 'gcs';
26
+ type?: 'auto' | 'memory' | 'opfs' | 'filesystem' | 's3' | 'r2' | 'gcs' | 'gcs-native';
25
27
  /**
26
28
  * Force the use of memory storage even if other storage types are available
27
29
  */
@@ -85,7 +87,7 @@ export interface StorageOptions {
85
87
  secretAccessKey: string;
86
88
  };
87
89
  /**
88
- * Configuration for Google Cloud Storage
90
+ * Configuration for Google Cloud Storage (S3-compatible with HMAC keys)
89
91
  */
90
92
  gcsStorage?: {
91
93
  /**
@@ -109,6 +111,31 @@ export interface StorageOptions {
109
111
  */
110
112
  endpoint?: string;
111
113
  };
114
+ /**
115
+ * Configuration for Google Cloud Storage (native SDK with ADC)
116
+ */
117
+ gcsNativeStorage?: {
118
+ /**
119
+ * GCS bucket name
120
+ */
121
+ bucketName: string;
122
+ /**
123
+ * Service account key file path (optional, uses ADC if not provided)
124
+ */
125
+ keyFilename?: string;
126
+ /**
127
+ * Service account credentials object (optional, uses ADC if not provided)
128
+ */
129
+ credentials?: object;
130
+ /**
131
+ * HMAC access key ID (backward compatibility, not recommended)
132
+ */
133
+ accessKeyId?: string;
134
+ /**
135
+ * HMAC secret access key (backward compatibility, not recommended)
136
+ */
137
+ secretAccessKey?: string;
138
+ };
112
139
  /**
113
140
  * Configuration for custom S3-compatible storage
114
141
  */
@@ -196,4 +223,4 @@ export declare function createStorage(options?: StorageOptions): Promise<Storage
196
223
  /**
197
224
  * Export storage adapters
198
225
  */
199
- export { MemoryStorage, OPFSStorage, S3CompatibleStorage, R2Storage };
226
+ export { MemoryStorage, OPFSStorage, S3CompatibleStorage, R2Storage, GcsStorage };
@@ -5,6 +5,7 @@
5
5
  import { MemoryStorage } from './adapters/memoryStorage.js';
6
6
  import { OPFSStorage } from './adapters/opfsStorage.js';
7
7
  import { S3CompatibleStorage, R2Storage } from './adapters/s3CompatibleStorage.js';
8
+ import { GcsStorage } from './adapters/gcsStorage.js';
8
9
  // FileSystemStorage is dynamically imported to avoid issues in browser environments
9
10
  import { isBrowser } from '../utils/environment.js';
10
11
  /**
@@ -109,7 +110,7 @@ export async function createStorage(options = {}) {
109
110
  }
110
111
  case 'gcs':
111
112
  if (options.gcsStorage) {
112
- console.log('Using Google Cloud Storage');
113
+ console.log('Using Google Cloud Storage (S3-compatible)');
113
114
  return new S3CompatibleStorage({
114
115
  bucketName: options.gcsStorage.bucketName,
115
116
  region: options.gcsStorage.region,
@@ -124,6 +125,22 @@ export async function createStorage(options = {}) {
124
125
  console.warn('GCS storage configuration is missing, falling back to memory storage');
125
126
  return new MemoryStorage();
126
127
  }
128
+ case 'gcs-native':
129
+ if (options.gcsNativeStorage) {
130
+ console.log('Using Google Cloud Storage (native SDK)');
131
+ return new GcsStorage({
132
+ bucketName: options.gcsNativeStorage.bucketName,
133
+ keyFilename: options.gcsNativeStorage.keyFilename,
134
+ credentials: options.gcsNativeStorage.credentials,
135
+ accessKeyId: options.gcsNativeStorage.accessKeyId,
136
+ secretAccessKey: options.gcsNativeStorage.secretAccessKey,
137
+ cacheConfig: options.cacheConfig
138
+ });
139
+ }
140
+ else {
141
+ console.warn('GCS native storage configuration is missing, falling back to memory storage');
142
+ return new MemoryStorage();
143
+ }
127
144
  default:
128
145
  console.warn(`Unknown storage type: ${options.type}, falling back to memory storage`);
129
146
  return new MemoryStorage();
@@ -167,9 +184,21 @@ export async function createStorage(options = {}) {
167
184
  cacheConfig: options.cacheConfig
168
185
  });
169
186
  }
170
- // If GCS storage is specified, use it
187
+ // If GCS native storage is specified, use it (prioritize native over S3-compatible)
188
+ if (options.gcsNativeStorage) {
189
+ console.log('Using Google Cloud Storage (native SDK)');
190
+ return new GcsStorage({
191
+ bucketName: options.gcsNativeStorage.bucketName,
192
+ keyFilename: options.gcsNativeStorage.keyFilename,
193
+ credentials: options.gcsNativeStorage.credentials,
194
+ accessKeyId: options.gcsNativeStorage.accessKeyId,
195
+ secretAccessKey: options.gcsNativeStorage.secretAccessKey,
196
+ cacheConfig: options.cacheConfig
197
+ });
198
+ }
199
+ // If GCS storage is specified, use it (S3-compatible)
171
200
  if (options.gcsStorage) {
172
- console.log('Using Google Cloud Storage');
201
+ console.log('Using Google Cloud Storage (S3-compatible)');
173
202
  return new S3CompatibleStorage({
174
203
  bucketName: options.gcsStorage.bucketName,
175
204
  region: options.gcsStorage.region,
@@ -224,7 +253,7 @@ export async function createStorage(options = {}) {
224
253
  /**
225
254
  * Export storage adapters
226
255
  */
227
- export { MemoryStorage, OPFSStorage, S3CompatibleStorage, R2Storage };
256
+ export { MemoryStorage, OPFSStorage, S3CompatibleStorage, R2Storage, GcsStorage };
228
257
  // Export FileSystemStorage conditionally
229
258
  // NOTE: FileSystemStorage is now only imported dynamically to avoid fs imports in browser builds
230
259
  // export { FileSystemStorage } from './adapters/fileSystemStorage.js'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soulcraft/brainy",
3
- "version": "3.25.2",
3
+ "version": "3.27.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",
@@ -157,6 +157,7 @@
157
157
  },
158
158
  "dependencies": {
159
159
  "@aws-sdk/client-s3": "^3.540.0",
160
+ "@google-cloud/storage": "^7.14.0",
160
161
  "@huggingface/transformers": "^3.7.2",
161
162
  "boxen": "^8.0.1",
162
163
  "chalk": "^5.3.0",