import { t as invariant } from "./invariant-vgHWClmd.js";
import { l as isLoggedIntoCloud } from "./accounts-Dz-Gsg_B.js";
import { i as REDTEAM_SIMULATED_USER_TASK_ID } from "./promptfoo-BeKIARFw.js";
import { t as SimulatedUser } from "./simulatedUser-BDdOHD-S.js";
import { d as messagesToRedteamHistory, s as getLastMessageContent } from "./shared-BH_KHSpG.js";
//#region src/redteam/providers/mischievousUser.ts
const PROVIDER_ID = "promptfoo:redteam:mischievous-user";
var RedteamMischievousUserProvider = class extends SimulatedUser {
	taskId = REDTEAM_SIMULATED_USER_TASK_ID;
	constructor(config) {
		invariant(config.injectVar, "Expected injectVar to be set");
		let maxTurns = config.maxTurns ?? 5;
		if (!isLoggedIntoCloud()) maxTurns = Math.min(maxTurns, 10);
		super({
			id: PROVIDER_ID,
			config: {
				instructions: `{{${config.injectVar}}}`,
				maxTurns,
				stateful: config.stateful ?? false
			}
		});
	}
	id() {
		return PROVIDER_ID;
	}
	serializeOutput(messages, tokenUsage, finalTargetResponse, sessionId) {
		const finalPrompt = getLastMessageContent(messages, "user") || "";
		return {
			output: getLastMessageContent(messages, "assistant") || "",
			prompt: finalPrompt,
			tokenUsage,
			metadata: {
				redteamFinalPrompt: finalPrompt,
				messages,
				redteamHistory: messagesToRedteamHistory(messages),
				sessionId
			},
			guardrails: finalTargetResponse?.guardrails,
			sessionId
		};
	}
};
//#endregion
export { RedteamMischievousUserProvider as default };

//# sourceMappingURL=mischievousUser-DhiirHJU.js.map