telecoder 0.0.0-stage → 1.2.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 (223) hide show
  1. package/.env.example +363 -0
  2. package/CHANGELOG.md +1186 -0
  3. package/LICENSE +22 -0
  4. package/README.md +126 -2
  5. package/dist/audio/transcribe.js +50 -0
  6. package/dist/bin/mcp-server.js +378 -0
  7. package/dist/bin/tool-result.js +22 -0
  8. package/dist/bot/access/group-access.js +147 -0
  9. package/dist/bot/bot.js +592 -0
  10. package/dist/bot/file-access.js +141 -0
  11. package/dist/bot/handlers/command/access.js +407 -0
  12. package/dist/bot/handlers/command/admin.js +827 -0
  13. package/dist/bot/handlers/command/auto-approve.js +138 -0
  14. package/dist/bot/handlers/command/btw.js +224 -0
  15. package/dist/bot/handlers/command/cost.js +409 -0
  16. package/dist/bot/handlers/command/media.js +197 -0
  17. package/dist/bot/handlers/command/model.js +305 -0
  18. package/dist/bot/handlers/command/prefs-scope.js +197 -0
  19. package/dist/bot/handlers/command/project.js +536 -0
  20. package/dist/bot/handlers/command/resume.js +321 -0
  21. package/dist/bot/handlers/command/session.js +438 -0
  22. package/dist/bot/handlers/command/settings.js +1012 -0
  23. package/dist/bot/handlers/command/shared.js +210 -0
  24. package/dist/bot/handlers/command/streaming-mode.js +16 -0
  25. package/dist/bot/handlers/command/tasks.js +513 -0
  26. package/dist/bot/handlers/command/topic-store.js +113 -0
  27. package/dist/bot/handlers/command/topic.js +80 -0
  28. package/dist/bot/handlers/command.handler.js +772 -0
  29. package/dist/bot/handlers/fork.handler.js +1109 -0
  30. package/dist/bot/handlers/media-fallback.js +121 -0
  31. package/dist/bot/handlers/message/replies.js +133 -0
  32. package/dist/bot/handlers/message/shared.js +117 -0
  33. package/dist/bot/handlers/message/throttle.js +49 -0
  34. package/dist/bot/handlers/message/turn-notify.js +169 -0
  35. package/dist/bot/handlers/message/turn-runner.js +141 -0
  36. package/dist/bot/handlers/message.handler.js +107 -0
  37. package/dist/bot/handlers/newbot.handler.js +221 -0
  38. package/dist/bot/handlers/photo.handler.js +327 -0
  39. package/dist/bot/handlers/prompts.handler.js +343 -0
  40. package/dist/bot/handlers/running-note.js +44 -0
  41. package/dist/bot/handlers/schedule.handler.js +303 -0
  42. package/dist/bot/handlers/session-guard.js +78 -0
  43. package/dist/bot/handlers/suggestion.handler.js +84 -0
  44. package/dist/bot/handlers/tree.handler.js +480 -0
  45. package/dist/bot/handlers/view.js +41 -0
  46. package/dist/bot/handlers/voice.handler.js +209 -0
  47. package/dist/bot/middleware/admin-only.js +49 -0
  48. package/dist/bot/middleware/auth.middleware.js +122 -0
  49. package/dist/bot/middleware/group-mention.middleware.js +139 -0
  50. package/dist/bot/middleware/group-role.middleware.js +75 -0
  51. package/dist/bot/middleware/message-batcher.js +87 -0
  52. package/dist/bot/middleware/queued-messages.js +971 -0
  53. package/dist/bot/middleware/stale-filter.js +31 -0
  54. package/dist/build-info.json +8 -0
  55. package/dist/claude/agent-watchdog.js +162 -0
  56. package/dist/claude/agent.js +1458 -0
  57. package/dist/claude/ask-user.js +295 -0
  58. package/dist/claude/auto-approve.js +225 -0
  59. package/dist/claude/auto-topic-haiku.js +126 -0
  60. package/dist/claude/available-commands.js +153 -0
  61. package/dist/claude/carry-over.js +27 -0
  62. package/dist/claude/ccr-shim.js +46 -0
  63. package/dist/claude/charter-judge.js +214 -0
  64. package/dist/claude/claude-auth.js +121 -0
  65. package/dist/claude/command-parser.js +200 -0
  66. package/dist/claude/cost-overlay-scraper.js +129 -0
  67. package/dist/claude/enabled-plugins.js +56 -0
  68. package/dist/claude/fork-tree.js +393 -0
  69. package/dist/claude/held-query.js +190 -0
  70. package/dist/claude/in-flight-tracker.js +61 -0
  71. package/dist/claude/ipc-server.js +192 -0
  72. package/dist/claude/mcp-bridge.js +453 -0
  73. package/dist/claude/mcp-tools.js +354 -0
  74. package/dist/claude/message-offsets.js +88 -0
  75. package/dist/claude/modal-relay.js +450 -0
  76. package/dist/claude/model-catalog.js +85 -0
  77. package/dist/claude/monitor-relay.js +597 -0
  78. package/dist/claude/pending-forks.js +93 -0
  79. package/dist/claude/pending-suggestions.js +50 -0
  80. package/dist/claude/permission-gate.js +337 -0
  81. package/dist/claude/permission-mode.js +178 -0
  82. package/dist/claude/poll-user.js +51 -0
  83. package/dist/claude/project-commands.js +69 -0
  84. package/dist/claude/prompt-hold.js +124 -0
  85. package/dist/claude/prompt-suggestion-scraper.js +89 -0
  86. package/dist/claude/pty-provider.js +2214 -0
  87. package/dist/claude/pty-spawn-config.js +296 -0
  88. package/dist/claude/pty-stream.js +363 -0
  89. package/dist/claude/request-queue.js +135 -0
  90. package/dist/claude/scheduled-runner.js +91 -0
  91. package/dist/claude/scheduler.js +237 -0
  92. package/dist/claude/scope-guard.js +274 -0
  93. package/dist/claude/sdk-permission-gate.js +77 -0
  94. package/dist/claude/secret-request.js +576 -0
  95. package/dist/claude/session-cost.js +41 -0
  96. package/dist/claude/session-history.js +286 -0
  97. package/dist/claude/session-jsonl.js +920 -0
  98. package/dist/claude/session-manager.js +195 -0
  99. package/dist/claude/session-scan.js +270 -0
  100. package/dist/claude/setup-token.js +285 -0
  101. package/dist/claude/side-call-options.js +45 -0
  102. package/dist/claude/side-question.js +249 -0
  103. package/dist/claude/stage-images.js +62 -0
  104. package/dist/claude/subagent-tools.js +12 -0
  105. package/dist/claude/synthetic-ctx.js +51 -0
  106. package/dist/claude/system-prompt.js +162 -0
  107. package/dist/claude/tasks-overlay-scraper.js +94 -0
  108. package/dist/claude/tip-scraper.js +78 -0
  109. package/dist/claude/tui-modal.js +501 -0
  110. package/dist/claude/tui-state.js +384 -0
  111. package/dist/claude/turn-end.js +91 -0
  112. package/dist/claude/turn-prose.js +64 -0
  113. package/dist/claude/update-banner-relay.js +70 -0
  114. package/dist/cli/commands/doctor.js +305 -0
  115. package/dist/cli/commands/help.js +25 -0
  116. package/dist/cli/commands/init.js +123 -0
  117. package/dist/cli/commands/service.js +678 -0
  118. package/dist/cli/commands/start.js +53 -0
  119. package/dist/cli/commands/version.js +11 -0
  120. package/dist/cli/dispatch.js +79 -0
  121. package/dist/cli/init/env-file.js +99 -0
  122. package/dist/cli/init/flow.js +638 -0
  123. package/dist/cli/init/prompter.js +116 -0
  124. package/dist/cli/init/telegram.js +94 -0
  125. package/dist/cli/service/render.js +212 -0
  126. package/dist/cli.js +18 -0
  127. package/dist/config-report.js +107 -0
  128. package/dist/config.js +500 -0
  129. package/dist/index.js +367 -0
  130. package/dist/launcher.js +933 -0
  131. package/dist/node-version-check.js +27 -0
  132. package/dist/providers/ccr-health.js +119 -0
  133. package/dist/providers/ccr-introspect.js +149 -0
  134. package/dist/providers/ccr-provider.js +60 -0
  135. package/dist/providers/claude-provider.js +63 -0
  136. package/dist/providers/prefs-sync.js +164 -0
  137. package/dist/providers/project-favorites.js +74 -0
  138. package/dist/providers/provider-router.js +127 -0
  139. package/dist/providers/provider-switch.js +91 -0
  140. package/dist/providers/sdk-provider.js +37 -0
  141. package/dist/providers/types.js +8 -0
  142. package/dist/providers/user-preferences.js +214 -0
  143. package/dist/restart-when-idle.js +153 -0
  144. package/dist/startup/auto-continue.js +67 -0
  145. package/dist/startup/auto-resume.js +173 -0
  146. package/dist/startup/notices.js +120 -0
  147. package/dist/startup/shared.js +44 -0
  148. package/dist/startup/verify-token.js +31 -0
  149. package/dist/telegram/access-request.js +153 -0
  150. package/dist/telegram/action-logger.js +684 -0
  151. package/dist/telegram/admin-mention.js +107 -0
  152. package/dist/telegram/background-activity-card.js +502 -0
  153. package/dist/telegram/botname-settings.js +336 -0
  154. package/dist/telegram/button-text.js +26 -0
  155. package/dist/telegram/client-options.js +27 -0
  156. package/dist/telegram/deduplication.js +33 -0
  157. package/dist/telegram/entities.js +295 -0
  158. package/dist/telegram/force-reply-tracker.js +57 -0
  159. package/dist/telegram/lettered-options.js +87 -0
  160. package/dist/telegram/markdown.js +362 -0
  161. package/dist/telegram/message-sender.js +1287 -0
  162. package/dist/telegram/prompt-label.js +142 -0
  163. package/dist/telegram/prompt-suggestion.js +54 -0
  164. package/dist/telegram/send.js +123 -0
  165. package/dist/telegram/streaming-turn.js +105 -0
  166. package/dist/telegram/suggestions-settings.js +30 -0
  167. package/dist/telegram/task-list.js +367 -0
  168. package/dist/telegram/task-tracker.js +209 -0
  169. package/dist/telegram/telegraph-settings.js +31 -0
  170. package/dist/telegram/telegraph.js +453 -0
  171. package/dist/telegram/terminal-renderer.js +671 -0
  172. package/dist/telegram/terminal-settings.js +25 -0
  173. package/dist/telegram/thread-titles.js +190 -0
  174. package/dist/telegram/threads-setup.js +117 -0
  175. package/dist/tts/tts-settings.js +62 -0
  176. package/dist/tts/tts.js +245 -0
  177. package/dist/tts/voice-reply.js +78 -0
  178. package/dist/utils/admins.js +143 -0
  179. package/dist/utils/agent-timer.js +55 -0
  180. package/dist/utils/atomic-write.js +24 -0
  181. package/dist/utils/bot-token.js +74 -0
  182. package/dist/utils/bounded-map.js +55 -0
  183. package/dist/utils/build-info.js +57 -0
  184. package/dist/utils/caffeinate.js +50 -0
  185. package/dist/utils/claude-env.js +54 -0
  186. package/dist/utils/claude-version.js +48 -0
  187. package/dist/utils/config-home.js +62 -0
  188. package/dist/utils/debug-agent.js +117 -0
  189. package/dist/utils/debug-watchdog.js +121 -0
  190. package/dist/utils/download.js +111 -0
  191. package/dist/utils/exit-codes.js +48 -0
  192. package/dist/utils/file-type.js +149 -0
  193. package/dist/utils/format.js +81 -0
  194. package/dist/utils/home-project.js +30 -0
  195. package/dist/utils/host-stall.js +51 -0
  196. package/dist/utils/id-list.js +44 -0
  197. package/dist/utils/idle-restart.js +92 -0
  198. package/dist/utils/install-mode.js +63 -0
  199. package/dist/utils/instance-config.js +148 -0
  200. package/dist/utils/instances.js +95 -0
  201. package/dist/utils/json-store.js +140 -0
  202. package/dist/utils/keyed-settings.js +62 -0
  203. package/dist/utils/legacy-env.js +35 -0
  204. package/dist/utils/npm-version.js +134 -0
  205. package/dist/utils/prefs-relay.js +107 -0
  206. package/dist/utils/proc-children.js +102 -0
  207. package/dist/utils/project-data-dir.js +33 -0
  208. package/dist/utils/reasoning-summary.js +12 -0
  209. package/dist/utils/resolve-bin.js +86 -0
  210. package/dist/utils/resolve-claude-bin.js +63 -0
  211. package/dist/utils/respawn-backoff.js +19 -0
  212. package/dist/utils/sanitize.js +91 -0
  213. package/dist/utils/session-key.js +37 -0
  214. package/dist/utils/stale-launcher.js +109 -0
  215. package/dist/utils/state-dir-migration.js +92 -0
  216. package/dist/utils/systemd.js +126 -0
  217. package/dist/utils/user-roster.js +275 -0
  218. package/dist/utils/verbosity.js +118 -0
  219. package/dist/utils/version-check.js +166 -0
  220. package/dist/utils/workspace-guard.js +44 -0
  221. package/dist/worker-restart.js +141 -0
  222. package/instances.json.example +41 -0
  223. package/package.json +76 -4
package/.env.example ADDED
@@ -0,0 +1,363 @@
1
+ # ═══════════════════════════════════════════════════════════════
2
+ # TeleCoder Configuration
3
+ # ═══════════════════════════════════════════════════════════════
4
+
5
+ # Note: a variable already exported in the environment the bot was started from
6
+ # wins over the value here — dotenv never overwrites what is already set, and a
7
+ # restart inherits the environment it was started from, so an old exported value
8
+ # can outlive every restart. The bot logs an [env] warning at startup naming any
9
+ # setting in this file that is being shadowed that way; the fix is to restart it
10
+ # from a shell that doesn't export them.
11
+
12
+ # ── Core ──────────────────────────────────────────────────────
13
+ # Telegram bot token from @BotFather
14
+ TELEGRAM_BOT_TOKEN=your_telegram_bot_token
15
+
16
+ # Comma-separated numeric Telegram user IDs allowed to use the bot — numbers,
17
+ # not @usernames. Get yours by messaging @userinfobot on Telegram, or message
18
+ # the bot once it runs: it tells anyone not on this list their ID.
19
+ # 123456789 below is a placeholder: the bot refuses to start until you replace it.
20
+ ALLOWED_USER_IDS=123456789
21
+
22
+ # ── Sharing the bot ───────────────────────────────────────────
23
+ # Everything below is for a bot you share with other people. A solo bot needs
24
+ # none of it and behaves exactly the same whether or not you read this section.
25
+ #
26
+ # ADMIN_USER_IDS is the subset of ALLOWED_USER_IDS that may approve permission
27
+ # prompts and run bot-lifecycle commands (/update, /restartbot, /rebuildbot)
28
+ # and transport ones (/method, /provider, /ccr). Everyone else is a "guest":
29
+ # they can use the agent normally, but guarded commands wait on an admin.
30
+ # Unset = every allowed user is an admin. Admins must also be in
31
+ # ALLOWED_USER_IDS — the auth check runs first and would turn them away, so the
32
+ # bot refuses to start rather than leave an admin who can never act.
33
+ # ADMIN_USER_IDS=111111111
34
+
35
+ # APPROVER_USER_IDS is the subset of ALLOWED_USER_IDS that may answer a
36
+ # permission prompt without owning the bot. An approver is a guest everywhere
37
+ # else — the charter judge still reads their messages, the gate still stops
38
+ # their tool calls, /restartbot and /method still refuse them. They just stop
39
+ # you being the only person who can unblock a prompt. Nobody approves their own
40
+ # request: the buttons go to the admins plus every approver except whoever
41
+ # asked. Needs ADMIN_USER_IDS set — without it everyone is already an admin.
42
+ # An approver has to be able to reach the bot first, so their id must be in
43
+ # ALLOWED_USER_IDS or have been /allow'd from chat; the bot says so at startup
44
+ # if it is in neither.
45
+ # APPROVER_USER_IDS=222222222,333333333
46
+
47
+ # Comma-separated group/supergroup chat IDs the bot is used in.
48
+ # ALLOWED_GROUP_IDS=-1001234567890
49
+
50
+ # What being in an allow-listed group grants:
51
+ # spectator — membership grants presence only. People read along and talk to
52
+ # each other; only someone an admin has /allow'd can prompt the
53
+ # agent. Right for a group with an audience in it, and the
54
+ # default: it matches what the roster gate already enforced.
55
+ # contributor — membership is the whole gate: anyone in the group can prompt
56
+ # the agent, which is shell access on this machine. Right for a
57
+ # group of peers who all own the box.
58
+ # Admins always have full access. Grant and revoke from the chat with /allow and
59
+ # /deny — replying to someone's message is the surest way to name them — and
60
+ # check the current state with /members. Those take effect immediately; no
61
+ # restart. /allow in the group grants it *there*; /allow in a DM admits someone
62
+ # to the bot everywhere, which /users reads back.
63
+ #
64
+ # Note: posts from anonymous group admins all arrive as the same Telegram user
65
+ # id (1087968824), so under 'spectator' they are gated as one. /allow 1087968824
66
+ # admits every anonymous admin at once, or ask them to post normally.
67
+ # GROUP_MEMBERS_DEFAULT=spectator
68
+
69
+ # In a group, only react to messages that address the bot: an @mention, a reply
70
+ # to one of the bot's own messages, or a slash command. Set to false to treat
71
+ # every message in the group as a prompt (only sensible in a group dedicated to
72
+ # the bot — otherwise people can't talk to each other).
73
+ # Requires Telegram's privacy mode to be OFF for the bot (@BotFather ->
74
+ # /setprivacy -> Disable, then re-add the bot to the group), or Telegram won't
75
+ # deliver mentions at all.
76
+ # GROUP_REQUIRE_MENTION=true
77
+
78
+ # Treat any reply to one of the bot's messages as addressing it, as it worked
79
+ # before mentions were required. Off by default: replying is also how you quote
80
+ # a message, so it is a poor signal of intent. Answers to the bot's own
81
+ # ForceReply prompts (/project, /plan, /file, ...) always get through, since
82
+ # Telegram leaves nowhere to put a mention in those.
83
+ # GROUP_REPLY_IS_MENTION=false
84
+
85
+ # Confine guests to those groups, so they can't take the bot into a private
86
+ # chat where you can't see what they're asking it. Admins can still DM it.
87
+ # RESTRICT_TO_GROUPS=false
88
+
89
+ # The permission gate: matching a dangerous Bash pattern (rm -rf, sudo,
90
+ # git push --force, DROP TABLE, terraform destroy, ...) pauses the tool call
91
+ # and posts an approval prompt that only an admin can answer. With guests
92
+ # present it turns itself on; set it explicitly to override in either
93
+ # direction.
94
+ # TELECODER_PERMISSION_PROMPTS=1
95
+
96
+ # How long a prompt (or a held message) waits for an admin before it is refused.
97
+ # PERMISSION_PROMPT_TIMEOUT_MINUTES=10
98
+
99
+ # Scope guard: also prompt when a tool call names a path outside the shared
100
+ # projects, or a credential path anywhere (~/.ssh, ~/.aws, a .env outside the
101
+ # roots, the bot's own state). System paths and language toolchains stay
102
+ # readable without prompting, so ordinary work is unaffected.
103
+ # 'auto' follows the permission gate. 'on' / 'off' force it.
104
+ # SCOPE_GUARD=auto
105
+
106
+ # Extra directories the scope guard counts as in-bounds, on top of
107
+ # WORKSPACE_DIR and the temp dir. Comma-separated absolute paths.
108
+ # SCOPE_ALLOWED_PATHS=/srv/data,/opt/shared
109
+
110
+ # Charter judge: before a guest's message reaches Claude, a Haiku side-call
111
+ # reads it against a plain-language charter and holds anything out of bounds
112
+ # for an admin. Catches what the scope guard cannot — "open a tunnel to this
113
+ # box", "email me the projects folder" — because neither names a path.
114
+ # Adds ~5s to a guest's turn; conversational filler is skipped. Fails open.
115
+ # 'auto' turns it on once the bot has guests.
116
+ # CHARTER_JUDGE=auto
117
+
118
+ # The charter the judge reads. Defaults to CHARTER.md in WORKSPACE_DIR when
119
+ # that file exists, and to a generated one naming the allowed roots otherwise.
120
+ # CHARTER_FILE=/srv/shared/CHARTER.md
121
+
122
+ # The gate is a PreToolUse hook on the `claude` CLI, so it only runs on the
123
+ # PTY transport. Make PTY the default for chats that haven't picked one.
124
+ # CLAUDE_METHOD_DEFAULT=pty
125
+
126
+ # ── Claude ────────────────────────────────────────────────────
127
+ # Anthropic API key (optional — leave empty to use Claude Max subscription)
128
+ # ANTHROPIC_API_KEY=sk-ant-...
129
+
130
+ # Optional: explicit .env path (useful if you start the bot from another directory)
131
+ # TELECODER_ENV_PATH=/absolute/path/to/telecoder/.env
132
+
133
+ # Upgrading from Claudegram? Every TELECODER_* var below was CLAUDEGRAM_* before
134
+ # the July 2026 rename. The old names still work and log a one-time deprecation
135
+ # warning at startup, so you can rename them whenever it suits you:
136
+ # TELECODER_ENV_PATH, TELECODER_INSTANCES_CONFIG, TELECODER_IPC_PORT,
137
+ # TELECODER_PERMISSION_PROMPTS, TELECODER_ALLOW_NATIVE_SCHEDULING
138
+
139
+ # Path to the Claude Code CLI executable
140
+ # Default: "claude" (assumes it's in your PATH)
141
+ # CLAUDE_EXECUTABLE_PATH=/home/username/.local/bin/claude
142
+
143
+ # Use SDK bundled executable for agent queries (true/false)
144
+ # CLAUDE_USE_BUNDLED_EXECUTABLE=true
145
+
146
+ # SDK log level: off | basic | verbose | trace
147
+ # CLAUDE_SDK_LOG_LEVEL=basic
148
+
149
+ # Load user-level Claude settings (~/.claude/settings.json) into the bot's SDK
150
+ # subprocess. Default false: bot runs in an isolated env, so your interactive
151
+ # Claude Code plugins/MCP servers/hooks don't leak into the bot. Enable only if
152
+ # you know what you're doing — extra MCP tools can trigger SDK tool-deferral
153
+ # and break proactive MCP tool calls (e.g. auto-topic, send_file).
154
+ # CLAUDE_SDK_LOAD_USER_SETTINGS=false
155
+
156
+ # Extra MCP servers for the bot's agent, as a path to a JSON file holding
157
+ # {"mcpServers": {...}} in the same shape as ~/.claude.json. Merged into the
158
+ # spawn config; the bot's own telecoder-tools always wins a name clash.
159
+ #
160
+ # This is the ONLY way to add one: the spawn passes --strict-mcp-config, so a
161
+ # `claude mcp add` entry is stored and then ignored. Keep the file outside the
162
+ # repo if it carries a token.
163
+ # EXTRA_MCP_CONFIG=/home/you/.config/telecoder-mcp.json
164
+
165
+ # Marketplace plugins to enable inside the bot's agent, comma-separated, as the
166
+ # plugin@marketplace ids `claude plugin list` prints. Enabling a plugin in the
167
+ # terminal is not enough on its own: that lands in ~/.claude/settings.json,
168
+ # which neither transport reads, so the plugin's skills and commands are simply
169
+ # missing in Telegram. Naming it here is what brings it across.
170
+ # CLAUDE_PLUGINS=frontend-design@claude-plugins-official
171
+
172
+ # Append a safe reasoning summary to each response (true/false)
173
+ # CLAUDE_REASONING_SUMMARY=true
174
+
175
+ # Bot personality name used in the system prompt
176
+ # BOT_NAME=TeleCoder
177
+
178
+ # Bot run mode (used by /restartbot and /botstatus)
179
+ # BOT_MODE=prod
180
+
181
+ # ── Workspace ─────────────────────────────────────────────────
182
+ # Root directory shown in /project picker
183
+ # Default: $HOME
184
+ # WORKSPACE_DIR=/home/username/projects
185
+
186
+ # The project this bot is for: conversations with nothing to restore start
187
+ # there, and threads in it are named without it. Usually set per bot in
188
+ # instances.json, which /newbot does. Absolute, or relative to WORKSPACE_DIR.
189
+ # HOME_PROJECT=my-project
190
+
191
+ # ── Response Behavior ─────────────────────────────────────────
192
+ # "streaming" = live-updating messages, "wait" = send when complete
193
+ STREAMING_MODE=streaming
194
+
195
+ # Debounce interval (ms) for streaming message edits
196
+ STREAMING_DEBOUNCE_MS=500
197
+
198
+ # Max characters per message chunk (Telegram limit is 4096)
199
+ MAX_MESSAGE_LENGTH=4096
200
+
201
+ # ── Telegraph (Instant View) ─────────────────────────────────
202
+ # Off by default. When enabled, long responses (>2500 chars) are also
203
+ # published to telegra.ph and linked as an Instant View page, as are /handoff
204
+ # notes, the full action log, and files sent with /telegraph <path>.
205
+ # Telegraph pages are PUBLIC: anyone with the link can read them, and they
206
+ # can't be deleted. Leave this off if replies may contain anything private.
207
+ # When disabled, long responses are sent in full as chunked messages.
208
+ TELEGRAPH_ENABLED=false
209
+
210
+ # ── Dangerous Mode ────────────────────────────────────────────
211
+ # Auto-approve all Claude tool permissions (use with caution!)
212
+ DANGEROUS_MODE=false
213
+
214
+ # Max iterations for /loop command
215
+ MAX_LOOP_ITERATIONS=5
216
+
217
+ # Auto-restore session on /restartbot and /rebuildbot (true/false)
218
+ # Default: false (shows manual Continue/Resume buttons instead)
219
+ AUTO_RESTORE_SESSION=false
220
+
221
+ # ── PTY turn timeout ──────────────────────────────────────────
222
+ # Absolute per-turn wall-clock cap. The turn is killed with a
223
+ # "turn exceeded" error if it runs longer. Default 7200000 = 2 h.
224
+ # Raise it if intensive turns legitimately hit the cap.
225
+ # CLAUDE_PTY_HARD_TIMEOUT_MS=7200000
226
+
227
+ # ── Question timeout ──────────────────────────────────────────
228
+ # How long a question the agent asks in the chat waits for an answer: the
229
+ # buttons of telecoder_ask_user, a telecoder_poll_user poll, a Claude Code
230
+ # dialog relayed to the chat. After that the turn carries on without one, and
231
+ # the question is closed — buttons taken down, poll stopped — so it doesn't
232
+ # look answerable any more. The turn is paused for the whole wait and new
233
+ # messages queue behind it, so a long timeout is a long stall whenever a
234
+ # question goes unanswered. Permission prompts have their own timeout,
235
+ # PERMISSION_PROMPT_TIMEOUT_MINUTES. Default: 10.
236
+ # QUESTION_TIMEOUT_MINUTES=10
237
+
238
+ # ── Voice Transcription (Groq Whisper) ────────────────────────
239
+ # Requires: a Groq API key
240
+ # Leave empty to disable voice message support
241
+
242
+ # Enable voice transcription + /transcribe (set false to disable)
243
+ TRANSCRIBE_ENABLED=true
244
+
245
+ # Groq API key for Whisper transcription
246
+ # GROQ_API_KEY=gsk_...
247
+
248
+
249
+ # Show transcript text before agent response
250
+ VOICE_SHOW_TRANSCRIPT=true
251
+
252
+ # Max voice file size in MB (Telegram limit ~20MB)
253
+ VOICE_MAX_FILE_SIZE_MB=19
254
+
255
+ # Transcription language (ISO 639-1 code)
256
+ VOICE_LANGUAGE=en
257
+
258
+ # Transcription timeout (ms)
259
+ VOICE_TIMEOUT_MS=60000
260
+
261
+ # /transcribe: send .txt file if transcript exceeds this many characters
262
+ # TRANSCRIBE_FILE_THRESHOLD_CHARS=4000
263
+
264
+ # ── Text-to-Speech ───────────────────────────────────────────
265
+ # Toggle per-chat with /tts command
266
+
267
+ # Enable /tts voice replies (set false to disable)
268
+ TTS_ENABLED=true
269
+
270
+ # TTS provider: "groq" (Groq Orpheus, default) or "openai" (OpenAI TTS)
271
+ # Groq reuses GROQ_API_KEY above; OpenAI requires OPENAI_API_KEY below
272
+ TTS_PROVIDER=groq
273
+
274
+ # OpenAI API key (only needed when TTS_PROVIDER=openai)
275
+ # OPENAI_API_KEY=sk-...
276
+
277
+ # OpenAI TTS model (only used with TTS_PROVIDER=openai):
278
+ # gpt-4o-mini-tts (newest, supports instructions), tts-1, tts-1-hd
279
+ TTS_MODEL=gpt-4o-mini-tts
280
+
281
+ # Voice name:
282
+ # groq voices: autumn, diana, hannah, austin, daniel, troy
283
+ # openai voices: alloy, ash, ballad, coral, echo, fable, nova, onyx, sage, shimmer, verse, marin, cedar
284
+ # Default: troy (groq) or coral (openai)
285
+ TTS_VOICE=troy
286
+
287
+ # Tone instructions (gpt-4o-mini-tts only)
288
+ TTS_INSTRUCTIONS="Speak in a friendly, natural conversational tone."
289
+
290
+ # Speech speed (0.25 to 4.0)
291
+ TTS_SPEED=1.5
292
+
293
+ # Max characters to send to TTS (longer responses skip voice reply)
294
+ TTS_MAX_CHARS=4096
295
+
296
+ # Audio format: opus (recommended for Telegram voice notes), mp3, wav, flac, aac
297
+ TTS_RESPONSE_FORMAT=opus
298
+
299
+ # Enable terminal-style UI by default (animated spinners, tool status)
300
+ TERMINAL_UI_DEFAULT=false
301
+
302
+ # Terminal UI verbose: show full commands, file paths, and URLs without truncation.
303
+ # Also increases session restore previews from 100/200 to 1000 chars.
304
+ # TERMINAL_UI_VERBOSE=true
305
+
306
+ # ── Message Batching ──────────────────────────────────────────
307
+ # Telegram splits a long paste into several messages; combine them back into a
308
+ # single prompt. Only a message of 2000+ characters waits for more parts, so
309
+ # ordinary messages aren't delayed. How long to wait for the next part, in ms;
310
+ # 0 = disabled.
311
+ # MESSAGE_BATCH_TIMEOUT_MS=1500
312
+
313
+ # ── Cancel Behaviour ──────────────────────────────────────────
314
+ # Auto-cancel the running query when a new message arrives, instead of
315
+ # queueing it behind the turn already in flight.
316
+ # CANCEL_ON_NEW_MESSAGE=false
317
+
318
+ # ── Agent Watchdog ────────────────────────────────────────────
319
+ # Auto-abort queries that appear stuck. Set to 0 to disable.
320
+ # Silence timeout: no messages at all from the agent (default: 180000 = 3 min)
321
+ # AGENT_SILENCE_TIMEOUT_MS=180000
322
+ # Stale tool timeout: heartbeats arrive but no meaningful progress (default: 180000 = 3 min)
323
+ # AGENT_STALE_TOOL_TIMEOUT_MS=180000
324
+
325
+ # Update the Telegram bot display name to include the active project (true/false)
326
+ # e.g. "TeleCoder | myproject" — useful when running multiple bot instances
327
+ DYNAMIC_BOT_NAME=false
328
+
329
+ # Fire a parallel Haiku side-call on every user message to derive a 1-4 word
330
+ # topic label, independent of the main agent. Deferral-immune (bypasses
331
+ # settingSources and tools entirely). Only takes effect when DYNAMIC_BOT_NAME
332
+ # is enabled and the per-chat /botname toggle is on. Auth piggybacks on the
333
+ # same Claude executable, so no extra API key is needed under Max.
334
+ AUTO_TOPIC_HAIKU=true
335
+
336
+ # Image Uploads
337
+ # Max image file size in MB (Telegram limit ~20MB for downloads)
338
+ IMAGE_MAX_FILE_SIZE_MB=20
339
+
340
+ # ── Claude Code Router (CCR) Provider ────────────────────────
341
+ # Enable /ccr and /provider toggling between Claude (Max) and CCR (true/false).
342
+ # Redirects the spawned `claude` binary through a local CCR proxy so it can
343
+ # be backed by non-Anthropic models — useful as a fallback when Max runs out.
344
+ # Requires CCR installed and running: https://github.com/musistudio/claude-code-router
345
+ # CCR_ENABLED=false
346
+
347
+ # CCR proxy base URL (where ccr's local HTTP proxy listens).
348
+ # CCR_BASE_URL=http://localhost:3456
349
+
350
+ # CCR's local auth token (see ccr config — usually any non-empty string).
351
+ # CCR_AUTH_TOKEN=
352
+
353
+ # Auto-prompt the user with an inline keyboard when a Max usage-limit
354
+ # throttle is detected. Lets them switch to CCR and retry with one tap.
355
+ # CCR_AUTO_PROMPT_ON_THROTTLE=true
356
+
357
+ # When the CCR proxy isn't reachable, automatically run `ccr start` in the
358
+ # background instead of letting the request hang on ConnectionRefused.
359
+ # CCR_AUTOSTART=false
360
+
361
+ # Path or name of the `ccr` binary used for autostart. Defaults to `ccr`
362
+ # (resolved via PATH). Override if `ccr` lives where systemd can't see it.
363
+ # CCR_BINARY=ccr