"use strict";
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 });
const assert = __importStar(require("assert"));
const child_process = __importStar(require("child_process"));
const path = __importStar(require("path"));
const InstallModules_1 = require("./cli/InstallModules");
function runCli(args) {
    return child_process.spawnSync(process.execPath, [path.join(__dirname, 'index.js'), ...args], {
        cwd: path.join(__dirname, '..'),
        encoding: 'utf-8',
        env: { ...process.env, OPENLIFE_DISABLE_CHAT_TUI: '1' },
        timeout: 5000,
    });
}
function main() {
    const cli = runCli(['chat', '--test']);
    assert.strictEqual(cli.status, 0, `chat --test should exit 0, stderr=${cli.stderr}, stdout=${cli.stdout}`);
    assert.match(cli.stdout, /OPENLIFE_CHAT_SMOKE_OK/, 'chat --test should print stable smoke marker');
    assert.match(cli.stdout, /sessionId=/, 'chat --test should surface session context');
    assert.match(cli.stdout, /model=/, 'chat --test should surface active model context');
    const smoke = (0, InstallModules_1.chatSmoke)(path.join(__dirname, '..'));
    assert.strictEqual(smoke.ok, true, smoke.detail);
    assert.match(smoke.detail, /OPENLIFE_CHAT_SMOKE_OK/, 'installer chatSmoke should call the real chat test path');
    console.log('TEST_CHAT_SMOKE_COMMAND_OK');
}
main();
