@snoai/memory 1.2.11 → 1.2.13
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-CglGg8uS.d.ts} +3 -3
- package/dist/{adapter-lyb6RaQE.d.ts → adapter-Cxyzdq6H.d.ts} +2 -2
- package/dist/{atomic-memory-extraction-B_XpkhMd.d.ts → atomic-memory-extraction-DO4yTfch.d.ts} +4 -4
- package/dist/{atomic-memory-extraction-o2v8mp7G.js → atomic-memory-extraction-DWhlXJT6.js} +4 -4
- package/dist/{b-profile-section-dictionary-provider-BK5NBs-y.d.ts → b-profile-section-dictionary-provider-BkUdS1SY.d.ts} +1 -1
- package/dist/{capture-policy-detector-BvVGmxxX.d.ts → capture-policy-detector-C7MA4jSr.d.ts} +1 -1
- package/dist/client.d.ts +2 -2
- package/dist/client.js +5 -4
- package/dist/{config-C7LzSWhG.js → config-D_KOwEyg.js} +84 -16
- 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-CmS4xAaN.d.ts} +1 -1
- package/dist/diagnostic-encoder.js +1 -1
- package/dist/{index-CsPUNkcm.d.ts → index-CTi1R9T4.d.ts} +5 -4
- package/dist/index.d.ts +11 -11
- package/dist/index.js +13 -11
- 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 +44 -8
- 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 +5 -5
- 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 +5 -5
- 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 +2 -2
- 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 +1 -1
- 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/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/model/llm-mode-routing.js +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-B7LSFL_m.d.ts} +1 -1
- package/dist/{llm-client-ConEyQEs.js → llm-client-C7yyFWu-.js} +38 -10
- package/dist/{log-site-catalog.generated-Dzgj9o5c.js → log-site-catalog.generated-BODn_6Kx.js} +80 -80
- package/dist/log-site-catalog.json +1 -1
- package/dist/{memory-kind-policy-ClQEXeOL.d.ts → memory-kind-policy-B4IBMAlv.d.ts} +1 -1
- package/dist/{memory-metadata-codec-wVAuoKrG.d.ts → memory-metadata-codec-BQ8tBY-g.d.ts} +1 -1
- package/dist/{memory-runtime-C8ZIW2WL.js → memory-runtime-4iOpeP09.js} +91 -88
- package/dist/{memory-snapshot-uTdxJnIh.d.ts → memory-snapshot-B8mQbWR-.d.ts} +2 -2
- package/dist/{memory-store-base-Bk2dOKED.d.ts → memory-store-base-CTAMKigD.d.ts} +2 -2
- package/dist/{memory-temporality-classifier-CcxfHYoT.d.ts → memory-temporality-classifier-LByFBiFJ.d.ts} +1 -1
- package/dist/{memory-temporality-classifier-MBJyJdvB.js → memory-temporality-classifier-epuZlfXa.js} +2 -2
- package/dist/{memory-tier-promoter-MkZPQ8u1.d.ts → memory-tier-promoter-CSGa4LBH.d.ts} +1 -1
- package/dist/memory-tool-dependencies-Bl11T6Xm.d.ts +14 -0
- package/dist/{memory-tool-dependencies-DUMY8SwB.js → memory-tool-dependencies-xLaWzwpI.js} +1 -1
- package/dist/{model-call-table-BE97f37s.js → model-call-table-DoIl2S0P.js} +32 -1
- package/dist/{observable-embedder-CGr3Zejf.d.ts → observable-embedder-Da0teBqx.d.ts} +1 -1
- package/dist/{observable-llm-client-CXUA7Gi3.d.ts → observable-llm-client-i0sp0veF.d.ts} +3 -3
- package/dist/{observable-memory-store-BwwKcUzf.d.ts → observable-memory-store-CS87pitJ.d.ts} +4 -4
- package/dist/{observable-retriever-bJbG9WtJ.d.ts → observable-retriever-Bhfg9DsZ.d.ts} +5 -5
- package/dist/{operation-cancellation-CTKWwNHk.js → operation-cancellation-QcwC4mDX.js} +7 -2
- package/dist/paths-B5y-npWs.d.ts +1 -0
- package/dist/{plugin-config-schema-BrhMvnXJ.d.ts → plugin-config-schema-CcEeAEdi.d.ts} +2 -2
- package/dist/{plugin-config-schema-Di-uKTP0.js → plugin-config-schema-CvAGFPyE.js} +1 -0
- package/dist/{profile-CF5oDjR7.d.ts → profile-BMvnRqf5.d.ts} +1 -1
- package/dist/{profile-section-writer-CmNa95uN.js → profile-section-writer-DeD9GPQJ.js} +2 -2
- package/dist/{reflection-command-hooks-CM2mWb69.d.ts → reflection-command-hooks-CFXyoVvE.d.ts} +4 -4
- package/dist/{reflection-command-hooks-CnTj8cKL.js → reflection-command-hooks-S5L6ZWeh.js} +5 -5
- package/dist/{reflection-deps-B5I0nYZS.d.ts → reflection-deps-BPMrDU0a.d.ts} +2 -2
- package/dist/{reflection-embedded-generator-CogQIBcG.d.ts → reflection-embedded-generator-CF-NbuPS.d.ts} +3 -3
- package/dist/{reflection-embedded-generator-DR525Moy.js → reflection-embedded-generator-nmVrj4AZ.js} +1 -1
- package/dist/{reflection-injection-hooks-BnbfZqpj.d.ts → reflection-injection-hooks-BRIr3lJM.d.ts} +4 -4
- package/dist/{reflection-lifecycle-hooks-DMDhtidj.d.ts → reflection-lifecycle-hooks-Ci8y4qHk.d.ts} +3 -3
- package/dist/{rem-batch-executor-DbV8Y-B-.js → rem-batch-executor-CfWChDAk.js} +1 -1
- package/dist/{rem-consumer-retrieval-CDMSCJYI.js → rem-consumer-retrieval-BhS1ivcd.js} +1 -0
- package/dist/{rem-trigger-BSrGyG0s.js → rem-trigger-B1P5_RqV.js} +86 -27
- package/dist/{retriever-Bzz6H8Mn.js → retriever-CpyZs2ND.js} +45 -18
- package/dist/{retriever-DyxY59Lg.d.ts → retriever-DdikFSDC.d.ts} +13 -8
- package/dist/{runtime-audit-log-DdhLlTxi.d.ts → runtime-audit-log-BVOxzkh7.d.ts} +1 -1
- package/dist/{server-CjwHZY1P.js → server-DOL3D6bb.js} +7 -6
- package/dist/sidecar/main.js +2 -2
- package/dist/{sno-station-mem-runtime-dependencies-DlvM6mL7.js → sno-station-mem-runtime-dependencies-DZe3z4RY.js} +7 -7
- package/dist/sno-station-mem-runtime-dependencies-DgAm7WqA.d.ts +31 -0
- package/dist/{store-BQxkgJTX.js → store-DY_rWx__.js} +2 -2
- package/dist/{store-BDIAl2cc.d.ts → store-DraRJ-HI.d.ts} +1 -1
- package/dist/{strategy-hook-runner-SvyyGBXw.js → strategy-hook-runner-CltVTtzk.js} +1 -1
- package/dist/{strategy-hook-runner-DT9emgCZ.d.ts → strategy-hook-runner-DH7OEQrH.d.ts} +7 -7
- package/dist/{types-Ae3a8562.d.ts → types-DZGL4QXi.d.ts} +1 -1
- package/package.json +1 -1
- package/settings.default.json +2 -2
- 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
|
|
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 CachedEmbeddingProvider, Ct as FIXED_MEMORY_CHUNKS_MEM_FACET_IDX, D as settingsToPluginConfig, Dn as DEFAULT_IMPORTANCE, Dr as LocalEmbedProvider, Dt as FIXED_MEMORY_MEMORIES_FACT_ID_INSERT_GUARD, En as DEFAULT_BM25_WEIGHT, Et as FIXED_MEMORY_MEMORIES, Fn as DEFAULT_VECTOR_WEIGHT, G as FIXED_EXTERNAL_VALUE_55, Gn as IMPORTANCE_WEIGHT_BASE, H as FIXED_EXTERNAL_VALUE_52, Hn as HEAD_EXTRACT_MIN_CONTENT_TOKENS, In as EMBEDDER_DIM, Ir as REM_SIDECAR_TOKEN_HEADER, It as FIXED_MEMORY_SNO_EXTRACT_CHAT, J as FIXED_EXTERNAL_VALUE_58, Jn as LIGHTWEIGHT_COSINE_WEIGHT, K as FIXED_EXTERNAL_VALUE_56, Kt as FIXED_PROTOCOL_VALUE_69, Ln as EMBEDDER_MODEL_DEFAULT, Mn as DEFAULT_RERANK_MODEL, Mt as FIXED_MEMORY_PROVIDER_PROJECT_AGENTS, Nn as DEFAULT_RERANK_TIMEOUT_MS, Nt as FIXED_MEMORY_PROVIDER_PROJECT_MAPPINGS, O as MODEL_CALLS, On as DEFAULT_RECALL_LIFECYCLE, Or as ensureModelDownloaded, Ot as FIXED_MEMORY_MEMORIES_FACT_ID_UPDATE_GUARD, P as observeAgentId, Q as FIXED_IDX_MEMORY, Rn as EMBEDDER_PROVIDER_DEFAULT, Rt as FIXED_MEMORY_TASK_LIFECYCLE_COMMANDS, Sn as CHUNK_MIN_TOKENS, St as FIXED_MEMORY_CHUNKS_MEMORY_ID_IDX, T as readSettings, Tn as CHUNK_TOKENIZER_MODE, Tr as LOCAL_EMBEDDING_MODEL, Tt as FIXED_MEMORY_EXTRACTION_TIMESTAMPS, U as FIXED_EXTERNAL_VALUE_53, Un as HEAD_EXTRACT_OVERLAP_DROP_RATIO, V as FIXED_EXTERNAL_VALUE_51, W as FIXED_EXTERNAL_VALUE_54, Wn as HEAD_EXTRACT_TOKEN_BUDGET, X as FIXED_EXTERNAL_VALUE_8, Xn as LIGHTWEIGHT_RERANK_PENALTY, Y as FIXED_EXTERNAL_VALUE_62, Yn as LIGHTWEIGHT_FUSION_WEIGHT, 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 MMR_LAMBDA, at as FIXED_IDX_MEMORY_MEMORIES_LANE_PROJECT, bn as CHUNKING_VERSION$1, br as experimentCandidatePoolOverride, bt as FIXED_MEMORY_CHUNKS_AU, cn as SUPPORTED_LOCALES, ct as FIXED_IDX_MEMORY_MEMORIES_PROJECT_FACT_KEY_ACTIVE, d as getRemDiscoveryPath, dn as ADJACENCY_BONUS_PER_PAIR, dt as FIXED_MEMORY_ACTIVE_TASK_EVIDENCE, en as FIXED_VEC_MEMORY, er as MAX_CHUNK_FETCH_LIMIT, et as FIXED_IDX_MEMORY_ACTIVE_TASK_EVIDENCE_INSTANCE, fr as RERANK_BLEND_CROSS, ft as FIXED_MEMORY_ACTIVE_TASK_INSTANCES, g as readRemOperationalConfig, gr as TIME_DECAY_FLOOR, gt as FIXED_MEMORY_ACTIVE_TASK_TRANSITIONS, ht as FIXED_MEMORY_ACTIVE_TASK_REVISIONS, in as PERSISTED_CONTENT_HASH_V3, 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, lr as RECENCY_WEIGHT, lt as FIXED_IDX_MEMORY_MEMORIES_PROJECT_TIMESTAMP, mr as RETRIEVAL_STORAGE_CHUNK_PROFILE, 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_CAP, ot as FIXED_IDX_MEMORY_MEMORIES_PROJECT, pr as RERANK_BLEND_VECTOR, pt as FIXED_MEMORY_ACTIVE_TASK_MIGRATION_EVIDENCE, q as FIXED_EXTERNAL_VALUE_57, qn as INTRA_MEMORY_COSINE_THRESHOLD, 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, sr as MULTI_HIT_BONUS_PER_HIT, st as FIXED_IDX_MEMORY_MEMORIES_PROJECT_CONTENT_HASH, tn as FIXED_VEC_MEMORY_CHUNKS, tr as MAX_LIST_LIMIT, 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_CACHE_DIR_DEFAULT, wt as FIXED_MEMORY_CHUNKS_MEM_IDX, xn as CHUNK_MAX_TOKENS, xr as experimentMmrDisabled, xt as FIXED_MEMORY_CHUNKS_FTS, yn as CACHE_TTL_MS, yt as FIXED_MEMORY_CHUNKS_AI, zn as EVAL_QA_TRACES_FILENAME, zt as FIXED_MEMORY_UNPLACED_CANDIDATES } from "./config-D_KOwEyg.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;
|
|
@@ -6655,11 +6660,23 @@ const providerResponses = new AsyncLocalStorage();
|
|
|
6655
6660
|
function withProviderResponses(responses, run) {
|
|
6656
6661
|
return providerResponses.run(responses, run);
|
|
6657
6662
|
}
|
|
6663
|
+
/** Sno GPU request attribution (GPU_REQUEST_METADATA_STANDARD): self-reported labels, never identity. */
|
|
6664
|
+
const SNO_GPU_SOURCE = "sno-station";
|
|
6665
|
+
function snoGpuAttributionHeaders(clientRequestId, callId) {
|
|
6666
|
+
return {
|
|
6667
|
+
"X-Sno-Source": SNO_GPU_SOURCE,
|
|
6668
|
+
"X-Sno-Workload": callId ? MODEL_CALL_WORKLOAD[callId] : "station-aux",
|
|
6669
|
+
"X-Request-ID": clientRequestId
|
|
6670
|
+
};
|
|
6671
|
+
}
|
|
6658
6672
|
async function observeRequest(input, run) {
|
|
6659
6673
|
const route = createHash("sha256").update(input.endpoint).digest("hex");
|
|
6660
6674
|
const inFlight = (routeInFlight.get(route) ?? 0) + 1;
|
|
6661
6675
|
routeInFlight.set(route, inFlight);
|
|
6662
|
-
const diagnostic = {
|
|
6676
|
+
const diagnostic = {
|
|
6677
|
+
started: performance.now(),
|
|
6678
|
+
clientRequestId: input.requestId ?? randomUUID()
|
|
6679
|
+
};
|
|
6663
6680
|
return withLogContext({ attempt_id: randomUUID() }, async () => {
|
|
6664
6681
|
let outcome = "failed";
|
|
6665
6682
|
let failure;
|
|
@@ -6679,6 +6696,7 @@ async function observeRequest(input, run) {
|
|
|
6679
6696
|
outcome,
|
|
6680
6697
|
error: failure,
|
|
6681
6698
|
call_id: input.slot ?? "unavailable",
|
|
6699
|
+
client_request_id: diagnostic.clientRequestId,
|
|
6682
6700
|
destination: input.label ?? "unavailable",
|
|
6683
6701
|
route_hash: route,
|
|
6684
6702
|
transport: input.transport,
|
|
@@ -6689,6 +6707,7 @@ async function observeRequest(input, run) {
|
|
|
6689
6707
|
prompt_template_unavailable_reason: input.promptTemplateHash ? void 0 : "caller_does_not_provide_template_identity",
|
|
6690
6708
|
config_hash: createHash("sha256").update(JSON.stringify({
|
|
6691
6709
|
...input,
|
|
6710
|
+
requestId: void 0,
|
|
6692
6711
|
endpoint: route
|
|
6693
6712
|
})).digest("hex"),
|
|
6694
6713
|
output_cap: input.cap ?? "unavailable",
|
|
@@ -6847,6 +6866,7 @@ async function callSnoProfileCompletion(request) {
|
|
|
6847
6866
|
transport: "raw-completions",
|
|
6848
6867
|
slot: request.callId,
|
|
6849
6868
|
label: request.destination,
|
|
6869
|
+
requestId: request.requestId,
|
|
6850
6870
|
timeout: request.timeoutMs,
|
|
6851
6871
|
cap: request.singleTokenVerdict ? 1 : request.maxTokens,
|
|
6852
6872
|
sampling: {},
|
|
@@ -6862,7 +6882,7 @@ async function callSnoProfileCompletion(request) {
|
|
|
6862
6882
|
headers: {
|
|
6863
6883
|
"Content-Type": "application/json",
|
|
6864
6884
|
"X-Internal-Token": request.apiKey,
|
|
6865
|
-
...
|
|
6885
|
+
...snoGpuAttributionHeaders(diagnostic.clientRequestId, request.callId),
|
|
6866
6886
|
...request.operationId ? { "X-Sno-Operation": request.operationId } : {}
|
|
6867
6887
|
},
|
|
6868
6888
|
body: JSON.stringify({
|
|
@@ -6942,6 +6962,7 @@ async function snoStationMemDispatch(ctx) {
|
|
|
6942
6962
|
transport: "chat-completions",
|
|
6943
6963
|
slot: cfgExt.callId,
|
|
6944
6964
|
label: cfgExt.destination,
|
|
6965
|
+
requestId: typeof cfgExt.requestId === "string" ? cfgExt.requestId : void 0,
|
|
6945
6966
|
timeout: timeoutMs,
|
|
6946
6967
|
cap: typeof callBody.max_tokens === "number" ? callBody.max_tokens : typeof callBody.max_completion_tokens === "number" ? callBody.max_completion_tokens : void 0,
|
|
6947
6968
|
sampling,
|
|
@@ -6961,6 +6982,7 @@ async function snoStationMemDispatch(ctx) {
|
|
|
6961
6982
|
if (typeof cfgExt.requestId === "string") headers["X-Request-ID"] = cfgExt.requestId;
|
|
6962
6983
|
if (provider === "sno-gpu") {
|
|
6963
6984
|
headers["X-Internal-Token"] = ctx.apiKey;
|
|
6985
|
+
Object.assign(headers, snoGpuAttributionHeaders(diagnostic.clientRequestId, cfgExt.callId));
|
|
6964
6986
|
if (typeof cfgExt.operationId === "string") headers["X-Sno-Operation"] = cfgExt.operationId;
|
|
6965
6987
|
} else headers.Authorization = `Bearer ${ctx.apiKey}`;
|
|
6966
6988
|
let response;
|
|
@@ -7309,7 +7331,14 @@ function createLlmClient(config) {
|
|
|
7309
7331
|
});
|
|
7310
7332
|
let lastError = null;
|
|
7311
7333
|
let lastUsage = null;
|
|
7312
|
-
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
|
+
};
|
|
7313
7342
|
const destinationFor = (request) => {
|
|
7314
7343
|
if (!config.routing) return "host";
|
|
7315
7344
|
const route = resolveLlmRoute({
|
|
@@ -7379,6 +7408,7 @@ function createLlmClient(config) {
|
|
|
7379
7408
|
destination,
|
|
7380
7409
|
transport
|
|
7381
7410
|
});
|
|
7411
|
+
const hostTimeoutMs = resolveRequestTimeoutMs(request);
|
|
7382
7412
|
const hostStarted = performance.now();
|
|
7383
7413
|
const hostInFlight = ++hostRequestsInFlight;
|
|
7384
7414
|
const result = await withLogContext({ attempt_id: randomUUID() }, async () => {
|
|
@@ -7389,7 +7419,7 @@ function createLlmClient(config) {
|
|
|
7389
7419
|
prompt,
|
|
7390
7420
|
maxTokens: request.maxTokens ?? 4096,
|
|
7391
7421
|
...request.enableThinking !== void 0 ? { enableThinking: request.enableThinking } : {},
|
|
7392
|
-
timeoutMs:
|
|
7422
|
+
timeoutMs: hostTimeoutMs,
|
|
7393
7423
|
...request.signal ? { signal: request.signal } : {}
|
|
7394
7424
|
});
|
|
7395
7425
|
outcome = completion.kind;
|
|
@@ -7412,12 +7442,12 @@ function createLlmClient(config) {
|
|
|
7412
7442
|
config_hash: createHash("sha256").update(JSON.stringify({
|
|
7413
7443
|
transport,
|
|
7414
7444
|
maxTokens: request.maxTokens ?? 4096,
|
|
7415
|
-
timeoutMs:
|
|
7445
|
+
timeoutMs: hostTimeoutMs
|
|
7416
7446
|
})).digest("hex"),
|
|
7417
7447
|
output_cap: "unavailable",
|
|
7418
7448
|
passed_output_cap: request.maxTokens ?? 4096,
|
|
7419
7449
|
output_cap_reason: "host_may_strip_requested_cap",
|
|
7420
|
-
timeout_ms:
|
|
7450
|
+
timeout_ms: hostTimeoutMs,
|
|
7421
7451
|
sampling: { source: "unknown" },
|
|
7422
7452
|
finish_reason: "unavailable",
|
|
7423
7453
|
route: "agent-host-seam",
|
|
@@ -7742,7 +7772,8 @@ function createLlmClient(config) {
|
|
|
7742
7772
|
signal: memoryOperationSignal(input.signal)
|
|
7743
7773
|
});
|
|
7744
7774
|
checkMemoryOperation();
|
|
7745
|
-
|
|
7775
|
+
request.timeoutMs = resolveRequestTimeoutMs(request);
|
|
7776
|
+
const deadlineMs = performance.now() + request.timeoutMs;
|
|
7746
7777
|
try {
|
|
7747
7778
|
let content = await requestContentWithHostFallback(state, request, JSON_SYSTEM_CONTENT, deadlineMs);
|
|
7748
7779
|
if (content === null) return null;
|
|
@@ -7815,7 +7846,8 @@ function createLlmClient(config) {
|
|
|
7815
7846
|
signal: memoryOperationSignal(input.signal)
|
|
7816
7847
|
});
|
|
7817
7848
|
checkMemoryOperation();
|
|
7818
|
-
|
|
7849
|
+
request.timeoutMs = resolveRequestTimeoutMs(request);
|
|
7850
|
+
const deadlineMs = performance.now() + request.timeoutMs;
|
|
7819
7851
|
try {
|
|
7820
7852
|
const text = (await requestContentWithHostFallback(state, request, textSystemContent(request), deadlineMs))?.raw.trim();
|
|
7821
7853
|
return text && text.length > 0 ? text : null;
|
|
@@ -27461,7 +27493,10 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
27461
27493
|
site_id: "retrieval.retriever-search-modes.precisionRecall.aaf0b2eb17"
|
|
27462
27494
|
});
|
|
27463
27495
|
trace?.startStage("rerank", fused.map((r) => r.entry.id));
|
|
27464
|
-
const rerankOutcome = await this.rerank(context.query, fused, queryVector
|
|
27496
|
+
const rerankOutcome = await this.rerank(context.query, fused, queryVector, {
|
|
27497
|
+
signal: context.signal,
|
|
27498
|
+
deadlineAt: context.rerankDeadlineAt
|
|
27499
|
+
});
|
|
27465
27500
|
fused = rerankOutcome.candidates;
|
|
27466
27501
|
this.throwIfAborted(context);
|
|
27467
27502
|
const rerankStageMetadata = rerankOutcome.fallback ? {
|
|
@@ -27554,10 +27589,15 @@ function buildRerankHttpError(status) {
|
|
|
27554
27589
|
}
|
|
27555
27590
|
function buildRerankRequest(provider, apiKey, model, query, candidates, topN) {
|
|
27556
27591
|
switch (provider) {
|
|
27557
|
-
case "tei":
|
|
27592
|
+
case "tei":
|
|
27593
|
+
case "sno-gpu": return {
|
|
27558
27594
|
headers: {
|
|
27559
27595
|
"Content-Type": "application/json",
|
|
27560
|
-
Authorization: `Bearer ${apiKey}
|
|
27596
|
+
Authorization: `Bearer ${apiKey}`,
|
|
27597
|
+
...provider === "sno-gpu" ? {
|
|
27598
|
+
"X-Sno-Source": "sno-station",
|
|
27599
|
+
"X-Sno-Workload": "station-rerank"
|
|
27600
|
+
} : {}
|
|
27561
27601
|
},
|
|
27562
27602
|
body: {
|
|
27563
27603
|
query,
|
|
@@ -27645,7 +27685,8 @@ function parseRerankResponse(provider, data) {
|
|
|
27645
27685
|
};
|
|
27646
27686
|
const objectData = data && typeof data === "object" && !Array.isArray(data) ? data : void 0;
|
|
27647
27687
|
switch (provider) {
|
|
27648
|
-
case "tei":
|
|
27688
|
+
case "tei":
|
|
27689
|
+
case "sno-gpu": return parseItems(data, ["score", "relevance_score"]) ?? parseItems(objectData?.results, ["score", "relevance_score"]) ?? parseItems(objectData?.data, ["score", "relevance_score"]);
|
|
27649
27690
|
case "dashscope": {
|
|
27650
27691
|
const output = objectData?.output;
|
|
27651
27692
|
if (output) return parseItems(output.results, ["relevance_score", "score"]);
|
|
@@ -27717,7 +27758,7 @@ function isTransientRerankError(error) {
|
|
|
27717
27758
|
if (isRerankTimeout(error)) return true;
|
|
27718
27759
|
return error instanceof TypeError && error.cause !== void 0;
|
|
27719
27760
|
}
|
|
27720
|
-
async function fetchRerankWithRetry(send) {
|
|
27761
|
+
async function fetchRerankWithRetry(send, stop) {
|
|
27721
27762
|
let lastError;
|
|
27722
27763
|
for (let attempt = 1; attempt <= RERANK_TRANSIENT_ATTEMPTS; attempt += 1) {
|
|
27723
27764
|
let retryDelayMs = RERANK_TRANSIENT_BACKOFF_MS * attempt;
|
|
@@ -27735,18 +27776,31 @@ async function fetchRerankWithRetry(send) {
|
|
|
27735
27776
|
await response.body?.cancel();
|
|
27736
27777
|
lastError = /* @__PURE__ */ new Error(`rerank API responded ${response.status}`);
|
|
27737
27778
|
} catch (error) {
|
|
27738
|
-
if (!isTransientRerankError(error) || attempt === RERANK_TRANSIENT_ATTEMPTS) throw error;
|
|
27779
|
+
if (!isTransientRerankError(error) || attempt === RERANK_TRANSIENT_ATTEMPTS || stop?.aborted) throw error;
|
|
27739
27780
|
lastError = error;
|
|
27740
27781
|
}
|
|
27741
|
-
|
|
27782
|
+
if (stop?.aborted) throw lastError;
|
|
27783
|
+
await new Promise((resolve) => {
|
|
27784
|
+
const onAbort = () => {
|
|
27785
|
+
clearTimeout(timer);
|
|
27786
|
+
resolve();
|
|
27787
|
+
};
|
|
27788
|
+
const timer = setTimeout(() => {
|
|
27789
|
+
stop?.removeEventListener("abort", onAbort);
|
|
27790
|
+
resolve();
|
|
27791
|
+
}, retryDelayMs);
|
|
27792
|
+
stop?.addEventListener("abort", onAbort, { once: true });
|
|
27793
|
+
});
|
|
27794
|
+
if (stop?.aborted) throw lastError;
|
|
27742
27795
|
}
|
|
27743
27796
|
throw lastError;
|
|
27744
27797
|
}
|
|
27745
27798
|
Object.assign(MemoryRetriever.prototype, {
|
|
27746
|
-
async rerank(query, candidates, queryVector) {
|
|
27799
|
+
async rerank(query, candidates, queryVector, options) {
|
|
27747
27800
|
if (candidates.length === 0) return { candidates };
|
|
27748
27801
|
if (this.config.rerank === "none") return { candidates };
|
|
27749
27802
|
const provider = this.config.rerankProvider ?? "none";
|
|
27803
|
+
const unranked = () => provider === "sno-gpu" ? this.rerankLightweight(candidates, queryVector) : candidates;
|
|
27750
27804
|
if (this.config.rerank === "cross-encoder" && !this.config.rerankApiKey) throw new RetrievalError(`rerank "cross-encoder" requires retrieval.rerankApiKey (provider: ${provider}); set the key, or set retrieval.rerank to "lightweight" to choose the local ranker`);
|
|
27751
27805
|
if (this.config.rerank === "lightweight" || !this.config.rerankApiKey) return { candidates: this.rerankLightweight(candidates, queryVector) };
|
|
27752
27806
|
const rerankEndpoint = this.config.rerankEndpoint ?? RERANK_DEFAULT_ENDPOINTS[provider];
|
|
@@ -27758,7 +27812,7 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
27758
27812
|
site_id: "retrieval.retriever-rerank.rerank.6fbc6b3a22"
|
|
27759
27813
|
});
|
|
27760
27814
|
return {
|
|
27761
|
-
candidates,
|
|
27815
|
+
candidates: unranked(),
|
|
27762
27816
|
fallback: {
|
|
27763
27817
|
reason: "no_endpoint",
|
|
27764
27818
|
provider
|
|
@@ -27766,6 +27820,8 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
27766
27820
|
};
|
|
27767
27821
|
}
|
|
27768
27822
|
const rerankTimeoutMs = this.config.rerankTimeoutMs ?? 15e3;
|
|
27823
|
+
const stepEnds = [options?.signal, provider === "sno-gpu" ? AbortSignal.timeout(Math.max(0, Math.floor(options?.deadlineAt === void 0 ? rerankTimeoutMs : options.deadlineAt - Date.now()))) : void 0].filter((each) => each !== void 0);
|
|
27824
|
+
const stepStop = stepEnds.length > 0 ? AbortSignal.any(stepEnds) : void 0;
|
|
27769
27825
|
const rerankApiKey = this.config.rerankApiKey;
|
|
27770
27826
|
const maxCandidates = this.config.rerankMaxCandidates;
|
|
27771
27827
|
const overCap = maxCandidates !== void 0 && candidates.length > maxCandidates;
|
|
@@ -27786,7 +27842,7 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
27786
27842
|
site_id: "retrieval.retriever-rerank.rerank.query_over_window"
|
|
27787
27843
|
});
|
|
27788
27844
|
return {
|
|
27789
|
-
candidates,
|
|
27845
|
+
candidates: unranked(),
|
|
27790
27846
|
fallback: {
|
|
27791
27847
|
reason: "query_over_window",
|
|
27792
27848
|
provider
|
|
@@ -27816,14 +27872,17 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
27816
27872
|
const { headers, body } = buildRerankRequest(provider, rerankApiKey, this.config.rerankModel ?? "rerank-2", query, batchTexts, batchTexts.length);
|
|
27817
27873
|
const { response, data } = await fetchRerankWithRetry(() => fetch(rerankEndpoint, {
|
|
27818
27874
|
method: "POST",
|
|
27819
|
-
headers
|
|
27875
|
+
headers: provider === "sno-gpu" ? {
|
|
27876
|
+
...headers,
|
|
27877
|
+
"X-Request-ID": randomUUID()
|
|
27878
|
+
} : headers,
|
|
27820
27879
|
body: JSON.stringify(body),
|
|
27821
|
-
signal: AbortSignal.timeout(rerankTimeoutMs)
|
|
27822
|
-
}));
|
|
27880
|
+
signal: stepStop ? AbortSignal.any([AbortSignal.timeout(rerankTimeoutMs), stepStop]) : AbortSignal.timeout(rerankTimeoutMs)
|
|
27881
|
+
}), stepStop);
|
|
27823
27882
|
if (!response.ok) {
|
|
27824
27883
|
const retryAfter = response.headers.get("retry-after");
|
|
27825
27884
|
const fatalError = buildRerankHttpError(response.status);
|
|
27826
|
-
if (fatalError) throw fatalError;
|
|
27885
|
+
if (fatalError && provider !== "sno-gpu") throw fatalError;
|
|
27827
27886
|
const errorBody = await response.text().catch(() => "<unreadable body>");
|
|
27828
27887
|
const refusal = pass === 0 ? parseOverWindowRefusal(errorBody) : void 0;
|
|
27829
27888
|
if (refusal) {
|
|
@@ -27899,7 +27958,7 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
27899
27958
|
for (const outcome of settled) if (outcome.status === "rejected" && outcome.reason instanceof RetrievalError) throw outcome.reason;
|
|
27900
27959
|
for (const outcome of settled) if (outcome.status === "rejected") throw outcome.reason;
|
|
27901
27960
|
for (const outcome of settled) if (outcome.status === "fulfilled" && typeof outcome.value === "string") return {
|
|
27902
|
-
candidates,
|
|
27961
|
+
candidates: unranked(),
|
|
27903
27962
|
fallback: {
|
|
27904
27963
|
reason: outcome.value,
|
|
27905
27964
|
provider
|
|
@@ -27919,7 +27978,7 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
27919
27978
|
if (!candidate) continue;
|
|
27920
27979
|
const sourceScore = this.getRerankSourceScore(candidate);
|
|
27921
27980
|
let crossScore = item.score;
|
|
27922
|
-
if (provider === "tei") crossScore = 1 / (1 + Math.exp(-item.score));
|
|
27981
|
+
if (provider === "tei" || provider === "sno-gpu") crossScore = 1 / (1 + Math.exp(-item.score));
|
|
27923
27982
|
const blendedScore = clamp01(crossScore * blendCross + sourceScore * blendVector, 0);
|
|
27924
27983
|
reranked.push({
|
|
27925
27984
|
...candidate,
|
|
@@ -27981,7 +28040,7 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
27981
28040
|
});
|
|
27982
28041
|
}
|
|
27983
28042
|
return {
|
|
27984
|
-
candidates,
|
|
28043
|
+
candidates: unranked(),
|
|
27985
28044
|
fallback: {
|
|
27986
28045
|
reason,
|
|
27987
28046
|
provider
|
|
@@ -3,7 +3,7 @@ import "./internal/engine/shared/types.js";
|
|
|
3
3
|
import { EmbeddingError, RetrievalError } from "./internal/engine/shared/errors.js";
|
|
4
4
|
import { o as isMemoryExpired, s as parseInsightMetadata } from "./memory-metadata-codec-DL1sbJiN.js";
|
|
5
5
|
import { clamp01 } from "./internal/engine/shared/utils.js";
|
|
6
|
-
import {
|
|
6
|
+
import { a as memoryOperationSignal } from "./operation-cancellation-QcwC4mDX.js";
|
|
7
7
|
import { classifyLlmFailure } from "./internal/model/llm-failure.js";
|
|
8
8
|
import { appendQaTrace, computeConfigHash, isTraceEnabled } from "./internal/engine/eval/trace.js";
|
|
9
9
|
import { computeEffectiveHalfLife, parseAccessMetadata } from "./internal/engine/retrieval/access-tracker.js";
|
|
@@ -546,7 +546,10 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
546
546
|
site_id: "retrieval.retriever-search-modes.precisionRecall.aaf0b2eb17"
|
|
547
547
|
});
|
|
548
548
|
trace?.startStage("rerank", fused.map((r) => r.entry.id));
|
|
549
|
-
const rerankOutcome = await this.rerank(context.query, fused, queryVector
|
|
549
|
+
const rerankOutcome = await this.rerank(context.query, fused, queryVector, {
|
|
550
|
+
signal: context.signal,
|
|
551
|
+
deadlineAt: context.rerankDeadlineAt
|
|
552
|
+
});
|
|
550
553
|
fused = rerankOutcome.candidates;
|
|
551
554
|
this.throwIfAborted(context);
|
|
552
555
|
const rerankStageMetadata = rerankOutcome.fallback ? {
|
|
@@ -639,10 +642,15 @@ function buildRerankHttpError(status) {
|
|
|
639
642
|
}
|
|
640
643
|
function buildRerankRequest(provider, apiKey, model, query, candidates, topN) {
|
|
641
644
|
switch (provider) {
|
|
642
|
-
case "tei":
|
|
645
|
+
case "tei":
|
|
646
|
+
case "sno-gpu": return {
|
|
643
647
|
headers: {
|
|
644
648
|
"Content-Type": "application/json",
|
|
645
|
-
Authorization: `Bearer ${apiKey}
|
|
649
|
+
Authorization: `Bearer ${apiKey}`,
|
|
650
|
+
...provider === "sno-gpu" ? {
|
|
651
|
+
"X-Sno-Source": "sno-station",
|
|
652
|
+
"X-Sno-Workload": "station-rerank"
|
|
653
|
+
} : {}
|
|
646
654
|
},
|
|
647
655
|
body: {
|
|
648
656
|
query,
|
|
@@ -730,7 +738,8 @@ function parseRerankResponse(provider, data) {
|
|
|
730
738
|
};
|
|
731
739
|
const objectData = data && typeof data === "object" && !Array.isArray(data) ? data : void 0;
|
|
732
740
|
switch (provider) {
|
|
733
|
-
case "tei":
|
|
741
|
+
case "tei":
|
|
742
|
+
case "sno-gpu": return parseItems(data, ["score", "relevance_score"]) ?? parseItems(objectData?.results, ["score", "relevance_score"]) ?? parseItems(objectData?.data, ["score", "relevance_score"]);
|
|
734
743
|
case "dashscope": {
|
|
735
744
|
const output = objectData?.output;
|
|
736
745
|
if (output) return parseItems(output.results, ["relevance_score", "score"]);
|
|
@@ -802,7 +811,7 @@ function isTransientRerankError(error) {
|
|
|
802
811
|
if (isRerankTimeout(error)) return true;
|
|
803
812
|
return error instanceof TypeError && error.cause !== void 0;
|
|
804
813
|
}
|
|
805
|
-
async function fetchRerankWithRetry(send) {
|
|
814
|
+
async function fetchRerankWithRetry(send, stop) {
|
|
806
815
|
let lastError;
|
|
807
816
|
for (let attempt = 1; attempt <= RERANK_TRANSIENT_ATTEMPTS; attempt += 1) {
|
|
808
817
|
let retryDelayMs = RERANK_TRANSIENT_BACKOFF_MS * attempt;
|
|
@@ -820,18 +829,31 @@ async function fetchRerankWithRetry(send) {
|
|
|
820
829
|
await response.body?.cancel();
|
|
821
830
|
lastError = /* @__PURE__ */ new Error(`rerank API responded ${response.status}`);
|
|
822
831
|
} catch (error) {
|
|
823
|
-
if (!isTransientRerankError(error) || attempt === RERANK_TRANSIENT_ATTEMPTS) throw error;
|
|
832
|
+
if (!isTransientRerankError(error) || attempt === RERANK_TRANSIENT_ATTEMPTS || stop?.aborted) throw error;
|
|
824
833
|
lastError = error;
|
|
825
834
|
}
|
|
826
|
-
|
|
835
|
+
if (stop?.aborted) throw lastError;
|
|
836
|
+
await new Promise((resolve) => {
|
|
837
|
+
const onAbort = () => {
|
|
838
|
+
clearTimeout(timer);
|
|
839
|
+
resolve();
|
|
840
|
+
};
|
|
841
|
+
const timer = setTimeout(() => {
|
|
842
|
+
stop?.removeEventListener("abort", onAbort);
|
|
843
|
+
resolve();
|
|
844
|
+
}, retryDelayMs);
|
|
845
|
+
stop?.addEventListener("abort", onAbort, { once: true });
|
|
846
|
+
});
|
|
847
|
+
if (stop?.aborted) throw lastError;
|
|
827
848
|
}
|
|
828
849
|
throw lastError;
|
|
829
850
|
}
|
|
830
851
|
Object.assign(MemoryRetriever.prototype, {
|
|
831
|
-
async rerank(query, candidates, queryVector) {
|
|
852
|
+
async rerank(query, candidates, queryVector, options) {
|
|
832
853
|
if (candidates.length === 0) return { candidates };
|
|
833
854
|
if (this.config.rerank === "none") return { candidates };
|
|
834
855
|
const provider = this.config.rerankProvider ?? "none";
|
|
856
|
+
const unranked = () => provider === "sno-gpu" ? this.rerankLightweight(candidates, queryVector) : candidates;
|
|
835
857
|
if (this.config.rerank === "cross-encoder" && !this.config.rerankApiKey) throw new RetrievalError(`rerank "cross-encoder" requires retrieval.rerankApiKey (provider: ${provider}); set the key, or set retrieval.rerank to "lightweight" to choose the local ranker`);
|
|
836
858
|
if (this.config.rerank === "lightweight" || !this.config.rerankApiKey) return { candidates: this.rerankLightweight(candidates, queryVector) };
|
|
837
859
|
const rerankEndpoint = this.config.rerankEndpoint ?? RERANK_DEFAULT_ENDPOINTS[provider];
|
|
@@ -843,7 +865,7 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
843
865
|
site_id: "retrieval.retriever-rerank.rerank.6fbc6b3a22"
|
|
844
866
|
});
|
|
845
867
|
return {
|
|
846
|
-
candidates,
|
|
868
|
+
candidates: unranked(),
|
|
847
869
|
fallback: {
|
|
848
870
|
reason: "no_endpoint",
|
|
849
871
|
provider
|
|
@@ -851,6 +873,8 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
851
873
|
};
|
|
852
874
|
}
|
|
853
875
|
const rerankTimeoutMs = this.config.rerankTimeoutMs ?? 15e3;
|
|
876
|
+
const stepEnds = [options?.signal, provider === "sno-gpu" ? AbortSignal.timeout(Math.max(0, Math.floor(options?.deadlineAt === void 0 ? rerankTimeoutMs : options.deadlineAt - Date.now()))) : void 0].filter((each) => each !== void 0);
|
|
877
|
+
const stepStop = stepEnds.length > 0 ? AbortSignal.any(stepEnds) : void 0;
|
|
854
878
|
const rerankApiKey = this.config.rerankApiKey;
|
|
855
879
|
const maxCandidates = this.config.rerankMaxCandidates;
|
|
856
880
|
const overCap = maxCandidates !== void 0 && candidates.length > maxCandidates;
|
|
@@ -871,7 +895,7 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
871
895
|
site_id: "retrieval.retriever-rerank.rerank.query_over_window"
|
|
872
896
|
});
|
|
873
897
|
return {
|
|
874
|
-
candidates,
|
|
898
|
+
candidates: unranked(),
|
|
875
899
|
fallback: {
|
|
876
900
|
reason: "query_over_window",
|
|
877
901
|
provider
|
|
@@ -901,14 +925,17 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
901
925
|
const { headers, body } = buildRerankRequest(provider, rerankApiKey, this.config.rerankModel ?? "rerank-2", query, batchTexts, batchTexts.length);
|
|
902
926
|
const { response, data } = await fetchRerankWithRetry(() => fetch(rerankEndpoint, {
|
|
903
927
|
method: "POST",
|
|
904
|
-
headers
|
|
928
|
+
headers: provider === "sno-gpu" ? {
|
|
929
|
+
...headers,
|
|
930
|
+
"X-Request-ID": randomUUID()
|
|
931
|
+
} : headers,
|
|
905
932
|
body: JSON.stringify(body),
|
|
906
|
-
signal: AbortSignal.timeout(rerankTimeoutMs)
|
|
907
|
-
}));
|
|
933
|
+
signal: stepStop ? AbortSignal.any([AbortSignal.timeout(rerankTimeoutMs), stepStop]) : AbortSignal.timeout(rerankTimeoutMs)
|
|
934
|
+
}), stepStop);
|
|
908
935
|
if (!response.ok) {
|
|
909
936
|
const retryAfter = response.headers.get("retry-after");
|
|
910
937
|
const fatalError = buildRerankHttpError(response.status);
|
|
911
|
-
if (fatalError) throw fatalError;
|
|
938
|
+
if (fatalError && provider !== "sno-gpu") throw fatalError;
|
|
912
939
|
const errorBody = await response.text().catch(() => "<unreadable body>");
|
|
913
940
|
const refusal = pass === 0 ? parseOverWindowRefusal(errorBody) : void 0;
|
|
914
941
|
if (refusal) {
|
|
@@ -984,7 +1011,7 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
984
1011
|
for (const outcome of settled) if (outcome.status === "rejected" && outcome.reason instanceof RetrievalError) throw outcome.reason;
|
|
985
1012
|
for (const outcome of settled) if (outcome.status === "rejected") throw outcome.reason;
|
|
986
1013
|
for (const outcome of settled) if (outcome.status === "fulfilled" && typeof outcome.value === "string") return {
|
|
987
|
-
candidates,
|
|
1014
|
+
candidates: unranked(),
|
|
988
1015
|
fallback: {
|
|
989
1016
|
reason: outcome.value,
|
|
990
1017
|
provider
|
|
@@ -1004,7 +1031,7 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
1004
1031
|
if (!candidate) continue;
|
|
1005
1032
|
const sourceScore = this.getRerankSourceScore(candidate);
|
|
1006
1033
|
let crossScore = item.score;
|
|
1007
|
-
if (provider === "tei") crossScore = 1 / (1 + Math.exp(-item.score));
|
|
1034
|
+
if (provider === "tei" || provider === "sno-gpu") crossScore = 1 / (1 + Math.exp(-item.score));
|
|
1008
1035
|
const blendedScore = clamp01(crossScore * blendCross + sourceScore * blendVector, 0);
|
|
1009
1036
|
reranked.push({
|
|
1010
1037
|
...candidate,
|
|
@@ -1066,7 +1093,7 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
1066
1093
|
});
|
|
1067
1094
|
}
|
|
1068
1095
|
return {
|
|
1069
|
-
candidates,
|
|
1096
|
+
candidates: unranked(),
|
|
1070
1097
|
fallback: {
|
|
1071
1098
|
reason,
|
|
1072
1099
|
provider
|
|
@@ -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-
|
|
1
|
+
import { h as MemoryCategory, l as DecayScore, r as AggregationQuery, u as DecayableMemory, x as RetrievalResult, y as MemorySearchResult } from "./types-DZGL4QXi.js";
|
|
2
2
|
import { sn as RecallLifecycleConfig } from "./index-Pb9LrHgL.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-BQ8tBY-g.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-CTAMKigD.js";
|
|
8
|
+
import "./store-DraRJ-HI.js";
|
|
9
|
+
import { n as AccessTracker } from "./access-tracker-CglGg8uS.js";
|
|
10
|
+
import { r as TierPromoter } from "./memory-tier-promoter-CSGa4LBH.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,7 @@ 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";
|
|
212
|
+
type RerankProvider = "jina" | "siliconflow" | "voyage" | "pinecone" | "dashscope" | "tei" | "sno-gpu";
|
|
213
213
|
interface RetrievalConfig {
|
|
214
214
|
/** Enable the historical recency, decay, and retention score transforms. */
|
|
215
215
|
temporalWeighting: boolean;
|
|
@@ -288,6 +288,8 @@ interface RetrievalContext {
|
|
|
288
288
|
*/
|
|
289
289
|
includeRefused?: boolean;
|
|
290
290
|
signal?: AbortSignal;
|
|
291
|
+
/** 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. */
|
|
292
|
+
rerankDeadlineAt?: number;
|
|
291
293
|
sessionId?: string;
|
|
292
294
|
explicitLocale?: string;
|
|
293
295
|
/** Retrieval source: "manual" for user-triggered, "auto-recall" for system-initiated, "cli" for CLI commands */
|
|
@@ -452,7 +454,10 @@ interface MemoryRetrieverInternals {
|
|
|
452
454
|
precisionRecall(context: RetrievalContext, trace?: TraceCollector): Promise<RetrievalResult[]>;
|
|
453
455
|
aggregationComplete(context: RetrievalContext, trace?: TraceCollector): Promise<RetrievalResult[]>;
|
|
454
456
|
rrfFuse(vector: MemorySearchResult[], keyword: MemorySearchResult[]): RetrievalResult[];
|
|
455
|
-
rerank(query: string, candidates: RetrievalResult[], queryVector: Float32Array
|
|
457
|
+
rerank(query: string, candidates: RetrievalResult[], queryVector: Float32Array, options?: {
|
|
458
|
+
signal?: AbortSignal;
|
|
459
|
+
deadlineAt?: number;
|
|
460
|
+
}): Promise<RerankOutcome>;
|
|
456
461
|
rerankLightweight(candidates: RetrievalResult[], queryVector: Float32Array): RetrievalResult[];
|
|
457
462
|
getRerankSourceScore(result: RetrievalResult): number;
|
|
458
463
|
applyScoringPipeline(results: RetrievalResult[], trace?: TraceCollector, limit?: number): RetrievalResult[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./paths-
|
|
1
|
+
import "./paths-B5y-npWs.js";
|
|
2
2
|
//#region src/engine/operations/runtime-audit-log.d.ts
|
|
3
3
|
type AuditEvent = "tool_call" | "hook_trigger" | "kill_switch" | "startup" | "error" | "auto_recall" | "ambient_learning" | "session_summary" | "envelope_strip" | "storage_integrity" | "memory_injected" | "memory_searched" | "memory_read" | "memory_updated" | "memory_superseded" | "memory_deleted" | "memory_purged" | "rem_trigger_evaluated" | "rem_triggered" | "rem_completed" | "rem_failed";
|
|
4
4
|
type AuditStatus = "ok" | "error" | "skipped" | "partial";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { At as getAuditPath, Dt as appendAuditEntryStrict, K as REM_BUILT_OPERATION_TYPES, Ot as compactAuditLog, Pt as readJsonlLines, bt as ModelCallRefusedError, d as RemJobStore, f as parseRemJobStats, n as remNeedsHost, q as parseRemOperationType } from "./rem-trigger-
|
|
2
|
-
import {
|
|
1
|
+
import { At as getAuditPath, Dt as appendAuditEntryStrict, K as REM_BUILT_OPERATION_TYPES, Ot as compactAuditLog, Pt as readJsonlLines, bt as ModelCallRefusedError, d as RemJobStore, f as parseRemJobStats, n as remNeedsHost, q as parseRemOperationType } from "./rem-trigger-B1P5_RqV.js";
|
|
2
|
+
import { C as getSnoStationMemStateDir, Fr as MEMORY_SKIN_HEADER, Lr as memoryMethod, Mr as MEMORY_ERROR_STATUS, Pr as MEMORY_ROUTES, S as getSidecarSocketPath, _ as readRemTestHoldMs, c as REM_SIDECAR_ORIGIN, d as getRemDiscoveryPath, f as getRemJobJournalPath, g as readRemOperationalConfig, i as REM_JOBS_PATH_PREFIX, jr as MEMORY_DEFAULT_SKIN_ID, l as REM_SOURCE, r as REM_CORRELATION_ID_HEADER, rr as MEMORY_SHUTDOWN_TIMEOUT_MS, s as REM_SIDECAR_HOST, u as getRemChassisJournalPath, v as SettingsUnavailableError, y as getDiscoveryPath } from "./config-D_KOwEyg.js";
|
|
3
3
|
import { t as ContractError } from "./error-D-wb-rZw.js";
|
|
4
4
|
import { setImmediate } from "node:timers/promises";
|
|
5
5
|
import { createLogger, currentLogContext, effectiveLogLevel, emitDiagnostic } from "@snoai/utils/logger";
|
|
@@ -88,8 +88,9 @@ async function serveMemoryRoute(request, response, pathname, openPool, activeTas
|
|
|
88
88
|
let timer;
|
|
89
89
|
const controller = new AbortController();
|
|
90
90
|
const abort = () => controller.abort(new ContractError("timeout"));
|
|
91
|
+
const deadlineMs = performance.now() + MEMORY_ROUTES[method].timeoutMs;
|
|
91
92
|
let rejectDeadline;
|
|
92
|
-
if (method !== "capture") response.once("close", abort);
|
|
93
|
+
if (method !== "capture" || request.headers["x-sno-cancel-on-disconnect"] === "1") response.once("close", abort);
|
|
93
94
|
try {
|
|
94
95
|
const deadline = new Promise((_, reject) => {
|
|
95
96
|
rejectDeadline = () => reject(controller.signal.reason);
|
|
@@ -101,7 +102,7 @@ async function serveMemoryRoute(request, response, pathname, openPool, activeTas
|
|
|
101
102
|
controller.signal.throwIfAborted();
|
|
102
103
|
const pool = await openPool();
|
|
103
104
|
controller.signal.throwIfAborted();
|
|
104
|
-
return pool.invoke(method, body, typeof skinId === "string" && skinId.trim() ? skinId : MEMORY_DEFAULT_SKIN_ID, controller.signal);
|
|
105
|
+
return pool.invoke(method, body, typeof skinId === "string" && skinId.trim() ? skinId : MEMORY_DEFAULT_SKIN_ID, controller.signal, method === "capture" ? deadlineMs : void 0);
|
|
105
106
|
})();
|
|
106
107
|
const boundedTask = Promise.race([task, deadline]);
|
|
107
108
|
const completion = Object.assign(task.then(() => void 0, () => void 0), {
|
|
@@ -334,7 +335,7 @@ async function startOwnedRemSidecar() {
|
|
|
334
335
|
async open() {
|
|
335
336
|
if (currentMemory) return currentMemory;
|
|
336
337
|
if (settingsError) throw settingsError;
|
|
337
|
-
openingMemory ??= import("./memory-runtime-
|
|
338
|
+
openingMemory ??= import("./memory-runtime-4iOpeP09.js").then((module) => module.MemoryRuntimePool.open()).then((pool) => {
|
|
338
339
|
currentMemory = pool;
|
|
339
340
|
if (stopping) pool.stopTimers();
|
|
340
341
|
return pool;
|
|
@@ -729,7 +730,7 @@ async function runChassisJob(store, journal, waveId, holdMs, runtime) {
|
|
|
729
730
|
cleanRefusalReasons.push(reason);
|
|
730
731
|
await appendChassisRefusal(journal, queued, operation, "refused", reason);
|
|
731
732
|
}
|
|
732
|
-
const { runRemProductionOrderedWave } = await import("./rem-batch-executor-
|
|
733
|
+
const { runRemProductionOrderedWave } = await import("./rem-batch-executor-CfWChDAk.js");
|
|
733
734
|
const result = enabledOperations.length === 0 ? {
|
|
734
735
|
decision: "allow",
|
|
735
736
|
reasonCode: null,
|
package/dist/sidecar/main.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Nr as MEMORY_RECONNECT_INTERVAL_MS, m as isRemTraceEnabled, p as getRemTraceLogPath, v as SettingsUnavailableError } from "../config-D_KOwEyg.js";
|
|
2
2
|
import { setTimeout } from "node:timers/promises";
|
|
3
3
|
import { addLogFileTarget, closeLogger, createLogger } from "@snoai/utils/logger";
|
|
4
4
|
//#region src/sidecar/main.ts
|
|
@@ -6,7 +6,7 @@ import { addLogFileTarget, closeLogger, createLogger } from "@snoai/utils/logger
|
|
|
6
6
|
* @purpose Boots the standalone local REM sidecar process.
|
|
7
7
|
* @boundary Process environment, sidecar lifecycle, and local request-log destination.
|
|
8
8
|
*/
|
|
9
|
-
const { startRemSidecar, DuplicateSidecarError } = await import("../server-
|
|
9
|
+
const { startRemSidecar, DuplicateSidecarError } = await import("../server-DOL3D6bb.js");
|
|
10
10
|
let sidecar;
|
|
11
11
|
for (let attempt = 1; !sidecar; attempt++) try {
|
|
12
12
|
sidecar = await startRemSidecar();
|