"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 fs = __importStar(require("fs"));
const os = __importStar(require("os"));
const path = __importStar(require("path"));
const DreamGoalStore_1 = require("./orchestrator/DreamGoalStore");
const Gateway_1 = require("./orchestrator/Gateway");
async function main() {
    const root = fs.mkdtempSync(path.join(os.tmpdir(), 'openlife-dream-goal-'));
    process.env.OPENLIFE_STATE_DIR = path.join(root, '.openlife');
    process.env.OPENLIFE_TELEGRAM_ALLOWED_USER_ID = '';
    process.env.OPENLIFE_TTS_ENABLED = 'off';
    const store = new DreamGoalStore_1.DreamGoalStore(process.env.OPENLIFE_STATE_DIR);
    const dream = store.setDream('Construir o OpenLife como sistema operacional de agentes autônomos.');
    assert.equal(dream.kind, 'dream');
    assert.ok(dream.value.includes('sistema operacional'));
    assert.ok(fs.existsSync(path.join(process.env.OPENLIFE_STATE_DIR, 'dream-goal.json')));
    const goal = store.setGoal('Implementar /dream e /goal no Telegram.');
    assert.equal(goal.kind, 'goal');
    assert.ok(goal.value.includes('/dream'));
    const summary = store.summary();
    assert.ok(summary.includes('Dream atual'));
    assert.ok(summary.includes('Goal atual'));
    const gateway = new Gateway_1.Gateway();
    const dreamResp = await gateway.processTextForTest('1344110010', '/dream Criar um AIOBUILDER que transforma sonhos em planos executáveis.');
    assert.match(dreamResp, /Dream registrado/i);
    assert.match(dreamResp, /AIOBUILDER/);
    const goalResp = await gateway.processTextForTest('1344110010', '/goal Entregar comandos slash persistentes no OpenLife.');
    assert.match(goalResp, /Goal registrado/i);
    assert.match(goalResp, /comandos slash/);
    const statusResp = await gateway.processTextForTest('1344110010', '/goal');
    assert.match(statusResp, /Goal atual/i);
    assert.match(statusResp, /comandos slash/);
    const dreamStatus = await gateway.processTextForTest('1344110010', '/dream');
    assert.match(dreamStatus, /Dream atual/i);
    assert.match(dreamStatus, /AIOBUILDER/);
    console.log('DREAM_GOAL_COMMANDS_OK');
}
main().catch((err) => {
    console.error(err);
    process.exit(1);
});
