import { logger } from "../../logger.js";
function summarise(systemPrompt) {
    const raw = typeof systemPrompt === "string"
        ? systemPrompt
        : `[preset:${systemPrompt.preset}]${systemPrompt.append ? "\n" + systemPrompt.append : ""}`;
    const fullOneLine = raw.replace(/\n/g, "\\n");
    let presetLabel;
    if (typeof systemPrompt === "string") {
        presetLabel = "none";
    }
    else {
        const appendLen = systemPrompt.append?.length ?? 0;
        presetLabel = `preset=${systemPrompt.preset} append=${appendLen}`;
    }
    return { length: fullOneLine.length, presetLabel, fullOneLine };
}
/**
 * Head + tail preview with an elided middle, e.g.
 *   `# Identity\n\nYou are duwan-… [+9672 chars] …Asia/Shanghai)\n`
 *
 * Keeps the console line short while still showing the opening identity block
 * and the trailing section. The system prompt is now time-agnostic (wall-clock
 * is in the wake-context user message), so the tail rarely changes between
 * wake cycles — but it's still useful for spotting config-driven diffs.
 */
function headTailPreview(oneLine, head = 100, tail = 100) {
    if (oneLine.length <= head + tail + 20)
        return oneLine;
    const start = oneLine.slice(0, head).trimEnd();
    const end = oneLine.slice(-tail).trimStart();
    const elided = oneLine.length - start.length - end.length;
    return `${start}… [+${elided} chars] …${end}`;
}
/**
 * Emit a `system_prompt` log entry. The console line is a compact summary
 * (length, preset, head/tail preview); the JSONL log entry keeps the original
 * full prompt in `message` so downstream training-data extraction remains
 * lossless.
 */
export function logSystemPrompt(systemPrompt) {
    const { length, presetLabel, fullOneLine } = summarise(systemPrompt);
    const preview = headTailPreview(fullOneLine);
    const consolePreview = `len=${length} ${presetLabel} | ${preview}`;
    logger.log("info", "system_prompt", fullOneLine, { consolePreview });
}
//# sourceMappingURL=system-prompt-log.js.map