MoonBitの新AI エージェント実装「Maria」

この記事は MoonBit Advent Calendar 2025 13日目の記事です。

Moonbit - Qiita Advent Calendar 2025 - Qiita
Calendar page for Qiita Advent Calendar 2025 regarding Moonbit.

MoonBit Maria(以下、Maria)は、MoonBit公式の AI エージェントなプロジェクトです。GitHub リポジトリで公開されています。MoonBitのasyncベースで実装されています。

GitHub - moonbitlang/maria: moon agent rewritten in async
moon agent rewritten in async. Contribute to moonbitlang/maria development by creating an account on GitHub.

現状、MoonBit には CLI エージェントとして使う MoonBit Pilot(moonagentがあります。これは Claude Code のようにターミナルから使えるエージェントですが、現状は同期実装で応答も遅く、将来的には Maria 側の仕組みに統合されていく想定です。MoonBit ブログ「Write a Simple Code Agent using moonbitlang/async」でシンプルなコードエージェントのループ実装が説明されています。

Write a Simple Code Agent using moonbitlang/async | MoonBit
Write a Simple Code Agent using moonbitlang/async

asyncの特徴:

  • 言語組み込み: Rust の tokio のような外部ランタイムではなく、MoonBit 標準機能
  • with_task_group でタスクをグループ化し、スコープ終了時に待機
  • pause() で明示的に実行を譲る
  • ネイティブターゲット向け: preferred-target: native で使用
@async.with_task_group(group => {
  // バックグラウンドで readline を開始
  group.spawn_bg(() => rl.start())
  
  // メインループ
  while true {
    let prompt = rl.read_line()
    maria.start(prompt~)
  }
})

Mariaは現時点ではリポジトリをチェックアウトして、単独のコマンドとして実行できます。moonagent と設定を共有しているため、セットアップは公式ドキュメントを参考にするのが確実です[1]。
[1]: https://docs.moonbitlang.com/en/latest/pilot/moonbit-pilot/model-configuration.html

実際に試すと、Streaming で非同期にレスポンスが返ってきてターミナルに描画されます。

❯ gh repo clone moonbitlang/maria moonbitlang/maria
❯ cd moonbitlang/maria
❯ moon run cmd/main

$ Hello
Hello! I'm here to help you with MoonBit programming tasks. I can assist you with:

- **Writing and improving MoonBit code** - creating new projects, implementing features, refactoring
- **Translating code** from other languages to MoonBit
- **Debugging and fixing issues** in MoonBit projects
- **Testing and validation** - writing tests, running test suites, checking coverage
- **Project structure and build system** - setting up packages, managing dependencies
- **API discovery** - finding and exploring available functions, types, and methods
- **Code analysis** - understanding existing codebases, searching for patterns

What would you like to work on today?

なお、まだ開発中のため、実用レベルまで到達していない点には注意が必要です。

Mariaのアーキテクチャ

ちょっと面白いのは、Maria は CLI エージェントというより、複数タスクを管理するプラットフォームとして設計されている点です。LLM エージェントを バックエンドの非同期タスクとして扱い、管理・再接続できるところがポイントです。感覚としては Cline CLI に近いアーキテクチャで、起動するとデバッグ用の管理画面も確認できます。

❯ moon run cmd/main -- daemon --port 8090 --serve cmd/daemon
Generated buildinfo package with version = 0.1.0+1832.e354548
[INFO] Starting HTTP server on port 8090...
[INFO] Visit http://localhost:8090/

daemon はタスクの生成・再利用やプロセス管理を担い、外部から操作するための HTTP / SSE API も提供します。「あるディレクトリで作業するエージェント」をタスクとして常駐させ、後からメッセージを送ったり、イベントを購読したりできます。

UI

管理画面含めリポジトリに同梱されています。Web UI 以外にも VSCode 拡張、Electron アプリといった形で、フロントエンドが用意されていました。

SDK

クライアント層として Python / Node.js / Java SDK が用意されています。ただし SDK は「本体」ではなく、ネイティブの maria 実行ファイルを サブプロセス起動するラッパーです(設計としては Claude Agent SDK に近い構造です)。初手でJavaがあるのが興味深い。

まとめ

MoonBit Maria は AI エージェントを管理するための MoonBit製ローカル Task Platform です。SDK・UI・CLI はすべてフロントエンドで、中心となる機能は daemon 側にあります。今後、moonagent のバックエンドがこの仕組みに寄っていくと思われます。楽しみですね。

Subscribe to laiso

Sign up now to get access to the library of members-only issues.
Jamie Larson
Subscribe