@anuma/sdk 7.0.3-next.20261014212810 → 7.0.4
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 +122 -106
- package/dist/expo/index.d.mts +8 -1
- package/dist/expo/index.d.ts +8 -1
- package/dist/expo/index.mjs +122 -104
- package/dist/index.cjs +7 -29
- package/dist/index.mjs +7 -29
- package/dist/react/index.cjs +122 -106
- package/dist/react/index.d.mts +8 -1
- package/dist/react/index.d.ts +8 -1
- package/dist/react/index.mjs +122 -104
- package/dist/server/index.cjs +140 -89
- package/dist/server/index.d.mts +5 -2
- package/dist/server/index.d.ts +5 -2
- package/dist/server/index.mjs +140 -87
- package/dist/tools/selection/index.cjs +7 -29
- package/dist/tools/selection/index.mjs +7 -29
- package/package.json +2 -2
package/dist/expo/index.cjs
CHANGED
|
@@ -3731,8 +3731,9 @@ async function updateConversationPinnedOp(ctx, id, pinned) {
|
|
|
3731
3731
|
}
|
|
3732
3732
|
return false;
|
|
3733
3733
|
}
|
|
3734
|
-
async function getMessagesOp(ctx, convId) {
|
|
3735
|
-
const
|
|
3734
|
+
async function getMessagesOp(ctx, convId, opts) {
|
|
3735
|
+
const fetched = await ctx.messagesCollection.query(import_watermelondb2.Q.where("conversation_id", convId), import_watermelondb2.Q.sortBy("message_id", import_watermelondb2.Q.asc)).unsafeFetchRaw();
|
|
3736
|
+
const results = opts?.rawFilter ? fetched.filter(opts.rawFilter) : fetched;
|
|
3736
3737
|
return Promise.all(
|
|
3737
3738
|
results.map(
|
|
3738
3739
|
(raw) => messageRawToStored(raw, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner)
|
|
@@ -5495,24 +5496,6 @@ var getApiV1Models = (options) => (options?.client ?? client).get({ url: "/api/v
|
|
|
5495
5496
|
// src/lib/memoryEngine/generate.ts
|
|
5496
5497
|
init_clientConfig();
|
|
5497
5498
|
init_taskType();
|
|
5498
|
-
|
|
5499
|
-
// src/lib/memoryEngine/embeddingCacheState.ts
|
|
5500
|
-
var EMBEDDING_CACHE_STATE_KEY = /* @__PURE__ */ Symbol.for("@anuma/sdk/embedding-cache/v1");
|
|
5501
|
-
var cacheGlobal = globalThis;
|
|
5502
|
-
var fallbackState = {
|
|
5503
|
-
scopedViews: /* @__PURE__ */ new WeakMap(),
|
|
5504
|
-
inFlightByCache: /* @__PURE__ */ new WeakMap(),
|
|
5505
|
-
cachedEmbeddingModels: /* @__PURE__ */ new WeakMap()
|
|
5506
|
-
};
|
|
5507
|
-
function getEmbeddingCacheState() {
|
|
5508
|
-
try {
|
|
5509
|
-
return cacheGlobal[EMBEDDING_CACHE_STATE_KEY] ?? (cacheGlobal[EMBEDDING_CACHE_STATE_KEY] = fallbackState);
|
|
5510
|
-
} catch {
|
|
5511
|
-
return fallbackState;
|
|
5512
|
-
}
|
|
5513
|
-
}
|
|
5514
|
-
|
|
5515
|
-
// src/lib/memoryEngine/generate.ts
|
|
5516
5499
|
var EMBED_MAX_ATTEMPTS = 4;
|
|
5517
5500
|
var DEFAULT_EMBEDDING_REQUEST_TIMEOUT_MS = 15e3;
|
|
5518
5501
|
var DEFAULT_EMBEDDING_TOKEN_TIMEOUT_MS = 1e4;
|
|
@@ -5603,18 +5586,15 @@ async function generateEmbedding(text14, options) {
|
|
|
5603
5586
|
if (total === void 0) return embedOne(text14, options, void 0);
|
|
5604
5587
|
return withDeadline((signal) => embedOne(text14, options, signal), total, "embedding");
|
|
5605
5588
|
}
|
|
5606
|
-
var
|
|
5589
|
+
var inFlightByCache = /* @__PURE__ */ new WeakMap();
|
|
5607
5590
|
async function embedOne(text14, options, outer) {
|
|
5608
5591
|
const { cache } = options;
|
|
5609
5592
|
if (!cache) return Array.from(await requestEmbedding(text14, options, outer));
|
|
5610
|
-
const model = options.model ?? DEFAULT_API_EMBEDDING_MODEL;
|
|
5611
5593
|
const cached = cache.get(text14);
|
|
5612
|
-
|
|
5613
|
-
if (cached && (cachedModel === void 0 || cachedModel === model)) return Array.from(cached);
|
|
5594
|
+
if (cached) return Array.from(cached);
|
|
5614
5595
|
const inFlight = inFlightByCache.get(cache) ?? /* @__PURE__ */ new Map();
|
|
5615
5596
|
inFlightByCache.set(cache, inFlight);
|
|
5616
|
-
const
|
|
5617
|
-
const pending = inFlight.get(requestKey);
|
|
5597
|
+
const pending = inFlight.get(text14);
|
|
5618
5598
|
if (pending) {
|
|
5619
5599
|
try {
|
|
5620
5600
|
return Array.from(await pending);
|
|
@@ -5623,14 +5603,13 @@ async function embedOne(text14, options, outer) {
|
|
|
5623
5603
|
}
|
|
5624
5604
|
}
|
|
5625
5605
|
const request = requestEmbedding(text14, options, outer);
|
|
5626
|
-
inFlight.set(
|
|
5606
|
+
inFlight.set(text14, request);
|
|
5627
5607
|
try {
|
|
5628
5608
|
const embedding2 = await request;
|
|
5629
|
-
cachedEmbeddingModels.set(embedding2, model);
|
|
5630
5609
|
cache.set(text14, embedding2);
|
|
5631
5610
|
return Array.from(embedding2);
|
|
5632
5611
|
} finally {
|
|
5633
|
-
if (inFlight.get(
|
|
5612
|
+
if (inFlight.get(text14) === request) inFlight.delete(text14);
|
|
5634
5613
|
}
|
|
5635
5614
|
}
|
|
5636
5615
|
async function requestEmbedding(text14, options, outer) {
|
|
@@ -5713,15 +5692,13 @@ async function embedMany(texts, options, outer) {
|
|
|
5713
5692
|
const { baseUrl = BASE_URL, model, batchSize, cache } = options;
|
|
5714
5693
|
const timeoutMs = options.timeoutMs ?? DEFAULT_EMBEDDING_REQUEST_TIMEOUT_MS;
|
|
5715
5694
|
const chunkSize = batchSize ?? DEFAULT_EMBEDDING_BATCH_SIZE;
|
|
5716
|
-
const embeddingModel = model ?? DEFAULT_API_EMBEDDING_MODEL;
|
|
5717
5695
|
const results = new Array(texts.length).fill(null);
|
|
5718
5696
|
const uncachedIndices = [];
|
|
5719
5697
|
const uncachedTexts = [];
|
|
5720
5698
|
for (let i = 0; i < texts.length; i++) {
|
|
5721
5699
|
if (cache) {
|
|
5722
5700
|
const cached = cache.get(texts[i]);
|
|
5723
|
-
|
|
5724
|
-
if (cached && (cachedModel === void 0 || cachedModel === embeddingModel)) {
|
|
5701
|
+
if (cached) {
|
|
5725
5702
|
results[i] = Array.from(cached);
|
|
5726
5703
|
continue;
|
|
5727
5704
|
}
|
|
@@ -5737,6 +5714,7 @@ async function embedMany(texts, options, outer) {
|
|
|
5737
5714
|
...taskTypeHeader(options.taskType)
|
|
5738
5715
|
};
|
|
5739
5716
|
if (outer?.aborted) throw outer.reason;
|
|
5717
|
+
const embeddingModel = model ?? DEFAULT_API_EMBEDDING_MODEL;
|
|
5740
5718
|
let newEmbeddings;
|
|
5741
5719
|
if (uncachedTexts.length <= chunkSize) {
|
|
5742
5720
|
newEmbeddings = await generateEmbeddingsBatch(
|
|
@@ -5784,7 +5762,6 @@ async function embedMany(texts, options, outer) {
|
|
|
5784
5762
|
const f32Embedding = Float32Array.from(newEmbeddings[i]);
|
|
5785
5763
|
results[uncachedIndices[i]] = Array.from(f32Embedding);
|
|
5786
5764
|
if (cache) {
|
|
5787
|
-
cachedEmbeddingModels.set(f32Embedding, embeddingModel);
|
|
5788
5765
|
cache.set(uncachedTexts[i], f32Embedding);
|
|
5789
5766
|
}
|
|
5790
5767
|
}
|
|
@@ -5909,6 +5886,37 @@ async function chunkAndEmbedMessage(ctx, messageId, options) {
|
|
|
5909
5886
|
}));
|
|
5910
5887
|
return updateMessageChunksOp(ctx, messageId, messageChunks, embeddingModel);
|
|
5911
5888
|
}
|
|
5889
|
+
var MIN_SEALED_EMBEDDING_HEX = 256;
|
|
5890
|
+
function rawHasEmbedding(value) {
|
|
5891
|
+
if (Array.isArray(value)) return value.length > 0;
|
|
5892
|
+
if (typeof value !== "string" || value.length === 0) return false;
|
|
5893
|
+
if (isEncrypted(value)) {
|
|
5894
|
+
return value.length - value.indexOf(":", 4) - 1 >= MIN_SEALED_EMBEDDING_HEX;
|
|
5895
|
+
}
|
|
5896
|
+
try {
|
|
5897
|
+
const parsed = JSON.parse(value);
|
|
5898
|
+
return Array.isArray(parsed) && parsed.length > 0;
|
|
5899
|
+
} catch {
|
|
5900
|
+
return false;
|
|
5901
|
+
}
|
|
5902
|
+
}
|
|
5903
|
+
function sealedVersion(value) {
|
|
5904
|
+
if (typeof value !== "string" || !isEncrypted(value)) return null;
|
|
5905
|
+
return value.startsWith("enc:v2:") ? "v2" : "v3";
|
|
5906
|
+
}
|
|
5907
|
+
function mayNeedChunkEmbedding(raw, embeddingModel, filter) {
|
|
5908
|
+
const role = raw.role;
|
|
5909
|
+
if (role === "system") return false;
|
|
5910
|
+
if (filter?.roles && !filter.roles.includes(role ?? "")) return false;
|
|
5911
|
+
if (isNonEmbeddableOrigin(raw.origin, filter?.reembedDiscarded)) {
|
|
5912
|
+
return false;
|
|
5913
|
+
}
|
|
5914
|
+
const model = raw.embedding_model;
|
|
5915
|
+
if (typeof model === "string" && model !== embeddingModel) return true;
|
|
5916
|
+
if (rawHasEmbedding(raw.chunks)) return false;
|
|
5917
|
+
if (rawHasEmbedding(raw.vector) && !filter?.rechunkExisting) return false;
|
|
5918
|
+
return true;
|
|
5919
|
+
}
|
|
5912
5920
|
async function chunkAndEmbedAllMessages(ctx, options, filter) {
|
|
5913
5921
|
const embeddingModel = options.model ?? DEFAULT_API_EMBEDDING_MODEL;
|
|
5914
5922
|
const { chunkSize = DEFAULT_CHUNK_SIZE } = options;
|
|
@@ -5921,11 +5929,31 @@ async function chunkAndEmbedAllMessages(ctx, options, filter) {
|
|
|
5921
5929
|
let considered = 0;
|
|
5922
5930
|
let sealedRowsSeen = 0;
|
|
5923
5931
|
let rowsSeen = 0;
|
|
5932
|
+
const keptSealed = /* @__PURE__ */ new Map();
|
|
5933
|
+
const candidatesStillSealed = /* @__PURE__ */ new Map();
|
|
5934
|
+
const droppedSealed = /* @__PURE__ */ new Map();
|
|
5935
|
+
const rawFilter = (raw) => {
|
|
5936
|
+
rowsSeen++;
|
|
5937
|
+
const keep = mayNeedChunkEmbedding(raw, embeddingModel, filter);
|
|
5938
|
+
const version = sealedVersion(raw.content);
|
|
5939
|
+
if (!version) return keep;
|
|
5940
|
+
if (keep) {
|
|
5941
|
+
keptSealed.set(version, (keptSealed.get(version) ?? 0) + 1);
|
|
5942
|
+
} else {
|
|
5943
|
+
const dropped = droppedSealed.get(version);
|
|
5944
|
+
if (dropped) dropped.count++;
|
|
5945
|
+
else droppedSealed.set(version, { count: 1, probeId: raw.id });
|
|
5946
|
+
}
|
|
5947
|
+
return keep;
|
|
5948
|
+
};
|
|
5924
5949
|
for (const conv of targetConversations) {
|
|
5925
|
-
const messages = await getMessagesOp(ctx, conv.conversationId);
|
|
5950
|
+
const messages = await getMessagesOp(ctx, conv.conversationId, { rawFilter });
|
|
5926
5951
|
for (const message of messages) {
|
|
5927
|
-
|
|
5928
|
-
if (
|
|
5952
|
+
const stillSealed = sealedVersion(message.content);
|
|
5953
|
+
if (stillSealed) {
|
|
5954
|
+
sealedRowsSeen++;
|
|
5955
|
+
candidatesStillSealed.set(stillSealed, (candidatesStillSealed.get(stillSealed) ?? 0) + 1);
|
|
5956
|
+
}
|
|
5929
5957
|
const isStale = message.embeddingModel !== void 0 && message.embeddingModel !== null && message.embeddingModel !== embeddingModel;
|
|
5930
5958
|
if (message.chunks && message.chunks.length > 0 && !isStale) continue;
|
|
5931
5959
|
const hasVector = message.vector && message.vector.length > 0;
|
|
@@ -5938,6 +5966,7 @@ async function chunkAndEmbedAllMessages(ctx, options, filter) {
|
|
|
5938
5966
|
stillEncrypted++;
|
|
5939
5967
|
continue;
|
|
5940
5968
|
}
|
|
5969
|
+
if (isToolResultsRow(message)) continue;
|
|
5941
5970
|
if (message.content.length < minLength) continue;
|
|
5942
5971
|
if (shouldChunkMessage(message.content, chunkSize)) {
|
|
5943
5972
|
longMessages.push({
|
|
@@ -5949,6 +5978,12 @@ async function chunkAndEmbedAllMessages(ctx, options, filter) {
|
|
|
5949
5978
|
}
|
|
5950
5979
|
}
|
|
5951
5980
|
}
|
|
5981
|
+
for (const [version, dropped] of droppedSealed) {
|
|
5982
|
+
const keyOpenedACandidate = (keptSealed.get(version) ?? 0) > (candidatesStillSealed.get(version) ?? 0);
|
|
5983
|
+
if (keyOpenedACandidate) continue;
|
|
5984
|
+
const probe = await getMessageOp(ctx, dropped.probeId);
|
|
5985
|
+
if (!probe || isEncrypted(probe.content)) sealedRowsSeen += dropped.count;
|
|
5986
|
+
}
|
|
5952
5987
|
if (stillEncrypted > 0 || sealedRowsSeen > 0) {
|
|
5953
5988
|
getLogger().error(
|
|
5954
5989
|
"memoryEngine: messages still encrypted (key unavailable?) \u2014 excluded from embedding",
|
|
@@ -11168,7 +11203,7 @@ var MaskScopedEmbeddingCache = class extends Map {
|
|
|
11168
11203
|
return this;
|
|
11169
11204
|
}
|
|
11170
11205
|
};
|
|
11171
|
-
var
|
|
11206
|
+
var scopedViews = /* @__PURE__ */ new WeakMap();
|
|
11172
11207
|
function maskScopedEmbeddingCache(cache, masked) {
|
|
11173
11208
|
const views = scopedViews.get(cache) ?? {};
|
|
11174
11209
|
scopedViews.set(cache, views);
|
|
@@ -19366,48 +19401,44 @@ async function recall(query, ctx, options = {}) {
|
|
|
19366
19401
|
embeddingOptions,
|
|
19367
19402
|
ctx.vaultCache,
|
|
19368
19403
|
searchOptions
|
|
19369
|
-
)))(
|
|
19370
|
-
|
|
19371
|
-
|
|
19372
|
-
|
|
19373
|
-
|
|
19374
|
-
|
|
19375
|
-
|
|
19376
|
-
|
|
19377
|
-
|
|
19378
|
-
...options.rerankLoadTimeoutMs !== void 0 && {
|
|
19379
|
-
rerankLoadTimeoutMs: options.rerankLoadTimeoutMs
|
|
19380
|
-
},
|
|
19381
|
-
...options.recencyAlpha !== void 0 && { recencyAlpha: options.recencyAlpha },
|
|
19382
|
-
...options.recency && { recency: options.recency },
|
|
19383
|
-
...options.mmr !== void 0 && { mmr: options.mmr },
|
|
19384
|
-
...options.supersessionBoost !== void 0 && {
|
|
19385
|
-
supersessionBoost: options.supersessionBoost
|
|
19386
|
-
},
|
|
19387
|
-
...options.supersessionWindow !== void 0 && {
|
|
19388
|
-
supersessionWindow: options.supersessionWindow
|
|
19389
|
-
},
|
|
19390
|
-
...options.proofCountAlpha !== void 0 && {
|
|
19391
|
-
proofCountAlpha: options.proofCountAlpha
|
|
19392
|
-
},
|
|
19393
|
-
...options.bm25AdmissionDivisor !== void 0 && {
|
|
19394
|
-
bm25AdmissionDivisor: options.bm25AdmissionDivisor
|
|
19395
|
-
},
|
|
19396
|
-
...options.rrfK !== void 0 && { rrfK: options.rrfK },
|
|
19397
|
-
...options.decryptLast !== void 0 && { decryptLast: options.decryptLast },
|
|
19398
|
-
...subQueries && { subQueries },
|
|
19399
|
-
...options.scopes && { scopes: options.scopes },
|
|
19400
|
-
...options.folderId !== void 0 && { folderId: options.folderId },
|
|
19401
|
-
...options.factTypes?.length && { factTypes: options.factTypes },
|
|
19402
|
-
...options.memoryIds !== void 0 && { memoryIds: options.memoryIds },
|
|
19403
|
-
...options.factTypeWeights && { factTypeWeights: options.factTypeWeights },
|
|
19404
|
-
...entityRanking.length > 0 && { entityRanking },
|
|
19405
|
-
...temporalRanking.length > 0 && { temporalRanking },
|
|
19406
|
-
...needsChunkEmbedding && { queryEmbedding: queryEmbedding ?? [] },
|
|
19407
|
-
queryEmbedTotalTimeoutMs
|
|
19404
|
+
)))(query, {
|
|
19405
|
+
limit: types.includes("chunk") ? Math.max(limit * 2, 16) : limit,
|
|
19406
|
+
minSimilarity: vaultMinScore,
|
|
19407
|
+
useFusion: true,
|
|
19408
|
+
rerank: flags.rerank,
|
|
19409
|
+
...options.rerankTopN !== void 0 && { rerankTopN: options.rerankTopN },
|
|
19410
|
+
...options.ceWeight !== void 0 && { ceWeight: options.ceWeight },
|
|
19411
|
+
...options.rerankLoadTimeoutMs !== void 0 && {
|
|
19412
|
+
rerankLoadTimeoutMs: options.rerankLoadTimeoutMs
|
|
19408
19413
|
},
|
|
19409
|
-
options.
|
|
19410
|
-
|
|
19414
|
+
...options.recencyAlpha !== void 0 && { recencyAlpha: options.recencyAlpha },
|
|
19415
|
+
...options.recency && { recency: options.recency },
|
|
19416
|
+
...options.mmr !== void 0 && { mmr: options.mmr },
|
|
19417
|
+
...options.supersessionBoost !== void 0 && {
|
|
19418
|
+
supersessionBoost: options.supersessionBoost
|
|
19419
|
+
},
|
|
19420
|
+
...options.supersessionWindow !== void 0 && {
|
|
19421
|
+
supersessionWindow: options.supersessionWindow
|
|
19422
|
+
},
|
|
19423
|
+
...options.proofCountAlpha !== void 0 && {
|
|
19424
|
+
proofCountAlpha: options.proofCountAlpha
|
|
19425
|
+
},
|
|
19426
|
+
...options.bm25AdmissionDivisor !== void 0 && {
|
|
19427
|
+
bm25AdmissionDivisor: options.bm25AdmissionDivisor
|
|
19428
|
+
},
|
|
19429
|
+
...options.rrfK !== void 0 && { rrfK: options.rrfK },
|
|
19430
|
+
...options.decryptLast !== void 0 && { decryptLast: options.decryptLast },
|
|
19431
|
+
...subQueries && { subQueries },
|
|
19432
|
+
...options.scopes && { scopes: options.scopes },
|
|
19433
|
+
...options.folderId !== void 0 && { folderId: options.folderId },
|
|
19434
|
+
...options.factTypes?.length && { factTypes: options.factTypes },
|
|
19435
|
+
...options.memoryIds !== void 0 && { memoryIds: options.memoryIds },
|
|
19436
|
+
...options.factTypeWeights && { factTypeWeights: options.factTypeWeights },
|
|
19437
|
+
...entityRanking.length > 0 && { entityRanking },
|
|
19438
|
+
...temporalRanking.length > 0 && { temporalRanking },
|
|
19439
|
+
...needsChunkEmbedding && { queryEmbedding: queryEmbedding ?? [] },
|
|
19440
|
+
queryEmbedTotalTimeoutMs
|
|
19441
|
+
});
|
|
19411
19442
|
factResults.push(
|
|
19412
19443
|
...dedupeBy(
|
|
19413
19444
|
results,
|
|
@@ -20554,19 +20585,10 @@ function createLocalMemoryStore(options) {
|
|
|
20554
20585
|
retainOptions
|
|
20555
20586
|
),
|
|
20556
20587
|
factSource: {
|
|
20557
|
-
search: (query, searchOptions
|
|
20588
|
+
search: (query, searchOptions) => searchVaultMemoriesWithSize(
|
|
20558
20589
|
query,
|
|
20559
20590
|
vaultCtx,
|
|
20560
|
-
{
|
|
20561
|
-
...options.embeddingOptions,
|
|
20562
|
-
taskType: "memory_recall_embed",
|
|
20563
|
-
...embeddingCache && !options.embeddingOptions.cache && {
|
|
20564
|
-
cache: maskScopedEmbeddingCache(
|
|
20565
|
-
embeddingCache,
|
|
20566
|
-
Boolean(options.embeddingOptions.maskInput)
|
|
20567
|
-
)
|
|
20568
|
-
}
|
|
20569
|
-
},
|
|
20591
|
+
{ ...options.embeddingOptions, taskType: "memory_recall_embed" },
|
|
20570
20592
|
vaultCache,
|
|
20571
20593
|
searchOptions
|
|
20572
20594
|
),
|
|
@@ -21198,7 +21220,7 @@ function stored(row) {
|
|
|
21198
21220
|
function createRemoteMemoryPipeline(options) {
|
|
21199
21221
|
const { persistence, embeddingOptions } = options;
|
|
21200
21222
|
const model = embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
|
|
21201
|
-
const operation = (mode
|
|
21223
|
+
const operation = (mode) => {
|
|
21202
21224
|
const rejectUndecryptable = (failed) => {
|
|
21203
21225
|
if (!failed.length) return;
|
|
21204
21226
|
if (mode === "retain")
|
|
@@ -21229,7 +21251,7 @@ function createRemoteMemoryPipeline(options) {
|
|
|
21229
21251
|
const start = Date.now();
|
|
21230
21252
|
const budgetMs = search.queryEmbedTotalTimeoutMs ?? 8e3;
|
|
21231
21253
|
const embed = (texts) => generateEmbeddings(texts, {
|
|
21232
|
-
...
|
|
21254
|
+
...embeddingOptions,
|
|
21233
21255
|
taskType: mode === "retain" ? "memory_retain_embed" : "memory_recall_embed",
|
|
21234
21256
|
totalTimeoutMs: budgetMs
|
|
21235
21257
|
});
|
|
@@ -21249,11 +21271,7 @@ function createRemoteMemoryPipeline(options) {
|
|
|
21249
21271
|
}
|
|
21250
21272
|
};
|
|
21251
21273
|
const [primary, facetEmbeddings] = await Promise.all([
|
|
21252
|
-
search.queryEmbedding ?? (
|
|
21253
|
-
...queryOptions,
|
|
21254
|
-
taskType: "memory_recall_embed",
|
|
21255
|
-
totalTimeoutMs: budgetMs
|
|
21256
|
-
}) : embed([query]).then((vectors2) => vectors2[0])),
|
|
21274
|
+
search.queryEmbedding ?? embed([query]).then((vectors2) => vectors2[0]),
|
|
21257
21275
|
embedFacets()
|
|
21258
21276
|
]);
|
|
21259
21277
|
const queryEmbedding = storedVector(primary);
|
|
@@ -21477,17 +21495,15 @@ function createRemoteMemoryPipeline(options) {
|
|
|
21477
21495
|
const factSource = {
|
|
21478
21496
|
graphRanking: options.graphRanking,
|
|
21479
21497
|
temporalRanking: options.temporalRanking,
|
|
21480
|
-
search: async (text14, searchOptions
|
|
21481
|
-
const
|
|
21482
|
-
...embeddingOptions,
|
|
21483
|
-
taskType: "memory_recall_embed",
|
|
21484
|
-
...embeddingCache && !embeddingOptions.cache && {
|
|
21485
|
-
cache: maskScopedEmbeddingCache(embeddingCache, Boolean(embeddingOptions.maskInput))
|
|
21486
|
-
}
|
|
21487
|
-
};
|
|
21488
|
-
const { prepare } = operation("recall", queryOptions);
|
|
21498
|
+
search: async (text14, searchOptions) => {
|
|
21499
|
+
const { prepare } = operation("recall");
|
|
21489
21500
|
const prepared = await prepare(text14, searchOptions);
|
|
21490
|
-
const ranked = await rankPreparedVaultCandidates(
|
|
21501
|
+
const ranked = await rankPreparedVaultCandidates(
|
|
21502
|
+
text14,
|
|
21503
|
+
prepared,
|
|
21504
|
+
{ ...embeddingOptions, taskType: "memory_recall_embed" },
|
|
21505
|
+
searchOptions
|
|
21506
|
+
);
|
|
21491
21507
|
return {
|
|
21492
21508
|
...ranked,
|
|
21493
21509
|
rankedOnCosine: prepared.memories.length > 0 && !prepared.embeddingsUnavailable,
|
package/dist/expo/index.d.mts
CHANGED
|
@@ -4508,7 +4508,7 @@ interface RecallOptions {
|
|
|
4508
4508
|
}
|
|
4509
4509
|
/** A fact source supplies bounded candidates; recall owns ranking and result handling. */
|
|
4510
4510
|
interface RecallFactSource {
|
|
4511
|
-
search: (query: string, options?: MemoryVaultSearchOptions
|
|
4511
|
+
search: (query: string, options?: MemoryVaultSearchOptions) => ReturnType<typeof searchVaultMemoriesWithSize>;
|
|
4512
4512
|
graphRanking: (query: string, traverse: boolean, options: RecallOptions) => Promise<string[]>;
|
|
4513
4513
|
temporalRanking: (query: string, now?: number) => Promise<string[]>;
|
|
4514
4514
|
}
|
|
@@ -7990,6 +7990,13 @@ declare const chatStorageMigrations: Readonly<{
|
|
|
7990
7990
|
sortedMigrations: _nozbe_watermelondb_Schema_migrations.Migration[];
|
|
7991
7991
|
}>;
|
|
7992
7992
|
|
|
7993
|
+
/**
|
|
7994
|
+
* Namespacing for a caller-shared embedding cache.
|
|
7995
|
+
*
|
|
7996
|
+
* Lives here, next to the `embeddingCache` send-arg it serves, rather than in either platform hook:
|
|
7997
|
+
* react and expo both thread the option through their own send paths, and a copy per platform is how
|
|
7998
|
+
* the two drift.
|
|
7999
|
+
*/
|
|
7993
8000
|
declare function maskScopedEmbeddingCache(cache: Map<string, Float32Array>, masked: boolean): Map<string, Float32Array>;
|
|
7994
8001
|
|
|
7995
8002
|
/**
|
package/dist/expo/index.d.ts
CHANGED
|
@@ -4508,7 +4508,7 @@ interface RecallOptions {
|
|
|
4508
4508
|
}
|
|
4509
4509
|
/** A fact source supplies bounded candidates; recall owns ranking and result handling. */
|
|
4510
4510
|
interface RecallFactSource {
|
|
4511
|
-
search: (query: string, options?: MemoryVaultSearchOptions
|
|
4511
|
+
search: (query: string, options?: MemoryVaultSearchOptions) => ReturnType<typeof searchVaultMemoriesWithSize>;
|
|
4512
4512
|
graphRanking: (query: string, traverse: boolean, options: RecallOptions) => Promise<string[]>;
|
|
4513
4513
|
temporalRanking: (query: string, now?: number) => Promise<string[]>;
|
|
4514
4514
|
}
|
|
@@ -7990,6 +7990,13 @@ declare const chatStorageMigrations: Readonly<{
|
|
|
7990
7990
|
sortedMigrations: _nozbe_watermelondb_Schema_migrations.Migration[];
|
|
7991
7991
|
}>;
|
|
7992
7992
|
|
|
7993
|
+
/**
|
|
7994
|
+
* Namespacing for a caller-shared embedding cache.
|
|
7995
|
+
*
|
|
7996
|
+
* Lives here, next to the `embeddingCache` send-arg it serves, rather than in either platform hook:
|
|
7997
|
+
* react and expo both thread the option through their own send paths, and a copy per platform is how
|
|
7998
|
+
* the two drift.
|
|
7999
|
+
*/
|
|
7993
8000
|
declare function maskScopedEmbeddingCache(cache: Map<string, Float32Array>, masked: boolean): Map<string, Float32Array>;
|
|
7994
8001
|
|
|
7995
8002
|
/**
|