#!/usr/bin/env node
//#region src/util/providerResponse.ts
/**
* Extracts the actual prompt from a ProviderResponse as a string.
*
* Priority chain:
* 1. response.prompt (provider-reported) - takes precedence
* 2. metadata.redteamFinalPrompt (legacy) - fallback for older redteam results
* 3. undefined if neither is set
*
* If the prompt is an array of chat messages, it will be JSON stringified.
*
* @param response - The provider response object
* @param options - Optional configuration
* @param options.formatted - If true, JSON stringify with indentation for display (default: false)
* @returns The actual prompt as a string, or undefined if not available
*/
function getActualPrompt(response, options = {}) {
	if (!response) return;
	if (response.prompt !== void 0) {
		if (typeof response.prompt === "string") return response.prompt || void 0;
		if (Array.isArray(response.prompt) && response.prompt.length > 0) return options.formatted ? JSON.stringify(response.prompt, null, 2) : JSON.stringify(response.prompt);
		return;
	}
	return response.metadata?.redteamFinalPrompt;
}
/**
* Gets the actual prompt with fallback to the original rendered prompt.
*
* Priority chain:
* 1. response.prompt (provider-reported)
* 2. metadata.redteamFinalPrompt (legacy)
* 3. originalPrompt (the rendered template)
*
* @param response - The provider response object
* @param originalPrompt - The original rendered prompt template
* @param options - Optional configuration
* @returns The actual prompt as a string
*/
function getActualPromptWithFallback(response, originalPrompt, options = {}) {
	return getActualPrompt(response, options) || originalPrompt;
}
//#endregion
export { getActualPromptWithFallback as n, getActualPrompt as t };

//# sourceMappingURL=providerResponse-DZhb1T_7.js.map