@anuma/sdk 9.1.7 → 9.1.8
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 +41 -6
- package/dist/expo/index.mjs +41 -6
- package/dist/react/index.cjs +41 -6
- package/dist/react/index.mjs +41 -6
- package/dist/server/index.cjs +41 -6
- package/dist/server/index.mjs +41 -6
- package/package.json +1 -1
package/dist/expo/index.cjs
CHANGED
|
@@ -14863,10 +14863,10 @@ async function getVaultRankingProjectionsOp(ctx, options) {
|
|
|
14863
14863
|
function baseVaultSql(ctx, options) {
|
|
14864
14864
|
const clauses = [
|
|
14865
14865
|
`"_status" is not 'deleted'`,
|
|
14866
|
-
'"is_deleted" = 0',
|
|
14866
|
+
...options?.includeDeleted ? [] : ['"is_deleted" = 0'],
|
|
14867
14867
|
...options?.includeArchived ? [] : ['"archived_at" is null'],
|
|
14868
14868
|
...options?.includeQuarantined ? [] : [`"trust_tier" is not 'quarantined'`],
|
|
14869
|
-
'"superseded_by" is null'
|
|
14869
|
+
...options?.includeSuperseded ? [] : ['"superseded_by" is null']
|
|
14870
14870
|
];
|
|
14871
14871
|
const args = [];
|
|
14872
14872
|
if (ctx.userId !== void 0) {
|
|
@@ -14875,6 +14875,38 @@ function baseVaultSql(ctx, options) {
|
|
|
14875
14875
|
}
|
|
14876
14876
|
return { sql: clauses.join(" and "), args };
|
|
14877
14877
|
}
|
|
14878
|
+
async function getVaultProfileMetadataOp(ctx, options) {
|
|
14879
|
+
const mapRaw = (raw) => ({
|
|
14880
|
+
uniqueId: raw.id,
|
|
14881
|
+
scope: raw.scope ?? "",
|
|
14882
|
+
createdAt: new Date(raw.created_at),
|
|
14883
|
+
updatedAt: new Date(raw.updated_at),
|
|
14884
|
+
lastObservedAt: raw.last_observed_at ?? null,
|
|
14885
|
+
supersededAt: raw.superseded_at ?? null,
|
|
14886
|
+
supersededBy: raw.superseded_by ?? null,
|
|
14887
|
+
isDeleted: raw.is_deleted === true || raw.is_deleted === 1,
|
|
14888
|
+
proofCount: raw.proof_count ?? null
|
|
14889
|
+
});
|
|
14890
|
+
const listOptions = { ...options, includeDeleted: true, includeSuperseded: true };
|
|
14891
|
+
let rows;
|
|
14892
|
+
try {
|
|
14893
|
+
const base = baseVaultSql(ctx, listOptions);
|
|
14894
|
+
const clauses = [base.sql, `"_status" != 'deleted'`];
|
|
14895
|
+
const args = [...base.args];
|
|
14896
|
+
if (options?.scopes?.length) {
|
|
14897
|
+
clauses.push(`"scope" in (${options.scopes.map(() => "?").join(",")})`);
|
|
14898
|
+
args.push(...options.scopes);
|
|
14899
|
+
}
|
|
14900
|
+
const sql = `select "id", "scope", "created_at", "updated_at", "last_observed_at", "superseded_at", "superseded_by", "is_deleted", "proof_count" from "memory_vault" where ${clauses.join(" and ")}`;
|
|
14901
|
+
rows = await ctx.vaultMemoryCollection.query(import_watermelondb21.Q.unsafeSqlQuery(sql, args)).unsafeFetchRaw();
|
|
14902
|
+
} catch (err) {
|
|
14903
|
+
getLogger().debug(
|
|
14904
|
+
"memoryVault: getVaultProfileMetadataOp uses the query fallback: " + (err instanceof Error ? err.message : String(err))
|
|
14905
|
+
);
|
|
14906
|
+
rows = await ctx.vaultMemoryCollection.query(...vaultListConditions(ctx, listOptions)).unsafeFetchRaw();
|
|
14907
|
+
}
|
|
14908
|
+
return rows.map(mapRaw);
|
|
14909
|
+
}
|
|
14878
14910
|
async function getVaultCandidateKeysOp(ctx, options) {
|
|
14879
14911
|
const mapRaw = (raw) => ({
|
|
14880
14912
|
uniqueId: raw.id,
|
|
@@ -24591,7 +24623,7 @@ async function synthesizeProfile(ctx, options = {}) {
|
|
|
24591
24623
|
};
|
|
24592
24624
|
const previous = options.previous && options.previous.version === PROFILE_DOC_VERSION && configMatches(options.previous.config, config) ? options.previous : void 0;
|
|
24593
24625
|
const listOptions = { scopes, includeDeleted: true, includeSuperseded: true };
|
|
24594
|
-
const [memories, projections] = store ? await Promise.all([store.list(listOptions), store.listProjections(listOptions)]) : [await
|
|
24626
|
+
const [memories, projections] = store ? await Promise.all([store.list(listOptions), store.listProjections(listOptions)]) : [await getVaultProfileMetadataOp(vaultCtx, { scopes }), []];
|
|
24595
24627
|
const watermark = computeVaultWatermark(memories);
|
|
24596
24628
|
const observationTrends = summarizeObservationTrends(
|
|
24597
24629
|
memories.filter((m) => !m.isDeleted && m.supersededBy === null).map((m) => ({
|
|
@@ -24627,7 +24659,8 @@ async function synthesizeProfile(ctx, options = {}) {
|
|
|
24627
24659
|
previous,
|
|
24628
24660
|
watermark,
|
|
24629
24661
|
options.reviewedMemoryIds,
|
|
24630
|
-
previousUnreadable
|
|
24662
|
+
previousUnreadable,
|
|
24663
|
+
store ? void 0 : (ids) => getVaultEmbeddingsByIdsOp(vaultCtx, ids)
|
|
24631
24664
|
);
|
|
24632
24665
|
const memoriesById = new Map(memories.map((memory) => [memory.uniqueId, memory]));
|
|
24633
24666
|
const fallbackPriors = /* @__PURE__ */ new Map();
|
|
@@ -24714,7 +24747,7 @@ function computeVaultWatermark(memories) {
|
|
|
24714
24747
|
}
|
|
24715
24748
|
return max;
|
|
24716
24749
|
}
|
|
24717
|
-
async function computeStaleFacetKeys(ctx, memories, facets, previous, watermark, reviewedMemoryIds, previouslyUnreadable) {
|
|
24750
|
+
async function computeStaleFacetKeys(ctx, memories, facets, previous, watermark, reviewedMemoryIds, previouslyUnreadable, loadEmbeddings) {
|
|
24718
24751
|
const allKeys = new Set(facets.map((f) => f.key));
|
|
24719
24752
|
if (previous && watermark < previous.vaultWatermark) return allKeys;
|
|
24720
24753
|
if (!previous) return allKeys;
|
|
@@ -24747,7 +24780,9 @@ async function computeStaleFacetKeys(ctx, memories, facets, previous, watermark,
|
|
|
24747
24780
|
toAttribute = toAttribute.filter((m) => allowed.has(m.uniqueId));
|
|
24748
24781
|
}
|
|
24749
24782
|
if (toAttribute.length > 0) {
|
|
24750
|
-
const
|
|
24783
|
+
const candidates = loadEmbeddings ? await loadEmbeddings(toAttribute.map((m) => m.uniqueId)) : toAttribute;
|
|
24784
|
+
if (candidates.length !== toAttribute.length) return allKeys;
|
|
24785
|
+
const attributed = await attributeFacts(ctx, candidates, facets);
|
|
24751
24786
|
if (attributed === null) return allKeys;
|
|
24752
24787
|
for (const k of attributed) stale.add(k);
|
|
24753
24788
|
}
|
package/dist/expo/index.mjs
CHANGED
|
@@ -13212,10 +13212,10 @@ async function getVaultRankingProjectionsOp(ctx, options) {
|
|
|
13212
13212
|
function baseVaultSql(ctx, options) {
|
|
13213
13213
|
const clauses = [
|
|
13214
13214
|
`"_status" is not 'deleted'`,
|
|
13215
|
-
'"is_deleted" = 0',
|
|
13215
|
+
...options?.includeDeleted ? [] : ['"is_deleted" = 0'],
|
|
13216
13216
|
...options?.includeArchived ? [] : ['"archived_at" is null'],
|
|
13217
13217
|
...options?.includeQuarantined ? [] : [`"trust_tier" is not 'quarantined'`],
|
|
13218
|
-
'"superseded_by" is null'
|
|
13218
|
+
...options?.includeSuperseded ? [] : ['"superseded_by" is null']
|
|
13219
13219
|
];
|
|
13220
13220
|
const args = [];
|
|
13221
13221
|
if (ctx.userId !== void 0) {
|
|
@@ -13224,6 +13224,38 @@ function baseVaultSql(ctx, options) {
|
|
|
13224
13224
|
}
|
|
13225
13225
|
return { sql: clauses.join(" and "), args };
|
|
13226
13226
|
}
|
|
13227
|
+
async function getVaultProfileMetadataOp(ctx, options) {
|
|
13228
|
+
const mapRaw = (raw) => ({
|
|
13229
|
+
uniqueId: raw.id,
|
|
13230
|
+
scope: raw.scope ?? "",
|
|
13231
|
+
createdAt: new Date(raw.created_at),
|
|
13232
|
+
updatedAt: new Date(raw.updated_at),
|
|
13233
|
+
lastObservedAt: raw.last_observed_at ?? null,
|
|
13234
|
+
supersededAt: raw.superseded_at ?? null,
|
|
13235
|
+
supersededBy: raw.superseded_by ?? null,
|
|
13236
|
+
isDeleted: raw.is_deleted === true || raw.is_deleted === 1,
|
|
13237
|
+
proofCount: raw.proof_count ?? null
|
|
13238
|
+
});
|
|
13239
|
+
const listOptions = { ...options, includeDeleted: true, includeSuperseded: true };
|
|
13240
|
+
let rows;
|
|
13241
|
+
try {
|
|
13242
|
+
const base = baseVaultSql(ctx, listOptions);
|
|
13243
|
+
const clauses = [base.sql, `"_status" != 'deleted'`];
|
|
13244
|
+
const args = [...base.args];
|
|
13245
|
+
if (options?.scopes?.length) {
|
|
13246
|
+
clauses.push(`"scope" in (${options.scopes.map(() => "?").join(",")})`);
|
|
13247
|
+
args.push(...options.scopes);
|
|
13248
|
+
}
|
|
13249
|
+
const sql = `select "id", "scope", "created_at", "updated_at", "last_observed_at", "superseded_at", "superseded_by", "is_deleted", "proof_count" from "memory_vault" where ${clauses.join(" and ")}`;
|
|
13250
|
+
rows = await ctx.vaultMemoryCollection.query(Q6.unsafeSqlQuery(sql, args)).unsafeFetchRaw();
|
|
13251
|
+
} catch (err) {
|
|
13252
|
+
getLogger().debug(
|
|
13253
|
+
"memoryVault: getVaultProfileMetadataOp uses the query fallback: " + (err instanceof Error ? err.message : String(err))
|
|
13254
|
+
);
|
|
13255
|
+
rows = await ctx.vaultMemoryCollection.query(...vaultListConditions(ctx, listOptions)).unsafeFetchRaw();
|
|
13256
|
+
}
|
|
13257
|
+
return rows.map(mapRaw);
|
|
13258
|
+
}
|
|
13227
13259
|
async function getVaultCandidateKeysOp(ctx, options) {
|
|
13228
13260
|
const mapRaw = (raw) => ({
|
|
13229
13261
|
uniqueId: raw.id,
|
|
@@ -22888,7 +22920,7 @@ async function synthesizeProfile(ctx, options = {}) {
|
|
|
22888
22920
|
};
|
|
22889
22921
|
const previous = options.previous && options.previous.version === PROFILE_DOC_VERSION && configMatches(options.previous.config, config) ? options.previous : void 0;
|
|
22890
22922
|
const listOptions = { scopes, includeDeleted: true, includeSuperseded: true };
|
|
22891
|
-
const [memories, projections] = store ? await Promise.all([store.list(listOptions), store.listProjections(listOptions)]) : [await
|
|
22923
|
+
const [memories, projections] = store ? await Promise.all([store.list(listOptions), store.listProjections(listOptions)]) : [await getVaultProfileMetadataOp(vaultCtx, { scopes }), []];
|
|
22892
22924
|
const watermark = computeVaultWatermark(memories);
|
|
22893
22925
|
const observationTrends = summarizeObservationTrends(
|
|
22894
22926
|
memories.filter((m) => !m.isDeleted && m.supersededBy === null).map((m) => ({
|
|
@@ -22924,7 +22956,8 @@ async function synthesizeProfile(ctx, options = {}) {
|
|
|
22924
22956
|
previous,
|
|
22925
22957
|
watermark,
|
|
22926
22958
|
options.reviewedMemoryIds,
|
|
22927
|
-
previousUnreadable
|
|
22959
|
+
previousUnreadable,
|
|
22960
|
+
store ? void 0 : (ids) => getVaultEmbeddingsByIdsOp(vaultCtx, ids)
|
|
22928
22961
|
);
|
|
22929
22962
|
const memoriesById = new Map(memories.map((memory) => [memory.uniqueId, memory]));
|
|
22930
22963
|
const fallbackPriors = /* @__PURE__ */ new Map();
|
|
@@ -23011,7 +23044,7 @@ function computeVaultWatermark(memories) {
|
|
|
23011
23044
|
}
|
|
23012
23045
|
return max;
|
|
23013
23046
|
}
|
|
23014
|
-
async function computeStaleFacetKeys(ctx, memories, facets, previous, watermark, reviewedMemoryIds, previouslyUnreadable) {
|
|
23047
|
+
async function computeStaleFacetKeys(ctx, memories, facets, previous, watermark, reviewedMemoryIds, previouslyUnreadable, loadEmbeddings) {
|
|
23015
23048
|
const allKeys = new Set(facets.map((f) => f.key));
|
|
23016
23049
|
if (previous && watermark < previous.vaultWatermark) return allKeys;
|
|
23017
23050
|
if (!previous) return allKeys;
|
|
@@ -23044,7 +23077,9 @@ async function computeStaleFacetKeys(ctx, memories, facets, previous, watermark,
|
|
|
23044
23077
|
toAttribute = toAttribute.filter((m) => allowed.has(m.uniqueId));
|
|
23045
23078
|
}
|
|
23046
23079
|
if (toAttribute.length > 0) {
|
|
23047
|
-
const
|
|
23080
|
+
const candidates = loadEmbeddings ? await loadEmbeddings(toAttribute.map((m) => m.uniqueId)) : toAttribute;
|
|
23081
|
+
if (candidates.length !== toAttribute.length) return allKeys;
|
|
23082
|
+
const attributed = await attributeFacts(ctx, candidates, facets);
|
|
23048
23083
|
if (attributed === null) return allKeys;
|
|
23049
23084
|
for (const k of attributed) stale.add(k);
|
|
23050
23085
|
}
|
package/dist/react/index.cjs
CHANGED
|
@@ -16687,10 +16687,10 @@ async function getVaultRankingProjectionsOp(ctx, options) {
|
|
|
16687
16687
|
function baseVaultSql(ctx, options) {
|
|
16688
16688
|
const clauses = [
|
|
16689
16689
|
`"_status" is not 'deleted'`,
|
|
16690
|
-
'"is_deleted" = 0',
|
|
16690
|
+
...options?.includeDeleted ? [] : ['"is_deleted" = 0'],
|
|
16691
16691
|
...options?.includeArchived ? [] : ['"archived_at" is null'],
|
|
16692
16692
|
...options?.includeQuarantined ? [] : [`"trust_tier" is not 'quarantined'`],
|
|
16693
|
-
'"superseded_by" is null'
|
|
16693
|
+
...options?.includeSuperseded ? [] : ['"superseded_by" is null']
|
|
16694
16694
|
];
|
|
16695
16695
|
const args = [];
|
|
16696
16696
|
if (ctx.userId !== void 0) {
|
|
@@ -16699,6 +16699,38 @@ function baseVaultSql(ctx, options) {
|
|
|
16699
16699
|
}
|
|
16700
16700
|
return { sql: clauses.join(" and "), args };
|
|
16701
16701
|
}
|
|
16702
|
+
async function getVaultProfileMetadataOp(ctx, options) {
|
|
16703
|
+
const mapRaw = (raw) => ({
|
|
16704
|
+
uniqueId: raw.id,
|
|
16705
|
+
scope: raw.scope ?? "",
|
|
16706
|
+
createdAt: new Date(raw.created_at),
|
|
16707
|
+
updatedAt: new Date(raw.updated_at),
|
|
16708
|
+
lastObservedAt: raw.last_observed_at ?? null,
|
|
16709
|
+
supersededAt: raw.superseded_at ?? null,
|
|
16710
|
+
supersededBy: raw.superseded_by ?? null,
|
|
16711
|
+
isDeleted: raw.is_deleted === true || raw.is_deleted === 1,
|
|
16712
|
+
proofCount: raw.proof_count ?? null
|
|
16713
|
+
});
|
|
16714
|
+
const listOptions = { ...options, includeDeleted: true, includeSuperseded: true };
|
|
16715
|
+
let rows;
|
|
16716
|
+
try {
|
|
16717
|
+
const base = baseVaultSql(ctx, listOptions);
|
|
16718
|
+
const clauses = [base.sql, `"_status" != 'deleted'`];
|
|
16719
|
+
const args = [...base.args];
|
|
16720
|
+
if (options?.scopes?.length) {
|
|
16721
|
+
clauses.push(`"scope" in (${options.scopes.map(() => "?").join(",")})`);
|
|
16722
|
+
args.push(...options.scopes);
|
|
16723
|
+
}
|
|
16724
|
+
const sql = `select "id", "scope", "created_at", "updated_at", "last_observed_at", "superseded_at", "superseded_by", "is_deleted", "proof_count" from "memory_vault" where ${clauses.join(" and ")}`;
|
|
16725
|
+
rows = await ctx.vaultMemoryCollection.query(import_watermelondb24.Q.unsafeSqlQuery(sql, args)).unsafeFetchRaw();
|
|
16726
|
+
} catch (err) {
|
|
16727
|
+
getLogger().debug(
|
|
16728
|
+
"memoryVault: getVaultProfileMetadataOp uses the query fallback: " + (err instanceof Error ? err.message : String(err))
|
|
16729
|
+
);
|
|
16730
|
+
rows = await ctx.vaultMemoryCollection.query(...vaultListConditions(ctx, listOptions)).unsafeFetchRaw();
|
|
16731
|
+
}
|
|
16732
|
+
return rows.map(mapRaw);
|
|
16733
|
+
}
|
|
16702
16734
|
async function getVaultCandidateKeysOp(ctx, options) {
|
|
16703
16735
|
const mapRaw = (raw) => ({
|
|
16704
16736
|
uniqueId: raw.id,
|
|
@@ -26911,7 +26943,7 @@ async function synthesizeProfile(ctx, options = {}) {
|
|
|
26911
26943
|
};
|
|
26912
26944
|
const previous = options.previous && options.previous.version === PROFILE_DOC_VERSION && configMatches(options.previous.config, config) ? options.previous : void 0;
|
|
26913
26945
|
const listOptions = { scopes, includeDeleted: true, includeSuperseded: true };
|
|
26914
|
-
const [memories, projections] = store ? await Promise.all([store.list(listOptions), store.listProjections(listOptions)]) : [await
|
|
26946
|
+
const [memories, projections] = store ? await Promise.all([store.list(listOptions), store.listProjections(listOptions)]) : [await getVaultProfileMetadataOp(vaultCtx, { scopes }), []];
|
|
26915
26947
|
const watermark = computeVaultWatermark(memories);
|
|
26916
26948
|
const observationTrends = summarizeObservationTrends(
|
|
26917
26949
|
memories.filter((m) => !m.isDeleted && m.supersededBy === null).map((m) => ({
|
|
@@ -26947,7 +26979,8 @@ async function synthesizeProfile(ctx, options = {}) {
|
|
|
26947
26979
|
previous,
|
|
26948
26980
|
watermark,
|
|
26949
26981
|
options.reviewedMemoryIds,
|
|
26950
|
-
previousUnreadable
|
|
26982
|
+
previousUnreadable,
|
|
26983
|
+
store ? void 0 : (ids) => getVaultEmbeddingsByIdsOp(vaultCtx, ids)
|
|
26951
26984
|
);
|
|
26952
26985
|
const memoriesById = new Map(memories.map((memory) => [memory.uniqueId, memory]));
|
|
26953
26986
|
const fallbackPriors = /* @__PURE__ */ new Map();
|
|
@@ -27034,7 +27067,7 @@ function computeVaultWatermark(memories) {
|
|
|
27034
27067
|
}
|
|
27035
27068
|
return max;
|
|
27036
27069
|
}
|
|
27037
|
-
async function computeStaleFacetKeys(ctx, memories, facets, previous, watermark, reviewedMemoryIds, previouslyUnreadable) {
|
|
27070
|
+
async function computeStaleFacetKeys(ctx, memories, facets, previous, watermark, reviewedMemoryIds, previouslyUnreadable, loadEmbeddings) {
|
|
27038
27071
|
const allKeys = new Set(facets.map((f) => f.key));
|
|
27039
27072
|
if (previous && watermark < previous.vaultWatermark) return allKeys;
|
|
27040
27073
|
if (!previous) return allKeys;
|
|
@@ -27067,7 +27100,9 @@ async function computeStaleFacetKeys(ctx, memories, facets, previous, watermark,
|
|
|
27067
27100
|
toAttribute = toAttribute.filter((m) => allowed.has(m.uniqueId));
|
|
27068
27101
|
}
|
|
27069
27102
|
if (toAttribute.length > 0) {
|
|
27070
|
-
const
|
|
27103
|
+
const candidates = loadEmbeddings ? await loadEmbeddings(toAttribute.map((m) => m.uniqueId)) : toAttribute;
|
|
27104
|
+
if (candidates.length !== toAttribute.length) return allKeys;
|
|
27105
|
+
const attributed = await attributeFacts(ctx, candidates, facets);
|
|
27071
27106
|
if (attributed === null) return allKeys;
|
|
27072
27107
|
for (const k of attributed) stale.add(k);
|
|
27073
27108
|
}
|
package/dist/react/index.mjs
CHANGED
|
@@ -14831,10 +14831,10 @@ async function getVaultRankingProjectionsOp(ctx, options) {
|
|
|
14831
14831
|
function baseVaultSql(ctx, options) {
|
|
14832
14832
|
const clauses = [
|
|
14833
14833
|
`"_status" is not 'deleted'`,
|
|
14834
|
-
'"is_deleted" = 0',
|
|
14834
|
+
...options?.includeDeleted ? [] : ['"is_deleted" = 0'],
|
|
14835
14835
|
...options?.includeArchived ? [] : ['"archived_at" is null'],
|
|
14836
14836
|
...options?.includeQuarantined ? [] : [`"trust_tier" is not 'quarantined'`],
|
|
14837
|
-
'"superseded_by" is null'
|
|
14837
|
+
...options?.includeSuperseded ? [] : ['"superseded_by" is null']
|
|
14838
14838
|
];
|
|
14839
14839
|
const args = [];
|
|
14840
14840
|
if (ctx.userId !== void 0) {
|
|
@@ -14843,6 +14843,38 @@ function baseVaultSql(ctx, options) {
|
|
|
14843
14843
|
}
|
|
14844
14844
|
return { sql: clauses.join(" and "), args };
|
|
14845
14845
|
}
|
|
14846
|
+
async function getVaultProfileMetadataOp(ctx, options) {
|
|
14847
|
+
const mapRaw = (raw) => ({
|
|
14848
|
+
uniqueId: raw.id,
|
|
14849
|
+
scope: raw.scope ?? "",
|
|
14850
|
+
createdAt: new Date(raw.created_at),
|
|
14851
|
+
updatedAt: new Date(raw.updated_at),
|
|
14852
|
+
lastObservedAt: raw.last_observed_at ?? null,
|
|
14853
|
+
supersededAt: raw.superseded_at ?? null,
|
|
14854
|
+
supersededBy: raw.superseded_by ?? null,
|
|
14855
|
+
isDeleted: raw.is_deleted === true || raw.is_deleted === 1,
|
|
14856
|
+
proofCount: raw.proof_count ?? null
|
|
14857
|
+
});
|
|
14858
|
+
const listOptions = { ...options, includeDeleted: true, includeSuperseded: true };
|
|
14859
|
+
let rows;
|
|
14860
|
+
try {
|
|
14861
|
+
const base = baseVaultSql(ctx, listOptions);
|
|
14862
|
+
const clauses = [base.sql, `"_status" != 'deleted'`];
|
|
14863
|
+
const args = [...base.args];
|
|
14864
|
+
if (options?.scopes?.length) {
|
|
14865
|
+
clauses.push(`"scope" in (${options.scopes.map(() => "?").join(",")})`);
|
|
14866
|
+
args.push(...options.scopes);
|
|
14867
|
+
}
|
|
14868
|
+
const sql = `select "id", "scope", "created_at", "updated_at", "last_observed_at", "superseded_at", "superseded_by", "is_deleted", "proof_count" from "memory_vault" where ${clauses.join(" and ")}`;
|
|
14869
|
+
rows = await ctx.vaultMemoryCollection.query(Q9.unsafeSqlQuery(sql, args)).unsafeFetchRaw();
|
|
14870
|
+
} catch (err) {
|
|
14871
|
+
getLogger().debug(
|
|
14872
|
+
"memoryVault: getVaultProfileMetadataOp uses the query fallback: " + (err instanceof Error ? err.message : String(err))
|
|
14873
|
+
);
|
|
14874
|
+
rows = await ctx.vaultMemoryCollection.query(...vaultListConditions(ctx, listOptions)).unsafeFetchRaw();
|
|
14875
|
+
}
|
|
14876
|
+
return rows.map(mapRaw);
|
|
14877
|
+
}
|
|
14846
14878
|
async function getVaultCandidateKeysOp(ctx, options) {
|
|
14847
14879
|
const mapRaw = (raw) => ({
|
|
14848
14880
|
uniqueId: raw.id,
|
|
@@ -25000,7 +25032,7 @@ async function synthesizeProfile(ctx, options = {}) {
|
|
|
25000
25032
|
};
|
|
25001
25033
|
const previous = options.previous && options.previous.version === PROFILE_DOC_VERSION && configMatches(options.previous.config, config) ? options.previous : void 0;
|
|
25002
25034
|
const listOptions = { scopes, includeDeleted: true, includeSuperseded: true };
|
|
25003
|
-
const [memories, projections] = store ? await Promise.all([store.list(listOptions), store.listProjections(listOptions)]) : [await
|
|
25035
|
+
const [memories, projections] = store ? await Promise.all([store.list(listOptions), store.listProjections(listOptions)]) : [await getVaultProfileMetadataOp(vaultCtx, { scopes }), []];
|
|
25004
25036
|
const watermark = computeVaultWatermark(memories);
|
|
25005
25037
|
const observationTrends = summarizeObservationTrends(
|
|
25006
25038
|
memories.filter((m) => !m.isDeleted && m.supersededBy === null).map((m) => ({
|
|
@@ -25036,7 +25068,8 @@ async function synthesizeProfile(ctx, options = {}) {
|
|
|
25036
25068
|
previous,
|
|
25037
25069
|
watermark,
|
|
25038
25070
|
options.reviewedMemoryIds,
|
|
25039
|
-
previousUnreadable
|
|
25071
|
+
previousUnreadable,
|
|
25072
|
+
store ? void 0 : (ids) => getVaultEmbeddingsByIdsOp(vaultCtx, ids)
|
|
25040
25073
|
);
|
|
25041
25074
|
const memoriesById = new Map(memories.map((memory) => [memory.uniqueId, memory]));
|
|
25042
25075
|
const fallbackPriors = /* @__PURE__ */ new Map();
|
|
@@ -25123,7 +25156,7 @@ function computeVaultWatermark(memories) {
|
|
|
25123
25156
|
}
|
|
25124
25157
|
return max;
|
|
25125
25158
|
}
|
|
25126
|
-
async function computeStaleFacetKeys(ctx, memories, facets, previous, watermark, reviewedMemoryIds, previouslyUnreadable) {
|
|
25159
|
+
async function computeStaleFacetKeys(ctx, memories, facets, previous, watermark, reviewedMemoryIds, previouslyUnreadable, loadEmbeddings) {
|
|
25127
25160
|
const allKeys = new Set(facets.map((f) => f.key));
|
|
25128
25161
|
if (previous && watermark < previous.vaultWatermark) return allKeys;
|
|
25129
25162
|
if (!previous) return allKeys;
|
|
@@ -25156,7 +25189,9 @@ async function computeStaleFacetKeys(ctx, memories, facets, previous, watermark,
|
|
|
25156
25189
|
toAttribute = toAttribute.filter((m) => allowed.has(m.uniqueId));
|
|
25157
25190
|
}
|
|
25158
25191
|
if (toAttribute.length > 0) {
|
|
25159
|
-
const
|
|
25192
|
+
const candidates = loadEmbeddings ? await loadEmbeddings(toAttribute.map((m) => m.uniqueId)) : toAttribute;
|
|
25193
|
+
if (candidates.length !== toAttribute.length) return allKeys;
|
|
25194
|
+
const attributed = await attributeFacts(ctx, candidates, facets);
|
|
25160
25195
|
if (attributed === null) return allKeys;
|
|
25161
25196
|
for (const k of attributed) stale.add(k);
|
|
25162
25197
|
}
|
package/dist/server/index.cjs
CHANGED
|
@@ -28971,10 +28971,10 @@ async function getVaultRankingProjectionsOp(ctx, options) {
|
|
|
28971
28971
|
function baseVaultSql(ctx, options) {
|
|
28972
28972
|
const clauses = [
|
|
28973
28973
|
`"_status" is not 'deleted'`,
|
|
28974
|
-
'"is_deleted" = 0',
|
|
28974
|
+
...options?.includeDeleted ? [] : ['"is_deleted" = 0'],
|
|
28975
28975
|
...options?.includeArchived ? [] : ['"archived_at" is null'],
|
|
28976
28976
|
...options?.includeQuarantined ? [] : [`"trust_tier" is not 'quarantined'`],
|
|
28977
|
-
'"superseded_by" is null'
|
|
28977
|
+
...options?.includeSuperseded ? [] : ['"superseded_by" is null']
|
|
28978
28978
|
];
|
|
28979
28979
|
const args = [];
|
|
28980
28980
|
if (ctx.userId !== void 0) {
|
|
@@ -28983,6 +28983,38 @@ function baseVaultSql(ctx, options) {
|
|
|
28983
28983
|
}
|
|
28984
28984
|
return { sql: clauses.join(" and "), args };
|
|
28985
28985
|
}
|
|
28986
|
+
async function getVaultProfileMetadataOp(ctx, options) {
|
|
28987
|
+
const mapRaw = (raw) => ({
|
|
28988
|
+
uniqueId: raw.id,
|
|
28989
|
+
scope: raw.scope ?? "",
|
|
28990
|
+
createdAt: new Date(raw.created_at),
|
|
28991
|
+
updatedAt: new Date(raw.updated_at),
|
|
28992
|
+
lastObservedAt: raw.last_observed_at ?? null,
|
|
28993
|
+
supersededAt: raw.superseded_at ?? null,
|
|
28994
|
+
supersededBy: raw.superseded_by ?? null,
|
|
28995
|
+
isDeleted: raw.is_deleted === true || raw.is_deleted === 1,
|
|
28996
|
+
proofCount: raw.proof_count ?? null
|
|
28997
|
+
});
|
|
28998
|
+
const listOptions = { ...options, includeDeleted: true, includeSuperseded: true };
|
|
28999
|
+
let rows;
|
|
29000
|
+
try {
|
|
29001
|
+
const base = baseVaultSql(ctx, listOptions);
|
|
29002
|
+
const clauses = [base.sql, `"_status" != 'deleted'`];
|
|
29003
|
+
const args = [...base.args];
|
|
29004
|
+
if (options?.scopes?.length) {
|
|
29005
|
+
clauses.push(`"scope" in (${options.scopes.map(() => "?").join(",")})`);
|
|
29006
|
+
args.push(...options.scopes);
|
|
29007
|
+
}
|
|
29008
|
+
const sql = `select "id", "scope", "created_at", "updated_at", "last_observed_at", "superseded_at", "superseded_by", "is_deleted", "proof_count" from "memory_vault" where ${clauses.join(" and ")}`;
|
|
29009
|
+
rows = await ctx.vaultMemoryCollection.query(import_watermelondb19.Q.unsafeSqlQuery(sql, args)).unsafeFetchRaw();
|
|
29010
|
+
} catch (err) {
|
|
29011
|
+
getLogger().debug(
|
|
29012
|
+
"memoryVault: getVaultProfileMetadataOp uses the query fallback: " + (err instanceof Error ? err.message : String(err))
|
|
29013
|
+
);
|
|
29014
|
+
rows = await ctx.vaultMemoryCollection.query(...vaultListConditions(ctx, listOptions)).unsafeFetchRaw();
|
|
29015
|
+
}
|
|
29016
|
+
return rows.map(mapRaw);
|
|
29017
|
+
}
|
|
28986
29018
|
async function getVaultCandidateKeysOp(ctx, options) {
|
|
28987
29019
|
const mapRaw = (raw) => ({
|
|
28988
29020
|
uniqueId: raw.id,
|
|
@@ -36717,7 +36749,7 @@ async function synthesizeProfile(ctx, options = {}) {
|
|
|
36717
36749
|
};
|
|
36718
36750
|
const previous = options.previous && options.previous.version === PROFILE_DOC_VERSION && configMatches(options.previous.config, config) ? options.previous : void 0;
|
|
36719
36751
|
const listOptions = { scopes, includeDeleted: true, includeSuperseded: true };
|
|
36720
|
-
const [memories, projections] = store ? await Promise.all([store.list(listOptions), store.listProjections(listOptions)]) : [await
|
|
36752
|
+
const [memories, projections] = store ? await Promise.all([store.list(listOptions), store.listProjections(listOptions)]) : [await getVaultProfileMetadataOp(vaultCtx, { scopes }), []];
|
|
36721
36753
|
const watermark = computeVaultWatermark(memories);
|
|
36722
36754
|
const observationTrends = summarizeObservationTrends(
|
|
36723
36755
|
memories.filter((m) => !m.isDeleted && m.supersededBy === null).map((m) => ({
|
|
@@ -36753,7 +36785,8 @@ async function synthesizeProfile(ctx, options = {}) {
|
|
|
36753
36785
|
previous,
|
|
36754
36786
|
watermark,
|
|
36755
36787
|
options.reviewedMemoryIds,
|
|
36756
|
-
previousUnreadable
|
|
36788
|
+
previousUnreadable,
|
|
36789
|
+
store ? void 0 : (ids) => getVaultEmbeddingsByIdsOp(vaultCtx, ids)
|
|
36757
36790
|
);
|
|
36758
36791
|
const memoriesById = new Map(memories.map((memory) => [memory.uniqueId, memory]));
|
|
36759
36792
|
const fallbackPriors = /* @__PURE__ */ new Map();
|
|
@@ -36840,7 +36873,7 @@ function computeVaultWatermark(memories) {
|
|
|
36840
36873
|
}
|
|
36841
36874
|
return max;
|
|
36842
36875
|
}
|
|
36843
|
-
async function computeStaleFacetKeys(ctx, memories, facets, previous, watermark, reviewedMemoryIds, previouslyUnreadable) {
|
|
36876
|
+
async function computeStaleFacetKeys(ctx, memories, facets, previous, watermark, reviewedMemoryIds, previouslyUnreadable, loadEmbeddings) {
|
|
36844
36877
|
const allKeys = new Set(facets.map((f) => f.key));
|
|
36845
36878
|
if (previous && watermark < previous.vaultWatermark) return allKeys;
|
|
36846
36879
|
if (!previous) return allKeys;
|
|
@@ -36873,7 +36906,9 @@ async function computeStaleFacetKeys(ctx, memories, facets, previous, watermark,
|
|
|
36873
36906
|
toAttribute = toAttribute.filter((m) => allowed.has(m.uniqueId));
|
|
36874
36907
|
}
|
|
36875
36908
|
if (toAttribute.length > 0) {
|
|
36876
|
-
const
|
|
36909
|
+
const candidates = loadEmbeddings ? await loadEmbeddings(toAttribute.map((m) => m.uniqueId)) : toAttribute;
|
|
36910
|
+
if (candidates.length !== toAttribute.length) return allKeys;
|
|
36911
|
+
const attributed = await attributeFacts(ctx, candidates, facets);
|
|
36877
36912
|
if (attributed === null) return allKeys;
|
|
36878
36913
|
for (const k of attributed) stale.add(k);
|
|
36879
36914
|
}
|
package/dist/server/index.mjs
CHANGED
|
@@ -27237,10 +27237,10 @@ async function getVaultRankingProjectionsOp(ctx, options) {
|
|
|
27237
27237
|
function baseVaultSql(ctx, options) {
|
|
27238
27238
|
const clauses = [
|
|
27239
27239
|
`"_status" is not 'deleted'`,
|
|
27240
|
-
'"is_deleted" = 0',
|
|
27240
|
+
...options?.includeDeleted ? [] : ['"is_deleted" = 0'],
|
|
27241
27241
|
...options?.includeArchived ? [] : ['"archived_at" is null'],
|
|
27242
27242
|
...options?.includeQuarantined ? [] : [`"trust_tier" is not 'quarantined'`],
|
|
27243
|
-
'"superseded_by" is null'
|
|
27243
|
+
...options?.includeSuperseded ? [] : ['"superseded_by" is null']
|
|
27244
27244
|
];
|
|
27245
27245
|
const args = [];
|
|
27246
27246
|
if (ctx.userId !== void 0) {
|
|
@@ -27249,6 +27249,38 @@ function baseVaultSql(ctx, options) {
|
|
|
27249
27249
|
}
|
|
27250
27250
|
return { sql: clauses.join(" and "), args };
|
|
27251
27251
|
}
|
|
27252
|
+
async function getVaultProfileMetadataOp(ctx, options) {
|
|
27253
|
+
const mapRaw = (raw) => ({
|
|
27254
|
+
uniqueId: raw.id,
|
|
27255
|
+
scope: raw.scope ?? "",
|
|
27256
|
+
createdAt: new Date(raw.created_at),
|
|
27257
|
+
updatedAt: new Date(raw.updated_at),
|
|
27258
|
+
lastObservedAt: raw.last_observed_at ?? null,
|
|
27259
|
+
supersededAt: raw.superseded_at ?? null,
|
|
27260
|
+
supersededBy: raw.superseded_by ?? null,
|
|
27261
|
+
isDeleted: raw.is_deleted === true || raw.is_deleted === 1,
|
|
27262
|
+
proofCount: raw.proof_count ?? null
|
|
27263
|
+
});
|
|
27264
|
+
const listOptions = { ...options, includeDeleted: true, includeSuperseded: true };
|
|
27265
|
+
let rows;
|
|
27266
|
+
try {
|
|
27267
|
+
const base = baseVaultSql(ctx, listOptions);
|
|
27268
|
+
const clauses = [base.sql, `"_status" != 'deleted'`];
|
|
27269
|
+
const args = [...base.args];
|
|
27270
|
+
if (options?.scopes?.length) {
|
|
27271
|
+
clauses.push(`"scope" in (${options.scopes.map(() => "?").join(",")})`);
|
|
27272
|
+
args.push(...options.scopes);
|
|
27273
|
+
}
|
|
27274
|
+
const sql = `select "id", "scope", "created_at", "updated_at", "last_observed_at", "superseded_at", "superseded_by", "is_deleted", "proof_count" from "memory_vault" where ${clauses.join(" and ")}`;
|
|
27275
|
+
rows = await ctx.vaultMemoryCollection.query(import_watermelondb19.Q.unsafeSqlQuery(sql, args)).unsafeFetchRaw();
|
|
27276
|
+
} catch (err) {
|
|
27277
|
+
getLogger().debug(
|
|
27278
|
+
"memoryVault: getVaultProfileMetadataOp uses the query fallback: " + (err instanceof Error ? err.message : String(err))
|
|
27279
|
+
);
|
|
27280
|
+
rows = await ctx.vaultMemoryCollection.query(...vaultListConditions(ctx, listOptions)).unsafeFetchRaw();
|
|
27281
|
+
}
|
|
27282
|
+
return rows.map(mapRaw);
|
|
27283
|
+
}
|
|
27252
27284
|
async function getVaultCandidateKeysOp(ctx, options) {
|
|
27253
27285
|
const mapRaw = (raw) => ({
|
|
27254
27286
|
uniqueId: raw.id,
|
|
@@ -34939,7 +34971,7 @@ async function synthesizeProfile(ctx, options = {}) {
|
|
|
34939
34971
|
};
|
|
34940
34972
|
const previous = options.previous && options.previous.version === PROFILE_DOC_VERSION && configMatches(options.previous.config, config) ? options.previous : void 0;
|
|
34941
34973
|
const listOptions = { scopes, includeDeleted: true, includeSuperseded: true };
|
|
34942
|
-
const [memories, projections] = store ? await Promise.all([store.list(listOptions), store.listProjections(listOptions)]) : [await
|
|
34974
|
+
const [memories, projections] = store ? await Promise.all([store.list(listOptions), store.listProjections(listOptions)]) : [await getVaultProfileMetadataOp(vaultCtx, { scopes }), []];
|
|
34943
34975
|
const watermark = computeVaultWatermark(memories);
|
|
34944
34976
|
const observationTrends = summarizeObservationTrends(
|
|
34945
34977
|
memories.filter((m) => !m.isDeleted && m.supersededBy === null).map((m) => ({
|
|
@@ -34975,7 +35007,8 @@ async function synthesizeProfile(ctx, options = {}) {
|
|
|
34975
35007
|
previous,
|
|
34976
35008
|
watermark,
|
|
34977
35009
|
options.reviewedMemoryIds,
|
|
34978
|
-
previousUnreadable
|
|
35010
|
+
previousUnreadable,
|
|
35011
|
+
store ? void 0 : (ids) => getVaultEmbeddingsByIdsOp(vaultCtx, ids)
|
|
34979
35012
|
);
|
|
34980
35013
|
const memoriesById = new Map(memories.map((memory) => [memory.uniqueId, memory]));
|
|
34981
35014
|
const fallbackPriors = /* @__PURE__ */ new Map();
|
|
@@ -35062,7 +35095,7 @@ function computeVaultWatermark(memories) {
|
|
|
35062
35095
|
}
|
|
35063
35096
|
return max;
|
|
35064
35097
|
}
|
|
35065
|
-
async function computeStaleFacetKeys(ctx, memories, facets, previous, watermark, reviewedMemoryIds, previouslyUnreadable) {
|
|
35098
|
+
async function computeStaleFacetKeys(ctx, memories, facets, previous, watermark, reviewedMemoryIds, previouslyUnreadable, loadEmbeddings) {
|
|
35066
35099
|
const allKeys = new Set(facets.map((f) => f.key));
|
|
35067
35100
|
if (previous && watermark < previous.vaultWatermark) return allKeys;
|
|
35068
35101
|
if (!previous) return allKeys;
|
|
@@ -35095,7 +35128,9 @@ async function computeStaleFacetKeys(ctx, memories, facets, previous, watermark,
|
|
|
35095
35128
|
toAttribute = toAttribute.filter((m) => allowed.has(m.uniqueId));
|
|
35096
35129
|
}
|
|
35097
35130
|
if (toAttribute.length > 0) {
|
|
35098
|
-
const
|
|
35131
|
+
const candidates = loadEmbeddings ? await loadEmbeddings(toAttribute.map((m) => m.uniqueId)) : toAttribute;
|
|
35132
|
+
if (candidates.length !== toAttribute.length) return allKeys;
|
|
35133
|
+
const attributed = await attributeFacts(ctx, candidates, facets);
|
|
35099
35134
|
if (attributed === null) return allKeys;
|
|
35100
35135
|
for (const k of attributed) stale.add(k);
|
|
35101
35136
|
}
|