Sign in

    #totto2727/agent-sdk/cli

    Provider-neutral MoonBit interfaces for prompts, live CLI sessions, opaque continuations, and completed responses.

    Consumer acquisition, imports, and the common session flow are documented in the root Setup and Usage.

    #Package role

    • Prompt carries caller-ordered context paths without changing text-only callers.
    • Cli and CliSession provide one flow for starting, prompting, and resuming provider adapters.
    • Continuation hides provider-owned resume identifiers and behavior from consumers.
    • FinalResponse exposes final text, optional session metadata, changed paths, and an optional continuation.
    • Cancelling the task running CliSession::prompt propagates the cancellation error after provider cleanup.

    #Usage

    #API

    This README was generated from the share-artifact skill and README template.

    CliSession

    pub(open) trait CliSession {
    fn id(Self) -> String?
    fn continuation(Self) -> Continuation?
    async fn prompt(Self, Prompt) -> FinalResponse
    }

    A live provider CLI session.

    id exposes the provider thread or session identifier when available, and continuation returns an opaque handle after a provider has completed a prompt. Provider errors pass through unchanged.

    Cancelling the task running prompt cancels the provider call and propagates the cancellation error after provider cleanup.

    Cli

    pub struct Cli {
    // private fields
    }

    Provider-neutral entry point for starting or resuming CLI sessions.

    Use start for a fresh provider session or continue_session with the continuation from a previous FinalResponse.

    Cli::Cli

    fn Cli::Cli(start : () -> &CliSession) -> Cli

    Creates a CLI adapter from provider-specific session factories.

    The factory is called when start is invoked, so provider-native options remain owned by the selected adapter.

    Cli::continue_session

    fn Cli::continue_session(_self : Cli, continuation : Continuation) -> &CliSession

    Resumes the provider session represented by an opaque continuation.

    The continuation remains opaque and is consumed only by the selected provider adapter.

    Cli::start

    fn Cli::start(self : Cli) -> &CliSession

    Starts a new provider session using the adapter's provider-native options.

    Continuation

    pub struct Continuation {
    // private fields
    }

    Opaque provider continuation handle.

    A continuation captures provider-owned resume behavior. Pass it to Cli::continue_session; callers do not inspect or construct its identifier.

    Continuation::Continuation

    fn Continuation::Continuation(resume_session : () -> &CliSession) -> Continuation

    Creates an opaque continuation handle from provider-owned resume behavior.

    FinalResponse

    pub struct FinalResponse {
    text : String
    session_id : String?
    changed_files : ReadOnlyArray[
    Path
    ]
    continuation : Continuation?
    }

    Final text, session metadata, changed files, and continuation returned by a completed prompt.

    session_id is populated when the provider exposes its thread identifier. changed_files contains completed Codex patch paths and is empty for the OpenCode adapter because its current event model has no reliable change set.

    FinalResponse::FinalResponse

    fn FinalResponse::FinalResponse(text : String, session_id? : String, changed_files? : ReadOnlyArray[
    Path
    ], continuation? : Continuation) -> FinalResponse

    Creates a final response with optional provider metadata.

    let response = FinalResponse::FinalResponse( "done", session_id="session-1", ) assert_eq(response.text, "done") assert_eq(response.session_id, Some("session-1"))

    Prompt

    pub struct Prompt {
    text : String
    context_files : ReadOnlyArray[
    Path
    ]
    } derive(Eq,
    Debug
    )

    Text and optional context files sent to a provider CLI session.

    The context_files collection preserves caller order. Codex adapters append the paths to the prompt text, while OpenCode adapters forward them as ordered local-file inputs. Callers should resolve relative paths against their workspace before constructing a prompt.

    Prompt::Prompt

    fn Prompt::Prompt(text : String, context_files? : ReadOnlyArray[
    Path
    ]) -> Prompt

    Creates a provider-neutral prompt without changing text-only callers.

    let prompt = Prompt::Prompt("review", context_files=[ @path.Path("src/main.mbt"), ]) assert_eq(prompt.text, "review") assert_eq(prompt.context_files.length(), 1)

    Source Files

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io