An autonomous Discord bot powered by Ollama with a 3D Turing-complete tape, self-modifying codebase, and continuous heartbeat for independent computation.
- 3D Turing Tape β Infinite sparse 3D grid for arbitrary, persistent working memory
- Autonomous Heartbeat β Continuous cognition loop that thinks independently between user messages
- Self-Modifying Code β Bot can write, execute, and hot-load Python extensions in a sandbox
- Sandboxed Execution β Extensions are blocked from accessing filesystem, network, system commands, and dangerous APIs
- Core Protection β Essential bot files are immutable; only the
extensions/directory is writable - Self-Describing Prompt β System prompt dynamically introspects the entire codebase
- Thought Transparency β All internal reasoning and tool usage streams to a dedicated channel
main.py β Entry point, wires everything together
config.py β Environment config + core file protection list
turing_tape.py β 3D sparse tape with read/write/move/jump/scan
codebase_rw.py β Self-modification with core protection + sandbox
sandbox.py β Import/builtin restrictions for extensions
brain.py β Ollama chat wrapper with 11 tool definitions
heartbeat.py β Async autonomous cognition loop
bot.py β Discord client with dual-channel support
prompt_builder.py β Dynamic system prompt from live codebase
- Python 3.9+
- Ollama installed and running
- A Discord bot application with a token
# Clone the repo
git clone https://github.com/YOUR_USERNAME/TuringBot.git
cd TuringBot
# Install dependencies
pip install -r requirements.txt
# Configure your bot
cp .env.example .env
# Edit .env with your Discord token and channel IDsEdit .env with your values:
| Variable | Description |
|---|---|
DISCORD_TOKEN |
Your Discord bot token |
LISTEN_CHANNEL_ID |
Channel where users interact with the bot |
THOUGHTS_CHANNEL_ID |
Channel where the bot streams all internal thoughts |
OLLAMA_MODEL |
Ollama model to use (default: qwen3:32b) |
OLLAMA_HOST |
Ollama API host (default: http://localhost:11434) |
HEARTBEAT_INTERVAL |
Seconds between autonomous ticks (default: 10.0) |
python main.pyTuringBot can modify its own code in the extensions/ directory, but all extensions run in a sandboxed environment that:
- β
Allows:
math,json,re,datetime,collections,itertools,random, and more - π« Blocks:
os,subprocess,socket,shutil,pickle,ctypes,sys, and all network/filesystem modules - π« Blocks builtins:
exec,eval,open,__import__,breakpoint,exit - π Core files are immutable β the bot cannot modify its own brain, config, or sandbox
# Run all tests
python -m pytest tests/ -v
# Run with coverage
python -m pytest tests/ --cov=. --cov-report=term-missing264 tests, 99% coverage, zero stubs or placeholders.
- Heartbeat Loop β Every N seconds, the bot thinks autonomously using the Ollama model
- User Messages β When a user sends a message, the heartbeat pauses, the bot processes the message, and resumes
- Tool Calls β The model can read/write the tape, read files, write extensions, and hot-load code
- Thought Streaming β All internal reasoning, tool usage, and decisions stream to the thoughts channel
- Persistence β The 3D tape saves to
tape_state.jsonafter every interaction
Maria Smith
- Discord:
metta_mazza - Email: Maria.smith.xo@outlook.com
MIT β see LICENSE for details.