Skip to main content
Run Muse Code inside a CoreWeave sandbox to edit files and execute commands in a remote workspace. This guide uses the Sandbox software development kit (SDK) to install the command-line interface (CLI) and clone a repository. You then run a task without an interactive terminal and retrieve the result before you stop the sandbox. The agent process and workspace run on CoreWeave, and model requests go to Meta.

Prerequisites

Before you begin, you need the following:
  • W&B APIキー。これらのサンプルでは W&B 認証を使用します。
  • Muse Code へのアクセス権がある Meta APIキー。
  • サンドボックスからクローンできる公開リポジトリの URL。プライベートリポジトリを使用する場合は、サンドボックス内に Git の認証情報が必要です。
  • Python 3.11 以降と uv、または Node.js 22 以降と npm。
シークレットマネージャーから認証情報を読み込み、ローカルのターミナル環境に設定します。[WANDB-API-KEY] を W&B APIキーに、[META-API-KEY] を Meta APIキーに置き換えてください。
このスクリプトは Meta キーを標準入力経由で渡すため、キーがコマンド引数やサンドボックスの設定に現れることはありません。チームで共有する認証情報をサンドボックスの作成時に環境変数として注入する方法については、W&B シークレットを参照してください。

Install the Sandbox client

Choose a language and prepare a local project:

Run a task in the sandbox

Save the script for your language using the filename shown. Each script creates a serverless sandbox with a 30-minute maximum lifetime and performs these steps:
  1. Installs Muse Code with Meta’s installer.
  2. Clones your repository into the /workspace/project directory.
  3. Runs muse exec to build and test a sparkline CLI that renders numbers as a small chart.
  4. Runs the generated CLI independently, checks its output, and saves the sparkline.mjs file locally.
  5. Stops the sandbox in a finally block, including when setup or execution fails.
These examples were tested with Muse Code 1.3.0. The installer can install a newer version, so each script runs muse --version after installation. The example uses --yolo to disable Muse Code’s approval prompts and operating system (OS) sandbox and trust the workspace for this run. CoreWeave supplies the outer sandbox. Muse can access files, credentials, and network destinations available inside that sandbox. Use a repository you trust and provide only the credentials the task needs. For more information, see Muse Code permissions.
run_muse.py
In your local project directory, replace [REPOSITORY-URL] with your public repository URL, then run the script:
After the installation and agent output, the script checks and prints the sparkline:
The script saves the generated sparkline.mjs file in your local project directory, then stops the sandbox. If the file already exists locally, the script overwrites it. The output check runs independently of Muse’s own test and verifies this example’s input. For a larger task, replace it with tests for your requirements. これらのサンプルでは永続ストレージを設定していません。finally ブロックが実行される前に、必要なファイルをサンドボックスからコピーしてください。詳しくはファイル操作およびファイルシステムスナップショットを参照してください。

Troubleshoot

Use these checks to resolve common issues:
  • サンドボックスの作成に失敗する場合は、W&B キーと認証設定を確認してください。
  • Muse Code で認証エラーが発生する場合は、META_API_KEY と Meta のアカウントの設定を確認してください。サンドボックスの認証情報は、モデルリクエストの認証には使用されません。
  • インストール、クローン、またはモデルリクエストが失敗する場合は、Meta および Git ホストへのアウトバウンドアクセスを確認してください。
  • 規模の大きいタスクがタイムアウトする場合は、実行前にコマンドのタイムアウトとサンドボックスのライフタイムを調整してください。30 分のライフタイムには、起動とインストールにかかる時間も含まれます。詳しくはコマンドのタイムアウトおよびサンドボックスのライフサイクルを参照してください。

Next steps

For more information, see these guides:
最終更新日 2026年9月30日