dsh-tg-bridge 1.20.2 → 1.20.4
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/bot-menu.mjs +91 -194
- package/commands-registry.mjs +20 -0
- package/control.mjs +1 -1
- package/handle-message.mjs +26 -10
- package/i18n/en/core.mjs +3 -2
- package/i18n/en/ctrl.mjs +13 -0
- package/i18n/ru/core.mjs +3 -2
- package/i18n/ru/ctrl.mjs +13 -0
- package/i18n/zh/core.mjs +3 -2
- package/i18n/zh/ctrl.mjs +13 -0
- package/package.json +1 -1
- package/topics.mjs +77 -0
package/bot-menu.mjs
CHANGED
|
@@ -1,194 +1,91 @@
|
|
|
1
|
-
// dsh-bot-menu — install the Telegram command menu that matches THIS bridge.
|
|
2
|
-
//
|
|
3
|
-
// Why it exists: the menu the person sees is whatever `setMyCommands` last
|
|
4
|
-
// wrote, and another plugin (@xmanrui/dsh-im) had set a Chinese list of 31
|
|
5
|
-
// commands that this bridge does not implement. A menu that lies is worse than
|
|
6
|
-
// no menu, so the bridge owns its own list and re-asserts it on start.
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
{ command: 'settings', description: 'Settings as buttons, grouped by topic' },
|
|
93
|
-
{ command: 'menu', description: 'Panel: everything as buttons, gone after a press' },
|
|
94
|
-
{ command: 'rewind', description: 'Go back a turn and rephrase: /rewind 2' },
|
|
95
|
-
{ command: 'lang', description: 'Interface language: en, ru, zh' },
|
|
96
|
-
{ command: 'reasoning', description: 'Working notes: /reasoning on|off' },
|
|
97
|
-
{ command: 'profile', description: 'Topic profile: /profile <name>, /profile new' },
|
|
98
|
-
{ command: 'agents', description: 'Agents and subagents: who runs, on which model, who was spawned' },
|
|
99
|
-
{ command: 'effort', description: 'Reasoning effort: /effort high' },
|
|
100
|
-
{ command: 'permissions', description: 'Profile permissions: sandbox and approval preset' },
|
|
101
|
-
{ command: 'preset', description: 'Agent preset (persona and tools): /preset <id>' },
|
|
102
|
-
{ command: 'plan', description: 'Plan mode: state and how to ask for a plan without edits' },
|
|
103
|
-
{ command: 'jobs', description: 'What the bridge runs now: turns and queue' },
|
|
104
|
-
{ command: 'remind', description: 'Reminder: /remind +15m text or 09:30 text' },
|
|
105
|
-
{ command: 'thoughts', description: 'Reasoning of the last turn (text, file or off)' },
|
|
106
|
-
{ command: 'version', description: 'Bridge version and how updates are handled' },
|
|
107
|
-
{ command: 'update', description: 'Update and its mode: /update, /update on|off|confirm' },
|
|
108
|
-
];
|
|
109
|
-
|
|
110
|
-
/** Chinese menu (language_code: zh-hans). */
|
|
111
|
-
const COMMANDS_ZH = [
|
|
112
|
-
{ command: 'new', description: '在本话题开始新会话' },
|
|
113
|
-
{ command: 'cd', description: '将本话题绑定到项目:/cd my-app' },
|
|
114
|
-
{ command: 'status', description: '会话、模型、进行中的任务' },
|
|
115
|
-
{ command: 'stop', description: '停止当前任务' },
|
|
116
|
-
{ command: 'prices', description: '模型价格与当前模型花费' },
|
|
117
|
-
{ command: 'send', description: '把项目中的文件发送到聊天' },
|
|
118
|
-
{ command: 'seed', description: '用文本初始化空话题并置顶' },
|
|
119
|
-
{ command: 'goal', description: '本话题目标:/goal <文本>、/goal done' },
|
|
120
|
-
{ command: 'task', description: '任务清单:/task <文本>、/task done <n>' },
|
|
121
|
-
{ command: 'sessions', description: '本主题的会话 —— 直接发文字会延续最近一个' },
|
|
122
|
-
{ command: 'resume', description: '继续会话:/resume <id>' },
|
|
123
|
-
{ command: 'model', description: '查看或切换:/model, /model <id>' },
|
|
124
|
-
{ command: 'skills', description: '已安装的技能' },
|
|
125
|
-
{ command: 'soul', description: '代理人格设定' },
|
|
126
|
-
{ command: 'plugins', description: '列表、add、remove、disable、enable 都在这里' },
|
|
127
|
-
{ command: 'app', description: 'DSH 桌面应用(不是桥接)' },
|
|
128
|
-
{ command: 'restart', description: '重启桥接:/restart confirm' },
|
|
129
|
-
{ command: 'doctor', description: '诊断:桥接、网络、磁盘、插件、会话' },
|
|
130
|
-
{ command: 'logs', description: '日志:/logs、/logs 100、/logs errors、/logs file' },
|
|
131
|
-
{ command: 'help', description: '全部命令与提示' },
|
|
132
|
-
{ command: 'settings', description: '用按钮调设置,按主题分组' },
|
|
133
|
-
{ command: 'menu', description: '面板:全部做成按钮,按一下就消失' },
|
|
134
|
-
{ command: 'rewind', description: '回退一轮并换种说法:/rewind 2' },
|
|
135
|
-
{ command: 'lang', description: '界面语言:en、ru、zh' },
|
|
136
|
-
{ command: 'reasoning', description: '工作记录:/reasoning on|off' },
|
|
137
|
-
{ command: 'profile', description: '话题配置档:/profile <名称>,/profile new' },
|
|
138
|
-
{ command: 'agents', description: '智能体与子智能体:谁在运行、用什么模型、启动过谁' },
|
|
139
|
-
{ command: 'effort', description: '推理力度:/effort high' },
|
|
140
|
-
{ command: 'permissions', description: '配置档权限:沙箱与确认预设' },
|
|
141
|
-
{ command: 'preset', description: '智能体预设(人格与工具):/preset <id>' },
|
|
142
|
-
{ command: 'plan', description: '计划模式:状态与如何只要计划不改动' },
|
|
143
|
-
{ command: 'jobs', description: '桥接器当前在跑:轮次与队列' },
|
|
144
|
-
{ command: 'remind', description: '提醒:/remind +15m 文本 或 09:30 文本' },
|
|
145
|
-
{ command: 'thoughts', description: '本轮推理:文本、文件或关闭' },
|
|
146
|
-
{ command: 'version', description: '桥接版本与 npm 上的最新版本' },
|
|
147
|
-
{ command: 'update', description: '从 npm 更新桥接:/update confirm' },
|
|
148
|
-
];
|
|
149
|
-
|
|
150
|
-
async function api(method, body) {
|
|
151
|
-
const res = await fetch(`https://api.telegram.org/bot${token}/${method}`, {
|
|
152
|
-
method: 'POST',
|
|
153
|
-
headers: { 'content-type': 'application/json' },
|
|
154
|
-
body: JSON.stringify(body ?? {}),
|
|
155
|
-
signal: AbortSignal.timeout(20000),
|
|
156
|
-
});
|
|
157
|
-
const json = await res.json().catch(() => ({}));
|
|
158
|
-
if (!json.ok) throw new Error(`${method}: ${json.description || res.status}`);
|
|
159
|
-
return json.result;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
async function main() {
|
|
163
|
-
if (!token) {
|
|
164
|
-
console.error('bot token not found in ~/.dsh/.credentials.yaml');
|
|
165
|
-
process.exit(1);
|
|
166
|
-
}
|
|
167
|
-
if (args.has('--delete')) {
|
|
168
|
-
await api('deleteMyCommands', {});
|
|
169
|
-
console.log('menu deleted');
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
// Telegram keeps one menu per language_code, so a Chinese or English user
|
|
173
|
-
// sees the list in their own language instead of Russian.
|
|
174
|
-
await api('setMyCommands', { commands: COMMANDS });
|
|
175
|
-
// Telegram validates language_code against its own ISO list: 'zh-hans' is
|
|
176
|
-
// rejected with "invalid language code", 'zh' is accepted. Each language is
|
|
177
|
-
// installed independently — one refusal must not leave the others unset.
|
|
178
|
-
for (const [code, list] of [['en', COMMANDS_EN], ['zh', COMMANDS_ZH]]) {
|
|
179
|
-
try {
|
|
180
|
-
await api('setMyCommands', { commands: list, language_code: code });
|
|
181
|
-
console.log(`menu installed for ${code}: ${list.length} commands`);
|
|
182
|
-
} catch (error) {
|
|
183
|
-
console.error(`menu for ${code} failed: ${error.message}`);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
const check = await api('getMyCommands', {});
|
|
187
|
-
console.log(`menu installed: ${check.length} commands`);
|
|
188
|
-
for (const c of check) console.log(` /${c.command} — ${c.description}`);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
main().catch((error) => {
|
|
192
|
-
console.error(error.message);
|
|
193
|
-
process.exit(1);
|
|
194
|
-
});
|
|
1
|
+
// dsh-bot-menu — install the Telegram command menu that matches THIS bridge.
|
|
2
|
+
//
|
|
3
|
+
// Why it exists: the menu the person sees is whatever `setMyCommands` last
|
|
4
|
+
// wrote, and another plugin (@xmanrui/dsh-im) had set a Chinese list of 31
|
|
5
|
+
// commands that this bridge does not implement. A menu that lies is worse than
|
|
6
|
+
// no menu, so the bridge owns its own list and re-asserts it on start.
|
|
7
|
+
//
|
|
8
|
+
// What it publishes comes from `MENU_COMMANDS` in `commands-registry.mjs`, not
|
|
9
|
+
// from a second list kept here. That second list is how `/task` stayed in the
|
|
10
|
+
// menu for a release after `/task` had become an alias: the registry said one
|
|
11
|
+
// thing, the menu said another, and both were "the source of truth".
|
|
12
|
+
//
|
|
13
|
+
// Usage: node bot-menu.mjs [--delete]
|
|
14
|
+
|
|
15
|
+
import { readFileSync } from 'node:fs';
|
|
16
|
+
import { join } from 'node:path';
|
|
17
|
+
import { homedir } from 'node:os';
|
|
18
|
+
import { MENU_COMMANDS } from './commands-registry.mjs';
|
|
19
|
+
import { LANGS, t } from './i18n.mjs';
|
|
20
|
+
|
|
21
|
+
const args = new Set(process.argv.slice(2));
|
|
22
|
+
|
|
23
|
+
const token = (() => {
|
|
24
|
+
const env = (process.env.DSH_TELEGRAM_BOT_TOKEN || '').trim();
|
|
25
|
+
if (env) return env;
|
|
26
|
+
try {
|
|
27
|
+
const home = process.env.DSH_HOME || join(homedir(), '.dsh');
|
|
28
|
+
const yaml = readFileSync(join(home, '.credentials.yaml'), 'utf8');
|
|
29
|
+
// `dsh-tg init` writes the plain name; the DSH app adds a random suffix.
|
|
30
|
+
const m = /^\s*(DSH_TELEGRAM_BOT_TOKEN[A-Z0-9_]*):\s*["']?([^"'\s]+)/m.exec(yaml);
|
|
31
|
+
return m ? m[2] : '';
|
|
32
|
+
} catch {
|
|
33
|
+
return '';
|
|
34
|
+
}
|
|
35
|
+
})();
|
|
36
|
+
|
|
37
|
+
/** The menu rows for one language, straight from the registry. */
|
|
38
|
+
function rows(lang) {
|
|
39
|
+
return MENU_COMMANDS.map((name) => ({
|
|
40
|
+
// Telegram caps a description at 256 characters and a name at 32; an
|
|
41
|
+
// over-long row makes the whole call fail, so the cut happens here once.
|
|
42
|
+
command: name,
|
|
43
|
+
description: String(t(lang, `menu.cmd.${name}`)).slice(0, 256),
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function api(method, body) {
|
|
48
|
+
const res = await fetch(`https://api.telegram.org/bot${token}/${method}`, {
|
|
49
|
+
method: 'POST',
|
|
50
|
+
headers: { 'content-type': 'application/json' },
|
|
51
|
+
body: JSON.stringify(body ?? {}),
|
|
52
|
+
signal: AbortSignal.timeout(20000),
|
|
53
|
+
});
|
|
54
|
+
const json = await res.json().catch(() => ({}));
|
|
55
|
+
if (!json.ok) throw new Error(`${method}: ${json.description || res.status}`);
|
|
56
|
+
return json.result;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function main() {
|
|
60
|
+
if (!token) {
|
|
61
|
+
console.error('bot token not found in ~/.dsh/.credentials.yaml');
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
if (args.has('--delete')) {
|
|
65
|
+
await api('deleteMyCommands', {});
|
|
66
|
+
console.log('menu deleted');
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
// The default list is the language the owner reads; the others are installed
|
|
70
|
+
// per language_code so an English or Chinese phone sees its own words.
|
|
71
|
+
await api('setMyCommands', { commands: rows('ru') });
|
|
72
|
+
// Telegram validates language_code against its own ISO list: 'zh-hans' is
|
|
73
|
+
// rejected with "invalid language code", 'zh' is accepted. Each language is
|
|
74
|
+
// installed independently — one refusal must not leave the others unset.
|
|
75
|
+
for (const code of LANGS.filter((lang) => lang !== 'ru')) {
|
|
76
|
+
try {
|
|
77
|
+
await api('setMyCommands', { commands: rows(code), language_code: code });
|
|
78
|
+
console.log(`menu installed for ${code}: ${MENU_COMMANDS.length} commands`);
|
|
79
|
+
} catch (error) {
|
|
80
|
+
console.error(`menu for ${code} failed: ${error.message}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const check = await api('getMyCommands', {});
|
|
84
|
+
console.log(`menu installed: ${check.length} commands`);
|
|
85
|
+
for (const c of check) console.log(` /${c.command} — ${c.description}`);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
main().catch((error) => {
|
|
89
|
+
console.error(error.message);
|
|
90
|
+
process.exit(1);
|
|
91
|
+
});
|
package/commands-registry.mjs
CHANGED
|
@@ -34,3 +34,23 @@ export const COMMAND_ALIASES = {
|
|
|
34
34
|
* deliberately absent: they work, and they are never advertised.
|
|
35
35
|
*/
|
|
36
36
|
export const DOCUMENTED_COMMANDS = CONTROL_COMMANDS.filter((name) => !COMMAND_ALIASES[name]);
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* What the Telegram menu shows — and it is deliberately shorter than what
|
|
40
|
+
* exists.
|
|
41
|
+
*
|
|
42
|
+
* Thirty-six rows is not a menu, it is a wall a phone keyboard scrolls through,
|
|
43
|
+
* and a wall cannot answer "which of these do I press". These are the thirteen
|
|
44
|
+
* things a person does from a chat; `/help` still explains every command, and
|
|
45
|
+
* `/menu` still draws every section as buttons. Hiding a name here costs
|
|
46
|
+
* nothing: nothing was removed, only unadvertised.
|
|
47
|
+
*
|
|
48
|
+
* Two rules for adding a row: it must be a documented name (an alias here would
|
|
49
|
+
* teach the duplication back through the menu), and it must not be one letter
|
|
50
|
+
* away from another row — `sessions` and `resume`, `task` and `tasks` is exactly
|
|
51
|
+
* the pair of names this list exists to avoid.
|
|
52
|
+
*/
|
|
53
|
+
export const MENU_COMMANDS = [
|
|
54
|
+
'new', 'status', 'sessions', 'goal', 'tasks', 'model', 'plugins',
|
|
55
|
+
'settings', 'menu', 'rewind', 'stop', 'help', 'update',
|
|
56
|
+
];
|
package/control.mjs
CHANGED
|
@@ -89,7 +89,7 @@ export async function handleControl(ctx) {
|
|
|
89
89
|
|
|
90
90
|
// The outside world imports these from `control.mjs`, so the move into `control/`
|
|
91
91
|
// keeps its promises: same names, same module, different file.
|
|
92
|
-
export { COMMAND_ALIASES, CONTROL_COMMANDS, DOCUMENTED_COMMANDS } from './commands-registry.mjs';
|
|
92
|
+
export { COMMAND_ALIASES, CONTROL_COMMANDS, DOCUMENTED_COMMANDS, MENU_COMMANDS } from './commands-registry.mjs';
|
|
93
93
|
export { copyRelease } from './control/release.mjs';
|
|
94
94
|
export { filterLogLines, reasoningOf } from './control/tasks.mjs';
|
|
95
95
|
export { DSH_HOME } from './paths.mjs';
|
package/handle-message.mjs
CHANGED
|
@@ -24,7 +24,7 @@ import { MAX_PARALLEL, lastPrompt, queues } from './queue.mjs';
|
|
|
24
24
|
import { token } from './secrets.mjs';
|
|
25
25
|
import { config, done, log, saveState, state } from './state.mjs';
|
|
26
26
|
import { send, sendEphemeral, sendFile, sendWithMarkup, tg } from './telegram.mjs';
|
|
27
|
-
import { ensureTopicSeed, logTopicToGeneral, newestBoundTopic, topicName, topicSeeded, topicSeededRecently, touchTopic } from './topics.mjs';
|
|
27
|
+
import { ensureTopicSeed, logTopicToGeneral, newestBoundTopic, startTopicFromMessage, topicName, topicSeeded, topicSeededRecently, touchTopic } from './topics.mjs';
|
|
28
28
|
import { activeTurns, killTurn, liveSessions, profileOf, runTurnLive, turnStartedAt, typingLoop } from './turn.mjs';
|
|
29
29
|
import { existsSync } from 'node:fs';
|
|
30
30
|
import { join } from 'node:path';
|
|
@@ -58,16 +58,32 @@ export async function handleMessage(msg, album = null) {
|
|
|
58
58
|
threadId = twin;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
// 4. Lobby rule
|
|
62
|
-
//
|
|
63
|
-
//
|
|
64
|
-
//
|
|
65
|
-
//
|
|
61
|
+
// 4. Lobby rule: the General thread is where topics are started, not where
|
|
62
|
+
// work runs. A prompt written there used to be moved into the most
|
|
63
|
+
// recently active topic, which silently dropped it into another project's
|
|
64
|
+
// conversation — the owner hit that twice. Now the prompt opens a topic of
|
|
65
|
+
// its own, named from its first words, with the person's message copied in
|
|
66
|
+
// as the first message and pinned.
|
|
67
|
+
//
|
|
68
|
+
// Commands are not prompts: `/status` typed in General asks about the
|
|
69
|
+
// bridge, it does not start a project. They keep the old recovery, and the
|
|
70
|
+
// guard below still refuses a state-changing one.
|
|
66
71
|
if (threadId === 0 && config.generalLobby !== false) {
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
const raw = (msg.text || msg.caption || '').trim();
|
|
73
|
+
const looksLikeCommand = raw.startsWith('/');
|
|
74
|
+
if (!looksLikeCommand && raw) {
|
|
75
|
+
const started = await startTopicFromMessage(chatId, msg, raw);
|
|
76
|
+
if (started > 0) {
|
|
77
|
+
threadId = started;
|
|
78
|
+
log(`General prompt started topic ${threadId}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (threadId === 0) {
|
|
82
|
+
const recovered = newestBoundTopic(chatId);
|
|
83
|
+
if (recovered > 0) {
|
|
84
|
+
log(`General message recovered into topic ${recovered}`);
|
|
85
|
+
threadId = recovered;
|
|
86
|
+
}
|
|
71
87
|
}
|
|
72
88
|
}
|
|
73
89
|
// The topic a General message was moved into, or 0 when it stayed where it was.
|
package/i18n/en/core.mjs
CHANGED
|
@@ -73,6 +73,7 @@ export default {
|
|
|
73
73
|
'status.speed': 'tok/s',
|
|
74
74
|
'status.cacheLine': '🧠 cache: {pct}% ({k}k from cache)',
|
|
75
75
|
'msg.topicLog': '📌 New topic: {preview}\n→ work happens in the topic, this is the log.',
|
|
76
|
+
'topic.untitled': 'New topic',
|
|
76
77
|
'msg.transcribing': '🎤 Transcribing…',
|
|
77
78
|
'status.steps': 'steps',
|
|
78
79
|
'status.thinking': 'waiting for the model',
|
|
@@ -165,14 +166,14 @@ export default {
|
|
|
165
166
|
'msg.voiceNotRecognized': 'Could not make out the voice message{detail}',
|
|
166
167
|
'prompt.photo': 'Look at the image at {path} and describe it in detail: text (verbatim, keeping its language), interface elements, objects.',
|
|
167
168
|
'prompt.file': 'The user sent a file: {path} ({type}, {size} bytes).',
|
|
168
|
-
'prompt.voice': '🎤 This is a transcript of a voice message, produced by speech recognition. Names, Latin words, file names and rare terms may be misheard. If a word makes no sense, ask what was meant instead of guessing — the text below is what was heard, not what was said.\n\n{text}',
|
|
169
|
+
'prompt.voice': '🎤 This is a transcript of a voice message, produced by speech recognition. Names, Latin words, file names and rare terms may be misheard. If a word makes no sense, ask what was meant instead of guessing — the text below is what was heard, not what was said.\n\n{text}',
|
|
169
170
|
'prompt.note': 'The request: {note}',
|
|
170
171
|
'prompt.fileText': 'The user sent a text file: {path} ({type}, {size} bytes). Its content is between the markers:\n<file>\n{body}\n</file>',
|
|
171
172
|
'prompt.photoMidTurn': 'The image arrived mid-turn, so only its path is attached: if you cannot open images, say so in one line.',
|
|
172
173
|
'bridge.progress.text': 'text: {text}',
|
|
173
174
|
'bridge.progress.empty': '(empty)',
|
|
174
175
|
'bridge.progress.emptyReply': '(empty reply)',
|
|
175
|
-
'bridge.progress.reasoningOnly': 'The turn ended without an answer. What I was thinking stayed in the notes above, so say it again in one line and I will answer.',
|
|
176
|
+
'bridge.progress.reasoningOnly': 'The turn ended without an answer. What I was thinking stayed in the notes above, so say it again in one line and I will answer.',
|
|
176
177
|
'bridge.error.inline': 'error: {msg}',
|
|
177
178
|
'bridge.error.cliDied': 'the CLI exited with code {code} and printed nothing',
|
|
178
179
|
'bridge.error.noApp': 'DeepSeek Harness is not at {path} — the bridge cannot start a turn. Install the app or point `dshApp` in config.json at it.',
|
package/i18n/en/ctrl.mjs
CHANGED
|
@@ -122,6 +122,19 @@ export default {
|
|
|
122
122
|
'ctrl.cmd.subscribe': "The same switch as /update on|off, said plainly.",
|
|
123
123
|
'ctrl.cmd.goal': "The one goal this topic works toward; /tasks adds its steps.",
|
|
124
124
|
'ctrl.cmd.notSettings': "Where a switch is NOT here: /settings shows them all as a card.",
|
|
125
|
+
'menu.cmd.new': "A new session in this topic",
|
|
126
|
+
'menu.cmd.status': "What is running: session, model, turn",
|
|
127
|
+
'menu.cmd.sessions': "The sessions of this topic, and switching between them",
|
|
128
|
+
'menu.cmd.goal': "This topic's goal: /goal <text>, /goal done",
|
|
129
|
+
'menu.cmd.tasks': "The checklist as buttons: /tasks, /tasks 2, /tasks text",
|
|
130
|
+
'menu.cmd.model': "The model of this session: /model, /model <id>",
|
|
131
|
+
'menu.cmd.plugins': "Plugins: list, install, enable",
|
|
132
|
+
'menu.cmd.settings': "Profile settings: language, permissions, effort",
|
|
133
|
+
'menu.cmd.menu': "The button panel: sections and frequent actions",
|
|
134
|
+
'menu.cmd.rewind': "Step back: /rewind <n>, files are untouched",
|
|
135
|
+
'menu.cmd.stop': "Stop the current turn",
|
|
136
|
+
'menu.cmd.help': "Every command with an explanation: /help <command>",
|
|
137
|
+
'menu.cmd.update': "Version and update: /update confirm",
|
|
125
138
|
'ctrl.settings.usage': 'Settings as buttons: /settings, /settings agent, /settings updates',
|
|
126
139
|
'ctrl.settings.opened': 'Tap a setting. Each button is the command you would otherwise type.',
|
|
127
140
|
'ctrl.profile.title': '🧩 Profile {name}',
|
package/i18n/ru/core.mjs
CHANGED
|
@@ -73,6 +73,7 @@ export default {
|
|
|
73
73
|
'status.speed': 'т/с',
|
|
74
74
|
'status.cacheLine': '🧠 кэш: {pct}% ({k}k из кэша)',
|
|
75
75
|
'msg.topicLog': '📌 Новая тема: {preview}\n→ работа идёт в теме, здесь — лог.',
|
|
76
|
+
'topic.untitled': 'Новая тема',
|
|
76
77
|
'msg.transcribing': '🎤 Расшифровываю…',
|
|
77
78
|
'status.steps': 'шагов',
|
|
78
79
|
'status.thinking': 'жду модель',
|
|
@@ -165,14 +166,14 @@ export default {
|
|
|
165
166
|
'msg.voiceNotRecognized': 'Не распознал голосовое{detail}',
|
|
166
167
|
'prompt.photo': 'Посмотри изображение по пути {path} и подробно опиши, что на нём: текст (дословно, с сохранением языка), элементы интерфейса, объекты.',
|
|
167
168
|
'prompt.file': 'Пользователь прислал файл: {path} ({type}, {size} байт).',
|
|
168
|
-
'prompt.voice': '🎤 Это расшифровка голосового сообщения, сделанная распознаванием речи. Имена, латиница, имена файлов и редкие слова могут быть перевраны. Если слово выглядит бессмысленно, спроси, что имелось в виду, вместо того чтобы додумывать: ниже — то, что услышано, а не то, что сказано.\n\n{text}',
|
|
169
|
+
'prompt.voice': '🎤 Это расшифровка голосового сообщения, сделанная распознаванием речи. Имена, латиница, имена файлов и редкие слова могут быть перевраны. Если слово выглядит бессмысленно, спроси, что имелось в виду, вместо того чтобы додумывать: ниже — то, что услышано, а не то, что сказано.\n\n{text}',
|
|
169
170
|
'prompt.note': 'Просьба: {note}',
|
|
170
171
|
'prompt.fileText': 'Пользователь прислал текстовый файл: {path} ({type}, {size} байт). Содержимое между маркерами:\n<file>\n{body}\n</file>',
|
|
171
172
|
'prompt.photoMidTurn': 'Картинка пришла во время хода, поэтому приложен только путь: если не можешь открыть изображение, скажи это одной строкой.',
|
|
172
173
|
'bridge.progress.text': 'текст: {text}',
|
|
173
174
|
'bridge.progress.empty': '(пусто)',
|
|
174
175
|
'bridge.progress.emptyReply': '(пустой ответ)',
|
|
175
|
-
'bridge.progress.reasoningOnly': 'Ход закончился без ответа: размышление выше — не ответ. Повтори мысль одной строкой, и я отвечу.',
|
|
176
|
+
'bridge.progress.reasoningOnly': 'Ход закончился без ответа: размышление выше — не ответ. Повтори мысль одной строкой, и я отвечу.',
|
|
176
177
|
'bridge.error.inline': 'ошибка: {msg}',
|
|
177
178
|
'bridge.error.cliDied': 'CLI завершился с кодом {code} без вывода',
|
|
178
179
|
'bridge.error.noApp': 'DeepSeek Harness не найден по пути {path} — ход запустить нечем. Установите приложение или укажите путь в `dshApp` в config.json.',
|
package/i18n/ru/ctrl.mjs
CHANGED
|
@@ -122,6 +122,19 @@ export default {
|
|
|
122
122
|
'ctrl.cmd.subscribe': "Тот же переключатель, что /update on|off, простыми словами.",
|
|
123
123
|
'ctrl.cmd.goal': "Одна цель, к которой идёт тема; шаги к ней — /tasks.",
|
|
124
124
|
'ctrl.cmd.notSettings': "Чего здесь нет: /settings показывает все переключатели карточкой.",
|
|
125
|
+
'menu.cmd.new': "Новая сессия в этой теме",
|
|
126
|
+
'menu.cmd.status': "Что сейчас: сессия, модель, активный ход",
|
|
127
|
+
'menu.cmd.sessions': "Сессии этой темы и переключение между ними",
|
|
128
|
+
'menu.cmd.goal': "Цель темы: /goal <текст>, /goal done",
|
|
129
|
+
'menu.cmd.tasks': "Чек-лист шагами кнопками: /tasks, /tasks 2, /tasks текст",
|
|
130
|
+
'menu.cmd.model': "Модель этой сессии: /model, /model <id>",
|
|
131
|
+
'menu.cmd.plugins': "Плагины: список, установка, включение",
|
|
132
|
+
'menu.cmd.settings': "Настройки профиля: язык, права, усилие",
|
|
133
|
+
'menu.cmd.menu': "Панель кнопками: разделы и частые действия",
|
|
134
|
+
'menu.cmd.rewind': "Откат назад: /rewind <n>, файлы остаются",
|
|
135
|
+
'menu.cmd.stop': "Остановить текущий ход",
|
|
136
|
+
'menu.cmd.help': "Все команды с пояснением: /help <команда>",
|
|
137
|
+
'menu.cmd.update': "Версия и обновление: /update confirm",
|
|
125
138
|
'ctrl.settings.usage': 'Настройки кнопками: /settings, /settings agent, /settings updates',
|
|
126
139
|
'ctrl.settings.opened': 'Нажми на настройку. Каждая кнопка — та команда, которую иначе пришлось бы печатать.',
|
|
127
140
|
'ctrl.profile.title': '🧩 Профиль {name}',
|
package/i18n/zh/core.mjs
CHANGED
|
@@ -73,6 +73,7 @@ export default {
|
|
|
73
73
|
'status.speed': 'tok/s',
|
|
74
74
|
'status.cacheLine': '🧠 缓存:{pct}%({k}k 来自缓存)',
|
|
75
75
|
'msg.topicLog': '📌 新主题:{preview}\n→ 工作在主题里进行,这里是日志。',
|
|
76
|
+
'topic.untitled': '新主题',
|
|
76
77
|
'msg.transcribing': '🎤 正在转写…',
|
|
77
78
|
'status.steps': '步',
|
|
78
79
|
'status.thinking': '等待模型',
|
|
@@ -165,14 +166,14 @@ export default {
|
|
|
165
166
|
'msg.voiceNotRecognized': '没能识别这条语音{detail}',
|
|
166
167
|
'prompt.photo': '查看路径 {path} 的图片并详细描述:文字(逐字,保留原语言)、界面元素、物体。',
|
|
167
168
|
'prompt.file': '用户发来文件:{path}({type},{size} 字节)。',
|
|
168
|
-
'prompt.voice': '🎤 这是语音消息的转写文本,由语音识别生成。人名、拉丁字母、文件名和生僻词可能听错。如果某个词看起来没有意义,请询问本意,不要自行猜测:下面是被听到的内容,不一定是原话。\n\n{text}',
|
|
169
|
+
'prompt.voice': '🎤 这是语音消息的转写文本,由语音识别生成。人名、拉丁字母、文件名和生僻词可能听错。如果某个词看起来没有意义,请询问本意,不要自行猜测:下面是被听到的内容,不一定是原话。\n\n{text}',
|
|
169
170
|
'prompt.note': '请求:{note}',
|
|
170
171
|
'prompt.fileText': '用户发来文本文件:{path}({type},{size} 字节)。内容在标记之间:\n<file>\n{body}\n</file>',
|
|
171
172
|
'prompt.photoMidTurn': '图片是在本轮进行中发来的,只附上了路径:如果无法打开图片,请用一句话说明。',
|
|
172
173
|
'bridge.progress.text': '文本:{text}',
|
|
173
174
|
'bridge.progress.empty': '(空)',
|
|
174
175
|
'bridge.progress.emptyReply': '(空回复)',
|
|
175
|
-
'bridge.progress.reasoningOnly': '这一轮没有生成回答,上面的笔记只是思考过程。请再把问题说一句,我来回答。',
|
|
176
|
+
'bridge.progress.reasoningOnly': '这一轮没有生成回答,上面的笔记只是思考过程。请再把问题说一句,我来回答。',
|
|
176
177
|
'bridge.error.inline': '错误:{msg}',
|
|
177
178
|
'bridge.error.cliDied': 'CLI 以代码 {code} 退出且没有输出',
|
|
178
179
|
'bridge.error.noApp': '未在 {path} 找到 DeepSeek Harness,无法启动回合。请安装应用,或在 config.json 中用 `dshApp` 指定路径。',
|
package/i18n/zh/ctrl.mjs
CHANGED
|
@@ -122,6 +122,19 @@ export default {
|
|
|
122
122
|
'ctrl.cmd.subscribe': "与 /update on|off 同一个开关,换个说法。",
|
|
123
123
|
'ctrl.cmd.goal': "本话题朝哪个目标走;拆成步骤用 /tasks。",
|
|
124
124
|
'ctrl.cmd.notSettings': "这里没有的东西:/settings 用一张卡片列出所有开关。",
|
|
125
|
+
'menu.cmd.new': "在此话题新建会话",
|
|
126
|
+
'menu.cmd.status': "当前状态:会话、模型、轮次",
|
|
127
|
+
'menu.cmd.sessions': "本话题的会话与切换",
|
|
128
|
+
'menu.cmd.goal': "本话题的目标:/goal <文本>、/goal done",
|
|
129
|
+
'menu.cmd.tasks': "用按钮勾选步骤:/tasks、/tasks 2、/tasks 文本",
|
|
130
|
+
'menu.cmd.model': "本会话的模型:/model、/model <id>",
|
|
131
|
+
'menu.cmd.plugins': "插件:列表、安装、启用",
|
|
132
|
+
'menu.cmd.settings': "配置档设置:语言、权限、思考力度",
|
|
133
|
+
'menu.cmd.menu': "按钮面板:分区与常用操作",
|
|
134
|
+
'menu.cmd.rewind': "回退:/rewind <n>,不动文件",
|
|
135
|
+
'menu.cmd.stop': "停止当前轮次",
|
|
136
|
+
'menu.cmd.help': "所有命令及说明:/help <命令>",
|
|
137
|
+
'menu.cmd.update': "版本与更新:/update confirm",
|
|
125
138
|
'ctrl.settings.usage': '用按钮调设置:/settings、/settings agent、/settings updates',
|
|
126
139
|
'ctrl.settings.opened': '点一项设置即可。每个按钮就是你本来要输入的命令。',
|
|
127
140
|
'ctrl.profile.title': '🧩 配置档 {name}',
|
package/package.json
CHANGED
package/topics.mjs
CHANGED
|
@@ -136,6 +136,83 @@ export async function ensureTopicSeed(chatId, threadId, text) {
|
|
|
136
136
|
return messageId;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
/**
|
|
140
|
+
* A topic title made from the first words of a prompt.
|
|
141
|
+
*
|
|
142
|
+
* Telegram caps topic names at 128 characters, but the useful limit is much
|
|
143
|
+
* shorter: the name is a handle in a sidebar, not a summary. Six words or forty
|
|
144
|
+
* characters, whichever comes first — a long first sentence would otherwise
|
|
145
|
+
* push every other topic out of view.
|
|
146
|
+
*/
|
|
147
|
+
export function topicTitleFrom(text, max = 40) {
|
|
148
|
+
const flat = String(text ?? '').replace(/\s+/g, ' ').trim();
|
|
149
|
+
if (!flat) return '';
|
|
150
|
+
const words = flat.split(' ').slice(0, 6).join(' ');
|
|
151
|
+
if (words.length <= max) return words;
|
|
152
|
+
return `${words.slice(0, max - 1).trimEnd()}…`;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Open a new topic for a message written in General, and make it start with
|
|
157
|
+
* that message.
|
|
158
|
+
*
|
|
159
|
+
* General ("Все") is the stream a person types into when they do not want to
|
|
160
|
+
* pick a topic first. The old rule moved such a message into the most recently
|
|
161
|
+
* active topic, which silently dropped it into another project's conversation —
|
|
162
|
+
* the owner hit this twice. Starting a topic instead keeps every prompt in a
|
|
163
|
+
* place of its own, named after what was asked.
|
|
164
|
+
*
|
|
165
|
+
* `copyMessage` is used rather than `sendMessage` so the topic opens with the
|
|
166
|
+
* person's own message, media included, and without a "forwarded from" header.
|
|
167
|
+
* The copy is pinned, which is the behaviour the owner asked for.
|
|
168
|
+
*
|
|
169
|
+
* Returns the new thread id, or 0 when Telegram refused to create the topic
|
|
170
|
+
* (a group without topic permissions, or a rate limit) — the caller then falls
|
|
171
|
+
* back to the old recovery so the message is not lost.
|
|
172
|
+
*/
|
|
173
|
+
export async function startTopicFromMessage(chatId, msg, text) {
|
|
174
|
+
const name = topicTitleFrom(text) || t(config.lang || 'en', 'topic.untitled');
|
|
175
|
+
let threadId = 0;
|
|
176
|
+
try {
|
|
177
|
+
const created = await tg('createForumTopic', { chat_id: chatId, name });
|
|
178
|
+
threadId = Number(created?.message_thread_id || 0);
|
|
179
|
+
} catch (error) {
|
|
180
|
+
log(`General message could not start a topic: ${error.message}`);
|
|
181
|
+
return 0;
|
|
182
|
+
}
|
|
183
|
+
if (!(threadId > 0)) return 0;
|
|
184
|
+
log(`General message started topic ${threadId} "${name}"`);
|
|
185
|
+
|
|
186
|
+
let messageId = 0;
|
|
187
|
+
try {
|
|
188
|
+
const copied = await tg('copyMessage', {
|
|
189
|
+
chat_id: chatId,
|
|
190
|
+
from_chat_id: chatId,
|
|
191
|
+
message_id: msg.message_id,
|
|
192
|
+
message_thread_id: threadId,
|
|
193
|
+
});
|
|
194
|
+
messageId = Number(copied?.message_id || 0);
|
|
195
|
+
} catch (error) {
|
|
196
|
+
// Media Telegram will not copy (a poll, a protected file) still deserves a
|
|
197
|
+
// seed, otherwise the topic is a title over an empty page.
|
|
198
|
+
log(`topic ${threadId} copy failed: ${error.message}`);
|
|
199
|
+
}
|
|
200
|
+
if (!messageId) return threadId;
|
|
201
|
+
|
|
202
|
+
state.seededTopics = state.seededTopics ?? {};
|
|
203
|
+
state.seededTopics[String(threadId)] = messageId;
|
|
204
|
+
saveState();
|
|
205
|
+
noteSeed(text, threadId);
|
|
206
|
+
if (config.pinTopicSeed !== false) {
|
|
207
|
+
try {
|
|
208
|
+
await tg('pinChatMessage', { chat_id: chatId, message_id: messageId, disable_notification: false });
|
|
209
|
+
} catch (error) {
|
|
210
|
+
log(`topic ${threadId} pin failed: ${error.message}`);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return threadId;
|
|
214
|
+
}
|
|
215
|
+
|
|
139
216
|
/**
|
|
140
217
|
* Write one line about a new topic into the General chat, so the main stream
|
|
141
218
|
* reads as a log of what was started instead of a wall of prompts. The full
|