@utaba/deep-memory 0.14.0 → 0.15.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/{StorageProvider-BfdyQgiI.d.cts → StorageProvider-BGtKZZt4.d.cts} +1 -1
- package/dist/{StorageProvider-jpzVIKXs.d.ts → StorageProvider-D_o2Hksf.d.ts} +1 -1
- package/dist/index.cjs +142 -66
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +58 -8
- package/dist/index.d.ts +58 -8
- package/dist/index.js +141 -66
- package/dist/index.js.map +1 -1
- package/dist/{portability-DWpZbxNn.d.cts → portability-P1hL-bOa.d.cts} +11 -0
- package/dist/{portability-DWpZbxNn.d.ts → portability-P1hL-bOa.d.ts} +11 -0
- package/dist/providers/index.d.cts +3 -3
- package/dist/providers/index.d.ts +3 -3
- package/dist/testing/conformance.d.cts +2 -2
- package/dist/testing/conformance.d.ts +2 -2
- package/dist/{traversal-COr0AJBc.d.ts → traversal-B_84kGaO.d.ts} +1 -1
- package/dist/{traversal-37JAiha-.d.cts → traversal-CBE5h5ob.d.cts} +1 -1
- package/dist/types/index.d.cts +3 -3
- package/dist/types/index.d.ts +3 -3
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { G as GovernanceConfig, M as MemoryVocabulary, x as ResolvedVocabulary, C as CreateEntityInput, y as ValidationResult, U as UpdateEntityInput, z as CreateRelationshipInput, A as EntityTypeDefinition, F as VocabularyProposal, H as VocabularyProposalResult, J as ProvenanceContext, K as Provenance, E as Entity, D as DetailLevel, a as EntitySummary, b as EntityBrief, L as FindEntitiesQuery, e as PaginatedResult, N as DeleteEntitiesResult, O as ReembedResult, Q as Relationship, T as RemoveRelationshipsResult, P as PropertyFilter, R as RelationshipSummary, W as GraphResult, X as ExploreOptions, Y as Neighborhood, Z as PathOptions, _ as PathResult, $ as ConceptSearchOptions, a0 as ScoredEntity, a1 as TimelineOptions, a2 as TimelineResult, i as RepositoryStats, a3 as ValidateEntitiesOptions, a4 as EntityValidationPage, a5 as ValidateRelationshipsOptions, a6 as RelationshipValidationPage, a7 as RepositoryConfig, c as StoredRepository, d as RepositoryFilter, a8 as RepositorySummary, g as RepositoryUpdate, a9 as ExportOptions, aa as ExportArchive, ab as ImportOptions, ac as ImportResult, ad as ExportStreamItem, ae as ImportStreamHeader, I as ImportChunk, k as StoredEntity, S as StorageRepositoryConfig, f as StoredRepositorySummary, h as DeleteProgressCallback, j as PaginationOptions, V as VocabularyChangeRecord, l as StoredEntityUpdate, m as StorageFindQuery, n as StoredRelationship, o as RelationshipQueryOptions, p as StorageExploreOptions, q as StorageNeighborhood, r as StoragePathOptions, s as StoragePathResult, t as StorageTimelineOptions, u as StorageTimelineResult, v as ExportChunk, B as BulkImportOptions, w as BulkImportResult, af as SearchOptions, ag as SearchHit } from './portability-
|
|
2
|
-
export { ah as AdaptiveConcurrencyAdjustEvent, ai as AdaptiveConcurrencyAdjustReason, aj as AdaptiveConcurrencyHandle, ak as AdaptiveConcurrencyOptions, al as EnrichedRelationship, am as EntityMap, an as EntityTypeInput, ao as EntityValidationIssue, ap as ExportLegalMetadata, aq as ExportManifest, ar as ExportPipelineMetadata, as as GetEntitiesOptions, at as GetEntityOptions, au as GovernanceMode, av as ImportWarning, aw as NeighborhoodCenter, ax as NeighborhoodGroup, ay as NeighborhoodLayer, az as Path, aA as PropertySchema, aB as PropertyType, aC as ProvenanceFilter, aD as RelationshipDirection, aE as RelationshipTypeDefinition, aF as RelationshipTypeInput, aG as RelationshipValidationIssue, aH as RepositoryMetadata, aI as StorageNeighborhoodGroup, aJ as StorageNeighborhoodLayer, aK as StoragePath, aL as StorageTimelineEvent, aM as TimelineEntityRef, aN as TimelineEvent, aO as TimelineRelationshipDetail, aP as VocabularyInput } from './portability-
|
|
1
|
+
import { G as GovernanceConfig, M as MemoryVocabulary, x as ResolvedVocabulary, C as CreateEntityInput, y as ValidationResult, U as UpdateEntityInput, z as CreateRelationshipInput, A as EntityTypeDefinition, F as VocabularyProposal, H as VocabularyProposalResult, J as ProvenanceContext, K as Provenance, E as Entity, D as DetailLevel, a as EntitySummary, b as EntityBrief, L as FindEntitiesQuery, e as PaginatedResult, N as DeleteEntitiesResult, O as ReembedResult, Q as Relationship, T as RemoveRelationshipsResult, P as PropertyFilter, R as RelationshipSummary, W as GraphResult, X as ExploreOptions, Y as Neighborhood, Z as PathOptions, _ as PathResult, $ as ConceptSearchOptions, a0 as ScoredEntity, a1 as TimelineOptions, a2 as TimelineResult, i as RepositoryStats, a3 as ValidateEntitiesOptions, a4 as EntityValidationPage, a5 as ValidateRelationshipsOptions, a6 as RelationshipValidationPage, a7 as RepositoryConfig, c as StoredRepository, d as RepositoryFilter, a8 as RepositorySummary, g as RepositoryUpdate, a9 as ExportOptions, aa as ExportArchive, ab as ImportOptions, ac as ImportResult, ad as ExportStreamItem, ae as ImportStreamHeader, I as ImportChunk, k as StoredEntity, S as StorageRepositoryConfig, f as StoredRepositorySummary, h as DeleteProgressCallback, j as PaginationOptions, V as VocabularyChangeRecord, l as StoredEntityUpdate, m as StorageFindQuery, n as StoredRelationship, o as RelationshipQueryOptions, p as StorageExploreOptions, q as StorageNeighborhood, r as StoragePathOptions, s as StoragePathResult, t as StorageTimelineOptions, u as StorageTimelineResult, v as ExportChunk, B as BulkImportOptions, w as BulkImportResult, af as SearchOptions, ag as SearchHit } from './portability-P1hL-bOa.cjs';
|
|
2
|
+
export { ah as AdaptiveConcurrencyAdjustEvent, ai as AdaptiveConcurrencyAdjustReason, aj as AdaptiveConcurrencyHandle, ak as AdaptiveConcurrencyOptions, al as EnrichedRelationship, am as EntityMap, an as EntityTypeInput, ao as EntityValidationIssue, ap as ExportLegalMetadata, aq as ExportManifest, ar as ExportPipelineMetadata, as as GetEntitiesOptions, at as GetEntityOptions, au as GovernanceMode, av as ImportWarning, aw as NeighborhoodCenter, ax as NeighborhoodGroup, ay as NeighborhoodLayer, az as Path, aA as PropertySchema, aB as PropertyType, aC as ProvenanceFilter, aD as RelationshipDirection, aE as RelationshipTypeDefinition, aF as RelationshipTypeInput, aG as RelationshipValidationIssue, aH as RepositoryMetadata, aI as StorageNeighborhoodGroup, aJ as StorageNeighborhoodLayer, aK as StoragePath, aL as StorageTimelineEvent, aM as TimelineEntityRef, aN as TimelineEvent, aO as TimelineRelationshipDetail, aP as VocabularyInput } from './portability-P1hL-bOa.cjs';
|
|
3
3
|
import { DeepMemoryEventType, EventHandler, Unsubscribe, DeepMemoryEvent, HookResult, EventPayload, UsageSink } from './types/index.cjs';
|
|
4
4
|
export { OperationUsage } from './types/index.cjs';
|
|
5
|
-
import { T as TraversalSpec, a as TraversalResult } from './traversal-
|
|
6
|
-
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-
|
|
7
|
-
import { S as StorageProvider, E as EnsureSchemaResult } from './StorageProvider-
|
|
5
|
+
import { T as TraversalSpec, a as TraversalResult } from './traversal-CBE5h5ob.cjs';
|
|
6
|
+
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-CBE5h5ob.cjs';
|
|
7
|
+
import { S as StorageProvider, E as EnsureSchemaResult } from './StorageProvider-BGtKZZt4.cjs';
|
|
8
8
|
import { EmbeddingProvider, SearchProvider, EmbeddingProviderFactory, GraphTraversalProvider, LockProvider, SearchableEntity } from './providers/index.cjs';
|
|
9
9
|
export { GraphTraversalCapabilities, LockHandle, LockOptions } from './providers/index.cjs';
|
|
10
10
|
|
|
11
11
|
/** Error codes for all Deep Memory errors */
|
|
12
|
-
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' | 'SELF_REFERENTIAL_RELATIONSHIP' | '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';
|
|
12
|
+
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' | 'SELF_REFERENTIAL_RELATIONSHIP' | 'GOVERNANCE_DENIED' | 'OPERATION_CANCELLED' | 'OPERATION_ABORTED' | 'EMBEDDING_PROVIDER_REQUIRED' | 'IMPORT_ERROR' | 'EXPORT_ERROR' | 'PROVIDER_ERROR' | 'GRAPH_TRAVERSAL_PROVIDER_REQUIRED' | 'TRAVERSAL_VALIDATION_FAILED' | 'TRAVERSAL_VOCABULARY_ERROR' | 'TRAVERSAL_TIMEOUT';
|
|
13
13
|
/** Base error class for all Deep Memory errors */
|
|
14
14
|
declare class DeepMemoryError extends Error {
|
|
15
15
|
readonly code: DeepMemoryErrorCode;
|
|
@@ -89,6 +89,15 @@ declare class OperationCancelledError extends DeepMemoryError {
|
|
|
89
89
|
readonly reason: string;
|
|
90
90
|
constructor(operation: string, reason: string);
|
|
91
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* A long-running operation was aborted by a caller-supplied AbortSignal.
|
|
94
|
+
* Cooperative — the in-flight batch/chunk completes before the abort is honoured,
|
|
95
|
+
* and any state written before the abort is left in place.
|
|
96
|
+
*/
|
|
97
|
+
declare class OperationAbortedError extends DeepMemoryError {
|
|
98
|
+
readonly operation: string;
|
|
99
|
+
constructor(operation: string);
|
|
100
|
+
}
|
|
92
101
|
/** Semantic search was attempted without an embedding provider */
|
|
93
102
|
declare class EmbeddingProviderRequiredError extends DeepMemoryError {
|
|
94
103
|
constructor();
|
|
@@ -284,7 +293,13 @@ declare class MemoryRepository {
|
|
|
284
293
|
* the repository's embedding configuration is updated to the new values before
|
|
285
294
|
* re-embedding, so all subsequent entity writes use the new model/dimensionality.
|
|
286
295
|
*
|
|
287
|
-
* Processes in batches with optional rate limiting.
|
|
296
|
+
* Processes in batches with optional rate limiting.
|
|
297
|
+
*
|
|
298
|
+
* Progress is delivered via the optional `onProgress` callback. Most callers
|
|
299
|
+
* should use {@link DeepMemory.reembedAll} instead, which wires this callback
|
|
300
|
+
* to the global event bus so `reembed:*` events are reachable via
|
|
301
|
+
* `DeepMemory.on()`.
|
|
302
|
+
*
|
|
288
303
|
* Updates repository metadata with the new model ID and dimensions on completion.
|
|
289
304
|
*/
|
|
290
305
|
reembedAll(options?: {
|
|
@@ -299,6 +314,20 @@ declare class MemoryRepository {
|
|
|
299
314
|
errorThresholdToAbort?: number;
|
|
300
315
|
/** Milliseconds to wait between batches for rate limiting (default 0) */
|
|
301
316
|
delayBetweenBatchesMs?: number;
|
|
317
|
+
/**
|
|
318
|
+
* Called after each batch completes. Internal plumbing — the {@link DeepMemory}
|
|
319
|
+
* facade wires this to `globalEventBus.emit('reembed:progress', ...)`.
|
|
320
|
+
*/
|
|
321
|
+
onProgress?: (progress: {
|
|
322
|
+
processed: number;
|
|
323
|
+
totalEntities: number;
|
|
324
|
+
failed: number;
|
|
325
|
+
}) => void | Promise<void>;
|
|
326
|
+
/**
|
|
327
|
+
* Caller-supplied abort signal. Honoured at batch boundaries.
|
|
328
|
+
* Any vectors already written by completed batches are left in place.
|
|
329
|
+
*/
|
|
330
|
+
signal?: AbortSignal;
|
|
302
331
|
}): Promise<ReembedResult>;
|
|
303
332
|
createRelationships(inputs: CreateRelationshipInput[]): Promise<Relationship[]>;
|
|
304
333
|
removeRelationships(ids: string[]): Promise<RemoveRelationshipsResult>;
|
|
@@ -434,6 +463,27 @@ declare class DeepMemory {
|
|
|
434
463
|
* Use for large repositories to avoid loading everything into memory.
|
|
435
464
|
*/
|
|
436
465
|
importRepositoryStream(header: ImportStreamHeader, chunks: AsyncIterable<ImportChunk>, options: ImportOptions): Promise<ImportResult>;
|
|
466
|
+
/**
|
|
467
|
+
* Re-embed all entities in a repository, emitting `reembed:*` events on the
|
|
468
|
+
* global event bus (reachable via {@link DeepMemory.on}).
|
|
469
|
+
*
|
|
470
|
+
* Mirrors the lifecycle of {@link importRepositoryStream}: emits
|
|
471
|
+
* `reembed:started` up front, `reembed:progress` after every batch,
|
|
472
|
+
* and either `reembed:completed` or `reembed:failed` at the end.
|
|
473
|
+
*
|
|
474
|
+
* `options.signal` is honoured at batch boundaries — any vectors already
|
|
475
|
+
* written by completed batches are retained, and `reembed:failed` is emitted
|
|
476
|
+
* with the abort error message.
|
|
477
|
+
*/
|
|
478
|
+
reembedAll(repositoryId: string, options?: {
|
|
479
|
+
model?: string;
|
|
480
|
+
dimensions?: number;
|
|
481
|
+
batchSize?: number;
|
|
482
|
+
maxRetries?: number;
|
|
483
|
+
errorThresholdToAbort?: number;
|
|
484
|
+
delayBetweenBatchesMs?: number;
|
|
485
|
+
signal?: AbortSignal;
|
|
486
|
+
}): Promise<ReembedResult>;
|
|
437
487
|
/** Subscribe to global events */
|
|
438
488
|
on<E extends DeepMemoryEventType>(event: E, handler: EventHandler<E>): Unsubscribe;
|
|
439
489
|
/** Update the provenance context (e.g., new conversation) */
|
|
@@ -563,4 +613,4 @@ declare class NoOpEmbeddingProvider implements EmbeddingProvider {
|
|
|
563
613
|
modelId(): string;
|
|
564
614
|
}
|
|
565
615
|
|
|
566
|
-
export { BulkImportOptions, BulkImportResult, type CompiledQuery, ConceptSearchOptions, CreateEntityInput, CreateRelationshipInput, CypherCompiler, DeepMemory, type DeepMemoryConfig, DeepMemoryError, type DeepMemoryErrorCode, DeepMemoryEvent, DeepMemoryEventType, DeleteEntitiesResult, DeleteProgressCallback, DetailLevel, DuplicateEntityError, DuplicateRelationshipError, DuplicateRepositoryError, EmbeddingProvider, EmbeddingProviderFactory, EmbeddingProviderRequiredError, EnsureSchemaResult, Entity, EntityBrief, EntityNotFoundError, EntitySummary, EntityTypeDefinition, EntityValidationPage, EventHandler, EventPayload, ExploreOptions, ExportArchive, ExportChunk, ExportError, ExportOptions, ExportStreamItem, FindEntitiesQuery, GovernanceConfig, GovernanceDeniedError, GraphResult, GraphTraversalProvider, GraphTraversalProviderRequiredError, GremlinCompiler, HookResult, ImportChunk, ImportError, ImportOptions, ImportResult, ImportStreamHeader, ImportThrottleAbortError, InMemorySearchProvider, InMemoryStorageProvider, InvalidInputError, LockProvider, MemoryRepository, MemoryVocabulary, Neighborhood, NoOpEmbeddingProvider, OperationCancelledError, PaginatedResult, PaginationOptions, PathOptions, PathResult, PropertyFilter, Provenance, ProvenanceContext, ProviderError, ReembedResult, Relationship, RelationshipConstraintError, RelationshipNotFoundError, RelationshipQueryOptions, RelationshipSummary, RelationshipValidationPage, RemoveRelationshipsResult, RepositoryConfig, RepositoryFilter, RepositoryNotFoundError, RepositoryStats, RepositorySummary, RepositoryUpdate, RepositoryValidator, ResolvedVocabulary, ScoredEntity, SearchHit, SearchOptions, SearchProvider, SearchableEntity, SelfReferentialRelationshipError, StorageExploreOptions, StorageFindQuery, StorageNeighborhood, StoragePathOptions, StoragePathResult, StorageProvider, StorageRepositoryConfig, StorageTimelineOptions, StorageTimelineResult, StoredEntity, StoredEntityUpdate, StoredRelationship, StoredRepository, StoredRepositorySummary, TimelineOptions, TimelineResult, type TraversalCompiler, TraversalResult, TraversalSpec, TraversalTimeoutError, TraversalValidationError, TraversalVocabularyError, Unsubscribe, UpdateEntityInput, UsageSink, ValidateEntitiesOptions, ValidateRelationshipsOptions, VocabularyChangeRecord, VocabularyProposal, VocabularyProposalResult, VocabularyValidationError, createSafeSink, generateId, isValidUuid, matchesPropertyFilters, projectEntity };
|
|
616
|
+
export { BulkImportOptions, BulkImportResult, type CompiledQuery, ConceptSearchOptions, CreateEntityInput, CreateRelationshipInput, CypherCompiler, DeepMemory, type DeepMemoryConfig, DeepMemoryError, type DeepMemoryErrorCode, DeepMemoryEvent, DeepMemoryEventType, DeleteEntitiesResult, DeleteProgressCallback, DetailLevel, DuplicateEntityError, DuplicateRelationshipError, DuplicateRepositoryError, EmbeddingProvider, EmbeddingProviderFactory, EmbeddingProviderRequiredError, EnsureSchemaResult, Entity, EntityBrief, EntityNotFoundError, EntitySummary, EntityTypeDefinition, EntityValidationPage, EventHandler, EventPayload, ExploreOptions, ExportArchive, ExportChunk, ExportError, ExportOptions, ExportStreamItem, FindEntitiesQuery, GovernanceConfig, GovernanceDeniedError, GraphResult, GraphTraversalProvider, GraphTraversalProviderRequiredError, GremlinCompiler, HookResult, ImportChunk, ImportError, ImportOptions, ImportResult, ImportStreamHeader, ImportThrottleAbortError, InMemorySearchProvider, InMemoryStorageProvider, InvalidInputError, LockProvider, MemoryRepository, MemoryVocabulary, Neighborhood, NoOpEmbeddingProvider, OperationAbortedError, OperationCancelledError, PaginatedResult, PaginationOptions, PathOptions, PathResult, PropertyFilter, Provenance, ProvenanceContext, ProviderError, ReembedResult, Relationship, RelationshipConstraintError, RelationshipNotFoundError, RelationshipQueryOptions, RelationshipSummary, RelationshipValidationPage, RemoveRelationshipsResult, RepositoryConfig, RepositoryFilter, RepositoryNotFoundError, RepositoryStats, RepositorySummary, RepositoryUpdate, RepositoryValidator, ResolvedVocabulary, ScoredEntity, SearchHit, SearchOptions, SearchProvider, SearchableEntity, SelfReferentialRelationshipError, StorageExploreOptions, StorageFindQuery, StorageNeighborhood, StoragePathOptions, StoragePathResult, StorageProvider, StorageRepositoryConfig, StorageTimelineOptions, StorageTimelineResult, StoredEntity, StoredEntityUpdate, StoredRelationship, StoredRepository, StoredRepositorySummary, TimelineOptions, TimelineResult, type TraversalCompiler, TraversalResult, TraversalSpec, TraversalTimeoutError, TraversalValidationError, TraversalVocabularyError, Unsubscribe, UpdateEntityInput, UsageSink, ValidateEntitiesOptions, ValidateRelationshipsOptions, VocabularyChangeRecord, VocabularyProposal, VocabularyProposalResult, VocabularyValidationError, createSafeSink, generateId, isValidUuid, matchesPropertyFilters, projectEntity };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { G as GovernanceConfig, M as MemoryVocabulary, x as ResolvedVocabulary, C as CreateEntityInput, y as ValidationResult, U as UpdateEntityInput, z as CreateRelationshipInput, A as EntityTypeDefinition, F as VocabularyProposal, H as VocabularyProposalResult, J as ProvenanceContext, K as Provenance, E as Entity, D as DetailLevel, a as EntitySummary, b as EntityBrief, L as FindEntitiesQuery, e as PaginatedResult, N as DeleteEntitiesResult, O as ReembedResult, Q as Relationship, T as RemoveRelationshipsResult, P as PropertyFilter, R as RelationshipSummary, W as GraphResult, X as ExploreOptions, Y as Neighborhood, Z as PathOptions, _ as PathResult, $ as ConceptSearchOptions, a0 as ScoredEntity, a1 as TimelineOptions, a2 as TimelineResult, i as RepositoryStats, a3 as ValidateEntitiesOptions, a4 as EntityValidationPage, a5 as ValidateRelationshipsOptions, a6 as RelationshipValidationPage, a7 as RepositoryConfig, c as StoredRepository, d as RepositoryFilter, a8 as RepositorySummary, g as RepositoryUpdate, a9 as ExportOptions, aa as ExportArchive, ab as ImportOptions, ac as ImportResult, ad as ExportStreamItem, ae as ImportStreamHeader, I as ImportChunk, k as StoredEntity, S as StorageRepositoryConfig, f as StoredRepositorySummary, h as DeleteProgressCallback, j as PaginationOptions, V as VocabularyChangeRecord, l as StoredEntityUpdate, m as StorageFindQuery, n as StoredRelationship, o as RelationshipQueryOptions, p as StorageExploreOptions, q as StorageNeighborhood, r as StoragePathOptions, s as StoragePathResult, t as StorageTimelineOptions, u as StorageTimelineResult, v as ExportChunk, B as BulkImportOptions, w as BulkImportResult, af as SearchOptions, ag as SearchHit } from './portability-
|
|
2
|
-
export { ah as AdaptiveConcurrencyAdjustEvent, ai as AdaptiveConcurrencyAdjustReason, aj as AdaptiveConcurrencyHandle, ak as AdaptiveConcurrencyOptions, al as EnrichedRelationship, am as EntityMap, an as EntityTypeInput, ao as EntityValidationIssue, ap as ExportLegalMetadata, aq as ExportManifest, ar as ExportPipelineMetadata, as as GetEntitiesOptions, at as GetEntityOptions, au as GovernanceMode, av as ImportWarning, aw as NeighborhoodCenter, ax as NeighborhoodGroup, ay as NeighborhoodLayer, az as Path, aA as PropertySchema, aB as PropertyType, aC as ProvenanceFilter, aD as RelationshipDirection, aE as RelationshipTypeDefinition, aF as RelationshipTypeInput, aG as RelationshipValidationIssue, aH as RepositoryMetadata, aI as StorageNeighborhoodGroup, aJ as StorageNeighborhoodLayer, aK as StoragePath, aL as StorageTimelineEvent, aM as TimelineEntityRef, aN as TimelineEvent, aO as TimelineRelationshipDetail, aP as VocabularyInput } from './portability-
|
|
1
|
+
import { G as GovernanceConfig, M as MemoryVocabulary, x as ResolvedVocabulary, C as CreateEntityInput, y as ValidationResult, U as UpdateEntityInput, z as CreateRelationshipInput, A as EntityTypeDefinition, F as VocabularyProposal, H as VocabularyProposalResult, J as ProvenanceContext, K as Provenance, E as Entity, D as DetailLevel, a as EntitySummary, b as EntityBrief, L as FindEntitiesQuery, e as PaginatedResult, N as DeleteEntitiesResult, O as ReembedResult, Q as Relationship, T as RemoveRelationshipsResult, P as PropertyFilter, R as RelationshipSummary, W as GraphResult, X as ExploreOptions, Y as Neighborhood, Z as PathOptions, _ as PathResult, $ as ConceptSearchOptions, a0 as ScoredEntity, a1 as TimelineOptions, a2 as TimelineResult, i as RepositoryStats, a3 as ValidateEntitiesOptions, a4 as EntityValidationPage, a5 as ValidateRelationshipsOptions, a6 as RelationshipValidationPage, a7 as RepositoryConfig, c as StoredRepository, d as RepositoryFilter, a8 as RepositorySummary, g as RepositoryUpdate, a9 as ExportOptions, aa as ExportArchive, ab as ImportOptions, ac as ImportResult, ad as ExportStreamItem, ae as ImportStreamHeader, I as ImportChunk, k as StoredEntity, S as StorageRepositoryConfig, f as StoredRepositorySummary, h as DeleteProgressCallback, j as PaginationOptions, V as VocabularyChangeRecord, l as StoredEntityUpdate, m as StorageFindQuery, n as StoredRelationship, o as RelationshipQueryOptions, p as StorageExploreOptions, q as StorageNeighborhood, r as StoragePathOptions, s as StoragePathResult, t as StorageTimelineOptions, u as StorageTimelineResult, v as ExportChunk, B as BulkImportOptions, w as BulkImportResult, af as SearchOptions, ag as SearchHit } from './portability-P1hL-bOa.js';
|
|
2
|
+
export { ah as AdaptiveConcurrencyAdjustEvent, ai as AdaptiveConcurrencyAdjustReason, aj as AdaptiveConcurrencyHandle, ak as AdaptiveConcurrencyOptions, al as EnrichedRelationship, am as EntityMap, an as EntityTypeInput, ao as EntityValidationIssue, ap as ExportLegalMetadata, aq as ExportManifest, ar as ExportPipelineMetadata, as as GetEntitiesOptions, at as GetEntityOptions, au as GovernanceMode, av as ImportWarning, aw as NeighborhoodCenter, ax as NeighborhoodGroup, ay as NeighborhoodLayer, az as Path, aA as PropertySchema, aB as PropertyType, aC as ProvenanceFilter, aD as RelationshipDirection, aE as RelationshipTypeDefinition, aF as RelationshipTypeInput, aG as RelationshipValidationIssue, aH as RepositoryMetadata, aI as StorageNeighborhoodGroup, aJ as StorageNeighborhoodLayer, aK as StoragePath, aL as StorageTimelineEvent, aM as TimelineEntityRef, aN as TimelineEvent, aO as TimelineRelationshipDetail, aP as VocabularyInput } from './portability-P1hL-bOa.js';
|
|
3
3
|
import { DeepMemoryEventType, EventHandler, Unsubscribe, DeepMemoryEvent, HookResult, EventPayload, UsageSink } from './types/index.js';
|
|
4
4
|
export { OperationUsage } from './types/index.js';
|
|
5
|
-
import { T as TraversalSpec, a as TraversalResult } from './traversal-
|
|
6
|
-
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-
|
|
7
|
-
import { S as StorageProvider, E as EnsureSchemaResult } from './StorageProvider-
|
|
5
|
+
import { T as TraversalSpec, a as TraversalResult } from './traversal-B_84kGaO.js';
|
|
6
|
+
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-B_84kGaO.js';
|
|
7
|
+
import { S as StorageProvider, E as EnsureSchemaResult } from './StorageProvider-D_o2Hksf.js';
|
|
8
8
|
import { EmbeddingProvider, SearchProvider, EmbeddingProviderFactory, GraphTraversalProvider, LockProvider, SearchableEntity } from './providers/index.js';
|
|
9
9
|
export { GraphTraversalCapabilities, LockHandle, LockOptions } from './providers/index.js';
|
|
10
10
|
|
|
11
11
|
/** Error codes for all Deep Memory errors */
|
|
12
|
-
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' | 'SELF_REFERENTIAL_RELATIONSHIP' | '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';
|
|
12
|
+
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' | 'SELF_REFERENTIAL_RELATIONSHIP' | 'GOVERNANCE_DENIED' | 'OPERATION_CANCELLED' | 'OPERATION_ABORTED' | 'EMBEDDING_PROVIDER_REQUIRED' | 'IMPORT_ERROR' | 'EXPORT_ERROR' | 'PROVIDER_ERROR' | 'GRAPH_TRAVERSAL_PROVIDER_REQUIRED' | 'TRAVERSAL_VALIDATION_FAILED' | 'TRAVERSAL_VOCABULARY_ERROR' | 'TRAVERSAL_TIMEOUT';
|
|
13
13
|
/** Base error class for all Deep Memory errors */
|
|
14
14
|
declare class DeepMemoryError extends Error {
|
|
15
15
|
readonly code: DeepMemoryErrorCode;
|
|
@@ -89,6 +89,15 @@ declare class OperationCancelledError extends DeepMemoryError {
|
|
|
89
89
|
readonly reason: string;
|
|
90
90
|
constructor(operation: string, reason: string);
|
|
91
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* A long-running operation was aborted by a caller-supplied AbortSignal.
|
|
94
|
+
* Cooperative — the in-flight batch/chunk completes before the abort is honoured,
|
|
95
|
+
* and any state written before the abort is left in place.
|
|
96
|
+
*/
|
|
97
|
+
declare class OperationAbortedError extends DeepMemoryError {
|
|
98
|
+
readonly operation: string;
|
|
99
|
+
constructor(operation: string);
|
|
100
|
+
}
|
|
92
101
|
/** Semantic search was attempted without an embedding provider */
|
|
93
102
|
declare class EmbeddingProviderRequiredError extends DeepMemoryError {
|
|
94
103
|
constructor();
|
|
@@ -284,7 +293,13 @@ declare class MemoryRepository {
|
|
|
284
293
|
* the repository's embedding configuration is updated to the new values before
|
|
285
294
|
* re-embedding, so all subsequent entity writes use the new model/dimensionality.
|
|
286
295
|
*
|
|
287
|
-
* Processes in batches with optional rate limiting.
|
|
296
|
+
* Processes in batches with optional rate limiting.
|
|
297
|
+
*
|
|
298
|
+
* Progress is delivered via the optional `onProgress` callback. Most callers
|
|
299
|
+
* should use {@link DeepMemory.reembedAll} instead, which wires this callback
|
|
300
|
+
* to the global event bus so `reembed:*` events are reachable via
|
|
301
|
+
* `DeepMemory.on()`.
|
|
302
|
+
*
|
|
288
303
|
* Updates repository metadata with the new model ID and dimensions on completion.
|
|
289
304
|
*/
|
|
290
305
|
reembedAll(options?: {
|
|
@@ -299,6 +314,20 @@ declare class MemoryRepository {
|
|
|
299
314
|
errorThresholdToAbort?: number;
|
|
300
315
|
/** Milliseconds to wait between batches for rate limiting (default 0) */
|
|
301
316
|
delayBetweenBatchesMs?: number;
|
|
317
|
+
/**
|
|
318
|
+
* Called after each batch completes. Internal plumbing — the {@link DeepMemory}
|
|
319
|
+
* facade wires this to `globalEventBus.emit('reembed:progress', ...)`.
|
|
320
|
+
*/
|
|
321
|
+
onProgress?: (progress: {
|
|
322
|
+
processed: number;
|
|
323
|
+
totalEntities: number;
|
|
324
|
+
failed: number;
|
|
325
|
+
}) => void | Promise<void>;
|
|
326
|
+
/**
|
|
327
|
+
* Caller-supplied abort signal. Honoured at batch boundaries.
|
|
328
|
+
* Any vectors already written by completed batches are left in place.
|
|
329
|
+
*/
|
|
330
|
+
signal?: AbortSignal;
|
|
302
331
|
}): Promise<ReembedResult>;
|
|
303
332
|
createRelationships(inputs: CreateRelationshipInput[]): Promise<Relationship[]>;
|
|
304
333
|
removeRelationships(ids: string[]): Promise<RemoveRelationshipsResult>;
|
|
@@ -434,6 +463,27 @@ declare class DeepMemory {
|
|
|
434
463
|
* Use for large repositories to avoid loading everything into memory.
|
|
435
464
|
*/
|
|
436
465
|
importRepositoryStream(header: ImportStreamHeader, chunks: AsyncIterable<ImportChunk>, options: ImportOptions): Promise<ImportResult>;
|
|
466
|
+
/**
|
|
467
|
+
* Re-embed all entities in a repository, emitting `reembed:*` events on the
|
|
468
|
+
* global event bus (reachable via {@link DeepMemory.on}).
|
|
469
|
+
*
|
|
470
|
+
* Mirrors the lifecycle of {@link importRepositoryStream}: emits
|
|
471
|
+
* `reembed:started` up front, `reembed:progress` after every batch,
|
|
472
|
+
* and either `reembed:completed` or `reembed:failed` at the end.
|
|
473
|
+
*
|
|
474
|
+
* `options.signal` is honoured at batch boundaries — any vectors already
|
|
475
|
+
* written by completed batches are retained, and `reembed:failed` is emitted
|
|
476
|
+
* with the abort error message.
|
|
477
|
+
*/
|
|
478
|
+
reembedAll(repositoryId: string, options?: {
|
|
479
|
+
model?: string;
|
|
480
|
+
dimensions?: number;
|
|
481
|
+
batchSize?: number;
|
|
482
|
+
maxRetries?: number;
|
|
483
|
+
errorThresholdToAbort?: number;
|
|
484
|
+
delayBetweenBatchesMs?: number;
|
|
485
|
+
signal?: AbortSignal;
|
|
486
|
+
}): Promise<ReembedResult>;
|
|
437
487
|
/** Subscribe to global events */
|
|
438
488
|
on<E extends DeepMemoryEventType>(event: E, handler: EventHandler<E>): Unsubscribe;
|
|
439
489
|
/** Update the provenance context (e.g., new conversation) */
|
|
@@ -563,4 +613,4 @@ declare class NoOpEmbeddingProvider implements EmbeddingProvider {
|
|
|
563
613
|
modelId(): string;
|
|
564
614
|
}
|
|
565
615
|
|
|
566
|
-
export { BulkImportOptions, BulkImportResult, type CompiledQuery, ConceptSearchOptions, CreateEntityInput, CreateRelationshipInput, CypherCompiler, DeepMemory, type DeepMemoryConfig, DeepMemoryError, type DeepMemoryErrorCode, DeepMemoryEvent, DeepMemoryEventType, DeleteEntitiesResult, DeleteProgressCallback, DetailLevel, DuplicateEntityError, DuplicateRelationshipError, DuplicateRepositoryError, EmbeddingProvider, EmbeddingProviderFactory, EmbeddingProviderRequiredError, EnsureSchemaResult, Entity, EntityBrief, EntityNotFoundError, EntitySummary, EntityTypeDefinition, EntityValidationPage, EventHandler, EventPayload, ExploreOptions, ExportArchive, ExportChunk, ExportError, ExportOptions, ExportStreamItem, FindEntitiesQuery, GovernanceConfig, GovernanceDeniedError, GraphResult, GraphTraversalProvider, GraphTraversalProviderRequiredError, GremlinCompiler, HookResult, ImportChunk, ImportError, ImportOptions, ImportResult, ImportStreamHeader, ImportThrottleAbortError, InMemorySearchProvider, InMemoryStorageProvider, InvalidInputError, LockProvider, MemoryRepository, MemoryVocabulary, Neighborhood, NoOpEmbeddingProvider, OperationCancelledError, PaginatedResult, PaginationOptions, PathOptions, PathResult, PropertyFilter, Provenance, ProvenanceContext, ProviderError, ReembedResult, Relationship, RelationshipConstraintError, RelationshipNotFoundError, RelationshipQueryOptions, RelationshipSummary, RelationshipValidationPage, RemoveRelationshipsResult, RepositoryConfig, RepositoryFilter, RepositoryNotFoundError, RepositoryStats, RepositorySummary, RepositoryUpdate, RepositoryValidator, ResolvedVocabulary, ScoredEntity, SearchHit, SearchOptions, SearchProvider, SearchableEntity, SelfReferentialRelationshipError, StorageExploreOptions, StorageFindQuery, StorageNeighborhood, StoragePathOptions, StoragePathResult, StorageProvider, StorageRepositoryConfig, StorageTimelineOptions, StorageTimelineResult, StoredEntity, StoredEntityUpdate, StoredRelationship, StoredRepository, StoredRepositorySummary, TimelineOptions, TimelineResult, type TraversalCompiler, TraversalResult, TraversalSpec, TraversalTimeoutError, TraversalValidationError, TraversalVocabularyError, Unsubscribe, UpdateEntityInput, UsageSink, ValidateEntitiesOptions, ValidateRelationshipsOptions, VocabularyChangeRecord, VocabularyProposal, VocabularyProposalResult, VocabularyValidationError, createSafeSink, generateId, isValidUuid, matchesPropertyFilters, projectEntity };
|
|
616
|
+
export { BulkImportOptions, BulkImportResult, type CompiledQuery, ConceptSearchOptions, CreateEntityInput, CreateRelationshipInput, CypherCompiler, DeepMemory, type DeepMemoryConfig, DeepMemoryError, type DeepMemoryErrorCode, DeepMemoryEvent, DeepMemoryEventType, DeleteEntitiesResult, DeleteProgressCallback, DetailLevel, DuplicateEntityError, DuplicateRelationshipError, DuplicateRepositoryError, EmbeddingProvider, EmbeddingProviderFactory, EmbeddingProviderRequiredError, EnsureSchemaResult, Entity, EntityBrief, EntityNotFoundError, EntitySummary, EntityTypeDefinition, EntityValidationPage, EventHandler, EventPayload, ExploreOptions, ExportArchive, ExportChunk, ExportError, ExportOptions, ExportStreamItem, FindEntitiesQuery, GovernanceConfig, GovernanceDeniedError, GraphResult, GraphTraversalProvider, GraphTraversalProviderRequiredError, GremlinCompiler, HookResult, ImportChunk, ImportError, ImportOptions, ImportResult, ImportStreamHeader, ImportThrottleAbortError, InMemorySearchProvider, InMemoryStorageProvider, InvalidInputError, LockProvider, MemoryRepository, MemoryVocabulary, Neighborhood, NoOpEmbeddingProvider, OperationAbortedError, OperationCancelledError, PaginatedResult, PaginationOptions, PathOptions, PathResult, PropertyFilter, Provenance, ProvenanceContext, ProviderError, ReembedResult, Relationship, RelationshipConstraintError, RelationshipNotFoundError, RelationshipQueryOptions, RelationshipSummary, RelationshipValidationPage, RemoveRelationshipsResult, RepositoryConfig, RepositoryFilter, RepositoryNotFoundError, RepositoryStats, RepositorySummary, RepositoryUpdate, RepositoryValidator, ResolvedVocabulary, ScoredEntity, SearchHit, SearchOptions, SearchProvider, SearchableEntity, SelfReferentialRelationshipError, StorageExploreOptions, StorageFindQuery, StorageNeighborhood, StoragePathOptions, StoragePathResult, StorageProvider, StorageRepositoryConfig, StorageTimelineOptions, StorageTimelineResult, StoredEntity, StoredEntityUpdate, StoredRelationship, StoredRepository, StoredRepositorySummary, TimelineOptions, TimelineResult, type TraversalCompiler, TraversalResult, TraversalSpec, TraversalTimeoutError, TraversalValidationError, TraversalVocabularyError, Unsubscribe, UpdateEntityInput, UsageSink, ValidateEntitiesOptions, ValidateRelationshipsOptions, VocabularyChangeRecord, VocabularyProposal, VocabularyProposalResult, VocabularyValidationError, createSafeSink, generateId, isValidUuid, matchesPropertyFilters, projectEntity };
|
package/dist/index.js
CHANGED
|
@@ -165,6 +165,18 @@ var OperationCancelledError = class extends DeepMemoryError {
|
|
|
165
165
|
this.reason = reason;
|
|
166
166
|
}
|
|
167
167
|
};
|
|
168
|
+
var OperationAbortedError = class extends DeepMemoryError {
|
|
169
|
+
operation;
|
|
170
|
+
constructor(operation) {
|
|
171
|
+
super(
|
|
172
|
+
"OPERATION_ABORTED",
|
|
173
|
+
`${operation} aborted by caller`,
|
|
174
|
+
`The caller's AbortSignal was triggered. Partial state from completed batches has been retained.`
|
|
175
|
+
);
|
|
176
|
+
this.name = "OperationAbortedError";
|
|
177
|
+
this.operation = operation;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
168
180
|
var EmbeddingProviderRequiredError = class extends DeepMemoryError {
|
|
169
181
|
constructor() {
|
|
170
182
|
super(
|
|
@@ -872,6 +884,7 @@ var EntityManager = class {
|
|
|
872
884
|
}
|
|
873
885
|
const batchSize = options?.batchSize ?? 50;
|
|
874
886
|
const errorThreshold = options?.errorThresholdToAbort;
|
|
887
|
+
const signal = options?.signal;
|
|
875
888
|
const firstPage = await this.storage.findEntities(this.repositoryId, { limit: 1, offset: 0 });
|
|
876
889
|
const total = firstPage.total;
|
|
877
890
|
let totalProcessed = 0;
|
|
@@ -879,6 +892,9 @@ var EntityManager = class {
|
|
|
879
892
|
const allErrors = [];
|
|
880
893
|
let offset = 0;
|
|
881
894
|
while (offset < total) {
|
|
895
|
+
if (signal?.aborted) {
|
|
896
|
+
throw new OperationAbortedError("reembedAll");
|
|
897
|
+
}
|
|
882
898
|
const page = await this.storage.findEntities(this.repositoryId, {
|
|
883
899
|
limit: batchSize,
|
|
884
900
|
offset
|
|
@@ -891,12 +907,15 @@ var EntityManager = class {
|
|
|
891
907
|
totalProcessed += result.processed;
|
|
892
908
|
totalFailed += result.failed;
|
|
893
909
|
allErrors.push(...result.errors);
|
|
894
|
-
options?.onProgress?.(totalProcessed, total, totalFailed);
|
|
910
|
+
await options?.onProgress?.(totalProcessed, total, totalFailed);
|
|
895
911
|
if (errorThreshold !== void 0 && totalFailed >= errorThreshold) {
|
|
896
912
|
allErrors.push({ entityId: "", error: `Aborted: error threshold of ${errorThreshold} reached (${totalFailed} failures)` });
|
|
897
913
|
break;
|
|
898
914
|
}
|
|
899
915
|
offset += page.items.length;
|
|
916
|
+
if (signal?.aborted) {
|
|
917
|
+
throw new OperationAbortedError("reembedAll");
|
|
918
|
+
}
|
|
900
919
|
const delayMs = options?.delayBetweenBatchesMs ?? 0;
|
|
901
920
|
if (delayMs > 0 && offset < total) {
|
|
902
921
|
await new Promise((resolve) => {
|
|
@@ -2263,7 +2282,13 @@ var MemoryRepository = class {
|
|
|
2263
2282
|
* the repository's embedding configuration is updated to the new values before
|
|
2264
2283
|
* re-embedding, so all subsequent entity writes use the new model/dimensionality.
|
|
2265
2284
|
*
|
|
2266
|
-
* Processes in batches with optional rate limiting.
|
|
2285
|
+
* Processes in batches with optional rate limiting.
|
|
2286
|
+
*
|
|
2287
|
+
* Progress is delivered via the optional `onProgress` callback. Most callers
|
|
2288
|
+
* should use {@link DeepMemory.reembedAll} instead, which wires this callback
|
|
2289
|
+
* to the global event bus so `reembed:*` events are reachable via
|
|
2290
|
+
* `DeepMemory.on()`.
|
|
2291
|
+
*
|
|
2267
2292
|
* Updates repository metadata with the new model ID and dimensions on completion.
|
|
2268
2293
|
*/
|
|
2269
2294
|
async reembedAll(options) {
|
|
@@ -2298,46 +2323,23 @@ var MemoryRepository = class {
|
|
|
2298
2323
|
}
|
|
2299
2324
|
});
|
|
2300
2325
|
}
|
|
2301
|
-
const
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2326
|
+
const result = await this.entityManager.reembedAll({
|
|
2327
|
+
batchSize: options?.batchSize,
|
|
2328
|
+
maxRetries: options?.maxRetries,
|
|
2329
|
+
errorThresholdToAbort: options?.errorThresholdToAbort,
|
|
2330
|
+
delayBetweenBatchesMs: options?.delayBetweenBatchesMs,
|
|
2331
|
+
signal: options?.signal,
|
|
2332
|
+
onProgress: async (processed, total, failed) => {
|
|
2333
|
+
await options?.onProgress?.({ processed, totalEntities: total, failed });
|
|
2334
|
+
}
|
|
2305
2335
|
});
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
await this.eventBus.emit("reembed:progress", {
|
|
2314
|
-
repositoryId: this.repositoryId,
|
|
2315
|
-
processed,
|
|
2316
|
-
totalEntities: total,
|
|
2317
|
-
failed
|
|
2318
|
-
});
|
|
2319
|
-
}
|
|
2320
|
-
});
|
|
2321
|
-
await this.storage.updateRepository(this.repositoryId, {
|
|
2322
|
-
metadata: {
|
|
2323
|
-
embeddingModelId: result.modelId,
|
|
2324
|
-
embeddingDimensions: result.dimensions
|
|
2325
|
-
}
|
|
2326
|
-
});
|
|
2327
|
-
await this.eventBus.emit("reembed:completed", {
|
|
2328
|
-
repositoryId: this.repositoryId,
|
|
2329
|
-
processed: result.processed,
|
|
2330
|
-
failed: result.failed,
|
|
2331
|
-
modelId: result.modelId
|
|
2332
|
-
});
|
|
2333
|
-
return result;
|
|
2334
|
-
} catch (err) {
|
|
2335
|
-
await this.eventBus.emit("reembed:failed", {
|
|
2336
|
-
repositoryId: this.repositoryId,
|
|
2337
|
-
error: err instanceof Error ? err.message : String(err)
|
|
2338
|
-
});
|
|
2339
|
-
throw err;
|
|
2340
|
-
}
|
|
2336
|
+
await this.storage.updateRepository(this.repositoryId, {
|
|
2337
|
+
metadata: {
|
|
2338
|
+
embeddingModelId: result.modelId,
|
|
2339
|
+
embeddingDimensions: result.dimensions
|
|
2340
|
+
}
|
|
2341
|
+
});
|
|
2342
|
+
return result;
|
|
2341
2343
|
}
|
|
2342
2344
|
// ─── Relationships ─────────────────────────────────────────────────
|
|
2343
2345
|
async createRelationships(inputs) {
|
|
@@ -3451,7 +3453,7 @@ var EventBus = class {
|
|
|
3451
3453
|
};
|
|
3452
3454
|
|
|
3453
3455
|
// src/portability/RepositoryExporter.ts
|
|
3454
|
-
var LIBRARY_VERSION = true ? "0.
|
|
3456
|
+
var LIBRARY_VERSION = true ? "0.15.0" : "0.1.0";
|
|
3455
3457
|
var RepositoryExporter = class {
|
|
3456
3458
|
storage;
|
|
3457
3459
|
provenance;
|
|
@@ -3805,11 +3807,18 @@ var RepositoryImporter = class {
|
|
|
3805
3807
|
storage;
|
|
3806
3808
|
actorId;
|
|
3807
3809
|
onProgress;
|
|
3810
|
+
signal;
|
|
3808
3811
|
migrationEngine = new MigrationEngine();
|
|
3809
3812
|
constructor(config) {
|
|
3810
3813
|
this.storage = config.storage;
|
|
3811
3814
|
this.actorId = config.actorId;
|
|
3812
3815
|
this.onProgress = config.onProgress;
|
|
3816
|
+
this.signal = config.signal;
|
|
3817
|
+
}
|
|
3818
|
+
throwIfAborted() {
|
|
3819
|
+
if (this.signal?.aborted) {
|
|
3820
|
+
throw new OperationAbortedError("import");
|
|
3821
|
+
}
|
|
3813
3822
|
}
|
|
3814
3823
|
/**
|
|
3815
3824
|
* Import an export archive according to the provided options.
|
|
@@ -3885,6 +3894,7 @@ var RepositoryImporter = class {
|
|
|
3885
3894
|
let chunksCompleted = 0;
|
|
3886
3895
|
const adaptiveConcurrencyHandle = options.bulk?.adaptiveConcurrencyHandle ?? {};
|
|
3887
3896
|
for await (const chunk of chunks) {
|
|
3897
|
+
this.throwIfAborted();
|
|
3888
3898
|
const bulkResult = await this.storage.importBulk(target.repositoryId, [chunk], {
|
|
3889
3899
|
...options.bulk,
|
|
3890
3900
|
skipExistenceCheck: true,
|
|
@@ -3966,6 +3976,7 @@ var RepositoryImporter = class {
|
|
|
3966
3976
|
let relationshipsSkipped = 0;
|
|
3967
3977
|
let chunksCompleted = 0;
|
|
3968
3978
|
for await (const chunk of chunks) {
|
|
3979
|
+
this.throwIfAborted();
|
|
3969
3980
|
if (chunk.entities) {
|
|
3970
3981
|
for (const entity of chunk.entities) {
|
|
3971
3982
|
let existing = await this.storage.getEntity(repositoryId, entity.id);
|
|
@@ -4384,22 +4395,31 @@ var DeepMemory = class {
|
|
|
4384
4395
|
const importer = new RepositoryImporter({
|
|
4385
4396
|
storage: this.storage,
|
|
4386
4397
|
actorId: this.provenance.getContext().actorId,
|
|
4387
|
-
onProgress: (progress) => this.globalEventBus.emit("import:progress", progress)
|
|
4398
|
+
onProgress: (progress) => this.globalEventBus.emit("import:progress", progress),
|
|
4399
|
+
signal: options.signal
|
|
4388
4400
|
});
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4401
|
+
try {
|
|
4402
|
+
const result = await importer.import(archive, options);
|
|
4403
|
+
if (result.success) {
|
|
4404
|
+
await this.globalEventBus.emit("import:completed", {
|
|
4405
|
+
repositoryId: result.repositoryId,
|
|
4406
|
+
entitiesImported: result.statistics.entitiesImported,
|
|
4407
|
+
relationshipsImported: result.statistics.relationshipsImported
|
|
4408
|
+
});
|
|
4409
|
+
} else {
|
|
4410
|
+
await this.globalEventBus.emit("import:failed", {
|
|
4411
|
+
repositoryId: result.repositoryId,
|
|
4412
|
+
error: result.warnings.map((w) => w.message).join("; ")
|
|
4413
|
+
});
|
|
4414
|
+
}
|
|
4415
|
+
return result;
|
|
4416
|
+
} catch (err) {
|
|
4397
4417
|
await this.globalEventBus.emit("import:failed", {
|
|
4398
|
-
repositoryId:
|
|
4399
|
-
error:
|
|
4418
|
+
repositoryId: options.target.repositoryId,
|
|
4419
|
+
error: err instanceof Error ? err.message : String(err)
|
|
4400
4420
|
});
|
|
4421
|
+
throw err;
|
|
4401
4422
|
}
|
|
4402
|
-
return result;
|
|
4403
4423
|
}
|
|
4404
4424
|
/**
|
|
4405
4425
|
* Stream a repository export as an async generator.
|
|
@@ -4468,23 +4488,77 @@ var DeepMemory = class {
|
|
|
4468
4488
|
const importer = new RepositoryImporter({
|
|
4469
4489
|
storage: this.storage,
|
|
4470
4490
|
actorId: this.provenance.getContext().actorId,
|
|
4471
|
-
onProgress: (progress) => this.globalEventBus.emit("import:progress", progress)
|
|
4491
|
+
onProgress: (progress) => this.globalEventBus.emit("import:progress", progress),
|
|
4492
|
+
signal: options.signal
|
|
4472
4493
|
});
|
|
4473
4494
|
await this.globalEventBus.emit("import:started", { repositoryId: options.target.repositoryId });
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4495
|
+
try {
|
|
4496
|
+
const result = await importer.importStream(header, chunks, options);
|
|
4497
|
+
if (result.success) {
|
|
4498
|
+
await this.globalEventBus.emit("import:completed", {
|
|
4499
|
+
repositoryId: result.repositoryId,
|
|
4500
|
+
entitiesImported: result.statistics.entitiesImported,
|
|
4501
|
+
relationshipsImported: result.statistics.relationshipsImported
|
|
4502
|
+
});
|
|
4503
|
+
} else {
|
|
4504
|
+
await this.globalEventBus.emit("import:failed", {
|
|
4505
|
+
repositoryId: result.repositoryId,
|
|
4506
|
+
error: result.warnings.map((w) => w.message).join("; ")
|
|
4507
|
+
});
|
|
4508
|
+
}
|
|
4509
|
+
return result;
|
|
4510
|
+
} catch (err) {
|
|
4482
4511
|
await this.globalEventBus.emit("import:failed", {
|
|
4483
|
-
repositoryId:
|
|
4484
|
-
error:
|
|
4512
|
+
repositoryId: options.target.repositoryId,
|
|
4513
|
+
error: err instanceof Error ? err.message : String(err)
|
|
4485
4514
|
});
|
|
4515
|
+
throw err;
|
|
4516
|
+
}
|
|
4517
|
+
}
|
|
4518
|
+
/**
|
|
4519
|
+
* Re-embed all entities in a repository, emitting `reembed:*` events on the
|
|
4520
|
+
* global event bus (reachable via {@link DeepMemory.on}).
|
|
4521
|
+
*
|
|
4522
|
+
* Mirrors the lifecycle of {@link importRepositoryStream}: emits
|
|
4523
|
+
* `reembed:started` up front, `reembed:progress` after every batch,
|
|
4524
|
+
* and either `reembed:completed` or `reembed:failed` at the end.
|
|
4525
|
+
*
|
|
4526
|
+
* `options.signal` is honoured at batch boundaries — any vectors already
|
|
4527
|
+
* written by completed batches are retained, and `reembed:failed` is emitted
|
|
4528
|
+
* with the abort error message.
|
|
4529
|
+
*/
|
|
4530
|
+
async reembedAll(repositoryId, options) {
|
|
4531
|
+
await this.ensureInitialized();
|
|
4532
|
+
const repo = await this.openRepository(repositoryId);
|
|
4533
|
+
const stats = await repo.getStats();
|
|
4534
|
+
await this.globalEventBus.emit("reembed:started", {
|
|
4535
|
+
repositoryId,
|
|
4536
|
+
totalEntities: stats.entityCount
|
|
4537
|
+
});
|
|
4538
|
+
try {
|
|
4539
|
+
const result = await repo.reembedAll({
|
|
4540
|
+
...options,
|
|
4541
|
+
onProgress: (progress) => this.globalEventBus.emit("reembed:progress", {
|
|
4542
|
+
repositoryId,
|
|
4543
|
+
processed: progress.processed,
|
|
4544
|
+
totalEntities: progress.totalEntities,
|
|
4545
|
+
failed: progress.failed
|
|
4546
|
+
})
|
|
4547
|
+
});
|
|
4548
|
+
await this.globalEventBus.emit("reembed:completed", {
|
|
4549
|
+
repositoryId,
|
|
4550
|
+
processed: result.processed,
|
|
4551
|
+
failed: result.failed,
|
|
4552
|
+
modelId: result.modelId
|
|
4553
|
+
});
|
|
4554
|
+
return result;
|
|
4555
|
+
} catch (err) {
|
|
4556
|
+
await this.globalEventBus.emit("reembed:failed", {
|
|
4557
|
+
repositoryId,
|
|
4558
|
+
error: err instanceof Error ? err.message : String(err)
|
|
4559
|
+
});
|
|
4560
|
+
throw err;
|
|
4486
4561
|
}
|
|
4487
|
-
return result;
|
|
4488
4562
|
}
|
|
4489
4563
|
/** Subscribe to global events */
|
|
4490
4564
|
on(event, handler) {
|
|
@@ -5585,6 +5659,7 @@ export {
|
|
|
5585
5659
|
InvalidInputError,
|
|
5586
5660
|
MemoryRepository,
|
|
5587
5661
|
NoOpEmbeddingProvider,
|
|
5662
|
+
OperationAbortedError,
|
|
5588
5663
|
OperationCancelledError,
|
|
5589
5664
|
ProviderError,
|
|
5590
5665
|
RelationshipConstraintError,
|