import { createEntitySession } from './session.js';
function send(msg) {
    process.send?.(msg);
}
let abortController;
process.on('message', async (msg) => {
    if (msg.type === 'abort') {
        abortController?.abort();
        return;
    }
    if (msg.type !== 'start')
        return;
    try {
        abortController = new AbortController();
        const session = await createEntitySession({
            ...msg.options,
            signal: abortController.signal,
            onProgress: (event) => {
                send({ type: 'progress', event });
            },
        });
        await session.dispose();
        send({ type: 'ready' });
    }
    catch (err) {
        const error = err instanceof Error ? err : new Error(String(err));
        if (error.name === 'AbortError')
            send({ type: 'aborted' });
        else
            send({ type: 'error', message: error.message, name: error.name });
    }
    process.disconnect?.();
});
//# sourceMappingURL=isolated-runner.js.map