# SimpleX Orchestrate — project notes for Claude Goal: a web-managed **orchestrator** that runs the **official SimpleX binaries** (instead of re-implementing bot logic against the FFI `libsimplex` SDK, as the older `simplex-manager` prototype did). The manager spawns/supervises real SimpleX processes, drives the interactive ones over WebSocket, and reads the autonomous ones' output. Reference checkout: `./simplex-chat/` (cloned from https://github.com/simplex-chat/simplex-chat). All facts below are taken from that repo's own docs — cited inline. There is **no** CLAUDE.md / AGENTS.md in the upstream repo; the authoritative interface docs are: - `simplex-chat/bots/README.md` — bot architecture & WebSocket API - `simplex-chat/bots/api/COMMANDS.md`, `EVENTS.md`, `TYPES.md` — full command/event/type reference - `simplex-chat/docs/CLI.md` — terminal client / DB / server flags - `simplex-chat/apps/*/README.md` + `src/.../Options.hs` — the official bot binaries - Official TypeScript SDK: `simplex-chat/packages/simplex-chat-client/typescript/` --- ## Two integration patterns (this is the core design decision) **1. Interactive accounts → drive the CLI over WebSocket** (`bots/README.md`) - Run the terminal client as a local WebSocket server: `simplex-chat -p 5225` - Our process connects over WebSocket and sends JSON commands / receives events. - This is how custom bots (TS/Python/Rust) and our manager talk to a profile. - Same command strings as the app's *Settings → Developer tools → Chat Console*. **2. Autonomous official bots → run the prebuilt Haskell binary directly** - `simplex-directory-service` and `simplex-broadcast-bot` are standalone executables built on the chat core. They run their **own** logic, with their **own** DB + config, no WebSocket. - The manager's job for these is lifecycle (spawn/stop/monitor/logs) + reading their output. - **Use these instead of reimplementing directory/broadcast in Python** — they're battle-tested and include captcha, moderation, approval, periodic re-checks, website generation, etc. --- ## WebSocket protocol (pattern 1) — `bots/README.md` - `simplex-chat -p ` starts the WS server. **localhost only, NO authentication** — keep the bot process on the same machine and firewall the port. Messages are unencrypted. - Command: `{"corrId":"", "cmd":""}` - Response: `{"corrId":"", "resp":{"type":"", ...}}` (matched by corrId) - Event: `{"resp":{"type":"", ...}}` (no corrId — connections, received messages, etc.) - `NewChatItems` arrives both as a command response (after `APISendMessages`) and as an event. - Parser must **ignore unknown event types / union tags / extra fields** (forward-compat rule). - Minimal bot loop: handle `NewChatItems` event → reply with `APISendMessages`. - Network usage per command is documented: `no` / `interactive` / `background`. ## Per-profile databases — `docs/CLI.md` - `simplex-chat -d ` → creates `_v1_chat.db` and `_v1_agent.db`. - Default data dir `~/.simplex` (`%APPDATA%/simplex` on Windows). - **One process = one DB prefix.** A single DB *can* hold multiple bot profiles via `/create bot [files=on] []`, but the simple model is one process per profile. - SMP servers: `-s smp://@host`. Tor: `-x` or `--socks-proxy=:9050`. `simplex-chat -h` for all. ## Bot profile setup — `bots/README.md` (needs app/CLI v6.4.3+) - Mark a profile as a bot: `peerType: "bot"`. Set via: - CLI flags `--create-bot-display-name`, `--create-bot-allow-files` on first start, or - `/create bot [files=on] '' []`, or - `APIUpdateProfile` (also sets command menus). - Command menus: `/set bot commands '