//#region src/agent/transcript/thinking.ts
function isAssistantMessageWithContent(message) {
	return !!message && typeof message === "object" && message.role === "assistant" && Array.isArray(message.content);
}
/**
* Strip all `type: "thinking"` content blocks from assistant messages.
*
* If an assistant message becomes empty after stripping, it is replaced with
* a synthetic `{ type: "text", text: "" }` block to preserve turn structure
* (some providers require strict user/assistant alternation).
*
* Returns the original array reference when nothing was changed (callers can
* use reference equality to skip downstream work).
*/
function dropThinkingBlocks(messages) {
	let touched = false;
	const out = [];
	for (const msg of messages) {
		if (!isAssistantMessageWithContent(msg)) {
			out.push(msg);
			continue;
		}
		const nextContent = [];
		let changed = false;
		for (const block of msg.content) {
			if (block && typeof block === "object" && block.type === "thinking") {
				touched = true;
				changed = true;
				continue;
			}
			nextContent.push(block);
		}
		if (!changed) {
			out.push(msg);
			continue;
		}
		const content = nextContent.length > 0 ? nextContent : [{
			type: "text",
			text: ""
		}];
		out.push({
			...msg,
			content
		});
	}
	return touched ? out : messages;
}
//#endregion
export { dropThinkingBlocks, isAssistantMessageWithContent };

//# sourceMappingURL=thinking.js.map