@xdarkicex/openclaw-memory-libravdb 1.6.12 → 1.6.14
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/context-engine.js +4 -1
- package/dist/dream-promotion.js +18 -4
- package/dist/index.js +21 -5
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/dist/context-engine.js
CHANGED
|
@@ -2,6 +2,7 @@ import { resolveIdentity } from "./identity.js";
|
|
|
2
2
|
import { resolveUserCollection } from "./memory-scopes.js";
|
|
3
3
|
const APPROX_CHARS_PER_TOKEN = 4;
|
|
4
4
|
const ASSEMBLE_BUDGET_HEADROOM_TOKENS = 256;
|
|
5
|
+
const ASSEMBLE_BUDGET_HEADROOM_FRACTION = 0.2;
|
|
5
6
|
const DEFAULT_COMPACTION_THRESHOLD_FRACTION = 0.8;
|
|
6
7
|
const STRUCTURED_MARKER_RE = /\b[A-Z][A-Z0-9]*(?:_[A-Z0-9]+){2,}_\d{6,}\b/g;
|
|
7
8
|
const DISTINCTIVE_IDENTIFIER_RE = /\b([A-Za-z][A-Za-z0-9]*(?:[_-][A-Za-z0-9]+){1,})\b/g;
|
|
@@ -138,7 +139,9 @@ function normalizeTokenBudget(tokenBudget) {
|
|
|
138
139
|
}
|
|
139
140
|
function resolveEffectiveAssembleBudget(tokenBudget) {
|
|
140
141
|
const normalized = normalizeTokenBudget(tokenBudget) ?? 1;
|
|
141
|
-
|
|
142
|
+
const proportionalHeadroom = Math.max(1, Math.floor(normalized * ASSEMBLE_BUDGET_HEADROOM_FRACTION));
|
|
143
|
+
const headroom = Math.min(ASSEMBLE_BUDGET_HEADROOM_TOKENS, proportionalHeadroom);
|
|
144
|
+
return Math.max(1, normalized - headroom);
|
|
142
145
|
}
|
|
143
146
|
function normalizeThresholdFraction(fraction) {
|
|
144
147
|
if (typeof fraction !== "number" || !Number.isFinite(fraction)) {
|
package/dist/dream-promotion.js
CHANGED
|
@@ -30,6 +30,7 @@ export function createDreamPromotionHandle(cfg, getClient, logger = console, fsA
|
|
|
30
30
|
const state = {
|
|
31
31
|
watching: false,
|
|
32
32
|
dirty: false,
|
|
33
|
+
scanning: false,
|
|
33
34
|
timer: null,
|
|
34
35
|
watcher: null,
|
|
35
36
|
};
|
|
@@ -62,6 +63,10 @@ export function createDreamPromotionHandle(cfg, getClient, logger = console, fsA
|
|
|
62
63
|
if (!state.watching) {
|
|
63
64
|
return;
|
|
64
65
|
}
|
|
66
|
+
if (state.scanning) {
|
|
67
|
+
state.dirty = true;
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
65
70
|
if (state.timer) {
|
|
66
71
|
state.dirty = true;
|
|
67
72
|
return;
|
|
@@ -77,6 +82,19 @@ export function createDreamPromotionHandle(cfg, getClient, logger = console, fsA
|
|
|
77
82
|
if (!state.watching) {
|
|
78
83
|
return;
|
|
79
84
|
}
|
|
85
|
+
state.scanning = true;
|
|
86
|
+
try {
|
|
87
|
+
await performScan();
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
state.scanning = false;
|
|
91
|
+
}
|
|
92
|
+
if (state.dirty) {
|
|
93
|
+
state.dirty = false;
|
|
94
|
+
await refreshDiary();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
async function performScan() {
|
|
80
98
|
await ensureWatcher();
|
|
81
99
|
const stat = await safeStat(diaryPath);
|
|
82
100
|
if (!stat) {
|
|
@@ -137,10 +155,6 @@ export function createDreamPromotionHandle(cfg, getClient, logger = console, fsA
|
|
|
137
155
|
mtimeMs: stat.mtimeMs,
|
|
138
156
|
fileHash,
|
|
139
157
|
};
|
|
140
|
-
if (state.dirty) {
|
|
141
|
-
state.dirty = false;
|
|
142
|
-
await refreshDiary();
|
|
143
|
-
}
|
|
144
158
|
}
|
|
145
159
|
async function safeStat(filePath) {
|
|
146
160
|
try {
|
package/dist/index.js
CHANGED
|
@@ -25355,6 +25355,7 @@ function createDreamPromotionHandle(cfg, getClient, logger = console, fsApi = cr
|
|
|
25355
25355
|
const state = {
|
|
25356
25356
|
watching: false,
|
|
25357
25357
|
dirty: false,
|
|
25358
|
+
scanning: false,
|
|
25358
25359
|
timer: null,
|
|
25359
25360
|
watcher: null
|
|
25360
25361
|
};
|
|
@@ -25387,6 +25388,10 @@ function createDreamPromotionHandle(cfg, getClient, logger = console, fsApi = cr
|
|
|
25387
25388
|
if (!state.watching) {
|
|
25388
25389
|
return;
|
|
25389
25390
|
}
|
|
25391
|
+
if (state.scanning) {
|
|
25392
|
+
state.dirty = true;
|
|
25393
|
+
return;
|
|
25394
|
+
}
|
|
25390
25395
|
if (state.timer) {
|
|
25391
25396
|
state.dirty = true;
|
|
25392
25397
|
return;
|
|
@@ -25402,6 +25407,18 @@ function createDreamPromotionHandle(cfg, getClient, logger = console, fsApi = cr
|
|
|
25402
25407
|
if (!state.watching) {
|
|
25403
25408
|
return;
|
|
25404
25409
|
}
|
|
25410
|
+
state.scanning = true;
|
|
25411
|
+
try {
|
|
25412
|
+
await performScan();
|
|
25413
|
+
} finally {
|
|
25414
|
+
state.scanning = false;
|
|
25415
|
+
}
|
|
25416
|
+
if (state.dirty) {
|
|
25417
|
+
state.dirty = false;
|
|
25418
|
+
await refreshDiary();
|
|
25419
|
+
}
|
|
25420
|
+
}
|
|
25421
|
+
async function performScan() {
|
|
25405
25422
|
await ensureWatcher();
|
|
25406
25423
|
const stat = await safeStat(diaryPath);
|
|
25407
25424
|
if (!stat) {
|
|
@@ -25462,10 +25479,6 @@ function createDreamPromotionHandle(cfg, getClient, logger = console, fsApi = cr
|
|
|
25462
25479
|
mtimeMs: stat.mtimeMs,
|
|
25463
25480
|
fileHash
|
|
25464
25481
|
};
|
|
25465
|
-
if (state.dirty) {
|
|
25466
|
-
state.dirty = false;
|
|
25467
|
-
await refreshDiary();
|
|
25468
|
-
}
|
|
25469
25482
|
}
|
|
25470
25483
|
async function safeStat(filePath) {
|
|
25471
25484
|
try {
|
|
@@ -26504,6 +26517,7 @@ function resolveCliMemoryOperationScope(opts) {
|
|
|
26504
26517
|
// src/context-engine.ts
|
|
26505
26518
|
var APPROX_CHARS_PER_TOKEN = 4;
|
|
26506
26519
|
var ASSEMBLE_BUDGET_HEADROOM_TOKENS = 256;
|
|
26520
|
+
var ASSEMBLE_BUDGET_HEADROOM_FRACTION = 0.2;
|
|
26507
26521
|
var DEFAULT_COMPACTION_THRESHOLD_FRACTION = 0.8;
|
|
26508
26522
|
var STRUCTURED_MARKER_RE = /\b[A-Z][A-Z0-9]*(?:_[A-Z0-9]+){2,}_\d{6,}\b/g;
|
|
26509
26523
|
var DISTINCTIVE_IDENTIFIER_RE = /\b([A-Za-z][A-Za-z0-9]*(?:[_-][A-Za-z0-9]+){1,})\b/g;
|
|
@@ -26656,7 +26670,9 @@ function normalizeTokenBudget(tokenBudget) {
|
|
|
26656
26670
|
}
|
|
26657
26671
|
function resolveEffectiveAssembleBudget(tokenBudget) {
|
|
26658
26672
|
const normalized = normalizeTokenBudget(tokenBudget) ?? 1;
|
|
26659
|
-
|
|
26673
|
+
const proportionalHeadroom = Math.max(1, Math.floor(normalized * ASSEMBLE_BUDGET_HEADROOM_FRACTION));
|
|
26674
|
+
const headroom = Math.min(ASSEMBLE_BUDGET_HEADROOM_TOKENS, proportionalHeadroom);
|
|
26675
|
+
return Math.max(1, normalized - headroom);
|
|
26660
26676
|
}
|
|
26661
26677
|
function normalizeThresholdFraction(fraction) {
|
|
26662
26678
|
if (typeof fraction !== "number" || !Number.isFinite(fraction)) {
|
package/openclaw.plugin.json
CHANGED