colmugx/posoco/types does not have a README file

    ChatOptions

    pub(all) struct ChatOptions {
    temperature : Double?
    max_output_tokens : Int?
    } derive(Eq,
    Debug
    )

    Provider-agnostic chat options. Trimmed in R3 M3.7 to just the two fields every provider accepts. Provider-specific tuning (tool_choice, reasoning effort, top_p, frequency_penalty, ...) belongs on the modelport's own config struct, not on this shared bag — that way adding a new provider never bloats the common type.

    EventScope

    Attribution identity of one emitted TurnEvent / HookStage: which session and run the event belongs to. Projected from the committed event envelope at the Agent boundary — never reconstructed by scanning a transcript. Scope answers "which run does this belong to"; it does not carry effect identity (ToolCall.call_id already correlates tool events).

    Session

    pub(all) struct Session {
    messages : Array[
    Message
    ]
    metadata : Map[String, Json]
    } derive(Eq,
    Debug
    )

    A conversation session. messages is the linear transcript this thread owns; metadata is a free-form product-owned bag (used for lineage via parent_thread_id, product-specific flags, anything posoco does not interpret).

    R3 M3.7: messages carries canonical @kernel.Message values directly. There is no longer a legacy @types.Message form — the kernel ADT is the single protocol.

    Session::parent_thread_id

    fn Session::parent_thread_id(self : Session) -> String?

    Read the parent thread id from a session's metadata. Returns None when the key is absent or not a string.

    Session::with_parent_thread_id

    fn Session::with_parent_thread_id(self : Session, parent_thread_id : String) -> Session

    Construct a Session with the given parent thread id recorded in its metadata. Used by fork/compact handlers.

    StreamAccumulator

    pub struct StreamAccumulator {
    // private fields
    } derive(
    Debug
    )

    Accumulates StreamChunk events during a streaming chat call. Modelports that want a standard "double-write" implementation (one chunk to the Stream(cb) callback for telemetry, one chunk to the accumulator for the final completion) can use this helper. Modelports with more sophisticated needs (e.g. DeepSeek's dynamic tool-result removal during streaming) are free to ignore this and maintain their own state.

    R3 M3.7: the previous to_response() -> ModelResponse has been replaced by to_completion() -> @kernel.Completion. The old ModelResponse type is deleted — chat now returns ModelCallResult whose completion field is the canonical Completion.

    StreamAccumulator::StreamAccumulator

    fn StreamAccumulator::StreamAccumulator() -> StreamAccumulator

    StreamAccumulator::push

    StreamAccumulator::reasoning

    fn StreamAccumulator::reasoning(self : StreamAccumulator) -> String

    StreamAccumulator::text

    fn StreamAccumulator::text(self : StreamAccumulator) -> String

    StreamAccumulator::to_completion

    Assemble accumulated stream chunks into a canonical @kernel.Completion.

    T07 error-transparency: malformed tool-call argument JSON raises ModelError::ResponseParse instead of silently becoming {}. This prevents a corrupted stream from masquerading as a valid empty-args call.

    StreamChunk

    pub(all) enum StreamChunk {
    TextDelta(token~ : String)
    ReasoningDelta(token~ : String)
    ToolCallDelta(index~ : Int, id~ : String?, name~ : String?, arguments_delta~ : String?)
    Usage(input_tokens~ : Int, output_tokens~ : Int, total_tokens~ : Int, cached_input_tokens~ : Int?, uncached_input_tokens~ : Int?)
    Finish(reason~ : String)
    } derive(Eq,
    Debug
    )

    Canonical streaming chunk shape emitted by modelports through the Stream(cb) callback of ModelPort::chat. HostChunkCallback receives this type directly; there is no separate JSON wire contract.

    Streaming remains a host/telemetry concern, not a transcript fact (ADR §2.11).

    StreamChunk::validate

    fn StreamChunk::validate(self : StreamChunk) -> Result[Unit, String]

    Validate the scalar part of one provider stream chunk before it reaches a live sink or the mutable accumulator. Tool-call sparsity is stateful and is checked by StreamAccumulator::push (and by the executor's callback guard); this method enforces the stateless part of that same protocol.

    StreamMode

    pub(all) enum StreamMode {
    NoStream
    Stream((StreamChunk) -> Unit)
    } derive(
    Debug
    )

    Streaming mode for ModelPort::chat. See trait doc.

    NoStream lets the modelport skip chunk wire-format work entirely (no SSE parsing, no callback construction). Stream(cb) asks it to emit each chunk to cb as a StreamChunk. The ADR §2.11 rationale still holds — streaming is a host/telemetry concern, not a transcript fact — but the chunk contract is now the canonical StreamChunk type, not a private JSON shape.
    impl Show for StreamMode

    ToolCallBuilder

    pub(all) struct ToolCallBuilder {
    id : String
    name : String
    arguments_buf : StringBuilder
    } derive(
    Debug
    )

    Mutable per-index accumulator used by StreamAccumulator while assembling streamed tool calls. Each streamed ToolCallDelta targets an index; the builder records the first non-empty id / name / arguments_json() it sees for that index.

    ToolCallBuilder::ToolCallBuilder

    fn ToolCallBuilder::ToolCallBuilder() -> ToolCallBuilder

    ToolCallBuilder::arguments_json

    fn ToolCallBuilder::arguments_json(self : ToolCallBuilder) -> String

    TurnEvent

    pub(all) enum TurnEvent {
    TurnStarted
    ToolCallPending(
    ToolCall
    )
    ToolCallResult(call~ :
    ToolCall
    , result~ :
    ToolOutcome
    , is_error~ : Bool)
    ModelResponseReceived(message~ :
    Message
    , usage~ :
    Usage
    ?)
    SessionRedirect(from~ : String, to~ : String, messages_before~ : Int, messages_after~ : Int)
    TurnCompleted
    TurnFailed(String)
    ToolCallDeferred(call~ :
    ToolCall
    , reason~ : String)
    StreamChunkReceived(chunk~ : StreamChunk)
    StreamChunksDropped(count~ : Int)
    ConfigWarning(field~ : String, value~ : String, reason~ : String)
    ConfigChanged(field~ : String, old_value~ : String, new_value~ : String)
    Custom(source~ : String, label~ : String, data~ : Json)
    } derive(Eq,
    Debug
    )

    Turn lifecycle events observed via Observer::on_event. R3 M3.7: payload types are now canonical kernel types (ToolCall, ToolOutcome, Message, Usage). is_error on ToolCallResult is preserved for legacy observer compatibility — it is derived from the ToolOutcome variant (is_failure).
    impl Show for TurnEvent

    TurnResult

    pub(all) struct TurnResult {
    message :
    Message

    tool_results : Array[
    ToolOutcome
    ]
    final_session_id : String
    } derive(Eq,
    Debug
    )

    Return value of Agent::run_turn. R3 M3.7: payload types are canonical.

    PARENT_THREAD_ID_KEY

    let PARENT_THREAD_ID_KEY : String

    Metadata key under which a session's parent thread id is stored. Absent for threads created via the new command (fresh, no parent). Present when this session was forked from another thread (user-initiated /fork-here) or compacted from another thread (modelport-driven compact via ModelPort::compact returning CompactMode::NewThread).

    Stored in metadata rather than a dedicated field so existing Session construction sites continue to compile unchanged. Product code reads it via Session::parent_thread_id(session).