Sign in

    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).

    MemoryEntry

    pub(all) struct MemoryEntry {
    id : String
    content : String
    metadata : Map[String, Json]
    score : Double?
    } derive(Eq,
    Debug
    )

    MemoryQuery

    pub(all) struct MemoryQuery {
    query : String
    top_k : Int
    threshold : Double?
    filter : Map[String, Json]
    } derive(Eq,
    Debug
    )

    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(all) struct StreamAccumulator {
    text : String
    reasoning : String
    tool_calls : Array[ToolCallBuilder]
    finish_reason : String
    usage_input : Int?
    usage_cached : Int?
    usage_uncached : Int?
    usage_output : Int?
    usage_total : Int?
    } 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

    fn StreamAccumulator::push(self : StreamAccumulator, chunk : StreamChunk) -> Unit

    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
    )

    Streaming chunk shape emitted by modelports inside the Stream(cb) callback of ModelPort::chat. This is the modelport's own representation of provider chunks; posoco does NOT define a canonical chunk type (ADR §2.11 — streaming is host/telemetry concern, not transcript fact).

    StreamChunk exists as a public type because it is useful for modelports that want a shared wire vocabulary (ext-llm and ext-deepseek both emit these). Modelports that prefer their own chunk type are free to use it; the only contract is "what you pass to the Stream(cb) callback, the HostChunkCallback consumer must be able to decode".

    StreamMode

    pub(all) enum StreamMode {
    NoStream
    Stream((Json) -> 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 raw JSON — posoco does NOT define a canonical chunk type (ADR §2.11: streaming is host/telemetry concern, not transcript fact), so the JSON shape is a private contract between the modelport and the HostChunkCallback consumer.
    impl Show for StreamMode

    ToolCallBuilder

    pub(all) struct ToolCallBuilder {
    id : String
    name : String
    arguments_json : String
    } 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

    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)
    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).