refactor: dedupe lowercase helper readers

This commit is contained in:
Peter Steinberger
2026-04-07 10:18:06 +01:00
parent f54a57b80a
commit 434d56a948
19 changed files with 95 additions and 65 deletions

View File

@@ -1,4 +1,7 @@
import { normalizeOptionalString } from "../shared/string-coerce.js";
import {
normalizeOptionalLowercaseString,
normalizeOptionalString,
} from "../shared/string-coerce.js";
type ToolResultCounts = {
total: number;
@@ -9,7 +12,7 @@ const TOOL_CALL_TYPES = new Set(["tool_use", "toolcall", "tool_call"]);
const TOOL_RESULT_TYPES = new Set(["tool_result", "tool_result_error"]);
const normalizeType = (value: unknown): string => {
return typeof value === "string" ? (normalizeOptionalString(value)?.toLowerCase() ?? "") : "";
return typeof value === "string" ? (normalizeOptionalLowercaseString(value) ?? "") : "";
};
export const extractToolCallNames = (message: Record<string, unknown>): string[] => {