/** * Response formatting + error detection utilities (Phase 1 of tool-discovery migration). * * 对标 unity-mcp-server/src/response-format.js(2026-08-10 深挖报告): * - compactStringify:默认紧凑 JSON,省 20-50% token(对标 unity PRETTY 开关) * - firstSentence:lean discovery 视图的一句话摘要(对标 unity firstSentence) * - looksLikeErrorObject / isErrorText:统一逻辑失败识别(对标 unity looksLikeErrorObject) * * 本模块是纯函数集合,无副作用,无外部依赖,便于单测。 */ /** * 紧凑序列化(默认),对齐 unity response-format.js:22。 * 设 GODOT_MCP_PRETTY_JSON=1 时输出缩进格式(调试用)。 */ export declare function compactStringify(value: unknown): string; /** * 取文本的第一句话(lean discovery 视图用),对齐 unity response-format.js:74-93。 * * 规则: * - 找第一个 ". "(句点+空格)作为句子边界,但跳过 "e.g." / "i.e." 这类缩写 * - 超过 160 字符截断并加 "..." * - 中文无 ". " 句号时返回全文(超 160 才截),兼容中文描述 * * 返回 undefined 当输入为 undefined/null/空串。 */ export declare function firstSentence(text: string | undefined | null): string | undefined; /** * 判断一个对象是否"看起来像错误",对齐 unity response-format.js:31-41。 * * 识别的 shape(godot opsError + unity 兼容): * - {success: false} 或 {ok: false} → true * - {error: "string"} 或 {error: {message: "string"}} → true(unity 形态) * - {error_code, message} 且无 success → true(godot advanced-proxy 形态,M1 收紧:需 error_code 共存) * - {success: true} 或 {ok: true} → false(显式成功优先,状态查询类带 error 字段但成功不算失败) * * @param obj 待检测对象(非对象/数组返回 false) */ export declare function looksLikeErrorObject(obj: unknown): boolean; /** * 判断一段文本是否表示错误,对齐 unity response-format.js:102-119。 * * 识别三类: * 1. JSON 对象 → looksLikeErrorObject * 2. 桥接 envelope:外层非错误但内层 data 是错误(unity 桥接包装) * 3. 纯文本以 "Error:" 或 "Error " 开头 * * @param text 待检测文本 */ export declare function isErrorText(text: string, opts?: { checkTextPrefix?: boolean; }): boolean;