blun-king-cli 9.1.218 → 9.1.219
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,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
isLowInformationPersonalMemoryQuery,
|
|
5
|
+
} = require('./personal-memory-performance-policy.cjs');
|
|
6
|
+
|
|
7
|
+
function isRealUserMessage(message) {
|
|
8
|
+
if (message?.role !== 'user') return false;
|
|
9
|
+
const kind = message.origin?.kind;
|
|
10
|
+
return kind !== 'injection' && kind !== 'compaction_summary' && kind !== 'system_trigger';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function textFromMessage(message) {
|
|
14
|
+
if (typeof message?.content === 'string') return message.content.trim();
|
|
15
|
+
if (!Array.isArray(message?.content)) return '';
|
|
16
|
+
return message.content
|
|
17
|
+
.filter((part) => part?.type === 'text' && typeof part.text === 'string')
|
|
18
|
+
.map((part) => part.text.trim())
|
|
19
|
+
.filter(Boolean)
|
|
20
|
+
.join('\n');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function directMessageText(value) {
|
|
24
|
+
let text = value.trim();
|
|
25
|
+
const marker = /^#?\s*\[tg\s+dm\b[^\]]*\]\s*/iu;
|
|
26
|
+
if (!marker.test(text)) return text;
|
|
27
|
+
text = text.replace(marker, '');
|
|
28
|
+
text = text.replace(/^[^\r\n]{1,160}\s+schrieb:\s*/iu, '');
|
|
29
|
+
return text.replace(/\r?\nWeiter-Signal:\s*[\s\S]*$/iu, '').trim();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function hasToolActivityAfter(history, userIndex) {
|
|
33
|
+
return history.slice(userIndex + 1).some((message) => (
|
|
34
|
+
message?.role === 'tool'
|
|
35
|
+
|| (message?.role === 'assistant'
|
|
36
|
+
&& (Array.isArray(message.toolCalls) || Array.isArray(message.tool_calls))
|
|
37
|
+
&& (message.toolCalls?.length > 0 || message.tool_calls?.length > 0))
|
|
38
|
+
));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function shouldSyncValidatedLearningCandidate(history) {
|
|
42
|
+
if (!Array.isArray(history)) return true;
|
|
43
|
+
const userIndex = history.findLastIndex(isRealUserMessage);
|
|
44
|
+
if (userIndex < 0 || hasToolActivityAfter(history, userIndex)) return true;
|
|
45
|
+
const message = history[userIndex];
|
|
46
|
+
if (Array.isArray(message.content)) {
|
|
47
|
+
const hasAttachment = message.content.some((part) => part?.type !== 'text' && part?.type !== 'think');
|
|
48
|
+
if (hasAttachment) return true;
|
|
49
|
+
}
|
|
50
|
+
return !isLowInformationPersonalMemoryQuery(directMessageText(textFromMessage(message)));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
module.exports = { shouldSyncValidatedLearningCandidate };
|
package/blun.mjs
CHANGED
|
@@ -232151,18 +232151,20 @@ function buildValidatedLearningSignalReminder(signal) {
|
|
|
232151
232151
|
lines.push("</validated-learning-signal>");
|
|
232152
232152
|
return lines.join("\n");
|
|
232153
232153
|
}
|
|
232154
|
-
var ValidatedLearningSignalInjector, syncValidatedLearningCandidate;
|
|
232154
|
+
var ValidatedLearningSignalInjector, shouldSyncValidatedLearningCandidate, syncValidatedLearningCandidate;
|
|
232155
232155
|
var init_validated_learning_signal = __esmMin((() => {
|
|
232156
232156
|
init_injector();
|
|
232157
232157
|
({ syncValidatedLearningCandidate } = createRequire(import.meta.url)("./bin/validated-learning-signal.cjs"));
|
|
232158
|
+
({ shouldSyncValidatedLearningCandidate } = createRequire(import.meta.url)("./bin/validated-learning-performance-policy.cjs"));
|
|
232158
232159
|
ValidatedLearningSignalInjector = class extends DynamicInjector {
|
|
232159
232160
|
injectionVariant = "validated_learning_signal";
|
|
232160
232161
|
async inject() {
|
|
232162
|
+
const existing = this.agent.context.history.filter(isValidatedLearningSignalReminder);
|
|
232163
|
+
if (!shouldSyncValidatedLearningCandidate(this.agent.context.history)) return;
|
|
232161
232164
|
const signal = syncValidatedLearningCandidate(this.agent.context.history, {
|
|
232162
232165
|
homeDir: process.env["BLUN_SHARED_HOME"] ?? process.env["BLUN_HOME"] ?? "",
|
|
232163
232166
|
profile: process.env["BLUN_PROFILE"] ?? "default"
|
|
232164
232167
|
});
|
|
232165
|
-
const existing = this.agent.context.history.filter(isValidatedLearningSignalReminder);
|
|
232166
232168
|
if (signal === null) {
|
|
232167
232169
|
if (existing.length > 0) this.agent.context.removeSystemRemindersMatching(isValidatedLearningSignalReminder);
|
|
232168
232170
|
return;
|