> ## Documentation Index
> Fetch the complete documentation index at: https://diasporic3lee7-ci-auto-mmdc-diagram-render.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Termux Multi-Agent: Agent Provisioning and Orchestration

> Provision and orchestrate autonomous agents in Termux with environment-driven tasks, a dashboard, and CedarScript MCP server integration.

The Termux Multi-Agent system provisions and orchestrates autonomous agents inside Termux on Android. It reads tasks from a central task registry, dispatches them through environment variables, and provides a live dashboard for monitoring agent state. The system also includes a CedarScript MCP server for external tool integration.

## Core components

The multi-agent system lives in the `termux-multi-agent/` directory and contains the following modules:

* **`run.py`** — Main orchestration loop that initializes the database and starts the agent scheduler
* **`provision_agent.py`** — Provisions a new agent with a unique identity, workspace, and environment
* **`dashboard.py`** — Live terminal dashboard showing active agents, task queue, and completion status
* **`patch_files.py`** — Applies file patches generated by agents during task execution
* **`cedar-mcp-server.js`** — CedarScript MCP server that exposes agent capabilities to external clients

## Task management

Agents receive tasks through environment variables rather than interactive prompts. The orchestrator reads the master task list from `~/workspace/llm_map/master_tasks.json` and binds each task to an agent via the following variables:

| Variable | Purpose |
| - | - |
| `TASK_ID` | Unique identifier for the task instance |
| `REFACTOR_GOAL` | Human-readable objective assigned to the agent |
| `TARGET_FILE` | Primary file the agent should operate on |
| `TASK_WORKSPACE` | Directory where the agent writes outputs and logs |

## Running an autonomous agent

Follow these steps to provision an agent and run it against a task from the master registry.

<Steps>
  <Step title="Initialize the database">
    From the `termux-multi-agent/` directory, run the initialization script. This creates the SQLite database that tracks agents, tasks, and outcomes.

    ```bash theme={null}
    cd termux-multi-agent
    python run.py
    ```

    <Note>
      Run this once. The database persists across restarts and holds agent state.
    </Note>
  </Step>

  <Step title="Review the task registry">
    Inspect `~/workspace/llm_map/master_tasks.json` to find the task you want to dispatch. Each entry contains a `task_id`, `goal`, `target`, and optional `constraints`.
  </Step>

  <Step title="Provision an agent">
    Use `provision_agent.py` to create a new agent. The script assigns a workspace under `termux-multi-agent/workspaces/` and writes the environment file.

    ```bash theme={null}
    python provision_agent.py --task-id TASK_001
    ```
  </Step>

  <Step title="Set environment variables">
    Export the task variables so the agent can read them at startup. You can also write them to the agent's `.env` file.

    ```bash theme={null}
    export TASK_ID="TASK_001"
    export REFACTOR_GOAL="Extract helper functions into a module"
    export TARGET_FILE="src/core.py"
    export TASK_WORKSPACE="termux-multi-agent/workspaces/TASK_001"
    ```
  </Step>

  <Step title="Start the agent">
    Launch the agent run loop. The agent reads its environment, loads the target file, performs the refactor, and writes results to `TASK_WORKSPACE`.

    ```bash theme={null}
    python run.py --agent-id TASK_001
    ```
  </Step>

  <Step title="Monitor with the dashboard">
    In a separate Termux session, open the live dashboard to watch progress.

    ```bash theme={null}
    python dashboard.py
    ```
  </Step>
</Steps>

## CedarScript MCP server

The CedarScript MCP server (`cedar-mcp-server.js`) exposes agent operations to external clients through the Model Context Protocol. Start it when you need to integrate the multi-agent system with an IDE or another orchestrator.

```bash theme={null}
node cedar-mcp-server.js
```

<Warning>
  The MCP server requires Node.js to be installed in Termux via `pkg install nodejs`.
</Warning>

## Next steps

<CardGroup cols={2}>
  <Card title="Autonomous Tasks Guide" icon="bot" href="/guides/autonomous-tasks">
    Learn advanced patterns for dispatching and chaining agent tasks.
  </Card>

  <Card title="First Session Guide" icon="play" href="/guides/first-session">
    Walk through a complete ArchWiz session with agent integration.
  </Card>
</CardGroup>
