/**
 * Shared sanitization helpers used by transcript parsers when converting
 * tool inputs / results into the condensed text fed to the summarizer.
 *
 * These intentionally do NOT mutate the input — they return a clean clone
 * so callers can safely JSON.stringify and truncate the result.
 */
function isObjectRecord(value) {
    return typeof value === "object" && value !== null;
}
/**
 * Recursively strip base64 image payloads and large base64-looking strings
 * from arbitrary JSON values. Used to keep tool inputs/outputs small in
 * the condensed transcript.
 */
export function sanitizeForSummary(value) {
    if (Array.isArray(value)) {
        return value.map((item) => sanitizeForSummary(item));
    }
    if (!isObjectRecord(value)) {
        return value;
    }
    if (value.type === "image") {
        const source = value.source;
        if (isObjectRecord(source)) {
            if (source.type === "base64") {
                return "[image: base64 omitted]";
            }
            if (source.type === "url") {
                return "[image: url omitted]";
            }
        }
        return "[image omitted]";
    }
    if (value.type === "image_url") {
        return "[image_url omitted]";
    }
    const sanitized = {};
    for (const [key, child] of Object.entries(value)) {
        if (key === "data" &&
            typeof child === "string" &&
            child.length > 200 &&
            /^[A-Za-z0-9+/=]+$/.test(child)) {
            sanitized[key] = "[base64 omitted]";
            continue;
        }
        sanitized[key] = sanitizeForSummary(child);
    }
    return sanitized;
}
//# sourceMappingURL=sanitize.js.map