grok-telegram-bot 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +135 -0
- package/CHANGELOG.md +598 -0
- package/LICENSE +21 -0
- package/README.md +644 -0
- package/bin/grok-tg.mjs +21 -0
- package/docs/INSTALL.md +153 -0
- package/docs/UPGRADE.md +253 -0
- package/docs/ops/RELEASE_CHECKLIST.md +39 -0
- package/package.json +74 -0
- package/scripts/setup.mjs +116 -0
- package/src/agents/catalog.ts +58 -0
- package/src/app/accounts.ts +162 -0
- package/src/app/auth-service.ts +136 -0
- package/src/app/grok-credentials.ts +103 -0
- package/src/app/instance-lock.ts +139 -0
- package/src/app/json-store.ts +54 -0
- package/src/app/reasoning.ts +30 -0
- package/src/app/settings-store.ts +38 -0
- package/src/app/stt.ts +53 -0
- package/src/app/types.ts +56 -0
- package/src/app/updater.ts +234 -0
- package/src/app/usage.ts +38 -0
- package/src/app/version.ts +41 -0
- package/src/bot/account-rotator.ts +52 -0
- package/src/bot/auth.ts +38 -0
- package/src/bot/bot.ts +225 -0
- package/src/bot/chat-controller.ts +317 -0
- package/src/bot/commands.ts +52 -0
- package/src/bot/deps.ts +67 -0
- package/src/bot/file-ingest.ts +190 -0
- package/src/bot/handlers/accounts.ts +220 -0
- package/src/bot/handlers/auth.ts +64 -0
- package/src/bot/handlers/control.ts +103 -0
- package/src/bot/handlers/document.ts +112 -0
- package/src/bot/handlers/history.ts +63 -0
- package/src/bot/handlers/kill.ts +54 -0
- package/src/bot/handlers/mcp.ts +206 -0
- package/src/bot/handlers/menu.ts +220 -0
- package/src/bot/handlers/message.ts +103 -0
- package/src/bot/handlers/photo.ts +123 -0
- package/src/bot/handlers/projects.ts +183 -0
- package/src/bot/handlers/running.ts +181 -0
- package/src/bot/handlers/session-card.ts +81 -0
- package/src/bot/handlers/session-kill.ts +95 -0
- package/src/bot/handlers/sessions.ts +148 -0
- package/src/bot/handlers/system.ts +51 -0
- package/src/bot/handlers/tasks.ts +224 -0
- package/src/bot/handlers/usage.ts +38 -0
- package/src/bot/handlers/voice.ts +55 -0
- package/src/bot/image-return.ts +69 -0
- package/src/bot/menu/ephemeral.ts +117 -0
- package/src/bot/menu/keyboard.ts +49 -0
- package/src/bot/menu/refresh.ts +13 -0
- package/src/bot/menu/status-panel.ts +173 -0
- package/src/bot/permission-service.ts +149 -0
- package/src/bot/prompt-content.ts +64 -0
- package/src/bot/prompt-retry.ts +70 -0
- package/src/bot/reauth-controller.ts +297 -0
- package/src/bot/registry.ts +186 -0
- package/src/bot/reply-context.ts +77 -0
- package/src/bot/session-fork.ts +35 -0
- package/src/bot/session-runtime.ts +1048 -0
- package/src/bot/telegram-io.ts +109 -0
- package/src/bot/typing.ts +35 -0
- package/src/bot/wizard/task-wizard.ts +214 -0
- package/src/cli.ts +126 -0
- package/src/config.ts +248 -0
- package/src/grok/client.ts +617 -0
- package/src/grok/models.ts +50 -0
- package/src/grok/session-log.ts +148 -0
- package/src/grok/transport.ts +51 -0
- package/src/grok/types.ts +136 -0
- package/src/index.ts +84 -0
- package/src/logger.ts +78 -0
- package/src/mcp/config.ts +120 -0
- package/src/mcp/probe.ts +218 -0
- package/src/mcp/types.ts +68 -0
- package/src/projects/manager.ts +99 -0
- package/src/render/chunk.ts +57 -0
- package/src/render/diff.ts +48 -0
- package/src/render/escape.ts +22 -0
- package/src/render/file-summary.ts +111 -0
- package/src/render/hashtags.ts +34 -0
- package/src/render/markdown.ts +130 -0
- package/src/render/progress-estimate.ts +63 -0
- package/src/render/progress.ts +80 -0
- package/src/render/subagent.ts +75 -0
- package/src/render/tool-call.ts +196 -0
- package/src/service/index.ts +24 -0
- package/src/service/linux.ts +85 -0
- package/src/service/macos.ts +101 -0
- package/src/service/platform.ts +64 -0
- package/src/service/types.ts +36 -0
- package/src/service/windows.ts +198 -0
- package/src/sessions/history.ts +225 -0
- package/src/sessions/process.ts +30 -0
- package/src/sessions/store.ts +133 -0
- package/src/sessions/tail.ts +86 -0
- package/src/sessions/types.ts +26 -0
- package/src/stream/streamer.ts +261 -0
- package/src/tasks/runner.ts +82 -0
- package/src/tasks/schedule.ts +142 -0
- package/src/tasks/scheduler.ts +53 -0
- package/src/tasks/store.ts +80 -0
- package/src/tasks/types.ts +33 -0
- package/tsconfig.json +19 -0
package/.env.example
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
2
|
+
# Grok Telegram Bot — configuration
|
|
3
|
+
# Copy this file to .env and fill in the values, or run: npm run setup
|
|
4
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
5
|
+
|
|
6
|
+
# REQUIRED — Telegram bot token from @BotFather (https://t.me/BotFather)
|
|
7
|
+
TELEGRAM_BOT_TOKEN=
|
|
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).
|
|
11
|
+
ALLOWED_USERS=
|
|
12
|
+
|
|
13
|
+
# ── Grok Build CLI ───────────────────────────────────────────────────────────
|
|
14
|
+
# Path to the `grok` binary. Leave blank to use "grok" from PATH.
|
|
15
|
+
# The official installer puts it in ~/.grok/bin/grok (install with:
|
|
16
|
+
# curl -fsSL https://x.ai/cli/install.sh | bash — needs SuperGrok / X Premium+)
|
|
17
|
+
GROK_CLI_PATH=
|
|
18
|
+
|
|
19
|
+
# Auth: sign in with your xAI account by running `grok login` once (or use the
|
|
20
|
+
# bot's /reauth). No API key needed. On a headless host with no browser, you can
|
|
21
|
+
# instead set an xAI API key here (exported to the agent as XAI_API_KEY):
|
|
22
|
+
# XAI_API_KEY=
|
|
23
|
+
|
|
24
|
+
# Default model that powers Grok Build.
|
|
25
|
+
GROK_MODEL=grok-4.5
|
|
26
|
+
|
|
27
|
+
# Default workspace directory used when you start without picking a project.
|
|
28
|
+
GROK_WORKSPACE=
|
|
29
|
+
|
|
30
|
+
# Pass --always-approve to `grok agent stdio` so tool calls run without inline
|
|
31
|
+
# permission prompts. Set false to get Approve/Deny buttons in Telegram before
|
|
32
|
+
# Grok runs risky tools (file writes, shell commands) — ACP "ask" mode.
|
|
33
|
+
GROK_TRUST_ALL_TOOLS=true
|
|
34
|
+
|
|
35
|
+
# Comma-separated roots the /projects browser is allowed to list.
|
|
36
|
+
# Supports ~ for home directory. Defaults to GROK_WORKSPACE's parent + home.
|
|
37
|
+
# Example: H:\Lucru\Domains,C:\Lucru\Domains
|
|
38
|
+
PROJECT_ROOTS=
|
|
39
|
+
|
|
40
|
+
# Where the bot stores the sessions it drives (<id>.json/.jsonl/.lock). Defaults
|
|
41
|
+
# to <data>/sessions. Grok itself keeps sessions in its own SQLite store.
|
|
42
|
+
# SESSIONS_DIR=
|
|
43
|
+
|
|
44
|
+
# ── Rendering / streaming ────────────────────────────────────────────────────
|
|
45
|
+
# How often (ms) to edit the streaming message while the agent is typing.
|
|
46
|
+
STREAM_THROTTLE_MS=1500
|
|
47
|
+
|
|
48
|
+
# Coalesce rapid consecutive text messages (a long message Telegram split at
|
|
49
|
+
# 4096 chars) into one prompt. 0 = disable.
|
|
50
|
+
MESSAGE_BATCH_MS=800
|
|
51
|
+
|
|
52
|
+
# Show tool-call status messages (file reads/writes, commands). true/false
|
|
53
|
+
SHOW_TOOL_CALLS=true
|
|
54
|
+
|
|
55
|
+
# Show unified diffs for file edits. true/false
|
|
56
|
+
SHOW_EDIT_DIFFS=true
|
|
57
|
+
|
|
58
|
+
# Max lines of a diff to show inline before truncating.
|
|
59
|
+
DIFF_MAX_LINES=120
|
|
60
|
+
|
|
61
|
+
# Send images the agent produces this turn back to Telegram automatically, and
|
|
62
|
+
# a per-turn cap.
|
|
63
|
+
SEND_AGENT_IMAGES=true
|
|
64
|
+
AGENT_IMAGES_MAX=8
|
|
65
|
+
|
|
66
|
+
# Max characters of a text file attachment inlined into the prompt (0 = unlimited).
|
|
67
|
+
DOC_MAX_CHARS=100000
|
|
68
|
+
|
|
69
|
+
# Show sub-agent activity while the main agent waits on its sub-agents (Grok
|
|
70
|
+
# delegates larger tasks to parallel sub-agents). true/false
|
|
71
|
+
SHOW_SUBAGENTS=true
|
|
72
|
+
|
|
73
|
+
# Task-progress bar. SHOW_PROGRESS asks the agent to end each message with a
|
|
74
|
+
# {progress: N%} marker (hidden and rendered as a green 0–100% bar). PROGRESS_FALLBACK
|
|
75
|
+
# shows a bot-computed bar from real activity when the model emits no marker.
|
|
76
|
+
SHOW_PROGRESS=true
|
|
77
|
+
PROGRESS_FALLBACK=true
|
|
78
|
+
|
|
79
|
+
# Deliver a background session's "Done" summary even while you're viewing another
|
|
80
|
+
# session (marked "From other session"). true/false
|
|
81
|
+
NOTIFY_OTHER_SESSIONS=true
|
|
82
|
+
|
|
83
|
+
# ── MCP servers (/mcp) ───────────────────────────────────────────────────────
|
|
84
|
+
# /mcp lists MCP servers the bot can discover and health-checks them. Grok Build
|
|
85
|
+
# manages its own MCP servers via `grok`'s /mcps modal and ~/.grok/config.toml,
|
|
86
|
+
# so configure them there; the bot's /mcp view is best-effort.
|
|
87
|
+
# MCP_PROBE_TIMEOUT_MS=8000
|
|
88
|
+
# MCP_PROBE_CONCURRENCY=6
|
|
89
|
+
|
|
90
|
+
# Auto-update (default on): hourly npm check; when a newer version exists AND the
|
|
91
|
+
# bot is idle, it updates + restarts and posts the release notes. Global npm only.
|
|
92
|
+
AUTO_UPDATE=true
|
|
93
|
+
# UPDATE_CHECK_MS=3600000
|
|
94
|
+
|
|
95
|
+
# Log level: debug | info | warn | error
|
|
96
|
+
LOG_LEVEL=info
|
|
97
|
+
|
|
98
|
+
# ── Daemon / background service ──────────────────────────────────────────────
|
|
99
|
+
# Emit a re-bind signal after /reauth / account switch (there is no persistent
|
|
100
|
+
# daemon with Grok; each turn spawns `grok`). true/false
|
|
101
|
+
GROK_AUTO_RESTART=true
|
|
102
|
+
|
|
103
|
+
# Quiet mode: send messages silently except turn completions, task results, and
|
|
104
|
+
# permission prompts. true/false
|
|
105
|
+
QUIET_NOTIFICATIONS=true
|
|
106
|
+
|
|
107
|
+
# Give up on a turn only after this many ms with NO streaming activity.
|
|
108
|
+
# PROMPT_IDLE_TIMEOUT_MS=900000
|
|
109
|
+
|
|
110
|
+
# Auto-retry a turn up to N times on a transient error before any output streamed
|
|
111
|
+
# (6s, 12s, 24s, 48s, capped 60s). 0 = off.
|
|
112
|
+
# PROMPT_RETRY_ATTEMPTS=5
|
|
113
|
+
|
|
114
|
+
# When retries are exhausted on a transient error (nothing streamed), fork the
|
|
115
|
+
# session into a fresh primed continuation and retry once. true/false
|
|
116
|
+
# AUTO_FORK_ON_ERROR=true
|
|
117
|
+
|
|
118
|
+
# Fork immediately (skip backoff) when a turn fails transiently AND context usage
|
|
119
|
+
# is at/above this %. Requires AUTO_FORK_ON_ERROR. 0 disables. Default 85.
|
|
120
|
+
# AUTO_FORK_CONTEXT_PCT=85
|
|
121
|
+
|
|
122
|
+
# When a transient error hits AFTER streaming started, ask the SAME session to
|
|
123
|
+
# continue instead of re-running tools. true/false
|
|
124
|
+
# RESUME_ON_STREAM_ERROR=true
|
|
125
|
+
|
|
126
|
+
# Where to write the log file. Defaults to <project>/logs/grok-telegram-bot.log
|
|
127
|
+
# LOG_DIR=
|
|
128
|
+
# LOG_FILE=
|
|
129
|
+
|
|
130
|
+
# ── Voice messages (speech-to-text) ──────────────────────────────────────────
|
|
131
|
+
# Any OpenAI/Whisper-compatible transcription endpoint. xAI offers one too:
|
|
132
|
+
# STT_API_URL=https://api.x.ai/v1
|
|
133
|
+
# STT_API_KEY=
|
|
134
|
+
# STT_MODEL=whisper-1
|
|
135
|
+
# STT_LANGUAGE=
|