@utaba/deep-memory 0.15.0 → 0.16.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.cjs +39 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +39 -5
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.cts +10 -1
- package/dist/types/index.d.ts +10 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -894,10 +894,15 @@ var EntityManager = class {
|
|
|
894
894
|
attempt++;
|
|
895
895
|
if (attempt > maxRetries) {
|
|
896
896
|
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
897
|
+
const failureMessage = `embedBatch failed after ${maxRetries} retries: ${errorMsg}`;
|
|
898
|
+
const failed = entries.map(([id]) => ({ entityId: id, error: failureMessage }));
|
|
899
|
+
for (const { entityId, error } of failed) {
|
|
900
|
+
await options?.onItemFailed?.(entityId, error);
|
|
901
|
+
}
|
|
897
902
|
return {
|
|
898
903
|
processed: 0,
|
|
899
904
|
failed: entries.length,
|
|
900
|
-
errors:
|
|
905
|
+
errors: failed,
|
|
901
906
|
modelId: this.embedding.modelId(),
|
|
902
907
|
dimensions: this.embedding.dimensions()
|
|
903
908
|
};
|
|
@@ -920,7 +925,9 @@ var EntityManager = class {
|
|
|
920
925
|
});
|
|
921
926
|
processed++;
|
|
922
927
|
} catch (err) {
|
|
923
|
-
|
|
928
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
929
|
+
errors.push({ entityId: id, error: errorMessage });
|
|
930
|
+
await options?.onItemFailed?.(id, errorMessage);
|
|
924
931
|
}
|
|
925
932
|
}
|
|
926
933
|
return {
|
|
@@ -963,7 +970,8 @@ var EntityManager = class {
|
|
|
963
970
|
if (page.items.length === 0) break;
|
|
964
971
|
const ids = page.items.map((e) => e.id);
|
|
965
972
|
const result = await this.reembedEntities(ids, {
|
|
966
|
-
maxRetries: options?.maxRetries
|
|
973
|
+
maxRetries: options?.maxRetries,
|
|
974
|
+
onItemFailed: options?.onItemFailed
|
|
967
975
|
});
|
|
968
976
|
totalProcessed += result.processed;
|
|
969
977
|
totalFailed += result.failed;
|
|
@@ -2392,6 +2400,9 @@ var MemoryRepository = class {
|
|
|
2392
2400
|
signal: options?.signal,
|
|
2393
2401
|
onProgress: async (processed, total, failed) => {
|
|
2394
2402
|
await options?.onProgress?.({ processed, totalEntities: total, failed });
|
|
2403
|
+
},
|
|
2404
|
+
onItemFailed: async (entityId, error) => {
|
|
2405
|
+
await options?.onItemFailed?.({ entityId, error });
|
|
2395
2406
|
}
|
|
2396
2407
|
});
|
|
2397
2408
|
await this.storage.updateRepository(this.repositoryId, {
|
|
@@ -3514,7 +3525,7 @@ var EventBus = class {
|
|
|
3514
3525
|
};
|
|
3515
3526
|
|
|
3516
3527
|
// src/portability/RepositoryExporter.ts
|
|
3517
|
-
var LIBRARY_VERSION = true ? "0.
|
|
3528
|
+
var LIBRARY_VERSION = true ? "0.16.0" : "0.1.0";
|
|
3518
3529
|
var RepositoryExporter = class {
|
|
3519
3530
|
storage;
|
|
3520
3531
|
provenance;
|
|
@@ -3868,12 +3879,14 @@ var RepositoryImporter = class {
|
|
|
3868
3879
|
storage;
|
|
3869
3880
|
actorId;
|
|
3870
3881
|
onProgress;
|
|
3882
|
+
onItemFailed;
|
|
3871
3883
|
signal;
|
|
3872
3884
|
migrationEngine = new MigrationEngine();
|
|
3873
3885
|
constructor(config) {
|
|
3874
3886
|
this.storage = config.storage;
|
|
3875
3887
|
this.actorId = config.actorId;
|
|
3876
3888
|
this.onProgress = config.onProgress;
|
|
3889
|
+
this.onItemFailed = config.onItemFailed;
|
|
3877
3890
|
this.signal = config.signal;
|
|
3878
3891
|
}
|
|
3879
3892
|
throwIfAborted() {
|
|
@@ -3970,6 +3983,8 @@ var RepositoryImporter = class {
|
|
|
3970
3983
|
message: `Failed to import ${e.item}: ${e.error}`,
|
|
3971
3984
|
id: e.item
|
|
3972
3985
|
});
|
|
3986
|
+
const itemType = chunk.entities?.some((x) => x.id === e.item) ? "entity" : chunk.relationships?.some((x) => x.id === e.item) ? "relationship" : "entity";
|
|
3987
|
+
await this.onItemFailed?.({ itemId: e.item, itemType, error: e.error });
|
|
3973
3988
|
}
|
|
3974
3989
|
await this.onProgress?.({
|
|
3975
3990
|
repositoryId: target.repositoryId,
|
|
@@ -4106,11 +4121,13 @@ var RepositoryImporter = class {
|
|
|
4106
4121
|
const targetExists = await this.storage.getEntity(repositoryId, rel.targetEntityId);
|
|
4107
4122
|
if (!sourceExists || !targetExists) {
|
|
4108
4123
|
relationshipsSkipped++;
|
|
4124
|
+
const errorMsg = `source or target entity missing`;
|
|
4109
4125
|
warnings.push({
|
|
4110
4126
|
code: "relationship_orphaned",
|
|
4111
|
-
message: `Relationship "${rel.id}" skipped \u2014
|
|
4127
|
+
message: `Relationship "${rel.id}" skipped \u2014 ${errorMsg}`,
|
|
4112
4128
|
relationshipId: rel.id
|
|
4113
4129
|
});
|
|
4130
|
+
await this.onItemFailed?.({ itemId: rel.id, itemType: "relationship", error: errorMsg });
|
|
4114
4131
|
} else {
|
|
4115
4132
|
try {
|
|
4116
4133
|
await this.storage.createRelationship(repositoryId, rel);
|
|
@@ -4457,6 +4474,12 @@ var DeepMemory = class {
|
|
|
4457
4474
|
storage: this.storage,
|
|
4458
4475
|
actorId: this.provenance.getContext().actorId,
|
|
4459
4476
|
onProgress: (progress) => this.globalEventBus.emit("import:progress", progress),
|
|
4477
|
+
onItemFailed: (failure) => this.globalEventBus.emit("import:item-failed", {
|
|
4478
|
+
repositoryId: options.target.repositoryId,
|
|
4479
|
+
itemId: failure.itemId,
|
|
4480
|
+
itemType: failure.itemType,
|
|
4481
|
+
error: failure.error
|
|
4482
|
+
}),
|
|
4460
4483
|
signal: options.signal
|
|
4461
4484
|
});
|
|
4462
4485
|
try {
|
|
@@ -4550,6 +4573,12 @@ var DeepMemory = class {
|
|
|
4550
4573
|
storage: this.storage,
|
|
4551
4574
|
actorId: this.provenance.getContext().actorId,
|
|
4552
4575
|
onProgress: (progress) => this.globalEventBus.emit("import:progress", progress),
|
|
4576
|
+
onItemFailed: (failure) => this.globalEventBus.emit("import:item-failed", {
|
|
4577
|
+
repositoryId: options.target.repositoryId,
|
|
4578
|
+
itemId: failure.itemId,
|
|
4579
|
+
itemType: failure.itemType,
|
|
4580
|
+
error: failure.error
|
|
4581
|
+
}),
|
|
4553
4582
|
signal: options.signal
|
|
4554
4583
|
});
|
|
4555
4584
|
await this.globalEventBus.emit("import:started", { repositoryId: options.target.repositoryId });
|
|
@@ -4604,6 +4633,11 @@ var DeepMemory = class {
|
|
|
4604
4633
|
processed: progress.processed,
|
|
4605
4634
|
totalEntities: progress.totalEntities,
|
|
4606
4635
|
failed: progress.failed
|
|
4636
|
+
}),
|
|
4637
|
+
onItemFailed: (failure) => this.globalEventBus.emit("reembed:item-failed", {
|
|
4638
|
+
repositoryId,
|
|
4639
|
+
entityId: failure.entityId,
|
|
4640
|
+
error: failure.error
|
|
4607
4641
|
})
|
|
4608
4642
|
});
|
|
4609
4643
|
await this.globalEventBus.emit("reembed:completed", {
|