---
url: 'https://adk.nht.io/api/@nhtio/adk/batteries/type-aliases/CodecMode.md'
description: >-
  Serialization strategy for a single method/stream call's arguments — see
  `codec.ts` for the tiered codec this selects. `'auto'` (the default when
  omitted) traverses each argument and escalates only the exotic leaves it
  finds; `'raw'` skips traversal entirely (trust the caller — cheapest, but
  unsafe for values containing functions/Errors/custom-encodables); `'encoded'`
  whole-value encodes every argument via the optional `@nhtio/encoder` peer. A
  caller may also inject a literal
---

# Type Alias: CodecMode

```ts
type CodecMode =
  | "auto"
  | "raw"
  | "encoded"
  | {
      decode: (encoded: string) => unknown | Promise<unknown>;
      encode: (value: unknown) => string | Promise<string>;
    };
```

Defined in: [src/batteries/isolation/types.ts:30](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/isolation/types.ts#L30)

Serialization strategy for a single method/stream call's arguments — see `codec.ts` for the tiered
codec this selects. `'auto'` (the default when omitted) traverses each argument and escalates only
the exotic leaves it finds; `'raw'` skips traversal entirely (trust the caller — cheapest, but unsafe
for values containing functions/Errors/custom-encodables); `'encoded'` whole-value encodes every
argument via the optional `@nhtio/encoder` peer. A caller may also inject a literal `{ encode, decode
}` pair to bring their own codec, bypassing both the traversal and the encoder peer entirely.

## Union Members

`"auto"`

***

`"raw"`

***

`"encoded"`

***

### Type Literal

```ts
{
  decode: (encoded: string) => unknown | Promise<unknown>;
  encode: (value: unknown) => string | Promise<string>;
}
```

| Name       | Type                                                         | Description                                                                                | Defined in                                                                                                                      |
| ---------- | ------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------- |
| `decode()` | (`encoded`: `string`) => `unknown` | `Promise`<`unknown`> | Reconstruct a value from a string produced by this codec's `encode`. May be sync or async. | [src/batteries/isolation/types.ts:38](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/isolation/types.ts#L38) |
| `encode()` | (`value`: `unknown`) => `string` | `Promise`<`string`>    | Serialize a single value to a wire-safe string. May be sync or async.                      | [src/batteries/isolation/types.ts:36](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/batteries/isolation/types.ts#L36) |
