refactor: dedupe agent and reply runtimes

This commit is contained in:
Peter Steinberger
2026-03-02 19:47:30 +00:00
parent 8768487aee
commit 9617ac9dd5
53 changed files with 1828 additions and 1176 deletions

View File

@@ -1,5 +1,6 @@
import type { Model } from "@mariozechner/pi-ai/dist/types.js";
import { expect } from "vitest";
import { makeZeroUsageSnapshot } from "../agents/usage.js";
export const asRecord = (value: unknown): Record<string, unknown> => {
expect(value).toBeTruthy();
@@ -48,23 +49,6 @@ export const makeGeminiCliModel = (id: string): Model<"google-gemini-cli"> =>
maxTokens: 1,
}) as Model<"google-gemini-cli">;
function makeZeroUsage() {
return {
input: 0,
output: 0,
cacheRead: 0,
cacheWrite: 0,
totalTokens: 0,
cost: {
input: 0,
output: 0,
cacheRead: 0,
cacheWrite: 0,
total: 0,
},
};
}
export function makeGoogleAssistantMessage(model: string, content: unknown) {
return {
role: "assistant",
@@ -72,7 +56,7 @@ export function makeGoogleAssistantMessage(model: string, content: unknown) {
api: "google-generative-ai",
provider: "google",
model,
usage: makeZeroUsage(),
usage: makeZeroUsageSnapshot(),
stopReason: "stop",
timestamp: 0,
};
@@ -85,7 +69,7 @@ export function makeGeminiCliAssistantMessage(model: string, content: unknown) {
api: "google-gemini-cli",
provider: "google-gemini-cli",
model,
usage: makeZeroUsage(),
usage: makeZeroUsageSnapshot(),
stopReason: "stop",
timestamp: 0,
};