MCPcopy Create free account
hub / github.com/apache/maka / accumulateUsage

Function accumulateUsage

packages/cli/src/pi-transcript.ts:214–233  ·  view source on GitHub ↗
(
  usage: MakaPiUsageSummary,
  msg: {
    costUsd?: number;
    input?: number;
    cacheHitInput?: number;
    cacheRead?: number;
    cacheWriteInput?: number;
    cacheCreation?: number;
    cacheMissInput?: number;
    contextRemaining?: number;
  },
)

Source from the content-addressed store, hash-verified

212}
213
214function accumulateUsage(
215 usage: MakaPiUsageSummary,
216 msg: {
217 costUsd?: number;
218 input?: number;
219 cacheHitInput?: number;
220 cacheRead?: number;
221 cacheWriteInput?: number;
222 cacheCreation?: number;
223 cacheMissInput?: number;
224 contextRemaining?: number;
225 },
226): void {
227 usage.costUsd += msg.costUsd ?? 0;
228 const hit = msg.cacheHitInput ?? msg.cacheRead ?? 0;
229 const write = msg.cacheWriteInput ?? msg.cacheCreation ?? 0;
230 usage.cacheHitInput += hit;
231 usage.cacheMissInput += msg.cacheMissInput ?? Math.max(0, (msg.input ?? 0) - hit - write);
232 usage.contextRemaining = msg.contextRemaining;
233}
234
235export function appendUserPrompt(state: MakaPiTranscriptState, text: string): void {
236 state.entries.push({ kind: 'user', text });

Calls

no outgoing calls

Tested by

no test coverage detected