better-tg-cli 0.19.0 → 0.21.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-tg-cli",
3
- "version": "0.19.0",
3
+ "version": "0.21.0",
4
4
  "description": "Unofficial agent-friendly Telegram client for the command line (MTProto, layer 229)",
5
5
  "type": "module",
6
6
  "main": "dist/telegram.mjs",
@@ -40,12 +40,13 @@
40
40
  "url": "https://github.com/TheVilfer/better-tg-cli/issues"
41
41
  },
42
42
  "devDependencies": {
43
- "@types/node": "^22.0.0",
43
+ "@types/node": "^26.6.2",
44
+ "@typescript/native": "npm:typescript@^7.0.2",
44
45
  "big-integer": "^1.6.52",
45
- "commander": "^14.0.0",
46
+ "commander": "^15.0.0",
46
47
  "teleproto": "^1.229.0",
47
48
  "tsx": "^4.23.15",
48
- "typescript": "^5.7.0",
49
+ "typescript": "npm:@typescript/typescript6@^6.0.2",
49
50
  "vitest": "^5.0.2"
50
51
  },
51
52
  "engines": {
package/reference.md CHANGED
@@ -102,11 +102,37 @@ Buttons that need 2FA take `--password`. `--no-wait` skips waiting for the bot's
102
102
  - `sync --resume` is incremental. Checkpoints are per chat ID in `DIR/.sync-meta.json`. A resumed
103
103
  run fetches everything after the checkpoint and ignores the default `--days` window.
104
104
 
105
+ ## MCP server (`telegram mcp`)
106
+
107
+ - **Tools:**
108
+ - `telegram_help {grep?}`;
109
+ - `telegram_read {args}`, marked `readOnlyHint`;
110
+ - `telegram_write {args, stdin?}`, marked `destructiveHint`.
111
+
112
+ `args` is the CLI argv with the command first, for example `["read","@x","-n","20"]`. `stdin`
113
+ fills a `-` text argument.
114
+ - **What runs where:**
115
+ - Read tool: only the read commands.
116
+ - Write tool: everything that changes the account or writes local files (`download`, `sync`,
117
+ `avatar`).
118
+ - Never over MCP: `auth`, `logout`, `transfer-owner`, `update`, and changing `write-access`.
119
+ Showing its status is allowed.
120
+ - **Safety:** the read tool runs with `TG_READ_ONLY=1`, which blocks every guarded write even if a
121
+ command were misclassified.
122
+ - **Execution:** each call is a separate CLI process with no stdin. Calls run one at a time, time
123
+ out after 120 s, and output is capped at 100 KB. `watch` needs `-t` or `-n`.
124
+ - **Protocol:** MCP 2025-11-25 with the `initialize` handshake. Newer clients fall back to it.
125
+
105
126
  ## Chat identifiers
106
127
 
107
128
  `me` / `self` / `saved` / `Saved Messages` / `Избранное` → your Saved Messages. A numeric ID must
108
129
  exactly match a dialog ID (the `id` from `chats`). `@username` resolves exactly. Anything else
109
- matches titles: exact first, then substring. For writes, prefer an ID or @username.
130
+ matches titles.
131
+
132
+ - **Reads:** an exact title first, then a substring.
133
+ - **Writes** (every command gated by write access) accept only an exact, unique title. A substring
134
+ or a title shared by several chats is refused with up to 5 candidates (`id type title @username`).
135
+ Retry with the ID.
110
136
 
111
137
  ## Troubleshooting
112
138
 
@@ -120,6 +146,10 @@ matches titles: exact first, then substring. For writes, prefer an ID or @userna
120
146
  as `(no text)`.
121
147
  - `Write access is disabled`: the account is read-only on purpose, or a `--for` window expired. Ask
122
148
  the user, then run `telegram write-access on --for 1h`; they confirm it in a dialog.
149
+ - `FLOOD_WAIT` (rate limit): waits of up to 60 s are retried automatically, and stderr says
150
+ `Telegram rate limit on <method>: waiting Ns`. Longer waits fail with the wait in the error
151
+ message. `TG_FLOOD_WAIT_MAX=<seconds>` changes the limit: `0` fails fast, a larger value suits
152
+ long `sync` runs. Don't retry in a loop, because Telegram extends the ban.
123
153
  - `CHANNELS_TOO_MUCH` on `join`: the account hit Telegram's channel limit, so leave some first.
124
154
  - `Could not find the input entity`: the ID is not in your dialogs. Use `@username` or open the
125
155
  chat first.