//#region src/agent/prompt/cache-boundary.ts
/**
* Prompt cache boundary — splits the system prompt into a stable prefix (cacheable
* by providers like Anthropic) and a dynamic suffix (changes per turn/session).
*
* xopc uses a system-prompt-cache-boundary pattern.
*/
const PROMPT_CACHE_BOUNDARY = "\n<!-- XOPC_CACHE_BOUNDARY -->\n";
/**
* Strip the cache boundary marker from a prompt string.
*/
function stripPromptCacheBoundary(text) {
	return text.replaceAll(PROMPT_CACHE_BOUNDARY, "\n");
}
/**
* Split a system prompt at the cache boundary.
* Returns undefined if no boundary is found.
*/
function splitPromptCacheBoundary(text) {
	const boundaryIndex = text.indexOf(PROMPT_CACHE_BOUNDARY);
	if (boundaryIndex === -1) return;
	return {
		stablePrefix: text.slice(0, boundaryIndex).trimEnd(),
		dynamicSuffix: text.slice(boundaryIndex + 30).trimStart()
	};
}
/**
* Normalize a prompt section for cache stability.
* Trims trailing whitespace per line, normalizes line endings, trims overall.
*/
function normalizePromptSection(text) {
	return text.replace(/\r\n?/g, "\n").replace(/[ \t]+$/gm, "").trim();
}
//#endregion
export { PROMPT_CACHE_BOUNDARY, normalizePromptSection, splitPromptCacheBoundary, stripPromptCacheBoundary };

//# sourceMappingURL=cache-boundary.js.map