1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132 | # Setup
This is a stdlib-only Python agent โ no `pip install`, no Docker, no build
step. The work is: get Python 3.9+, get one API key, and fix a few paths
that were hardcoded to the original author's machine.
## What you need
| Requirement | Why | Have it already? |
|---|---|---|
| macOS or Linux with a shell | `agent.py` shells out via `/bin/bash -lc`; any POSIX shell works | Check: `which bash` |
| Python 3.9 or newer | `pathlib`, f-strings, and the stdlib modules used throughout (`urllib`, `http.server`, `hmac`, `argparse`) | Check: `python3 --version` |
| An Anthropic API key | The only required credential โ `agent.py` exits immediately without `ANTHROPIC_API_KEY` | Get one at console.anthropic.com |
| Homebrew (macOS only, optional) | Only needed if you don't already have Python 3, or if you wire up the SendBlue tunnel (`cloudflared`/`ngrok`) | Check: `which brew` |
**NOT needed:**
- No Docker โ nothing here runs in a container.
- No `pip install` โ every file imports only the Python standard library (`urllib`, `json`, `subprocess`, `hashlib`, `hmac`, `http.server`, `threading`, `argparse`, `pathlib`, `logging`, `re`, `shlex`, `importlib`). There is no `requirements.txt` in this repo because none is needed.
- No GPU.
- No database to install โ Supabase (if you use it) is a hosted service you connect to over HTTPS, not something you run.
- No account required to run the core agent beyond Anthropic. Supabase, SendBlue, and Telegram are all optional and each gates its own feature; leave any of them unset and that part of the agent simply doesn't activate.
- macOS LaunchAgents (the two `.plist` files) are macOS-only and optional โ they schedule the heartbeat and webhook to run automatically. On Linux, use `cron` or `systemd` instead to run the same commands (see Troubleshooting).
## Install, step by step
Fresh machine, assume nothing is installed yet.
### 1. Install Homebrew (macOS, skip if you already have it)
```
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```
Sets up the macOS package manager.
**Check it worked:** `brew --version` โ prints `Homebrew 4.x.x`.
### 2. Install Python 3
macOS:
```
brew install python3
```
Windows/Linux: install from https://python.org/downloads (Linux: `sudo apt install python3` on Debian/Ubuntu, or your distro's equivalent).
**Check it worked:** `python3 --version` โ prints `Python 3.9.x` or newer. (Any version 3.9+ is fine โ nothing here depends on a specific minor release.)
### 3. Clone this repo
```
git clone <this repo's KeyzHub URL> chairman-agent
cd chairman-agent
```
**Check it worked:** `ls agent.py prompt.py` โ both files listed, no "No such file" error.
### 4. Get your Anthropic API key
Sign up / log in at https://console.anthropic.com, create a key under API Keys. This is a paid API โ you need billing set up there before calls will succeed.
## Configure
Copy the example env file and fill in real values:
```
cp env.example .env
```
`agent.py` looks for its env file at `<repo-root>/../content-os/config/.env`
by default โ that is, **one directory above wherever you put this repo**,
under `content-os/config/.env`. This path is a leftover of the original
project's folder layout, not a requirement of your setup. Either:
- recreate that exact relative path (`mkdir -p ../content-os/config && cp env.example ../content-os/config/.env`), or
- open `agent.py` and change the `ENV_FILE` constant near the top to point at wherever you put your `.env` (also update the same constant in `sendblue.py`, `webhook.py`, and `telegram_bridge.py` โ each loads its own copy of `ENV_FILE`).
Required variable:
```
ANTHROPIC_API_KEY=YOUR_KEY_HERE # keyzhub-allow
```
Everything else in `env.example` is optional and independently gated:
```
# Supabase โ live business-numbers grounding + task ledger (agent_bus.py). Leave unset: agent runs, just no live-numbers block.
SUPABASE_URL=YOUR_SUPABASE_PROJECT_URL_HERE # keyzhub-allow
SUPABASE_ANON_KEY=YOUR_SUPABASE_ANON_KEY_HERE # keyzhub-allow
SUPABASE_SERVICE_KEY=YOUR_SUPABASE_SERVICE_KEY_HERE # keyzhub-allow
# SendBlue โ iMessage bridge (see SENDBLUE-SETUP.md). Leave unset: no iMessage channel.
SENDBLUE_API_KEY_ID=YOUR_SENDBLUE_KEY_ID_HERE # keyzhub-allow
SENDBLUE_API_SECRET_KEY=YOUR_SENDBLUE_SECRET_HERE # keyzhub-allow
SENDBLUE_FROM_NUMBER=+1YOUR_SENDBLUE_NUMBER_HERE # keyzhub-allow
SENDBLUE_WEBHOOK_SECRET=YOUR_SENDBLUE_WEBHOOK_SECRET_HERE # keyzhub-allow
SENDBLUE_AUTHORIZED_NUMBERS=+1YOUR_PHONE_NUMBER_HERE # keyzhub-allow
KEYS_IMESSAGE_NUMBER=+1YOUR_PHONE_NUMBER_HERE # keyzhub-allow
# Telegram โ chat bridge (telegram_bridge.py). Leave unset: no Telegram channel.
TELEGRAM_BOT_TOKEN=YOUR_TELEGRAM_BOT_TOKEN_HERE # keyzhub-allow
TELEGRAM_USER_ID=YOUR_TELEGRAM_USER_ID_HERE # keyzhub-allow
```
Also worth knowing before you run anything:
- **`prompt.py` and `config/agents.py` are written for 19Keys / Sovereign Mind Media by name.** They are plain-language system prompts, not code that needs to compile โ but the agent will follow whatever persona you leave in there, verbatim. Rewrite them before pointing this at your own business.
- **Hardcoded absolute paths.** `musa_cadence.py` (line 30) and `dashboard/server.py` (line 24) hardcode `/Users/19keys/sovereign-empire-sweep/...` / `chairman-agent` as their root path. If you didn't clone to that exact location, edit those two `ROOT`/`HOME` constants (or don't use `musa_cadence.py` / `dashboard/server.py` until you have). `agent.py`, `webhook.py`, `sendblue.py`, and `telegram_bridge.py` all resolve their own paths relative to the file (`Path(__file__).resolve().parent`), so those work regardless of clone location.
- **`prompt.py`'s `MEMORY_ANCHOR` references `sovereign-wiki/memory/CHAIRMAN-MEMORY.md`**, a file not included in this repo. Either create that path yourself or edit/remove the reference โ the agent works without it, it just has no persistent memory file to read/write.
## Run it
```
python3 agent.py --chat "what should I focus on this week"
```
Success looks like: a plain-text reply printed to stdout after a few
seconds (the agent may call its `bash`/`web_search`/file tools first โ you
won't see that, just the final answer). If instead you see
`ERROR: ANTHROPIC_API_KEY not set`, your `.env` isn't being found โ see
Troubleshooting.
Other entry points once the basic chat works:
```
python3 agent.py --heartbeat # one autonomous cycle (what the LaunchAgent runs on a schedule)
echo "summarize today" | python3 agent.py --chat-stdin
cd dashboard && python3 server.py # local ops dashboard at http://localhost:8919
```
## Troubleshooting
1. **`ERROR: ANTHROPIC_API_KEY not set`** โ the `.env` file isn't where `agent.py` is looking (`../content-os/config/.env` relative to the repo, by default). Either put your `.env` at that exact path or edit `ENV_FILE` in `agent.py` (and in `sendblue.py`/`webhook.py`/`telegram_bridge.py` if you use those). Quick sanity check: `python3 -c "import os; print(os.environ.get('ANTHROPIC_API_KEY'))"` after `source .env` โ but `agent.py` does its own file parsing, not `source`, so this only confirms the key format, not that the loader finds the file.
2. **`API 400: ... credit balance is too low`** or a stalled heartbeat with no error** โ the Anthropic account has no credit, or `cost_guard.py`'s 80%-of-$50/month cutoff has tripped (see `chairman-agent/data/api_costs.json` once it exists). Add credit at console.anthropic.com, or for a tripped budget cutoff, ask the Telegram bridge for `/unlock` (or call `cost_guard.reset_cutoff()` directly).
3. **`python3` not found, or a `python3` older than 3.9 runs instead of the one you installed** โ the two `.plist` files and some docs assume `/usr/bin/python3` (macOS system Python). If you installed via Homebrew, that binary is usually at `/opt/homebrew/bin/python3` instead. Check with `which -a python3` and either update the `.plist` `ProgramArguments` to the correct path or symlink accordingly. On Linux there is no `.plist` equivalent โ run these as `cron` entries or a `systemd --user` service instead, pointing at your real `python3` path.
|