import { o as normalizeOptionalLowercaseString } from "./string-coerce-CIT1-v_a.js";
//#region src/agents/tool-error-summary.ts
const EXEC_LIKE_TOOL_NAMES = new Set(["exec", "bash"]);
function isExecLikeToolName(toolName) {
	return EXEC_LIKE_TOOL_NAMES.has(normalizeOptionalLowercaseString(toolName) ?? "");
}
const errorAccumulatorMap = /* @__PURE__ */ new Map();
function accumulateToolError(sessionKey, details) {
	let profile = errorAccumulatorMap.get(sessionKey);
	if (!profile) {
		profile = {
			errorCount: 0,
			failedToolNames: /* @__PURE__ */ new Set(),
			hasMutatingErrors: false
		};
		errorAccumulatorMap.set(sessionKey, profile);
	}
	profile.errorCount += 1;
	profile.failedToolNames.add(details.toolName);
	if (details.mutatingAction) profile.hasMutatingErrors = true;
}
function consumeToolErrorProfile(sessionKey) {
	const profile = errorAccumulatorMap.get(sessionKey);
	if (!profile) return;
	errorAccumulatorMap.delete(sessionKey);
	return {
		errorCount: profile.errorCount,
		failedToolNames: [...profile.failedToolNames],
		hasMutatingErrors: profile.hasMutatingErrors
	};
}
//#endregion
export { consumeToolErrorProfile as n, isExecLikeToolName as r, accumulateToolError as t };
