@anuma/sdk 9.1.5 → 9.1.6
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/expo/{chunk-XW3LYSDA.mjs → chunk-WRZTH4OS.mjs} +38 -13
- package/dist/expo/{consolidate-4CQJYKRK.mjs → consolidate-HKL5EGZT.mjs} +1 -1
- package/dist/expo/index.cjs +69 -28
- package/dist/expo/index.d.mts +9 -5
- package/dist/expo/index.d.ts +9 -5
- package/dist/expo/index.mjs +32 -16
- package/dist/react/{chunk-7QX4J7KV.mjs → chunk-RSA3S6OA.mjs} +38 -13
- package/dist/react/{consolidate-WLDYJF6J.mjs → consolidate-WFTPBHDV.mjs} +1 -1
- package/dist/react/index.cjs +80 -38
- package/dist/react/index.d.mts +9 -5
- package/dist/react/index.d.ts +9 -5
- package/dist/react/index.mjs +48 -31
- package/dist/server/{chunk-AU3Z7NBC.mjs → chunk-QEROZ4VH.mjs} +38 -13
- package/dist/server/{consolidate-B6OSCZU4.mjs → consolidate-PYED62LW.mjs} +1 -1
- package/dist/server/index.cjs +66 -25
- package/dist/server/index.d.mts +9 -5
- package/dist/server/index.d.ts +9 -5
- package/dist/server/index.mjs +29 -13
- package/package.json +1 -1
package/dist/server/index.mjs
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
taskTypeHeader,
|
|
14
14
|
validateEndpointOverride,
|
|
15
15
|
withInternalFlowMarker
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-QEROZ4VH.mjs";
|
|
17
17
|
import {
|
|
18
18
|
BASE_URL,
|
|
19
19
|
__commonJS,
|
|
@@ -27363,6 +27363,16 @@ async function updateVaultMemoryOp(ctx, id, opts) {
|
|
|
27363
27363
|
const probe = await ctx.vaultMemoryCollection.find(id);
|
|
27364
27364
|
if (probe.isDeleted || probe.supersededBy || !isOwnedByCtxUser(ctx, probe)) return null;
|
|
27365
27365
|
if (opts.freeFormOnly && isKinded(probe)) return null;
|
|
27366
|
+
const readStoredContent = probe._getRaw("content");
|
|
27367
|
+
if (opts.expectedContent !== void 0) {
|
|
27368
|
+
const current = await vaultMemoryToStored(
|
|
27369
|
+
probe,
|
|
27370
|
+
ctx.walletAddress,
|
|
27371
|
+
ctx.signMessage,
|
|
27372
|
+
ctx.embeddedWalletSigner
|
|
27373
|
+
);
|
|
27374
|
+
if (current.content !== opts.expectedContent) return null;
|
|
27375
|
+
}
|
|
27366
27376
|
const levelAfter = (current) => {
|
|
27367
27377
|
if (opts.level !== void 0) return opts.level;
|
|
27368
27378
|
if (opts.scope === void 0) return resolveMemoryLevel(current.level, current.scope);
|
|
@@ -27370,7 +27380,7 @@ async function updateVaultMemoryOp(ctx, id, opts) {
|
|
|
27370
27380
|
};
|
|
27371
27381
|
assertValidKindLevel(opts.kind !== void 0 ? opts.kind : probe.kind, levelAfter(probe));
|
|
27372
27382
|
const encryptedKindValue = await encryptKindValue(ctx, opts.kindValue);
|
|
27373
|
-
const encryptedContent = ctx.walletAddress && ctx.signMessage ? await encryptVaultMemoryContent(
|
|
27383
|
+
const encryptedContent = opts.content !== void 0 && ctx.walletAddress && ctx.signMessage ? await encryptVaultMemoryContent(
|
|
27374
27384
|
opts.content,
|
|
27375
27385
|
ctx.walletAddress,
|
|
27376
27386
|
ctx.signMessage,
|
|
@@ -27378,13 +27388,13 @@ async function updateVaultMemoryOp(ctx, id, opts) {
|
|
|
27378
27388
|
) : opts.content;
|
|
27379
27389
|
let stale = false;
|
|
27380
27390
|
const record = probe;
|
|
27381
|
-
const originalUpdatedAt = record.updatedAt.getTime();
|
|
27382
27391
|
await ctx.database.write(async () => {
|
|
27383
27392
|
await assertCanWrite2(ctx);
|
|
27384
|
-
if (record.isDeleted || record.supersededBy || !isOwnedByCtxUser(ctx, record) || opts.freeFormOnly && isKinded(record)) {
|
|
27393
|
+
if (record.isDeleted || record.supersededBy || !isOwnedByCtxUser(ctx, record) || opts.freeFormOnly && isKinded(record) || opts.expectedContent !== void 0 && record._getRaw("content") !== readStoredContent) {
|
|
27385
27394
|
stale = true;
|
|
27386
27395
|
return;
|
|
27387
27396
|
}
|
|
27397
|
+
const originalUpdatedAt = record.updatedAt.getTime();
|
|
27388
27398
|
const nextKind = opts.kind !== void 0 ? opts.kind : record.kind;
|
|
27389
27399
|
const nextLevel = levelAfter(record);
|
|
27390
27400
|
assertValidKindLevel(nextKind, nextLevel);
|
|
@@ -27400,7 +27410,7 @@ async function updateVaultMemoryOp(ctx, id, opts) {
|
|
|
27400
27410
|
replayedObservation = opts.observationSourceIds.every((id2) => observedSources.includes(id2));
|
|
27401
27411
|
}
|
|
27402
27412
|
await record.update((r) => {
|
|
27403
|
-
r._setRaw("content", encryptedContent);
|
|
27413
|
+
if (encryptedContent !== void 0) r._setRaw("content", encryptedContent);
|
|
27404
27414
|
if (opts.level !== void 0) {
|
|
27405
27415
|
r._setRaw("level", nextLevel);
|
|
27406
27416
|
r._setRaw("scope", scopeForLevel(nextLevel));
|
|
@@ -28167,7 +28177,7 @@ function classifyDecay(m, now, policy) {
|
|
|
28167
28177
|
if (m.source === "manual" || m.source === SOURCE_PHOTO) return "keep";
|
|
28168
28178
|
if (isTimeSensitiveType(m.factType) && m.eventTimeEnd !== null) {
|
|
28169
28179
|
if (m.eventTimeEnd < now - resolved.pastEventGraceMs) return "archive";
|
|
28170
|
-
|
|
28180
|
+
return "keep";
|
|
28171
28181
|
}
|
|
28172
28182
|
if (now - lastActivityAt(m) > ttlForType(m.factType, resolved)) return "archive";
|
|
28173
28183
|
return "keep";
|
|
@@ -31368,7 +31378,6 @@ async function retainWithPersistence(content, ctx, options = {}) {
|
|
|
31368
31378
|
const factTypeUpdate = pickFactTypeUpdate(existing, options.factType);
|
|
31369
31379
|
const resurrect = resurrectFields(existing);
|
|
31370
31380
|
const updated = await ctx.persistence.update(targetId, {
|
|
31371
|
-
content: existing.content,
|
|
31372
31381
|
freeFormOnly: true,
|
|
31373
31382
|
proofCountIncrement: 1,
|
|
31374
31383
|
observationSourceIds: options.sourceChunkIds,
|
|
@@ -31572,7 +31581,7 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
|
|
|
31572
31581
|
content: m.content,
|
|
31573
31582
|
similarity: m.similarity
|
|
31574
31583
|
}));
|
|
31575
|
-
const { consolidateMemory: doConsolidate } = await import("./consolidate-
|
|
31584
|
+
const { consolidateMemory: doConsolidate } = await import("./consolidate-PYED62LW.mjs");
|
|
31576
31585
|
const decision = await doConsolidate(trimmed, candidates, consolidateOptions);
|
|
31577
31586
|
if (decision.action === "create") return decision.fallbackReason ? null : { create: true };
|
|
31578
31587
|
if (decision.action === "supersede" && decision.content) {
|
|
@@ -31607,7 +31616,6 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
|
|
|
31607
31616
|
const factTypeUpdate = pickFactTypeUpdate(existing, options.factType);
|
|
31608
31617
|
const resurrect = resurrectFields(existing);
|
|
31609
31618
|
const updated = await ctx.persistence.update(decision.targetId, {
|
|
31610
|
-
content: existing.content,
|
|
31611
31619
|
freeFormOnly: true,
|
|
31612
31620
|
proofCountIncrement: 1,
|
|
31613
31621
|
observationSourceIds: options.sourceChunkIds,
|
|
@@ -31635,6 +31643,10 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
|
|
|
31635
31643
|
};
|
|
31636
31644
|
}
|
|
31637
31645
|
if (decision.action === "update" && decision.targetId && decision.content) {
|
|
31646
|
+
const expectedContent = candidates.find(
|
|
31647
|
+
(candidate) => candidate.id === decision.targetId
|
|
31648
|
+
)?.content;
|
|
31649
|
+
if (expectedContent === void 0) return null;
|
|
31638
31650
|
const existing = await ctx.persistence.get(decision.targetId);
|
|
31639
31651
|
if (!existing || existing.supersededBy) {
|
|
31640
31652
|
return abandonToRace(
|
|
@@ -31642,6 +31654,9 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
|
|
|
31642
31654
|
`update: target ${decision.targetId} ${existing ? "superseded" : "deleted"} before the write`
|
|
31643
31655
|
);
|
|
31644
31656
|
}
|
|
31657
|
+
if (existing.content !== expectedContent) {
|
|
31658
|
+
return abandonToRace(options, `update: target ${decision.targetId} edited before the write`);
|
|
31659
|
+
}
|
|
31645
31660
|
const mergedSourceIds = unionStrings(
|
|
31646
31661
|
existing.sourceChunkIds ?? [],
|
|
31647
31662
|
options.sourceChunkIds ?? []
|
|
@@ -31654,6 +31669,7 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
|
|
|
31654
31669
|
const resurrect = resurrectFields(existing);
|
|
31655
31670
|
const updated = await ctx.persistence.update(decision.targetId, {
|
|
31656
31671
|
content: decision.content,
|
|
31672
|
+
expectedContent,
|
|
31657
31673
|
freeFormOnly: true,
|
|
31658
31674
|
proofCountIncrement: 1,
|
|
31659
31675
|
observationSourceIds: options.sourceChunkIds,
|
|
@@ -31666,10 +31682,10 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
|
|
|
31666
31682
|
...factTypeUpdate !== void 0 && { factType: factTypeUpdate }
|
|
31667
31683
|
});
|
|
31668
31684
|
if (!updated) {
|
|
31669
|
-
await assertMergeTargetGoneOrThrow(ctx, decision.targetId);
|
|
31685
|
+
await assertMergeTargetGoneOrThrow(ctx, decision.targetId, expectedContent);
|
|
31670
31686
|
return abandonToRace(
|
|
31671
31687
|
options,
|
|
31672
|
-
`update: target ${decision.targetId}
|
|
31688
|
+
`update: target ${decision.targetId} changed mid-write (consolidated rewrite lost)`
|
|
31673
31689
|
);
|
|
31674
31690
|
}
|
|
31675
31691
|
cacheRowVector(
|
|
@@ -31696,9 +31712,9 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
|
|
|
31696
31712
|
);
|
|
31697
31713
|
return null;
|
|
31698
31714
|
}
|
|
31699
|
-
async function assertMergeTargetGoneOrThrow(ctx, targetId) {
|
|
31715
|
+
async function assertMergeTargetGoneOrThrow(ctx, targetId, expectedContent) {
|
|
31700
31716
|
const stillExists = await (ctx.persistence.getFresh ? ctx.persistence.getFresh(targetId) : ctx.persistence.get(targetId));
|
|
31701
|
-
if (stillExists && (stillExists.kind === null || stillExists.kind === void 0)) {
|
|
31717
|
+
if (stillExists && (stillExists.kind === null || stillExists.kind === void 0) && (expectedContent === void 0 || stillExists.content === expectedContent)) {
|
|
31702
31718
|
throw new RetainError(
|
|
31703
31719
|
"merge-not-persisted",
|
|
31704
31720
|
`retain: merge into memory ${targetId} failed to persist`
|