# Canonical K1 chat boxes 0.2.1
`kcode-k1-chat-boxes` is the concrete value and metadata owner for K1 chat boxes.
## Contract
`BoxId`, `ToolCallId`, and `ChatBox` preserve open values exactly; familiar type constants remain conventions rather than a closed registry. `Agent Message` identifies an explicit user-facing agent message, while `Agent Response` identifies ordinary provider-generated response text.
Tool Call v1 and Tool Result v1 retain Chatend's established text and byte encoding. Tool Message v1 retains its established visible envelope, deterministic hidden encoding, and one-based message correlation. Tool Result v2 preserves every v1 field and adds opaque metadata type and contents.
Named Tool Message v2 is additive. `TOOL_MESSAGE_V2_HIDDEN_TYPE` identifies the hidden convention, and `named_tool_message_box(&ToolMessageMetadata, title)` requires a nonempty caller-supplied visible title plus a one-based message index. Its visible contents are the exact raw message with no envelope. Its hidden contents use the same deterministic five correlation fields as Tool Message v1. Decoding requires a nonempty visible title and exact equality between the visible body and hidden message, so malformed or tampered named messages fail closed. Existing Tool Message v1 bytes and APIs are unchanged.
Hidden metadata uses deterministic byte-length-prefixed UTF-8 fields. Recognized malformed conventions return `MetadataError`; unknown hidden conventions remain generic boxes.
## Boundary
This crate owns values, encoding, decoding, and owner constructors only—not append ordering, rounds, retries, recovery, state transitions, providers, or deployment.