@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.cjs
CHANGED
|
@@ -17419,6 +17419,27 @@ var init_encryption2 = __esm({
|
|
|
17419
17419
|
}
|
|
17420
17420
|
});
|
|
17421
17421
|
|
|
17422
|
+
// src/lib/db/memoryVault/types.ts
|
|
17423
|
+
function parseMedia(value) {
|
|
17424
|
+
if (typeof value !== "string" || value === "") return null;
|
|
17425
|
+
try {
|
|
17426
|
+
const parsed = JSON.parse(value);
|
|
17427
|
+
if (!Array.isArray(parsed)) return null;
|
|
17428
|
+
const refs = parsed.filter((r) => typeof r === "object" && r !== null).map((r) => ({
|
|
17429
|
+
feedItemId: Number(r.feedItemId ?? r.feed_item_id),
|
|
17430
|
+
objectKey: r.objectKey ?? r.object_key ?? null
|
|
17431
|
+
})).filter((r) => Number.isFinite(r.feedItemId));
|
|
17432
|
+
return refs.length > 0 ? refs : null;
|
|
17433
|
+
} catch {
|
|
17434
|
+
return null;
|
|
17435
|
+
}
|
|
17436
|
+
}
|
|
17437
|
+
var init_types4 = __esm({
|
|
17438
|
+
"src/lib/db/memoryVault/types.ts"() {
|
|
17439
|
+
"use strict";
|
|
17440
|
+
}
|
|
17441
|
+
});
|
|
17442
|
+
|
|
17422
17443
|
// src/lib/db/memoryVault/operations.ts
|
|
17423
17444
|
function visibilityOrPrivate(value) {
|
|
17424
17445
|
return value === "public" ? value : "private";
|
|
@@ -17480,6 +17501,7 @@ function vaultMemoryToStoredRaw(memory) {
|
|
|
17480
17501
|
sourceChunkIds,
|
|
17481
17502
|
proofCount: memory.proofCount ?? null,
|
|
17482
17503
|
source: memory.source ?? null,
|
|
17504
|
+
media: parseMedia(memory.media),
|
|
17483
17505
|
eventTimeStart: memory.eventTimeStart ?? null,
|
|
17484
17506
|
eventTimeEnd: memory.eventTimeEnd ?? null,
|
|
17485
17507
|
eventTimeKind: memory.eventTimeKind ?? null,
|
|
@@ -17762,6 +17784,7 @@ function vaultMemoryRawToStoredRaw(raw) {
|
|
|
17762
17784
|
eventTimeKind: raw.event_time_kind ?? null,
|
|
17763
17785
|
// SQLite stores booleans as 0/1, LokiJS as true/false — coerce both.
|
|
17764
17786
|
topicsUserManaged: raw.topics_user_managed === true || raw.topics_user_managed === 1,
|
|
17787
|
+
media: parseMedia(raw.media),
|
|
17765
17788
|
topics: parseTopics(raw.topics),
|
|
17766
17789
|
topicsUpdatedAt: raw.topics_updated_at ?? null,
|
|
17767
17790
|
topicsExtractedAt: raw.topics_extracted_at ?? null,
|
|
@@ -18486,6 +18509,7 @@ var init_operations3 = __esm({
|
|
|
18486
18509
|
init_operations2();
|
|
18487
18510
|
init_types3();
|
|
18488
18511
|
init_encryption2();
|
|
18512
|
+
init_types4();
|
|
18489
18513
|
NON_PRIVATE_VISIBILITIES = ["public"];
|
|
18490
18514
|
KNOWN_TRUST_TIERS = /* @__PURE__ */ new Set(["quarantined", "trusted"]);
|
|
18491
18515
|
TOPICS_EXTRACTION_VERSION = 3;
|
|
@@ -19997,17 +20021,17 @@ function recencyMultiplier(updatedAt, opts = {}) {
|
|
|
19997
20021
|
const now = opts.now ?? /* @__PURE__ */ new Date();
|
|
19998
20022
|
const nowMs2 = now.getTime();
|
|
19999
20023
|
if (!Number.isFinite(nowMs2)) return noDate;
|
|
20000
|
-
const ageDays2 = Math.max(0, (nowMs2 - updatedMs) /
|
|
20024
|
+
const ageDays2 = Math.max(0, (nowMs2 - updatedMs) / DAY_MS2);
|
|
20001
20025
|
const perYearDecay = opts.perYearDecay ?? DEFAULT_PER_YEAR_DECAY;
|
|
20002
20026
|
const floor = opts.floor ?? DEFAULT_FLOOR;
|
|
20003
20027
|
const decay = perYearDecay * (ageDays2 / 365);
|
|
20004
20028
|
return Math.max(floor, 1 - decay);
|
|
20005
20029
|
}
|
|
20006
|
-
var
|
|
20030
|
+
var DAY_MS2, DEFAULT_PER_YEAR_DECAY, DEFAULT_FLOOR, DEFAULT_NO_DATE_MULTIPLIER;
|
|
20007
20031
|
var init_recency = __esm({
|
|
20008
20032
|
"src/lib/memory/recency.ts"() {
|
|
20009
20033
|
"use strict";
|
|
20010
|
-
|
|
20034
|
+
DAY_MS2 = 1e3 * 60 * 60 * 24;
|
|
20011
20035
|
DEFAULT_PER_YEAR_DECAY = 0.2;
|
|
20012
20036
|
DEFAULT_FLOOR = 0.1;
|
|
20013
20037
|
DEFAULT_NO_DATE_MULTIPLIER = 0.5;
|
|
@@ -20997,8 +21021,8 @@ function classifyObservationTrend(input, now = Date.now()) {
|
|
|
20997
21021
|
const lastMsRaw = input.lastObservedAt;
|
|
20998
21022
|
const lastMs = lastMsRaw !== null && lastMsRaw !== void 0 && Number.isFinite(lastMsRaw) ? Math.max(createdMs, lastMsRaw) : createdMs;
|
|
20999
21023
|
const proofs = Math.max(1, input.proofCount ?? 1);
|
|
21000
|
-
const ageDays2 = Math.max(0, (now - createdMs) /
|
|
21001
|
-
const daysSinceLast = Math.max(0, (now - lastMs) /
|
|
21024
|
+
const ageDays2 = Math.max(0, (now - createdMs) / DAY_MS3);
|
|
21025
|
+
const daysSinceLast = Math.max(0, (now - lastMs) / DAY_MS3);
|
|
21002
21026
|
if (daysSinceLast >= TREND_STALE_WINDOW_DAYS) return "stale";
|
|
21003
21027
|
if (daysSinceLast >= TREND_RECENT_WINDOW_DAYS) return "weakening";
|
|
21004
21028
|
if (ageDays2 <= TREND_RECENT_WINDOW_DAYS && proofs <= 2) return "new";
|
|
@@ -21019,11 +21043,11 @@ function summarizeObservationTrends(inputs, now = Date.now()) {
|
|
|
21019
21043
|
}
|
|
21020
21044
|
return counts;
|
|
21021
21045
|
}
|
|
21022
|
-
var
|
|
21046
|
+
var DAY_MS3, TREND_RECENT_WINDOW_DAYS, TREND_STALE_WINDOW_DAYS;
|
|
21023
21047
|
var init_observationTrend = __esm({
|
|
21024
21048
|
"src/lib/memory/observationTrend.ts"() {
|
|
21025
21049
|
"use strict";
|
|
21026
|
-
|
|
21050
|
+
DAY_MS3 = 1e3 * 60 * 60 * 24;
|
|
21027
21051
|
TREND_RECENT_WINDOW_DAYS = 30;
|
|
21028
21052
|
TREND_STALE_WINDOW_DAYS = 90;
|
|
21029
21053
|
}
|
|
@@ -24039,6 +24063,7 @@ __export(index_exports, {
|
|
|
24039
24063
|
hardDeleteMediaOp: () => hardDeleteMediaOp,
|
|
24040
24064
|
hasEncryptionKey: () => hasEncryptionKey,
|
|
24041
24065
|
hasKeyPair: () => hasKeyPair,
|
|
24066
|
+
ingestPublishedPhotoMemoriesOp: () => ingestPublishedPhotoMemoriesOp,
|
|
24042
24067
|
injectionSignatureCatalog: () => injectionSignatureCatalog,
|
|
24043
24068
|
isRerankerAvailable: () => isRerankerAvailable,
|
|
24044
24069
|
isSupportedFile: () => isSupportedFile,
|
|
@@ -24049,6 +24074,7 @@ __export(index_exports, {
|
|
|
24049
24074
|
mediaToStored: () => mediaToStored,
|
|
24050
24075
|
migrateFromModelPreferencesOp: () => migrateFromModelPreferencesOp,
|
|
24051
24076
|
onKeyAvailable: () => onKeyAvailable,
|
|
24077
|
+
parseMedia: () => parseMedia,
|
|
24052
24078
|
preEmbedVaultMemories: () => preEmbedVaultMemories,
|
|
24053
24079
|
preprocessFiles: () => preprocessFiles,
|
|
24054
24080
|
progressiveSummarize: () => progressiveSummarize,
|
|
@@ -24456,6 +24482,9 @@ __decorateClass([
|
|
|
24456
24482
|
__decorateClass([
|
|
24457
24483
|
(0, import_decorators6.field)("topics_updated_at")
|
|
24458
24484
|
], VaultMemory.prototype, "topicsUpdatedAt", 2);
|
|
24485
|
+
__decorateClass([
|
|
24486
|
+
(0, import_decorators6.field)("media")
|
|
24487
|
+
], VaultMemory.prototype, "media", 2);
|
|
24459
24488
|
__decorateClass([
|
|
24460
24489
|
(0, import_decorators6.field)("topics_extracted_at")
|
|
24461
24490
|
], VaultMemory.prototype, "topicsExtractedAt", 2);
|
|
@@ -24639,7 +24668,7 @@ __decorateClass([
|
|
|
24639
24668
|
], VaultFolder.prototype, "context", 2);
|
|
24640
24669
|
|
|
24641
24670
|
// src/lib/db/schema.ts
|
|
24642
|
-
var SDK_SCHEMA_VERSION =
|
|
24671
|
+
var SDK_SCHEMA_VERSION = 45;
|
|
24643
24672
|
var sdkSchema = (0, import_watermelondb12.appSchema)({
|
|
24644
24673
|
version: SDK_SCHEMA_VERSION,
|
|
24645
24674
|
tables: [
|
|
@@ -24787,6 +24816,18 @@ var sdkSchema = (0, import_watermelondb12.appSchema)({
|
|
|
24787
24816
|
// paths key on `updated_at` — so without this a topic-only change would
|
|
24788
24817
|
// neither upload nor merge. Null = `topics` never written.
|
|
24789
24818
|
{ name: "topics_updated_at", type: "number", isOptional: true },
|
|
24819
|
+
// The photo(s) a SERVER-EXTRACTED memory was read out of, as a JSON
|
|
24820
|
+
// array of `{feed_item_id, object_key}` — exactly what
|
|
24821
|
+
// GET /api/memories/published returns in `media[]`. Enough to render the
|
|
24822
|
+
// source image without a second round-trip per memory.
|
|
24823
|
+
//
|
|
24824
|
+
// A JSON column rather than a join table: nothing on the client ever
|
|
24825
|
+
// queries BY photo (the only direction is memory -> render its image),
|
|
24826
|
+
// so a table would add a sync lane and a local-id space to serve a
|
|
24827
|
+
// question nobody asks. `topics` and `source_chunk_ids` set the
|
|
24828
|
+
// precedent for a list that is only ever read back whole. Null on
|
|
24829
|
+
// anything not extracted from a photo.
|
|
24830
|
+
{ name: "media", type: "string", isOptional: true },
|
|
24790
24831
|
// Unix ms of the last LLM topic-extraction pass over this memory's
|
|
24791
24832
|
// content. Null = never extracted standalone (legacy rows with entity
|
|
24792
24833
|
// links are grandfathered — see getMemoriesNeedingTopicExtractionOp).
|
|
@@ -25621,6 +25662,20 @@ var sdkMigrations = (0, import_migrations.schemaMigrations)({
|
|
|
25621
25662
|
columns: [{ name: "origin", type: "string", isOptional: true }]
|
|
25622
25663
|
})
|
|
25623
25664
|
]
|
|
25665
|
+
},
|
|
25666
|
+
// v44 -> v45: `media` on memory_vault — the photo(s) a server-extracted
|
|
25667
|
+
// memory was read out of, as JSON `[{feed_item_id, object_key}]`, mirroring
|
|
25668
|
+
// the `media[]` that GET /api/memories/published already returns. Existing
|
|
25669
|
+
// rows keep NULL, which is the correct value for every memory that did not
|
|
25670
|
+
// come from a photo (i.e. all of them until photo ingest runs).
|
|
25671
|
+
{
|
|
25672
|
+
toVersion: 45,
|
|
25673
|
+
steps: [
|
|
25674
|
+
(0, import_migrations.addColumns)({
|
|
25675
|
+
table: "memory_vault",
|
|
25676
|
+
columns: [{ name: "media", type: "string", isOptional: true }]
|
|
25677
|
+
})
|
|
25678
|
+
]
|
|
25624
25679
|
}
|
|
25625
25680
|
]
|
|
25626
25681
|
});
|
|
@@ -26912,6 +26967,138 @@ async function cleanupConversationSummary(database, conversationId) {
|
|
|
26912
26967
|
// src/lib/db/memoryVault/index.ts
|
|
26913
26968
|
init_operations3();
|
|
26914
26969
|
|
|
26970
|
+
// src/lib/memory/decay.ts
|
|
26971
|
+
init_logger();
|
|
26972
|
+
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
26973
|
+
var SHORT_TTL_MS = 30 * DAY_MS;
|
|
26974
|
+
var MEDIUM_TTL_MS = 180 * DAY_MS;
|
|
26975
|
+
var SOURCE_PHOTO = "photo";
|
|
26976
|
+
var NEVER_TTL_MS = Number.POSITIVE_INFINITY;
|
|
26977
|
+
var HARD_DELETE_WINDOW_MS = 30 * DAY_MS;
|
|
26978
|
+
var PAST_EVENT_GRACE_MS = 7 * DAY_MS;
|
|
26979
|
+
var DEFAULT_DECAY_POLICY = {
|
|
26980
|
+
ttlByType: {
|
|
26981
|
+
identity: NEVER_TTL_MS,
|
|
26982
|
+
preference: NEVER_TTL_MS,
|
|
26983
|
+
relationship: NEVER_TTL_MS,
|
|
26984
|
+
constraint: NEVER_TTL_MS,
|
|
26985
|
+
plan: SHORT_TTL_MS,
|
|
26986
|
+
ongoing_context: SHORT_TTL_MS,
|
|
26987
|
+
other: MEDIUM_TTL_MS
|
|
26988
|
+
},
|
|
26989
|
+
fallbackTtlMs: MEDIUM_TTL_MS,
|
|
26990
|
+
hardDeleteWindowMs: HARD_DELETE_WINDOW_MS,
|
|
26991
|
+
pastEventGraceMs: PAST_EVENT_GRACE_MS
|
|
26992
|
+
};
|
|
26993
|
+
function resolvePolicy(policy) {
|
|
26994
|
+
if (!policy) return DEFAULT_DECAY_POLICY;
|
|
26995
|
+
return {
|
|
26996
|
+
ttlByType: { ...DEFAULT_DECAY_POLICY.ttlByType, ...policy.ttlByType },
|
|
26997
|
+
fallbackTtlMs: policy.fallbackTtlMs ?? DEFAULT_DECAY_POLICY.fallbackTtlMs,
|
|
26998
|
+
hardDeleteWindowMs: policy.hardDeleteWindowMs ?? DEFAULT_DECAY_POLICY.hardDeleteWindowMs,
|
|
26999
|
+
pastEventGraceMs: policy.pastEventGraceMs ?? DEFAULT_DECAY_POLICY.pastEventGraceMs
|
|
27000
|
+
};
|
|
27001
|
+
}
|
|
27002
|
+
function ttlForType(factType, policy) {
|
|
27003
|
+
const resolved = resolvePolicy(policy);
|
|
27004
|
+
if (factType === null) return resolved.fallbackTtlMs;
|
|
27005
|
+
return resolved.ttlByType[factType] ?? resolved.fallbackTtlMs;
|
|
27006
|
+
}
|
|
27007
|
+
function isTimeSensitiveType(factType) {
|
|
27008
|
+
return factType === "plan" || factType === "ongoing_context";
|
|
27009
|
+
}
|
|
27010
|
+
function hasFiniteTimestamps(m, now) {
|
|
27011
|
+
return Number.isFinite(now) && Number.isFinite(m.updatedAt) && (m.archivedAt === null || Number.isFinite(m.archivedAt));
|
|
27012
|
+
}
|
|
27013
|
+
function classifyDecay(m, now, policy) {
|
|
27014
|
+
const resolved = resolvePolicy(policy);
|
|
27015
|
+
if (!hasFiniteTimestamps(m, now)) {
|
|
27016
|
+
getLogger().warn("[memory/decay] non-finite timestamp on a memory row; keeping it", {
|
|
27017
|
+
now,
|
|
27018
|
+
updatedAt: m.updatedAt,
|
|
27019
|
+
archivedAt: m.archivedAt,
|
|
27020
|
+
factType: m.factType
|
|
27021
|
+
});
|
|
27022
|
+
return "keep";
|
|
27023
|
+
}
|
|
27024
|
+
if (m.archivedAt !== null) {
|
|
27025
|
+
return now - m.archivedAt > resolved.hardDeleteWindowMs ? "delete" : "keep";
|
|
27026
|
+
}
|
|
27027
|
+
if (m.source === "manual" || m.source === SOURCE_PHOTO) return "keep";
|
|
27028
|
+
if (isTimeSensitiveType(m.factType) && m.eventTimeEnd !== null) {
|
|
27029
|
+
if (m.eventTimeEnd < now - resolved.pastEventGraceMs) return "archive";
|
|
27030
|
+
if (m.eventTimeEnd >= now) return "keep";
|
|
27031
|
+
}
|
|
27032
|
+
if (now - m.updatedAt > ttlForType(m.factType, resolved)) return "archive";
|
|
27033
|
+
return "keep";
|
|
27034
|
+
}
|
|
27035
|
+
|
|
27036
|
+
// src/lib/db/memoryVault/photoIngest.ts
|
|
27037
|
+
init_encryption2();
|
|
27038
|
+
var PHOTO_MEMORY_ID_PREFIX = "photo:";
|
|
27039
|
+
async function ingestPublishedPhotoMemoriesOp(ctx, rows) {
|
|
27040
|
+
const byId = /* @__PURE__ */ new Map();
|
|
27041
|
+
for (const r of rows) {
|
|
27042
|
+
if (typeof r.memoryId !== "string" || !r.memoryId.startsWith(PHOTO_MEMORY_ID_PREFIX)) continue;
|
|
27043
|
+
if (!byId.has(r.memoryId)) byId.set(r.memoryId, r);
|
|
27044
|
+
}
|
|
27045
|
+
const photoRows = [...byId.values()];
|
|
27046
|
+
if (photoRows.length === 0) return { inserted: 0, skipped: 0 };
|
|
27047
|
+
const known = await ctx.vaultMemoryCollection.query().fetchIds().then((ids) => new Set(ids));
|
|
27048
|
+
const candidates = photoRows.filter((r) => !known.has(r.memoryId));
|
|
27049
|
+
if (candidates.length === 0) return { inserted: 0, skipped: photoRows.length };
|
|
27050
|
+
const fresh = candidates;
|
|
27051
|
+
const contents = await Promise.all(
|
|
27052
|
+
fresh.map(async (r) => {
|
|
27053
|
+
if (ctx.walletAddress && ctx.signMessage) {
|
|
27054
|
+
return encryptVaultMemoryContent(
|
|
27055
|
+
r.text,
|
|
27056
|
+
ctx.walletAddress,
|
|
27057
|
+
ctx.signMessage,
|
|
27058
|
+
ctx.embeddedWalletSigner
|
|
27059
|
+
);
|
|
27060
|
+
}
|
|
27061
|
+
return r.text;
|
|
27062
|
+
})
|
|
27063
|
+
);
|
|
27064
|
+
const now = Date.now();
|
|
27065
|
+
let inserted = 0;
|
|
27066
|
+
await ctx.database.write(async () => {
|
|
27067
|
+
const present = new Set(await ctx.vaultMemoryCollection.query().fetchIds());
|
|
27068
|
+
const writable = fresh.map((row, i) => ({ row, content: contents[i] })).filter(({ row }) => !present.has(row.memoryId));
|
|
27069
|
+
inserted = writable.length;
|
|
27070
|
+
if (writable.length === 0) return;
|
|
27071
|
+
const prepared = writable.map(
|
|
27072
|
+
({ row, content }) => ctx.vaultMemoryCollection.prepareCreate((record) => {
|
|
27073
|
+
record._raw.id = row.memoryId;
|
|
27074
|
+
record._setRaw("content", content);
|
|
27075
|
+
record._setRaw("scope", "private");
|
|
27076
|
+
record._setRaw("folder_id", null);
|
|
27077
|
+
record._setRaw("user_id", ctx.userId ?? null);
|
|
27078
|
+
record._setRaw("is_deleted", false);
|
|
27079
|
+
record._setRaw("proof_count", 1);
|
|
27080
|
+
record._setRaw("source", SOURCE_PHOTO);
|
|
27081
|
+
record._setRaw(
|
|
27082
|
+
"media",
|
|
27083
|
+
row.media && row.media.length > 0 ? JSON.stringify(row.media) : null
|
|
27084
|
+
);
|
|
27085
|
+
record._setRaw("visibility", "public");
|
|
27086
|
+
record._setRaw("published_at", now);
|
|
27087
|
+
if (row.eventTime) {
|
|
27088
|
+
record._setRaw("event_time_start", row.eventTime.start ?? null);
|
|
27089
|
+
record._setRaw("event_time_end", row.eventTime.end ?? null);
|
|
27090
|
+
record._setRaw("event_time_kind", row.eventTime.kind ?? null);
|
|
27091
|
+
}
|
|
27092
|
+
})
|
|
27093
|
+
);
|
|
27094
|
+
await ctx.database.batch(...prepared);
|
|
27095
|
+
});
|
|
27096
|
+
return { inserted, skipped: photoRows.length - inserted };
|
|
27097
|
+
}
|
|
27098
|
+
|
|
27099
|
+
// src/lib/db/memoryVault/index.ts
|
|
27100
|
+
init_types4();
|
|
27101
|
+
|
|
26915
27102
|
// src/lib/db/project/operations.ts
|
|
26916
27103
|
var import_watermelondb18 = __toESM(require_watermelondb());
|
|
26917
27104
|
init_operations();
|
|
@@ -29106,6 +29293,9 @@ async function extractFacts(messages, options) {
|
|
|
29106
29293
|
...options.apiKey !== void 0 && { apiKey: options.apiKey },
|
|
29107
29294
|
...options.getToken !== void 0 && { getToken: options.getToken },
|
|
29108
29295
|
...options.baseUrl !== void 0 && { baseUrl: options.baseUrl },
|
|
29296
|
+
...options.endpointOverride !== void 0 && {
|
|
29297
|
+
endpointOverride: options.endpointOverride
|
|
29298
|
+
},
|
|
29109
29299
|
model: options.model ?? DEFAULT_EXTRACTION_MODEL,
|
|
29110
29300
|
systemPrompt: SYSTEM_PROMPT4,
|
|
29111
29301
|
userMessage: `Today's date is ${today}. Resolve any relative dates ("yesterday", "next week") against it.
|
|
@@ -29619,71 +29809,6 @@ function createChunkVectorCache(maxSize = DEFAULT_CHUNK_CACHE_SIZE) {
|
|
|
29619
29809
|
return new LRUCache(maxSize);
|
|
29620
29810
|
}
|
|
29621
29811
|
|
|
29622
|
-
// src/lib/memory/decay.ts
|
|
29623
|
-
init_logger();
|
|
29624
|
-
var DAY_MS3 = 24 * 60 * 60 * 1e3;
|
|
29625
|
-
var SHORT_TTL_MS = 30 * DAY_MS3;
|
|
29626
|
-
var MEDIUM_TTL_MS = 180 * DAY_MS3;
|
|
29627
|
-
var NEVER_TTL_MS = Number.POSITIVE_INFINITY;
|
|
29628
|
-
var HARD_DELETE_WINDOW_MS = 30 * DAY_MS3;
|
|
29629
|
-
var PAST_EVENT_GRACE_MS = 7 * DAY_MS3;
|
|
29630
|
-
var DEFAULT_DECAY_POLICY = {
|
|
29631
|
-
ttlByType: {
|
|
29632
|
-
identity: NEVER_TTL_MS,
|
|
29633
|
-
preference: NEVER_TTL_MS,
|
|
29634
|
-
relationship: NEVER_TTL_MS,
|
|
29635
|
-
constraint: NEVER_TTL_MS,
|
|
29636
|
-
plan: SHORT_TTL_MS,
|
|
29637
|
-
ongoing_context: SHORT_TTL_MS,
|
|
29638
|
-
other: MEDIUM_TTL_MS
|
|
29639
|
-
},
|
|
29640
|
-
fallbackTtlMs: MEDIUM_TTL_MS,
|
|
29641
|
-
hardDeleteWindowMs: HARD_DELETE_WINDOW_MS,
|
|
29642
|
-
pastEventGraceMs: PAST_EVENT_GRACE_MS
|
|
29643
|
-
};
|
|
29644
|
-
function resolvePolicy(policy) {
|
|
29645
|
-
if (!policy) return DEFAULT_DECAY_POLICY;
|
|
29646
|
-
return {
|
|
29647
|
-
ttlByType: { ...DEFAULT_DECAY_POLICY.ttlByType, ...policy.ttlByType },
|
|
29648
|
-
fallbackTtlMs: policy.fallbackTtlMs ?? DEFAULT_DECAY_POLICY.fallbackTtlMs,
|
|
29649
|
-
hardDeleteWindowMs: policy.hardDeleteWindowMs ?? DEFAULT_DECAY_POLICY.hardDeleteWindowMs,
|
|
29650
|
-
pastEventGraceMs: policy.pastEventGraceMs ?? DEFAULT_DECAY_POLICY.pastEventGraceMs
|
|
29651
|
-
};
|
|
29652
|
-
}
|
|
29653
|
-
function ttlForType(factType, policy) {
|
|
29654
|
-
const resolved = resolvePolicy(policy);
|
|
29655
|
-
if (factType === null) return resolved.fallbackTtlMs;
|
|
29656
|
-
return resolved.ttlByType[factType] ?? resolved.fallbackTtlMs;
|
|
29657
|
-
}
|
|
29658
|
-
function isTimeSensitiveType(factType) {
|
|
29659
|
-
return factType === "plan" || factType === "ongoing_context";
|
|
29660
|
-
}
|
|
29661
|
-
function hasFiniteTimestamps(m, now) {
|
|
29662
|
-
return Number.isFinite(now) && Number.isFinite(m.updatedAt) && (m.archivedAt === null || Number.isFinite(m.archivedAt));
|
|
29663
|
-
}
|
|
29664
|
-
function classifyDecay(m, now, policy) {
|
|
29665
|
-
const resolved = resolvePolicy(policy);
|
|
29666
|
-
if (!hasFiniteTimestamps(m, now)) {
|
|
29667
|
-
getLogger().warn("[memory/decay] non-finite timestamp on a memory row; keeping it", {
|
|
29668
|
-
now,
|
|
29669
|
-
updatedAt: m.updatedAt,
|
|
29670
|
-
archivedAt: m.archivedAt,
|
|
29671
|
-
factType: m.factType
|
|
29672
|
-
});
|
|
29673
|
-
return "keep";
|
|
29674
|
-
}
|
|
29675
|
-
if (m.archivedAt !== null) {
|
|
29676
|
-
return now - m.archivedAt > resolved.hardDeleteWindowMs ? "delete" : "keep";
|
|
29677
|
-
}
|
|
29678
|
-
if (m.source === "manual") return "keep";
|
|
29679
|
-
if (isTimeSensitiveType(m.factType) && m.eventTimeEnd !== null) {
|
|
29680
|
-
if (m.eventTimeEnd < now - resolved.pastEventGraceMs) return "archive";
|
|
29681
|
-
if (m.eventTimeEnd >= now) return "keep";
|
|
29682
|
-
}
|
|
29683
|
-
if (now - m.updatedAt > ttlForType(m.factType, resolved)) return "archive";
|
|
29684
|
-
return "keep";
|
|
29685
|
-
}
|
|
29686
|
-
|
|
29687
29812
|
// src/lib/memory/decayClassifier.ts
|
|
29688
29813
|
init_logger();
|
|
29689
29814
|
init_redactor();
|
|
@@ -29786,7 +29911,7 @@ function toDecayInput(c) {
|
|
|
29786
29911
|
};
|
|
29787
29912
|
}
|
|
29788
29913
|
function isBorderline(input) {
|
|
29789
|
-
if (input.source === "manual") return false;
|
|
29914
|
+
if (input.source === "manual" || input.source === SOURCE_PHOTO) return false;
|
|
29790
29915
|
if (input.trustTier === "quarantined") return false;
|
|
29791
29916
|
if (input.archivedAt !== null) return false;
|
|
29792
29917
|
if (input.factType === null || input.factType === "other") return true;
|
|
@@ -37106,6 +37231,7 @@ function buildSystemPrompt(ctx, options) {
|
|
|
37106
37231
|
hardDeleteMediaOp,
|
|
37107
37232
|
hasEncryptionKey,
|
|
37108
37233
|
hasKeyPair,
|
|
37234
|
+
ingestPublishedPhotoMemoriesOp,
|
|
37109
37235
|
injectionSignatureCatalog,
|
|
37110
37236
|
isRerankerAvailable,
|
|
37111
37237
|
isSupportedFile,
|
|
@@ -37116,6 +37242,7 @@ function buildSystemPrompt(ctx, options) {
|
|
|
37116
37242
|
mediaToStored,
|
|
37117
37243
|
migrateFromModelPreferencesOp,
|
|
37118
37244
|
onKeyAvailable,
|
|
37245
|
+
parseMedia,
|
|
37119
37246
|
preEmbedVaultMemories,
|
|
37120
37247
|
preprocessFiles,
|
|
37121
37248
|
progressiveSummarize,
|