"use strict";
// SPDX-License-Identifier: AGPL-3.0-or-later
// Copyright (C) 2024-2026 Gracker (Chris)
// This file is part of SmartPerfetto. See LICENSE for details.
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.appendTranscriptTurn = appendTranscriptTurn;
exports.appendStreamEvent = appendStreamEvent;
/**
 * Append-only JSONL writers for transcript + raw stream logs.
 *
 * Why JSONL: resilient to partial writes (each line stands alone), trivial
 * to grep/tail, and future tooling can aggregate across sessions with
 * a one-liner like `cat ~/.smartperfetto/sessions/<id>/transcript.jsonl | jq`.
 */
const fs = __importStar(require("fs"));
/** Append one serialized line to a JSONL file. Creates the file if missing. */
function appendJsonLine(filePath, obj) {
    fs.appendFileSync(filePath, `${JSON.stringify(obj)}\n`, 'utf-8');
}
function appendTranscriptTurn(transcriptFile, turn) {
    appendJsonLine(transcriptFile, turn);
}
/** Append a raw StreamingUpdate event. PR1 always writes — PR4 may add `--no-stream-log`. */
function appendStreamEvent(streamFile, event) {
    appendJsonLine(streamFile, event);
}
//# sourceMappingURL=transcriptWriter.js.map