Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fcb835d129 | |||
| f1400ffb7c |
+2
-14
@@ -189,7 +189,6 @@ async function runClaude(params: RunParams): Promise<AgentResult> {
|
||||
|
||||
let finalOutput = "";
|
||||
let accumulatedTokens = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
|
||||
let costUsd: number | undefined;
|
||||
let tokensLogged = false;
|
||||
|
||||
function buildUsage(): AgentUsage | undefined {
|
||||
@@ -202,7 +201,6 @@ async function runClaude(params: RunParams): Promise<AgentResult> {
|
||||
outputTokens: accumulatedTokens.output,
|
||||
cacheReadTokens: accumulatedTokens.cacheRead || undefined,
|
||||
cacheWriteTokens: accumulatedTokens.cacheWrite || undefined,
|
||||
costUsd,
|
||||
}
|
||||
: undefined;
|
||||
}
|
||||
@@ -291,28 +289,18 @@ async function runClaude(params: RunParams): Promise<AgentResult> {
|
||||
const totalInput = inputTokens + cacheRead + cacheWrite;
|
||||
|
||||
accumulatedTokens = { input: inputTokens, output: outputTokens, cacheRead, cacheWrite };
|
||||
costUsd = event.total_cost_usd ?? undefined;
|
||||
|
||||
log.info(
|
||||
`» ${params.label} result: subtype=${subtype}, turns=${numTurns}, cost=$${costUsd?.toFixed(4) ?? "?"}`
|
||||
);
|
||||
log.info(`» ${params.label} result: subtype=${subtype}, turns=${numTurns}`);
|
||||
|
||||
if (!tokensLogged) {
|
||||
log.table([
|
||||
[
|
||||
{ data: "Cost", header: true },
|
||||
{ data: "Input", header: true },
|
||||
{ data: "Cache Read", header: true },
|
||||
{ data: "Cache Write", header: true },
|
||||
{ data: "Output", header: true },
|
||||
],
|
||||
[
|
||||
`$${costUsd?.toFixed(4) || "0.0000"}`,
|
||||
String(totalInput),
|
||||
String(cacheRead),
|
||||
String(cacheWrite),
|
||||
String(outputTokens),
|
||||
],
|
||||
[String(totalInput), String(cacheRead), String(cacheWrite), String(outputTokens)],
|
||||
]);
|
||||
tokensLogged = true;
|
||||
}
|
||||
|
||||
@@ -107596,27 +107596,21 @@ function formatJsonValue(value2) {
|
||||
}
|
||||
function formatUsageSummary(entries) {
|
||||
if (entries.length === 0) return "";
|
||||
const hasCost = entries.some((e) => e.costUsd !== void 0);
|
||||
const header = hasCost ? "| Agent | Input | Output | Cache Read | Cache Write | Cost |" : "| Agent | Input | Output | Cache Read | Cache Write |";
|
||||
const header = "| Agent | Input | Output | Cache Read | Cache Write |";
|
||||
const separatorRow = "| --- | ---: | ---: | ---: | ---: |";
|
||||
const fmt = (n) => n.toLocaleString("en-US");
|
||||
const separatorRow = hasCost ? "| --- | ---: | ---: | ---: | ---: | ---: |" : "| --- | ---: | ---: | ---: | ---: |";
|
||||
const rows = entries.map((e) => {
|
||||
const base = `| ${e.agent} | ${fmt(e.inputTokens)} | ${fmt(e.outputTokens)} | ${fmt(e.cacheReadTokens ?? 0)} | ${fmt(e.cacheWriteTokens ?? 0)} |`;
|
||||
return hasCost ? `${base} ${e.costUsd !== void 0 ? `$${e.costUsd.toFixed(4)}` : "-"} |` : base;
|
||||
});
|
||||
const rows = entries.map(
|
||||
(e) => `| ${e.agent} | ${fmt(e.inputTokens)} | ${fmt(e.outputTokens)} | ${fmt(e.cacheReadTokens ?? 0)} | ${fmt(e.cacheWriteTokens ?? 0)} |`
|
||||
);
|
||||
const totalsRows = [];
|
||||
if (entries.length > 1) {
|
||||
const totalInput = entries.reduce((sum, e) => sum + e.inputTokens, 0);
|
||||
const totalOutput = entries.reduce((sum, e) => sum + e.outputTokens, 0);
|
||||
const totalCacheRead = entries.reduce((sum, e) => sum + (e.cacheReadTokens ?? 0), 0);
|
||||
const totalCacheWrite = entries.reduce((sum, e) => sum + (e.cacheWriteTokens ?? 0), 0);
|
||||
const totalBase = `| **Total** | **${fmt(totalInput)}** | **${fmt(totalOutput)}** | **${fmt(totalCacheRead)}** | **${fmt(totalCacheWrite)}** |`;
|
||||
if (hasCost) {
|
||||
const totalCost = entries.reduce((sum, e) => sum + (e.costUsd ?? 0), 0);
|
||||
totalsRows.push(`${totalBase} **$${totalCost.toFixed(4)}** |`);
|
||||
} else {
|
||||
totalsRows.push(totalBase);
|
||||
}
|
||||
totalsRows.push(
|
||||
`| **Total** | **${fmt(totalInput)}** | **${fmt(totalOutput)}** | **${fmt(totalCacheRead)}** | **${fmt(totalCacheWrite)}** |`
|
||||
);
|
||||
}
|
||||
return [
|
||||
"<details>",
|
||||
@@ -144702,7 +144696,7 @@ var import_semver = __toESM(require_semver2(), 1);
|
||||
// package.json
|
||||
var package_default = {
|
||||
name: "@pullfrog/pullfrog",
|
||||
version: "0.0.185",
|
||||
version: "0.0.186",
|
||||
type: "module",
|
||||
files: [
|
||||
"index.js",
|
||||
@@ -149453,7 +149447,6 @@ async function runClaude(params) {
|
||||
const thinkingTimer = new ThinkingTimer();
|
||||
let finalOutput = "";
|
||||
let accumulatedTokens = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
|
||||
let costUsd;
|
||||
let tokensLogged = false;
|
||||
function buildUsage() {
|
||||
const totalInput = accumulatedTokens.input + accumulatedTokens.cacheRead + accumulatedTokens.cacheWrite;
|
||||
@@ -149462,8 +149455,7 @@ async function runClaude(params) {
|
||||
inputTokens: totalInput,
|
||||
outputTokens: accumulatedTokens.output,
|
||||
cacheReadTokens: accumulatedTokens.cacheRead || void 0,
|
||||
cacheWriteTokens: accumulatedTokens.cacheWrite || void 0,
|
||||
costUsd
|
||||
cacheWriteTokens: accumulatedTokens.cacheWrite || void 0
|
||||
} : void 0;
|
||||
}
|
||||
const handlers2 = {
|
||||
@@ -149526,26 +149518,16 @@ async function runClaude(params) {
|
||||
const outputTokens = usage?.output_tokens || 0;
|
||||
const totalInput = inputTokens + cacheRead + cacheWrite;
|
||||
accumulatedTokens = { input: inputTokens, output: outputTokens, cacheRead, cacheWrite };
|
||||
costUsd = event.total_cost_usd ?? void 0;
|
||||
log.info(
|
||||
`\xBB ${params.label} result: subtype=${subtype}, turns=${numTurns}, cost=$${costUsd?.toFixed(4) ?? "?"}`
|
||||
);
|
||||
log.info(`\xBB ${params.label} result: subtype=${subtype}, turns=${numTurns}`);
|
||||
if (!tokensLogged) {
|
||||
log.table([
|
||||
[
|
||||
{ data: "Cost", header: true },
|
||||
{ data: "Input", header: true },
|
||||
{ data: "Cache Read", header: true },
|
||||
{ data: "Cache Write", header: true },
|
||||
{ data: "Output", header: true }
|
||||
],
|
||||
[
|
||||
`$${costUsd?.toFixed(4) || "0.0000"}`,
|
||||
String(totalInput),
|
||||
String(cacheRead),
|
||||
String(cacheWrite),
|
||||
String(outputTokens)
|
||||
]
|
||||
[String(totalInput), String(cacheRead), String(cacheWrite), String(outputTokens)]
|
||||
]);
|
||||
tokensLogged = true;
|
||||
}
|
||||
@@ -150728,7 +150710,7 @@ function buildCommonInputs(ctx) {
|
||||
};
|
||||
}
|
||||
function assembleFullPrompt(ctx) {
|
||||
const learningsSection = ctx.learnings ? `************* REPO INTELLIGENCE *************
|
||||
const learningsSection = ctx.learnings ? `************* LEARNINGS *************
|
||||
|
||||
${ctx.learnings}` : "";
|
||||
const rawFull = `************* RUNTIME CONTEXT *************
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pullfrog/pullfrog",
|
||||
"version": "0.0.185",
|
||||
"version": "0.0.186",
|
||||
"type": "module",
|
||||
"files": [
|
||||
"index.js",
|
||||
|
||||
@@ -41557,7 +41557,7 @@ var core3 = __toESM(require_core(), 1);
|
||||
// package.json
|
||||
var package_default = {
|
||||
name: "@pullfrog/pullfrog",
|
||||
version: "0.0.185",
|
||||
version: "0.0.186",
|
||||
type: "module",
|
||||
files: [
|
||||
"index.js",
|
||||
|
||||
@@ -340,7 +340,7 @@ interface AssembleFullPromptInput {
|
||||
|
||||
function assembleFullPrompt(ctx: AssembleFullPromptInput): string {
|
||||
const learningsSection = ctx.learnings
|
||||
? `************* REPO INTELLIGENCE *************\n\n${ctx.learnings}`
|
||||
? `************* LEARNINGS *************\n\n${ctx.learnings}`
|
||||
: "";
|
||||
|
||||
const rawFull = `************* RUNTIME CONTEXT *************
|
||||
|
||||
+9
-25
@@ -339,40 +339,24 @@ export function formatIndentedField(label: string, content: string): string {
|
||||
export function formatUsageSummary(entries: AgentUsage[]): string {
|
||||
if (entries.length === 0) return "";
|
||||
|
||||
const hasCost = entries.some((e) => e.costUsd !== undefined);
|
||||
|
||||
const header = hasCost
|
||||
? "| Agent | Input | Output | Cache Read | Cache Write | Cost |"
|
||||
: "| Agent | Input | Output | Cache Read | Cache Write |";
|
||||
|
||||
const header = "| Agent | Input | Output | Cache Read | Cache Write |";
|
||||
const separatorRow = "| --- | ---: | ---: | ---: | ---: |";
|
||||
const fmt = (n: number) => n.toLocaleString("en-US");
|
||||
|
||||
const separatorRow = hasCost
|
||||
? "| --- | ---: | ---: | ---: | ---: | ---: |"
|
||||
: "| --- | ---: | ---: | ---: | ---: |";
|
||||
const rows = entries.map(
|
||||
(e) =>
|
||||
`| ${e.agent} | ${fmt(e.inputTokens)} | ${fmt(e.outputTokens)} | ${fmt(e.cacheReadTokens ?? 0)} | ${fmt(e.cacheWriteTokens ?? 0)} |`
|
||||
);
|
||||
|
||||
const rows = entries.map((e) => {
|
||||
const base = `| ${e.agent} | ${fmt(e.inputTokens)} | ${fmt(e.outputTokens)} | ${fmt(e.cacheReadTokens ?? 0)} | ${fmt(e.cacheWriteTokens ?? 0)} |`;
|
||||
return hasCost
|
||||
? `${base} ${e.costUsd !== undefined ? `$${e.costUsd.toFixed(4)}` : "-"} |`
|
||||
: base;
|
||||
});
|
||||
|
||||
// totals row (only useful when there are multiple entries)
|
||||
const totalsRows: string[] = [];
|
||||
if (entries.length > 1) {
|
||||
const totalInput = entries.reduce((sum, e) => sum + e.inputTokens, 0);
|
||||
const totalOutput = entries.reduce((sum, e) => sum + e.outputTokens, 0);
|
||||
const totalCacheRead = entries.reduce((sum, e) => sum + (e.cacheReadTokens ?? 0), 0);
|
||||
const totalCacheWrite = entries.reduce((sum, e) => sum + (e.cacheWriteTokens ?? 0), 0);
|
||||
const totalBase = `| **Total** | **${fmt(totalInput)}** | **${fmt(totalOutput)}** | **${fmt(totalCacheRead)}** | **${fmt(totalCacheWrite)}** |`;
|
||||
|
||||
if (hasCost) {
|
||||
const totalCost = entries.reduce((sum, e) => sum + (e.costUsd ?? 0), 0);
|
||||
totalsRows.push(`${totalBase} **$${totalCost.toFixed(4)}** |`);
|
||||
} else {
|
||||
totalsRows.push(totalBase);
|
||||
}
|
||||
totalsRows.push(
|
||||
`| **Total** | **${fmt(totalInput)}** | **${fmt(totalOutput)}** | **${fmt(totalCacheRead)}** | **${fmt(totalCacheWrite)}** |`
|
||||
);
|
||||
}
|
||||
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user