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
@@ -7,15 +7,14 @@ import { messageSender } from '../../telegram/message-sender.js';
7
7
  import { closeTurn, relayCatchUpIfMissed } from './message/turn-notify.js';
8
8
  import { isDuplicate, markProcessed } from '../../telegram/deduplication.js';
9
9
  import { isStaleMessage } from '../middleware/stale-filter.js';
10
- import { queueRequest, setAbortController, } from '../../claude/request-queue.js';
11
- import { getStreamingMode } from './command.handler.js';
12
- import { maybeSendVoiceReply } from '../../tts/voice-reply.js';
10
+ import { queueRequest } from '../../claude/request-queue.js';
13
11
  import { transcribeFile } from '../../audio/transcribe.js';
14
- import { sendTranscriptResult } from './command.handler.js';
15
12
  import { downloadFileSecure, getTelegramFileUrl } from '../../utils/download.js';
13
+ import { telegramProxyUrl } from '../../telegram/client-options.js';
16
14
  import { sanitizeError, sanitizePath } from '../../utils/sanitize.js';
17
15
  import { getSessionKeyFromCtx } from '../../utils/session-key.js';
18
16
  import { requireSession } from './session-guard.js';
17
+ import { replyFeatureDisabled, replyVoiceNotSetUp } from './command/shared.js';
19
18
  import { progressCallbacks, withStreamingTurn } from '../../telegram/streaming-turn.js';
20
19
  export async function handleVoice(ctx) {
21
20
  const keyInfo = getSessionKeyFromCtx(ctx);
@@ -35,14 +34,16 @@ export async function handleVoice(ctx) {
35
34
  return;
36
35
  }
37
36
  markProcessed(messageId);
38
- // If this is a reply to the bot's "Transcribe Audio" ForceReply, route to transcribe-only flow
39
- const replyTo = ctx.message?.reply_to_message;
40
- if (replyTo && replyTo.from?.is_bot) {
41
- const replyText = replyTo.text || '';
42
- if (replyText.includes('Transcribe Audio')) {
43
- await handleTranscribeOnly(ctx, chatId, messageId, voice);
44
- return;
45
- }
37
+ // TRANSCRIBE_ENABLED=false turns voice notes off.
38
+ if (!config.TRANSCRIBE_ENABLED) {
39
+ await replyFeatureDisabled(ctx, 'Voice transcription');
40
+ return;
41
+ }
42
+ // No Groq key, the common state after declining voice in `telecoder init`:
43
+ // say how to turn it on, instead of an ack and then a raw "not configured" error.
44
+ if (!config.GROQ_API_KEY) {
45
+ await replyVoiceNotSetUp(ctx);
46
+ return;
46
47
  }
47
48
  // Check session — fall back to disk if the bot restarted recently.
48
49
  const session = await requireSession(ctx, sessionKey);
@@ -65,10 +66,11 @@ export async function handleVoice(ctx) {
65
66
  throw new Error('Telegram did not provide a file path.');
66
67
  }
67
68
  const fileUrl = getTelegramFileUrl(config.TELEGRAM_BOT_TOKEN, file.file_path);
68
- // In-process fetch: the token-bearing URL never reaches a process argument list.
69
+ // Fetched in this process: the token-bearing URL never reaches a process
70
+ // argument list. Through the proxy, when the bot reaches Telegram by one.
69
71
  const ext = voice.mime_type?.includes('ogg') ? '.ogg' : '.oga';
70
72
  tempFilePath = path.join(os.tmpdir(), `telecoder_voice_${messageId}${ext}`);
71
- await downloadFileSecure(fileUrl, tempFilePath);
73
+ await downloadFileSecure(fileUrl, tempFilePath, { proxyUrl: telegramProxyUrl() });
72
74
  const audioBuffer = fs.readFileSync(tempFilePath);
73
75
  if (!audioBuffer.length) {
74
76
  throw new Error('Downloaded empty voice file.');
@@ -104,29 +106,16 @@ export async function handleVoice(ctx) {
104
106
  }
105
107
  // Feed transcript into agent
106
108
  await queueRequest(sessionKey, transcript, async () => {
107
- if (getStreamingMode() === 'streaming') {
108
- await withStreamingTurn(ctx, sessionKey, transcript, async (abortController) => {
109
- const response = await sendToAgent(sessionKey, transcript, {
110
- ...progressCallbacks(ctx),
111
- abortController,
112
- telegramCtx: ctx,
113
- });
114
- await messageSender.finishStreaming(ctx, response.text);
115
- await relayCatchUpIfMissed(ctx, sessionKey, response.text || '');
116
- await maybeSendVoiceReply(ctx, response.text);
117
- await closeTurn(ctx, sessionKey, response, transcript);
109
+ await withStreamingTurn(ctx, sessionKey, transcript, async (abortController) => {
110
+ const response = await sendToAgent(sessionKey, transcript, {
111
+ ...progressCallbacks(ctx),
112
+ abortController,
113
+ telegramCtx: ctx,
118
114
  });
119
- }
120
- else {
121
- await ctx.replyWithChatAction('typing');
122
- const abortController = new AbortController();
123
- setAbortController(sessionKey, abortController);
124
- const response = await sendToAgent(sessionKey, transcript, { abortController, telegramCtx: ctx });
125
- await messageSender.sendMessage(ctx, response.text);
115
+ await messageSender.finishStreaming(ctx, response.text);
126
116
  await relayCatchUpIfMissed(ctx, sessionKey, response.text || '');
127
- await maybeSendVoiceReply(ctx, response.text);
128
117
  await closeTurn(ctx, sessionKey, response, transcript);
129
- }
118
+ });
130
119
  });
131
120
  }
132
121
  catch (error) {
@@ -155,55 +144,4 @@ export async function handleVoice(ctx) {
155
144
  }
156
145
  }
157
146
  }
158
- /**
159
- * Transcribe-only flow: voice note sent as reply to "Transcribe Audio" ForceReply.
160
- * Does NOT send transcript to the Claude agent.
161
- */
162
- async function handleTranscribeOnly(ctx, chatId, messageId, voice) {
163
- const ackMsg = await ctx.reply('🎤 Transcribing...');
164
- let tempFilePath = null;
165
- try {
166
- const file = await ctx.api.getFile(voice.file_id);
167
- if (!file.file_path) {
168
- throw new Error('Telegram did not provide a file path.');
169
- }
170
- const fileUrl = getTelegramFileUrl(config.TELEGRAM_BOT_TOKEN, file.file_path);
171
- const ext = voice.mime_type?.includes('ogg') ? '.ogg' : '.oga';
172
- tempFilePath = path.join(os.tmpdir(), `telecoder_transcribe_${messageId}${ext}`);
173
- await downloadFileSecure(fileUrl, tempFilePath);
174
- const audioBuffer = fs.readFileSync(tempFilePath);
175
- if (!audioBuffer.length) {
176
- throw new Error('Downloaded empty voice file.');
177
- }
178
- const transcript = await transcribeFile(tempFilePath);
179
- // Remove ack
180
- try {
181
- await ctx.api.deleteMessage(chatId, ackMsg.message_id);
182
- }
183
- catch (e) {
184
- console.debug('[Transcribe] Failed to delete ack message:', e instanceof Error ? e.message : e);
185
- }
186
- await sendTranscriptResult(ctx, transcript);
187
- }
188
- catch (error) {
189
- const errorMessage = sanitizeError(error);
190
- console.error('[Transcribe] Voice ForceReply error:', errorMessage);
191
- try {
192
- await ctx.api.editMessageText(chatId, ackMsg.message_id, `❌ ${errorMessage}`);
193
- }
194
- catch {
195
- await ctx.reply(`❌ Transcription error: ${errorMessage}`);
196
- }
197
- }
198
- finally {
199
- if (tempFilePath && fs.existsSync(tempFilePath)) {
200
- try {
201
- fs.unlinkSync(tempFilePath);
202
- }
203
- catch (e) {
204
- console.warn(`[Transcribe] Cleanup failed for ${sanitizePath(tempFilePath)}:`, sanitizeError(e));
205
- }
206
- }
207
- }
208
- }
209
147
  //# sourceMappingURL=voice.handler.js.map
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Threads marked with /threadkeep, which /threadcleanup leaves alone.
3
+ *
4
+ * A thread is kept until /threadkeep off, or until it's deleted anyway (by
5
+ * /threaddelete, or by hand): a deleted thread has nothing left to keep.
6
+ * Kept per bot, since each bot has its own threads.
7
+ */
8
+ import * as path from 'path';
9
+ import { z } from 'zod';
10
+ import { BOT_ID } from '../config.js';
11
+ import { ensureStateDir, getStateDir, readJsonFile, writeJsonFile } from '../utils/json-store.js';
12
+ const fileSchema = z.object({ threads: z.array(z.string()) });
13
+ /** What goes in front of a kept thread's name, where the bot names it. */
14
+ export const KEEP_MARK = '📌 ';
15
+ let keptSet;
16
+ function stateFile() {
17
+ return path.join(getStateDir(), `kept-threads-${BOT_ID}.json`);
18
+ }
19
+ function kept() {
20
+ keptSet ??= new Set(readJsonFile(stateFile(), fileSchema, 'KeptThreads')?.threads ?? []);
21
+ return keptSet;
22
+ }
23
+ function save() {
24
+ ensureStateDir(getStateDir(), 'KeptThreads');
25
+ writeJsonFile(stateFile(), { threads: [...kept()] }, 'KeptThreads');
26
+ }
27
+ export function isThreadKept(sessionKey) {
28
+ return kept().has(sessionKey);
29
+ }
30
+ /** Mark or unmark a thread. Whether that changed anything. */
31
+ export function setThreadKept(sessionKey, keep) {
32
+ if (kept().has(sessionKey) === keep)
33
+ return false;
34
+ if (keep)
35
+ kept().add(sessionKey);
36
+ else
37
+ kept().delete(sessionKey);
38
+ save();
39
+ return true;
40
+ }
41
+ /** Drop the mark of a thread that no longer exists. */
42
+ export function forgetKeptThread(sessionKey) {
43
+ if (kept().delete(sessionKey))
44
+ save();
45
+ }
46
+ /** Test seam: forget every mark, on disk too. */
47
+ export function resetKeptThreadsForTest() {
48
+ keptSet = new Set();
49
+ save();
50
+ }
51
+ //# sourceMappingURL=kept-threads.js.map
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Albums: files sent together, gathered into one message.
3
+ *
4
+ * Telegram has no message holding several files. Files picked together and sent
5
+ * with "Group items" on arrive one message each, sharing a `media_group_id`,
6
+ * with the caption on just one of them. Taken one at a time, each became a turn
7
+ * of its own: Claude answered once per file, never knowing the others came with
8
+ * it, and all but one went without the caption.
9
+ *
10
+ * So the parts are gathered here into the first to arrive, which carries the
11
+ * others in `album` and goes on alone. handlers/album.handler.ts sends the lot
12
+ * as one prompt. The others leave the stream.
13
+ *
14
+ * The caption moves onto that first part when another has it. The group
15
+ * mention gate reads it to decide whether a message is for the bot, and this
16
+ * runs ahead of the gate, since a part without the caption would fail it on its
17
+ * own. It runs behind auth, so only an allowed sender's parts are gathered, and
18
+ * ahead of sequentialize, like the message batcher: the parts would otherwise
19
+ * wait there behind the first one's turn.
20
+ *
21
+ * The parts ride on the message itself, so they stay with a message set aside
22
+ * and sent later, which comes back through here and goes straight on.
23
+ */
24
+ /**
25
+ * How long after the last part an album is taken as complete. A client uploads
26
+ * every file before it sends any of the messages, so the parts arrive within
27
+ * moments of each other.
28
+ */
29
+ export const ALBUM_WAIT_MS = 1000;
30
+ const albums = new Map();
31
+ /** The other parts of the album this message leads, or undefined when it leads none. */
32
+ export function albumParts(message) {
33
+ return message?.album;
34
+ }
35
+ export function createAlbumMiddleware() {
36
+ return async (ctx, next) => {
37
+ const message = ctx.message;
38
+ const groupId = message?.media_group_id;
39
+ if (!message || !groupId || albumParts(message) || !ctx.chat)
40
+ return next();
41
+ const key = `${ctx.chat.id}:${groupId}`;
42
+ const existing = albums.get(key);
43
+ if (existing) {
44
+ existing.parts.push(message);
45
+ existing.timer.refresh();
46
+ return; // absorbed into the album's first part
47
+ }
48
+ const parts = [];
49
+ await new Promise((resolve) => {
50
+ const timer = setTimeout(() => {
51
+ albums.delete(key);
52
+ resolve();
53
+ }, ALBUM_WAIT_MS);
54
+ albums.set(key, { parts, timer, resolve });
55
+ });
56
+ if (parts.length > 0) {
57
+ const captioned = message.caption ? undefined : parts.find((part) => part.caption);
58
+ if (captioned) {
59
+ Object.assign(message, { caption: captioned.caption, caption_entities: captioned.caption_entities });
60
+ delete captioned.caption;
61
+ delete captioned.caption_entities;
62
+ }
63
+ console.log(`[Album] Gathered ${parts.length + 1} files sent together`);
64
+ Object.assign(message, { album: parts });
65
+ }
66
+ return next();
67
+ };
68
+ }
69
+ //# sourceMappingURL=album-collector.js.map
@@ -52,7 +52,7 @@ export async function authMiddleware(ctx, next) {
52
52
  // The bot's own doings come back as updates too: opening a thread in a
53
53
  // private chat delivers its forum_topic_created service message, sent by the
54
54
  // bot. Nothing downstream wants those, and refusing one answered the bot with
55
- // "⛔ You are not authorized" as the first message of every /fork and
55
+ // "⛔ You are not authorized" as the first message of every /branch and
56
56
  // /spinoff thread.
57
57
  if (userId === ctx.me?.id)
58
58
  return;
@@ -9,10 +9,11 @@
9
9
  *
10
10
  * Addressed means one of:
11
11
  * - an @mention of this bot's username
12
- * - a slash command meant for this bot (`/status` or `/status@this_bot`)
13
- * - an answer to one of the bot's ForceReply prompts (/project, /plan, …),
14
- * where Telegram attaches the reply itself and leaves nowhere to put a
12
+ * - a slash command meant for this bot (`/info` or `/info@this_bot`)
13
+ * - an answer to one of the bot's ForceReply prompts (/dir), where Telegram attaches the reply itself and leaves nowhere to put a
15
14
  * mention
15
+ * - a reply to a question Claude is waiting on: an answer in the sender's
16
+ * own words (see claude/typed-answer.ts)
16
17
  *
17
18
  * A plain reply is deliberately not enough: replying is how you quote someone
18
19
  * in Telegram, so people reply to the bot to talk *about* what it said as
@@ -22,6 +23,7 @@
22
23
  */
23
24
  import { config } from '../../config.js';
24
25
  import { isForceReplyPrompt } from '../../telegram/force-reply-tracker.js';
26
+ import { isOpenQuestionMessage } from '../../claude/typed-answer.js';
25
27
  /**
26
28
  * Updates this gate has already let through, going round again: a message set
27
29
  * aside and then sent. It can't judge one a second time, because stripBotMention
@@ -51,8 +53,8 @@ function mentionsBot({ text, entities }, me) {
51
53
  /**
52
54
  * True if the message opens with a slash command this bot should see.
53
55
  *
54
- * `/status@other_bot` in a group with several bots is not ours; a bare
55
- * `/status` is, and grammy's command handlers decide from there.
56
+ * `/info@other_bot` in a group with several bots is not ours; a bare
57
+ * `/info` is, and grammy's command handlers decide from there.
56
58
  *
57
59
  * Telegram also tags the first segment of an absolute path as a command —
58
60
  * `/home/me/projects` arrives with a bot_command entity on `/home` — so the
@@ -91,6 +93,10 @@ export function isAddressedToBot(ctx) {
91
93
  // typed into a composer the bot opened, and could not have mentioned it.
92
94
  if (isForceReplyPrompt(ctx.chat.id, repliedTo.message_id))
93
95
  return true;
96
+ // Likewise a reply to a question Claude is waiting on: quoting one to
97
+ // talk about it can wait until it's answered.
98
+ if (isOpenQuestionMessage(ctx.chat.id, repliedTo.message_id))
99
+ return true;
94
100
  }
95
101
  return isCommandForBot(content, ctx.me) || mentionsBot(content, ctx.me);
96
102
  }