blun-king-cli 9.1.161 → 9.1.163
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,60 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const SKILL_ACTIVATION_KEEP_RECENT_MESSAGES = 20;
|
|
4
|
+
const SKILL_ACTIVATION_MIN_CHARS = 4_000;
|
|
5
|
+
const SKILL_ACTIVATION_MARKER = '[Earlier skill activation compacted]';
|
|
6
|
+
|
|
7
|
+
function compactSkillActivationMessage(message) {
|
|
8
|
+
if (message?.role !== 'user' || message.origin?.kind !== 'skill_activation') return message;
|
|
9
|
+
if (!Array.isArray(message.content) || message.content.length !== 1) return message;
|
|
10
|
+
if (Array.isArray(message.toolCalls) && message.toolCalls.length > 0) return message;
|
|
11
|
+
|
|
12
|
+
const part = message.content[0];
|
|
13
|
+
const skillName = String(message.origin.skillName || '').trim();
|
|
14
|
+
const skillPath = String(message.origin.skillPath || '').trim();
|
|
15
|
+
if (
|
|
16
|
+
part?.type !== 'text'
|
|
17
|
+
|| typeof part.text !== 'string'
|
|
18
|
+
|| part.text.length <= SKILL_ACTIVATION_MIN_CHARS
|
|
19
|
+
|| !skillName
|
|
20
|
+
|| !skillPath
|
|
21
|
+
) return message;
|
|
22
|
+
|
|
23
|
+
const lines = [
|
|
24
|
+
SKILL_ACTIVATION_MARKER,
|
|
25
|
+
'The complete instructions remain available and were removed only from the model projection.',
|
|
26
|
+
`skill_name: ${skillName}`,
|
|
27
|
+
`skill_path: ${skillPath}`,
|
|
28
|
+
];
|
|
29
|
+
const trigger = String(message.origin.trigger || '').trim();
|
|
30
|
+
const skillArgs = String(message.origin.skillArgs || '').trim();
|
|
31
|
+
if (trigger) lines.push(`trigger: ${trigger}`);
|
|
32
|
+
if (skillArgs) lines.push(`skill_args: ${skillArgs}`);
|
|
33
|
+
lines.push('next_step: If this skill still governs the current work, reload it with the Skill tool using skill_name and skill_args when present, or Read skill_path before continuing.');
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
...message,
|
|
37
|
+
content: [{ ...part, text: lines.join('\n') }],
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function compactHistoricalSkillActivations(messages) {
|
|
42
|
+
if (!Array.isArray(messages) || messages.length === 0) return messages;
|
|
43
|
+
const recentStart = Math.max(0, messages.length - SKILL_ACTIVATION_KEEP_RECENT_MESSAGES);
|
|
44
|
+
let changed = false;
|
|
45
|
+
const projected = messages.map((message, index) => {
|
|
46
|
+
if (index >= recentStart) return message;
|
|
47
|
+
const compacted = compactSkillActivationMessage(message);
|
|
48
|
+
if (compacted !== message) changed = true;
|
|
49
|
+
return compacted;
|
|
50
|
+
});
|
|
51
|
+
return changed ? projected : messages;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
module.exports = {
|
|
55
|
+
SKILL_ACTIVATION_KEEP_RECENT_MESSAGES,
|
|
56
|
+
SKILL_ACTIVATION_MARKER,
|
|
57
|
+
SKILL_ACTIVATION_MIN_CHARS,
|
|
58
|
+
compactHistoricalSkillActivations,
|
|
59
|
+
compactSkillActivationMessage,
|
|
60
|
+
};
|
package/blun.mjs
CHANGED
|
@@ -75986,11 +75986,12 @@ var init_full = __esmMin((() => {
|
|
|
75986
75986
|
}));
|
|
75987
75987
|
//#endregion
|
|
75988
75988
|
//#region ../../packages/agent-core/src/agent/compaction/micro.ts
|
|
75989
|
-
var selectMicroCompactionCutoff, MICRO_COMPACTION_RECENT_MESSAGES, MICRO_COMPACTION_TOOL_ARGUMENT_MIN_TOKENS, isPersistedToolResultReference, projectHistoricalUnaddressedTelegramMessages, dedupeRecurringCronWakeups, dedupeRepeatedInjections, DEFAULT_CONFIG, MicroCompaction;
|
|
75989
|
+
var selectMicroCompactionCutoff, MICRO_COMPACTION_RECENT_MESSAGES, MICRO_COMPACTION_TOOL_ARGUMENT_MIN_TOKENS, isPersistedToolResultReference, projectHistoricalUnaddressedTelegramMessages, compactHistoricalSkillActivations, dedupeRecurringCronWakeups, dedupeRepeatedInjections, DEFAULT_CONFIG, MicroCompaction;
|
|
75990
75990
|
var init_micro = __esmMin((() => {
|
|
75991
75991
|
({ selectMicroCompactionCutoff, MICRO_COMPACTION_RECENT_MESSAGES, MICRO_COMPACTION_TOOL_ARGUMENT_MIN_TOKENS } = createRequire(import.meta.url)("./bin/micro-compaction-policy.cjs"));
|
|
75992
75992
|
({ isPersistedToolResultReference } = createRequire(import.meta.url)("./bin/tool-result-offload-policy.cjs"));
|
|
75993
75993
|
({ projectHistoricalUnaddressedTelegramMessages } = createRequire(import.meta.url)("./bin/telegram-context-projection-policy.cjs"));
|
|
75994
|
+
({ compactHistoricalSkillActivations } = createRequire(import.meta.url)("./bin/skill-activation-performance-policy.cjs"));
|
|
75994
75995
|
({ dedupeRecurringCronWakeups, dedupeRepeatedInjections } = createRequire(import.meta.url)("./bin/repeated-injection-projection.cjs"));
|
|
75995
75996
|
init_tokens();
|
|
75996
75997
|
DEFAULT_CONFIG = {
|
|
@@ -78967,7 +78968,7 @@ var init_context$2 = __esmMin((() => {
|
|
|
78967
78968
|
const userOffloaded = this.agent.userMessageOffload.compact(messages);
|
|
78968
78969
|
const historicalUserReferencesProjected = compactHistoricalPersistedUserMessageReferences(userOffloaded);
|
|
78969
78970
|
const historicalTelegramProjected = projectHistoricalUnaddressedTelegramMessages(historicalUserReferencesProjected);
|
|
78970
|
-
const result = project(this.agent.assistantMessageOffload.compact(this.agent.microCompaction.compact(compactHistoricalSuccessfulToolResults(this.agent.toolResultBatchOffload.compact(dedupeRecurringCronWakeups(dedupeRepeatedInjections(compactBaselineSkillInjections(historicalTelegramProjected))))))), {
|
|
78971
|
+
const result = project(this.agent.assistantMessageOffload.compact(this.agent.microCompaction.compact(compactHistoricalSuccessfulToolResults(this.agent.toolResultBatchOffload.compact(dedupeRecurringCronWakeups(dedupeRepeatedInjections(compactHistoricalSkillActivations(compactBaselineSkillInjections(historicalTelegramProjected)))))))), {
|
|
78971
78972
|
...options,
|
|
78972
78973
|
onAnomaly: (anomaly) => {
|
|
78973
78974
|
anomalies.push(anomaly);
|