@xdarkicex/openclaw-memory-libravdb 1.4.6 → 1.4.8
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/HOOK.md +14 -0
- package/README.md +32 -2
- package/dist/cli.d.ts +39 -0
- package/dist/cli.js +208 -0
- package/dist/context-engine.d.ts +56 -0
- package/dist/context-engine.js +125 -0
- package/dist/dream-promotion.d.ts +47 -0
- package/dist/dream-promotion.js +363 -0
- package/dist/dream-routing.d.ts +6 -0
- package/dist/dream-routing.js +31 -0
- package/dist/durable-namespace.d.ts +6 -0
- package/dist/durable-namespace.js +24 -0
- package/dist/grpc-client.d.ts +23 -0
- package/dist/grpc-client.js +104 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +40 -0
- package/dist/lifecycle-hooks.d.ts +4 -0
- package/dist/lifecycle-hooks.js +64 -0
- package/dist/markdown-hash.d.ts +3 -0
- package/dist/markdown-hash.js +82 -0
- package/dist/markdown-ingest.d.ts +43 -0
- package/dist/markdown-ingest.js +464 -0
- package/dist/memory-provider.d.ts +4 -0
- package/dist/memory-provider.js +13 -0
- package/dist/memory-runtime.d.ts +118 -0
- package/dist/memory-runtime.js +217 -0
- package/dist/plugin-runtime.d.ts +28 -0
- package/dist/plugin-runtime.js +127 -0
- package/dist/proto/intelligence_kernel/v1/kernel.proto +378 -0
- package/dist/recall-cache.d.ts +2 -0
- package/dist/recall-cache.js +30 -0
- package/dist/rpc-protobuf-codecs.d.ts +70 -0
- package/dist/rpc-protobuf-codecs.js +77 -0
- package/dist/rpc.d.ts +14 -0
- package/dist/rpc.js +121 -0
- package/dist/sidecar.d.ts +34 -0
- package/dist/sidecar.js +535 -0
- package/dist/types.d.ts +163 -0
- package/dist/types.js +1 -0
- package/docs/contributing.md +14 -13
- package/docs/install.md +7 -9
- package/docs/installation.md +23 -16
- package/docs/uninstall.md +1 -1
- package/index.js +2 -0
- package/openclaw.plugin.json +2 -2
- package/package.json +39 -16
- package/packaging/README.md +0 -71
- package/packaging/homebrew/libravdbd.rb.tmpl +0 -224
- package/packaging/launchd/com.xdarkicex.libravdbd.plist +0 -32
- package/packaging/systemd/libravdbd.service +0 -12
- package/src/cli.ts +0 -299
- package/src/comparison-experiments.ts +0 -128
- package/src/context-engine.ts +0 -1645
- package/src/continuity.ts +0 -93
- package/src/dream-promotion.ts +0 -492
- package/src/dream-routing.ts +0 -40
- package/src/durable-namespace.ts +0 -34
- package/src/index.ts +0 -47
- package/src/lifecycle-hooks.ts +0 -96
- package/src/markdown-hash.ts +0 -104
- package/src/markdown-ingest.ts +0 -627
- package/src/memory-provider.ts +0 -25
- package/src/memory-runtime.ts +0 -283
- package/src/openclaw-plugin-sdk.d.ts +0 -59
- package/src/plugin-runtime.ts +0 -119
- package/src/recall-cache.ts +0 -34
- package/src/recall-utils.ts +0 -131
- package/src/rpc.ts +0 -92
- package/src/scoring.ts +0 -632
- package/src/sidecar.ts +0 -583
- package/src/temporal.ts +0 -1031
- package/src/tokens.ts +0 -52
- package/src/types.ts +0 -278
- package/tsconfig.json +0 -20
- package/tsconfig.tests.json +0 -12
package/src/tokens.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { SearchResult } from "./types.js";
|
|
2
|
-
|
|
3
|
-
export function estimateTokens(text: string): number {
|
|
4
|
-
const charsPerToken = detectCharsPerToken(text);
|
|
5
|
-
return Math.ceil(text.length / charsPerToken);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function fitPromptBudget(items: SearchResult[], budget: number): SearchResult[] {
|
|
9
|
-
const selected: SearchResult[] = [];
|
|
10
|
-
let used = 0;
|
|
11
|
-
|
|
12
|
-
for (const item of items) {
|
|
13
|
-
const cost = estimateTokens(item.text);
|
|
14
|
-
if (used + cost > budget) {
|
|
15
|
-
break;
|
|
16
|
-
}
|
|
17
|
-
selected.push(item);
|
|
18
|
-
used += cost;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return selected;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function fitPromptBudgetFirstFit(items: SearchResult[], budget: number): SearchResult[] {
|
|
25
|
-
const selected: SearchResult[] = [];
|
|
26
|
-
let used = 0;
|
|
27
|
-
|
|
28
|
-
for (const item of items) {
|
|
29
|
-
const cost = estimateTokens(item.text);
|
|
30
|
-
if (used + cost > budget) {
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
selected.push(item);
|
|
34
|
-
used += cost;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return selected;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function countTokens(messages: Array<{ content: string }>): number {
|
|
41
|
-
return messages.reduce((sum, msg) => sum + estimateTokens(msg.content), 0);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function detectCharsPerToken(text: string): number {
|
|
45
|
-
if (/[一-龯ぁ-ゖァ-ヺ가-힣]/u.test(text)) {
|
|
46
|
-
return 1.6;
|
|
47
|
-
}
|
|
48
|
-
if (/[Ѐ-ӿ-ۿ-]/u.test(text)) {
|
|
49
|
-
return 2.5;
|
|
50
|
-
}
|
|
51
|
-
return 4.0;
|
|
52
|
-
}
|
package/src/types.ts
DELETED
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
import type { ComparisonProfileSummary } from "./comparison-experiments.js";
|
|
2
|
-
|
|
3
|
-
export interface PluginConfig {
|
|
4
|
-
dbPath?: string;
|
|
5
|
-
sidecarPath?: string;
|
|
6
|
-
useSessionRecallProjection?: boolean;
|
|
7
|
-
useSessionSummarySearchExperiment?: boolean;
|
|
8
|
-
embeddingRuntimePath?: string;
|
|
9
|
-
embeddingBackend?: "bundled" | "onnx-local" | "custom-local";
|
|
10
|
-
embeddingProfile?: string;
|
|
11
|
-
fallbackProfile?: string;
|
|
12
|
-
embeddingModelPath?: string;
|
|
13
|
-
embeddingTokenizerPath?: string;
|
|
14
|
-
embeddingDimensions?: number;
|
|
15
|
-
embeddingNormalize?: boolean;
|
|
16
|
-
summarizerBackend?: "bundled" | "onnx-local" | "ollama-local" | "custom-local";
|
|
17
|
-
summarizerProfile?: string;
|
|
18
|
-
summarizerRuntimePath?: string;
|
|
19
|
-
summarizerModelPath?: string;
|
|
20
|
-
summarizerTokenizerPath?: string;
|
|
21
|
-
summarizerModel?: string;
|
|
22
|
-
summarizerEndpoint?: string;
|
|
23
|
-
sessionTTL?: number;
|
|
24
|
-
topK?: number;
|
|
25
|
-
alpha?: number;
|
|
26
|
-
beta?: number;
|
|
27
|
-
gamma?: number;
|
|
28
|
-
ingestionGateThreshold?: number;
|
|
29
|
-
markdownIngestionEnabled?: boolean;
|
|
30
|
-
markdownIngestionRoots?: string[];
|
|
31
|
-
markdownIngestionObsidianEnabled?: boolean;
|
|
32
|
-
markdownIngestionObsidianRoots?: string[];
|
|
33
|
-
markdownIngestionObsidianInclude?: string[];
|
|
34
|
-
markdownIngestionObsidianExclude?: string[];
|
|
35
|
-
markdownIngestionObsidianDebounceMs?: number;
|
|
36
|
-
markdownIngestionInclude?: string[];
|
|
37
|
-
markdownIngestionExclude?: string[];
|
|
38
|
-
markdownIngestionCollection?: string;
|
|
39
|
-
markdownIngestionDebounceMs?: number;
|
|
40
|
-
dreamPromotionEnabled?: boolean;
|
|
41
|
-
dreamPromotionDiaryPath?: string;
|
|
42
|
-
dreamPromotionUserId?: string;
|
|
43
|
-
dreamPromotionDebounceMs?: number;
|
|
44
|
-
gatingWeights?: {
|
|
45
|
-
w1c?: number;
|
|
46
|
-
w2c?: number;
|
|
47
|
-
w3c?: number;
|
|
48
|
-
w1t?: number;
|
|
49
|
-
w2t?: number;
|
|
50
|
-
w3t?: number;
|
|
51
|
-
};
|
|
52
|
-
gatingTechNorm?: number;
|
|
53
|
-
gatingCentroidK?: number;
|
|
54
|
-
lifecycleJournalMaxEntries?: number;
|
|
55
|
-
compactionQualityWeight?: number;
|
|
56
|
-
recencyLambdaSession?: number;
|
|
57
|
-
recencyLambdaUser?: number;
|
|
58
|
-
recencyLambdaGlobal?: number;
|
|
59
|
-
tokenBudgetFraction?: number;
|
|
60
|
-
authoredHardBudgetFraction?: number;
|
|
61
|
-
authoredSoftBudgetFraction?: number;
|
|
62
|
-
elevatedGuidanceBudgetFraction?: number;
|
|
63
|
-
section7StartupTokenBudgetTokens?: number;
|
|
64
|
-
continuityMinTurns?: number;
|
|
65
|
-
continuityTailBudgetTokens?: number;
|
|
66
|
-
continuityPriorContextTokens?: number;
|
|
67
|
-
compactThreshold?: number;
|
|
68
|
-
compactSessionTokenBudget?: number;
|
|
69
|
-
section7CoarseTopK?: number;
|
|
70
|
-
section7SecondPassTopK?: number;
|
|
71
|
-
section7Theta1?: number;
|
|
72
|
-
section7Kappa?: number;
|
|
73
|
-
section7HopEta?: number;
|
|
74
|
-
section7HopThreshold?: number;
|
|
75
|
-
section7AuthorityRecencyLambda?: number;
|
|
76
|
-
section7AuthorityRecencyWeight?: number;
|
|
77
|
-
section7AuthorityFrequencyWeight?: number;
|
|
78
|
-
section7AuthorityAuthoredWeight?: number;
|
|
79
|
-
summaryExpansionConfidenceThreshold?: number;
|
|
80
|
-
summaryExpansionDepth?: number;
|
|
81
|
-
summaryExpansionTokenBudget?: number;
|
|
82
|
-
summaryExpansionPenaltyFactor?: number;
|
|
83
|
-
recoveryFloorScore?: number;
|
|
84
|
-
recoveryMinTopK?: number;
|
|
85
|
-
recoveryMinConfidenceMean?: number;
|
|
86
|
-
ollamaUrl?: string;
|
|
87
|
-
compactModel?: string;
|
|
88
|
-
rpcTimeoutMs?: number;
|
|
89
|
-
maxRetries?: number;
|
|
90
|
-
logLevel?: "debug" | "info" | "warn" | "error";
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export interface GatingResult {
|
|
94
|
-
g: number;
|
|
95
|
-
t: number;
|
|
96
|
-
h: number;
|
|
97
|
-
r: number;
|
|
98
|
-
d: number;
|
|
99
|
-
p: number;
|
|
100
|
-
a: number;
|
|
101
|
-
dtech: number;
|
|
102
|
-
gconv: number;
|
|
103
|
-
gtech: number;
|
|
104
|
-
inputFreq: number;
|
|
105
|
-
memSaturation: number;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export interface MemoryMessage {
|
|
109
|
-
id?: string;
|
|
110
|
-
role: string;
|
|
111
|
-
content: string;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export interface SearchResult {
|
|
115
|
-
id: string;
|
|
116
|
-
score: number;
|
|
117
|
-
text: string;
|
|
118
|
-
metadata: {
|
|
119
|
-
ts?: number;
|
|
120
|
-
sessionId?: string;
|
|
121
|
-
userId?: string;
|
|
122
|
-
role?: string;
|
|
123
|
-
source_doc?: string;
|
|
124
|
-
node_kind?: string;
|
|
125
|
-
ordinal?: number;
|
|
126
|
-
position?: number;
|
|
127
|
-
tier?: number;
|
|
128
|
-
authored?: boolean;
|
|
129
|
-
authority?: number;
|
|
130
|
-
access_count?: number;
|
|
131
|
-
collection?: string;
|
|
132
|
-
hop_targets?: string[] | string;
|
|
133
|
-
token_estimate?: number;
|
|
134
|
-
continuity_tail?: boolean;
|
|
135
|
-
continuity_base?: boolean;
|
|
136
|
-
continuity_bundle_id?: string;
|
|
137
|
-
elevated_guidance?: boolean;
|
|
138
|
-
source_turn_id?: string;
|
|
139
|
-
source_turn_ts?: number;
|
|
140
|
-
provenance_class?: string;
|
|
141
|
-
stability_weight?: number;
|
|
142
|
-
expanded_from_summary?: boolean;
|
|
143
|
-
parent_summary_id?: string;
|
|
144
|
-
expansion_depth?: number;
|
|
145
|
-
cascade_tier?: number;
|
|
146
|
-
[key: string]: unknown;
|
|
147
|
-
};
|
|
148
|
-
finalScore?: number;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export interface SidecarSocket {
|
|
152
|
-
setEncoding(encoding: string): void;
|
|
153
|
-
on(event: "data", handler: (chunk: string) => void): void;
|
|
154
|
-
on(event: "close", handler: () => void): void;
|
|
155
|
-
on(event: "error", handler: (error: Error) => void): void;
|
|
156
|
-
once(event: "connect", handler: () => void): void;
|
|
157
|
-
once(event: "error", handler: (error: Error) => void): void;
|
|
158
|
-
write(chunk: string): void;
|
|
159
|
-
destroy(): void;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export interface LoggerLike {
|
|
163
|
-
error(message: string): void;
|
|
164
|
-
info?(message: string): void;
|
|
165
|
-
warn?(message: string): void;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
export interface SidecarHandle {
|
|
169
|
-
socket: SidecarSocket;
|
|
170
|
-
isDegraded(): boolean;
|
|
171
|
-
shutdown(): Promise<void>;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
export interface RpcCallOptions {
|
|
175
|
-
timeoutMs: number;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
export interface RecallCacheEntry<T = unknown> {
|
|
179
|
-
userId: string;
|
|
180
|
-
queryText: string;
|
|
181
|
-
durableVariantHits: T[];
|
|
182
|
-
userHits?: T[];
|
|
183
|
-
globalHits?: T[];
|
|
184
|
-
authoredVariantHits?: T[];
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
export interface RecallCache<T = unknown> {
|
|
188
|
-
put(entry: RecallCacheEntry<T>): void;
|
|
189
|
-
get(key: Pick<RecallCacheEntry<T>, "userId" | "queryText">): RecallCacheEntry<T> | undefined;
|
|
190
|
-
take(key: Pick<RecallCacheEntry<T>, "userId" | "queryText">): RecallCacheEntry<T> | undefined;
|
|
191
|
-
clearUser(userId: string): void;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
export interface ContextNamespaceArgs {
|
|
195
|
-
sessionId: string;
|
|
196
|
-
sessionKey?: string;
|
|
197
|
-
userId?: string;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
export interface ContextBootstrapArgs extends ContextNamespaceArgs {}
|
|
201
|
-
|
|
202
|
-
export interface ContextIngestArgs extends ContextNamespaceArgs {
|
|
203
|
-
message: MemoryMessage;
|
|
204
|
-
isHeartbeat?: boolean;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
export interface ContextAssembleArgs extends ContextNamespaceArgs {
|
|
208
|
-
messages: MemoryMessage[];
|
|
209
|
-
tokenBudget: number;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
export interface ContextAssembleResult {
|
|
213
|
-
messages: MemoryMessage[];
|
|
214
|
-
estimatedTokens: number;
|
|
215
|
-
systemPromptAddition: string;
|
|
216
|
-
_profile?: string[];
|
|
217
|
-
_debug?: {
|
|
218
|
-
recoveryTriggerFired?: boolean;
|
|
219
|
-
crossSessionRawRecovery?: boolean;
|
|
220
|
-
rawUserRecoveryCandidates?: Array<{
|
|
221
|
-
id: string;
|
|
222
|
-
text: string;
|
|
223
|
-
selected: boolean;
|
|
224
|
-
tokenEstimate: number;
|
|
225
|
-
temporalAnchorDensity: number;
|
|
226
|
-
semanticScore: number;
|
|
227
|
-
slotCoverage?: number;
|
|
228
|
-
slotMatches?: string[];
|
|
229
|
-
lexicalCoverage: number;
|
|
230
|
-
recencyScore: number;
|
|
231
|
-
finalScore: number;
|
|
232
|
-
rationale: string;
|
|
233
|
-
comparisonSide?: 0 | 1 | null;
|
|
234
|
-
comparisonSlot?: string;
|
|
235
|
-
comparisonSlotRecall?: number;
|
|
236
|
-
comparisonSlotPrecision?: number;
|
|
237
|
-
comparisonSlotSpecificity?: number;
|
|
238
|
-
comparisonSlotPositionWeightedRecall?: number;
|
|
239
|
-
comparisonSlotPositionWeightedPrecision?: number;
|
|
240
|
-
comparisonSlotPositionWeightedSpecificity?: number;
|
|
241
|
-
comparisonFirstPersonClauseCount?: number;
|
|
242
|
-
comparisonProspectivePersonalVerbCount?: number;
|
|
243
|
-
comparisonPlanningDensity?: number;
|
|
244
|
-
comparisonPastness?: number;
|
|
245
|
-
comparisonSideWitnessScore?: number;
|
|
246
|
-
}>;
|
|
247
|
-
recoveryDedupedOrder?: Array<{
|
|
248
|
-
id: string;
|
|
249
|
-
recoveryScope: string;
|
|
250
|
-
finalScore: number;
|
|
251
|
-
tokenEstimate: number;
|
|
252
|
-
}>;
|
|
253
|
-
recoveryFittedOrder?: Array<{
|
|
254
|
-
id: string;
|
|
255
|
-
recoveryScope: string;
|
|
256
|
-
finalScore: number;
|
|
257
|
-
tokenEstimate: number;
|
|
258
|
-
}>;
|
|
259
|
-
recoveryReserveTokens?: number;
|
|
260
|
-
temporalQueryIndicator?: number;
|
|
261
|
-
temporalQueryActive?: boolean;
|
|
262
|
-
temporalQueryPatterns?: string[];
|
|
263
|
-
temporalSelectorApplied?: boolean;
|
|
264
|
-
temporalSelectorReason?: string;
|
|
265
|
-
temporalRecoverySlots?: string[];
|
|
266
|
-
temporalComparisonCoverageApplied?: boolean;
|
|
267
|
-
temporalComparisonCoverageSlots?: string[];
|
|
268
|
-
temporalComparisonCoverageMinTokens?: number;
|
|
269
|
-
temporalComparisonWitnessIds?: string[];
|
|
270
|
-
comparisonProfile?: ComparisonProfileSummary;
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
export interface ContextCompactArgs {
|
|
275
|
-
sessionId: string;
|
|
276
|
-
force?: boolean;
|
|
277
|
-
targetSize?: number;
|
|
278
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "NodeNext",
|
|
5
|
-
"moduleResolution": "NodeNext",
|
|
6
|
-
"strict": true,
|
|
7
|
-
"noEmit": true,
|
|
8
|
-
"types": ["node"],
|
|
9
|
-
"typeRoots": ["./.ts-toolchain/node_modules/@types"],
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"resolveJsonModule": true,
|
|
12
|
-
"allowSyntheticDefaultImports": true
|
|
13
|
-
},
|
|
14
|
-
"include": [
|
|
15
|
-
"src/**/*.ts",
|
|
16
|
-
"scripts/**/*.ts",
|
|
17
|
-
"scripts/**/*.js",
|
|
18
|
-
"test/**/*.ts"
|
|
19
|
-
]
|
|
20
|
-
}
|