@utaba/deep-memory 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,12 +1,14 @@
1
- import { G as GovernanceConfig, M as MemoryVocabulary, q as ResolvedVocabulary, C as CreateEntityInput, U as UpdateEntityInput, r as CreateRelationshipInput, s as EntityTypeDefinition, t as VocabularyProposal, u as VocabularyProposalResult, v as ProvenanceContext, w as Provenance, x as Entity, D as DetailLevel, y as EntitySummary, z as EntityBrief, F as FindEntitiesQuery, P as PaginatedResult, A as ReembedResult, H as Relationship, J as PropertyFilter, K as RelationshipSummary, L as GraphResult, N as ExploreOptions, O as Neighbourhood, Q as PathOptions, T as PathResult, W as ConceptSearchOptions, X as ScoredEntity, Y as TimelineOptions, Z as TimelineResult, d as RepositoryStats, _ as RepositoryConfig, R as RepositoryFilter, $ as RepositorySummary, c as RepositoryUpdate, a as StoredRepository, a0 as ExportArchive, a1 as ImportOptions, a2 as ImportResult, a3 as ExportStreamItem, a4 as ImportStreamHeader, I as ImportChunk, S as StorageRepositoryConfig, b as StoredRepositorySummary, e as PaginationOptions, V as VocabularyChangeRecord, f as StoredEntity, g as StoredEntityUpdate, h as StorageFindQuery, i as StoredRelationship, j as RelationshipQueryOptions, k as StorageExploreOptions, l as StorageNeighbourhood, m as StoragePathOptions, n as StoragePathResult, o as StorageTimelineOptions, p as StorageTimelineResult, E as ExportChunk, B as BulkImportResult, a5 as SearchOptions, a6 as SearchHit } from './portability-DdlNYXGX.cjs';
2
- export { a7 as EnrichedRelationship, a8 as EntityMap, a9 as EntityTypeInput, aa as ExportManifest, ab as GetEntitiesOptions, ac as GetEntityOptions, ad as GovernanceMode, ae as ImportWarning, af as NeighbourhoodCentre, ag as NeighbourhoodGroup, ah as NeighbourhoodLayer, ai as Path, aj as PropertySchema, ak as PropertyType, al as ProvenanceFilter, am as RelationshipDirection, an as RelationshipTypeDefinition, ao as RelationshipTypeInput, ap as RepositoryMetadata, aq as StorageNeighbourhoodGroup, ar as StorageNeighbourhoodLayer, as as StoragePath, at as StorageTimelineEvent, au as TimelineEntityRef, av as TimelineEvent, aw as TimelineRelationshipDetail, ax as VocabularyInput } from './portability-DdlNYXGX.cjs';
1
+ import { G as GovernanceConfig, M as MemoryVocabulary, x as ResolvedVocabulary, C as CreateEntityInput, U as UpdateEntityInput, y as CreateRelationshipInput, z as EntityTypeDefinition, A as VocabularyProposal, F as VocabularyProposalResult, H as ProvenanceContext, J as Provenance, E as Entity, D as DetailLevel, a as EntitySummary, b as EntityBrief, K as FindEntitiesQuery, e as PaginatedResult, L as ReembedResult, N as Relationship, P as PropertyFilter, R as RelationshipSummary, O as GraphResult, Q as ExploreOptions, T as Neighbourhood, W as PathOptions, X as PathResult, Y as ConceptSearchOptions, Z as ScoredEntity, _ as TimelineOptions, $ as TimelineResult, i as RepositoryStats, a0 as RepositoryConfig, d as RepositoryFilter, a1 as RepositorySummary, g as RepositoryUpdate, c as StoredRepository, a2 as ExportOptions, a3 as ExportArchive, a4 as ImportOptions, a5 as ImportResult, a6 as ExportStreamItem, a7 as ImportStreamHeader, I as ImportChunk, S as StorageRepositoryConfig, f as StoredRepositorySummary, h as DeleteProgressCallback, j as PaginationOptions, V as VocabularyChangeRecord, k as StoredEntity, l as StoredEntityUpdate, m as StorageFindQuery, n as StoredRelationship, o as RelationshipQueryOptions, p as StorageExploreOptions, q as StorageNeighbourhood, r as StoragePathOptions, s as StoragePathResult, t as StorageTimelineOptions, u as StorageTimelineResult, v as ExportChunk, B as BulkImportOptions, w as BulkImportResult, a8 as SearchOptions, a9 as SearchHit } from './portability-1KBMVBGJ.cjs';
2
+ export { aa as EnrichedRelationship, ab as EntityMap, ac as EntityTypeInput, ad as ExportLegalMetadata, ae as ExportManifest, af as ExportPipelineMetadata, ag as GetEntitiesOptions, ah as GetEntityOptions, ai as GovernanceMode, aj as ImportWarning, ak as NeighbourhoodCentre, al as NeighbourhoodGroup, am as NeighbourhoodLayer, an as Path, ao as PropertySchema, ap as PropertyType, aq as ProvenanceFilter, ar as RelationshipDirection, as as RelationshipTypeDefinition, at as RelationshipTypeInput, au as RepositoryMetadata, av as StorageNeighbourhoodGroup, aw as StorageNeighbourhoodLayer, ax as StoragePath, ay as StorageTimelineEvent, az as TimelineEntityRef, aA as TimelineEvent, aB as TimelineRelationshipDetail, aC as VocabularyInput } from './portability-1KBMVBGJ.cjs';
3
3
  import { DeepMemoryEventType, EventHandler, Unsubscribe, DeepMemoryEvent, HookResult, EventPayload } from './types/index.cjs';
4
- import { S as StorageProvider } from './StorageProvider-CkFjdboX.cjs';
5
- import { EmbeddingProvider, SearchProvider, LockProvider, SearchableEntity } from './providers/index.cjs';
6
- export { LockHandle, LockOptions } from './providers/index.cjs';
4
+ import { T as TraversalSpec, a as TraversalResult } from './traversal-DQynd-to.cjs';
5
+ export { Q as QueryMetadata, b as TraversalAggregation, c as TraversalPath, d as TraversalProjection, e as TraversalRelationship, f as TraversalReturnMode, g as TraversalStart, h as TraversalStep } from './traversal-DQynd-to.cjs';
6
+ import { S as StorageProvider, E as EnsureSchemaResult } from './StorageProvider-CSbaIY6X.cjs';
7
+ import { EmbeddingProvider, SearchProvider, GraphTraversalProvider, LockProvider, SearchableEntity } from './providers/index.cjs';
8
+ export { GraphTraversalCapabilities, LockHandle, LockOptions } from './providers/index.cjs';
7
9
 
8
10
  /** Error codes for all Deep Memory errors */
9
- type DeepMemoryErrorCode = 'INVALID_INPUT' | 'ENTITY_NOT_FOUND' | 'ENTITY_ALREADY_EXISTS' | 'RELATIONSHIP_NOT_FOUND' | 'RELATIONSHIP_ALREADY_EXISTS' | 'REPOSITORY_NOT_FOUND' | 'REPOSITORY_ALREADY_EXISTS' | 'VOCABULARY_VALIDATION_FAILED' | 'RELATIONSHIP_CONSTRAINT_FAILED' | 'GOVERNANCE_DENIED' | 'OPERATION_CANCELLED' | 'EMBEDDING_PROVIDER_REQUIRED' | 'IMPORT_ERROR' | 'EXPORT_ERROR' | 'PROVIDER_ERROR';
11
+ type DeepMemoryErrorCode = 'INVALID_INPUT' | 'ENTITY_NOT_FOUND' | 'ENTITY_ALREADY_EXISTS' | 'RELATIONSHIP_NOT_FOUND' | 'RELATIONSHIP_ALREADY_EXISTS' | 'REPOSITORY_NOT_FOUND' | 'REPOSITORY_ALREADY_EXISTS' | 'VOCABULARY_VALIDATION_FAILED' | 'RELATIONSHIP_CONSTRAINT_FAILED' | 'GOVERNANCE_DENIED' | 'OPERATION_CANCELLED' | 'EMBEDDING_PROVIDER_REQUIRED' | 'IMPORT_ERROR' | 'EXPORT_ERROR' | 'PROVIDER_ERROR' | 'GRAPH_TRAVERSAL_PROVIDER_REQUIRED' | 'TRAVERSAL_VALIDATION_FAILED' | 'TRAVERSAL_VOCABULARY_ERROR' | 'TRAVERSAL_TIMEOUT';
10
12
  /** Base error class for all Deep Memory errors */
11
13
  declare class DeepMemoryError extends Error {
12
14
  readonly code: DeepMemoryErrorCode;
@@ -96,6 +98,25 @@ declare class ExportError extends DeepMemoryError {
96
98
  declare class ProviderError extends DeepMemoryError {
97
99
  constructor(message: string, suggestion?: string);
98
100
  }
101
+ /** Thrown when executeNativeQuery() is called but no GraphTraversalProvider is registered. */
102
+ declare class GraphTraversalProviderRequiredError extends DeepMemoryError {
103
+ constructor();
104
+ }
105
+ /** Thrown when a TraversalSpec is structurally invalid. */
106
+ declare class TraversalValidationError extends DeepMemoryError {
107
+ readonly errors: string[];
108
+ constructor(errors: string[]);
109
+ }
110
+ /** Thrown when a TraversalSpec references relationship/entity types not in the vocabulary. */
111
+ declare class TraversalVocabularyError extends DeepMemoryError {
112
+ readonly unknownTypes: string[];
113
+ constructor(unknownTypes: string[]);
114
+ }
115
+ /** Thrown when a native query times out. */
116
+ declare class TraversalTimeoutError extends DeepMemoryError {
117
+ readonly timeoutMs: number;
118
+ constructor(timeoutMs: number);
119
+ }
99
120
 
100
121
  /** A single validation error with optional suggestion */
101
122
  interface ValidationError {
@@ -210,6 +231,7 @@ interface MemoryRepositoryConfig {
210
231
  storage: StorageProvider;
211
232
  search?: SearchProvider;
212
233
  embedding?: EmbeddingProvider;
234
+ graphTraversal?: GraphTraversalProvider;
213
235
  vocabularyEngine: VocabularyEngine;
214
236
  provenanceTracker: ProvenanceTracker;
215
237
  eventBus: EventBus;
@@ -230,7 +252,7 @@ declare class MemoryRepository {
230
252
  proposeVocabularyChange(proposal: VocabularyProposal): Promise<VocabularyProposalResult>;
231
253
  /** @deprecated Use proposeVocabularyChange instead */
232
254
  proposeVocabularyExtension(proposal: VocabularyProposal): Promise<VocabularyProposalResult>;
233
- createEntity(input: CreateEntityInput): Promise<Entity>;
255
+ createEntities(inputs: CreateEntityInput[]): Promise<Entity[]>;
234
256
  updateEntity(entityId: string, updates: UpdateEntityInput): Promise<Entity>;
235
257
  getEntity(entityId: string, detailLevel?: DetailLevel): Promise<Entity | EntitySummary | EntityBrief | null>;
236
258
  getBySlug(slug: string, detailLevel?: DetailLevel): Promise<Entity | EntitySummary | EntityBrief | null>;
@@ -253,7 +275,7 @@ declare class MemoryRepository {
253
275
  /** Milliseconds to wait between batches for rate limiting (default 0) */
254
276
  delayBetweenBatchesMs?: number;
255
277
  }): Promise<ReembedResult>;
256
- createRelationship(input: CreateRelationshipInput): Promise<Relationship>;
278
+ createRelationships(inputs: CreateRelationshipInput[]): Promise<Relationship[]>;
257
279
  removeRelationship(relationshipId: string): Promise<void>;
258
280
  getRelationships(entityId: string, options?: {
259
281
  relationshipTypes?: string[];
@@ -272,9 +294,21 @@ declare class MemoryRepository {
272
294
  }): Promise<GraphResult>;
273
295
  exploreNeighbourhood(entityId: string, options?: ExploreOptions): Promise<Neighbourhood>;
274
296
  findPaths(sourceId: string, targetId: string, options?: PathOptions): Promise<PathResult>;
297
+ traverse(spec: TraversalSpec): Promise<TraversalResult>;
298
+ executeNativeQuery(query: string, params?: Record<string, unknown>): Promise<TraversalResult>;
275
299
  searchByConcept(query: string, options?: ConceptSearchOptions): Promise<PaginatedResult<ScoredEntity>>;
276
300
  getTimeline(entityId: string, options?: TimelineOptions): Promise<TimelineResult>;
277
301
  getStats(): Promise<RepositoryStats>;
302
+ /** Delete all entities and relationships in this repository, preserving the repository and vocabulary */
303
+ deleteAllContents(): Promise<{
304
+ deletedEntities: number;
305
+ deletedRelationships: number;
306
+ }>;
307
+ /**
308
+ * Returns a static markdown guide describing the recommended query strategy
309
+ * for AI agents and other consumers of the repository.
310
+ */
311
+ getQueryGuide(): string;
278
312
  on<E extends DeepMemoryEventType>(event: E, handler: EventHandler<E>): Unsubscribe;
279
313
  onHook<E extends Extract<DeepMemoryEventType, 'entity:creating' | 'entity:updating' | 'entity:deleting' | 'relationship:creating' | 'relationship:removing'>>(event: E, handler: HookHandler<E>): Unsubscribe;
280
314
  }
@@ -293,6 +327,8 @@ interface DeepMemoryConfig {
293
327
  embedding?: EmbeddingProvider;
294
328
  /** Optional: lock provider for distributed locking */
295
329
  lock?: LockProvider;
330
+ /** Optional: graph traversal provider for native multi-hop queries */
331
+ graphTraversal?: GraphTraversalProvider;
296
332
  /** Required: provenance context identifying the actor */
297
333
  provenance: ProvenanceContext;
298
334
  }
@@ -302,14 +338,15 @@ declare class DeepMemory {
302
338
  private readonly embedding?;
303
339
  /** Reserved for future distributed locking support */
304
340
  readonly lock?: LockProvider;
341
+ private readonly graphTraversalProvider?;
305
342
  private readonly provenance;
306
343
  private readonly globalEventBus;
307
344
  private initialised;
308
345
  constructor(config: DeepMemoryConfig);
309
- /** Initialise the storage provider (call once before use) */
346
+ /** Initialise the storage provider and optional providers (call once before use) */
310
347
  private ensureInitialised;
311
348
  /** Create or migrate the storage schema. Call once at deployment / startup, not per-request. */
312
- ensureSchema(): Promise<void>;
349
+ ensureSchema(): Promise<EnsureSchemaResult>;
313
350
  private validateRepositoryId;
314
351
  /** Create a new memory repository */
315
352
  createRepository(config: RepositoryConfig): Promise<MemoryRepository>;
@@ -321,8 +358,13 @@ declare class DeepMemory {
321
358
  updateRepository(repositoryId: string, updates: RepositoryUpdate): Promise<StoredRepository>;
322
359
  /** Delete a repository */
323
360
  deleteRepository(repositoryId: string): Promise<void>;
361
+ /** Delete all entities and relationships in a repository, preserving the repository and vocabulary */
362
+ deleteAllContents(repositoryId: string): Promise<{
363
+ deletedEntities: number;
364
+ deletedRelationships: number;
365
+ }>;
324
366
  /** Export a repository to a portable archive */
325
- exportRepository(repositoryId: string): Promise<ExportArchive>;
367
+ exportRepository(repositoryId: string, options?: ExportOptions): Promise<ExportArchive>;
326
368
  /** Import a repository from a portable archive */
327
369
  importRepository(archive: ExportArchive, options: ImportOptions): Promise<ImportResult>;
328
370
  /**
@@ -330,7 +372,7 @@ declare class DeepMemory {
330
372
  * Yields: manifest → vocabulary → entity chunks → relationship chunks.
331
373
  * Use for large repositories to avoid loading everything into memory.
332
374
  */
333
- exportRepositoryStream(repositoryId: string): AsyncGenerator<ExportStreamItem>;
375
+ exportRepositoryStream(repositoryId: string, options?: ExportOptions): AsyncGenerator<ExportStreamItem>;
334
376
  /**
335
377
  * Import a repository from a stream of chunks.
336
378
  * Use for large repositories to avoid loading everything into memory.
@@ -350,6 +392,31 @@ declare class DeepMemory {
350
392
  */
351
393
  declare function matchesPropertyFilters(properties: Record<string, unknown>, filters: PropertyFilter[]): boolean;
352
394
 
395
+ interface TraversalCompiler {
396
+ /** The query language this compiler targets. */
397
+ readonly language: 'gremlin' | 'cypher' | 'sql';
398
+ /** Compile a validated TraversalSpec into a native query string. */
399
+ compile(spec: TraversalSpec, vocabulary: MemoryVocabulary): CompiledQuery;
400
+ }
401
+ interface CompiledQuery {
402
+ /** The native query string. */
403
+ query: string;
404
+ /** Parameter bindings (for parameterized queries). */
405
+ params: Record<string, unknown>;
406
+ /** Estimated cost heuristic (fan-out estimation). Provider may override. */
407
+ estimatedFanOut: number;
408
+ }
409
+
410
+ declare class GremlinCompiler implements TraversalCompiler {
411
+ readonly language: "gremlin";
412
+ compile(spec: TraversalSpec, _vocabulary: MemoryVocabulary): CompiledQuery;
413
+ }
414
+
415
+ declare class CypherCompiler implements TraversalCompiler {
416
+ readonly language: "cypher";
417
+ compile(spec: TraversalSpec, _vocabulary: MemoryVocabulary): CompiledQuery;
418
+ }
419
+
353
420
  declare class InMemoryStorageProvider implements StorageProvider {
354
421
  private stores;
355
422
  private getStore;
@@ -359,7 +426,11 @@ declare class InMemoryStorageProvider implements StorageProvider {
359
426
  getRepository(repositoryId: string): Promise<StoredRepository | null>;
360
427
  listRepositories(filter?: RepositoryFilter): Promise<PaginatedResult<StoredRepositorySummary>>;
361
428
  updateRepository(repositoryId: string, updates: RepositoryUpdate): Promise<StoredRepository>;
362
- deleteRepository(repositoryId: string): Promise<void>;
429
+ deleteRepository(repositoryId: string, _onProgress?: DeleteProgressCallback): Promise<void>;
430
+ deleteAllContents(repositoryId: string, _onProgress?: DeleteProgressCallback): Promise<{
431
+ deletedEntities: number;
432
+ deletedRelationships: number;
433
+ }>;
363
434
  getRepositoryStats(repositoryId: string): Promise<RepositoryStats>;
364
435
  getVocabulary(repositoryId: string): Promise<MemoryVocabulary>;
365
436
  saveVocabulary(repositoryId: string, vocabulary: MemoryVocabulary): Promise<void>;
@@ -386,7 +457,7 @@ declare class InMemoryStorageProvider implements StorageProvider {
386
457
  findPaths(repositoryId: string, sourceId: string, targetId: string, options: StoragePathOptions): Promise<StoragePathResult>;
387
458
  getTimeline(repositoryId: string, entityId: string, options: StorageTimelineOptions): Promise<StorageTimelineResult>;
388
459
  exportAll(repositoryId: string): AsyncIterable<ExportChunk>;
389
- importBulk(repositoryId: string, data: ImportChunk[]): Promise<BulkImportResult>;
460
+ importBulk(repositoryId: string, data: ImportChunk[], _options?: BulkImportOptions): Promise<BulkImportResult>;
390
461
  }
391
462
 
392
463
  declare class InMemorySearchProvider implements SearchProvider {
@@ -405,4 +476,4 @@ declare class NoOpEmbeddingProvider implements EmbeddingProvider {
405
476
  modelId(): string;
406
477
  }
407
478
 
408
- export { BulkImportResult, ConceptSearchOptions, CreateEntityInput, CreateRelationshipInput, DeepMemory, type DeepMemoryConfig, DeepMemoryError, type DeepMemoryErrorCode, DeepMemoryEvent, DeepMemoryEventType, DetailLevel, DuplicateEntityError, DuplicateRelationshipError, DuplicateRepositoryError, EmbeddingProvider, EmbeddingProviderRequiredError, Entity, EntityBrief, EntityNotFoundError, EntitySummary, EntityTypeDefinition, EventHandler, EventPayload, ExploreOptions, ExportArchive, ExportChunk, ExportError, ExportStreamItem, FindEntitiesQuery, GovernanceConfig, GovernanceDeniedError, GraphResult, HookResult, ImportChunk, ImportError, ImportOptions, ImportResult, ImportStreamHeader, InMemorySearchProvider, InMemoryStorageProvider, InvalidInputError, LockProvider, MemoryRepository, MemoryVocabulary, Neighbourhood, NoOpEmbeddingProvider, OperationCancelledError, PaginatedResult, PaginationOptions, PathOptions, PathResult, PropertyFilter, Provenance, ProvenanceContext, ProviderError, ReembedResult, Relationship, RelationshipConstraintError, RelationshipNotFoundError, RelationshipQueryOptions, RelationshipSummary, RepositoryConfig, RepositoryFilter, RepositoryNotFoundError, RepositoryStats, RepositorySummary, RepositoryUpdate, ResolvedVocabulary, ScoredEntity, SearchHit, SearchOptions, SearchProvider, SearchableEntity, StorageExploreOptions, StorageFindQuery, StorageNeighbourhood, StoragePathOptions, StoragePathResult, StorageProvider, StorageRepositoryConfig, StorageTimelineOptions, StorageTimelineResult, StoredEntity, StoredEntityUpdate, StoredRelationship, StoredRepository, StoredRepositorySummary, TimelineOptions, TimelineResult, Unsubscribe, UpdateEntityInput, VocabularyChangeRecord, VocabularyProposal, VocabularyProposalResult, VocabularyValidationError, generateId, isValidUuid, matchesPropertyFilters };
479
+ export { BulkImportOptions, BulkImportResult, type CompiledQuery, ConceptSearchOptions, CreateEntityInput, CreateRelationshipInput, CypherCompiler, DeepMemory, type DeepMemoryConfig, DeepMemoryError, type DeepMemoryErrorCode, DeepMemoryEvent, DeepMemoryEventType, DeleteProgressCallback, DetailLevel, DuplicateEntityError, DuplicateRelationshipError, DuplicateRepositoryError, EmbeddingProvider, EmbeddingProviderRequiredError, EnsureSchemaResult, Entity, EntityBrief, EntityNotFoundError, EntitySummary, EntityTypeDefinition, EventHandler, EventPayload, ExploreOptions, ExportArchive, ExportChunk, ExportError, ExportOptions, ExportStreamItem, FindEntitiesQuery, GovernanceConfig, GovernanceDeniedError, GraphResult, GraphTraversalProvider, GraphTraversalProviderRequiredError, GremlinCompiler, HookResult, ImportChunk, ImportError, ImportOptions, ImportResult, ImportStreamHeader, InMemorySearchProvider, InMemoryStorageProvider, InvalidInputError, LockProvider, MemoryRepository, MemoryVocabulary, Neighbourhood, NoOpEmbeddingProvider, OperationCancelledError, PaginatedResult, PaginationOptions, PathOptions, PathResult, PropertyFilter, Provenance, ProvenanceContext, ProviderError, ReembedResult, Relationship, RelationshipConstraintError, RelationshipNotFoundError, RelationshipQueryOptions, RelationshipSummary, RepositoryConfig, RepositoryFilter, RepositoryNotFoundError, RepositoryStats, RepositorySummary, RepositoryUpdate, ResolvedVocabulary, ScoredEntity, SearchHit, SearchOptions, SearchProvider, SearchableEntity, StorageExploreOptions, StorageFindQuery, StorageNeighbourhood, StoragePathOptions, StoragePathResult, StorageProvider, StorageRepositoryConfig, StorageTimelineOptions, StorageTimelineResult, StoredEntity, StoredEntityUpdate, StoredRelationship, StoredRepository, StoredRepositorySummary, TimelineOptions, TimelineResult, type TraversalCompiler, TraversalResult, TraversalSpec, TraversalTimeoutError, TraversalValidationError, TraversalVocabularyError, Unsubscribe, UpdateEntityInput, VocabularyChangeRecord, VocabularyProposal, VocabularyProposalResult, VocabularyValidationError, generateId, isValidUuid, matchesPropertyFilters };
package/dist/index.d.ts CHANGED
@@ -1,12 +1,14 @@
1
- import { G as GovernanceConfig, M as MemoryVocabulary, q as ResolvedVocabulary, C as CreateEntityInput, U as UpdateEntityInput, r as CreateRelationshipInput, s as EntityTypeDefinition, t as VocabularyProposal, u as VocabularyProposalResult, v as ProvenanceContext, w as Provenance, x as Entity, D as DetailLevel, y as EntitySummary, z as EntityBrief, F as FindEntitiesQuery, P as PaginatedResult, A as ReembedResult, H as Relationship, J as PropertyFilter, K as RelationshipSummary, L as GraphResult, N as ExploreOptions, O as Neighbourhood, Q as PathOptions, T as PathResult, W as ConceptSearchOptions, X as ScoredEntity, Y as TimelineOptions, Z as TimelineResult, d as RepositoryStats, _ as RepositoryConfig, R as RepositoryFilter, $ as RepositorySummary, c as RepositoryUpdate, a as StoredRepository, a0 as ExportArchive, a1 as ImportOptions, a2 as ImportResult, a3 as ExportStreamItem, a4 as ImportStreamHeader, I as ImportChunk, S as StorageRepositoryConfig, b as StoredRepositorySummary, e as PaginationOptions, V as VocabularyChangeRecord, f as StoredEntity, g as StoredEntityUpdate, h as StorageFindQuery, i as StoredRelationship, j as RelationshipQueryOptions, k as StorageExploreOptions, l as StorageNeighbourhood, m as StoragePathOptions, n as StoragePathResult, o as StorageTimelineOptions, p as StorageTimelineResult, E as ExportChunk, B as BulkImportResult, a5 as SearchOptions, a6 as SearchHit } from './portability-DdlNYXGX.js';
2
- export { a7 as EnrichedRelationship, a8 as EntityMap, a9 as EntityTypeInput, aa as ExportManifest, ab as GetEntitiesOptions, ac as GetEntityOptions, ad as GovernanceMode, ae as ImportWarning, af as NeighbourhoodCentre, ag as NeighbourhoodGroup, ah as NeighbourhoodLayer, ai as Path, aj as PropertySchema, ak as PropertyType, al as ProvenanceFilter, am as RelationshipDirection, an as RelationshipTypeDefinition, ao as RelationshipTypeInput, ap as RepositoryMetadata, aq as StorageNeighbourhoodGroup, ar as StorageNeighbourhoodLayer, as as StoragePath, at as StorageTimelineEvent, au as TimelineEntityRef, av as TimelineEvent, aw as TimelineRelationshipDetail, ax as VocabularyInput } from './portability-DdlNYXGX.js';
1
+ import { G as GovernanceConfig, M as MemoryVocabulary, x as ResolvedVocabulary, C as CreateEntityInput, U as UpdateEntityInput, y as CreateRelationshipInput, z as EntityTypeDefinition, A as VocabularyProposal, F as VocabularyProposalResult, H as ProvenanceContext, J as Provenance, E as Entity, D as DetailLevel, a as EntitySummary, b as EntityBrief, K as FindEntitiesQuery, e as PaginatedResult, L as ReembedResult, N as Relationship, P as PropertyFilter, R as RelationshipSummary, O as GraphResult, Q as ExploreOptions, T as Neighbourhood, W as PathOptions, X as PathResult, Y as ConceptSearchOptions, Z as ScoredEntity, _ as TimelineOptions, $ as TimelineResult, i as RepositoryStats, a0 as RepositoryConfig, d as RepositoryFilter, a1 as RepositorySummary, g as RepositoryUpdate, c as StoredRepository, a2 as ExportOptions, a3 as ExportArchive, a4 as ImportOptions, a5 as ImportResult, a6 as ExportStreamItem, a7 as ImportStreamHeader, I as ImportChunk, S as StorageRepositoryConfig, f as StoredRepositorySummary, h as DeleteProgressCallback, j as PaginationOptions, V as VocabularyChangeRecord, k as StoredEntity, l as StoredEntityUpdate, m as StorageFindQuery, n as StoredRelationship, o as RelationshipQueryOptions, p as StorageExploreOptions, q as StorageNeighbourhood, r as StoragePathOptions, s as StoragePathResult, t as StorageTimelineOptions, u as StorageTimelineResult, v as ExportChunk, B as BulkImportOptions, w as BulkImportResult, a8 as SearchOptions, a9 as SearchHit } from './portability-1KBMVBGJ.js';
2
+ export { aa as EnrichedRelationship, ab as EntityMap, ac as EntityTypeInput, ad as ExportLegalMetadata, ae as ExportManifest, af as ExportPipelineMetadata, ag as GetEntitiesOptions, ah as GetEntityOptions, ai as GovernanceMode, aj as ImportWarning, ak as NeighbourhoodCentre, al as NeighbourhoodGroup, am as NeighbourhoodLayer, an as Path, ao as PropertySchema, ap as PropertyType, aq as ProvenanceFilter, ar as RelationshipDirection, as as RelationshipTypeDefinition, at as RelationshipTypeInput, au as RepositoryMetadata, av as StorageNeighbourhoodGroup, aw as StorageNeighbourhoodLayer, ax as StoragePath, ay as StorageTimelineEvent, az as TimelineEntityRef, aA as TimelineEvent, aB as TimelineRelationshipDetail, aC as VocabularyInput } from './portability-1KBMVBGJ.js';
3
3
  import { DeepMemoryEventType, EventHandler, Unsubscribe, DeepMemoryEvent, HookResult, EventPayload } from './types/index.js';
4
- import { S as StorageProvider } from './StorageProvider-CJjz8uBY.js';
5
- import { EmbeddingProvider, SearchProvider, LockProvider, SearchableEntity } from './providers/index.js';
6
- export { LockHandle, LockOptions } from './providers/index.js';
4
+ import { T as TraversalSpec, a as TraversalResult } from './traversal-B4SUysM-.js';
5
+ export { Q as QueryMetadata, b as TraversalAggregation, c as TraversalPath, d as TraversalProjection, e as TraversalRelationship, f as TraversalReturnMode, g as TraversalStart, h as TraversalStep } from './traversal-B4SUysM-.js';
6
+ import { S as StorageProvider, E as EnsureSchemaResult } from './StorageProvider-DqW-zpd0.js';
7
+ import { EmbeddingProvider, SearchProvider, GraphTraversalProvider, LockProvider, SearchableEntity } from './providers/index.js';
8
+ export { GraphTraversalCapabilities, LockHandle, LockOptions } from './providers/index.js';
7
9
 
8
10
  /** Error codes for all Deep Memory errors */
9
- type DeepMemoryErrorCode = 'INVALID_INPUT' | 'ENTITY_NOT_FOUND' | 'ENTITY_ALREADY_EXISTS' | 'RELATIONSHIP_NOT_FOUND' | 'RELATIONSHIP_ALREADY_EXISTS' | 'REPOSITORY_NOT_FOUND' | 'REPOSITORY_ALREADY_EXISTS' | 'VOCABULARY_VALIDATION_FAILED' | 'RELATIONSHIP_CONSTRAINT_FAILED' | 'GOVERNANCE_DENIED' | 'OPERATION_CANCELLED' | 'EMBEDDING_PROVIDER_REQUIRED' | 'IMPORT_ERROR' | 'EXPORT_ERROR' | 'PROVIDER_ERROR';
11
+ type DeepMemoryErrorCode = 'INVALID_INPUT' | 'ENTITY_NOT_FOUND' | 'ENTITY_ALREADY_EXISTS' | 'RELATIONSHIP_NOT_FOUND' | 'RELATIONSHIP_ALREADY_EXISTS' | 'REPOSITORY_NOT_FOUND' | 'REPOSITORY_ALREADY_EXISTS' | 'VOCABULARY_VALIDATION_FAILED' | 'RELATIONSHIP_CONSTRAINT_FAILED' | 'GOVERNANCE_DENIED' | 'OPERATION_CANCELLED' | 'EMBEDDING_PROVIDER_REQUIRED' | 'IMPORT_ERROR' | 'EXPORT_ERROR' | 'PROVIDER_ERROR' | 'GRAPH_TRAVERSAL_PROVIDER_REQUIRED' | 'TRAVERSAL_VALIDATION_FAILED' | 'TRAVERSAL_VOCABULARY_ERROR' | 'TRAVERSAL_TIMEOUT';
10
12
  /** Base error class for all Deep Memory errors */
11
13
  declare class DeepMemoryError extends Error {
12
14
  readonly code: DeepMemoryErrorCode;
@@ -96,6 +98,25 @@ declare class ExportError extends DeepMemoryError {
96
98
  declare class ProviderError extends DeepMemoryError {
97
99
  constructor(message: string, suggestion?: string);
98
100
  }
101
+ /** Thrown when executeNativeQuery() is called but no GraphTraversalProvider is registered. */
102
+ declare class GraphTraversalProviderRequiredError extends DeepMemoryError {
103
+ constructor();
104
+ }
105
+ /** Thrown when a TraversalSpec is structurally invalid. */
106
+ declare class TraversalValidationError extends DeepMemoryError {
107
+ readonly errors: string[];
108
+ constructor(errors: string[]);
109
+ }
110
+ /** Thrown when a TraversalSpec references relationship/entity types not in the vocabulary. */
111
+ declare class TraversalVocabularyError extends DeepMemoryError {
112
+ readonly unknownTypes: string[];
113
+ constructor(unknownTypes: string[]);
114
+ }
115
+ /** Thrown when a native query times out. */
116
+ declare class TraversalTimeoutError extends DeepMemoryError {
117
+ readonly timeoutMs: number;
118
+ constructor(timeoutMs: number);
119
+ }
99
120
 
100
121
  /** A single validation error with optional suggestion */
101
122
  interface ValidationError {
@@ -210,6 +231,7 @@ interface MemoryRepositoryConfig {
210
231
  storage: StorageProvider;
211
232
  search?: SearchProvider;
212
233
  embedding?: EmbeddingProvider;
234
+ graphTraversal?: GraphTraversalProvider;
213
235
  vocabularyEngine: VocabularyEngine;
214
236
  provenanceTracker: ProvenanceTracker;
215
237
  eventBus: EventBus;
@@ -230,7 +252,7 @@ declare class MemoryRepository {
230
252
  proposeVocabularyChange(proposal: VocabularyProposal): Promise<VocabularyProposalResult>;
231
253
  /** @deprecated Use proposeVocabularyChange instead */
232
254
  proposeVocabularyExtension(proposal: VocabularyProposal): Promise<VocabularyProposalResult>;
233
- createEntity(input: CreateEntityInput): Promise<Entity>;
255
+ createEntities(inputs: CreateEntityInput[]): Promise<Entity[]>;
234
256
  updateEntity(entityId: string, updates: UpdateEntityInput): Promise<Entity>;
235
257
  getEntity(entityId: string, detailLevel?: DetailLevel): Promise<Entity | EntitySummary | EntityBrief | null>;
236
258
  getBySlug(slug: string, detailLevel?: DetailLevel): Promise<Entity | EntitySummary | EntityBrief | null>;
@@ -253,7 +275,7 @@ declare class MemoryRepository {
253
275
  /** Milliseconds to wait between batches for rate limiting (default 0) */
254
276
  delayBetweenBatchesMs?: number;
255
277
  }): Promise<ReembedResult>;
256
- createRelationship(input: CreateRelationshipInput): Promise<Relationship>;
278
+ createRelationships(inputs: CreateRelationshipInput[]): Promise<Relationship[]>;
257
279
  removeRelationship(relationshipId: string): Promise<void>;
258
280
  getRelationships(entityId: string, options?: {
259
281
  relationshipTypes?: string[];
@@ -272,9 +294,21 @@ declare class MemoryRepository {
272
294
  }): Promise<GraphResult>;
273
295
  exploreNeighbourhood(entityId: string, options?: ExploreOptions): Promise<Neighbourhood>;
274
296
  findPaths(sourceId: string, targetId: string, options?: PathOptions): Promise<PathResult>;
297
+ traverse(spec: TraversalSpec): Promise<TraversalResult>;
298
+ executeNativeQuery(query: string, params?: Record<string, unknown>): Promise<TraversalResult>;
275
299
  searchByConcept(query: string, options?: ConceptSearchOptions): Promise<PaginatedResult<ScoredEntity>>;
276
300
  getTimeline(entityId: string, options?: TimelineOptions): Promise<TimelineResult>;
277
301
  getStats(): Promise<RepositoryStats>;
302
+ /** Delete all entities and relationships in this repository, preserving the repository and vocabulary */
303
+ deleteAllContents(): Promise<{
304
+ deletedEntities: number;
305
+ deletedRelationships: number;
306
+ }>;
307
+ /**
308
+ * Returns a static markdown guide describing the recommended query strategy
309
+ * for AI agents and other consumers of the repository.
310
+ */
311
+ getQueryGuide(): string;
278
312
  on<E extends DeepMemoryEventType>(event: E, handler: EventHandler<E>): Unsubscribe;
279
313
  onHook<E extends Extract<DeepMemoryEventType, 'entity:creating' | 'entity:updating' | 'entity:deleting' | 'relationship:creating' | 'relationship:removing'>>(event: E, handler: HookHandler<E>): Unsubscribe;
280
314
  }
@@ -293,6 +327,8 @@ interface DeepMemoryConfig {
293
327
  embedding?: EmbeddingProvider;
294
328
  /** Optional: lock provider for distributed locking */
295
329
  lock?: LockProvider;
330
+ /** Optional: graph traversal provider for native multi-hop queries */
331
+ graphTraversal?: GraphTraversalProvider;
296
332
  /** Required: provenance context identifying the actor */
297
333
  provenance: ProvenanceContext;
298
334
  }
@@ -302,14 +338,15 @@ declare class DeepMemory {
302
338
  private readonly embedding?;
303
339
  /** Reserved for future distributed locking support */
304
340
  readonly lock?: LockProvider;
341
+ private readonly graphTraversalProvider?;
305
342
  private readonly provenance;
306
343
  private readonly globalEventBus;
307
344
  private initialised;
308
345
  constructor(config: DeepMemoryConfig);
309
- /** Initialise the storage provider (call once before use) */
346
+ /** Initialise the storage provider and optional providers (call once before use) */
310
347
  private ensureInitialised;
311
348
  /** Create or migrate the storage schema. Call once at deployment / startup, not per-request. */
312
- ensureSchema(): Promise<void>;
349
+ ensureSchema(): Promise<EnsureSchemaResult>;
313
350
  private validateRepositoryId;
314
351
  /** Create a new memory repository */
315
352
  createRepository(config: RepositoryConfig): Promise<MemoryRepository>;
@@ -321,8 +358,13 @@ declare class DeepMemory {
321
358
  updateRepository(repositoryId: string, updates: RepositoryUpdate): Promise<StoredRepository>;
322
359
  /** Delete a repository */
323
360
  deleteRepository(repositoryId: string): Promise<void>;
361
+ /** Delete all entities and relationships in a repository, preserving the repository and vocabulary */
362
+ deleteAllContents(repositoryId: string): Promise<{
363
+ deletedEntities: number;
364
+ deletedRelationships: number;
365
+ }>;
324
366
  /** Export a repository to a portable archive */
325
- exportRepository(repositoryId: string): Promise<ExportArchive>;
367
+ exportRepository(repositoryId: string, options?: ExportOptions): Promise<ExportArchive>;
326
368
  /** Import a repository from a portable archive */
327
369
  importRepository(archive: ExportArchive, options: ImportOptions): Promise<ImportResult>;
328
370
  /**
@@ -330,7 +372,7 @@ declare class DeepMemory {
330
372
  * Yields: manifest → vocabulary → entity chunks → relationship chunks.
331
373
  * Use for large repositories to avoid loading everything into memory.
332
374
  */
333
- exportRepositoryStream(repositoryId: string): AsyncGenerator<ExportStreamItem>;
375
+ exportRepositoryStream(repositoryId: string, options?: ExportOptions): AsyncGenerator<ExportStreamItem>;
334
376
  /**
335
377
  * Import a repository from a stream of chunks.
336
378
  * Use for large repositories to avoid loading everything into memory.
@@ -350,6 +392,31 @@ declare class DeepMemory {
350
392
  */
351
393
  declare function matchesPropertyFilters(properties: Record<string, unknown>, filters: PropertyFilter[]): boolean;
352
394
 
395
+ interface TraversalCompiler {
396
+ /** The query language this compiler targets. */
397
+ readonly language: 'gremlin' | 'cypher' | 'sql';
398
+ /** Compile a validated TraversalSpec into a native query string. */
399
+ compile(spec: TraversalSpec, vocabulary: MemoryVocabulary): CompiledQuery;
400
+ }
401
+ interface CompiledQuery {
402
+ /** The native query string. */
403
+ query: string;
404
+ /** Parameter bindings (for parameterized queries). */
405
+ params: Record<string, unknown>;
406
+ /** Estimated cost heuristic (fan-out estimation). Provider may override. */
407
+ estimatedFanOut: number;
408
+ }
409
+
410
+ declare class GremlinCompiler implements TraversalCompiler {
411
+ readonly language: "gremlin";
412
+ compile(spec: TraversalSpec, _vocabulary: MemoryVocabulary): CompiledQuery;
413
+ }
414
+
415
+ declare class CypherCompiler implements TraversalCompiler {
416
+ readonly language: "cypher";
417
+ compile(spec: TraversalSpec, _vocabulary: MemoryVocabulary): CompiledQuery;
418
+ }
419
+
353
420
  declare class InMemoryStorageProvider implements StorageProvider {
354
421
  private stores;
355
422
  private getStore;
@@ -359,7 +426,11 @@ declare class InMemoryStorageProvider implements StorageProvider {
359
426
  getRepository(repositoryId: string): Promise<StoredRepository | null>;
360
427
  listRepositories(filter?: RepositoryFilter): Promise<PaginatedResult<StoredRepositorySummary>>;
361
428
  updateRepository(repositoryId: string, updates: RepositoryUpdate): Promise<StoredRepository>;
362
- deleteRepository(repositoryId: string): Promise<void>;
429
+ deleteRepository(repositoryId: string, _onProgress?: DeleteProgressCallback): Promise<void>;
430
+ deleteAllContents(repositoryId: string, _onProgress?: DeleteProgressCallback): Promise<{
431
+ deletedEntities: number;
432
+ deletedRelationships: number;
433
+ }>;
363
434
  getRepositoryStats(repositoryId: string): Promise<RepositoryStats>;
364
435
  getVocabulary(repositoryId: string): Promise<MemoryVocabulary>;
365
436
  saveVocabulary(repositoryId: string, vocabulary: MemoryVocabulary): Promise<void>;
@@ -386,7 +457,7 @@ declare class InMemoryStorageProvider implements StorageProvider {
386
457
  findPaths(repositoryId: string, sourceId: string, targetId: string, options: StoragePathOptions): Promise<StoragePathResult>;
387
458
  getTimeline(repositoryId: string, entityId: string, options: StorageTimelineOptions): Promise<StorageTimelineResult>;
388
459
  exportAll(repositoryId: string): AsyncIterable<ExportChunk>;
389
- importBulk(repositoryId: string, data: ImportChunk[]): Promise<BulkImportResult>;
460
+ importBulk(repositoryId: string, data: ImportChunk[], _options?: BulkImportOptions): Promise<BulkImportResult>;
390
461
  }
391
462
 
392
463
  declare class InMemorySearchProvider implements SearchProvider {
@@ -405,4 +476,4 @@ declare class NoOpEmbeddingProvider implements EmbeddingProvider {
405
476
  modelId(): string;
406
477
  }
407
478
 
408
- export { BulkImportResult, ConceptSearchOptions, CreateEntityInput, CreateRelationshipInput, DeepMemory, type DeepMemoryConfig, DeepMemoryError, type DeepMemoryErrorCode, DeepMemoryEvent, DeepMemoryEventType, DetailLevel, DuplicateEntityError, DuplicateRelationshipError, DuplicateRepositoryError, EmbeddingProvider, EmbeddingProviderRequiredError, Entity, EntityBrief, EntityNotFoundError, EntitySummary, EntityTypeDefinition, EventHandler, EventPayload, ExploreOptions, ExportArchive, ExportChunk, ExportError, ExportStreamItem, FindEntitiesQuery, GovernanceConfig, GovernanceDeniedError, GraphResult, HookResult, ImportChunk, ImportError, ImportOptions, ImportResult, ImportStreamHeader, InMemorySearchProvider, InMemoryStorageProvider, InvalidInputError, LockProvider, MemoryRepository, MemoryVocabulary, Neighbourhood, NoOpEmbeddingProvider, OperationCancelledError, PaginatedResult, PaginationOptions, PathOptions, PathResult, PropertyFilter, Provenance, ProvenanceContext, ProviderError, ReembedResult, Relationship, RelationshipConstraintError, RelationshipNotFoundError, RelationshipQueryOptions, RelationshipSummary, RepositoryConfig, RepositoryFilter, RepositoryNotFoundError, RepositoryStats, RepositorySummary, RepositoryUpdate, ResolvedVocabulary, ScoredEntity, SearchHit, SearchOptions, SearchProvider, SearchableEntity, StorageExploreOptions, StorageFindQuery, StorageNeighbourhood, StoragePathOptions, StoragePathResult, StorageProvider, StorageRepositoryConfig, StorageTimelineOptions, StorageTimelineResult, StoredEntity, StoredEntityUpdate, StoredRelationship, StoredRepository, StoredRepositorySummary, TimelineOptions, TimelineResult, Unsubscribe, UpdateEntityInput, VocabularyChangeRecord, VocabularyProposal, VocabularyProposalResult, VocabularyValidationError, generateId, isValidUuid, matchesPropertyFilters };
479
+ export { BulkImportOptions, BulkImportResult, type CompiledQuery, ConceptSearchOptions, CreateEntityInput, CreateRelationshipInput, CypherCompiler, DeepMemory, type DeepMemoryConfig, DeepMemoryError, type DeepMemoryErrorCode, DeepMemoryEvent, DeepMemoryEventType, DeleteProgressCallback, DetailLevel, DuplicateEntityError, DuplicateRelationshipError, DuplicateRepositoryError, EmbeddingProvider, EmbeddingProviderRequiredError, EnsureSchemaResult, Entity, EntityBrief, EntityNotFoundError, EntitySummary, EntityTypeDefinition, EventHandler, EventPayload, ExploreOptions, ExportArchive, ExportChunk, ExportError, ExportOptions, ExportStreamItem, FindEntitiesQuery, GovernanceConfig, GovernanceDeniedError, GraphResult, GraphTraversalProvider, GraphTraversalProviderRequiredError, GremlinCompiler, HookResult, ImportChunk, ImportError, ImportOptions, ImportResult, ImportStreamHeader, InMemorySearchProvider, InMemoryStorageProvider, InvalidInputError, LockProvider, MemoryRepository, MemoryVocabulary, Neighbourhood, NoOpEmbeddingProvider, OperationCancelledError, PaginatedResult, PaginationOptions, PathOptions, PathResult, PropertyFilter, Provenance, ProvenanceContext, ProviderError, ReembedResult, Relationship, RelationshipConstraintError, RelationshipNotFoundError, RelationshipQueryOptions, RelationshipSummary, RepositoryConfig, RepositoryFilter, RepositoryNotFoundError, RepositoryStats, RepositorySummary, RepositoryUpdate, ResolvedVocabulary, ScoredEntity, SearchHit, SearchOptions, SearchProvider, SearchableEntity, StorageExploreOptions, StorageFindQuery, StorageNeighbourhood, StoragePathOptions, StoragePathResult, StorageProvider, StorageRepositoryConfig, StorageTimelineOptions, StorageTimelineResult, StoredEntity, StoredEntityUpdate, StoredRelationship, StoredRepository, StoredRepositorySummary, TimelineOptions, TimelineResult, type TraversalCompiler, TraversalResult, TraversalSpec, TraversalTimeoutError, TraversalValidationError, TraversalVocabularyError, Unsubscribe, UpdateEntityInput, VocabularyChangeRecord, VocabularyProposal, VocabularyProposalResult, VocabularyValidationError, generateId, isValidUuid, matchesPropertyFilters };