@goodandready/dsh-messenger-gateway 0.3.19 → 0.3.21

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/lib/documents.js CHANGED
@@ -5,16 +5,16 @@ import { inflateRawSync } from 'node:zlib'
5
5
  /** Format a cached inbound document/video path for the agent (fs tools). */
6
6
  export function formatInboundDocument(att, parsed = null) {
7
7
  const kind = att?.kind || 'document'
8
- const labels = { video: 'Видео', sticker: 'Стикер', animation: 'GIF', document: 'Документ' }
9
- const label = labels[kind] || 'Файл'
8
+ const labels = { video: 'Video', sticker: 'Sticker', animation: 'GIF', document: 'Document' }
9
+ const label = labels[kind] || 'File'
10
10
  const name = att?.name ? ` ${att.name}` : ''
11
11
  const mime = att?.mime ? ` (${att.mime})` : ''
12
12
  const emoji = att?.emoji ? ` emoji=${att.emoji}` : ''
13
- let base = `[${label}${name}${mime}${emoji}]\nПуть: ${att.path}`
13
+ let base = `[${label}${name}${mime}${emoji}]\nPath: ${att.path}`
14
14
 
15
15
  if (parsed?.text) {
16
- const truncNote = parsed.truncated ? ' (содержимое усечено)' : ''
17
- base += `\n\n[Распознанный текст из файла${truncNote}]:\n\`\`\`\n${parsed.text}\n\`\`\``
16
+ const truncNote = parsed.truncated ? ' (content truncated)' : ''
17
+ base += `\n\n[Extracted text from file${truncNote}]:\n\`\`\`\n${parsed.text}\n\`\`\``
18
18
  }
19
19
  return base
20
20
  }
@@ -25,11 +25,11 @@ export function documentOnlyHint(attachments, userText) {
25
25
  if (!docs.length) return ''
26
26
  if (docs.length === 1) {
27
27
  const k = docs[0].kind
28
- if (k === 'sticker') return '[Пользователь отправил стикер]'
29
- if (k === 'video' || k === 'animation') return '[Пользователь отправил видео]'
30
- return '[Пользователь отправил файл]'
28
+ if (k === 'sticker') return '[User sent a sticker]'
29
+ if (k === 'video' || k === 'animation') return '[User sent a video]'
30
+ return '[User sent a file]'
31
31
  }
32
- return `[Пользователь отправил ${docs.length} файла]`
32
+ return `[User sent ${docs.length} files]`
33
33
  }
34
34
 
35
35
  export const TEXT_INJECT_EXTS = new Set([
@@ -32,7 +32,7 @@ export async function listFiles(baseCwd, subPath = '.', opts = {}) {
32
32
  try {
33
33
  st = await stat(target)
34
34
  } catch (err) {
35
- return { ok: false, error: `Каталог не найден: ${err.message}` }
35
+ return { ok: false, error: `Directory not found: ${err.message}` }
36
36
  }
37
37
 
38
38
  if (!st.isDirectory()) {
@@ -41,7 +41,7 @@ export async function listFiles(baseCwd, subPath = '.', opts = {}) {
41
41
  isDirectory: false,
42
42
  currentPath: relativePath,
43
43
  entries: [{ name: relativePath, size: st.size, isDirectory: false }],
44
- formattedText: `📄 <b>${relativePath}</b> (${formatFileSize(st.size)})\nДля скачивания: <code>/get ${relativePath}</code>`,
44
+ formattedText: `📄 <b>${relativePath}</b> (${formatFileSize(st.size)})\nDownload: <code>/get ${relativePath}</code>`,
45
45
  }
46
46
  }
47
47
 
@@ -81,12 +81,12 @@ export async function listFiles(baseCwd, subPath = '.', opts = {}) {
81
81
  const sliced = entries.slice(0, maxEntries)
82
82
 
83
83
  const lines = [
84
- `📂 <b>Файлы: <code>${relativePath === '.' ? '/' : `/${relativePath}`}</code></b> (${total} элементов):`,
84
+ `📂 <b>Files: <code>${relativePath === '.' ? '/' : `/${relativePath}`}</code></b> (${total} items):`,
85
85
  '',
86
86
  ]
87
87
 
88
88
  if (relativePath !== '.') {
89
- lines.push('📁 <code>..</code> (на уровень выше: <code>/files ..</code>)')
89
+ lines.push('📁 <code>..</code> (parent folder: <code>/files ..</code>)')
90
90
  }
91
91
 
92
92
  for (const e of sliced) {
@@ -98,10 +98,10 @@ export async function listFiles(baseCwd, subPath = '.', opts = {}) {
98
98
  }
99
99
 
100
100
  if (total > maxEntries) {
101
- lines.push(`\n<i>... и ещё ${total - maxEntries} файлов</i>`)
101
+ lines.push(`\n<i>... and ${total - maxEntries} more files</i>`)
102
102
  }
103
103
 
104
- lines.push('\nСкачать файл: <code>/get <файл></code>\nПереход по папкам: <code>/files <папка></code>')
104
+ lines.push('\nDownload file: <code>/get <file></code>\nNavigate directory: <code>/files <dir></code>')
105
105
 
106
106
  return {
107
107
  ok: true,
@@ -119,17 +119,17 @@ export async function getFileForDownload(baseCwd, relativePath, maxBytes = 50 *
119
119
  try {
120
120
  st = await stat(target)
121
121
  } catch (err) {
122
- return { ok: false, error: `Файл не найден: ${safeRel}` }
122
+ return { ok: false, error: `File not found: ${safeRel}` }
123
123
  }
124
124
 
125
125
  if (st.isDirectory()) {
126
- return { ok: false, error: `«${safeRel}» является каталогом, а не файлом. Список: /files ${safeRel}` }
126
+ return { ok: false, error: `"${safeRel}" is a directory, not a file. List: /files ${safeRel}` }
127
127
  }
128
128
 
129
129
  if (st.size > maxBytes) {
130
130
  return {
131
131
  ok: false,
132
- error: `Файл слишком большой (${formatFileSize(st.size)} > ${formatFileSize(maxBytes)}).`,
132
+ error: `File is too large (${formatFileSize(st.size)} > ${formatFileSize(maxBytes)}).`,
133
133
  }
134
134
  }
135
135