@goodandready/dsh-messenger-gateway 0.1.0 → 0.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.
- package/README.md +68 -19
- package/lib/adapters/index.js +15 -2
- package/lib/adapters/telegram.js +375 -52
- package/lib/client.js +480 -46
- package/lib/commands.js +30 -0
- package/lib/config.js +78 -0
- package/lib/documents.js +19 -5
- package/lib/gateway.js +496 -56
- package/lib/groups.js +72 -0
- package/lib/homes.js +58 -0
- package/lib/index.js +261 -39
- package/lib/messenger-api.js +5 -5
- package/lib/pairing.js +110 -0
- package/lib/stream.js +64 -0
- package/lib/telegram-errors.js +41 -0
- package/lib/telegram-format.js +141 -0
- package/lib/text.js +18 -1
- package/lib/topics.js +23 -4
- package/lib/tts.js +82 -2
- package/lib/voice-prefs.js +44 -0
- package/package.json +15 -9
- package/docs/architecture/2026-08-23-messenger-gateway-design.md +0 -30
- package/docs/deployment/0.1.0-install.md +0 -28
- package/docs/testing/0.1.0-smoke.md +0 -12
package/README.md
CHANGED
|
@@ -1,26 +1,24 @@
|
|
|
1
1
|
# @goodandready/dsh-messenger-gateway
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Telegram messenger bridge for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Talk to your Harness agent from Telegram: text, voice, photos, documents, inline buttons, named homes, and optional spoken replies.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- Text, voice (`dsh-voice`), photos (`attachments` + `dsh-vision-bridge`), documents
|
|
9
|
-
- Outbound images from tool results
|
|
10
|
-
- `messenger` service: HTTP `/messenger/send`, `/ask`, `/progress` and `ctx.provide('messenger')`
|
|
11
|
-
- Forum topics = separate agent sessions (`message_thread_id`)
|
|
12
|
-
- Optional spoken replies (`dsh-tts`)
|
|
13
|
-
- Commands: `/start` `/help` `/new` `/whoami` `/stop`
|
|
7
|
+
## Features
|
|
14
8
|
|
|
15
|
-
|
|
9
|
+
- Long-poll or webhook Telegram bot
|
|
10
|
+
- Allowlist + pairing codes
|
|
11
|
+
- Per-user or per-chat sessions (`sessionScope`)
|
|
12
|
+
- Forum topics as separate sessions
|
|
13
|
+
- Steer: follow-up messages while the agent is busy (instead of aborting)
|
|
14
|
+
- `/stop`, `/new`, `/model`, `/status`, `/voice`, `/sethome`, `/home`
|
|
15
|
+
- Agent tool `messenger_ask` (inline keyboard answers return to the agent)
|
|
16
|
+
- Named homes for outbound notify / `messenger.send`
|
|
17
|
+
- Optional notify bridge: web session events → Telegram home (excludes messenger sessions)
|
|
18
|
+
- Inbound voice → STT (`dsh-voice`), photos → vision (`dsh-vision-bridge`)
|
|
19
|
+
- Optional TTS replies (`dsh-tts`); mp3 is converted to OGG/Opus via `ffmpeg` for Telegram voice notes
|
|
16
20
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Install these plugins in the same Harness profile (they are not npm dependencies):
|
|
20
|
-
|
|
21
|
-
- `dsh-voice` — inbound voice transcription
|
|
22
|
-
- `dsh-tts` — optional spoken replies
|
|
23
|
-
- `dsh-vision-bridge` — inbound photo understanding
|
|
21
|
+
Discord is listed in settings as a placeholder only — the Discord adapter is not implemented yet.
|
|
24
22
|
|
|
25
23
|
## Install
|
|
26
24
|
|
|
@@ -28,8 +26,59 @@ Install these plugins in the same Harness profile (they are not npm dependencies
|
|
|
28
26
|
dsh plugin --profile web add @goodandready/dsh-messenger-gateway
|
|
29
27
|
```
|
|
30
28
|
|
|
31
|
-
|
|
29
|
+
Then open **Settings → Plugins → Messenger gateway**:
|
|
30
|
+
|
|
31
|
+
1. Enable Telegram
|
|
32
|
+
2. Paste the BotFather token (write-only; leave blank to keep the current token)
|
|
33
|
+
3. Set allowed Telegram user IDs (or use pairing)
|
|
34
|
+
|
|
35
|
+
### Optional companion plugins (same profile)
|
|
36
|
+
|
|
37
|
+
| Plugin | Role |
|
|
38
|
+
|--------|------|
|
|
39
|
+
| `@goodandready/dsh-voice` | Transcribe inbound voice messages |
|
|
40
|
+
| `@goodandready/dsh-tts` | Speak agent replies |
|
|
41
|
+
| `@goodandready/dsh-vision-bridge` | Describe inbound photos |
|
|
42
|
+
|
|
43
|
+
They are **not** npm dependencies of this package — install them separately if you want those features.
|
|
44
|
+
|
|
45
|
+
### Voice notes
|
|
46
|
+
|
|
47
|
+
Spoken replies use Telegram `sendVoice`. If TTS returns MP3 (or other non-Opus audio), the gateway runs `ffmpeg` (`libopus`) to produce OGG. If `ffmpeg` is missing or conversion fails, the audio is sent as a regular audio file instead of a voice note.
|
|
48
|
+
|
|
49
|
+
## Commands (Telegram)
|
|
50
|
+
|
|
51
|
+
| Command | Description |
|
|
52
|
+
|---------|-------------|
|
|
53
|
+
| `/start` `/help` | Help |
|
|
54
|
+
| `/whoami` | Your Telegram user id |
|
|
55
|
+
| `/new` | New agent session |
|
|
56
|
+
| `/stop` | Abort the current turn |
|
|
57
|
+
| `/model` `/status` | Model / gateway status |
|
|
58
|
+
| `/voice on\|off` | Per-user spoken replies |
|
|
59
|
+
| `/sethome [name]` | Bind current chat/topic as a named home |
|
|
60
|
+
| `/home` | List homes |
|
|
61
|
+
|
|
62
|
+
## Agent tools & HTTP
|
|
63
|
+
|
|
64
|
+
- Tool: `messenger_ask` — ask the user with inline buttons; choice is fed back into the turn
|
|
65
|
+
- HTTP (when enabled): `/messenger/send`, `/messenger/ask`, `/messenger/progress`
|
|
66
|
+
- Cordis service: `ctx.messenger` for other plugins
|
|
67
|
+
|
|
68
|
+
## Configuration notes
|
|
69
|
+
|
|
70
|
+
- `sessionScope`: `user` (default) or `chat` — how group chats isolate sessions
|
|
71
|
+
- `voiceMode`: `mirror` / `always` / `off` — when to speak replies (also `/voice`)
|
|
72
|
+
- `tts.enabled` / `tts.maxChars` — TTS gate and length cap
|
|
73
|
+
- `notifyBridge` — forward non-messenger web session events to a home
|
|
74
|
+
- Bot token is a DSH secret field — never commit it
|
|
75
|
+
|
|
76
|
+
## Requirements
|
|
77
|
+
|
|
78
|
+
- DeepSeek Harness web (or compatible) profile
|
|
79
|
+
- Node.js matching your Harness install
|
|
80
|
+
- For voice notes from non-Opus TTS: `ffmpeg` on the host `PATH`
|
|
32
81
|
|
|
33
|
-
|
|
82
|
+
## License
|
|
34
83
|
|
|
35
84
|
MIT
|
package/lib/adapters/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TelegramAdapter } from './telegram.js'
|
|
2
2
|
|
|
3
3
|
export default function createAdapters(deps) {
|
|
4
|
-
const { config, onMessage, onCallback, logger } = deps
|
|
4
|
+
const { config, onMessage, onCallback, onUnauthorized, isUserAllowed, logger } = deps
|
|
5
5
|
const list = []
|
|
6
6
|
const tg = config.telegram || {}
|
|
7
7
|
if (config.enabled !== false && tg.enabled && String(tg.botToken || '').trim()) {
|
|
@@ -10,9 +10,22 @@ export default function createAdapters(deps) {
|
|
|
10
10
|
allowedUserIds: tg.allowedUserIds,
|
|
11
11
|
timeoutSeconds: tg.pollTimeoutSeconds,
|
|
12
12
|
pollIntervalMs: tg.pollIntervalMs,
|
|
13
|
+
commands: tg.commands,
|
|
14
|
+
textFormat: tg.textFormat,
|
|
15
|
+
groupsEnabled: tg.groupsEnabled,
|
|
16
|
+
groupRequireMention: tg.groupRequireMention,
|
|
17
|
+
reactionsEnabled: tg.reactionsEnabled,
|
|
18
|
+
statusIndicator: tg.statusIndicator,
|
|
19
|
+
statusOnline: tg.statusOnline,
|
|
20
|
+
statusOffline: tg.statusOffline,
|
|
21
|
+
transport: tg.transport,
|
|
22
|
+
webhookUrl: tg.webhookUrl,
|
|
23
|
+
webhookSecret: tg.webhookSecret,
|
|
13
24
|
media: config.media,
|
|
14
25
|
onMessage,
|
|
15
26
|
onCallback,
|
|
27
|
+
onUnauthorized,
|
|
28
|
+
isUserAllowed,
|
|
16
29
|
logger,
|
|
17
30
|
}))
|
|
18
31
|
}
|
|
@@ -21,4 +34,4 @@ export default function createAdapters(deps) {
|
|
|
21
34
|
logger?.warn?.('dsh-messenger-gateway: discord adapter is not implemented yet')
|
|
22
35
|
}
|
|
23
36
|
return list
|
|
24
|
-
}
|
|
37
|
+
}
|