Manaflow Documentation

repository·main·Indexed 22 days ago

https://github.com/manaflow-ai/manaflow

An open-source orchestration platform for parallel execution of AI coding agents within isolated, sandboxed VS Code workspaces. Includes documentation for the cmux devbox CLI, which manages Morph Cloud VMs, browser automation via element references, and workspace lifecycle management.

Tokens
102.2K
Snippets
370
Records
495
Agent score
77%

What's inside Manaflow

  1. Overview of cmux-env

    main

    cmux-env is a system composed of a daemon (envd) and a client (envctl) designed to coordinate shared environment variables across different shells and projects.

    • envd (Daemon): Runs in the background to maintain the state of global and directory-scoped key/value pairs.
    • envctl (Client): The command-line interface used to interact with the daemon to set, unset, list, or export variables.
  2. Overview of Manaflow

    main

    Manaflow is an open-source orchestration platform designed as an alternative to Claude Code, Codex Cloud, or Devin. It allows you to spawn multiple coding agent CLIs (such as Claude Code, Codex CLI, Cursor CLI, Gemini CLI, Amp, and Opencode) to work on tasks in parallel.

    Key capabilities include:

    • Parallel Agent Orchestration: Run multiple agents simultaneously with different models and prompts.
    • Isolated VS Code Workspaces: Each agent operates in a sandboxed environment (cloud or local Docker) with full VS Code, terminal, and source control access.
    • Live Web Preview: An embedded browser allows you to view dev server output in real-time as agents modify code.
    • One-Click PR Creation: Review git diffs, squash/merge, and manage pull requests or CI status directly from the workspace.
    • Workspace Monitoring: A grid view to monitor the editor, TUI, and browser preview for all active agents.
    • Heatmap Diff Viewer: Color-coded annotations to highlight risky code changes during reviews.
  3. Cloudrouter Sandbox Features and Components

    main

    The Cloudrouter Sandbox is an Ubuntu 22.04-based environment designed for development and automation. It includes:

    • VNC Desktop: Uses TigerVNC (display :1) and XFCE4. A web-based proxy (noVNC) is available on port 39380. Chrome opens maximized by default.
    • VSCode: OpenVSCode Server is available for browser-based IDE access with the workspace located at /home/user/workspace.
    • Chrome:
      • A visible instance for manual browsing within the VNC desktop.
      • A headless instance accessible via Chrome DevTools Protocol (CDP) on port 9222 for automation.
    • Runtime/Tools: Node.js 20, Bun, Git, GitHub CLI.
  4. Handle Validation Errors with Hooks

    main

    You can handle Zod validation errors using hooks. You can provide a hook locally at the route level or globally for the entire application.

    Local Hook

    Pass a third argument to app.openapi() to intercept the result of the validation. If result.success is false, you can return a custom error response.

    Global Hook (DRY approach)

    Initialize OpenAPIHono with a defaultHook to apply a common error formatter to all routes. Local hooks provided in app.openapi() will override the defaultHook.

    // Global Hook
    const app = new OpenAPIHono({
      defaultHook: (result, c) => {
        if (!result.success) {
          return c.json({
            ok: false,
            errors: "formatted_errors",
            source: "custom_error_handler",
          }, 422);
        }
      },
    });
    
    // Local Hook (Overrides defaultHook)
    app.openapi(
      createRoute({ /* ... */ }),
      (c) => { /* ... */ },
      (result, c) => {
        if (!result.success) {
          return c.json({ ok: false, source: "routeHook" as const }, 400);
        }
      }
    );
  5. How cmux devbox works

    main

    The cmux devbox CLI manages remote development environments (Morph instances) via the following components:

    • Auth: Uses Stack Auth to handle logins and fetch team information. Tokens and profiles are cached in ~/.config/cmux.
    • State Management: Maps absolute local paths to Morph instance IDs using state files located at ~/.config/cmux/cmux_devbox_state_{dev,prod}.json.
    • VM API: Communicates with Convex HTTP endpoints to manage instances (create, resume, stop), execute commands, fetch SSH details, and perform file synchronization via rsync over SSH.
    • Command Scoping: Commands are typically scoped to the current working directory, but can be overridden using a path argument or the --instance flag.
  6. Using annotated diffs for ground truth

    main

    The framework supports .annotated.diff files (e.g., full.annotated.diff or individual *.annotated.diff files). Unlike other files in data/, these are tracked in git.

    You can use them to manually mark expected issues/bugs as ground truth for evaluation comparisons:

    1. View an annotated diff: cat apps/www/scripts/pr-review/evals/data/<pr-id>/full.annotated.diff
    2. Edit the file to add inline annotations.
    3. Commit the changes to git to preserve your ground truth annotations.
  7. Best practices for AI agents using cmux

    main

    When building AI agents that use cmux computer commands, follow these patterns to ensure reliability:

    1. Refresh Refs After Navigation: Element references (@e1, etc.) become stale as soon as the page changes. Always run cmux computer snapshot -i after any navigation or interaction that changes the DOM.
    2. Verify Actions: After performing an action like fill, use cmux computer get value to confirm the state.
    3. Use Waits for Dynamic Content: Don't assume a page is ready. Use cmux computer wait --text or cmux computer wait --url before attempting to interact with new elements.
    4. Save Checkpoints: Use cmux computer save --name=<name> after complex setup steps so you can resume from a known good state using --from=<name> if an error occurs.
  8. How to use OSC 52 for Clipboard Access

    main

    The OSC 52 sequence allows applications to interact with the system clipboard or the primary selection.

    Format: OSC 52 ; <target> ; <base64-data> ST

    Targets:

    • c: System clipboard
    • p: Primary selection

    Operations:

    • Read (Query): Send OSC 52 ; c ; ? ST to receive the current clipboard contents as base64.
    • Write: Send OSC 52 ; c ; <base64> ST to set the clipboard content.
  9. How browser automation architecture works

    main

    Browser automation in cmux devbox follows a multi-layered architecture:

    1. CLI (Local Machine): The user executes commands. For cmux exec, it reads a worker token from /var/run/cmux/worker-token.
    2. Worker Daemon (VM): A remote worker daemon (running on a .http.cloud.morph.so URL) receives requests. It requires a Bearer token for authentication.
    3. agent-browser (VM): The worker daemon wraps agent-browser (a Vercel tool) which connects to Chrome via the Chrome DevTools Protocol (CDP).
    4. Chrome (VM): The browser instance listening on 127.0.0.1:9222.