kcode-k1-codex-runtime 0.2.1

Multiplexed Codex conversation runtime for K1
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# kcode-k1-codex-runtime
This crate combines `kcode-k1-codex-conversations` state with one shared, initialized `kcode-k1-codex-transport` app-server. Cloned `Adapter` handles multiplex persistent native threads by opaque conversation key; one key is sequential while different keys may progress concurrently.

`Adapter::open` starts the sole process and establishes its executable and working directory. `Adapter::with_config` derives another handle on that process. Derived configurations must retain the executable and working directory, but may select a different model, reasoning effort, base instructions, and dynamic-tool set. Each conversation key binds by complete configuration value on its first accepted turn and remains bound until its native thread is successfully unsubscribed. Starting or closing a bound key through a different profile fails before app-server I/O. The bound profile supplies thread instructions and tools, every turn's model and optional effort, and dynamic-tool allowlisting.

`start_turn` returns a `Turn` streaming ordered text, dynamic calls, and terminal events. Results answer the exact pending call, preserving string-versus-number JSON-RPC IDs. `Turn::try_next_event` returns the next already-buffered event without waiting, returns `Ok(None)` only when presently empty, and handles terminal events or channel disconnection consistently with the existing turn lifecycle. Dropping a live turn rejects calls and interrupts it.

Inbound classification and field validation come from `kcode-k1-codex-events`. Early events are bounded, scope and correlation are strict, malformed calls are rejected when identifiable, unsupported requests are rejected, and model rerouting fails closed.

`close_conversation` is idle-only and idempotent. A native mapping and its profile binding are forgotten only after the matching `thread/unsubscribe` succeeds. A normal rejection clears the closing transition while preserving a usable adapter, mapping, and binding. Closing a key without a native thread clears its profile binding immediately.

The transport supplies global no-history configuration, process I/O, diagnostics capture, and graceful close. The opening profile's effort remains the process default, while every turn explicitly supplies its bound profile's model and optional effort. Threads are never ephemeral, and diagnostics remain separate from `Error` display text.

## 0.2.1
Adds value-bound per-conversation profiles through `Adapter::with_config`, allowing distinct model, effort, instructions, and dynamic tools to share one app-server process without cross-profile key reuse or tool exposure. Every `turn/start` now carries the bound model and optional effort.