claude-code-telegrammer 0.2.0__tar.gz → 0.4.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 (63) hide show
  1. {claude_code_telegrammer-0.2.0 → claude_code_telegrammer-0.4.0}/.github/workflows/test.yml +13 -0
  2. claude_code_telegrammer-0.4.0/.gitignore +1 -0
  3. claude_code_telegrammer-0.4.0/.readthedocs.yaml +31 -0
  4. claude_code_telegrammer-0.4.0/PKG-INFO +368 -0
  5. claude_code_telegrammer-0.4.0/README.md +335 -0
  6. claude_code_telegrammer-0.4.0/docs/sphinx/_static/.gitkeep +0 -0
  7. claude_code_telegrammer-0.4.0/docs/sphinx/_templates/.gitkeep +0 -0
  8. claude_code_telegrammer-0.4.0/docs/sphinx/api/claude_code_telegrammer.rst +12 -0
  9. claude_code_telegrammer-0.4.0/docs/sphinx/conf.py +138 -0
  10. claude_code_telegrammer-0.4.0/docs/sphinx/index.rst +134 -0
  11. claude_code_telegrammer-0.4.0/docs/sphinx/installation.rst +123 -0
  12. claude_code_telegrammer-0.4.0/docs/sphinx/quickstart.rst +169 -0
  13. claude_code_telegrammer-0.4.0/docs/sphinx/requirements.txt +5 -0
  14. {claude_code_telegrammer-0.2.0 → claude_code_telegrammer-0.4.0}/lib/auto-response.sh +1 -1
  15. {claude_code_telegrammer-0.2.0 → claude_code_telegrammer-0.4.0}/lib/lock.sh +1 -1
  16. {claude_code_telegrammer-0.2.0 → claude_code_telegrammer-0.4.0}/lib/state-detection.sh +1 -1
  17. {claude_code_telegrammer-0.2.0 → claude_code_telegrammer-0.4.0}/pyproject.toml +10 -17
  18. {claude_code_telegrammer-0.2.0 → claude_code_telegrammer-0.4.0}/src/claude_code_telegrammer/__init__.py +3 -1
  19. claude_code_telegrammer-0.4.0/src/claude_code_telegrammer/_skills/claude-code-telegrammer/SKILL.md +49 -0
  20. claude_code_telegrammer-0.4.0/tests/test-state-detection.sh +641 -0
  21. claude_code_telegrammer-0.4.0/ts/.gitignore +1 -0
  22. claude_code_telegrammer-0.4.0/ts/bun.lock +195 -0
  23. claude_code_telegrammer-0.4.0/ts/bunfig.toml +2 -0
  24. claude_code_telegrammer-0.4.0/ts/dist/telegram-server.js +14485 -0
  25. claude_code_telegrammer-0.4.0/ts/lib/access.ts +125 -0
  26. claude_code_telegrammer-0.4.0/ts/lib/attachments.ts +104 -0
  27. claude_code_telegrammer-0.4.0/ts/lib/config.ts +42 -0
  28. claude_code_telegrammer-0.4.0/ts/lib/lock.ts +45 -0
  29. claude_code_telegrammer-0.4.0/ts/lib/log.ts +17 -0
  30. claude_code_telegrammer-0.4.0/ts/lib/poller.ts +292 -0
  31. claude_code_telegrammer-0.4.0/ts/lib/store.ts +352 -0
  32. claude_code_telegrammer-0.4.0/ts/lib/telegram-api.ts +139 -0
  33. claude_code_telegrammer-0.4.0/ts/lib/tools.ts +396 -0
  34. claude_code_telegrammer-0.4.0/ts/package.json +13 -0
  35. claude_code_telegrammer-0.4.0/ts/telegram-server.ts +127 -0
  36. claude_code_telegrammer-0.4.0/ts/test/access.test.ts +95 -0
  37. claude_code_telegrammer-0.4.0/ts/test/config.test.ts +85 -0
  38. claude_code_telegrammer-0.4.0/ts/test/lock.test.ts +67 -0
  39. claude_code_telegrammer-0.4.0/ts/test/preload.ts +17 -0
  40. claude_code_telegrammer-0.4.0/ts/test/store.test.ts +193 -0
  41. claude_code_telegrammer-0.4.0/ts/test/telegram-api.test.ts +99 -0
  42. claude_code_telegrammer-0.2.0/PKG-INFO +0 -223
  43. claude_code_telegrammer-0.2.0/README.md +0 -196
  44. claude_code_telegrammer-0.2.0/bin/telegrammer +0 -266
  45. claude_code_telegrammer-0.2.0/bin/telegrammer-guard +0 -89
  46. claude_code_telegrammer-0.2.0/bin/telegrammer-init +0 -104
  47. claude_code_telegrammer-0.2.0/bin/telegrammer-relay +0 -55
  48. claude_code_telegrammer-0.2.0/bin/telegrammer-watchdog +0 -118
  49. claude_code_telegrammer-0.2.0/config/telegram-master.yaml +0 -35
  50. claude_code_telegrammer-0.2.0/src/claude_code_telegrammer/cli.py +0 -34
  51. claude_code_telegrammer-0.2.0/tests/test-state-detection.sh +0 -222
  52. {claude_code_telegrammer-0.2.0 → claude_code_telegrammer-0.4.0}/.github/workflows/publish-pypi.yml +0 -0
  53. {claude_code_telegrammer-0.2.0 → claude_code_telegrammer-0.4.0}/LICENSE +0 -0
  54. {claude_code_telegrammer-0.2.0 → claude_code_telegrammer-0.4.0}/docs/scitex-icon-navy-inverted.png +0 -0
  55. {claude_code_telegrammer-0.2.0 → claude_code_telegrammer-0.4.0}/docs/scitex-logo-blue-cropped.png +0 -0
  56. {claude_code_telegrammer-0.2.0 → claude_code_telegrammer-0.4.0}/hooks/enforce_background_subagents.sh +0 -0
  57. {claude_code_telegrammer-0.2.0 → claude_code_telegrammer-0.4.0}/lib/common.sh +0 -0
  58. {claude_code_telegrammer-0.2.0 → claude_code_telegrammer-0.4.0}/lib/orochi-relay.sh +0 -0
  59. {claude_code_telegrammer-0.2.0 → claude_code_telegrammer-0.4.0}/src/claude_code_telegrammer.egg-info/PKG-INFO +0 -0
  60. {claude_code_telegrammer-0.2.0 → claude_code_telegrammer-0.4.0}/src/claude_code_telegrammer.egg-info/SOURCES.txt +0 -0
  61. {claude_code_telegrammer-0.2.0 → claude_code_telegrammer-0.4.0}/src/claude_code_telegrammer.egg-info/dependency_links.txt +0 -0
  62. {claude_code_telegrammer-0.2.0 → claude_code_telegrammer-0.4.0}/src/claude_code_telegrammer.egg-info/entry_points.txt +0 -0
  63. {claude_code_telegrammer-0.2.0 → claude_code_telegrammer-0.4.0}/src/claude_code_telegrammer.egg-info/top_level.txt +0 -0
@@ -22,5 +22,18 @@ jobs:
22
22
  run: |
23
23
  python -m pip install --upgrade pip
24
24
  pip install -e .
25
+ pip install pyyaml
25
26
  - name: Run shell tests
26
27
  run: bash tests/test-state-detection.sh
28
+
29
+ test-ts:
30
+ runs-on: ubuntu-latest
31
+ steps:
32
+ - uses: actions/checkout@v4
33
+ - uses: oven-sh/setup-bun@v2
34
+ - name: Install dependencies
35
+ run: bun install
36
+ working-directory: ts
37
+ - name: Run TypeScript tests
38
+ run: bun test
39
+ working-directory: ts
@@ -0,0 +1 @@
1
+ .mcp.json
@@ -0,0 +1,31 @@
1
+ # Read the Docs configuration file
2
+ # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3
+
4
+ version: 2
5
+
6
+ # Set the OS, Python version and other tools you might need
7
+ build:
8
+ os: ubuntu-22.04
9
+ tools:
10
+ python: "3.11"
11
+
12
+ # Build documentation in the "docs/sphinx" directory with Sphinx
13
+ sphinx:
14
+ configuration: docs/sphinx/conf.py
15
+ fail_on_warning: false
16
+
17
+ # Optionally build your docs in additional formats such as PDF and ePub
18
+ formats:
19
+ - pdf
20
+ - epub
21
+
22
+ # Python configuration
23
+ python:
24
+ install:
25
+ # Install package with all optional dependencies
26
+ - method: pip
27
+ path: .
28
+ extra_requirements:
29
+ - docs
30
+ # Install sphinx documentation requirements
31
+ - requirements: docs/sphinx/requirements.txt
@@ -0,0 +1,368 @@
1
+ Metadata-Version: 2.4
2
+ Name: claude-code-telegrammer
3
+ Version: 0.4.0
4
+ Summary: Custom Telegram MCP server + TUI auto-responder for running Claude Code as an autonomous Telegram agent
5
+ Project-URL: Homepage, https://github.com/ywatanabe1989/claude-code-telegrammer
6
+ Project-URL: Repository, https://github.com/ywatanabe1989/claude-code-telegrammer.git
7
+ Project-URL: Issues, https://github.com/ywatanabe1989/claude-code-telegrammer/issues
8
+ Author-email: Yusuke Watanabe <ywatanabe@scitex.ai>
9
+ License-Expression: AGPL-3.0
10
+ License-File: LICENSE
11
+ Keywords: auto-response,claude-code,telegram,watchdog
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: GNU Affero General Public License v3
16
+ Classifier: Operating System :: POSIX :: Linux
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Unix Shell
23
+ Classifier: Topic :: Communications :: Chat
24
+ Classifier: Topic :: Software Development :: Libraries
25
+ Requires-Python: >=3.10
26
+ Provides-Extra: docs
27
+ Requires-Dist: myst-parser>=2.0; extra == 'docs'
28
+ Requires-Dist: sphinx-autodoc-typehints>=1.25; extra == 'docs'
29
+ Requires-Dist: sphinx-copybutton>=0.5; extra == 'docs'
30
+ Requires-Dist: sphinx-rtd-theme>=2.0; extra == 'docs'
31
+ Requires-Dist: sphinx>=7.0; extra == 'docs'
32
+ Description-Content-Type: text/markdown
33
+
34
+ <!-- ---
35
+ !-- Timestamp: 2026-04-10 18:13:14
36
+ !-- Author: ywatanabe
37
+ !-- File: /home/ywatanabe/proj/claude-code-telegrammer/README.md
38
+ !-- --- -->
39
+
40
+ <!-- SciTeX Convention: Header (logo, tagline, badges) -->
41
+ # claude-code-telegrammer
42
+
43
+ <p align="center">
44
+ <a href="https://scitex.ai">
45
+ <img src="docs/scitex-logo-blue-cropped.png" alt="SciTeX" width="400">
46
+ </a>
47
+ </p>
48
+
49
+ <p align="center"><b>Custom Telegram MCP server + TUI auto-responder for running Claude Code as an autonomous Telegram agent</b></p>
50
+
51
+ <p align="center">
52
+ <a href="https://badge.fury.io/py/claude-code-telegrammer"><img src="https://badge.fury.io/py/claude-code-telegrammer.svg" alt="PyPI version"></a>
53
+ <a href="https://claude-code-telegrammer.readthedocs.io/"><img src="https://readthedocs.org/projects/claude-code-telegrammer/badge/?version=latest" alt="Documentation"></a>
54
+ <a href="https://github.com/ywatanabe1989/claude-code-telegrammer/actions/workflows/test.yml"><img src="https://github.com/ywatanabe1989/claude-code-telegrammer/actions/workflows/test.yml/badge.svg" alt="Tests"></a>
55
+ <a href="https://www.gnu.org/licenses/agpl-3.0"><img src="https://img.shields.io/badge/License-AGPL--3.0-blue.svg" alt="License: AGPL-3.0"></a>
56
+ </p>
57
+
58
+ <p align="center">
59
+ <a href="https://claude-code-telegrammer.readthedocs.io/">Documentation</a> ·
60
+ <code>pip install claude-code-telegrammer</code>
61
+ </p>
62
+
63
+ ---
64
+
65
+ ## Problem
66
+
67
+ The official `plugin:telegram@claude-plugins-official` has several unresolved issues that make it unusable for production autonomous agents:
68
+
69
+ - **[#851](https://github.com/anthropics/claude-code/issues/851)** -- `STATE_DIR` not respected; access.json path hardcoded
70
+ - **[#1075](https://github.com/anthropics/claude-code/issues/1075)** -- 409 Conflict errors when multiple instances poll the same bot
71
+ - **[#1146](https://github.com/anthropics/claude-code/issues/1146)** -- Zombie CPU consumption after session ends
72
+
73
+ Additionally, Claude Code sessions running unattended will stall at permission prompts or idle states with no way to recover.
74
+
75
+ ## Solution
76
+
77
+ Two subsystems that replace and extend the official plugin:
78
+
79
+ 1. **Custom Telegram MCP Server** (`ts/`) -- A self-contained MCP server that fixes all three official plugin issues: configurable state directory via `CLAUDE_CODE_TELEGRAMMER_TELEGRAM_STATE_DIR`, PID-based single-instance lock, and clean shutdown on stdin close/SIGTERM. Provides 10 MCP tools (vs 3 in the official plugin), SQLite message persistence, allowlist-based access control, and inbound reaction (`message_reaction`) delivery. Incoming messages are acknowledged with a 📩 reaction.
80
+
81
+ 2. **TUI Watchdog** (`lib/`) -- Polls a GNU Screen session, detects Claude Code's TUI state via pattern matching, and sends keystrokes to keep the agent running unattended (auto-accepts permission prompts, re-engages on idle). Throttled with burst limits to prevent runaway responses. Orchestration and lifecycle management is handled by [scitex-agent-container](https://github.com/ywatanabe1989/scitex-agent-container).
82
+
83
+ <details>
84
+ <summary><strong>MCP Tools (10)</strong></summary>
85
+
86
+ | Tool | Description |
87
+ |------|-------------|
88
+ | `reply` | Reply on Telegram. Supports threading (`reply_to`), auto-marks inbound as read. Inbound reply-to-message references are tracked and forwarded. |
89
+ | `react` | Add an emoji reaction to a message. Inbound reactions (`message_reaction`) are also delivered as channel notifications. |
90
+ | `edit_message` | Edit a previously sent bot message. |
91
+ | `get_history` | Retrieve message history for a chat from local SQLite. |
92
+ | `get_unread` | List unread inbound messages, optionally filtered by `chat_id`. |
93
+ | `mark_read` | Mark messages as read by `chat_id` or `message_ids`. |
94
+ | `download_attachment` | Download a Telegram file by `file_id`, returns local path. |
95
+ | `send_document` | Upload a local file to a Telegram chat. |
96
+ | `search_messages` | Text search across stored messages. |
97
+ | `get_context` | Recent conversation formatted as compact text for LLM context. |
98
+
99
+ </details>
100
+
101
+ ## Installation
102
+
103
+ ### Prerequisites
104
+
105
+ - Python >= 3.10 and GNU Screen (for watchdog/CLI)
106
+ - [Bun](https://bun.sh/) >= 1.0 (for the MCP server)
107
+
108
+ ### Install
109
+
110
+ ```bash
111
+ pip install claude-code-telegrammer
112
+ ```
113
+
114
+ Or from source:
115
+
116
+ ```bash
117
+ git clone https://github.com/ywatanabe1989/claude-code-telegrammer.git
118
+ cd claude-code-telegrammer
119
+ pip install -e .
120
+
121
+ # Install TypeScript dependencies for the MCP server
122
+ cd ts && bun install
123
+ ```
124
+
125
+ ## Quickstart
126
+
127
+ ### Get a Telegram Bot Token
128
+
129
+ 1. Open Telegram and message [@BotFather](https://t.me/BotFather)
130
+ 2. Send `/newbot`, then enter a name (e.g., `Claude Code Telegrammer`) and a username (e.g., `ClaudeCodeTelegrammerBot`)
131
+ 3. BotFather replies with your token: `123456789:AAH...`
132
+ 4. Verify your token works:
133
+ ```bash
134
+ curl -s "https://api.telegram.org/bot<YOUR_TOKEN>/getMe"
135
+ # Should return {"ok":true,"result":{"is_bot":true,...}}
136
+ ```
137
+ 5. Open your bot (e.g., [t.me/ClaudeCodeTelegrammerBot](https://t.me/ClaudeCodeTelegrammerBot)) and send any message to start a conversation
138
+
139
+ ### Register MCP Server with Claude Code
140
+
141
+ Copy the example and fill in your values (`.mcp.json` is gitignored):
142
+
143
+ ```json
144
+ {
145
+ "mcpServers": {
146
+ "claude-code-telegrammer": {
147
+ "type": "stdio",
148
+ "command": "bun",
149
+ "args": ["run", "/path/to/claude-code-telegrammer/ts/telegram-server.ts"],
150
+ "env": {
151
+ "CLAUDE_CODE_TELEGRAMMER_TELEGRAM_BOT_TOKEN": "123456789:AAH...",
152
+ "CLAUDE_CODE_TELEGRAMMER_TELEGRAM_ALLOWED_USERS": "YOUR_TELEGRAM_USER_ID",
153
+ "CLAUDE_CODE_TELEGRAMMER_TELEGRAM_STATE_DIR": "~/.claude-code-telegrammer"
154
+ }
155
+ }
156
+ }
157
+ }
158
+ ```
159
+
160
+ ```bash
161
+ cp .mcp.json.example .mcp.json
162
+ # Edit .mcp.json with your token, user ID, and paths
163
+ ```
164
+
165
+ Find your Telegram user ID by messaging [@userinfobot](https://t.me/userinfobot).
166
+
167
+ ### Run
168
+
169
+ ```bash
170
+ claude \
171
+ --dangerously-skip-permissions \
172
+ --dangerously-load-development-channels server:claude-code-telegrammer
173
+ ```
174
+
175
+ For full agent orchestration (screen sessions, watchdog, YAML configs), see [scitex-agent-container](https://github.com/ywatanabe1989/scitex-agent-container).
176
+
177
+ ## Interfaces
178
+
179
+ <details>
180
+ <summary><strong>MCP Server -- for AI Agents</strong></summary>
181
+
182
+ Start command:
183
+ ```bash
184
+ bun run ts/telegram-server.ts
185
+ ```
186
+
187
+ 10 tools exposed via MCP stdio protocol. See [MCP Tools](#solution) above. The server's MCP instructions include a responsiveness policy that directs the agent to acknowledge messages immediately and delegate heavy work to background subagents.
188
+
189
+ </details>
190
+
191
+ <details>
192
+ <summary><strong>Skills -- for AI Agent Discovery</strong></summary>
193
+
194
+ Skills are bundled at `src/claude_code_telegrammer/_skills/claude-code-telegrammer/SKILL.md`.
195
+
196
+ </details>
197
+
198
+ ## Architecture
199
+
200
+ ```
201
+ User (Telegram)
202
+ |
203
+ | Bot API (getUpdates long-polling)
204
+ v
205
+ ┌──────────────────────────────────────────────────────────────┐
206
+ │ Custom Telegram MCP Server (ts/telegram-server.ts) │
207
+ │ Bun + @modelcontextprotocol/sdk │
208
+ │ │
209
+ │ ┌─────────┐ ┌─────────┐ ┌──────────┐ ┌────────────┐ │
210
+ │ │ Poller │ │ Store │ │ Tools │ │ Attachments│ │
211
+ │ │ (long │ │ (SQLite │ │ (10 MCP │ │ (download │ │
212
+ │ │ poll) │ │ WAL) │ │ tools) │ │ queue) │ │
213
+ │ └─────────┘ └─────────┘ └──────────┘ └────────────┘ │
214
+ │ ┌─────────┐ ┌─────────┐ ┌──────────┐ │
215
+ │ │ Access │ │ Config │ │ Lock │ │
216
+ │ │ (allow- │ │ (env │ │ (PID │ │
217
+ │ │ list) │ │ vars) │ │ file) │ │
218
+ │ └─────────┘ └─────────┘ └──────────┘ │
219
+ └──────────────────────┬───────────────────────────────────────┘
220
+ │ MCP stdio
221
+ v
222
+ ┌──────────────────────────────────────────────────────────────┐
223
+ │ Claude Code (in GNU Screen session) │
224
+ │ --mcp-config points to the custom MCP server │
225
+ └──────────────────────┬───────────────────────────────────────┘
226
+ │ screen buffer
227
+ v
228
+ ┌──────────────────────────────────────────────────────────────┐
229
+ │ Watchdog (claude-code-telegrammer-watchdog) │
230
+ │ Polls screen buffer every 1.5s │
231
+ │ Detects: y/n prompt -> "1", y/y/n -> "2", idle -> cmd │
232
+ │ Throttled: burst limit, same-state delay, min interval │
233
+ └──────────────────────────────────────────────────────────────┘
234
+ ```
235
+
236
+ <details>
237
+ <summary><strong>State Detection</strong></summary>
238
+
239
+ | State | Pattern | Response |
240
+ |-------|---------|----------|
241
+ | `running` | `(esc to interrupt)`, `tokens ·`, `ing...` | No action |
242
+ | `y_n` | `1. Yes` + `3. No` (two-choice prompt) | Send `1` (accept) |
243
+ | `y_y_n` | `2. Yes, and...` / `2. Yes, allow...` / `2. Yes, don't ask...` | Send `2` (accept all) |
244
+ | `waiting` | Cooking puns (`Crafted for`, etc.), empty `>` prompt, idle hints | Send configurable command |
245
+
246
+ Response throttling: minimum interval between responses, burst limit (10 in 3s window), same-state delay.
247
+
248
+ </details>
249
+
250
+ <details>
251
+ <summary><strong>Configuration (Environment Variables)</strong></summary>
252
+
253
+ **MCP Server:**
254
+
255
+ | Variable | Required | Default | Description |
256
+ |----------|----------|---------|-------------|
257
+ | `CLAUDE_CODE_TELEGRAMMER_TELEGRAM_BOT_TOKEN` | Yes | -- | Telegram Bot API token |
258
+ | `CLAUDE_CODE_TELEGRAMMER_TELEGRAM_STATE_DIR` | No | `~/.claude-code-telegrammer` | Directory for SQLite DB, access.json, lock file |
259
+ | `CLAUDE_CODE_TELEGRAMMER_TELEGRAM_ALLOWED_USERS` | No | -- | Comma-separated Telegram user IDs for DM allowlist |
260
+ | `CLAUDE_CODE_TELEGRAMMER_TELEGRAM_HOST_NAME` | No | `os.hostname()` | Hostname stored with each message |
261
+ | `CLAUDE_CODE_TELEGRAMMER_TELEGRAM_PROJECT` | No | `process.cwd()` | Project path stored with each message |
262
+ | `CLAUDE_CODE_TELEGRAMMER_TELEGRAM_AGENT_ID` | No | `'telegram'` | Agent identifier stored with each message |
263
+
264
+ **Watchdog:**
265
+
266
+ | Variable | Default | Description |
267
+ |----------|---------|-------------|
268
+ | `CLAUDE_CODE_TELEGRAMMER_SESSION` | `claude-code-telegrammer` | GNU Screen session name |
269
+ | `CLAUDE_CODE_TELEGRAMMER_WATCHDOG_INTERVAL` | `1.5` | Poll interval in seconds |
270
+ | `CLAUDE_CODE_TELEGRAMMER_RESP_Y_N` | `1` | Response for y/n prompts |
271
+ | `CLAUDE_CODE_TELEGRAMMER_RESP_Y_Y_N` | `2` | Response for y/y/n prompts |
272
+ | `CLAUDE_CODE_TELEGRAMMER_RESP_WAITING` | `/speak-and-call` | Response when idle/waiting |
273
+
274
+ </details>
275
+
276
+ <details>
277
+ <summary><strong>SQLite Schema (v2)</strong></summary>
278
+
279
+ All messages persisted in `$CLAUDE_CODE_TELEGRAMMER_TELEGRAM_STATE_DIR/messages.db` using WAL mode.
280
+
281
+ **messages table:** direction, chat_id, message_id, user_id, username, text, timestamps (telegram_ts, received_at, read_at, replied_at), threading (reply_to_message_id, reply_to_row_id), identity (host, project, agent_id, bot_token_hash), raw_json.
282
+
283
+ **attachments table:** message_row_id (FK), kind, file_id, file_name, mime_type, file_size, local_path, downloaded_at.
284
+
285
+ **meta table:** key-value store for schema_version, update_offset.
286
+
287
+ </details>
288
+
289
+ <details>
290
+ <summary><strong>Integration with scitex-agent-container</strong></summary>
291
+
292
+ For YAML-based agent orchestration (screen sessions, watchdog lifecycle, restart policies), see [scitex-agent-container](https://github.com/ywatanabe1989/scitex-agent-container).
293
+
294
+ </details>
295
+
296
+ <details>
297
+ <summary><strong>Access Control</strong></summary>
298
+
299
+ Managed via `access.json` in `$CLAUDE_CODE_TELEGRAMMER_TELEGRAM_STATE_DIR`:
300
+
301
+ ```json
302
+ {
303
+ "dmPolicy": "allowlist",
304
+ "allowFrom": ["123456789"],
305
+ "groups": {
306
+ "-100123456": {
307
+ "requireMention": true,
308
+ "allowFrom": ["123456789"]
309
+ }
310
+ }
311
+ }
312
+ ```
313
+
314
+ Merged with `CLAUDE_CODE_TELEGRAMMER_TELEGRAM_ALLOWED_USERS` env var at runtime. Mtime-based caching means edits take effect without restart.
315
+
316
+ </details>
317
+
318
+ <!-- SciTeX Convention: Ecosystem -->
319
+ ## Part of SciTeX
320
+
321
+ claude-code-telegrammer is part of [**SciTeX**](https://scitex.ai). It provides the Telegram communication layer and TUI watchdog used by [scitex-agent-container](https://github.com/ywatanabe1989/scitex-agent-container) for autonomous agent operation.
322
+
323
+ ```
324
+ ┌─────────────────────────────────────────────────────────┐
325
+ │ scitex-orochi — agent definitions, dashboard │
326
+ └──────────────────────────┬──────────────────────────────┘
327
+ v
328
+ ┌─────────────────────────────────────────────────────────┐
329
+ │ scitex-agent-container — lifecycle, health, restart │
330
+ └──────────────────────────┬──────────────────────────────┘
331
+ v
332
+ ┌─────────────────────────────────────────────────────────┐
333
+ │ claude-code-telegrammer <-- YOU ARE HERE │
334
+ │ MCP server: Telegram API, message DB, 10 tools │
335
+ │ Watchdog: TUI auto-response, screen polling │
336
+ └─────────────────────────────────────────────────────────┘
337
+ ```
338
+
339
+ ## References
340
+
341
+ - [Claude Code Channels](https://docs.anthropic.com/en/docs/claude-code/channels) -- Official documentation for Claude Code's channel system
342
+ - [Official Telegram Plugin](https://github.com/anthropics/claude-code/tree/main/plugins/telegram) -- The `plugin:telegram@claude-plugins-official` source code
343
+ - [#851: STATE_DIR not respected](https://github.com/anthropics/claude-code/issues/851) -- Hardcoded access.json path
344
+ - [#1075: 409 Conflict errors](https://github.com/anthropics/claude-code/issues/1075) -- Multiple instances polling the same bot
345
+ - [#1146: Zombie CPU consumption](https://github.com/anthropics/claude-code/issues/1146) -- Runaway process after session ends
346
+ - [Telegram BotFather](https://t.me/BotFather) -- Create and manage Telegram bots
347
+ - [Telegram Bot API](https://core.telegram.org/bots/api) -- Official Bot API documentation
348
+ - [MCP Specification](https://modelcontextprotocol.io/) -- Model Context Protocol standard
349
+ - [claude-code-telegrammer Issues](https://github.com/ywatanabe1989/claude-code-telegrammer/issues) -- Bug reports and feature requests
350
+ - [claude-code-telegrammer Pull Requests](https://github.com/ywatanabe1989/claude-code-telegrammer/pulls) -- Contributions
351
+
352
+ <!-- SciTeX Convention: Footer (Four Freedoms + icon) -->
353
+ >Four Freedoms for Research
354
+ >
355
+ >0. The freedom to **run** your research anywhere -- your machine, your terms.
356
+ >1. The freedom to **study** how every step works -- from raw data to final manuscript.
357
+ >2. The freedom to **redistribute** your workflows, not just your papers.
358
+ >3. The freedom to **modify** any module and share improvements with the community.
359
+ >
360
+ >AGPL-3.0 -- because we believe research infrastructure deserves the same freedoms as the software it runs on.
361
+
362
+ ---
363
+
364
+ <p align="center">
365
+ <a href="https://scitex.ai" target="_blank"><img src="docs/scitex-icon-navy-inverted.png" alt="SciTeX" width="40"/></a>
366
+ </p>
367
+
368
+ <!-- EOF -->