@anuma/sdk 6.18.0 → 6.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/expo/{chunk-JXN7LD6B.mjs → chunk-GRU24OP4.mjs} +13 -9
- package/dist/expo/{chunk-4Z2X4UYQ.mjs → chunk-WUG6GTHO.mjs} +10 -1
- package/dist/expo/{chunk-A2G6TRUK.mjs → chunk-XDBX4FZY.mjs} +1 -1
- package/dist/{react/consolidate-7NMKF7UC.mjs → expo/consolidate-XBYKAFKT.mjs} +2 -2
- package/dist/expo/index.cjs +24 -10
- package/dist/expo/index.d.mts +30 -3
- package/dist/expo/index.d.ts +30 -3
- package/dist/expo/index.mjs +6 -5
- package/dist/expo/{recall-TGRI5MN4.mjs → recall-PI7FZQNO.mjs} +2 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/react/{chunk-TVPCH7ZZ.mjs → chunk-2EEPAOHJ.mjs} +13 -9
- package/dist/react/{chunk-7X7BNMGS.mjs → chunk-AVYB5IXC.mjs} +1 -1
- package/dist/react/{chunk-4Z2X4UYQ.mjs → chunk-WUG6GTHO.mjs} +10 -1
- package/dist/{expo/consolidate-ZM5JNULQ.mjs → react/consolidate-URHGJT7I.mjs} +2 -2
- package/dist/react/index.cjs +24 -10
- package/dist/react/index.d.mts +30 -3
- package/dist/react/index.d.ts +30 -3
- package/dist/react/index.mjs +6 -5
- package/dist/react/{recall-OKNLU335.mjs → recall-D6ODL36R.mjs} +2 -2
- package/dist/server/{chunk-4LPSEROP.mjs → chunk-RKQ4MRS2.mjs} +1 -1
- package/dist/server/{chunk-K7H7ICPK.mjs → chunk-SPHKT76E.mjs} +13 -9
- package/dist/server/{chunk-BSCEZOIW.mjs → chunk-YXL5VKCO.mjs} +10 -1
- package/dist/server/{consolidate-MSAXASHL.mjs → consolidate-54P6QZKU.mjs} +2 -2
- package/dist/server/index.cjs +24 -10
- package/dist/server/index.d.mts +30 -3
- package/dist/server/index.d.ts +30 -3
- package/dist/server/index.mjs +6 -5
- package/dist/server/{recall-YXJATOSD.mjs → recall-NLCZUGXN.mjs} +2 -2
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
callPortalJsonCompletion,
|
|
3
3
|
getLogger
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-WUG6GTHO.mjs";
|
|
5
5
|
import {
|
|
6
6
|
BASE_URL,
|
|
7
7
|
createClientConfig
|
|
@@ -5643,6 +5643,7 @@ function createVaultEmbeddingCache(maxSize = DEFAULT_VAULT_CACHE_SIZE) {
|
|
|
5643
5643
|
}
|
|
5644
5644
|
|
|
5645
5645
|
// src/lib/memoryVault/searchTool.ts
|
|
5646
|
+
var DEFAULT_RERANK_TOP_N = 5;
|
|
5646
5647
|
var nowMs = () => typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
|
|
5647
5648
|
var warnedProgrammaticDecomposeIgnored = false;
|
|
5648
5649
|
function normalizeEventTimeKind(kind) {
|
|
@@ -5873,7 +5874,7 @@ async function rankFusedVaultMemoriesAsync(query, queryEmbedding, items, options
|
|
|
5873
5874
|
let tailSlice = [];
|
|
5874
5875
|
const itemById = new Map(items.map((i) => [i.id, i]));
|
|
5875
5876
|
if (options?.rerank) {
|
|
5876
|
-
const rerankTopN = options.rerankTopN ??
|
|
5877
|
+
const rerankTopN = options.rerankTopN ?? DEFAULT_RERANK_TOP_N;
|
|
5877
5878
|
const ceWeight = options.ceWeight ?? 0.1;
|
|
5878
5879
|
const headSlice = v2Ranked.slice(0, rerankTopN);
|
|
5879
5880
|
const ceStart = nowMs();
|
|
@@ -5919,9 +5920,12 @@ async function rankFusedVaultMemoriesAsync(query, queryEmbedding, items, options
|
|
|
5919
5920
|
}
|
|
5920
5921
|
if (sideLanesAsync.length > 0) {
|
|
5921
5922
|
const headIds = combined.map((r) => r.uniqueId);
|
|
5922
|
-
const
|
|
5923
|
-
const
|
|
5924
|
-
const
|
|
5923
|
+
const tailIds = tailSlice.map((r) => r.uniqueId);
|
|
5924
|
+
const rankedIds = tailIds.length > 0 ? [...headIds, ...tailIds] : headIds;
|
|
5925
|
+
const fused = rrfFuse([rankedIds, rankedIds, ...sideLanesAsync], options?.rrfK);
|
|
5926
|
+
const fusedHead = [...combined, ...tailSlice].map((r) => ({ ...r, similarity: fused.get(r.uniqueId) ?? r.similarity })).sort((a, b) => b.similarity - a.similarity);
|
|
5927
|
+
tailSlice = [];
|
|
5928
|
+
const seen = new Set(fusedHead.map((r) => r.uniqueId));
|
|
5925
5929
|
const itemById2 = new Map(items.map((i) => [i.id, i]));
|
|
5926
5930
|
for (const lane of sideLanesAsync) {
|
|
5927
5931
|
for (const id of lane) {
|
|
@@ -5946,7 +5950,7 @@ async function rankFusedVaultMemoriesAsync(query, queryEmbedding, items, options
|
|
|
5946
5950
|
const lambda = options.mmrLambda ?? 0.7;
|
|
5947
5951
|
const mmrTopN = options.mmrTopN ?? 20;
|
|
5948
5952
|
const itemById2 = new Map(items.map((i) => [i.id, i]));
|
|
5949
|
-
const mmrCandidates = combined.slice(0, mmrTopN).map((r) => ({
|
|
5953
|
+
const mmrCandidates = [...combined, ...tailSlice].slice(0, mmrTopN).map((r) => ({
|
|
5950
5954
|
id: r.uniqueId,
|
|
5951
5955
|
score: r.similarity,
|
|
5952
5956
|
embedding: itemById2.get(r.uniqueId)?.embedding ?? [],
|
|
@@ -5954,7 +5958,7 @@ async function rankFusedVaultMemoriesAsync(query, queryEmbedding, items, options
|
|
|
5954
5958
|
}));
|
|
5955
5959
|
const picked = applyMMR(mmrCandidates, limit, lambda);
|
|
5956
5960
|
const pickedIds = new Set(picked.map((p) => p.id));
|
|
5957
|
-
const resultMap = new Map(combined.map((r) => [r.uniqueId, r]));
|
|
5961
|
+
const resultMap = new Map([...combined, ...tailSlice].map((r) => [r.uniqueId, r]));
|
|
5958
5962
|
const pickedResults = picked.map((p) => {
|
|
5959
5963
|
const orig = resultMap.get(p.id);
|
|
5960
5964
|
return {
|
|
@@ -6068,7 +6072,7 @@ async function rankComposite(originalQuery, originalQueryEmbedding, subQueries,
|
|
|
6068
6072
|
}
|
|
6069
6073
|
}
|
|
6070
6074
|
if (options?.rerank && combined.length > 0) {
|
|
6071
|
-
const rerankTopN = options.rerankTopN ??
|
|
6075
|
+
const rerankTopN = options.rerankTopN ?? DEFAULT_RERANK_TOP_N;
|
|
6072
6076
|
const ceWeight = options.ceWeight ?? 0.1;
|
|
6073
6077
|
const headSlice = combined.slice(0, rerankTopN);
|
|
6074
6078
|
const tailSlice = combined.slice(rerankTopN);
|
|
@@ -6908,7 +6912,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
|
|
|
6908
6912
|
subQueries = decomp.subQueries;
|
|
6909
6913
|
}
|
|
6910
6914
|
}
|
|
6911
|
-
const { recall: recall2 } = await import("./recall-
|
|
6915
|
+
const { recall: recall2 } = await import("./recall-PI7FZQNO.mjs");
|
|
6912
6916
|
let recallDegraded = [];
|
|
6913
6917
|
const result = await recall2(
|
|
6914
6918
|
query,
|
|
@@ -172,7 +172,16 @@ async function callPortalJsonCompletion(req) {
|
|
|
172
172
|
...reinforce && { reinforceJsonContract: true }
|
|
173
173
|
} : reinforce ? { ...req, reinforceJsonContract: true } : req;
|
|
174
174
|
const outcome = await attemptPortalJson(attemptReq, endpoint);
|
|
175
|
-
if (outcome.kind === "ok")
|
|
175
|
+
if (outcome.kind === "ok") {
|
|
176
|
+
req.onAttempt?.({ attempt, ok: true });
|
|
177
|
+
return outcome.value;
|
|
178
|
+
}
|
|
179
|
+
req.onAttempt?.({
|
|
180
|
+
attempt,
|
|
181
|
+
ok: false,
|
|
182
|
+
reason: outcome.code,
|
|
183
|
+
...outcome.httpStatus !== void 0 && { httpStatus: outcome.httpStatus }
|
|
184
|
+
});
|
|
176
185
|
lastFailure = {
|
|
177
186
|
reason: outcome.code,
|
|
178
187
|
...outcome.httpStatus !== void 0 && { httpStatus: outcome.httpStatus },
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
notifyConsolidationFallback,
|
|
3
3
|
resolvePiiRedactor
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-XDBX4FZY.mjs";
|
|
5
5
|
import {
|
|
6
6
|
callPortalJsonCompletion
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-WUG6GTHO.mjs";
|
|
8
8
|
import "./chunk-GYKJOWEO.mjs";
|
|
9
9
|
|
|
10
10
|
// src/lib/memory/consolidate.ts
|
package/dist/expo/index.cjs
CHANGED
|
@@ -6261,7 +6261,16 @@ async function callPortalJsonCompletion(req) {
|
|
|
6261
6261
|
...reinforce && { reinforceJsonContract: true }
|
|
6262
6262
|
} : reinforce ? { ...req, reinforceJsonContract: true } : req;
|
|
6263
6263
|
const outcome = await attemptPortalJson(attemptReq, endpoint);
|
|
6264
|
-
if (outcome.kind === "ok")
|
|
6264
|
+
if (outcome.kind === "ok") {
|
|
6265
|
+
req.onAttempt?.({ attempt, ok: true });
|
|
6266
|
+
return outcome.value;
|
|
6267
|
+
}
|
|
6268
|
+
req.onAttempt?.({
|
|
6269
|
+
attempt,
|
|
6270
|
+
ok: false,
|
|
6271
|
+
reason: outcome.code,
|
|
6272
|
+
...outcome.httpStatus !== void 0 && { httpStatus: outcome.httpStatus }
|
|
6273
|
+
});
|
|
6265
6274
|
lastFailure = {
|
|
6266
6275
|
reason: outcome.code,
|
|
6267
6276
|
...outcome.httpStatus !== void 0 && { httpStatus: outcome.httpStatus },
|
|
@@ -8284,7 +8293,7 @@ async function rankFusedVaultMemoriesAsync(query, queryEmbedding, items, options
|
|
|
8284
8293
|
let tailSlice = [];
|
|
8285
8294
|
const itemById = new Map(items.map((i) => [i.id, i]));
|
|
8286
8295
|
if (options?.rerank) {
|
|
8287
|
-
const rerankTopN = options.rerankTopN ??
|
|
8296
|
+
const rerankTopN = options.rerankTopN ?? DEFAULT_RERANK_TOP_N;
|
|
8288
8297
|
const ceWeight = options.ceWeight ?? 0.1;
|
|
8289
8298
|
const headSlice = v2Ranked.slice(0, rerankTopN);
|
|
8290
8299
|
const ceStart = nowMs2();
|
|
@@ -8330,9 +8339,12 @@ async function rankFusedVaultMemoriesAsync(query, queryEmbedding, items, options
|
|
|
8330
8339
|
}
|
|
8331
8340
|
if (sideLanesAsync.length > 0) {
|
|
8332
8341
|
const headIds = combined.map((r) => r.uniqueId);
|
|
8333
|
-
const
|
|
8334
|
-
const
|
|
8335
|
-
const
|
|
8342
|
+
const tailIds = tailSlice.map((r) => r.uniqueId);
|
|
8343
|
+
const rankedIds = tailIds.length > 0 ? [...headIds, ...tailIds] : headIds;
|
|
8344
|
+
const fused = rrfFuse([rankedIds, rankedIds, ...sideLanesAsync], options?.rrfK);
|
|
8345
|
+
const fusedHead = [...combined, ...tailSlice].map((r) => ({ ...r, similarity: fused.get(r.uniqueId) ?? r.similarity })).sort((a, b) => b.similarity - a.similarity);
|
|
8346
|
+
tailSlice = [];
|
|
8347
|
+
const seen = new Set(fusedHead.map((r) => r.uniqueId));
|
|
8336
8348
|
const itemById2 = new Map(items.map((i) => [i.id, i]));
|
|
8337
8349
|
for (const lane of sideLanesAsync) {
|
|
8338
8350
|
for (const id of lane) {
|
|
@@ -8357,7 +8369,7 @@ async function rankFusedVaultMemoriesAsync(query, queryEmbedding, items, options
|
|
|
8357
8369
|
const lambda = options.mmrLambda ?? 0.7;
|
|
8358
8370
|
const mmrTopN = options.mmrTopN ?? 20;
|
|
8359
8371
|
const itemById2 = new Map(items.map((i) => [i.id, i]));
|
|
8360
|
-
const mmrCandidates = combined.slice(0, mmrTopN).map((r) => ({
|
|
8372
|
+
const mmrCandidates = [...combined, ...tailSlice].slice(0, mmrTopN).map((r) => ({
|
|
8361
8373
|
id: r.uniqueId,
|
|
8362
8374
|
score: r.similarity,
|
|
8363
8375
|
embedding: itemById2.get(r.uniqueId)?.embedding ?? [],
|
|
@@ -8365,7 +8377,7 @@ async function rankFusedVaultMemoriesAsync(query, queryEmbedding, items, options
|
|
|
8365
8377
|
}));
|
|
8366
8378
|
const picked = applyMMR(mmrCandidates, limit, lambda);
|
|
8367
8379
|
const pickedIds = new Set(picked.map((p) => p.id));
|
|
8368
|
-
const resultMap = new Map(combined.map((r) => [r.uniqueId, r]));
|
|
8380
|
+
const resultMap = new Map([...combined, ...tailSlice].map((r) => [r.uniqueId, r]));
|
|
8369
8381
|
const pickedResults = picked.map((p) => {
|
|
8370
8382
|
const orig = resultMap.get(p.id);
|
|
8371
8383
|
return {
|
|
@@ -8479,7 +8491,7 @@ async function rankComposite(originalQuery, originalQueryEmbedding, subQueries,
|
|
|
8479
8491
|
}
|
|
8480
8492
|
}
|
|
8481
8493
|
if (options?.rerank && combined.length > 0) {
|
|
8482
|
-
const rerankTopN = options.rerankTopN ??
|
|
8494
|
+
const rerankTopN = options.rerankTopN ?? DEFAULT_RERANK_TOP_N;
|
|
8483
8495
|
const ceWeight = options.ceWeight ?? 0.1;
|
|
8484
8496
|
const headSlice = combined.slice(0, rerankTopN);
|
|
8485
8497
|
const tailSlice = combined.slice(rerankTopN);
|
|
@@ -9364,7 +9376,7 @@ ${formatted}`;
|
|
|
9364
9376
|
}
|
|
9365
9377
|
};
|
|
9366
9378
|
}
|
|
9367
|
-
var nowMs2, warnedProgrammaticDecomposeIgnored, SUPERSESSION_SIMILARITY_THRESHOLD, SUPERSESSION_MIN_AGE_GAP_MS, SUPERSESSION_BOOST_FACTOR, SUPERSESSION_MAX_WINDOW, EMBEDDINGS_DEGRADED_EMPTY_NO_LEXICAL;
|
|
9379
|
+
var DEFAULT_RERANK_TOP_N, nowMs2, warnedProgrammaticDecomposeIgnored, SUPERSESSION_SIMILARITY_THRESHOLD, SUPERSESSION_MIN_AGE_GAP_MS, SUPERSESSION_BOOST_FACTOR, SUPERSESSION_MAX_WINDOW, EMBEDDINGS_DEGRADED_EMPTY_NO_LEXICAL;
|
|
9368
9380
|
var init_searchTool = __esm({
|
|
9369
9381
|
"src/lib/memoryVault/searchTool.ts"() {
|
|
9370
9382
|
"use strict";
|
|
@@ -9382,6 +9394,7 @@ var init_searchTool = __esm({
|
|
|
9382
9394
|
init_bm25();
|
|
9383
9395
|
init_decomposeQuery();
|
|
9384
9396
|
init_lruCache();
|
|
9397
|
+
DEFAULT_RERANK_TOP_N = 5;
|
|
9385
9398
|
nowMs2 = () => typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
|
|
9386
9399
|
warnedProgrammaticDecomposeIgnored = false;
|
|
9387
9400
|
SUPERSESSION_SIMILARITY_THRESHOLD = 0.7;
|
|
@@ -16861,7 +16874,8 @@ Extract durable user facts.`,
|
|
|
16861
16874
|
...options.maxAttempts !== void 0 && { maxAttempts: options.maxAttempts },
|
|
16862
16875
|
...options.timeoutMs !== void 0 && { timeoutMs: options.timeoutMs },
|
|
16863
16876
|
...options.totalTimeoutMs !== void 0 && { totalTimeoutMs: options.totalTimeoutMs },
|
|
16864
|
-
...options.backoffMs && { backoffMs: options.backoffMs }
|
|
16877
|
+
...options.backoffMs && { backoffMs: options.backoffMs },
|
|
16878
|
+
...options.onAttempt && { onAttempt: options.onAttempt }
|
|
16865
16879
|
});
|
|
16866
16880
|
if (parsed === null) {
|
|
16867
16881
|
options.onExhaustedEmpty?.(failure ?? { reason: "empty-content", attempts: 1 });
|
package/dist/expo/index.d.mts
CHANGED
|
@@ -5002,7 +5002,7 @@ interface EntityOperationsContext {
|
|
|
5002
5002
|
*
|
|
5003
5003
|
* @public
|
|
5004
5004
|
*/
|
|
5005
|
-
type TaskType = "title" | "commit_message" | "memory_extract" | "memory_dedup" | "memory_decay" | "memory_injection_check" | "memory_verify_support" | "memory_autosort" | "memory_topic" | "memory_consolidate" | "memory_decompose" | "memory_profile_synth" | "memory_graph" | "folder_context" | "selection_memory" | "summarize" | "style_analysis" | "classify_search" | "app_inspiration_generate" | "app_inspiration_trends" | "app_inspiration_remix" | "spotlight_image" | "slide_image" | "slide_video" | "slide_music" | "slide_sfx" | "media_video" | "media_audio" | "media_bg_removal" | "media_image_preset" | "tool_app_builder" | "tool_document_builder" | "tool_slides" | "tool_slides_image_gen" | "connector_guidance" | "cf_task" | "xbot_intent" | "xbot_council" | "scheduled_task";
|
|
5005
|
+
type TaskType = "title" | "commit_message" | "memory_extract" | "memory_import_extract" | "memory_dedup" | "memory_decay" | "memory_injection_check" | "memory_verify_support" | "memory_autosort" | "memory_topic" | "memory_consolidate" | "memory_decompose" | "memory_profile_synth" | "memory_graph" | "folder_context" | "selection_memory" | "summarize" | "style_analysis" | "classify_search" | "app_inspiration_generate" | "app_inspiration_trends" | "app_inspiration_remix" | "spotlight_image" | "slide_image" | "slide_video" | "slide_music" | "slide_sfx" | "media_video" | "media_audio" | "media_bg_removal" | "media_image_preset" | "tool_app_builder" | "tool_document_builder" | "tool_slides" | "tool_slides_image_gen" | "connector_guidance" | "cf_task" | "xbot_intent" | "xbot_council" | "scheduled_task";
|
|
5006
5006
|
|
|
5007
5007
|
/**
|
|
5008
5008
|
* Shared portal LLM call for the memory pipeline.
|
|
@@ -5099,6 +5099,26 @@ type PortalLlmFailureReason =
|
|
|
5099
5099
|
| "null-completion"
|
|
5100
5100
|
/** `totalTimeoutMs` was spent before the next attempt could run. */
|
|
5101
5101
|
| "time-budget-exhausted";
|
|
5102
|
+
/**
|
|
5103
|
+
* One attempt of a {@link callPortalJsonCompletion} call, reported to
|
|
5104
|
+
* `onAttempt` as it settles — success included. The wire-level diagnostic the
|
|
5105
|
+
* give-up hook cannot provide: a call that succeeds on its third try returns a
|
|
5106
|
+
* value and fires no `onFailure`, yet it cost three completions and its first
|
|
5107
|
+
* two answers were unusable. Extraction quality regressions have hidden in
|
|
5108
|
+
* exactly that shape (a prompt change that made the model answer `NONE` first,
|
|
5109
|
+
* JSON on retry), so the extraction eval gates on the first-attempt clean rate.
|
|
5110
|
+
*
|
|
5111
|
+
* @public
|
|
5112
|
+
*/
|
|
5113
|
+
interface PortalLlmAttempt {
|
|
5114
|
+
/** 1-based attempt index. */
|
|
5115
|
+
attempt: number;
|
|
5116
|
+
/** Whether this attempt produced a parseable JSON value. */
|
|
5117
|
+
ok: boolean;
|
|
5118
|
+
/** Classification when `ok` is false. */
|
|
5119
|
+
reason?: PortalLlmFailureReason;
|
|
5120
|
+
httpStatus?: number;
|
|
5121
|
+
}
|
|
5102
5122
|
/**
|
|
5103
5123
|
* A give-up report: the classified {@link PortalLlmFailureReason} plus the
|
|
5104
5124
|
* little context worth carrying into telemetry. Both extra fields are bounded
|
|
@@ -5355,7 +5375,7 @@ interface MemoryVaultSearchOptions {
|
|
|
5355
5375
|
* When true, switches to the async pipeline (rankFusedVaultMemoriesAsync).
|
|
5356
5376
|
*/
|
|
5357
5377
|
rerank?: boolean;
|
|
5358
|
-
/** Number of CE rerank candidates. Default
|
|
5378
|
+
/** Number of CE rerank candidates. Default 5 ({@link DEFAULT_RERANK_TOP_N}). */
|
|
5359
5379
|
rerankTopN?: number;
|
|
5360
5380
|
/** Multiplicative cross-encoder blend weight. Default 0.1. Only used when `rerank` is true. */
|
|
5361
5381
|
ceWeight?: number;
|
|
@@ -5710,7 +5730,8 @@ interface RecallOptions {
|
|
|
5710
5730
|
* swallowed (diagnostics must never break retrieval). Off unless provided.
|
|
5711
5731
|
*/
|
|
5712
5732
|
onDiagnostics?: (diagnostics: RecallDiagnostics) => void;
|
|
5713
|
-
/** Number of candidates fed to the cross-encoder rerank stage. Default:
|
|
5733
|
+
/** Number of candidates fed to the cross-encoder rerank stage. Default: 5;
|
|
5734
|
+
* was 30 until 2026-08-13 — see anuma-ai/sdk#845. */
|
|
5714
5735
|
rerankTopN?: number;
|
|
5715
5736
|
/** Multiplicative cross-encoder blend weight. Default: 0.1. */
|
|
5716
5737
|
ceWeight?: number;
|
|
@@ -6278,6 +6299,12 @@ interface ExtractFactsOptions extends PortalLlmAuth {
|
|
|
6278
6299
|
* (i.e. redaction silently eating facts) is alarmable.
|
|
6279
6300
|
*/
|
|
6280
6301
|
onCandidatesDropped?: () => void;
|
|
6302
|
+
/**
|
|
6303
|
+
* Per-attempt wire diagnostic, forwarded to {@link callPortalJsonCompletion}.
|
|
6304
|
+
* The extraction eval gates on it (first-attempt clean rate); production
|
|
6305
|
+
* callers may leave it unset.
|
|
6306
|
+
*/
|
|
6307
|
+
onAttempt?: (attempt: PortalLlmAttempt) => void;
|
|
6281
6308
|
}
|
|
6282
6309
|
/**
|
|
6283
6310
|
* Stage 1 — call the LLM to extract candidate facts from the recent
|
package/dist/expo/index.d.ts
CHANGED
|
@@ -5002,7 +5002,7 @@ interface EntityOperationsContext {
|
|
|
5002
5002
|
*
|
|
5003
5003
|
* @public
|
|
5004
5004
|
*/
|
|
5005
|
-
type TaskType = "title" | "commit_message" | "memory_extract" | "memory_dedup" | "memory_decay" | "memory_injection_check" | "memory_verify_support" | "memory_autosort" | "memory_topic" | "memory_consolidate" | "memory_decompose" | "memory_profile_synth" | "memory_graph" | "folder_context" | "selection_memory" | "summarize" | "style_analysis" | "classify_search" | "app_inspiration_generate" | "app_inspiration_trends" | "app_inspiration_remix" | "spotlight_image" | "slide_image" | "slide_video" | "slide_music" | "slide_sfx" | "media_video" | "media_audio" | "media_bg_removal" | "media_image_preset" | "tool_app_builder" | "tool_document_builder" | "tool_slides" | "tool_slides_image_gen" | "connector_guidance" | "cf_task" | "xbot_intent" | "xbot_council" | "scheduled_task";
|
|
5005
|
+
type TaskType = "title" | "commit_message" | "memory_extract" | "memory_import_extract" | "memory_dedup" | "memory_decay" | "memory_injection_check" | "memory_verify_support" | "memory_autosort" | "memory_topic" | "memory_consolidate" | "memory_decompose" | "memory_profile_synth" | "memory_graph" | "folder_context" | "selection_memory" | "summarize" | "style_analysis" | "classify_search" | "app_inspiration_generate" | "app_inspiration_trends" | "app_inspiration_remix" | "spotlight_image" | "slide_image" | "slide_video" | "slide_music" | "slide_sfx" | "media_video" | "media_audio" | "media_bg_removal" | "media_image_preset" | "tool_app_builder" | "tool_document_builder" | "tool_slides" | "tool_slides_image_gen" | "connector_guidance" | "cf_task" | "xbot_intent" | "xbot_council" | "scheduled_task";
|
|
5006
5006
|
|
|
5007
5007
|
/**
|
|
5008
5008
|
* Shared portal LLM call for the memory pipeline.
|
|
@@ -5099,6 +5099,26 @@ type PortalLlmFailureReason =
|
|
|
5099
5099
|
| "null-completion"
|
|
5100
5100
|
/** `totalTimeoutMs` was spent before the next attempt could run. */
|
|
5101
5101
|
| "time-budget-exhausted";
|
|
5102
|
+
/**
|
|
5103
|
+
* One attempt of a {@link callPortalJsonCompletion} call, reported to
|
|
5104
|
+
* `onAttempt` as it settles — success included. The wire-level diagnostic the
|
|
5105
|
+
* give-up hook cannot provide: a call that succeeds on its third try returns a
|
|
5106
|
+
* value and fires no `onFailure`, yet it cost three completions and its first
|
|
5107
|
+
* two answers were unusable. Extraction quality regressions have hidden in
|
|
5108
|
+
* exactly that shape (a prompt change that made the model answer `NONE` first,
|
|
5109
|
+
* JSON on retry), so the extraction eval gates on the first-attempt clean rate.
|
|
5110
|
+
*
|
|
5111
|
+
* @public
|
|
5112
|
+
*/
|
|
5113
|
+
interface PortalLlmAttempt {
|
|
5114
|
+
/** 1-based attempt index. */
|
|
5115
|
+
attempt: number;
|
|
5116
|
+
/** Whether this attempt produced a parseable JSON value. */
|
|
5117
|
+
ok: boolean;
|
|
5118
|
+
/** Classification when `ok` is false. */
|
|
5119
|
+
reason?: PortalLlmFailureReason;
|
|
5120
|
+
httpStatus?: number;
|
|
5121
|
+
}
|
|
5102
5122
|
/**
|
|
5103
5123
|
* A give-up report: the classified {@link PortalLlmFailureReason} plus the
|
|
5104
5124
|
* little context worth carrying into telemetry. Both extra fields are bounded
|
|
@@ -5355,7 +5375,7 @@ interface MemoryVaultSearchOptions {
|
|
|
5355
5375
|
* When true, switches to the async pipeline (rankFusedVaultMemoriesAsync).
|
|
5356
5376
|
*/
|
|
5357
5377
|
rerank?: boolean;
|
|
5358
|
-
/** Number of CE rerank candidates. Default
|
|
5378
|
+
/** Number of CE rerank candidates. Default 5 ({@link DEFAULT_RERANK_TOP_N}). */
|
|
5359
5379
|
rerankTopN?: number;
|
|
5360
5380
|
/** Multiplicative cross-encoder blend weight. Default 0.1. Only used when `rerank` is true. */
|
|
5361
5381
|
ceWeight?: number;
|
|
@@ -5710,7 +5730,8 @@ interface RecallOptions {
|
|
|
5710
5730
|
* swallowed (diagnostics must never break retrieval). Off unless provided.
|
|
5711
5731
|
*/
|
|
5712
5732
|
onDiagnostics?: (diagnostics: RecallDiagnostics) => void;
|
|
5713
|
-
/** Number of candidates fed to the cross-encoder rerank stage. Default:
|
|
5733
|
+
/** Number of candidates fed to the cross-encoder rerank stage. Default: 5;
|
|
5734
|
+
* was 30 until 2026-08-13 — see anuma-ai/sdk#845. */
|
|
5714
5735
|
rerankTopN?: number;
|
|
5715
5736
|
/** Multiplicative cross-encoder blend weight. Default: 0.1. */
|
|
5716
5737
|
ceWeight?: number;
|
|
@@ -6278,6 +6299,12 @@ interface ExtractFactsOptions extends PortalLlmAuth {
|
|
|
6278
6299
|
* (i.e. redaction silently eating facts) is alarmable.
|
|
6279
6300
|
*/
|
|
6280
6301
|
onCandidatesDropped?: () => void;
|
|
6302
|
+
/**
|
|
6303
|
+
* Per-attempt wire diagnostic, forwarded to {@link callPortalJsonCompletion}.
|
|
6304
|
+
* The extraction eval gates on it (first-attempt clean rate); production
|
|
6305
|
+
* callers may leave it unset.
|
|
6306
|
+
*/
|
|
6307
|
+
onAttempt?: (attempt: PortalLlmAttempt) => void;
|
|
6281
6308
|
}
|
|
6282
6309
|
/**
|
|
6283
6310
|
* Stage 1 — call the LLM to extract candidate facts from the recent
|
package/dist/expo/index.mjs
CHANGED
|
@@ -133,7 +133,7 @@ import {
|
|
|
133
133
|
upsertMessageOp,
|
|
134
134
|
useEncryption,
|
|
135
135
|
vaultMemoryToStored
|
|
136
|
-
} from "./chunk-
|
|
136
|
+
} from "./chunk-GRU24OP4.mjs";
|
|
137
137
|
import {
|
|
138
138
|
PII_PATTERNS,
|
|
139
139
|
PiiRedactor,
|
|
@@ -141,7 +141,7 @@ import {
|
|
|
141
141
|
isPiiRedactor,
|
|
142
142
|
notifyConsolidationFallback,
|
|
143
143
|
resolvePiiRedactor
|
|
144
|
-
} from "./chunk-
|
|
144
|
+
} from "./chunk-XDBX4FZY.mjs";
|
|
145
145
|
import {
|
|
146
146
|
INTERNAL_FLOW_MARKER,
|
|
147
147
|
callPortalJsonCompletion,
|
|
@@ -157,7 +157,7 @@ import {
|
|
|
157
157
|
taskTypeHeader,
|
|
158
158
|
validateEndpointOverride,
|
|
159
159
|
withInternalFlowMarker
|
|
160
|
-
} from "./chunk-
|
|
160
|
+
} from "./chunk-WUG6GTHO.mjs";
|
|
161
161
|
import {
|
|
162
162
|
BASE_URL,
|
|
163
163
|
MCP_R2_DOMAIN,
|
|
@@ -6893,7 +6893,7 @@ async function tryConsolidate(trimmed, ctx, options, prepared) {
|
|
|
6893
6893
|
content: m.content,
|
|
6894
6894
|
similarity: m.similarity
|
|
6895
6895
|
}));
|
|
6896
|
-
const { consolidateMemory: doConsolidate } = await import("./consolidate-
|
|
6896
|
+
const { consolidateMemory: doConsolidate } = await import("./consolidate-XBYKAFKT.mjs");
|
|
6897
6897
|
const decision = await doConsolidate(trimmed, candidates, consolidateOptions);
|
|
6898
6898
|
if (decision.action === "create") return null;
|
|
6899
6899
|
if (decision.action === "supersede" && decision.content) {
|
|
@@ -7135,7 +7135,8 @@ Extract durable user facts.`,
|
|
|
7135
7135
|
...options.maxAttempts !== void 0 && { maxAttempts: options.maxAttempts },
|
|
7136
7136
|
...options.timeoutMs !== void 0 && { timeoutMs: options.timeoutMs },
|
|
7137
7137
|
...options.totalTimeoutMs !== void 0 && { totalTimeoutMs: options.totalTimeoutMs },
|
|
7138
|
-
...options.backoffMs && { backoffMs: options.backoffMs }
|
|
7138
|
+
...options.backoffMs && { backoffMs: options.backoffMs },
|
|
7139
|
+
...options.onAttempt && { onAttempt: options.onAttempt }
|
|
7139
7140
|
});
|
|
7140
7141
|
if (parsed === null) {
|
|
7141
7142
|
options.onExhaustedEmpty?.(failure ?? { reason: "empty-content", attempts: 1 });
|
package/dist/index.d.mts
CHANGED
|
@@ -8951,7 +8951,7 @@ declare function decryptConversationTitle(encryptedTitle: string, address: strin
|
|
|
8951
8951
|
*
|
|
8952
8952
|
* @public
|
|
8953
8953
|
*/
|
|
8954
|
-
type TaskType = "title" | "commit_message" | "memory_extract" | "memory_dedup" | "memory_decay" | "memory_injection_check" | "memory_verify_support" | "memory_autosort" | "memory_topic" | "memory_consolidate" | "memory_decompose" | "memory_profile_synth" | "memory_graph" | "folder_context" | "selection_memory" | "summarize" | "style_analysis" | "classify_search" | "app_inspiration_generate" | "app_inspiration_trends" | "app_inspiration_remix" | "spotlight_image" | "slide_image" | "slide_video" | "slide_music" | "slide_sfx" | "media_video" | "media_audio" | "media_bg_removal" | "media_image_preset" | "tool_app_builder" | "tool_document_builder" | "tool_slides" | "tool_slides_image_gen" | "connector_guidance" | "cf_task" | "xbot_intent" | "xbot_council" | "scheduled_task";
|
|
8954
|
+
type TaskType = "title" | "commit_message" | "memory_extract" | "memory_import_extract" | "memory_dedup" | "memory_decay" | "memory_injection_check" | "memory_verify_support" | "memory_autosort" | "memory_topic" | "memory_consolidate" | "memory_decompose" | "memory_profile_synth" | "memory_graph" | "folder_context" | "selection_memory" | "summarize" | "style_analysis" | "classify_search" | "app_inspiration_generate" | "app_inspiration_trends" | "app_inspiration_remix" | "spotlight_image" | "slide_image" | "slide_video" | "slide_music" | "slide_sfx" | "media_video" | "media_audio" | "media_bg_removal" | "media_image_preset" | "tool_app_builder" | "tool_document_builder" | "tool_slides" | "tool_slides_image_gen" | "connector_guidance" | "cf_task" | "xbot_intent" | "xbot_council" | "scheduled_task";
|
|
8955
8955
|
/**
|
|
8956
8956
|
* HTTP header naming the Class-B task a request performs.
|
|
8957
8957
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -8951,7 +8951,7 @@ declare function decryptConversationTitle(encryptedTitle: string, address: strin
|
|
|
8951
8951
|
*
|
|
8952
8952
|
* @public
|
|
8953
8953
|
*/
|
|
8954
|
-
type TaskType = "title" | "commit_message" | "memory_extract" | "memory_dedup" | "memory_decay" | "memory_injection_check" | "memory_verify_support" | "memory_autosort" | "memory_topic" | "memory_consolidate" | "memory_decompose" | "memory_profile_synth" | "memory_graph" | "folder_context" | "selection_memory" | "summarize" | "style_analysis" | "classify_search" | "app_inspiration_generate" | "app_inspiration_trends" | "app_inspiration_remix" | "spotlight_image" | "slide_image" | "slide_video" | "slide_music" | "slide_sfx" | "media_video" | "media_audio" | "media_bg_removal" | "media_image_preset" | "tool_app_builder" | "tool_document_builder" | "tool_slides" | "tool_slides_image_gen" | "connector_guidance" | "cf_task" | "xbot_intent" | "xbot_council" | "scheduled_task";
|
|
8954
|
+
type TaskType = "title" | "commit_message" | "memory_extract" | "memory_import_extract" | "memory_dedup" | "memory_decay" | "memory_injection_check" | "memory_verify_support" | "memory_autosort" | "memory_topic" | "memory_consolidate" | "memory_decompose" | "memory_profile_synth" | "memory_graph" | "folder_context" | "selection_memory" | "summarize" | "style_analysis" | "classify_search" | "app_inspiration_generate" | "app_inspiration_trends" | "app_inspiration_remix" | "spotlight_image" | "slide_image" | "slide_video" | "slide_music" | "slide_sfx" | "media_video" | "media_audio" | "media_bg_removal" | "media_image_preset" | "tool_app_builder" | "tool_document_builder" | "tool_slides" | "tool_slides_image_gen" | "connector_guidance" | "cf_task" | "xbot_intent" | "xbot_council" | "scheduled_task";
|
|
8955
8955
|
/**
|
|
8956
8956
|
* HTTP header naming the Class-B task a request performs.
|
|
8957
8957
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
callPortalJsonCompletion,
|
|
3
3
|
getLogger
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-WUG6GTHO.mjs";
|
|
5
5
|
import {
|
|
6
6
|
BASE_URL,
|
|
7
7
|
createClientConfig
|
|
@@ -5927,6 +5927,7 @@ function createVaultEmbeddingCache(maxSize = DEFAULT_VAULT_CACHE_SIZE) {
|
|
|
5927
5927
|
}
|
|
5928
5928
|
|
|
5929
5929
|
// src/lib/memoryVault/searchTool.ts
|
|
5930
|
+
var DEFAULT_RERANK_TOP_N = 5;
|
|
5930
5931
|
var nowMs = () => typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
|
|
5931
5932
|
var warnedProgrammaticDecomposeIgnored = false;
|
|
5932
5933
|
function normalizeEventTimeKind(kind) {
|
|
@@ -6157,7 +6158,7 @@ async function rankFusedVaultMemoriesAsync(query, queryEmbedding, items, options
|
|
|
6157
6158
|
let tailSlice = [];
|
|
6158
6159
|
const itemById = new Map(items.map((i) => [i.id, i]));
|
|
6159
6160
|
if (options?.rerank) {
|
|
6160
|
-
const rerankTopN = options.rerankTopN ??
|
|
6161
|
+
const rerankTopN = options.rerankTopN ?? DEFAULT_RERANK_TOP_N;
|
|
6161
6162
|
const ceWeight = options.ceWeight ?? 0.1;
|
|
6162
6163
|
const headSlice = v2Ranked.slice(0, rerankTopN);
|
|
6163
6164
|
const ceStart = nowMs();
|
|
@@ -6203,9 +6204,12 @@ async function rankFusedVaultMemoriesAsync(query, queryEmbedding, items, options
|
|
|
6203
6204
|
}
|
|
6204
6205
|
if (sideLanesAsync.length > 0) {
|
|
6205
6206
|
const headIds = combined.map((r) => r.uniqueId);
|
|
6206
|
-
const
|
|
6207
|
-
const
|
|
6208
|
-
const
|
|
6207
|
+
const tailIds = tailSlice.map((r) => r.uniqueId);
|
|
6208
|
+
const rankedIds = tailIds.length > 0 ? [...headIds, ...tailIds] : headIds;
|
|
6209
|
+
const fused = rrfFuse([rankedIds, rankedIds, ...sideLanesAsync], options?.rrfK);
|
|
6210
|
+
const fusedHead = [...combined, ...tailSlice].map((r) => ({ ...r, similarity: fused.get(r.uniqueId) ?? r.similarity })).sort((a, b) => b.similarity - a.similarity);
|
|
6211
|
+
tailSlice = [];
|
|
6212
|
+
const seen = new Set(fusedHead.map((r) => r.uniqueId));
|
|
6209
6213
|
const itemById2 = new Map(items.map((i) => [i.id, i]));
|
|
6210
6214
|
for (const lane of sideLanesAsync) {
|
|
6211
6215
|
for (const id of lane) {
|
|
@@ -6230,7 +6234,7 @@ async function rankFusedVaultMemoriesAsync(query, queryEmbedding, items, options
|
|
|
6230
6234
|
const lambda = options.mmrLambda ?? 0.7;
|
|
6231
6235
|
const mmrTopN = options.mmrTopN ?? 20;
|
|
6232
6236
|
const itemById2 = new Map(items.map((i) => [i.id, i]));
|
|
6233
|
-
const mmrCandidates = combined.slice(0, mmrTopN).map((r) => ({
|
|
6237
|
+
const mmrCandidates = [...combined, ...tailSlice].slice(0, mmrTopN).map((r) => ({
|
|
6234
6238
|
id: r.uniqueId,
|
|
6235
6239
|
score: r.similarity,
|
|
6236
6240
|
embedding: itemById2.get(r.uniqueId)?.embedding ?? [],
|
|
@@ -6238,7 +6242,7 @@ async function rankFusedVaultMemoriesAsync(query, queryEmbedding, items, options
|
|
|
6238
6242
|
}));
|
|
6239
6243
|
const picked = applyMMR(mmrCandidates, limit, lambda);
|
|
6240
6244
|
const pickedIds = new Set(picked.map((p) => p.id));
|
|
6241
|
-
const resultMap = new Map(combined.map((r) => [r.uniqueId, r]));
|
|
6245
|
+
const resultMap = new Map([...combined, ...tailSlice].map((r) => [r.uniqueId, r]));
|
|
6242
6246
|
const pickedResults = picked.map((p) => {
|
|
6243
6247
|
const orig = resultMap.get(p.id);
|
|
6244
6248
|
return {
|
|
@@ -6352,7 +6356,7 @@ async function rankComposite(originalQuery, originalQueryEmbedding, subQueries,
|
|
|
6352
6356
|
}
|
|
6353
6357
|
}
|
|
6354
6358
|
if (options?.rerank && combined.length > 0) {
|
|
6355
|
-
const rerankTopN = options.rerankTopN ??
|
|
6359
|
+
const rerankTopN = options.rerankTopN ?? DEFAULT_RERANK_TOP_N;
|
|
6356
6360
|
const ceWeight = options.ceWeight ?? 0.1;
|
|
6357
6361
|
const headSlice = combined.slice(0, rerankTopN);
|
|
6358
6362
|
const tailSlice = combined.slice(rerankTopN);
|
|
@@ -7192,7 +7196,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
|
|
|
7192
7196
|
subQueries = decomp.subQueries;
|
|
7193
7197
|
}
|
|
7194
7198
|
}
|
|
7195
|
-
const { recall: recall2 } = await import("./recall-
|
|
7199
|
+
const { recall: recall2 } = await import("./recall-D6ODL36R.mjs");
|
|
7196
7200
|
let recallDegraded = [];
|
|
7197
7201
|
const result = await recall2(
|
|
7198
7202
|
query,
|
|
@@ -172,7 +172,16 @@ async function callPortalJsonCompletion(req) {
|
|
|
172
172
|
...reinforce && { reinforceJsonContract: true }
|
|
173
173
|
} : reinforce ? { ...req, reinforceJsonContract: true } : req;
|
|
174
174
|
const outcome = await attemptPortalJson(attemptReq, endpoint);
|
|
175
|
-
if (outcome.kind === "ok")
|
|
175
|
+
if (outcome.kind === "ok") {
|
|
176
|
+
req.onAttempt?.({ attempt, ok: true });
|
|
177
|
+
return outcome.value;
|
|
178
|
+
}
|
|
179
|
+
req.onAttempt?.({
|
|
180
|
+
attempt,
|
|
181
|
+
ok: false,
|
|
182
|
+
reason: outcome.code,
|
|
183
|
+
...outcome.httpStatus !== void 0 && { httpStatus: outcome.httpStatus }
|
|
184
|
+
});
|
|
176
185
|
lastFailure = {
|
|
177
186
|
reason: outcome.code,
|
|
178
187
|
...outcome.httpStatus !== void 0 && { httpStatus: outcome.httpStatus },
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
notifyConsolidationFallback,
|
|
3
3
|
resolvePiiRedactor
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-AVYB5IXC.mjs";
|
|
5
5
|
import {
|
|
6
6
|
callPortalJsonCompletion
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-WUG6GTHO.mjs";
|
|
8
8
|
import "./chunk-GYKJOWEO.mjs";
|
|
9
9
|
|
|
10
10
|
// src/lib/memory/consolidate.ts
|