# `@automate.ax/codec`

Msgpack-based encoding helpers for Automate.ax runtime data.

This package owns the shared `Encodable` value contract used by automation signals and storage boundaries. Most app authors should not need it directly.

## Install

```bash
bun add @automate.ax/codec
```

## Usage

```ts
import { decode, encodableSchema, encode } from "@automate.ax/codec"

const bytes = await encode({
  message: "hello",
  createdAt: new Date(),
})

const value = await decode(bytes)
const validated = encodableSchema.parse(value)
```

## API

- `encode(value)` — Checks an unknown value against the supported input surface, then serializes it.
- `decode(bytes)` — Deserializes msgpack bytes and returns `Encodable`.
- `encodableSchema` — Zod schema for validating unknown values against the supported input surface.
- `isEncodable(value)` — Runtime guard for the supported input surface.
- `Encodable` — Recursive type accepted by the encoder.

## Supported Values

`Encodable` includes primitives, arrays, plain objects, `Map`, `Set`, `Date`, `RegExp`, typed arrays, `ArrayBuffer`, `DataView`, and web platform values such as `Request`, `Response`, `Blob`, `File`, `Headers`, `URL`, and `URLSearchParams`.
