@remnic/core 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/access-audit.d.ts +56 -0
- package/dist/access-audit.js +9 -0
- package/dist/access-cli.js +62 -45
- package/dist/access-cli.js.map +1 -1
- package/dist/access-http.d.ts +16 -9
- package/dist/access-http.js +25 -17
- package/dist/access-mcp.d.ts +16 -9
- package/dist/access-mcp.js +29 -7
- package/dist/access-schema.d.ts +124 -33
- package/dist/access-schema.js +5 -1
- package/dist/{access-service-HmO1Trrx.d.ts → access-service-Br8ZydTK.d.ts} +158 -63
- package/dist/access-service.d.ts +13 -6
- package/dist/access-service.js +22 -14
- package/dist/bootstrap.d.ts +6 -3
- package/dist/briefing.d.ts +1 -0
- package/dist/briefing.js +7 -6
- package/dist/buffer-surprise-report.d.ts +70 -0
- package/dist/buffer-surprise-report.js +7 -0
- package/dist/buffer-surprise-report.js.map +1 -0
- package/dist/buffer-surprise.d.ts +98 -0
- package/dist/buffer-surprise.js +11 -0
- package/dist/buffer-surprise.js.map +1 -0
- package/dist/buffer.d.ts +100 -2
- package/dist/buffer.js +1 -1
- package/dist/calibration.js +5 -5
- package/dist/causal-behavior.js +4 -4
- package/dist/causal-chain.js +2 -2
- package/dist/causal-consolidation.js +17 -16
- package/dist/causal-consolidation.js.map +1 -1
- package/dist/causal-retrieval.js +4 -4
- package/dist/causal-trajectory.js +1 -1
- package/dist/{chunk-QNJMBKFK.js → chunk-2LGMW3DJ.js} +3 -2
- package/dist/chunk-2LGMW3DJ.js.map +1 -0
- package/dist/{chunk-QDYXG4CS.js → chunk-3FPTCC3Z.js} +4 -3
- package/dist/chunk-3FPTCC3Z.js.map +1 -0
- package/dist/chunk-3GPTTA4J.js +57 -0
- package/dist/chunk-3GPTTA4J.js.map +1 -0
- package/dist/{chunk-44ICJRF3.js → chunk-3GXCSUXR.js} +4 -4
- package/dist/{chunk-ITRLGI2T.js → chunk-3OGMS3PE.js} +2 -2
- package/dist/chunk-54V4BZWP.js +139 -0
- package/dist/chunk-54V4BZWP.js.map +1 -0
- package/dist/chunk-5JRF2PZA.js +67 -0
- package/dist/chunk-5JRF2PZA.js.map +1 -0
- package/dist/chunk-64NJRYU2.js +332 -0
- package/dist/chunk-64NJRYU2.js.map +1 -0
- package/dist/{chunk-OIT5QGG4.js → chunk-6AUUAZEX.js} +72 -2
- package/dist/chunk-6AUUAZEX.js.map +1 -0
- package/dist/{chunk-ZVBB3T7V.js → chunk-7I7FKFZH.js} +24 -22
- package/dist/chunk-7I7FKFZH.js.map +1 -0
- package/dist/chunk-AJU4PJGY.js +126 -0
- package/dist/chunk-AJU4PJGY.js.map +1 -0
- package/dist/chunk-ASAITVLA.js +64 -0
- package/dist/chunk-ASAITVLA.js.map +1 -0
- package/dist/{chunk-3QHL5ABG.js → chunk-B5WXLVDY.js} +187 -6
- package/dist/chunk-B5WXLVDY.js.map +1 -0
- package/dist/{chunk-SYUK3VLY.js → chunk-BGJGXLZ7.js} +111 -2
- package/dist/{chunk-SYUK3VLY.js.map → chunk-BGJGXLZ7.js.map} +1 -1
- package/dist/{chunk-MBJHSA7F.js → chunk-BK2EFTE2.js} +258 -13
- package/dist/chunk-BK2EFTE2.js.map +1 -0
- package/dist/chunk-C4SQJZAF.js +486 -0
- package/dist/chunk-C4SQJZAF.js.map +1 -0
- package/dist/{chunk-6UJ47TVX.js → chunk-CUPFXL3J.js} +2 -2
- package/dist/chunk-DF3RVK3X.js +119 -0
- package/dist/chunk-DF3RVK3X.js.map +1 -0
- package/dist/{chunk-37UIFYWO.js → chunk-DFTTJYSO.js} +108 -9
- package/dist/chunk-DFTTJYSO.js.map +1 -0
- package/dist/chunk-DGVM5SFL.js +69 -0
- package/dist/chunk-DGVM5SFL.js.map +1 -0
- package/dist/chunk-EIR5VLIH.js +90 -0
- package/dist/chunk-EIR5VLIH.js.map +1 -0
- package/dist/{chunk-PAORGQRI.js → chunk-EPQJM2GC.js} +37 -23
- package/dist/chunk-EPQJM2GC.js.map +1 -0
- package/dist/{chunk-GV6NLQ4X.js → chunk-F5VP6YCB.js} +374 -16
- package/dist/chunk-F5VP6YCB.js.map +1 -0
- package/dist/{chunk-6ZH4TU6I.js → chunk-FAAFWE4G.js} +2 -1
- package/dist/chunk-FAAFWE4G.js.map +1 -0
- package/dist/{chunk-7WQ6SLIE.js → chunk-FVA6TGI3.js} +2 -2
- package/dist/chunk-GDFS42HT.js +206 -0
- package/dist/chunk-GDFS42HT.js.map +1 -0
- package/dist/{chunk-MVTHXUBX.js → chunk-GKFXUTJ2.js} +479 -20
- package/dist/chunk-GKFXUTJ2.js.map +1 -0
- package/dist/{chunk-NQEVYWX6.js → chunk-HK3FGIEW.js} +209 -5
- package/dist/chunk-HK3FGIEW.js.map +1 -0
- package/dist/chunk-IISBCCWR.js +52 -0
- package/dist/chunk-IISBCCWR.js.map +1 -0
- package/dist/{chunk-WBSAYXVI.js → chunk-INXV5JBT.js} +198 -42
- package/dist/chunk-INXV5JBT.js.map +1 -0
- package/dist/chunk-JBMSGZEQ.js +441 -0
- package/dist/chunk-JBMSGZEQ.js.map +1 -0
- package/dist/{chunk-J4IYOZZ5.js → chunk-JXS5PDQ7.js} +3 -1
- package/dist/chunk-JXS5PDQ7.js.map +1 -0
- package/dist/{chunk-6LX5ORAS.js → chunk-KUB6JU6H.js} +4 -4
- package/dist/chunk-KVBLZUKV.js +173 -0
- package/dist/chunk-KVBLZUKV.js.map +1 -0
- package/dist/chunk-LBLXEFWK.js +51 -0
- package/dist/chunk-LBLXEFWK.js.map +1 -0
- package/dist/{chunk-3WHVNEN7.js → chunk-LTCGGW2D.js} +1 -1
- package/dist/chunk-LTCGGW2D.js.map +1 -0
- package/dist/{chunk-UEYA6UC7.js → chunk-NZLQTHS5.js} +25 -2
- package/dist/chunk-NZLQTHS5.js.map +1 -0
- package/dist/chunk-PVPWZSSI.js +37 -0
- package/dist/chunk-PVPWZSSI.js.map +1 -0
- package/dist/{chunk-4NRAJUDS.js → chunk-RBBWYEFJ.js} +1 -1
- package/dist/chunk-RFYAYKTD.js +146 -0
- package/dist/chunk-RFYAYKTD.js.map +1 -0
- package/dist/{chunk-DHHP2Z4X.js → chunk-RGLL5SPU.js} +2 -2
- package/dist/{chunk-3SV6CQHO.js → chunk-S3EEFKNY.js} +101 -65
- package/dist/chunk-S3EEFKNY.js.map +1 -0
- package/dist/chunk-SOBJ6NEY.js +18 -0
- package/dist/chunk-SOBJ6NEY.js.map +1 -0
- package/dist/{chunk-JIU55F3X.js → chunk-SPI27QT6.js} +2 -2
- package/dist/chunk-TVVEYCNW.js +65 -0
- package/dist/chunk-TVVEYCNW.js.map +1 -0
- package/dist/chunk-ULYOGL6R.js +322 -0
- package/dist/chunk-ULYOGL6R.js.map +1 -0
- package/dist/{chunk-47UU5PU2.js → chunk-VBVG2M5G.js} +18 -3
- package/dist/chunk-VBVG2M5G.js.map +1 -0
- package/dist/{chunk-7ECD5ATE.js → chunk-VDX363PS.js} +2 -2
- package/dist/{chunk-DEPL3635.js → chunk-VYM3VWOF.js} +1432 -188
- package/dist/chunk-VYM3VWOF.js.map +1 -0
- package/dist/{chunk-MTLYEMJB.js → chunk-WCLICCGB.js} +18 -3
- package/dist/chunk-WCLICCGB.js.map +1 -0
- package/dist/{chunk-4LACOVZX.js → chunk-WVVA7F5A.js} +2 -2
- package/dist/chunk-X6GF3FX2.js +26 -0
- package/dist/chunk-X6GF3FX2.js.map +1 -0
- package/dist/{chunk-3QFQGRHO.js → chunk-XMHBH5H6.js} +4 -4
- package/dist/{chunk-BLKTA7MM.js → chunk-YNQKWQT4.js} +50 -17
- package/dist/chunk-YNQKWQT4.js.map +1 -0
- package/dist/chunk-ZAIM4TUE.js +488 -0
- package/dist/chunk-ZAIM4TUE.js.map +1 -0
- package/dist/{chunk-N42IWANG.js → chunk-ZEM3OK2K.js} +2 -2
- package/dist/chunk-ZZTOURJI.js +91 -0
- package/dist/chunk-ZZTOURJI.js.map +1 -0
- package/dist/{cli-BneVIEvh.d.ts → cli-BkeRaYfk.d.ts} +2 -2
- package/dist/cli.d.ts +13 -6
- package/dist/cli.js +40 -29
- package/dist/config.js +1 -1
- package/dist/consolidation-operator.d.ts +41 -0
- package/dist/consolidation-operator.js +11 -0
- package/dist/consolidation-operator.js.map +1 -0
- package/dist/consolidation-provenance-check.d.ts +68 -0
- package/dist/consolidation-provenance-check.js +9 -0
- package/dist/consolidation-provenance-check.js.map +1 -0
- package/dist/consolidation-undo.d.ts +123 -0
- package/dist/consolidation-undo.js +426 -0
- package/dist/consolidation-undo.js.map +1 -0
- package/dist/{contradiction-scan-GR33PONM.js → contradiction-scan-E3GJTI4F.js} +43 -7
- package/dist/contradiction-scan-E3GJTI4F.js.map +1 -0
- package/dist/cross-namespace-budget.d.ts +133 -0
- package/dist/cross-namespace-budget.js +9 -0
- package/dist/cross-namespace-budget.js.map +1 -0
- package/dist/direct-answer-wiring.js +5 -70
- package/dist/direct-answer-wiring.js.map +1 -1
- package/dist/{engine-5TIQBYZR.js → engine-F3GOXGE5.js} +8 -7
- package/dist/engine-F3GOXGE5.js.map +1 -0
- package/dist/entity-retrieval.d.ts +1 -0
- package/dist/entity-retrieval.js +7 -6
- package/dist/explicit-capture.d.ts +6 -3
- package/dist/explicit-capture.js +2 -2
- package/dist/extraction-judge-telemetry.d.ts +113 -0
- package/dist/extraction-judge-telemetry.js +14 -0
- package/dist/extraction-judge-telemetry.js.map +1 -0
- package/dist/extraction-judge-training.d.ts +85 -0
- package/dist/extraction-judge-training.js +16 -0
- package/dist/extraction-judge-training.js.map +1 -0
- package/dist/extraction-judge.d.ts +124 -2
- package/dist/extraction-judge.js +11 -1
- package/dist/extraction.js +6 -5
- package/dist/fallback-llm.js +2 -2
- package/dist/graph-recall.d.ts +100 -0
- package/dist/graph-recall.js +8 -0
- package/dist/graph-recall.js.map +1 -0
- package/dist/graph-retrieval.d.ts +271 -0
- package/dist/graph-retrieval.js +21 -0
- package/dist/graph-retrieval.js.map +1 -0
- package/dist/importance.js +1 -1
- package/dist/index.d.ts +585 -20
- package/dist/index.js +503 -312
- package/dist/index.js.map +1 -1
- package/dist/memory-worth-bench.d.ts +51 -0
- package/dist/memory-worth-bench.js +131 -0
- package/dist/memory-worth-bench.js.map +1 -0
- package/dist/memory-worth-filter.d.ts +128 -0
- package/dist/memory-worth-filter.js +10 -0
- package/dist/memory-worth-filter.js.map +1 -0
- package/dist/memory-worth-outcomes.d.ts +118 -0
- package/dist/memory-worth-outcomes.js +9 -0
- package/dist/memory-worth-outcomes.js.map +1 -0
- package/dist/memory-worth.d.ts +102 -0
- package/dist/memory-worth.js +7 -0
- package/dist/memory-worth.js.map +1 -0
- package/dist/operator-toolkit.d.ts +40 -1
- package/dist/operator-toolkit.js +23 -14
- package/dist/{orchestrator-DRYA6_lW.d.ts → orchestrator-CmJ-NTdJ.d.ts} +233 -8
- package/dist/orchestrator.d.ts +6 -3
- package/dist/orchestrator.js +49 -39
- package/dist/page-versioning.d.ts +12 -1
- package/dist/page-versioning.js +5 -3
- package/dist/{port-C1GZFv8h.d.ts → port-BADbLZU5.d.ts} +2 -2
- package/dist/qmd-recall-cache.d.ts +1 -1
- package/dist/qmd.d.ts +5 -3
- package/dist/qmd.js +1 -1
- package/dist/reasoning-trace-recall.d.ts +90 -0
- package/dist/reasoning-trace-recall.js +13 -0
- package/dist/reasoning-trace-recall.js.map +1 -0
- package/dist/reasoning-trace-types.d.ts +54 -0
- package/dist/reasoning-trace-types.js +17 -0
- package/dist/reasoning-trace-types.js.map +1 -0
- package/dist/recall-audit-anomaly.d.ts +112 -0
- package/dist/recall-audit-anomaly.js +11 -0
- package/dist/recall-audit-anomaly.js.map +1 -0
- package/dist/recall-audit.js +5 -44
- package/dist/recall-audit.js.map +1 -1
- package/dist/recall-explain-renderer.d.ts +49 -0
- package/dist/recall-explain-renderer.js +18 -0
- package/dist/recall-explain-renderer.js.map +1 -0
- package/dist/recall-state.d.ts +12 -1
- package/dist/recall-state.js +1 -1
- package/dist/recall-xray-cli.d.ts +40 -0
- package/dist/recall-xray-cli.js +11 -0
- package/dist/recall-xray-cli.js.map +1 -0
- package/dist/recall-xray-renderer.d.ts +44 -0
- package/dist/recall-xray-renderer.js +18 -0
- package/dist/recall-xray-renderer.js.map +1 -0
- package/dist/recall-xray.d.ts +179 -0
- package/dist/recall-xray.js +13 -0
- package/dist/recall-xray.js.map +1 -0
- package/dist/resume-bundles.js +5 -5
- package/dist/retrieval-agents.d.ts +1 -1
- package/dist/retrieval-tiers.d.ts +17 -0
- package/dist/retrieval-tiers.js +9 -0
- package/dist/retrieval-tiers.js.map +1 -0
- package/dist/schemas.d.ts +287 -31
- package/dist/schemas.js +1 -1
- package/dist/{semantic-consolidation-DrvSYRdB.d.ts → semantic-consolidation-CxJU6MJk.d.ts} +62 -1
- package/dist/semantic-consolidation.d.ts +2 -1
- package/dist/semantic-consolidation.js +21 -7
- package/dist/semantic-rule-promotion.js +7 -6
- package/dist/semantic-rule-verifier.js +7 -6
- package/dist/storage.d.ts +82 -1
- package/dist/storage.js +6 -5
- package/dist/summarizer.js +3 -3
- package/dist/temporal-supersession.d.ts +1 -0
- package/dist/tier-migration.d.ts +2 -1
- package/dist/types.d.ts +276 -2
- package/dist/types.js +1 -1
- package/dist/verified-recall.js +7 -6
- package/package.json +1 -1
- package/dist/chunk-37UIFYWO.js.map +0 -1
- package/dist/chunk-3QHL5ABG.js.map +0 -1
- package/dist/chunk-3SV6CQHO.js.map +0 -1
- package/dist/chunk-3WHVNEN7.js.map +0 -1
- package/dist/chunk-47UU5PU2.js.map +0 -1
- package/dist/chunk-6ZH4TU6I.js.map +0 -1
- package/dist/chunk-BLKTA7MM.js.map +0 -1
- package/dist/chunk-DEPL3635.js.map +0 -1
- package/dist/chunk-GV6NLQ4X.js.map +0 -1
- package/dist/chunk-J4IYOZZ5.js.map +0 -1
- package/dist/chunk-LAYN4LDC.js +0 -267
- package/dist/chunk-LAYN4LDC.js.map +0 -1
- package/dist/chunk-MBJHSA7F.js.map +0 -1
- package/dist/chunk-MTLYEMJB.js.map +0 -1
- package/dist/chunk-MVTHXUBX.js.map +0 -1
- package/dist/chunk-NQEVYWX6.js.map +0 -1
- package/dist/chunk-OIT5QGG4.js.map +0 -1
- package/dist/chunk-PAORGQRI.js.map +0 -1
- package/dist/chunk-QDYXG4CS.js.map +0 -1
- package/dist/chunk-QNJMBKFK.js.map +0 -1
- package/dist/chunk-UEYA6UC7.js.map +0 -1
- package/dist/chunk-UVJFDP7P.js +0 -202
- package/dist/chunk-UVJFDP7P.js.map +0 -1
- package/dist/chunk-WBSAYXVI.js.map +0 -1
- package/dist/chunk-ZVBB3T7V.js.map +0 -1
- package/dist/contradiction-scan-GR33PONM.js.map +0 -1
- /package/dist/{engine-5TIQBYZR.js.map → access-audit.js.map} +0 -0
- /package/dist/{chunk-44ICJRF3.js.map → chunk-3GXCSUXR.js.map} +0 -0
- /package/dist/{chunk-ITRLGI2T.js.map → chunk-3OGMS3PE.js.map} +0 -0
- /package/dist/{chunk-6UJ47TVX.js.map → chunk-CUPFXL3J.js.map} +0 -0
- /package/dist/{chunk-7WQ6SLIE.js.map → chunk-FVA6TGI3.js.map} +0 -0
- /package/dist/{chunk-6LX5ORAS.js.map → chunk-KUB6JU6H.js.map} +0 -0
- /package/dist/{chunk-4NRAJUDS.js.map → chunk-RBBWYEFJ.js.map} +0 -0
- /package/dist/{chunk-DHHP2Z4X.js.map → chunk-RGLL5SPU.js.map} +0 -0
- /package/dist/{chunk-JIU55F3X.js.map → chunk-SPI27QT6.js.map} +0 -0
- /package/dist/{chunk-7ECD5ATE.js.map → chunk-VDX363PS.js.map} +0 -0
- /package/dist/{chunk-4LACOVZX.js.map → chunk-WVVA7F5A.js.map} +0 -0
- /package/dist/{chunk-3QFQGRHO.js.map → chunk-XMHBH5H6.js.map} +0 -0
- /package/dist/{chunk-N42IWANG.js.map → chunk-ZEM3OK2K.js.map} +0 -0
|
@@ -31,8 +31,8 @@ interface SearchBackend {
|
|
|
31
31
|
bm25Search(query: string, collection?: string, maxResults?: number, execution?: SearchExecutionOptions): Promise<SearchResult[]>;
|
|
32
32
|
vectorSearch(query: string, collection?: string, maxResults?: number, execution?: SearchExecutionOptions): Promise<SearchResult[]>;
|
|
33
33
|
hybridSearch(query: string, collection?: string, maxResults?: number, execution?: SearchExecutionOptions): Promise<SearchResult[]>;
|
|
34
|
-
update(): Promise<void>;
|
|
35
|
-
updateCollection(collection: string): Promise<void>;
|
|
34
|
+
update(execution?: SearchExecutionOptions): Promise<void>;
|
|
35
|
+
updateCollection(collection: string, execution?: SearchExecutionOptions): Promise<void>;
|
|
36
36
|
embed(): Promise<void>;
|
|
37
37
|
embedCollection(collection: string): Promise<void>;
|
|
38
38
|
ensureCollection(memoryDir: string): Promise<"present" | "missing" | "unknown" | "skipped">;
|
package/dist/qmd.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { QmdSearchResult, QmdSearchExplain } from './types.js';
|
|
2
|
-
import { S as SearchBackend, a as SearchQueryOptions, b as SearchExecutionOptions } from './port-
|
|
2
|
+
import { S as SearchBackend, a as SearchQueryOptions, b as SearchExecutionOptions } from './port-BADbLZU5.js';
|
|
3
3
|
|
|
4
4
|
interface QmdClientOptions {
|
|
5
5
|
slowLog?: {
|
|
@@ -32,6 +32,7 @@ declare class QmdClient implements SearchBackend {
|
|
|
32
32
|
private lastCliProbeError;
|
|
33
33
|
private daemonSession;
|
|
34
34
|
private daemonAvailable;
|
|
35
|
+
private daemonSessionPath;
|
|
35
36
|
private lastDaemonCheckAtMs;
|
|
36
37
|
private readonly daemonEnabled;
|
|
37
38
|
private readonly daemonRecheckIntervalMs;
|
|
@@ -50,6 +51,7 @@ declare class QmdClient implements SearchBackend {
|
|
|
50
51
|
/** Debug string for troubleshooting availability issues. */
|
|
51
52
|
debugStatus(): string;
|
|
52
53
|
isDaemonMode(): boolean;
|
|
54
|
+
dispose(): void;
|
|
53
55
|
/**
|
|
54
56
|
* Record a daemon search success — resets the transient failure counter.
|
|
55
57
|
*/
|
|
@@ -97,8 +99,8 @@ declare class QmdClient implements SearchBackend {
|
|
|
97
99
|
private bm25SearchViaSubprocess;
|
|
98
100
|
private vsearchViaSubprocess;
|
|
99
101
|
private searchGlobalViaSubprocess;
|
|
100
|
-
update(
|
|
101
|
-
updateCollection(collection: string): Promise<void>;
|
|
102
|
+
update(execution?: SearchExecutionOptions): Promise<void>;
|
|
103
|
+
updateCollection(collection: string, execution?: SearchExecutionOptions): Promise<void>;
|
|
102
104
|
private runUpdateForCollection;
|
|
103
105
|
embed(): Promise<void>;
|
|
104
106
|
embedCollection(collection: string): Promise<void>;
|
package/dist/qmd.js
CHANGED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reasoning-trace recall boost (issue #564 PR 3).
|
|
3
|
+
*
|
|
4
|
+
* Pure helpers for:
|
|
5
|
+
* - detecting whether a user query looks like a problem-solving ask
|
|
6
|
+
* ("how do I…", "step by step", etc.)
|
|
7
|
+
* - boosting stored reasoning_trace memories within a result list when that
|
|
8
|
+
* condition matches.
|
|
9
|
+
*
|
|
10
|
+
* Callers gate these helpers behind the `recallReasoningTraceBoostEnabled`
|
|
11
|
+
* config flag (default false); the helpers themselves are also no-ops when
|
|
12
|
+
* `enabled` is false so they can be safely chained into the recall pipeline.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Heuristic: does the incoming query read like the user wants a stored
|
|
16
|
+
* solution chain (reasoning trace)?
|
|
17
|
+
*
|
|
18
|
+
* Positive signals:
|
|
19
|
+
* - starts with "how do I", "how can I", "how would I", "how to"
|
|
20
|
+
* - contains "step by step", "walk me through", "work through"
|
|
21
|
+
* - contains "reasoning", "think through", "figure out", "debug"
|
|
22
|
+
* - explicitly mentions "trace" or "chain of thought"
|
|
23
|
+
*
|
|
24
|
+
* This is intentionally conservative — the boost is OFF by default, so false
|
|
25
|
+
* negatives are cheap, but false positives would shift retrieval for ordinary
|
|
26
|
+
* queries on an opt-in install.
|
|
27
|
+
*/
|
|
28
|
+
declare function looksLikeProblemSolvingQuery(query: string): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Minimal shape the boost helper needs to read from a recall result. Matches
|
|
31
|
+
* QmdSearchResult as of issue #564 but kept structural so tests and future
|
|
32
|
+
* callers don't have to import orchestrator-level types.
|
|
33
|
+
*/
|
|
34
|
+
interface BoostableResult {
|
|
35
|
+
path: string;
|
|
36
|
+
score: number;
|
|
37
|
+
docid?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Path-based marker for memories that live in the dedicated
|
|
41
|
+
* reasoning-traces/ subtree. Using a path segment keeps this cheap: no
|
|
42
|
+
* frontmatter parsing or extra I/O is needed.
|
|
43
|
+
*/
|
|
44
|
+
declare function isReasoningTracePath(candidatePath: string): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Default additive boost applied to a reasoning_trace candidate when the
|
|
47
|
+
* current query looks like a problem-solving ask.
|
|
48
|
+
*
|
|
49
|
+
* Chosen to be roughly the same magnitude as the existing CATEGORY_BOOSTS
|
|
50
|
+
* entry for reasoning_trace (0.09 in importance scoring), keeping the signal
|
|
51
|
+
* visible but not overwhelming stronger lexical/vector matches.
|
|
52
|
+
*/
|
|
53
|
+
declare const DEFAULT_REASONING_TRACE_BOOST = 0.15;
|
|
54
|
+
interface ApplyReasoningTraceBoostOptions {
|
|
55
|
+
enabled: boolean;
|
|
56
|
+
query: string;
|
|
57
|
+
boost?: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Apply a score boost to results whose path sits under reasoning-traces/
|
|
61
|
+
* when the query looks like a problem-solving ask. Returns a new array;
|
|
62
|
+
* the input array is not mutated.
|
|
63
|
+
*
|
|
64
|
+
* Ordering policy: the helper walks the results in order, boosts every
|
|
65
|
+
* matching reasoning trace in place, then promotes each boosted trace
|
|
66
|
+
* upward PAST any non-boosted neighbor whose score is strictly lower
|
|
67
|
+
* than the trace's boosted score. Non-matching results keep their
|
|
68
|
+
* incoming relative order — so reranker-driven path ordering and any
|
|
69
|
+
* other upstream nudges on non-trace items are preserved. We do NOT
|
|
70
|
+
* re-sort the full list, which would wipe out rerank priority on
|
|
71
|
+
* non-trace items (whose numeric scores may have been left stale by the
|
|
72
|
+
* rerank pass). This matters because MMR runs immediately after and
|
|
73
|
+
* truncates to a topN window — globally re-sorting would silently drop
|
|
74
|
+
* reranker-promoted items below the cutoff.
|
|
75
|
+
*
|
|
76
|
+
* No-ops (returns a copy of the input unchanged) when:
|
|
77
|
+
* - `enabled` is false,
|
|
78
|
+
* - `query` is empty / not a problem-solving ask,
|
|
79
|
+
* - the result list contains no reasoning-trace paths.
|
|
80
|
+
*
|
|
81
|
+
* Note on legacy paths: this helper intentionally only matches paths
|
|
82
|
+
* under the dedicated `reasoning-traces/` subtree introduced by PR 3.
|
|
83
|
+
* Historical reasoning_trace memories (if any) written before that
|
|
84
|
+
* subtree existed were routed to `facts/<date>/` and are NOT
|
|
85
|
+
* boost-eligible. Operators upgrading across that boundary should run
|
|
86
|
+
* the migration CLI or rewrite old paths before enabling the boost.
|
|
87
|
+
*/
|
|
88
|
+
declare function applyReasoningTraceBoost<R extends BoostableResult>(results: readonly R[], options: ApplyReasoningTraceBoostOptions): R[];
|
|
89
|
+
|
|
90
|
+
export { type ApplyReasoningTraceBoostOptions, type BoostableResult, DEFAULT_REASONING_TRACE_BOOST, applyReasoningTraceBoost, isReasoningTracePath, looksLikeProblemSolvingQuery };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_REASONING_TRACE_BOOST,
|
|
3
|
+
applyReasoningTraceBoost,
|
|
4
|
+
isReasoningTracePath,
|
|
5
|
+
looksLikeProblemSolvingQuery
|
|
6
|
+
} from "./chunk-ZZTOURJI.js";
|
|
7
|
+
export {
|
|
8
|
+
DEFAULT_REASONING_TRACE_BOOST,
|
|
9
|
+
applyReasoningTraceBoost,
|
|
10
|
+
isReasoningTracePath,
|
|
11
|
+
looksLikeProblemSolvingQuery
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=reasoning-trace-recall.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reasoning-trace memory structural types (issue #564).
|
|
3
|
+
*
|
|
4
|
+
* Captures stored solution chains / chain-of-thought the user walked through
|
|
5
|
+
* to solve a problem. Traces have an ordered list of steps, a final answer,
|
|
6
|
+
* and an optional observed outcome.
|
|
7
|
+
*/
|
|
8
|
+
interface ReasoningTraceStep {
|
|
9
|
+
/** 1-based ordinal within the trace. */
|
|
10
|
+
order: number;
|
|
11
|
+
/** Human-readable description of what happened at this step. */
|
|
12
|
+
description: string;
|
|
13
|
+
}
|
|
14
|
+
interface ReasoningTraceStructuredData {
|
|
15
|
+
steps: ReasoningTraceStep[];
|
|
16
|
+
finalAnswer: string;
|
|
17
|
+
/** Optional confirmation of how the answer played out in practice. */
|
|
18
|
+
observedOutcome?: string;
|
|
19
|
+
}
|
|
20
|
+
/** Normalize loose extraction JSON into ReasoningTraceStep records. */
|
|
21
|
+
declare function normalizeReasoningTraceSteps(raw: unknown): ReasoningTraceStep[];
|
|
22
|
+
/**
|
|
23
|
+
* Normalize a loose reasoningTrace object (e.g. coming back from the LLM) to
|
|
24
|
+
* a strict ReasoningTraceStructuredData shape. Returns null when the data is
|
|
25
|
+
* clearly incomplete (no steps or no final answer).
|
|
26
|
+
*/
|
|
27
|
+
declare function normalizeReasoningTrace(raw: unknown): ReasoningTraceStructuredData | null;
|
|
28
|
+
/**
|
|
29
|
+
* Serialize a normalized reasoning trace into a human-readable markdown body.
|
|
30
|
+
* Output shape mirrors the procedure body format: ## Step N sections followed
|
|
31
|
+
* by final answer and optional observed outcome.
|
|
32
|
+
*/
|
|
33
|
+
declare function buildReasoningTraceMarkdownBody(trace: ReasoningTraceStructuredData): string;
|
|
34
|
+
/**
|
|
35
|
+
* Combine a short title with the structured trace body. The title becomes the
|
|
36
|
+
* one-line content of the stored memory, and the full body is appended below.
|
|
37
|
+
*/
|
|
38
|
+
declare function buildReasoningTracePersistBody(title: string, trace: ReasoningTraceStructuredData): string;
|
|
39
|
+
/**
|
|
40
|
+
* Best-effort parse of a reasoning-trace markdown body back into structured
|
|
41
|
+
* data. Returns null when the document does not look like a reasoning trace.
|
|
42
|
+
*/
|
|
43
|
+
declare function parseReasoningTraceFromBody(content: string): ReasoningTraceStructuredData | null;
|
|
44
|
+
/**
|
|
45
|
+
* Heuristic detector for whether a user message contains a chain-of-thought /
|
|
46
|
+
* solution trace that should be extracted. This is intentionally conservative:
|
|
47
|
+
* we require at least two explicitly-ordered steps and some form of final
|
|
48
|
+
* answer / resolution. Used by the extraction pipeline to decide whether to
|
|
49
|
+
* even consider emitting a reasoning_trace fact, so false positives are more
|
|
50
|
+
* costly than false negatives.
|
|
51
|
+
*/
|
|
52
|
+
declare function looksLikeReasoningTrace(message: string): boolean;
|
|
53
|
+
|
|
54
|
+
export { type ReasoningTraceStep, type ReasoningTraceStructuredData, buildReasoningTraceMarkdownBody, buildReasoningTracePersistBody, looksLikeReasoningTrace, normalizeReasoningTrace, normalizeReasoningTraceSteps, parseReasoningTraceFromBody };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildReasoningTraceMarkdownBody,
|
|
3
|
+
buildReasoningTracePersistBody,
|
|
4
|
+
looksLikeReasoningTrace,
|
|
5
|
+
normalizeReasoningTrace,
|
|
6
|
+
normalizeReasoningTraceSteps,
|
|
7
|
+
parseReasoningTraceFromBody
|
|
8
|
+
} from "./chunk-54V4BZWP.js";
|
|
9
|
+
export {
|
|
10
|
+
buildReasoningTraceMarkdownBody,
|
|
11
|
+
buildReasoningTracePersistBody,
|
|
12
|
+
looksLikeReasoningTrace,
|
|
13
|
+
normalizeReasoningTrace,
|
|
14
|
+
normalizeReasoningTraceSteps,
|
|
15
|
+
parseReasoningTraceFromBody
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=reasoning-trace-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { RecallAuditEntry } from './recall-audit.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Recall-audit anomaly detector (issue #565 PR 5/5).
|
|
5
|
+
*
|
|
6
|
+
* Given a sequence of `RecallAuditEntry` records for a single principal /
|
|
7
|
+
* session, classify the series and emit `AnomalyFlag`s for suspicious
|
|
8
|
+
* patterns. Intended to run on both:
|
|
9
|
+
*
|
|
10
|
+
* 1. The MCP / HTTP access layers — every `recall` / `memory_search` /
|
|
11
|
+
* `memory_timeline` call appends an audit entry and the detector is
|
|
12
|
+
* invoked against the tail of the series (streaming mode).
|
|
13
|
+
* 2. The existing Openclaw hook (already writes `transcripts/*.jsonl`) —
|
|
14
|
+
* the detector can be invoked out-of-band over the same entries.
|
|
15
|
+
*
|
|
16
|
+
* See the threat model §5 (gap: recall-audit was only on the Openclaw
|
|
17
|
+
* hook) and §6.3 (anomaly signals) for the patterns below.
|
|
18
|
+
*
|
|
19
|
+
* The module is pure: no I/O, no clock. Callers pass the entries +
|
|
20
|
+
* configured thresholds; the detector returns a deterministic classification.
|
|
21
|
+
*
|
|
22
|
+
* Patterns detected:
|
|
23
|
+
*
|
|
24
|
+
* - `repeat-query` — the same normalized query text issued more than N
|
|
25
|
+
* times in the window. Covers the ADAM "exploitation" phase where the
|
|
26
|
+
* attacker re-queries a high-signal token until it plateaus.
|
|
27
|
+
* - `namespace-walk` — the same principal's queries visit more than N
|
|
28
|
+
* distinct candidate memory namespaces in the window. Suggests the
|
|
29
|
+
* attacker is enumerating the namespace tree for leaks.
|
|
30
|
+
* - `high-cardinality-return` — a single recall surfaced more than N
|
|
31
|
+
* candidate memory IDs in one response. Covers the "one query, dump
|
|
32
|
+
* everything" exfiltration path.
|
|
33
|
+
* - `rapid-fire` — more than N recalls in the window irrespective of
|
|
34
|
+
* content. Blunt instrument; useful when nothing else fires.
|
|
35
|
+
*
|
|
36
|
+
* Each flag carries the entry indices that support it so an audit UI can
|
|
37
|
+
* highlight the underlying evidence.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
type AnomalyKind = "repeat-query" | "namespace-walk" | "high-cardinality-return" | "rapid-fire";
|
|
41
|
+
type AnomalySeverity = "info" | "warn" | "alert";
|
|
42
|
+
interface AnomalyFlag {
|
|
43
|
+
kind: AnomalyKind;
|
|
44
|
+
severity: AnomalySeverity;
|
|
45
|
+
/** Human-readable rationale, e.g. `"query 'alex' repeated 12 times in 60s"`. */
|
|
46
|
+
message: string;
|
|
47
|
+
/** Indices into the supplied `entries` array that triggered the flag. */
|
|
48
|
+
entryIndices: number[];
|
|
49
|
+
/**
|
|
50
|
+
* Optional extra signal the caller can use to key metrics. For
|
|
51
|
+
* `repeat-query` this is the normalized query text; for
|
|
52
|
+
* `namespace-walk` it is the namespace count; etc.
|
|
53
|
+
*/
|
|
54
|
+
signal?: string | number;
|
|
55
|
+
}
|
|
56
|
+
interface AnomalyDetectorConfig {
|
|
57
|
+
/** Detector feature-flag. Defaults to false — ships disabled. */
|
|
58
|
+
enabled?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Rolling window in ms. The detector only considers entries whose `ts`
|
|
61
|
+
* falls within `[now - windowMs, now]`. Default 5 minutes.
|
|
62
|
+
*/
|
|
63
|
+
windowMs?: number;
|
|
64
|
+
/**
|
|
65
|
+
* Threshold for `repeat-query`: a normalized query repeated more than
|
|
66
|
+
* this many times in the window trips the flag. Default 5.
|
|
67
|
+
*/
|
|
68
|
+
repeatQueryLimit?: number;
|
|
69
|
+
/**
|
|
70
|
+
* Threshold for `namespace-walk`: more than this many distinct
|
|
71
|
+
* candidate namespaces in the window trips the flag. Default 3.
|
|
72
|
+
*/
|
|
73
|
+
namespaceWalkLimit?: number;
|
|
74
|
+
/**
|
|
75
|
+
* Threshold for `high-cardinality-return`: more than this many
|
|
76
|
+
* `candidateMemoryIds` in a single entry trips the flag. Default 50.
|
|
77
|
+
*/
|
|
78
|
+
highCardinalityReturnLimit?: number;
|
|
79
|
+
/**
|
|
80
|
+
* Threshold for `rapid-fire`: more than this many entries in the
|
|
81
|
+
* window trips the flag. Default 30. (Matches the default
|
|
82
|
+
* `recallCrossNamespaceBudgetHardLimit` from PR 4.)
|
|
83
|
+
*/
|
|
84
|
+
rapidFireLimit?: number;
|
|
85
|
+
}
|
|
86
|
+
declare const DEFAULT_ANOMALY_DETECTOR_CONFIG: Required<AnomalyDetectorConfig>;
|
|
87
|
+
interface AnomalyDetectorInput {
|
|
88
|
+
entries: readonly RecallAuditEntry[];
|
|
89
|
+
/** Current time in epoch ms. Entries older than `now - windowMs` are ignored. */
|
|
90
|
+
now: number;
|
|
91
|
+
config?: AnomalyDetectorConfig;
|
|
92
|
+
}
|
|
93
|
+
interface AnomalyDetectorResult {
|
|
94
|
+
/** All flags ordered by descending severity then kind. */
|
|
95
|
+
flags: AnomalyFlag[];
|
|
96
|
+
/** Number of entries inside the active window (after filtering). */
|
|
97
|
+
windowEntryCount: number;
|
|
98
|
+
/** Window size actually used, in ms. */
|
|
99
|
+
windowMs: number;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Normalize query text so cosmetic variation doesn't defeat the
|
|
103
|
+
* repeat-query detector. Lowercase, collapse whitespace, trim.
|
|
104
|
+
*/
|
|
105
|
+
declare function normalizeQueryText(raw: string): string;
|
|
106
|
+
/**
|
|
107
|
+
* Run the detector against a series of audit entries. Pure; no side
|
|
108
|
+
* effects.
|
|
109
|
+
*/
|
|
110
|
+
declare function detectRecallAnomalies(input: AnomalyDetectorInput): AnomalyDetectorResult;
|
|
111
|
+
|
|
112
|
+
export { type AnomalyDetectorConfig, type AnomalyDetectorInput, type AnomalyDetectorResult, type AnomalyFlag, type AnomalyKind, type AnomalySeverity, DEFAULT_ANOMALY_DETECTOR_CONFIG, detectRecallAnomalies, normalizeQueryText };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_ANOMALY_DETECTOR_CONFIG,
|
|
3
|
+
detectRecallAnomalies,
|
|
4
|
+
normalizeQueryText
|
|
5
|
+
} from "./chunk-RFYAYKTD.js";
|
|
6
|
+
export {
|
|
7
|
+
DEFAULT_ANOMALY_DETECTOR_CONFIG,
|
|
8
|
+
detectRecallAnomalies,
|
|
9
|
+
normalizeQueryText
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=recall-audit-anomaly.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/recall-audit.js
CHANGED
|
@@ -1,47 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (Number.isNaN(normalized.getTime())) {
|
|
7
|
-
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
8
|
-
}
|
|
9
|
-
return normalized.toISOString().slice(0, 10);
|
|
10
|
-
}
|
|
11
|
-
function buildRecallAuditPath(rootDir, ts, sessionKey) {
|
|
12
|
-
const safeSessionKey = encodeURIComponent(sessionKey);
|
|
13
|
-
return path.join(rootDir, "transcripts", formatIsoDate(ts), `${safeSessionKey}.jsonl`);
|
|
14
|
-
}
|
|
15
|
-
async function appendRecallAuditEntry(rootDir, entry) {
|
|
16
|
-
const filePath = buildRecallAuditPath(rootDir, entry.ts, entry.sessionKey);
|
|
17
|
-
await mkdir(path.dirname(filePath), { recursive: true });
|
|
18
|
-
await appendFile(filePath, `${JSON.stringify(entry)}
|
|
19
|
-
`, "utf8");
|
|
20
|
-
return filePath;
|
|
21
|
-
}
|
|
22
|
-
async function pruneRecallAuditEntries(rootDir, retentionDays, now = /* @__PURE__ */ new Date()) {
|
|
23
|
-
const transcriptsDir = path.join(rootDir, "transcripts");
|
|
24
|
-
const removed = [];
|
|
25
|
-
const cutoff = new Date(now);
|
|
26
|
-
cutoff.setUTCHours(0, 0, 0, 0);
|
|
27
|
-
cutoff.setUTCDate(cutoff.getUTCDate() - Math.max(1, Math.floor(retentionDays)));
|
|
28
|
-
let entries;
|
|
29
|
-
try {
|
|
30
|
-
entries = await readdir(transcriptsDir, { withFileTypes: true });
|
|
31
|
-
} catch {
|
|
32
|
-
return removed;
|
|
33
|
-
}
|
|
34
|
-
for (const entry of entries) {
|
|
35
|
-
if (!entry.isDirectory()) continue;
|
|
36
|
-
if (!/^\d{4}-\d{2}-\d{2}$/.test(entry.name)) continue;
|
|
37
|
-
const day = /* @__PURE__ */ new Date(`${entry.name}T00:00:00.000Z`);
|
|
38
|
-
if (Number.isNaN(day.getTime()) || day >= cutoff) continue;
|
|
39
|
-
const dirPath = path.join(transcriptsDir, entry.name);
|
|
40
|
-
await rm(dirPath, { recursive: true, force: true });
|
|
41
|
-
removed.push(dirPath);
|
|
42
|
-
}
|
|
43
|
-
return removed;
|
|
44
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
appendRecallAuditEntry,
|
|
3
|
+
buildRecallAuditPath,
|
|
4
|
+
pruneRecallAuditEntries
|
|
5
|
+
} from "./chunk-LBLXEFWK.js";
|
|
45
6
|
export {
|
|
46
7
|
appendRecallAuditEntry,
|
|
47
8
|
buildRecallAuditPath,
|
package/dist/recall-audit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { LastRecallSnapshot } from './recall-state.js';
|
|
2
|
+
import { RecallTierExplain } from './types.js';
|
|
3
|
+
import { RecallXraySnapshot } from './recall-xray.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Renderers for RecallTierExplain (issue #518).
|
|
7
|
+
*
|
|
8
|
+
* Pure functions that format a `LastRecallSnapshot` and its
|
|
9
|
+
* optional `tierExplain` field for human text and machine JSON
|
|
10
|
+
* consumption. CLI / HTTP / MCP surfaces consume these — they do
|
|
11
|
+
* not format explain output themselves, so rendering is tested in
|
|
12
|
+
* one place.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* `text` and `json` are the original formats (backwards-compatible
|
|
17
|
+
* since issue #518). `markdown` was added in issue #570 PR 7 and
|
|
18
|
+
* delegates to the shared X-ray renderer so the three observability
|
|
19
|
+
* surfaces stay in lock-step (CLAUDE.md rule 22).
|
|
20
|
+
*/
|
|
21
|
+
type RecallExplainFormat = "text" | "json" | "markdown";
|
|
22
|
+
interface RecallExplainJsonPayload {
|
|
23
|
+
hasExplain: boolean;
|
|
24
|
+
snapshotFound: boolean;
|
|
25
|
+
sessionKey: string | null;
|
|
26
|
+
recordedAt: string | null;
|
|
27
|
+
namespace: string | null;
|
|
28
|
+
memoryIds: string[];
|
|
29
|
+
source: string | null;
|
|
30
|
+
sourcesUsed: string[] | null;
|
|
31
|
+
latencyMs: number | null;
|
|
32
|
+
tierExplain: RecallTierExplain | null;
|
|
33
|
+
}
|
|
34
|
+
declare function toRecallExplainJson(snapshot: LastRecallSnapshot | null): RecallExplainJsonPayload;
|
|
35
|
+
/**
|
|
36
|
+
* Render the shared "--- tier explain ---" text block used by both the
|
|
37
|
+
* recall-explain surface and the Recall X-ray surface. Callers provide
|
|
38
|
+
* the normalized `RecallTierExplain` (or `null` for the
|
|
39
|
+
* not-populated/disabled case) so the block stays character-for-character
|
|
40
|
+
* identical across surfaces (CLAUDE.md rule 22). The returned strings do
|
|
41
|
+
* NOT include leading blank lines or headers — callers own that framing.
|
|
42
|
+
*/
|
|
43
|
+
declare function renderTierExplainTextLines(tierExplain: RecallTierExplain | null): string[];
|
|
44
|
+
declare function toRecallExplainText(snapshot: LastRecallSnapshot | null): string;
|
|
45
|
+
declare function toRecallXraySnapshotFromLegacy(snapshot: LastRecallSnapshot | null): RecallXraySnapshot | null;
|
|
46
|
+
declare function renderRecallExplain(snapshot: LastRecallSnapshot | null, format: RecallExplainFormat): string;
|
|
47
|
+
declare function parseRecallExplainFormat(value: unknown): RecallExplainFormat;
|
|
48
|
+
|
|
49
|
+
export { type RecallExplainFormat, type RecallExplainJsonPayload, parseRecallExplainFormat, renderRecallExplain, renderTierExplainTextLines, toRecallExplainJson, toRecallExplainText, toRecallXraySnapshotFromLegacy };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
parseRecallExplainFormat,
|
|
3
|
+
renderRecallExplain,
|
|
4
|
+
renderTierExplainTextLines,
|
|
5
|
+
toRecallExplainJson,
|
|
6
|
+
toRecallExplainText,
|
|
7
|
+
toRecallXraySnapshotFromLegacy
|
|
8
|
+
} from "./chunk-ZAIM4TUE.js";
|
|
9
|
+
import "./chunk-SOBJ6NEY.js";
|
|
10
|
+
export {
|
|
11
|
+
parseRecallExplainFormat,
|
|
12
|
+
renderRecallExplain,
|
|
13
|
+
renderTierExplainTextLines,
|
|
14
|
+
toRecallExplainJson,
|
|
15
|
+
toRecallExplainText,
|
|
16
|
+
toRecallXraySnapshotFromLegacy
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=recall-explain-renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/recall-state.d.ts
CHANGED
|
@@ -32,6 +32,13 @@ interface LastRecallSnapshot {
|
|
|
32
32
|
identityInjectionMode?: IdentityInjectionMode | "none";
|
|
33
33
|
identityInjectedChars?: number;
|
|
34
34
|
identityInjectionTruncated?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Collision-safe write nonce. Random UUID set on every `record()`
|
|
37
|
+
* call so the observation-mode direct-answer hook can detect stale
|
|
38
|
+
* snapshots and avoid annotating a snapshot that a subsequent recall
|
|
39
|
+
* already replaced (issue #518).
|
|
40
|
+
*/
|
|
41
|
+
writeNonce?: string;
|
|
35
42
|
/**
|
|
36
43
|
* Optional tier-level explanation of how recall was served
|
|
37
44
|
* (issue #518). Populated by orchestrator call sites that can
|
|
@@ -126,7 +133,11 @@ declare class LastRecallStore {
|
|
|
126
133
|
* No-op when no snapshot exists for the given session; callers do
|
|
127
134
|
* not need to guard on existence.
|
|
128
135
|
*/
|
|
129
|
-
annotateTierExplain(sessionKey: string, tierExplain: RecallTierExplain
|
|
136
|
+
annotateTierExplain(sessionKey: string, tierExplain: RecallTierExplain, expected?: {
|
|
137
|
+
writeNonce?: string;
|
|
138
|
+
traceId?: string;
|
|
139
|
+
recordedAt?: string;
|
|
140
|
+
}): Promise<void>;
|
|
130
141
|
}
|
|
131
142
|
declare class TierMigrationStatusStore {
|
|
132
143
|
private readonly statePath;
|
package/dist/recall-state.js
CHANGED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { RecallXrayFormat } from './recall-xray-renderer.js';
|
|
2
|
+
import './recall-xray.js';
|
|
3
|
+
import './types.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Input-validation helpers for the `remnic xray` CLI command (issue
|
|
7
|
+
* #570, PR 3).
|
|
8
|
+
*
|
|
9
|
+
* Pulled out of `cli.ts` so the validation paths can be unit-tested in
|
|
10
|
+
* isolation — the full CLI handler is hard to exercise without booting
|
|
11
|
+
* an orchestrator. CLAUDE.md rules 14 + 51 require that `--format`,
|
|
12
|
+
* `--budget`, `--namespace`, and `--out` reject missing-value /
|
|
13
|
+
* unknown / non-positive arguments with a listed-options error, rather
|
|
14
|
+
* than silently defaulting.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
interface ParsedXrayCliOptions {
|
|
18
|
+
format: RecallXrayFormat;
|
|
19
|
+
/** Positive integer override, or undefined when not specified. */
|
|
20
|
+
budget?: number;
|
|
21
|
+
/** Trimmed namespace, or undefined when not specified. */
|
|
22
|
+
namespace?: string;
|
|
23
|
+
/** Trimmed, tilde-unexpanded output path, or undefined when stdout. */
|
|
24
|
+
outPath?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Validate and coerce `--budget <chars>`. Must be a positive integer;
|
|
28
|
+
* throws a listed-options error otherwise.
|
|
29
|
+
*/
|
|
30
|
+
declare function parseXrayBudgetFlag(value: unknown): number | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Parse and validate the full option bag for `remnic xray`. Extracted
|
|
33
|
+
* so the CLI handler in `cli.ts` can stay thin and the validation can
|
|
34
|
+
* be unit-tested without booting an orchestrator.
|
|
35
|
+
*/
|
|
36
|
+
declare function parseXrayCliOptions(rawQuery: unknown, options: Record<string, unknown>): {
|
|
37
|
+
query: string;
|
|
38
|
+
} & ParsedXrayCliOptions;
|
|
39
|
+
|
|
40
|
+
export { type ParsedXrayCliOptions, parseXrayBudgetFlag, parseXrayCliOptions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { RecallXraySnapshot } from './recall-xray.js';
|
|
2
|
+
import './types.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Unified Recall X-ray renderer (issue #570, PR 2).
|
|
6
|
+
*
|
|
7
|
+
* Pure functions that format a `RecallXraySnapshot` for human text,
|
|
8
|
+
* GitHub-flavored markdown, and machine JSON consumption. CLI / HTTP
|
|
9
|
+
* / MCP surfaces all call into this module — they do NOT format X-ray
|
|
10
|
+
* output themselves, so rendering is tested in one place (CLAUDE.md
|
|
11
|
+
* rule 22).
|
|
12
|
+
*
|
|
13
|
+
* Scope for PR 2 (this slice):
|
|
14
|
+
* - Pure rendering. No IO, no transport, no capture.
|
|
15
|
+
* - `renderXray(snapshot, format)` with format ∈
|
|
16
|
+
* `{"json", "text", "markdown"}`.
|
|
17
|
+
* - `parseXrayFormat(value)` — input validator that rejects unknown
|
|
18
|
+
* formats with a listed-options error (CLAUDE.md rule 51).
|
|
19
|
+
* - Golden-file-style tests in `recall-xray-renderer.test.ts`.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
type RecallXrayFormat = "json" | "text" | "markdown";
|
|
23
|
+
declare const RECALL_XRAY_FORMATS: readonly RecallXrayFormat[];
|
|
24
|
+
/**
|
|
25
|
+
* Validate and coerce a user-provided `--format` / `format` argument to
|
|
26
|
+
* `RecallXrayFormat`. Unknown values throw an error listing valid
|
|
27
|
+
* options (CLAUDE.md rule 51). `undefined`/`null` defaults to `"text"`.
|
|
28
|
+
*/
|
|
29
|
+
declare function parseXrayFormat(value: unknown): RecallXrayFormat;
|
|
30
|
+
/**
|
|
31
|
+
* Top-level dispatcher. CLI / HTTP / MCP callers should always route
|
|
32
|
+
* through this function so the three formats stay in lock-step.
|
|
33
|
+
*/
|
|
34
|
+
declare function renderXray(snapshot: RecallXraySnapshot | null, format: RecallXrayFormat): string;
|
|
35
|
+
/**
|
|
36
|
+
* Deterministic JSON encoding of an X-ray snapshot. Returns a stable
|
|
37
|
+
* v1 envelope when the snapshot is absent so consumers can pattern-match
|
|
38
|
+
* on `snapshotFound` rather than distinguishing `null` vs `{}`.
|
|
39
|
+
*/
|
|
40
|
+
declare function renderXrayJson(snapshot: RecallXraySnapshot | null): string;
|
|
41
|
+
declare function renderXrayText(snapshot: RecallXraySnapshot | null): string;
|
|
42
|
+
declare function renderXrayMarkdown(snapshot: RecallXraySnapshot | null): string;
|
|
43
|
+
|
|
44
|
+
export { RECALL_XRAY_FORMATS, type RecallXrayFormat, parseXrayFormat, renderXray, renderXrayJson, renderXrayMarkdown, renderXrayText };
|