@remnic/core 1.1.4 → 1.1.6
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-cli.js +32 -30
- package/dist/access-cli.js.map +1 -1
- package/dist/access-http.d.ts +7 -7
- package/dist/access-http.js +13 -13
- package/dist/access-mcp.d.ts +7 -7
- package/dist/access-mcp.js +12 -12
- package/dist/access-schema.d.ts +89 -4
- package/dist/access-schema.js +3 -3
- package/dist/{access-service-CtXFnprR.d.ts → access-service-CcKu1Yc0.d.ts} +22 -18
- package/dist/access-service.d.ts +7 -7
- package/dist/access-service.js +10 -10
- package/dist/active-memory-bridge.d.ts +1 -1
- package/dist/active-recall.d.ts +1 -1
- package/dist/behavior-learner.d.ts +1 -1
- package/dist/behavior-signals.d.ts +1 -1
- package/dist/bootstrap.d.ts +6 -6
- package/dist/briefing.d.ts +2 -2
- package/dist/briefing.js +3 -3
- package/dist/buffer-surprise-report.d.ts +1 -1
- package/dist/buffer.d.ts +2 -2
- package/dist/calibration.d.ts +1 -1
- package/dist/calibration.js +1 -1
- package/dist/{capsule-crypto-5CYAGVC5.js → capsule-crypto-SJS5VVAP.js} +2 -2
- package/dist/{capsule-export-NZQPOTQ4.js → capsule-export-LLEVB2RG.js} +3 -3
- package/dist/{capsule-import-SDCUXLEV.js → capsule-import-UW45R2MZ.js} +3 -3
- package/dist/causal-behavior.d.ts +1 -1
- package/dist/causal-consolidation.d.ts +2 -2
- package/dist/causal-consolidation.js +4 -4
- package/dist/{chunk-CRU27Q4J.js → chunk-3P6TPZM4.js} +64 -5
- package/dist/chunk-3P6TPZM4.js.map +1 -0
- package/dist/{chunk-LW2NMHDW.js → chunk-5NS6NN5A.js} +2 -2
- package/dist/{chunk-KNKUID7G.js → chunk-767ODGE6.js} +1 -1
- package/dist/{chunk-V7TEH5I2.js → chunk-7RAW2T4P.js} +2 -2
- package/dist/{chunk-RILIVK4O.js → chunk-A4ACKWIW.js} +29 -3
- package/dist/chunk-A4ACKWIW.js.map +1 -0
- package/dist/{chunk-F5VQOQ2E.js → chunk-AIT53NLG.js} +2 -2
- package/dist/chunk-AKV3HOGZ.js +757 -0
- package/dist/chunk-AKV3HOGZ.js.map +1 -0
- package/dist/{chunk-NZS2BLTP.js → chunk-AOABCJVL.js} +772 -59
- package/dist/chunk-AOABCJVL.js.map +1 -0
- package/dist/{chunk-B2TL6GA2.js → chunk-BFVBG5XY.js} +2 -2
- package/dist/{chunk-43EKP2UK.js → chunk-COAGZQT7.js} +1 -1
- package/dist/{chunk-43EKP2UK.js.map → chunk-COAGZQT7.js.map} +1 -1
- package/dist/{chunk-USFPPRAF.js → chunk-D7WYTVUQ.js} +5 -3
- package/dist/chunk-D7WYTVUQ.js.map +1 -0
- package/dist/{chunk-Y4A6M3B6.js → chunk-DLYTYJ43.js} +2 -2
- package/dist/{chunk-ZIBOQULP.js → chunk-EONJ7GK3.js} +2 -2
- package/dist/{chunk-JWSENLQI.js → chunk-FSWYMUWI.js} +15 -1
- package/dist/chunk-FSWYMUWI.js.map +1 -0
- package/dist/{chunk-SMA4IMHV.js → chunk-KUIEFH2S.js} +3 -3
- package/dist/{chunk-EGEPUGN4.js → chunk-LKJA5MR2.js} +2 -2
- package/dist/{chunk-XRCYKJ3V.js → chunk-M3QQ5DRA.js} +61 -18
- package/dist/chunk-M3QQ5DRA.js.map +1 -0
- package/dist/{chunk-CUI2STX6.js → chunk-MYMOXFMR.js} +12 -6
- package/dist/chunk-MYMOXFMR.js.map +1 -0
- package/dist/{chunk-AEMBDV7M.js → chunk-OZAFME7S.js} +22 -17
- package/dist/chunk-OZAFME7S.js.map +1 -0
- package/dist/{chunk-IYY4MCPG.js → chunk-P73JTV34.js} +2 -2
- package/dist/{chunk-52PDY6GD.js → chunk-PT2EZWOH.js} +2 -2
- package/dist/{chunk-3KIS4VGT.js → chunk-QIGOEM65.js} +2 -2
- package/dist/{chunk-47WOM4YW.js → chunk-RXGR3YLU.js} +2 -2
- package/dist/{chunk-VTJVUHRK.js → chunk-SRBJUAMP.js} +1 -1
- package/dist/chunk-SRBJUAMP.js.map +1 -0
- package/dist/{chunk-XQ4EJLUD.js → chunk-TMSHGSIG.js} +2 -2
- package/dist/{chunk-X6VBWOVZ.js → chunk-UE2OQNQQ.js} +2 -2
- package/dist/{chunk-HIRKCQGF.js → chunk-XOG2FHYW.js} +44 -44
- package/dist/{chunk-HIRKCQGF.js.map → chunk-XOG2FHYW.js.map} +1 -1
- package/dist/{chunk-MUELDH4F.js → chunk-YELFQNQH.js} +2 -2
- package/dist/{chunk-TIFRGAKO.js → chunk-YKGRACQP.js} +5 -5
- package/dist/{chunk-AGZHRWPT.js → chunk-ZBZVNWQO.js} +2 -2
- package/dist/{chunk-W7WWT4FJ.js → chunk-ZOMA7J3J.js} +2 -2
- package/dist/{cli-lMql2FCr.d.ts → cli-WahR0rs-.d.ts} +4 -4
- package/dist/cli.d.ts +8 -8
- package/dist/cli.js +25 -25
- package/dist/{codex-materialize-CQlLTzke.d.ts → codex-materialize-D5d5vvyS.d.ts} +1 -1
- package/dist/compression-optimizer.d.ts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -1
- package/dist/consolidation-provenance-check.d.ts +2 -2
- package/dist/consolidation-undo.d.ts +2 -2
- package/dist/day-summary.d.ts +1 -1
- package/dist/delinearize.d.ts +1 -1
- package/dist/direct-answer-wiring.d.ts +1 -1
- package/dist/direct-answer.d.ts +1 -1
- package/dist/embedding-fallback.d.ts +1 -1
- package/dist/{engine-O6YWKQM3.js → engine-5OTS6GY3.js} +4 -4
- package/dist/entity-retrieval.d.ts +2 -2
- package/dist/entity-retrieval.js +3 -3
- package/dist/entity-schema.d.ts +1 -1
- package/dist/explicit-capture.d.ts +6 -6
- package/dist/explicit-cue-recall.d.ts +40 -0
- package/dist/explicit-cue-recall.js +21 -0
- package/dist/extraction-judge-telemetry.d.ts +1 -1
- package/dist/extraction-judge-training.d.ts +1 -1
- package/dist/extraction-judge.d.ts +1 -1
- package/dist/extraction.d.ts +1 -1
- package/dist/extraction.js +2 -2
- package/dist/fallback-llm.d.ts +3 -1
- package/dist/fallback-llm.js +1 -1
- package/dist/identity-continuity.d.ts +1 -1
- package/dist/importance.d.ts +1 -1
- package/dist/index.d.ts +14 -13
- package/dist/index.js +191 -52
- package/dist/index.js.map +1 -1
- package/dist/intent.d.ts +1 -1
- package/dist/lifecycle.d.ts +1 -1
- package/dist/live-connectors-runner.d.ts +1 -1
- package/dist/local-llm.d.ts +1 -1
- package/dist/memory-action-policy.d.ts +1 -1
- package/dist/memory-cache.d.ts +1 -1
- package/dist/{memory-governance-JZHZDOLN.js → memory-governance-7MI7KE35.js} +4 -4
- package/dist/memory-governance-7MI7KE35.js.map +1 -0
- package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
- package/dist/{memory-projection-store-CY8TU40w.d.ts → memory-projection-store-BQt5VUQ8.d.ts} +1 -1
- package/dist/memory-projection-store.d.ts +2 -2
- package/dist/memory-worth-outcomes.d.ts +2 -2
- package/dist/models-json.d.ts +1 -1
- package/dist/native-knowledge.d.ts +1 -1
- package/dist/operator-toolkit.d.ts +2 -2
- package/dist/operator-toolkit.js +6 -6
- package/dist/{orchestrator-ChkesB8U.d.ts → orchestrator-D2lHhFWI.d.ts} +36 -11
- package/dist/orchestrator.d.ts +6 -6
- package/dist/orchestrator.js +24 -22
- package/dist/patterns-cli.d.ts +1 -1
- package/dist/policy-runtime.d.ts +1 -1
- package/dist/{port-hqGnoStS.d.ts → port-5W-r5SKc.d.ts} +1 -1
- package/dist/qmd-recall-cache.d.ts +2 -2
- package/dist/qmd.d.ts +2 -2
- package/dist/recall-disclosure-escalation.d.ts +1 -1
- package/dist/recall-explain-renderer.d.ts +1 -1
- package/dist/recall-explain-renderer.js +3 -3
- package/dist/recall-state.d.ts +1 -1
- package/dist/recall-tag-filter.d.ts +1 -1
- package/dist/recall-xray-cli.d.ts +1 -1
- package/dist/recall-xray-cli.js +4 -4
- package/dist/recall-xray-renderer.d.ts +1 -1
- package/dist/recall-xray-renderer.js +3 -3
- package/dist/recall-xray.d.ts +2 -2
- package/dist/recall-xray.js +2 -2
- package/dist/resolve-auth-token.d.ts +1 -1
- package/dist/resume-bundles.js +3 -3
- package/dist/retrieval-agents.d.ts +2 -2
- package/dist/retrieval-tiers.d.ts +1 -1
- package/dist/schemas.d.ts +54 -54
- package/dist/{semantic-consolidation-ByBXb-sf.d.ts → semantic-consolidation-tDODR2je.d.ts} +2 -2
- package/dist/semantic-consolidation.d.ts +3 -3
- package/dist/semantic-consolidation.js +3 -3
- package/dist/semantic-rule-promotion.js +3 -3
- package/dist/semantic-rule-verifier.d.ts +1 -1
- package/dist/semantic-rule-verifier.js +3 -3
- package/dist/session-observer-bands.d.ts +1 -1
- package/dist/session-observer-state.d.ts +1 -1
- package/dist/signal.d.ts +1 -1
- package/dist/storage.d.ts +2 -2
- package/dist/storage.js +2 -2
- package/dist/summarizer.d.ts +1 -1
- package/dist/summarizer.js +2 -2
- package/dist/summary-snapshot.d.ts +1 -1
- package/dist/temporal-supersession.d.ts +2 -2
- package/dist/temporal-validity.d.ts +1 -1
- package/dist/threading.d.ts +1 -1
- package/dist/tier-migration.d.ts +3 -3
- package/dist/tier-routing.d.ts +1 -1
- package/dist/topics.d.ts +1 -1
- package/dist/transcript.d.ts +1 -1
- package/dist/types-C-USTTAx.d.ts +2713 -0
- package/dist/types.d.ts +1 -2668
- package/dist/types.js +1 -1
- package/dist/utility-runtime.d.ts +1 -1
- package/dist/verified-recall.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-AEMBDV7M.js.map +0 -1
- package/dist/chunk-CRU27Q4J.js.map +0 -1
- package/dist/chunk-CUI2STX6.js.map +0 -1
- package/dist/chunk-JWSENLQI.js.map +0 -1
- package/dist/chunk-NZS2BLTP.js.map +0 -1
- package/dist/chunk-RILIVK4O.js.map +0 -1
- package/dist/chunk-USFPPRAF.js.map +0 -1
- package/dist/chunk-VTJVUHRK.js.map +0 -1
- package/dist/chunk-XRCYKJ3V.js.map +0 -1
- /package/dist/{capsule-crypto-5CYAGVC5.js.map → capsule-crypto-SJS5VVAP.js.map} +0 -0
- /package/dist/{capsule-export-NZQPOTQ4.js.map → capsule-export-LLEVB2RG.js.map} +0 -0
- /package/dist/{capsule-import-SDCUXLEV.js.map → capsule-import-UW45R2MZ.js.map} +0 -0
- /package/dist/{chunk-LW2NMHDW.js.map → chunk-5NS6NN5A.js.map} +0 -0
- /package/dist/{chunk-KNKUID7G.js.map → chunk-767ODGE6.js.map} +0 -0
- /package/dist/{chunk-V7TEH5I2.js.map → chunk-7RAW2T4P.js.map} +0 -0
- /package/dist/{chunk-F5VQOQ2E.js.map → chunk-AIT53NLG.js.map} +0 -0
- /package/dist/{chunk-B2TL6GA2.js.map → chunk-BFVBG5XY.js.map} +0 -0
- /package/dist/{chunk-Y4A6M3B6.js.map → chunk-DLYTYJ43.js.map} +0 -0
- /package/dist/{chunk-ZIBOQULP.js.map → chunk-EONJ7GK3.js.map} +0 -0
- /package/dist/{chunk-SMA4IMHV.js.map → chunk-KUIEFH2S.js.map} +0 -0
- /package/dist/{chunk-EGEPUGN4.js.map → chunk-LKJA5MR2.js.map} +0 -0
- /package/dist/{chunk-IYY4MCPG.js.map → chunk-P73JTV34.js.map} +0 -0
- /package/dist/{chunk-52PDY6GD.js.map → chunk-PT2EZWOH.js.map} +0 -0
- /package/dist/{chunk-3KIS4VGT.js.map → chunk-QIGOEM65.js.map} +0 -0
- /package/dist/{chunk-47WOM4YW.js.map → chunk-RXGR3YLU.js.map} +0 -0
- /package/dist/{chunk-XQ4EJLUD.js.map → chunk-TMSHGSIG.js.map} +0 -0
- /package/dist/{chunk-X6VBWOVZ.js.map → chunk-UE2OQNQQ.js.map} +0 -0
- /package/dist/{chunk-MUELDH4F.js.map → chunk-YELFQNQH.js.map} +0 -0
- /package/dist/{chunk-TIFRGAKO.js.map → chunk-YKGRACQP.js.map} +0 -0
- /package/dist/{chunk-AGZHRWPT.js.map → chunk-ZBZVNWQO.js.map} +0 -0
- /package/dist/{chunk-W7WWT4FJ.js.map → chunk-ZOMA7J3J.js.map} +0 -0
- /package/dist/{engine-O6YWKQM3.js.map → engine-5OTS6GY3.js.map} +0 -0
- /package/dist/{memory-governance-JZHZDOLN.js.map → explicit-cue-recall.js.map} +0 -0
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
CompoundingEngine,
|
|
3
3
|
SharedContextManager,
|
|
4
4
|
defaultTierMigrationCycleBudget
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-TMSHGSIG.js";
|
|
6
6
|
import {
|
|
7
7
|
applyUtilityPromotionRuntimePolicy,
|
|
8
8
|
applyUtilityRankingRuntimeDelta,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
} from "./chunk-UHGBNIOS.js";
|
|
23
23
|
import {
|
|
24
24
|
HourlySummarizer
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-BFVBG5XY.js";
|
|
26
26
|
import {
|
|
27
27
|
applyTemporalSupersession,
|
|
28
28
|
normalizeSupersessionKey,
|
|
@@ -34,19 +34,6 @@ import {
|
|
|
34
34
|
import {
|
|
35
35
|
SessionObserverState
|
|
36
36
|
} from "./chunk-JR4ZC3G4.js";
|
|
37
|
-
import {
|
|
38
|
-
applyRuntimeRetrievalPolicy
|
|
39
|
-
} from "./chunk-5IZL4DCV.js";
|
|
40
|
-
import {
|
|
41
|
-
findUnresolvedEntityRefs
|
|
42
|
-
} from "./chunk-X7XN6YU4.js";
|
|
43
|
-
import {
|
|
44
|
-
RelevanceStore
|
|
45
|
-
} from "./chunk-5NPGSAVB.js";
|
|
46
|
-
import {
|
|
47
|
-
RerankCache,
|
|
48
|
-
rerankLocalOrNoop
|
|
49
|
-
} from "./chunk-C7VW7C3F.js";
|
|
50
37
|
import {
|
|
51
38
|
mergeWithAgentResults,
|
|
52
39
|
runDirectAgent,
|
|
@@ -65,6 +52,22 @@ import {
|
|
|
65
52
|
recencyWindowFromPrompt,
|
|
66
53
|
resolvePromptTagPrefilterAsync
|
|
67
54
|
} from "./chunk-V3RXWQIE.js";
|
|
55
|
+
import {
|
|
56
|
+
applyRuntimeRetrievalPolicy
|
|
57
|
+
} from "./chunk-5IZL4DCV.js";
|
|
58
|
+
import {
|
|
59
|
+
findUnresolvedEntityRefs
|
|
60
|
+
} from "./chunk-X7XN6YU4.js";
|
|
61
|
+
import {
|
|
62
|
+
RelevanceStore
|
|
63
|
+
} from "./chunk-5NPGSAVB.js";
|
|
64
|
+
import {
|
|
65
|
+
RerankCache,
|
|
66
|
+
rerankLocalOrNoop
|
|
67
|
+
} from "./chunk-C7VW7C3F.js";
|
|
68
|
+
import {
|
|
69
|
+
reorderRecallResultsWithMmr
|
|
70
|
+
} from "./chunk-YDBIWGNI.js";
|
|
68
71
|
import {
|
|
69
72
|
createRecallSectionMetricRecorder
|
|
70
73
|
} from "./chunk-7DHTMOND.js";
|
|
@@ -73,33 +76,24 @@ import {
|
|
|
73
76
|
TierMigrationStatusStore,
|
|
74
77
|
clampGraphRecallExpandedEntries
|
|
75
78
|
} from "./chunk-WPGJYVUH.js";
|
|
76
|
-
import {
|
|
77
|
-
applyReasoningTraceBoost
|
|
78
|
-
} from "./chunk-ZZTOURJI.js";
|
|
79
|
-
import {
|
|
80
|
-
reorderRecallResultsWithMmr
|
|
81
|
-
} from "./chunk-YDBIWGNI.js";
|
|
82
79
|
import {
|
|
83
80
|
buildQmdRecallCacheKey,
|
|
84
81
|
getCachedQmdRecall,
|
|
85
82
|
setCachedQmdRecall
|
|
86
83
|
} from "./chunk-YCN4BVDK.js";
|
|
84
|
+
import {
|
|
85
|
+
applyReasoningTraceBoost
|
|
86
|
+
} from "./chunk-ZZTOURJI.js";
|
|
87
87
|
import {
|
|
88
88
|
NegativeExampleStore
|
|
89
89
|
} from "./chunk-D654IBA6.js";
|
|
90
|
-
import {
|
|
91
|
-
applyMemoryWorthFilter,
|
|
92
|
-
buildMemoryWorthCounterMap
|
|
93
|
-
} from "./chunk-3GPTTA4J.js";
|
|
94
|
-
import {
|
|
95
|
-
runLiveConnectorsOnce
|
|
96
|
-
} from "./chunk-ASIQZXYO.js";
|
|
97
90
|
import {
|
|
98
91
|
evaluateMemoryActionPolicy
|
|
99
92
|
} from "./chunk-H63EDPFJ.js";
|
|
100
93
|
import {
|
|
101
|
-
|
|
102
|
-
|
|
94
|
+
applyMemoryWorthFilter,
|
|
95
|
+
buildMemoryWorthCounterMap
|
|
96
|
+
} from "./chunk-3GPTTA4J.js";
|
|
103
97
|
import {
|
|
104
98
|
hasBroadGraphIntent,
|
|
105
99
|
inferIntentFromText,
|
|
@@ -107,6 +101,15 @@ import {
|
|
|
107
101
|
isTaskInitiationIntent,
|
|
108
102
|
planRecallMode
|
|
109
103
|
} from "./chunk-GGD5W7TB.js";
|
|
104
|
+
import {
|
|
105
|
+
runLiveConnectorsOnce
|
|
106
|
+
} from "./chunk-ASIQZXYO.js";
|
|
107
|
+
import {
|
|
108
|
+
classifyMemoryKind
|
|
109
|
+
} from "./chunk-YAZNBMNF.js";
|
|
110
|
+
import {
|
|
111
|
+
buildExplicitCueRecallSection
|
|
112
|
+
} from "./chunk-AKV3HOGZ.js";
|
|
110
113
|
import {
|
|
111
114
|
recordJudgeTrainingPair
|
|
112
115
|
} from "./chunk-DF3RVK3X.js";
|
|
@@ -119,7 +122,7 @@ import {
|
|
|
119
122
|
} from "./chunk-C4SQJZAF.js";
|
|
120
123
|
import {
|
|
121
124
|
ExtractionEngine
|
|
122
|
-
} from "./chunk-
|
|
125
|
+
} from "./chunk-UE2OQNQQ.js";
|
|
123
126
|
import {
|
|
124
127
|
parseMemoryActionEligibilityContext
|
|
125
128
|
} from "./chunk-WW3QQF4H.js";
|
|
@@ -142,7 +145,7 @@ import {
|
|
|
142
145
|
buildEntityRecallSection,
|
|
143
146
|
entityRecentTranscriptLookbackHours,
|
|
144
147
|
readRecentEntityTranscriptEntries
|
|
145
|
-
} from "./chunk-
|
|
148
|
+
} from "./chunk-PT2EZWOH.js";
|
|
146
149
|
import {
|
|
147
150
|
buildCompressionGuidelinesMarkdown,
|
|
148
151
|
computeCompressionGuidelineCandidate,
|
|
@@ -152,28 +155,22 @@ import {
|
|
|
152
155
|
import {
|
|
153
156
|
RoutingRulesStore,
|
|
154
157
|
normalizeReplaySessionKey
|
|
155
|
-
} from "./chunk-
|
|
158
|
+
} from "./chunk-SRBJUAMP.js";
|
|
156
159
|
import {
|
|
157
160
|
searchVerifiedEpisodes
|
|
158
|
-
} from "./chunk-
|
|
161
|
+
} from "./chunk-LKJA5MR2.js";
|
|
159
162
|
import {
|
|
160
163
|
ThreadingManager
|
|
161
164
|
} from "./chunk-JRNQ3RNA.js";
|
|
162
165
|
import {
|
|
163
166
|
searchVerifiedSemanticRules
|
|
164
|
-
} from "./chunk-
|
|
167
|
+
} from "./chunk-ZOMA7J3J.js";
|
|
165
168
|
import {
|
|
166
169
|
searchWorkProductLedgerEntries
|
|
167
170
|
} from "./chunk-CULXMQJH.js";
|
|
168
171
|
import {
|
|
169
172
|
TranscriptManager
|
|
170
173
|
} from "./chunk-E6K4NIEU.js";
|
|
171
|
-
import {
|
|
172
|
-
PolicyRuntimeManager
|
|
173
|
-
} from "./chunk-EABGC2TL.js";
|
|
174
|
-
import {
|
|
175
|
-
searchObjectiveStateSnapshots
|
|
176
|
-
} from "./chunk-LOBRX7VD.js";
|
|
177
174
|
import {
|
|
178
175
|
NamespaceSearchRouter,
|
|
179
176
|
NamespaceStorageRouter,
|
|
@@ -181,10 +178,16 @@ import {
|
|
|
181
178
|
createConversationIndexRuntime,
|
|
182
179
|
createSearchBackend,
|
|
183
180
|
writeConversationChunks
|
|
184
|
-
} from "./chunk-
|
|
181
|
+
} from "./chunk-7RAW2T4P.js";
|
|
185
182
|
import {
|
|
186
183
|
parseQmdExplain
|
|
187
184
|
} from "./chunk-WSZIHQBK.js";
|
|
185
|
+
import {
|
|
186
|
+
PolicyRuntimeManager
|
|
187
|
+
} from "./chunk-EABGC2TL.js";
|
|
188
|
+
import {
|
|
189
|
+
searchObjectiveStateSnapshots
|
|
190
|
+
} from "./chunk-LOBRX7VD.js";
|
|
188
191
|
import {
|
|
189
192
|
searchHarmonicRetrieval
|
|
190
193
|
} from "./chunk-HMDCOMYU.js";
|
|
@@ -228,10 +231,10 @@ import {
|
|
|
228
231
|
materializeAfterSemanticConsolidation,
|
|
229
232
|
parseConsolidationResponse,
|
|
230
233
|
parseOperatorAwareConsolidationResponse
|
|
231
|
-
} from "./chunk-
|
|
234
|
+
} from "./chunk-ZBZVNWQO.js";
|
|
232
235
|
import {
|
|
233
236
|
FallbackLlmClient
|
|
234
|
-
} from "./chunk-
|
|
237
|
+
} from "./chunk-3P6TPZM4.js";
|
|
235
238
|
import {
|
|
236
239
|
buildRecallQueryPolicy
|
|
237
240
|
} from "./chunk-6HZ6AO2P.js";
|
|
@@ -263,7 +266,7 @@ import {
|
|
|
263
266
|
} from "./chunk-EQINRHYR.js";
|
|
264
267
|
import {
|
|
265
268
|
buildXraySnapshot
|
|
266
|
-
} from "./chunk-
|
|
269
|
+
} from "./chunk-D7WYTVUQ.js";
|
|
267
270
|
import {
|
|
268
271
|
shouldSkipImplicitExtraction
|
|
269
272
|
} from "./chunk-3FPTCC3Z.js";
|
|
@@ -303,7 +306,7 @@ import {
|
|
|
303
306
|
normalizeAttributePairs,
|
|
304
307
|
normalizeEntityName,
|
|
305
308
|
parseEntityFile
|
|
306
|
-
} from "./chunk-
|
|
309
|
+
} from "./chunk-DLYTYJ43.js";
|
|
307
310
|
import {
|
|
308
311
|
attachCitation,
|
|
309
312
|
hasCitationForTemplate,
|
|
@@ -311,7 +314,7 @@ import {
|
|
|
311
314
|
} from "./chunk-4KAN3GZ3.js";
|
|
312
315
|
import {
|
|
313
316
|
confidenceTier
|
|
314
|
-
} from "./chunk-
|
|
317
|
+
} from "./chunk-COAGZQT7.js";
|
|
315
318
|
import {
|
|
316
319
|
isActiveMemoryStatus
|
|
317
320
|
} from "./chunk-RULE4VG5.js";
|
|
@@ -1613,7 +1616,7 @@ function getTaxonomyFilePath(memoryDir) {
|
|
|
1613
1616
|
// src/lcm/schema.ts
|
|
1614
1617
|
import path4 from "path";
|
|
1615
1618
|
import { mkdir as mkdir4 } from "fs/promises";
|
|
1616
|
-
var LCM_SCHEMA_VERSION =
|
|
1619
|
+
var LCM_SCHEMA_VERSION = 2;
|
|
1617
1620
|
function openLcmDatabase(memoryDir) {
|
|
1618
1621
|
const dbPath = path4.join(memoryDir, "state", "lcm.sqlite");
|
|
1619
1622
|
const db = openBetterSqlite3(dbPath);
|
|
@@ -1662,6 +1665,23 @@ function createTables(db) {
|
|
|
1662
1665
|
CREATE INDEX IF NOT EXISTS idx_lcm_messages_session
|
|
1663
1666
|
ON lcm_messages(session_id, turn_index);
|
|
1664
1667
|
|
|
1668
|
+
CREATE TABLE IF NOT EXISTS lcm_message_parts (
|
|
1669
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
1670
|
+
message_id INTEGER NOT NULL REFERENCES lcm_messages(id) ON DELETE CASCADE,
|
|
1671
|
+
ordinal INTEGER NOT NULL,
|
|
1672
|
+
kind TEXT NOT NULL,
|
|
1673
|
+
payload TEXT NOT NULL,
|
|
1674
|
+
tool_name TEXT,
|
|
1675
|
+
file_path TEXT,
|
|
1676
|
+
created_at TEXT NOT NULL
|
|
1677
|
+
);
|
|
1678
|
+
CREATE INDEX IF NOT EXISTS idx_lcm_message_parts_msg
|
|
1679
|
+
ON lcm_message_parts(message_id, ordinal);
|
|
1680
|
+
CREATE INDEX IF NOT EXISTS idx_lcm_message_parts_tool
|
|
1681
|
+
ON lcm_message_parts(tool_name);
|
|
1682
|
+
CREATE INDEX IF NOT EXISTS idx_lcm_message_parts_file
|
|
1683
|
+
ON lcm_message_parts(file_path);
|
|
1684
|
+
|
|
1665
1685
|
CREATE TABLE IF NOT EXISTS lcm_summary_nodes (
|
|
1666
1686
|
id TEXT PRIMARY KEY,
|
|
1667
1687
|
session_id TEXT NOT NULL,
|
|
@@ -1714,6 +1734,423 @@ function createTables(db) {
|
|
|
1714
1734
|
);
|
|
1715
1735
|
}
|
|
1716
1736
|
|
|
1737
|
+
// src/message-parts/index.ts
|
|
1738
|
+
var LCM_MESSAGE_PART_KINDS = [
|
|
1739
|
+
"text",
|
|
1740
|
+
"tool_call",
|
|
1741
|
+
"tool_result",
|
|
1742
|
+
"patch",
|
|
1743
|
+
"file_read",
|
|
1744
|
+
"file_write",
|
|
1745
|
+
"step_start",
|
|
1746
|
+
"step_finish",
|
|
1747
|
+
"snapshot",
|
|
1748
|
+
"retry"
|
|
1749
|
+
];
|
|
1750
|
+
var SECRET_KEY_RE = /(api[_-]?key|authorization|bearer|credential|password|secret|token)/i;
|
|
1751
|
+
var MAX_PAYLOAD_STRING = 8e3;
|
|
1752
|
+
var MAX_FILE_SCAN_CHARS = 2e4;
|
|
1753
|
+
function isLcmMessagePartKind(value) {
|
|
1754
|
+
return typeof value === "string" && LCM_MESSAGE_PART_KINDS.includes(value);
|
|
1755
|
+
}
|
|
1756
|
+
function parseMessageParts(input, options = {}) {
|
|
1757
|
+
const explicit = normalizeExplicitParts(input);
|
|
1758
|
+
if (explicit.length > 0) return explicit;
|
|
1759
|
+
const format = options.sourceFormat ?? inferSourceFormat(input);
|
|
1760
|
+
switch (format) {
|
|
1761
|
+
case "openai":
|
|
1762
|
+
return withRenderedFallback(parseOpenAiMessageParts(input, options), options);
|
|
1763
|
+
case "anthropic":
|
|
1764
|
+
return withRenderedFallback(parseAnthropicMessageParts(input, options), options);
|
|
1765
|
+
case "openclaw":
|
|
1766
|
+
return withRenderedFallback(parseOpenClawMessageParts(input, options), options);
|
|
1767
|
+
case "lossless-claw":
|
|
1768
|
+
case "remnic":
|
|
1769
|
+
return withRenderedFallback(normalizeExplicitParts(input), options);
|
|
1770
|
+
default:
|
|
1771
|
+
return renderedFallbackParts(options);
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
function normalizeExplicitParts(input) {
|
|
1775
|
+
const rawParts = pickArray(input, "parts") ?? pickArray(input, "message_parts");
|
|
1776
|
+
if (!rawParts) return [];
|
|
1777
|
+
const parts = [];
|
|
1778
|
+
rawParts.forEach((raw, index) => {
|
|
1779
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return;
|
|
1780
|
+
const obj = raw;
|
|
1781
|
+
const kind = normalizeKind(obj.kind ?? obj.type);
|
|
1782
|
+
if (!kind) return;
|
|
1783
|
+
const payload = obj.payload && typeof obj.payload === "object" && !Array.isArray(obj.payload) ? obj.payload : { value: sanitizePayload(obj) };
|
|
1784
|
+
const toolName = asNonEmptyString(obj.toolName ?? obj.tool_name ?? obj.name);
|
|
1785
|
+
const filePath = asNonEmptyString(obj.filePath ?? obj.file_path ?? obj.path);
|
|
1786
|
+
const ordinal = typeof obj.ordinal === "number" && Number.isInteger(obj.ordinal) ? Math.max(0, obj.ordinal) : index;
|
|
1787
|
+
parts.push({
|
|
1788
|
+
ordinal,
|
|
1789
|
+
kind,
|
|
1790
|
+
payload: sanitizePayload(payload),
|
|
1791
|
+
toolName,
|
|
1792
|
+
filePath,
|
|
1793
|
+
createdAt: asNonEmptyString(obj.createdAt ?? obj.created_at)
|
|
1794
|
+
});
|
|
1795
|
+
});
|
|
1796
|
+
return parts;
|
|
1797
|
+
}
|
|
1798
|
+
function parseOpenAiMessageParts(input, _options = {}) {
|
|
1799
|
+
const items = gatherOpenAiItems(input);
|
|
1800
|
+
const parts = [];
|
|
1801
|
+
for (const item of items) {
|
|
1802
|
+
const type = asNonEmptyString(item.type) ?? asNonEmptyString(item.kind);
|
|
1803
|
+
if (!type) continue;
|
|
1804
|
+
if (isOpenAiContentBlock(item)) {
|
|
1805
|
+
const text = asNonEmptyString(item.text ?? item.content);
|
|
1806
|
+
if (text) parts.push(makePart("text", { type, text }, { filePath: firstFilePath(text) }));
|
|
1807
|
+
continue;
|
|
1808
|
+
}
|
|
1809
|
+
if (type === "message") {
|
|
1810
|
+
for (const block of gatherContentBlocks(item.content)) {
|
|
1811
|
+
const text = asNonEmptyString(block.text ?? block.content);
|
|
1812
|
+
if (text) parts.push(makePart("text", { type, text }, { filePath: firstFilePath(text) }));
|
|
1813
|
+
}
|
|
1814
|
+
continue;
|
|
1815
|
+
}
|
|
1816
|
+
if (type === "function_call") {
|
|
1817
|
+
const toolName = asNonEmptyString(item.name ?? item.tool_name);
|
|
1818
|
+
const payload = {
|
|
1819
|
+
id: item.id ?? item.call_id,
|
|
1820
|
+
name: toolName,
|
|
1821
|
+
arguments: parseMaybeJson(item.arguments)
|
|
1822
|
+
};
|
|
1823
|
+
parts.push(classifyToolPart(toolName, payload));
|
|
1824
|
+
continue;
|
|
1825
|
+
}
|
|
1826
|
+
if (type === "function_call_output") {
|
|
1827
|
+
const output = asNonEmptyString(item.output) ?? JSON.stringify(sanitizePayload(item.output ?? item));
|
|
1828
|
+
parts.push(makePart("tool_result", { id: item.id ?? item.call_id, output }, {
|
|
1829
|
+
filePath: firstFilePath(output)
|
|
1830
|
+
}));
|
|
1831
|
+
continue;
|
|
1832
|
+
}
|
|
1833
|
+
if (type === "reasoning") {
|
|
1834
|
+
parts.push(makePart("step_start", { type, summary: sanitizePayload(item.summary ?? item) }));
|
|
1835
|
+
continue;
|
|
1836
|
+
}
|
|
1837
|
+
if (type === "retry") {
|
|
1838
|
+
parts.push(makePart("retry", { type, item: sanitizePayload(item) }));
|
|
1839
|
+
}
|
|
1840
|
+
}
|
|
1841
|
+
return withOrdinals(parts);
|
|
1842
|
+
}
|
|
1843
|
+
function parseAnthropicMessageParts(input, _options = {}) {
|
|
1844
|
+
const blocks = gatherContentBlocks(
|
|
1845
|
+
Array.isArray(input) ? input : input && typeof input === "object" ? input.content : input
|
|
1846
|
+
);
|
|
1847
|
+
const parts = [];
|
|
1848
|
+
for (const block of blocks) {
|
|
1849
|
+
const type = asNonEmptyString(block.type);
|
|
1850
|
+
if (type === "text") {
|
|
1851
|
+
const text = asNonEmptyString(block.text);
|
|
1852
|
+
if (text) parts.push(makePart("text", { type, text }, { filePath: firstFilePath(text) }));
|
|
1853
|
+
continue;
|
|
1854
|
+
}
|
|
1855
|
+
if (type === "tool_use") {
|
|
1856
|
+
const toolName = asNonEmptyString(block.name);
|
|
1857
|
+
parts.push(classifyToolPart(toolName, {
|
|
1858
|
+
id: block.id,
|
|
1859
|
+
name: toolName,
|
|
1860
|
+
input: sanitizePayload(block.input)
|
|
1861
|
+
}));
|
|
1862
|
+
continue;
|
|
1863
|
+
}
|
|
1864
|
+
if (type === "tool_result") {
|
|
1865
|
+
const content = block.content;
|
|
1866
|
+
const rendered = renderUnknownContent(content);
|
|
1867
|
+
parts.push(makePart("tool_result", { id: block.tool_use_id, content: sanitizePayload(content) }, {
|
|
1868
|
+
filePath: firstFilePath(rendered)
|
|
1869
|
+
}));
|
|
1870
|
+
continue;
|
|
1871
|
+
}
|
|
1872
|
+
if (type === "thinking") {
|
|
1873
|
+
parts.push(makePart("step_start", {
|
|
1874
|
+
type,
|
|
1875
|
+
thinking: truncateString(asNonEmptyString(block.thinking) ?? ""),
|
|
1876
|
+
signature: asNonEmptyString(block.signature)
|
|
1877
|
+
}));
|
|
1878
|
+
continue;
|
|
1879
|
+
}
|
|
1880
|
+
if (type === "redacted_thinking") {
|
|
1881
|
+
parts.push(makePart("step_finish", { type }));
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
return withOrdinals(parts);
|
|
1885
|
+
}
|
|
1886
|
+
function parseOpenClawMessageParts(input, options = {}) {
|
|
1887
|
+
const explicit = normalizeExplicitParts(input);
|
|
1888
|
+
if (explicit.length > 0) return explicit;
|
|
1889
|
+
if (!input || typeof input !== "object") return [];
|
|
1890
|
+
const obj = input;
|
|
1891
|
+
const content = obj.content;
|
|
1892
|
+
if (Array.isArray(content)) {
|
|
1893
|
+
const hasOpenAiBlocks = content.some(isOpenAiContentBlock);
|
|
1894
|
+
if (hasOpenAiBlocks) return parseOpenAiMessageParts(content, options);
|
|
1895
|
+
const hasAnthropicBlocks = content.some(
|
|
1896
|
+
(block) => block && typeof block === "object" && typeof block.type === "string"
|
|
1897
|
+
);
|
|
1898
|
+
if (hasAnthropicBlocks) return parseAnthropicMessageParts({ content }, options);
|
|
1899
|
+
}
|
|
1900
|
+
const toolName = asNonEmptyString(obj.toolName ?? obj.tool_name ?? obj.name);
|
|
1901
|
+
if (toolName) {
|
|
1902
|
+
return withOrdinals([
|
|
1903
|
+
classifyToolPart(toolName, {
|
|
1904
|
+
name: toolName,
|
|
1905
|
+
input: sanitizePayload(obj.input ?? obj.arguments ?? obj.params),
|
|
1906
|
+
output: sanitizePayload(obj.output ?? obj.result)
|
|
1907
|
+
})
|
|
1908
|
+
]);
|
|
1909
|
+
}
|
|
1910
|
+
const rendered = options.renderedContent ?? asNonEmptyString(obj.content);
|
|
1911
|
+
return rendered ? withOrdinals(partsFromRenderedText(rendered)) : [];
|
|
1912
|
+
}
|
|
1913
|
+
function partsFromRenderedText(text) {
|
|
1914
|
+
if (text.includes("*** Begin Patch")) {
|
|
1915
|
+
const paths2 = extractFilePaths(text);
|
|
1916
|
+
const patchPaths = extractPatchPaths(text);
|
|
1917
|
+
return withOrdinals((patchPaths.length > 0 ? patchPaths : paths2).map(
|
|
1918
|
+
(filePath) => makePart("patch", { text: truncateString(text) }, { filePath })
|
|
1919
|
+
));
|
|
1920
|
+
}
|
|
1921
|
+
const paths = extractFilePaths(text);
|
|
1922
|
+
if (paths.length === 0) return [];
|
|
1923
|
+
return withOrdinals(paths.map(
|
|
1924
|
+
(filePath) => makePart("file_read", { text: truncateString(text) }, { filePath })
|
|
1925
|
+
));
|
|
1926
|
+
}
|
|
1927
|
+
function inferSourceFormat(input) {
|
|
1928
|
+
if (input && typeof input === "object") {
|
|
1929
|
+
const obj = input;
|
|
1930
|
+
const explicit = asNonEmptyString(obj.sourceFormat ?? obj.source_format);
|
|
1931
|
+
if (explicit === "openai" || explicit === "anthropic" || explicit === "openclaw" || explicit === "lossless-claw" || explicit === "remnic") {
|
|
1932
|
+
return explicit;
|
|
1933
|
+
}
|
|
1934
|
+
if (Array.isArray(obj.output)) return "openai";
|
|
1935
|
+
if (isOpenAiResponseItem(obj)) return "openai";
|
|
1936
|
+
if (Array.isArray(obj.content) && obj.content.some(isOpenAiContentBlock)) return "openai";
|
|
1937
|
+
if (Array.isArray(obj.content)) return "anthropic";
|
|
1938
|
+
}
|
|
1939
|
+
if (Array.isArray(input)) {
|
|
1940
|
+
return input.some(
|
|
1941
|
+
(item) => isRecord(item) && (isOpenAiResponseItem(item) || isOpenAiContentBlock(item))
|
|
1942
|
+
) ? "openai" : "anthropic";
|
|
1943
|
+
}
|
|
1944
|
+
return void 0;
|
|
1945
|
+
}
|
|
1946
|
+
function isOpenAiResponseItem(obj) {
|
|
1947
|
+
const type = asNonEmptyString(obj.type ?? obj.kind);
|
|
1948
|
+
return type === "message" || type === "function_call" || type === "function_call_output" || type === "reasoning" || type === "retry";
|
|
1949
|
+
}
|
|
1950
|
+
function isOpenAiContentBlock(value) {
|
|
1951
|
+
if (!isRecord(value)) return false;
|
|
1952
|
+
const type = asNonEmptyString(value.type);
|
|
1953
|
+
return type === "input_text" || type === "output_text" || type === "input_image" || type === "input_file" || type === "refusal";
|
|
1954
|
+
}
|
|
1955
|
+
function gatherOpenAiItems(input) {
|
|
1956
|
+
if (Array.isArray(input)) return input.filter(isRecord);
|
|
1957
|
+
if (!isRecord(input)) return [];
|
|
1958
|
+
if (Array.isArray(input.output)) return input.output.filter(isRecord);
|
|
1959
|
+
if (Array.isArray(input.items)) return input.items.filter(isRecord);
|
|
1960
|
+
return [input];
|
|
1961
|
+
}
|
|
1962
|
+
function gatherContentBlocks(input) {
|
|
1963
|
+
if (Array.isArray(input)) return input.filter(isRecord);
|
|
1964
|
+
if (typeof input === "string") return [{ type: "text", text: input }];
|
|
1965
|
+
if (isRecord(input)) return [input];
|
|
1966
|
+
return [];
|
|
1967
|
+
}
|
|
1968
|
+
function classifyToolPart(toolName, payload) {
|
|
1969
|
+
const normalized = (toolName ?? "").toLowerCase();
|
|
1970
|
+
const rendered = renderUnknownContent(payload);
|
|
1971
|
+
const filePath = firstFilePathFromObject(payload) ?? firstFilePath(rendered) ?? null;
|
|
1972
|
+
if (normalized.includes("apply_patch") || rendered.includes("*** Begin Patch")) {
|
|
1973
|
+
return makePart("patch", payload, { toolName, filePath: filePath ?? extractPatchPaths(rendered)[0] ?? null });
|
|
1974
|
+
}
|
|
1975
|
+
if (/(write|edit|multiedit|create|save)/i.test(normalized)) {
|
|
1976
|
+
return makePart("file_write", payload, { toolName, filePath });
|
|
1977
|
+
}
|
|
1978
|
+
if (/(read|grep|glob|search|list|ls)/i.test(normalized)) {
|
|
1979
|
+
return makePart("file_read", payload, { toolName, filePath });
|
|
1980
|
+
}
|
|
1981
|
+
return makePart("tool_call", payload, { toolName, filePath });
|
|
1982
|
+
}
|
|
1983
|
+
function makePart(kind, payload, options = {}) {
|
|
1984
|
+
return {
|
|
1985
|
+
kind,
|
|
1986
|
+
payload: sanitizePayload(payload),
|
|
1987
|
+
toolName: options.toolName ?? null,
|
|
1988
|
+
filePath: options.filePath ?? null
|
|
1989
|
+
};
|
|
1990
|
+
}
|
|
1991
|
+
function withOrdinals(parts) {
|
|
1992
|
+
return parts.map((part, ordinal) => ({ ...part, ordinal: part.ordinal ?? ordinal }));
|
|
1993
|
+
}
|
|
1994
|
+
function withRenderedFallback(parts, options) {
|
|
1995
|
+
return parts.length > 0 ? parts : renderedFallbackParts(options);
|
|
1996
|
+
}
|
|
1997
|
+
function renderedFallbackParts(options) {
|
|
1998
|
+
const rendered = asNonEmptyString(options.renderedContent);
|
|
1999
|
+
return rendered ? partsFromRenderedText(rendered) : [];
|
|
2000
|
+
}
|
|
2001
|
+
function normalizeKind(value) {
|
|
2002
|
+
if (isLcmMessagePartKind(value)) return value;
|
|
2003
|
+
if (value === "tool_use" || value === "function_call") return "tool_call";
|
|
2004
|
+
if (value === "function_call_output") return "tool_result";
|
|
2005
|
+
if (value === "thinking" || value === "reasoning") return "step_start";
|
|
2006
|
+
return null;
|
|
2007
|
+
}
|
|
2008
|
+
function pickArray(input, key) {
|
|
2009
|
+
if (!input || typeof input !== "object" || Array.isArray(input)) return null;
|
|
2010
|
+
const value = input[key];
|
|
2011
|
+
return Array.isArray(value) ? value : null;
|
|
2012
|
+
}
|
|
2013
|
+
function asNonEmptyString(value) {
|
|
2014
|
+
if (typeof value !== "string") return null;
|
|
2015
|
+
const trimmed = value.trim();
|
|
2016
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
2017
|
+
}
|
|
2018
|
+
function isRecord(value) {
|
|
2019
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
2020
|
+
}
|
|
2021
|
+
function parseMaybeJson(value) {
|
|
2022
|
+
if (typeof value !== "string") return sanitizePayload(value);
|
|
2023
|
+
try {
|
|
2024
|
+
return sanitizePayload(JSON.parse(value));
|
|
2025
|
+
} catch {
|
|
2026
|
+
return truncateString(value);
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
function sanitizePayload(value, depth = 0) {
|
|
2030
|
+
if (value === null || value === void 0) return value;
|
|
2031
|
+
if (typeof value === "string") return truncateString(value);
|
|
2032
|
+
if (typeof value === "number" || typeof value === "boolean") return value;
|
|
2033
|
+
if (Array.isArray(value)) {
|
|
2034
|
+
if (depth >= 4) return "[truncated]";
|
|
2035
|
+
return value.slice(0, 100).map((item) => sanitizePayload(item, depth + 1));
|
|
2036
|
+
}
|
|
2037
|
+
if (typeof value === "object") {
|
|
2038
|
+
if (depth >= 4) return "[truncated]";
|
|
2039
|
+
const out = {};
|
|
2040
|
+
for (const [key, child] of Object.entries(value)) {
|
|
2041
|
+
out[key] = SECRET_KEY_RE.test(key) ? "[redacted]" : sanitizePayload(child, depth + 1);
|
|
2042
|
+
}
|
|
2043
|
+
return out;
|
|
2044
|
+
}
|
|
2045
|
+
return String(value);
|
|
2046
|
+
}
|
|
2047
|
+
function truncateString(value) {
|
|
2048
|
+
return value.length > MAX_PAYLOAD_STRING ? `${value.slice(0, MAX_PAYLOAD_STRING)}...[truncated]` : value;
|
|
2049
|
+
}
|
|
2050
|
+
function renderUnknownContent(value) {
|
|
2051
|
+
if (typeof value === "string") return value;
|
|
2052
|
+
try {
|
|
2053
|
+
return JSON.stringify(value ?? "");
|
|
2054
|
+
} catch {
|
|
2055
|
+
return String(value ?? "");
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
function firstFilePathFromObject(value) {
|
|
2059
|
+
if (!isRecord(value)) return null;
|
|
2060
|
+
const keys = ["file_path", "filePath", "path", "filename", "cwd"];
|
|
2061
|
+
for (const key of keys) {
|
|
2062
|
+
const candidate = asNonEmptyString(value[key]);
|
|
2063
|
+
if (candidate) return candidate;
|
|
2064
|
+
}
|
|
2065
|
+
for (const child of Object.values(value)) {
|
|
2066
|
+
if (typeof child === "string") {
|
|
2067
|
+
const fromText = extractPatchPaths(child)[0] ?? firstFilePath(child);
|
|
2068
|
+
if (fromText) return fromText;
|
|
2069
|
+
}
|
|
2070
|
+
if (isRecord(child)) {
|
|
2071
|
+
const nested = firstFilePathFromObject(child);
|
|
2072
|
+
if (nested) return nested;
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
return null;
|
|
2076
|
+
}
|
|
2077
|
+
function firstFilePath(text) {
|
|
2078
|
+
return extractFilePaths(text)[0] ?? null;
|
|
2079
|
+
}
|
|
2080
|
+
function extractFilePaths(text) {
|
|
2081
|
+
const out = /* @__PURE__ */ new Set();
|
|
2082
|
+
let token = "";
|
|
2083
|
+
const scanLength = Math.min(text.length, MAX_FILE_SCAN_CHARS);
|
|
2084
|
+
for (let index = 0; index <= scanLength; index += 1) {
|
|
2085
|
+
const char = index < scanLength ? text[index] : " ";
|
|
2086
|
+
if (isFilePathTokenSeparator(char)) {
|
|
2087
|
+
addFilePathCandidate(out, token);
|
|
2088
|
+
token = "";
|
|
2089
|
+
continue;
|
|
2090
|
+
}
|
|
2091
|
+
token += char;
|
|
2092
|
+
if (token.length > 512) {
|
|
2093
|
+
addFilePathCandidate(out, token);
|
|
2094
|
+
token = "";
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
return [...out].slice(0, 20);
|
|
2098
|
+
}
|
|
2099
|
+
function isFilePathTokenSeparator(char) {
|
|
2100
|
+
return char === " " || char === "\n" || char === "\r" || char === " " || char === '"' || char === "'" || char === "`" || char === "(" || char === ")" || char === "[" || char === "]" || char === "{" || char === "}" || char === "<" || char === ">" || char === ",";
|
|
2101
|
+
}
|
|
2102
|
+
function addFilePathCandidate(out, raw) {
|
|
2103
|
+
const candidate = trimFilePathPunctuation(raw);
|
|
2104
|
+
if (candidate.length === 0 || candidate.includes("://")) return;
|
|
2105
|
+
if (isLikelyFilePath(candidate)) out.add(candidate);
|
|
2106
|
+
}
|
|
2107
|
+
function trimFilePathPunctuation(raw) {
|
|
2108
|
+
let start = 0;
|
|
2109
|
+
let end = raw.length;
|
|
2110
|
+
while (start < end && isLeadingFilePathPunctuation(raw[start])) start += 1;
|
|
2111
|
+
while (end > start && isTrailingFilePathPunctuation(raw[end - 1])) end -= 1;
|
|
2112
|
+
return raw.slice(start, end);
|
|
2113
|
+
}
|
|
2114
|
+
function isLeadingFilePathPunctuation(char) {
|
|
2115
|
+
return char === ":" || char === ";" || char === "!" || char === "?" || char === "|" || char === "*" || char === "=";
|
|
2116
|
+
}
|
|
2117
|
+
function isTrailingFilePathPunctuation(char) {
|
|
2118
|
+
return char === "." || char === ":" || char === ";" || char === "!" || char === "?" || char === "|" || char === "*" || char === "=";
|
|
2119
|
+
}
|
|
2120
|
+
function isLikelyFilePath(value) {
|
|
2121
|
+
if (value.startsWith("/") || value.startsWith("./") || value.startsWith("../") || value.startsWith("~/")) {
|
|
2122
|
+
return hasValidFileExtension(value);
|
|
2123
|
+
}
|
|
2124
|
+
if (value.includes("/")) return hasValidFileExtension(value);
|
|
2125
|
+
return hasValidFileExtension(value);
|
|
2126
|
+
}
|
|
2127
|
+
function hasValidFileExtension(value) {
|
|
2128
|
+
const lastSlash = value.lastIndexOf("/");
|
|
2129
|
+
const basename = value.slice(lastSlash + 1);
|
|
2130
|
+
const dot = basename.lastIndexOf(".");
|
|
2131
|
+
if (dot <= 0 || dot === basename.length - 1) return false;
|
|
2132
|
+
const ext = basename.slice(dot + 1);
|
|
2133
|
+
if (ext.length < 1 || ext.length > 12) return false;
|
|
2134
|
+
for (const char of ext) {
|
|
2135
|
+
if (!isFileExtensionChar(char)) return false;
|
|
2136
|
+
}
|
|
2137
|
+
return true;
|
|
2138
|
+
}
|
|
2139
|
+
function isFileExtensionChar(char) {
|
|
2140
|
+
const code = char.charCodeAt(0);
|
|
2141
|
+
return code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || char === "_" || char === "+" || char === "-";
|
|
2142
|
+
}
|
|
2143
|
+
function extractPatchPaths(text) {
|
|
2144
|
+
const out = /* @__PURE__ */ new Set();
|
|
2145
|
+
for (const line of text.split(/\r?\n/)) {
|
|
2146
|
+
const match = line.match(/^\*\*\* (?:Add|Update|Delete) File: (.+)$/);
|
|
2147
|
+
if (match?.[1]) out.add(match[1].trim());
|
|
2148
|
+
const move = line.match(/^\*\*\* Move to: (.+)$/);
|
|
2149
|
+
if (move?.[1]) out.add(move[1].trim());
|
|
2150
|
+
}
|
|
2151
|
+
return [...out].slice(0, 20);
|
|
2152
|
+
}
|
|
2153
|
+
|
|
1717
2154
|
// src/lcm/archive.ts
|
|
1718
2155
|
function estimateTokens(text) {
|
|
1719
2156
|
return Math.ceil(text.length / 4);
|
|
@@ -1724,7 +2161,7 @@ var LcmArchive = class {
|
|
|
1724
2161
|
}
|
|
1725
2162
|
db;
|
|
1726
2163
|
/** Append a message to the archive. Returns the row id. */
|
|
1727
|
-
appendMessage(sessionId, turnIndex, role, content, metadata) {
|
|
2164
|
+
appendMessage(sessionId, turnIndex, role, content, metadata, parts) {
|
|
1728
2165
|
const tokenCount = estimateTokens(content);
|
|
1729
2166
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
1730
2167
|
const metaJson = metadata ? JSON.stringify(metadata) : null;
|
|
@@ -1735,18 +2172,58 @@ var LcmArchive = class {
|
|
|
1735
2172
|
const result = stmt.run(sessionId, turnIndex, role, content, tokenCount, now, metaJson);
|
|
1736
2173
|
const rowId = Number(result.lastInsertRowid);
|
|
1737
2174
|
this.db.prepare("INSERT INTO lcm_messages_fts (rowid, content) VALUES (?, ?)").run(rowId, content);
|
|
2175
|
+
if (parts && parts.length > 0) {
|
|
2176
|
+
this.insertMessageParts(rowId, parts, now);
|
|
2177
|
+
}
|
|
1738
2178
|
return rowId;
|
|
1739
2179
|
}
|
|
1740
2180
|
/** Append multiple messages in a single transaction. */
|
|
1741
|
-
appendMessages(sessionId, messages) {
|
|
2181
|
+
appendMessages(sessionId, messages, options = {}) {
|
|
1742
2182
|
if (messages.length === 0) return;
|
|
2183
|
+
const captureMessageParts = options.messagePartsEnabled !== false;
|
|
1743
2184
|
const txn = this.db.transaction(() => {
|
|
1744
2185
|
for (const msg of messages) {
|
|
1745
|
-
|
|
2186
|
+
const explicitParts = msg.parts && msg.parts.length > 0 ? msg.parts : void 0;
|
|
2187
|
+
const rawContent = msg.rawContent ?? msg.content;
|
|
2188
|
+
const parts = captureMessageParts ? explicitParts ?? parseMessageParts(rawContent, {
|
|
2189
|
+
sourceFormat: msg.sourceFormat,
|
|
2190
|
+
renderedContent: msg.content
|
|
2191
|
+
}) : void 0;
|
|
2192
|
+
this.appendMessage(
|
|
2193
|
+
sessionId,
|
|
2194
|
+
msg.turnIndex,
|
|
2195
|
+
msg.role,
|
|
2196
|
+
msg.content,
|
|
2197
|
+
msg.metadata,
|
|
2198
|
+
parts
|
|
2199
|
+
);
|
|
1746
2200
|
}
|
|
1747
2201
|
});
|
|
1748
2202
|
txn();
|
|
1749
2203
|
}
|
|
2204
|
+
insertMessageParts(messageId, parts, fallbackCreatedAt) {
|
|
2205
|
+
if (parts.length === 0) return;
|
|
2206
|
+
const stmt = this.db.prepare(`
|
|
2207
|
+
INSERT INTO lcm_message_parts (message_id, ordinal, kind, payload, tool_name, file_path, created_at)
|
|
2208
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
2209
|
+
`);
|
|
2210
|
+
for (let index = 0; index < parts.length; index += 1) {
|
|
2211
|
+
const part = parts[index];
|
|
2212
|
+
const rawPart = part;
|
|
2213
|
+
const toolName = part.toolName ?? asNullableString(rawPart.tool_name);
|
|
2214
|
+
const filePath = part.filePath ?? asNullableString(rawPart.file_path);
|
|
2215
|
+
const createdAt = part.createdAt ?? asNullableString(rawPart.created_at);
|
|
2216
|
+
stmt.run(
|
|
2217
|
+
messageId,
|
|
2218
|
+
part.ordinal ?? index,
|
|
2219
|
+
part.kind,
|
|
2220
|
+
JSON.stringify(part.payload ?? {}),
|
|
2221
|
+
toolName ?? null,
|
|
2222
|
+
filePath ?? null,
|
|
2223
|
+
createdAt ?? fallbackCreatedAt
|
|
2224
|
+
);
|
|
2225
|
+
}
|
|
2226
|
+
}
|
|
1750
2227
|
/** Get the highest turn_index for a session, or -1 if none. */
|
|
1751
2228
|
getMaxTurnIndex(sessionId) {
|
|
1752
2229
|
const row = this.db.prepare("SELECT MAX(turn_index) as max_turn FROM lcm_messages WHERE session_id = ?").get(sessionId);
|
|
@@ -1868,6 +2345,55 @@ var LcmArchive = class {
|
|
|
1868
2345
|
return [];
|
|
1869
2346
|
}
|
|
1870
2347
|
}
|
|
2348
|
+
searchStructuredParts(query, limit, sessionId) {
|
|
2349
|
+
const cappedLimit = Math.max(0, Math.min(20, Math.floor(limit)));
|
|
2350
|
+
if (cappedLimit === 0) return [];
|
|
2351
|
+
const fileTerms = extractStructuredFileTerms(query);
|
|
2352
|
+
const toolTerms = extractStructuredToolTerms(query);
|
|
2353
|
+
if (fileTerms.length === 0 && toolTerms.length === 0) return [];
|
|
2354
|
+
const matchWhere = [];
|
|
2355
|
+
const whereParams = [];
|
|
2356
|
+
for (const term of fileTerms) {
|
|
2357
|
+
matchWhere.push("(p.file_path = ? OR p.file_path LIKE ? ESCAPE '\\')");
|
|
2358
|
+
whereParams.push(term, `%${escapeLike(term)}%`);
|
|
2359
|
+
}
|
|
2360
|
+
for (const term of toolTerms) {
|
|
2361
|
+
matchWhere.push("p.tool_name LIKE ? ESCAPE '\\'");
|
|
2362
|
+
whereParams.push(`%${escapeLike(term)}%`);
|
|
2363
|
+
}
|
|
2364
|
+
const where = [`(${matchWhere.join(" OR ")})`];
|
|
2365
|
+
if (sessionId) {
|
|
2366
|
+
where.push("m.session_id = ?");
|
|
2367
|
+
whereParams.push(sessionId);
|
|
2368
|
+
}
|
|
2369
|
+
const exactFileScoreParams = [...fileTerms];
|
|
2370
|
+
const sqlParams = [...exactFileScoreParams, ...whereParams, cappedLimit];
|
|
2371
|
+
const rows = this.db.prepare(`
|
|
2372
|
+
SELECT
|
|
2373
|
+
p.id AS part_id,
|
|
2374
|
+
p.message_id AS message_id,
|
|
2375
|
+
m.turn_index AS turn_index,
|
|
2376
|
+
m.role AS role,
|
|
2377
|
+
m.content AS content,
|
|
2378
|
+
m.session_id AS session_id,
|
|
2379
|
+
p.kind AS kind,
|
|
2380
|
+
p.tool_name AS tool_name,
|
|
2381
|
+
p.file_path AS file_path,
|
|
2382
|
+
p.payload AS payload,
|
|
2383
|
+
CASE
|
|
2384
|
+
WHEN p.file_path IN (${fileTerms.map(() => "?").join(",") || "NULL"}) THEN 3
|
|
2385
|
+
WHEN p.file_path IS NOT NULL THEN 2
|
|
2386
|
+
WHEN p.tool_name IS NOT NULL THEN 1
|
|
2387
|
+
ELSE 0
|
|
2388
|
+
END AS score
|
|
2389
|
+
FROM lcm_message_parts p
|
|
2390
|
+
JOIN lcm_messages m ON m.id = p.message_id
|
|
2391
|
+
WHERE ${where.join(" AND ")}
|
|
2392
|
+
ORDER BY score DESC, m.turn_index DESC, p.ordinal ASC
|
|
2393
|
+
LIMIT ?
|
|
2394
|
+
`).all(...sqlParams);
|
|
2395
|
+
return rows;
|
|
2396
|
+
}
|
|
1871
2397
|
/** Get total message count for a session. */
|
|
1872
2398
|
getMessageCount(sessionId) {
|
|
1873
2399
|
const row = this.db.prepare("SELECT COUNT(*) as cnt FROM lcm_messages WHERE session_id = ?").get(sessionId);
|
|
@@ -2019,6 +2545,72 @@ var STOPWORDS = /* @__PURE__ */ new Set([
|
|
|
2019
2545
|
"we",
|
|
2020
2546
|
"they"
|
|
2021
2547
|
]);
|
|
2548
|
+
function extractStructuredFileTerms(query) {
|
|
2549
|
+
const terms = /* @__PURE__ */ new Set();
|
|
2550
|
+
for (const raw of splitQueryTerms(query)) {
|
|
2551
|
+
const cleaned = trimStructuredQueryTerm(raw);
|
|
2552
|
+
if (cleaned.includes("/") || hasStructuredFileExtension(cleaned)) {
|
|
2553
|
+
terms.add(cleaned);
|
|
2554
|
+
const basename = cleaned.split("/").pop();
|
|
2555
|
+
if (basename && basename !== cleaned) terms.add(basename);
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
return [...terms].filter((term) => term.length > 1).slice(0, 12);
|
|
2559
|
+
}
|
|
2560
|
+
function splitQueryTerms(query) {
|
|
2561
|
+
const terms = [];
|
|
2562
|
+
let term = "";
|
|
2563
|
+
for (const char of query.slice(0, 2e4)) {
|
|
2564
|
+
if (char === " " || char === "\n" || char === "\r" || char === " ") {
|
|
2565
|
+
if (term.length > 0) terms.push(term);
|
|
2566
|
+
term = "";
|
|
2567
|
+
continue;
|
|
2568
|
+
}
|
|
2569
|
+
term += char;
|
|
2570
|
+
if (term.length > 512) {
|
|
2571
|
+
terms.push(term);
|
|
2572
|
+
term = "";
|
|
2573
|
+
}
|
|
2574
|
+
}
|
|
2575
|
+
if (term.length > 0) terms.push(term);
|
|
2576
|
+
return terms;
|
|
2577
|
+
}
|
|
2578
|
+
function trimStructuredQueryTerm(raw) {
|
|
2579
|
+
const leading = /* @__PURE__ */ new Set(["`", "'", '"', "(", "[", "{"]);
|
|
2580
|
+
const trailing = /* @__PURE__ */ new Set(["`", "'", '"', ",", ".", "?", "!", ":", ";", ")", "]", "}"]);
|
|
2581
|
+
let start = 0;
|
|
2582
|
+
let end = raw.length;
|
|
2583
|
+
while (start < end && leading.has(raw[start])) start += 1;
|
|
2584
|
+
while (end > start && trailing.has(raw[end - 1])) end -= 1;
|
|
2585
|
+
return raw.slice(start, end);
|
|
2586
|
+
}
|
|
2587
|
+
function hasStructuredFileExtension(value) {
|
|
2588
|
+
const slash = value.lastIndexOf("/");
|
|
2589
|
+
const basename = value.slice(slash + 1);
|
|
2590
|
+
const dot = basename.lastIndexOf(".");
|
|
2591
|
+
if (dot <= 0 || dot === basename.length - 1) return false;
|
|
2592
|
+
const ext = basename.slice(dot + 1);
|
|
2593
|
+
if (ext.length < 1 || ext.length > 12) return false;
|
|
2594
|
+
for (const char of ext) {
|
|
2595
|
+
const code = char.charCodeAt(0);
|
|
2596
|
+
const valid = code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || char === "_" || char === "+" || char === "-";
|
|
2597
|
+
if (!valid) return false;
|
|
2598
|
+
}
|
|
2599
|
+
return true;
|
|
2600
|
+
}
|
|
2601
|
+
function extractStructuredToolTerms(query) {
|
|
2602
|
+
const lower = query.toLowerCase();
|
|
2603
|
+
if (!/\b(tool|command|invocation|called|used|ran|read|write|patch|edit|grep|search)\b/.test(lower)) {
|
|
2604
|
+
return [];
|
|
2605
|
+
}
|
|
2606
|
+
return query.replace(/[^\w.-]/g, " ").split(/\s+/).filter((term) => term.length > 2 && !STOPWORDS.has(term.toLowerCase())).slice(0, 8);
|
|
2607
|
+
}
|
|
2608
|
+
function escapeLike(value) {
|
|
2609
|
+
return value.replace(/[\\%_]/g, (char) => `\\${char}`);
|
|
2610
|
+
}
|
|
2611
|
+
function asNullableString(value) {
|
|
2612
|
+
return typeof value === "string" && value.trim().length > 0 ? value : null;
|
|
2613
|
+
}
|
|
2022
2614
|
function sanitizeFtsQuery(raw) {
|
|
2023
2615
|
const words = raw.replace(/[^\w\s]/g, " ").split(/\s+/).filter((w) => w.length > 1 && !STOPWORDS.has(w.toLowerCase()));
|
|
2024
2616
|
if (words.length === 0) {
|
|
@@ -2488,7 +3080,9 @@ function extractLcmConfig(cfg) {
|
|
|
2488
3080
|
maxDepth: cfg.lcmMaxDepth ?? 5,
|
|
2489
3081
|
deterministicMaxTokens: cfg.lcmDeterministicMaxTokens ?? 512,
|
|
2490
3082
|
archiveRetentionDays: cfg.lcmArchiveRetentionDays ?? 90,
|
|
2491
|
-
recallBudgetShare: cfg.lcmRecallBudgetShare ?? 0.15
|
|
3083
|
+
recallBudgetShare: cfg.lcmRecallBudgetShare ?? 0.15,
|
|
3084
|
+
messagePartsEnabled: cfg.messagePartsEnabled === true,
|
|
3085
|
+
messagePartsRecallMaxResults: typeof cfg.messagePartsRecallMaxResults === "number" ? Math.max(0, Math.floor(cfg.messagePartsRecallMaxResults)) : 6
|
|
2492
3086
|
};
|
|
2493
3087
|
}
|
|
2494
3088
|
var LcmEngine = class {
|
|
@@ -2620,9 +3214,14 @@ var LcmEngine = class {
|
|
|
2620
3214
|
const newMessages = messages.map((m, i) => ({
|
|
2621
3215
|
turnIndex: currentMax + 1 + i,
|
|
2622
3216
|
role: m.role,
|
|
2623
|
-
content: m.content
|
|
3217
|
+
content: m.content,
|
|
3218
|
+
parts: this.config.messagePartsEnabled ? m.parts : void 0,
|
|
3219
|
+
rawContent: this.config.messagePartsEnabled ? m.rawContent : void 0,
|
|
3220
|
+
sourceFormat: this.config.messagePartsEnabled ? m.sourceFormat : void 0
|
|
2624
3221
|
}));
|
|
2625
|
-
this.archive.appendMessages(sessionId, newMessages
|
|
3222
|
+
this.archive.appendMessages(sessionId, newMessages, {
|
|
3223
|
+
messagePartsEnabled: this.config.messagePartsEnabled
|
|
3224
|
+
});
|
|
2626
3225
|
try {
|
|
2627
3226
|
await this.summarizer.summarizeIncremental(sessionId);
|
|
2628
3227
|
} catch (err) {
|
|
@@ -2700,6 +3299,28 @@ var LcmEngine = class {
|
|
|
2700
3299
|
budgetChars: effectiveBudget
|
|
2701
3300
|
});
|
|
2702
3301
|
}
|
|
3302
|
+
async searchStructuredParts(sessionId, query, limit = this.config.messagePartsRecallMaxResults) {
|
|
3303
|
+
if (!this.config.enabled || !this.config.messagePartsEnabled) return [];
|
|
3304
|
+
await this.ensureInitialized();
|
|
3305
|
+
if (!this.archive) return [];
|
|
3306
|
+
return this.archive.searchStructuredParts(query, limit, sessionId);
|
|
3307
|
+
}
|
|
3308
|
+
formatStructuredRecall(matches, budgetChars) {
|
|
3309
|
+
if (matches.length === 0 || budgetChars <= 0) return "";
|
|
3310
|
+
const lines = [];
|
|
3311
|
+
let used = "## Structured Session Matches\n\n".length;
|
|
3312
|
+
for (const match of matches) {
|
|
3313
|
+
const label = match.file_path ? `${match.kind} ${match.file_path}` : match.tool_name ? `${match.kind} ${match.tool_name}` : match.kind;
|
|
3314
|
+
const excerpt = match.content.replace(/\s+/g, " ").slice(0, 220);
|
|
3315
|
+
const line = `- turn ${match.turn_index} (${match.role}): ${label} \u2014 ${excerpt}`;
|
|
3316
|
+
if (used + line.length + 1 > budgetChars) break;
|
|
3317
|
+
lines.push(line);
|
|
3318
|
+
used += line.length + 1;
|
|
3319
|
+
}
|
|
3320
|
+
return lines.length > 0 ? `## Structured Session Matches
|
|
3321
|
+
|
|
3322
|
+
${lines.join("\n")}` : "";
|
|
3323
|
+
}
|
|
2703
3324
|
/** Flush pending summaries before compaction (called from before_compaction hook). */
|
|
2704
3325
|
async preCompactionFlush(sessionId) {
|
|
2705
3326
|
if (!this.config.enabled) return;
|
|
@@ -4933,7 +5554,7 @@ ${doc.content}` : doc.content,
|
|
|
4933
5554
|
}
|
|
4934
5555
|
async runDeepSleepGovernanceNow(options) {
|
|
4935
5556
|
const targetStorage = options?.storage ?? this.storage;
|
|
4936
|
-
const { runMemoryGovernance } = await import("./memory-governance-
|
|
5557
|
+
const { runMemoryGovernance } = await import("./memory-governance-7MI7KE35.js");
|
|
4937
5558
|
const { summarizeGovernanceResultForDreams } = await import("./dreams-ledger-LR2NBAZE.js");
|
|
4938
5559
|
const govResult = await runMemoryGovernance({
|
|
4939
5560
|
memoryDir: targetStorage.dir,
|
|
@@ -7027,6 +7648,7 @@ ${r.snippet.trim()}
|
|
|
7027
7648
|
let recalledMemoryIds = [];
|
|
7028
7649
|
let recalledMemoryPaths = [];
|
|
7029
7650
|
let xrayRecalledResults = [];
|
|
7651
|
+
const lcmStructuredXrayResults = [];
|
|
7030
7652
|
const xrayBranchPoolSize = {
|
|
7031
7653
|
hot_qmd: 0,
|
|
7032
7654
|
hot_embedding: 0,
|
|
@@ -8830,6 +9452,27 @@ ${formatted}`;
|
|
|
8830
9452
|
this.profiler.startSpan("assembly", profileTraceId);
|
|
8831
9453
|
if (sharedCtx)
|
|
8832
9454
|
this.appendRecallSection(sectionBuckets, "shared-context", sharedCtx);
|
|
9455
|
+
const explicitCueMaxChars = this.getRecallSectionMaxChars("explicit-cue") ?? this.config.explicitCueRecallMaxChars;
|
|
9456
|
+
if (this.config.explicitCueRecallEnabled && this.isRecallSectionEnabled("explicit-cue") && explicitCueMaxChars !== 0 && this.lcmEngine?.enabled && recallMode !== "no_recall") {
|
|
9457
|
+
try {
|
|
9458
|
+
const explicitCueSection = await buildExplicitCueRecallSection({
|
|
9459
|
+
engine: this.lcmEngine,
|
|
9460
|
+
sessionId: sessionKey,
|
|
9461
|
+
query: retrievalQuery,
|
|
9462
|
+
maxChars: explicitCueMaxChars,
|
|
9463
|
+
maxReferences: this.getRecallSectionNumber("explicit-cue", "maxResults") ?? this.config.explicitCueRecallMaxReferences
|
|
9464
|
+
});
|
|
9465
|
+
if (explicitCueSection) {
|
|
9466
|
+
this.appendRecallSection(
|
|
9467
|
+
sectionBuckets,
|
|
9468
|
+
"explicit-cue",
|
|
9469
|
+
explicitCueSection
|
|
9470
|
+
);
|
|
9471
|
+
}
|
|
9472
|
+
} catch (err) {
|
|
9473
|
+
log.debug(`Explicit cue recall assembly error: ${err}`);
|
|
9474
|
+
}
|
|
9475
|
+
}
|
|
8833
9476
|
if (profile)
|
|
8834
9477
|
this.appendRecallSection(
|
|
8835
9478
|
sectionBuckets,
|
|
@@ -8950,6 +9593,32 @@ ${tmtNode.summary}`
|
|
|
8950
9593
|
}
|
|
8951
9594
|
if (this.lcmEngine?.enabled && recallMode !== "minimal" && recallMode !== "no_recall") {
|
|
8952
9595
|
try {
|
|
9596
|
+
const structuredMatches = await this.lcmEngine.searchStructuredParts(
|
|
9597
|
+
sessionKey ?? "default",
|
|
9598
|
+
retrievalQuery
|
|
9599
|
+
);
|
|
9600
|
+
const structuredSection = this.lcmEngine.formatStructuredRecall(
|
|
9601
|
+
structuredMatches,
|
|
9602
|
+
Math.ceil(this.config.recallBudgetChars * 0.08)
|
|
9603
|
+
);
|
|
9604
|
+
if (structuredSection) {
|
|
9605
|
+
const structuredAppended = this.appendRecallSection(
|
|
9606
|
+
sectionBuckets,
|
|
9607
|
+
"lcm-message-parts",
|
|
9608
|
+
structuredSection
|
|
9609
|
+
);
|
|
9610
|
+
if (structuredAppended) {
|
|
9611
|
+
for (const match of structuredMatches) {
|
|
9612
|
+
lcmStructuredXrayResults.push({
|
|
9613
|
+
memoryId: `lcm-message-part-${match.part_id}`,
|
|
9614
|
+
path: `lcm://${match.session_id}/turn/${match.turn_index}/part/${match.part_id}`,
|
|
9615
|
+
servedBy: match.file_path ? "lcm-file-parts" : "lcm-tool-parts",
|
|
9616
|
+
scoreDecomposition: { final: match.score },
|
|
9617
|
+
admittedBy: ["lcm-message-parts"]
|
|
9618
|
+
});
|
|
9619
|
+
}
|
|
9620
|
+
}
|
|
9621
|
+
}
|
|
8953
9622
|
const lcmSection = await this.lcmEngine.assembleRecall(
|
|
8954
9623
|
sessionKey ?? "default",
|
|
8955
9624
|
this.config.recallBudgetChars
|
|
@@ -9850,10 +10519,17 @@ _Context: ${topQuestion.context}_`
|
|
|
9850
10519
|
admitted: recalledMemoryIds.length
|
|
9851
10520
|
}
|
|
9852
10521
|
];
|
|
10522
|
+
if (lcmStructuredXrayResults.length > 0) {
|
|
10523
|
+
filters.push({
|
|
10524
|
+
name: "lcm-message-parts",
|
|
10525
|
+
considered: lcmStructuredXrayResults.length,
|
|
10526
|
+
admitted: lcmStructuredXrayResults.length
|
|
10527
|
+
});
|
|
10528
|
+
}
|
|
9853
10529
|
this.lastXraySnapshot = buildXraySnapshot({
|
|
9854
10530
|
query: retrievalQuery,
|
|
9855
10531
|
tierExplain: null,
|
|
9856
|
-
results,
|
|
10532
|
+
results: [...results, ...lcmStructuredXrayResults],
|
|
9857
10533
|
filters,
|
|
9858
10534
|
budget: {
|
|
9859
10535
|
chars: this.getRecallBudgetChars(options.budgetCharsOverride),
|
|
@@ -10020,13 +10696,28 @@ _Context: ${topQuestion.context}_`
|
|
|
10020
10696
|
role: turn.role,
|
|
10021
10697
|
content: turn.content,
|
|
10022
10698
|
timestamp: turn.timestamp,
|
|
10023
|
-
sessionKey: key
|
|
10699
|
+
sessionKey: key,
|
|
10700
|
+
parts: turn.parts,
|
|
10701
|
+
rawContent: turn.rawContent,
|
|
10702
|
+
sourceFormat: turn.sourceFormat
|
|
10024
10703
|
});
|
|
10025
10704
|
bySession.set(key, list);
|
|
10026
10705
|
}
|
|
10027
10706
|
const replayTasks = [];
|
|
10028
10707
|
for (const [key, sessionTurns] of bySession.entries()) {
|
|
10029
10708
|
if (sessionTurns.length === 0) continue;
|
|
10709
|
+
if (options.archiveLcm !== false && this.lcmEngine?.enabled) {
|
|
10710
|
+
await this.lcmEngine.observeMessages(
|
|
10711
|
+
key,
|
|
10712
|
+
sessionTurns.map((turn) => ({
|
|
10713
|
+
role: turn.role,
|
|
10714
|
+
content: turn.content,
|
|
10715
|
+
parts: turn.parts,
|
|
10716
|
+
rawContent: turn.rawContent,
|
|
10717
|
+
sourceFormat: turn.sourceFormat
|
|
10718
|
+
}))
|
|
10719
|
+
);
|
|
10720
|
+
}
|
|
10030
10721
|
replayTasks.push(
|
|
10031
10722
|
new Promise((resolve, reject) => {
|
|
10032
10723
|
void this.queueBufferedExtraction(sessionTurns, "trigger_mode", {
|
|
@@ -10115,10 +10806,25 @@ _Context: ${topQuestion.context}_`
|
|
|
10115
10806
|
role: turn.role,
|
|
10116
10807
|
content: turn.content,
|
|
10117
10808
|
timestamp: turn.timestamp,
|
|
10118
|
-
sessionKey
|
|
10809
|
+
sessionKey,
|
|
10810
|
+
parts: turn.parts,
|
|
10811
|
+
rawContent: turn.rawContent,
|
|
10812
|
+
sourceFormat: turn.sourceFormat
|
|
10119
10813
|
});
|
|
10120
10814
|
}
|
|
10121
10815
|
if (sessionTurns.length === 0) return;
|
|
10816
|
+
if (this.lcmEngine?.enabled) {
|
|
10817
|
+
await this.lcmEngine.observeMessages(
|
|
10818
|
+
sessionKey,
|
|
10819
|
+
sessionTurns.map((turn) => ({
|
|
10820
|
+
role: turn.role,
|
|
10821
|
+
content: turn.content,
|
|
10822
|
+
parts: turn.parts,
|
|
10823
|
+
rawContent: turn.rawContent,
|
|
10824
|
+
sourceFormat: turn.sourceFormat
|
|
10825
|
+
}))
|
|
10826
|
+
);
|
|
10827
|
+
}
|
|
10122
10828
|
await new Promise((resolve, reject) => {
|
|
10123
10829
|
void this.queueBufferedExtraction(sessionTurns, "trigger_mode", {
|
|
10124
10830
|
skipDedupeCheck: true,
|
|
@@ -14040,6 +14746,13 @@ export {
|
|
|
14040
14746
|
openLcmDatabase,
|
|
14041
14747
|
ensureLcmStateDir,
|
|
14042
14748
|
applyLcmSchema,
|
|
14749
|
+
isLcmMessagePartKind,
|
|
14750
|
+
parseMessageParts,
|
|
14751
|
+
normalizeExplicitParts,
|
|
14752
|
+
parseOpenAiMessageParts,
|
|
14753
|
+
parseAnthropicMessageParts,
|
|
14754
|
+
parseOpenClawMessageParts,
|
|
14755
|
+
partsFromRenderedText,
|
|
14043
14756
|
projectNamespaceName,
|
|
14044
14757
|
branchNamespaceName,
|
|
14045
14758
|
resolveCodingNamespaceOverlay,
|
|
@@ -14072,4 +14785,4 @@ export {
|
|
|
14072
14785
|
resolvePersistedMemoryRelativePath,
|
|
14073
14786
|
Orchestrator
|
|
14074
14787
|
};
|
|
14075
|
-
//# sourceMappingURL=chunk-
|
|
14788
|
+
//# sourceMappingURL=chunk-AOABCJVL.js.map
|