# Kernel Factories
URL: /docs/api/kernels



Kernel Factories [#kernel-factories]

Use kernel factories when registering CAD engines with `createRuntimeClient`. Each factory returns a `KernelPlugin` that the client uses for kernel selection and worker loading.

Types [#types]

<TypeTable
  type={{
  "name": "KernelPlugin",
  "description": "Plugin registration for a CAD kernel.\nReturned by factory functions like `replicad()`, `opencascade()`.\n\nThe actual type includes a phantom generic for compile-time export schema\ntype safety, which is omitted here for documentation clarity.",
  "entries": [
    {
      "name": "id",
      "description": "Unique identifier for this kernel",
      "tags": [],
      "type": "string",
      "simplifiedType": "string",
      "required": true,
      "deprecated": false
    },
    {
      "name": "moduleUrl",
      "description": "URL of the kernel module (resolved via import.meta.url)",
      "tags": [],
      "type": "string",
      "simplifiedType": "string",
      "required": true,
      "deprecated": false
    },
    {
      "name": "extensions",
      "description": "File extensions this kernel handles (e.g., ['scad'], ['ts', 'js']). '*' is a catch-all.",
      "tags": [],
      "type": "string[]",
      "simplifiedType": "array",
      "required": true,
      "deprecated": false
    },
    {
      "name": "detectImport",
      "description": "Regex to match against file content for kernel selection",
      "tags": [],
      "type": "RegExp | undefined",
      "simplifiedType": "object",
      "required": false,
      "deprecated": false
    },
    {
      "name": "builtinModuleNames",
      "description": "Bare-specifier module names this kernel provides for bundler-assisted detection",
      "tags": [],
      "type": "string[] | undefined",
      "simplifiedType": "array",
      "required": false,
      "deprecated": false
    },
    {
      "name": "options",
      "description": "Kernel-specific options passed to initialize()",
      "tags": [],
      "type": "Record<string, unknown> | undefined",
      "simplifiedType": "Record<string, unknown>",
      "required": false,
      "deprecated": false
    }
  ]
}}
/>

<TypeTable
  type={{
  "name": "ReplicadOptions",
  "description": "Configuration for the Replicad kernel, controlling WASM variant, OC tracing, and edge rendering.",
  "entries": [
    {
      "name": "wasm",
      "description": "WASM build variant or custom build configuration.\n\n- `'single'` (default) -- exceptions-enabled build with human-readable OC error messages\n- `ReplicadWasmConfig` -- custom WASM/JS URLs for runtime injection (Node.js tooling)",
      "tags": [
        {
          "name": "default",
          "text": "'single'"
        }
      ],
      "type": "\"single\" | ReplicadWasmConfig | undefined",
      "simplifiedType": "ReplicadWasmConfig | \"single\"",
      "required": false,
      "deprecated": false
    },
    {
      "name": "ocTracing",
      "description": "OC API call tracing mode. 'summary' (default) emits aggregated stats, 'per-call' emits individual spans.",
      "tags": [],
      "type": "\"off\" | \"summary\" | \"per-call\" | undefined",
      "simplifiedType": "\"per-call\" | \"summary\" | \"off\"",
      "required": false,
      "deprecated": false
    },
    {
      "name": "withBrepEdges",
      "description": "Include Boundary Representation (BRep) edge lines in the generated GLTF geometry. Defaults to `false`.",
      "tags": [],
      "type": "boolean | undefined",
      "simplifiedType": "boolean",
      "required": false,
      "deprecated": false
    },
    {
      "name": "withSourceMapping",
      "description": "Load library source maps for enriched error stack traces. Adds ~50ms to init. Defaults to `false`.",
      "tags": [],
      "type": "boolean | undefined",
      "simplifiedType": "boolean",
      "required": false,
      "deprecated": false
    }
  ]
}}
/>

<TypeTable
  type={{
  "name": "OpenCascadeOptions",
  "description": "Configuration options for the OpenCascade kernel plugin.",
  "entries": [
    {
      "name": "wasm",
      "description": "",
      "tags": [],
      "type": "\"full\" | OpenCascadeWasmConfig | undefined",
      "simplifiedType": "OpenCascadeWasmConfig | \"full\"",
      "required": false,
      "deprecated": false
    }
  ]
}}
/>

<TypeTable
  type={{
  "name": "ManifoldOptions",
  "description": "Configuration for the Manifold kernel, allowing custom WASM builds for benchmarking or CI.",
  "entries": [
    {
      "name": "wasmUrl",
      "description": "Override the default Manifold WASM URL for custom builds or benchmarking.",
      "tags": [],
      "type": "string | undefined",
      "simplifiedType": "string",
      "required": false,
      "deprecated": false
    }
  ]
}}
/>

<TypeTable
  type={{
  "name": "ZooOptions",
  "description": "Zoo (KCL) kernel options.",
  "entries": [
    {
      "name": "baseUrl",
      "description": "WebSocket base URL for the Zoo engine connection. Defaults to 'wss://api.zoo.dev'.",
      "tags": [],
      "type": "string | undefined",
      "simplifiedType": "string",
      "required": false,
      "deprecated": false
    }
  ]
}}
/>

Factories [#factories]

| Factory                 | Extensions | Purpose                                             |
| ----------------------- | ---------- | --------------------------------------------------- |
| `replicad(options?)`    | `ts`, `js` | OpenCASCADE-based parametric BRep via Replicad API  |
| `opencascade(options?)` | `ts`, `js` | Direct OpenCASCADE API access                       |
| `manifold(options?)`    | `ts`, `js` | Mesh-first manifold modeling with robust booleans   |
| `openscad()`            | `scad`     | CSG modeling with OpenSCAD language                 |
| `jscad()`               | `ts`, `js` | @jscad/modeling parametric CSG                      |
| `zoo(options)`          | `kcl`      | KCL via Zoo WebSocket API                           |
| `tau()`                 | `*`        | Catch-all converter for STEP, STL, 3MF, OBJ imports |

Usage [#usage]

```typescript
import { createRuntimeClient, fromMemoryFS } from '@taucad/runtime';
import { replicad, opencascade, manifold, openscad, jscad, zoo, tau } from '@taucad/runtime/kernels';
import { esbuild } from '@taucad/runtime/bundler';

const client = createRuntimeClient({
  kernels: [
    replicad({ withBrepEdges: true }),
    opencascade(),
    manifold(),
    openscad(),
    jscad(),
    zoo({ baseUrl: 'wss://example.com/v1/kernels/zoo' }),
    tau(),
  ],
  bundlers: [esbuild()],
  fileSystem: fromMemoryFS(),
});
```

Related [#related]

* [Choose a Kernel](../guides/choosing-a-kernel)
* [Plugin System](../concepts/plugin-system)
* [Create a Custom Kernel](../guides/custom-kernel)
