blun-king-cli 9.1.200 → 9.1.201
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.
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const ERROR_MEMORY_MAX_CHARS = 2_800;
|
|
4
|
+
|
|
5
|
+
function buildCompactErrorMemoryReminder(patterns) {
|
|
6
|
+
const lines = [
|
|
7
|
+
'<error-memory-check>',
|
|
8
|
+
'Vor Abschluss jede Regel pruefen; Verletzungen korrigieren oder offen benennen.',
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
for (const pattern of patterns) {
|
|
12
|
+
const check = pattern.check ? ` | Pruefung: ${pattern.check}` : '';
|
|
13
|
+
lines.push(`${pattern.number}. ${pattern.rule}${check}`);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
lines.push(
|
|
17
|
+
'Arbeitsweise: 3-7 sichtbare Schritte; Werkzeuge proaktiv; nach zwei gleichen Fehlern Ansatz wechseln; Schritte erst nach echtem Nachweis abschliessen; nach Zielerreichung stoppen; Teilerfolg oder Scheitern mit Grund und naechstem Schritt offen melden.',
|
|
18
|
+
'</error-memory-check>',
|
|
19
|
+
);
|
|
20
|
+
return lines.join('\n');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function compactLegacyErrorMemoryReminder(text) {
|
|
24
|
+
const source = String(text);
|
|
25
|
+
if (!source.includes('<error-memory-check>') || !source.includes(' Regel: ')) return source;
|
|
26
|
+
|
|
27
|
+
const lines = source.split(/\r?\n/u);
|
|
28
|
+
const patterns = [];
|
|
29
|
+
for (let index = 0; index + 1 < lines.length; index += 1) {
|
|
30
|
+
const title = lines[index].match(/^\s*(\d+)\.\s+(.+)$/u);
|
|
31
|
+
const rule = lines[index + 1].match(/^\s*Regel:\s*(.+)$/u);
|
|
32
|
+
if (!title || !rule) continue;
|
|
33
|
+
const check = lines[index + 2]?.match(/^\s*Pruefung:\s*(.+)$/u);
|
|
34
|
+
patterns.push({
|
|
35
|
+
number: Number(title[1]),
|
|
36
|
+
title: title[2],
|
|
37
|
+
rule: rule[1],
|
|
38
|
+
check: check?.[1],
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return patterns.length > 0 ? buildCompactErrorMemoryReminder(patterns) : source;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
module.exports = {
|
|
45
|
+
ERROR_MEMORY_MAX_CHARS,
|
|
46
|
+
buildCompactErrorMemoryReminder,
|
|
47
|
+
compactLegacyErrorMemoryReminder,
|
|
48
|
+
};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const {
|
|
4
|
+
compactLegacyErrorMemoryReminder,
|
|
5
|
+
} = require('./error-memory-performance-policy.cjs');
|
|
6
|
+
|
|
7
|
+
const LATEST_ONLY_INJECTION_VARIANTS = new Set(['error-memory', 'mistake_md']);
|
|
4
8
|
|
|
5
9
|
function repeatedInjectionKey(message) {
|
|
6
10
|
if (message?.role !== 'user') return null;
|
|
@@ -34,7 +38,15 @@ function dedupeRepeatedInjections(history) {
|
|
|
34
38
|
}
|
|
35
39
|
if (seenTexts.has(key.text)) continue;
|
|
36
40
|
seenTexts.add(key.text);
|
|
37
|
-
|
|
41
|
+
if (key.variant === 'error-memory') {
|
|
42
|
+
const compactText = compactLegacyErrorMemoryReminder(key.text);
|
|
43
|
+
kept.push(compactText === key.text ? message : {
|
|
44
|
+
...message,
|
|
45
|
+
content: [{ ...message.content[0], text: compactText }],
|
|
46
|
+
});
|
|
47
|
+
} else {
|
|
48
|
+
kept.push(message);
|
|
49
|
+
}
|
|
38
50
|
}
|
|
39
51
|
|
|
40
52
|
kept.reverse();
|
package/blun.mjs
CHANGED
|
@@ -79224,6 +79224,10 @@ var init_injector = __esmMin((() => {
|
|
|
79224
79224
|
//#endregion
|
|
79225
79225
|
//#region ../../packages/agent-core/src/agent/injection/error-memory.ts
|
|
79226
79226
|
function buildErrorMemoryReminder(patterns) {
|
|
79227
|
+
try {
|
|
79228
|
+
const { buildCompactErrorMemoryReminder } = createRequire(import.meta.url)("./bin/error-memory-performance-policy.cjs");
|
|
79229
|
+
return buildCompactErrorMemoryReminder(patterns);
|
|
79230
|
+
} catch {}
|
|
79227
79231
|
const lines = [];
|
|
79228
79232
|
lines.push("<error-memory-check>");
|
|
79229
79233
|
lines.push("");
|