parallelclaw 1.0.0
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/CHANGELOG.md +204 -0
- package/HELP.md +600 -0
- package/LICENSE +21 -0
- package/MULTI_MACHINE.md +152 -0
- package/README.md +417 -0
- package/README.ru.md +740 -0
- package/SYNC.md +844 -0
- package/bot/README.md +173 -0
- package/bot/config.js +66 -0
- package/bot/inbox.js +153 -0
- package/bot/index.js +294 -0
- package/bot/nexara.js +61 -0
- package/bot/poll.js +304 -0
- package/bot/search.js +155 -0
- package/bot/telegram.js +96 -0
- package/ingest.js +2712 -0
- package/lib/cli/index.js +1987 -0
- package/lib/config.js +220 -0
- package/lib/db-init.js +158 -0
- package/lib/hook/install.js +268 -0
- package/lib/import-telegram.js +158 -0
- package/lib/ingest-file.js +779 -0
- package/lib/notify-click-action.js +281 -0
- package/lib/openclaw-channel.js +643 -0
- package/lib/parse-cursor.js +172 -0
- package/lib/parse-obsidian.js +256 -0
- package/lib/parse-telegram-html.js +384 -0
- package/lib/parse.js +175 -0
- package/lib/render-markdown.js +0 -0
- package/lib/store-doc/canonicalize.js +116 -0
- package/lib/store-doc/detect.js +209 -0
- package/lib/store-doc/extract-title.js +162 -0
- package/lib/sync/auth.js +80 -0
- package/lib/sync/cert.js +144 -0
- package/lib/sync/cli.js +906 -0
- package/lib/sync/client.js +138 -0
- package/lib/sync/config.js +130 -0
- package/lib/sync/pair.js +145 -0
- package/lib/sync/pull.js +158 -0
- package/lib/sync/push.js +305 -0
- package/lib/sync/replicate.js +335 -0
- package/lib/sync/server.js +224 -0
- package/lib/sync/service.js +726 -0
- package/lib/tasks.js +215 -0
- package/lib/telegram-decisions.js +165 -0
- package/lib/telegram-discovery.js +373 -0
- package/lib/telegram-notify.js +272 -0
- package/lib/telegram-pending.js +200 -0
- package/lib/web/index.js +265 -0
- package/lib/web/routes/conversation.js +193 -0
- package/lib/web/routes/conversations.js +180 -0
- package/lib/web/routes/dashboard.js +175 -0
- package/lib/web/routes/pending.js +277 -0
- package/lib/web/routes/settings.js +226 -0
- package/lib/web/static/style.css +393 -0
- package/lib/web/templates.js +234 -0
- package/package.json +84 -0
- package/server.js +3816 -0
- package/skills/install-memex/README.md +109 -0
- package/skills/install-memex/SKILL.md +342 -0
- package/skills/install-memex/examples.md +294 -0
- package/skills/install-memex-claw/SKILL.md +423 -0
package/MULTI_MACHINE.md
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# Multi-machine ParallelClaw
|
|
2
|
+
|
|
3
|
+
> 🆕 **Update (v0.13):** настоящий двусторонний sync встроен и ставится **двумя
|
|
4
|
+
> copy-paste шагами**: агент на сервере выполняет `memex-sync sync-server install
|
|
5
|
+
> --bind 127.0.0.1` + `memex-sync sync-server invite --join`, ты на ноуте — одну
|
|
6
|
+
> команду `memex-sync sync-join <токен>`. Туннель (самовосстанавливающийся),
|
|
7
|
+
> расписание, watchdog и проверка петли ставятся автоматически; никаких
|
|
8
|
+
> публичных портов и ручных ключей. Полный гайд — [SYNC.md](SYNC.md),
|
|
9
|
+
> краткий — README → Cross-device.
|
|
10
|
+
>
|
|
11
|
+
> Паттерны A/B/C ниже — **DEPRECATED legacy-обходные пути** (file-sync с
|
|
12
|
+
> ограничением single-writer). Подходят только тем, кто сознательно не хочет
|
|
13
|
+
> включать sync-движок. Для всех новых установок — `sync-join`.
|
|
14
|
+
|
|
15
|
+
## Почему это сложно
|
|
16
|
+
|
|
17
|
+
memex — это локальный SQLite-файл (`~/.memex/data/memex.db`) который активно пишется (auto-capture daemon, MCP-сервер при импорте inbox). Если **два экземпляра memex** на разных машинах одновременно пишут в **один и тот же** SQLite-файл через filesystem-sync (Syncthing/Dropbox/iCloud), почти гарантированный исход — повреждение БД. SQLite WAL-mode безопасен только когда все процессы видят одну файловую систему, не когда файл синкается «снаружи».
|
|
18
|
+
|
|
19
|
+
Поэтому ниже — паттерны которые **обходят** проблему конкурентной записи, не решают её.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Паттерн A — Hub + read-replicas (рекомендуется)
|
|
24
|
+
|
|
25
|
+
**Идея:** одна машина «hub» — основная (например рабочий ноут). Только на ней крутится daemon и memex MCP-сервер. Остальные машины получают **read-only копию** БД через любой filesystem-sync.
|
|
26
|
+
|
|
27
|
+
**Как настроить:**
|
|
28
|
+
|
|
29
|
+
На hub-машине (рабочий ноут):
|
|
30
|
+
```bash
|
|
31
|
+
npx memex-sync install # как обычно
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Подключи Syncthing / iCloud Drive / Dropbox / OneDrive только к **папке `~/.memex/data/`**, не к `~/.memex/inbox/`:
|
|
35
|
+
```
|
|
36
|
+
Source on hub: ~/.memex/data/ (read-write)
|
|
37
|
+
Target on B/C/…: ~/.memex/data/ (read-only)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
На read-replica машинах:
|
|
41
|
+
- НЕ запускай `memex-sync install` (иначе будет конкурентная запись)
|
|
42
|
+
- Подключи memex как обычный MCP-сервер в Claude Code config
|
|
43
|
+
- Доступ к памяти полный read-only — `memex_search`, `memex_get_conversation`, `memex_overview` все работают
|
|
44
|
+
|
|
45
|
+
**Плюсы:** простая настройка, single-writer гарантирован, не нужны custom-скрипты.
|
|
46
|
+
|
|
47
|
+
**Минусы:** read-replica eventually consistent (latency 5-30 секунд в зависимости от sync-провайдера). Если сидишь на ноутбуке-replica и одновременно ведёшь сессию Claude Code — она НЕ попадёт в memex пока ты не вернёшься к hub. Для большинства пользователей это OK.
|
|
48
|
+
|
|
49
|
+
**Гочи:**
|
|
50
|
+
- На read-replica добавь `&mode=ro` в путь к БД если возможно — снижает риск случайной записи
|
|
51
|
+
- Не запускай `npx memex-sync install` на replica — проверь через `npx memex-sync status` что daemon **не** установлен
|
|
52
|
+
- Если ты редактируешь конфиг через MCP (например `memex_archive_conversation`) на replica — изменение **не** залетит обратно на hub
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Паттерн B — Per-machine independent + shared archive
|
|
57
|
+
|
|
58
|
+
**Идея:** каждая машина ведёт свою memex.db самостоятельно (свой daemon, свой MCP). Синкается только **архив исходных файлов** (`~/.memex/data/conversations/`). Когда хочешь чтобы machine B увидела сессии с machine A — кладёшь файлы из архива в её inbox.
|
|
59
|
+
|
|
60
|
+
**Как настроить:**
|
|
61
|
+
|
|
62
|
+
На обеих машинах:
|
|
63
|
+
```bash
|
|
64
|
+
npx memex-sync install
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Sync через Syncthing/iCloud только папки:
|
|
68
|
+
```
|
|
69
|
+
~/.memex/data/conversations/ (bi-directional)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Когда хочешь импортировать чужую активность на текущую машину:
|
|
73
|
+
```bash
|
|
74
|
+
# скопировать все накопленные с другой машины JSONL в свой inbox
|
|
75
|
+
cp ~/.memex/data/conversations/claude-code/*.jsonl ~/.memex/inbox/
|
|
76
|
+
cp ~/.memex/data/conversations/claude-cowork/*.jsonl ~/.memex/inbox/
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
memex inbox-watcher подберёт их за секунды, дедуп через UNIQUE(msg_id) отсечёт уже виденные сообщения.
|
|
80
|
+
|
|
81
|
+
**Плюсы:** обе машины полностью функциональны независимо. Никаких read-only ограничений.
|
|
82
|
+
|
|
83
|
+
**Минусы:** ручной шаг «принести историю с другой машины». Возможно автоматизировать через cron, но это уже custom.
|
|
84
|
+
|
|
85
|
+
**Гочи:**
|
|
86
|
+
- НЕ синкай `~/.memex/data/memex.db` — каждая машина имеет свой
|
|
87
|
+
- НЕ синкай `~/.memex/inbox/` — race с inbox-watcher
|
|
88
|
+
- Важно — у нас сейчас daemon процессит ингест **в архив автоматически после import**. Так что после первого ингеста на A, файл попадает в `data/conversations/`, Syncthing-копирует его на B. На B этот файл **уже** в архиве — не нужно повторно его инжектить.
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Паттерн C — Single-master через rsync (для CLI-power-users)
|
|
93
|
+
|
|
94
|
+
**Идея:** не используем непрерывный sync вообще. По требованию делаем `rsync` всего `~/.memex/` с одной машины на другую. Single-master, никаких race-условий.
|
|
95
|
+
|
|
96
|
+
**Как настроить:**
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
# Из B "забрать" свежее состояние с A
|
|
100
|
+
rsync -av --delete user@hostA:.memex/ ~/.memex/
|
|
101
|
+
|
|
102
|
+
# Не забудь остановить daemon на B перед rsync если он установлен:
|
|
103
|
+
launchctl unload ~/Library/LaunchAgents/com.parallelclaw.memex.sync.plist
|
|
104
|
+
|
|
105
|
+
# После rsync — снова запусти, но осторожно:
|
|
106
|
+
# state-файл daemon'а тоже синкается, теперь B будет считать что уже видел все источники A
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**Плюсы:** простой mental model, никаких длительных процессов sync, явный контроль когда происходит обмен.
|
|
110
|
+
|
|
111
|
+
**Минусы:** ручной запуск, потенциальная проблема с offset state daemon'а (если на B раньше был свой daemon — его state перезаписывается).
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Сравнительная таблица
|
|
116
|
+
|
|
117
|
+
| | Паттерн A (Hub+replicas) | Паттерн B (Per-machine) | Паттерн C (rsync) |
|
|
118
|
+
|---|---|---|---|
|
|
119
|
+
| Свежесть данных | 5-30 сек lag | сразу после copy | по нажатию |
|
|
120
|
+
| Сложность настройки | низкая | средняя | низкая |
|
|
121
|
+
| Риск повреждения БД | нулевой (single-writer) | нулевой (отдельные БД) | нулевой |
|
|
122
|
+
| Работает offline | ✅ | ✅ | ✅ |
|
|
123
|
+
| Запись с любой машины | ❌ | ✅ | ❌ (single-master) |
|
|
124
|
+
| Custom-скрипты нужны | ❌ | да (cp в inbox) | да (rsync wrapper) |
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Что сделать **нельзя** (общие грабли)
|
|
129
|
+
|
|
130
|
+
- ❌ **Синкать `~/.memex/data/memex.db` между двумя машинами с активным daemon'ом** — гарантированное повреждение БД через несколько часов
|
|
131
|
+
- ❌ **Синкать `~/.memex/inbox/`** — chokidar-watcher на одной машине может удалить файл из inbox раньше чем sync долетит до второй, второй машина потеряет данные
|
|
132
|
+
- ❌ **Хранить БД на сетевой ФС (NFS/SMB) и работать с ней с двух машин одновременно** — SQLite WAL не дружит с network FS
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## Что в roadmap
|
|
137
|
+
|
|
138
|
+
**v0.4 — Multi-device sync через CRDT.** Каждая машина хранит локальную копию + change-log. Синхронизация через любой transport (cloud relay, peer-to-peer, USB). Конфликтное состояние невозможно by-design. Это нетривиальная инженерная задача (~3-4 недели), но она в плане.
|
|
139
|
+
|
|
140
|
+
До v0.4 — пользуйся паттернами выше. Для большинства pro-юзеров **Паттерн A (Hub + read-replicas)** покрывает 90% потребностей.
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Помощь
|
|
145
|
+
|
|
146
|
+
Если у тебя нестандартный setup и непонятно как лучше — открой [issue](https://github.com/parallelclaw/memex-mvp/issues) с описанием:
|
|
147
|
+
- сколько у тебя машин
|
|
148
|
+
- какой sync-провайдер ты уже используешь (Syncthing / iCloud / git-annex / etc.)
|
|
149
|
+
- ОС каждой машины
|
|
150
|
+
- хочешь ли write-доступ с каждой или только с одной
|
|
151
|
+
|
|
152
|
+
Подскажем какой паттерн оптимален.
|
package/README.md
ADDED
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
# ParallelClaw · shared memory + coordination for your AI agents
|
|
2
|
+
|
|
3
|
+
> **English** · [Русский](README.ru.md)
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/parallelclaw)
|
|
6
|
+
[](https://www.npmjs.com/package/parallelclaw)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
|
|
9
|
+
> **One verbatim memory for all your AI agents — and a coordination layer so they can hand tasks to each other.**
|
|
10
|
+
|
|
11
|
+
ParallelClaw is a local-first **personal AI ops layer**, built in two layers:
|
|
12
|
+
|
|
13
|
+
1. **Shared memory (the foundation, shipped).** A local-first MCP server indexes **every conversation you have with AI** — Claude Code, Claude Cowork, Cursor, OpenClaw, Hermes, Obsidian notes, and selected Telegram chats — into one searchable SQLite + FTS5 corpus, served to **any MCP-compatible client** through a handful of tools.
|
|
14
|
+
2. **Coordination (the direction, rolling out).** On top of that shared memory, any of your agents can **delegate a task to any other** — across tools and across machines. It runs when that agent is available; the result comes back to where you asked. The transport (cross-machine sync + per-row provenance) is live today; the turnkey delegation loop is rolling out.
|
|
15
|
+
|
|
16
|
+
No cloud. No account. No data leaves your machine.
|
|
17
|
+
|
|
18
|
+
> **CLI naming:** the binary is `parallelclaw` (short alias `pclaw`). The legacy `memex` / `memex-sync` commands, the `~/.memex` data dir, and the `memex_*` MCP tool names are kept as-is for back-compat — so examples below that say `memex …` still work verbatim.
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
~/.memex/inbox/ ← drop chat exports here (or symlink AI session files)
|
|
22
|
+
↓ chokidar watcher
|
|
23
|
+
parser (Telegram JSON · Claude Code JSONL · Cursor SQLite · Obsidian md)
|
|
24
|
+
↓
|
|
25
|
+
SQLite + FTS5 (~/.memex/data/memex.db)
|
|
26
|
+
↓
|
|
27
|
+
MCP server → Claude Code · Cursor · OpenClaw · …
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Install in 60 seconds
|
|
33
|
+
|
|
34
|
+
**One-line install (recommended):**
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
curl -fsSL https://memex.parallelclaw.ai/install.sh | bash
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
That single command:
|
|
41
|
+
1. Verifies Node ≥ 20.
|
|
42
|
+
2. Runs `npm install -g parallelclaw`, auto-fixing `EACCES` by moving npm's prefix to `~/.npm-global` (no `sudo` needed, ever).
|
|
43
|
+
3. Installs the auto-capture daemon (`memex-sync install`) **with** the v0.8 Brian Chesky auto-context hook into `~/.claude/settings.json` (preserves existing hooks).
|
|
44
|
+
4. Backfills history (`memex-sync scan`) so memex already knows about your past sessions.
|
|
45
|
+
5. If `claude` (Claude Code CLI) is on PATH, runs `claude mcp add memex --scope user -- memex` to wire MCP automatically.
|
|
46
|
+
|
|
47
|
+
Idempotent — safe to re-run. To inspect the script before piping to bash: `curl -fsSL https://memex.parallelclaw.ai/install.sh | less`.
|
|
48
|
+
|
|
49
|
+
**Prefer manual install?**
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
npm install -g parallelclaw
|
|
53
|
+
memex-sync install # macOS LaunchAgent for auto-capture
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
If `npm install -g` hits `EACCES` (system Node on macOS), either fix your prefix once:
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
mkdir -p ~/.npm-global
|
|
60
|
+
npm config set prefix ~/.npm-global
|
|
61
|
+
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.zshrc
|
|
62
|
+
source ~/.zshrc
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Or use one-shot `sudo npm install -g parallelclaw`.
|
|
66
|
+
|
|
67
|
+
**Want to try without installing globally?**
|
|
68
|
+
|
|
69
|
+
```sh
|
|
70
|
+
npx -p parallelclaw memex-sync install
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Install via AI skill (Claude Code / OpenClaw)
|
|
74
|
+
|
|
75
|
+
If you'd rather have an AI agent walk you through everything, drop the
|
|
76
|
+
[install-memex skill](skills/install-memex/) into `~/.claude/skills/`:
|
|
77
|
+
|
|
78
|
+
```sh
|
|
79
|
+
mkdir -p ~/.claude/skills
|
|
80
|
+
curl -fsSL https://raw.githubusercontent.com/parallelclaw/memex-mvp/main/skills/install-memex/SKILL.md \
|
|
81
|
+
-o ~/.claude/skills/install-memex/SKILL.md
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Then in Claude Code (or any Skills-aware agent) just say:
|
|
85
|
+
|
|
86
|
+
> install memex
|
|
87
|
+
|
|
88
|
+
…or `/install-memex`. The agent handles `npm install`, MCP-config wiring,
|
|
89
|
+
auto-capture daemon, and verification — ~2 minutes.
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Connect to your MCP client
|
|
94
|
+
|
|
95
|
+
After install, point your client at `memex` (an alias of `server.js` exposed on `PATH`):
|
|
96
|
+
|
|
97
|
+
### Claude Code
|
|
98
|
+
|
|
99
|
+
```sh
|
|
100
|
+
claude mcp add memex --scope user -- memex
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Cursor / OpenClaw
|
|
104
|
+
|
|
105
|
+
Add to that client's MCP config (e.g. `~/.cursor/mcp.json`):
|
|
106
|
+
|
|
107
|
+
```json
|
|
108
|
+
{
|
|
109
|
+
"mcpServers": {
|
|
110
|
+
"memex": { "command": "memex" }
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Restart the client. Try the prompt:
|
|
116
|
+
|
|
117
|
+
> *"Use memex_overview to show me what's in my AI memory."*
|
|
118
|
+
|
|
119
|
+
If you see a snapshot of sources and recent conversations — you're done.
|
|
120
|
+
|
|
121
|
+
For a fully-automated install across all detected MCP clients, see [the AI-driven install guide](https://memex.parallelclaw.ai) on the landing page (paste the prompt into any MCP-enabled agent, it'll wire everything up itself).
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Terminal CLI (v0.7+) — query memex without MCP
|
|
126
|
+
|
|
127
|
+
The same `memex` binary that runs as an MCP server also has a terminal mode for direct queries. Useful when MCP isn't wired up, when you want to pipe results into shell scripts, or when debugging MCP-config issues:
|
|
128
|
+
|
|
129
|
+
```sh
|
|
130
|
+
memex search "Postgres migration" # full-text search
|
|
131
|
+
memex search "Q2 deck" --chat "Memex Bot" # scope to one conversation by title
|
|
132
|
+
memex search "JWT" --as-of 2026-05-01 # v0.8.1: time-travel — only msgs before date
|
|
133
|
+
memex when "Brian Chesky" # v0.8.1: "when did we talk about X" — dates + chats
|
|
134
|
+
memex recent --limit 5 # last 5 messages across all sources
|
|
135
|
+
memex list --source web # all saved URLs
|
|
136
|
+
memex get web-1582ab51a7b7 # full content of one conversation
|
|
137
|
+
memex overview # snapshot of corpus + v0.8.1: capture streak
|
|
138
|
+
memex projects # distinct project_paths captured
|
|
139
|
+
memex import ~/projects/memex/result.json # v0.10.12: ingest any file from any path
|
|
140
|
+
memex help # full user guide (HELP.md)
|
|
141
|
+
memex --help # command reference
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Ingest from any path (v0.10.12+)
|
|
145
|
+
|
|
146
|
+
```sh
|
|
147
|
+
memex import ~/projects/memex/result.json # auto-detects Telegram JSON
|
|
148
|
+
memex import ~/Downloads/ChatExport_2026-05-18/ # Telegram HTML export directory
|
|
149
|
+
memex import ~/path/to/session.jsonl # Claude Code JSONL
|
|
150
|
+
memex import ~/Downloads/result.json --force # skip Telegram privacy gate
|
|
151
|
+
memex import some-file --format claude-jsonl # explicit format override
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
For Telegram, the privacy gate fires for any chat that isn't on your allow-list — the command exits with a preview (title, message count, date range, senders) so you can review before re-running with `--force`. Same path via MCP: any AI agent can call `memex_import_file({path: "..."})` to ingest one file in one tool call (instead of ~10k tokens of bash `mv`-shuffling).
|
|
155
|
+
|
|
156
|
+
Every query supports `--json` for machine-readable output: `memex search foo --json | jq '.results[].snippet'`. The DB is opened **read-only** — safe to run while `memex-sync` daemon is writing.
|
|
157
|
+
|
|
158
|
+
When called **without arguments** (`memex`), the binary still runs as an MCP stdio server (the way Claude Code / Cursor / OpenClaw launch it). CLI mode and MCP mode are the same package — no extra install.
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Auto-context (v0.8+) — Claude already knows what you were doing
|
|
163
|
+
|
|
164
|
+
After `memex-sync install`, you're prompted to enable **auto-context**. When yes, memex adds a SessionStart hook to `~/.claude/settings.json` so that **every time you open Claude Code in a project**, Claude gets injected with ~500-1500 tokens of relevant context — what you did recently in this project, which conversations touched it, which related topics came up. No prompts. No tool calls. Just memory.
|
|
165
|
+
|
|
166
|
+
```sh
|
|
167
|
+
# Adding/removing the hook outside the install flow:
|
|
168
|
+
memex hook install # add SessionStart hook (idempotent)
|
|
169
|
+
memex hook uninstall # remove only the memex entry, preserves other hooks
|
|
170
|
+
memex hook status # show current state
|
|
171
|
+
|
|
172
|
+
# Inspecting what gets injected:
|
|
173
|
+
memex context # dry-run the hook output for the current dir
|
|
174
|
+
memex context --pwd /path # for a different project
|
|
175
|
+
memex context --no-source telegram # exclude a source
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
The hook respects existing hooks (e.g. `gstack`, custom user hooks) — they're preserved untouched.
|
|
179
|
+
|
|
180
|
+
**Currently only Claude Code has native SessionStart hooks.** For Cursor, an MCP-tool-based fallback is available (v0.9+).
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Save URLs into memex (v0.6+)
|
|
185
|
+
|
|
186
|
+
Once memex is installed, any MCP-aware agent can also save **web pages, AI chat shares, and pasted text** into your memex memory — searchable from any other AI chat later. In Claude Code, Cursor, OpenClaw, …:
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
Save https://www.perplexity.ai/share/<id> to memex
|
|
190
|
+
Add this article to my memex: https://example.com/long-post
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
The agent fetches the page via its own WebFetch (auto-falling back to `r.jina.ai` for Cloudflare-protected sites — memex teaches the trick) and calls `memex_store_document`. Memex stores the content verbatim as a `web` source conversation, indistinguishable from AI chats at search time.
|
|
194
|
+
|
|
195
|
+
Perplexity threads need to be made **Public** in the Share dialog first — memex detects private threads and tells the user how to fix it. Full guide: [HELP.md §8](HELP.md).
|
|
196
|
+
|
|
197
|
+
**ParallelClaw stays 100% local** — the agent fetches, it only stores. Zero outbound calls from ParallelClaw itself.
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Telegram chats (v0.10+) — agent walks you through it
|
|
202
|
+
|
|
203
|
+
Telegram-export setup used to be 8 steps. v0.10+ collapses it to 2 (you click in Telegram; you pick which chats to keep). The rest is automatic.
|
|
204
|
+
|
|
205
|
+
**How it works:**
|
|
206
|
+
1. The daemon watches `~/Downloads/Telegram Desktop/` in the background. **No setup needed** — already on after install.
|
|
207
|
+
2. You export a chat from Telegram Desktop (chat → ⋮ → Export chat history → HTML or JSON).
|
|
208
|
+
3. memex detects the export, **moves it to `~/.memex/pending/`** (NOT into your DB yet).
|
|
209
|
+
4. Your AI agent (or you in terminal) calls `memex_telegram_pending` — sees a numbered list with chat name, msg count, date range.
|
|
210
|
+
5. You pick which to import. Sensitive ones (Bank, Therapist, Tinder) — skip. memex remembers and won't ask again.
|
|
211
|
+
6. Future re-exports of allowed chats auto-merge. Skipped ones stay out.
|
|
212
|
+
|
|
213
|
+
**The agent leads.** Just say *"set up Telegram for memex"* (or **install memex** in a fresh session — the install-memex skill v1.2+ proactively offers it). The agent will:
|
|
214
|
+
- Check if Telegram Desktop is installed (give you the right download link if not)
|
|
215
|
+
- Check the 24h post-login export-block window (tell you when you can export)
|
|
216
|
+
- Show the click-path in Telegram
|
|
217
|
+
- Wait for your export, then present the picker
|
|
218
|
+
|
|
219
|
+
**Three modes:** `pick` (default — review each export), `auto` (allowed chats auto-import; new ones go to pending), `manual` (watcher off — drop files yourself).
|
|
220
|
+
|
|
221
|
+
Terminal equivalents: `memex telegram check / pending / import 1 3 5 / skip 2 / mode auto`. Full reference: `memex telegram --help`.
|
|
222
|
+
|
|
223
|
+
**v0.10.1: 4-channel proactive notification.** You'll find out about pending exports from whichever channel reaches you first:
|
|
224
|
+
|
|
225
|
+
1. **In the AI agent (active session)** — `memex_search` / `memex_recent` / `memex_overview` tool responses include a `telegram_pending` field with chat names. Agent surfaces it as a natural aside.
|
|
226
|
+
2. **In the terminal** — any `memex` CLI command appends a 💡 tip line when pending > 0. Throttled to once per 6h.
|
|
227
|
+
3. **macOS native notification** (opt-in) — daemon fires a banner when a new export is staged. `memex telegram notifications on` to enable. Default OFF for lock-screen privacy; add `--show-titles` if you want chat names in the banner. **v0.10.4+ clickable:** if `terminal-notifier` is installed (`brew install terminal-notifier`), clicking the banner opens — in priority order — Claude Code CLI in a fresh Terminal (Brian Chesky moment via SessionStart hook), Claude Desktop, or Terminal with `memex telegram pending` queued. Override priority via `memex telegram notifications target <auto|claude-cli|claude-desktop|terminal|none>`.
|
|
228
|
+
4. **Brian Chesky hook (next Claude Code session)** — `memex context` injection includes a "🆕 N exports awaiting review" block with chat names. Claude leads with the question before you type anything.
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## Web dashboard (v0.10.8+) — see your own memory
|
|
233
|
+
|
|
234
|
+
Opt-in, read-only local UI for browsing the corpus without any AI in the loop. Same SQLite, different surface.
|
|
235
|
+
|
|
236
|
+
```sh
|
|
237
|
+
memex web --open # localhost:8765, opens in browser
|
|
238
|
+
memex web --port 9000 # custom port
|
|
239
|
+
memex web --public --token s3cret # bind on 0.0.0.0 with bearer auth (for remote / tunnel)
|
|
240
|
+
memex web --help
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
Five pages:
|
|
244
|
+
|
|
245
|
+
| Page | What it shows |
|
|
246
|
+
|-------------------|------------------------------------------------------------------------------------------|
|
|
247
|
+
| `/` | Stats grid · sources breakdown · pending Telegram callout · recent 10 conversations |
|
|
248
|
+
| `/conversations` | Live FTS5 search via htmx (200ms debounce) · source-chip filters · hit counts per chat |
|
|
249
|
+
| `/c/:id` | **Verbatim** transcript in chat-bubbles · in-chat search with `<mark>` highlight · paged |
|
|
250
|
+
| `/pending` | Telegram exports awaiting decision · bulk Import / Skip checkboxes · decision history |
|
|
251
|
+
| `/settings` | Daemon status · DB path & size · hooks installed · TG decisions counts (read-only) |
|
|
252
|
+
|
|
253
|
+
**Design constraints:**
|
|
254
|
+
- **Opt-in, not always-on.** `memex web` starts the server; Ctrl+C stops it. No daemon.
|
|
255
|
+
- **Read-only by default.** The only writes are TG import / skip on the `/pending` page — same privacy gate as `memex telegram import`.
|
|
256
|
+
- **Localhost-only by default.** Binds `127.0.0.1`. Use `--public --token <…>` for remote access (cron-friendly: same endpoint reserved for the future multi-host sync API).
|
|
257
|
+
- **No build step.** Node raw `http` + tagged template literals + htmx 14KB CDN. Total client bundle: ~30KB.
|
|
258
|
+
- **Brand-aligned.** Same Inter + mint palette as [memex.parallelclaw.ai](https://memex.parallelclaw.ai).
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## What it captures
|
|
263
|
+
|
|
264
|
+
| Source | How it gets in |
|
|
265
|
+
|-----------------------|----------------------------------------------------------------|
|
|
266
|
+
| Claude Code sessions | Auto: `memex-sync` watches `~/.claude/projects/` |
|
|
267
|
+
| Claude Cowork | Auto: same watcher, including all subagent transcripts |
|
|
268
|
+
| Cursor IDE chats | Auto: reads Cursor's local SQLite session store |
|
|
269
|
+
| OpenClaw sessions | Auto: watches `~/.openclaw/agents/main/sessions/` |
|
|
270
|
+
| Obsidian notes | Auto: per-vault markdown watcher |
|
|
271
|
+
| Telegram exports | **v0.10+: auto.** Daemon watches `~/Downloads/Telegram Desktop/`. Each new ChatExport appears in `memex telegram pending` — review chat-by-chat, import the ones you want. Privacy-first: nothing lands in the DB without your `memex telegram import <indices>`. Allow-list remembers your decisions so future re-exports auto-merge. JSON + HTML both supported. (Legacy path still works: drop into `~/.memex/inbox/`.) |
|
|
272
|
+
| Telegram (live) | Run [`memex-bot`](bot/README.md) — captures messages you send/forward to your private bot |
|
|
273
|
+
| **Web pages, AI chat shares, pasted text** | From any MCP agent: *"save https://... to memex"*. Agent fetches; memex stores verbatim. Cloudflare-protected pages (Perplexity, npm.com, Twitter, Medium, …) handled via the agent's r.jina.ai fallback. See [HELP.md §8](HELP.md) |
|
|
274
|
+
|
|
275
|
+
All sources land in the same FTS5 corpus, searchable by one `memex_search` call.
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
## MCP tools
|
|
280
|
+
|
|
281
|
+
| Tool | What it does |
|
|
282
|
+
|-------------------------------|---------------------------------------------------------------------------|
|
|
283
|
+
| `memex_overview` | Corpus snapshot — sources, counts, recent chats, daemon health |
|
|
284
|
+
| `memex_search` | Full-text search with BM25 × recency boost. Filter by date range (`since_ts`/`until_ts`), one session (`conversation_id`), capture node (`origin`, v0.14), `source`/`project`/`chat` |
|
|
285
|
+
| `memex_recent` | Most recent messages across all sources |
|
|
286
|
+
| `memex_get_conversation` | Transcript by `conversation_id` — page long sessions with `offset`/`order` (`desc` = freshest first); reports `total` |
|
|
287
|
+
| `memex_list_conversations` | Conversations sorted by activity, filterable by source |
|
|
288
|
+
| `memex_list_projects` | Distinct project paths captured (for the `project` filter) |
|
|
289
|
+
| `memex_archive_conversation` | Hide a chat from default listings (data preserved) |
|
|
290
|
+
| `memex_export_markdown` | Export one conversation as Markdown (for Obsidian round-trip) |
|
|
291
|
+
| `memex_store_document` | Save a web page, AI chat share, or pasted text. Agent fetches; memex stores verbatim. Teaches the Jina r.jina.ai trick for Cloudflare-blocked pages |
|
|
292
|
+
| `memex_list_sources` | Per-source enabled/disabled + counts |
|
|
293
|
+
| `memex_status` | Daemon health: PID, last capture, watched files |
|
|
294
|
+
| `memex_sources_status` | Which sources are captured + the exact CLI to opt out |
|
|
295
|
+
| `memex_help` | Returns the full user guide with concrete use cases |
|
|
296
|
+
| `memex_telegram_check` | v0.10+: Detect Telegram Desktop, login age (24h block), pending count, suggested next step |
|
|
297
|
+
| `memex_telegram_pending` | v0.10+: List exports staged for review with chat name + msg count + dates |
|
|
298
|
+
| `memex_telegram_import` | v0.10+: Import selected exports into memex.db (by index or title) — auto-allowlists |
|
|
299
|
+
| `memex_telegram_skip` | v0.10+: Mark chats as "never index" — applies to future re-exports too |
|
|
300
|
+
| `memex_telegram_mode` | v0.10+: Get/set capture mode: pick (default) · auto · manual |
|
|
301
|
+
|
|
302
|
+
Detailed search parameters (filters, sort, format) live in [HELP.md](HELP.md).
|
|
303
|
+
|
|
304
|
+
---
|
|
305
|
+
|
|
306
|
+
## Why ParallelClaw (vs. cloud memory services)
|
|
307
|
+
|
|
308
|
+
| Concern | ParallelClaw | Cloud memory (Mem0 / Supermemory / …) |
|
|
309
|
+
|-------------------------------|------------------------------------|---------------------------------------|
|
|
310
|
+
| Where your data lives | Your machine, one SQLite file | Their servers |
|
|
311
|
+
| Cost per ingested turn | 0 (no LLM call on write) | $0.005+/1K tokens |
|
|
312
|
+
| Cross-AI corpus | ✅ same DB for all clients | ⚠️ depends on plugin coverage |
|
|
313
|
+
| Telegram ingestion | ✅ first-class | ❌ not supported |
|
|
314
|
+
| Verbatim storage | ✅ raw text preserved | ❌ usually fact-extracted |
|
|
315
|
+
| Survives if vendor blocks you | ✅ your DB stays on disk | ❌ data inaccessible |
|
|
316
|
+
| Offline / air-gapped | ✅ | ❌ |
|
|
317
|
+
| Trade-off | Lexical search (FTS5), not semantic | Semantic + reranker, but cloud-bound |
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
321
|
+
## Privacy
|
|
322
|
+
|
|
323
|
+
- **Zero network egress** during normal operation. The MCP server only listens on stdio.
|
|
324
|
+
- **No account, no telemetry.** First-time install ping (planned, opt-out) is the only network call ever — and it's anonymous (UUID + version + OS, no content).
|
|
325
|
+
- **The DB is one file** at `~/.memex/data/memex.db`. Back it up, encrypt it (FileVault is enough), `rm` it — your call.
|
|
326
|
+
- **Source opt-out per category**: `memex-sync sources <name> disable` keeps that source out of the corpus permanently.
|
|
327
|
+
|
|
328
|
+
See [PRIVACY section in the Russian README](README.ru.md#приватность-и-безопасность--privacy--security) for the full breakdown.
|
|
329
|
+
|
|
330
|
+
---
|
|
331
|
+
|
|
332
|
+
## Cross-device
|
|
333
|
+
|
|
334
|
+
**Built-in real sync (v0.13).** Laptop with Claude/Cursor + a server with an
|
|
335
|
+
agent (OpenClaw etc.)? Connect their memory in **two copy-paste steps** — no
|
|
336
|
+
public ports, no firewall changes, no manual SSH keys, no hand-written services.
|
|
337
|
+
|
|
338
|
+
**Step 1 — paste this prompt to the agent on your server:**
|
|
339
|
+
|
|
340
|
+
```
|
|
341
|
+
Set up memex sync as a hub and give me a join token for my laptop:
|
|
342
|
+
1. npm install -g parallelclaw@latest (skip if installed)
|
|
343
|
+
2. memex-sync sync-server install --bind 127.0.0.1
|
|
344
|
+
3. memex-sync sync-server invite --join
|
|
345
|
+
Send me the memex-join:... line.
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
**Step 2 — one command on your laptop:**
|
|
349
|
+
|
|
350
|
+
```sh
|
|
351
|
+
memex-sync sync-join memex-join:eyJ2...
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
What that one command does, in order — and verifies at each step:
|
|
355
|
+
|
|
356
|
+
```
|
|
357
|
+
✓ token valid (openclaw@203.0.113.7, expires in 28m)
|
|
358
|
+
✓ SSH access — OK (no key? it prints yours + what to do)
|
|
359
|
+
✓ self-healing tunnel up (survives sleep, network changes, reboot)
|
|
360
|
+
✓ hub sync-server alive (cert pinned)
|
|
361
|
+
✓ first sync: pulled N · pushed M
|
|
362
|
+
✓ auto-sync every 15m installed
|
|
363
|
+
✓ health watchdog installed (alerts if sync goes silent > 1h)
|
|
364
|
+
✓ end-to-end verified: a test note round-tripped in 3.4s
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
The server binds **loopback only** — nothing is ever exposed to the internet;
|
|
368
|
+
all traffic rides inside SSH on port 22 (the one port that's never blocked).
|
|
369
|
+
Conflict-free by design: verbatim memory is append-only
|
|
370
|
+
(`UNIQUE(source, conversation_id, msg_id)`), so there is nothing to merge.
|
|
371
|
+
Interrupted first syncs **resume** from the last good page. Re-joining the same
|
|
372
|
+
hub keeps sync cursors — no pointless full re-replication. After a successful
|
|
373
|
+
join, no `MEMEX_SYNC_EXPERIMENTAL` env var is needed for any sync command.
|
|
374
|
+
|
|
375
|
+
**Provenance (v0.14).** Every row is stamped with the node that captured it,
|
|
376
|
+
and the stamp travels with sync — so "what did I discuss with the VPS agent
|
|
377
|
+
vs. on my laptop?" stays answerable after the corpora merge:
|
|
378
|
+
`memex_search(query, origin: "vps1")`. Conversations where two agents
|
|
379
|
+
interleave (e.g. two OpenClaw instances bridging one Telegram account) get
|
|
380
|
+
per-line `[@node]` tags in `memex_get_conversation`. Name your node by setting
|
|
381
|
+
`origin` in `~/.memex/config.json` (defaults to the hostname, persisted) —
|
|
382
|
+
best done **before** data accumulates, since old rows keep their stamp.
|
|
383
|
+
|
|
384
|
+
**Advanced topologies** — multi-node mesh, reverse tunnels (laptop-as-hub),
|
|
385
|
+
transit hubs gluing nodes that can't see each other (proven live on a
|
|
386
|
+
San-Francisco Mac + Italy VPS + Asia VPS mesh) — are documented with the wire
|
|
387
|
+
protocol in **[SYNC.md](SYNC.md)**. Agents can emit pair tokens via the
|
|
388
|
+
`memex_sync_invite` MCP tool.
|
|
389
|
+
|
|
390
|
+
**Simple alternative (no sync engine).** The corpus is one SQLite file plus a small
|
|
391
|
+
inbox directory, so a one-time `scp` covers migrations. See
|
|
392
|
+
[MULTI_MACHINE.md](MULTI_MACHINE.md) for legacy file-sync recipes.
|
|
393
|
+
|
|
394
|
+
---
|
|
395
|
+
|
|
396
|
+
## Limitations (v0.5)
|
|
397
|
+
|
|
398
|
+
- **FTS5 only** — no semantic search yet. Russian/English cross-lingual queries don't bridge ("git rebase" vs "перебазирование коммитов" return different hits). Vector embeddings are on the roadmap.
|
|
399
|
+
- **macOS-first** — daemon installer registers a LaunchAgent. Linux works as a foreground process; Windows untested.
|
|
400
|
+
- **Single user** — the Telegram bot serves exactly one Telegram user_id (you).
|
|
401
|
+
- **No webhook for the bot** — long-polling only, captures buffer ~24h server-side when laptop is offline.
|
|
402
|
+
|
|
403
|
+
---
|
|
404
|
+
|
|
405
|
+
## Resources
|
|
406
|
+
|
|
407
|
+
- 🏠 Landing: [memex.parallelclaw.ai](https://memex.parallelclaw.ai) — the AI-driven install prompt
|
|
408
|
+
- 📖 [HELP.md](HELP.md) — concrete use cases + full tool reference + troubleshooting
|
|
409
|
+
- 🤖 [bot/README.md](bot/README.md) — Telegram capture bot setup
|
|
410
|
+
- 🇷🇺 [README.ru.md](README.ru.md) — full Russian README with deeper privacy / migration sections
|
|
411
|
+
- 🐛 [Issues](https://github.com/parallelclaw/memex-mvp/issues) on GitHub
|
|
412
|
+
|
|
413
|
+
---
|
|
414
|
+
|
|
415
|
+
## License
|
|
416
|
+
|
|
417
|
+
MIT — see [LICENSE](LICENSE).
|