fathom-server 0.1.0__tar.gz

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.
Files changed (53) hide show
  1. fathom_server-0.1.0/MANIFEST.in +2 -0
  2. fathom_server-0.1.0/PKG-INFO +351 -0
  3. fathom_server-0.1.0/README.md +323 -0
  4. fathom_server-0.1.0/fathom_server/__init__.py +8 -0
  5. fathom_server-0.1.0/fathom_server/app.py +254 -0
  6. fathom_server-0.1.0/fathom_server/auth.py +139 -0
  7. fathom_server-0.1.0/fathom_server/config.py +148 -0
  8. fathom_server-0.1.0/fathom_server/paths.py +30 -0
  9. fathom_server-0.1.0/fathom_server/routes/__init__.py +0 -0
  10. fathom_server-0.1.0/fathom_server/routes/activation.py +311 -0
  11. fathom_server-0.1.0/fathom_server/routes/room.py +573 -0
  12. fathom_server-0.1.0/fathom_server/routes/settings.py +514 -0
  13. fathom_server-0.1.0/fathom_server/routes/telegram.py +236 -0
  14. fathom_server-0.1.0/fathom_server/routes/terminal.py +157 -0
  15. fathom_server-0.1.0/fathom_server/routes/vault.py +744 -0
  16. fathom_server-0.1.0/fathom_server/service.py +126 -0
  17. fathom_server-0.1.0/fathom_server/services/__init__.py +0 -0
  18. fathom_server-0.1.0/fathom_server/services/access.py +209 -0
  19. fathom_server-0.1.0/fathom_server/services/crystal_scheduler.py +51 -0
  20. fathom_server-0.1.0/fathom_server/services/crystallization.py +225 -0
  21. fathom_server-0.1.0/fathom_server/services/indexer.py +90 -0
  22. fathom_server-0.1.0/fathom_server/services/links.py +106 -0
  23. fathom_server-0.1.0/fathom_server/services/memento.py +146 -0
  24. fathom_server-0.1.0/fathom_server/services/persistent_session.py +411 -0
  25. fathom_server-0.1.0/fathom_server/services/ping_scheduler.py +375 -0
  26. fathom_server-0.1.0/fathom_server/services/schema.py +33 -0
  27. fathom_server-0.1.0/fathom_server/services/settings.py +554 -0
  28. fathom_server-0.1.0/fathom_server/services/telegram_bridge.py +555 -0
  29. fathom_server-0.1.0/fathom_server/services/vault.py +187 -0
  30. fathom_server-0.1.0/fathom_server/static/.gitkeep +0 -0
  31. fathom_server-0.1.0/fathom_server/static/assets/index-CoS7M8QX.js +93 -0
  32. fathom_server-0.1.0/fathom_server/static/assets/index-DOcm59Zq.css +1 -0
  33. fathom_server-0.1.0/fathom_server/static/assets/index-LeWKhG39.js +93 -0
  34. fathom_server-0.1.0/fathom_server/static/index.html +22 -0
  35. fathom_server-0.1.0/fathom_server.egg-info/PKG-INFO +351 -0
  36. fathom_server-0.1.0/fathom_server.egg-info/SOURCES.txt +51 -0
  37. fathom_server-0.1.0/fathom_server.egg-info/dependency_links.txt +1 -0
  38. fathom_server-0.1.0/fathom_server.egg-info/entry_points.txt +2 -0
  39. fathom_server-0.1.0/fathom_server.egg-info/requires.txt +9 -0
  40. fathom_server-0.1.0/fathom_server.egg-info/top_level.txt +1 -0
  41. fathom_server-0.1.0/pyproject.toml +70 -0
  42. fathom_server-0.1.0/setup.cfg +4 -0
  43. fathom_server-0.1.0/tests/test_access.py +148 -0
  44. fathom_server-0.1.0/tests/test_activation_routes.py +313 -0
  45. fathom_server-0.1.0/tests/test_auth.py +213 -0
  46. fathom_server-0.1.0/tests/test_links.py +108 -0
  47. fathom_server-0.1.0/tests/test_room.py +936 -0
  48. fathom_server-0.1.0/tests/test_settings.py +194 -0
  49. fathom_server-0.1.0/tests/test_telegram_image.py +335 -0
  50. fathom_server-0.1.0/tests/test_vault_routes.py +631 -0
  51. fathom_server-0.1.0/tests/test_vault_search.py +284 -0
  52. fathom_server-0.1.0/tests/test_vault_service.py +167 -0
  53. fathom_server-0.1.0/tests/test_vault_storage.py +458 -0
@@ -0,0 +1,2 @@
1
+ recursive-include fathom_server/static *
2
+ recursive-exclude * *.sync-conflict*
@@ -0,0 +1,351 @@
1
+ Metadata-Version: 2.4
2
+ Name: fathom-server
3
+ Version: 0.1.0
4
+ Summary: Dashboard + REST API + background services for the Fathom vault layer
5
+ Author-email: Myra Krusemark <myra@myrakrusemark.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://hifathom.com
8
+ Project-URL: Repository, https://github.com/myrakrusemark/fathom-vault
9
+ Project-URL: Issues, https://github.com/myrakrusemark/fathom-vault/issues
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Framework :: Flask
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: Software Development :: Libraries
18
+ Requires-Python: >=3.11
19
+ Description-Content-Type: text/markdown
20
+ Requires-Dist: flask>=3.1.0
21
+ Requires-Dist: flask-sock>=0.7.0
22
+ Requires-Dist: pyyaml>=6.0
23
+ Requires-Dist: python-dotenv>=1.0.0
24
+ Requires-Dist: telethon>=1.36.0
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=8.0; extra == "dev"
27
+ Requires-Dist: ruff>=0.9.0; extra == "dev"
28
+
29
+ # Fathom Server
30
+
31
+ Dashboard, API, and background services for [Fathom](https://hifathom.com) — a multi-workspace vault system with search, activity tracking, rooms, and agent coordination.
32
+
33
+ Runs once, serves all workspaces. Per-workspace MCP tools are provided by [`fathom-mcp`](./fathom-mcp/).
34
+
35
+ ## Architecture
36
+
37
+ ```
38
+ ┌──────────────────────────────────────────────┐
39
+ │ fathom-server (Python) │
40
+ │ │
41
+ │ React Dashboard ─── REST API ─── Services │
42
+ │ (vault browser, (Flask, (indexer, │
43
+ │ terminal, :4243) pings, │
44
+ │ activation, crystal, │
45
+ │ rooms, telegram, │
46
+ │ telegram) access) │
47
+ │ │
48
+ │ Workspace Registry + API Key Auth │
49
+ └──────────────────┬───────────────────────────┘
50
+ │ HTTP localhost:4243
51
+ ┌────────────┼──────────────┐
52
+ ▼ ▼ ▼
53
+ ┌──────────┐ ┌──────────┐ ┌──────────┐
54
+ │ ws: main │ │ ws: ns │ │ ws: apps │
55
+ │ npx │ │ npx │ │ npx │
56
+ │ fathom- │ │ fathom- │ │ fathom- │
57
+ │ mcp │ │ mcp │ │ mcp │
58
+ └──────────┘ └──────────┘ └──────────┘
59
+ Claude inst. Claude inst. Claude inst.
60
+ ```
61
+
62
+ ## Requirements
63
+
64
+ - Python 3.11+
65
+ - Node.js 18+ (for frontend build and [qmd](https://github.com/nicoblu/qmd))
66
+ - [qmd](https://github.com/nicoblu/qmd) — `npm install -g @tobilu/qmd` (powers search)
67
+ - tmux (for agent sessions and inter-workspace messaging)
68
+
69
+ ## Install
70
+
71
+ ```bash
72
+ git clone https://github.com/myrakrusemark/fathom-vault.git
73
+ cd fathom-vault
74
+
75
+ # Install Python package + dependencies
76
+ pip install -e . # editable install — includes CLI entry point
77
+ pip install -e '.[dev]' # optional: adds pytest + ruff
78
+
79
+ # Build the frontend
80
+ cd frontend && npm install && npm run build && cd ..
81
+ cp -r frontend/dist/* fathom_server/static/
82
+ ```
83
+
84
+ ## Setup
85
+
86
+ Run the setup command to create the data directory and generate an API key:
87
+
88
+ ```bash
89
+ fathom-server setup # interactive — prompts for confirmation
90
+ fathom-server setup -y # non-interactive — just do it
91
+ ```
92
+
93
+ This creates the data directory (see [Data directory](#data-directory) below) and generates an API key. The key is printed once — copy it, you'll need it when running `npx fathom-mcp init` in your project directories.
94
+
95
+ ## Run
96
+
97
+ ```bash
98
+ fathom-server # start the server (default: 0.0.0.0:4243)
99
+ fathom-server --port 8080 # custom port
100
+ fathom-server --host 127.0.0.1 # bind to localhost only
101
+ ```
102
+
103
+ Opens at `http://localhost:4243`. On startup the server:
104
+
105
+ 1. Loads all registered workspaces
106
+ 2. Starts persistent Claude sessions for each workspace (if configured)
107
+ 3. Configures ping schedulers, background indexer, and crystal regeneration
108
+ 4. Starts the Telegram bridge (if enabled)
109
+
110
+ ## Install as a system service
111
+
112
+ Register fathom-server as a systemd user service that starts on boot:
113
+
114
+ ```bash
115
+ fathom-server install # install, enable, and start
116
+ fathom-server install --port 8080 # custom port
117
+ fathom-server install --data-dir /opt/fathom # custom data directory
118
+ fathom-server install --no-start # install and enable without starting
119
+ ```
120
+
121
+ This writes a unit file to `~/.config/systemd/user/fathom-server.service`, enables linger (so the service survives logout), and starts it.
122
+
123
+ Manage the service with standard systemd commands:
124
+
125
+ ```bash
126
+ systemctl --user status fathom-server.service
127
+ systemctl --user restart fathom-server.service
128
+ journalctl --user -u fathom-server.service -f
129
+ ```
130
+
131
+ To remove the service:
132
+
133
+ ```bash
134
+ fathom-server uninstall
135
+ ```
136
+
137
+ ## CLI reference
138
+
139
+ ```
140
+ fathom-server Run the server (default)
141
+ fathom-server serve Run the server (explicit)
142
+ --host HOST Bind address (default: 0.0.0.0)
143
+ --port PORT Port (default: 4243)
144
+
145
+ fathom-server setup First-time setup (data dirs + API key)
146
+ -y, --yes Skip confirmation prompt
147
+
148
+ fathom-server install Install as a systemd user service
149
+ --host HOST Bind address (default: 0.0.0.0)
150
+ --port PORT Port (default: 4243)
151
+ --data-dir DIR FATHOM_DATA_DIR override
152
+ --working-dir DIR WorkingDirectory for the service
153
+ --no-start Install and enable without starting
154
+
155
+ fathom-server uninstall Remove the systemd user service
156
+ ```
157
+
158
+ ## Quick start — new workspace
159
+
160
+ ```bash
161
+ # In your project directory:
162
+ npx fathom-mcp init
163
+ ```
164
+
165
+ The init wizard prompts for server URL and API key, creates `.fathom.json`, registers the workspace with the server, and sets up Claude Code hooks. See [`fathom-mcp` README](./fathom-mcp/README.md) for details.
166
+
167
+ You can also add workspaces via the dashboard at Settings > Workspaces.
168
+
169
+ ## Data directory
170
+
171
+ Runtime data (SQLite database, API key, vaults, Telegram assets) is stored outside the install directory:
172
+
173
+ | Priority | Location |
174
+ |----------|----------|
175
+ | 1. `FATHOM_DATA_DIR` env var | Wherever you point it |
176
+ | 2. `XDG_DATA_HOME`/fathom-server | Follows XDG spec |
177
+ | 3. `~/.local/share/fathom-server` | Default fallback |
178
+
179
+ For development, set `FATHOM_DATA_DIR=./data` in your `.env` file to keep data in the project directory.
180
+
181
+ ### Configuration
182
+
183
+ **Environment variables** (override defaults):
184
+
185
+ | Variable | Default | Description |
186
+ |----------|---------|-------------|
187
+ | `FATHOM_DATA_DIR` | `~/.local/share/fathom-server` | Runtime data directory |
188
+ | `FATHOM_PORT` | `4243` | Server port |
189
+ | `FATHOM_VAULT_DIR` | (none) | Default vault directory |
190
+
191
+ **Server config** — `<data-dir>/server.json` (auto-generated):
192
+
193
+ ```json
194
+ {
195
+ "api_key": "fv_...",
196
+ "auth_enabled": true
197
+ }
198
+ ```
199
+
200
+ **Per-workspace config** — `<project>/.fathom/settings.json` (auto-created with defaults):
201
+
202
+ ```json
203
+ {
204
+ "background_index": {
205
+ "enabled": true,
206
+ "interval_minutes": 15
207
+ },
208
+ "mcp": {
209
+ "query_timeout_seconds": 120,
210
+ "search_results": 10,
211
+ "search_mode": "hybrid"
212
+ },
213
+ "activity": {
214
+ "decay_halflife_days": 7,
215
+ "recency_window_hours": 48,
216
+ "show_heat_indicator": true
217
+ },
218
+ "crystal_regen": {
219
+ "enabled": false,
220
+ "interval_days": 7
221
+ },
222
+ "ping": {
223
+ "routines": []
224
+ }
225
+ }
226
+ ```
227
+
228
+ ## API Authentication
229
+
230
+ All `/api/*` routes require a Bearer token when auth is enabled:
231
+
232
+ ```bash
233
+ curl -H "Authorization: Bearer fv_abc123..." http://localhost:4243/api/workspaces
234
+ ```
235
+
236
+ The dashboard is exempt (served from the same origin). Manage the API key from the dashboard at Settings > API Key & Auth.
237
+
238
+ ## HTTP API
239
+
240
+ | Endpoint | Method | Description |
241
+ |----------|--------|-------------|
242
+ | `/api/workspaces` | GET | List all workspaces with status |
243
+ | `/api/workspaces` | POST | Register a workspace (name, path) |
244
+ | `/api/workspaces/<name>` | DELETE | Unregister a workspace |
245
+ | `/api/vault` | GET | Folder tree |
246
+ | `/api/vault/folder/<path>` | GET | List files with metadata and previews |
247
+ | `/api/vault/file/<path>` | GET/POST | Read/write files |
248
+ | `/api/vault/append/<path>` | POST | Append to files |
249
+ | `/api/search` | GET | Unified search (`?q=...&mode=bm25\|vector\|hybrid`) |
250
+ | `/api/vault/links/<path>` | GET | Forward/backlinks |
251
+ | `/api/vault/activity` | GET | Activity-scored file list |
252
+ | `/api/room` | GET | List all rooms |
253
+ | `/api/room/<name>` | GET/POST | Read/post room messages |
254
+ | `/api/room/<name>/describe` | POST | Set room description |
255
+ | `/api/telegram/contacts` | GET | List Telegram contacts |
256
+ | `/api/telegram/messages/<id>` | GET | Read messages (windowed) |
257
+ | `/api/telegram/send/<id>` | POST | Send a message |
258
+ | `/api/telegram/send-image/<id>` | POST | Send an image |
259
+ | `/api/telegram/image/<id>` | GET | Get message image (base64) |
260
+ | `/api/telegram/status` | GET | Bridge connection status |
261
+ | `/api/settings` | GET/POST | Settings management |
262
+ | `/api/auth/status` | GET | Auth status (masked key) |
263
+ | `/api/auth/key` | GET | Full API key |
264
+ | `/api/auth/key/regenerate` | POST | Generate new API key |
265
+ | `/api/auth/toggle` | POST | Enable/disable auth |
266
+
267
+ All endpoints accept `?workspace=` parameter. When omitted, they use the default workspace.
268
+
269
+ ## Search
270
+
271
+ Requires qmd with a collection matching the workspace name:
272
+
273
+ ```bash
274
+ qmd collection add /path/to/project/vault --name my-project
275
+ qmd index my-project
276
+ ```
277
+
278
+ The background indexer keeps it updated automatically.
279
+
280
+ Three search modes:
281
+ - **bm25** — keyword search, fast, exact-match oriented
282
+ - **vector** — semantic/vector search, finds conceptually similar content
283
+ - **hybrid** — BM25 + vector + reranking, most thorough (default)
284
+
285
+ ## Dashboard
286
+
287
+ The React SPA at `localhost:4243` provides:
288
+
289
+ - **Vault browser** — file tree with previews, heat indicators, frontmatter display
290
+ - **Editor** — markdown editing with frontmatter validation
291
+ - **Terminal** — WebSocket-connected tmux terminal for workspace sessions (Inbox mode for human workspaces)
292
+ - **Activation** — identity crystal viewer, ping scheduler controls
293
+ - **Rooms** — shared chatrooms for cross-workspace communication
294
+ - **Telegram** — contact list, message history, send/receive
295
+ - **Settings** — workspace management, API key management, per-workspace config
296
+
297
+ ## Project structure
298
+
299
+ ```
300
+ fathom-vault/
301
+ ├── fathom_server/ # Python package
302
+ │ ├── __init__.py # Version from importlib.metadata
303
+ │ ├── app.py # Flask entry — routes, startup, CLI
304
+ │ ├── auth.py # API key generation + Bearer token middleware
305
+ │ ├── config.py # Port, paths — configurable via env vars
306
+ │ ├── paths.py # XDG-compliant data directory resolution
307
+ │ ├── service.py # systemd user service management
308
+ │ ├── static/ # Built frontend (copied from frontend/dist/)
309
+ │ ├── routes/
310
+ │ │ ├── vault.py # Vault CRUD, search, links, activity
311
+ │ │ ├── room.py # Room chat endpoints
312
+ │ │ ├── settings.py # Settings, workspace CRUD, auth management
313
+ │ │ ├── activation.py # Identity crystal + activation
314
+ │ │ ├── telegram.py # Telegram contacts, messages, images
315
+ │ │ └── terminal.py # WebSocket terminal (tmux)
316
+ │ └── services/
317
+ │ ├── access.py # SQLite activity tracking + scoring
318
+ │ ├── settings.py # Settings persistence
319
+ │ ├── indexer.py # Background vault indexing (qmd)
320
+ │ ├── links.py # Wikilink parsing + backlinks
321
+ │ ├── crystallization.py # Identity crystal synthesis
322
+ │ ├── crystal_scheduler.py # Scheduled crystal regen
323
+ │ ├── persistent_session.py# Workspace session management
324
+ │ ├── ping_scheduler.py # Scheduled ping routines
325
+ │ ├── telegram_bridge.py # Telegram bridge (Telethon)
326
+ │ ├── memento.py # Memento SaaS API integration
327
+ │ └── vault.py # Core vault file operations
328
+ ├── frontend/ # React SPA (Vite, Tailwind, DaisyUI, xterm.js)
329
+ ├── fathom-mcp/ # MCP tools npm package (see fathom-mcp/README.md)
330
+ ├── tests/ # pytest suite
331
+ ├── pyproject.toml # pip packaging + ruff/pytest config
332
+ └── .env # FATHOM_DATA_DIR for development
333
+ ```
334
+
335
+ ## Test
336
+
337
+ ```bash
338
+ pip install -e '.[dev]'
339
+ pytest
340
+ ```
341
+
342
+ Pre-commit hooks run ruff (lint + format) and pytest:
343
+
344
+ ```bash
345
+ pre-commit install
346
+ pre-commit run --all-files
347
+ ```
348
+
349
+ ## License
350
+
351
+ MIT
@@ -0,0 +1,323 @@
1
+ # Fathom Server
2
+
3
+ Dashboard, API, and background services for [Fathom](https://hifathom.com) — a multi-workspace vault system with search, activity tracking, rooms, and agent coordination.
4
+
5
+ Runs once, serves all workspaces. Per-workspace MCP tools are provided by [`fathom-mcp`](./fathom-mcp/).
6
+
7
+ ## Architecture
8
+
9
+ ```
10
+ ┌──────────────────────────────────────────────┐
11
+ │ fathom-server (Python) │
12
+ │ │
13
+ │ React Dashboard ─── REST API ─── Services │
14
+ │ (vault browser, (Flask, (indexer, │
15
+ │ terminal, :4243) pings, │
16
+ │ activation, crystal, │
17
+ │ rooms, telegram, │
18
+ │ telegram) access) │
19
+ │ │
20
+ │ Workspace Registry + API Key Auth │
21
+ └──────────────────┬───────────────────────────┘
22
+ │ HTTP localhost:4243
23
+ ┌────────────┼──────────────┐
24
+ ▼ ▼ ▼
25
+ ┌──────────┐ ┌──────────┐ ┌──────────┐
26
+ │ ws: main │ │ ws: ns │ │ ws: apps │
27
+ │ npx │ │ npx │ │ npx │
28
+ │ fathom- │ │ fathom- │ │ fathom- │
29
+ │ mcp │ │ mcp │ │ mcp │
30
+ └──────────┘ └──────────┘ └──────────┘
31
+ Claude inst. Claude inst. Claude inst.
32
+ ```
33
+
34
+ ## Requirements
35
+
36
+ - Python 3.11+
37
+ - Node.js 18+ (for frontend build and [qmd](https://github.com/nicoblu/qmd))
38
+ - [qmd](https://github.com/nicoblu/qmd) — `npm install -g @tobilu/qmd` (powers search)
39
+ - tmux (for agent sessions and inter-workspace messaging)
40
+
41
+ ## Install
42
+
43
+ ```bash
44
+ git clone https://github.com/myrakrusemark/fathom-vault.git
45
+ cd fathom-vault
46
+
47
+ # Install Python package + dependencies
48
+ pip install -e . # editable install — includes CLI entry point
49
+ pip install -e '.[dev]' # optional: adds pytest + ruff
50
+
51
+ # Build the frontend
52
+ cd frontend && npm install && npm run build && cd ..
53
+ cp -r frontend/dist/* fathom_server/static/
54
+ ```
55
+
56
+ ## Setup
57
+
58
+ Run the setup command to create the data directory and generate an API key:
59
+
60
+ ```bash
61
+ fathom-server setup # interactive — prompts for confirmation
62
+ fathom-server setup -y # non-interactive — just do it
63
+ ```
64
+
65
+ This creates the data directory (see [Data directory](#data-directory) below) and generates an API key. The key is printed once — copy it, you'll need it when running `npx fathom-mcp init` in your project directories.
66
+
67
+ ## Run
68
+
69
+ ```bash
70
+ fathom-server # start the server (default: 0.0.0.0:4243)
71
+ fathom-server --port 8080 # custom port
72
+ fathom-server --host 127.0.0.1 # bind to localhost only
73
+ ```
74
+
75
+ Opens at `http://localhost:4243`. On startup the server:
76
+
77
+ 1. Loads all registered workspaces
78
+ 2. Starts persistent Claude sessions for each workspace (if configured)
79
+ 3. Configures ping schedulers, background indexer, and crystal regeneration
80
+ 4. Starts the Telegram bridge (if enabled)
81
+
82
+ ## Install as a system service
83
+
84
+ Register fathom-server as a systemd user service that starts on boot:
85
+
86
+ ```bash
87
+ fathom-server install # install, enable, and start
88
+ fathom-server install --port 8080 # custom port
89
+ fathom-server install --data-dir /opt/fathom # custom data directory
90
+ fathom-server install --no-start # install and enable without starting
91
+ ```
92
+
93
+ This writes a unit file to `~/.config/systemd/user/fathom-server.service`, enables linger (so the service survives logout), and starts it.
94
+
95
+ Manage the service with standard systemd commands:
96
+
97
+ ```bash
98
+ systemctl --user status fathom-server.service
99
+ systemctl --user restart fathom-server.service
100
+ journalctl --user -u fathom-server.service -f
101
+ ```
102
+
103
+ To remove the service:
104
+
105
+ ```bash
106
+ fathom-server uninstall
107
+ ```
108
+
109
+ ## CLI reference
110
+
111
+ ```
112
+ fathom-server Run the server (default)
113
+ fathom-server serve Run the server (explicit)
114
+ --host HOST Bind address (default: 0.0.0.0)
115
+ --port PORT Port (default: 4243)
116
+
117
+ fathom-server setup First-time setup (data dirs + API key)
118
+ -y, --yes Skip confirmation prompt
119
+
120
+ fathom-server install Install as a systemd user service
121
+ --host HOST Bind address (default: 0.0.0.0)
122
+ --port PORT Port (default: 4243)
123
+ --data-dir DIR FATHOM_DATA_DIR override
124
+ --working-dir DIR WorkingDirectory for the service
125
+ --no-start Install and enable without starting
126
+
127
+ fathom-server uninstall Remove the systemd user service
128
+ ```
129
+
130
+ ## Quick start — new workspace
131
+
132
+ ```bash
133
+ # In your project directory:
134
+ npx fathom-mcp init
135
+ ```
136
+
137
+ The init wizard prompts for server URL and API key, creates `.fathom.json`, registers the workspace with the server, and sets up Claude Code hooks. See [`fathom-mcp` README](./fathom-mcp/README.md) for details.
138
+
139
+ You can also add workspaces via the dashboard at Settings > Workspaces.
140
+
141
+ ## Data directory
142
+
143
+ Runtime data (SQLite database, API key, vaults, Telegram assets) is stored outside the install directory:
144
+
145
+ | Priority | Location |
146
+ |----------|----------|
147
+ | 1. `FATHOM_DATA_DIR` env var | Wherever you point it |
148
+ | 2. `XDG_DATA_HOME`/fathom-server | Follows XDG spec |
149
+ | 3. `~/.local/share/fathom-server` | Default fallback |
150
+
151
+ For development, set `FATHOM_DATA_DIR=./data` in your `.env` file to keep data in the project directory.
152
+
153
+ ### Configuration
154
+
155
+ **Environment variables** (override defaults):
156
+
157
+ | Variable | Default | Description |
158
+ |----------|---------|-------------|
159
+ | `FATHOM_DATA_DIR` | `~/.local/share/fathom-server` | Runtime data directory |
160
+ | `FATHOM_PORT` | `4243` | Server port |
161
+ | `FATHOM_VAULT_DIR` | (none) | Default vault directory |
162
+
163
+ **Server config** — `<data-dir>/server.json` (auto-generated):
164
+
165
+ ```json
166
+ {
167
+ "api_key": "fv_...",
168
+ "auth_enabled": true
169
+ }
170
+ ```
171
+
172
+ **Per-workspace config** — `<project>/.fathom/settings.json` (auto-created with defaults):
173
+
174
+ ```json
175
+ {
176
+ "background_index": {
177
+ "enabled": true,
178
+ "interval_minutes": 15
179
+ },
180
+ "mcp": {
181
+ "query_timeout_seconds": 120,
182
+ "search_results": 10,
183
+ "search_mode": "hybrid"
184
+ },
185
+ "activity": {
186
+ "decay_halflife_days": 7,
187
+ "recency_window_hours": 48,
188
+ "show_heat_indicator": true
189
+ },
190
+ "crystal_regen": {
191
+ "enabled": false,
192
+ "interval_days": 7
193
+ },
194
+ "ping": {
195
+ "routines": []
196
+ }
197
+ }
198
+ ```
199
+
200
+ ## API Authentication
201
+
202
+ All `/api/*` routes require a Bearer token when auth is enabled:
203
+
204
+ ```bash
205
+ curl -H "Authorization: Bearer fv_abc123..." http://localhost:4243/api/workspaces
206
+ ```
207
+
208
+ The dashboard is exempt (served from the same origin). Manage the API key from the dashboard at Settings > API Key & Auth.
209
+
210
+ ## HTTP API
211
+
212
+ | Endpoint | Method | Description |
213
+ |----------|--------|-------------|
214
+ | `/api/workspaces` | GET | List all workspaces with status |
215
+ | `/api/workspaces` | POST | Register a workspace (name, path) |
216
+ | `/api/workspaces/<name>` | DELETE | Unregister a workspace |
217
+ | `/api/vault` | GET | Folder tree |
218
+ | `/api/vault/folder/<path>` | GET | List files with metadata and previews |
219
+ | `/api/vault/file/<path>` | GET/POST | Read/write files |
220
+ | `/api/vault/append/<path>` | POST | Append to files |
221
+ | `/api/search` | GET | Unified search (`?q=...&mode=bm25\|vector\|hybrid`) |
222
+ | `/api/vault/links/<path>` | GET | Forward/backlinks |
223
+ | `/api/vault/activity` | GET | Activity-scored file list |
224
+ | `/api/room` | GET | List all rooms |
225
+ | `/api/room/<name>` | GET/POST | Read/post room messages |
226
+ | `/api/room/<name>/describe` | POST | Set room description |
227
+ | `/api/telegram/contacts` | GET | List Telegram contacts |
228
+ | `/api/telegram/messages/<id>` | GET | Read messages (windowed) |
229
+ | `/api/telegram/send/<id>` | POST | Send a message |
230
+ | `/api/telegram/send-image/<id>` | POST | Send an image |
231
+ | `/api/telegram/image/<id>` | GET | Get message image (base64) |
232
+ | `/api/telegram/status` | GET | Bridge connection status |
233
+ | `/api/settings` | GET/POST | Settings management |
234
+ | `/api/auth/status` | GET | Auth status (masked key) |
235
+ | `/api/auth/key` | GET | Full API key |
236
+ | `/api/auth/key/regenerate` | POST | Generate new API key |
237
+ | `/api/auth/toggle` | POST | Enable/disable auth |
238
+
239
+ All endpoints accept `?workspace=` parameter. When omitted, they use the default workspace.
240
+
241
+ ## Search
242
+
243
+ Requires qmd with a collection matching the workspace name:
244
+
245
+ ```bash
246
+ qmd collection add /path/to/project/vault --name my-project
247
+ qmd index my-project
248
+ ```
249
+
250
+ The background indexer keeps it updated automatically.
251
+
252
+ Three search modes:
253
+ - **bm25** — keyword search, fast, exact-match oriented
254
+ - **vector** — semantic/vector search, finds conceptually similar content
255
+ - **hybrid** — BM25 + vector + reranking, most thorough (default)
256
+
257
+ ## Dashboard
258
+
259
+ The React SPA at `localhost:4243` provides:
260
+
261
+ - **Vault browser** — file tree with previews, heat indicators, frontmatter display
262
+ - **Editor** — markdown editing with frontmatter validation
263
+ - **Terminal** — WebSocket-connected tmux terminal for workspace sessions (Inbox mode for human workspaces)
264
+ - **Activation** — identity crystal viewer, ping scheduler controls
265
+ - **Rooms** — shared chatrooms for cross-workspace communication
266
+ - **Telegram** — contact list, message history, send/receive
267
+ - **Settings** — workspace management, API key management, per-workspace config
268
+
269
+ ## Project structure
270
+
271
+ ```
272
+ fathom-vault/
273
+ ├── fathom_server/ # Python package
274
+ │ ├── __init__.py # Version from importlib.metadata
275
+ │ ├── app.py # Flask entry — routes, startup, CLI
276
+ │ ├── auth.py # API key generation + Bearer token middleware
277
+ │ ├── config.py # Port, paths — configurable via env vars
278
+ │ ├── paths.py # XDG-compliant data directory resolution
279
+ │ ├── service.py # systemd user service management
280
+ │ ├── static/ # Built frontend (copied from frontend/dist/)
281
+ │ ├── routes/
282
+ │ │ ├── vault.py # Vault CRUD, search, links, activity
283
+ │ │ ├── room.py # Room chat endpoints
284
+ │ │ ├── settings.py # Settings, workspace CRUD, auth management
285
+ │ │ ├── activation.py # Identity crystal + activation
286
+ │ │ ├── telegram.py # Telegram contacts, messages, images
287
+ │ │ └── terminal.py # WebSocket terminal (tmux)
288
+ │ └── services/
289
+ │ ├── access.py # SQLite activity tracking + scoring
290
+ │ ├── settings.py # Settings persistence
291
+ │ ├── indexer.py # Background vault indexing (qmd)
292
+ │ ├── links.py # Wikilink parsing + backlinks
293
+ │ ├── crystallization.py # Identity crystal synthesis
294
+ │ ├── crystal_scheduler.py # Scheduled crystal regen
295
+ │ ├── persistent_session.py# Workspace session management
296
+ │ ├── ping_scheduler.py # Scheduled ping routines
297
+ │ ├── telegram_bridge.py # Telegram bridge (Telethon)
298
+ │ ├── memento.py # Memento SaaS API integration
299
+ │ └── vault.py # Core vault file operations
300
+ ├── frontend/ # React SPA (Vite, Tailwind, DaisyUI, xterm.js)
301
+ ├── fathom-mcp/ # MCP tools npm package (see fathom-mcp/README.md)
302
+ ├── tests/ # pytest suite
303
+ ├── pyproject.toml # pip packaging + ruff/pytest config
304
+ └── .env # FATHOM_DATA_DIR for development
305
+ ```
306
+
307
+ ## Test
308
+
309
+ ```bash
310
+ pip install -e '.[dev]'
311
+ pytest
312
+ ```
313
+
314
+ Pre-commit hooks run ruff (lint + format) and pytest:
315
+
316
+ ```bash
317
+ pre-commit install
318
+ pre-commit run --all-files
319
+ ```
320
+
321
+ ## License
322
+
323
+ MIT
@@ -0,0 +1,8 @@
1
+ """Fathom Server — dashboard + REST API + background services for the vault layer."""
2
+
3
+ try:
4
+ from importlib.metadata import version
5
+
6
+ __version__ = version("fathom-server")
7
+ except Exception:
8
+ __version__ = "0.0.0-dev"