@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/README.md +40 -2
- package/README.ru.md +10 -0
- package/README.zh.md +10 -0
- package/lib/adapters/discord.js +65 -11
- package/lib/adapters/slack.js +72 -12
- package/lib/adapters/telegram.js +708 -690
- package/lib/alerts.js +10 -10
- package/lib/artifacts.js +117 -117
- package/lib/ask.js +151 -151
- package/lib/client.js +104 -104
- package/lib/commands.js +73 -47
- package/lib/config.js +104 -98
- package/lib/content-guard.js +14 -14
- package/lib/documents.js +9 -9
- package/lib/file-manager.js +9 -9
- package/lib/gateway.js +1737 -1406
- package/lib/index.js +500 -488
- package/lib/locales/en.js +114 -0
- package/lib/locales/index.js +21 -0
- package/lib/locales/zh.js +114 -0
- package/lib/models.js +1 -1
- package/lib/personas.js +67 -14
- package/lib/photos.js +2 -2
- package/lib/scheduler.js +159 -142
- package/lib/stream.js +4 -2
- package/lib/telegram-errors.js +0 -0
- package/lib/text.js +39 -39
- package/package.json +1 -1
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: '
|
|
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}]\
|
|
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[
|
|
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 `[
|
|
32
|
+
return `[User sent ${docs.length} files]`
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export const TEXT_INJECT_EXTS = new Set([
|
package/lib/file-manager.js
CHANGED
|
@@ -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:
|
|
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)})\
|
|
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
|
|
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> (
|
|
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>...
|
|
101
|
+
lines.push(`\n<i>... and ${total - maxEntries} more files</i>`)
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
lines.push('\
|
|
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:
|
|
122
|
+
return { ok: false, error: `File not found: ${safeRel}` }
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
if (st.isDirectory()) {
|
|
126
|
-
return { ok: false, error:
|
|
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:
|
|
132
|
+
error: `File is too large (${formatFileSize(st.size)} > ${formatFileSize(maxBytes)}).`,
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
|