"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WorkerThreadEvaluationListener = void 0;
const rpc_1 = require("./rpc");
const serializer_1 = require("./serializer");
class WorkerThreadEvaluationListener {
    constructor(workerRuntime, worker) {
        this.exposedListener = (0, rpc_1.exposeAll)({
            onPrompt(question, type) {
                return (workerRuntime.evaluationListener?.onPrompt?.(question, type) ?? '');
            },
            onPrint(values) {
                values = values.map(serializer_1.deserializeEvaluationResult);
                return workerRuntime.evaluationListener?.onPrint?.(values);
            },
            setConfig(key, value) {
                return (workerRuntime.evaluationListener?.setConfig?.(key, value) ??
                    Promise.resolve('ignored'));
            },
            resetConfig(key) {
                return (workerRuntime.evaluationListener?.resetConfig?.(key) ??
                    Promise.resolve('ignored'));
            },
            validateConfig(key, value) {
                return (workerRuntime.evaluationListener?.validateConfig?.(key, value) ??
                    Promise.resolve(null));
            },
            getConfig(key) {
                return workerRuntime.evaluationListener?.getConfig?.(key);
            },
            listConfigOptions() {
                return workerRuntime.evaluationListener?.listConfigOptions?.();
            },
            onClearCommand() {
                return workerRuntime.evaluationListener?.onClearCommand?.();
            },
            onExit(exitCode) {
                return (workerRuntime.evaluationListener?.onExit?.(exitCode) ??
                    Promise.resolve());
            },
            getLogPath() {
                return workerRuntime.evaluationListener?.getLogPath?.();
            },
        }, worker);
    }
    terminate() {
        this.exposedListener[rpc_1.close]();
    }
}
exports.WorkerThreadEvaluationListener = WorkerThreadEvaluationListener;
//# sourceMappingURL=worker-thread-evaluation-listener.js.map