@gonzih/cc-tg 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -53,6 +53,8 @@ Message [@userinfobot](https://t.me/userinfobot) on Telegram — it replies with
53
53
  | `/cron clear` | Remove all cron jobs |
54
54
  | Any text | Sent directly to Claude Code |
55
55
  | Voice message | Transcribed via whisper.cpp and sent to Claude |
56
+ | Photo | Sent as native image input to Claude (base64 content block) |
57
+ | Document / file | Downloaded to `<CWD>/.cc-tg/uploads/`, path passed to Claude as `ATTACHMENTS: [name](path)` |
56
58
 
57
59
  ## Features
58
60
 
@@ -62,6 +64,12 @@ Each Telegram chat ID gets its own isolated Claude Code subprocess. Sessions sur
62
64
  ### Voice messages
63
65
  Send a voice message → automatically transcribed via whisper.cpp → fed into Claude as text. Requires `whisper-cpp` and `ffmpeg` installed on the host.
64
66
 
67
+ ### Images
68
+ Send a photo → downloaded and base64-encoded → sent to Claude as a native image content block via the stream-JSON protocol. Claude sees the full image, no intermediate vision step. Caption (if any) is included as text alongside the image.
69
+
70
+ ### Documents
71
+ Send any file as a document → downloaded to `<CWD>/.cc-tg/uploads/<filename>` → Claude receives the path as `ATTACHMENTS: [filename](path)` and can read/process it directly. Works for PDFs, CSVs, code files, etc.
72
+
65
73
  ### File delivery
66
74
  When Claude writes a file and mentions it in the response, the bot automatically uploads it to Telegram. Hybrid detection: tracks `Write`/`Edit` tool calls during the session, cross-references with filenames mentioned in the final response.
67
75
 
package/dist/bot.d.ts CHANGED
@@ -25,6 +25,7 @@ export declare class CcTgBot {
25
25
  private stopTyping;
26
26
  private flushPending;
27
27
  private trackWrittenFiles;
28
+ private isSensitiveFile;
28
29
  private uploadMentionedFiles;
29
30
  private extractToolName;
30
31
  private handleCron;
package/dist/bot.js CHANGED
@@ -306,6 +306,16 @@ export class CcTgBot {
306
306
  session.writtenFiles.add(resolved);
307
307
  }
308
308
  }
309
+ isSensitiveFile(filePath) {
310
+ const name = basename(filePath).toLowerCase();
311
+ const sensitivePatterns = [
312
+ /credential/i, /secret/i, /password/i, /passwd/i, /\.env/i,
313
+ /api[_-]?key/i, /token/i, /private[_-]?key/i, /id_rsa/i,
314
+ /\.pem$/i, /\.key$/i, /\.pfx$/i, /\.p12$/i,
315
+ /gmail/i, /oauth/i, /auth/i,
316
+ ];
317
+ return sensitivePatterns.some((p) => p.test(name));
318
+ }
309
319
  uploadMentionedFiles(chatId, resultText, session) {
310
320
  if (session.writtenFiles.size === 0)
311
321
  return;
@@ -336,9 +346,13 @@ export class CcTgBot {
336
346
  }
337
347
  }
338
348
  }
339
- // Deduplicate
349
+ // Deduplicate and filter sensitive files
340
350
  const unique = [...new Set(toUpload)];
341
351
  for (const filePath of unique) {
352
+ if (this.isSensitiveFile(filePath)) {
353
+ console.log(`[claude:files] skipping sensitive file: ${filePath}`);
354
+ continue;
355
+ }
342
356
  console.log(`[claude:files] uploading to telegram: ${filePath}`);
343
357
  this.bot.sendDocument(chatId, filePath).catch((err) => console.error(`[tg:${chatId}] sendDocument failed for ${filePath}:`, err.message));
344
358
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gonzih/cc-tg",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "Claude Code Telegram bot — chat with Claude Code via Telegram",
5
5
  "type": "module",
6
6
  "bin": {