blun-king-cli 9.1.241 → 9.1.243
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.
|
@@ -9,12 +9,18 @@ const STEP_END_LIVE_ONLY_FIELDS = [
|
|
|
9
9
|
'llmClientConsumeMs',
|
|
10
10
|
'messageId',
|
|
11
11
|
];
|
|
12
|
+
const STEP_END_ROUTINE_FINISH_REASONS = new Set(['tool_use', 'end_turn']);
|
|
12
13
|
|
|
13
14
|
function hasOwn(object, key) {
|
|
14
15
|
return Object.prototype.hasOwnProperty.call(object, key);
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
function projectLoopEventForRecord(event) {
|
|
19
|
+
if (event?.type === 'step.begin' && hasOwn(event, 'step')) {
|
|
20
|
+
const { step: _step, ...recordedEvent } = event;
|
|
21
|
+
return recordedEvent;
|
|
22
|
+
}
|
|
23
|
+
|
|
18
24
|
if (
|
|
19
25
|
event?.type === 'content.part' &&
|
|
20
26
|
(hasOwn(event, 'uuid') || hasOwn(event, 'turnId') || hasOwn(event, 'step'))
|
|
@@ -49,11 +55,13 @@ function projectLoopEventForRecord(event) {
|
|
|
49
55
|
return recordedEvent;
|
|
50
56
|
}
|
|
51
57
|
|
|
58
|
+
const hasRoutineFinishReason = STEP_END_ROUTINE_FINISH_REASONS.has(event?.finishReason);
|
|
52
59
|
if (
|
|
53
60
|
event?.type !== 'step.end' ||
|
|
54
61
|
(
|
|
55
62
|
!hasOwn(event, 'turnId') &&
|
|
56
63
|
!hasOwn(event, 'step') &&
|
|
64
|
+
!hasRoutineFinishReason &&
|
|
57
65
|
!STEP_END_LIVE_ONLY_FIELDS.some((field) => hasOwn(event, field))
|
|
58
66
|
)
|
|
59
67
|
) {
|
|
@@ -72,7 +80,9 @@ function projectLoopEventForRecord(event) {
|
|
|
72
80
|
messageId: _messageId,
|
|
73
81
|
...recordedEvent
|
|
74
82
|
} = event;
|
|
75
|
-
return recordedEvent;
|
|
83
|
+
if (!hasRoutineFinishReason) return recordedEvent;
|
|
84
|
+
const { finishReason: _finishReason, ...withoutRoutineFinishReason } = recordedEvent;
|
|
85
|
+
return withoutRoutineFinishReason;
|
|
76
86
|
}
|
|
77
87
|
|
|
78
88
|
module.exports = { projectLoopEventForRecord };
|