@sunasteriskrnd/takumi 1.0.0-dev.32 → 1.0.0-dev.33
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/index.js +21 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -19815,7 +19815,7 @@ var package_default;
|
|
|
19815
19815
|
var init_package = __esm(() => {
|
|
19816
19816
|
package_default = {
|
|
19817
19817
|
name: "@sunasteriskrnd/takumi",
|
|
19818
|
-
version: "1.0.0-dev.
|
|
19818
|
+
version: "1.0.0-dev.33",
|
|
19819
19819
|
description: "CLI tool for bootstrapping and managing Takumi projects",
|
|
19820
19820
|
type: "module",
|
|
19821
19821
|
repository: {
|
|
@@ -61955,6 +61955,7 @@ function buildSessionPayload(args) {
|
|
|
61955
61955
|
const endedAt = summary.timing.ended_at ?? startedAt;
|
|
61956
61956
|
const durationS = summary.timing.duration_s ?? Math.max(0, Math.round((Date.parse(endedAt) - Date.parse(startedAt)) / 1000));
|
|
61957
61957
|
const tokens = summary.totals;
|
|
61958
|
+
const hasTokenUsage = summary.token_usage && Object.keys(summary.token_usage).length > 0;
|
|
61958
61959
|
return {
|
|
61959
61960
|
session: {
|
|
61960
61961
|
id: summary.session_id,
|
|
@@ -61971,7 +61972,8 @@ function buildSessionPayload(args) {
|
|
|
61971
61972
|
cache_write_tokens: tokens.cache_write,
|
|
61972
61973
|
milestone_completed: args.milestone,
|
|
61973
61974
|
error_count: args.errorCount,
|
|
61974
|
-
tool_stats: summary.tool_stats
|
|
61975
|
+
tool_stats: summary.tool_stats,
|
|
61976
|
+
...hasTokenUsage ? { token_usage: summary.token_usage } : {}
|
|
61975
61977
|
}
|
|
61976
61978
|
};
|
|
61977
61979
|
}
|
|
@@ -61991,6 +61993,7 @@ function initialSummary(args) {
|
|
|
61991
61993
|
project: args.project,
|
|
61992
61994
|
timing: { started_at: args.startedAt, ended_at: null, duration_s: null },
|
|
61993
61995
|
main_loop_tokens: zeroTokens(),
|
|
61996
|
+
token_usage: {},
|
|
61994
61997
|
subagents: [],
|
|
61995
61998
|
skills: [],
|
|
61996
61999
|
tool_stats: {
|
|
@@ -62123,6 +62126,7 @@ async function tailRead(args) {
|
|
|
62123
62126
|
function bucketTokens(records) {
|
|
62124
62127
|
const mainLoopDelta = zeroTokens2();
|
|
62125
62128
|
const subagentDeltas = new Map;
|
|
62129
|
+
const tokenUsageDeltas = new Map;
|
|
62126
62130
|
for (const record of records) {
|
|
62127
62131
|
if (record.type !== "assistant")
|
|
62128
62132
|
continue;
|
|
@@ -62141,8 +62145,13 @@ function bucketTokens(records) {
|
|
|
62141
62145
|
} else {
|
|
62142
62146
|
Object.assign(mainLoopDelta, addTokens2(mainLoopDelta, tokens));
|
|
62143
62147
|
}
|
|
62148
|
+
const model = record.message?.model;
|
|
62149
|
+
if (model) {
|
|
62150
|
+
const prev = tokenUsageDeltas.get(model) ?? zeroTokens2();
|
|
62151
|
+
tokenUsageDeltas.set(model, addTokens2(prev, tokens));
|
|
62152
|
+
}
|
|
62144
62153
|
}
|
|
62145
|
-
return { mainLoopDelta, subagentDeltas };
|
|
62154
|
+
return { mainLoopDelta, subagentDeltas, tokenUsageDeltas };
|
|
62146
62155
|
}
|
|
62147
62156
|
|
|
62148
62157
|
// src/domains/hooks/telemetry/lib/transcript-apply.ts
|
|
@@ -62157,6 +62166,13 @@ function addTokens3(a3, b3) {
|
|
|
62157
62166
|
cache_write: a3.cache_write + b3.cache_write
|
|
62158
62167
|
};
|
|
62159
62168
|
}
|
|
62169
|
+
function mergeTokenUsageDeltas(existing, deltas) {
|
|
62170
|
+
const out = { ...existing ?? {} };
|
|
62171
|
+
for (const [model, delta] of deltas) {
|
|
62172
|
+
out[model] = addTokens3(ensureTokens(out[model]), delta);
|
|
62173
|
+
}
|
|
62174
|
+
return out;
|
|
62175
|
+
}
|
|
62160
62176
|
async function applyTranscriptDelta(args) {
|
|
62161
62177
|
if (!args.transcriptPath) {
|
|
62162
62178
|
return { summary: args.summary, read: false };
|
|
@@ -62169,7 +62185,7 @@ async function applyTranscriptDelta(args) {
|
|
|
62169
62185
|
if (records.length === 0 && nextOffset === args.summary.transcript_offset) {
|
|
62170
62186
|
return { summary: args.summary, read: true };
|
|
62171
62187
|
}
|
|
62172
|
-
const { mainLoopDelta, subagentDeltas } = bucketTokens(records);
|
|
62188
|
+
const { mainLoopDelta, subagentDeltas, tokenUsageDeltas } = bucketTokens(records);
|
|
62173
62189
|
const updated = {
|
|
62174
62190
|
...args.summary,
|
|
62175
62191
|
main_loop_tokens: addTokens3(args.summary.main_loop_tokens, mainLoopDelta),
|
|
@@ -62179,6 +62195,7 @@ async function applyTranscriptDelta(args) {
|
|
|
62179
62195
|
return rec;
|
|
62180
62196
|
return { ...rec, tokens: addTokens3(ensureTokens(rec.tokens), delta) };
|
|
62181
62197
|
}),
|
|
62198
|
+
token_usage: mergeTokenUsageDeltas(args.summary.token_usage, tokenUsageDeltas),
|
|
62182
62199
|
transcript_offset: nextOffset
|
|
62183
62200
|
};
|
|
62184
62201
|
return { summary: updated, read: true };
|