grok-telegram-bot 2.4.0 → 2.6.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.
Files changed (81) hide show
  1. package/.env.example +38 -2
  2. package/CHANGELOG.md +190 -1
  3. package/README.md +60 -15
  4. package/docs/GROUP.md +260 -0
  5. package/docs/INSTALL.md +3 -0
  6. package/package.json +4 -4
  7. package/src/app/lifetime-flag.ts +20 -0
  8. package/src/app/settings-store.ts +47 -8
  9. package/src/app/types.ts +38 -1
  10. package/src/app/updater.ts +24 -3
  11. package/src/bot/auth.ts +100 -15
  12. package/src/bot/bot.ts +193 -17
  13. package/src/bot/chat-controller.ts +181 -18
  14. package/src/bot/commands.ts +69 -29
  15. package/src/bot/deps.ts +3 -0
  16. package/src/bot/group-memory.ts +339 -0
  17. package/src/bot/handlers/accounts.ts +7 -0
  18. package/src/bot/handlers/control.ts +85 -32
  19. package/src/bot/handlers/document.ts +31 -4
  20. package/src/bot/handlers/forum.ts +217 -0
  21. package/src/bot/handlers/menu.ts +86 -24
  22. package/src/bot/handlers/message.ts +247 -27
  23. package/src/bot/handlers/photo.ts +126 -16
  24. package/src/bot/handlers/running.ts +150 -24
  25. package/src/bot/handlers/session-card.ts +13 -5
  26. package/src/bot/handlers/sessions.ts +68 -18
  27. package/src/bot/handlers/voice.ts +52 -7
  28. package/src/bot/image-return.ts +11 -5
  29. package/src/bot/manager-context.ts +208 -0
  30. package/src/bot/manager-jobs.ts +142 -0
  31. package/src/bot/menu/ephemeral.ts +16 -3
  32. package/src/bot/menu/keyboard.ts +53 -14
  33. package/src/bot/menu/refresh.ts +3 -1
  34. package/src/bot/menu/status-panel.ts +12 -6
  35. package/src/bot/permission-service.ts +19 -0
  36. package/src/bot/prompt-anchor.ts +299 -0
  37. package/src/bot/prompt-content.ts +8 -0
  38. package/src/bot/registry.ts +94 -1
  39. package/src/bot/scope.ts +95 -0
  40. package/src/bot/session-runtime.ts +1280 -183
  41. package/src/bot/suggestions.ts +91 -31
  42. package/src/bot/telegram-actions.ts +1130 -0
  43. package/src/bot/telegram-bots.ts +496 -0
  44. package/src/bot/telegram-io.ts +97 -10
  45. package/src/cli.ts +2 -0
  46. package/src/config.ts +201 -2
  47. package/src/forum/bind-path.ts +146 -0
  48. package/src/forum/manager.ts +652 -0
  49. package/src/forum/project-icon.ts +142 -0
  50. package/src/forum/thread.ts +49 -0
  51. package/src/forum/topic-store.ts +114 -0
  52. package/src/forum/types.ts +29 -0
  53. package/src/grok/client.ts +130 -28
  54. package/src/index.ts +205 -75
  55. package/src/projects/manager.ts +16 -3
  56. package/src/render/chunk.ts +17 -10
  57. package/src/render/hashtags.ts +5 -1
  58. package/src/render/manager-directive.ts +137 -0
  59. package/src/render/session-comment.ts +74 -7
  60. package/src/render/telegram-bridge.ts +464 -0
  61. package/src/render/tool-call.ts +56 -37
  62. package/src/service/platform.ts +44 -7
  63. package/src/service/windows.ts +16 -4
  64. package/src/sessions/history.ts +68 -9
  65. package/src/sessions/process.ts +7 -0
  66. package/src/sessions/types.ts +2 -2
  67. package/src/stream/streamer.ts +62 -15
  68. package/scripts/analyze-jsonl.ts +0 -33
  69. package/scripts/delayed-restart.ps1 +0 -29
  70. package/scripts/probe-exit-response-shape.py +0 -77
  71. package/scripts/probe-plan-exit.py +0 -60
  72. package/scripts/probe-plan-exit2.py +0 -48
  73. package/scripts/probe-plan-fields.py +0 -41
  74. package/scripts/probe-plan-fields2.py +0 -58
  75. package/scripts/probe-plan-response-path.py +0 -48
  76. package/scripts/sample-claude-tooluse.ts +0 -21
  77. package/scripts/sample-kiro-events.ts +0 -31
  78. package/scripts/smoke-exit-plan.ts +0 -274
  79. package/scripts/smoke-exit-shapes.ts +0 -252
  80. package/scripts/smoke-import.mjs +0 -82
  81. package/scripts/smoke-import.ts +0 -73
package/.env.example CHANGED
@@ -6,8 +6,11 @@
6
6
  # REQUIRED — Telegram bot token from @BotFather (https://t.me/BotFather)
7
7
  TELEGRAM_BOT_TOKEN=
8
8
 
9
- # RECOMMENDED — comma-separated Telegram user IDs allowed to use the bot.
10
- # Get yours from @userinfobot. If empty, ANYONE can use the bot (unsafe).
9
+ # RECOMMENDED — comma-separated Telegram user IDs allowed to use the bot
10
+ # (private chats AND groups / forum topics). Get yours from @userinfobot.
11
+ # Example: ALLOWED_USERS=123456789,987654321
12
+ # If empty, ANYONE can use the bot (unsafe — especially with TOPIC_GROUP_ID).
13
+ # Unauthorized group members are ignored silently (no ⛔ spam in the group).
11
14
  ALLOWED_USERS=
12
15
 
13
16
  # ── Grok Build CLI ───────────────────────────────────────────────────────────
@@ -96,6 +99,36 @@ NOTIFY_OTHER_SESSIONS=true
96
99
  # 2) second
97
100
  # SUGGESTIONS_AUTO_APPROVE_PCT=95
98
101
 
102
+ # ── Forum topics (optional project workspace) ────────────────────────────────
103
+ # Telegram forum supergroup id (negative for supergroups). When set, the bot
104
+ # probes the group at startup / /forum_setup:
105
+ # • not admin (or no Manage Topics) → ignore group for topic features
106
+ # • Topics off → best-effort try to enable (Bot API has no official method;
107
+ # if it fails, enable Topics manually in group settings and re-run setup)
108
+ # • Topics on + admin → creates "AI Chat" + optional per-project topics
109
+ # (TOPIC_AUTO_CREATE), paced + 429-retried for large catalogs
110
+ # • pins favicon / MSIX logo when found; user topics auto-bind on exact
111
+ # catalog name match only (else absolute path / exact name)
112
+ # Messages in a topic run Grok sessions in that topic's project path.
113
+ # TOPIC_GROUP_ID=
114
+ # TOPIC_AUTO_CREATE=true
115
+ # TOPIC_AI_CHAT_NAME=AI Chat
116
+
117
+ # ── Sibling Telegram bots (agent "MCP-like" tools via JSON actions) ──────────
118
+ # Comma-separated usernames (with or without @) the agent may call with
119
+ # bot_command / list_bots after the first-prompt Telegram bridge directive.
120
+ # Example: ALLOWED_TELEGRAM_BOTS=helperbot,other_bot
121
+ # ALLOWED_TELEGRAM_BOTS=
122
+ # Optional command catalogs (shown by list_bots / first-prompt teaching).
123
+ # Compact: TELEGRAM_BOT_COMMANDS=helperbot:status,help,ping;otherbot:start|Start,info
124
+ # JSON: TELEGRAM_BOT_COMMANDS={"helperbot":["status","help"],"otherbot":[{"command":"start","description":"Start"}]}
125
+ # TELEGRAM_BOT_COMMANDS=
126
+ # Hard timeout waiting for a sibling bot after /cmd@bot (ms). Default 45000.
127
+ # TELEGRAM_BOT_REPLY_TIMEOUT_MS=45000
128
+ # Quiet settle after last message/edit from that bot (ms) — "typing done" for
129
+ # streaming bots that edit one message. Default 2000.
130
+ # TELEGRAM_BOT_SETTLE_MS=2000
131
+
99
132
  # ── Self-recheck (once per user prompt, gated) ───────────────────────────────
100
133
  # After a successful user turn (queue empty), the bot may run one quality pass.
101
134
  # Flow:
@@ -110,6 +143,9 @@ NOTIFY_OTHER_SESSIONS=true
110
143
  # Optional: when set AND the AI decides recheck is needed, use this template
111
144
  # instead of the AI-written recheck body ({{USER}} / {{DONE}} placeholders).
112
145
  # SELF_RECHECK_PROMPT=
146
+ # Max wait (ms) for quiet meta prompts (recheck decision + suggestions JSON).
147
+ # On timeout the session prompt is cancelled so ✅ Done is not blocked forever.
148
+ # QUIET_PROMPT_TIMEOUT_MS=90000
113
149
 
114
150
  # ── MCP servers (/mcp) ───────────────────────────────────────────────────────
115
151
  # /mcp lists MCP servers the bot can discover and health-checks them. Grok Build
package/CHANGELOG.md CHANGED
@@ -7,7 +7,194 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
  The latest section is published verbatim as the GitHub Release notes by
8
8
  `.github/workflows/release.yml` when a `vX.Y.Z` tag is pushed.
9
9
 
10
- ## [Unreleased]
10
+ ## [2.6.0] - 2026-08-30
11
+
12
+ General becomes a chat-like **manager** for the forum group: memory-first
13
+ routing, `send_prompt` into project topics with job report-back, and **visible
14
+ short replies** (the previous notify-only quiet path looked like the bot was
15
+ dead). Also bumps runtime deps (`tsx`, `grammy`).
16
+
17
+ ### Added
18
+
19
+ - **General manager mode.** The forum **General** topic (`thread id 1`) is an
20
+ OpenClaw-style orchestrator, not a coding workspace. It keeps user messages,
21
+ starts a **new parallel session** per message (reply-to continues the same
22
+ session), streams **prose only** (no tools / progress / Done spam), and
23
+ dispatches real work into project topics.
24
+ - **Manager directive + auto context.** First General prompt injects how to
25
+ behave (delegate, memory-first, no git-first). Every user turn also gets a
26
+ capped **MANAGER CONTEXT** block: topic catalog, recent General chat, ranked
27
+ memory hits, and in-process manager jobs.
28
+ - **Manager jobs + work reports.** `send_prompt` from General registers a job
29
+ (`list_jobs`). When the child topic turn finishes, General is woken with a
30
+ structured `MANAGER WORK REPORT` so the manager can tell you done / failed.
31
+ - **Bridge: `notify`, `list_topics`, `list_jobs`, `session_id`.**
32
+ - `notify` — optional extra ping (not required in General; prose is shown).
33
+ - `list_topics` / `list_jobs` — catalog and dispatch status for the agent.
34
+ - `send_prompt.session_id` — resume a **specific** Grok session (full UUID or
35
+ short prefix from memory). Topic may be omitted; path → forum topic is
36
+ inferred. Placeholder topics (`…`) are rejected / inferred from memory.
37
+ - **Group memory ranking.** `search_memory` scores **relevance + recency**
38
+ (newest session per project path wins) so “last modifications” does not
39
+ surface stale Done notes. Hits include `[Xm/h/d ago]` stamps.
40
+ - **Outbound General thread helper.** Telegram rejects `message_thread_id: 1`.
41
+ Sends/edits to General omit that field (`outboundThreadExtra`); inbound
42
+ routing still treats missing thread id as General.
43
+
44
+ ### Changed
45
+
46
+ - **General UX.** User messages are **kept** (not replaced by prompt anchors).
47
+ Replies thread to the user message. A `Starting…` / `Thinking…` bubble is
48
+ edited in place into the short answer. Independent General messages no longer
49
+ coalesce into one queued turn.
50
+ - **Prose is the user-facing channel.** The manager is told the user **sees**
51
+ free-form chat text. `notify` is optional. Bridge-result follow-ups (after
52
+ `search_memory` / `list_topics`) stream the real answer instead of staying
53
+ silent. If the model emits no prose, the Thinking bubble is replaced with a
54
+ short fallback — never deleted leaving an empty chat.
55
+ - **Streamer prose-only mode.** General streams agent text only (no thoughts,
56
+ tools, plan board, or progress bar), seeded on the Thinking placeholder.
57
+ - **Forum send path.** `sendMessage` / stream edits / auth deny / prompt
58
+ anchors / photos / docs use `outboundThreadExtra` so General posts succeed.
59
+ - **Dependencies.** `tsx` `^4.19.2` → `^4.23.13`; `grammy` and `@types/node`
60
+ updated to current 1.x / 22.x wanted versions.
61
+
62
+ ### Fixed
63
+
64
+ - **Bot not responding in General after manager-mode work.** Notify-only +
65
+ deleting `Thinking…` when `search_memory` chained made every answer vanish.
66
+ General now streams short prose, keeps the status bubble across bridge
67
+ follow-ups, and never drops the placeholder without a visible line.
68
+ - **`message_thread_id: 1` rejected by Telegram** (“message thread not found”)
69
+ on General sends — omit the field for General; keep it for real topics.
70
+ - **Manager context path trap.** Recent General history no longer treats every
71
+ session under the workspace root as General chat (title + exact cwd only).
72
+
73
+ ### Docs
74
+
75
+ - **[docs/GROUP.md](./docs/GROUP.md)** — General = manager, memory-first
76
+ dispatch, `session_id`, `list_jobs`, prose vs `notify`.
77
+ - **AGENTS.md** — General manager conventions for future changes.
78
+ - **README** — General manager + expanded bridge actions.
79
+
80
+ ## [2.5.0] - 2026-08-05
81
+
82
+ Forum project topics, cross-topic Telegram bridge, prompt anchors, and a more
83
+ reliable Done / stop path for multi-topic groups.
84
+
85
+ ### Added
86
+
87
+ - **Forum project topics (optional).** `TOPIC_GROUP_ID` manages a Telegram forum
88
+ supergroup: default **AI Chat** topic (workspace), optional auto-create one
89
+ topic per catalog project (`TOPIC_AUTO_CREATE`), favicon/MSIX logo discovery
90
+ pinned in the topic, and path-binding when users create new topics. Messages
91
+ in a topic run sessions in that project path.
92
+ - **Telegram bridge actions (agent JSON).** On the first prompt of a session the
93
+ bot injects how-to-work memory: the agent may emit a fenced `json` block with
94
+ `"telegram": [ actions ]` to create forum topics, search session/topic memory,
95
+ list allowlisted sibling bots, and call them via `/cmd@bot` (MCP-like). Results
96
+ are fed back as a quiet follow-up turn (not a Done). Configure bots with
97
+ `ALLOWED_TELEGRAM_BOTS`, optional `TELEGRAM_BOT_COMMANDS` catalogs, reply
98
+ timeout / settle (`TELEGRAM_BOT_REPLY_TIMEOUT_MS`, `TELEGRAM_BOT_SETTLE_MS`).
99
+ Sibling-bot waits only accept content from the triggered bot (prefer reply-to
100
+ our trigger), collect edits until idle, and timeouts continue the session.
101
+ Bridge plumbing stays out of the chat (no “continuing session” / queue spam);
102
+ only durable side-effects like topic creation are announced.
103
+ - **Cross-topic bridge actions.** From General / AI Chat (`GROK_WORKSPACE`), the
104
+ agent can orchestrate other forum topics via telegram JSON:
105
+ - `create_topic` with optional path
106
+ - **`set_path`** — bind/rebind a topic to an absolute path or exact catalog name
107
+ - **`send_prompt`** — inject a prompt into another topic’s session (`ran`/`queued`;
108
+ does not wait for that turn). Optional `new_session`.
109
+ Multiple actions run in order (cap **9**; up to **5** `send_prompt` per turn).
110
+ **New project paths:** agent `create_topic` / `set_path` with an absolute path
111
+ that does not exist yet **creates the folder** on disk, then binds the topic.
112
+ - **New session on the persistent bar + `/new`.** Private chat: bar is
113
+ ☰ Menu · 🆕 New session / 🧭 Running · ⏹ Stop (not the inline Menu message).
114
+ Slash command `/new` (Telegram command list) starts a fresh session. Forum
115
+ topics keep New on the topic inline menu because reply keyboards are unreliable.
116
+ - **Instant command feedback.** Slash commands and bar taps are deleted
117
+ immediately; handlers post bot status messages (e.g. `/new` →
118
+ “Creating new session…”) so the chat feels alive while the CLI/ACP starts.
119
+ - **Prompt anchors + `#prompt_<id>`.** User prompts (text, photos, docs, voice,
120
+ `/btw`, suggestion taps) are re-posted as bot messages with a searchable
121
+ `#prompt_` tag; the originals are best-effort deleted. Photos, documents, and
122
+ voice/audio are re-attached on the anchor via Telegram `file_id` so media is
123
+ not lost when the user message is removed. All AI stream bubbles, Done/error
124
+ notices, and queue acks for that turn reply to the anchor and carry the same
125
+ tag (alongside `#proj_` / `#sess_`).
126
+
127
+ ### Changed
128
+
129
+ - **Session card comments.** Cards (`/running`, `/sessions`, `/active`, status
130
+ panel) now show the **last user prompt** (max 250 chars). While a session is
131
+ running, a second line shows the **last AI agent thinking** (max 250). Idle
132
+ cards no longer use last-turn assistant outcome summaries as the comment.
133
+ - **Stronger self-recheck prompts.** Decision + default recheck briefs now push
134
+ production-related completeness for the same feature (e.g. water→waves,
135
+ auth→rate limits), **finish-all** (no “still need…” / incomplete honest
136
+ leftovers that force critical follow-up buttons), and a required **per-bug
137
+ recheck checklist** at the end of the pass. Compose always injects those
138
+ rules when an AI brief looks complete (headers only) but omitted them.
139
+ `/new`, bar **New**, and inline **New** share the same success copy.
140
+
141
+ ### Fixed
142
+
143
+ - **Missing `✅ Done` after a turn.** Done no longer waits on suggestion JSON
144
+ (send Done first, then attach buttons). Quiet meta prompts (recheck decision
145
+ + suggestions) use `QUIET_PROMPT_TIMEOUT_MS` (default 90s) and cancel the
146
+ session prompt on timeout so a hung meta call cannot block Done forever
147
+ (does not set user-cancelled / does not kill the agent). Chat shows
148
+ “Checking if a quality pass is needed…” while deciding recheck. Done text is
149
+ rebuilt after that wait so `/stop` mid-decision shows ⏹ Stopped. `notify`
150
+ retries truncated/plain text if the first send fails; a finally safety net
151
+ forces a short Done when one was expected but never delivered.
152
+ - **`/stop` / `/cancel` must not kill the bot or other sessions.** Stop is
153
+ session-scoped only: soft ACP `session/cancel`, cancel pending permissions
154
+ for that session, and force-complete that session’s in-flight prompt after a
155
+ short grace if the agent is slow — **never** kill the shared `grok agent`
156
+ process (which multiplexes every chat/topic). `killPid` also refuses to
157
+ target the bot’s own Node process.
158
+ - **`grok-tg install|start|restart` hang on Windows.** The service VBS is a
159
+ forever-restart loop (`Run …, True` waits for the bot). Launching it with
160
+ `execFileSync` made the CLI wait forever. Startup launches now use detached
161
+ `spawn` so the CLI returns immediately.
162
+ - **No silent process death.** Exit paths always log reason + code to stderr/file;
163
+ instance-lock conflict uses exit 1; polling classifies 429/409/401/network with
164
+ backoff; interactive runs recover in-process (no detach re-exec that blanks the
165
+ terminal); ref'd keepalive every 5m; `beforeExit` keeps the process up if the
166
+ event loop empties unexpectedly. Updater re-exec inherits TTY stdio.
167
+ - **Markdown / tool path rendering.** File paths in tool cards (Edit/Read/…) are
168
+ no longer wrapped in bold (Windows `C:\…` paths broke MarkdownV2 and fell
169
+ back to plain text that clients soft-render as `**Edit C:**`). Paths use
170
+ inline code; plain fallback demotes `**`/fences so soft-render cannot mangle
171
+ them. Chunked fences preserve tick length when reopening.
172
+ - **Group / topic stop controls.** Forum topic menu leads with **Stop** + Running;
173
+ `/cancel` and `/stop` work in topics; group slash-command menu is a short,
174
+ sorted list with cancel first (private keeps the full sorted catalog). Stop
175
+ confirms in-thread (not only a toast).
176
+ - **Forum topic bind: exact name only.** New user topics auto-bind when the
177
+ topic title exactly matches a catalog project (case-insensitive). Path prompts
178
+ and first messages no longer use fuzzy/partial project search (which could
179
+ bind the wrong folder). Unmatched topics still accept an absolute path or an
180
+ exact catalog name.
181
+ - **Forum bulk topic create.** Startup/`/forum_setup` walks the **full** project
182
+ catalog (not a 200-item cap), paces creates, and retries on Telegram 429
183
+ (`retry_after`) and transient network errors so large catalogs (1000+) can
184
+ finish reliably across restarts.
185
+ - **Forum group readiness.** Setup probes the configured group: if the bot is
186
+ not admin (or lacks Manage Topics), the group is **ignored** for topic
187
+ features. If Topics are off, the bot best-effort tries to enable them (no
188
+ official Bot API method today), otherwise ignores the group with a clear
189
+ status. Re-probes on promotion via `my_chat_member`; `/forum_setup` reports
190
+ ready vs disabled reason.
191
+
192
+ ### Docs
193
+
194
+ - **README** updated for forum topics, bridge, prompt anchors, suggestions,
195
+ self-recheck, and related config.
196
+ - **[docs/GROUP.md](./docs/GROUP.md)** — how to set up and use a forum project
197
+ group (binding, bridge actions, access control, troubleshooting).
11
198
 
12
199
  ## [2.4.0] - 2026-08-01
13
200
 
@@ -814,6 +1001,8 @@ from a single chat and switch between them, on a redesigned, compact menu.
814
1001
  diffs, MarkdownV2 rendering, scheduled tasks, multi-image prompts, and a
815
1002
  cross-platform 24/7 background service.
816
1003
 
1004
+ [2.6.0]: https://github.com/artickc/grok-telegram-bot/releases/tag/v2.6.0
1005
+ [2.5.0]: https://github.com/artickc/grok-telegram-bot/releases/tag/v2.5.0
817
1006
  [2.4.0]: https://github.com/artickc/grok-telegram-bot/releases/tag/v2.4.0
818
1007
  [2.3.1]: https://github.com/artickc/grok-telegram-bot/releases/tag/v2.3.1
819
1008
  [2.3.0]: https://github.com/artickc/grok-telegram-bot/releases/tag/v2.3.0
package/README.md CHANGED
@@ -27,9 +27,16 @@ re-architected for the Grok Build CLI and extended into a full multi-session cli
27
27
  | Capability | What it does |
28
28
  |---|---|
29
29
  | 🗂 **Projects** | `/projects` browses your folders and runs Grok in the one you pick. |
30
+ | 🏷 **Forum project topics** | Optional forum supergroup: **General** manager, **AI Chat** workspace, one topic per project, exact-name bind, `/forum_setup`. See **[docs/GROUP.md](./docs/GROUP.md)**. |
31
+ | 🎛 **General manager** | Forum General is a chat-like orchestrator: memory-first, short replies, `send_prompt` into project topics, report-back when child work finishes. |
32
+ | 🌉 **Telegram bridge** | Agent can `create_topic`, `set_path`, `send_prompt` (optional `session_id`), `notify`, `search_memory`, `list_topics` / `list_jobs`, and call allowlisted sibling bots via JSON actions. |
33
+ | 🔖 **Prompt anchors** | Each user prompt is re-posted with a searchable `#prompt_…` tag; stream/Done messages reply to that anchor (media re-attached). |
34
+ | 🆕 **New session** | `/new` or the bar **New** button starts a fresh session; forum topics keep New on the topic menu. |
35
+ | 💡 **Post-turn suggestions** | After Done, 1–3 scored follow-ups as buttons; high-score items can auto-queue as one multi-step prompt. |
36
+ | 🔍 **Gated self-recheck** | After file-changing turns, an optional quality pass runs once before Done (`SELF_RECHECK`). |
30
37
  | ♻️ **Resume sessions** | `/sessions` lists recent Grok sessions; tap to resume one (`grok --session <id>`). |
31
38
  | 🟢 **Connect to live sessions** | `/active` shows sessions running **right now** on your PC. Watch them live, or continue them — see below. |
32
- | 🛑 **Kill a session / PID** | Each live `/sessions` · `/active` card has a **🛑 Kill · pid N** button (confirm-guarded) that stops that session's process and its child tree; `/killall` stops them all. The bot's own agent is never killable. |
39
+ | 🛑 **Kill a session / PID** | Each live `/sessions` · `/active` card has a **🛑 Kill · pid N** button (confirm-guarded) that stops that session's process and its child tree; `/killall` stops them all. The bot's own agent is never killable. **Stop** only cancels the current session turn — never the shared agent. |
33
40
  | 📡 **Live watch** | Follow a running session read-only in real time (tails its event log). |
34
41
  | 🧭 **Always-visible menu** | A persistent keyboard plus a pinned status panel that appears while a task runs (and clears when idle), showing your current **project, agent, reasoning effort, model, session and queue**. |
35
42
  | ⏰ **Scheduled tasks** | Create prompts that run on a schedule (once / daily / weekly / monthly / every-N-minutes) in a chosen project, delivered back to your chat. |
@@ -49,7 +56,7 @@ re-architected for the Grok Build CLI and extended into a full multi-session cli
49
56
  | 💬 **Quality markdown** | Converts agent markdown to Telegram **MarkdownV2** with safe escaping and code-fence-aware splitting. |
50
57
  | 🔁 **Self-healing** | Auto-restarts the Grok agent with backoff and re-binds your session. |
51
58
  | 🖥 **Runs 24/7** | 1-click install as a background service that starts on boot — Windows, Linux, macOS, auto-detected. |
52
- | 🔒 **Access control** | Restrict to specific Telegram user IDs. |
59
+ | 🔒 **Access control** | Restrict to specific Telegram user IDs (private chats **and** forum groups). |
53
60
 
54
61
  ---
55
62
 
@@ -59,6 +66,9 @@ re-architected for the Grok Build CLI and extended into a full multi-session cli
59
66
  |---|:---:|:---:|
60
67
  | Connect Grok CLI to Telegram (ACP) | ✅ | ✅ |
61
68
  | Switch between projects | ✅ | ❌ |
69
+ | **Forum topics = projects** + AI Chat workspace | ✅ | ❌ |
70
+ | **General manager** (memory-first, dispatch + report-back) | ✅ | ❌ |
71
+ | **Cross-topic agent bridge** (create / bind / send_prompt / session_id) | ✅ | ❌ |
62
72
  | Resume saved sessions | ✅ | ❌ |
63
73
  | Attach to **live** PC sessions (watch / fork) | ✅ | ❌ |
64
74
  | **Kill a session by PID** (or all at once) | ✅ | ❌ |
@@ -69,6 +79,7 @@ re-architected for the Grok Build CLI and extended into a full multi-session cli
69
79
  | **Session auto-approve** + **pinned** interactive permissions | ✅ | ❌ |
70
80
  | Multiple isolated sessions | ✅ | ❌ (single shared) |
71
81
  | Queued follow-ups while busy | ✅ | ❌ |
82
+ | **Post-turn suggestions** + gated self-recheck | ✅ | ❌ |
72
83
  | **Scheduled tasks** (cron-like) | ✅ | ❌ |
73
84
  | **Multi-image** prompts (albums) | ✅ | ❌ |
74
85
  | Unified **edit diffs** | ✅ | ❌ |
@@ -216,14 +227,16 @@ Logs are written to `logs/grok-telegram-bot.log` (rotated at 5 MB).
216
227
  /tasks Manage scheduled tasks
217
228
  /newtask Create a scheduled task (wizard)
218
229
  /history Show recent conversation history
219
- /new Start a fresh session here
230
+ /new Start a fresh session here (also bar: 🆕 New session)
231
+ /forum_setup Re-probe / create forum topics (use inside the configured group)
220
232
  /status Current session, project & queue
221
233
  /usage Account info & current context usage
222
234
  /btw <text> Run it now if idle, else queue to run right after the current task
223
235
  /flush Send queued follow-ups now
224
236
  /queue Show queued follow-ups
225
237
  /clearqueue Clear the queue
226
- /cancel Stop the current turn
238
+ /cancel Stop the current turn (session-scoped — never kills the shared agent)
239
+ /stop Same as /cancel
227
240
  /unwatch Stop following a live session
228
241
  /model <id> Switch the model for this session
229
242
  /restart Restart the Grok agent
@@ -237,13 +250,28 @@ running, your messages are queued and sent automatically when it finishes.
237
250
 
238
251
  ---
239
252
 
253
+ ## 🏷 Forum project group (optional)
254
+
255
+ Drive **many projects in parallel** from one Telegram forum supergroup: each
256
+ topic is bound to a folder, and **AI Chat** stays on `GROK_WORKSPACE` for
257
+ orchestration. Set `TOPIC_GROUP_ID`, make the bot admin with Manage Topics, and
258
+ run `/forum_setup`. Full walkthrough (binding rules, agent bridge, access
259
+ control, troubleshooting):
260
+
261
+ **→ [docs/GROUP.md](./docs/GROUP.md)**
262
+
263
+ ---
264
+
240
265
  ## 🧭 The menu & status panel
241
266
 
242
- A tiny **persistent bar** sits under the message box — **☰ Menu · 🧭 Running ·
243
- Stop** so common actions are one tap away without clutter. Tap **☰ Menu**
244
- (or `/menu`) to open a clean, grouped **inline menu**: Project · New · Running ·
245
- Sessions · Agent · Model · Reasoning · Tasks · Status · Usage · Stop · Kill all.
246
- The bar can be hidden (🙈) and restored (⌨️ Show bar or `/menu`).
267
+ A tiny **persistent bar** sits under the message box — **☰ Menu · 🆕 New session
268
+ · 🧭 Running · Stop** (while idle/busy the middle button may show Running
269
+ instead of New) so common actions are one tap away without clutter. Tap
270
+ **☰ Menu** (or `/menu`) to open a clean, grouped **inline menu**: Project ·
271
+ Running · Sessions · Agent · Model · Reasoning · Tasks · Status · Usage · Stop ·
272
+ Kill all. Forum topics keep **New** on the topic inline menu (reply keyboards are
273
+ unreliable there). The bar can be hidden (🙈) and restored (⌨️ Show bar or
274
+ `/menu`).
247
275
 
248
276
  While a task is running, a **pinned status panel** appears at the top of the chat
249
277
  showing your current **task progress, activity, queue, project, session, context
@@ -403,9 +431,9 @@ Resuming an **idle** session loads it directly so you continue the exact thread.
403
431
  | Variable | Required | Default | Description |
404
432
  |---|---|---|---|
405
433
  | `TELEGRAM_BOT_TOKEN` | **yes** | — | Bot token from @BotFather. |
406
- | `ALLOWED_USERS` | recommended | *(all)* | Comma-separated Telegram user IDs. Empty = anyone (unsafe). |
434
+ | `ALLOWED_USERS` | recommended | *(all)* | Comma-separated Telegram user IDs for private chats **and** groups. Empty = anyone (unsafe — never leave empty with `TOPIC_GROUP_ID`). Unauthorized group members are ignored silently. |
407
435
  | `GROK_CLI_PATH` | no | auto / `grok` | Path to the `grok` binary. |
408
- | `GROK_WORKSPACE` | no | cwd | Default working directory. |
436
+ | `GROK_WORKSPACE` | no | cwd | Default working directory (also AI Chat / General in a forum group). |
409
437
  | `XAI_API_KEY` | no | — | xAI API key, only for headless hosts with no browser. Normally you sign in with `grok login` (or `/reauth`) — no key needed. Exported to the agent when set. |
410
438
  | `GROK_MODEL` | no | `grok-4.5` | Default model for new sessions. |
411
439
  | `GROK_TG_DIR` | no | `~/.grok/tg` | Folder holding this instance's `.env`, `logs/`, `data/`. Resolution: `--instance` → `GROK_TG_DIR` → a `.env` in the current folder → `~/.grok/tg`. So a `.env` created once is loaded from any startup path. |
@@ -423,6 +451,18 @@ Resuming an **idle** session loads it directly so you continue the exact thread.
423
451
  | `SHOW_PROGRESS` | no | `true` | Ask the agent to append a `{progress: N%}` marker to each message; the bot parses it, hides the marker, and renders a green 0–100% bar on the live message, in session cards, and in the status panel. |
424
452
  | `PROGRESS_FALLBACK` | no | `true` | When `SHOW_PROGRESS` is on but the agent emits **no** `{progress: N%}` marker (weaker/free models and long tool-heavy turns often skip it), render a **bot-computed** bar derived from real activity (completed tool calls, streamed output, elapsed time) so a live bar still advances — filling to 100% when the turn completes. The agent's own marker, when present, always takes precedence and stays monotonic. |
425
453
  | `NOTIFY_OTHER_SESSIONS` | no | `true` | Deliver a session's "Done" summary (with a short created/edited/deleted count) even when it's a background session, marked "From other session". `false` keeps background sessions silent. |
454
+ | `SUGGESTIONS_ENABLED` | no | `true` | After Done, quietly ask for 1–3 scored follow-ups shown as buttons. |
455
+ | `SUGGESTIONS_AUTO_APPROVE_PCT` | no | `95` | Auto-queue suggestions with need ≥ this % as one multi-step prompt (`0` = buttons only). |
456
+ | `SELF_RECHECK` | no | `true` | After a successful user turn that modified files, optionally run one gated quality pass before Done. Alias: `SLEF_RECHECK`. |
457
+ | `SELF_RECHECK_PROMPT` | no | — | Optional fixed recheck template when AI decides recheck is needed (`{{USER}}` / `{{DONE}}`). |
458
+ | `QUIET_PROMPT_TIMEOUT_MS` | no | `90000` | Max wait for quiet meta prompts (recheck decision + suggestions). Timeout cancels the meta prompt so Done is not blocked. |
459
+ | `TOPIC_GROUP_ID` | no | — | Forum supergroup id for project topics. Bot must be admin with Manage Topics. See **[docs/GROUP.md](./docs/GROUP.md)**. |
460
+ | `TOPIC_AUTO_CREATE` | no | `true` | When forum is ready, create one topic per catalog project (paced + 429-retried). |
461
+ | `TOPIC_AI_CHAT_NAME` | no | `AI Chat` | Display name for the workspace topic. |
462
+ | `ALLOWED_TELEGRAM_BOTS` | no | — | Comma-separated sibling bot usernames the agent may call via bridge `bot_command` / `list_bots`. |
463
+ | `TELEGRAM_BOT_COMMANDS` | no | — | Optional command catalogs for sibling bots (compact or JSON; see `.env.example`). |
464
+ | `TELEGRAM_BOT_REPLY_TIMEOUT_MS` | no | `45000` | Hard timeout waiting for a sibling bot after `/cmd@bot`. |
465
+ | `TELEGRAM_BOT_SETTLE_MS` | no | `2000` | Quiet settle after the last message/edit from that bot. |
426
466
  | `MCP_PROBE_TIMEOUT_MS` | no | `8000` | Per-server timeout for the `/mcp` live health-check. |
427
467
  | `MCP_PROBE_CONCURRENCY` | no | `6` | How many MCP health probes run at once. |
428
468
  | `GROK_AUTO_RESTART` | no | `true` | Auto-restart the agent if it exits. |
@@ -475,11 +515,12 @@ src/
475
515
  ├── grok/ Grok bridge: headless client, JSONL types, models, session log
476
516
  ├── sessions/ Session discovery, history parser, live tail watcher
477
517
  ├── projects/ Project directory discovery
518
+ ├── forum/ Forum topic store, path bind, project icons
478
519
  ├── mcp/ MCP config (list/toggle) + live health probe
479
520
  ├── render/ Markdown→MarkdownV2, diffs, tool formatting, chunking
480
521
  ├── stream/ Incremental edit-streaming
481
522
  ├── service/ Cross-platform daemon (windows/linux/macos + selector)
482
- └── bot/ grammY bot, per-chat runtime, handlers
523
+ └── bot/ grammY bot, per-chat runtime, handlers, Telegram bridge
483
524
  ```
484
525
 
485
526
  ---
@@ -549,10 +590,13 @@ user. See [SECURITY.md](./SECURITY.md) for the full model.
549
590
  - [x] Device-code `/reauth` (no host browser) + real email labels from auth.json
550
591
  - [x] Rich per-kind tool-call detail (search / edit diffs / shell / MCP / …)
551
592
  - [x] README community sections — Contributors, Top Contributors, Stars, StarMapper
593
+ - [x] Forum project topics + AI Chat workspace (`TOPIC_GROUP_ID`)
594
+ - [x] Cross-topic Telegram bridge (`create_topic` / `set_path` / `send_prompt` / …)
595
+ - [x] Prompt anchors, post-turn suggestions, gated self-recheck
552
596
  - [ ] **Token & cost meter** — per-session token counts and an estimated spend tally
553
597
  - [ ] **Text-to-speech replies** — optionally speak answers back as voice notes
554
598
  - [ ] **Scheduled-task chaining & conditions** — run task B after A, or only if a command/file check passes
555
- - [ ] **Team mode** — multiple authorized users with per-user sessions, roles, and an audit log
599
+ - [ ] **Team mode** — roles and audit log beyond shared `ALLOWED_USERS` + forum topics
556
600
  - [ ] Localized bot UI (i18n)
557
601
  - [ ] Docker image with `grok` preinstalled
558
602
  - [ ] Webhook mode for serverless deployment
@@ -657,8 +701,9 @@ Grab the latest packaged build from the
657
701
  release ships a clean `grok-telegram-bot-<version>.zip` (no `node_modules` or
658
702
  secrets) plus GitHub's source archives. See [CHANGELOG.md](./CHANGELOG.md) for
659
703
  what changed in each version, **[docs/INSTALL.md](./docs/INSTALL.md)** for the
660
- full 1-click install guide, and **[docs/UPGRADE.md](./docs/UPGRADE.md)** for how
661
- to update an existing install (npm, zip, or source).
704
+ full 1-click install guide, **[docs/UPGRADE.md](./docs/UPGRADE.md)** for how to
705
+ update an existing install (npm, zip, or source), and
706
+ **[docs/GROUP.md](./docs/GROUP.md)** for forum project topics.
662
707
 
663
708
  ---
664
709