@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
|
@@ -2410,6 +2410,22 @@ async function decryptVaultMemoryFields(memory, address, signMessage, embeddedWa
|
|
|
2410
2410
|
};
|
|
2411
2411
|
}
|
|
2412
2412
|
|
|
2413
|
+
// src/lib/db/memoryVault/types.ts
|
|
2414
|
+
function parseMedia(value) {
|
|
2415
|
+
if (typeof value !== "string" || value === "") return null;
|
|
2416
|
+
try {
|
|
2417
|
+
const parsed = JSON.parse(value);
|
|
2418
|
+
if (!Array.isArray(parsed)) return null;
|
|
2419
|
+
const refs = parsed.filter((r) => typeof r === "object" && r !== null).map((r) => ({
|
|
2420
|
+
feedItemId: Number(r.feedItemId ?? r.feed_item_id),
|
|
2421
|
+
objectKey: r.objectKey ?? r.object_key ?? null
|
|
2422
|
+
})).filter((r) => Number.isFinite(r.feedItemId));
|
|
2423
|
+
return refs.length > 0 ? refs : null;
|
|
2424
|
+
} catch {
|
|
2425
|
+
return null;
|
|
2426
|
+
}
|
|
2427
|
+
}
|
|
2428
|
+
|
|
2413
2429
|
// src/lib/db/memoryVault/operations.ts
|
|
2414
2430
|
function visibilityOrPrivate(value) {
|
|
2415
2431
|
return value === "public" ? value : "private";
|
|
@@ -2473,6 +2489,7 @@ function vaultMemoryToStoredRaw(memory) {
|
|
|
2473
2489
|
sourceChunkIds,
|
|
2474
2490
|
proofCount: memory.proofCount ?? null,
|
|
2475
2491
|
source: memory.source ?? null,
|
|
2492
|
+
media: parseMedia(memory.media),
|
|
2476
2493
|
eventTimeStart: memory.eventTimeStart ?? null,
|
|
2477
2494
|
eventTimeEnd: memory.eventTimeEnd ?? null,
|
|
2478
2495
|
eventTimeKind: memory.eventTimeKind ?? null,
|
|
@@ -2755,6 +2772,7 @@ function vaultMemoryRawToStoredRaw(raw) {
|
|
|
2755
2772
|
eventTimeKind: raw.event_time_kind ?? null,
|
|
2756
2773
|
// SQLite stores booleans as 0/1, LokiJS as true/false — coerce both.
|
|
2757
2774
|
topicsUserManaged: raw.topics_user_managed === true || raw.topics_user_managed === 1,
|
|
2775
|
+
media: parseMedia(raw.media),
|
|
2758
2776
|
topics: parseTopics(raw.topics),
|
|
2759
2777
|
topicsUpdatedAt: raw.topics_updated_at ?? null,
|
|
2760
2778
|
topicsExtractedAt: raw.topics_extracted_at ?? null,
|
|
@@ -6500,7 +6518,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
|
|
|
6500
6518
|
subQueries = decomp.subQueries;
|
|
6501
6519
|
}
|
|
6502
6520
|
}
|
|
6503
|
-
const { recall: recall2 } = await import("./recall-
|
|
6521
|
+
const { recall: recall2 } = await import("./recall-UVM2366D.mjs");
|
|
6504
6522
|
let recallDegraded = [];
|
|
6505
6523
|
const result = await recall2(
|
|
6506
6524
|
query,
|
|
@@ -7516,6 +7534,8 @@ export {
|
|
|
7516
7534
|
ENTITY_KINDS,
|
|
7517
7535
|
linkMemoryEntitiesOp,
|
|
7518
7536
|
replaceMemoryEntitiesGuardedOp,
|
|
7537
|
+
encryptVaultMemoryContent,
|
|
7538
|
+
parseMedia,
|
|
7519
7539
|
vaultMemoryToStored,
|
|
7520
7540
|
createVaultMemoryOp,
|
|
7521
7541
|
createSupersedingMemoryOp,
|
package/dist/expo/index.cjs
CHANGED
|
@@ -4663,6 +4663,27 @@ var init_encryption2 = __esm({
|
|
|
4663
4663
|
}
|
|
4664
4664
|
});
|
|
4665
4665
|
|
|
4666
|
+
// src/lib/db/memoryVault/types.ts
|
|
4667
|
+
function parseMedia(value) {
|
|
4668
|
+
if (typeof value !== "string" || value === "") return null;
|
|
4669
|
+
try {
|
|
4670
|
+
const parsed = JSON.parse(value);
|
|
4671
|
+
if (!Array.isArray(parsed)) return null;
|
|
4672
|
+
const refs = parsed.filter((r) => typeof r === "object" && r !== null).map((r) => ({
|
|
4673
|
+
feedItemId: Number(r.feedItemId ?? r.feed_item_id),
|
|
4674
|
+
objectKey: r.objectKey ?? r.object_key ?? null
|
|
4675
|
+
})).filter((r) => Number.isFinite(r.feedItemId));
|
|
4676
|
+
return refs.length > 0 ? refs : null;
|
|
4677
|
+
} catch {
|
|
4678
|
+
return null;
|
|
4679
|
+
}
|
|
4680
|
+
}
|
|
4681
|
+
var init_types4 = __esm({
|
|
4682
|
+
"src/lib/db/memoryVault/types.ts"() {
|
|
4683
|
+
"use strict";
|
|
4684
|
+
}
|
|
4685
|
+
});
|
|
4686
|
+
|
|
4666
4687
|
// src/lib/db/memoryVault/operations.ts
|
|
4667
4688
|
function visibilityOrPrivate(value) {
|
|
4668
4689
|
return value === "public" ? value : "private";
|
|
@@ -4724,6 +4745,7 @@ function vaultMemoryToStoredRaw(memory) {
|
|
|
4724
4745
|
sourceChunkIds,
|
|
4725
4746
|
proofCount: memory.proofCount ?? null,
|
|
4726
4747
|
source: memory.source ?? null,
|
|
4748
|
+
media: parseMedia(memory.media),
|
|
4727
4749
|
eventTimeStart: memory.eventTimeStart ?? null,
|
|
4728
4750
|
eventTimeEnd: memory.eventTimeEnd ?? null,
|
|
4729
4751
|
eventTimeKind: memory.eventTimeKind ?? null,
|
|
@@ -5006,6 +5028,7 @@ function vaultMemoryRawToStoredRaw(raw) {
|
|
|
5006
5028
|
eventTimeKind: raw.event_time_kind ?? null,
|
|
5007
5029
|
// SQLite stores booleans as 0/1, LokiJS as true/false — coerce both.
|
|
5008
5030
|
topicsUserManaged: raw.topics_user_managed === true || raw.topics_user_managed === 1,
|
|
5031
|
+
media: parseMedia(raw.media),
|
|
5009
5032
|
topics: parseTopics(raw.topics),
|
|
5010
5033
|
topicsUpdatedAt: raw.topics_updated_at ?? null,
|
|
5011
5034
|
topicsExtractedAt: raw.topics_extracted_at ?? null,
|
|
@@ -5730,6 +5753,7 @@ var init_operations3 = __esm({
|
|
|
5730
5753
|
init_operations2();
|
|
5731
5754
|
init_types3();
|
|
5732
5755
|
init_encryption2();
|
|
5756
|
+
init_types4();
|
|
5733
5757
|
NON_PRIVATE_VISIBILITIES = ["public"];
|
|
5734
5758
|
KNOWN_TRUST_TIERS = /* @__PURE__ */ new Set(["quarantined", "trusted"]);
|
|
5735
5759
|
TOPICS_EXTRACTION_VERSION = 3;
|
|
@@ -6057,17 +6081,17 @@ function recencyMultiplier(updatedAt, opts = {}) {
|
|
|
6057
6081
|
const now = opts.now ?? /* @__PURE__ */ new Date();
|
|
6058
6082
|
const nowMs2 = now.getTime();
|
|
6059
6083
|
if (!Number.isFinite(nowMs2)) return noDate;
|
|
6060
|
-
const ageDays2 = Math.max(0, (nowMs2 - updatedMs) /
|
|
6084
|
+
const ageDays2 = Math.max(0, (nowMs2 - updatedMs) / DAY_MS2);
|
|
6061
6085
|
const perYearDecay = opts.perYearDecay ?? DEFAULT_PER_YEAR_DECAY;
|
|
6062
6086
|
const floor = opts.floor ?? DEFAULT_FLOOR;
|
|
6063
6087
|
const decay = perYearDecay * (ageDays2 / 365);
|
|
6064
6088
|
return Math.max(floor, 1 - decay);
|
|
6065
6089
|
}
|
|
6066
|
-
var
|
|
6090
|
+
var DAY_MS2, DEFAULT_PER_YEAR_DECAY, DEFAULT_FLOOR, DEFAULT_NO_DATE_MULTIPLIER;
|
|
6067
6091
|
var init_recency = __esm({
|
|
6068
6092
|
"src/lib/memory/recency.ts"() {
|
|
6069
6093
|
"use strict";
|
|
6070
|
-
|
|
6094
|
+
DAY_MS2 = 1e3 * 60 * 60 * 24;
|
|
6071
6095
|
DEFAULT_PER_YEAR_DECAY = 0.2;
|
|
6072
6096
|
DEFAULT_FLOOR = 0.1;
|
|
6073
6097
|
DEFAULT_NO_DATE_MULTIPLIER = 0.5;
|
|
@@ -6824,8 +6848,8 @@ function classifyObservationTrend(input, now = Date.now()) {
|
|
|
6824
6848
|
const lastMsRaw = input.lastObservedAt;
|
|
6825
6849
|
const lastMs = lastMsRaw !== null && lastMsRaw !== void 0 && Number.isFinite(lastMsRaw) ? Math.max(createdMs, lastMsRaw) : createdMs;
|
|
6826
6850
|
const proofs = Math.max(1, input.proofCount ?? 1);
|
|
6827
|
-
const ageDays2 = Math.max(0, (now - createdMs) /
|
|
6828
|
-
const daysSinceLast = Math.max(0, (now - lastMs) /
|
|
6851
|
+
const ageDays2 = Math.max(0, (now - createdMs) / DAY_MS3);
|
|
6852
|
+
const daysSinceLast = Math.max(0, (now - lastMs) / DAY_MS3);
|
|
6829
6853
|
if (daysSinceLast >= TREND_STALE_WINDOW_DAYS) return "stale";
|
|
6830
6854
|
if (daysSinceLast >= TREND_RECENT_WINDOW_DAYS) return "weakening";
|
|
6831
6855
|
if (ageDays2 <= TREND_RECENT_WINDOW_DAYS && proofs <= 2) return "new";
|
|
@@ -6846,11 +6870,11 @@ function summarizeObservationTrends(inputs, now = Date.now()) {
|
|
|
6846
6870
|
}
|
|
6847
6871
|
return counts;
|
|
6848
6872
|
}
|
|
6849
|
-
var
|
|
6873
|
+
var DAY_MS3, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS;
|
|
6850
6874
|
var init_observationTrend = __esm({
|
|
6851
6875
|
"src/lib/memory/observationTrend.ts"() {
|
|
6852
6876
|
"use strict";
|
|
6853
|
-
|
|
6877
|
+
DAY_MS3 = 1e3 * 60 * 60 * 24;
|
|
6854
6878
|
TREND_RECENT_WINDOW_DAYS = 30;
|
|
6855
6879
|
TREND_STALE_WINDOW_DAYS = 90;
|
|
6856
6880
|
}
|
|
@@ -9133,12 +9157,14 @@ __export(index_exports, {
|
|
|
9133
9157
|
getVaultMemoryOp: () => getVaultMemoryOp,
|
|
9134
9158
|
hardDeleteDecayedOp: () => hardDeleteDecayedOp,
|
|
9135
9159
|
hasEncryptionKey: () => hasEncryptionKey,
|
|
9160
|
+
ingestPublishedPhotoMemoriesOp: () => ingestPublishedPhotoMemoriesOp,
|
|
9136
9161
|
injectionSignatureCatalog: () => injectionSignatureCatalog,
|
|
9137
9162
|
isPiiRedactor: () => isPiiRedactor,
|
|
9138
9163
|
isRerankerAvailable: () => isRerankerAvailable,
|
|
9139
9164
|
moveMemoriesToFolderOp: () => moveMemoriesToFolderOp,
|
|
9140
9165
|
noopLogger: () => noopLogger,
|
|
9141
9166
|
onKeyAvailable: () => onKeyAvailable,
|
|
9167
|
+
parseMedia: () => parseMedia,
|
|
9142
9168
|
preEmbedVaultMemories: () => preEmbedVaultMemories,
|
|
9143
9169
|
quantizeEmbedding: () => quantizeEmbedding,
|
|
9144
9170
|
queueManager: () => queueManager,
|
|
@@ -14730,6 +14756,9 @@ __decorateClass([
|
|
|
14730
14756
|
__decorateClass([
|
|
14731
14757
|
(0, import_decorators3.field)("topics_updated_at")
|
|
14732
14758
|
], VaultMemory.prototype, "topicsUpdatedAt", 2);
|
|
14759
|
+
__decorateClass([
|
|
14760
|
+
(0, import_decorators3.field)("media")
|
|
14761
|
+
], VaultMemory.prototype, "media", 2);
|
|
14733
14762
|
__decorateClass([
|
|
14734
14763
|
(0, import_decorators3.field)("topics_extracted_at")
|
|
14735
14764
|
], VaultMemory.prototype, "topicsExtractedAt", 2);
|
|
@@ -14780,6 +14809,138 @@ __decorateClass([
|
|
|
14780
14809
|
// src/lib/db/memoryVault/index.ts
|
|
14781
14810
|
init_operations3();
|
|
14782
14811
|
|
|
14812
|
+
// src/lib/memory/decay.ts
|
|
14813
|
+
init_logger();
|
|
14814
|
+
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
14815
|
+
var SHORT_TTL_MS = 30 * DAY_MS;
|
|
14816
|
+
var MEDIUM_TTL_MS = 180 * DAY_MS;
|
|
14817
|
+
var SOURCE_PHOTO = "photo";
|
|
14818
|
+
var NEVER_TTL_MS = Number.POSITIVE_INFINITY;
|
|
14819
|
+
var HARD_DELETE_WINDOW_MS = 30 * DAY_MS;
|
|
14820
|
+
var PAST_EVENT_GRACE_MS = 7 * DAY_MS;
|
|
14821
|
+
var DEFAULT_DECAY_POLICY = {
|
|
14822
|
+
ttlByType: {
|
|
14823
|
+
identity: NEVER_TTL_MS,
|
|
14824
|
+
preference: NEVER_TTL_MS,
|
|
14825
|
+
relationship: NEVER_TTL_MS,
|
|
14826
|
+
constraint: NEVER_TTL_MS,
|
|
14827
|
+
plan: SHORT_TTL_MS,
|
|
14828
|
+
ongoing_context: SHORT_TTL_MS,
|
|
14829
|
+
other: MEDIUM_TTL_MS
|
|
14830
|
+
},
|
|
14831
|
+
fallbackTtlMs: MEDIUM_TTL_MS,
|
|
14832
|
+
hardDeleteWindowMs: HARD_DELETE_WINDOW_MS,
|
|
14833
|
+
pastEventGraceMs: PAST_EVENT_GRACE_MS
|
|
14834
|
+
};
|
|
14835
|
+
function resolvePolicy(policy) {
|
|
14836
|
+
if (!policy) return DEFAULT_DECAY_POLICY;
|
|
14837
|
+
return {
|
|
14838
|
+
ttlByType: { ...DEFAULT_DECAY_POLICY.ttlByType, ...policy.ttlByType },
|
|
14839
|
+
fallbackTtlMs: policy.fallbackTtlMs ?? DEFAULT_DECAY_POLICY.fallbackTtlMs,
|
|
14840
|
+
hardDeleteWindowMs: policy.hardDeleteWindowMs ?? DEFAULT_DECAY_POLICY.hardDeleteWindowMs,
|
|
14841
|
+
pastEventGraceMs: policy.pastEventGraceMs ?? DEFAULT_DECAY_POLICY.pastEventGraceMs
|
|
14842
|
+
};
|
|
14843
|
+
}
|
|
14844
|
+
function ttlForType(factType, policy) {
|
|
14845
|
+
const resolved = resolvePolicy(policy);
|
|
14846
|
+
if (factType === null) return resolved.fallbackTtlMs;
|
|
14847
|
+
return resolved.ttlByType[factType] ?? resolved.fallbackTtlMs;
|
|
14848
|
+
}
|
|
14849
|
+
function isTimeSensitiveType(factType) {
|
|
14850
|
+
return factType === "plan" || factType === "ongoing_context";
|
|
14851
|
+
}
|
|
14852
|
+
function hasFiniteTimestamps(m, now) {
|
|
14853
|
+
return Number.isFinite(now) && Number.isFinite(m.updatedAt) && (m.archivedAt === null || Number.isFinite(m.archivedAt));
|
|
14854
|
+
}
|
|
14855
|
+
function classifyDecay(m, now, policy) {
|
|
14856
|
+
const resolved = resolvePolicy(policy);
|
|
14857
|
+
if (!hasFiniteTimestamps(m, now)) {
|
|
14858
|
+
getLogger().warn("[memory/decay] non-finite timestamp on a memory row; keeping it", {
|
|
14859
|
+
now,
|
|
14860
|
+
updatedAt: m.updatedAt,
|
|
14861
|
+
archivedAt: m.archivedAt,
|
|
14862
|
+
factType: m.factType
|
|
14863
|
+
});
|
|
14864
|
+
return "keep";
|
|
14865
|
+
}
|
|
14866
|
+
if (m.archivedAt !== null) {
|
|
14867
|
+
return now - m.archivedAt > resolved.hardDeleteWindowMs ? "delete" : "keep";
|
|
14868
|
+
}
|
|
14869
|
+
if (m.source === "manual" || m.source === SOURCE_PHOTO) return "keep";
|
|
14870
|
+
if (isTimeSensitiveType(m.factType) && m.eventTimeEnd !== null) {
|
|
14871
|
+
if (m.eventTimeEnd < now - resolved.pastEventGraceMs) return "archive";
|
|
14872
|
+
if (m.eventTimeEnd >= now) return "keep";
|
|
14873
|
+
}
|
|
14874
|
+
if (now - m.updatedAt > ttlForType(m.factType, resolved)) return "archive";
|
|
14875
|
+
return "keep";
|
|
14876
|
+
}
|
|
14877
|
+
|
|
14878
|
+
// src/lib/db/memoryVault/photoIngest.ts
|
|
14879
|
+
init_encryption2();
|
|
14880
|
+
var PHOTO_MEMORY_ID_PREFIX = "photo:";
|
|
14881
|
+
async function ingestPublishedPhotoMemoriesOp(ctx, rows) {
|
|
14882
|
+
const byId = /* @__PURE__ */ new Map();
|
|
14883
|
+
for (const r of rows) {
|
|
14884
|
+
if (typeof r.memoryId !== "string" || !r.memoryId.startsWith(PHOTO_MEMORY_ID_PREFIX)) continue;
|
|
14885
|
+
if (!byId.has(r.memoryId)) byId.set(r.memoryId, r);
|
|
14886
|
+
}
|
|
14887
|
+
const photoRows = [...byId.values()];
|
|
14888
|
+
if (photoRows.length === 0) return { inserted: 0, skipped: 0 };
|
|
14889
|
+
const known = await ctx.vaultMemoryCollection.query().fetchIds().then((ids) => new Set(ids));
|
|
14890
|
+
const candidates = photoRows.filter((r) => !known.has(r.memoryId));
|
|
14891
|
+
if (candidates.length === 0) return { inserted: 0, skipped: photoRows.length };
|
|
14892
|
+
const fresh = candidates;
|
|
14893
|
+
const contents = await Promise.all(
|
|
14894
|
+
fresh.map(async (r) => {
|
|
14895
|
+
if (ctx.walletAddress && ctx.signMessage) {
|
|
14896
|
+
return encryptVaultMemoryContent(
|
|
14897
|
+
r.text,
|
|
14898
|
+
ctx.walletAddress,
|
|
14899
|
+
ctx.signMessage,
|
|
14900
|
+
ctx.embeddedWalletSigner
|
|
14901
|
+
);
|
|
14902
|
+
}
|
|
14903
|
+
return r.text;
|
|
14904
|
+
})
|
|
14905
|
+
);
|
|
14906
|
+
const now = Date.now();
|
|
14907
|
+
let inserted = 0;
|
|
14908
|
+
await ctx.database.write(async () => {
|
|
14909
|
+
const present = new Set(await ctx.vaultMemoryCollection.query().fetchIds());
|
|
14910
|
+
const writable = fresh.map((row, i) => ({ row, content: contents[i] })).filter(({ row }) => !present.has(row.memoryId));
|
|
14911
|
+
inserted = writable.length;
|
|
14912
|
+
if (writable.length === 0) return;
|
|
14913
|
+
const prepared = writable.map(
|
|
14914
|
+
({ row, content }) => ctx.vaultMemoryCollection.prepareCreate((record) => {
|
|
14915
|
+
record._raw.id = row.memoryId;
|
|
14916
|
+
record._setRaw("content", content);
|
|
14917
|
+
record._setRaw("scope", "private");
|
|
14918
|
+
record._setRaw("folder_id", null);
|
|
14919
|
+
record._setRaw("user_id", ctx.userId ?? null);
|
|
14920
|
+
record._setRaw("is_deleted", false);
|
|
14921
|
+
record._setRaw("proof_count", 1);
|
|
14922
|
+
record._setRaw("source", SOURCE_PHOTO);
|
|
14923
|
+
record._setRaw(
|
|
14924
|
+
"media",
|
|
14925
|
+
row.media && row.media.length > 0 ? JSON.stringify(row.media) : null
|
|
14926
|
+
);
|
|
14927
|
+
record._setRaw("visibility", "public");
|
|
14928
|
+
record._setRaw("published_at", now);
|
|
14929
|
+
if (row.eventTime) {
|
|
14930
|
+
record._setRaw("event_time_start", row.eventTime.start ?? null);
|
|
14931
|
+
record._setRaw("event_time_end", row.eventTime.end ?? null);
|
|
14932
|
+
record._setRaw("event_time_kind", row.eventTime.kind ?? null);
|
|
14933
|
+
}
|
|
14934
|
+
})
|
|
14935
|
+
);
|
|
14936
|
+
await ctx.database.batch(...prepared);
|
|
14937
|
+
});
|
|
14938
|
+
return { inserted, skipped: photoRows.length - inserted };
|
|
14939
|
+
}
|
|
14940
|
+
|
|
14941
|
+
// src/lib/db/memoryVault/index.ts
|
|
14942
|
+
init_types4();
|
|
14943
|
+
|
|
14783
14944
|
// src/lib/db/queue/manager.ts
|
|
14784
14945
|
var import_uuid4 = require("uuid");
|
|
14785
14946
|
init_logger();
|
|
@@ -16046,6 +16207,9 @@ async function extractFacts(messages, options) {
|
|
|
16046
16207
|
...options.apiKey !== void 0 && { apiKey: options.apiKey },
|
|
16047
16208
|
...options.getToken !== void 0 && { getToken: options.getToken },
|
|
16048
16209
|
...options.baseUrl !== void 0 && { baseUrl: options.baseUrl },
|
|
16210
|
+
...options.endpointOverride !== void 0 && {
|
|
16211
|
+
endpointOverride: options.endpointOverride
|
|
16212
|
+
},
|
|
16049
16213
|
model: options.model ?? DEFAULT_EXTRACTION_MODEL,
|
|
16050
16214
|
systemPrompt: SYSTEM_PROMPT4,
|
|
16051
16215
|
userMessage: `Today's date is ${today}. Resolve any relative dates ("yesterday", "next week") against it.
|
|
@@ -16559,71 +16723,6 @@ function createChunkVectorCache(maxSize = DEFAULT_CHUNK_CACHE_SIZE) {
|
|
|
16559
16723
|
return new LRUCache(maxSize);
|
|
16560
16724
|
}
|
|
16561
16725
|
|
|
16562
|
-
// src/lib/memory/decay.ts
|
|
16563
|
-
init_logger();
|
|
16564
|
-
var DAY_MS3 = 24 * 60 * 60 * 1e3;
|
|
16565
|
-
var SHORT_TTL_MS = 30 * DAY_MS3;
|
|
16566
|
-
var MEDIUM_TTL_MS = 180 * DAY_MS3;
|
|
16567
|
-
var NEVER_TTL_MS = Number.POSITIVE_INFINITY;
|
|
16568
|
-
var HARD_DELETE_WINDOW_MS = 30 * DAY_MS3;
|
|
16569
|
-
var PAST_EVENT_GRACE_MS = 7 * DAY_MS3;
|
|
16570
|
-
var DEFAULT_DECAY_POLICY = {
|
|
16571
|
-
ttlByType: {
|
|
16572
|
-
identity: NEVER_TTL_MS,
|
|
16573
|
-
preference: NEVER_TTL_MS,
|
|
16574
|
-
relationship: NEVER_TTL_MS,
|
|
16575
|
-
constraint: NEVER_TTL_MS,
|
|
16576
|
-
plan: SHORT_TTL_MS,
|
|
16577
|
-
ongoing_context: SHORT_TTL_MS,
|
|
16578
|
-
other: MEDIUM_TTL_MS
|
|
16579
|
-
},
|
|
16580
|
-
fallbackTtlMs: MEDIUM_TTL_MS,
|
|
16581
|
-
hardDeleteWindowMs: HARD_DELETE_WINDOW_MS,
|
|
16582
|
-
pastEventGraceMs: PAST_EVENT_GRACE_MS
|
|
16583
|
-
};
|
|
16584
|
-
function resolvePolicy(policy) {
|
|
16585
|
-
if (!policy) return DEFAULT_DECAY_POLICY;
|
|
16586
|
-
return {
|
|
16587
|
-
ttlByType: { ...DEFAULT_DECAY_POLICY.ttlByType, ...policy.ttlByType },
|
|
16588
|
-
fallbackTtlMs: policy.fallbackTtlMs ?? DEFAULT_DECAY_POLICY.fallbackTtlMs,
|
|
16589
|
-
hardDeleteWindowMs: policy.hardDeleteWindowMs ?? DEFAULT_DECAY_POLICY.hardDeleteWindowMs,
|
|
16590
|
-
pastEventGraceMs: policy.pastEventGraceMs ?? DEFAULT_DECAY_POLICY.pastEventGraceMs
|
|
16591
|
-
};
|
|
16592
|
-
}
|
|
16593
|
-
function ttlForType(factType, policy) {
|
|
16594
|
-
const resolved = resolvePolicy(policy);
|
|
16595
|
-
if (factType === null) return resolved.fallbackTtlMs;
|
|
16596
|
-
return resolved.ttlByType[factType] ?? resolved.fallbackTtlMs;
|
|
16597
|
-
}
|
|
16598
|
-
function isTimeSensitiveType(factType) {
|
|
16599
|
-
return factType === "plan" || factType === "ongoing_context";
|
|
16600
|
-
}
|
|
16601
|
-
function hasFiniteTimestamps(m, now) {
|
|
16602
|
-
return Number.isFinite(now) && Number.isFinite(m.updatedAt) && (m.archivedAt === null || Number.isFinite(m.archivedAt));
|
|
16603
|
-
}
|
|
16604
|
-
function classifyDecay(m, now, policy) {
|
|
16605
|
-
const resolved = resolvePolicy(policy);
|
|
16606
|
-
if (!hasFiniteTimestamps(m, now)) {
|
|
16607
|
-
getLogger().warn("[memory/decay] non-finite timestamp on a memory row; keeping it", {
|
|
16608
|
-
now,
|
|
16609
|
-
updatedAt: m.updatedAt,
|
|
16610
|
-
archivedAt: m.archivedAt,
|
|
16611
|
-
factType: m.factType
|
|
16612
|
-
});
|
|
16613
|
-
return "keep";
|
|
16614
|
-
}
|
|
16615
|
-
if (m.archivedAt !== null) {
|
|
16616
|
-
return now - m.archivedAt > resolved.hardDeleteWindowMs ? "delete" : "keep";
|
|
16617
|
-
}
|
|
16618
|
-
if (m.source === "manual") return "keep";
|
|
16619
|
-
if (isTimeSensitiveType(m.factType) && m.eventTimeEnd !== null) {
|
|
16620
|
-
if (m.eventTimeEnd < now - resolved.pastEventGraceMs) return "archive";
|
|
16621
|
-
if (m.eventTimeEnd >= now) return "keep";
|
|
16622
|
-
}
|
|
16623
|
-
if (now - m.updatedAt > ttlForType(m.factType, resolved)) return "archive";
|
|
16624
|
-
return "keep";
|
|
16625
|
-
}
|
|
16626
|
-
|
|
16627
16726
|
// src/lib/memory/decayClassifier.ts
|
|
16628
16727
|
init_logger();
|
|
16629
16728
|
init_redactor();
|
|
@@ -16726,7 +16825,7 @@ function toDecayInput(c) {
|
|
|
16726
16825
|
};
|
|
16727
16826
|
}
|
|
16728
16827
|
function isBorderline(input) {
|
|
16729
|
-
if (input.source === "manual") return false;
|
|
16828
|
+
if (input.source === "manual" || input.source === SOURCE_PHOTO) return false;
|
|
16730
16829
|
if (input.trustTier === "quarantined") return false;
|
|
16731
16830
|
if (input.archivedAt !== null) return false;
|
|
16732
16831
|
if (input.factType === null || input.factType === "other") return true;
|
|
@@ -21448,7 +21547,7 @@ __decorateClass([
|
|
|
21448
21547
|
], VaultFolder.prototype, "context", 2);
|
|
21449
21548
|
|
|
21450
21549
|
// src/lib/db/schema.ts
|
|
21451
|
-
var SDK_SCHEMA_VERSION =
|
|
21550
|
+
var SDK_SCHEMA_VERSION = 45;
|
|
21452
21551
|
var sdkSchema = (0, import_watermelondb19.appSchema)({
|
|
21453
21552
|
version: SDK_SCHEMA_VERSION,
|
|
21454
21553
|
tables: [
|
|
@@ -21596,6 +21695,18 @@ var sdkSchema = (0, import_watermelondb19.appSchema)({
|
|
|
21596
21695
|
// paths key on `updated_at` — so without this a topic-only change would
|
|
21597
21696
|
// neither upload nor merge. Null = `topics` never written.
|
|
21598
21697
|
{ name: "topics_updated_at", type: "number", isOptional: true },
|
|
21698
|
+
// The photo(s) a SERVER-EXTRACTED memory was read out of, as a JSON
|
|
21699
|
+
// array of `{feed_item_id, object_key}` — exactly what
|
|
21700
|
+
// GET /api/memories/published returns in `media[]`. Enough to render the
|
|
21701
|
+
// source image without a second round-trip per memory.
|
|
21702
|
+
//
|
|
21703
|
+
// A JSON column rather than a join table: nothing on the client ever
|
|
21704
|
+
// queries BY photo (the only direction is memory -> render its image),
|
|
21705
|
+
// so a table would add a sync lane and a local-id space to serve a
|
|
21706
|
+
// question nobody asks. `topics` and `source_chunk_ids` set the
|
|
21707
|
+
// precedent for a list that is only ever read back whole. Null on
|
|
21708
|
+
// anything not extracted from a photo.
|
|
21709
|
+
{ name: "media", type: "string", isOptional: true },
|
|
21599
21710
|
// Unix ms of the last LLM topic-extraction pass over this memory's
|
|
21600
21711
|
// content. Null = never extracted standalone (legacy rows with entity
|
|
21601
21712
|
// links are grandfathered — see getMemoriesNeedingTopicExtractionOp).
|
|
@@ -22430,6 +22541,20 @@ var sdkMigrations = (0, import_migrations2.schemaMigrations)({
|
|
|
22430
22541
|
columns: [{ name: "origin", type: "string", isOptional: true }]
|
|
22431
22542
|
})
|
|
22432
22543
|
]
|
|
22544
|
+
},
|
|
22545
|
+
// v44 -> v45: `media` on memory_vault — the photo(s) a server-extracted
|
|
22546
|
+
// memory was read out of, as JSON `[{feed_item_id, object_key}]`, mirroring
|
|
22547
|
+
// the `media[]` that GET /api/memories/published already returns. Existing
|
|
22548
|
+
// rows keep NULL, which is the correct value for every memory that did not
|
|
22549
|
+
// come from a photo (i.e. all of them until photo ingest runs).
|
|
22550
|
+
{
|
|
22551
|
+
toVersion: 45,
|
|
22552
|
+
steps: [
|
|
22553
|
+
(0, import_migrations2.addColumns)({
|
|
22554
|
+
table: "memory_vault",
|
|
22555
|
+
columns: [{ name: "media", type: "string", isOptional: true }]
|
|
22556
|
+
})
|
|
22557
|
+
]
|
|
22433
22558
|
}
|
|
22434
22559
|
]
|
|
22435
22560
|
});
|
|
@@ -23901,12 +24026,14 @@ function createNotionTools(getAccessToken, requestNotionAccess) {
|
|
|
23901
24026
|
getVaultMemoryOp,
|
|
23902
24027
|
hardDeleteDecayedOp,
|
|
23903
24028
|
hasEncryptionKey,
|
|
24029
|
+
ingestPublishedPhotoMemoriesOp,
|
|
23904
24030
|
injectionSignatureCatalog,
|
|
23905
24031
|
isPiiRedactor,
|
|
23906
24032
|
isRerankerAvailable,
|
|
23907
24033
|
moveMemoriesToFolderOp,
|
|
23908
24034
|
noopLogger,
|
|
23909
24035
|
onKeyAvailable,
|
|
24036
|
+
parseMedia,
|
|
23910
24037
|
preEmbedVaultMemories,
|
|
23911
24038
|
quantizeEmbedding,
|
|
23912
24039
|
queueManager,
|