Downloads · 30 days
0
webxos/mochaclaw-js
mochaclaw-js is a machine learning model from webxos. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers.js. The card lists the license as mit.
Lightweight, local‑first AI agent for Debian Privacy‑first automation with OpenClaw tactics, powered by Ollama or Transformers.js (WASM).
Downloads · 30 days
0
Access
Public
Updated Mar 8, 2026
Repo size
—
Likes
4
Public
Click a slice to open those files.
Other16.5 KB · 61%
From the Hugging Face model README
Lightweight, local‑first AI agent for Debian
Privacy‑first automation with OpenClaw tactics, powered by Ollama or Transformers.js (WASM).
▖ ▖ ▌ ▜
▛▖▞▌▛▌▛▘▛▌▀▌▛▘▐ ▀▌▌▌▌
▌▝ ▌▙▌▙▖▌▌█▌▙▖▐▖█▌▚▚▘
M O C H A C L A W
Privacy-first Local AI Agent for Debian
Mochaclaw is a single‑file CLI agent harness that runs entirely on your local machine. It uses Ollama (default) or Transformers.js (WASM) to execute AI workflows without any cloud dependencies. All state (persona, memory, journal) is stored in a single MOCHASOUL.md file – a unified soul that grows with every interaction.
/mochaclaw/
├── mochaclaw # main executable
├── package.json # dependencies
├── .env # optional configuration
├── INSTALL.md # detailed installation & testing guide
├── MOCHASOUL.md # auto-created on first run
└── package-lock.json # will be generated by npm
ollama – use any Ollama model (default: qwen2.5:0.5b).transformers – pure WASM execution via Transformers.js (no GPU needed).Thought → Action → Observation logged in MOCHASOUL.md.sudo apt update
sudo apt install build-essential python3 python3-pip -y
Line 18 of the mochaclaw file:
// ----------------------------------------------------------------------
// 1. Configuration
const SOUL_FILE = path.join(process.cwd(), 'MOCHASOUL.md');
const BACKEND = process.env.INFERENCE_BACKEND || 'ollama';
const OLLAMA_URL = process.env.OLLAMA_URL || 'http://localhost:11434';
const OLLAMA_MODEL = process.env.OLLAMA_MODEL || 'qwen2.5:0.5b';
git clone https://github.com/yourusername/mochaclaw.git
cd mochaclaw
Or simply create the files manually in a new directory:
mkdir -p ~/mochaclaw && cd ~/mochaclaw
# ... copy mochaclaw, package.json, .env (optional) from the repository
npm install
Make the main script executable:
chmod +x mochaclaw
ollama serve # run in a separate terminal or as a service
ollama pull qwen2.5:0.5b # or any Ollama model you prefer
Just run ./mochaclaw. You’ll see the banner and the prompt mocha>.
./mochaclaw
Type your requests normally. The agent will either answer directly or decide to use a tool.
Use the built‑in commands (starting with /) to control the session.
Pass your query as an argument. The agent processes it, prints the result, and exits.
./mochaclaw "What files are in my home directory?"
| Command | Aliases | Description |
|---|---|---|
/help | /h | Show this help menu. |
/guide | /g | Display detailed usage guide. |
/memory | /m | Show the current memory section of MOCHASOUL.md. |
/journal | /j | Show the most recent journal entries (Thought/Action/Observation). |
/tools | /t | List all available tools with example syntax. |
/exit | /quit | Exit the interactive session. |
The agent can invoke these tools by outputting Action: toolName({ "arg": "value" }).
The tool result is then fed back into the loop (and also logged in the journal).
| Tool | Description | Example |
|---|---|---|
run_command | Execute a shell command (5 sec timeout). | Action: run_command({ "command": "ls -la ~" }) |
read_file | Read a file from disk. | Action: read_file({ "path": "/home/kali/.bashrc" }) |
write_file | Write content to a file (creates/overwrites). | Action: write_file({ "path": "./note.txt", "content": "Hello Mocha" }) |
update_memory | Add a fact to long‑term memory (appended to # Memory). | Action: update_memory({ "content": "User likes dark mode" }) |
.env)Create a .env file in the same directory to override defaults:
# Inference backend: "ollama" (default) or "transformers"
INFERENCE_BACKEND=ollama
# Ollama settings (only used if backend = ollama)
OLLAMA_URL=http://localhost:11434
OLLAMA_MODEL=qwen2.5:0.5b (adjust to your own custom model)
# Transformers.js model (only used if backend = transformers)
TRANSFORMERS_MODEL=Xenova/phi-3-mini-4k-instruct
MOCHASOUL.mdThis single Markdown file holds the agent’s entire persistent state. It is automatically created on first run with default content, but you can edit it anytime.
# Persona
You are MochaClaw, a privacy-first AI assistant running locally on Debian.
You have access to these tools: run_command, read_file, write_file, update_memory.
When you need to perform an action, output exactly:
Action: toolName({ "arg": "value" })
Then wait for the observation. Otherwise, you may answer directly.
# Memory
- User likes dark mode.
- The home directory contains Documents, Downloads, etc.
# Journal
## Thought
User: What's in my home directory?
I should use run_command to list files.
Action: run_command({ "command": "ls -la ~" })
**Action:** run_command
**Observation:** {"success":true,"output":"total 48\ndrwxr-xr-x ..."}
---
update_memory.Thought → Action → Observation.-Run MochaClaw offline to scan sensitive directories. Ask it to redact PII from documents using a local NER model (switch to transformers backend with a small BERT model). No data ever leaves your machine.
-Set up a pre‑commit hook that calls MochaClaw to analyse your code diff and generate a journal.md entry documenting your changes. Keep a persistent memory of your project evolution.
-Use the update_memory tool to store facts extracted from your browser history or markdown notes. Later, query your personal knowledge base without ever connecting to the cloud.
-Combine MochaClaw with a simple WebSocket server (not included) to feed hardware metrics (CPU temp, disk usage) into the agent. Ask it to predict failures using a lightweight regression model.
| Problem | Solution |
|---|---|
Cannot connect to Ollama | Run ollama serve and ensure Ollama is listening on http://localhost:11434. |
SyntaxError: Unexpected token | Your Node.js version is too old. Upgrade to v18+. |
Error: Cannot find module '...' | Run npm install again. |
| Native module build fails | Install build tools: sudo apt install build-essential python3. |
| Agent never calls tools | Check the persona in MOCHASOUL.md – it must include the instruction to output Action: .... |
| Tool parsing fails | The regex expects exact format Action: toolName({ "arg": "value" }). If the model output differs, you may need to tweak the prompt. |
Executes a shell command (with a 5‑second timeout). Arguments: command (string)
Reads the contents of a file. Arguments: path or file (string)
Adds a fact to the long‑term memory section of MOCHASOUL.md. Arguments: content (string)
text
mocha> Show me what's in my current folder. MochaClaw thinking... Agent: I'll list the files for you. Action: run_command({ "command": "ls -la" }) Observation: {"success":true,"output":"total 48\ndrwxr-xr-x 3 user user 4096 ..."} Answer: The directory contains mochaclaw, package.json, .env, and MOCHASOUL.md.
text
mocha> Can you read the file datetime.sh for me? MochaClaw thinking... Action: read_file({ "file": "datetime.sh" }) Observation: {"success":true,"data":"#!/bin/bash\necho "Current date: $(date)"\n"} Answer: Here's the content of datetime.sh: #!/bin/bash echo "Current date: $(date)"
text
mocha> Create a file called test.txt with the text "Hello from MochaClaw". MochaClaw thinking... Action: write_file({ "path": "test.txt", "content": "Hello from MochaClaw" }) Observation: {"success":true} Answer: File test.txt has been created.
mocha> Now read test.txt. MochaClaw thinking... Action: read_file({ "file": "test.txt" }) Observation: {"success":true,"data":"Hello from MochaClaw"} Answer: The file contains: Hello from MochaClaw
text
mocha> Remember that I like coffee. MochaClaw thinking... Action: update_memory({ "content": "User likes coffee" }) Observation: {"success":true,"status":"Memory updated"} Answer: I've stored that in my memory.
mocha> /memory Current Memory:
MIT