import { t as invariant } from "./invariant-D3duWnAm.js";
import { s as isLoggedIntoCloud } from "./accounts-B1w_ge6E.js";
import { i as REDTEAM_SIMULATED_USER_TASK_ID } from "./promptfoo-BWD23-aj.js";
import { t as SimulatedUser } from "./simulatedUser-8a58f3Yx.js";
import { d as messagesToRedteamHistory, s as getLastMessageContent } from "./shared-Bi98VsZS.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-HOfxMGi_.js.map