"use strict";
/**
 * Claude output parsing utilities
 * Shared between webhook handlers and polling logic
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseClaudeOutput = parseClaudeOutput;
const LOG_FILE_REGEX = /📄 Session log: (.+?\/([^\/\s]+\.jsonl))/;
const REQUEST_ID_REGEX = /Request ID: ([^\s\n]+)/;
const SUMMARY_REGEX = /Summary: (.+?)(?:\n─|$)/s;
/**
 * Parse Claude CLI output and extract metadata that the UI relies on.
 *
 * @param output Raw tmux capture string
 */
function parseClaudeOutput(output) {
    const result = {
        content: output,
    };
    const logFileMatch = LOG_FILE_REGEX.exec(output);
    if (logFileMatch) {
        result.logFileName = logFileMatch[2];
    }
    const requestIdMatch = REQUEST_ID_REGEX.exec(output);
    if (requestIdMatch) {
        result.requestId = requestIdMatch[1];
    }
    const summaryMatch = SUMMARY_REGEX.exec(output);
    if (summaryMatch) {
        result.summary = summaryMatch[1].trim();
    }
    return result;
}
