blun-king-cli 9.1.125 → 9.1.126
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/LIESMICH.txt +2 -0
- package/README.md +2 -0
- package/bin/mistake-relevance-policy.cjs +152 -0
- package/blun.mjs +25 -10
- package/package.json +1 -1
package/LIESMICH.txt
CHANGED
|
@@ -125,6 +125,8 @@ Ab BLUN King 9.1.122 wird die vollständige integrierte Designrichtlinie nicht m
|
|
|
125
125
|
|
|
126
126
|
Ab BLUN King 9.1.123 entlastet die Modellprojektion zusätzlich die Argumente älterer, bereits abgeschlossener Werkzeugaufrufe. Name, Kennung und Ergebnis bleiben erhalten; nur die wiederholte Übertragung großer alter JSON-Argumente entfällt. Unbeantwortete Werkzeugaufrufe, ungültige JSON-Argumente und die neuesten 20 Nachrichten bleiben vollständig. Der gespeicherte Rohverlauf und Exporte werden nicht verändert. In Fredriks gemessener Projektion sank der Anfrageumfang dadurch von 101.459 auf 94.026 Zeichen, also um etwa 1.859 geschätzte Token je Anfrage.
|
|
127
127
|
|
|
128
|
+
Ab BLUN King 9.1.126 wird die laufzeitweite `Mistake.md` nicht mehr bei jedem Zug vollständig mitgesendet. King wählt deterministisch bis zu fünf Abschnitte aus, die zu den letzten vier Nutzernachrichten passen, und bevorzugt dabei wiederverwendbare Regeln, Bedingungen und Gegenproben. Die Auswahl ist auf 6.000 Zeichen begrenzt und ersetzt den vorherigen Hinweis, statt weitere Kopien anzusammeln. Die vollständige Datei, ihr Register, ihr Archiv und ihr Schreibweg bleiben unverändert. Dafür ist kein zusätzlicher Modell-, Einbettungs- oder Netzwerkaufruf nötig. In der aktuell gemessenen laufzeitweiten Datei sank die Modellsicht abhängig von der Anfrage von 13.470 Zeichen auf 2.921 bis 4.819 Zeichen.
|
|
129
|
+
|
|
128
130
|
Verliert ein delegierter Einzelagent oder ein Mitglied eines Agentenschwarms die Provider-Verbindung, erhält es eine leere Provider-Antwort, bricht sein Stream wegen Leerlaufs ab oder meldet der Server HTTP 408/500/502/503/504, setzt BLUN King denselben Agenten anhand seines dauerhaften Verlaufs fort. Bei Einzelagenten sowie bei Schwarm-Unterbrechungen außerhalb von HTTP 429 wartet die erste Fortsetzung zwei Sekunden und die zweite fünf Sekunden; danach bleibt der ursprüngliche Fehler sichtbar. HTTP 429 behält im Schwarm seine getrennte, längere Überlastungsregel. Authentifizierungs-, Zahlungs- oder Kontingent-, Richtlinien-, Kontext-, Werkzeug- und Codefehler sowie manuelle Abbrüche lösen keine automatische Fortsetzung aus. Jeder Fortsetzungsversuch verwendet die bestehende Agenten-ID, damit bereits abgeschlossene Arbeit nicht wiederholt wird.
|
|
129
131
|
|
|
130
132
|
Rein lesende Sitzungsdiagnose
|
package/README.md
CHANGED
|
@@ -131,6 +131,8 @@ Ab BLUN King 9.1.122 wird die vollständige integrierte Designrichtlinie nicht m
|
|
|
131
131
|
|
|
132
132
|
Ab BLUN King 9.1.123 entlastet die Modellprojektion zusätzlich die Argumente älterer, bereits abgeschlossener Werkzeugaufrufe. Name, Kennung und Ergebnis bleiben erhalten; nur die wiederholte Übertragung großer alter JSON-Argumente entfällt. Unbeantwortete Werkzeugaufrufe, ungültige JSON-Argumente und die neuesten 20 Nachrichten bleiben vollständig. Der gespeicherte Rohverlauf und Exporte werden nicht verändert. In Fredriks gemessener Projektion sank der Anfrageumfang dadurch von 101.459 auf 94.026 Zeichen, also um etwa 1.859 geschätzte Token je Anfrage.
|
|
133
133
|
|
|
134
|
+
Ab BLUN King 9.1.126 wird die laufzeitweite `Mistake.md` nicht mehr bei jedem Zug vollständig mitgesendet. King wählt deterministisch bis zu fünf Abschnitte aus, die zu den letzten vier Nutzernachrichten passen, und bevorzugt dabei wiederverwendbare Regeln, Bedingungen und Gegenproben. Die Auswahl ist auf 6.000 Zeichen begrenzt und ersetzt den vorherigen Hinweis, statt weitere Kopien anzusammeln. Die vollständige Datei, ihr Register, ihr Archiv und ihr Schreibweg bleiben unverändert. Dafür ist kein zusätzlicher Modell-, Einbettungs- oder Netzwerkaufruf nötig. In der aktuell gemessenen laufzeitweiten Datei sank die Modellsicht abhängig von der Anfrage von 13.470 Zeichen auf 2.921 bis 4.819 Zeichen.
|
|
135
|
+
|
|
134
136
|
Ab BLUN King 9.1.99 werden auch direkt aufeinanderfolgende reine Textergebnisse als Stapel betrachtet. Enthalten sie zusammen mehr als 12.000 Zeichen, obwohl kein einzelnes Ergebnis diese Grenze überschreitet, speichert King so viele der größten geeigneten Ergebnisse wie nötig in privaten Dateien. In der Modellprojektion verbleiben lesbare Verweise. Der unveränderte Sitzungsrohverlauf bleibt vollständig erhalten. Gemischte Medienergebnisse, einzelne Ergebnisse unter 3.000 Zeichen und Stapel bis einschließlich 12.000 Zeichen bleiben unverändert. Beispiel: Bei zwei Suchergebnissen mit 7.000 und 6.000 Zeichen wird das größere Ergebnis privat gespeichert; Anfang, Ende, ausgelassene Zeichenzahl und `output_path` bleiben für den Agenten sichtbar.
|
|
135
137
|
|
|
136
138
|
Ab BLUN King 9.1.100 beendet eine begrenzte Grep-Inhaltssuche ripgrep, sobald der Versatz, die angeforderten Zeilen und eine zusätzliche Vorschauzeile vollständig vorliegen. Die Vorschauzeile belegt, ob eine weitere Seite existiert, ohne vorher bis zu 10 MB einzulesen. Unbegrenzte Suchen, Trefferzählungen und nach Änderungszeit sortierte Dateilisten laufen weiterhin vollständig durch.
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_MAX_CHARS = 6_000;
|
|
4
|
+
const DEFAULT_MAX_SECTIONS = 5;
|
|
5
|
+
const RECENT_USER_MESSAGES = 4;
|
|
6
|
+
const STOP_WORDS = new Set([
|
|
7
|
+
'aber', 'alle', 'alles', 'auch', 'eine', 'einem', 'einen', 'einer', 'eines',
|
|
8
|
+
'fuer', 'haben', 'hier', 'immer', 'jetzt', 'kann', 'machen', 'mehr', 'mich',
|
|
9
|
+
'nicht', 'noch', 'oder', 'sein', 'sind', 'soll', 'und', 'uns', 'von', 'was',
|
|
10
|
+
'wenn', 'werden', 'wie', 'with', 'that', 'this', 'from', 'have', 'into',
|
|
11
|
+
'your', 'you', 'the', 'and', 'for', 'are', 'not', 'but', 'all', 'can',
|
|
12
|
+
]);
|
|
13
|
+
const REUSABLE_HEADING = /\b(rule|regel|condition|bedingung|countercheck|gegenprobe|trigger|ausloeser|auslöser)\b/iu;
|
|
14
|
+
|
|
15
|
+
function normalizeText(value) {
|
|
16
|
+
return String(value || '').normalize('NFKD').replace(/\p{M}/gu, '').toLowerCase();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function terms(value) {
|
|
20
|
+
return [...new Set(normalizeText(value).match(/[\p{L}\p{N}_-]{3,}/gu) || [])]
|
|
21
|
+
.filter((term) => !STOP_WORDS.has(term));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function textFromMessage(message) {
|
|
25
|
+
if (typeof message?.content === 'string') return message.content.trim();
|
|
26
|
+
if (!Array.isArray(message?.content)) return '';
|
|
27
|
+
return message.content
|
|
28
|
+
.filter((part) => part?.type === 'text' && typeof part.text === 'string')
|
|
29
|
+
.map((part) => part.text.trim())
|
|
30
|
+
.filter(Boolean)
|
|
31
|
+
.join('\n');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function recentUserText(history, limit = RECENT_USER_MESSAGES) {
|
|
35
|
+
if (!Array.isArray(history)) return '';
|
|
36
|
+
return history
|
|
37
|
+
.filter((message) => message?.role === 'user')
|
|
38
|
+
.map(textFromMessage)
|
|
39
|
+
.filter(Boolean)
|
|
40
|
+
.slice(-Math.max(1, Number(limit) || RECENT_USER_MESSAGES))
|
|
41
|
+
.join('\n');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function splitSections(source) {
|
|
45
|
+
const text = String(source || '').replace(/\r\n?/gu, '\n').trim();
|
|
46
|
+
if (!text) return [];
|
|
47
|
+
const headings = [...text.matchAll(/^#{2,3}\s+.+$/gmu)];
|
|
48
|
+
const sections = [];
|
|
49
|
+
let parent = '';
|
|
50
|
+
const preambleEnd = headings[0]?.index ?? text.length;
|
|
51
|
+
const preamble = text.slice(0, preambleEnd).trim();
|
|
52
|
+
if (preamble) {
|
|
53
|
+
const separator = preamble.indexOf('\n---');
|
|
54
|
+
const body = separator >= 0 ? preamble.slice(separator + 4).trim() : '';
|
|
55
|
+
if (body) sections.push({ heading: '# Mistake.md', parent: '', body, index: -1 });
|
|
56
|
+
}
|
|
57
|
+
headings.forEach((match, index) => {
|
|
58
|
+
const heading = match[0].trim();
|
|
59
|
+
const level = heading.startsWith('### ') ? 3 : 2;
|
|
60
|
+
if (level === 2) parent = heading;
|
|
61
|
+
const start = match.index + match[0].length;
|
|
62
|
+
const end = headings[index + 1]?.index ?? text.length;
|
|
63
|
+
sections.push({
|
|
64
|
+
heading,
|
|
65
|
+
parent: level === 3 ? parent : '',
|
|
66
|
+
body: text.slice(start, end).trim(),
|
|
67
|
+
index,
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
return sections;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function scoreSection(section, queryTerms) {
|
|
74
|
+
const heading = normalizeText(`${section.parent} ${section.heading}`);
|
|
75
|
+
const body = normalizeText(section.body);
|
|
76
|
+
let score = REUSABLE_HEADING.test(section.heading) ? 1 : 0;
|
|
77
|
+
for (const term of queryTerms) {
|
|
78
|
+
if (heading.includes(term)) score += 6;
|
|
79
|
+
if (body.includes(term)) score += 4;
|
|
80
|
+
}
|
|
81
|
+
return score;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function compactSection(section, maxChars) {
|
|
85
|
+
const title = section.parent && section.parent !== section.heading
|
|
86
|
+
? `${section.parent}\n${section.heading}`
|
|
87
|
+
: section.heading;
|
|
88
|
+
const full = `${title}\n${section.body}`.trim();
|
|
89
|
+
if (full.length <= maxChars) return full;
|
|
90
|
+
const marker = '\n\n[section shortened deterministically]\n\n';
|
|
91
|
+
const available = Math.max(0, maxChars - marker.length);
|
|
92
|
+
const headChars = Math.ceil(available * 0.55);
|
|
93
|
+
const tailChars = Math.floor(available * 0.45);
|
|
94
|
+
return `${full.slice(0, headChars).trimEnd()}${marker}${full.slice(-tailChars).trimStart()}`;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function selectRelevantMistakeContent(source, query, options = {}) {
|
|
98
|
+
const maxChars = Math.max(256, Number(options.maxChars) || DEFAULT_MAX_CHARS);
|
|
99
|
+
const maxSections = Math.max(1, Number(options.maxSections) || DEFAULT_MAX_SECTIONS);
|
|
100
|
+
const sourceText = String(source || '').trim();
|
|
101
|
+
const sections = splitSections(sourceText);
|
|
102
|
+
const queryTerms = terms(query);
|
|
103
|
+
const ranked = sections.map((section) => ({
|
|
104
|
+
...section,
|
|
105
|
+
score: scoreSection(section, queryTerms),
|
|
106
|
+
}));
|
|
107
|
+
const hasMatch = ranked.some((section) => section.score > (REUSABLE_HEADING.test(section.heading) ? 1 : 0));
|
|
108
|
+
ranked.sort((left, right) => {
|
|
109
|
+
if (hasMatch && right.score !== left.score) return right.score - left.score;
|
|
110
|
+
const rightReusable = REUSABLE_HEADING.test(right.heading) ? 1 : 0;
|
|
111
|
+
const leftReusable = REUSABLE_HEADING.test(left.heading) ? 1 : 0;
|
|
112
|
+
if (rightReusable !== leftReusable) return rightReusable - leftReusable;
|
|
113
|
+
return right.index - left.index;
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
const header = '# Mistake.md\n\nRelevant verified lessons for the current turn.';
|
|
117
|
+
const selected = [];
|
|
118
|
+
let remaining = maxChars - header.length - 2;
|
|
119
|
+
const perSectionMax = Math.max(
|
|
120
|
+
160,
|
|
121
|
+
Math.floor(remaining / Math.min(maxSections, 3)),
|
|
122
|
+
);
|
|
123
|
+
for (const section of ranked) {
|
|
124
|
+
if (selected.length >= maxSections || remaining < 64) break;
|
|
125
|
+
if (hasMatch && section.score === 0) continue;
|
|
126
|
+
const rendered = compactSection(section, Math.min(remaining, perSectionMax));
|
|
127
|
+
if (!rendered) continue;
|
|
128
|
+
selected.push({ ...section, rendered });
|
|
129
|
+
remaining -= rendered.length + 2;
|
|
130
|
+
}
|
|
131
|
+
if (selected.length === 0 && sections.length > 0) {
|
|
132
|
+
const fallback = sections.at(-1);
|
|
133
|
+
selected.push({ ...fallback, rendered: compactSection(fallback, remaining) });
|
|
134
|
+
}
|
|
135
|
+
selected.sort((left, right) => left.index - right.index);
|
|
136
|
+
const text = [header, ...selected.map((section) => section.rendered)].join('\n\n').slice(0, maxChars);
|
|
137
|
+
return {
|
|
138
|
+
selectedChars: text.length,
|
|
139
|
+
selectedSections: selected.length,
|
|
140
|
+
text,
|
|
141
|
+
totalChars: sourceText.length,
|
|
142
|
+
totalSections: sections.length,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
module.exports = {
|
|
147
|
+
DEFAULT_MAX_CHARS,
|
|
148
|
+
DEFAULT_MAX_SECTIONS,
|
|
149
|
+
RECENT_USER_MESSAGES,
|
|
150
|
+
recentUserText,
|
|
151
|
+
selectRelevantMistakeContent,
|
|
152
|
+
};
|
package/blun.mjs
CHANGED
|
@@ -231442,13 +231442,16 @@ var init_mistake_md_writer = __esmMin((() => {
|
|
|
231442
231442
|
* Nach jedem Turn kann der Writer neue Eintraege an Mistake.md anhaengen.
|
|
231443
231443
|
* Der Writer laeuft NACH dem Lesen, nie waehrend (C3).
|
|
231444
231444
|
*/
|
|
231445
|
-
|
|
231445
|
+
function isMistakeMdReminder(message) {
|
|
231446
|
+
return message.origin?.kind === "injection" && message.origin.variant === "mistake_md";
|
|
231447
|
+
}
|
|
231448
|
+
var MistakeMdInjector, recentUserText, selectRelevantMistakeContent;
|
|
231446
231449
|
var init_mistake_md = __esmMin((() => {
|
|
231447
231450
|
init_injector();
|
|
231448
231451
|
init_mistake_md_writer();
|
|
231452
|
+
({ recentUserText, selectRelevantMistakeContent } = createRequire(import.meta.url)("./bin/mistake-relevance-policy.cjs"));
|
|
231449
231453
|
MistakeMdInjector = class extends DynamicInjector {
|
|
231450
231454
|
injectionVariant = "mistake_md";
|
|
231451
|
-
lastHash = null;
|
|
231452
231455
|
reserveChecked = false;
|
|
231453
231456
|
mistakeDir;
|
|
231454
231457
|
mistakeFile;
|
|
@@ -231459,12 +231462,24 @@ var init_mistake_md = __esmMin((() => {
|
|
|
231459
231462
|
}
|
|
231460
231463
|
onContextClear() {
|
|
231461
231464
|
super.onContextClear();
|
|
231462
|
-
this.lastHash = null;
|
|
231463
231465
|
this.reserveChecked = false;
|
|
231464
231466
|
}
|
|
231465
|
-
|
|
231466
|
-
|
|
231467
|
-
|
|
231467
|
+
async inject() {
|
|
231468
|
+
const injection = await this.getInjection();
|
|
231469
|
+
const existing = this.agent.context.history.filter(isMistakeMdReminder);
|
|
231470
|
+
if (!injection) {
|
|
231471
|
+
if (existing.length > 0) this.agent.context.removeSystemRemindersMatching(isMistakeMdReminder);
|
|
231472
|
+
return;
|
|
231473
|
+
}
|
|
231474
|
+
const expected = wrapSystemReminder(injection);
|
|
231475
|
+
if (existing.length === 1 && reminderText(existing[0]) === expected) return;
|
|
231476
|
+
this.agent.context.removeSystemRemindersMatching(isMistakeMdReminder);
|
|
231477
|
+
this.injectedAt = this.agent.context.history.length;
|
|
231478
|
+
this.lastInjection = injection;
|
|
231479
|
+
this.agent.context.appendSystemReminder(injection, {
|
|
231480
|
+
kind: "injection",
|
|
231481
|
+
variant: this.injectionVariant
|
|
231482
|
+
});
|
|
231468
231483
|
}
|
|
231469
231484
|
async getInjection() {
|
|
231470
231485
|
try {
|
|
@@ -231477,16 +231492,16 @@ var init_mistake_md = __esmMin((() => {
|
|
|
231477
231492
|
}
|
|
231478
231493
|
const trimmed = content.trim();
|
|
231479
231494
|
if (trimmed.length === 0) return void 0;
|
|
231480
|
-
const
|
|
231481
|
-
|
|
231482
|
-
|
|
231495
|
+
const query = recentUserText(this.agent.context.history);
|
|
231496
|
+
const selected = selectRelevantMistakeContent(trimmed, query);
|
|
231497
|
+
if (!selected.text) return void 0;
|
|
231483
231498
|
let prefix = "";
|
|
231484
231499
|
if (!this.reserveChecked) {
|
|
231485
231500
|
this.reserveChecked = true;
|
|
231486
231501
|
const reserveWarning = await checkReserve(this.mistakeDir);
|
|
231487
231502
|
if (reserveWarning) prefix = `<!-- D2a: ${reserveWarning} -->\n\n`;
|
|
231488
231503
|
}
|
|
231489
|
-
return prefix +
|
|
231504
|
+
return prefix + selected.text;
|
|
231490
231505
|
});
|
|
231491
231506
|
} catch {
|
|
231492
231507
|
return;
|