@utaba/deep-memory 0.1.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.
@@ -0,0 +1,897 @@
1
+ /** Context provided by the consumer to identify who is performing operations */
2
+ interface ProvenanceContext {
3
+ /** User or agent ID performing the operation */
4
+ actorId: string;
5
+ /** Whether the actor is a human user or an AI agent */
6
+ actorType: 'user' | 'agent';
7
+ /** Optional conversation ID — links memory to a conversation */
8
+ conversationId?: string;
9
+ /** Optional message ID — links memory to a specific message */
10
+ messageId?: string;
11
+ }
12
+ /** Full provenance record stored on every entity and relationship */
13
+ interface Provenance {
14
+ createdBy: string;
15
+ createdByType: 'user' | 'agent';
16
+ createdAt: string;
17
+ createdInConversation?: string;
18
+ createdFromMessage?: string;
19
+ modifiedBy: string;
20
+ modifiedByType: 'user' | 'agent';
21
+ modifiedAt: string;
22
+ modifiedInConversation?: string;
23
+ modifiedFromMessage?: string;
24
+ }
25
+
26
+ /** Property type for vocabulary property schemas */
27
+ type PropertyType = 'string' | 'number' | 'boolean' | 'date' | 'enum';
28
+ /** Defines a property on an entity or relationship type */
29
+ interface PropertySchema {
30
+ name: string;
31
+ type: PropertyType;
32
+ required: boolean;
33
+ description?: string;
34
+ /** Valid values when type === "enum" */
35
+ enumValues?: string[];
36
+ defaultValue?: unknown;
37
+ }
38
+ /** Definition of an entity type within a vocabulary */
39
+ interface EntityTypeDefinition {
40
+ /** Type identifier, e.g., "clause", "part", "person" */
41
+ type: string;
42
+ /** Natural language description — critical for AI comprehension */
43
+ description: string;
44
+ /** Version of this type definition */
45
+ version: string;
46
+ /** Expected properties and their types */
47
+ properties: PropertySchema[];
48
+ createdAt: string;
49
+ createdBy: string;
50
+ modifiedAt: string;
51
+ modifiedBy: string;
52
+ }
53
+ /** Definition of a relationship type within a vocabulary */
54
+ interface RelationshipTypeDefinition {
55
+ /** Type identifier, e.g., "requires_clause", "component_of" */
56
+ type: string;
57
+ /** Natural language description */
58
+ description: string;
59
+ /** Version of this type definition */
60
+ version: string;
61
+ /** Valid source entity types */
62
+ allowedSourceTypes: string[];
63
+ /** Valid target entity types */
64
+ allowedTargetTypes: string[];
65
+ /** Whether the relationship is symmetric */
66
+ bidirectional: boolean;
67
+ /** Optional edge properties */
68
+ properties?: PropertySchema[];
69
+ createdAt: string;
70
+ createdBy: string;
71
+ modifiedAt: string;
72
+ modifiedBy: string;
73
+ }
74
+ /** The vocabulary schema of a memory repository */
75
+ interface MemoryVocabulary {
76
+ /** Semantic version of the vocabulary */
77
+ version: string;
78
+ /** ISO timestamp of last modification */
79
+ lastModified: string;
80
+ /** User or system that last modified the vocabulary */
81
+ modifiedBy: string;
82
+ entityTypes: EntityTypeDefinition[];
83
+ relationshipTypes: RelationshipTypeDefinition[];
84
+ }
85
+ /** Vocabulary governance mode — controls how the vocabulary can evolve */
86
+ type GovernanceMode = 'locked' | 'managed' | 'open';
87
+ /** Governance configuration for a repository */
88
+ interface GovernanceConfig {
89
+ mode: GovernanceMode;
90
+ /** Managed mode: similarity score below which proposals auto-approve (default 0.3) */
91
+ autoApproveThreshold?: number;
92
+ /** Managed mode: if true, all proposals queue for human approval regardless of checks */
93
+ requireApproval?: boolean;
94
+ /** Open mode: whether deduplication is still enforced (default true) */
95
+ deduplicationEnabled?: boolean;
96
+ /** Default similarity threshold for semantic search (0.0-1.0, default 0.5). Model-dependent — lower for local models, higher for OpenAI. */
97
+ defaultSimilarityThreshold?: number;
98
+ }
99
+ /** Proposal to change the vocabulary — add, edit, or delete a type */
100
+ interface VocabularyProposal {
101
+ proposalType: 'entity_type' | 'relationship_type' | 'edit_entity_type' | 'edit_relationship_type' | 'delete_entity_type' | 'delete_relationship_type';
102
+ /** Used when proposalType is 'entity_type' (add new) */
103
+ entityType?: {
104
+ type: string;
105
+ description: string;
106
+ properties?: PropertySchema[];
107
+ };
108
+ /** Used when proposalType is 'relationship_type' (add new) */
109
+ relationshipType?: {
110
+ type: string;
111
+ description: string;
112
+ allowedSourceTypes: string[];
113
+ allowedTargetTypes: string[];
114
+ bidirectional?: boolean;
115
+ properties?: PropertySchema[];
116
+ };
117
+ /** Used when proposalType is 'edit_entity_type' */
118
+ editEntityType?: {
119
+ type: string;
120
+ description?: string;
121
+ addProperties?: PropertySchema[];
122
+ removeProperties?: string[];
123
+ updateProperties?: PropertySchema[];
124
+ };
125
+ /** Used when proposalType is 'edit_relationship_type' */
126
+ editRelationshipType?: {
127
+ type: string;
128
+ description?: string;
129
+ allowedSourceTypes?: string[];
130
+ allowedTargetTypes?: string[];
131
+ bidirectional?: boolean;
132
+ addProperties?: PropertySchema[];
133
+ removeProperties?: string[];
134
+ updateProperties?: PropertySchema[];
135
+ };
136
+ /** Used when proposalType is 'delete_entity_type' */
137
+ deleteEntityType?: {
138
+ type: string;
139
+ };
140
+ /** Used when proposalType is 'delete_relationship_type' */
141
+ deleteRelationshipType?: {
142
+ type: string;
143
+ };
144
+ /** Why this change is needed */
145
+ justification: string;
146
+ }
147
+ /** Result of a vocabulary change proposal */
148
+ interface VocabularyProposalResult {
149
+ status: 'approved' | 'pending_approval' | 'rejected';
150
+ proposalId?: string;
151
+ /** The type name that was proposed */
152
+ type: string;
153
+ /** New vocabulary version if approved */
154
+ vocabularyVersion?: string;
155
+ /** Reason for rejection */
156
+ reason?: string;
157
+ /** Similar existing types if rejected as duplicate */
158
+ duplicates?: Array<{
159
+ type: string;
160
+ description: string;
161
+ similarity: number;
162
+ }>;
163
+ /** Number of entities cascade-deleted (delete_entity_type only) */
164
+ cascadedEntities?: number;
165
+ /** Number of relationships cascade-deleted (delete operations) */
166
+ cascadedRelationships?: number;
167
+ }
168
+ /** Record of a vocabulary change for auditing */
169
+ interface VocabularyChangeRecord {
170
+ changeId: string;
171
+ changeType: 'entity_type_added' | 'relationship_type_added' | 'entity_type_modified' | 'relationship_type_modified' | 'entity_type_removed' | 'relationship_type_removed';
172
+ typeName: string;
173
+ previousVersion?: string;
174
+ newVersion: string;
175
+ proposedBy: string;
176
+ proposedAt: string;
177
+ approvedBy?: string;
178
+ approvedAt?: string;
179
+ reason: string;
180
+ }
181
+ /** Vocabulary with resolved governance info and stats */
182
+ interface ResolvedVocabulary {
183
+ vocabulary: MemoryVocabulary;
184
+ governanceMode: GovernanceMode;
185
+ governanceConfig: GovernanceConfig;
186
+ }
187
+ /** Input for creating entity type definitions (without system-managed fields) */
188
+ interface EntityTypeInput {
189
+ type: string;
190
+ description: string;
191
+ properties?: PropertySchema[];
192
+ }
193
+ /** Input for creating relationship type definitions (without system-managed fields) */
194
+ interface RelationshipTypeInput {
195
+ type: string;
196
+ description: string;
197
+ allowedSourceTypes: string[];
198
+ allowedTargetTypes: string[];
199
+ bidirectional?: boolean;
200
+ properties?: PropertySchema[];
201
+ }
202
+ /** Input vocabulary definition used when creating a repository */
203
+ interface VocabularyInput {
204
+ entityTypes?: EntityTypeInput[];
205
+ relationshipTypes?: RelationshipTypeInput[];
206
+ }
207
+
208
+ /** Detail level for entity retrieval */
209
+ type DetailLevel = 'brief' | 'summary' | 'full';
210
+ /** Full entity representation (returned at "full" detail level) */
211
+ interface Entity {
212
+ id: string;
213
+ slug: string;
214
+ entityType: string;
215
+ label: string;
216
+ summary?: string;
217
+ properties: Record<string, unknown>;
218
+ /** Raw content/data of the entity — only at "full" detail level */
219
+ data?: string;
220
+ /** Format of the data field, e.g., "text/plain", "text/markdown" */
221
+ dataFormat?: string;
222
+ provenance: Provenance;
223
+ }
224
+ /** Entity at "summary" detail level — properties but no raw data */
225
+ interface EntitySummary {
226
+ id: string;
227
+ slug: string;
228
+ entityType: string;
229
+ label: string;
230
+ summary?: string;
231
+ properties: Record<string, unknown>;
232
+ }
233
+ /** Entity at "brief" detail level — minimal info for lists */
234
+ interface EntityBrief {
235
+ id: string;
236
+ slug: string;
237
+ entityType: string;
238
+ label: string;
239
+ summary?: string;
240
+ }
241
+ /** Input for creating a new entity */
242
+ interface CreateEntityInput {
243
+ /** Explicit GUID — auto-generated if omitted */
244
+ id?: string;
245
+ /** Must exist in the repository's vocabulary */
246
+ entityType: string;
247
+ label: string;
248
+ summary?: string;
249
+ /** Must conform to the vocabulary's property schema */
250
+ properties?: Record<string, unknown>;
251
+ /** Raw content/data */
252
+ data?: string;
253
+ /** Format of the data field */
254
+ dataFormat?: string;
255
+ }
256
+ /** Input for updating an existing entity */
257
+ interface UpdateEntityInput {
258
+ label?: string;
259
+ summary?: string;
260
+ /** Merged with existing properties */
261
+ properties?: Record<string, unknown>;
262
+ data?: string;
263
+ dataFormat?: string;
264
+ /** Force regeneration of the embedding vector (e.g. after switching embedding models) */
265
+ reembed?: boolean;
266
+ }
267
+ /** Internal stored representation — includes provenance and embeddings */
268
+ interface StoredEntity {
269
+ id: string;
270
+ slug: string;
271
+ entityType: string;
272
+ label: string;
273
+ summary?: string;
274
+ properties: Record<string, unknown>;
275
+ data?: string;
276
+ dataFormat?: string;
277
+ provenance: Provenance;
278
+ /** Vector embedding of the entity (label + summary + properties) */
279
+ embedding?: number[];
280
+ }
281
+ /** Internal update representation for the storage provider */
282
+ interface StoredEntityUpdate {
283
+ label?: string;
284
+ slug?: string;
285
+ summary?: string;
286
+ properties?: Record<string, unknown>;
287
+ data?: string;
288
+ dataFormat?: string;
289
+ provenance: Provenance;
290
+ embedding?: number[];
291
+ }
292
+ /** Options for getEntity */
293
+ interface GetEntityOptions {
294
+ detailLevel?: DetailLevel;
295
+ }
296
+ /** Options for getEntities (batch) */
297
+ interface GetEntitiesOptions {
298
+ /** Only "brief" or "summary" for batch retrieval */
299
+ detailLevel?: 'brief' | 'summary';
300
+ }
301
+
302
+ /** Pagination options used across all paginated queries */
303
+ interface PaginationOptions {
304
+ /** Maximum number of results (default 10, max 50) */
305
+ limit?: number;
306
+ /** Pagination offset */
307
+ offset?: number;
308
+ }
309
+ /** Query for finding entities by label, type, and property filters */
310
+ interface FindEntitiesQuery extends PaginationOptions {
311
+ /** Search term to match against entity labels */
312
+ searchTerm?: string;
313
+ /** Filter by entity type(s) */
314
+ entityTypes?: string[];
315
+ /** Filter by property values */
316
+ properties?: Record<string, unknown>;
317
+ /** Detail level for returned entities (default: summary) */
318
+ detailLevel?: DetailLevel;
319
+ /** Filter by provenance metadata */
320
+ provenance?: ProvenanceFilter;
321
+ }
322
+ /** Options for neighbourhood exploration */
323
+ interface ExploreOptions {
324
+ /** Exploration depth: 1, 2, or 3 (default 1) */
325
+ depth?: 1 | 2 | 3;
326
+ /** Filter by relationship type(s) */
327
+ relationshipTypes?: string[];
328
+ /** Filter result entity types */
329
+ entityTypes?: string[];
330
+ /** Direction filter */
331
+ direction?: RelationshipDirection;
332
+ /** Max results per relationship type (default 10) */
333
+ limitPerType?: number;
334
+ /** Pagination offset per relationship type */
335
+ offsetPerType?: number;
336
+ /** Detail level for returned entities (default: summary) */
337
+ detailLevel?: DetailLevel;
338
+ /** Filter relationships by property values (all filters are AND'd) */
339
+ relationshipPropertyFilters?: PropertyFilter[];
340
+ }
341
+ /** Options for path finding between two entities */
342
+ interface PathOptions {
343
+ /** Maximum path depth (default 3, max 5) */
344
+ maxDepth?: number;
345
+ /** Filter allowed relationship types */
346
+ relationshipTypes?: string[];
347
+ /** Filter entities in paths by type(s) — only paths through matching entity types are returned */
348
+ entityTypes?: string[];
349
+ /** Maximum number of paths to return (default 5) */
350
+ limit?: number;
351
+ /** Pagination offset */
352
+ offset?: number;
353
+ /** Detail level for returned entities (default: brief) */
354
+ detailLevel?: DetailLevel;
355
+ /** Filter relationships in paths by property values (all filters are AND'd) */
356
+ relationshipPropertyFilters?: PropertyFilter[];
357
+ }
358
+ /** Options for semantic/vector similarity search */
359
+ interface ConceptSearchOptions extends PaginationOptions {
360
+ /** Minimum similarity threshold (0.0–1.0, default 0.7) */
361
+ similarityThreshold?: number;
362
+ /** Filter by entity type(s) */
363
+ entityTypes?: string[];
364
+ /** Detail level for returned entities (default: summary) */
365
+ detailLevel?: DetailLevel;
366
+ }
367
+ /** Options for timeline queries */
368
+ interface TimelineOptions extends PaginationOptions {
369
+ /** Date range filter */
370
+ timeRange?: {
371
+ from: string;
372
+ to: string;
373
+ };
374
+ /** Filter by event types */
375
+ eventTypes?: string[];
376
+ /** Filter by provenance metadata */
377
+ provenance?: ProvenanceFilter;
378
+ }
379
+ /** Filter by provenance metadata (conversation, actor, date range) */
380
+ interface ProvenanceFilter {
381
+ /** Filter to entities created/modified in these conversations */
382
+ conversationIds?: string[];
383
+ /** Filter to entities created/modified by these actors */
384
+ actors?: string[];
385
+ /** Filter to entities created/modified within this date range */
386
+ dateRange?: {
387
+ from: string;
388
+ to: string;
389
+ };
390
+ }
391
+ /** Filter on a relationship property value */
392
+ interface PropertyFilter {
393
+ /** Property name on the relationship */
394
+ key: string;
395
+ /** Filter operator */
396
+ operator: 'eq' | 'neq' | 'isNull' | 'isNotNull' | 'gt' | 'lt' | 'gte' | 'lte' | 'contains';
397
+ /** Value to compare (not needed for isNull/isNotNull) */
398
+ value?: unknown;
399
+ }
400
+ /** Storage-level find query */
401
+ interface StorageFindQuery {
402
+ searchTerm?: string;
403
+ entityTypes?: string[];
404
+ properties?: Record<string, unknown>;
405
+ provenance?: ProvenanceFilter;
406
+ limit: number;
407
+ offset: number;
408
+ }
409
+ /** Storage-level explore options */
410
+ interface StorageExploreOptions {
411
+ depth: number;
412
+ relationshipTypes?: string[];
413
+ entityTypes?: string[];
414
+ direction: RelationshipDirection;
415
+ limitPerType: number;
416
+ offsetPerType: number;
417
+ relationshipPropertyFilters?: PropertyFilter[];
418
+ }
419
+ /** Storage-level path finding options */
420
+ interface StoragePathOptions {
421
+ maxDepth: number;
422
+ relationshipTypes?: string[];
423
+ entityTypes?: string[];
424
+ limit: number;
425
+ offset: number;
426
+ relationshipPropertyFilters?: PropertyFilter[];
427
+ }
428
+ /** Storage-level timeline options */
429
+ interface StorageTimelineOptions {
430
+ timeRange?: {
431
+ from: string;
432
+ to: string;
433
+ };
434
+ eventTypes?: string[];
435
+ provenance?: ProvenanceFilter;
436
+ limit: number;
437
+ offset: number;
438
+ }
439
+ /** Options for full-text search (SearchProvider) */
440
+ interface SearchOptions extends PaginationOptions {
441
+ /** Filter by entity type(s) */
442
+ entityTypes?: string[];
443
+ }
444
+
445
+ /** Direction filter for relationship queries */
446
+ type RelationshipDirection = 'outbound' | 'inbound' | 'both';
447
+ /** Public relationship representation */
448
+ interface Relationship {
449
+ id: string;
450
+ relationshipType: string;
451
+ sourceEntityId: string;
452
+ targetEntityId: string;
453
+ properties: Record<string, unknown>;
454
+ bidirectional: boolean;
455
+ provenance: Provenance;
456
+ }
457
+ /** Input for creating a new relationship */
458
+ interface CreateRelationshipInput {
459
+ /** Explicit GUID — auto-generated if omitted */
460
+ id?: string;
461
+ /** Must exist in the repository's vocabulary */
462
+ relationshipType: string;
463
+ /** Must match allowedSourceTypes (GUID or slug) */
464
+ sourceEntityId: string;
465
+ /** Must match allowedTargetTypes (GUID or slug) */
466
+ targetEntityId: string;
467
+ /** Must conform to the relationship type's property schema */
468
+ properties?: Record<string, unknown>;
469
+ }
470
+ /** Internal stored representation */
471
+ interface StoredRelationship {
472
+ id: string;
473
+ relationshipType: string;
474
+ sourceEntityId: string;
475
+ targetEntityId: string;
476
+ properties: Record<string, unknown>;
477
+ bidirectional: boolean;
478
+ provenance: Provenance;
479
+ }
480
+ /** Relationship with human-readable source/target info */
481
+ interface EnrichedRelationship {
482
+ id: string;
483
+ relationshipType: string;
484
+ sourceEntityId: string;
485
+ sourceSlug: string;
486
+ sourceLabel: string;
487
+ targetEntityId: string;
488
+ targetSlug: string;
489
+ targetLabel: string;
490
+ properties: Record<string, unknown>;
491
+ bidirectional: boolean;
492
+ provenance: Provenance;
493
+ }
494
+ /** Aggregated relationship counts by type and direction */
495
+ interface RelationshipSummary {
496
+ outbound: Record<string, number>;
497
+ inbound: Record<string, number>;
498
+ }
499
+ /** Options for querying relationships of an entity */
500
+ interface RelationshipQueryOptions {
501
+ /** Filter by relationship type(s) */
502
+ relationshipTypes?: string[];
503
+ /** Filter by direction relative to the entity */
504
+ direction?: RelationshipDirection;
505
+ /** Maximum number of results */
506
+ limit?: number;
507
+ /** Pagination offset */
508
+ offset?: number;
509
+ /** Filter by relationship property values (all filters are AND'd) */
510
+ propertyFilters?: PropertyFilter[];
511
+ }
512
+
513
+ /** Extensible metadata bag persisted as a single JSON column */
514
+ interface RepositoryMetadata {
515
+ /** Embedding model identifier (e.g. "Qwen/Qwen3-Embedding-8B") */
516
+ embeddingModelId?: string;
517
+ /** Dimensionality of embedding vectors */
518
+ embeddingDimensions?: number;
519
+ /** Arbitrary additional properties */
520
+ [key: string]: unknown;
521
+ }
522
+ /** Configuration for creating a new repository */
523
+ interface RepositoryConfig {
524
+ /** Optional: if omitted a GUID is generated automatically */
525
+ repositoryId?: string;
526
+ type?: string;
527
+ label: string;
528
+ description?: string;
529
+ /** Legal terms, licence, or compliance notes (stored but excluded from list queries) */
530
+ legal?: string;
531
+ /** Repository owner identifier (stored but excluded from list queries) */
532
+ owner?: string;
533
+ /** Initial vocabulary definition */
534
+ vocabulary?: VocabularyInput;
535
+ /** Governance configuration */
536
+ governance?: GovernanceConfig;
537
+ /** Extensible metadata — embedding model info, custom fields, etc. */
538
+ metadata?: RepositoryMetadata;
539
+ }
540
+ /** Summary of a repository for listing */
541
+ interface RepositorySummary {
542
+ repositoryId: string;
543
+ type?: string;
544
+ label: string;
545
+ description?: string;
546
+ governanceMode: GovernanceMode;
547
+ stats?: RepositoryStats;
548
+ }
549
+ /** Repository statistics */
550
+ interface RepositoryStats {
551
+ entityCount: number;
552
+ relationshipCount: number;
553
+ vocabularyVersion: string;
554
+ entityTypeBreakdown: Record<string, number>;
555
+ relationshipTypeBreakdown: Record<string, number>;
556
+ }
557
+ /** Internal stored representation of a repository */
558
+ interface StoredRepository {
559
+ repositoryId: string;
560
+ type?: string;
561
+ label: string;
562
+ description?: string;
563
+ /** Legal terms, licence, or compliance notes */
564
+ legal?: string;
565
+ /** Repository owner identifier */
566
+ owner?: string;
567
+ governanceConfig: GovernanceConfig;
568
+ /** Extensible metadata bag (embedding model info, custom fields, etc.) */
569
+ metadata?: RepositoryMetadata;
570
+ createdAt: string;
571
+ createdBy: string;
572
+ }
573
+ /** Internal stored summary for listing */
574
+ interface StoredRepositorySummary {
575
+ repositoryId: string;
576
+ type?: string;
577
+ label: string;
578
+ description?: string;
579
+ governanceConfig: GovernanceConfig;
580
+ }
581
+ /** Fields that can be updated on an existing repository */
582
+ interface RepositoryUpdate {
583
+ label?: string;
584
+ description?: string;
585
+ type?: string;
586
+ legal?: string;
587
+ owner?: string;
588
+ governanceConfig?: GovernanceConfig;
589
+ /** Metadata updates — merged with existing metadata (shallow merge) */
590
+ metadata?: RepositoryMetadata;
591
+ }
592
+ /** Filter for listing repositories */
593
+ interface RepositoryFilter {
594
+ /** Filter by repository type */
595
+ type?: string;
596
+ /** Include statistics */
597
+ includeStats?: boolean;
598
+ /** Maximum number of results (default 20) */
599
+ limit?: number;
600
+ /** Pagination offset */
601
+ offset?: number;
602
+ }
603
+ /** Configuration passed to the storage provider for repository creation */
604
+ interface StorageRepositoryConfig {
605
+ repositoryId: string;
606
+ type?: string;
607
+ label: string;
608
+ description?: string;
609
+ /** Legal terms, licence, or compliance notes */
610
+ legal?: string;
611
+ /** Repository owner identifier */
612
+ owner?: string;
613
+ governanceConfig: GovernanceConfig;
614
+ /** Extensible metadata bag */
615
+ metadata?: RepositoryMetadata;
616
+ createdAt: string;
617
+ createdBy: string;
618
+ }
619
+
620
+ /** Paginated result wrapper */
621
+ interface PaginatedResult<T> {
622
+ items: T[];
623
+ total: number;
624
+ hasMore: boolean;
625
+ limit: number;
626
+ offset: number;
627
+ }
628
+ /** Centre entity in a neighbourhood exploration */
629
+ interface NeighbourhoodCentre {
630
+ id: string;
631
+ slug: string;
632
+ entityType: string;
633
+ label: string;
634
+ }
635
+ /** A group of entities connected by a specific relationship type */
636
+ interface NeighbourhoodGroup {
637
+ total: number;
638
+ returned: number;
639
+ entities: Array<Entity | EntitySummary | EntityBrief>;
640
+ }
641
+ /** A layer of connected entities at a specific depth */
642
+ interface NeighbourhoodLayer {
643
+ /** Keyed by relationship type */
644
+ [relationshipType: string]: NeighbourhoodGroup;
645
+ }
646
+ /** Result of neighbourhood exploration */
647
+ interface Neighbourhood {
648
+ centre: NeighbourhoodCentre;
649
+ layers: NeighbourhoodLayer[];
650
+ statistics: {
651
+ totalEntities: number;
652
+ returnedEntities: number;
653
+ truncatedTypes: string[];
654
+ };
655
+ }
656
+ /** A single path between two entities */
657
+ interface Path {
658
+ length: number;
659
+ entities: Array<Entity | EntitySummary | EntityBrief>;
660
+ relationships: Array<{
661
+ id: string;
662
+ type: string;
663
+ direction: string;
664
+ properties: Record<string, unknown>;
665
+ }>;
666
+ }
667
+ /** Result of path finding */
668
+ interface PathResult {
669
+ totalPaths: number;
670
+ returned: number;
671
+ paths: Path[];
672
+ }
673
+ /** Entity with a relevance/similarity score */
674
+ interface ScoredEntity {
675
+ id: string;
676
+ slug: string;
677
+ entityType: string;
678
+ label: string;
679
+ summary?: string;
680
+ score: number;
681
+ }
682
+ /** A related entity reference with human-readable info */
683
+ interface TimelineEntityRef {
684
+ id: string;
685
+ slug: string;
686
+ label: string;
687
+ }
688
+ /** Relationship detail included in relationship timeline events */
689
+ interface TimelineRelationshipDetail {
690
+ id: string;
691
+ relationshipType: string;
692
+ sourceEntity: TimelineEntityRef;
693
+ targetEntity: TimelineEntityRef;
694
+ }
695
+ /** A single timeline event */
696
+ interface TimelineEvent {
697
+ timestamp: string;
698
+ eventType: string;
699
+ description: string;
700
+ relatedEntities: TimelineEntityRef[];
701
+ relationship?: TimelineRelationshipDetail;
702
+ }
703
+ /** Result of a timeline query */
704
+ interface TimelineResult {
705
+ id: string;
706
+ slug: string;
707
+ totalEvents: number;
708
+ returned: number;
709
+ events: TimelineEvent[];
710
+ }
711
+ /** Result of a getGraph query — paginated entities with enriched relationships */
712
+ interface GraphResult {
713
+ vocabulary: ResolvedVocabulary;
714
+ stats: RepositoryStats;
715
+ entities: Array<Entity | EntitySummary | EntityBrief>;
716
+ relationships: EnrichedRelationship[];
717
+ /** Total relationship count for this page (before truncation) */
718
+ totalRelationships: number;
719
+ /** Whether the relationships were truncated due to the max limit */
720
+ relationshipsTruncated: boolean;
721
+ hasMore: boolean;
722
+ cursor?: string;
723
+ }
724
+ /** Map of entity ID → Entity (for batch retrieval) */
725
+ type EntityMap = Map<string, EntitySummary>;
726
+ /** Storage-level neighbourhood (uses StoredEntity) */
727
+ interface StorageNeighbourhoodGroup {
728
+ total: number;
729
+ entities: StoredEntity[];
730
+ relationships: StoredRelationship[];
731
+ }
732
+ interface StorageNeighbourhoodLayer {
733
+ [relationshipType: string]: StorageNeighbourhoodGroup;
734
+ }
735
+ interface StorageNeighbourhood {
736
+ centreId: string;
737
+ layers: StorageNeighbourhoodLayer[];
738
+ }
739
+ /** Storage-level path result */
740
+ interface StoragePath {
741
+ entityIds: string[];
742
+ relationshipIds: string[];
743
+ }
744
+ interface StoragePathResult {
745
+ paths: StoragePath[];
746
+ totalPaths: number;
747
+ }
748
+ /** Storage-level timeline result */
749
+ interface StorageTimelineEvent {
750
+ timestamp: string;
751
+ eventType: string;
752
+ entityId: string;
753
+ relationshipId?: string;
754
+ }
755
+ interface StorageTimelineResult {
756
+ events: StorageTimelineEvent[];
757
+ total: number;
758
+ }
759
+ /** Search hit from a SearchProvider */
760
+ interface SearchHit {
761
+ id: string;
762
+ score: number;
763
+ highlights?: Record<string, string[]>;
764
+ }
765
+ /** Result of a bulk import operation */
766
+ interface BulkImportResult {
767
+ entitiesImported: number;
768
+ relationshipsImported: number;
769
+ errors: Array<{
770
+ item: string;
771
+ error: string;
772
+ }>;
773
+ }
774
+ /** Result of a re-embedding operation */
775
+ interface ReembedResult {
776
+ processed: number;
777
+ failed: number;
778
+ errors: Array<{
779
+ entityId: string;
780
+ error: string;
781
+ }>;
782
+ modelId: string;
783
+ dimensions: number;
784
+ }
785
+
786
+ /** Manifest describing an exported repository archive */
787
+ interface ExportManifest {
788
+ /** Archive format version — for forward compatibility */
789
+ formatVersion: '1.0.0';
790
+ /** @utaba/deep-memory version that created this export */
791
+ libraryVersion: string;
792
+ /** ISO 8601 timestamp */
793
+ exportedAt: string;
794
+ exportedBy: ProvenanceContext;
795
+ repository: {
796
+ repositoryId: string;
797
+ type?: string;
798
+ label: string;
799
+ description?: string;
800
+ vocabularyVersion: string;
801
+ governanceMode: GovernanceMode;
802
+ };
803
+ statistics: {
804
+ entityCount: number;
805
+ relationshipCount: number;
806
+ entityTypeBreakdown: Record<string, number>;
807
+ relationshipTypeBreakdown: Record<string, number>;
808
+ };
809
+ /** Embedding metadata — critical for portability */
810
+ embedding?: {
811
+ modelId: string;
812
+ dimensions: number;
813
+ note: string;
814
+ };
815
+ }
816
+ /** A complete repository export archive */
817
+ interface ExportArchive {
818
+ manifest: ExportManifest;
819
+ vocabulary: MemoryVocabulary;
820
+ entities: StoredEntity[];
821
+ relationships: StoredRelationship[];
822
+ }
823
+ /** A chunk of exported data (for streaming) */
824
+ interface ExportChunk {
825
+ type: 'entities' | 'relationships';
826
+ data: StoredEntity[] | StoredRelationship[];
827
+ sequence: number;
828
+ isLast: boolean;
829
+ }
830
+ /** Items yielded by the streaming export */
831
+ type ExportStreamItem = {
832
+ type: 'manifest';
833
+ data: ExportManifest;
834
+ } | {
835
+ type: 'vocabulary';
836
+ data: MemoryVocabulary;
837
+ } | {
838
+ type: 'entities';
839
+ data: StoredEntity[];
840
+ sequence: number;
841
+ isLast: boolean;
842
+ } | {
843
+ type: 'relationships';
844
+ data: StoredRelationship[];
845
+ sequence: number;
846
+ isLast: boolean;
847
+ };
848
+ /** Options for importing a repository archive */
849
+ interface ImportOptions {
850
+ /** How to handle the target repository */
851
+ target: {
852
+ mode: 'create';
853
+ repositoryId: string;
854
+ config: RepositoryConfig;
855
+ } | {
856
+ mode: 'merge';
857
+ repositoryId: string;
858
+ };
859
+ /** How to handle vocabulary differences (only for "merge" mode) */
860
+ vocabularyConflict?: 'reject' | 'extend' | 'prompt';
861
+ /** How to handle entity ID collisions (only for "merge" mode) */
862
+ entityConflict?: 'skip' | 'overwrite' | 'rename';
863
+ /** Whether to re-generate embeddings using the current EmbeddingProvider */
864
+ reEmbed?: boolean;
865
+ }
866
+ /** A chunk of data for bulk import */
867
+ interface ImportChunk {
868
+ entities?: StoredEntity[];
869
+ relationships?: StoredRelationship[];
870
+ }
871
+ /** Header for streaming import — sent before data chunks */
872
+ interface ImportStreamHeader {
873
+ manifest: ExportManifest;
874
+ vocabulary: MemoryVocabulary;
875
+ }
876
+ /** Warning generated during import */
877
+ interface ImportWarning {
878
+ code: string;
879
+ message: string;
880
+ id?: string;
881
+ relationshipId?: string;
882
+ }
883
+ /** Result of an import operation */
884
+ interface ImportResult {
885
+ success: boolean;
886
+ repositoryId: string;
887
+ statistics: {
888
+ entitiesImported: number;
889
+ entitiesSkipped: number;
890
+ relationshipsImported: number;
891
+ relationshipsSkipped: number;
892
+ vocabularyExtensions: number;
893
+ };
894
+ warnings: ImportWarning[];
895
+ }
896
+
897
+ export type { RepositorySummary as $, ReembedResult as A, BulkImportResult as B, CreateEntityInput as C, DetailLevel as D, ExportChunk as E, FindEntitiesQuery as F, GovernanceConfig as G, Relationship as H, ImportChunk as I, PropertyFilter as J, RelationshipSummary as K, GraphResult as L, MemoryVocabulary as M, ExploreOptions as N, Neighbourhood as O, PaginatedResult as P, PathOptions as Q, RepositoryFilter as R, StorageRepositoryConfig as S, PathResult as T, UpdateEntityInput as U, VocabularyChangeRecord as V, ConceptSearchOptions as W, ScoredEntity as X, TimelineOptions as Y, TimelineResult as Z, RepositoryConfig as _, StoredRepository as a, ExportArchive as a0, ImportOptions as a1, ImportResult as a2, ExportStreamItem as a3, ImportStreamHeader as a4, SearchOptions as a5, SearchHit as a6, EnrichedRelationship as a7, EntityMap as a8, EntityTypeInput as a9, ExportManifest as aa, GetEntitiesOptions as ab, GetEntityOptions as ac, GovernanceMode as ad, ImportWarning as ae, NeighbourhoodCentre as af, NeighbourhoodGroup as ag, NeighbourhoodLayer as ah, Path as ai, PropertySchema as aj, PropertyType as ak, ProvenanceFilter as al, RelationshipDirection as am, RelationshipTypeDefinition as an, RelationshipTypeInput as ao, RepositoryMetadata as ap, StorageNeighbourhoodGroup as aq, StorageNeighbourhoodLayer as ar, StoragePath as as, StorageTimelineEvent as at, TimelineEntityRef as au, TimelineEvent as av, TimelineRelationshipDetail as aw, VocabularyInput as ax, StoredRepositorySummary as b, RepositoryUpdate as c, RepositoryStats as d, PaginationOptions as e, StoredEntity as f, StoredEntityUpdate as g, StorageFindQuery as h, StoredRelationship as i, RelationshipQueryOptions as j, StorageExploreOptions as k, StorageNeighbourhood as l, StoragePathOptions as m, StoragePathResult as n, StorageTimelineOptions as o, StorageTimelineResult as p, ResolvedVocabulary as q, CreateRelationshipInput as r, EntityTypeDefinition as s, VocabularyProposal as t, VocabularyProposalResult as u, ProvenanceContext as v, Provenance as w, Entity as x, EntitySummary as y, EntityBrief as z };