//#region src/session/user-round-delete.ts
function isUserRole(role) {
	return role === "user";
}
/**
* LLM transcript range for one user turn: the user row plus every following
* assistant / tool / toolResult row until the next user (or EOF).
*/
function computeUserRoundDeleteRange(messages, userRoundIndex) {
	if (userRoundIndex < 0 || messages.length === 0) return null;
	let userCount = 0;
	let startIndex = -1;
	for (let i = 0; i < messages.length; i++) {
		if (!isUserRole(String(messages[i]?.role ?? ""))) continue;
		if (userCount === userRoundIndex) {
			startIndex = i;
			break;
		}
		userCount += 1;
	}
	if (startIndex < 0) return null;
	let end = startIndex + 1;
	while (end < messages.length) {
		if (isUserRole(String(messages[end]?.role ?? ""))) break;
		end += 1;
	}
	return {
		startIndex,
		count: end - startIndex
	};
}
//#endregion
export { computeUserRoundDeleteRange };

//# sourceMappingURL=user-round-delete.js.map