|
| 1 | +# Clawdbot Smalltalk Setup |
| 2 | + |
| 3 | +This guide explains how to set up the Smalltalk skill for [Clawdbot](https://github.com/clawdbot/clawdbot). |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +- **Linux x86_64** (tested on Ubuntu 24.04) |
| 8 | +- **Python 3.10+** |
| 9 | +- **xvfb** for headless operation |
| 10 | + |
| 11 | +## Step 1: Install System Dependencies |
| 12 | + |
| 13 | +```bash |
| 14 | +sudo apt update |
| 15 | +sudo apt install xvfb |
| 16 | +``` |
| 17 | + |
| 18 | +## Step 2: Install Squeak VM |
| 19 | + |
| 20 | +Download Squeak 6.0 from https://squeak.org/downloads/ |
| 21 | + |
| 22 | +```bash |
| 23 | +cd ~ |
| 24 | +wget https://files.squeak.org/6.0/Squeak6.0-22148-64bit-202312181441-Linux-x64.tar.gz |
| 25 | +tar xzf Squeak6.0-22148-64bit-202312181441-Linux-x64.tar.gz |
| 26 | +``` |
| 27 | + |
| 28 | +## Step 3: Build the Image |
| 29 | + |
| 30 | +Follow [SQUEAK-SETUP.md](SQUEAK-SETUP.md) to: |
| 31 | +1. Install OSProcess package |
| 32 | +2. File in `MCP-Server-Squeak.st` |
| 33 | +3. Register MCPServer for startup |
| 34 | +4. Save as `ClaudeSqueak.image` |
| 35 | + |
| 36 | +Or for Cuis, use the provided `ClaudeCuis.image`. |
| 37 | + |
| 38 | +## Step 4: Set Up Sources File |
| 39 | + |
| 40 | +The Smalltalk image needs access to the sources file. Symlink it to your image directory: |
| 41 | + |
| 42 | +```bash |
| 43 | +# For Squeak |
| 44 | +ln -s ~/Squeak6.0-*/shared/SqueakV60.sources ~/SqueakV60.sources |
| 45 | + |
| 46 | +# Or copy it next to your image |
| 47 | +cp ~/Squeak6.0-*/shared/SqueakV60.sources ~/ |
| 48 | +``` |
| 49 | + |
| 50 | +## Step 5: Install the Skill |
| 51 | + |
| 52 | +Copy the skill to your Clawdbot skills directory: |
| 53 | + |
| 54 | +```bash |
| 55 | +mkdir -p ~/clawd/skills/smalltalk |
| 56 | +cp clawdbot/SKILL.md ~/clawd/skills/smalltalk/ |
| 57 | +cp clawdbot/smalltalk.py ~/clawd/skills/smalltalk/ |
| 58 | +chmod +x ~/clawd/skills/smalltalk/smalltalk.py |
| 59 | +``` |
| 60 | + |
| 61 | +## Step 6: Configure Paths (Optional) |
| 62 | + |
| 63 | +The script auto-detects common paths. If needed, set environment variables: |
| 64 | + |
| 65 | +```bash |
| 66 | +export SQUEAK_VM_PATH=~/Squeak6.0-22148-64bit-202312181441-Linux-x64/bin/squeak |
| 67 | +export SQUEAK_IMAGE_PATH=~/ClaudeSqueak.image |
| 68 | +``` |
| 69 | + |
| 70 | +Add to `~/.bashrc` or `~/.profile` to persist. |
| 71 | + |
| 72 | +## Step 7: Verify Setup |
| 73 | + |
| 74 | +```bash |
| 75 | +python3 ~/clawd/skills/smalltalk/smalltalk.py --check |
| 76 | +``` |
| 77 | + |
| 78 | +Expected output: |
| 79 | +``` |
| 80 | +🔍 Checking Clawdbot Smalltalk setup... |
| 81 | +
|
| 82 | +✅ xvfb-run found |
| 83 | +✅ VM found: /home/user/Squeak6.0-.../bin/squeak |
| 84 | +✅ Image found: /home/user/ClaudeSqueak.image |
| 85 | +✅ Sources file found: /home/user/SqueakV60.sources |
| 86 | +
|
| 87 | +✅ Setup looks good! |
| 88 | +``` |
| 89 | + |
| 90 | +## Step 8: Test |
| 91 | + |
| 92 | +```bash |
| 93 | +python3 ~/clawd/skills/smalltalk/smalltalk.py evaluate "3 factorial" |
| 94 | +# Should output: 6 |
| 95 | +``` |
| 96 | + |
| 97 | +## Usage with Clawdbot |
| 98 | + |
| 99 | +Once set up, ask Clawdbot things like: |
| 100 | +- "Evaluate `Date today` in Smalltalk" |
| 101 | +- "Browse the OrderedCollection class" |
| 102 | +- "Show me the source of String>>asUppercase" |
| 103 | +- "What are the subclasses of Collection?" |
| 104 | + |
| 105 | +## Troubleshooting |
| 106 | + |
| 107 | +### Dialog boxes blocking (sources file) |
| 108 | +``` |
| 109 | +Squeak cannot locate the sources file... |
| 110 | +``` |
| 111 | +**Fix:** Symlink or copy the sources file next to your image. |
| 112 | + |
| 113 | +### xvfb-run not found |
| 114 | +```bash |
| 115 | +sudo apt install xvfb |
| 116 | +``` |
| 117 | + |
| 118 | +### Permission denied on VM |
| 119 | +```bash |
| 120 | +chmod +x ~/Squeak6.0-*/bin/squeak |
| 121 | +``` |
| 122 | + |
| 123 | +### No response from MCP server |
| 124 | +- Ensure image was saved after `Smalltalk addToStartUpList: MCPServer` |
| 125 | +- Check that `--mcp` flag triggers the server |
| 126 | +- Verify xvfb is working: `xvfb-run -a echo "works"` |
| 127 | + |
| 128 | +### Debugging a hung system with screenshots |
| 129 | + |
| 130 | +If the MCP server isn't responding, Squeak may be blocked on a dialog (e.g., missing sources file). Capture a screenshot of the virtual display: |
| 131 | + |
| 132 | +```bash |
| 133 | +# Start Xvfb on display :99 |
| 134 | +export DISPLAY=:99 |
| 135 | +Xvfb :99 -screen 0 1024x768x24 & |
| 136 | + |
| 137 | +# Start Squeak |
| 138 | +/path/to/squeak ~/ClaudeSqueak.image --mcp & |
| 139 | + |
| 140 | +# Wait a few seconds, then capture screenshot |
| 141 | +sleep 5 |
| 142 | +import -window root -display :99 /tmp/squeak_debug.png |
| 143 | + |
| 144 | +# View the screenshot to see what's blocking |
| 145 | +``` |
| 146 | + |
| 147 | +Requires `imagemagick` (`sudo apt install imagemagick`). |
| 148 | + |
| 149 | +### Getting a stack trace with SIGUSR1 |
| 150 | + |
| 151 | +Send SIGUSR1 to the Squeak process to dump the current stack to stderr: |
| 152 | + |
| 153 | +```bash |
| 154 | +# Find the Squeak process |
| 155 | +pgrep -f squeak |
| 156 | + |
| 157 | +# Send signal (replace PID with actual) |
| 158 | +kill -USR1 <PID> |
| 159 | +``` |
| 160 | + |
| 161 | +If Squeak was started with output redirected to a log file: |
| 162 | +```bash |
| 163 | +/path/to/squeak image.image --mcp > /tmp/squeak.log 2>&1 & |
| 164 | +``` |
| 165 | + |
| 166 | +The stack trace will appear in `/tmp/squeak.log`, showing what each process is doing: |
| 167 | +``` |
| 168 | +ProcessorScheduler>>#relinquishProcessorForMicroseconds: |
| 169 | +EventSensor>>#primGetNextEvent: |
| 170 | +Semaphore>>#wait |
| 171 | +... |
| 172 | +(SIGUSR1) |
| 173 | +``` |
| 174 | + |
| 175 | +This helps identify what's blocking when the MCP server is unresponsive. |
| 176 | + |
| 177 | +### pthread_setschedparam warning |
| 178 | +This is harmless. To suppress, create: |
| 179 | +```bash |
| 180 | +sudo tee /etc/security/limits.d/squeak.conf << 'EOF' |
| 181 | +* hard rtprio 2 |
| 182 | +* soft rtprio 2 |
| 183 | +EOF |
| 184 | +``` |
| 185 | +Then log out and back in. |
| 186 | + |
| 187 | +## Architecture |
| 188 | + |
| 189 | +``` |
| 190 | +Clawdbot |
| 191 | + │ |
| 192 | + ▼ exec |
| 193 | +smalltalk.py |
| 194 | + │ |
| 195 | + ▼ xvfb-run + stdio |
| 196 | +Squeak VM + ClaudeSqueak.image |
| 197 | + │ |
| 198 | + ▼ MCP JSON-RPC |
| 199 | +MCPServer (12 tools) |
| 200 | +``` |
0 commit comments