@anuma/sdk 3.1.3 → 3.2.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/expo/{chunk-JVL5PLZS.mjs → chunk-KXIUA7ZV.mjs} +6 -1
- package/dist/expo/index.cjs +353 -2
- package/dist/expo/index.d.mts +143 -2
- package/dist/expo/index.d.ts +143 -2
- package/dist/expo/index.mjs +341 -3
- package/dist/expo/{recall-WPKWZM5N.mjs → recall-3YPU4PS2.mjs} +1 -1
- package/dist/react/{chunk-3KGACSSP.mjs → chunk-Y7PMXJT6.mjs} +6 -1
- package/dist/react/index.cjs +353 -2
- package/dist/react/index.d.mts +143 -2
- package/dist/react/index.d.ts +143 -2
- package/dist/react/index.mjs +341 -3
- package/dist/react/{recall-NG2P5ZQ7.mjs → recall-GYNSL2DS.mjs} +1 -1
- package/dist/server/{chunk-A4V7FRZ6.mjs → chunk-Y3ZS4OI3.mjs} +6 -1
- package/dist/server/index.cjs +353 -2
- package/dist/server/index.d.mts +143 -2
- package/dist/server/index.d.ts +143 -2
- package/dist/server/index.mjs +341 -3
- package/dist/server/{recall-2K7IOKY3.mjs → recall-Z72DM2JK.mjs} +1 -1
- package/package.json +1 -1
package/dist/react/index.cjs
CHANGED
|
@@ -3524,6 +3524,7 @@ function vaultMemoryToStoredRaw(memory) {
|
|
|
3524
3524
|
topicsExtractedVersion: memory.topicsExtractedVersion ?? null,
|
|
3525
3525
|
supersededBy: memory.supersededBy ?? null,
|
|
3526
3526
|
supersededAt: memory.supersededAt ?? null,
|
|
3527
|
+
lastObservedAt: memory.lastObservedAt ?? null,
|
|
3527
3528
|
createdAt: memory.createdAt,
|
|
3528
3529
|
updatedAt: memory.updatedAt,
|
|
3529
3530
|
isDeleted: memory.isDeleted
|
|
@@ -3764,6 +3765,7 @@ function vaultMemoryRawToStoredRaw(raw) {
|
|
|
3764
3765
|
topicsExtractedVersion: raw.topics_extracted_version ?? null,
|
|
3765
3766
|
supersededBy: raw.superseded_by ?? null,
|
|
3766
3767
|
supersededAt: raw.superseded_at ?? null,
|
|
3768
|
+
lastObservedAt: raw.last_observed_at ?? null,
|
|
3767
3769
|
createdAt: new Date(raw.created_at),
|
|
3768
3770
|
updatedAt: new Date(raw.updated_at),
|
|
3769
3771
|
isDeleted: raw.is_deleted === true || raw.is_deleted === 1
|
|
@@ -3852,6 +3854,9 @@ async function updateVaultMemoryOp(ctx, id, opts) {
|
|
|
3852
3854
|
if (opts.topicsUserManaged !== void 0) {
|
|
3853
3855
|
r._setRaw("topics_user_managed", opts.topicsUserManaged);
|
|
3854
3856
|
}
|
|
3857
|
+
if (opts.lastObservedAt !== void 0) {
|
|
3858
|
+
r._setRaw("last_observed_at", opts.lastObservedAt);
|
|
3859
|
+
}
|
|
3855
3860
|
if (opts.preserveUpdatedAt) {
|
|
3856
3861
|
r._setRaw("updated_at", originalUpdatedAt);
|
|
3857
3862
|
}
|
|
@@ -6502,6 +6507,7 @@ __export(index_exports, {
|
|
|
6502
6507
|
DEFAULT_ICLOUD_BACKUP_FOLDER: () => DEFAULT_BACKUP_FOLDER2,
|
|
6503
6508
|
DEFAULT_MIN_CHUNK_SIZE: () => DEFAULT_MIN_CHUNK_SIZE,
|
|
6504
6509
|
DEFAULT_PERSONALITY_SETTINGS: () => DEFAULT_PERSONALITY_SETTINGS,
|
|
6510
|
+
DEFAULT_PROFILE_FACETS: () => DEFAULT_PROFILE_FACETS,
|
|
6505
6511
|
DEFAULT_SERVER_TOOLS_MATCH_OPTIONS: () => DEFAULT_SERVER_TOOLS_MATCH_OPTIONS,
|
|
6506
6512
|
DEFAULT_VAULT_CACHE_SIZE: () => DEFAULT_VAULT_CACHE_SIZE,
|
|
6507
6513
|
DatabaseManager: () => DatabaseManager,
|
|
@@ -6516,6 +6522,7 @@ __export(index_exports, {
|
|
|
6516
6522
|
INFERENCE_ID_HEADER: () => INFERENCE_ID_HEADER,
|
|
6517
6523
|
LoggerProvider: () => LoggerProvider,
|
|
6518
6524
|
MemoryEntityModel: () => MemoryEntity,
|
|
6525
|
+
PROFILE_DOC_VERSION: () => PROFILE_DOC_VERSION,
|
|
6519
6526
|
PdfProcessor: () => PdfProcessor,
|
|
6520
6527
|
ProcessorRegistry: () => ProcessorRegistry,
|
|
6521
6528
|
Project: () => Project,
|
|
@@ -6819,6 +6826,7 @@ __export(index_exports, {
|
|
|
6819
6826
|
streamCancelPath: () => streamCancelPath,
|
|
6820
6827
|
streamReplayPath: () => streamReplayPath,
|
|
6821
6828
|
supersedeVaultMemoryOp: () => supersedeVaultMemoryOp,
|
|
6829
|
+
synthesizeProfile: () => synthesizeProfile,
|
|
6822
6830
|
updateAttrs: () => updateAttrs,
|
|
6823
6831
|
updateConversationProjectOp: () => updateConversationProjectOp,
|
|
6824
6832
|
updateMediaMessageIdBatchOp: () => updateMediaMessageIdBatchOp,
|
|
@@ -13596,6 +13604,9 @@ __decorateClass([
|
|
|
13596
13604
|
__decorateClass([
|
|
13597
13605
|
(0, import_decorators3.field)("topics_extracted_version")
|
|
13598
13606
|
], VaultMemory.prototype, "topicsExtractedVersion", 2);
|
|
13607
|
+
__decorateClass([
|
|
13608
|
+
(0, import_decorators3.field)("last_observed_at")
|
|
13609
|
+
], VaultMemory.prototype, "lastObservedAt", 2);
|
|
13599
13610
|
__decorateClass([
|
|
13600
13611
|
import_decorators3.readonly,
|
|
13601
13612
|
(0, import_decorators3.date)("created_at")
|
|
@@ -13678,6 +13689,8 @@ async function retain(content, ctx, options = {}) {
|
|
|
13678
13689
|
proofCountIncrement: 1,
|
|
13679
13690
|
sourceChunkIds: mergedSourceIds,
|
|
13680
13691
|
preserveUpdatedAt: true,
|
|
13692
|
+
// C3: record the re-observation without touching updated_at.
|
|
13693
|
+
lastObservedAt: Date.now(),
|
|
13681
13694
|
...eventTimeUpdate && { eventTime: eventTimeUpdate }
|
|
13682
13695
|
});
|
|
13683
13696
|
if (updated) {
|
|
@@ -13828,6 +13841,8 @@ async function tryConsolidate(trimmed, ctx, options) {
|
|
|
13828
13841
|
proofCountIncrement: 1,
|
|
13829
13842
|
sourceChunkIds: mergedSourceIds,
|
|
13830
13843
|
preserveUpdatedAt: true,
|
|
13844
|
+
// C3: record the re-observation without touching updated_at.
|
|
13845
|
+
lastObservedAt: Date.now(),
|
|
13831
13846
|
...eventTimeUpdate && { eventTime: eventTimeUpdate }
|
|
13832
13847
|
});
|
|
13833
13848
|
if (!updated) {
|
|
@@ -13864,6 +13879,8 @@ async function tryConsolidate(trimmed, ctx, options) {
|
|
|
13864
13879
|
// one. Preserving updated_at keeps the recency multiplier honest
|
|
13865
13880
|
// and matches the merge/noop paths above.
|
|
13866
13881
|
preserveUpdatedAt: true,
|
|
13882
|
+
// C3: record the re-observation without touching updated_at.
|
|
13883
|
+
lastObservedAt: Date.now(),
|
|
13867
13884
|
...eventTimeUpdate && { eventTime: eventTimeUpdate }
|
|
13868
13885
|
});
|
|
13869
13886
|
if (!updated) {
|
|
@@ -14683,6 +14700,316 @@ function parseAnswer(body, base, parseSchema) {
|
|
|
14683
14700
|
// src/lib/memory/index.ts
|
|
14684
14701
|
init_reranker();
|
|
14685
14702
|
|
|
14703
|
+
// src/lib/memory/synthesizeProfile.ts
|
|
14704
|
+
init_operations3();
|
|
14705
|
+
init_logger();
|
|
14706
|
+
init_constants();
|
|
14707
|
+
init_embeddings();
|
|
14708
|
+
init_vector();
|
|
14709
|
+
var DEFAULT_SYNTHESIS_MODEL = "inclusionai/ling-2.6-flash";
|
|
14710
|
+
var DEFAULT_FACET_RECALL_LIMIT = 20;
|
|
14711
|
+
var DEFAULT_FACET_MAX_TOKENS = 512;
|
|
14712
|
+
var DEFAULT_SCOPES = ["private"];
|
|
14713
|
+
var NEW_FACT_ATTRIBUTION_MIN_SCORE = 0.1;
|
|
14714
|
+
var PROFILE_DOC_VERSION = 1;
|
|
14715
|
+
var DEFAULT_PROFILE_FACETS = [
|
|
14716
|
+
{
|
|
14717
|
+
key: "bio",
|
|
14718
|
+
label: "Bio",
|
|
14719
|
+
query: "Who is this person? Their background, personality, values, and what defines them.",
|
|
14720
|
+
guidance: "Write a 1-2 sentence bio (max ~40 words) that captures what makes this person distinctive \u2014 their character, values, or a defining thread across the memories. Be specific and grounded; ban generic dating clich\xE9s ('loves to laugh', 'foodie', 'work hard play hard', 'living life to the fullest')."
|
|
14721
|
+
},
|
|
14722
|
+
{
|
|
14723
|
+
key: "interests",
|
|
14724
|
+
label: "Interests",
|
|
14725
|
+
query: "What are this person's hobbies, passions, pastimes, and interests?",
|
|
14726
|
+
guidance: "Return 3-6 specific interests as a comma-separated list (e.g. 'trail running, film photography, Thai cooking'). Prefer concrete activities the memories actually show over broad categories ('music', 'travel'). No sentence, just the list."
|
|
14727
|
+
},
|
|
14728
|
+
{
|
|
14729
|
+
key: "work_role",
|
|
14730
|
+
label: "Work & Role",
|
|
14731
|
+
query: "What does this person do for work \u2014 their profession, role, industry, or studies?",
|
|
14732
|
+
guidance: "State the person's current role/profession and field in one short line (e.g. 'Backend engineer at a fintech startup'). Use only what the memories support; if unclear or absent, return hasEvidence=false rather than guessing a title."
|
|
14733
|
+
},
|
|
14734
|
+
{
|
|
14735
|
+
key: "location_context",
|
|
14736
|
+
label: "Location",
|
|
14737
|
+
query: "Where does this person live, spend time, or come from?",
|
|
14738
|
+
guidance: "Summarize where the person is based or spends time at neighborhood-or-city granularity in one short line (e.g. 'Based in the Mission, SF'). PRIVACY: never emit a precise address, building, or workplace location \u2014 coarse-grain to the city/neighborhood."
|
|
14739
|
+
},
|
|
14740
|
+
{
|
|
14741
|
+
key: "communication_style",
|
|
14742
|
+
label: "Communication Style",
|
|
14743
|
+
query: "How does this person communicate, express themselves, and interact with others?",
|
|
14744
|
+
guidance: "Describe the person's communication and social style in one line using 2-4 concrete adjectives grounded in the memories (e.g. 'Direct, dry-humored, and a careful listener'). Avoid empty praise."
|
|
14745
|
+
},
|
|
14746
|
+
{
|
|
14747
|
+
key: "recent_activity",
|
|
14748
|
+
label: "Recently",
|
|
14749
|
+
query: "What has this person been doing, focused on, or working on recently?",
|
|
14750
|
+
guidance: "Summarize what the person has been up to lately in one line, favoring the most recently reinforced facts. Frame it as current/ongoing (e.g. 'Lately: training for a first half-marathon and learning Portuguese'). Omit if nothing recent stands out."
|
|
14751
|
+
}
|
|
14752
|
+
];
|
|
14753
|
+
var FACET_RESPONSE_SCHEMA = {
|
|
14754
|
+
type: "object",
|
|
14755
|
+
properties: {
|
|
14756
|
+
summary: {
|
|
14757
|
+
type: "string",
|
|
14758
|
+
description: "The synthesized section prose. Empty string if the memories don't cover it."
|
|
14759
|
+
},
|
|
14760
|
+
hasEvidence: {
|
|
14761
|
+
type: "boolean",
|
|
14762
|
+
description: "False when the supplied memories don't support any claim for this facet."
|
|
14763
|
+
}
|
|
14764
|
+
},
|
|
14765
|
+
required: ["summary", "hasEvidence"],
|
|
14766
|
+
additionalProperties: false
|
|
14767
|
+
};
|
|
14768
|
+
async function synthesizeProfile(ctx, options = {}) {
|
|
14769
|
+
if (!ctx.vaultCtx) {
|
|
14770
|
+
throw new Error("synthesizeProfile requires ctx.vaultCtx (vault-backed facts).");
|
|
14771
|
+
}
|
|
14772
|
+
if (!ctx.vaultCache) {
|
|
14773
|
+
throw new Error("synthesizeProfile requires ctx.vaultCache (semantic fact recall).");
|
|
14774
|
+
}
|
|
14775
|
+
const facets = options.facets ?? DEFAULT_PROFILE_FACETS;
|
|
14776
|
+
const scopes = options.scopes ?? DEFAULT_SCOPES;
|
|
14777
|
+
const config = {
|
|
14778
|
+
facetKeys: facets.map((f) => f.key).sort(),
|
|
14779
|
+
facetsSignature: facetsSignature(facets),
|
|
14780
|
+
scopes: [...scopes].sort(),
|
|
14781
|
+
redacted: options.redactor !== void 0
|
|
14782
|
+
};
|
|
14783
|
+
const previous = options.previous && options.previous.version === PROFILE_DOC_VERSION && configMatches(options.previous.config, config) ? options.previous : void 0;
|
|
14784
|
+
const memories = await getAllVaultMemoriesOp(ctx.vaultCtx, {
|
|
14785
|
+
// Scope the snapshot to the same scopes synthesis recalls from, so the
|
|
14786
|
+
// watermark, delta, and new-fact attribution all track only facts that can
|
|
14787
|
+
// actually appear in the profile — an out-of-scope change/new-fact must not
|
|
14788
|
+
// trigger a regeneration that scoped recall would never reflect.
|
|
14789
|
+
scopes,
|
|
14790
|
+
includeDeleted: true,
|
|
14791
|
+
includeSuperseded: true
|
|
14792
|
+
});
|
|
14793
|
+
const watermark = computeVaultWatermark(memories);
|
|
14794
|
+
const presentIds = new Set(memories.map((m) => m.uniqueId));
|
|
14795
|
+
const hasStaleSections = previous?.sections.some((s) => s.stale);
|
|
14796
|
+
const citesMissingFact = previous?.sections.some(
|
|
14797
|
+
(s) => s.sourceMemoryIds.some((id) => !presentIds.has(id))
|
|
14798
|
+
);
|
|
14799
|
+
if (previous && previous.vaultWatermark === watermark && !hasStaleSections && !citesMissingFact) {
|
|
14800
|
+
const sameOrder = previous.sections.length === facets.length && facets.every((f, i) => previous.sections[i]?.key === f.key);
|
|
14801
|
+
if (sameOrder) return previous;
|
|
14802
|
+
return {
|
|
14803
|
+
...previous,
|
|
14804
|
+
sections: facets.map((f) => previous.sections.find((s) => s.key === f.key))
|
|
14805
|
+
};
|
|
14806
|
+
}
|
|
14807
|
+
const staleKeys = await computeStaleFacetKeys(ctx, memories, facets, previous, watermark);
|
|
14808
|
+
const settled = await Promise.allSettled(
|
|
14809
|
+
facets.map(async (facet) => {
|
|
14810
|
+
const prior = previous?.sections.find((s) => s.key === facet.key);
|
|
14811
|
+
if (prior && !staleKeys.has(facet.key)) {
|
|
14812
|
+
return prior;
|
|
14813
|
+
}
|
|
14814
|
+
return synthesizeFacet(facet, ctx, options, prior);
|
|
14815
|
+
})
|
|
14816
|
+
);
|
|
14817
|
+
const sections = settled.map((r, i) => {
|
|
14818
|
+
if (r.status === "fulfilled") return r.value;
|
|
14819
|
+
const facet = facets[i];
|
|
14820
|
+
getLogger().warn(
|
|
14821
|
+
"[memory/synthesizeProfile] facet synthesis rejected; using fallback section",
|
|
14822
|
+
{
|
|
14823
|
+
facet: facet.key,
|
|
14824
|
+
error: r.reason instanceof Error ? r.reason.message : String(r.reason)
|
|
14825
|
+
}
|
|
14826
|
+
);
|
|
14827
|
+
return fallbackSection(
|
|
14828
|
+
facet,
|
|
14829
|
+
previous?.sections.find((s) => s.key === facet.key)
|
|
14830
|
+
);
|
|
14831
|
+
});
|
|
14832
|
+
return {
|
|
14833
|
+
version: PROFILE_DOC_VERSION,
|
|
14834
|
+
sections,
|
|
14835
|
+
vaultWatermark: watermark,
|
|
14836
|
+
config,
|
|
14837
|
+
generatedAt: Date.now()
|
|
14838
|
+
};
|
|
14839
|
+
}
|
|
14840
|
+
function configMatches(a, b) {
|
|
14841
|
+
if (!a) return false;
|
|
14842
|
+
return a.redacted === b.redacted && a.facetsSignature === b.facetsSignature && a.scopes.length === b.scopes.length && a.scopes.every((s, i) => s === b.scopes[i]);
|
|
14843
|
+
}
|
|
14844
|
+
function facetsSignature(facets) {
|
|
14845
|
+
return facets.map((f) => JSON.stringify([f.key, f.label, f.query, f.guidance])).sort().join("\n");
|
|
14846
|
+
}
|
|
14847
|
+
function changeTime(m) {
|
|
14848
|
+
return Math.max(m.updatedAt.getTime(), m.supersededAt ?? 0, m.lastObservedAt ?? 0);
|
|
14849
|
+
}
|
|
14850
|
+
function computeVaultWatermark(memories) {
|
|
14851
|
+
let max = 0;
|
|
14852
|
+
for (const m of memories) {
|
|
14853
|
+
const t = changeTime(m);
|
|
14854
|
+
if (t > max) max = t;
|
|
14855
|
+
}
|
|
14856
|
+
return max;
|
|
14857
|
+
}
|
|
14858
|
+
async function computeStaleFacetKeys(ctx, memories, facets, previous, watermark) {
|
|
14859
|
+
const allKeys = new Set(facets.map((f) => f.key));
|
|
14860
|
+
if (previous && watermark < previous.vaultWatermark) return allKeys;
|
|
14861
|
+
if (!previous) return allKeys;
|
|
14862
|
+
const changed = memories.filter((m) => changeTime(m) > previous.vaultWatermark);
|
|
14863
|
+
const changedIds = new Set(changed.map((m) => m.uniqueId));
|
|
14864
|
+
const presentIds = new Set(memories.map((m) => m.uniqueId));
|
|
14865
|
+
const stale = /* @__PURE__ */ new Set();
|
|
14866
|
+
for (const section of previous.sections) {
|
|
14867
|
+
if (section.sourceMemoryIds.some((id) => changedIds.has(id))) {
|
|
14868
|
+
stale.add(section.key);
|
|
14869
|
+
}
|
|
14870
|
+
if (section.sourceMemoryIds.some((id) => !presentIds.has(id))) {
|
|
14871
|
+
stale.add(section.key);
|
|
14872
|
+
}
|
|
14873
|
+
if (section.stale) {
|
|
14874
|
+
stale.add(section.key);
|
|
14875
|
+
}
|
|
14876
|
+
}
|
|
14877
|
+
for (const facet of facets) {
|
|
14878
|
+
if (!previous.sections.some((s) => s.key === facet.key)) stale.add(facet.key);
|
|
14879
|
+
}
|
|
14880
|
+
const citedIds = new Set(previous.sections.flatMap((s) => s.sourceMemoryIds));
|
|
14881
|
+
const toAttribute = changed.filter(
|
|
14882
|
+
(m) => !m.isDeleted && !m.supersededBy && !citedIds.has(m.uniqueId)
|
|
14883
|
+
);
|
|
14884
|
+
if (toAttribute.length > 0) {
|
|
14885
|
+
const attributed = await attributeFacts(ctx, toAttribute, facets);
|
|
14886
|
+
if (attributed === null) return allKeys;
|
|
14887
|
+
for (const k of attributed) stale.add(k);
|
|
14888
|
+
}
|
|
14889
|
+
return stale;
|
|
14890
|
+
}
|
|
14891
|
+
async function attributeFacts(ctx, candidates, facets) {
|
|
14892
|
+
const model = ctx.embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
|
|
14893
|
+
const factVectors = [];
|
|
14894
|
+
for (const f of candidates) {
|
|
14895
|
+
if (!f.embedding || f.embeddingModel && f.embeddingModel !== model) {
|
|
14896
|
+
getLogger().warn(
|
|
14897
|
+
"[memory/synthesizeProfile] fact lacks a usable current-model embedding; regenerating all facets",
|
|
14898
|
+
{ memoryId: f.uniqueId, hasEmbedding: !!f.embedding, embeddingModel: f.embeddingModel }
|
|
14899
|
+
);
|
|
14900
|
+
return null;
|
|
14901
|
+
}
|
|
14902
|
+
let vec;
|
|
14903
|
+
try {
|
|
14904
|
+
vec = JSON.parse(f.embedding);
|
|
14905
|
+
} catch {
|
|
14906
|
+
getLogger().warn(
|
|
14907
|
+
"[memory/synthesizeProfile] fact embedding failed to parse; regenerating all facets",
|
|
14908
|
+
{ memoryId: f.uniqueId }
|
|
14909
|
+
);
|
|
14910
|
+
return null;
|
|
14911
|
+
}
|
|
14912
|
+
if (!Array.isArray(vec) || vec.length === 0) return null;
|
|
14913
|
+
factVectors.push(vec);
|
|
14914
|
+
}
|
|
14915
|
+
let queryVectors;
|
|
14916
|
+
try {
|
|
14917
|
+
queryVectors = await generateEmbeddings(
|
|
14918
|
+
facets.map((f) => f.query),
|
|
14919
|
+
ctx.embeddingOptions
|
|
14920
|
+
);
|
|
14921
|
+
} catch (err) {
|
|
14922
|
+
getLogger().warn(
|
|
14923
|
+
"[memory/synthesizeProfile] facet-query embedding failed; regenerating all facets",
|
|
14924
|
+
{ error: err instanceof Error ? err.message : String(err) }
|
|
14925
|
+
);
|
|
14926
|
+
return null;
|
|
14927
|
+
}
|
|
14928
|
+
const keys = /* @__PURE__ */ new Set();
|
|
14929
|
+
for (const fv of factVectors) {
|
|
14930
|
+
let matchedAny = false;
|
|
14931
|
+
for (let i = 0; i < facets.length; i++) {
|
|
14932
|
+
if (cosineSimilarity(fv, queryVectors[i]) >= NEW_FACT_ATTRIBUTION_MIN_SCORE) {
|
|
14933
|
+
keys.add(facets[i].key);
|
|
14934
|
+
matchedAny = true;
|
|
14935
|
+
}
|
|
14936
|
+
}
|
|
14937
|
+
if (!matchedAny) return null;
|
|
14938
|
+
}
|
|
14939
|
+
return keys;
|
|
14940
|
+
}
|
|
14941
|
+
async function synthesizeFacet(facet, ctx, options, prior) {
|
|
14942
|
+
const result = await reflect(facet.query, ctx, {
|
|
14943
|
+
apiKey: options.apiKey,
|
|
14944
|
+
getToken: options.getToken,
|
|
14945
|
+
llmModel: options.llmModel ?? DEFAULT_SYNTHESIS_MODEL,
|
|
14946
|
+
baseUrl: options.baseUrl,
|
|
14947
|
+
fetchFn: options.fetchFn,
|
|
14948
|
+
scopes: options.scopes ?? DEFAULT_SCOPES,
|
|
14949
|
+
limit: options.limit ?? DEFAULT_FACET_RECALL_LIMIT,
|
|
14950
|
+
types: ["fact"],
|
|
14951
|
+
maxTokens: DEFAULT_FACET_MAX_TOKENS,
|
|
14952
|
+
systemPrompt: buildFacetSystemPrompt(facet),
|
|
14953
|
+
responseSchema: FACET_RESPONSE_SCHEMA
|
|
14954
|
+
});
|
|
14955
|
+
const noEvidence = result.basedOn.memoryIds.length === 0;
|
|
14956
|
+
const { text: text12, legitimateEmpty } = extractFacetText(result.structuredOutput);
|
|
14957
|
+
if (!text12 && !legitimateEmpty && !noEvidence) {
|
|
14958
|
+
getLogger().warn(
|
|
14959
|
+
"[memory/synthesizeProfile] facet synthesis returned degraded-empty; keeping prior section",
|
|
14960
|
+
{ facet: facet.key, recalledCount: result.basedOn.memoryIds.length }
|
|
14961
|
+
);
|
|
14962
|
+
return fallbackSection(facet, prior);
|
|
14963
|
+
}
|
|
14964
|
+
const section = {
|
|
14965
|
+
key: facet.key,
|
|
14966
|
+
label: facet.label,
|
|
14967
|
+
text: text12,
|
|
14968
|
+
sourceMemoryIds: result.basedOn.memoryIds,
|
|
14969
|
+
generatedAt: Date.now()
|
|
14970
|
+
};
|
|
14971
|
+
if (options.redactor && text12) {
|
|
14972
|
+
const redacted = await options.redactor.redactTextAsync(text12);
|
|
14973
|
+
section.text = redacted.text;
|
|
14974
|
+
}
|
|
14975
|
+
return section;
|
|
14976
|
+
}
|
|
14977
|
+
function fallbackSection(facet, prior) {
|
|
14978
|
+
if (prior && prior.text) {
|
|
14979
|
+
return { ...prior, stale: true };
|
|
14980
|
+
}
|
|
14981
|
+
return {
|
|
14982
|
+
key: facet.key,
|
|
14983
|
+
label: facet.label,
|
|
14984
|
+
text: "",
|
|
14985
|
+
sourceMemoryIds: [],
|
|
14986
|
+
generatedAt: Date.now(),
|
|
14987
|
+
stale: true
|
|
14988
|
+
};
|
|
14989
|
+
}
|
|
14990
|
+
function buildFacetSystemPrompt(facet) {
|
|
14991
|
+
return `You are writing the "${facet.label}" section of a person's shareable profile, using their private memories (supplied as evidence) as the only source of truth.
|
|
14992
|
+
|
|
14993
|
+
Task for this section:
|
|
14994
|
+
${facet.guidance}
|
|
14995
|
+
|
|
14996
|
+
Rules:
|
|
14997
|
+
- Ground every claim in the supplied memories \u2014 never invent, infer beyond, or embellish what they support.
|
|
14998
|
+
- If the memories don't cover this section, return an empty summary with hasEvidence=false. Do not pad or guess.
|
|
14999
|
+
- Write in third person about the person, in a natural voice suitable for a public profile (no "I"/"you", no name repetition).
|
|
15000
|
+
- Be concise and specific; no preamble, hedging, or meta-commentary.
|
|
15001
|
+
- Respond as JSON: { "summary": <the section text, or "">, "hasEvidence": <true|false> }.`;
|
|
15002
|
+
}
|
|
15003
|
+
function extractFacetText(structured) {
|
|
15004
|
+
if (structured && typeof structured === "object") {
|
|
15005
|
+
const obj = structured;
|
|
15006
|
+
if (obj.hasEvidence === false) return { text: "", legitimateEmpty: true };
|
|
15007
|
+
if (typeof obj.summary === "string")
|
|
15008
|
+
return { text: obj.summary.trim(), legitimateEmpty: false };
|
|
15009
|
+
}
|
|
15010
|
+
return { text: "", legitimateEmpty: false };
|
|
15011
|
+
}
|
|
15012
|
+
|
|
14686
15013
|
// src/lib/memory/topicExtract.ts
|
|
14687
15014
|
init_operations2();
|
|
14688
15015
|
init_operations3();
|
|
@@ -19295,7 +19622,7 @@ __decorateClass([
|
|
|
19295
19622
|
], VaultFolder.prototype, "context", 2);
|
|
19296
19623
|
|
|
19297
19624
|
// src/lib/db/schema.ts
|
|
19298
|
-
var SDK_SCHEMA_VERSION =
|
|
19625
|
+
var SDK_SCHEMA_VERSION = 39;
|
|
19299
19626
|
var sdkSchema = (0, import_watermelondb20.appSchema)({
|
|
19300
19627
|
version: SDK_SCHEMA_VERSION,
|
|
19301
19628
|
tables: [
|
|
@@ -19433,7 +19760,14 @@ var sdkSchema = (0, import_watermelondb20.appSchema)({
|
|
|
19433
19760
|
// The extraction-logic version this memory was last stamped under. Null
|
|
19434
19761
|
// (pre-v38) is treated as version 0, so a bump of TOPICS_EXTRACTION_VERSION
|
|
19435
19762
|
// re-extracts stale rows. See getMemoriesNeedingTopicExtractionOp.
|
|
19436
|
-
{ name: "topics_extracted_version", type: "number", isOptional: true }
|
|
19763
|
+
{ name: "topics_extracted_version", type: "number", isOptional: true },
|
|
19764
|
+
// Re-observation watermark (C3). Unix ms of the last time retain() merged
|
|
19765
|
+
// a duplicate observation into this fact (proof_count++). Distinct from
|
|
19766
|
+
// updated_at, which merges deliberately preserve (preserveUpdatedAt) so a
|
|
19767
|
+
// re-observation doesn't reorder the vault by edit time. Null = never
|
|
19768
|
+
// re-observed since the column was added. Indexed so recency-weighted
|
|
19769
|
+
// synthesis can filter/sort on it cheaply.
|
|
19770
|
+
{ name: "last_observed_at", type: "number", isOptional: true, isIndexed: true }
|
|
19437
19771
|
]
|
|
19438
19772
|
}),
|
|
19439
19773
|
// Entity table — canonical names extracted from auto-extraction (W5).
|
|
@@ -20072,6 +20406,20 @@ var sdkMigrations = (0, import_migrations2.schemaMigrations)({
|
|
|
20072
20406
|
columns: [{ name: "topics_extracted_version", type: "number", isOptional: true }]
|
|
20073
20407
|
})
|
|
20074
20408
|
]
|
|
20409
|
+
},
|
|
20410
|
+
// v38 -> v39: re-observation watermark on memory_vault (C3). Existing rows
|
|
20411
|
+
// keep NULL (= never re-observed since the column was added); synthesis
|
|
20412
|
+
// treats NULL as "fall back to updated_at" so no backfill is needed.
|
|
20413
|
+
{
|
|
20414
|
+
toVersion: 39,
|
|
20415
|
+
steps: [
|
|
20416
|
+
(0, import_migrations2.addColumns)({
|
|
20417
|
+
table: "memory_vault",
|
|
20418
|
+
columns: [
|
|
20419
|
+
{ name: "last_observed_at", type: "number", isOptional: true, isIndexed: true }
|
|
20420
|
+
]
|
|
20421
|
+
})
|
|
20422
|
+
]
|
|
20075
20423
|
}
|
|
20076
20424
|
]
|
|
20077
20425
|
});
|
|
@@ -30517,6 +30865,7 @@ function renderAnumaJsx(jsx3) {
|
|
|
30517
30865
|
DEFAULT_ICLOUD_BACKUP_FOLDER,
|
|
30518
30866
|
DEFAULT_MIN_CHUNK_SIZE,
|
|
30519
30867
|
DEFAULT_PERSONALITY_SETTINGS,
|
|
30868
|
+
DEFAULT_PROFILE_FACETS,
|
|
30520
30869
|
DEFAULT_SERVER_TOOLS_MATCH_OPTIONS,
|
|
30521
30870
|
DEFAULT_VAULT_CACHE_SIZE,
|
|
30522
30871
|
DatabaseManager,
|
|
@@ -30531,6 +30880,7 @@ function renderAnumaJsx(jsx3) {
|
|
|
30531
30880
|
INFERENCE_ID_HEADER,
|
|
30532
30881
|
LoggerProvider,
|
|
30533
30882
|
MemoryEntityModel,
|
|
30883
|
+
PROFILE_DOC_VERSION,
|
|
30534
30884
|
PdfProcessor,
|
|
30535
30885
|
ProcessorRegistry,
|
|
30536
30886
|
Project,
|
|
@@ -30834,6 +31184,7 @@ function renderAnumaJsx(jsx3) {
|
|
|
30834
31184
|
streamCancelPath,
|
|
30835
31185
|
streamReplayPath,
|
|
30836
31186
|
supersedeVaultMemoryOp,
|
|
31187
|
+
synthesizeProfile,
|
|
30837
31188
|
updateAttrs,
|
|
30838
31189
|
updateConversationProjectOp,
|
|
30839
31190
|
updateMediaMessageIdBatchOp,
|