@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.
- package/LICENSE +190 -0
- package/README.md +224 -0
- package/dist/StorageProvider-CJjz8uBY.d.ts +56 -0
- package/dist/StorageProvider-CkFjdboX.d.cts +56 -0
- package/dist/index.cjs +4054 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +408 -0
- package/dist/index.d.ts +408 -0
- package/dist/index.js +4004 -0
- package/dist/index.js.map +1 -0
- package/dist/portability-DdlNYXGX.d.cts +897 -0
- package/dist/portability-DdlNYXGX.d.ts +897 -0
- package/dist/providers/index.cjs +19 -0
- package/dist/providers/index.cjs.map +1 -0
- package/dist/providers/index.d.cts +75 -0
- package/dist/providers/index.d.ts +75 -0
- package/dist/providers/index.js +1 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/testing/conformance.cjs +357 -0
- package/dist/testing/conformance.cjs.map +1 -0
- package/dist/testing/conformance.d.cts +12 -0
- package/dist/testing/conformance.d.ts +12 -0
- package/dist/testing/conformance.js +332 -0
- package/dist/testing/conformance.js.map +1 -0
- package/dist/types/index.cjs +19 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.d.cts +121 -0
- package/dist/types/index.d.ts +121 -0
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +96 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,408 @@
|
|
|
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';
|
|
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';
|
|
7
|
+
|
|
8
|
+
/** 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';
|
|
10
|
+
/** Base error class for all Deep Memory errors */
|
|
11
|
+
declare class DeepMemoryError extends Error {
|
|
12
|
+
readonly code: DeepMemoryErrorCode;
|
|
13
|
+
readonly suggestion?: string;
|
|
14
|
+
constructor(code: DeepMemoryErrorCode, message: string, suggestion?: string);
|
|
15
|
+
}
|
|
16
|
+
/** Input validation failed (e.g. invalid ID format) */
|
|
17
|
+
declare class InvalidInputError extends DeepMemoryError {
|
|
18
|
+
readonly field: string;
|
|
19
|
+
constructor(field: string, message: string, suggestion?: string);
|
|
20
|
+
}
|
|
21
|
+
/** Entity was not found in the repository */
|
|
22
|
+
declare class EntityNotFoundError extends DeepMemoryError {
|
|
23
|
+
readonly id: string;
|
|
24
|
+
readonly slug?: string;
|
|
25
|
+
constructor(idOrSlug: string, slug?: string);
|
|
26
|
+
}
|
|
27
|
+
/** Attempted to create an entity with an ID that already exists */
|
|
28
|
+
declare class DuplicateEntityError extends DeepMemoryError {
|
|
29
|
+
readonly id: string;
|
|
30
|
+
constructor(id: string);
|
|
31
|
+
}
|
|
32
|
+
/** Relationship was not found */
|
|
33
|
+
declare class RelationshipNotFoundError extends DeepMemoryError {
|
|
34
|
+
readonly relationshipId: string;
|
|
35
|
+
constructor(relationshipId: string);
|
|
36
|
+
}
|
|
37
|
+
/** Attempted to create a relationship with an ID that already exists */
|
|
38
|
+
declare class DuplicateRelationshipError extends DeepMemoryError {
|
|
39
|
+
readonly relationshipId: string;
|
|
40
|
+
constructor(relationshipId: string);
|
|
41
|
+
}
|
|
42
|
+
/** Repository was not found */
|
|
43
|
+
declare class RepositoryNotFoundError extends DeepMemoryError {
|
|
44
|
+
readonly repositoryId: string;
|
|
45
|
+
constructor(repositoryId: string);
|
|
46
|
+
}
|
|
47
|
+
/** Attempted to create a repository with an ID that already exists */
|
|
48
|
+
declare class DuplicateRepositoryError extends DeepMemoryError {
|
|
49
|
+
readonly repositoryId: string;
|
|
50
|
+
constructor(repositoryId: string);
|
|
51
|
+
}
|
|
52
|
+
/** Entity or relationship failed vocabulary validation */
|
|
53
|
+
declare class VocabularyValidationError extends DeepMemoryError {
|
|
54
|
+
readonly errors: Array<{
|
|
55
|
+
field: string;
|
|
56
|
+
message: string;
|
|
57
|
+
suggestion?: string;
|
|
58
|
+
}>;
|
|
59
|
+
constructor(errors: Array<{
|
|
60
|
+
field: string;
|
|
61
|
+
message: string;
|
|
62
|
+
suggestion?: string;
|
|
63
|
+
}>);
|
|
64
|
+
}
|
|
65
|
+
/** Relationship source/target entity types violate vocabulary constraints */
|
|
66
|
+
declare class RelationshipConstraintError extends DeepMemoryError {
|
|
67
|
+
readonly relationshipType: string;
|
|
68
|
+
readonly sourceType?: string;
|
|
69
|
+
readonly targetType?: string;
|
|
70
|
+
constructor(relationshipType: string, message: string, sourceType?: string, targetType?: string);
|
|
71
|
+
}
|
|
72
|
+
/** Governance rules denied the operation */
|
|
73
|
+
declare class GovernanceDeniedError extends DeepMemoryError {
|
|
74
|
+
readonly governanceMode: string;
|
|
75
|
+
constructor(governanceMode: string, reason: string);
|
|
76
|
+
}
|
|
77
|
+
/** A pre-mutation hook cancelled the operation */
|
|
78
|
+
declare class OperationCancelledError extends DeepMemoryError {
|
|
79
|
+
readonly operation: string;
|
|
80
|
+
readonly reason: string;
|
|
81
|
+
constructor(operation: string, reason: string);
|
|
82
|
+
}
|
|
83
|
+
/** Semantic search was attempted without an embedding provider */
|
|
84
|
+
declare class EmbeddingProviderRequiredError extends DeepMemoryError {
|
|
85
|
+
constructor();
|
|
86
|
+
}
|
|
87
|
+
/** Error during import operations */
|
|
88
|
+
declare class ImportError extends DeepMemoryError {
|
|
89
|
+
constructor(message: string, suggestion?: string);
|
|
90
|
+
}
|
|
91
|
+
/** Error during export operations */
|
|
92
|
+
declare class ExportError extends DeepMemoryError {
|
|
93
|
+
constructor(message: string, suggestion?: string);
|
|
94
|
+
}
|
|
95
|
+
/** Generic provider-level error */
|
|
96
|
+
declare class ProviderError extends DeepMemoryError {
|
|
97
|
+
constructor(message: string, suggestion?: string);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** A single validation error with optional suggestion */
|
|
101
|
+
interface ValidationError {
|
|
102
|
+
field: string;
|
|
103
|
+
message: string;
|
|
104
|
+
suggestion?: string;
|
|
105
|
+
}
|
|
106
|
+
/** Result of a validation check */
|
|
107
|
+
interface ValidationResult {
|
|
108
|
+
valid: boolean;
|
|
109
|
+
errors: ValidationError[];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
interface VocabularyEngineConfig {
|
|
113
|
+
repositoryId: string;
|
|
114
|
+
storageProvider: StorageProvider;
|
|
115
|
+
governanceConfig: GovernanceConfig;
|
|
116
|
+
embeddingProvider?: EmbeddingProvider;
|
|
117
|
+
/** Similarity threshold for deduplication (default 0.85) */
|
|
118
|
+
deduplicationThreshold?: number;
|
|
119
|
+
}
|
|
120
|
+
declare class VocabularyEngine {
|
|
121
|
+
private readonly repositoryId;
|
|
122
|
+
private readonly storage;
|
|
123
|
+
private readonly governanceConfig;
|
|
124
|
+
private readonly deduplicator;
|
|
125
|
+
/** Cached vocabulary — invalidated on mutation */
|
|
126
|
+
private cachedVocabulary;
|
|
127
|
+
constructor(config: VocabularyEngineConfig);
|
|
128
|
+
/** Get the governance configuration for this repository */
|
|
129
|
+
getGovernanceConfig(): GovernanceConfig;
|
|
130
|
+
/** Get the current vocabulary from storage (cached) */
|
|
131
|
+
getVocabulary(): Promise<MemoryVocabulary>;
|
|
132
|
+
/** Get the resolved vocabulary with governance info */
|
|
133
|
+
getResolvedVocabulary(): Promise<ResolvedVocabulary>;
|
|
134
|
+
/** Invalidate the cached vocabulary (call after external mutations) */
|
|
135
|
+
invalidateCache(): void;
|
|
136
|
+
/** Validate an entity creation input against the vocabulary */
|
|
137
|
+
validateEntity(input: CreateEntityInput): Promise<ValidationResult>;
|
|
138
|
+
/** Validate an entity update input against the vocabulary */
|
|
139
|
+
validateEntityUpdate(input: UpdateEntityInput, entityType: string): Promise<ValidationResult>;
|
|
140
|
+
/** Validate a relationship creation input against the vocabulary */
|
|
141
|
+
validateRelationship(input: CreateRelationshipInput, sourceEntityType: string, targetEntityType: string): Promise<ValidationResult>;
|
|
142
|
+
/** Get an entity type definition from the vocabulary */
|
|
143
|
+
getEntityTypeDef(entityType: string): Promise<EntityTypeDefinition | null>;
|
|
144
|
+
/**
|
|
145
|
+
* Propose a vocabulary change (add, edit, or delete).
|
|
146
|
+
* Runs deduplication for add proposals, then governance rules.
|
|
147
|
+
* For delete proposals, cascades data deletion if approved.
|
|
148
|
+
*/
|
|
149
|
+
proposeChange(proposal: VocabularyProposal, proposedBy: string): Promise<VocabularyProposalResult>;
|
|
150
|
+
/** @deprecated Use proposeChange instead */
|
|
151
|
+
proposeExtension(proposal: VocabularyProposal, proposedBy: string): Promise<VocabularyProposalResult>;
|
|
152
|
+
/** Cascade-delete all data for a deleted vocabulary type */
|
|
153
|
+
private cascadeDeleteData;
|
|
154
|
+
private getExistingTypesForProposal;
|
|
155
|
+
private getProposedTypeName;
|
|
156
|
+
private getProposedDescription;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Stamps provenance metadata on entities and relationships.
|
|
161
|
+
* The storage provider never needs to worry about provenance —
|
|
162
|
+
* it just stores what it receives from the tracker.
|
|
163
|
+
*/
|
|
164
|
+
declare class ProvenanceTracker {
|
|
165
|
+
private context;
|
|
166
|
+
constructor(context: ProvenanceContext);
|
|
167
|
+
/** Update the active provenance context (e.g., different conversation) */
|
|
168
|
+
updateContext(newContext: Partial<ProvenanceContext>): void;
|
|
169
|
+
/** Get the current provenance context */
|
|
170
|
+
getContext(): ProvenanceContext;
|
|
171
|
+
/** Stamp a newly created entity or relationship with full provenance */
|
|
172
|
+
stampCreate(): Provenance;
|
|
173
|
+
/** Stamp an updated entity or relationship — preserves creation fields, updates modified fields */
|
|
174
|
+
stampUpdate(existing: Provenance): Provenance;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** Pre-mutation event types (those ending in "ing") */
|
|
178
|
+
type PreMutationEvent = Extract<DeepMemoryEventType, 'entity:creating' | 'entity:updating' | 'entity:deleting' | 'relationship:creating' | 'relationship:removing'>;
|
|
179
|
+
/** Hook handler that can cancel or modify operations */
|
|
180
|
+
type HookHandler<T extends PreMutationEvent> = (event: DeepMemoryEvent<T>) => HookResult | Promise<HookResult>;
|
|
181
|
+
declare class EventBus {
|
|
182
|
+
private handlers;
|
|
183
|
+
private hookHandlers;
|
|
184
|
+
private provenance;
|
|
185
|
+
private repositoryId?;
|
|
186
|
+
constructor(provenance: ProvenanceContext, repositoryId?: string);
|
|
187
|
+
/** Update provenance context (e.g., when conversation changes) */
|
|
188
|
+
updateProvenance(provenance: ProvenanceContext): void;
|
|
189
|
+
/** Subscribe to an event. Returns an unsubscribe function. */
|
|
190
|
+
on<E extends DeepMemoryEventType>(event: E, handler: EventHandler<E>): Unsubscribe;
|
|
191
|
+
/** Register a pre-mutation hook that can cancel operations */
|
|
192
|
+
onHook<E extends PreMutationEvent>(event: E, handler: HookHandler<E>): Unsubscribe;
|
|
193
|
+
/** Emit an event to all registered handlers */
|
|
194
|
+
emit<E extends DeepMemoryEventType>(event: E, payload: EventPayload<E>): Promise<void>;
|
|
195
|
+
/**
|
|
196
|
+
* Emit a pre-mutation hook event.
|
|
197
|
+
* Returns `{ cancelled: false }` if all hooks pass,
|
|
198
|
+
* or `{ cancelled: true, reason }` if any hook cancels.
|
|
199
|
+
*/
|
|
200
|
+
emitHook<E extends PreMutationEvent>(event: E, payload: EventPayload<E>): Promise<{
|
|
201
|
+
cancelled: boolean;
|
|
202
|
+
reason?: string;
|
|
203
|
+
}>;
|
|
204
|
+
/** Remove all listeners and hooks */
|
|
205
|
+
removeAllListeners(): void;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
interface MemoryRepositoryConfig {
|
|
209
|
+
repositoryId: string;
|
|
210
|
+
storage: StorageProvider;
|
|
211
|
+
search?: SearchProvider;
|
|
212
|
+
embedding?: EmbeddingProvider;
|
|
213
|
+
vocabularyEngine: VocabularyEngine;
|
|
214
|
+
provenanceTracker: ProvenanceTracker;
|
|
215
|
+
eventBus: EventBus;
|
|
216
|
+
}
|
|
217
|
+
declare class MemoryRepository {
|
|
218
|
+
readonly repositoryId: string;
|
|
219
|
+
private readonly storage;
|
|
220
|
+
private readonly search?;
|
|
221
|
+
private readonly vocabularyEngine;
|
|
222
|
+
private readonly provenanceTracker;
|
|
223
|
+
private readonly eventBus;
|
|
224
|
+
private readonly entityManager;
|
|
225
|
+
private readonly relationshipManager;
|
|
226
|
+
private readonly graphTraversal;
|
|
227
|
+
private readonly searchOrchestrator;
|
|
228
|
+
constructor(config: MemoryRepositoryConfig);
|
|
229
|
+
getVocabulary(): Promise<ResolvedVocabulary>;
|
|
230
|
+
proposeVocabularyChange(proposal: VocabularyProposal): Promise<VocabularyProposalResult>;
|
|
231
|
+
/** @deprecated Use proposeVocabularyChange instead */
|
|
232
|
+
proposeVocabularyExtension(proposal: VocabularyProposal): Promise<VocabularyProposalResult>;
|
|
233
|
+
createEntity(input: CreateEntityInput): Promise<Entity>;
|
|
234
|
+
updateEntity(entityId: string, updates: UpdateEntityInput): Promise<Entity>;
|
|
235
|
+
getEntity(entityId: string, detailLevel?: DetailLevel): Promise<Entity | EntitySummary | EntityBrief | null>;
|
|
236
|
+
getBySlug(slug: string, detailLevel?: DetailLevel): Promise<Entity | EntitySummary | EntityBrief | null>;
|
|
237
|
+
getEntities(entityIds: string[], detailLevel?: 'brief' | 'summary'): Promise<Map<string, EntitySummary | EntityBrief>>;
|
|
238
|
+
findEntities(query: FindEntitiesQuery): Promise<PaginatedResult<Entity | EntitySummary | EntityBrief>>;
|
|
239
|
+
deleteEntity(entityId: string): Promise<void>;
|
|
240
|
+
/** Re-embed specific entities using the current EmbeddingProvider */
|
|
241
|
+
reembedEntities(entityIds: string[]): Promise<ReembedResult>;
|
|
242
|
+
/**
|
|
243
|
+
* Re-embed all entities in the repository using the current EmbeddingProvider.
|
|
244
|
+
* Processes in batches with optional rate limiting. Emits reembed:* events for progress tracking.
|
|
245
|
+
* Updates repository metadata with the new model ID and dimensions on completion.
|
|
246
|
+
*/
|
|
247
|
+
reembedAll(options?: {
|
|
248
|
+
batchSize?: number;
|
|
249
|
+
/** Max retries per batch on embedding failure (default 3) */
|
|
250
|
+
maxRetries?: number;
|
|
251
|
+
/** Abort after this many cumulative failures (default: no limit) */
|
|
252
|
+
errorThresholdToAbort?: number;
|
|
253
|
+
/** Milliseconds to wait between batches for rate limiting (default 0) */
|
|
254
|
+
delayBetweenBatchesMs?: number;
|
|
255
|
+
}): Promise<ReembedResult>;
|
|
256
|
+
createRelationship(input: CreateRelationshipInput): Promise<Relationship>;
|
|
257
|
+
removeRelationship(relationshipId: string): Promise<void>;
|
|
258
|
+
getRelationships(entityId: string, options?: {
|
|
259
|
+
relationshipTypes?: string[];
|
|
260
|
+
direction?: 'outbound' | 'inbound' | 'both';
|
|
261
|
+
limit?: number;
|
|
262
|
+
offset?: number;
|
|
263
|
+
propertyFilters?: PropertyFilter[];
|
|
264
|
+
}): Promise<PaginatedResult<Relationship>>;
|
|
265
|
+
getRelationshipSummary(entityId: string): Promise<RelationshipSummary>;
|
|
266
|
+
getRelationshipsForEntities(entityIds: string[]): Promise<Relationship[]>;
|
|
267
|
+
/** Get the full graph — entities with enriched relationships, vocabulary, and stats. Paginated. */
|
|
268
|
+
getGraph(options?: {
|
|
269
|
+
limit?: number;
|
|
270
|
+
offset?: number;
|
|
271
|
+
detailLevel?: DetailLevel;
|
|
272
|
+
}): Promise<GraphResult>;
|
|
273
|
+
exploreNeighbourhood(entityId: string, options?: ExploreOptions): Promise<Neighbourhood>;
|
|
274
|
+
findPaths(sourceId: string, targetId: string, options?: PathOptions): Promise<PathResult>;
|
|
275
|
+
searchByConcept(query: string, options?: ConceptSearchOptions): Promise<PaginatedResult<ScoredEntity>>;
|
|
276
|
+
getTimeline(entityId: string, options?: TimelineOptions): Promise<TimelineResult>;
|
|
277
|
+
getStats(): Promise<RepositoryStats>;
|
|
278
|
+
on<E extends DeepMemoryEventType>(event: E, handler: EventHandler<E>): Unsubscribe;
|
|
279
|
+
onHook<E extends Extract<DeepMemoryEventType, 'entity:creating' | 'entity:updating' | 'entity:deleting' | 'relationship:creating' | 'relationship:removing'>>(event: E, handler: HookHandler<E>): Unsubscribe;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/** Generate a v4 UUID without depending on node:crypto */
|
|
283
|
+
declare function generateId(): string;
|
|
284
|
+
/** Validate that a string is a valid UUID */
|
|
285
|
+
declare function isValidUuid(value: string): boolean;
|
|
286
|
+
/** Configuration for creating a DeepMemory instance */
|
|
287
|
+
interface DeepMemoryConfig {
|
|
288
|
+
/** Required: the storage provider for persistence */
|
|
289
|
+
storage: StorageProvider;
|
|
290
|
+
/** Optional: search provider for full-text search */
|
|
291
|
+
search?: SearchProvider;
|
|
292
|
+
/** Optional: embedding provider for semantic search */
|
|
293
|
+
embedding?: EmbeddingProvider;
|
|
294
|
+
/** Optional: lock provider for distributed locking */
|
|
295
|
+
lock?: LockProvider;
|
|
296
|
+
/** Required: provenance context identifying the actor */
|
|
297
|
+
provenance: ProvenanceContext;
|
|
298
|
+
}
|
|
299
|
+
declare class DeepMemory {
|
|
300
|
+
private readonly storage;
|
|
301
|
+
private readonly search?;
|
|
302
|
+
private readonly embedding?;
|
|
303
|
+
/** Reserved for future distributed locking support */
|
|
304
|
+
readonly lock?: LockProvider;
|
|
305
|
+
private readonly provenance;
|
|
306
|
+
private readonly globalEventBus;
|
|
307
|
+
private initialised;
|
|
308
|
+
constructor(config: DeepMemoryConfig);
|
|
309
|
+
/** Initialise the storage provider (call once before use) */
|
|
310
|
+
private ensureInitialised;
|
|
311
|
+
/** Create or migrate the storage schema. Call once at deployment / startup, not per-request. */
|
|
312
|
+
ensureSchema(): Promise<void>;
|
|
313
|
+
private validateRepositoryId;
|
|
314
|
+
/** Create a new memory repository */
|
|
315
|
+
createRepository(config: RepositoryConfig): Promise<MemoryRepository>;
|
|
316
|
+
/** Open an existing repository */
|
|
317
|
+
openRepository(repositoryId: string): Promise<MemoryRepository>;
|
|
318
|
+
/** List all repositories */
|
|
319
|
+
listRepositories(filter?: RepositoryFilter): Promise<PaginatedResult<RepositorySummary>>;
|
|
320
|
+
/** Update repository metadata and settings */
|
|
321
|
+
updateRepository(repositoryId: string, updates: RepositoryUpdate): Promise<StoredRepository>;
|
|
322
|
+
/** Delete a repository */
|
|
323
|
+
deleteRepository(repositoryId: string): Promise<void>;
|
|
324
|
+
/** Export a repository to a portable archive */
|
|
325
|
+
exportRepository(repositoryId: string): Promise<ExportArchive>;
|
|
326
|
+
/** Import a repository from a portable archive */
|
|
327
|
+
importRepository(archive: ExportArchive, options: ImportOptions): Promise<ImportResult>;
|
|
328
|
+
/**
|
|
329
|
+
* Stream a repository export as an async generator.
|
|
330
|
+
* Yields: manifest → vocabulary → entity chunks → relationship chunks.
|
|
331
|
+
* Use for large repositories to avoid loading everything into memory.
|
|
332
|
+
*/
|
|
333
|
+
exportRepositoryStream(repositoryId: string): AsyncGenerator<ExportStreamItem>;
|
|
334
|
+
/**
|
|
335
|
+
* Import a repository from a stream of chunks.
|
|
336
|
+
* Use for large repositories to avoid loading everything into memory.
|
|
337
|
+
*/
|
|
338
|
+
importRepositoryStream(header: ImportStreamHeader, chunks: AsyncIterable<ImportChunk>, options: ImportOptions): Promise<ImportResult>;
|
|
339
|
+
/** Subscribe to global events */
|
|
340
|
+
on<E extends DeepMemoryEventType>(event: E, handler: EventHandler<E>): Unsubscribe;
|
|
341
|
+
/** Update the provenance context (e.g., new conversation) */
|
|
342
|
+
updateProvenance(context: Partial<ProvenanceContext>): void;
|
|
343
|
+
/** Dispose of all resources */
|
|
344
|
+
dispose(): Promise<void>;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Evaluate whether a set of properties matches all given filters.
|
|
349
|
+
* All filters are AND'd — every filter must match for the result to be true.
|
|
350
|
+
*/
|
|
351
|
+
declare function matchesPropertyFilters(properties: Record<string, unknown>, filters: PropertyFilter[]): boolean;
|
|
352
|
+
|
|
353
|
+
declare class InMemoryStorageProvider implements StorageProvider {
|
|
354
|
+
private stores;
|
|
355
|
+
private getStore;
|
|
356
|
+
initialise(): Promise<void>;
|
|
357
|
+
dispose(): Promise<void>;
|
|
358
|
+
createRepository(config: StorageRepositoryConfig): Promise<StoredRepository>;
|
|
359
|
+
getRepository(repositoryId: string): Promise<StoredRepository | null>;
|
|
360
|
+
listRepositories(filter?: RepositoryFilter): Promise<PaginatedResult<StoredRepositorySummary>>;
|
|
361
|
+
updateRepository(repositoryId: string, updates: RepositoryUpdate): Promise<StoredRepository>;
|
|
362
|
+
deleteRepository(repositoryId: string): Promise<void>;
|
|
363
|
+
getRepositoryStats(repositoryId: string): Promise<RepositoryStats>;
|
|
364
|
+
getVocabulary(repositoryId: string): Promise<MemoryVocabulary>;
|
|
365
|
+
saveVocabulary(repositoryId: string, vocabulary: MemoryVocabulary): Promise<void>;
|
|
366
|
+
getVocabularyChangeLog(repositoryId: string, options?: PaginationOptions): Promise<PaginatedResult<VocabularyChangeRecord>>;
|
|
367
|
+
createEntity(repositoryId: string, entity: StoredEntity): Promise<StoredEntity>;
|
|
368
|
+
getEntity(repositoryId: string, entityId: string): Promise<StoredEntity | null>;
|
|
369
|
+
getEntityBySlug(repositoryId: string, slug: string): Promise<StoredEntity | null>;
|
|
370
|
+
getEntities(repositoryId: string, entityIds: string[]): Promise<Map<string, StoredEntity>>;
|
|
371
|
+
updateEntity(repositoryId: string, entityId: string, updates: StoredEntityUpdate): Promise<StoredEntity>;
|
|
372
|
+
deleteEntity(repositoryId: string, entityId: string): Promise<void>;
|
|
373
|
+
deleteEntitiesByType(repositoryId: string, entityType: string): Promise<{
|
|
374
|
+
deletedEntities: number;
|
|
375
|
+
deletedRelationships: number;
|
|
376
|
+
}>;
|
|
377
|
+
findEntities(repositoryId: string, query: StorageFindQuery): Promise<PaginatedResult<StoredEntity>>;
|
|
378
|
+
createRelationship(repositoryId: string, relationship: StoredRelationship): Promise<StoredRelationship>;
|
|
379
|
+
getRelationship(repositoryId: string, relationshipId: string): Promise<StoredRelationship | null>;
|
|
380
|
+
getEntityRelationships(repositoryId: string, entityId: string, options?: RelationshipQueryOptions): Promise<PaginatedResult<StoredRelationship>>;
|
|
381
|
+
deleteRelationship(repositoryId: string, relationshipId: string): Promise<void>;
|
|
382
|
+
deleteRelationshipsByType(repositoryId: string, relationshipType: string): Promise<{
|
|
383
|
+
deletedRelationships: number;
|
|
384
|
+
}>;
|
|
385
|
+
exploreNeighbourhood(repositoryId: string, entityId: string, options: StorageExploreOptions): Promise<StorageNeighbourhood>;
|
|
386
|
+
findPaths(repositoryId: string, sourceId: string, targetId: string, options: StoragePathOptions): Promise<StoragePathResult>;
|
|
387
|
+
getTimeline(repositoryId: string, entityId: string, options: StorageTimelineOptions): Promise<StorageTimelineResult>;
|
|
388
|
+
exportAll(repositoryId: string): AsyncIterable<ExportChunk>;
|
|
389
|
+
importBulk(repositoryId: string, data: ImportChunk[]): Promise<BulkImportResult>;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
declare class InMemorySearchProvider implements SearchProvider {
|
|
393
|
+
private indices;
|
|
394
|
+
private getIndex;
|
|
395
|
+
indexEntity(repositoryId: string, entity: SearchableEntity): Promise<void>;
|
|
396
|
+
removeEntity(repositoryId: string, entityId: string): Promise<void>;
|
|
397
|
+
search(repositoryId: string, query: string, options?: SearchOptions): Promise<PaginatedResult<SearchHit>>;
|
|
398
|
+
reindexRepository(repositoryId: string, entities: AsyncIterable<SearchableEntity>): Promise<void>;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
declare class NoOpEmbeddingProvider implements EmbeddingProvider {
|
|
402
|
+
embed(_text: string): Promise<number[]>;
|
|
403
|
+
embedBatch(_texts: string[]): Promise<number[][]>;
|
|
404
|
+
dimensions(): number;
|
|
405
|
+
modelId(): string;
|
|
406
|
+
}
|
|
407
|
+
|
|
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 };
|