Metadata-Version: 2.5
Name: monarchagents
Version: 0.1.6
Summary: MonarchAgents — you are the monarch, they are the agents. Local-first multi-agent collaboration platform.
Author: Hux Chen
License-Expression: MIT
License-File: LICENSE
Keywords: langgraph,llm,multi-agent,research
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.11
Requires-Dist: fastapi>=0.115
Requires-Dist: langchain-anthropic>=0.3
Requires-Dist: langchain-core>=0.3
Requires-Dist: langchain-openai>=0.3
Requires-Dist: langgraph-checkpoint-sqlite>=3.0
Requires-Dist: langgraph>=0.2
Requires-Dist: pydantic>=2.0
Requires-Dist: python-dotenv>=1.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: requests>=2.32
Requires-Dist: uvicorn>=0.30
Provides-Extra: desktop
Requires-Dist: pyinstaller>=6.0; extra == 'desktop'
Requires-Dist: pywebview>=5.0; extra == 'desktop'
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Description-Content-Type: text/markdown

# MonarchAgents

**English** | [简体中文](README.zh-CN.md)

![Python](https://img.shields.io/badge/python-3.11%2B-blue)
![License](https://img.shields.io/badge/license-MIT-green)
![Ruff](https://img.shields.io/badge/lint-ruff-blue)

**MonarchAgents — you are the monarch, they are the agents.**  
（你当君主，agents 替你办事。）

MonarchAgents is an open-source, local-first multi-agent collaboration platform.  
You give high-level direction; an appointed **Cabinet** agent clarifies requirements, proposes a division of labor, and presents a confirmation checklist; **Minister** agents (your local CLI agents like Claude Code, Codex, Gemini CLI, or API-backed models) execute within scoped positions; the Cabinet reviews deliverables first and rejects substandard work (with mandatory reasons) before presenting approved results to you.

---

## Why MonarchAgents?

- **Human-in-the-loop by design**: Nothing is dispatched until you confirm the Cabinet's checklist; nothing reaches you until the Cabinet verifies it. After 3 rejections (configurable), the Cabinet escalates to you (*Continue*, *Adjust Plan*, or *Accept As Is*).
- **CLI + API + MCP + GitHub Skills**: Connect local coding CLIs (**Claude Code**, **Codex**, **Gemini CLI**) alongside **10 built-in API providers** (DeepSeek, OpenAI, Anthropic Claude, Google Gemini, OpenRouter, xAI Grok, Qwen, Kimi, GLM, Ollama) and custom relays. Attach **stdio MCP servers** or install **GitHub `SKILL.md` skills** directly in the UI.
- **Pluggable Cultural Themes + 10 Languages**: Switch seamlessly between **Chinese Imperial Court (`zh_court`)**, **Western Royal Court (`en_royal`)**, and **Parliamentary Cabinet (`parliament`)**, with an independent **10-language switcher** (`zh`, `en`, `ja`, `ko`, `fr`, `de`, `es`, `pt`, `ru`, `ar`).
- **Local-first & Auditable**: Positions, appointments/dismissals, confirmation checklists, rejections, memorials, inter-agent messages, and provider-reported token costs (never estimated) are stored locally in SQLite. API keys stay in `.env`.

---

## Screenshots

The Chinese Imperial Court theme with the Chinese UI — the court scene, the Cabinet Secretary's seal, and the three-step court setup:

![MonarchAgents — Chinese Imperial Court](docs/images/overview-zh-court.png)

The Parliamentary Cabinet theme with the English UI — same product, different court:

![MonarchAgents — Parliamentary Cabinet](docs/images/overview-parliament-en.png)

Settings: registering an agent, with automatic detection of locally installed CLIs (Claude Code / Codex / Gemini CLI):

![MonarchAgents — Settings with CLI detection](docs/images/settings-cli-detection.png)

---

## Quickstart

### Option A: Desktop App (Recommended — No Python Setup Required)

Download the latest release from [GitHub Releases](https://github.com/hx2167564036-hash/MonarchAgents/releases/latest):

- **macOS (Apple Silicon / arm64)** — v0.1.3 and later: open `MonarchAgents-macos-arm64.dmg` and drag **MonarchAgents** into the **Applications** folder, then launch it from there.
  *(First launch: the app is not yet signed with an Apple Developer ID, so Gatekeeper may warn — right-click the app → **Open** → **Open** to allow it once.)*
- **Windows (x64)** — v0.1.3 and later: run `MonarchAgents-Setup-x64.exe` and follow the installer (Start Menu shortcut, optional desktop shortcut, uninstaller included).
  *(First launch: SmartScreen may warn about an unsigned app — choose **More info** → **Run anyway**.)*
- *Earlier releases (up to v0.1.2) shipped as `.zip`: unzip and open the app directly. A portable `.zip` stays attached to every release as an alternative.*

**Connect an agent before your first edict**: MonarchAgents ships without agents. Local CLI agents (Claude Code, Codex, Gemini CLI) are detected automatically — check the **Settings** page. For API agents, register one on the same page: pick the provider, paste your API key into the form (stored only on this device), and hit **Test Connection** to verify it before your first edict. (Alternatively, keys can come from a `.env` file in the app data folder — macOS: `~/Library/Application Support/MonarchAgents/.env`, Windows: `%LOCALAPPDATA%\MonarchAgents\.env`.)

### Option B: Run from Source

```bash
git clone https://github.com/hx2167564036-hash/MonarchAgents.git
cd MonarchAgents
uv sync --extra dev
```

Or with standard `pip`:

```bash
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
```

Configure API keys (optional if using local CLIs or Ollama):

```bash
cp .env.example .env
# Add keys you use, e.g. DEEPSEEK_API_KEY, OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY, BAIFAN_API_KEY
```

Launch the local platform (or desktop window with `desktop`):

```bash
.venv/bin/python -m monarchagents serve --host 127.0.0.1 --port 8000
```

First-run flow:
1. **Onboarding**: Pick your language and cultural theme, then walk through the 5-step interactive tutorial.
2. **Settings**: Register your CLI (`claude_code` / `codex` / `gemini_cli`) or API agents.
3. **Appointments**: Appoint a **Cabinet** position (reports to Monarch) and one or more **Minister** positions (with explicit `scope` and allowed `tools`).
4. **Overview**: Issue an edict → review and confirm the Cabinet's checklist item by item → inspect deliverables & acceptance verdicts in **Memorials** and full logs/costs in **Tasks**.

---

## Real End-to-End Run Archives

- [Real Codex CLI + API Run](examples/monarch-real-cli-run-2026-12-01.md) — `codex-cli` Minister + `baifan/deepseek-v4.1-flash-eco` Cabinet (`tsk_08ba6d7213`, `presented`).
- [Real API Rejection & Escalation Run](examples/monarch-real-run-2026-12-01.md) — 3 Cabinet rejections + Monarch escalation resolution + provider-reported costs (`tsk_3208540069`).

---

## Build Desktop App Locally

```bash
# macOS (.app + drag-to-install .dmg + .zip)
uv sync --extra desktop
bash scripts/build_bundle.sh
```

```powershell
# Windows (.exe + .zip; also builds MonarchAgents-Setup-x64.exe when Inno Setup 6 is installed)
uv sync --extra desktop
powershell -ExecutionPolicy Bypass -File scripts\build_windows.ps1
```

---

## Development & Contributing

```bash
.venv/bin/python -m pytest tests/ -q
.venv/bin/python -m ruff check src tests
```

See [CONTRIBUTING.md](CONTRIBUTING.md) for adding new themes, CLI adapters, or skills.

---

## Architecture & History

- `src/monarchagents/` — Court core (`core/`), CLI & API adapters (`adapters/`), ToolRegistry / MCP client / GitHub skills installer (`tools/`), SQLite persistence (`storage/`), themes (`themes/`), 10-language locales (`locales/`), FastAPI Web UI (`web/`), and desktop launcher (`desktop.py`).
- `src/researchcrew/` — Preserved from **ResearchCrew** (`v0.1–v0.3`) and imported directly by `monarchagents.adapters` and `monarchagents.tools` for LLM provider routing, fallback, and web search/fetch.
