@snoai/memory 1.2.14 → 1.5.0
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-DT04huAG.d.ts → access-tracker-B1H2AJlH.d.ts} +4 -4
- package/dist/{adapter-BMx-VcJy.d.ts → adapter-CgdVA88V.d.ts} +2 -2
- package/dist/{atomic-memory-extraction-_OEsSJbC.d.ts → atomic-memory-extraction-DCMTQ0h-.d.ts} +4 -4
- package/dist/{b-profile-section-dictionary-provider-DTE4uWyh.d.ts → b-profile-section-dictionary-provider-DbqdRYMw.d.ts} +1 -1
- package/dist/{capture-policy-detector-B8sqRTlB.d.ts → capture-policy-detector-D4ziS7KF.d.ts} +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/{config-C1X5rsAx.js → config-DWeuetYo.js} +735 -396
- package/dist/{derived-suppression-cache-Cha_e2Cr.d.ts → derived-suppression-cache-2xOq6XHX.d.ts} +1 -1
- package/dist/diagnostic-encoder.js +1 -1
- package/dist/{embedding-provider-client-vynZMuit.d.ts → embedding-provider-client-CELWtPgt.d.ts} +6 -0
- package/dist/{embedding-provider-client-40tpzKou.js → embedding-provider-client-CgpUK_1G.js} +16 -1
- package/dist/{index-8CfO_-6T.d.ts → index-BGu91bjB.d.ts} +19 -4
- package/dist/{index-C8tTzfrH.d.ts → index-PjHhlG6e.d.ts} +2 -2
- package/dist/index.d.ts +10 -10
- package/dist/internal/config/index.d.ts +2 -2
- package/dist/internal/config/index.js +19 -4
- package/dist/internal/config/plugin-config-schema.d.ts +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/skin-defaults.d.ts +1 -1
- package/dist/internal/contract/profile.d.ts +1 -1
- package/dist/internal/contract/routes.d.ts +1 -1
- package/dist/internal/engine/bindings/memory-cli-shared.d.ts +5 -5
- package/dist/internal/engine/bindings/memory-tool-access.d.ts +1 -1
- package/dist/internal/engine/bindings/memory-tool-results.d.ts +1 -1
- package/dist/internal/engine/bindings/memory-tool-schemas.d.ts +6 -6
- package/dist/internal/engine/bindings/sno-station-mem-ambient-learning-hook.d.ts +5 -5
- package/dist/internal/engine/bindings/sno-station-mem-ambient-learning-hook.js +1 -1
- 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 +1 -1
- 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 +1 -1
- package/dist/internal/engine/bindings/sno-station-mem-message-transcript.js +1 -1
- package/dist/internal/engine/bindings/sno-station-mem-reset-hook.d.ts +4 -4
- 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/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/embedding-provider-client.d.ts +1 -1
- package/dist/internal/engine/extraction/embedding-provider-client.js +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/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-embedder.js +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-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/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/reflection-command-hooks.d.ts +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-injection-hooks.d.ts +1 -1
- package/dist/internal/engine/reflection/reflection-lifecycle-hooks.d.ts +1 -1
- package/dist/internal/engine/reflection/strategy-hook-runner.d.ts +3 -3
- 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/telemetry/observe-ledger.d.ts +1 -1
- package/dist/internal/model/llm-client.d.ts +2 -2
- 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 +2 -2
- package/dist/internal/store/store.d.ts +2 -2
- package/dist/{llm-client-BoClMktv.d.ts → llm-client-C-K7oyfu.d.ts} +1 -1
- package/dist/{log-site-catalog.generated-DGia_6ZR.js → log-site-catalog.generated-Cn8rTa65.js} +58 -44
- package/dist/log-site-catalog.json +1 -1
- package/dist/{memory-kind-policy-C7p4o8ru.d.ts → memory-kind-policy-DgPCjfY4.d.ts} +1 -1
- package/dist/{memory-metadata-codec-CFY8YtXf.d.ts → memory-metadata-codec-CfP9JLVO.d.ts} +1 -1
- package/dist/{memory-runtime-CCPRiAk9.js → memory-runtime-jQke2sBc.js} +61 -47
- package/dist/{memory-snapshot-DADY3InD.d.ts → memory-snapshot-B6a-6nJ7.d.ts} +2 -2
- package/dist/{memory-store-base-D0bLwzyF.d.ts → memory-store-base-upd9MuG6.d.ts} +4 -4
- package/dist/{memory-temporality-classifier-DL14kjtv.d.ts → memory-temporality-classifier-DPk3_9Or.d.ts} +1 -1
- package/dist/{memory-tier-promoter-Cf1OdoZK.d.ts → memory-tier-promoter-Cq23yveQ.d.ts} +1 -1
- package/dist/memory-tool-dependencies-C9qgVGOn.d.ts +14 -0
- package/dist/{observable-embedder-CPyX9y7c.d.ts → observable-embedder-DihQuuQD.d.ts} +2 -2
- package/dist/{observable-llm-client-C8ndPJck.d.ts → observable-llm-client-BglDBFN5.d.ts} +3 -3
- package/dist/{observable-memory-store-DhOfgjkU.d.ts → observable-memory-store--n02Dre8.d.ts} +5 -5
- package/dist/{observable-retriever-CUlmCFy5.d.ts → observable-retriever-CV6odifA.d.ts} +6 -6
- package/dist/paths-qJqwGcKl.d.ts +1 -0
- package/dist/{plugin-config-schema-BPg-ppSt.d.ts → plugin-config-schema-dV2_HgBo.d.ts} +1 -1
- package/dist/{profile-BksZRjJ8.d.ts → profile-CoLKGobS.d.ts} +1 -1
- package/dist/{reflection-command-hooks-mCOmD8b6.d.ts → reflection-command-hooks-Cfv836Wc.d.ts} +4 -4
- package/dist/{reflection-deps-BYkAaKxD.d.ts → reflection-deps-DihlwQxE.d.ts} +3 -3
- package/dist/{reflection-embedded-generator-ve1PhgUY.d.ts → reflection-embedded-generator-DCZaS6kz.d.ts} +3 -3
- package/dist/{reflection-injection-hooks-CphBCA9F.d.ts → reflection-injection-hooks-BYxkrds6.d.ts} +4 -4
- package/dist/{reflection-lifecycle-hooks-CFGYh_8m.d.ts → reflection-lifecycle-hooks-Bwq2y5pe.d.ts} +3 -3
- package/dist/{rem-batch-executor-TSYG7oVi.js → rem-batch-executor-B_49KivZ.js} +1 -1
- package/dist/{rem-trigger-i_E8I9lv.js → rem-trigger-DL0MlLeo.js} +88 -7
- package/dist/{retriever-Dnjl_FHu.js → retriever-CsBW6MZv.js} +71 -5
- package/dist/{retriever-6ybsoVuY.d.ts → retriever-hTIkt3CJ.d.ts} +12 -9
- package/dist/{runtime-audit-log-DWpWmCx5.d.ts → runtime-audit-log-eBrt_iPp.d.ts} +1 -1
- package/dist/{server-DsaVeSaM.js → server-BnBzsvMF.js} +9 -9
- package/dist/sidecar/main.js +2 -2
- package/dist/sno-station-mem-runtime-dependencies-9L8WkMMV.d.ts +31 -0
- package/dist/{sno-station-mem-runtime-dependencies-zzcjHD_N.js → sno-station-mem-runtime-dependencies-DrVDRAmf.js} +1 -1
- package/dist/{store-HyzTUvwj.d.ts → store-DEG06TLb.d.ts} +2 -2
- package/dist/{strategy-hook-runner-B_m1L5CB.d.ts → strategy-hook-runner-D1sRVThs.d.ts} +7 -7
- package/dist/{types-Dm_XhSne.d.ts → types-DBEwNYdR.d.ts} +1 -1
- package/package.json +2 -2
- package/dist/memory-tool-dependencies-Bxdpvs3Z.d.ts +0 -14
- package/dist/paths-DnNN0G1t.d.ts +0 -1
- package/dist/sno-station-mem-runtime-dependencies-DtKDYdsh.d.ts +0 -31
|
@@ -1,14 +1,14 @@
|
|
|
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
|
|
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 LocalReranker, 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, G as FIXED_EXTERNAL_VALUE_55, H as FIXED_EXTERNAL_VALUE_52, Hn as HEAD_EXTRACT_OVERLAP_DROP_RATIO, In as EMBEDDER_MODEL_DEFAULT, Ir as REM_SIDECAR_TOKEN_HEADER, 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, Or as ensureModelDownloaded, 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-DWeuetYo.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";
|
|
5
5
|
import { arch, availableParallelism, platform } from "node:os";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { createHash, createHmac, createPublicKey, randomUUID, randomUUID as randomUUID$1, timingSafeEqual, verify } from "node:crypto";
|
|
7
8
|
import { LRUCache } from "lru-cache";
|
|
8
9
|
import { z } from "zod";
|
|
9
10
|
import { CHUNKING_VERSION, aggregateChunksToMemories, buildChunkId, buildDensePayload, chunk, chunk as chunk$1, countTokens, expandSnippetWindow, extractMetadataHeader, headExtract, shouldDropSummary } from "@snoai/chunking";
|
|
10
11
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
11
|
-
import { createHash, createHmac, createPublicKey, randomUUID, randomUUID as randomUUID$1, timingSafeEqual, verify } from "node:crypto";
|
|
12
12
|
import { getDek, openEncryptedDb, openEncryptedDbReadonly } from "@snoai/sqlite-crypto";
|
|
13
13
|
import { appendFile, mkdir, open, readFile, rename, rm } from "node:fs/promises";
|
|
14
14
|
import { Temporal } from "@js-temporal/polyfill";
|
|
@@ -26400,6 +26400,7 @@ var Embedder = class {
|
|
|
26400
26400
|
model;
|
|
26401
26401
|
warmupPromise = null;
|
|
26402
26402
|
modelDownload;
|
|
26403
|
+
reranker;
|
|
26403
26404
|
/**
|
|
26404
26405
|
* Initializes embedding generation collaborators while keeping runtime work in explicit
|
|
26405
26406
|
* methods.
|
|
@@ -26417,6 +26418,12 @@ var Embedder = class {
|
|
|
26417
26418
|
this.dimensions = inner.dimension;
|
|
26418
26419
|
this.providerKind = providerKind;
|
|
26419
26420
|
this.model = config.model && config.model.trim().length > 0 ? config.model : LOCAL_EMBEDDING_MODEL;
|
|
26421
|
+
this.reranker = new LocalReranker({
|
|
26422
|
+
cacheDir: resolveEmbeddingCacheDir(config),
|
|
26423
|
+
offline: config.offline === true,
|
|
26424
|
+
...config.mirror ? { mirror: config.mirror } : {},
|
|
26425
|
+
intraOpNumThreads: config.sessionOptions?.intraOpNumThreads ?? Math.max(1, Math.min(4, Math.floor(availableParallelism() / 2)))
|
|
26426
|
+
});
|
|
26420
26427
|
this.provider = new CachedEmbeddingProvider(inner, {
|
|
26421
26428
|
maxSize: 256,
|
|
26422
26429
|
ttlMs: CACHE_TTL_MS
|
|
@@ -26586,11 +26593,19 @@ var Embedder = class {
|
|
|
26586
26593
|
});
|
|
26587
26594
|
return this.warmupPromise;
|
|
26588
26595
|
}
|
|
26596
|
+
/**
|
|
26597
|
+
* Local relevance scores (raw logits, higher is more relevant) for each text against the query, or undefined while
|
|
26598
|
+
* the local reranker is not loaded; the first call starts loading it in the background.
|
|
26599
|
+
*/
|
|
26600
|
+
scoreRelevance(query, texts, signal) {
|
|
26601
|
+
return this.reranker.score(query, texts, signal);
|
|
26602
|
+
}
|
|
26589
26603
|
/** Implements dispose as the local embedding generation operation. */
|
|
26590
26604
|
async dispose() {
|
|
26591
26605
|
const warmup = this.warmupPromise;
|
|
26592
26606
|
if (warmup) await warmup.catch(() => void 0);
|
|
26593
26607
|
await this.provider.dispose();
|
|
26608
|
+
await this.reranker.dispose();
|
|
26594
26609
|
}
|
|
26595
26610
|
};
|
|
26596
26611
|
/** Creates the embedder facade around the local ONNX provider. */
|
|
@@ -27509,7 +27524,7 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
27509
27524
|
rerankFallbackReason: rerankOutcome.fallback.reason
|
|
27510
27525
|
} : rerankOutcome.stats;
|
|
27511
27526
|
trace?.endStage(fused.map((r) => r.entry.id), fused.map((r) => r.score), rerankStageMetadata);
|
|
27512
|
-
fused = this.applyScoringPipeline(fused, trace, context.limit);
|
|
27527
|
+
fused = this.applyScoringPipeline(fused, trace, context.limit, rerankOutcome.modelOrder);
|
|
27513
27528
|
trace?.startStage("min_score_filter", fused.map((result) => result.entry.id));
|
|
27514
27529
|
fused = fused.filter((result) => result.score >= (context.minScore ?? this.config.minScore));
|
|
27515
27530
|
trace?.endStage(fused.map((result) => result.entry.id), fused.map((result) => result.score));
|
|
@@ -27723,7 +27738,7 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
27723
27738
|
if (this.config.rerank === "none") return { candidates };
|
|
27724
27739
|
const unranked = () => this.rerankLightweight(candidates, queryVector);
|
|
27725
27740
|
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");
|
|
27726
|
-
if (this.config.rerank === "lightweight" || !this.config.rerankApiKey) return
|
|
27741
|
+
if (this.config.rerank === "lightweight" || !this.config.rerankApiKey) return await this.rerankLocalModel(query, this.rerankLightweight(candidates, queryVector), options?.deadlineAt, options?.signal);
|
|
27727
27742
|
const rerankEndpoint = this.config.rerankEndpoint;
|
|
27728
27743
|
if (!rerankEndpoint) {
|
|
27729
27744
|
log$4.warn("rerank skipped: no reranker address", {}, {
|
|
@@ -27992,8 +28007,8 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
27992
28007
|
if (candidates.length === 0) return candidates;
|
|
27993
28008
|
const chunkIds = candidates.map((c) => c.chunkId).filter((id) => id !== void 0);
|
|
27994
28009
|
const vectorMap = chunkIds.length > 0 ? this.store.getVectorsByIds(chunkIds) : /* @__PURE__ */ new Map();
|
|
27995
|
-
const wF = this.config.lightweightFusionWeight ?? .
|
|
27996
|
-
const wC = this.config.lightweightCosineWeight ?? .
|
|
28010
|
+
const wF = this.config.lightweightFusionWeight ?? .1;
|
|
28011
|
+
const wC = this.config.lightweightCosineWeight ?? .9;
|
|
27997
28012
|
let blendedCount = 0;
|
|
27998
28013
|
let dimMismatchCount = 0;
|
|
27999
28014
|
const reranked = candidates.map((candidate) => {
|
|
@@ -28053,6 +28068,58 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
28053
28068
|
return a.entry.id.localeCompare(b.entry.id);
|
|
28054
28069
|
});
|
|
28055
28070
|
},
|
|
28071
|
+
/**
|
|
28072
|
+
* The local reranker model reorders the first candidates of the local ranking. Their order is unchanged while the
|
|
28073
|
+
* model is not loaded yet (the first call starts loading it), past the caller's deadline, and after a cancel.
|
|
28074
|
+
*/
|
|
28075
|
+
async rerankLocalModel(query, ordered, deadlineAt, signal) {
|
|
28076
|
+
if (ordered.length < 2 || signal?.aborted || deadlineAt !== void 0 && Date.now() >= deadlineAt) return { candidates: ordered };
|
|
28077
|
+
const head = ordered.slice(0, 15);
|
|
28078
|
+
const started = performance.now();
|
|
28079
|
+
const budgetMs = deadlineAt === void 0 ? this.config.rerankTimeoutMs ?? 15e3 : Math.max(0, Math.floor(deadlineAt - Date.now()));
|
|
28080
|
+
const stop = signal ? AbortSignal.any([signal, AbortSignal.timeout(budgetMs)]) : AbortSignal.timeout(budgetMs);
|
|
28081
|
+
const scoring = this.embedder.scoreRelevance(query, head.map((r) => r.entry.text), stop).catch((error) => {
|
|
28082
|
+
log$4.warn("local reranker failed; recall keeps the local ranking order", { error }, {
|
|
28083
|
+
event_name: "memory.retriever_rerank.diagnostic",
|
|
28084
|
+
file: "packages/memory/src/engine/retrieval/retriever-rerank.ts",
|
|
28085
|
+
function: "rerankLocalModel",
|
|
28086
|
+
site_id: "retrieval.retriever-rerank.rerankLocalModel.failed"
|
|
28087
|
+
});
|
|
28088
|
+
});
|
|
28089
|
+
const logits = await Promise.race([scoring, new Promise((resolve) => stop.addEventListener("abort", () => resolve(void 0), { once: true }))]);
|
|
28090
|
+
if (!logits || signal?.aborted) return { candidates: ordered };
|
|
28091
|
+
const blended = head.map((candidate, index) => ({
|
|
28092
|
+
candidate,
|
|
28093
|
+
value: logits[index] ?? Number.NEGATIVE_INFINITY
|
|
28094
|
+
}));
|
|
28095
|
+
blended.sort((a, b) => b.value - a.value || a.candidate.entry.id.localeCompare(b.candidate.entry.id));
|
|
28096
|
+
const slots = head.map((candidate) => candidate.score).sort((a, b) => b - a);
|
|
28097
|
+
const rescored = blended.map(({ candidate }, index) => {
|
|
28098
|
+
const score = slots[index] ?? candidate.score;
|
|
28099
|
+
return {
|
|
28100
|
+
...candidate,
|
|
28101
|
+
score,
|
|
28102
|
+
rerankScore: score,
|
|
28103
|
+
sources: {
|
|
28104
|
+
...candidate.sources,
|
|
28105
|
+
reranked: { score }
|
|
28106
|
+
}
|
|
28107
|
+
};
|
|
28108
|
+
});
|
|
28109
|
+
log$4.debug("local reranker applied", {
|
|
28110
|
+
scored: head.length,
|
|
28111
|
+
duration_ms: performance.now() - started
|
|
28112
|
+
}, {
|
|
28113
|
+
event_name: "memory.retriever_rerank.diagnostic",
|
|
28114
|
+
file: "packages/memory/src/engine/retrieval/retriever-rerank.ts",
|
|
28115
|
+
function: "rerankLocalModel",
|
|
28116
|
+
site_id: "retrieval.retriever-rerank.rerankLocalModel.applied"
|
|
28117
|
+
});
|
|
28118
|
+
return {
|
|
28119
|
+
candidates: [...rescored, ...ordered.slice(head.length)],
|
|
28120
|
+
modelOrder: blended.map(({ candidate }) => candidate.entry.id)
|
|
28121
|
+
};
|
|
28122
|
+
},
|
|
28056
28123
|
getRerankSourceScore(result) {
|
|
28057
28124
|
return clamp01(Math.max(result.sources.bm25?.score ?? 0, result.sources.vector?.score ?? 0), 0);
|
|
28058
28125
|
}
|
|
@@ -28244,8 +28311,21 @@ function tracedStage(trace, name, skipReason, run, input) {
|
|
|
28244
28311
|
trace.endStage(output.map((result) => result.entry.id), output.map((result) => result.score), skipReason === void 0 ? void 0 : { skipped: skipReason });
|
|
28245
28312
|
return output;
|
|
28246
28313
|
}
|
|
28314
|
+
/** The candidates the local reranker model scored take their own scores, highest first, in its order. */
|
|
28315
|
+
function orderByLocalModel(results, modelOrder) {
|
|
28316
|
+
const present = new Set(results.map((result) => result.entry.id));
|
|
28317
|
+
const order = modelOrder.filter((id) => present.has(id));
|
|
28318
|
+
if (order.length < 2) return results;
|
|
28319
|
+
const judged = new Set(order);
|
|
28320
|
+
const slots = results.filter((result) => judged.has(result.entry.id)).map((result) => result.score).sort((a, b) => b - a);
|
|
28321
|
+
const scores = new Map(order.map((id, index) => [id, slots[index] ?? 0]));
|
|
28322
|
+
return results.map((result) => ({
|
|
28323
|
+
...result,
|
|
28324
|
+
score: scores.get(result.entry.id) ?? result.score
|
|
28325
|
+
})).sort((a, b) => b.score - a.score);
|
|
28326
|
+
}
|
|
28247
28327
|
Object.assign(MemoryRetriever.prototype, {
|
|
28248
|
-
applyScoringPipeline(results, trace, limit = results.length) {
|
|
28328
|
+
applyScoringPipeline(results, trace, limit = results.length, modelOrder) {
|
|
28249
28329
|
const stage = (name, skipReason, run, input) => tracedStage(trace, name, skipReason, run, input);
|
|
28250
28330
|
const temporalOff = !this.config.temporalWeighting;
|
|
28251
28331
|
let scored = stage("recency_boost", temporalOff ? "temporalWeighting" : this.config.recencyHalfLifeDays <= 0 ? "recencyHalfLifeDays" : this.config.recencyWeight <= 0 ? "recencyWeight" : void 0, (input) => temporalOff ? input : this.applyRecencyBoost(input), results);
|
|
@@ -28253,6 +28333,7 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
28253
28333
|
scored = stage("length_normalization", this.config.lengthNormAnchor <= 0 ? "lengthNormAnchor" : void 0, (input) => this.applyLengthNormalization(input), scored);
|
|
28254
28334
|
scored = stage("time_decay", temporalOff ? "temporalWeighting" : this.config.timeDecayHalfLifeDays <= 0 ? "timeDecayHalfLifeDays" : void 0, (input) => temporalOff ? input : this.applyTimeDecay(input), scored);
|
|
28255
28335
|
scored = stage("retention_boost", temporalOff ? "temporalWeighting" : this.config.recallLifecycle?.retentionScorer === true ? void 0 : "recallLifecycle.retentionScorer", (input) => temporalOff ? input : this.applyRetentionBoost(input), scored);
|
|
28336
|
+
scored = stage("local_model_order", modelOrder ? void 0 : "modelOrder", (input) => modelOrder ? orderByLocalModel(input, modelOrder) : input, scored);
|
|
28256
28337
|
scored = stage("hard_min_score", void 0, (input) => input.filter((result) => result.score >= this.config.hardMinScore), scored);
|
|
28257
28338
|
const mmrOff = experimentMmrDisabled();
|
|
28258
28339
|
scored = stage("mmr_diversity", mmrOff ? "experiment.disableMmr" : void 0, (input) => {
|
|
@@ -552,7 +552,7 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
552
552
|
rerankFallbackReason: rerankOutcome.fallback.reason
|
|
553
553
|
} : rerankOutcome.stats;
|
|
554
554
|
trace?.endStage(fused.map((r) => r.entry.id), fused.map((r) => r.score), rerankStageMetadata);
|
|
555
|
-
fused = this.applyScoringPipeline(fused, trace, context.limit);
|
|
555
|
+
fused = this.applyScoringPipeline(fused, trace, context.limit, rerankOutcome.modelOrder);
|
|
556
556
|
trace?.startStage("min_score_filter", fused.map((result) => result.entry.id));
|
|
557
557
|
fused = fused.filter((result) => result.score >= (context.minScore ?? this.config.minScore));
|
|
558
558
|
trace?.endStage(fused.map((result) => result.entry.id), fused.map((result) => result.score));
|
|
@@ -766,7 +766,7 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
766
766
|
if (this.config.rerank === "none") return { candidates };
|
|
767
767
|
const unranked = () => this.rerankLightweight(candidates, queryVector);
|
|
768
768
|
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");
|
|
769
|
-
if (this.config.rerank === "lightweight" || !this.config.rerankApiKey) return
|
|
769
|
+
if (this.config.rerank === "lightweight" || !this.config.rerankApiKey) return await this.rerankLocalModel(query, this.rerankLightweight(candidates, queryVector), options?.deadlineAt, options?.signal);
|
|
770
770
|
const rerankEndpoint = this.config.rerankEndpoint;
|
|
771
771
|
if (!rerankEndpoint) {
|
|
772
772
|
log.warn("rerank skipped: no reranker address", {}, {
|
|
@@ -1036,8 +1036,8 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
1036
1036
|
if (candidates.length === 0) return candidates;
|
|
1037
1037
|
const chunkIds = candidates.map((c) => c.chunkId).filter((id) => id !== void 0);
|
|
1038
1038
|
const vectorMap = chunkIds.length > 0 ? this.store.getVectorsByIds(chunkIds) : /* @__PURE__ */ new Map();
|
|
1039
|
-
const wF = this.config.lightweightFusionWeight ?? .
|
|
1040
|
-
const wC = this.config.lightweightCosineWeight ?? .
|
|
1039
|
+
const wF = this.config.lightweightFusionWeight ?? .1;
|
|
1040
|
+
const wC = this.config.lightweightCosineWeight ?? .9;
|
|
1041
1041
|
let blendedCount = 0;
|
|
1042
1042
|
let dimMismatchCount = 0;
|
|
1043
1043
|
const reranked = candidates.map((candidate) => {
|
|
@@ -1098,6 +1098,58 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
1098
1098
|
return a.entry.id.localeCompare(b.entry.id);
|
|
1099
1099
|
});
|
|
1100
1100
|
},
|
|
1101
|
+
/**
|
|
1102
|
+
* The local reranker model reorders the first candidates of the local ranking. Their order is unchanged while the
|
|
1103
|
+
* model is not loaded yet (the first call starts loading it), past the caller's deadline, and after a cancel.
|
|
1104
|
+
*/
|
|
1105
|
+
async rerankLocalModel(query, ordered, deadlineAt, signal) {
|
|
1106
|
+
if (ordered.length < 2 || signal?.aborted || deadlineAt !== void 0 && Date.now() >= deadlineAt) return { candidates: ordered };
|
|
1107
|
+
const head = ordered.slice(0, 15);
|
|
1108
|
+
const started = performance.now();
|
|
1109
|
+
const budgetMs = deadlineAt === void 0 ? this.config.rerankTimeoutMs ?? 15e3 : Math.max(0, Math.floor(deadlineAt - Date.now()));
|
|
1110
|
+
const stop = signal ? AbortSignal.any([signal, AbortSignal.timeout(budgetMs)]) : AbortSignal.timeout(budgetMs);
|
|
1111
|
+
const scoring = this.embedder.scoreRelevance(query, head.map((r) => r.entry.text), stop).catch((error) => {
|
|
1112
|
+
log.warn("local reranker failed; recall keeps the local ranking order", { error }, {
|
|
1113
|
+
event_name: "memory.retriever_rerank.diagnostic",
|
|
1114
|
+
file: "packages/memory/src/engine/retrieval/retriever-rerank.ts",
|
|
1115
|
+
function: "rerankLocalModel",
|
|
1116
|
+
site_id: "retrieval.retriever-rerank.rerankLocalModel.failed"
|
|
1117
|
+
});
|
|
1118
|
+
});
|
|
1119
|
+
const logits = await Promise.race([scoring, new Promise((resolve) => stop.addEventListener("abort", () => resolve(void 0), { once: true }))]);
|
|
1120
|
+
if (!logits || signal?.aborted) return { candidates: ordered };
|
|
1121
|
+
const blended = head.map((candidate, index) => ({
|
|
1122
|
+
candidate,
|
|
1123
|
+
value: logits[index] ?? Number.NEGATIVE_INFINITY
|
|
1124
|
+
}));
|
|
1125
|
+
blended.sort((a, b) => b.value - a.value || a.candidate.entry.id.localeCompare(b.candidate.entry.id));
|
|
1126
|
+
const slots = head.map((candidate) => candidate.score).sort((a, b) => b - a);
|
|
1127
|
+
const rescored = blended.map(({ candidate }, index) => {
|
|
1128
|
+
const score = slots[index] ?? candidate.score;
|
|
1129
|
+
return {
|
|
1130
|
+
...candidate,
|
|
1131
|
+
score,
|
|
1132
|
+
rerankScore: score,
|
|
1133
|
+
sources: {
|
|
1134
|
+
...candidate.sources,
|
|
1135
|
+
reranked: { score }
|
|
1136
|
+
}
|
|
1137
|
+
};
|
|
1138
|
+
});
|
|
1139
|
+
log.debug("local reranker applied", {
|
|
1140
|
+
scored: head.length,
|
|
1141
|
+
duration_ms: performance.now() - started
|
|
1142
|
+
}, {
|
|
1143
|
+
event_name: "memory.retriever_rerank.diagnostic",
|
|
1144
|
+
file: "packages/memory/src/engine/retrieval/retriever-rerank.ts",
|
|
1145
|
+
function: "rerankLocalModel",
|
|
1146
|
+
site_id: "retrieval.retriever-rerank.rerankLocalModel.applied"
|
|
1147
|
+
});
|
|
1148
|
+
return {
|
|
1149
|
+
candidates: [...rescored, ...ordered.slice(head.length)],
|
|
1150
|
+
modelOrder: blended.map(({ candidate }) => candidate.entry.id)
|
|
1151
|
+
};
|
|
1152
|
+
},
|
|
1101
1153
|
getRerankSourceScore(result) {
|
|
1102
1154
|
return clamp01(Math.max(result.sources.bm25?.score ?? 0, result.sources.vector?.score ?? 0), 0);
|
|
1103
1155
|
}
|
|
@@ -1289,8 +1341,21 @@ function tracedStage(trace, name, skipReason, run, input) {
|
|
|
1289
1341
|
trace.endStage(output.map((result) => result.entry.id), output.map((result) => result.score), skipReason === void 0 ? void 0 : { skipped: skipReason });
|
|
1290
1342
|
return output;
|
|
1291
1343
|
}
|
|
1344
|
+
/** The candidates the local reranker model scored take their own scores, highest first, in its order. */
|
|
1345
|
+
function orderByLocalModel(results, modelOrder) {
|
|
1346
|
+
const present = new Set(results.map((result) => result.entry.id));
|
|
1347
|
+
const order = modelOrder.filter((id) => present.has(id));
|
|
1348
|
+
if (order.length < 2) return results;
|
|
1349
|
+
const judged = new Set(order);
|
|
1350
|
+
const slots = results.filter((result) => judged.has(result.entry.id)).map((result) => result.score).sort((a, b) => b - a);
|
|
1351
|
+
const scores = new Map(order.map((id, index) => [id, slots[index] ?? 0]));
|
|
1352
|
+
return results.map((result) => ({
|
|
1353
|
+
...result,
|
|
1354
|
+
score: scores.get(result.entry.id) ?? result.score
|
|
1355
|
+
})).sort((a, b) => b.score - a.score);
|
|
1356
|
+
}
|
|
1292
1357
|
Object.assign(MemoryRetriever.prototype, {
|
|
1293
|
-
applyScoringPipeline(results, trace, limit = results.length) {
|
|
1358
|
+
applyScoringPipeline(results, trace, limit = results.length, modelOrder) {
|
|
1294
1359
|
const stage = (name, skipReason, run, input) => tracedStage(trace, name, skipReason, run, input);
|
|
1295
1360
|
const temporalOff = !this.config.temporalWeighting;
|
|
1296
1361
|
let scored = stage("recency_boost", temporalOff ? "temporalWeighting" : this.config.recencyHalfLifeDays <= 0 ? "recencyHalfLifeDays" : this.config.recencyWeight <= 0 ? "recencyWeight" : void 0, (input) => temporalOff ? input : this.applyRecencyBoost(input), results);
|
|
@@ -1298,6 +1363,7 @@ Object.assign(MemoryRetriever.prototype, {
|
|
|
1298
1363
|
scored = stage("length_normalization", this.config.lengthNormAnchor <= 0 ? "lengthNormAnchor" : void 0, (input) => this.applyLengthNormalization(input), scored);
|
|
1299
1364
|
scored = stage("time_decay", temporalOff ? "temporalWeighting" : this.config.timeDecayHalfLifeDays <= 0 ? "timeDecayHalfLifeDays" : void 0, (input) => temporalOff ? input : this.applyTimeDecay(input), scored);
|
|
1300
1365
|
scored = stage("retention_boost", temporalOff ? "temporalWeighting" : this.config.recallLifecycle?.retentionScorer === true ? void 0 : "recallLifecycle.retentionScorer", (input) => temporalOff ? input : this.applyRetentionBoost(input), scored);
|
|
1366
|
+
scored = stage("local_model_order", modelOrder ? void 0 : "modelOrder", (input) => modelOrder ? orderByLocalModel(input, modelOrder) : input, scored);
|
|
1301
1367
|
scored = stage("hard_min_score", void 0, (input) => input.filter((result) => result.score >= this.config.hardMinScore), scored);
|
|
1302
1368
|
const mmrOff = experimentMmrDisabled();
|
|
1303
1369
|
scored = stage("mmr_diversity", mmrOff ? "experiment.disableMmr" : void 0, (input) => {
|
|
@@ -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 {
|
|
3
|
-
import { t as Embedder } from "./embedding-provider-client-
|
|
1
|
+
import { h as MemoryCategory, l as DecayScore, r as AggregationQuery, u as DecayableMemory, x as RetrievalResult, y as MemorySearchResult } from "./types-DBEwNYdR.js";
|
|
2
|
+
import { sn as RecallLifecycleConfig } from "./index-BGu91bjB.js";
|
|
3
|
+
import { t as Embedder } from "./embedding-provider-client-CELWtPgt.js";
|
|
4
4
|
import "./trace-C1JxMfs-.js";
|
|
5
|
-
import "./memory-metadata-codec-
|
|
5
|
+
import "./memory-metadata-codec-CfP9JLVO.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-upd9MuG6.js";
|
|
8
|
+
import "./store-DEG06TLb.js";
|
|
9
|
+
import { n as AccessTracker } from "./access-tracker-B1H2AJlH.js";
|
|
10
|
+
import { r as TierPromoter } from "./memory-tier-promoter-Cq23yveQ.js";
|
|
11
11
|
import "@snoai/utils/logger";
|
|
12
12
|
//#region src/engine/retrieval/retrieval-trace.d.ts
|
|
13
13
|
/** @file retrieval-trace.ts
|
|
@@ -369,6 +369,8 @@ interface RerankFallbackSignal {
|
|
|
369
369
|
}
|
|
370
370
|
interface RerankOutcome {
|
|
371
371
|
candidates: RetrievalResult[];
|
|
372
|
+
/** Ids of the candidates the local reranker model scored, in its order; the scoring pipeline restores it last. */
|
|
373
|
+
modelOrder?: string[];
|
|
372
374
|
fallback?: RerankFallbackSignal;
|
|
373
375
|
stats?: {
|
|
374
376
|
rerankSentCount: number;
|
|
@@ -449,8 +451,9 @@ interface MemoryRetrieverInternals {
|
|
|
449
451
|
deadlineAt?: number;
|
|
450
452
|
}): Promise<RerankOutcome>;
|
|
451
453
|
rerankLightweight(candidates: RetrievalResult[], queryVector: Float32Array): RetrievalResult[];
|
|
454
|
+
rerankLocalModel(query: string, ordered: RetrievalResult[], deadlineAt?: number, signal?: AbortSignal): Promise<RerankOutcome>;
|
|
452
455
|
getRerankSourceScore(result: RetrievalResult): number;
|
|
453
|
-
applyScoringPipeline(results: RetrievalResult[], trace?: TraceCollector, limit?: number): RetrievalResult[];
|
|
456
|
+
applyScoringPipeline(results: RetrievalResult[], trace?: TraceCollector, limit?: number, modelOrder?: readonly string[]): RetrievalResult[];
|
|
454
457
|
applyRecencyBoost(results: RetrievalResult[]): RetrievalResult[];
|
|
455
458
|
applyImportanceWeight(results: RetrievalResult[]): RetrievalResult[];
|
|
456
459
|
applyLengthNormalization(results: RetrievalResult[]): RetrievalResult[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./paths-
|
|
1
|
+
import "./paths-qJqwGcKl.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,16 +1,16 @@
|
|
|
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-DL0MlLeo.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, nr as MEMORY_SHUTDOWN_TIMEOUT_MS, r as REM_CORRELATION_ID_HEADER, s as REM_SIDECAR_HOST, u as getRemChassisJournalPath, v as SettingsUnavailableError, y as getDiscoveryPath } from "./config-DWeuetYo.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";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { constants, existsSync, readFileSync, rmSync } from "node:fs";
|
|
8
|
-
import { z } from "zod";
|
|
9
8
|
import { randomBytes, randomUUID } from "node:crypto";
|
|
9
|
+
import { createServer } from "node:http";
|
|
10
|
+
import { z } from "zod";
|
|
10
11
|
import { mkdir, open, readFile, rename, rm } from "node:fs/promises";
|
|
11
12
|
import { withLogContext as withLogContext$1 } from "@snoai/utils/log-context";
|
|
12
|
-
import { createConnection, createServer } from "node:net";
|
|
13
|
-
import { createServer as createServer$1 } from "node:http";
|
|
13
|
+
import { createConnection, createServer as createServer$1 } from "node:net";
|
|
14
14
|
import { tryLock } from "fs-native-extensions";
|
|
15
15
|
//#region src/contract/discovery.ts
|
|
16
16
|
const discoverySchema = z.strictObject({
|
|
@@ -268,7 +268,7 @@ async function bindSidecarSocket() {
|
|
|
268
268
|
const lock = await open(`${socketPath}.lock`, constants.O_RDWR | constants.O_CREAT | constants.O_NOFOLLOW, 384);
|
|
269
269
|
try {
|
|
270
270
|
while (!tryLock(lock.fd)) await setImmediate();
|
|
271
|
-
const guard = createServer((socket) => socket.destroy());
|
|
271
|
+
const guard = createServer$1((socket) => socket.destroy());
|
|
272
272
|
for (;;) try {
|
|
273
273
|
await new Promise((resolve, reject) => {
|
|
274
274
|
guard.once("error", reject);
|
|
@@ -335,7 +335,7 @@ async function startOwnedRemSidecar() {
|
|
|
335
335
|
async open() {
|
|
336
336
|
if (currentMemory) return currentMemory;
|
|
337
337
|
if (settingsError) throw settingsError;
|
|
338
|
-
openingMemory ??= import("./memory-runtime-
|
|
338
|
+
openingMemory ??= import("./memory-runtime-jQke2sBc.js").then((module) => module.MemoryRuntimePool.open()).then((pool) => {
|
|
339
339
|
currentMemory = pool;
|
|
340
340
|
if (stopping) pool.stopTimers();
|
|
341
341
|
return pool;
|
|
@@ -372,7 +372,7 @@ async function startOwnedRemSidecar() {
|
|
|
372
372
|
};
|
|
373
373
|
const activeTasks = /* @__PURE__ */ new Set();
|
|
374
374
|
const pendingRequests = /* @__PURE__ */ new Set();
|
|
375
|
-
const server = createServer
|
|
375
|
+
const server = createServer((request, response) => {
|
|
376
376
|
const started = performance.now();
|
|
377
377
|
const operationId = `rem-http-${randomUUID()}`;
|
|
378
378
|
const context = {};
|
|
@@ -730,7 +730,7 @@ async function runChassisJob(store, journal, waveId, holdMs, runtime) {
|
|
|
730
730
|
cleanRefusalReasons.push(reason);
|
|
731
731
|
await appendChassisRefusal(journal, queued, operation, "refused", reason);
|
|
732
732
|
}
|
|
733
|
-
const { runRemProductionOrderedWave } = await import("./rem-batch-executor-
|
|
733
|
+
const { runRemProductionOrderedWave } = await import("./rem-batch-executor-B_49KivZ.js");
|
|
734
734
|
const result = enabledOperations.length === 0 ? {
|
|
735
735
|
decision: "allow",
|
|
736
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-DWeuetYo.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-BnBzsvMF.js");
|
|
10
10
|
let sidecar;
|
|
11
11
|
for (let attempt = 1; !sidecar; attempt++) try {
|
|
12
12
|
sidecar = await startRemSidecar();
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import "./types-DBEwNYdR.js";
|
|
2
|
+
import "./index-BGu91bjB.js";
|
|
3
|
+
import "./adapter-CgdVA88V.js";
|
|
4
|
+
import "./embedding-provider-client-CELWtPgt.js";
|
|
5
|
+
import "./retriever-hTIkt3CJ.js";
|
|
6
|
+
import "./connection-3IVXpuPE.js";
|
|
7
|
+
import "./sqlite-runtime-L_ywirTm.js";
|
|
8
|
+
import "./store-DEG06TLb.js";
|
|
9
|
+
import "./access-tracker-B1H2AJlH.js";
|
|
10
|
+
import "./memory-tier-promoter-Cq23yveQ.js";
|
|
11
|
+
import "./capture-policy-detector-D4ziS7KF.js";
|
|
12
|
+
import "./memory-temporality-classifier-DPk3_9Or.js";
|
|
13
|
+
import "./runtime-audit-log-eBrt_iPp.js";
|
|
14
|
+
import "./atomic-memory-extraction-DCMTQ0h-.js";
|
|
15
|
+
import "./llm-client-C-K7oyfu.js";
|
|
16
|
+
import "./memory-snapshot-B6a-6nJ7.js";
|
|
17
|
+
import "./observable-embedder-DihQuuQD.js";
|
|
18
|
+
import "./observable-llm-client-BglDBFN5.js";
|
|
19
|
+
import "./observable-memory-store--n02Dre8.js";
|
|
20
|
+
import "./observable-retriever-CV6odifA.js";
|
|
21
|
+
import "./reflection-embedded-generator-DCZaS6kz.js";
|
|
22
|
+
import "./strategy-hook-runner-D1sRVThs.js";
|
|
23
|
+
import "./data-bootstrap-Bl3lthzE.js";
|
|
24
|
+
import "@snoai/sqlite-crypto";
|
|
25
|
+
//#region src/engine/bindings/sno-station-mem-runtime-dependencies.d.ts
|
|
26
|
+
/** Legacy parameters carry only an unused logger slot; no host operations are exposed. */
|
|
27
|
+
type SnoStationMemPluginApi = {
|
|
28
|
+
logger: unknown;
|
|
29
|
+
};
|
|
30
|
+
//#endregion
|
|
31
|
+
export { SnoStationMemPluginApi as t };
|
|
@@ -19,7 +19,7 @@ import "./internal/engine/observability/observable-embedder.js";
|
|
|
19
19
|
import "./internal/engine/observability/observable-llm-client.js";
|
|
20
20
|
import "./internal/engine/observability/observable-memory-store.js";
|
|
21
21
|
import "./internal/engine/retrieval/access-tracker.js";
|
|
22
|
-
import "./retriever-
|
|
22
|
+
import "./retriever-CsBW6MZv.js";
|
|
23
23
|
import "./internal/engine/observability/observable-retriever.js";
|
|
24
24
|
import "./internal/engine/observability/session-registry.js";
|
|
25
25
|
import "./daily-log-generator-DEsiCs7o.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./embedding-provider-client-
|
|
2
|
-
import { B as TaskLifecycleMigrationManifest, H as TaskLifecycleMigrationSourceRow, a as AtomicExtractionRepairStrategy, c as AtomicExtractionRunParameters, n as AtomicExtractionLedgerEntry, o as AtomicExtractionReprocessBounds, s as AtomicExtractionReprocessReason, x as MemoryRelationPredicate, z as TaskLifecycleMigrationCensusRow } from "./memory-store-base-
|
|
1
|
+
import "./embedding-provider-client-CELWtPgt.js";
|
|
2
|
+
import { B as TaskLifecycleMigrationManifest, H as TaskLifecycleMigrationSourceRow, a as AtomicExtractionRepairStrategy, c as AtomicExtractionRunParameters, n as AtomicExtractionLedgerEntry, o as AtomicExtractionReprocessBounds, s as AtomicExtractionReprocessReason, x as MemoryRelationPredicate, z as TaskLifecycleMigrationCensusRow } from "./memory-store-base-upd9MuG6.js";
|
|
3
3
|
import { a as StorageError } from "./errors-CeVRxf9V.js";
|
|
4
4
|
import "./sqlite-runtime-L_ywirTm.js";
|
|
5
5
|
//#region src/store/memory-store-relation-api.d.ts
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { t as PluginConfig } from "./plugin-config-schema-
|
|
2
|
-
import "./types-
|
|
3
|
-
import "./reflection-embedded-generator-
|
|
4
|
-
import { t as ReflectionLifecycleParams } from "./reflection-lifecycle-hooks-
|
|
5
|
-
import { t as ReflectionInjectionParams } from "./reflection-injection-hooks-
|
|
6
|
-
import { t as ReflectionDeps } from "./reflection-deps-
|
|
7
|
-
import { t as ReflectionCommandParams } from "./reflection-command-hooks-
|
|
1
|
+
import { t as PluginConfig } from "./plugin-config-schema-dV2_HgBo.js";
|
|
2
|
+
import "./types-DBEwNYdR.js";
|
|
3
|
+
import "./reflection-embedded-generator-DCZaS6kz.js";
|
|
4
|
+
import { t as ReflectionLifecycleParams } from "./reflection-lifecycle-hooks-Bwq2y5pe.js";
|
|
5
|
+
import { t as ReflectionInjectionParams } from "./reflection-injection-hooks-BYxkrds6.js";
|
|
6
|
+
import { t as ReflectionDeps } from "./reflection-deps-DihlwQxE.js";
|
|
7
|
+
import { t as ReflectionCommandParams } from "./reflection-command-hooks-Cfv836Wc.js";
|
|
8
8
|
//#region src/engine/reflection/strategy-hook-runner.d.ts
|
|
9
9
|
declare function createReflectionStrategyState(config: PluginConfig, deps: ReflectionDeps): ReflectionStrategyState;
|
|
10
10
|
type ReflectionStrategyState = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@snoai/memory",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"publishConfig": { "access": "public" },
|
|
6
6
|
"repository": {
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"@snoai/chunking": "^1.0.1",
|
|
90
90
|
"@snoai/common-core": "^1.1.0",
|
|
91
91
|
"@snoai/content-sanitizer": "^0.99.3 || ^1.1.0",
|
|
92
|
-
"@snoai/embedder": "^1.
|
|
92
|
+
"@snoai/embedder": "^1.2.0",
|
|
93
93
|
"@snoai/llmix": "2.2.0",
|
|
94
94
|
"@snoai/mda-config": "^1.1.2",
|
|
95
95
|
"@snoai/observability": "^1.2.2",
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import "./types-Dm_XhSne.js";
|
|
2
|
-
import "./index-8CfO_-6T.js";
|
|
3
|
-
import "./embedding-provider-client-vynZMuit.js";
|
|
4
|
-
import "./retriever-6ybsoVuY.js";
|
|
5
|
-
import "./memory-metadata-codec-CFY8YtXf.js";
|
|
6
|
-
import "./store-HyzTUvwj.js";
|
|
7
|
-
import "./capture-policy-detector-B8sqRTlB.js";
|
|
8
|
-
import "./memory-temporality-classifier-DL14kjtv.js";
|
|
9
|
-
import "./runtime-audit-log-DWpWmCx5.js";
|
|
10
|
-
import { z as z$1 } from "zod";
|
|
11
|
-
import "@snoai/chunking";
|
|
12
|
-
import "@sinclair/typebox";
|
|
13
|
-
import "async-mutex";
|
|
14
|
-
export { z$1 as t };
|
package/dist/paths-DnNN0G1t.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "./profile-BksZRjJ8.js";
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import "./types-Dm_XhSne.js";
|
|
2
|
-
import "./index-8CfO_-6T.js";
|
|
3
|
-
import "./adapter-BMx-VcJy.js";
|
|
4
|
-
import "./embedding-provider-client-vynZMuit.js";
|
|
5
|
-
import "./retriever-6ybsoVuY.js";
|
|
6
|
-
import "./connection-3IVXpuPE.js";
|
|
7
|
-
import "./sqlite-runtime-L_ywirTm.js";
|
|
8
|
-
import "./store-HyzTUvwj.js";
|
|
9
|
-
import "./access-tracker-DT04huAG.js";
|
|
10
|
-
import "./memory-tier-promoter-Cf1OdoZK.js";
|
|
11
|
-
import "./capture-policy-detector-B8sqRTlB.js";
|
|
12
|
-
import "./memory-temporality-classifier-DL14kjtv.js";
|
|
13
|
-
import "./runtime-audit-log-DWpWmCx5.js";
|
|
14
|
-
import "./atomic-memory-extraction-_OEsSJbC.js";
|
|
15
|
-
import "./llm-client-BoClMktv.js";
|
|
16
|
-
import "./memory-snapshot-DADY3InD.js";
|
|
17
|
-
import "./observable-embedder-CPyX9y7c.js";
|
|
18
|
-
import "./observable-llm-client-C8ndPJck.js";
|
|
19
|
-
import "./observable-memory-store-DhOfgjkU.js";
|
|
20
|
-
import "./observable-retriever-CUlmCFy5.js";
|
|
21
|
-
import "./reflection-embedded-generator-ve1PhgUY.js";
|
|
22
|
-
import "./strategy-hook-runner-B_m1L5CB.js";
|
|
23
|
-
import "./data-bootstrap-Bl3lthzE.js";
|
|
24
|
-
import "@snoai/sqlite-crypto";
|
|
25
|
-
//#region src/engine/bindings/sno-station-mem-runtime-dependencies.d.ts
|
|
26
|
-
/** Legacy parameters carry only an unused logger slot; no host operations are exposed. */
|
|
27
|
-
type SnoStationMemPluginApi = {
|
|
28
|
-
logger: unknown;
|
|
29
|
-
};
|
|
30
|
-
//#endregion
|
|
31
|
-
export { SnoStationMemPluginApi as t };
|