//#region src/domains/run/utils/json-postprocessor.ts
/**
* Simple post-processor to clean up common LLM JSON formatting issues
*/
function stripJsonCodeBlocks(text) {
	return text.trim().replace(/^```json\s*/is, "").replace(/^```\s*/s, "").replace(/\s*```$/s, "").replace(/^```json\s*([\s\S]*?)\s*```$/i, "$1").replace(/^```\s*([\s\S]*?)\s*```$/i, "$1").trim();
}
/**
* Configuration helper to add JSON post-processing to structured output generateText calls
*/
function withJsonPostProcessing(config) {
	return {
		...config,
		experimental_transform: (text) => stripJsonCodeBlocks(text)
	};
}

//#endregion
export { stripJsonCodeBlocks, withJsonPostProcessing };