// Shared JSON-ish parsing helpers
import { parseLenientJsonishWithNative, repairArgumentsToStringWithNative } from '../router/virtual-router/engine-selection/native-shared-conversion-semantics.js';
export function tryParseJson(s) {
    if (typeof s !== 'string')
        return s;
    try {
        return JSON.parse(s);
    }
    catch {
        return s;
    }
}
// Lenient parsing for function.arguments often produced by models
export function parseLenient(value) {
    return parseLenientJsonishWithNative(value);
}
// CCR-style repair: JSON -> JSON5-like cleanup -> safe fallback
export function repairArgumentsToString(value) {
    return repairArgumentsToStringWithNative(value);
}
