@anuma/sdk 6.40.0 → 6.41.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/index.cjs +132 -67
- package/dist/expo/index.d.mts +26 -1
- package/dist/expo/index.d.ts +26 -1
- package/dist/expo/index.mjs +129 -67
- package/dist/memory/context.d.mts +2 -0
- package/dist/memory/context.d.ts +2 -0
- package/dist/react/index.cjs +94 -27
- package/dist/react/index.d.mts +26 -1
- package/dist/react/index.d.ts +26 -1
- package/dist/react/index.mjs +91 -27
- package/dist/server/index.cjs +71 -24
- package/dist/server/index.d.mts +4 -0
- package/dist/server/index.d.ts +4 -0
- package/dist/server/index.mjs +71 -24
- package/package.json +1 -1
package/dist/server/index.cjs
CHANGED
|
@@ -27383,6 +27383,10 @@ var ENTITY_KINDS = [
|
|
|
27383
27383
|
function normalizeEntityName(name) {
|
|
27384
27384
|
return name.trim().toLowerCase();
|
|
27385
27385
|
}
|
|
27386
|
+
var TOPIC_SALIENCE_WEIGHTS = { primary: 1, secondary: 0.6, mention: 0.3 };
|
|
27387
|
+
function parseTopicWeight(value) {
|
|
27388
|
+
return typeof value === "number" && value > 0 && value <= 1 ? value : void 0;
|
|
27389
|
+
}
|
|
27386
27390
|
function serializeTopics(topics) {
|
|
27387
27391
|
return JSON.stringify(topics);
|
|
27388
27392
|
}
|
|
@@ -27398,12 +27402,14 @@ function parseTopics(value) {
|
|
|
27398
27402
|
const out = [];
|
|
27399
27403
|
for (const raw of parsed) {
|
|
27400
27404
|
if (typeof raw !== "object" || raw === null) continue;
|
|
27401
|
-
const { name, kind, source } = raw;
|
|
27405
|
+
const { name, kind, source, weight } = raw;
|
|
27402
27406
|
if (typeof name !== "string" || name.trim().length === 0) continue;
|
|
27407
|
+
const parsedWeight = parseTopicWeight(weight);
|
|
27403
27408
|
out.push({
|
|
27404
27409
|
name,
|
|
27405
27410
|
...typeof kind === "string" && kind.length > 0 ? { kind } : {},
|
|
27406
|
-
source: source === "user" ? "user" : "auto"
|
|
27411
|
+
source: source === "user" ? "user" : "auto",
|
|
27412
|
+
...parsedWeight !== void 0 ? { weight: parsedWeight } : {}
|
|
27407
27413
|
});
|
|
27408
27414
|
}
|
|
27409
27415
|
return out;
|
|
@@ -27490,21 +27496,47 @@ function displayNamesOf(entities) {
|
|
|
27490
27496
|
}
|
|
27491
27497
|
function topicsEqual(stored, computed) {
|
|
27492
27498
|
if (stored === null || stored.length !== computed.length) return false;
|
|
27493
|
-
const key = (t) => JSON.stringify([t.name, t.kind ?? null, t.source]);
|
|
27499
|
+
const key = (t) => JSON.stringify([t.name, t.kind ?? null, t.source, t.weight ?? null]);
|
|
27494
27500
|
const storedKeys = stored.map(key).sort();
|
|
27495
27501
|
const computedKeys = computed.map(key).sort();
|
|
27496
27502
|
return storedKeys.every((k, i) => k === computedKeys[i]);
|
|
27497
27503
|
}
|
|
27498
|
-
function resolveTopicsWrite(row, linked,
|
|
27504
|
+
function resolveTopicsWrite(row, linked, inputs, source, mode) {
|
|
27499
27505
|
if (row === null || source === null) return null;
|
|
27500
|
-
const
|
|
27501
|
-
|
|
27506
|
+
const stored = parseTopics(row.topics);
|
|
27507
|
+
const carried = mode === "merge" ? stored : null;
|
|
27508
|
+
const weights = source === "auto" ? weightsOf(carried, inputs) : null;
|
|
27509
|
+
const displayNames = displayNamesOf([...inputs, ...carried ?? []]);
|
|
27510
|
+
const topics = topicsForEntities(linked, displayNames, source, weights);
|
|
27511
|
+
if (topicsEqual(stored, topics)) return null;
|
|
27502
27512
|
return { row, topics };
|
|
27503
27513
|
}
|
|
27504
|
-
function
|
|
27514
|
+
function weightsOf(stored, inputs) {
|
|
27515
|
+
const out = /* @__PURE__ */ new Map();
|
|
27516
|
+
for (const topic of stored ?? []) out.set(normalizeEntityName(topic.name), topic.weight);
|
|
27517
|
+
for (const input of inputs) {
|
|
27518
|
+
const weight = parseTopicWeight(input.weight);
|
|
27519
|
+
if (weight === void 0) continue;
|
|
27520
|
+
const name = normalizeEntityName(input.name);
|
|
27521
|
+
if (!out.has(name)) {
|
|
27522
|
+
out.set(name, weight);
|
|
27523
|
+
continue;
|
|
27524
|
+
}
|
|
27525
|
+
const current = out.get(name);
|
|
27526
|
+
if (current !== void 0 && weight > current) out.set(name, weight);
|
|
27527
|
+
}
|
|
27528
|
+
return out;
|
|
27529
|
+
}
|
|
27530
|
+
function topicsForEntities(entities, displayNames, source, weights) {
|
|
27505
27531
|
return entities.map((e) => {
|
|
27506
27532
|
const name = displayNames.get(e.canonicalName) ?? e.canonicalName;
|
|
27507
|
-
|
|
27533
|
+
const weight = weights?.get(e.canonicalName);
|
|
27534
|
+
return {
|
|
27535
|
+
name,
|
|
27536
|
+
...e.kind ? { kind: e.kind } : {},
|
|
27537
|
+
source,
|
|
27538
|
+
...weight !== void 0 ? { weight } : {}
|
|
27539
|
+
};
|
|
27508
27540
|
});
|
|
27509
27541
|
}
|
|
27510
27542
|
function toEntityObjects(entityInputs) {
|
|
@@ -27512,7 +27544,7 @@ function toEntityObjects(entityInputs) {
|
|
|
27512
27544
|
}
|
|
27513
27545
|
async function resolveMemoryTopicsWrite(ctx, memoryId, linked, inputs, source) {
|
|
27514
27546
|
const row = await findVaultRowInWrite(ctx, memoryId);
|
|
27515
|
-
return resolveTopicsWrite(row, linked,
|
|
27547
|
+
return resolveTopicsWrite(row, linked, toEntityObjects(inputs), source, "replace");
|
|
27516
27548
|
}
|
|
27517
27549
|
function prepareMemoryTopicsUpdate(write) {
|
|
27518
27550
|
return prepareTopicsUpdate(write.row, write.topics, Date.now());
|
|
@@ -27550,8 +27582,9 @@ async function linkMemoryEntitiesOp(ctx, memoryId, entityInputs, options) {
|
|
|
27550
27582
|
const topicsWrite = resolveTopicsWrite(
|
|
27551
27583
|
vaultRow,
|
|
27552
27584
|
[...carriedOver, ...entities],
|
|
27553
|
-
|
|
27554
|
-
options?.topicsSource ?? "auto"
|
|
27585
|
+
normalized,
|
|
27586
|
+
options?.topicsSource ?? "auto",
|
|
27587
|
+
"merge"
|
|
27555
27588
|
);
|
|
27556
27589
|
if (entityOps.length === 0 && kindBackfills.length === 0 && toCreate.length === 0 && topicsWrite === null) {
|
|
27557
27590
|
return;
|
|
@@ -27617,8 +27650,9 @@ async function replaceMemoryEntities(ctx, memoryId, entityInputs, options) {
|
|
|
27617
27650
|
const topicsWrite = resolveTopicsWrite(
|
|
27618
27651
|
vaultRow,
|
|
27619
27652
|
entities,
|
|
27620
|
-
|
|
27621
|
-
options.topicsSource
|
|
27653
|
+
normalized,
|
|
27654
|
+
options.topicsSource,
|
|
27655
|
+
"replace"
|
|
27622
27656
|
);
|
|
27623
27657
|
if (entityOps.length === 0 && kindBackfills.length === 0 && toCreate.length === 0 && toDestroy.length === 0 && topicsWrite === null) {
|
|
27624
27658
|
return;
|
|
@@ -32599,9 +32633,9 @@ For each durable fact, output:
|
|
|
32599
32633
|
- type: one of identity | preference | relationship | plan | ongoing_context | constraint | other
|
|
32600
32634
|
- confidence: 0.0-1.0; how sure you are this is durable AND true. Only include facts >= 0.7.
|
|
32601
32635
|
- sourceMessageIds: which message IDs from the conversation contained the evidence
|
|
32602
|
-
- entities: named entities mentioned, each as an object { "name": string, "kind": one of "person" | "organization" | "place" | "event" | "product" | "thing" | "concept" | "other" }. Optional \u2014 include only NAMED entities, skip generic/common nouns. ${ENTITY_KIND_GUIDELINES} Examples:
|
|
32603
|
-
- "started a new job at Hollowpoint Labs and I'm learning Haskell for it" \u2192 entities: [{ "name": "Hollowpoint Labs", "kind": "organization" }, { "name": "Haskell", "kind": "concept" }]
|
|
32604
|
-
- "running the Berlin Half in May and I track workouts in Whoop" \u2192 entities: [{ "name": "Berlin Half", "kind": "event" }, { "name": "Whoop", "kind": "product" }]
|
|
32636
|
+
- entities: named entities mentioned, each as an object { "name": string, "kind": one of "person" | "organization" | "place" | "event" | "product" | "thing" | "concept" | "other", "salience": one of "primary" | "secondary" | "mention" }. Optional \u2014 include only NAMED entities, skip generic/common nouns. ${ENTITY_KIND_GUIDELINES} Salience is how central the entity is to the fact: "primary" = the fact is ABOUT it (usually exactly one per fact), "secondary" = a meaningful part of it, "mention" = named in passing. Examples:
|
|
32637
|
+
- "started a new job at Hollowpoint Labs and I'm learning Haskell for it" \u2192 entities: [{ "name": "Hollowpoint Labs", "kind": "organization", "salience": "primary" }, { "name": "Haskell", "kind": "concept", "salience": "secondary" }]
|
|
32638
|
+
- "running the Berlin Half in May and I track workouts in Whoop" \u2192 entities: [{ "name": "Berlin Half", "kind": "event", "salience": "primary" }, { "name": "Whoop", "kind": "product", "salience": "mention" }]
|
|
32605
32639
|
- eventTime: when the event in this fact occurs/occurred. Resolve relative phrases ("yesterday", "next week") against the current date given in the user message. Output one of:
|
|
32606
32640
|
- { "kind": "point", "start": "YYYY-MM-DD" } for a single date ("met Sara on March 14, 2026")
|
|
32607
32641
|
- { "kind": "range", "start": "YYYY-MM-DD", "end": "YYYY-MM-DD" } for a span ("Japan trip May 4\u201315, 2026")
|
|
@@ -32682,9 +32716,10 @@ function restoreCandidates(candidates, redactor, ownNames) {
|
|
|
32682
32716
|
candidate: {
|
|
32683
32717
|
...c,
|
|
32684
32718
|
content: content.text,
|
|
32685
|
-
entities: c.entities.
|
|
32686
|
-
|
|
32687
|
-
|
|
32719
|
+
entities: c.entities.flatMap((e) => {
|
|
32720
|
+
const restored = redactor.restoreForStorage(e.name);
|
|
32721
|
+
return restored.unresolved ? [] : [{ ...e, name: restored.text }];
|
|
32722
|
+
})
|
|
32688
32723
|
},
|
|
32689
32724
|
unresolved: content.unresolved
|
|
32690
32725
|
};
|
|
@@ -32913,7 +32948,12 @@ function parseEntities(raw) {
|
|
|
32913
32948
|
const name = typeof obj.name === "string" ? obj.name.trim() : "";
|
|
32914
32949
|
if (name.length === 0 || isGenericEntityName(name)) continue;
|
|
32915
32950
|
const kind = typeof obj.kind === "string" && ENTITY_KINDS.includes(obj.kind) ? obj.kind : void 0;
|
|
32916
|
-
|
|
32951
|
+
const weight = typeof obj.salience === "string" && Object.keys(TOPIC_SALIENCE_WEIGHTS).includes(obj.salience) ? TOPIC_SALIENCE_WEIGHTS[obj.salience] : void 0;
|
|
32952
|
+
out.push({
|
|
32953
|
+
name,
|
|
32954
|
+
...kind !== void 0 ? { kind } : {},
|
|
32955
|
+
...weight !== void 0 ? { weight } : {}
|
|
32956
|
+
});
|
|
32917
32957
|
}
|
|
32918
32958
|
return out;
|
|
32919
32959
|
}
|
|
@@ -34893,7 +34933,13 @@ Include only NAMED entities, skip generic/common nouns. A topic must identify a
|
|
|
34893
34933
|
- Prefer 0 entities over a weak one. A memory whose only candidate is a generic noun has NO entities.
|
|
34894
34934
|
${ENTITY_KIND_GUIDELINES}
|
|
34895
34935
|
|
|
34896
|
-
|
|
34936
|
+
Give each entity a "salience" \u2014 how central it is to the memory:
|
|
34937
|
+
- "primary": the memory is ABOUT it. A memory with entities usually has exactly one primary; never more than two.
|
|
34938
|
+
- "secondary": a meaningful part of the memory, but not its subject.
|
|
34939
|
+
- "mention": named in passing; the memory would say much the same without it.
|
|
34940
|
+
Example: "Ran the Chicago Marathon with my sister Ana in 3:41" \u2192 Chicago Marathon primary, Ana secondary.
|
|
34941
|
+
|
|
34942
|
+
Each memory below is written as "<id>: <text>". Output strict JSON: {"memories": [{"id": string, "entities": [{"name": string, "kind": string, "salience": "primary" | "secondary" | "mention"}]}]}
|
|
34897
34943
|
- exactly one element per input memory; copy its id EXACTLY as written (the token before the first ": "), with no brackets, quotes, or extra characters
|
|
34898
34944
|
- "entities" may be empty when a memory mentions no named entities \u2014 most short memories have 0-3
|
|
34899
34945
|
No prose.`;
|
|
@@ -34964,9 +35010,10 @@ List each memory's named entities.`,
|
|
|
34964
35010
|
return out;
|
|
34965
35011
|
}
|
|
34966
35012
|
function restoreEntities(entities, redactor) {
|
|
34967
|
-
return entities.
|
|
34968
|
-
|
|
34969
|
-
|
|
35013
|
+
return entities.flatMap((e) => {
|
|
35014
|
+
const restored = redactor.restoreForStorage(e.name);
|
|
35015
|
+
return restored.unresolved ? [] : [{ ...e, name: restored.text }];
|
|
35016
|
+
});
|
|
34970
35017
|
}
|
|
34971
35018
|
function parseTopicResponse(parsed, validIds) {
|
|
34972
35019
|
if (typeof parsed !== "object" || parsed === null) return null;
|
package/dist/server/index.d.mts
CHANGED
|
@@ -2699,6 +2699,8 @@ interface StoredTopic {
|
|
|
2699
2699
|
name: string;
|
|
2700
2700
|
kind?: string;
|
|
2701
2701
|
source: TopicSource;
|
|
2702
|
+
/** How central the topic is to the memory, in (0, 1]; read it with {@link topicWeight}. */
|
|
2703
|
+
weight?: number;
|
|
2702
2704
|
}
|
|
2703
2705
|
|
|
2704
2706
|
/**
|
|
@@ -2710,6 +2712,7 @@ interface StoredTopic {
|
|
|
2710
2712
|
type EntityInput = string | {
|
|
2711
2713
|
name: string;
|
|
2712
2714
|
kind?: EntityKind | (string & {});
|
|
2715
|
+
weight?: number;
|
|
2713
2716
|
};
|
|
2714
2717
|
interface EntityOperationsContext {
|
|
2715
2718
|
database: Database;
|
|
@@ -4635,6 +4638,7 @@ interface AutoExtractMessage {
|
|
|
4635
4638
|
interface ExtractedEntity {
|
|
4636
4639
|
name: string;
|
|
4637
4640
|
kind?: EntityKind;
|
|
4641
|
+
weight?: number;
|
|
4638
4642
|
}
|
|
4639
4643
|
interface ExtractedCandidate {
|
|
4640
4644
|
content: string;
|
package/dist/server/index.d.ts
CHANGED
|
@@ -2699,6 +2699,8 @@ interface StoredTopic {
|
|
|
2699
2699
|
name: string;
|
|
2700
2700
|
kind?: string;
|
|
2701
2701
|
source: TopicSource;
|
|
2702
|
+
/** How central the topic is to the memory, in (0, 1]; read it with {@link topicWeight}. */
|
|
2703
|
+
weight?: number;
|
|
2702
2704
|
}
|
|
2703
2705
|
|
|
2704
2706
|
/**
|
|
@@ -2710,6 +2712,7 @@ interface StoredTopic {
|
|
|
2710
2712
|
type EntityInput = string | {
|
|
2711
2713
|
name: string;
|
|
2712
2714
|
kind?: EntityKind | (string & {});
|
|
2715
|
+
weight?: number;
|
|
2713
2716
|
};
|
|
2714
2717
|
interface EntityOperationsContext {
|
|
2715
2718
|
database: Database;
|
|
@@ -4635,6 +4638,7 @@ interface AutoExtractMessage {
|
|
|
4635
4638
|
interface ExtractedEntity {
|
|
4636
4639
|
name: string;
|
|
4637
4640
|
kind?: EntityKind;
|
|
4641
|
+
weight?: number;
|
|
4638
4642
|
}
|
|
4639
4643
|
interface ExtractedCandidate {
|
|
4640
4644
|
content: string;
|
package/dist/server/index.mjs
CHANGED
|
@@ -25703,6 +25703,10 @@ var ENTITY_KINDS = [
|
|
|
25703
25703
|
function normalizeEntityName(name) {
|
|
25704
25704
|
return name.trim().toLowerCase();
|
|
25705
25705
|
}
|
|
25706
|
+
var TOPIC_SALIENCE_WEIGHTS = { primary: 1, secondary: 0.6, mention: 0.3 };
|
|
25707
|
+
function parseTopicWeight(value) {
|
|
25708
|
+
return typeof value === "number" && value > 0 && value <= 1 ? value : void 0;
|
|
25709
|
+
}
|
|
25706
25710
|
function serializeTopics(topics) {
|
|
25707
25711
|
return JSON.stringify(topics);
|
|
25708
25712
|
}
|
|
@@ -25718,12 +25722,14 @@ function parseTopics(value) {
|
|
|
25718
25722
|
const out = [];
|
|
25719
25723
|
for (const raw of parsed) {
|
|
25720
25724
|
if (typeof raw !== "object" || raw === null) continue;
|
|
25721
|
-
const { name, kind, source } = raw;
|
|
25725
|
+
const { name, kind, source, weight } = raw;
|
|
25722
25726
|
if (typeof name !== "string" || name.trim().length === 0) continue;
|
|
25727
|
+
const parsedWeight = parseTopicWeight(weight);
|
|
25723
25728
|
out.push({
|
|
25724
25729
|
name,
|
|
25725
25730
|
...typeof kind === "string" && kind.length > 0 ? { kind } : {},
|
|
25726
|
-
source: source === "user" ? "user" : "auto"
|
|
25731
|
+
source: source === "user" ? "user" : "auto",
|
|
25732
|
+
...parsedWeight !== void 0 ? { weight: parsedWeight } : {}
|
|
25727
25733
|
});
|
|
25728
25734
|
}
|
|
25729
25735
|
return out;
|
|
@@ -25810,21 +25816,47 @@ function displayNamesOf(entities) {
|
|
|
25810
25816
|
}
|
|
25811
25817
|
function topicsEqual(stored, computed) {
|
|
25812
25818
|
if (stored === null || stored.length !== computed.length) return false;
|
|
25813
|
-
const key = (t) => JSON.stringify([t.name, t.kind ?? null, t.source]);
|
|
25819
|
+
const key = (t) => JSON.stringify([t.name, t.kind ?? null, t.source, t.weight ?? null]);
|
|
25814
25820
|
const storedKeys = stored.map(key).sort();
|
|
25815
25821
|
const computedKeys = computed.map(key).sort();
|
|
25816
25822
|
return storedKeys.every((k, i) => k === computedKeys[i]);
|
|
25817
25823
|
}
|
|
25818
|
-
function resolveTopicsWrite(row, linked,
|
|
25824
|
+
function resolveTopicsWrite(row, linked, inputs, source, mode) {
|
|
25819
25825
|
if (row === null || source === null) return null;
|
|
25820
|
-
const
|
|
25821
|
-
|
|
25826
|
+
const stored = parseTopics(row.topics);
|
|
25827
|
+
const carried = mode === "merge" ? stored : null;
|
|
25828
|
+
const weights = source === "auto" ? weightsOf(carried, inputs) : null;
|
|
25829
|
+
const displayNames = displayNamesOf([...inputs, ...carried ?? []]);
|
|
25830
|
+
const topics = topicsForEntities(linked, displayNames, source, weights);
|
|
25831
|
+
if (topicsEqual(stored, topics)) return null;
|
|
25822
25832
|
return { row, topics };
|
|
25823
25833
|
}
|
|
25824
|
-
function
|
|
25834
|
+
function weightsOf(stored, inputs) {
|
|
25835
|
+
const out = /* @__PURE__ */ new Map();
|
|
25836
|
+
for (const topic of stored ?? []) out.set(normalizeEntityName(topic.name), topic.weight);
|
|
25837
|
+
for (const input of inputs) {
|
|
25838
|
+
const weight = parseTopicWeight(input.weight);
|
|
25839
|
+
if (weight === void 0) continue;
|
|
25840
|
+
const name = normalizeEntityName(input.name);
|
|
25841
|
+
if (!out.has(name)) {
|
|
25842
|
+
out.set(name, weight);
|
|
25843
|
+
continue;
|
|
25844
|
+
}
|
|
25845
|
+
const current = out.get(name);
|
|
25846
|
+
if (current !== void 0 && weight > current) out.set(name, weight);
|
|
25847
|
+
}
|
|
25848
|
+
return out;
|
|
25849
|
+
}
|
|
25850
|
+
function topicsForEntities(entities, displayNames, source, weights) {
|
|
25825
25851
|
return entities.map((e) => {
|
|
25826
25852
|
const name = displayNames.get(e.canonicalName) ?? e.canonicalName;
|
|
25827
|
-
|
|
25853
|
+
const weight = weights?.get(e.canonicalName);
|
|
25854
|
+
return {
|
|
25855
|
+
name,
|
|
25856
|
+
...e.kind ? { kind: e.kind } : {},
|
|
25857
|
+
source,
|
|
25858
|
+
...weight !== void 0 ? { weight } : {}
|
|
25859
|
+
};
|
|
25828
25860
|
});
|
|
25829
25861
|
}
|
|
25830
25862
|
function toEntityObjects(entityInputs) {
|
|
@@ -25832,7 +25864,7 @@ function toEntityObjects(entityInputs) {
|
|
|
25832
25864
|
}
|
|
25833
25865
|
async function resolveMemoryTopicsWrite(ctx, memoryId, linked, inputs, source) {
|
|
25834
25866
|
const row = await findVaultRowInWrite(ctx, memoryId);
|
|
25835
|
-
return resolveTopicsWrite(row, linked,
|
|
25867
|
+
return resolveTopicsWrite(row, linked, toEntityObjects(inputs), source, "replace");
|
|
25836
25868
|
}
|
|
25837
25869
|
function prepareMemoryTopicsUpdate(write) {
|
|
25838
25870
|
return prepareTopicsUpdate(write.row, write.topics, Date.now());
|
|
@@ -25870,8 +25902,9 @@ async function linkMemoryEntitiesOp(ctx, memoryId, entityInputs, options) {
|
|
|
25870
25902
|
const topicsWrite = resolveTopicsWrite(
|
|
25871
25903
|
vaultRow,
|
|
25872
25904
|
[...carriedOver, ...entities],
|
|
25873
|
-
|
|
25874
|
-
options?.topicsSource ?? "auto"
|
|
25905
|
+
normalized,
|
|
25906
|
+
options?.topicsSource ?? "auto",
|
|
25907
|
+
"merge"
|
|
25875
25908
|
);
|
|
25876
25909
|
if (entityOps.length === 0 && kindBackfills.length === 0 && toCreate.length === 0 && topicsWrite === null) {
|
|
25877
25910
|
return;
|
|
@@ -25937,8 +25970,9 @@ async function replaceMemoryEntities(ctx, memoryId, entityInputs, options) {
|
|
|
25937
25970
|
const topicsWrite = resolveTopicsWrite(
|
|
25938
25971
|
vaultRow,
|
|
25939
25972
|
entities,
|
|
25940
|
-
|
|
25941
|
-
options.topicsSource
|
|
25973
|
+
normalized,
|
|
25974
|
+
options.topicsSource,
|
|
25975
|
+
"replace"
|
|
25942
25976
|
);
|
|
25943
25977
|
if (entityOps.length === 0 && kindBackfills.length === 0 && toCreate.length === 0 && toDestroy.length === 0 && topicsWrite === null) {
|
|
25944
25978
|
return;
|
|
@@ -30897,9 +30931,9 @@ For each durable fact, output:
|
|
|
30897
30931
|
- type: one of identity | preference | relationship | plan | ongoing_context | constraint | other
|
|
30898
30932
|
- confidence: 0.0-1.0; how sure you are this is durable AND true. Only include facts >= 0.7.
|
|
30899
30933
|
- sourceMessageIds: which message IDs from the conversation contained the evidence
|
|
30900
|
-
- entities: named entities mentioned, each as an object { "name": string, "kind": one of "person" | "organization" | "place" | "event" | "product" | "thing" | "concept" | "other" }. Optional \u2014 include only NAMED entities, skip generic/common nouns. ${ENTITY_KIND_GUIDELINES} Examples:
|
|
30901
|
-
- "started a new job at Hollowpoint Labs and I'm learning Haskell for it" \u2192 entities: [{ "name": "Hollowpoint Labs", "kind": "organization" }, { "name": "Haskell", "kind": "concept" }]
|
|
30902
|
-
- "running the Berlin Half in May and I track workouts in Whoop" \u2192 entities: [{ "name": "Berlin Half", "kind": "event" }, { "name": "Whoop", "kind": "product" }]
|
|
30934
|
+
- entities: named entities mentioned, each as an object { "name": string, "kind": one of "person" | "organization" | "place" | "event" | "product" | "thing" | "concept" | "other", "salience": one of "primary" | "secondary" | "mention" }. Optional \u2014 include only NAMED entities, skip generic/common nouns. ${ENTITY_KIND_GUIDELINES} Salience is how central the entity is to the fact: "primary" = the fact is ABOUT it (usually exactly one per fact), "secondary" = a meaningful part of it, "mention" = named in passing. Examples:
|
|
30935
|
+
- "started a new job at Hollowpoint Labs and I'm learning Haskell for it" \u2192 entities: [{ "name": "Hollowpoint Labs", "kind": "organization", "salience": "primary" }, { "name": "Haskell", "kind": "concept", "salience": "secondary" }]
|
|
30936
|
+
- "running the Berlin Half in May and I track workouts in Whoop" \u2192 entities: [{ "name": "Berlin Half", "kind": "event", "salience": "primary" }, { "name": "Whoop", "kind": "product", "salience": "mention" }]
|
|
30903
30937
|
- eventTime: when the event in this fact occurs/occurred. Resolve relative phrases ("yesterday", "next week") against the current date given in the user message. Output one of:
|
|
30904
30938
|
- { "kind": "point", "start": "YYYY-MM-DD" } for a single date ("met Sara on March 14, 2026")
|
|
30905
30939
|
- { "kind": "range", "start": "YYYY-MM-DD", "end": "YYYY-MM-DD" } for a span ("Japan trip May 4\u201315, 2026")
|
|
@@ -30980,9 +31014,10 @@ function restoreCandidates(candidates, redactor, ownNames) {
|
|
|
30980
31014
|
candidate: {
|
|
30981
31015
|
...c,
|
|
30982
31016
|
content: content.text,
|
|
30983
|
-
entities: c.entities.
|
|
30984
|
-
|
|
30985
|
-
|
|
31017
|
+
entities: c.entities.flatMap((e) => {
|
|
31018
|
+
const restored = redactor.restoreForStorage(e.name);
|
|
31019
|
+
return restored.unresolved ? [] : [{ ...e, name: restored.text }];
|
|
31020
|
+
})
|
|
30986
31021
|
},
|
|
30987
31022
|
unresolved: content.unresolved
|
|
30988
31023
|
};
|
|
@@ -31211,7 +31246,12 @@ function parseEntities(raw) {
|
|
|
31211
31246
|
const name = typeof obj.name === "string" ? obj.name.trim() : "";
|
|
31212
31247
|
if (name.length === 0 || isGenericEntityName(name)) continue;
|
|
31213
31248
|
const kind = typeof obj.kind === "string" && ENTITY_KINDS.includes(obj.kind) ? obj.kind : void 0;
|
|
31214
|
-
|
|
31249
|
+
const weight = typeof obj.salience === "string" && Object.keys(TOPIC_SALIENCE_WEIGHTS).includes(obj.salience) ? TOPIC_SALIENCE_WEIGHTS[obj.salience] : void 0;
|
|
31250
|
+
out.push({
|
|
31251
|
+
name,
|
|
31252
|
+
...kind !== void 0 ? { kind } : {},
|
|
31253
|
+
...weight !== void 0 ? { weight } : {}
|
|
31254
|
+
});
|
|
31215
31255
|
}
|
|
31216
31256
|
return out;
|
|
31217
31257
|
}
|
|
@@ -33170,7 +33210,13 @@ Include only NAMED entities, skip generic/common nouns. A topic must identify a
|
|
|
33170
33210
|
- Prefer 0 entities over a weak one. A memory whose only candidate is a generic noun has NO entities.
|
|
33171
33211
|
${ENTITY_KIND_GUIDELINES}
|
|
33172
33212
|
|
|
33173
|
-
|
|
33213
|
+
Give each entity a "salience" \u2014 how central it is to the memory:
|
|
33214
|
+
- "primary": the memory is ABOUT it. A memory with entities usually has exactly one primary; never more than two.
|
|
33215
|
+
- "secondary": a meaningful part of the memory, but not its subject.
|
|
33216
|
+
- "mention": named in passing; the memory would say much the same without it.
|
|
33217
|
+
Example: "Ran the Chicago Marathon with my sister Ana in 3:41" \u2192 Chicago Marathon primary, Ana secondary.
|
|
33218
|
+
|
|
33219
|
+
Each memory below is written as "<id>: <text>". Output strict JSON: {"memories": [{"id": string, "entities": [{"name": string, "kind": string, "salience": "primary" | "secondary" | "mention"}]}]}
|
|
33174
33220
|
- exactly one element per input memory; copy its id EXACTLY as written (the token before the first ": "), with no brackets, quotes, or extra characters
|
|
33175
33221
|
- "entities" may be empty when a memory mentions no named entities \u2014 most short memories have 0-3
|
|
33176
33222
|
No prose.`;
|
|
@@ -33241,9 +33287,10 @@ List each memory's named entities.`,
|
|
|
33241
33287
|
return out;
|
|
33242
33288
|
}
|
|
33243
33289
|
function restoreEntities(entities, redactor) {
|
|
33244
|
-
return entities.
|
|
33245
|
-
|
|
33246
|
-
|
|
33290
|
+
return entities.flatMap((e) => {
|
|
33291
|
+
const restored = redactor.restoreForStorage(e.name);
|
|
33292
|
+
return restored.unresolved ? [] : [{ ...e, name: restored.text }];
|
|
33293
|
+
});
|
|
33247
33294
|
}
|
|
33248
33295
|
function parseTopicResponse(parsed, validIds) {
|
|
33249
33296
|
if (typeof parsed !== "object" || parsed === null) return null;
|