kcode-k1-chat-web-code-output 0.1.0

Pure model-facing outputs for K1 Chat Web-code tasks
Documentation
# K1 Chat Web-code output 0.1.0

`kcode-k1-chat-web-code-output` is a pure leaf that builds model-facing Web-code tool outputs. It performs no I/O, state management, history lookup, Box ID resolution, authorization, persistence, retry, publication, service work, or projection.

## Public API

`WebCodeOutput` is cloneable and contains the originating `ToolCallId`, caller-supplied ordered `Vec<String>` messages, the complete caller-supplied terminal `Result<String, String>`, and owned metadata type and compact JSON metadata contents.

The pure builders are:

- `docs(tool_call_id, messages, result, authority, name, version)`
- `open(tool_call_id, messages, result, authority, name, version, language, code_message_count)`
- `overwrite(tool_call_id, messages, result, box_id, part)`
- `check_success(tool_call_id, messages, result)`
- `check_failed(tool_call_id, messages, result, diagnostics)`
- `publish(tool_call_id, messages, result, source_object, winning, submitted, check, status)`
- `error(tool_call_id, messages, result, operation, code, source_object)`

`Language` is the protocol crate's typed `javascript | html | css` value. `DocumentPart` serializes as `documentation | code`. `PublishCheck` serializes as `reused_same_session | fresh`; `PublishStatus` serializes as `published | idempotent | conflict`. `Operation` maps exactly to the five protocol metadata type constants. Callers must supply a canonical decimal `box_id` and a stable snake_case error `code`.

## Metadata schemas

Fields are serialized in the declaration order shown, as compact JSON without whitespace or a trailing newline. Documentation and code payloads remain in ordered messages and never appear in metadata.

- docs (`k1.web-code-docs/v1`): `{"status":"found","authority":string,"name":string,"version":string}`
- open (`k1.web-code-open/v1`): `{"status":"opened","authority":string,"name":string,"version":string,"language":"javascript|html|css","documentation_message_index":1,"code_message_start":2,"code_message_count":integer}`
- overwrite (`k1.web-code-overwrite/v1`): `{"status":"overwritten","box_id":string,"part":"documentation|code"}`
- successful check (`k1.web-code-check/v1`): `{"status":"success","fresh":true}`
- failed check (`k1.web-code-check/v1`): `{"status":"failed","diagnostics":string}`
- publish (`k1.web-code-publish/v1`): `{"status":"published|idempotent|conflict","source_object":string,"winning":string,"submitted":string|null,"check":"reused_same_session|fresh"}`
- error (the selected operation's metadata type): `{"status":"error","code":string,"source_object":string|null}`

Building metadata is linear in the UTF-8 bytes serialized into JSON and allocates the resulting metadata string. Moving the tool call ID, messages, and result is constant time; their payloads are not copied by the builder. No benchmark or fixed allocation bound is claimed.