Sign in

    workgraph-codex-cli

    Codex CLI integration for workgraph

    agent
    codex
    graph
    moonbit
    Download zip
    Author
    Version
    0.2.1
    License
    MIT
    Last updated
    2 months ago
    Downloads
    27

    #moonbit: import: - path: moonbitlang/async@0.21.0 alias: async - path: moonbitlang/core/immut/hashmap alias: immut_hashmap - path: moonbitlang/x@0.5.1/path alias: path - path: totto2727/agent-sdk@0.2.1/cli alias: cli - path: totto2727/workgraph-agent-cli@0.2.1 alias: coding - path: totto2727/workgraph-codex-cli@0.2.1 alias: codex - path: totto2727/workgraph-core@0.1.4 alias: core backend: native

    #workgraph-codex-cli

    workgraph-codex-cli owns the Codex-native CodexAgentOptions and codex_agent composition root for the provider-neutral Workgraph coding-agent contract. For shared installation and graph construction, see the root Setup and Usage.

    #Usage

    Send a read-only task through a Codex-backed graph node and return its final response from graph state:

    ///|
    pub async fn run_codex_graph() -> String raise {
    let entry = @core.NodeId::NodeId("codex")
    let agent = @codex.codex_agent(
    @coding.CodingAgentId::CodingAgentId("codex-cli"),
    @codex.CodexAgentOptions::CodexAgentOptions(),
    )
    let node = @coding.coding_agent_node(
    entry,
    @core.NodeMetadata::NodeMetadata(
    name="Codex",
    description=None,
    kind=@core.CodingAgent,
    tags=[],
    ),
    @coding.CodingAgentNodeSpec::CodingAgentNodeSpec(
    agent~,
    resource_key=@core.ResourceKey::ResourceKey("codex-session"),
    resource_scope=@core.Run,
    open_context=fn(context, _state) {
    @coding.CodingAgentOpenContext::CodingAgentOpenContext(
    run_id=context.run_id,
    task_group=context.task_group,
    workspace=@coding.WorkspaceRef::WorkspaceRef(@path.Path("."), []),
    approval=@coding.Never,
    network=@coding.Disabled,
    environment=@immut_hashmap.new(),
    events=context.events,
    )
    },
    build_prompt=fn(_context, state : String) { @cli.Prompt::Prompt(state) },
    select_continuation=fn(_context, _state) { None },
    decode_response=fn(_state, response, _continuation) {
    @core.NodeOutput::NodeOutput(Some(response.text), None)
    },
    ),
    )
    let definition = @core.GraphDefinition::GraphDefinition(
    @core.Reducer::Reducer(fn(_state : String, patch : String) { patch }),
    )
    definition.add_node(node)
    definition.set_router(
    entry,
    @core.router([], fn(_state, _completion) { @core.End }),
    )
    definition.set_entry(entry)
    let result = @core.GraphRuntime::GraphRuntime(definition.compile()).invoke(
    "Reply with WORKGRAPH_CODEX_OK only. Do not modify files or use tools.",
    )
    result.final_state
    }

    Version 0.2.1 prefers Wasm/WASI and supports Wasm/WASI and native from the same production source; JavaScript is not supported. It resolves totto2727/agent-sdk@0.2.1 and totto2727/codex-sdk@0.4.1 from the MoonBit registry. The shared CI check follows the Wasm/WASI preferred target and loads the Codex CLI from the repository's ci Nix dev shell. Fake CLI process tests run only on native.

    With an installed and authenticated Codex CLI, the expected result is WORKGRAPH_CODEX_OK. The literate function is type-checked without executing credentials; the runnable Codex example executes the same prompt-to-result flow.

    #API

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

    CodexAgentOptions

    pub struct CodexAgentOptions {
    codex_path_override :
    Path
    ?
    base_url : String?
    api_key : String?
    config : Map[String, Json]?
    resume_thread_id : String?
    model : String?
    sandbox :
    SandboxMode
    ?
    skip_git : Bool?
    reasoning :
    ModelReasoningEffort
    ?
    web_search :
    WebSearchMode
    ?
    }

    Configuration shared by every Codex session opened by this adapter.

    CodexAgentOptions::CodexAgentOptions

    fn CodexAgentOptions::CodexAgentOptions(codex_path_override? :
    Path
    , base_url? : String, api_key? : String, config? : Map[String, Json], resume_thread_id? : String, model? : String, sandbox? :
    SandboxMode
    , skip_git? : Bool, reasoning? :
    ModelReasoningEffort
    , web_search? :
    WebSearchMode
    ) -> CodexAgentOptions

    Creates Codex adapter options with the SDK's defaults.

    codex_agent

    Creates a coding agent backed by the pinned Codex SDK.

    Source Files

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io