@rozek/nanoclaw 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.json +1 -0
- package/.claude/skills/add-compact/SKILL.md +135 -0
- package/.claude/skills/add-discord/SKILL.md +203 -0
- package/.claude/skills/add-gmail/SKILL.md +220 -0
- package/.claude/skills/add-image-vision/SKILL.md +94 -0
- package/.claude/skills/add-ollama-tool/SKILL.md +153 -0
- package/.claude/skills/add-parallel/SKILL.md +290 -0
- package/.claude/skills/add-pdf-reader/SKILL.md +104 -0
- package/.claude/skills/add-reactions/SKILL.md +117 -0
- package/.claude/skills/add-slack/SKILL.md +207 -0
- package/.claude/skills/add-telegram/SKILL.md +222 -0
- package/.claude/skills/add-telegram-swarm/SKILL.md +384 -0
- package/.claude/skills/add-voice-transcription/SKILL.md +148 -0
- package/.claude/skills/add-whatsapp/SKILL.md +372 -0
- package/.claude/skills/convert-to-apple-container/SKILL.md +175 -0
- package/.claude/skills/customize/SKILL.md +110 -0
- package/.claude/skills/debug/SKILL.md +349 -0
- package/.claude/skills/get-qodo-rules/SKILL.md +122 -0
- package/.claude/skills/get-qodo-rules/references/output-format.md +41 -0
- package/.claude/skills/get-qodo-rules/references/pagination.md +33 -0
- package/.claude/skills/get-qodo-rules/references/repository-scope.md +26 -0
- package/.claude/skills/qodo-pr-resolver/SKILL.md +326 -0
- package/.claude/skills/qodo-pr-resolver/resources/providers.md +329 -0
- package/.claude/skills/setup/SKILL.md +218 -0
- package/.claude/skills/update-nanoclaw/SKILL.md +235 -0
- package/.claude/skills/update-skills/SKILL.md +130 -0
- package/.claude/skills/use-local-whisper/SKILL.md +152 -0
- package/.claude/skills/x-integration/SKILL.md +417 -0
- package/.claude/skills/x-integration/agent.ts +243 -0
- package/.claude/skills/x-integration/host.ts +159 -0
- package/.claude/skills/x-integration/lib/browser.ts +148 -0
- package/.claude/skills/x-integration/lib/config.ts +62 -0
- package/.claude/skills/x-integration/scripts/like.ts +56 -0
- package/.claude/skills/x-integration/scripts/post.ts +66 -0
- package/.claude/skills/x-integration/scripts/quote.ts +80 -0
- package/.claude/skills/x-integration/scripts/reply.ts +74 -0
- package/.claude/skills/x-integration/scripts/retweet.ts +62 -0
- package/.claude/skills/x-integration/scripts/setup.ts +87 -0
- package/.env.example +1 -0
- package/.github/CODEOWNERS +10 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +14 -0
- package/.github/workflows/bump-version.yml +32 -0
- package/.github/workflows/ci.yml +25 -0
- package/.github/workflows/merge-forward-skills.yml +160 -0
- package/.github/workflows/update-tokens.yml +42 -0
- package/.husky/pre-commit +1 -0
- package/.mcp.json +3 -0
- package/.nvmrc +1 -0
- package/.prettierrc +3 -0
- package/CHANGELOG.md +8 -0
- package/CLAUDE.md +64 -0
- package/CONTRIBUTING.md +23 -0
- package/CONTRIBUTORS.md +15 -0
- package/LICENSE +21 -0
- package/NanoClaw_with_Web-Support.md +325 -0
- package/README.md +261 -0
- package/README_zh.md +200 -0
- package/assets/nanoclaw-favicon.png +0 -0
- package/assets/nanoclaw-icon.png +0 -0
- package/assets/nanoclaw-logo-dark.png +0 -0
- package/assets/nanoclaw-logo.png +0 -0
- package/assets/nanoclaw-profile.jpeg +0 -0
- package/assets/nanoclaw-sales.png +0 -0
- package/assets/social-preview.jpg +0 -0
- package/config-examples/mount-allowlist.json +25 -0
- package/container/Dockerfile +70 -0
- package/container/agent-runner/package.json +21 -0
- package/container/agent-runner/src/index.ts +774 -0
- package/container/agent-runner/src/ipc-mcp-stdio.ts +338 -0
- package/container/agent-runner/tsconfig.json +15 -0
- package/container/build.sh +23 -0
- package/container/skills/agent-browser/SKILL.md +159 -0
- package/container/skills/capabilities/SKILL.md +100 -0
- package/container/skills/cwd/SKILL.md +32 -0
- package/container/skills/pwd/SKILL.md +19 -0
- package/container/skills/status/SKILL.md +104 -0
- package/dist/channels/index.d.ts +2 -0
- package/dist/channels/index.d.ts.map +1 -0
- package/dist/channels/index.js +10 -0
- package/dist/channels/index.js.map +1 -0
- package/dist/channels/registry.d.ts +13 -0
- package/dist/channels/registry.d.ts.map +1 -0
- package/dist/channels/registry.js +11 -0
- package/dist/channels/registry.js.map +1 -0
- package/dist/channels/registry.test.d.ts +2 -0
- package/dist/channels/registry.test.d.ts.map +1 -0
- package/dist/channels/registry.test.js +32 -0
- package/dist/channels/registry.test.js.map +1 -0
- package/dist/channels/web.d.ts +2 -0
- package/dist/channels/web.d.ts.map +1 -0
- package/dist/channels/web.js +1843 -0
- package/dist/channels/web.js.map +1 -0
- package/dist/cli.d.ts +11 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +182 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +19 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +36 -0
- package/dist/config.js.map +1 -0
- package/dist/container-runner.d.ts +44 -0
- package/dist/container-runner.d.ts.map +1 -0
- package/dist/container-runner.js +511 -0
- package/dist/container-runner.js.map +1 -0
- package/dist/container-runner.test.d.ts +2 -0
- package/dist/container-runner.test.d.ts.map +1 -0
- package/dist/container-runner.test.js +150 -0
- package/dist/container-runner.test.js.map +1 -0
- package/dist/container-runtime.d.ts +22 -0
- package/dist/container-runtime.d.ts.map +1 -0
- package/dist/container-runtime.js +96 -0
- package/dist/container-runtime.js.map +1 -0
- package/dist/container-runtime.test.d.ts +2 -0
- package/dist/container-runtime.test.d.ts.map +1 -0
- package/dist/container-runtime.test.js +93 -0
- package/dist/container-runtime.test.js.map +1 -0
- package/dist/credential-proxy.d.ts +21 -0
- package/dist/credential-proxy.d.ts.map +1 -0
- package/dist/credential-proxy.js +95 -0
- package/dist/credential-proxy.js.map +1 -0
- package/dist/credential-proxy.test.d.ts +2 -0
- package/dist/credential-proxy.test.d.ts.map +1 -0
- package/dist/credential-proxy.test.js +134 -0
- package/dist/credential-proxy.test.js.map +1 -0
- package/dist/db.d.ts +115 -0
- package/dist/db.d.ts.map +1 -0
- package/dist/db.js +549 -0
- package/dist/db.js.map +1 -0
- package/dist/db.test.d.ts +2 -0
- package/dist/db.test.d.ts.map +1 -0
- package/dist/db.test.js +360 -0
- package/dist/db.test.js.map +1 -0
- package/dist/env.d.ts +8 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +42 -0
- package/dist/env.js.map +1 -0
- package/dist/formatting.test.d.ts +2 -0
- package/dist/formatting.test.d.ts.map +1 -0
- package/dist/formatting.test.js +183 -0
- package/dist/formatting.test.js.map +1 -0
- package/dist/group-folder.d.ts +5 -0
- package/dist/group-folder.d.ts.map +1 -0
- package/dist/group-folder.js +44 -0
- package/dist/group-folder.js.map +1 -0
- package/dist/group-folder.test.d.ts +2 -0
- package/dist/group-folder.test.d.ts.map +1 -0
- package/dist/group-folder.test.js +29 -0
- package/dist/group-folder.test.js.map +1 -0
- package/dist/group-queue.d.ts +40 -0
- package/dist/group-queue.d.ts.map +1 -0
- package/dist/group-queue.js +276 -0
- package/dist/group-queue.js.map +1 -0
- package/dist/group-queue.test.d.ts +2 -0
- package/dist/group-queue.test.d.ts.map +1 -0
- package/dist/group-queue.test.js +341 -0
- package/dist/group-queue.test.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +592 -0
- package/dist/index.js.map +1 -0
- package/dist/ipc-auth.test.d.ts +2 -0
- package/dist/ipc-auth.test.d.ts.map +1 -0
- package/dist/ipc-auth.test.js +434 -0
- package/dist/ipc-auth.test.js.map +1 -0
- package/dist/ipc.d.ts +32 -0
- package/dist/ipc.d.ts.map +1 -0
- package/dist/ipc.js +311 -0
- package/dist/ipc.js.map +1 -0
- package/dist/logger.d.ts +3 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +14 -0
- package/dist/logger.js.map +1 -0
- package/dist/mount-security.d.ts +34 -0
- package/dist/mount-security.d.ts.map +1 -0
- package/dist/mount-security.js +325 -0
- package/dist/mount-security.js.map +1 -0
- package/dist/remote-control.d.ts +32 -0
- package/dist/remote-control.d.ts.map +1 -0
- package/dist/remote-control.js +185 -0
- package/dist/remote-control.js.map +1 -0
- package/dist/remote-control.test.d.ts +2 -0
- package/dist/remote-control.test.d.ts.map +1 -0
- package/dist/remote-control.test.js +321 -0
- package/dist/remote-control.test.js.map +1 -0
- package/dist/router.d.ts +8 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.js +37 -0
- package/dist/router.js.map +1 -0
- package/dist/routing.test.d.ts +2 -0
- package/dist/routing.test.d.ts.map +1 -0
- package/dist/routing.test.js +81 -0
- package/dist/routing.test.js.map +1 -0
- package/dist/sender-allowlist.d.ts +14 -0
- package/dist/sender-allowlist.d.ts.map +1 -0
- package/dist/sender-allowlist.js +79 -0
- package/dist/sender-allowlist.js.map +1 -0
- package/dist/sender-allowlist.test.d.ts +2 -0
- package/dist/sender-allowlist.test.d.ts.map +1 -0
- package/dist/sender-allowlist.test.js +186 -0
- package/dist/sender-allowlist.test.js.map +1 -0
- package/dist/session-commands.d.ts +47 -0
- package/dist/session-commands.d.ts.map +1 -0
- package/dist/session-commands.js +104 -0
- package/dist/session-commands.js.map +1 -0
- package/dist/session-commands.test.d.ts +2 -0
- package/dist/session-commands.test.d.ts.map +1 -0
- package/dist/session-commands.test.js +194 -0
- package/dist/session-commands.test.js.map +1 -0
- package/dist/task-scheduler.d.ts +22 -0
- package/dist/task-scheduler.d.ts.map +1 -0
- package/dist/task-scheduler.js +241 -0
- package/dist/task-scheduler.js.map +1 -0
- package/dist/task-scheduler.test.d.ts +2 -0
- package/dist/task-scheduler.test.d.ts.map +1 -0
- package/dist/task-scheduler.test.js +107 -0
- package/dist/task-scheduler.test.js.map +1 -0
- package/dist/timezone.d.ts +6 -0
- package/dist/timezone.d.ts.map +1 -0
- package/dist/timezone.js +17 -0
- package/dist/timezone.js.map +1 -0
- package/dist/timezone.test.d.ts +2 -0
- package/dist/timezone.test.d.ts.map +1 -0
- package/dist/timezone.test.js +23 -0
- package/dist/timezone.test.js.map +1 -0
- package/dist/types.d.ts +79 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/docs/APPLE-CONTAINER-NETWORKING.md +90 -0
- package/docs/DEBUG_CHECKLIST.md +143 -0
- package/docs/REQUIREMENTS.md +196 -0
- package/docs/SDK_DEEP_DIVE.md +643 -0
- package/docs/SECURITY.md +122 -0
- package/docs/SPEC.md +785 -0
- package/docs/docker-sandboxes.md +359 -0
- package/docs/nanoclaw-architecture-final.md +1063 -0
- package/docs/nanorepo-architecture.md +168 -0
- package/docs/skills-as-branches.md +662 -0
- package/groups/global/CLAUDE.md +58 -0
- package/groups/main/CLAUDE.md +246 -0
- package/launchd/com.nanoclaw.plist +32 -0
- package/package.json +45 -0
- package/repo-tokens/README.md +113 -0
- package/repo-tokens/action.yml +186 -0
- package/repo-tokens/badge.svg +23 -0
- package/repo-tokens/examples/green.svg +14 -0
- package/repo-tokens/examples/red.svg +14 -0
- package/repo-tokens/examples/yellow-green.svg +14 -0
- package/repo-tokens/examples/yellow.svg +14 -0
- package/scripts/run-migrations.ts +105 -0
- package/setup/container.ts +144 -0
- package/setup/environment.test.ts +121 -0
- package/setup/environment.ts +94 -0
- package/setup/groups.ts +229 -0
- package/setup/index.ts +58 -0
- package/setup/mounts.ts +115 -0
- package/setup/platform.test.ts +120 -0
- package/setup/platform.ts +132 -0
- package/setup/register.test.ts +257 -0
- package/setup/register.ts +177 -0
- package/setup/service.test.ts +187 -0
- package/setup/service.ts +362 -0
- package/setup/status.ts +16 -0
- package/setup/verify.ts +192 -0
- package/setup.sh +161 -0
- package/src/channels/index.ts +15 -0
- package/src/channels/registry.test.ts +42 -0
- package/src/channels/registry.ts +32 -0
- package/src/channels/web.ts +1931 -0
- package/src/cli.ts +209 -0
- package/src/config.ts +73 -0
- package/src/container-runner.test.ts +210 -0
- package/src/container-runner.ts +768 -0
- package/src/container-runtime.test.ts +149 -0
- package/src/container-runtime.ts +127 -0
- package/src/credential-proxy.test.ts +192 -0
- package/src/credential-proxy.ts +125 -0
- package/src/db.test.ts +484 -0
- package/src/db.ts +803 -0
- package/src/env.ts +42 -0
- package/src/formatting.test.ts +256 -0
- package/src/group-folder.test.ts +43 -0
- package/src/group-folder.ts +44 -0
- package/src/group-queue.test.ts +484 -0
- package/src/group-queue.ts +379 -0
- package/src/index.ts +832 -0
- package/src/ipc-auth.test.ts +679 -0
- package/src/ipc.ts +461 -0
- package/src/logger.ts +16 -0
- package/src/mount-security.ts +419 -0
- package/src/remote-control.test.ts +397 -0
- package/src/remote-control.ts +224 -0
- package/src/router.ts +52 -0
- package/src/routing.test.ts +170 -0
- package/src/sender-allowlist.test.ts +216 -0
- package/src/sender-allowlist.ts +128 -0
- package/src/session-commands.test.ts +247 -0
- package/src/session-commands.ts +163 -0
- package/src/task-scheduler.test.ts +129 -0
- package/src/task-scheduler.ts +328 -0
- package/src/timezone.test.ts +29 -0
- package/src/timezone.ts +16 -0
- package/src/types.ts +109 -0
- package/tsconfig.json +20 -0
- package/vitest.config.ts +7 -0
- package/vitest.skills.config.ts +7 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: use-local-whisper
|
|
3
|
+
description: Use when the user wants local voice transcription instead of OpenAI Whisper API. Switches to whisper.cpp running on Apple Silicon. WhatsApp only for now. Requires voice-transcription skill to be applied first.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Use Local Whisper
|
|
7
|
+
|
|
8
|
+
Switches voice transcription from OpenAI's Whisper API to local whisper.cpp. Runs entirely on-device — no API key, no network, no cost.
|
|
9
|
+
|
|
10
|
+
**Channel support:** Currently WhatsApp only. The transcription module (`src/transcription.ts`) uses Baileys types for audio download. Other channels (Telegram, Discord, etc.) would need their own audio-download logic before this skill can serve them.
|
|
11
|
+
|
|
12
|
+
**Note:** The Homebrew package is `whisper-cpp`, but the CLI binary it installs is `whisper-cli`.
|
|
13
|
+
|
|
14
|
+
## Prerequisites
|
|
15
|
+
|
|
16
|
+
- `voice-transcription` skill must be applied first (WhatsApp channel)
|
|
17
|
+
- macOS with Apple Silicon (M1+) recommended
|
|
18
|
+
- `whisper-cpp` installed: `brew install whisper-cpp` (provides the `whisper-cli` binary)
|
|
19
|
+
- `ffmpeg` installed: `brew install ffmpeg`
|
|
20
|
+
- A GGML model file downloaded to `data/models/`
|
|
21
|
+
|
|
22
|
+
## Phase 1: Pre-flight
|
|
23
|
+
|
|
24
|
+
### Check if already applied
|
|
25
|
+
|
|
26
|
+
Check if `src/transcription.ts` already uses `whisper-cli`:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
grep 'whisper-cli' src/transcription.ts && echo "Already applied" || echo "Not applied"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
If already applied, skip to Phase 3 (Verify).
|
|
33
|
+
|
|
34
|
+
### Check dependencies are installed
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
whisper-cli --help >/dev/null 2>&1 && echo "WHISPER_OK" || echo "WHISPER_MISSING"
|
|
38
|
+
ffmpeg -version >/dev/null 2>&1 && echo "FFMPEG_OK" || echo "FFMPEG_MISSING"
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
If missing, install via Homebrew:
|
|
42
|
+
```bash
|
|
43
|
+
brew install whisper-cpp ffmpeg
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Check for model file
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
ls data/models/ggml-*.bin 2>/dev/null || echo "NO_MODEL"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
If no model exists, download the base model (148MB, good balance of speed and accuracy):
|
|
53
|
+
```bash
|
|
54
|
+
mkdir -p data/models
|
|
55
|
+
curl -L -o data/models/ggml-base.bin "https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-base.bin"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
For better accuracy at the cost of speed, use `ggml-small.bin` (466MB) or `ggml-medium.bin` (1.5GB).
|
|
59
|
+
|
|
60
|
+
## Phase 2: Apply Code Changes
|
|
61
|
+
|
|
62
|
+
### Ensure WhatsApp fork remote
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
git remote -v
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
If `whatsapp` is missing, add it:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
git remote add whatsapp https://github.com/qwibitai/nanoclaw-whatsapp.git
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Merge the skill branch
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
git fetch whatsapp skill/local-whisper
|
|
78
|
+
git merge whatsapp/skill/local-whisper || {
|
|
79
|
+
git checkout --theirs package-lock.json
|
|
80
|
+
git add package-lock.json
|
|
81
|
+
git merge --continue
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
This modifies `src/transcription.ts` to use the `whisper-cli` binary instead of the OpenAI API.
|
|
86
|
+
|
|
87
|
+
### Validate
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
npm run build
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Phase 3: Verify
|
|
94
|
+
|
|
95
|
+
### Ensure launchd PATH includes Homebrew
|
|
96
|
+
|
|
97
|
+
The NanoClaw launchd service runs with a restricted PATH. `whisper-cli` and `ffmpeg` are in `/opt/homebrew/bin/` (Apple Silicon) or `/usr/local/bin/` (Intel), which may not be in the plist's PATH.
|
|
98
|
+
|
|
99
|
+
Check the current PATH:
|
|
100
|
+
```bash
|
|
101
|
+
grep -A1 'PATH' ~/Library/LaunchAgents/com.nanoclaw.plist
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
If `/opt/homebrew/bin` is missing, add it to the `<string>` value inside the `PATH` key in the plist. Then reload:
|
|
105
|
+
```bash
|
|
106
|
+
launchctl unload ~/Library/LaunchAgents/com.nanoclaw.plist
|
|
107
|
+
launchctl load ~/Library/LaunchAgents/com.nanoclaw.plist
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Build and restart
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
npm run build
|
|
114
|
+
launchctl kickstart -k gui/$(id -u)/com.nanoclaw
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Test
|
|
118
|
+
|
|
119
|
+
Send a voice note in any registered group. The agent should receive it as `[Voice: <transcript>]`.
|
|
120
|
+
|
|
121
|
+
### Check logs
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
tail -f logs/nanoclaw.log | grep -i -E "voice|transcri|whisper"
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Look for:
|
|
128
|
+
- `Transcribed voice message` — successful transcription
|
|
129
|
+
- `whisper.cpp transcription failed` — check model path, ffmpeg, or PATH
|
|
130
|
+
|
|
131
|
+
## Configuration
|
|
132
|
+
|
|
133
|
+
Environment variables (optional, set in `.env`):
|
|
134
|
+
|
|
135
|
+
| Variable | Default | Description |
|
|
136
|
+
|----------|---------|-------------|
|
|
137
|
+
| `WHISPER_BIN` | `whisper-cli` | Path to whisper.cpp binary |
|
|
138
|
+
| `WHISPER_MODEL` | `data/models/ggml-base.bin` | Path to GGML model file |
|
|
139
|
+
|
|
140
|
+
## Troubleshooting
|
|
141
|
+
|
|
142
|
+
**"whisper.cpp transcription failed"**: Ensure both `whisper-cli` and `ffmpeg` are in PATH. The launchd service uses a restricted PATH — see Phase 3 above. Test manually:
|
|
143
|
+
```bash
|
|
144
|
+
ffmpeg -f lavfi -i anullsrc=r=16000:cl=mono -t 1 -f wav /tmp/test.wav -y
|
|
145
|
+
whisper-cli -m data/models/ggml-base.bin -f /tmp/test.wav --no-timestamps -nt
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**Transcription works in dev but not as service**: The launchd plist PATH likely doesn't include `/opt/homebrew/bin`. See "Ensure launchd PATH includes Homebrew" in Phase 3.
|
|
149
|
+
|
|
150
|
+
**Slow transcription**: The base model processes ~30s of audio in <1s on M1+. If slower, check CPU usage — another process may be competing.
|
|
151
|
+
|
|
152
|
+
**Wrong language**: whisper.cpp auto-detects language. To force a language, you can set `WHISPER_LANG` and modify `src/transcription.ts` to pass `-l $WHISPER_LANG`.
|
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: x-integration
|
|
3
|
+
description: X (Twitter) integration for NanoClaw. Post tweets, like, reply, retweet, and quote. Use for setup, testing, or troubleshooting X functionality. Triggers on "setup x", "x integration", "twitter", "post tweet", "tweet".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# X (Twitter) Integration
|
|
7
|
+
|
|
8
|
+
Browser automation for X interactions via WhatsApp.
|
|
9
|
+
|
|
10
|
+
> **Compatibility:** NanoClaw v1.0.0. Directory structure may change in future versions.
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
| Action | Tool | Description |
|
|
15
|
+
|--------|------|-------------|
|
|
16
|
+
| Post | `x_post` | Publish new tweets |
|
|
17
|
+
| Like | `x_like` | Like any tweet |
|
|
18
|
+
| Reply | `x_reply` | Reply to tweets |
|
|
19
|
+
| Retweet | `x_retweet` | Retweet without comment |
|
|
20
|
+
| Quote | `x_quote` | Quote tweet with comment |
|
|
21
|
+
|
|
22
|
+
## Prerequisites
|
|
23
|
+
|
|
24
|
+
Before using this skill, ensure:
|
|
25
|
+
|
|
26
|
+
1. **NanoClaw is installed and running** - WhatsApp connected, service active
|
|
27
|
+
2. **Dependencies installed**:
|
|
28
|
+
```bash
|
|
29
|
+
npm ls playwright dotenv-cli || npm install playwright dotenv-cli
|
|
30
|
+
```
|
|
31
|
+
3. **CHROME_PATH configured** in `.env` (if Chrome is not at default location):
|
|
32
|
+
```bash
|
|
33
|
+
# Find your Chrome path
|
|
34
|
+
mdfind "kMDItemCFBundleIdentifier == 'com.google.Chrome'" 2>/dev/null | head -1
|
|
35
|
+
# Add to .env
|
|
36
|
+
CHROME_PATH=/path/to/Google Chrome.app/Contents/MacOS/Google Chrome
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Quick Start
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# 1. Setup authentication (interactive)
|
|
43
|
+
npx dotenv -e .env -- npx tsx .claude/skills/x-integration/scripts/setup.ts
|
|
44
|
+
# Verify: data/x-auth.json should exist after successful login
|
|
45
|
+
|
|
46
|
+
# 2. Rebuild container to include skill
|
|
47
|
+
./container/build.sh
|
|
48
|
+
# Verify: Output shows "COPY .claude/skills/x-integration/agent.ts"
|
|
49
|
+
|
|
50
|
+
# 3. Rebuild host and restart service
|
|
51
|
+
npm run build
|
|
52
|
+
launchctl kickstart -k gui/$(id -u)/com.nanoclaw # macOS
|
|
53
|
+
# Linux: systemctl --user restart nanoclaw
|
|
54
|
+
# Verify: launchctl list | grep nanoclaw (macOS) or systemctl --user status nanoclaw (Linux)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Configuration
|
|
58
|
+
|
|
59
|
+
### Environment Variables
|
|
60
|
+
|
|
61
|
+
| Variable | Default | Description |
|
|
62
|
+
|----------|---------|-------------|
|
|
63
|
+
| `CHROME_PATH` | `/Applications/Google Chrome.app/Contents/MacOS/Google Chrome` | Chrome executable path |
|
|
64
|
+
| `NANOCLAW_ROOT` | `process.cwd()` | Project root directory |
|
|
65
|
+
| `LOG_LEVEL` | `info` | Logging level (debug, info, warn, error) |
|
|
66
|
+
|
|
67
|
+
Set in `.env` file (loaded via `dotenv-cli` at runtime):
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# .env
|
|
71
|
+
CHROME_PATH=/Applications/Google Chrome.app/Contents/MacOS/Google Chrome
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Configuration File
|
|
75
|
+
|
|
76
|
+
Edit `lib/config.ts` to modify defaults:
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
export const config = {
|
|
80
|
+
// Browser viewport
|
|
81
|
+
viewport: { width: 1280, height: 800 },
|
|
82
|
+
|
|
83
|
+
// Timeouts (milliseconds)
|
|
84
|
+
timeouts: {
|
|
85
|
+
navigation: 30000, // Page navigation
|
|
86
|
+
elementWait: 5000, // Wait for element
|
|
87
|
+
afterClick: 1000, // Delay after click
|
|
88
|
+
afterFill: 1000, // Delay after form fill
|
|
89
|
+
afterSubmit: 3000, // Delay after submit
|
|
90
|
+
pageLoad: 3000, // Initial page load
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
// Tweet limits
|
|
94
|
+
limits: {
|
|
95
|
+
tweetMaxLength: 280,
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Data Directories
|
|
101
|
+
|
|
102
|
+
Paths relative to project root:
|
|
103
|
+
|
|
104
|
+
| Path | Purpose | Git |
|
|
105
|
+
|------|---------|-----|
|
|
106
|
+
| `data/x-browser-profile/` | Chrome profile with X session | Ignored |
|
|
107
|
+
| `data/x-auth.json` | Auth state marker | Ignored |
|
|
108
|
+
| `logs/nanoclaw.log` | Service logs (contains X operation logs) | Ignored |
|
|
109
|
+
|
|
110
|
+
## Architecture
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
114
|
+
│ Container (Linux VM) │
|
|
115
|
+
│ └── agent.ts → MCP tool definitions (x_post, etc.) │
|
|
116
|
+
│ └── Writes IPC request to /workspace/ipc/tasks/ │
|
|
117
|
+
└──────────────────────┬──────────────────────────────────────┘
|
|
118
|
+
│ IPC (file system)
|
|
119
|
+
▼
|
|
120
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
121
|
+
│ Host (macOS) │
|
|
122
|
+
│ └── src/ipc.ts → processTaskIpc() │
|
|
123
|
+
│ └── host.ts → handleXIpc() │
|
|
124
|
+
│ └── spawn subprocess → scripts/*.ts │
|
|
125
|
+
│ └── Playwright → Chrome → X Website │
|
|
126
|
+
└─────────────────────────────────────────────────────────────┘
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Why This Design?
|
|
130
|
+
|
|
131
|
+
- **API is expensive** - X official API requires paid subscription ($100+/month) for posting
|
|
132
|
+
- **Bot browsers get blocked** - X detects and bans headless browsers and common automation fingerprints
|
|
133
|
+
- **Must use user's real browser** - Reuses the user's actual Chrome on Host with real browser fingerprint to avoid detection
|
|
134
|
+
- **One-time authorization** - User logs in manually once, session persists in Chrome profile for future use
|
|
135
|
+
|
|
136
|
+
### File Structure
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
.claude/skills/x-integration/
|
|
140
|
+
├── SKILL.md # This documentation
|
|
141
|
+
├── host.ts # Host-side IPC handler
|
|
142
|
+
├── agent.ts # Container-side MCP tool definitions
|
|
143
|
+
├── lib/
|
|
144
|
+
│ ├── config.ts # Centralized configuration
|
|
145
|
+
│ └── browser.ts # Playwright utilities
|
|
146
|
+
└── scripts/
|
|
147
|
+
├── setup.ts # Interactive login
|
|
148
|
+
├── post.ts # Post tweet
|
|
149
|
+
├── like.ts # Like tweet
|
|
150
|
+
├── reply.ts # Reply to tweet
|
|
151
|
+
├── retweet.ts # Retweet
|
|
152
|
+
└── quote.ts # Quote tweet
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Integration Points
|
|
156
|
+
|
|
157
|
+
To integrate this skill into NanoClaw, make the following modifications:
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
**1. Host side: `src/ipc.ts`**
|
|
162
|
+
|
|
163
|
+
Add import after other local imports:
|
|
164
|
+
```typescript
|
|
165
|
+
import { handleXIpc } from '../.claude/skills/x-integration/host.js';
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Modify `processTaskIpc` function's switch statement default case:
|
|
169
|
+
```typescript
|
|
170
|
+
// Find:
|
|
171
|
+
default:
|
|
172
|
+
logger.warn({ type: data.type }, 'Unknown IPC task type');
|
|
173
|
+
|
|
174
|
+
// Replace with:
|
|
175
|
+
default:
|
|
176
|
+
const handled = await handleXIpc(data, sourceGroup, isMain, DATA_DIR);
|
|
177
|
+
if (!handled) {
|
|
178
|
+
logger.warn({ type: data.type }, 'Unknown IPC task type');
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
**2. Container side: `container/agent-runner/src/ipc-mcp.ts`**
|
|
185
|
+
|
|
186
|
+
Add import after `cron-parser` import:
|
|
187
|
+
```typescript
|
|
188
|
+
// @ts-ignore - Copied during Docker build from .claude/skills/x-integration/
|
|
189
|
+
import { createXTools } from './skills/x-integration/agent.js';
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Add to the end of tools array (before the closing `]`):
|
|
193
|
+
```typescript
|
|
194
|
+
...createXTools({ groupFolder, isMain })
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
**3. Build script: `container/build.sh`**
|
|
200
|
+
|
|
201
|
+
Change build context from `container/` to project root (required to access `.claude/skills/`):
|
|
202
|
+
```bash
|
|
203
|
+
# Find:
|
|
204
|
+
docker build -t "${IMAGE_NAME}:${TAG}" .
|
|
205
|
+
|
|
206
|
+
# Replace with:
|
|
207
|
+
cd "$SCRIPT_DIR/.."
|
|
208
|
+
docker build -t "${IMAGE_NAME}:${TAG}" -f container/Dockerfile .
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
**4. Dockerfile: `container/Dockerfile`**
|
|
214
|
+
|
|
215
|
+
First, update the build context paths (required to access `.claude/skills/` from project root):
|
|
216
|
+
```dockerfile
|
|
217
|
+
# Find:
|
|
218
|
+
COPY agent-runner/package*.json ./
|
|
219
|
+
...
|
|
220
|
+
COPY agent-runner/ ./
|
|
221
|
+
|
|
222
|
+
# Replace with:
|
|
223
|
+
COPY container/agent-runner/package*.json ./
|
|
224
|
+
...
|
|
225
|
+
COPY container/agent-runner/ ./
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Then add COPY line after `COPY container/agent-runner/ ./` and before `RUN npm run build`:
|
|
229
|
+
```dockerfile
|
|
230
|
+
# Copy skill MCP tools
|
|
231
|
+
COPY .claude/skills/x-integration/agent.ts ./src/skills/x-integration/
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Setup
|
|
235
|
+
|
|
236
|
+
All paths below are relative to project root (`NANOCLAW_ROOT`).
|
|
237
|
+
|
|
238
|
+
### 1. Check Chrome Path
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
# Check if Chrome exists at configured path
|
|
242
|
+
cat .env | grep CHROME_PATH
|
|
243
|
+
ls -la "$(grep CHROME_PATH .env | cut -d= -f2)" 2>/dev/null || \
|
|
244
|
+
echo "Chrome not found - update CHROME_PATH in .env"
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### 2. Run Authentication
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
npx dotenv -e .env -- npx tsx .claude/skills/x-integration/scripts/setup.ts
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
This opens Chrome for manual X login. Session saved to `data/x-browser-profile/`.
|
|
254
|
+
|
|
255
|
+
**Verify success:**
|
|
256
|
+
```bash
|
|
257
|
+
cat data/x-auth.json # Should show {"authenticated": true, ...}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### 3. Rebuild Container
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
./container/build.sh
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
**Verify success:**
|
|
267
|
+
```bash
|
|
268
|
+
./container/build.sh 2>&1 | grep -i "agent.ts" # Should show COPY line
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### 4. Restart Service
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
npm run build
|
|
275
|
+
launchctl kickstart -k gui/$(id -u)/com.nanoclaw # macOS
|
|
276
|
+
# Linux: systemctl --user restart nanoclaw
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
**Verify success:**
|
|
280
|
+
```bash
|
|
281
|
+
launchctl list | grep nanoclaw # macOS — should show PID and exit code 0 or -
|
|
282
|
+
# Linux: systemctl --user status nanoclaw
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## Usage via WhatsApp
|
|
286
|
+
|
|
287
|
+
Replace `@Assistant` with your configured trigger name (`ASSISTANT_NAME` in `.env`):
|
|
288
|
+
|
|
289
|
+
```
|
|
290
|
+
@Assistant post a tweet: Hello world!
|
|
291
|
+
|
|
292
|
+
@Assistant like this tweet https://x.com/user/status/123
|
|
293
|
+
|
|
294
|
+
@Assistant reply to https://x.com/user/status/123 with: Great post!
|
|
295
|
+
|
|
296
|
+
@Assistant retweet https://x.com/user/status/123
|
|
297
|
+
|
|
298
|
+
@Assistant quote https://x.com/user/status/123 with comment: Interesting
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
**Note:** Only the main group can use X tools. Other groups will receive an error.
|
|
302
|
+
|
|
303
|
+
## Testing
|
|
304
|
+
|
|
305
|
+
Scripts require environment variables from `.env`. Use `dotenv-cli` to load them:
|
|
306
|
+
|
|
307
|
+
### Check Authentication Status
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
# Check if auth file exists and is valid
|
|
311
|
+
cat data/x-auth.json 2>/dev/null && echo "Auth configured" || echo "Auth not configured"
|
|
312
|
+
|
|
313
|
+
# Check if browser profile exists
|
|
314
|
+
ls -la data/x-browser-profile/ 2>/dev/null | head -5
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### Re-authenticate (if expired)
|
|
318
|
+
|
|
319
|
+
```bash
|
|
320
|
+
npx dotenv -e .env -- npx tsx .claude/skills/x-integration/scripts/setup.ts
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
### Test Post (will actually post)
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
echo '{"content":"Test tweet - please ignore"}' | npx dotenv -e .env -- npx tsx .claude/skills/x-integration/scripts/post.ts
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### Test Like
|
|
330
|
+
|
|
331
|
+
```bash
|
|
332
|
+
echo '{"tweetUrl":"https://x.com/user/status/123"}' | npx dotenv -e .env -- npx tsx .claude/skills/x-integration/scripts/like.ts
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
Or export `CHROME_PATH` manually before running:
|
|
336
|
+
|
|
337
|
+
```bash
|
|
338
|
+
export CHROME_PATH="/path/to/chrome"
|
|
339
|
+
echo '{"content":"Test"}' | npx tsx .claude/skills/x-integration/scripts/post.ts
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
## Troubleshooting
|
|
343
|
+
|
|
344
|
+
### Authentication Expired
|
|
345
|
+
|
|
346
|
+
```bash
|
|
347
|
+
npx dotenv -e .env -- npx tsx .claude/skills/x-integration/scripts/setup.ts
|
|
348
|
+
launchctl kickstart -k gui/$(id -u)/com.nanoclaw # macOS
|
|
349
|
+
# Linux: systemctl --user restart nanoclaw
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### Browser Lock Files
|
|
353
|
+
|
|
354
|
+
If Chrome fails to launch:
|
|
355
|
+
|
|
356
|
+
```bash
|
|
357
|
+
rm -f data/x-browser-profile/SingletonLock
|
|
358
|
+
rm -f data/x-browser-profile/SingletonSocket
|
|
359
|
+
rm -f data/x-browser-profile/SingletonCookie
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
### Check Logs
|
|
363
|
+
|
|
364
|
+
```bash
|
|
365
|
+
# Host logs (relative to project root)
|
|
366
|
+
grep -i "x_post\|x_like\|x_reply\|handleXIpc" logs/nanoclaw.log | tail -20
|
|
367
|
+
|
|
368
|
+
# Script errors
|
|
369
|
+
grep -i "error\|failed" logs/nanoclaw.log | tail -20
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### Script Timeout
|
|
373
|
+
|
|
374
|
+
Default timeout is 2 minutes (120s). Increase in `host.ts`:
|
|
375
|
+
|
|
376
|
+
```typescript
|
|
377
|
+
const timer = setTimeout(() => {
|
|
378
|
+
proc.kill('SIGTERM');
|
|
379
|
+
resolve({ success: false, message: 'Script timed out (120s)' });
|
|
380
|
+
}, 120000); // ← Increase this value
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
### X UI Selector Changes
|
|
384
|
+
|
|
385
|
+
If X updates their UI, selectors in scripts may break. Current selectors:
|
|
386
|
+
|
|
387
|
+
| Element | Selector |
|
|
388
|
+
|---------|----------|
|
|
389
|
+
| Tweet input | `[data-testid="tweetTextarea_0"]` |
|
|
390
|
+
| Post button | `[data-testid="tweetButtonInline"]` |
|
|
391
|
+
| Reply button | `[data-testid="reply"]` |
|
|
392
|
+
| Like | `[data-testid="like"]` |
|
|
393
|
+
| Unlike | `[data-testid="unlike"]` |
|
|
394
|
+
| Retweet | `[data-testid="retweet"]` |
|
|
395
|
+
| Unretweet | `[data-testid="unretweet"]` |
|
|
396
|
+
| Confirm retweet | `[data-testid="retweetConfirm"]` |
|
|
397
|
+
| Modal dialog | `[role="dialog"][aria-modal="true"]` |
|
|
398
|
+
| Modal submit | `[data-testid="tweetButton"]` |
|
|
399
|
+
|
|
400
|
+
### Container Build Issues
|
|
401
|
+
|
|
402
|
+
If MCP tools not found in container:
|
|
403
|
+
|
|
404
|
+
```bash
|
|
405
|
+
# Verify build copies skill
|
|
406
|
+
./container/build.sh 2>&1 | grep -i skill
|
|
407
|
+
|
|
408
|
+
# Check container has the file
|
|
409
|
+
docker run nanoclaw-agent ls -la /app/src/skills/
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
## Security
|
|
413
|
+
|
|
414
|
+
- `data/x-browser-profile/` - Contains X session cookies (in `.gitignore`)
|
|
415
|
+
- `data/x-auth.json` - Auth state marker (in `.gitignore`)
|
|
416
|
+
- Only main group can use X tools (enforced in `agent.ts` and `host.ts`)
|
|
417
|
+
- Scripts run as subprocesses with limited environment
|