Sign in

    moon-agent-graph

    Native asynchronous agent graph runtime with Mermaid visualization

    agent
    graph
    runtime
    visualization
    mermaid
    moonbit
    Download zip
    Author
    Version
    0.1.2
    License
    MIT
    Last updated
    2 months ago
    Downloads
    22

    #Moon Agent Graph Runtime

    Native asynchronous graph execution for MoonBit with typed state patches, deterministic routing, run-local resources, lifecycle events, MoonLLM nodes, and coding-agent adapters.

    #Status

    The sequential native runtime, MoonLLM boundary, common coding-agent node, Codex adapter, OpenCode adapter, deterministic test kit, and local E2E workflows are implemented. See the architecture, core guide, interfaces, test plan, and Japanese framework comparison.

    #Packages

    • core: graph definitions, runtime, events, resources, and coding-agent contracts.
    • moonllm: typed MoonLLM node boundary.
    • coding_agent: shared coding-agent graph node.
    • integrations/codex: Codex SDK adapter.
    • integrations/opencode: OpenCode CLI SDK adapter.
    • testing: deterministic public fixtures and native test helpers.
    • visualization: deterministic Mermaid rendering for compiled graphs.
    • e2e: reusable credential-free workflow support.
    • test: native cross-package integration tests.

    #Basic example

    From the repository root:

    moon build --target native mbt/package/moon-agent-graph/src/examples/basic moon run --target native mbt/package/moon-agent-graph/src/examples/basic

    Expected output:

    labels=plan,test steps=2

    The example uses exported core APIs only and requires no provider credentials.

    #Visualization

    Import the optional visualization package from this module:

    import { "totto2727/moon-agent-graph/visualization", }

    Render the callback-free static structure of a compiled graph:

    let graph = definition.compile()
    println(@visualization.to_mermaid(graph))

    Node descriptions, router descriptions, and declared route labels come from metadata in core. Routers with multiple destinations or descriptions are rendered as decision diamonds. Runtime-only conditions, End, and Fail outcomes are intentionally omitted because they cannot be determined without evaluating a router.

    @core.router(
    [
    @core.DeclaredRoute::DeclaredRoute(
    fix,
    metadata=@core.DeclaredRouteMetadata::DeclaredRouteMetadata(
    label="failed",
    ),
    ),
    @core.DeclaredRoute::DeclaredRoute(
    review,
    metadata=@core.DeclaredRouteMetadata::DeclaredRouteMetadata(
    label="passed",
    ),
    ),
    ],
    evaluate,
    metadata=@core.RouterMetadata::RouterMetadata(description="Test result"),
    )

    Run the complete branching example from the repository root:

    moon run --target native mbt/package/moon-agent-graph/src/examples/visualization

    flowchart TD node_0["Fix [04-fix] / Coding Agent<br/>Repair a failed change"] node_1["Plan [01-plan] / LLM<br/>Create a plan"] node_2["Test [03-test] / Function<br/>Run automated tests"] node_3["Review [05-review] / Custom: Human review<br/>Review the verified change"] node_4["Release [06-release] / Function<br/>Publish the result"] node_5["Implement [02-implement] / Coding Agent<br/>Write the change"] graph_entry(["Entry"]) --> node_1 node_0 --> node_2 node_1 --> node_5 node_2 --> router_2{"Test result"} router_2 -->|failed| node_0 router_2 -->|passed| node_3 node_3 --> router_3{"Review result"} router_3 -->|changes requested| node_0 router_3 -->|approved| node_4 node_5 --> node_2

    #Limitations

    • Execution is sequential and native-only.
    • Provider adapters require their corresponding local SDK executable or endpoint in real use.
    • Remote provider calls are intentionally excluded from normal automated tests.

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io