@snoai/memory 1.2.12 → 1.2.14
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/README.md +1 -1
- package/dist/{access-tracker-BOPHSJjf.d.ts → access-tracker-DT04huAG.d.ts} +4 -4
- package/dist/{adapter-lyb6RaQE.d.ts → adapter-BMx-VcJy.d.ts} +2 -2
- package/dist/{agent-llm-port-DY2290EK.d.ts → agent-llm-port-BlFrD2ro.d.ts} +5 -0
- package/dist/{atomic-memory-extraction-B5FW2HhR.js → atomic-memory-extraction-De86y7O-.js} +4 -4
- package/dist/{atomic-memory-extraction-B_XpkhMd.d.ts → atomic-memory-extraction-_OEsSJbC.d.ts} +4 -4
- package/dist/{b-profile-section-dictionary-provider-BK5NBs-y.d.ts → b-profile-section-dictionary-provider-DTE4uWyh.d.ts} +1 -1
- package/dist/{capture-policy-detector-BvVGmxxX.d.ts → capture-policy-detector-B8sqRTlB.d.ts} +1 -1
- package/dist/client.d.ts +2 -2
- package/dist/client.js +5 -4
- package/dist/{config-BWHnCb_Z.js → config-C1X5rsAx.js} +44 -53
- package/dist/{daily-log-generator-CH_KuWHs.js → daily-log-generator-DEsiCs7o.js} +1 -1
- package/dist/{derived-suppression-cache-Ckwjey7I.d.ts → derived-suppression-cache-Cha_e2Cr.d.ts} +1 -1
- package/dist/diagnostic-encoder.js +1 -1
- package/dist/{index-Pb9LrHgL.d.ts → index-8CfO_-6T.d.ts} +7 -16
- package/dist/{index-CsPUNkcm.d.ts → index-C8tTzfrH.d.ts} +5 -4
- package/dist/index.d.ts +12 -12
- package/dist/index.js +13 -11
- package/dist/internal/config/index.d.ts +2 -2
- package/dist/internal/config/index.js +7 -16
- package/dist/internal/config/plugin-config-schema.d.ts +1 -1
- package/dist/internal/config/plugin-config-schema.js +1 -1
- package/dist/internal/config/product-mode.d.ts +1 -1
- package/dist/internal/config/settings.d.ts +1 -1
- package/dist/internal/config/settings.js +32 -23
- package/dist/internal/config/skin-defaults.d.ts +1 -1
- package/dist/internal/contract/profile.d.ts +1 -1
- package/dist/internal/contract/routes.d.ts +2 -2
- package/dist/internal/contract/routes.js +2 -1
- package/dist/internal/engine/bindings/memory-cli-shared.d.ts +4 -4
- package/dist/internal/engine/bindings/memory-forget-tool.js +1 -1
- package/dist/internal/engine/bindings/memory-list-tool.js +1 -1
- package/dist/internal/engine/bindings/memory-recall-tool.js +2 -2
- package/dist/internal/engine/bindings/memory-reflection-resolve-tool.js +1 -1
- package/dist/internal/engine/bindings/memory-stats-tool.js +1 -1
- package/dist/internal/engine/bindings/memory-store-tool.js +3 -3
- package/dist/internal/engine/bindings/memory-tool-access.d.ts +1 -1
- package/dist/internal/engine/bindings/memory-tool-access.js +1 -1
- package/dist/internal/engine/bindings/memory-tool-results.d.ts +1 -1
- package/dist/internal/engine/bindings/memory-tool-results.js +1 -1
- package/dist/internal/engine/bindings/memory-tool-schemas.d.ts +5 -5
- package/dist/internal/engine/bindings/memory-tool-schemas.js +1 -1
- package/dist/internal/engine/bindings/memory-update-tool.js +2 -2
- package/dist/internal/engine/bindings/sno-station-mem-ambient-learning-hook.d.ts +4 -4
- package/dist/internal/engine/bindings/sno-station-mem-ambient-learning-hook.js +4 -4
- package/dist/internal/engine/bindings/sno-station-mem-auto-recall-hook.d.ts +4 -4
- package/dist/internal/engine/bindings/sno-station-mem-auto-recall-hook.js +4 -2
- package/dist/internal/engine/bindings/sno-station-mem-insight-distill-factory.d.ts +6 -6
- package/dist/internal/engine/bindings/sno-station-mem-insight-distill-factory.js +2 -2
- package/dist/internal/engine/bindings/sno-station-mem-message-transcript.js +2 -2
- package/dist/internal/engine/bindings/sno-station-mem-reset-hook.d.ts +3 -3
- package/dist/internal/engine/bindings/sno-station-mem-runtime-mode.d.ts +1 -1
- package/dist/internal/engine/extraction/atomic-memory-extraction.d.ts +1 -1
- package/dist/internal/engine/extraction/atomic-memory-extraction.js +1 -1
- package/dist/internal/engine/extraction/b-profile-section-dictionary-provider.d.ts +1 -1
- package/dist/internal/engine/extraction/b-profile-section-rekey.d.ts +5 -5
- package/dist/internal/engine/extraction/capture-policy-detector.d.ts +1 -1
- package/dist/internal/engine/extraction/memory-metadata-codec.d.ts +2 -2
- package/dist/internal/engine/extraction/memory-temporality-classifier.d.ts +1 -1
- package/dist/internal/engine/extraction/memory-temporality-classifier.js +1 -1
- package/dist/internal/engine/observability/adapter.d.ts +1 -1
- package/dist/internal/engine/observability/memory-snapshot.d.ts +1 -1
- package/dist/internal/engine/observability/observable-embedder.d.ts +1 -1
- package/dist/internal/engine/observability/observable-llm-client.d.ts +1 -1
- package/dist/internal/engine/observability/observable-memory-store.d.ts +1 -1
- package/dist/internal/engine/observability/observable-memory-store.js +1 -1
- package/dist/internal/engine/observability/observable-retriever.d.ts +1 -1
- package/dist/internal/engine/observability/observable-retriever.js +1 -1
- package/dist/internal/engine/observability/runtime-diagnostics.d.ts +1 -1
- package/dist/internal/engine/observability/runtime-diagnostics.js +1 -1
- package/dist/internal/engine/operations/learning-file-maintenance.js +1 -1
- package/dist/internal/engine/operations/memory-tier-promoter.d.ts +1 -1
- package/dist/internal/engine/operations/runtime-audit-log.d.ts +2 -2
- package/dist/internal/engine/provider/provider-registration.d.ts +4 -4
- package/dist/internal/engine/provider/provider-row-renderer.d.ts +1 -1
- package/dist/internal/engine/reflection/daily-log-generator.js +1 -1
- package/dist/internal/engine/reflection/reflection-command-hooks.d.ts +1 -1
- package/dist/internal/engine/reflection/reflection-command-hooks.js +1 -1
- package/dist/internal/engine/reflection/reflection-deps.d.ts +1 -1
- package/dist/internal/engine/reflection/reflection-embedded-generator.d.ts +1 -1
- package/dist/internal/engine/reflection/reflection-embedded-generator.js +1 -1
- package/dist/internal/engine/reflection/reflection-injection-hooks.d.ts +1 -1
- package/dist/internal/engine/reflection/reflection-injection-hooks.js +1 -1
- package/dist/internal/engine/reflection/reflection-lifecycle-hooks.d.ts +1 -1
- package/dist/internal/engine/reflection/reflection-lifecycle-hooks.js +1 -1
- package/dist/internal/engine/reflection/strategy-hook-runner.d.ts +3 -3
- package/dist/internal/engine/reflection/strategy-hook-runner.js +2 -2
- package/dist/internal/engine/retrieval/access-tracker.d.ts +1 -1
- package/dist/internal/engine/retrieval/retriever.d.ts +2 -2
- package/dist/internal/engine/retrieval/retriever.js +1 -1
- package/dist/internal/engine/shared/memory-kind-policy.d.ts +1 -1
- package/dist/internal/engine/shared/paths.d.ts +2 -2
- package/dist/internal/engine/shared/types.d.ts +2 -2
- package/dist/internal/engine/shared/types.js +1 -1
- package/dist/internal/engine/telemetry/observe-ledger.d.ts +1 -1
- package/dist/internal/model/agent-llm-port.d.ts +1 -1
- package/dist/internal/model/llm-client.d.ts +2 -2
- package/dist/internal/model/llm-client.js +1 -1
- package/dist/internal/model/llm-mode-routing.d.ts +1 -1
- package/dist/internal/store/maintenance.d.ts +2 -2
- package/dist/internal/store/maintenance.js +3 -3
- package/dist/internal/store/sqlite-runtime.js +1 -1
- package/dist/internal/store/store.d.ts +2 -2
- package/dist/internal/store/store.js +1 -1
- package/dist/{llm-client-BTaUVmDe.d.ts → llm-client-BoClMktv.d.ts} +1 -1
- package/dist/{llm-client-DPBhPtmQ.js → llm-client-DDdUjYWS.js} +28 -10
- package/dist/{log-site-catalog.generated-B4LkDXe0.js → log-site-catalog.generated-DGia_6ZR.js} +86 -79
- package/dist/log-site-catalog.json +1 -1
- package/dist/{memory-kind-policy-ClQEXeOL.d.ts → memory-kind-policy-C7p4o8ru.d.ts} +1 -1
- package/dist/{memory-metadata-codec-wVAuoKrG.d.ts → memory-metadata-codec-CFY8YtXf.d.ts} +1 -1
- package/dist/{memory-runtime-D6cAHd34.js → memory-runtime-CCPRiAk9.js} +118 -89
- package/dist/{memory-snapshot-uTdxJnIh.d.ts → memory-snapshot-DADY3InD.d.ts} +2 -2
- package/dist/{memory-store-base-Bk2dOKED.d.ts → memory-store-base-D0bLwzyF.d.ts} +3 -3
- package/dist/{memory-temporality-classifier-Bm4-tqB5.js → memory-temporality-classifier-BwBKEQbL.js} +1 -1
- package/dist/{memory-temporality-classifier-CcxfHYoT.d.ts → memory-temporality-classifier-DL14kjtv.d.ts} +1 -1
- package/dist/{memory-tier-promoter-MkZPQ8u1.d.ts → memory-tier-promoter-Cf1OdoZK.d.ts} +1 -1
- package/dist/memory-tool-dependencies-Bxdpvs3Z.d.ts +14 -0
- package/dist/{memory-tool-dependencies-R_yWuFEg.js → memory-tool-dependencies-aAr7Pkuj.js} +1 -1
- package/dist/{observable-embedder-CGr3Zejf.d.ts → observable-embedder-CPyX9y7c.d.ts} +1 -1
- package/dist/{observable-llm-client-CXUA7Gi3.d.ts → observable-llm-client-C8ndPJck.d.ts} +3 -3
- package/dist/{observable-memory-store-BwwKcUzf.d.ts → observable-memory-store-DhOfgjkU.d.ts} +4 -4
- package/dist/{observable-retriever-bJbG9WtJ.d.ts → observable-retriever-CUlmCFy5.d.ts} +5 -5
- package/dist/{operation-cancellation-CTKWwNHk.js → operation-cancellation-QcwC4mDX.js} +7 -2
- package/dist/paths-DnNN0G1t.d.ts +1 -0
- package/dist/{plugin-config-schema-BrhMvnXJ.d.ts → plugin-config-schema-BPg-ppSt.d.ts} +2 -8
- package/dist/{plugin-config-schema-Di-uKTP0.js → plugin-config-schema-D9riSXDg.js} +3 -19
- package/dist/{profile-CF5oDjR7.d.ts → profile-BksZRjJ8.d.ts} +1 -1
- package/dist/{profile-section-writer-Cu3ND3j7.js → profile-section-writer-Dd4FKpt5.js} +2 -2
- package/dist/{reflection-command-hooks-vKpljnqv.js → reflection-command-hooks-B2P4zDr6.js} +5 -5
- package/dist/{reflection-command-hooks-CM2mWb69.d.ts → reflection-command-hooks-mCOmD8b6.d.ts} +4 -4
- package/dist/{reflection-deps-B5I0nYZS.d.ts → reflection-deps-BYkAaKxD.d.ts} +3 -3
- package/dist/{reflection-embedded-generator-CwTXvERI.js → reflection-embedded-generator-DV-NkeU-.js} +1 -1
- package/dist/{reflection-embedded-generator-CogQIBcG.d.ts → reflection-embedded-generator-ve1PhgUY.d.ts} +4 -4
- package/dist/{reflection-injection-hooks-BnbfZqpj.d.ts → reflection-injection-hooks-CphBCA9F.d.ts} +4 -4
- package/dist/{reflection-lifecycle-hooks-DMDhtidj.d.ts → reflection-lifecycle-hooks-CFGYh_8m.d.ts} +3 -3
- package/dist/{rem-batch-executor-Cn-MBe4m.js → rem-batch-executor-TSYG7oVi.js} +1 -1
- package/dist/{rem-consumer-retrieval-CDMSCJYI.js → rem-consumer-retrieval-BhS1ivcd.js} +1 -0
- package/dist/{rem-trigger-B_S0CBa7.js → rem-trigger-i_E8I9lv.js} +139 -158
- package/dist/{retriever-DyxY59Lg.d.ts → retriever-6ybsoVuY.d.ts} +20 -25
- package/dist/{retriever-Bzz6H8Mn.js → retriever-Dnjl_FHu.js} +112 -155
- package/dist/{runtime-audit-log-DdhLlTxi.d.ts → runtime-audit-log-DWpWmCx5.d.ts} +1 -1
- package/dist/{server-C2XTjGFr.js → server-DsaVeSaM.js} +7 -6
- package/dist/sidecar/main.js +2 -2
- package/dist/sno-station-mem-runtime-dependencies-DtKDYdsh.d.ts +31 -0
- package/dist/{sno-station-mem-runtime-dependencies-BaaXGrZb.js → sno-station-mem-runtime-dependencies-zzcjHD_N.js} +7 -7
- package/dist/{store-BzWYcvpF.js → store-COwW7mIh.js} +2 -2
- package/dist/{store-BDIAl2cc.d.ts → store-HyzTUvwj.d.ts} +1 -1
- package/dist/{strategy-hook-runner-DT9emgCZ.d.ts → strategy-hook-runner-B_m1L5CB.d.ts} +7 -7
- package/dist/{strategy-hook-runner-GaJKb3O8.js → strategy-hook-runner-CALbWcys.js} +1 -1
- package/dist/{types-Ae3a8562.d.ts → types-Dm_XhSne.d.ts} +1 -1
- package/package.json +1 -1
- package/settings.default.json +1 -5
- package/dist/memory-tool-dependencies-CWnD5mia.d.ts +0 -14
- package/dist/paths-DmmPxD_v.d.ts +0 -1
- package/dist/sno-station-mem-runtime-dependencies-BZjUo6Jr.d.ts +0 -31
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as FIXED_IDX_MEMORY_ACTIVE_TASK_CURRENT_REVISION, A as modelCallDestination, At as FIXED_MEMORY_PROFILE_RECOVERY_ENTRIES, B as FIXED_EXTERNAL_VALUE_49, C as getSnoStationMemStateDir, Cn as CHUNK_OVERLAP_TOKENS, Cr as
|
|
1
|
+
import { $ as FIXED_IDX_MEMORY_ACTIVE_TASK_CURRENT_REVISION, $n as MAX_CHUNK_FETCH_LIMIT, A as modelCallDestination, At as FIXED_MEMORY_PROFILE_RECOVERY_ENTRIES, B as FIXED_EXTERNAL_VALUE_49, C as getSnoStationMemStateDir, Cn as CHUNK_OVERLAP_TOKENS, Cr as LOCAL_EMBEDDING_CACHE_DIR_DEFAULT, Ct as FIXED_MEMORY_CHUNKS_MEM_FACET_IDX, D as settingsToPluginConfig, Dn as DEFAULT_IMPORTANCE, Dr as ensureModelDownloaded, Dt as FIXED_MEMORY_MEMORIES_FACT_ID_INSERT_GUARD, En as DEFAULT_BM25_WEIGHT, Er as LocalEmbedProvider, Et as FIXED_MEMORY_MEMORIES, Fn as EMBEDDER_DIM, Fr as REM_SIDECAR_TOKEN_HEADER, G as FIXED_EXTERNAL_VALUE_55, H as FIXED_EXTERNAL_VALUE_52, Hn as HEAD_EXTRACT_OVERLAP_DROP_RATIO, In as EMBEDDER_MODEL_DEFAULT, It as FIXED_MEMORY_SNO_EXTRACT_CHAT, J as FIXED_EXTERNAL_VALUE_58, Jn as LIGHTWEIGHT_FUSION_WEIGHT, K as FIXED_EXTERNAL_VALUE_56, Kn as INTRA_MEMORY_COSINE_THRESHOLD, Kt as FIXED_PROTOCOL_VALUE_69, Ln as EMBEDDER_PROVIDER_DEFAULT, Mn as DEFAULT_RERANK_TIMEOUT_MS, Mt as FIXED_MEMORY_PROVIDER_PROJECT_AGENTS, Nt as FIXED_MEMORY_PROVIDER_PROJECT_MAPPINGS, O as MODEL_CALLS, On as DEFAULT_RECALL_LIFECYCLE, Ot as FIXED_MEMORY_MEMORIES_FACT_ID_UPDATE_GUARD, P as observeAgentId, Pn as DEFAULT_VECTOR_WEIGHT, Q as FIXED_IDX_MEMORY, Rn as EVAL_QA_TRACES_FILENAME, Rt as FIXED_MEMORY_TASK_LIFECYCLE_COMMANDS, Sn as CHUNK_MIN_TOKENS, Sr as CachedEmbeddingProvider, St as FIXED_MEMORY_CHUNKS_MEMORY_ID_IDX, T as readSettings, Tn as CHUNK_TOKENIZER_MODE, Tt as FIXED_MEMORY_EXTRACTION_TIMESTAMPS, U as FIXED_EXTERNAL_VALUE_53, Un as HEAD_EXTRACT_TOKEN_BUDGET, V as FIXED_EXTERNAL_VALUE_51, Vn as HEAD_EXTRACT_MIN_CONTENT_TOKENS, W as FIXED_EXTERNAL_VALUE_54, Wn as IMPORTANCE_WEIGHT_BASE, X as FIXED_EXTERNAL_VALUE_8, Y as FIXED_EXTERNAL_VALUE_62, Yn as LIGHTWEIGHT_RERANK_PENALTY, Z as FIXED_EXTERNAL_VALUE_9, _t as FIXED_MEMORY_CHUNKS, a as REM_MODEL_OUTPUT_TOKEN_CAP, an as PERSISTED_PROVIDER_SYSTEM, ar as MULTI_HIT_BONUS_CAP, at as FIXED_IDX_MEMORY_MEMORIES_LANE_PROJECT, bn as CHUNKING_VERSION$1, br as experimentMmrDisabled, bt as FIXED_MEMORY_CHUNKS_AU, cn as SUPPORTED_LOCALES, cr as RECENCY_WEIGHT, ct as FIXED_IDX_MEMORY_MEMORIES_PROJECT_FACT_KEY_ACTIVE, d as getRemDiscoveryPath, dn as ADJACENCY_BONUS_PER_PAIR, dr as RERANK_BLEND_CROSS, dt as FIXED_MEMORY_ACTIVE_TASK_EVIDENCE, en as FIXED_VEC_MEMORY, er as MAX_LIST_LIMIT, et as FIXED_IDX_MEMORY_ACTIVE_TASK_EVIDENCE_INSTANCE, fr as RERANK_BLEND_VECTOR, ft as FIXED_MEMORY_ACTIVE_TASK_INSTANCES, g as readRemOperationalConfig, gt as FIXED_MEMORY_ACTIVE_TASK_TRANSITIONS, hr as TIME_DECAY_FLOOR, ht as FIXED_MEMORY_ACTIVE_TASK_REVISIONS, in as PERSISTED_CONTENT_HASH_V3, ir as MMR_LAMBDA, it as FIXED_IDX_MEMORY_MEMORIES_FACT_ID, jt as FIXED_MEMORY_PROVIDER_AGENT_MAPPINGS, k as MODEL_CALL_WORKLOAD, kt as FIXED_MEMORY_MIGRATION_MARKERS, lt as FIXED_IDX_MEMORY_MEMORIES_PROJECT_TIMESTAMP, mt as FIXED_MEMORY_ACTIVE_TASK_MIGRATION_MANIFESTS, nn as PERSISTED_CANDIDATE_HASH_V1, nt as FIXED_IDX_MEMORY_MEMORIES_CATEGORY, o as REM_RUN_PATH, or as MULTI_HIT_BONUS_PER_HIT, ot as FIXED_IDX_MEMORY_MEMORIES_PROJECT, pr as RETRIEVAL_STORAGE_CHUNK_PROFILE, pt as FIXED_MEMORY_ACTIVE_TASK_MIGRATION_EVIDENCE, q as FIXED_EXTERNAL_VALUE_57, qn as LIGHTWEIGHT_COSINE_WEIGHT, qt as FIXED_PROTOCOL_VALUE_73, r as REM_CORRELATION_ID_HEADER, rn as PERSISTED_CONTENT_HASH_V1, rt as FIXED_IDX_MEMORY_MEMORIES_CONTENT_HASH, s as REM_SIDECAR_HOST, sn as llmRoutingConfigSchema, st as FIXED_IDX_MEMORY_MEMORIES_PROJECT_CONTENT_HASH, tn as FIXED_VEC_MEMORY_CHUNKS, tt as FIXED_IDX_MEMORY_ACTIVE_TASK_INSTANCES_PROJECTION, un as ADJACENCY_BONUS_CAP, ut as FIXED_MEMORY, vn as BONUS_TOTAL_INVARIANT, vt as FIXED_MEMORY_CHUNKS_AD, wn as CHUNK_TARGET_TOKENS, wr as LOCAL_EMBEDDING_MODEL, wt as FIXED_MEMORY_CHUNKS_MEM_IDX, xn as CHUNK_MAX_TOKENS, xt as FIXED_MEMORY_CHUNKS_FTS, yn as CACHE_TTL_MS, yr as experimentCandidatePoolOverride, yt as FIXED_MEMORY_CHUNKS_AI, zt as FIXED_MEMORY_UNPLACED_CANDIDATES } from "./config-C1X5rsAx.js";
|
|
2
2
|
import { createLogger, createLogger as createLogger$1, currentLogContext, privateLogReference, withLogContext } from "@snoai/utils/logger";
|
|
3
3
|
import path, { dirname, join, resolve } from "node:path";
|
|
4
4
|
import { appendFileSync, closeSync, createReadStream, existsSync, fstatSync, fsyncSync, ftruncateSync, mkdirSync, openSync, readFileSync, readSync, realpathSync, renameSync, rmSync, statSync, writeFileSync, writeSync } from "node:fs";
|
|
@@ -171,10 +171,11 @@ async function forwardObserveLedgerUntilIdle(options) {
|
|
|
171
171
|
const operations = new AsyncLocalStorage();
|
|
172
172
|
const log$23 = createLogger("sno-station-mem:cancellation");
|
|
173
173
|
/** Carries cancellation through the existing nested extraction and reflection writers. */
|
|
174
|
-
async function withMemoryOperation(method, signal, run) {
|
|
174
|
+
async function withMemoryOperation(method, signal, run, deadlineMs) {
|
|
175
175
|
const operation = {
|
|
176
176
|
id: randomUUID(),
|
|
177
177
|
signal,
|
|
178
|
+
deadlineMs,
|
|
178
179
|
writes: 0,
|
|
179
180
|
transactionDepth: 0
|
|
180
181
|
};
|
|
@@ -201,6 +202,10 @@ async function withMemoryOperation(method, signal, run) {
|
|
|
201
202
|
function memoryOperationId() {
|
|
202
203
|
return operations.getStore()?.id;
|
|
203
204
|
}
|
|
205
|
+
/** The owning operation's absolute performance.now() deadline, shared by all extraction calls. */
|
|
206
|
+
function memoryOperationDeadline() {
|
|
207
|
+
return operations.getStore()?.deadlineMs;
|
|
208
|
+
}
|
|
204
209
|
function memoryOperationSignal(signal) {
|
|
205
210
|
const request = operations.getStore()?.signal;
|
|
206
211
|
if (!request) return signal;
|
|
@@ -7326,7 +7331,14 @@ function createLlmClient(config) {
|
|
|
7326
7331
|
});
|
|
7327
7332
|
let lastError = null;
|
|
7328
7333
|
let lastUsage = null;
|
|
7329
|
-
const resolveRequestTimeoutMs = (request) =>
|
|
7334
|
+
const resolveRequestTimeoutMs = (request) => {
|
|
7335
|
+
if (destinationFor(request) !== "sno-gpu" || !request.callId.startsWith("E") || MODEL_CALLS[request.callId].occasion !== "memoryExtract") return request.timeoutMs ?? config.timeoutMs ?? 3e4;
|
|
7336
|
+
const operationDeadline = memoryOperationDeadline();
|
|
7337
|
+
if (operationDeadline === void 0) return request.timeoutMs ?? 3e5;
|
|
7338
|
+
const remainingMs = operationDeadline - performance.now();
|
|
7339
|
+
if (remainingMs <= 0) throw new LlmClientTerminalError("timeout", "Memory operation deadline exhausted before extraction");
|
|
7340
|
+
return Math.min(request.timeoutMs ?? remainingMs, remainingMs);
|
|
7341
|
+
};
|
|
7330
7342
|
const destinationFor = (request) => {
|
|
7331
7343
|
if (!config.routing) return "host";
|
|
7332
7344
|
const route = resolveLlmRoute({
|
|
@@ -7396,20 +7408,23 @@ function createLlmClient(config) {
|
|
|
7396
7408
|
destination,
|
|
7397
7409
|
transport
|
|
7398
7410
|
});
|
|
7411
|
+
const hostTimeoutMs = resolveRequestTimeoutMs(request);
|
|
7399
7412
|
const hostStarted = performance.now();
|
|
7400
7413
|
const hostInFlight = ++hostRequestsInFlight;
|
|
7401
7414
|
const result = await withLogContext({ attempt_id: randomUUID() }, async () => {
|
|
7402
7415
|
let outcome = "failed";
|
|
7416
|
+
let hostReport = {};
|
|
7403
7417
|
try {
|
|
7404
7418
|
const completion = await agentPort.complete({
|
|
7405
7419
|
system: systemContent,
|
|
7406
7420
|
prompt,
|
|
7407
7421
|
maxTokens: request.maxTokens ?? 4096,
|
|
7408
7422
|
...request.enableThinking !== void 0 ? { enableThinking: request.enableThinking } : {},
|
|
7409
|
-
timeoutMs:
|
|
7423
|
+
timeoutMs: hostTimeoutMs,
|
|
7410
7424
|
...request.signal ? { signal: request.signal } : {}
|
|
7411
7425
|
});
|
|
7412
7426
|
outcome = completion.kind;
|
|
7427
|
+
if (completion.kind === "ok") hostReport = completion;
|
|
7413
7428
|
return completion;
|
|
7414
7429
|
} finally {
|
|
7415
7430
|
hostRequestsInFlight -= 1;
|
|
@@ -7421,27 +7436,32 @@ function createLlmClient(config) {
|
|
|
7421
7436
|
duration_ms: performance.now() - hostStarted,
|
|
7422
7437
|
in_flight_at_dispatch: hostInFlight,
|
|
7423
7438
|
requested_model: "unavailable",
|
|
7424
|
-
returned_model: "unavailable",
|
|
7425
|
-
usage:
|
|
7439
|
+
returned_model: hostReport.model ?? "unavailable",
|
|
7440
|
+
usage: hostReport.usage ? {
|
|
7441
|
+
source: "provider_reported",
|
|
7442
|
+
inputTokens: hostReport.usage.inputTokens,
|
|
7443
|
+
outputTokens: hostReport.usage.outputTokens,
|
|
7444
|
+
totalTokens: hostReport.usage.inputTokens + hostReport.usage.outputTokens
|
|
7445
|
+
} : { source: "unavailable" },
|
|
7426
7446
|
prompt_template_hash: request.promptTemplateHash ?? "unavailable",
|
|
7427
7447
|
extraction_skill_hash: request.extractionSkillHash ?? "unavailable",
|
|
7428
7448
|
prompt_template_unavailable_reason: request.promptTemplateHash ? void 0 : "caller_does_not_provide_template_identity",
|
|
7429
7449
|
config_hash: createHash("sha256").update(JSON.stringify({
|
|
7430
7450
|
transport,
|
|
7431
7451
|
maxTokens: request.maxTokens ?? 4096,
|
|
7432
|
-
timeoutMs:
|
|
7452
|
+
timeoutMs: hostTimeoutMs
|
|
7433
7453
|
})).digest("hex"),
|
|
7434
7454
|
output_cap: "unavailable",
|
|
7435
7455
|
passed_output_cap: request.maxTokens ?? 4096,
|
|
7436
7456
|
output_cap_reason: "host_may_strip_requested_cap",
|
|
7437
|
-
timeout_ms:
|
|
7457
|
+
timeout_ms: hostTimeoutMs,
|
|
7438
7458
|
sampling: { source: "unknown" },
|
|
7439
7459
|
finish_reason: "unavailable",
|
|
7440
7460
|
route: "agent-host-seam",
|
|
7441
7461
|
dispatch_to_headers_ms: "unavailable",
|
|
7442
7462
|
headers_to_body_ms: "unavailable",
|
|
7443
7463
|
first_token_ms: "unavailable",
|
|
7444
|
-
provider_unavailable_reason: "host_port_does_not_report_provider_fields"
|
|
7464
|
+
...hostReport.usage || hostReport.model ? {} : { provider_unavailable_reason: "host_port_does_not_report_provider_fields" }
|
|
7445
7465
|
}, {
|
|
7446
7466
|
event_name: "llm.request.completed",
|
|
7447
7467
|
file: "packages/memory/src/model/llm-client.ts",
|
|
@@ -7759,7 +7779,8 @@ function createLlmClient(config) {
|
|
|
7759
7779
|
signal: memoryOperationSignal(input.signal)
|
|
7760
7780
|
});
|
|
7761
7781
|
checkMemoryOperation();
|
|
7762
|
-
|
|
7782
|
+
request.timeoutMs = resolveRequestTimeoutMs(request);
|
|
7783
|
+
const deadlineMs = performance.now() + request.timeoutMs;
|
|
7763
7784
|
try {
|
|
7764
7785
|
let content = await requestContentWithHostFallback(state, request, JSON_SYSTEM_CONTENT, deadlineMs);
|
|
7765
7786
|
if (content === null) return null;
|
|
@@ -7832,7 +7853,8 @@ function createLlmClient(config) {
|
|
|
7832
7853
|
signal: memoryOperationSignal(input.signal)
|
|
7833
7854
|
});
|
|
7834
7855
|
checkMemoryOperation();
|
|
7835
|
-
|
|
7856
|
+
request.timeoutMs = resolveRequestTimeoutMs(request);
|
|
7857
|
+
const deadlineMs = performance.now() + request.timeoutMs;
|
|
7836
7858
|
try {
|
|
7837
7859
|
const text = (await requestContentWithHostFallback(state, request, textSystemContent(request), deadlineMs))?.raw.trim();
|
|
7838
7860
|
return text && text.length > 0 ? text : null;
|
|
@@ -27179,9 +27201,7 @@ const DEFAULT_RETRIEVAL_CONFIG = {
|
|
|
27179
27201
|
recencyWeight: RECENCY_WEIGHT,
|
|
27180
27202
|
temporalExpiry: false,
|
|
27181
27203
|
temporalDecay: true,
|
|
27182
|
-
rerankModel: DEFAULT_RERANK_MODEL,
|
|
27183
27204
|
rerankTimeoutMs: DEFAULT_RERANK_TIMEOUT_MS,
|
|
27184
|
-
rerankProvider: "voyage",
|
|
27185
27205
|
lengthNormAnchor: 0,
|
|
27186
27206
|
hardMinScore: 0,
|
|
27187
27207
|
timeDecayHalfLifeDays: 60,
|
|
@@ -27478,13 +27498,15 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
27478
27498
|
site_id: "retrieval.retriever-search-modes.precisionRecall.aaf0b2eb17"
|
|
27479
27499
|
});
|
|
27480
27500
|
trace?.startStage("rerank", fused.map((r) => r.entry.id));
|
|
27481
|
-
const rerankOutcome = await this.rerank(context.query, fused, queryVector
|
|
27501
|
+
const rerankOutcome = await this.rerank(context.query, fused, queryVector, {
|
|
27502
|
+
signal: context.signal,
|
|
27503
|
+
deadlineAt: context.rerankDeadlineAt
|
|
27504
|
+
});
|
|
27482
27505
|
fused = rerankOutcome.candidates;
|
|
27483
27506
|
this.throwIfAborted(context);
|
|
27484
27507
|
const rerankStageMetadata = rerankOutcome.fallback ? {
|
|
27485
27508
|
...rerankOutcome.stats,
|
|
27486
|
-
rerankFallbackReason: rerankOutcome.fallback.reason
|
|
27487
|
-
rerankFallbackProvider: rerankOutcome.fallback.provider
|
|
27509
|
+
rerankFallbackReason: rerankOutcome.fallback.reason
|
|
27488
27510
|
} : rerankOutcome.stats;
|
|
27489
27511
|
trace?.endStage(fused.map((r) => r.entry.id), fused.map((r) => r.score), rerankStageMetadata);
|
|
27490
27512
|
fused = this.applyScoringPipeline(fused, trace, context.limit);
|
|
@@ -27556,95 +27578,31 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
27556
27578
|
});
|
|
27557
27579
|
//#endregion
|
|
27558
27580
|
//#region src/engine/retrieval/retrieval-rerank-provider.ts
|
|
27559
|
-
|
|
27560
|
-
|
|
27561
|
-
|
|
27562
|
-
|
|
27563
|
-
|
|
27564
|
-
|
|
27565
|
-
|
|
27566
|
-
|
|
27567
|
-
|
|
27568
|
-
|
|
27569
|
-
|
|
27570
|
-
|
|
27571
|
-
}
|
|
27572
|
-
|
|
27573
|
-
switch (provider) {
|
|
27574
|
-
case "tei": return {
|
|
27575
|
-
headers: {
|
|
27576
|
-
"Content-Type": "application/json",
|
|
27577
|
-
Authorization: `Bearer ${apiKey}`
|
|
27578
|
-
},
|
|
27579
|
-
body: {
|
|
27580
|
-
query,
|
|
27581
|
-
texts: candidates,
|
|
27582
|
-
raw_scores: true
|
|
27583
|
-
}
|
|
27584
|
-
};
|
|
27585
|
-
case "dashscope": return {
|
|
27586
|
-
headers: {
|
|
27587
|
-
"Content-Type": "application/json",
|
|
27588
|
-
Authorization: `Bearer ${apiKey}`
|
|
27589
|
-
},
|
|
27590
|
-
body: {
|
|
27591
|
-
model,
|
|
27592
|
-
input: {
|
|
27593
|
-
query,
|
|
27594
|
-
documents: candidates
|
|
27595
|
-
}
|
|
27596
|
-
}
|
|
27597
|
-
};
|
|
27598
|
-
case "pinecone": return {
|
|
27599
|
-
headers: {
|
|
27600
|
-
"Content-Type": "application/json",
|
|
27601
|
-
"Api-Key": apiKey,
|
|
27602
|
-
"X-Pinecone-API-Version": "2024-10"
|
|
27603
|
-
},
|
|
27604
|
-
body: {
|
|
27605
|
-
model,
|
|
27606
|
-
query,
|
|
27607
|
-
documents: candidates.map((text) => ({ text })),
|
|
27608
|
-
top_n: topN,
|
|
27609
|
-
rank_fields: ["text"]
|
|
27610
|
-
}
|
|
27611
|
-
};
|
|
27612
|
-
case "voyage": return {
|
|
27613
|
-
headers: {
|
|
27614
|
-
"Content-Type": "application/json",
|
|
27615
|
-
Authorization: `Bearer ${apiKey}`
|
|
27616
|
-
},
|
|
27617
|
-
body: {
|
|
27618
|
-
model,
|
|
27619
|
-
query,
|
|
27620
|
-
documents: candidates,
|
|
27621
|
-
top_k: topN
|
|
27622
|
-
}
|
|
27623
|
-
};
|
|
27624
|
-
default: return {
|
|
27625
|
-
headers: {
|
|
27626
|
-
"Content-Type": "application/json",
|
|
27627
|
-
Authorization: `Bearer ${apiKey}`
|
|
27628
|
-
},
|
|
27629
|
-
body: {
|
|
27630
|
-
model,
|
|
27631
|
-
query,
|
|
27632
|
-
documents: candidates,
|
|
27633
|
-
top_n: topN
|
|
27634
|
-
}
|
|
27635
|
-
};
|
|
27636
|
-
}
|
|
27581
|
+
function buildRerankRequest(apiKey, query, candidates) {
|
|
27582
|
+
return {
|
|
27583
|
+
headers: {
|
|
27584
|
+
"Content-Type": "application/json",
|
|
27585
|
+
Authorization: `Bearer ${apiKey}`,
|
|
27586
|
+
"X-Sno-Source": "sno-station",
|
|
27587
|
+
"X-Sno-Workload": "station-rerank"
|
|
27588
|
+
},
|
|
27589
|
+
body: {
|
|
27590
|
+
query,
|
|
27591
|
+
texts: candidates,
|
|
27592
|
+
raw_scores: true
|
|
27593
|
+
}
|
|
27594
|
+
};
|
|
27637
27595
|
}
|
|
27638
|
-
|
|
27639
|
-
|
|
27640
|
-
const parseItems = (items
|
|
27596
|
+
/** Sno's reranker answers a list of `{index, score}`, bare or under `results` / `data`. */
|
|
27597
|
+
function parseRerankResponse(data) {
|
|
27598
|
+
const parseItems = (items) => {
|
|
27641
27599
|
if (!Array.isArray(items)) return void 0;
|
|
27642
27600
|
const parsed = [];
|
|
27643
27601
|
for (const raw of items) {
|
|
27644
27602
|
const index = typeof raw?.index === "number" ? raw.index : Number(raw?.index);
|
|
27645
27603
|
if (!Number.isFinite(index)) continue;
|
|
27646
27604
|
let score;
|
|
27647
|
-
for (const key of
|
|
27605
|
+
for (const key of ["score", "relevance_score"]) {
|
|
27648
27606
|
const value = raw?.[key];
|
|
27649
27607
|
const n = typeof value === "number" ? value : Number(value);
|
|
27650
27608
|
if (Number.isFinite(n)) {
|
|
@@ -27661,17 +27619,7 @@ function parseRerankResponse(provider, data) {
|
|
|
27661
27619
|
return parsed.length > 0 ? parsed : void 0;
|
|
27662
27620
|
};
|
|
27663
27621
|
const objectData = data && typeof data === "object" && !Array.isArray(data) ? data : void 0;
|
|
27664
|
-
|
|
27665
|
-
case "tei": return parseItems(data, ["score", "relevance_score"]) ?? parseItems(objectData?.results, ["score", "relevance_score"]) ?? parseItems(objectData?.data, ["score", "relevance_score"]);
|
|
27666
|
-
case "dashscope": {
|
|
27667
|
-
const output = objectData?.output;
|
|
27668
|
-
if (output) return parseItems(output.results, ["relevance_score", "score"]);
|
|
27669
|
-
return parseItems(objectData?.results, ["relevance_score", "score"]);
|
|
27670
|
-
}
|
|
27671
|
-
case "pinecone": return parseItems(objectData?.data, ["score", "relevance_score"]) ?? parseItems(objectData?.results, ["score", "relevance_score"]);
|
|
27672
|
-
case "voyage": return parseItems(objectData?.data, ["relevance_score", "score"]) ?? parseItems(objectData?.results, ["relevance_score", "score"]);
|
|
27673
|
-
default: return parseItems(objectData?.results, ["relevance_score", "score"]) ?? parseItems(objectData?.data, ["relevance_score", "score"]);
|
|
27674
|
-
}
|
|
27622
|
+
return parseItems(data) ?? parseItems(objectData?.results) ?? parseItems(objectData?.data);
|
|
27675
27623
|
}
|
|
27676
27624
|
//#endregion
|
|
27677
27625
|
//#region src/engine/retrieval/retriever-rerank.ts
|
|
@@ -27734,16 +27682,14 @@ function isTransientRerankError(error) {
|
|
|
27734
27682
|
if (isRerankTimeout(error)) return true;
|
|
27735
27683
|
return error instanceof TypeError && error.cause !== void 0;
|
|
27736
27684
|
}
|
|
27737
|
-
async function fetchRerankWithRetry(send) {
|
|
27685
|
+
async function fetchRerankWithRetry(send, stop) {
|
|
27738
27686
|
let lastError;
|
|
27739
27687
|
for (let attempt = 1; attempt <= RERANK_TRANSIENT_ATTEMPTS; attempt += 1) {
|
|
27740
27688
|
let retryDelayMs = RERANK_TRANSIENT_BACKOFF_MS * attempt;
|
|
27741
27689
|
try {
|
|
27742
|
-
const
|
|
27743
|
-
|
|
27744
|
-
|
|
27745
|
-
data: await response.json()
|
|
27746
|
-
};
|
|
27690
|
+
const reply = await send();
|
|
27691
|
+
const { response } = reply;
|
|
27692
|
+
if (response.ok) return reply;
|
|
27747
27693
|
if (!RERANK_TRANSIENT_STATUSES.has(response.status) || attempt === RERANK_TRANSIENT_ATTEMPTS) return { response };
|
|
27748
27694
|
if (response.status === 429) {
|
|
27749
27695
|
const retryAfter = response.headers.get("retry-after");
|
|
@@ -27752,37 +27698,48 @@ async function fetchRerankWithRetry(send) {
|
|
|
27752
27698
|
await response.body?.cancel();
|
|
27753
27699
|
lastError = /* @__PURE__ */ new Error(`rerank API responded ${response.status}`);
|
|
27754
27700
|
} catch (error) {
|
|
27755
|
-
if (!isTransientRerankError(error) || attempt === RERANK_TRANSIENT_ATTEMPTS) throw error;
|
|
27701
|
+
if (!isTransientRerankError(error) || attempt === RERANK_TRANSIENT_ATTEMPTS || stop?.aborted) throw error;
|
|
27756
27702
|
lastError = error;
|
|
27757
27703
|
}
|
|
27758
|
-
|
|
27704
|
+
if (stop?.aborted) throw lastError;
|
|
27705
|
+
await new Promise((resolve) => {
|
|
27706
|
+
const onAbort = () => {
|
|
27707
|
+
clearTimeout(timer);
|
|
27708
|
+
resolve();
|
|
27709
|
+
};
|
|
27710
|
+
const timer = setTimeout(() => {
|
|
27711
|
+
stop?.removeEventListener("abort", onAbort);
|
|
27712
|
+
resolve();
|
|
27713
|
+
}, retryDelayMs);
|
|
27714
|
+
stop?.addEventListener("abort", onAbort, { once: true });
|
|
27715
|
+
});
|
|
27716
|
+
if (stop?.aborted) throw lastError;
|
|
27759
27717
|
}
|
|
27760
27718
|
throw lastError;
|
|
27761
27719
|
}
|
|
27762
27720
|
Object.assign(MemoryRetriever.prototype, {
|
|
27763
|
-
async rerank(query, candidates, queryVector) {
|
|
27721
|
+
async rerank(query, candidates, queryVector, options) {
|
|
27764
27722
|
if (candidates.length === 0) return { candidates };
|
|
27765
27723
|
if (this.config.rerank === "none") return { candidates };
|
|
27766
|
-
const
|
|
27767
|
-
if (this.config.rerank === "cross-encoder" && !this.config.rerankApiKey) throw new RetrievalError(
|
|
27724
|
+
const unranked = () => this.rerankLightweight(candidates, queryVector);
|
|
27725
|
+
if (this.config.rerank === "cross-encoder" && !this.config.rerankApiKey) throw new RetrievalError("rerank \"cross-encoder\" requires retrieval.rerankApiKey; set the key, or set retrieval.rerank to \"lightweight\" to choose the local ranker");
|
|
27768
27726
|
if (this.config.rerank === "lightweight" || !this.config.rerankApiKey) return { candidates: this.rerankLightweight(candidates, queryVector) };
|
|
27769
|
-
const rerankEndpoint = this.config.rerankEndpoint
|
|
27727
|
+
const rerankEndpoint = this.config.rerankEndpoint;
|
|
27770
27728
|
if (!rerankEndpoint) {
|
|
27771
|
-
log$4.warn("rerank skipped: no
|
|
27729
|
+
log$4.warn("rerank skipped: no reranker address", {}, {
|
|
27772
27730
|
event_name: "memory.retriever_rerank.diagnostic",
|
|
27773
27731
|
file: "packages/memory/src/engine/retrieval/retriever-rerank.ts",
|
|
27774
27732
|
function: "rerank",
|
|
27775
27733
|
site_id: "retrieval.retriever-rerank.rerank.6fbc6b3a22"
|
|
27776
27734
|
});
|
|
27777
27735
|
return {
|
|
27778
|
-
candidates,
|
|
27779
|
-
fallback: {
|
|
27780
|
-
reason: "no_endpoint",
|
|
27781
|
-
provider
|
|
27782
|
-
}
|
|
27736
|
+
candidates: unranked(),
|
|
27737
|
+
fallback: { reason: "no_endpoint" }
|
|
27783
27738
|
};
|
|
27784
27739
|
}
|
|
27785
27740
|
const rerankTimeoutMs = this.config.rerankTimeoutMs ?? 15e3;
|
|
27741
|
+
const stepBudget = AbortSignal.timeout(Math.max(0, Math.floor(options?.deadlineAt === void 0 ? rerankTimeoutMs : options.deadlineAt - Date.now())));
|
|
27742
|
+
const stepStop = options?.signal ? AbortSignal.any([options.signal, stepBudget]) : stepBudget;
|
|
27786
27743
|
const rerankApiKey = this.config.rerankApiKey;
|
|
27787
27744
|
const maxCandidates = this.config.rerankMaxCandidates;
|
|
27788
27745
|
const overCap = maxCandidates !== void 0 && candidates.length > maxCandidates;
|
|
@@ -27803,11 +27760,8 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
27803
27760
|
site_id: "retrieval.retriever-rerank.rerank.query_over_window"
|
|
27804
27761
|
});
|
|
27805
27762
|
return {
|
|
27806
|
-
candidates,
|
|
27807
|
-
fallback: {
|
|
27808
|
-
reason: "query_over_window",
|
|
27809
|
-
provider
|
|
27810
|
-
}
|
|
27763
|
+
candidates: unranked(),
|
|
27764
|
+
fallback: { reason: "query_over_window" }
|
|
27811
27765
|
};
|
|
27812
27766
|
}
|
|
27813
27767
|
let truncatedCandidates = 0;
|
|
@@ -27830,17 +27784,54 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
27830
27784
|
const runBatch = async (start) => {
|
|
27831
27785
|
let batchTexts = rerankTexts.slice(start, start + batchSize);
|
|
27832
27786
|
for (let pass = 0;; pass += 1) {
|
|
27833
|
-
const { headers, body } = buildRerankRequest(
|
|
27834
|
-
const
|
|
27835
|
-
|
|
27836
|
-
|
|
27837
|
-
|
|
27838
|
-
|
|
27839
|
-
|
|
27787
|
+
const { headers, body } = buildRerankRequest(rerankApiKey, query, batchTexts);
|
|
27788
|
+
const sendAttempt = async () => {
|
|
27789
|
+
const clientRequestId = randomUUID();
|
|
27790
|
+
const attemptStarted = performance.now();
|
|
27791
|
+
let outcome = "failed";
|
|
27792
|
+
let statusCode;
|
|
27793
|
+
try {
|
|
27794
|
+
const attempt = await fetch(rerankEndpoint, {
|
|
27795
|
+
method: "POST",
|
|
27796
|
+
headers: {
|
|
27797
|
+
...headers,
|
|
27798
|
+
"X-Request-ID": clientRequestId
|
|
27799
|
+
},
|
|
27800
|
+
body: JSON.stringify(body),
|
|
27801
|
+
signal: AbortSignal.any([AbortSignal.timeout(rerankTimeoutMs), stepStop])
|
|
27802
|
+
});
|
|
27803
|
+
statusCode = attempt.status;
|
|
27804
|
+
if (!attempt.ok) {
|
|
27805
|
+
outcome = "http_error";
|
|
27806
|
+
return { response: attempt };
|
|
27807
|
+
}
|
|
27808
|
+
const data = await attempt.json();
|
|
27809
|
+
outcome = "success";
|
|
27810
|
+
return {
|
|
27811
|
+
response: attempt,
|
|
27812
|
+
data
|
|
27813
|
+
};
|
|
27814
|
+
} catch (error) {
|
|
27815
|
+
outcome = isRerankTimeout(error) ? "timeout" : "failed";
|
|
27816
|
+
throw error;
|
|
27817
|
+
} finally {
|
|
27818
|
+
log$4.info("Rerank request completed", {
|
|
27819
|
+
outcome,
|
|
27820
|
+
status_code: statusCode ?? "unavailable",
|
|
27821
|
+
duration_ms: performance.now() - attemptStarted,
|
|
27822
|
+
texts_sent: batchTexts.length,
|
|
27823
|
+
client_request_id: clientRequestId
|
|
27824
|
+
}, {
|
|
27825
|
+
event_name: "rerank.request.completed",
|
|
27826
|
+
file: "packages/memory/src/engine/retrieval/retriever-rerank.ts",
|
|
27827
|
+
function: "runBatch",
|
|
27828
|
+
site_id: "rerank.request.completed"
|
|
27829
|
+
});
|
|
27830
|
+
}
|
|
27831
|
+
};
|
|
27832
|
+
const { response, data } = await fetchRerankWithRetry(sendAttempt, stepStop);
|
|
27840
27833
|
if (!response.ok) {
|
|
27841
27834
|
const retryAfter = response.headers.get("retry-after");
|
|
27842
|
-
const fatalError = buildRerankHttpError(response.status);
|
|
27843
|
-
if (fatalError) throw fatalError;
|
|
27844
27835
|
const errorBody = await response.text().catch(() => "<unreadable body>");
|
|
27845
27836
|
const refusal = pass === 0 ? parseOverWindowRefusal(errorBody) : void 0;
|
|
27846
27837
|
if (refusal) {
|
|
@@ -27882,10 +27873,9 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
27882
27873
|
});
|
|
27883
27874
|
return "http_error";
|
|
27884
27875
|
}
|
|
27885
|
-
const parsed = parseRerankResponse(
|
|
27876
|
+
const parsed = parseRerankResponse(data);
|
|
27886
27877
|
if (!parsed) {
|
|
27887
27878
|
log$4.warn("rerank API returned unparseable response", {
|
|
27888
|
-
provider,
|
|
27889
27879
|
endpoint_hash: createHash("sha256").update(rerankEndpoint).digest("hex"),
|
|
27890
27880
|
batchStart: start
|
|
27891
27881
|
}, {
|
|
@@ -27916,11 +27906,8 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
27916
27906
|
for (const outcome of settled) if (outcome.status === "rejected" && outcome.reason instanceof RetrievalError) throw outcome.reason;
|
|
27917
27907
|
for (const outcome of settled) if (outcome.status === "rejected") throw outcome.reason;
|
|
27918
27908
|
for (const outcome of settled) if (outcome.status === "fulfilled" && typeof outcome.value === "string") return {
|
|
27919
|
-
candidates,
|
|
27920
|
-
fallback: {
|
|
27921
|
-
reason: outcome.value,
|
|
27922
|
-
provider
|
|
27923
|
-
}
|
|
27909
|
+
candidates: unranked(),
|
|
27910
|
+
fallback: { reason: outcome.value }
|
|
27924
27911
|
};
|
|
27925
27912
|
for (const outcome of settled) if (outcome.status === "fulfilled" && typeof outcome.value !== "string") items.push(...outcome.value);
|
|
27926
27913
|
}
|
|
@@ -27935,9 +27922,7 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
27935
27922
|
const candidate = toRerank[item.index];
|
|
27936
27923
|
if (!candidate) continue;
|
|
27937
27924
|
const sourceScore = this.getRerankSourceScore(candidate);
|
|
27938
|
-
|
|
27939
|
-
if (provider === "tei") crossScore = 1 / (1 + Math.exp(-item.score));
|
|
27940
|
-
const blendedScore = clamp01(crossScore * blendCross + sourceScore * blendVector, 0);
|
|
27925
|
+
const blendedScore = clamp01(1 / (1 + Math.exp(-item.score)) * blendCross + sourceScore * blendVector, 0);
|
|
27941
27926
|
reranked.push({
|
|
27942
27927
|
...candidate,
|
|
27943
27928
|
score: blendedScore,
|
|
@@ -27955,8 +27940,7 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
27955
27940
|
log$4.debug("reranked", {
|
|
27956
27941
|
totalCandidateCount: candidates.length,
|
|
27957
27942
|
sentToRerankCount: toRerank.length,
|
|
27958
|
-
returnedCount: reranked.length
|
|
27959
|
-
provider
|
|
27943
|
+
returnedCount: reranked.length
|
|
27960
27944
|
}, {
|
|
27961
27945
|
event_name: "memory.retriever_rerank.diagnostic",
|
|
27962
27946
|
file: "packages/memory/src/engine/retrieval/retriever-rerank.ts",
|
|
@@ -27998,11 +27982,8 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
27998
27982
|
});
|
|
27999
27983
|
}
|
|
28000
27984
|
return {
|
|
28001
|
-
candidates,
|
|
28002
|
-
fallback: {
|
|
28003
|
-
reason,
|
|
28004
|
-
provider
|
|
28005
|
-
}
|
|
27985
|
+
candidates: unranked(),
|
|
27986
|
+
fallback: { reason }
|
|
28006
27987
|
};
|
|
28007
27988
|
}
|
|
28008
27989
|
},
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { h as MemoryCategory, l as DecayScore, r as AggregationQuery, u as DecayableMemory, x as RetrievalResult, y as MemorySearchResult } from "./types-
|
|
2
|
-
import {
|
|
1
|
+
import { h as MemoryCategory, l as DecayScore, r as AggregationQuery, u as DecayableMemory, x as RetrievalResult, y as MemorySearchResult } from "./types-Dm_XhSne.js";
|
|
2
|
+
import { on as RecallLifecycleConfig } from "./index-8CfO_-6T.js";
|
|
3
3
|
import { t as Embedder } from "./embedding-provider-client-vynZMuit.js";
|
|
4
4
|
import "./trace-C1JxMfs-.js";
|
|
5
|
-
import "./memory-metadata-codec-
|
|
5
|
+
import "./memory-metadata-codec-CFY8YtXf.js";
|
|
6
6
|
import { K as RemFacetPolicy } from "./index-DPfJrOFD.js";
|
|
7
|
-
import { C as MemoryStore } from "./memory-store-base-
|
|
8
|
-
import "./store-
|
|
9
|
-
import { n as AccessTracker } from "./access-tracker-
|
|
10
|
-
import { r as TierPromoter } from "./memory-tier-promoter-
|
|
7
|
+
import { C as MemoryStore } from "./memory-store-base-D0bLwzyF.js";
|
|
8
|
+
import "./store-HyzTUvwj.js";
|
|
9
|
+
import { n as AccessTracker } from "./access-tracker-DT04huAG.js";
|
|
10
|
+
import { r as TierPromoter } from "./memory-tier-promoter-Cf1OdoZK.js";
|
|
11
11
|
import "@snoai/utils/logger";
|
|
12
12
|
//#region src/engine/retrieval/retrieval-trace.d.ts
|
|
13
13
|
/** @file retrieval-trace.ts
|
|
@@ -209,7 +209,6 @@ declare class RetrievalStatsCollector {
|
|
|
209
209
|
}
|
|
210
210
|
//#endregion
|
|
211
211
|
//#region src/engine/retrieval/retrieval-config.d.ts
|
|
212
|
-
type RerankProvider = "jina" | "siliconflow" | "voyage" | "pinecone" | "dashscope" | "tei";
|
|
213
212
|
interface RetrievalConfig {
|
|
214
213
|
/** Enable the historical recency, decay, and retention score transforms. */
|
|
215
214
|
temporalWeighting: boolean;
|
|
@@ -228,7 +227,6 @@ interface RetrievalConfig {
|
|
|
228
227
|
/** Dynamic memories decay 3× faster in time-decay scoring (default ON) */
|
|
229
228
|
temporalDecay: boolean;
|
|
230
229
|
rerankApiKey?: string;
|
|
231
|
-
rerankModel?: string;
|
|
232
230
|
rerankTimeoutMs?: number;
|
|
233
231
|
lengthNormAnchor: number;
|
|
234
232
|
hardMinScore: number;
|
|
@@ -247,15 +245,10 @@ interface RetrievalConfig {
|
|
|
247
245
|
timeDecayFloor?: number;
|
|
248
246
|
/** Relevance vs diversity tradeoff (default: 0.7) */
|
|
249
247
|
mmrLambda?: number;
|
|
250
|
-
/**
|
|
248
|
+
/** Address of Sno's reranker (the Sno GPU address plus `/rerank`) */
|
|
251
249
|
rerankEndpoint?: string;
|
|
252
|
-
/** Rerank provider name */
|
|
253
|
-
rerankProvider?: RerankProvider | string;
|
|
254
250
|
/**
|
|
255
|
-
*
|
|
256
|
-
* in one request. Some rerank deployments (e.g. this repo's Sno TEI
|
|
257
|
-
* reranker) reject a batch above a fixed size instead of truncating it, so
|
|
258
|
-
* an unset value here must never silently violate that limit. Candidates
|
|
251
|
+
* Cap on how many candidates are sent to Sno's reranker in total. Candidates
|
|
259
252
|
* beyond the cap are NOT dropped — they still flow through the standard
|
|
260
253
|
* `unreturned` preservation-floor path, same as a real reranker choosing
|
|
261
254
|
* not to return them.
|
|
@@ -288,6 +281,8 @@ interface RetrievalContext {
|
|
|
288
281
|
*/
|
|
289
282
|
includeRefused?: boolean;
|
|
290
283
|
signal?: AbortSignal;
|
|
284
|
+
/** The time (ms since the epoch) by which a Sno reranker must have finished, retries included, before recall falls back to local ranking; set by callers that have a deadline. */
|
|
285
|
+
rerankDeadlineAt?: number;
|
|
291
286
|
sessionId?: string;
|
|
292
287
|
explicitLocale?: string;
|
|
293
288
|
/** Retrieval source: "manual" for user-triggered, "auto-recall" for system-initiated, "cli" for CLI commands */
|
|
@@ -359,12 +354,10 @@ interface RetentionScorer {
|
|
|
359
354
|
*
|
|
360
355
|
* - `missing_api_key`: cross-encoder configured but no rerankApiKey set;
|
|
361
356
|
* call routes through the lightweight cosine path instead.
|
|
362
|
-
* - `no_endpoint`:
|
|
363
|
-
*
|
|
364
|
-
* - `
|
|
365
|
-
*
|
|
366
|
-
* - `invalid_response`: provider HTTP 2xx but response shape did not parse.
|
|
367
|
-
* - `timeout`: the per-call AbortSignal fired before the provider responded.
|
|
357
|
+
* - `no_endpoint`: no reranker address (`rerankEndpoint`) was set; rerank was skipped.
|
|
358
|
+
* - `http_error`: the reranker responded with a non-OK status.
|
|
359
|
+
* - `invalid_response`: the reranker answered HTTP 2xx but the response shape did not parse.
|
|
360
|
+
* - `timeout`: the per-call AbortSignal fired before the reranker responded.
|
|
368
361
|
* - `request_error`: any other thrown error inside the fetch path.
|
|
369
362
|
* - `query_over_window`: the query alone fills the reranker's per-pair token window, so no
|
|
370
363
|
* document could be sent with it. Nothing was requested.
|
|
@@ -373,7 +366,6 @@ declare const RERANK_FALLBACK_REASONS: readonly ["missing_api_key", "no_endpoint
|
|
|
373
366
|
type RerankFallbackReason = (typeof RERANK_FALLBACK_REASONS)[number];
|
|
374
367
|
interface RerankFallbackSignal {
|
|
375
368
|
reason: RerankFallbackReason;
|
|
376
|
-
provider: string;
|
|
377
369
|
}
|
|
378
370
|
interface RerankOutcome {
|
|
379
371
|
candidates: RetrievalResult[];
|
|
@@ -452,7 +444,10 @@ interface MemoryRetrieverInternals {
|
|
|
452
444
|
precisionRecall(context: RetrievalContext, trace?: TraceCollector): Promise<RetrievalResult[]>;
|
|
453
445
|
aggregationComplete(context: RetrievalContext, trace?: TraceCollector): Promise<RetrievalResult[]>;
|
|
454
446
|
rrfFuse(vector: MemorySearchResult[], keyword: MemorySearchResult[]): RetrievalResult[];
|
|
455
|
-
rerank(query: string, candidates: RetrievalResult[], queryVector: Float32Array
|
|
447
|
+
rerank(query: string, candidates: RetrievalResult[], queryVector: Float32Array, options?: {
|
|
448
|
+
signal?: AbortSignal;
|
|
449
|
+
deadlineAt?: number;
|
|
450
|
+
}): Promise<RerankOutcome>;
|
|
456
451
|
rerankLightweight(candidates: RetrievalResult[], queryVector: Float32Array): RetrievalResult[];
|
|
457
452
|
getRerankSourceScore(result: RetrievalResult): number;
|
|
458
453
|
applyScoringPipeline(results: RetrievalResult[], trace?: TraceCollector, limit?: number): RetrievalResult[];
|
|
@@ -468,4 +463,4 @@ declare function createRetriever(store: MemoryStore, embedder: Embedder, logger?
|
|
|
468
463
|
warn: (message: string, fields?: Record<string, unknown>) => void;
|
|
469
464
|
}, config?: RetrievalConfig): MemoryRetriever;
|
|
470
465
|
//#endregion
|
|
471
|
-
export { RerankFallbackSignal as a, collectParallelStage as c,
|
|
466
|
+
export { RerankFallbackSignal as a, collectParallelStage as c, RetrievalContext as d, withServingValidityDefault as f, RerankFallbackReason as i, DEFAULT_RETRIEVAL_CONFIG as l, MemoryRetrieverInternals as n, RerankOutcome as o, RERANK_FALLBACK_REASONS as r, createRetriever as s, MemoryRetriever as t, RetrievalConfig as u };
|