mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-07 10:34:44 +00:00
refactor(copilot): remove unused usage total helper
This commit is contained in:
@@ -3,7 +3,6 @@ import type { NormalizedUsage } from "openclaw/plugin-sdk/agent-harness-runtime"
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
buildCopilotAssistantUsage,
|
||||
deriveCopilotUsageTotal,
|
||||
normalizeCopilotUsage,
|
||||
} from "./usage-bridge.js";
|
||||
|
||||
@@ -251,21 +250,4 @@ describe("usage-bridge", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("deriveCopilotUsageTotal", () => {
|
||||
it("returns undefined when usage is undefined", () => {
|
||||
expect(deriveCopilotUsageTotal(undefined)).toBeUndefined();
|
||||
});
|
||||
|
||||
it("sums input/output/cacheRead/cacheWrite for total", () => {
|
||||
const usage: NormalizedUsage = {
|
||||
cacheRead: 3,
|
||||
cacheWrite: 4,
|
||||
input: 1,
|
||||
output: 2,
|
||||
total: 999,
|
||||
};
|
||||
|
||||
expect(deriveCopilotUsageTotal(usage)).toBe(10);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -72,13 +72,3 @@ export function buildCopilotAssistantUsage(params: {
|
||||
totalTokens: usage?.total ?? 0,
|
||||
};
|
||||
}
|
||||
|
||||
export function deriveCopilotUsageTotal(usage?: NormalizedUsage): number | undefined {
|
||||
if (!usage) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return (
|
||||
(usage.input ?? 0) + (usage.output ?? 0) + (usage.cacheRead ?? 0) + (usage.cacheWrite ?? 0)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user