"use strict";
/**
 * Copyright: (c) Myia SAS 2026.
 * This file and its contents are licensed under the AGPLv3 License.
 * Please see the LICENSE file at the root of this repository
 */
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.SystemInfoAdapter = void 0;
// SystemInfoAdapter — default SystemInfoProvider implementation.
//
// Reads per-process technical state once: Node version, platform,
// arch, hostname, CI flag, cwd, pid, and the current git SHA
// (best-effort; empty when not a git repo). All values are captured
// eagerly at construction so repeated calls are free and the shell
// out to `git rev-parse HEAD` happens at most once per process.
//
// Tests do NOT use this adapter — they pass a stub implementing
// SystemInfoProvider with fixed values for deterministic assertions.
const os = __importStar(require("os"));
const child_process_1 = require("child_process");
class SystemInfoAdapter {
    constructor() {
        this.info = {
            pid: process.pid,
            nodeVersion: process.versions.node,
            platform: process.platform,
            arch: process.arch,
            hostname: os.hostname(),
            isCI: !!process.env.CI,
            cwd: process.cwd(),
            gitSha: SystemInfoAdapter.readGitSha(),
        };
    }
    getStaticContext() {
        return this.info;
    }
    static readGitSha() {
        try {
            return (0, child_process_1.execSync)('git rev-parse HEAD', {
                stdio: ['ignore', 'pipe', 'ignore'],
            })
                .toString()
                .trim();
        }
        catch (_) {
            return undefined;
        }
    }
}
exports.SystemInfoAdapter = SystemInfoAdapter;
