blun-king-cli 9.1.249 → 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.
@@ -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;
@@ -135,6 +156,8 @@ function projectLoopEventForRecord(event) {
135
156
 
136
157
  module.exports = {
137
158
  projectLoopEventForRecord,
159
+ projectUsageForRecord,
138
160
  resolveCompletedStepUuid,
139
161
  resolveStepEventUuid,
162
+ restoreUsageFromRecord,
140
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
- addUsage(usage.byScope[scope], rec.usage);
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], rec.usage);
399122
+ addUsage(usage.byModel[rec.model], restoredUsage);
399122
399123
  break;
399123
399124
  }
399124
399125
  case "config.update": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "9.1.249",
3
+ "version": "9.1.250",
4
4
  "description": "BLUN CLI - your own AI agent with a Telegram channel. Get it done. With BLUN.",
5
5
  "license": "MIT",
6
6
  "bin": {