import { normalizeWhitespace, truncateText } from "@best-agent/foundation";
export function formatToolInputForPrompt(input) {
    return typeof input === "string" ? input : JSON.stringify(input);
}
export function truncateForReasoning(value, maxLength = 240) {
    return truncateText(normalizeWhitespace(value), maxLength);
}
export function truncateTitle(value) {
    return truncateText(normalizeWhitespace(value), 60);
}
export function previewDebugText(value, maxLength) {
    return value.length <= maxLength ? value : `${value.slice(0, maxLength)}...[truncated]`;
}
export function previewToolInputForDebugLog(input) {
    if (typeof input === "string") {
        return previewDebugText(input, 500);
    }
    if (Array.isArray(input)) {
        return input
            .slice(0, 12)
            .map((value) => (typeof value === "string" ? previewDebugText(value, 240) : value));
    }
    if (!input || typeof input !== "object") {
        return input;
    }
    const output = {};
    for (const [key, value] of Object.entries(input)) {
        if (typeof value === "string") {
            output[key] = previewDebugText(value, 500);
            continue;
        }
        if (Array.isArray(value)) {
            output[key] = value
                .slice(0, 12)
                .map((item) => (typeof item === "string" ? previewDebugText(item, 240) : item));
            continue;
        }
        output[key] = value;
    }
    return output;
}
export function extractInlinePaths(value) {
    return value
        .split(/\s+/)
        .map((part) => part.trim())
        .filter((part) => part.includes("/") || part.includes("."));
}
export function sleep(durationMs) {
    return new Promise((resolve) => {
        setTimeout(resolve, durationMs);
    });
}
//# sourceMappingURL=text.js.map