import { HostTransport } from './host.js';
import { resolveEmbeddedCliBinary } from './embedded-cli.js';
/**
 * Internal runtime that delegates CLI invocations to a persistent host transport.
 *
 * Resolves the CLI binary and creates a {@link HostTransport} that communicates
 * with a long-lived `superdoc host --stdio` process.
 */
export class SuperDocRuntime {
    transport;
    constructor(options = {}) {
        const cliBin = options.env?.SUPERDOC_CLI_BIN ?? process.env.SUPERDOC_CLI_BIN ?? resolveEmbeddedCliBinary();
        this.transport = new HostTransport({
            cliBin,
            ...options,
        });
    }
    async connect() {
        await this.transport.connect();
    }
    async dispose() {
        await this.transport.dispose();
    }
    async invoke(operation, params = {}, options = {}) {
        return this.transport.invoke(operation, params, options);
    }
}
