@soulcraft/brainy 3.50.2 → 4.0.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.
Files changed (57) hide show
  1. package/CHANGELOG.md +201 -0
  2. package/README.md +358 -658
  3. package/dist/api/ConfigAPI.js +56 -19
  4. package/dist/api/DataAPI.js +24 -18
  5. package/dist/augmentations/storageAugmentations.d.ts +24 -0
  6. package/dist/augmentations/storageAugmentations.js +22 -0
  7. package/dist/brainy.js +32 -9
  8. package/dist/cli/commands/core.d.ts +20 -10
  9. package/dist/cli/commands/core.js +384 -82
  10. package/dist/cli/commands/import.d.ts +41 -0
  11. package/dist/cli/commands/import.js +456 -0
  12. package/dist/cli/commands/insights.d.ts +34 -0
  13. package/dist/cli/commands/insights.js +300 -0
  14. package/dist/cli/commands/neural.d.ts +6 -12
  15. package/dist/cli/commands/neural.js +113 -10
  16. package/dist/cli/commands/nlp.d.ts +28 -0
  17. package/dist/cli/commands/nlp.js +246 -0
  18. package/dist/cli/commands/storage.d.ts +64 -0
  19. package/dist/cli/commands/storage.js +730 -0
  20. package/dist/cli/index.js +210 -24
  21. package/dist/coreTypes.d.ts +206 -34
  22. package/dist/distributed/configManager.js +8 -6
  23. package/dist/distributed/shardMigration.js +2 -0
  24. package/dist/distributed/storageDiscovery.js +6 -4
  25. package/dist/embeddings/EmbeddingManager.d.ts +2 -2
  26. package/dist/embeddings/EmbeddingManager.js +5 -1
  27. package/dist/graph/lsm/LSMTree.js +32 -20
  28. package/dist/hnsw/typeAwareHNSWIndex.js +6 -2
  29. package/dist/storage/adapters/azureBlobStorage.d.ts +545 -0
  30. package/dist/storage/adapters/azureBlobStorage.js +1809 -0
  31. package/dist/storage/adapters/baseStorageAdapter.d.ts +16 -13
  32. package/dist/storage/adapters/fileSystemStorage.d.ts +21 -9
  33. package/dist/storage/adapters/fileSystemStorage.js +204 -127
  34. package/dist/storage/adapters/gcsStorage.d.ts +119 -9
  35. package/dist/storage/adapters/gcsStorage.js +317 -62
  36. package/dist/storage/adapters/memoryStorage.d.ts +30 -18
  37. package/dist/storage/adapters/memoryStorage.js +99 -94
  38. package/dist/storage/adapters/opfsStorage.d.ts +48 -10
  39. package/dist/storage/adapters/opfsStorage.js +201 -80
  40. package/dist/storage/adapters/r2Storage.d.ts +12 -5
  41. package/dist/storage/adapters/r2Storage.js +63 -15
  42. package/dist/storage/adapters/s3CompatibleStorage.d.ts +164 -17
  43. package/dist/storage/adapters/s3CompatibleStorage.js +472 -80
  44. package/dist/storage/adapters/typeAwareStorageAdapter.d.ts +38 -6
  45. package/dist/storage/adapters/typeAwareStorageAdapter.js +218 -39
  46. package/dist/storage/baseStorage.d.ts +41 -38
  47. package/dist/storage/baseStorage.js +110 -134
  48. package/dist/storage/storageFactory.d.ts +29 -2
  49. package/dist/storage/storageFactory.js +30 -1
  50. package/dist/utils/entityIdMapper.js +5 -2
  51. package/dist/utils/fieldTypeInference.js +8 -1
  52. package/dist/utils/metadataFilter.d.ts +3 -2
  53. package/dist/utils/metadataFilter.js +1 -0
  54. package/dist/utils/metadataIndex.js +2 -0
  55. package/dist/utils/metadataIndexChunking.js +9 -4
  56. package/dist/utils/periodicCleanup.js +1 -0
  57. package/package.json +3 -1
@@ -18,7 +18,7 @@
18
18
  * @since Phase 1 - Type-First Implementation
19
19
  */
20
20
  import { BaseStorage } from '../baseStorage.js';
21
- import { GraphVerb, HNSWNoun, HNSWVerb, StatisticsData } from '../../coreTypes.js';
21
+ import { HNSWNoun, HNSWVerb, HNSWVerbWithMetadata, NounMetadata, VerbMetadata, StatisticsData } from '../../coreTypes.js';
22
22
  import { NounType, VerbType } from '../../types/graphTypes.js';
23
23
  /**
24
24
  * Options for TypeAwareStorageAdapter
@@ -68,7 +68,10 @@ export declare class TypeAwareStorageAdapter extends BaseStorage {
68
68
  */
69
69
  private saveTypeStatistics;
70
70
  /**
71
- * Get noun type from noun object or cache
71
+ * Get noun type from cache
72
+ *
73
+ * v4.0.0: Metadata is stored separately, so we rely on the cache
74
+ * which is populated when saveNounMetadata is called
72
75
  */
73
76
  private getNounType;
74
77
  /**
@@ -110,21 +113,50 @@ export declare class TypeAwareStorageAdapter extends BaseStorage {
110
113
  /**
111
114
  * Get verbs by source
112
115
  */
113
- protected getVerbsBySource_internal(sourceId: string): Promise<GraphVerb[]>;
116
+ protected getVerbsBySource_internal(sourceId: string): Promise<HNSWVerbWithMetadata[]>;
114
117
  /**
115
118
  * Get verbs by target
116
119
  */
117
- protected getVerbsByTarget_internal(targetId: string): Promise<GraphVerb[]>;
120
+ protected getVerbsByTarget_internal(targetId: string): Promise<HNSWVerbWithMetadata[]>;
118
121
  /**
119
122
  * Get verbs by type (O(1) with type-first paths!)
120
123
  *
121
- * ARCHITECTURAL FIX (v3.50.1): Type is now in HNSWVerb, cached on read
124
+ * v4.0.0: Load verbs and combine with metadata
122
125
  */
123
- protected getVerbsByType_internal(verbType: string): Promise<GraphVerb[]>;
126
+ protected getVerbsByType_internal(verbType: string): Promise<HNSWVerbWithMetadata[]>;
124
127
  /**
125
128
  * Delete verb (type-first path)
126
129
  */
127
130
  protected deleteVerb_internal(id: string): Promise<void>;
131
+ /**
132
+ * Save noun metadata (override to cache type for type-aware routing)
133
+ *
134
+ * v4.0.0: Extract and cache noun type when metadata is saved
135
+ */
136
+ saveNounMetadata(id: string, metadata: NounMetadata): Promise<void>;
137
+ /**
138
+ * Get noun metadata (override to use type-aware paths)
139
+ */
140
+ getNounMetadata(id: string): Promise<NounMetadata | null>;
141
+ /**
142
+ * Delete noun metadata (override to use type-aware paths)
143
+ */
144
+ deleteNounMetadata(id: string): Promise<void>;
145
+ /**
146
+ * Save verb metadata (override to use type-aware paths)
147
+ *
148
+ * Note: Verb type comes from HNSWVerb.verb field, not metadata
149
+ * We need to read the verb to get the type for path routing
150
+ */
151
+ saveVerbMetadata(id: string, metadata: VerbMetadata): Promise<void>;
152
+ /**
153
+ * Get verb metadata (override to use type-aware paths)
154
+ */
155
+ getVerbMetadata(id: string): Promise<VerbMetadata | null>;
156
+ /**
157
+ * Delete verb metadata (override to use type-aware paths)
158
+ */
159
+ deleteVerbMetadata(id: string): Promise<void>;
128
160
  /**
129
161
  * Write object to path (delegate to underlying storage)
130
162
  */
@@ -136,19 +136,19 @@ export class TypeAwareStorageAdapter extends BaseStorage {
136
136
  await this.u.writeObjectToPath(`${SYSTEM_DIR}/type-statistics.json`, stats);
137
137
  }
138
138
  /**
139
- * Get noun type from noun object or cache
139
+ * Get noun type from cache
140
+ *
141
+ * v4.0.0: Metadata is stored separately, so we rely on the cache
142
+ * which is populated when saveNounMetadata is called
140
143
  */
141
144
  getNounType(noun) {
142
- // Try metadata first (most reliable)
143
- if (noun.metadata?.noun) {
144
- return noun.metadata.noun;
145
- }
146
- // Try cache
145
+ // Check cache (populated when metadata is saved)
147
146
  const cached = this.nounTypeCache.get(noun.id);
148
147
  if (cached) {
149
148
  return cached;
150
149
  }
151
150
  // Default to 'thing' if unknown
151
+ // This should only happen if saveNoun_internal is called before saveNounMetadata
152
152
  console.warn(`[TypeAwareStorage] Unknown noun type for ${noun.id}, defaulting to 'thing'`);
153
153
  return 'thing';
154
154
  }
@@ -340,21 +340,35 @@ export class TypeAwareStorageAdapter extends BaseStorage {
340
340
  const verbs = [];
341
341
  for (let i = 0; i < VERB_TYPE_COUNT; i++) {
342
342
  const type = TypeUtils.getVerbFromIndex(i);
343
- const prefix = `entities/verbs/${type}/metadata/`;
343
+ const prefix = `entities/verbs/${type}/vectors/`;
344
344
  const paths = await this.u.listObjectsUnderPath(prefix);
345
345
  for (const path of paths) {
346
346
  try {
347
- const metadata = await this.u.readObjectFromPath(path);
348
- if (metadata && metadata.sourceId === sourceId) {
349
- // Load the full GraphVerb
350
- const id = path.split('/').pop()?.replace('.json', '');
351
- if (id) {
352
- const verb = await this.getVerb(id);
353
- if (verb) {
354
- verbs.push(verb);
355
- }
356
- }
357
- }
347
+ const id = path.split('/').pop()?.replace('.json', '');
348
+ if (!id)
349
+ continue;
350
+ // Load the HNSWVerb
351
+ const hnswVerb = await this.u.readObjectFromPath(path);
352
+ if (!hnswVerb)
353
+ continue;
354
+ // Check sourceId from HNSWVerb (v4.0.0: core fields are in HNSWVerb)
355
+ if (hnswVerb.sourceId !== sourceId)
356
+ continue;
357
+ // Load metadata separately
358
+ const metadata = await this.getVerbMetadata(id);
359
+ if (!metadata)
360
+ continue;
361
+ // Create HNSWVerbWithMetadata (verbs don't have level field)
362
+ const verbWithMetadata = {
363
+ id: hnswVerb.id,
364
+ vector: [...hnswVerb.vector],
365
+ connections: new Map(hnswVerb.connections),
366
+ verb: hnswVerb.verb,
367
+ sourceId: hnswVerb.sourceId,
368
+ targetId: hnswVerb.targetId,
369
+ metadata: metadata
370
+ };
371
+ verbs.push(verbWithMetadata);
358
372
  }
359
373
  catch (error) {
360
374
  // Continue searching
@@ -371,20 +385,35 @@ export class TypeAwareStorageAdapter extends BaseStorage {
371
385
  const verbs = [];
372
386
  for (let i = 0; i < VERB_TYPE_COUNT; i++) {
373
387
  const type = TypeUtils.getVerbFromIndex(i);
374
- const prefix = `entities/verbs/${type}/metadata/`;
388
+ const prefix = `entities/verbs/${type}/vectors/`;
375
389
  const paths = await this.u.listObjectsUnderPath(prefix);
376
390
  for (const path of paths) {
377
391
  try {
378
- const metadata = await this.u.readObjectFromPath(path);
379
- if (metadata && metadata.targetId === targetId) {
380
- const id = path.split('/').pop()?.replace('.json', '');
381
- if (id) {
382
- const verb = await this.getVerb(id);
383
- if (verb) {
384
- verbs.push(verb);
385
- }
386
- }
387
- }
392
+ const id = path.split('/').pop()?.replace('.json', '');
393
+ if (!id)
394
+ continue;
395
+ // Load the HNSWVerb
396
+ const hnswVerb = await this.u.readObjectFromPath(path);
397
+ if (!hnswVerb)
398
+ continue;
399
+ // Check targetId from HNSWVerb (v4.0.0: core fields are in HNSWVerb)
400
+ if (hnswVerb.targetId !== targetId)
401
+ continue;
402
+ // Load metadata separately
403
+ const metadata = await this.getVerbMetadata(id);
404
+ if (!metadata)
405
+ continue;
406
+ // Create HNSWVerbWithMetadata (verbs don't have level field)
407
+ const verbWithMetadata = {
408
+ id: hnswVerb.id,
409
+ vector: [...hnswVerb.vector],
410
+ connections: new Map(hnswVerb.connections),
411
+ verb: hnswVerb.verb,
412
+ sourceId: hnswVerb.sourceId,
413
+ targetId: hnswVerb.targetId,
414
+ metadata: metadata
415
+ };
416
+ verbs.push(verbWithMetadata);
388
417
  }
389
418
  catch (error) {
390
419
  // Continue
@@ -396,7 +425,7 @@ export class TypeAwareStorageAdapter extends BaseStorage {
396
425
  /**
397
426
  * Get verbs by type (O(1) with type-first paths!)
398
427
  *
399
- * ARCHITECTURAL FIX (v3.50.1): Type is now in HNSWVerb, cached on read
428
+ * v4.0.0: Load verbs and combine with metadata
400
429
  */
401
430
  async getVerbsByType_internal(verbType) {
402
431
  const type = verbType;
@@ -406,15 +435,25 @@ export class TypeAwareStorageAdapter extends BaseStorage {
406
435
  for (const path of paths) {
407
436
  try {
408
437
  const hnswVerb = await this.u.readObjectFromPath(path);
409
- if (hnswVerb) {
410
- // Cache type from HNSWVerb for future O(1) retrievals
411
- this.verbTypeCache.set(hnswVerb.id, hnswVerb.verb);
412
- // Convert to GraphVerb
413
- const graphVerb = await this.convertHNSWVerbToGraphVerb(hnswVerb);
414
- if (graphVerb) {
415
- verbs.push(graphVerb);
416
- }
417
- }
438
+ if (!hnswVerb)
439
+ continue;
440
+ // Cache type from HNSWVerb for future O(1) retrievals
441
+ this.verbTypeCache.set(hnswVerb.id, hnswVerb.verb);
442
+ // Load metadata separately
443
+ const metadata = await this.getVerbMetadata(hnswVerb.id);
444
+ if (!metadata)
445
+ continue;
446
+ // Create HNSWVerbWithMetadata (verbs don't have level field)
447
+ const verbWithMetadata = {
448
+ id: hnswVerb.id,
449
+ vector: [...hnswVerb.vector],
450
+ connections: new Map(hnswVerb.connections),
451
+ verb: hnswVerb.verb,
452
+ sourceId: hnswVerb.sourceId,
453
+ targetId: hnswVerb.targetId,
454
+ metadata: metadata
455
+ };
456
+ verbs.push(verbWithMetadata);
418
457
  }
419
458
  catch (error) {
420
459
  console.warn(`[TypeAwareStorage] Failed to load verb from ${path}:`, error);
@@ -455,6 +494,146 @@ export class TypeAwareStorageAdapter extends BaseStorage {
455
494
  }
456
495
  }
457
496
  }
497
+ /**
498
+ * Save noun metadata (override to cache type for type-aware routing)
499
+ *
500
+ * v4.0.0: Extract and cache noun type when metadata is saved
501
+ */
502
+ async saveNounMetadata(id, metadata) {
503
+ // Extract and cache the type
504
+ const type = (metadata.noun || 'thing');
505
+ this.nounTypeCache.set(id, type);
506
+ // Save to type-aware path
507
+ const path = getNounMetadataPath(type, id);
508
+ await this.u.writeObjectToPath(path, metadata);
509
+ }
510
+ /**
511
+ * Get noun metadata (override to use type-aware paths)
512
+ */
513
+ async getNounMetadata(id) {
514
+ // Try cache first
515
+ const cachedType = this.nounTypeCache.get(id);
516
+ if (cachedType) {
517
+ const path = getNounMetadataPath(cachedType, id);
518
+ return await this.u.readObjectFromPath(path);
519
+ }
520
+ // Search across all types
521
+ for (let i = 0; i < NOUN_TYPE_COUNT; i++) {
522
+ const type = TypeUtils.getNounFromIndex(i);
523
+ const path = getNounMetadataPath(type, id);
524
+ try {
525
+ const metadata = await this.u.readObjectFromPath(path);
526
+ if (metadata) {
527
+ // Cache the type for next time
528
+ const metadataType = (metadata.noun || 'thing');
529
+ this.nounTypeCache.set(id, metadataType);
530
+ return metadata;
531
+ }
532
+ }
533
+ catch (error) {
534
+ // Not in this type, continue searching
535
+ }
536
+ }
537
+ return null;
538
+ }
539
+ /**
540
+ * Delete noun metadata (override to use type-aware paths)
541
+ */
542
+ async deleteNounMetadata(id) {
543
+ const cachedType = this.nounTypeCache.get(id);
544
+ if (cachedType) {
545
+ const path = getNounMetadataPath(cachedType, id);
546
+ await this.u.deleteObjectFromPath(path);
547
+ return;
548
+ }
549
+ // Search across all types
550
+ for (let i = 0; i < NOUN_TYPE_COUNT; i++) {
551
+ const type = TypeUtils.getNounFromIndex(i);
552
+ const path = getNounMetadataPath(type, id);
553
+ try {
554
+ await this.u.deleteObjectFromPath(path);
555
+ return;
556
+ }
557
+ catch (error) {
558
+ // Not in this type, continue
559
+ }
560
+ }
561
+ }
562
+ /**
563
+ * Save verb metadata (override to use type-aware paths)
564
+ *
565
+ * Note: Verb type comes from HNSWVerb.verb field, not metadata
566
+ * We need to read the verb to get the type for path routing
567
+ */
568
+ async saveVerbMetadata(id, metadata) {
569
+ // Get verb type from cache or by reading the verb
570
+ let type = this.verbTypeCache.get(id);
571
+ if (!type) {
572
+ // Need to read the verb to get its type
573
+ const verb = await this.getVerb_internal(id);
574
+ if (verb) {
575
+ type = verb.verb;
576
+ this.verbTypeCache.set(id, type);
577
+ }
578
+ else {
579
+ type = 'relatedTo';
580
+ }
581
+ }
582
+ // Save to type-aware path
583
+ const path = getVerbMetadataPath(type, id);
584
+ await this.u.writeObjectToPath(path, metadata);
585
+ }
586
+ /**
587
+ * Get verb metadata (override to use type-aware paths)
588
+ */
589
+ async getVerbMetadata(id) {
590
+ // Try cache first
591
+ const cachedType = this.verbTypeCache.get(id);
592
+ if (cachedType) {
593
+ const path = getVerbMetadataPath(cachedType, id);
594
+ return await this.u.readObjectFromPath(path);
595
+ }
596
+ // Search across all types
597
+ for (let i = 0; i < VERB_TYPE_COUNT; i++) {
598
+ const type = TypeUtils.getVerbFromIndex(i);
599
+ const path = getVerbMetadataPath(type, id);
600
+ try {
601
+ const metadata = await this.u.readObjectFromPath(path);
602
+ if (metadata) {
603
+ // Cache the type for next time
604
+ this.verbTypeCache.set(id, type);
605
+ return metadata;
606
+ }
607
+ }
608
+ catch (error) {
609
+ // Not in this type, continue
610
+ }
611
+ }
612
+ return null;
613
+ }
614
+ /**
615
+ * Delete verb metadata (override to use type-aware paths)
616
+ */
617
+ async deleteVerbMetadata(id) {
618
+ const cachedType = this.verbTypeCache.get(id);
619
+ if (cachedType) {
620
+ const path = getVerbMetadataPath(cachedType, id);
621
+ await this.u.deleteObjectFromPath(path);
622
+ return;
623
+ }
624
+ // Search across all types
625
+ for (let i = 0; i < VERB_TYPE_COUNT; i++) {
626
+ const type = TypeUtils.getVerbFromIndex(i);
627
+ const path = getVerbMetadataPath(type, id);
628
+ try {
629
+ await this.u.deleteObjectFromPath(path);
630
+ return;
631
+ }
632
+ catch (error) {
633
+ // Not in this type, continue
634
+ }
635
+ }
636
+ }
458
637
  /**
459
638
  * Write object to path (delegate to underlying storage)
460
639
  */
@@ -3,7 +3,7 @@
3
3
  * Provides common functionality for all storage adapters
4
4
  */
5
5
  import { GraphAdjacencyIndex } from '../graph/graphAdjacencyIndex.js';
6
- import { GraphVerb, HNSWNoun, HNSWVerb, StatisticsData } from '../coreTypes.js';
6
+ import { GraphVerb, HNSWNoun, HNSWVerb, NounMetadata, VerbMetadata, HNSWNounWithMetadata, HNSWVerbWithMetadata, StatisticsData } from '../coreTypes.js';
7
7
  import { BaseStorageAdapter } from './adapters/baseStorageAdapter.js';
8
8
  export declare const ENTITIES_DIR = "entities";
9
9
  export declare const NOUNS_VECTOR_DIR = "entities/nouns/vectors";
@@ -52,40 +52,43 @@ export declare abstract class BaseStorage extends BaseStorageAdapter {
52
52
  */
53
53
  protected ensureInitialized(): Promise<void>;
54
54
  /**
55
- * Save a noun to storage
55
+ * Save a noun to storage (v4.0.0: vector only, metadata saved separately)
56
+ * @param noun Pure HNSW vector data (no metadata)
56
57
  */
57
58
  saveNoun(noun: HNSWNoun): Promise<void>;
58
59
  /**
59
- * Get a noun from storage
60
+ * Get a noun from storage (v4.0.0: returns combined HNSWNounWithMetadata)
61
+ * @param id Entity ID
62
+ * @returns Combined vector + metadata or null
60
63
  */
61
- getNoun(id: string): Promise<HNSWNoun | null>;
64
+ getNoun(id: string): Promise<HNSWNounWithMetadata | null>;
62
65
  /**
63
66
  * Get nouns by noun type
64
67
  * @param nounType The noun type to filter by
65
68
  * @returns Promise that resolves to an array of nouns of the specified noun type
66
69
  */
67
- getNounsByNounType(nounType: string): Promise<HNSWNoun[]>;
70
+ getNounsByNounType(nounType: string): Promise<HNSWNounWithMetadata[]>;
68
71
  /**
69
72
  * Delete a noun from storage
70
73
  */
71
74
  deleteNoun(id: string): Promise<void>;
72
75
  /**
73
- * Save a verb to storage
76
+ * Save a verb to storage (v4.0.0: verb only, metadata saved separately)
74
77
  *
75
- * ARCHITECTURAL FIX (v3.50.1): HNSWVerb now includes verb/sourceId/targetId
76
- * These are core relational fields, not metadata. They're stored in the vector
77
- * file for fast access and to align with actual usage patterns.
78
+ * @param verb Pure HNSW verb with core relational fields (verb, sourceId, targetId)
78
79
  */
79
- saveVerb(verb: GraphVerb): Promise<void>;
80
+ saveVerb(verb: HNSWVerb): Promise<void>;
80
81
  /**
81
- * Get a verb from storage
82
+ * Get a verb from storage (v4.0.0: returns combined HNSWVerbWithMetadata)
83
+ * @param id Entity ID
84
+ * @returns Combined verb + metadata or null
82
85
  */
83
- getVerb(id: string): Promise<GraphVerb | null>;
86
+ getVerb(id: string): Promise<HNSWVerbWithMetadata | null>;
84
87
  /**
85
88
  * Convert HNSWVerb to GraphVerb by combining with metadata
89
+ * DEPRECATED: For backward compatibility only. Use getVerb() which returns HNSWVerbWithMetadata.
86
90
  *
87
- * ARCHITECTURAL FIX (v3.50.1): Core fields (verb/sourceId/targetId) are now in HNSWVerb
88
- * Only optional fields (weight, timestamps, etc.) come from metadata file
91
+ * @deprecated Use getVerb() instead which returns HNSWVerbWithMetadata
89
92
  */
90
93
  protected convertHNSWVerbToGraphVerb(hnswVerb: HNSWVerb): Promise<GraphVerb | null>;
91
94
  /**
@@ -96,15 +99,15 @@ export declare abstract class BaseStorage extends BaseStorageAdapter {
96
99
  /**
97
100
  * Get verbs by source
98
101
  */
99
- getVerbsBySource(sourceId: string): Promise<GraphVerb[]>;
102
+ getVerbsBySource(sourceId: string): Promise<HNSWVerbWithMetadata[]>;
100
103
  /**
101
104
  * Get verbs by target
102
105
  */
103
- getVerbsByTarget(targetId: string): Promise<GraphVerb[]>;
106
+ getVerbsByTarget(targetId: string): Promise<HNSWVerbWithMetadata[]>;
104
107
  /**
105
108
  * Get verbs by type
106
109
  */
107
- getVerbsByType(type: string): Promise<GraphVerb[]>;
110
+ getVerbsByType(type: string): Promise<HNSWVerbWithMetadata[]>;
108
111
  /**
109
112
  * Internal method for loading all nouns - used by performance optimizations
110
113
  * @internal - Do not use directly, use getNouns() with pagination instead
@@ -127,7 +130,7 @@ export declare abstract class BaseStorage extends BaseStorageAdapter {
127
130
  metadata?: Record<string, any>;
128
131
  };
129
132
  }): Promise<{
130
- items: HNSWNoun[];
133
+ items: HNSWNounWithMetadata[];
131
134
  totalCount?: number;
132
135
  hasMore: boolean;
133
136
  nextCursor?: string;
@@ -151,7 +154,7 @@ export declare abstract class BaseStorage extends BaseStorageAdapter {
151
154
  metadata?: Record<string, any>;
152
155
  };
153
156
  }): Promise<{
154
- items: GraphVerb[];
157
+ items: HNSWVerbWithMetadata[];
155
158
  totalCount?: number;
156
159
  hasMore: boolean;
157
160
  nextCursor?: string;
@@ -211,52 +214,52 @@ export declare abstract class BaseStorage extends BaseStorageAdapter {
211
214
  */
212
215
  protected abstract listObjectsUnderPath(prefix: string): Promise<string[]>;
213
216
  /**
214
- * Save metadata to storage
217
+ * Save metadata to storage (v4.0.0: now typed)
215
218
  * Routes to correct location (system or entity) based on key format
216
219
  */
217
- saveMetadata(id: string, metadata: any): Promise<void>;
220
+ saveMetadata(id: string, metadata: NounMetadata): Promise<void>;
218
221
  /**
219
- * Get metadata from storage
222
+ * Get metadata from storage (v4.0.0: now typed)
220
223
  * Routes to correct location (system or entity) based on key format
221
224
  */
222
- getMetadata(id: string): Promise<any | null>;
225
+ getMetadata(id: string): Promise<NounMetadata | null>;
223
226
  /**
224
- * Save noun metadata to storage
227
+ * Save noun metadata to storage (v4.0.0: now typed)
225
228
  * Routes to correct sharded location based on UUID
226
229
  */
227
- saveNounMetadata(id: string, metadata: any): Promise<void>;
230
+ saveNounMetadata(id: string, metadata: NounMetadata): Promise<void>;
228
231
  /**
229
- * Internal method for saving noun metadata
232
+ * Internal method for saving noun metadata (v4.0.0: now typed)
230
233
  * Uses routing logic to handle both UUIDs (sharded) and system keys (unsharded)
231
234
  * @protected
232
235
  */
233
- protected saveNounMetadata_internal(id: string, metadata: any): Promise<void>;
236
+ protected saveNounMetadata_internal(id: string, metadata: NounMetadata): Promise<void>;
234
237
  /**
235
- * Get noun metadata from storage
238
+ * Get noun metadata from storage (v4.0.0: now typed)
236
239
  * Uses routing logic to handle both UUIDs (sharded) and system keys (unsharded)
237
240
  */
238
- getNounMetadata(id: string): Promise<any | null>;
241
+ getNounMetadata(id: string): Promise<NounMetadata | null>;
239
242
  /**
240
243
  * Delete noun metadata from storage
241
244
  * Uses routing logic to handle both UUIDs (sharded) and system keys (unsharded)
242
245
  */
243
246
  deleteNounMetadata(id: string): Promise<void>;
244
247
  /**
245
- * Save verb metadata to storage
248
+ * Save verb metadata to storage (v4.0.0: now typed)
246
249
  * Routes to correct sharded location based on UUID
247
250
  */
248
- saveVerbMetadata(id: string, metadata: any): Promise<void>;
251
+ saveVerbMetadata(id: string, metadata: VerbMetadata): Promise<void>;
249
252
  /**
250
- * Internal method for saving verb metadata
253
+ * Internal method for saving verb metadata (v4.0.0: now typed)
251
254
  * Uses routing logic to handle both UUIDs (sharded) and system keys (unsharded)
252
255
  * @protected
253
256
  */
254
- protected saveVerbMetadata_internal(id: string, metadata: any): Promise<void>;
257
+ protected saveVerbMetadata_internal(id: string, metadata: VerbMetadata): Promise<void>;
255
258
  /**
256
- * Get verb metadata from storage
259
+ * Get verb metadata from storage (v4.0.0: now typed)
257
260
  * Uses routing logic to handle both UUIDs (sharded) and system keys (unsharded)
258
261
  */
259
- getVerbMetadata(id: string): Promise<any | null>;
262
+ getVerbMetadata(id: string): Promise<VerbMetadata | null>;
260
263
  /**
261
264
  * Delete verb metadata from storage
262
265
  * Uses routing logic to handle both UUIDs (sharded) and system keys (unsharded)
@@ -296,17 +299,17 @@ export declare abstract class BaseStorage extends BaseStorageAdapter {
296
299
  * Get verbs by source
297
300
  * This method should be implemented by each specific adapter
298
301
  */
299
- protected abstract getVerbsBySource_internal(sourceId: string): Promise<GraphVerb[]>;
302
+ protected abstract getVerbsBySource_internal(sourceId: string): Promise<HNSWVerbWithMetadata[]>;
300
303
  /**
301
304
  * Get verbs by target
302
305
  * This method should be implemented by each specific adapter
303
306
  */
304
- protected abstract getVerbsByTarget_internal(targetId: string): Promise<GraphVerb[]>;
307
+ protected abstract getVerbsByTarget_internal(targetId: string): Promise<HNSWVerbWithMetadata[]>;
305
308
  /**
306
309
  * Get verbs by type
307
310
  * This method should be implemented by each specific adapter
308
311
  */
309
- protected abstract getVerbsByType_internal(type: string): Promise<GraphVerb[]>;
312
+ protected abstract getVerbsByType_internal(type: string): Promise<HNSWVerbWithMetadata[]>;
310
313
  /**
311
314
  * Delete a verb from storage
312
315
  * This method should be implemented by each specific adapter