blun-king-cli 9.1.248 → 9.1.250
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/bin/loop-event-record-policy.cjs +31 -3
- package/blun.mjs +7 -6
- package/package.json +1 -1
|
@@ -34,6 +34,27 @@ function hasOwn(object, key) {
|
|
|
34
34
|
return Object.prototype.hasOwnProperty.call(object, key);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
function projectUsageForRecord(usage) {
|
|
38
|
+
if (!usage || typeof usage !== 'object') return usage;
|
|
39
|
+
const omitCacheRead = usage.inputCacheRead === 0;
|
|
40
|
+
const omitCacheCreation = usage.inputCacheCreation === 0;
|
|
41
|
+
if (!omitCacheRead && !omitCacheCreation) return usage;
|
|
42
|
+
const recordedUsage = { ...usage };
|
|
43
|
+
if (omitCacheRead) delete recordedUsage.inputCacheRead;
|
|
44
|
+
if (omitCacheCreation) delete recordedUsage.inputCacheCreation;
|
|
45
|
+
return recordedUsage;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function restoreUsageFromRecord(usage) {
|
|
49
|
+
if (!usage || typeof usage !== 'object') return usage;
|
|
50
|
+
if (hasOwn(usage, 'inputCacheRead') && hasOwn(usage, 'inputCacheCreation')) return usage;
|
|
51
|
+
return {
|
|
52
|
+
...usage,
|
|
53
|
+
...hasOwn(usage, 'inputCacheRead') ? {} : { inputCacheRead: 0 },
|
|
54
|
+
...hasOwn(usage, 'inputCacheCreation') ? {} : { inputCacheCreation: 0 },
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
37
58
|
function projectLoopEventForRecord(event) {
|
|
38
59
|
if (event?.type === 'step.begin' && hasOwn(event, 'step')) {
|
|
39
60
|
const { step: _step, ...withoutStep } = event;
|
|
@@ -84,9 +105,14 @@ function projectLoopEventForRecord(event) {
|
|
|
84
105
|
return recordedEvent;
|
|
85
106
|
}
|
|
86
107
|
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
-
|
|
108
|
+
if (
|
|
109
|
+
event?.type === 'tool.result' &&
|
|
110
|
+
(hasOwn(event, 'parentUuid') || event.result?.exitCode === 0)
|
|
111
|
+
) {
|
|
112
|
+
const { parentUuid: _parentUuid, ...withoutParentUuid } = event;
|
|
113
|
+
if (event.result?.exitCode !== 0) return withoutParentUuid;
|
|
114
|
+
const { exitCode: _exitCode, ...recordedResult } = event.result;
|
|
115
|
+
return { ...withoutParentUuid, result: recordedResult };
|
|
90
116
|
}
|
|
91
117
|
|
|
92
118
|
const hasRoutineFinishReason = STEP_END_ROUTINE_FINISH_REASONS.has(event?.finishReason);
|
|
@@ -130,6 +156,8 @@ function projectLoopEventForRecord(event) {
|
|
|
130
156
|
|
|
131
157
|
module.exports = {
|
|
132
158
|
projectLoopEventForRecord,
|
|
159
|
+
projectUsageForRecord,
|
|
133
160
|
resolveCompletedStepUuid,
|
|
134
161
|
resolveStepEventUuid,
|
|
162
|
+
restoreUsageFromRecord,
|
|
135
163
|
};
|
package/blun.mjs
CHANGED
|
@@ -75992,7 +75992,7 @@ var init_full = __esmMin((() => {
|
|
|
75992
75992
|
}));
|
|
75993
75993
|
//#endregion
|
|
75994
75994
|
//#region ../../packages/agent-core/src/agent/compaction/micro.ts
|
|
75995
|
-
var selectMicroCompactionCutoff, MICRO_COMPACTION_RECENT_MESSAGES, MICRO_COMPACTION_TOOL_ARGUMENTS_ENABLED, MICRO_COMPACTION_TOOL_ARGUMENT_MIN_TOKENS, isPersistedToolResultReference, projectHistoricalUnaddressedTelegramMessages, dedupeRepeatedUserMessages, projectRepeatedAssistantResponses, compactHistoricalSkillActivations, dedupeRecurringCronWakeups, dedupeRepeatedInjections, projectLoopEventForRecord, resolveCompletedStepUuid, resolveStepEventUuid, DEFAULT_CONFIG, MicroCompaction;
|
|
75995
|
+
var selectMicroCompactionCutoff, MICRO_COMPACTION_RECENT_MESSAGES, MICRO_COMPACTION_TOOL_ARGUMENTS_ENABLED, MICRO_COMPACTION_TOOL_ARGUMENT_MIN_TOKENS, isPersistedToolResultReference, projectHistoricalUnaddressedTelegramMessages, dedupeRepeatedUserMessages, projectRepeatedAssistantResponses, compactHistoricalSkillActivations, dedupeRecurringCronWakeups, dedupeRepeatedInjections, projectLoopEventForRecord, projectUsageForRecord, resolveCompletedStepUuid, resolveStepEventUuid, restoreUsageFromRecord, DEFAULT_CONFIG, MicroCompaction;
|
|
75996
75996
|
var init_micro = __esmMin((() => {
|
|
75997
75997
|
({ selectMicroCompactionCutoff, MICRO_COMPACTION_RECENT_MESSAGES, MICRO_COMPACTION_TOOL_ARGUMENTS_ENABLED, MICRO_COMPACTION_TOOL_ARGUMENT_MIN_TOKENS } = createRequire(import.meta.url)("./bin/micro-compaction-policy.cjs"));
|
|
75998
75998
|
({ isPersistedToolResultReference } = createRequire(import.meta.url)("./bin/tool-result-offload-policy.cjs"));
|
|
@@ -76001,7 +76001,7 @@ var init_micro = __esmMin((() => {
|
|
|
76001
76001
|
({ projectRepeatedAssistantResponses } = createRequire(import.meta.url)("./bin/repeated-assistant-response-policy.cjs"));
|
|
76002
76002
|
({ compactHistoricalSkillActivations } = createRequire(import.meta.url)("./bin/skill-activation-performance-policy.cjs"));
|
|
76003
76003
|
({ dedupeRecurringCronWakeups, dedupeRepeatedInjections } = createRequire(import.meta.url)("./bin/repeated-injection-projection.cjs"));
|
|
76004
|
-
({ projectLoopEventForRecord, resolveCompletedStepUuid, resolveStepEventUuid } = createRequire(import.meta.url)("./bin/loop-event-record-policy.cjs"));
|
|
76004
|
+
({ projectLoopEventForRecord, projectUsageForRecord, resolveCompletedStepUuid, resolveStepEventUuid, restoreUsageFromRecord } = createRequire(import.meta.url)("./bin/loop-event-record-policy.cjs"));
|
|
76005
76005
|
init_tokens();
|
|
76006
76006
|
DEFAULT_CONFIG = {
|
|
76007
76007
|
keepRecentMessages: MICRO_COMPACTION_RECENT_MESSAGES,
|
|
@@ -235036,7 +235036,7 @@ function restoreAgentRecord(agent, input) {
|
|
|
235036
235036
|
agent.permission.recordApprovalResult(input);
|
|
235037
235037
|
return;
|
|
235038
235038
|
case "usage.record":
|
|
235039
|
-
agent.usage.record(input.model, input.usage, "session");
|
|
235039
|
+
agent.usage.record(input.model, restoreUsageFromRecord(input.usage), "session");
|
|
235040
235040
|
return;
|
|
235041
235041
|
case "full_compaction.begin":
|
|
235042
235042
|
agent.fullCompaction.begin(input);
|
|
@@ -264638,7 +264638,7 @@ var init_usage = __esmMin((() => {
|
|
|
264638
264638
|
this.agent?.records.logRecord({
|
|
264639
264639
|
type: "usage.record",
|
|
264640
264640
|
model,
|
|
264641
|
-
usage,
|
|
264641
|
+
usage: projectUsageForRecord(usage),
|
|
264642
264642
|
usageScope: scope
|
|
264643
264643
|
});
|
|
264644
264644
|
const current = this.byModel[model];
|
|
@@ -399116,9 +399116,10 @@ function projectContext(entries, mode = "model") {
|
|
|
399116
399116
|
}
|
|
399117
399117
|
case "usage.record": {
|
|
399118
399118
|
const scope = rec.usageScope ?? "session";
|
|
399119
|
-
|
|
399119
|
+
const restoredUsage = restoreUsageFromRecord(rec.usage);
|
|
399120
|
+
addUsage(usage.byScope[scope], restoredUsage);
|
|
399120
399121
|
if (!usage.byModel[rec.model]) usage.byModel[rec.model] = { ...ZERO };
|
|
399121
|
-
addUsage(usage.byModel[rec.model],
|
|
399122
|
+
addUsage(usage.byModel[rec.model], restoredUsage);
|
|
399122
399123
|
break;
|
|
399123
399124
|
}
|
|
399124
399125
|
case "config.update": {
|