/** * Robust JSON parsing for LLM responses. * * LLM 응답은 다음 같은 변형이 흔하다: * - 마크다운 코드펜스로 감싸짐 (```json ... ```) * - 앞뒤 자연어 코멘트 ("Sure, here is: { ... }") * - 끝에 trailing 문자 (Gemini 의 알려진 케이스: 닫는 } 가 한 번 더) * - smart quote 등의 사소한 변형 * * 이 helper 는: * 1) 코드펜스를 제거 * 2) 첫 balanced JSON object/array 만 잘라냄 (brace counting + 문자열 인지) * 3) 그래도 실패하면 raw 출력 포함한 명확한 에러 */ /** * The model answered, and the answer is not JSON (figure audit 2026-10-16 N2). Told apart from a request that failed -- * a rejected key, a rate limit, a dropped connection -- because only this is worth asking again, with why it was not. * `cutShort`: the answer stopped at the output limit before it ended, so asking again for the same is cut off again. */ export declare class AIAnswerNotJSON extends Error { readonly cutShort: boolean; constructor(message: string, cutShort?: boolean); } export declare function parseJSONResponse(text: string, { cutShort }?: { cutShort?: boolean; }): T; /** * 첫 balanced { ... } 또는 [ ... ] 추출. * 문자열 내의 brace 는 무시. escape 처리. */ export declare function extractFirstBalanced(text: string): string | null;