//#region src/session/reset-triggers.ts
/** Default reset triggers (OpenClaw-aligned). */
const DEFAULT_RESET_TRIGGERS = ["/new", "/reset"];
/** Strip gateway/channel envelope prefix e.g. `[Jun 4 17:35] `. */
function stripLeadingEnvelopeTimestamp(body) {
	return body.replace(/^\[[^\]]+\]\s*/, "");
}
/**
* Match configured reset triggers against inbound body (case-insensitive trigger,
* preserve tail casing). Mirrors OpenClaw `initSessionState` reset-trigger loop.
*/
function matchResetTriggers(body, triggers) {
	const normalized = stripLeadingEnvelopeTimestamp(body.trim());
	const lower = normalized.toLowerCase();
	for (const trigger of triggers) {
		const trimmedTrigger = trigger.trim();
		if (!trimmedTrigger) continue;
		const triggerLower = trimmedTrigger.toLowerCase();
		if (lower === triggerLower) return {
			resetTriggered: true,
			bodyStripped: "",
			matchedTrigger: trimmedTrigger,
			bareReset: true
		};
		const prefix = `${triggerLower} `;
		if (lower.startsWith(prefix)) {
			const rest = normalized.slice(trimmedTrigger.length).trimStart();
			return {
				resetTriggered: true,
				bodyStripped: rest,
				matchedTrigger: trimmedTrigger,
				bareReset: rest.length === 0
			};
		}
	}
	return {
		resetTriggered: false,
		bodyStripped: body,
		bareReset: false
	};
}
function resolveResetTriggers(configured) {
	if (configured?.length) return configured;
	return DEFAULT_RESET_TRIGGERS;
}
function bareResetAckMessage(matchedTrigger) {
	if ((matchedTrigger ?? "").toLowerCase().includes("reset")) return "✅ Session reset.";
	return "✅ New session started.";
}
/** Slash command names that overlap reset triggers — skip when init already reset. */
const RESET_OVERLAP_COMMANDS = new Set([
	"new",
	"reset",
	"restart"
]);
function shouldSkipResetOverlapCommand(command, resetTriggered) {
	if (!resetTriggered || !command) return false;
	return RESET_OVERLAP_COMMANDS.has(command.toLowerCase());
}
//#endregion
export { DEFAULT_RESET_TRIGGERS, RESET_OVERLAP_COMMANDS, bareResetAckMessage, matchResetTriggers, resolveResetTriggers, shouldSkipResetOverlapCommand, stripLeadingEnvelopeTimestamp };

//# sourceMappingURL=reset-triggers.js.map