# kcode-k1-chat-codex-codec
Concrete K1/Codex codec consumed only by `kcode-k1-chat-thread-main-actor`.
## Public contract
```rust
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Call { pub name: String, pub arguments: String }
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum BoxValue { History(String), Call(Result<Call, String>) }
#[derive(Default)]
pub struct Codec;
impl kcode_k1_codex_adapter::BoxCodec for Codec {
type Box = BoxValue;
}
pub fn project(box_: &kcode_k1_chat_chatend::ChatBox) -> BoxValue;
```
`Codec::tool_call_box` accepts only a typed `call_ktool` wrapper whose JSON arguments are exactly `name` (a string) and `arguments` (any JSON value). It returns a validation error in `BoxValue::Call` for every malformed wrapper and never panics. Inner arguments use deterministic JSON serialization.
`Codec::box_text` returns the complete history string and returns an empty string for calls. `project` produces the canonical one-object JSON history representation for a K1 chat box. Each operation is linear in the size of the text or JSON it processes for the main actor's practical single-box workload.