colmugx/posoco/port does not have a README file

    CommandPort

    pub(open) trait CommandPort {
    fn commands(Self) -> Array[CommandDef]
    async fn invoke(Self, id : String, args : Json) -> CommandOutcome raise
    CommandError

    }

    User-initiated, enumerable, side-effecting commands. Distinct from ToolProvider (LLM-initiated, results re-enter session). Both panel TUIs and slash command lines consume this without knowing command semantics. pub(open) so any ext can declare commands.

    Compressor

    pub(open) trait Compressor {
    fn compress(Self, messages : Array[
    Message
    ], ctx : CompressContext) -> CompressAction
    }

    Compressor: pure function that decides how to shrink the message context. Returns instructions (None/Replace/NewThread) — never saves sessions or emits events directly; the Agent and Observer handle side effects.

    Lifecycle

    pub(open) trait Lifecycle {
    async fn on_shutdown(Self) -> Unit
    }

    Lifecycle: resource cleanup hook. Called once on agent shutdown to release connections, flush buffers, etc. async to allow IO during cleanup.

    MemoryPort

    MemoryPort: durable cross-session memory store/search/delete. Distinct from SessionStore (conversation history) — memory holds durable decisions/knowledge (e.g. brain.md integration).

    ModelPort

    ModelPort: the LLM calling interface. Every ext-deepseek / ext-openai / ext-anthropic implements this. chat is the primary call; chat_streaming has a default that ignores on_chunk and falls back to chat().

    Observer

    pub(open) trait Observer {
    fn on_event(Self, event :
    TurnEvent
    ) -> Unit
    }

    Observer: read-only event listener. Never blocks or mutates — use PipelineHook for interception/abortion. Receives TurnEvent for every significant turn lifecycle event.

    PipelineHook

    pub(open) trait PipelineHook {
    async fn on_stage(Self, stage : Stage) -> Result[Stage, HookError]
    }

    Pipeline hook: observe or mutate stages before/after each phase. Before* stages may rewrite or abort; After*/*Error stages run under finally semantics (always invoked) in reverse hook order.

    SessionStore

    pub(open) trait SessionStore {
    fn load(Self, id : String) -> Result[
    Session
    ,
    SessionError
    ]
    fn save(Self, id : String, session :
    Session
    ) -> Result[Unit,
    SessionError
    ]
    }

    SessionStore: persist and load conversation sessions by id.

    ToolProvider

    pub(open) trait ToolProvider {
    fn list_tools(Self) -> Array[
    ToolDef
    ]
    async fn execute(Self, name : String, call :
    ToolCall
    ) ->
    ToolResult
    raise
    RuntimeError

    }

    Unified tool interface: declare tools via list_tools(), execute via execute().

    CommandDef

    pub(all) struct CommandDef {
    id : String
    label : String
    description : String
    category : String
    ctype : CommandType
    params : Array[CommandParam]
    aliases : Array[String]
    shortcut : String?
    icon : String?
    visible : Bool
    metadata : Json?
    } derive(Eq,
    Debug
    )

    Command declaration. params is the source of truth for argument rendering (panel form) and parsing (slash). Redundant fields (aliases/shortcut/icon/ visible/metadata) are deliberate "escape hatches" for ext authors to use without changing the trait — meta does not define their semantics.

    CommandOutcome

    pub(all) enum CommandOutcome {
    Success(feedback~ : String, structured~ : Json?, ui_hint~ : UiHint?)
    Failure(reason~ : String)
    NeedsInput(prompt~ : String)
    } derive(Eq,
    Debug
    )

    Outcome of invoking a command. feedback is for slash (print directly); structured + ui_hint are for panel (deep render + UI action). NeedsInput supports multi-step commands.

    CommandParam

    pub(all) struct CommandParam {
    name : String
    label : String
    description : String
    ptype : ParamType
    required : Bool
    default : Json?
    choices : Array[String]?
    positional : Bool
    } derive(Eq,
    Debug
    )

    A single command parameter. Explicit and human-facing, in contrast to ToolDef.input_schema (which is JSON Schema for LLM consumption).

    CommandType

    pub(all) enum CommandType {
    Action
    Toggle
    Select
    Input
    MultiStep
    } derive(Eq,
    Debug
    )

    Semantic command type. Determines how a panel renders the control (button / toggle / dropdown / input / multi-step form) and how a slash parser expects arguments.

    CompressAction

    pub(all) enum CompressAction {
    None
    Replace(Array[
    Message
    ])
    NewThread(messages~ : Array[
    Message
    ], new_session_id~ : String, messages_before~ : Int, messages_after~ : Int)
    } derive(Eq,
    Debug
    )

    Action returned by a Compressor. None = no compression; Replace = substitute the message list; NewThread = start a fresh session with a summary carried over.

    CompressContext

    pub(all) struct CompressContext {
    session_id : String
    model_context_window : Int?
    } derive(Eq,
    Debug
    )

    Context passed to Compressor::compress.

    HookError

    pub(all) enum HookError {
    Aborted(String)
    Deferred(reason~ : String)
    } derive(Eq,
    Debug
    )

    impl Show for HookError

    ParamType

    pub(all) enum ParamType {
    Str
    Int
    Bool
    Strs
    } derive(Eq,
    Debug
    )

    Value type of a command parameter. Human-friendly (unlike JSON Schema which targets LLMs). Panel/slash consumers render and parse directly from this.

    Stage

    Pipeline hook stages. The Before* variants run hooks in forward order (short-circuit on error); the After*/*Error variants run in reverse order (onion semantics) without short-circuiting (finally semantics).

    UiHint

    pub(all) enum UiHint {
    RefreshModelList
    RefreshSettings
    ClosePanel
    Toast
    None
    } derive(Eq,
    Debug
    )

    Hint to a panel consumer about what UI action to take after invoke. Slash consumers ignore this. Fixed enum + None fallback; ext long-tail needs go through CommandDef.metadata.