@anuma/sdk 6.2.0 → 6.3.1
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-NH5VY3G7.mjs → chunk-PBCULYOW.mjs} +21 -1
- package/dist/expo/index.cjs +201 -74
- package/dist/expo/index.d.mts +161 -3
- package/dist/expo/index.d.ts +161 -3
- package/dist/expo/index.mjs +166 -67
- package/dist/expo/{recall-ZIKIYARO.mjs → recall-UVM2366D.mjs} +1 -1
- package/dist/react/{chunk-EMVLDEPB.mjs → chunk-TI3UVQPF.mjs} +21 -1
- package/dist/react/index.cjs +201 -74
- package/dist/react/index.d.mts +161 -3
- package/dist/react/index.d.ts +161 -3
- package/dist/react/index.mjs +166 -67
- package/dist/react/{recall-B7POS7NA.mjs → recall-PCM7H5TA.mjs} +1 -1
- package/dist/server/{chunk-6JS7SY6A.mjs → chunk-S5WEN7TE.mjs} +21 -1
- package/dist/server/index.cjs +201 -74
- package/dist/server/index.d.mts +161 -3
- package/dist/server/index.d.ts +161 -3
- package/dist/server/index.mjs +166 -67
- package/dist/server/{recall-IM6RLRI6.mjs → recall-BQSCJBGI.mjs} +1 -1
- package/package.json +1 -1
package/dist/server/index.mjs
CHANGED
|
@@ -63,6 +63,7 @@ import {
|
|
|
63
63
|
encryptDataWithKey,
|
|
64
64
|
encryptField,
|
|
65
65
|
encryptJsonField,
|
|
66
|
+
encryptVaultMemoryContent,
|
|
66
67
|
exportPublicKey,
|
|
67
68
|
generateConversationId,
|
|
68
69
|
generateEmbedding,
|
|
@@ -93,6 +94,7 @@ import {
|
|
|
93
94
|
makeSyntheticStoredMessage,
|
|
94
95
|
onClearAllEncryptionState,
|
|
95
96
|
onKeyAvailable,
|
|
97
|
+
parseMedia,
|
|
96
98
|
preEmbedVaultMemories,
|
|
97
99
|
prepareVaultCandidates,
|
|
98
100
|
rankPreparedVaultCandidates,
|
|
@@ -137,7 +139,7 @@ import {
|
|
|
137
139
|
updateVaultMemoryOp,
|
|
138
140
|
upsertMessageOp,
|
|
139
141
|
vaultMemoryToStored
|
|
140
|
-
} from "./chunk-
|
|
142
|
+
} from "./chunk-S5WEN7TE.mjs";
|
|
141
143
|
import {
|
|
142
144
|
createStreamingDeAnonymizer,
|
|
143
145
|
notifyConsolidationFallback,
|
|
@@ -1139,6 +1141,9 @@ __decorateClass([
|
|
|
1139
1141
|
__decorateClass([
|
|
1140
1142
|
(0, import_decorators6.field)("topics_updated_at")
|
|
1141
1143
|
], VaultMemory.prototype, "topicsUpdatedAt", 2);
|
|
1144
|
+
__decorateClass([
|
|
1145
|
+
(0, import_decorators6.field)("media")
|
|
1146
|
+
], VaultMemory.prototype, "media", 2);
|
|
1142
1147
|
__decorateClass([
|
|
1143
1148
|
(0, import_decorators6.field)("topics_extracted_at")
|
|
1144
1149
|
], VaultMemory.prototype, "topicsExtractedAt", 2);
|
|
@@ -1322,7 +1327,7 @@ __decorateClass([
|
|
|
1322
1327
|
], VaultFolder.prototype, "context", 2);
|
|
1323
1328
|
|
|
1324
1329
|
// src/lib/db/schema.ts
|
|
1325
|
-
var SDK_SCHEMA_VERSION =
|
|
1330
|
+
var SDK_SCHEMA_VERSION = 45;
|
|
1326
1331
|
var sdkSchema = (0, import_watermelondb12.appSchema)({
|
|
1327
1332
|
version: SDK_SCHEMA_VERSION,
|
|
1328
1333
|
tables: [
|
|
@@ -1470,6 +1475,18 @@ var sdkSchema = (0, import_watermelondb12.appSchema)({
|
|
|
1470
1475
|
// paths key on `updated_at` — so without this a topic-only change would
|
|
1471
1476
|
// neither upload nor merge. Null = `topics` never written.
|
|
1472
1477
|
{ name: "topics_updated_at", type: "number", isOptional: true },
|
|
1478
|
+
// The photo(s) a SERVER-EXTRACTED memory was read out of, as a JSON
|
|
1479
|
+
// array of `{feed_item_id, object_key}` — exactly what
|
|
1480
|
+
// GET /api/memories/published returns in `media[]`. Enough to render the
|
|
1481
|
+
// source image without a second round-trip per memory.
|
|
1482
|
+
//
|
|
1483
|
+
// A JSON column rather than a join table: nothing on the client ever
|
|
1484
|
+
// queries BY photo (the only direction is memory -> render its image),
|
|
1485
|
+
// so a table would add a sync lane and a local-id space to serve a
|
|
1486
|
+
// question nobody asks. `topics` and `source_chunk_ids` set the
|
|
1487
|
+
// precedent for a list that is only ever read back whole. Null on
|
|
1488
|
+
// anything not extracted from a photo.
|
|
1489
|
+
{ name: "media", type: "string", isOptional: true },
|
|
1473
1490
|
// Unix ms of the last LLM topic-extraction pass over this memory's
|
|
1474
1491
|
// content. Null = never extracted standalone (legacy rows with entity
|
|
1475
1492
|
// links are grandfathered — see getMemoriesNeedingTopicExtractionOp).
|
|
@@ -2304,6 +2321,20 @@ var sdkMigrations = (0, import_migrations.schemaMigrations)({
|
|
|
2304
2321
|
columns: [{ name: "origin", type: "string", isOptional: true }]
|
|
2305
2322
|
})
|
|
2306
2323
|
]
|
|
2324
|
+
},
|
|
2325
|
+
// v44 -> v45: `media` on memory_vault — the photo(s) a server-extracted
|
|
2326
|
+
// memory was read out of, as JSON `[{feed_item_id, object_key}]`, mirroring
|
|
2327
|
+
// the `media[]` that GET /api/memories/published already returns. Existing
|
|
2328
|
+
// rows keep NULL, which is the correct value for every memory that did not
|
|
2329
|
+
// come from a photo (i.e. all of them until photo ingest runs).
|
|
2330
|
+
{
|
|
2331
|
+
toVersion: 45,
|
|
2332
|
+
steps: [
|
|
2333
|
+
(0, import_migrations.addColumns)({
|
|
2334
|
+
table: "memory_vault",
|
|
2335
|
+
columns: [{ name: "media", type: "string", isOptional: true }]
|
|
2336
|
+
})
|
|
2337
|
+
]
|
|
2307
2338
|
}
|
|
2308
2339
|
]
|
|
2309
2340
|
});
|
|
@@ -3582,6 +3613,133 @@ async function cleanupConversationSummary(database, conversationId) {
|
|
|
3582
3613
|
}
|
|
3583
3614
|
}
|
|
3584
3615
|
|
|
3616
|
+
// src/lib/memory/decay.ts
|
|
3617
|
+
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
3618
|
+
var SHORT_TTL_MS = 30 * DAY_MS;
|
|
3619
|
+
var MEDIUM_TTL_MS = 180 * DAY_MS;
|
|
3620
|
+
var SOURCE_PHOTO = "photo";
|
|
3621
|
+
var NEVER_TTL_MS = Number.POSITIVE_INFINITY;
|
|
3622
|
+
var HARD_DELETE_WINDOW_MS = 30 * DAY_MS;
|
|
3623
|
+
var PAST_EVENT_GRACE_MS = 7 * DAY_MS;
|
|
3624
|
+
var DEFAULT_DECAY_POLICY = {
|
|
3625
|
+
ttlByType: {
|
|
3626
|
+
identity: NEVER_TTL_MS,
|
|
3627
|
+
preference: NEVER_TTL_MS,
|
|
3628
|
+
relationship: NEVER_TTL_MS,
|
|
3629
|
+
constraint: NEVER_TTL_MS,
|
|
3630
|
+
plan: SHORT_TTL_MS,
|
|
3631
|
+
ongoing_context: SHORT_TTL_MS,
|
|
3632
|
+
other: MEDIUM_TTL_MS
|
|
3633
|
+
},
|
|
3634
|
+
fallbackTtlMs: MEDIUM_TTL_MS,
|
|
3635
|
+
hardDeleteWindowMs: HARD_DELETE_WINDOW_MS,
|
|
3636
|
+
pastEventGraceMs: PAST_EVENT_GRACE_MS
|
|
3637
|
+
};
|
|
3638
|
+
function resolvePolicy(policy) {
|
|
3639
|
+
if (!policy) return DEFAULT_DECAY_POLICY;
|
|
3640
|
+
return {
|
|
3641
|
+
ttlByType: { ...DEFAULT_DECAY_POLICY.ttlByType, ...policy.ttlByType },
|
|
3642
|
+
fallbackTtlMs: policy.fallbackTtlMs ?? DEFAULT_DECAY_POLICY.fallbackTtlMs,
|
|
3643
|
+
hardDeleteWindowMs: policy.hardDeleteWindowMs ?? DEFAULT_DECAY_POLICY.hardDeleteWindowMs,
|
|
3644
|
+
pastEventGraceMs: policy.pastEventGraceMs ?? DEFAULT_DECAY_POLICY.pastEventGraceMs
|
|
3645
|
+
};
|
|
3646
|
+
}
|
|
3647
|
+
function ttlForType(factType, policy) {
|
|
3648
|
+
const resolved = resolvePolicy(policy);
|
|
3649
|
+
if (factType === null) return resolved.fallbackTtlMs;
|
|
3650
|
+
return resolved.ttlByType[factType] ?? resolved.fallbackTtlMs;
|
|
3651
|
+
}
|
|
3652
|
+
function isTimeSensitiveType(factType) {
|
|
3653
|
+
return factType === "plan" || factType === "ongoing_context";
|
|
3654
|
+
}
|
|
3655
|
+
function hasFiniteTimestamps(m, now) {
|
|
3656
|
+
return Number.isFinite(now) && Number.isFinite(m.updatedAt) && (m.archivedAt === null || Number.isFinite(m.archivedAt));
|
|
3657
|
+
}
|
|
3658
|
+
function classifyDecay(m, now, policy) {
|
|
3659
|
+
const resolved = resolvePolicy(policy);
|
|
3660
|
+
if (!hasFiniteTimestamps(m, now)) {
|
|
3661
|
+
getLogger().warn("[memory/decay] non-finite timestamp on a memory row; keeping it", {
|
|
3662
|
+
now,
|
|
3663
|
+
updatedAt: m.updatedAt,
|
|
3664
|
+
archivedAt: m.archivedAt,
|
|
3665
|
+
factType: m.factType
|
|
3666
|
+
});
|
|
3667
|
+
return "keep";
|
|
3668
|
+
}
|
|
3669
|
+
if (m.archivedAt !== null) {
|
|
3670
|
+
return now - m.archivedAt > resolved.hardDeleteWindowMs ? "delete" : "keep";
|
|
3671
|
+
}
|
|
3672
|
+
if (m.source === "manual" || m.source === SOURCE_PHOTO) return "keep";
|
|
3673
|
+
if (isTimeSensitiveType(m.factType) && m.eventTimeEnd !== null) {
|
|
3674
|
+
if (m.eventTimeEnd < now - resolved.pastEventGraceMs) return "archive";
|
|
3675
|
+
if (m.eventTimeEnd >= now) return "keep";
|
|
3676
|
+
}
|
|
3677
|
+
if (now - m.updatedAt > ttlForType(m.factType, resolved)) return "archive";
|
|
3678
|
+
return "keep";
|
|
3679
|
+
}
|
|
3680
|
+
|
|
3681
|
+
// src/lib/db/memoryVault/photoIngest.ts
|
|
3682
|
+
var PHOTO_MEMORY_ID_PREFIX = "photo:";
|
|
3683
|
+
async function ingestPublishedPhotoMemoriesOp(ctx, rows) {
|
|
3684
|
+
const byId = /* @__PURE__ */ new Map();
|
|
3685
|
+
for (const r of rows) {
|
|
3686
|
+
if (typeof r.memoryId !== "string" || !r.memoryId.startsWith(PHOTO_MEMORY_ID_PREFIX)) continue;
|
|
3687
|
+
if (!byId.has(r.memoryId)) byId.set(r.memoryId, r);
|
|
3688
|
+
}
|
|
3689
|
+
const photoRows = [...byId.values()];
|
|
3690
|
+
if (photoRows.length === 0) return { inserted: 0, skipped: 0 };
|
|
3691
|
+
const known = await ctx.vaultMemoryCollection.query().fetchIds().then((ids) => new Set(ids));
|
|
3692
|
+
const candidates = photoRows.filter((r) => !known.has(r.memoryId));
|
|
3693
|
+
if (candidates.length === 0) return { inserted: 0, skipped: photoRows.length };
|
|
3694
|
+
const fresh = candidates;
|
|
3695
|
+
const contents = await Promise.all(
|
|
3696
|
+
fresh.map(async (r) => {
|
|
3697
|
+
if (ctx.walletAddress && ctx.signMessage) {
|
|
3698
|
+
return encryptVaultMemoryContent(
|
|
3699
|
+
r.text,
|
|
3700
|
+
ctx.walletAddress,
|
|
3701
|
+
ctx.signMessage,
|
|
3702
|
+
ctx.embeddedWalletSigner
|
|
3703
|
+
);
|
|
3704
|
+
}
|
|
3705
|
+
return r.text;
|
|
3706
|
+
})
|
|
3707
|
+
);
|
|
3708
|
+
const now = Date.now();
|
|
3709
|
+
let inserted = 0;
|
|
3710
|
+
await ctx.database.write(async () => {
|
|
3711
|
+
const present = new Set(await ctx.vaultMemoryCollection.query().fetchIds());
|
|
3712
|
+
const writable = fresh.map((row, i) => ({ row, content: contents[i] })).filter(({ row }) => !present.has(row.memoryId));
|
|
3713
|
+
inserted = writable.length;
|
|
3714
|
+
if (writable.length === 0) return;
|
|
3715
|
+
const prepared = writable.map(
|
|
3716
|
+
({ row, content }) => ctx.vaultMemoryCollection.prepareCreate((record) => {
|
|
3717
|
+
record._raw.id = row.memoryId;
|
|
3718
|
+
record._setRaw("content", content);
|
|
3719
|
+
record._setRaw("scope", "private");
|
|
3720
|
+
record._setRaw("folder_id", null);
|
|
3721
|
+
record._setRaw("user_id", ctx.userId ?? null);
|
|
3722
|
+
record._setRaw("is_deleted", false);
|
|
3723
|
+
record._setRaw("proof_count", 1);
|
|
3724
|
+
record._setRaw("source", SOURCE_PHOTO);
|
|
3725
|
+
record._setRaw(
|
|
3726
|
+
"media",
|
|
3727
|
+
row.media && row.media.length > 0 ? JSON.stringify(row.media) : null
|
|
3728
|
+
);
|
|
3729
|
+
record._setRaw("visibility", "public");
|
|
3730
|
+
record._setRaw("published_at", now);
|
|
3731
|
+
if (row.eventTime) {
|
|
3732
|
+
record._setRaw("event_time_start", row.eventTime.start ?? null);
|
|
3733
|
+
record._setRaw("event_time_end", row.eventTime.end ?? null);
|
|
3734
|
+
record._setRaw("event_time_kind", row.eventTime.kind ?? null);
|
|
3735
|
+
}
|
|
3736
|
+
})
|
|
3737
|
+
);
|
|
3738
|
+
await ctx.database.batch(...prepared);
|
|
3739
|
+
});
|
|
3740
|
+
return { inserted, skipped: photoRows.length - inserted };
|
|
3741
|
+
}
|
|
3742
|
+
|
|
3585
3743
|
// src/lib/db/project/operations.ts
|
|
3586
3744
|
var import_watermelondb15 = __toESM(require_watermelondb());
|
|
3587
3745
|
|
|
@@ -5742,6 +5900,9 @@ async function extractFacts(messages, options) {
|
|
|
5742
5900
|
...options.apiKey !== void 0 && { apiKey: options.apiKey },
|
|
5743
5901
|
...options.getToken !== void 0 && { getToken: options.getToken },
|
|
5744
5902
|
...options.baseUrl !== void 0 && { baseUrl: options.baseUrl },
|
|
5903
|
+
...options.endpointOverride !== void 0 && {
|
|
5904
|
+
endpointOverride: options.endpointOverride
|
|
5905
|
+
},
|
|
5745
5906
|
model: options.model ?? DEFAULT_EXTRACTION_MODEL,
|
|
5746
5907
|
systemPrompt: SYSTEM_PROMPT2,
|
|
5747
5908
|
userMessage: `Today's date is ${today}. Resolve any relative dates ("yesterday", "next week") against it.
|
|
@@ -6252,70 +6413,6 @@ function createChunkVectorCache(maxSize = DEFAULT_CHUNK_CACHE_SIZE) {
|
|
|
6252
6413
|
return new LRUCache(maxSize);
|
|
6253
6414
|
}
|
|
6254
6415
|
|
|
6255
|
-
// src/lib/memory/decay.ts
|
|
6256
|
-
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
6257
|
-
var SHORT_TTL_MS = 30 * DAY_MS;
|
|
6258
|
-
var MEDIUM_TTL_MS = 180 * DAY_MS;
|
|
6259
|
-
var NEVER_TTL_MS = Number.POSITIVE_INFINITY;
|
|
6260
|
-
var HARD_DELETE_WINDOW_MS = 30 * DAY_MS;
|
|
6261
|
-
var PAST_EVENT_GRACE_MS = 7 * DAY_MS;
|
|
6262
|
-
var DEFAULT_DECAY_POLICY = {
|
|
6263
|
-
ttlByType: {
|
|
6264
|
-
identity: NEVER_TTL_MS,
|
|
6265
|
-
preference: NEVER_TTL_MS,
|
|
6266
|
-
relationship: NEVER_TTL_MS,
|
|
6267
|
-
constraint: NEVER_TTL_MS,
|
|
6268
|
-
plan: SHORT_TTL_MS,
|
|
6269
|
-
ongoing_context: SHORT_TTL_MS,
|
|
6270
|
-
other: MEDIUM_TTL_MS
|
|
6271
|
-
},
|
|
6272
|
-
fallbackTtlMs: MEDIUM_TTL_MS,
|
|
6273
|
-
hardDeleteWindowMs: HARD_DELETE_WINDOW_MS,
|
|
6274
|
-
pastEventGraceMs: PAST_EVENT_GRACE_MS
|
|
6275
|
-
};
|
|
6276
|
-
function resolvePolicy(policy) {
|
|
6277
|
-
if (!policy) return DEFAULT_DECAY_POLICY;
|
|
6278
|
-
return {
|
|
6279
|
-
ttlByType: { ...DEFAULT_DECAY_POLICY.ttlByType, ...policy.ttlByType },
|
|
6280
|
-
fallbackTtlMs: policy.fallbackTtlMs ?? DEFAULT_DECAY_POLICY.fallbackTtlMs,
|
|
6281
|
-
hardDeleteWindowMs: policy.hardDeleteWindowMs ?? DEFAULT_DECAY_POLICY.hardDeleteWindowMs,
|
|
6282
|
-
pastEventGraceMs: policy.pastEventGraceMs ?? DEFAULT_DECAY_POLICY.pastEventGraceMs
|
|
6283
|
-
};
|
|
6284
|
-
}
|
|
6285
|
-
function ttlForType(factType, policy) {
|
|
6286
|
-
const resolved = resolvePolicy(policy);
|
|
6287
|
-
if (factType === null) return resolved.fallbackTtlMs;
|
|
6288
|
-
return resolved.ttlByType[factType] ?? resolved.fallbackTtlMs;
|
|
6289
|
-
}
|
|
6290
|
-
function isTimeSensitiveType(factType) {
|
|
6291
|
-
return factType === "plan" || factType === "ongoing_context";
|
|
6292
|
-
}
|
|
6293
|
-
function hasFiniteTimestamps(m, now) {
|
|
6294
|
-
return Number.isFinite(now) && Number.isFinite(m.updatedAt) && (m.archivedAt === null || Number.isFinite(m.archivedAt));
|
|
6295
|
-
}
|
|
6296
|
-
function classifyDecay(m, now, policy) {
|
|
6297
|
-
const resolved = resolvePolicy(policy);
|
|
6298
|
-
if (!hasFiniteTimestamps(m, now)) {
|
|
6299
|
-
getLogger().warn("[memory/decay] non-finite timestamp on a memory row; keeping it", {
|
|
6300
|
-
now,
|
|
6301
|
-
updatedAt: m.updatedAt,
|
|
6302
|
-
archivedAt: m.archivedAt,
|
|
6303
|
-
factType: m.factType
|
|
6304
|
-
});
|
|
6305
|
-
return "keep";
|
|
6306
|
-
}
|
|
6307
|
-
if (m.archivedAt !== null) {
|
|
6308
|
-
return now - m.archivedAt > resolved.hardDeleteWindowMs ? "delete" : "keep";
|
|
6309
|
-
}
|
|
6310
|
-
if (m.source === "manual") return "keep";
|
|
6311
|
-
if (isTimeSensitiveType(m.factType) && m.eventTimeEnd !== null) {
|
|
6312
|
-
if (m.eventTimeEnd < now - resolved.pastEventGraceMs) return "archive";
|
|
6313
|
-
if (m.eventTimeEnd >= now) return "keep";
|
|
6314
|
-
}
|
|
6315
|
-
if (now - m.updatedAt > ttlForType(m.factType, resolved)) return "archive";
|
|
6316
|
-
return "keep";
|
|
6317
|
-
}
|
|
6318
|
-
|
|
6319
6416
|
// src/lib/memory/decayClassifier.ts
|
|
6320
6417
|
var DEFAULT_MODEL2 = "inclusionai/ling-2.6-flash";
|
|
6321
6418
|
var DEFAULT_ATTEMPTS2 = 2;
|
|
@@ -6413,7 +6510,7 @@ function toDecayInput(c) {
|
|
|
6413
6510
|
};
|
|
6414
6511
|
}
|
|
6415
6512
|
function isBorderline(input) {
|
|
6416
|
-
if (input.source === "manual") return false;
|
|
6513
|
+
if (input.source === "manual" || input.source === SOURCE_PHOTO) return false;
|
|
6417
6514
|
if (input.trustTier === "quarantined") return false;
|
|
6418
6515
|
if (input.archivedAt !== null) return false;
|
|
6419
6516
|
if (input.factType === null || input.factType === "other") return true;
|
|
@@ -13653,6 +13750,7 @@ export {
|
|
|
13653
13750
|
hardDeleteMediaOp,
|
|
13654
13751
|
hasEncryptionKey,
|
|
13655
13752
|
hasKeyPair,
|
|
13753
|
+
ingestPublishedPhotoMemoriesOp,
|
|
13656
13754
|
injectionSignatureCatalog,
|
|
13657
13755
|
isRerankerAvailable,
|
|
13658
13756
|
isSupportedFile,
|
|
@@ -13663,6 +13761,7 @@ export {
|
|
|
13663
13761
|
mediaToStored,
|
|
13664
13762
|
migrateFromModelPreferencesOp,
|
|
13665
13763
|
onKeyAvailable,
|
|
13764
|
+
parseMedia,
|
|
13666
13765
|
preEmbedVaultMemories,
|
|
13667
13766
|
preprocessFiles,
|
|
13668
13767
|
progressiveSummarize,
|