import { parseContextWindowValue } from "../../core/context-window.js";
export function createRpcSuccessResponse(id, command, data) {
    if (data === undefined) {
        return { id, type: "response", command, success: true };
    }
    return { id, type: "response", command, success: true, data };
}
export function createRpcErrorResponse(id, command, message) {
    return { id, type: "response", command, success: false, error: message };
}
export function formatRpcErrorMessage(error) {
    return error instanceof Error ? error.message : String(error);
}
export function parseRpcContextWindow(value) {
    if (typeof value === "number") {
        return value;
    }
    if (typeof value === "string") {
        const parsed = parseContextWindowValue(value);
        if (parsed.value !== undefined) {
            return parsed.value;
        }
        throw new Error(parsed.error ?? "Invalid context window");
    }
    throw new Error("Context window must be a number of tokens or a compact value like 400k or 1m");
}
//# sourceMappingURL=rpc-responses.js.map