telecoder 1.2.0 → 1.3.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 (197) hide show
  1. package/.env.example +142 -130
  2. package/CHANGELOG.md +683 -2
  3. package/README.md +36 -32
  4. package/dist/audio/transcribe.js +0 -9
  5. package/dist/bin/mcp-server.js +46 -61
  6. package/dist/bot/bot.js +162 -181
  7. package/dist/bot/command-catalog.js +263 -0
  8. package/dist/bot/deleted-threads.js +103 -0
  9. package/dist/bot/file-access.js +35 -26
  10. package/dist/bot/handlers/album.handler.js +128 -0
  11. package/dist/bot/handlers/{fork.handler.js → branch.handler.js} +267 -280
  12. package/dist/bot/handlers/command/access.js +1 -1
  13. package/dist/bot/handlers/command/admin.js +86 -110
  14. package/dist/bot/handlers/command/all-view.js +33 -0
  15. package/dist/bot/handlers/command/auto-approve.js +3 -3
  16. package/dist/bot/handlers/command/background.js +37 -0
  17. package/dist/bot/handlers/command/botname.js +76 -0
  18. package/dist/bot/handlers/command/btw.js +20 -69
  19. package/dist/bot/handlers/command/cleanup.js +329 -0
  20. package/dist/bot/handlers/command/model.js +40 -119
  21. package/dist/bot/handlers/command/prefs-scope.js +255 -90
  22. package/dist/bot/handlers/command/project.js +31 -109
  23. package/dist/bot/handlers/command/resume.js +8 -4
  24. package/dist/bot/handlers/command/session.js +74 -213
  25. package/dist/bot/handlers/command/settings.js +92 -447
  26. package/dist/bot/handlers/command/shared.js +32 -35
  27. package/dist/bot/handlers/command/tasks.js +263 -95
  28. package/dist/bot/handlers/command/thread.js +128 -0
  29. package/dist/bot/handlers/command/topic-store.js +14 -53
  30. package/dist/bot/handlers/command/topic.js +8 -61
  31. package/dist/bot/handlers/command/{cost.js → usage.js} +32 -59
  32. package/dist/bot/handlers/command-fallback.js +179 -0
  33. package/dist/bot/handlers/command.handler.js +96 -422
  34. package/dist/bot/handlers/{schedule.handler.js → loop.handler.js} +159 -73
  35. package/dist/bot/handlers/media-fallback.js +12 -7
  36. package/dist/bot/handlers/message/replies.js +10 -87
  37. package/dist/bot/handlers/message/shared.js +9 -31
  38. package/dist/bot/handlers/message/turn-notify.js +15 -49
  39. package/dist/bot/handlers/message/turn-runner.js +18 -103
  40. package/dist/bot/handlers/message.handler.js +59 -52
  41. package/dist/bot/handlers/newbot.handler.js +13 -4
  42. package/dist/bot/handlers/photo.handler.js +88 -129
  43. package/dist/bot/handlers/prompts.handler.js +11 -11
  44. package/dist/bot/handlers/running-note.js +2 -2
  45. package/dist/bot/handlers/session-guard.js +4 -4
  46. package/dist/bot/handlers/suggestion.handler.js +2 -2
  47. package/dist/bot/handlers/tree.handler.js +20 -20
  48. package/dist/bot/handlers/voice.handler.js +23 -85
  49. package/dist/bot/kept-threads.js +51 -0
  50. package/dist/bot/middleware/album-collector.js +69 -0
  51. package/dist/bot/middleware/auth.middleware.js +1 -1
  52. package/dist/bot/middleware/group-mention.middleware.js +11 -5
  53. package/dist/bot/middleware/queued-messages.js +143 -32
  54. package/dist/bot/middleware/stale-filter.js +0 -22
  55. package/dist/build-info.json +5 -5
  56. package/dist/claude/ask-user-form.js +517 -0
  57. package/dist/claude/ask-user.js +94 -26
  58. package/dist/claude/auto-topic-haiku.js +17 -0
  59. package/dist/claude/available-commands.js +22 -19
  60. package/dist/claude/background-hint.js +91 -0
  61. package/dist/claude/{fork-tree.js → branch-tree.js} +9 -9
  62. package/dist/claude/carry-over.js +0 -2
  63. package/dist/claude/ccr-shim.js +12 -10
  64. package/dist/claude/claude-auth.js +6 -10
  65. package/dist/claude/command-parser.js +49 -43
  66. package/dist/claude/cost-overlay-scraper.js +7 -2
  67. package/dist/claude/effort-level.js +5 -0
  68. package/dist/claude/enabled-plugins.js +12 -16
  69. package/dist/claude/in-flight-tracker.js +21 -0
  70. package/dist/claude/mcp-bridge.js +86 -58
  71. package/dist/claude/memory-guard.js +400 -0
  72. package/dist/claude/message-offsets.js +5 -5
  73. package/dist/claude/modal-relay.js +401 -34
  74. package/dist/claude/model-catalog.js +20 -3
  75. package/dist/claude/monitor-relay.js +130 -15
  76. package/dist/claude/native-commands.js +40 -0
  77. package/dist/claude/{pending-forks.js → pending-branches.js} +26 -26
  78. package/dist/claude/permission-gate.js +11 -10
  79. package/dist/claude/permission-mode.js +19 -45
  80. package/dist/claude/prewarm.js +70 -0
  81. package/dist/claude/pty-idle-reaper.js +96 -0
  82. package/dist/claude/pty-provider.js +473 -188
  83. package/dist/claude/pty-spawn-config.js +79 -32
  84. package/dist/claude/pty-watch.js +201 -0
  85. package/dist/claude/request-queue.js +7 -35
  86. package/dist/claude/rewind.js +111 -0
  87. package/dist/claude/scheduled-runner.js +1 -3
  88. package/dist/claude/scheduler.js +6 -2
  89. package/dist/claude/scope-guard.js +8 -3
  90. package/dist/claude/screen-marks.js +83 -0
  91. package/dist/claude/screen-render.js +96 -0
  92. package/dist/claude/session-history.js +4 -2
  93. package/dist/claude/session-jsonl.js +162 -15
  94. package/dist/claude/session-manager.js +29 -8
  95. package/dist/claude/session-move.js +70 -0
  96. package/dist/claude/shell-mode-gate.js +60 -0
  97. package/dist/claude/side-question.js +20 -17
  98. package/dist/claude/stage-images.js +5 -5
  99. package/dist/claude/tasks-overlay-scraper.js +143 -20
  100. package/dist/claude/thread-judge-haiku.js +88 -0
  101. package/dist/claude/tip-scraper.js +3 -4
  102. package/dist/claude/tui-modal.js +272 -27
  103. package/dist/claude/tui-state.js +74 -2
  104. package/dist/claude/turn-end.js +15 -1
  105. package/dist/claude/turn-prose.js +1 -1
  106. package/dist/claude/typed-answer.js +104 -0
  107. package/dist/claude/update-banner-relay.js +1 -1
  108. package/dist/cli/commands/doctor.js +48 -15
  109. package/dist/cli/commands/help.js +11 -2
  110. package/dist/cli/commands/init.js +16 -13
  111. package/dist/cli/commands/service.js +40 -8
  112. package/dist/cli/commands/start.js +10 -0
  113. package/dist/cli/commands/watch.js +322 -0
  114. package/dist/cli/dispatch.js +5 -0
  115. package/dist/cli/init/env-file.js +1 -1
  116. package/dist/cli/init/flow.js +114 -47
  117. package/dist/cli/init/prompter.js +8 -0
  118. package/dist/cli/init/telegram.js +35 -9
  119. package/dist/cli/service/render.js +3 -3
  120. package/dist/config.js +156 -131
  121. package/dist/index.js +107 -31
  122. package/dist/launcher.js +34 -7
  123. package/dist/providers/ccr-introspect.js +1 -8
  124. package/dist/providers/ccr-provider.js +19 -20
  125. package/dist/providers/claude-provider.js +4 -57
  126. package/dist/providers/prefs-sync.js +16 -59
  127. package/dist/providers/provider-router.js +24 -23
  128. package/dist/providers/spawn-settings.js +45 -0
  129. package/dist/providers/user-preferences.js +127 -19
  130. package/dist/restart-when-idle.js +27 -7
  131. package/dist/startup/auto-continue.js +2 -2
  132. package/dist/startup/auto-resume.js +3 -15
  133. package/dist/startup/notices.js +1 -1
  134. package/dist/startup/verify-token.js +4 -4
  135. package/dist/telegram/action-logger.js +3 -165
  136. package/dist/telegram/background-activity-card.js +1 -1
  137. package/dist/telegram/botname-settings.js +71 -125
  138. package/dist/telegram/client-options.js +6 -7
  139. package/dist/telegram/force-reply-tracker.js +55 -16
  140. package/dist/telegram/message-sender.js +92 -360
  141. package/dist/telegram/prompt-label.js +11 -5
  142. package/dist/telegram/streaming-turn.js +5 -7
  143. package/dist/telegram/table-lists.js +56 -0
  144. package/dist/telegram/task-list.js +4 -4
  145. package/dist/telegram/task-tracker.js +45 -126
  146. package/dist/telegram/terminal-renderer.js +1 -5
  147. package/dist/telegram/thread-titles.js +74 -2
  148. package/dist/telegram/threads-setup.js +1 -1
  149. package/dist/utils/admins.js +2 -2
  150. package/dist/utils/bot-icon.js +248 -0
  151. package/dist/utils/bot-token.js +8 -5
  152. package/dist/utils/build-info.js +3 -3
  153. package/dist/utils/caffeinate.js +6 -3
  154. package/dist/utils/claude-env.js +0 -1
  155. package/dist/utils/claude-version.js +2 -2
  156. package/dist/utils/config-home.js +3 -3
  157. package/dist/utils/download.js +41 -15
  158. package/dist/utils/exit-codes.js +11 -0
  159. package/dist/utils/format.js +3 -6
  160. package/dist/utils/home-project.js +1 -1
  161. package/dist/utils/idle-restart.js +1 -1
  162. package/dist/utils/install-mode.js +1 -1
  163. package/dist/utils/instance-config.js +1 -1
  164. package/dist/utils/instances.js +1 -1
  165. package/dist/utils/keyed-settings.js +2 -2
  166. package/dist/utils/memory-pressure.js +60 -0
  167. package/dist/utils/npm-version.js +2 -2
  168. package/dist/utils/resolve-claude-bin.js +13 -24
  169. package/dist/utils/respawn-backoff.js +9 -0
  170. package/dist/utils/stale-launcher.js +1 -1
  171. package/dist/utils/systemd.js +8 -8
  172. package/dist/utils/telegram-proxy.js +72 -0
  173. package/dist/utils/uploads-dir.js +27 -0
  174. package/dist/utils/verbosity.js +8 -8
  175. package/dist/utils/version-check.js +5 -5
  176. package/package.json +3 -4
  177. package/dist/bot/handlers/command/media.js +0 -197
  178. package/dist/bot/handlers/command/streaming-mode.js +0 -16
  179. package/dist/bot/handlers/message/throttle.js +0 -49
  180. package/dist/claude/agent-watchdog.js +0 -162
  181. package/dist/claude/agent.js +0 -1458
  182. package/dist/claude/held-query.js +0 -190
  183. package/dist/claude/mcp-tools.js +0 -354
  184. package/dist/claude/sdk-permission-gate.js +0 -77
  185. package/dist/claude/session-cost.js +0 -41
  186. package/dist/claude/system-prompt.js +0 -162
  187. package/dist/providers/sdk-provider.js +0 -37
  188. package/dist/telegram/telegraph-settings.js +0 -31
  189. package/dist/telegram/telegraph.js +0 -453
  190. package/dist/telegram/terminal-settings.js +0 -25
  191. package/dist/tts/tts-settings.js +0 -62
  192. package/dist/tts/tts.js +0 -245
  193. package/dist/tts/voice-reply.js +0 -78
  194. package/dist/utils/debug-agent.js +0 -117
  195. package/dist/utils/debug-watchdog.js +0 -121
  196. package/dist/utils/project-data-dir.js +0 -33
  197. package/dist/utils/reasoning-summary.js +0 -12
@@ -1,5 +1,5 @@
1
1
  /**
2
- * The npm side of /version and /update, for a package install (see
2
+ * The npm side of /botversion and /botupdate, for a package install (see
3
3
  * utils/install-mode.ts). A checkout asks git instead (utils/version-check.ts).
4
4
  *
5
5
  * `npm view` goes to the registry, so its answer is cached in the state
@@ -115,7 +115,7 @@ export function describeNpmCheck(check, runner) {
115
115
  return `⬆️ v${check.installed} is newer than the latest release (v${check.latest}).`;
116
116
  case 'behind':
117
117
  return runner === 'global'
118
- ? `⚠️ v${check.latest} is out (this is v${check.installed}). /update installs it.`
118
+ ? `⚠️ v${check.latest} is out (this is v${check.installed}). /botupdate installs it.`
119
119
  : `⚠️ v${check.latest} is out (this is v${check.installed}). Update with: ${updateCommand(runner)}`;
120
120
  }
121
121
  }
@@ -1,20 +1,7 @@
1
1
  import { createRequire } from 'node:module';
2
- import { config } from '../config.js';
2
+ import { resolveBin } from './resolve-bin.js';
3
3
  const require = createRequire(import.meta.url);
4
4
  let cachedBundled;
5
- /**
6
- * Resolve the executable path TeleCoder would normally hand to the SDK.
7
- * Mirrors the precedence in `src/claude/agent.ts`:
8
- * 1. If CLAUDE_USE_BUNDLED_EXECUTABLE=false, use CLAUDE_EXECUTABLE_PATH.
9
- * 2. Else, prefer the matching-libc bundled binary.
10
- * 3. Fall back to CLAUDE_EXECUTABLE_PATH (or `claude` on PATH).
11
- */
12
- export function resolveActiveClaudeExecutable() {
13
- if (!config.CLAUDE_USE_BUNDLED_EXECUTABLE) {
14
- return config.CLAUDE_EXECUTABLE_PATH;
15
- }
16
- return resolveBundledClaudeBin() ?? config.CLAUDE_EXECUTABLE_PATH;
17
- }
18
5
  function isMuslLibc() {
19
6
  // On glibc systems, process.report.header includes glibcVersionRuntime.
20
7
  // On musl (Alpine etc.), that field is absent.
@@ -22,7 +9,9 @@ function isMuslLibc() {
22
9
  return !header?.glibcVersionRuntime;
23
10
  }
24
11
  /**
25
- * Resolve the bundled Claude Code binary for the current Linux libc.
12
+ * Resolve the bundled Claude Code binary for the current Linux libc: the
13
+ * `claude` the Haiku side calls run through (side-call-options.ts). The ptys
14
+ * spawn resolvePtyClaudeBin below instead.
26
15
  *
27
16
  * The SDK's own auto-detection (sdk.mjs `N7`) tries the musl package first
28
17
  * and only falls back when require.resolve throws. Both packages are
@@ -49,15 +38,15 @@ export function resolveBundledClaudeBin() {
49
38
  }
50
39
  }
51
40
  /**
52
- * The executable a given transport actually runs, so anything that inspects
53
- * the CLI (its command list, its version) inspects the same build the user's
54
- * turns go through. The two can be different installs at different versions:
55
- * SDK mode prefers the binary bundled in node_modules, PTY mode spawns
56
- * CLAUDE_BIN — the same precedence `/context` already follows.
41
+ * The `claude` the ptys run: CLAUDE_BIN, else the CLI found on PATH with
42
+ * ~/.local/bin searched first (see resolve-bin.ts). A path, not a bare name:
43
+ * node-pty execs the name as given, in the service's PATH, and a systemd user
44
+ * unit gets the bare default without ~/.local/bin, which is where the native
45
+ * installer puts the CLI. That failure is silent in the worst way: execvp
46
+ * writes "No such file or directory" into the pty and exits, so the bot sees a
47
+ * session that produced nothing and reports that the input box never appeared.
57
48
  */
58
- export function resolveClaudeExecutableForMethod(method) {
59
- return method === 'pty'
60
- ? process.env.CLAUDE_BIN || config.CLAUDE_EXECUTABLE_PATH
61
- : resolveActiveClaudeExecutable();
49
+ export function resolvePtyClaudeBin() {
50
+ return process.env.CLAUDE_BIN || resolveBin('claude');
62
51
  }
63
52
  //# sourceMappingURL=resolve-claude-bin.js.map
@@ -16,4 +16,13 @@ export function planRespawn({ aliveMs, previousStreak, delays, streakResetMs, })
16
16
  const streak = aliveMs >= streakResetMs ? 1 : previousStreak + 1;
17
17
  return { streak, delayMs: delays[streak - 1] ?? null };
18
18
  }
19
+ /**
20
+ * How long to wait before respawning an instance that exited because Telegram
21
+ * couldn't be reached. Unlike a crash this never gives up: an outage ends on
22
+ * its own, and the bot should be back when it does.
23
+ */
24
+ export function planOutageRespawn({ aliveMs, previousAttempts, delays, streakResetMs, }) {
25
+ const attempts = aliveMs >= streakResetMs ? 1 : previousAttempts + 1;
26
+ return { attempts, delayMs: delays[Math.min(attempts, delays.length) - 1] };
27
+ }
19
28
  //# sourceMappingURL=respawn-backoff.js.map
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Recognising a launcher that is running code the build has already replaced.
3
3
  *
4
- * /rebuildbot rebuilds every file and then has the launcher respawn its
4
+ * /botrebuild rebuilds every file and then has the launcher respawn its
5
5
  * workers. A respawned worker is a fresh isolate that re-imports dist from
6
6
  * disk, so worker-side changes are live the moment it comes back. The launcher
7
7
  * is the exception: it is the process the workers are threads in, and the copy
@@ -2,14 +2,14 @@
2
2
  * Whether this process is a systemd service — and whether systemd will bring
3
3
  * it back if it exits.
4
4
  *
5
- * This matters because the botctl restart dance cannot work under systemd.
6
- * `spawn(..., { detached: true })` escapes the process group and session but
7
- * not the cgroup, so the helper that would start the replacement stays inside
8
- * the unit. The moment the bot exits, systemd deactivates the unit and (with
9
- * the default `KillMode=control-group`) reaps everything left in it — the
10
- * helper included, before it ever gets to the start half of its job. The bot
11
- * has to exit and let systemd restart it instead, which means first knowing
12
- * whether systemd actually will.
5
+ * This matters because a restart cannot be done by a helper process under
6
+ * systemd. `spawn(..., { detached: true })` escapes the process group and
7
+ * session but not the cgroup, so a helper that would start the replacement
8
+ * stays inside the unit. The moment the bot exits, systemd deactivates the
9
+ * unit and (with the default `KillMode=control-group`) reaps everything left
10
+ * in it — the helper included, before it ever gets to the start half of its
11
+ * job. The bot has to exit and let systemd restart it instead, which means
12
+ * first knowing whether systemd actually will.
13
13
  */
14
14
  import { execFile } from 'child_process';
15
15
  import * as fs from 'fs';
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Finding the proxy for requests to Telegram, and making a request through
3
+ * it, without the bot's config module.
4
+ *
5
+ * The bot itself gives the proxy to grammY (telegram/client-options.ts).
6
+ * `telecoder init` runs before there is a config, and `telecoder doctor` reads
7
+ * the .env itself, so both make their few Bot API calls through here.
8
+ */
9
+ import * as http from 'http';
10
+ import * as https from 'https';
11
+ import { HttpsProxyAgent } from 'https-proxy-agent';
12
+ /** Where the proxy is read from. The first one set wins. */
13
+ export const PROXY_SETTINGS = ['TELEGRAM_PROXY_URL', 'HTTPS_PROXY', 'https_proxy', 'HTTP_PROXY', 'http_proxy'];
14
+ /** The proxy for requests to Telegram, given how to read a setting. */
15
+ export function findProxy(lookup) {
16
+ for (const setting of PROXY_SETTINGS) {
17
+ const url = lookup(setting)?.trim();
18
+ if (url)
19
+ return { url, setting };
20
+ }
21
+ return undefined;
22
+ }
23
+ /**
24
+ * A fetch that goes through `proxyUrl`, an HTTP or HTTPS proxy.
25
+ *
26
+ * Node's own fetch takes no proxy agent, so the request goes out over
27
+ * `http(s).request` with the agent the bot's requests to Telegram use. The
28
+ * answer is read whole before the promise settles, which suits what this is
29
+ * for: Bot API calls, a few KB each way. Redirects aren't followed. A request
30
+ * that is aborted rejects with the signal's reason, as fetch does.
31
+ */
32
+ export function fetchThroughProxy(proxyUrl) {
33
+ return async (url, init) => {
34
+ const { signal, ...rest } = init;
35
+ // Request works out the body and its content-type as fetch would, a
36
+ // FormData's multipart boundary included.
37
+ const request = new Request(url, rest);
38
+ const body = request.body ? Buffer.from(await request.arrayBuffer()) : undefined;
39
+ const headers = Object.fromEntries(request.headers);
40
+ if (body)
41
+ headers['content-length'] = String(body.length);
42
+ signal?.throwIfAborted();
43
+ const agent = new HttpsProxyAgent(proxyUrl);
44
+ return new Promise((resolve, reject) => {
45
+ const fail = (error) => reject(signal?.aborted ? signal.reason ?? error : error);
46
+ const send = new URL(url).protocol === 'https:' ? https.request : http.request;
47
+ const req = send(url, { method: request.method, headers, agent, signal: signal ?? undefined }, (res) => {
48
+ const chunks = [];
49
+ res.on('data', (chunk) => chunks.push(chunk));
50
+ res.on('error', fail);
51
+ res.on('end', () => {
52
+ const answered = new Headers();
53
+ for (const [name, value] of Object.entries(res.headers)) {
54
+ for (const one of Array.isArray(value) ? value : value === undefined ? [] : [value])
55
+ answered.append(name, one);
56
+ }
57
+ const text = Buffer.concat(chunks);
58
+ try {
59
+ // A status that carries no body (204, 304) refuses even an empty one.
60
+ resolve(new Response(text.length ? text : null, { status: res.statusCode, headers: answered }));
61
+ }
62
+ catch (error) {
63
+ reject(error);
64
+ }
65
+ });
66
+ });
67
+ req.on('error', fail);
68
+ req.end(body);
69
+ });
70
+ };
71
+ }
72
+ //# sourceMappingURL=telegram-proxy.js.map
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Where files sent in a chat are saved for Claude to read:
3
+ * `~/.telecoder/uploads/<project name>/`.
4
+ *
5
+ * They used to go to `<project>/.telecoder/uploads/`, which left a folder in
6
+ * every project someone had sent a photo to, and needed a `.gitignore` of its
7
+ * own so the photos stayed out of commits. The bot's state directory has
8
+ * neither problem. Claude still gets the absolute path in the prompt, so where
9
+ * the file lives makes no difference to it — except that the scope guard
10
+ * treats the rest of `~/.telecoder` as bot state and prompts on every read;
11
+ * `uploads/` is the one subfolder it exempts, since what's in it is the user's
12
+ * own files (see claude/scope-guard.ts).
13
+ */
14
+ import * as fs from 'fs';
15
+ import * as path from 'path';
16
+ import { getStateDir } from './json-store.js';
17
+ /** The folder every upload lives under. */
18
+ export function getUploadsRoot() {
19
+ return path.join(getStateDir(), 'uploads');
20
+ }
21
+ /** Create the uploads folder for a project if needed, and return its path. */
22
+ export function ensureUploadsDir(projectDir) {
23
+ const dir = path.join(getUploadsRoot(), path.basename(projectDir));
24
+ fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
25
+ return dir;
26
+ }
27
+ //# sourceMappingURL=uploads-dir.js.map
@@ -15,7 +15,7 @@ export const VERBOSITY_INFO = [
15
15
  {
16
16
  id: 'quiet',
17
17
  label: '🔇 Quiet',
18
- description: 'Answer only. Suppresses completion pings and the usage footer; keeps compaction warnings.',
18
+ description: 'Answer only. Suppresses completion pings and the usage line; keeps compaction warnings.',
19
19
  },
20
20
  {
21
21
  id: 'normal',
@@ -25,12 +25,12 @@ export const VERBOSITY_INFO = [
25
25
  {
26
26
  id: 'verbose',
27
27
  label: '🔊 Verbose',
28
- description: 'Adds the per-turn usage footer, untruncated tool inputs, and a consolidated action log that streams tool results and diffs live, then collapses to a Telegraph link at the end of each turn.',
28
+ description: 'Adds the per-turn usage line, untruncated tool inputs, and a consolidated action log that streams tool results and diffs live and stays in the chat at the end of each turn.',
29
29
  },
30
30
  {
31
31
  id: 'debug',
32
32
  label: '🐛 Debug',
33
- description: 'Verbose mode with extended limits: longer tool result previews (40 lines) and diffs (50 lines) in the consolidated action log. Same end-of-turn collapse to a Telegraph link. Reserved for upcoming thinking blocks, hook events, and SDK internals.',
33
+ description: 'Verbose mode with extended limits: longer tool result previews (40 lines) and diffs (50 lines) in the consolidated action log. The log stays in the chat at the end of the turn. Reserved for upcoming thinking blocks and hook events.',
34
34
  },
35
35
  ];
36
36
  function defaultsForLevel(level) {
@@ -39,7 +39,7 @@ function defaultsForLevel(level) {
39
39
  return {
40
40
  showUsageFooter: false,
41
41
  notifyCompaction: true,
42
- terminalUiVerbose: false,
42
+ fullToolInputs: false,
43
43
  sendCompletionPing: false,
44
44
  showToolResults: false,
45
45
  toolResultMaxLines: 0,
@@ -52,7 +52,7 @@ function defaultsForLevel(level) {
52
52
  return {
53
53
  showUsageFooter: false,
54
54
  notifyCompaction: true,
55
- terminalUiVerbose: false,
55
+ fullToolInputs: false,
56
56
  sendCompletionPing: true,
57
57
  showToolResults: false,
58
58
  toolResultMaxLines: 0,
@@ -65,7 +65,7 @@ function defaultsForLevel(level) {
65
65
  return {
66
66
  showUsageFooter: true,
67
67
  notifyCompaction: true,
68
- terminalUiVerbose: true,
68
+ fullToolInputs: true,
69
69
  sendCompletionPing: true,
70
70
  showToolResults: true,
71
71
  toolResultMaxLines: 20,
@@ -78,7 +78,7 @@ function defaultsForLevel(level) {
78
78
  return {
79
79
  showUsageFooter: true,
80
80
  notifyCompaction: true,
81
- terminalUiVerbose: true,
81
+ fullToolInputs: true,
82
82
  sendCompletionPing: true,
83
83
  showToolResults: true,
84
84
  toolResultMaxLines: 40,
@@ -105,7 +105,7 @@ export function resolveVerbosityFlags(chatId) {
105
105
  return {
106
106
  showUsageFooter: explicitFlags.CONTEXT_SHOW_USAGE ? config.CONTEXT_SHOW_USAGE : tier.showUsageFooter,
107
107
  notifyCompaction: explicitFlags.CONTEXT_NOTIFY_COMPACTION ? config.CONTEXT_NOTIFY_COMPACTION : tier.notifyCompaction,
108
- terminalUiVerbose: explicitFlags.TERMINAL_UI_VERBOSE ? config.TERMINAL_UI_VERBOSE : tier.terminalUiVerbose,
108
+ fullToolInputs: explicitFlags.FULL_TOOL_INPUTS ? config.FULL_TOOL_INPUTS : tier.fullToolInputs,
109
109
  sendCompletionPing: tier.sendCompletionPing,
110
110
  showToolResults: tier.showToolResults,
111
111
  toolResultMaxLines: tier.toolResultMaxLines,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Whether the build this process loaded is the latest one, for /version.
2
+ * Whether the build this process loaded is the latest one, for /botversion.
3
3
  *
4
4
  * Same code or not comes from comparing hashes (scripts/source-hash.mjs), never
5
5
  * from commits. Git only describes a difference once there is one, and says how
@@ -132,7 +132,7 @@ export function describeCodeCheck(check) {
132
132
  case 'current':
133
133
  return '✅ This is the current code.';
134
134
  case 'not-loaded':
135
- return '⚠️ A newer build is on disk but not loaded. /restartbot picks it up.';
135
+ return '⚠️ A newer build is on disk but not loaded. /botrestart picks it up.';
136
136
  case 'changed': {
137
137
  const { commits, uncommitted } = check;
138
138
  const parts = [
@@ -140,9 +140,9 @@ export function describeCodeCheck(check) {
140
140
  ...(uncommitted ? ['uncommitted changes'] : []),
141
141
  ];
142
142
  if (parts.length === 0)
143
- return '⚠️ The code here has changed since this build. /rebuildbot picks it up.';
143
+ return '⚠️ The code here has changed since this build. /botrebuild picks it up.';
144
144
  const them = commits === 1 && !uncommitted ? 'it' : 'them';
145
- return `⚠️ The code here has ${parts.join(' and ')}. /rebuildbot picks ${them} up.`;
145
+ return `⚠️ The code here has ${parts.join(' and ')}. /botrebuild picks ${them} up.`;
146
146
  }
147
147
  }
148
148
  }
@@ -158,7 +158,7 @@ export function describeRemoteCheck(check) {
158
158
  case 'ahead':
159
159
  return `⬆️ This checkout is ${plural(check.commits, 'commit')} ahead of ${check.ref}.`;
160
160
  case 'behind':
161
- return `⚠️ ${check.ref} has commits this checkout doesn't. git pull, then /rebuildbot.`;
161
+ return `⚠️ ${check.ref} has commits this checkout doesn't. git pull, then /botrebuild.`;
162
162
  case 'diverged':
163
163
  return `⚠️ This checkout and ${check.ref} have diverged.`;
164
164
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "telecoder",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Claude Code from Telegram: a self-hosted bot that drives the Claude Code agent on your own machine",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -41,10 +41,10 @@
41
41
  "homepage": "https://telecoder.dev",
42
42
  "repository": {
43
43
  "type": "git",
44
- "url": "git+https://github.com/gitaarik/telecoder.git"
44
+ "url": "git+https://github.com/telecoderbot/telecoder.git"
45
45
  },
46
46
  "bugs": {
47
- "url": "https://github.com/gitaarik/telecoder/issues"
47
+ "url": "https://github.com/telecoderbot/telecoder/issues"
48
48
  },
49
49
  "engines": {
50
50
  "node": ">=22"
@@ -64,7 +64,6 @@
64
64
  "mdast-util-gfm": "^3.1.0",
65
65
  "micromark-extension-gfm": "^3.0.0",
66
66
  "node-pty": "^1.1.0",
67
- "openai": "^6.16.0",
68
67
  "zod": "^4.3.6"
69
68
  },
70
69
  "devDependencies": {
@@ -1,197 +0,0 @@
1
- /**
2
- * /transcribe — turning an uploaded voice note or audio file into text, behind
3
- * the same download-limit and staleness guards as the other upload handlers.
4
- */
5
- import { InputFile } from 'grammy';
6
- import * as fs from 'fs';
7
- import * as os from 'os';
8
- import * as path from 'path';
9
- import { config } from '../../../config.js';
10
- import { messageSender } from '../../../telegram/message-sender.js';
11
- import { EntityText } from '../../../telegram/entities.js';
12
- import { replyFormatted } from '../../../telegram/send.js';
13
- import { isDuplicate, markProcessed } from '../../../telegram/deduplication.js';
14
- import { isStaleMessage } from '../../middleware/stale-filter.js';
15
- import { replyBareAudio, exceedsDownloadLimit, replyTooLargeToFetch } from '../media-fallback.js';
16
- import { transcribeFile, downloadTelegramAudio } from '../../../audio/transcribe.js';
17
- import { sanitizeError, sanitizePath } from '../../../utils/sanitize.js';
18
- import { replyFeatureDisabled } from './shared.js';
19
- // ── /transcribe command ────────────────────────────────────────────
20
- /**
21
- * Send a transcript as text (short) or .txt document (long).
22
- * Exported so voice.handler.ts can reuse it for the ForceReply path.
23
- */
24
- export async function sendTranscriptResult(ctx, transcript) {
25
- if (transcript.length <= config.TRANSCRIBE_FILE_THRESHOLD_CHARS) {
26
- await messageSender.sendMessage(ctx, transcript);
27
- }
28
- else {
29
- const tmpPath = path.join(os.tmpdir(), `telecoder_transcript_${Date.now()}.txt`);
30
- try {
31
- fs.writeFileSync(tmpPath, transcript, { encoding: 'utf-8', mode: 0o600 });
32
- const inputFile = new InputFile(fs.readFileSync(tmpPath), 'transcript.txt');
33
- await ctx.replyWithDocument(inputFile, {
34
- caption: `🎤 Transcript (${transcript.length} chars)`,
35
- });
36
- }
37
- finally {
38
- try {
39
- if (fs.existsSync(tmpPath))
40
- fs.unlinkSync(tmpPath);
41
- }
42
- catch (e) {
43
- console.warn(`[transcribe] Cleanup failed for ${sanitizePath(tmpPath)}:`, sanitizeError(e));
44
- }
45
- }
46
- }
47
- }
48
- /**
49
- * Download a Telegram file by file_id → transcribe → send result.
50
- * Shared helper for reply-to and ForceReply paths.
51
- */
52
- async function transcribeAndSend(ctx, fileId, mimeHint, fileSizeBytes) {
53
- if (!config.TRANSCRIBE_ENABLED) {
54
- await replyFeatureDisabled(ctx, 'Transcribe');
55
- return;
56
- }
57
- const chatId = ctx.chat?.id;
58
- if (!chatId)
59
- return;
60
- // Check before the ack, not after: getFile rejects anything over Telegram's
61
- // download ceiling, and the bare 400 that comes back reads like a bot fault.
62
- if (exceedsDownloadLimit(fileSizeBytes)) {
63
- await replyTooLargeToFetch(ctx, 'Audio file', fileSizeBytes);
64
- return;
65
- }
66
- const ackMsg = await ctx.reply('🎤 Transcribing...');
67
- let tempFilePath = null;
68
- try {
69
- const file = await ctx.api.getFile(fileId);
70
- if (!file.file_path)
71
- throw new Error('Telegram did not return file_path.');
72
- const ext = mimeHint?.includes('ogg') ? '.ogg'
73
- : mimeHint?.includes('mp3') ? '.mp3'
74
- : mimeHint?.includes('wav') ? '.wav'
75
- : mimeHint?.includes('mp4') ? '.m4a'
76
- : '.oga';
77
- tempFilePath = path.join(os.tmpdir(), `telecoder_transcribe_${Date.now()}${ext}`);
78
- await downloadTelegramAudio(config.TELEGRAM_BOT_TOKEN, file.file_path, tempFilePath);
79
- const buf = fs.readFileSync(tempFilePath);
80
- if (!buf.length)
81
- throw new Error('Downloaded empty audio file.');
82
- const transcript = await transcribeFile(tempFilePath);
83
- // Remove ack
84
- try {
85
- await ctx.api.deleteMessage(chatId, ackMsg.message_id);
86
- }
87
- catch (e) {
88
- console.debug('[Transcribe] Failed to delete ack message:', e instanceof Error ? e.message : e);
89
- }
90
- await sendTranscriptResult(ctx, transcript);
91
- }
92
- catch (error) {
93
- const errorMessage = error instanceof Error ? error.message : 'Unknown error';
94
- console.error('[Transcribe] Error:', sanitizeError(error));
95
- try {
96
- await ctx.api.editMessageText(chatId, ackMsg.message_id, `❌ ${errorMessage}`);
97
- }
98
- catch {
99
- await ctx.reply(`❌ Transcription error: ${errorMessage}`);
100
- }
101
- }
102
- finally {
103
- if (tempFilePath && fs.existsSync(tempFilePath)) {
104
- try {
105
- fs.unlinkSync(tempFilePath);
106
- }
107
- catch (e) {
108
- console.warn(`[Transcribe] Cleanup failed for ${sanitizePath(tempFilePath)}:`, sanitizeError(e));
109
- }
110
- }
111
- }
112
- }
113
- export async function handleTranscribe(ctx) {
114
- if (!config.TRANSCRIBE_ENABLED) {
115
- await replyFeatureDisabled(ctx, 'Transcribe');
116
- return;
117
- }
118
- // Path A: reply to a voice/audio/audio-document message
119
- const reply = ctx.message?.reply_to_message;
120
- if (reply) {
121
- const voice = reply.voice;
122
- const audio = reply.audio;
123
- const doc = reply.document;
124
- const fileId = voice?.file_id
125
- || audio?.file_id
126
- || (doc?.mime_type?.startsWith('audio/') ? doc.file_id : null);
127
- const mime = voice?.mime_type || audio?.mime_type || doc?.mime_type;
128
- if (fileId) {
129
- await transcribeAndSend(ctx, fileId, mime);
130
- return;
131
- }
132
- }
133
- // Path B: no audio attached — send ForceReply prompt
134
- await replyFormatted(ctx, new EntityText().add('🎤 ').bold('Transcribe Audio').add('\n\n').italic('Send a voice note or audio file:').build(), {
135
- reply_markup: {
136
- force_reply: true,
137
- input_field_placeholder: 'Send a voice note or audio file',
138
- selective: true,
139
- },
140
- });
141
- }
142
- /**
143
- * Handle audio messages (message:audio) sent as reply to the Transcribe ForceReply.
144
- */
145
- export async function handleTranscribeAudio(ctx) {
146
- const audio = ctx.message?.audio;
147
- const messageId = ctx.message?.message_id;
148
- const messageDate = ctx.message?.date;
149
- if (!audio || !messageId || !messageDate)
150
- return;
151
- // Guard before replying to anything. This handler used to return silently on
152
- // every path, so it never needed these; now that it answers, a restart would
153
- // otherwise respond to every audio file sent while the bot was down.
154
- if (isStaleMessage(messageDate)) {
155
- console.log(`[Transcribe] Ignoring stale audio ${messageId}`);
156
- return;
157
- }
158
- if (isDuplicate(messageId)) {
159
- console.log(`[Transcribe] Ignoring duplicate audio ${messageId}`);
160
- return;
161
- }
162
- markProcessed(messageId);
163
- if (!config.TRANSCRIBE_ENABLED) {
164
- await replyFeatureDisabled(ctx, 'Transcribe');
165
- return;
166
- }
167
- // Transcription is opt-in: the file has to be a reply to the /transcribe
168
- // ForceReply prompt. A bare audio upload isn't a transcribe request, but it
169
- // isn't nothing either — tell the user how to ask for one.
170
- const replyTo = ctx.message?.reply_to_message;
171
- const replyText = replyTo?.from?.is_bot ? (replyTo.text || '') : '';
172
- if (!replyText.includes('Transcribe Audio')) {
173
- await replyBareAudio(ctx, audio.file_size);
174
- return;
175
- }
176
- await transcribeAndSend(ctx, audio.file_id, audio.mime_type, audio.file_size);
177
- }
178
- /**
179
- * Handle document messages with audio MIME sent as reply to the Transcribe ForceReply.
180
- */
181
- export async function handleTranscribeDocument(ctx) {
182
- if (!config.TRANSCRIBE_ENABLED) {
183
- await replyFeatureDisabled(ctx, 'Transcribe');
184
- return;
185
- }
186
- const replyTo = ctx.message?.reply_to_message;
187
- if (!replyTo || !replyTo.from?.is_bot)
188
- return;
189
- const replyText = replyTo.text || '';
190
- if (!replyText.includes('Transcribe Audio'))
191
- return;
192
- const doc = ctx.message?.document;
193
- if (!doc || !doc.mime_type?.startsWith('audio/'))
194
- return;
195
- await transcribeAndSend(ctx, doc.file_id, doc.mime_type, doc.file_size);
196
- }
197
- //# sourceMappingURL=media.js.map
@@ -1,16 +0,0 @@
1
- /**
2
- * Runtime override for the streaming/wait response mode.
3
- *
4
- * Its own module because it is process-global state read from several command
5
- * domains and from message.handler — keeping it in any one domain module would
6
- * make the others import that domain just to read a boolean.
7
- */
8
- import { config } from '../../../config.js';
9
- let runtimeStreamingMode = config.STREAMING_MODE;
10
- export function getStreamingMode() {
11
- return runtimeStreamingMode;
12
- }
13
- export function setStreamingMode(mode) {
14
- runtimeStreamingMode = mode;
15
- }
16
- //# sourceMappingURL=streaming-mode.js.map
@@ -1,49 +0,0 @@
1
- /**
2
- * CCR throttle state and the "switch & retry" prompt.
3
- *
4
- * Deliberately holds no reference to the turn runner: the retry *callback*
5
- * lives in turn-runner.ts alongside the other turn entry points, so this
6
- * module stays a leaf that the runner can import without a cycle.
7
- */
8
- import { config } from '../../../config.js';
9
- import { EntityText } from '../../../telegram/entities.js';
10
- import { replyFormatted } from '../../../telegram/send.js';
11
- // Last user prompt that hit a throttle, keyed by sessionKey. Used by the
12
- // "Switch & Retry" callback so the bot can replay the prompt under CCR
13
- // without the user having to retype it. Cleared on consumption or on a
14
- // new successful query.
15
- export const lastThrottledPrompt = new Map();
16
- export function formatResetIn(resetAt) {
17
- if (!resetAt)
18
- return '';
19
- const ms = resetAt - Date.now();
20
- if (ms <= 0)
21
- return '';
22
- const mins = Math.round(ms / 60_000);
23
- if (mins < 60)
24
- return ` Resets in ~${mins} min.`;
25
- const hours = Math.floor(mins / 60);
26
- const remainder = mins % 60;
27
- return ` Resets in ~${hours}h${remainder ? ` ${remainder}m` : ''}.`;
28
- }
29
- export async function postThrottlePrompt(ctx, sessionKey, message, throttle) {
30
- if (!config.CCR_ENABLED || !config.CCR_AUTO_PROMPT_ON_THROTTLE)
31
- return;
32
- lastThrottledPrompt.set(sessionKey, message);
33
- const resetTxt = formatResetIn(throttle.resetAt);
34
- await replyFormatted(ctx, new EntityText()
35
- .add('⚠️ ').bold('Max usage limit reached.').add(resetTxt).newline(2)
36
- .add('Route your message through Claude Code Router (CCR) instead?').newline()
37
- .italic('The switch is sticky — use /ccr to flip back.')
38
- .build(), {
39
- reply_markup: {
40
- inline_keyboard: [
41
- [
42
- { text: '🔌 Switch to CCR & retry', callback_data: 'ccr_throttle:switch' },
43
- { text: 'Cancel', callback_data: 'ccr_throttle:cancel' },
44
- ],
45
- ],
46
- },
47
- });
48
- }
49
- //# sourceMappingURL=throttle.js.map