/**
 * Shared types and utilities for tool execution rendering.
 *
 * Defines the content block, result, and preview state types used across
 * the tool execution pipeline, plus string coercion and path helpers.
 */
import * as os from 'node:os';
/** Coerce a tool argument to string. Returns null for non-string/non-null values (invalid). */
export function coerceToolString(value) {
    if (typeof value === 'string')
        return value;
    if (value == null)
        return '';
    return null;
}
/** Replace tabs with spaces for consistent terminal rendering. */
export function normalizeToolText(text) {
    return text.replace(/\t/g, '   ');
}
/** Replace the user's home directory prefix with ~ for display. */
export function shortenHomePath(path) {
    const home = os.homedir();
    if (path.startsWith(home)) {
        return `~${path.slice(home.length)}`;
    }
    return path;
}
//# sourceMappingURL=tool-execution-types.js.map