> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mirurobotics.com/llms.txt
> Use this file to discover all available pages before exploring further.

# CUE

export const Framed = ({image, background, link, alt = "Framed content", borderWidth = "24px", outerRadius = "10px", innerRadius = "6px"}) => {
  const parseShorthand = value => {
    const values = String(value).trim().split(/\s+/);
    switch (values.length) {
      case 1:
        return [values[0], values[0], values[0], values[0]];
      case 2:
        return [values[0], values[1], values[0], values[1]];
      case 3:
        return [values[0], values[1], values[2], values[1]];
      default:
        return values.slice(0, 4);
    }
  };
  const isZero = v => parseFloat(v) === 0;
  const padding = parseShorthand(borderWidth);
  const outer = parseShorthand(outerRadius);
  const cornerMasks = [];
  if (isZero(padding[0]) && isZero(padding[3])) {
    cornerMasks.push(`radial-gradient(circle at 0% 0%, transparent ${outer[0]}, black ${outer[0]})`);
  }
  if (isZero(padding[0]) && isZero(padding[1])) {
    cornerMasks.push(`radial-gradient(circle at 100% 0%, transparent ${outer[1]}, black ${outer[1]})`);
  }
  if (isZero(padding[2]) && isZero(padding[1])) {
    cornerMasks.push(`radial-gradient(circle at 100% 100%, transparent ${outer[2]}, black ${outer[2]})`);
  }
  if (isZero(padding[2]) && isZero(padding[3])) {
    cornerMasks.push(`radial-gradient(circle at 0% 100%, transparent ${outer[3]}, black ${outer[3]})`);
  }
  const backgroundMask = cornerMasks.length > 0 ? cornerMasks.join(", ") : undefined;
  const innerImage = <img src={image} alt={alt} noZoom={link ? true : false} style={{
    display: "block",
    width: "100%",
    margin: 0,
    borderRadius: 0
  }} />;
  return <div style={{
    display: "inline-block",
    position: "relative",
    borderRadius: outerRadius,
    overflow: "hidden"
  }}>
            {}
            {background && <div style={{
    position: "absolute",
    inset: 0,
    backgroundImage: `url(${background})`,
    backgroundSize: "cover",
    maskImage: backgroundMask,
    WebkitMaskImage: backgroundMask,
    maskComposite: "intersect",
    WebkitMaskComposite: "source-in"
  }} />}
            {}
            <div style={{
    position: "relative",
    padding: borderWidth
  }}>
                <div style={{
    borderRadius: innerRadius,
    overflow: "hidden",
    lineHeight: 0
  }}>
                    {link ? <a href={link}>{innerImage}</a> : innerImage}
                </div>
            </div>
        </div>;
};

<Framed image="https://assets.mirurobotics.com/docs/v04/images/schema-langs/cue/website.png" link="https://cuelang.org/" borderWidth={"0px"} />

[CUE](https://cuelang.org/) (Configure, Unify, Execute) is another well-regarded schema language, useful for defining valid fields, types, and values for a config.

CUE was developed at Google by Marcel van Lohuizen, one of the original creators of Go. The original motivation stemmed from Google's internal struggles in managing complex, large-scale configurations for infrastructure and applications. JSON and YAML were too weak for expressing constraints, logic, or composition, so CUE set out to solve that.

Instead of building and managing external tools to validate, patch, or generate configs, CUE itself is a fully programmable config engine. This means CUE wholly encapsulates the configuration data, the schema, and the logic (how to derive those config values).

## Example

Below is an example CUE schema:

```cue CUE expandable theme={null}
@miru(config_type="communication")

control_loop_rate_hz: number & >=1 & <=1000 | *50
watchdog_timeout_ms: number & >=100 & <=5000 | *500

network: {
	max_latency_ms: number & >=10 & <=1000 | *100
	connection_timeout_ms: number & >=100 & <=10000 | *2000
	reconnect_attempts: number & >=1 & <=10 | *3
	reconnect_interval_ms: number & >=100 & <=5000 | *1000
	heartbeat_interval_ms: number & >=50 & <=1000 | *250
}

logging: {
	enable_packet_logging: bool | *true
	log_level: "debug" | "info" | "warn" | "error" | *"info"
	max_log_size_mb: number & >=1 & <=1024 | *100
	retain_logs_days: number & >=1 & <=90 | *30
}

error_handling: {
	max_consecutive_failures: number & >=1 & <=20 | *5
	failure_timeout_ms: number & >=100 & <=30000 | *5000
	enable_auto_recovery: bool | *true
}
```

Although many of CUE's capabilities are omitted in this example, you'll find some of the most commonly used features, including:

* type specification - `number`, `string`, `bool`, etc.
* numeric constraints- `>=`, `<=`, `==`, `!=`, `=~`, `!~`, etc.
* default values - `| *value`
* enumerations - `| "value1" | "value2" | "value3"`
* intersection of constraints - `&`

As you can see, CUE inlines constraints directly with type definitions, making schemas significantly more concise than JSON Schema. For more information on the supported features of CUE, check out the [CUE tour](https://cuelang.org/docs/tour/) on the official CUE website.

## CUE version

Miru fully supports CUE and stays up to date with the latest CUE features and syntax. Currently, Miru uses CUE API [`v0.14.2`](https://github.com/cue-lang/cue/releases/tag/v0.14.2).

## File formats

Unlike JSON Schema, CUE can only be written in the CUE file format and must have the `.cue` extension:

* **CUE** (`.cue`)

Similar to JSON Schema, CUE schemas can validate config instances in formats other than CUE. The following formats are supported:

* **JSON** (`.json`)
* **YAML** (`.yaml`, `.yml`)

<Note>
  YAML support requires Miru Agent **v0.7.0** or newer
</Note>

## CUE packages

[CUE](/cfg-mgmt/primitives/schemas/languages/cue) supports the concept of a [package](https://cuelang.org/docs/tour/packages/packages/)—a way to spread a schema's definition across multiple files.

For example, say we have a `communication` schema which contains the following files:

<Tree.Folder name="communication" defaultOpen>
  <Tree.File name="peripherals.cue" />

  <Tree.File name="network.cue" />

  <Tree.File name="sensors.cue" />

  <Tree.File name="main.cue" />
</Tree.Folder>

Each file defines a portion of the schema, which is then aggregated by the `main.cue` file to define the schema. Miru fully supports CUE packages, treating the `communication` directory as a single schema.

**Identifying packages**

The Miru CLI automatically identifies CUE packages for you when creating a release using the `package` clause at the top of each schema file (as described in the [CUE documentation](https://cuelang.org/docs/tour/packages/packages/)).

You don't need to explicitly specify the package in the CLI command—just provide the path to the package directory or to the individual schema files within the package.

**Annotations**

To annotate a CUE package, annotate **exactly one file** in the package. Annotating multiple files or no files will result in an error.
