@bakers-build/addon-claude 0.9.1-next.1 → 0.9.1-next.2
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/dist/src/footprint.d.ts +5 -0
- package/dist/src/footprint.js +20 -2
- package/package.json +4 -4
package/dist/src/footprint.d.ts
CHANGED
|
@@ -9,6 +9,11 @@ import { type AgentFootprint } from '@bakers-build/conductor/contract';
|
|
|
9
9
|
* as an array and are ignored). Blank or malformed lines are skipped — never
|
|
10
10
|
* throws.
|
|
11
11
|
*
|
|
12
|
+
* Claude Code writes one API response as several assistant entries (thinking,
|
|
13
|
+
* text, each tool_use) that share `message.id` and repeat its usage, so usage
|
|
14
|
+
* and the agent turn count once per id, from its last entry; entries without an
|
|
15
|
+
* id count one each. `tool_calls` counts every tool_use block.
|
|
16
|
+
*
|
|
12
17
|
* `duration_s` is the run's wall-clock length: the span between the first and
|
|
13
18
|
* last entry that carries a parseable `timestamp` (BB-151). This makes the
|
|
14
19
|
* transcript the single source of the run length — no `started_at` re-read, no
|
package/dist/src/footprint.js
CHANGED
|
@@ -27,6 +27,11 @@ function countWords(text) {
|
|
|
27
27
|
* as an array and are ignored). Blank or malformed lines are skipped — never
|
|
28
28
|
* throws.
|
|
29
29
|
*
|
|
30
|
+
* Claude Code writes one API response as several assistant entries (thinking,
|
|
31
|
+
* text, each tool_use) that share `message.id` and repeat its usage, so usage
|
|
32
|
+
* and the agent turn count once per id, from its last entry; entries without an
|
|
33
|
+
* id count one each. `tool_calls` counts every tool_use block.
|
|
34
|
+
*
|
|
30
35
|
* `duration_s` is the run's wall-clock length: the span between the first and
|
|
31
36
|
* last entry that carries a parseable `timestamp` (BB-151). This makes the
|
|
32
37
|
* transcript the single source of the run length — no `started_at` re-read, no
|
|
@@ -46,6 +51,7 @@ export function parseClaudeTranscript(jsonl) {
|
|
|
46
51
|
// shortcut: parallel open questions are summed, not merged, so overlapping
|
|
47
52
|
// waits count twice (clamped at 0); merge intervals if parallel asks appear.
|
|
48
53
|
const openQuestions = new Map();
|
|
54
|
+
const usageById = new Map();
|
|
49
55
|
for (const raw of jsonl.split('\n')) {
|
|
50
56
|
const line = raw.trim();
|
|
51
57
|
if (line === '') {
|
|
@@ -79,10 +85,18 @@ export function parseClaudeTranscript(jsonl) {
|
|
|
79
85
|
waitMs += humanWait(entry.type, message.content, ts);
|
|
80
86
|
}
|
|
81
87
|
if (entry.type === 'assistant') {
|
|
82
|
-
footprint.agent_turns += 1;
|
|
83
88
|
const usage = message.usage ?? {};
|
|
89
|
+
let tokens = 0;
|
|
84
90
|
for (const key of TOKEN_KEYS) {
|
|
85
|
-
|
|
91
|
+
tokens += num(usage[key]);
|
|
92
|
+
}
|
|
93
|
+
if (typeof message.id === 'string') {
|
|
94
|
+
// Entries of one response repeat its usage; the last one is final.
|
|
95
|
+
usageById.set(message.id, tokens);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
footprint.agent_turns += 1;
|
|
99
|
+
footprint.tokens += tokens;
|
|
86
100
|
}
|
|
87
101
|
if (Array.isArray(message.content)) {
|
|
88
102
|
for (const block of message.content) {
|
|
@@ -102,6 +116,10 @@ export function parseClaudeTranscript(jsonl) {
|
|
|
102
116
|
footprint.user_prompt_words += countWords(message.content);
|
|
103
117
|
}
|
|
104
118
|
}
|
|
119
|
+
footprint.agent_turns += usageById.size;
|
|
120
|
+
for (const tokens of usageById.values()) {
|
|
121
|
+
footprint.tokens += tokens;
|
|
122
|
+
}
|
|
105
123
|
if (Number.isFinite(minTs) && Number.isFinite(maxTs) && maxTs > minTs) {
|
|
106
124
|
footprint.duration_s = Math.floor((maxTs - minTs) / 1000);
|
|
107
125
|
footprint.active_s = Math.max(0, Math.floor((maxTs - minTs - waitMs) / 1000));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bakers-build/addon-claude",
|
|
3
|
-
"version": "0.9.1-next.
|
|
3
|
+
"version": "0.9.1-next.2",
|
|
4
4
|
"description": "bakers.build agent plugin for the Claude CLI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
"directory": "bakers-cli/addons/claude"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@bakers-build/conductor": "^0.9.1-next.
|
|
30
|
-
"@bakers-build/core": "^0.9.1-next.
|
|
29
|
+
"@bakers-build/conductor": "^0.9.1-next.2",
|
|
30
|
+
"@bakers-build/core": "^0.9.1-next.2"
|
|
31
31
|
},
|
|
32
32
|
"bakersBuild": {
|
|
33
|
-
"commit": "
|
|
33
|
+
"commit": "941ab7a2b01d76c841f2a9a55f14649d7c3a1167",
|
|
34
34
|
"channel": "next"
|
|
35
35
|
}
|
|
36
36
|
}
|