monarchagents 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- monarchagents-0.1.2/.env.example +45 -0
- monarchagents-0.1.2/.github/ISSUE_TEMPLATE/bug_report.md +21 -0
- monarchagents-0.1.2/.github/ISSUE_TEMPLATE/feature_request.md +12 -0
- monarchagents-0.1.2/.github/workflows/ci.yml +24 -0
- monarchagents-0.1.2/.gitignore +71 -0
- monarchagents-0.1.2/CONTRIBUTING.md +35 -0
- monarchagents-0.1.2/LICENSE +21 -0
- monarchagents-0.1.2/PKG-INFO +143 -0
- monarchagents-0.1.2/README.md +109 -0
- monarchagents-0.1.2/README.zh-CN.md +109 -0
- monarchagents-0.1.2/config.yaml +139 -0
- monarchagents-0.1.2/docs/design-1k-stars.md +154 -0
- monarchagents-0.1.2/docs/handoff.md +165 -0
- monarchagents-0.1.2/docs/images/overview-parliament-en.png +0 -0
- monarchagents-0.1.2/docs/images/overview-zh-court.png +0 -0
- monarchagents-0.1.2/docs/images/settings-cli-detection.png +0 -0
- monarchagents-0.1.2/examples/example_question.md +55 -0
- monarchagents-0.1.2/examples/monarch-real-cli-run-2026-12-01.md +26 -0
- monarchagents-0.1.2/examples/monarch-real-run-2026-12-01.md +26 -0
- monarchagents-0.1.2/examples/real-run-2026-11-30-eco.md +53 -0
- monarchagents-0.1.2/examples/real-run-2026-12-01-eco.md +33 -0
- monarchagents-0.1.2/plan.md +245 -0
- monarchagents-0.1.2/pyproject.toml +68 -0
- monarchagents-0.1.2/scripts/build_bundle.sh +30 -0
- monarchagents-0.1.2/scripts/build_windows.ps1 +28 -0
- monarchagents-0.1.2/scripts/desktop_entry.py +8 -0
- monarchagents-0.1.2/src/monarchagents/__init__.py +8 -0
- monarchagents-0.1.2/src/monarchagents/__main__.py +6 -0
- monarchagents-0.1.2/src/monarchagents/adapters/__init__.py +32 -0
- monarchagents-0.1.2/src/monarchagents/adapters/api.py +126 -0
- monarchagents-0.1.2/src/monarchagents/adapters/base.py +26 -0
- monarchagents-0.1.2/src/monarchagents/adapters/cli.py +130 -0
- monarchagents-0.1.2/src/monarchagents/cli.py +56 -0
- monarchagents-0.1.2/src/monarchagents/core/__init__.py +21 -0
- monarchagents-0.1.2/src/monarchagents/core/engine.py +429 -0
- monarchagents-0.1.2/src/monarchagents/desktop.py +127 -0
- monarchagents-0.1.2/src/monarchagents/locales/__init__.py +1585 -0
- monarchagents-0.1.2/src/monarchagents/storage/__init__.py +6 -0
- monarchagents-0.1.2/src/monarchagents/storage/db.py +119 -0
- monarchagents-0.1.2/src/monarchagents/storage/repo.py +391 -0
- monarchagents-0.1.2/src/monarchagents/themes/__init__.py +46 -0
- monarchagents-0.1.2/src/monarchagents/themes/en_royal.py +226 -0
- monarchagents-0.1.2/src/monarchagents/themes/parliament.py +320 -0
- monarchagents-0.1.2/src/monarchagents/themes/zh_court.py +161 -0
- monarchagents-0.1.2/src/monarchagents/tools/__init__.py +13 -0
- monarchagents-0.1.2/src/monarchagents/tools/mcp.py +125 -0
- monarchagents-0.1.2/src/monarchagents/tools/registry.py +116 -0
- monarchagents-0.1.2/src/monarchagents/tools/skills.py +163 -0
- monarchagents-0.1.2/src/monarchagents/web/__init__.py +5 -0
- monarchagents-0.1.2/src/monarchagents/web/app.py +411 -0
- monarchagents-0.1.2/src/monarchagents/web/static/assets/cabinet.jpg +0 -0
- monarchagents-0.1.2/src/monarchagents/web/static/assets/cabinet_en.jpg +0 -0
- monarchagents-0.1.2/src/monarchagents/web/static/assets/cabinet_parliament.jpg +0 -0
- monarchagents-0.1.2/src/monarchagents/web/static/assets/ministers_banner.jpg +0 -0
- monarchagents-0.1.2/src/monarchagents/web/static/assets/ministers_en.jpg +0 -0
- monarchagents-0.1.2/src/monarchagents/web/static/assets/ministers_parliament.jpg +0 -0
- monarchagents-0.1.2/src/monarchagents/web/static/assets/monarch.jpg +0 -0
- monarchagents-0.1.2/src/monarchagents/web/static/assets/monarch_en.jpg +0 -0
- monarchagents-0.1.2/src/monarchagents/web/static/assets/monarch_parliament.jpg +0 -0
- monarchagents-0.1.2/src/monarchagents/web/static/index.html +1512 -0
- monarchagents-0.1.2/src/researchcrew/__init__.py +11 -0
- monarchagents-0.1.2/src/researchcrew/agents.py +874 -0
- monarchagents-0.1.2/src/researchcrew/graph.py +99 -0
- monarchagents-0.1.2/src/researchcrew/llm.py +657 -0
- monarchagents-0.1.2/src/researchcrew/main.py +402 -0
- monarchagents-0.1.2/src/researchcrew/modes.py +174 -0
- monarchagents-0.1.2/src/researchcrew/router.py +104 -0
- monarchagents-0.1.2/src/researchcrew/state.py +96 -0
- monarchagents-0.1.2/src/researchcrew/static/dashboard.html +1226 -0
- monarchagents-0.1.2/src/researchcrew/tools.py +128 -0
- monarchagents-0.1.2/src/researchcrew/web.py +1036 -0
- monarchagents-0.1.2/tests/test_custom_providers.py +385 -0
- monarchagents-0.1.2/tests/test_desktop.py +27 -0
- monarchagents-0.1.2/tests/test_e2e_mock.py +197 -0
- monarchagents-0.1.2/tests/test_escalation.py +452 -0
- monarchagents-0.1.2/tests/test_modes.py +557 -0
- monarchagents-0.1.2/tests/test_monarch_m0.py +327 -0
- monarchagents-0.1.2/tests/test_monarch_m1.py +326 -0
- monarchagents-0.1.2/tests/test_monarch_m2.py +165 -0
- monarchagents-0.1.2/tests/test_ollama.py +50 -0
- monarchagents-0.1.2/tests/test_robustness.py +274 -0
- monarchagents-0.1.2/tests/test_roles_v03.py +103 -0
- monarchagents-0.1.2/tests/test_routing.py +385 -0
- monarchagents-0.1.2/tests/test_state.py +63 -0
- monarchagents-0.1.2/tests/test_tools.py +102 -0
- monarchagents-0.1.2/tests/test_v02.py +289 -0
- monarchagents-0.1.2/tests/test_web.py +404 -0
- monarchagents-0.1.2/uv.lock +1936 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Copy this file to `.env` and fill in your own keys. Never commit `.env`.
|
|
2
|
+
#
|
|
3
|
+
# At least one LLM key is required (DeepSeek is the default provider).
|
|
4
|
+
# A search key is optional: without it, ResearchCrew falls back to
|
|
5
|
+
# DuckDuckGo HTML search, which needs no key.
|
|
6
|
+
|
|
7
|
+
# --- LLM provider -----------------------------------------------------------
|
|
8
|
+
# Which provider to use by default: "deepseek" or "openai".
|
|
9
|
+
LLM_PROVIDER=deepseek
|
|
10
|
+
|
|
11
|
+
# DeepSeek (OpenAI-compatible endpoint). Get a key at https://platform.deepseek.com
|
|
12
|
+
DEEPSEEK_API_KEY=
|
|
13
|
+
# Optional: override the DeepSeek model (default: deepseek-chat)
|
|
14
|
+
# DEEPSEEK_MODEL=deepseek-chat
|
|
15
|
+
|
|
16
|
+
# OpenAI. Get a key at https://platform.openai.com/api-keys
|
|
17
|
+
OPENAI_API_KEY=
|
|
18
|
+
# Optional: override the OpenAI model (default: gpt-4o-mini)
|
|
19
|
+
# OPENAI_MODEL=gpt-4o-mini
|
|
20
|
+
|
|
21
|
+
# Ollama (local models, no API key required).
|
|
22
|
+
# Start Ollama locally (`ollama serve`) and set LLM_PROVIDER=ollama.
|
|
23
|
+
# OLLAMA_BASE_URL=http://localhost:11434/v1
|
|
24
|
+
# OLLAMA_MODEL=llama3.2
|
|
25
|
+
|
|
26
|
+
# Custom provider: baifan relay (an OpenAI-compatible third-party API).
|
|
27
|
+
# The key goes with the `baifan` entry under `custom_providers:` in
|
|
28
|
+
# config.yaml; any custom provider only needs its own key env var set.
|
|
29
|
+
# Only the deepseek-v4.1-flash-eco model has been verified to work.
|
|
30
|
+
BAIFAN_API_KEY=
|
|
31
|
+
|
|
32
|
+
# Optional: a single model name that overrides the provider default above.
|
|
33
|
+
# LLM_MODEL=
|
|
34
|
+
|
|
35
|
+
# Per-role models are configured in config.yaml (`agents:` section), and the
|
|
36
|
+
# fallback model in its `fallback:` section — no env vars needed for those.
|
|
37
|
+
|
|
38
|
+
# --- Web search -------------------------------------------------------------
|
|
39
|
+
# Tavily search API key (optional). Get one at https://tavily.com
|
|
40
|
+
# ResearchCrew accepts either spelling of the variable name.
|
|
41
|
+
TAVILY_API_KEY=
|
|
42
|
+
TAVILIO_API_KEY=
|
|
43
|
+
|
|
44
|
+
# Optional: how many search results to use per sub-task (default: 5)
|
|
45
|
+
# SEARCH_MAX_RESULTS=5
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug Report
|
|
3
|
+
about: Report a bug in MonarchAgents
|
|
4
|
+
title: "[Bug] "
|
|
5
|
+
labels: bug
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
### Describe the bug
|
|
9
|
+
A clear and concise description of what happened.
|
|
10
|
+
|
|
11
|
+
### Steps to reproduce
|
|
12
|
+
1. Start server with `python -m monarchagents serve`
|
|
13
|
+
2. ...
|
|
14
|
+
|
|
15
|
+
### Expected behavior
|
|
16
|
+
What you expected to happen.
|
|
17
|
+
|
|
18
|
+
### Environment
|
|
19
|
+
- OS:
|
|
20
|
+
- Python version:
|
|
21
|
+
- Adapter / Provider (CLI or API):
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature Request
|
|
3
|
+
about: Suggest a new theme, CLI adapter, or capability
|
|
4
|
+
title: "[Feature] "
|
|
5
|
+
labels: enhancement
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
### Summary
|
|
9
|
+
What feature, theme, or adapter would you like to see?
|
|
10
|
+
|
|
11
|
+
### Motivation
|
|
12
|
+
Why is this useful for MonarchAgents workflows?
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main, monarch]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main, monarch]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
- uses: actions/setup-python@v5
|
|
15
|
+
with:
|
|
16
|
+
python-version: "3.11"
|
|
17
|
+
- name: Install dependencies
|
|
18
|
+
run: |
|
|
19
|
+
python -m pip install --upgrade pip
|
|
20
|
+
pip install -e ".[dev]"
|
|
21
|
+
- name: Lint with ruff
|
|
22
|
+
run: ruff check src tests
|
|
23
|
+
- name: Run tests
|
|
24
|
+
run: pytest tests/ -q
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
.Python
|
|
7
|
+
build/
|
|
8
|
+
develop-eggs/
|
|
9
|
+
dist/
|
|
10
|
+
downloads/
|
|
11
|
+
eggs/
|
|
12
|
+
.eggs/
|
|
13
|
+
lib/
|
|
14
|
+
lib64/
|
|
15
|
+
parts/
|
|
16
|
+
sdist/
|
|
17
|
+
var/
|
|
18
|
+
wheels/
|
|
19
|
+
*.egg-info/
|
|
20
|
+
.installed.cfg
|
|
21
|
+
*.egg
|
|
22
|
+
MANIFEST
|
|
23
|
+
|
|
24
|
+
# Virtual environments
|
|
25
|
+
.env
|
|
26
|
+
.venv
|
|
27
|
+
env/
|
|
28
|
+
venv/
|
|
29
|
+
ENV/
|
|
30
|
+
env.bak/
|
|
31
|
+
venv.bak/
|
|
32
|
+
|
|
33
|
+
# Environment variables (never commit real keys)
|
|
34
|
+
.env
|
|
35
|
+
.env.local
|
|
36
|
+
|
|
37
|
+
# Testing / coverage
|
|
38
|
+
.tox/
|
|
39
|
+
.coverage
|
|
40
|
+
.coverage.*
|
|
41
|
+
htmlcov/
|
|
42
|
+
.pytest_cache/
|
|
43
|
+
.cache
|
|
44
|
+
nosetests.xml
|
|
45
|
+
coverage.xml
|
|
46
|
+
*.cover
|
|
47
|
+
|
|
48
|
+
# Type checkers
|
|
49
|
+
.mypy_cache/
|
|
50
|
+
.dmypy.json
|
|
51
|
+
dmypy.json
|
|
52
|
+
.pyre/
|
|
53
|
+
.pytype/
|
|
54
|
+
|
|
55
|
+
# IDEs
|
|
56
|
+
.idea/
|
|
57
|
+
.vscode/
|
|
58
|
+
*.swp
|
|
59
|
+
*.swo
|
|
60
|
+
*~
|
|
61
|
+
|
|
62
|
+
# OS
|
|
63
|
+
.DS_Store
|
|
64
|
+
Thumbs.db
|
|
65
|
+
|
|
66
|
+
# Project outputs
|
|
67
|
+
output/
|
|
68
|
+
*.md.report
|
|
69
|
+
|
|
70
|
+
# Run checkpoints (SQLite, one file per run-id) — resumable runs
|
|
71
|
+
runs/
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Contributing to MonarchAgents
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to **MonarchAgents**!
|
|
4
|
+
|
|
5
|
+
## Development Setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
git clone https://github.com/hx2167564036-hash/MonarchAgents.git
|
|
9
|
+
cd MonarchAgents
|
|
10
|
+
uv sync --extra dev
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Run tests and lint before opening a PR:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
.venv/bin/python -m pytest tests/ -q
|
|
17
|
+
.venv/bin/python -m ruff check src tests
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Ways to Contribute
|
|
21
|
+
|
|
22
|
+
1. **Add a Cultural Theme**:
|
|
23
|
+
- Create a single file under `src/monarchagents/themes/<your_theme>.py` defining `THEME` (`id`, `name`, `terms`, `css_vars`).
|
|
24
|
+
- Register it in `src/monarchagents/themes/__init__.py`.
|
|
25
|
+
- Ensure all neutral keys match `THEME_TERM_KEYS` (verified by `tests/test_monarch_m0.py`).
|
|
26
|
+
2. **Add a CLI Adapter**:
|
|
27
|
+
- Implement `BaseAdapter.dispatch` in `src/monarchagents/adapters/cli.py` with structured output parsing and mock tests.
|
|
28
|
+
3. **Share a Skill**:
|
|
29
|
+
- Any GitHub repository with a `SKILL.md` (YAML `name` + `description` frontmatter) can be installed directly in the Skills view.
|
|
30
|
+
|
|
31
|
+
## Rules
|
|
32
|
+
|
|
33
|
+
- Keep internal logic neutral (`monarch`, `cabinet`, `minister`, `memorial`, `appointments`); never hardcode theme terminology in backend logic.
|
|
34
|
+
- Token counts must come strictly from provider metadata — never estimate or fabricate usage.
|
|
35
|
+
- Never commit `.env`, API keys, or local `runs/` databases.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Hux Chen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: monarchagents
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: MonarchAgents — you are the monarch, they are the agents. Local-first multi-agent collaboration platform.
|
|
5
|
+
Author: Hux Chen
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Keywords: langgraph,llm,multi-agent,research
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Requires-Python: >=3.11
|
|
16
|
+
Requires-Dist: fastapi>=0.115
|
|
17
|
+
Requires-Dist: langchain-anthropic>=0.3
|
|
18
|
+
Requires-Dist: langchain-core>=0.3
|
|
19
|
+
Requires-Dist: langchain-openai>=0.3
|
|
20
|
+
Requires-Dist: langgraph-checkpoint-sqlite>=3.0
|
|
21
|
+
Requires-Dist: langgraph>=0.2
|
|
22
|
+
Requires-Dist: pydantic>=2.0
|
|
23
|
+
Requires-Dist: python-dotenv>=1.0
|
|
24
|
+
Requires-Dist: pyyaml>=6.0
|
|
25
|
+
Requires-Dist: requests>=2.32
|
|
26
|
+
Requires-Dist: uvicorn>=0.30
|
|
27
|
+
Provides-Extra: desktop
|
|
28
|
+
Requires-Dist: pyinstaller>=6.0; extra == 'desktop'
|
|
29
|
+
Requires-Dist: pywebview>=5.0; extra == 'desktop'
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
32
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
33
|
+
Description-Content-Type: text/markdown
|
|
34
|
+
|
|
35
|
+
# MonarchAgents
|
|
36
|
+
|
|
37
|
+
**English** | [简体中文](README.zh-CN.md)
|
|
38
|
+
|
|
39
|
+

|
|
40
|
+

|
|
41
|
+

|
|
42
|
+
|
|
43
|
+
**MonarchAgents — you are the monarch, they are the agents.**
|
|
44
|
+
(你当君主,agents 替你办事。)
|
|
45
|
+
|
|
46
|
+
MonarchAgents is an open-source, local-first multi-agent collaboration platform.
|
|
47
|
+
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.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Why MonarchAgents?
|
|
52
|
+
|
|
53
|
+
- **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*).
|
|
54
|
+
- **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.
|
|
55
|
+
- **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`).
|
|
56
|
+
- **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`.
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Quickstart
|
|
61
|
+
|
|
62
|
+
### Option A: Desktop App (Recommended — No Python Setup Required)
|
|
63
|
+
|
|
64
|
+
Download the latest release from [GitHub Releases](https://github.com/hx2167564036-hash/MonarchAgents/releases/latest):
|
|
65
|
+
|
|
66
|
+
- **macOS (Apple Silicon / arm64)**: Unzip `MonarchAgents-macos-arm64.zip` and open `MonarchAgents.app`
|
|
67
|
+
*(First launch on macOS: if Gatekeeper warns about an unsigned app, right-click `MonarchAgents.app` → **Open**, or run `xattr -dr com.apple.quarantine MonarchAgents.app`.)*
|
|
68
|
+
- **Windows (x64)**: Unzip `MonarchAgents-windows-x64.zip` and double-click `MonarchAgents.exe`
|
|
69
|
+
|
|
70
|
+
### Option B: Run from Source
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
git clone https://github.com/hx2167564036-hash/MonarchAgents.git
|
|
74
|
+
cd MonarchAgents
|
|
75
|
+
uv sync --extra dev
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Or with standard `pip`:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
python -m venv .venv && source .venv/bin/activate
|
|
82
|
+
pip install -e ".[dev]"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Configure API keys (optional if using local CLIs or Ollama):
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
cp .env.example .env
|
|
89
|
+
# Add keys you use, e.g. DEEPSEEK_API_KEY, OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY, BAIFAN_API_KEY
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Launch the local platform (or desktop window with `desktop`):
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
.venv/bin/python -m monarchagents serve --host 127.0.0.1 --port 8000
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
First-run flow:
|
|
99
|
+
1. **Onboarding**: Pick your language and cultural theme, then walk through the 5-step interactive tutorial.
|
|
100
|
+
2. **Settings**: Register your CLI (`claude_code` / `codex` / `gemini_cli`) or API agents.
|
|
101
|
+
3. **Appointments**: Appoint a **Cabinet** position (reports to Monarch) and one or more **Minister** positions (with explicit `scope` and allowed `tools`).
|
|
102
|
+
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**.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Real End-to-End Run Archives
|
|
107
|
+
|
|
108
|
+
- [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`).
|
|
109
|
+
- [Real API Rejection & Escalation Run](examples/monarch-real-run-2026-12-01.md) — 3 Cabinet rejections + Monarch escalation resolution + provider-reported costs (`tsk_3208540069`).
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Build Desktop App Locally
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
# macOS (.app + .zip)
|
|
117
|
+
uv sync --extra desktop
|
|
118
|
+
bash scripts/build_bundle.sh
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
```powershell
|
|
122
|
+
# Windows (.exe + .zip)
|
|
123
|
+
uv sync --extra desktop
|
|
124
|
+
powershell -ExecutionPolicy Bypass -File scripts\build_windows.ps1
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Development & Contributing
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
.venv/bin/python -m pytest tests/ -q
|
|
133
|
+
.venv/bin/python -m ruff check src tests
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for adding new themes, CLI adapters, or skills.
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## Architecture & History
|
|
141
|
+
|
|
142
|
+
- `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`).
|
|
143
|
+
- `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.
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# MonarchAgents
|
|
2
|
+
|
|
3
|
+
**English** | [简体中文](README.zh-CN.md)
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
**MonarchAgents — you are the monarch, they are the agents.**
|
|
10
|
+
(你当君主,agents 替你办事。)
|
|
11
|
+
|
|
12
|
+
MonarchAgents is an open-source, local-first multi-agent collaboration platform.
|
|
13
|
+
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.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Why MonarchAgents?
|
|
18
|
+
|
|
19
|
+
- **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*).
|
|
20
|
+
- **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.
|
|
21
|
+
- **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`).
|
|
22
|
+
- **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`.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Quickstart
|
|
27
|
+
|
|
28
|
+
### Option A: Desktop App (Recommended — No Python Setup Required)
|
|
29
|
+
|
|
30
|
+
Download the latest release from [GitHub Releases](https://github.com/hx2167564036-hash/MonarchAgents/releases/latest):
|
|
31
|
+
|
|
32
|
+
- **macOS (Apple Silicon / arm64)**: Unzip `MonarchAgents-macos-arm64.zip` and open `MonarchAgents.app`
|
|
33
|
+
*(First launch on macOS: if Gatekeeper warns about an unsigned app, right-click `MonarchAgents.app` → **Open**, or run `xattr -dr com.apple.quarantine MonarchAgents.app`.)*
|
|
34
|
+
- **Windows (x64)**: Unzip `MonarchAgents-windows-x64.zip` and double-click `MonarchAgents.exe`
|
|
35
|
+
|
|
36
|
+
### Option B: Run from Source
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
git clone https://github.com/hx2167564036-hash/MonarchAgents.git
|
|
40
|
+
cd MonarchAgents
|
|
41
|
+
uv sync --extra dev
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Or with standard `pip`:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
python -m venv .venv && source .venv/bin/activate
|
|
48
|
+
pip install -e ".[dev]"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Configure API keys (optional if using local CLIs or Ollama):
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
cp .env.example .env
|
|
55
|
+
# Add keys you use, e.g. DEEPSEEK_API_KEY, OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY, BAIFAN_API_KEY
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Launch the local platform (or desktop window with `desktop`):
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
.venv/bin/python -m monarchagents serve --host 127.0.0.1 --port 8000
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
First-run flow:
|
|
65
|
+
1. **Onboarding**: Pick your language and cultural theme, then walk through the 5-step interactive tutorial.
|
|
66
|
+
2. **Settings**: Register your CLI (`claude_code` / `codex` / `gemini_cli`) or API agents.
|
|
67
|
+
3. **Appointments**: Appoint a **Cabinet** position (reports to Monarch) and one or more **Minister** positions (with explicit `scope` and allowed `tools`).
|
|
68
|
+
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**.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Real End-to-End Run Archives
|
|
73
|
+
|
|
74
|
+
- [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`).
|
|
75
|
+
- [Real API Rejection & Escalation Run](examples/monarch-real-run-2026-12-01.md) — 3 Cabinet rejections + Monarch escalation resolution + provider-reported costs (`tsk_3208540069`).
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Build Desktop App Locally
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# macOS (.app + .zip)
|
|
83
|
+
uv sync --extra desktop
|
|
84
|
+
bash scripts/build_bundle.sh
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
```powershell
|
|
88
|
+
# Windows (.exe + .zip)
|
|
89
|
+
uv sync --extra desktop
|
|
90
|
+
powershell -ExecutionPolicy Bypass -File scripts\build_windows.ps1
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Development & Contributing
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
.venv/bin/python -m pytest tests/ -q
|
|
99
|
+
.venv/bin/python -m ruff check src tests
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for adding new themes, CLI adapters, or skills.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Architecture & History
|
|
107
|
+
|
|
108
|
+
- `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`).
|
|
109
|
+
- `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.
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# MonarchAgents
|
|
2
|
+
|
|
3
|
+
[English](README.md) | **简体中文**
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
**MonarchAgents —— 你当君主,agents 替你办事。**
|
|
10
|
+
*(You are the monarch, they are the agents.)*
|
|
11
|
+
|
|
12
|
+
MonarchAgents 是一个开源、本地优先(Local-first)的多智能体协作平台。
|
|
13
|
+
你只需下达高层指令;由你任命的 **内阁(Cabinet)** 负责澄清需求、拆解分工并呈报确认清单;各 **臣子(Minister)**(支持本机 Claude Code、Codex、Gemini CLI 或各类 API 模型)在明确职权与工具白名单内执行;内阁先对交付物逐项验收,不合格直接带理由打回重写,达标后再呈报给你批阅。
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 核心特性
|
|
18
|
+
|
|
19
|
+
- **全程可控的人机协同(Human-in-the-loop)**:确认清单未通过你批准前不会派发任务;交付物未经内阁验收前不会呈报给你。连续打回 3 次(可配置)自动升级呈报君主拍板(*继续 / 调整方案 / 照此接收*)。
|
|
20
|
+
- **CLI + API + MCP + GitHub Skills 全打通**:支持接入本机命令行代理(**Claude Code**、**Codex**、**Gemini CLI**),内置 **10 家主流 API 提供商**(DeepSeek、OpenAI、Anthropic Claude、Google Gemini、OpenRouter、xAI Grok、Qwen、Kimi、GLM、Ollama)及自定义中转站;支持直接在界面挂载 **stdio MCP 服务** 和一键安装 **GitHub `SKILL.md` 技能**。
|
|
21
|
+
- **可插拔文化主题 + 10 国语言**:支持在 **中国朝廷(`zh_court`)**、**西方王庭(`en_royal`)** 与 **议会内阁(`parliament`)** 之间无缝切换,并配备独立 **10 语言切换**(中文、English、日本語、한국어、Français、Deutsch、Español、Português、Русский、العربية)。
|
|
22
|
+
- **本地优先与全程可审计**:官职任命/罢免、确认清单、打回记录、奏折交付物、Agent 间通信与真实 Token 成本(仅记录接口实报,绝不估算)全部保存在本地 SQLite;API Key 仅存于本地 `.env`。
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## 快速上手
|
|
27
|
+
|
|
28
|
+
### 方式一:直接下载桌面 App(推荐,无需配置 Python)
|
|
29
|
+
|
|
30
|
+
前往 [GitHub Releases](https://github.com/hx2167564036-hash/MonarchAgents/releases/latest) 下载最新版本:
|
|
31
|
+
|
|
32
|
+
- **macOS(Apple Silicon / arm64)**:解压 `MonarchAgents-macos-arm64.zip`,双击打开 `MonarchAgents.app`
|
|
33
|
+
*(首次打开如系统提示未签名应用,右键 `MonarchAgents.app` → **打开**,或执行 `xattr -dr com.apple.quarantine MonarchAgents.app`。)*
|
|
34
|
+
- **Windows(x64)**:解压 `MonarchAgents-windows-x64.zip`,双击运行 `MonarchAgents.exe`
|
|
35
|
+
|
|
36
|
+
### 方式二:从源码运行
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
git clone https://github.com/hx2167564036-hash/MonarchAgents.git
|
|
40
|
+
cd MonarchAgents
|
|
41
|
+
uv sync --extra dev
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
或使用标准 `pip`:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
python -m venv .venv && source .venv/bin/activate
|
|
48
|
+
pip install -e ".[dev]"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
配置 API Key(如仅使用本机 CLI 或 Ollama 可跳过):
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
cp .env.example .env
|
|
55
|
+
# 填入所需 Key,例如 DEEPSEEK_API_KEY、OPENAI_API_KEY、ANTHROPIC_API_KEY、GEMINI_API_KEY、BAIFAN_API_KEY
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
启动本地 Web 服务(或使用 `desktop` 启动独立桌面窗口):
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
.venv/bin/python -m monarchagents serve --host 127.0.0.1 --port 8000
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
首次使用流程:
|
|
65
|
+
1. **新手引导**:选择系统语言与文化主题,跟随 5 步交互式教程快速熟悉界面。
|
|
66
|
+
2. **人员配置(Settings)**:登记本机 CLI(`claude_code` / `codex` / `gemini_cli`)或 API Agent。
|
|
67
|
+
3. **封官授职(Appointments)**:任命一位 **内阁(Cabinet)**(直接对君主负责)以及若干 **臣子(Minister)** 官职,明确职责范围(`scope`)和允许使用的工具。
|
|
68
|
+
4. **总览御批(Overview)**:下达圣旨 → 逐项确认内阁提交的分工清单 → 在 **奏折(Memorials)** 查看交付物与验收结论,在 **任务(Tasks)** 查看完整日志与成本。
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 真实端到端运行归档
|
|
73
|
+
|
|
74
|
+
- [真实 Codex CLI + API 实测归档](examples/monarch-real-cli-run-2026-12-01.md) — 本机 `codex-cli` 任臣子 + `baifan/deepseek-v4.1-flash-eco` 任内阁(`tsk_08ba6d7213`,`presented`)。
|
|
75
|
+
- [真实 API 3 次打回升级实测归档](examples/monarch-real-run-2026-12-01.md) — 演示内阁连续打回 3 次后升级呈报君主拍板与真实成本记账(`tsk_3208540069`)。
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## 本地构建桌面安装包
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# macOS (.app + .zip)
|
|
83
|
+
uv sync --extra desktop
|
|
84
|
+
bash scripts/build_bundle.sh
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
```powershell
|
|
88
|
+
# Windows (.exe + .zip)
|
|
89
|
+
uv sync --extra desktop
|
|
90
|
+
powershell -ExecutionPolicy Bypass -File scripts\build_windows.ps1
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## 开发与贡献
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
.venv/bin/python -m pytest tests/ -q
|
|
99
|
+
.venv/bin/python -m ruff check src tests
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
欢迎阅读 [CONTRIBUTING.md](CONTRIBUTING.md) 了解如何新增文化主题、CLI 适配器或技能。
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## 目录架构
|
|
107
|
+
|
|
108
|
+
- `src/monarchagents/` — 朝堂状态机核心(`core/`)、CLI/API 适配器(`adapters/`)、工具注册/MCP 客户端/GitHub Skills 安装器(`tools/`)、SQLite 持久化(`storage/`)、文化主题(`themes/`)、10 国语言包(`locales/`)、FastAPI Web 界面(`web/`)以及桌面端启动器(`desktop.py`)。
|
|
109
|
+
- `src/researchcrew/` — 保留自 **ResearchCrew**(`v0.1–v0.3`),由 `monarchagents.adapters` 与 `monarchagents.tools` 直接复用其多模型路由、降级策略与网页检索能力。
|