blun-king-cli 9.1.245 → 9.1.247

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.
@@ -22,31 +22,52 @@ function resolveCompletedStepUuid(openSteps, event) {
22
22
  return latest;
23
23
  }
24
24
 
25
+ function resolveStepEventUuid(openSteps, event) {
26
+ if (event.stepUuid !== undefined) return event.stepUuid;
27
+ let latest;
28
+ for (const uuid of openSteps.keys()) latest = uuid;
29
+ return latest;
30
+ }
31
+
25
32
  function hasOwn(object, key) {
26
33
  return Object.prototype.hasOwnProperty.call(object, key);
27
34
  }
28
35
 
29
36
  function projectLoopEventForRecord(event) {
30
37
  if (event?.type === 'step.begin' && hasOwn(event, 'step')) {
31
- const { step: _step, ...recordedEvent } = event;
38
+ const { step: _step, ...withoutStep } = event;
39
+ if (event.step <= 1 || !hasOwn(withoutStep, 'turnId')) return withoutStep;
40
+ const { turnId: _turnId, ...recordedEvent } = withoutStep;
32
41
  return recordedEvent;
33
42
  }
34
43
 
35
44
  if (
36
45
  event?.type === 'content.part' &&
37
- (hasOwn(event, 'uuid') || hasOwn(event, 'turnId') || hasOwn(event, 'step'))
46
+ (
47
+ hasOwn(event, 'uuid') ||
48
+ hasOwn(event, 'turnId') ||
49
+ hasOwn(event, 'step') ||
50
+ hasOwn(event, 'stepUuid')
51
+ )
38
52
  ) {
39
- const { uuid: _uuid, turnId: _turnId, step: _step, ...recordedEvent } = event;
53
+ const {
54
+ uuid: _uuid,
55
+ turnId: _turnId,
56
+ step: _step,
57
+ stepUuid: _stepUuid,
58
+ ...recordedEvent
59
+ } = event;
40
60
  return recordedEvent;
41
61
  }
42
62
 
43
63
  if (
44
64
  event?.type === 'tool.call' &&
45
65
  (
46
- hasOwn(event, 'uuid') ||
47
- hasOwn(event, 'turnId') ||
48
- hasOwn(event, 'step') ||
49
- hasOwn(event, 'display') ||
66
+ hasOwn(event, 'uuid') ||
67
+ hasOwn(event, 'turnId') ||
68
+ hasOwn(event, 'step') ||
69
+ hasOwn(event, 'stepUuid') ||
70
+ hasOwn(event, 'display') ||
50
71
  hasOwn(event, 'description')
51
72
  )
52
73
  ) {
@@ -54,6 +75,7 @@ function projectLoopEventForRecord(event) {
54
75
  uuid: _uuid,
55
76
  turnId: _turnId,
56
77
  step: _step,
78
+ stepUuid: _stepUuid,
57
79
  display: _display,
58
80
  description: _description,
59
81
  ...recordedEvent
@@ -104,4 +126,8 @@ function projectLoopEventForRecord(event) {
104
126
  return withoutRoutineFinishReason;
105
127
  }
106
128
 
107
- module.exports = { projectLoopEventForRecord, resolveCompletedStepUuid };
129
+ module.exports = {
130
+ projectLoopEventForRecord,
131
+ resolveCompletedStepUuid,
132
+ resolveStepEventUuid,
133
+ };
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, 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, resolveCompletedStepUuid, resolveStepEventUuid, 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 } = createRequire(import.meta.url)("./bin/loop-event-record-policy.cjs"));
76004
+ ({ projectLoopEventForRecord, resolveCompletedStepUuid, resolveStepEventUuid } = 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,
@@ -79149,15 +79149,17 @@ var init_context$2 = __esmMin((() => {
79149
79149
  return;
79150
79150
  }
79151
79151
  case "content.part": {
79152
- const openStep = this.openSteps.get(event.stepUuid);
79153
- if (openStep === void 0) throw new Error(`Received content_part for unknown step_uuid '${event.stepUuid}' (no open step_begin)`);
79152
+ const stepEventUuid = resolveStepEventUuid(this.openSteps, event);
79153
+ const openStep = this.openSteps.get(stepEventUuid);
79154
+ if (openStep === void 0) throw new Error(`Received content_part for unknown step_uuid '${stepEventUuid}' (no open step_begin)`);
79154
79155
  openStep.content.push(event.part);
79155
79156
  this.markPendingTokenEstimateDirty();
79156
79157
  return;
79157
79158
  }
79158
79159
  case "tool.call": {
79159
- const openStep = this.openSteps.get(event.stepUuid);
79160
- if (openStep === void 0) throw new Error(`Received tool_call for unknown step_uuid '${event.stepUuid}' (no open step_begin)`);
79160
+ const stepEventUuid = resolveStepEventUuid(this.openSteps, event);
79161
+ const openStep = this.openSteps.get(stepEventUuid);
79162
+ if (openStep === void 0) throw new Error(`Received tool_call for unknown step_uuid '${stepEventUuid}' (no open step_begin)`);
79161
79163
  openStep.toolCalls.push({
79162
79164
  type: "function",
79163
79165
  id: event.toolCallId,
@@ -324056,10 +324058,10 @@ function reduceWireRecords(records) {
324056
324058
  return;
324057
324059
  }
324058
324060
  case "content.part":
324059
- openSteps.get(event.stepUuid)?.message.content.push(event.part);
324061
+ openSteps.get(resolveStepEventUuid(openSteps, event))?.message.content.push(event.part);
324060
324062
  return;
324061
324063
  case "tool.call": {
324062
- const openStep = openSteps.get(event.stepUuid);
324064
+ const openStep = openSteps.get(resolveStepEventUuid(openSteps, event));
324063
324065
  if (openStep === void 0) return;
324064
324066
  openStep.message.toolCalls.push({
324065
324067
  type: "function",
@@ -398957,10 +398959,10 @@ function projectContext(entries, mode = "model") {
398957
398959
  messages.push(projected);
398958
398960
  openSteps.set(ev.uuid, projected);
398959
398961
  } else if (ev.type === "content.part") {
398960
- const projected = openSteps.get(ev.stepUuid);
398962
+ const projected = openSteps.get(resolveStepEventUuid(openSteps, ev));
398961
398963
  if (projected !== void 0) projected.message.content.push(ev.part);
398962
398964
  } else if (ev.type === "tool.call") {
398963
- const projected = openSteps.get(ev.stepUuid);
398965
+ const projected = openSteps.get(resolveStepEventUuid(openSteps, ev));
398964
398966
  if (projected !== void 0) {
398965
398967
  const args = typeof ev.args === "string" ? ev.args : ev.args === void 0 ? null : JSON.stringify(ev.args);
398966
398968
  projected.message.toolCalls.push({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "9.1.245",
3
+ "version": "9.1.247",
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": {