import type { BackendInfo, RunRequest, RunResult, Runner } from "./types"; import { numblVersion } from "./execute"; import { executeRequest, type GpuProvider } from "./executeGpu"; /** * Runs numbl in the current Node process. Used by tests and scripts; cannot * cancel. Pass `gpu` to run the ported time loop on a WebGPU device (the * optional `webgpu` package, Google Dawn, provides one under Node). */ export class NodeRunner implements Runner { private readonly info: BackendInfo = { engine: "numbl", version: numblVersion(), optimization: "1", host: "node", }; readonly backend = Promise.resolve(this.info); private readonly gpu?: GpuProvider; constructor(opts: { gpu?: GpuProvider } = {}) { this.gpu = opts.gpu; } run(req: RunRequest, onOutput?: (text: string) => void): Promise { return executeRequest(req, this.info, onOutput, this.gpu); } cancel(): void { /* synchronous host: nothing in flight between awaits */ } dispose(): void { /* nothing to release */ } }