dsh-tg-bridge 1.7.4 → 1.7.6

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 CHANGED
@@ -47,7 +47,7 @@ const COMMANDS = [
47
47
  { command: 'app', description: 'Приложение DSH, не мост: /app restart confirm' },
48
48
  { command: 'restart', description: 'Перезапуск моста: /restart confirm' },
49
49
  { command: 'doctor', description: 'Диагностика: мост, сеть, диск, плагины, сессия' },
50
- { command: 'logs', description: 'Лог: /logs, /logs 100, /logs errors, /logs <текст>' },
50
+ { command: 'logs', description: 'Лог: /logs, /logs 100, /logs errors, /logs file' },
51
51
  { command: 'help', description: 'Все команды и подсказки' },
52
52
  { command: 'lang', description: 'Язык интерфейса: en, ru, zh' },
53
53
  { command: 'reasoning', description: 'Заметки по ходу: /reasoning on|off' },
@@ -77,7 +77,7 @@ const COMMANDS_EN = [
77
77
  { command: 'app', description: 'DSH desktop app (not the bridge)' },
78
78
  { command: 'restart', description: 'Restart the bridge: /restart confirm' },
79
79
  { command: 'doctor', description: 'Diagnostics: bridge, network, disk, plugins, session' },
80
- { command: 'logs', description: 'Log: /logs, /logs 100, /logs errors, /logs <text>' },
80
+ { command: 'logs', description: 'Log: /logs, /logs 100, /logs errors, /logs file' },
81
81
  { command: 'help', description: 'All commands and hints' },
82
82
  { command: 'lang', description: 'Interface language: en, ru, zh' },
83
83
  { command: 'reasoning', description: 'Working notes: /reasoning on|off' },
@@ -107,7 +107,7 @@ const COMMANDS_ZH = [
107
107
  { command: 'app', description: 'DSH 桌面应用(不是桥接)' },
108
108
  { command: 'restart', description: '重启桥接:/restart confirm' },
109
109
  { command: 'doctor', description: '诊断:桥接、网络、磁盘、插件、会话' },
110
- { command: 'logs', description: '日志:/logs、/logs 100、/logs errors、/logs <文本>' },
110
+ { command: 'logs', description: '日志:/logs、/logs 100、/logs errors、/logs file' },
111
111
  { command: 'help', description: '全部命令与提示' },
112
112
  { command: 'lang', description: '界面语言:en、ru、zh' },
113
113
  { command: 'reasoning', description: '工作记录:/reasoning on|off' },
package/control.mjs CHANGED
@@ -368,6 +368,21 @@ function recentSessions(cwd, limit, lang = 'ru') { const root = join(DSH_HOME,
368
368
  .map((row) => ({ ...row, title: titles.get(bareId(row.id))?.title || t(lang, 'ctrl.sessions.untitled') }));
369
369
  }
370
370
 
371
+ /**
372
+ * A session's title, read from DSH's own projection cache. `/sessions` already
373
+ * shows these, and the status card is a worse place to lose one: the card is
374
+ * what a person screenshots. Empty when the session was never titled.
375
+ */
376
+ function sessionTitle(id) {
377
+ const record = readJson(join(DSH_HOME, 'storages', 'session_projcache', 'sessions', `session-${bareId(id)}.json`));
378
+ const rows = record?.record?.rows ?? record?.rows ?? {};
379
+ const title = rows.title?.val;
380
+ if (typeof title === 'string' && title.trim()) return title.trim();
381
+ const first = rows.titleInput?.val?.first?.text;
382
+ if (typeof first === 'string' && first.trim()) return first.trim().split('\n')[0].slice(0, 80);
383
+ return '';
384
+ }
385
+
371
386
  /** Skills directory listing. */
372
387
  function skillsOf() {
373
388
  const dir = join(DSH_HOME, 'skills');
@@ -494,7 +509,7 @@ export async function handleControl(ctx) {
494
509
  // ("how much context is left", "how big is this session").
495
510
  const sessionId = state.sessions[key] || '';
496
511
  const stats = sessionId ? sessionStats(sessionFile(join(DSH_HOME, 'sessions'), sessionId)) : null;
497
- const title = sessionId ? state.titles?.[key] : '';
512
+ const title = sessionId ? (state.titles?.[key] || sessionTitle(sessionId)) : '';
498
513
  const lines = [t(lang, 'ctrl.status.head')];
499
514
  lines.push(t(lang, 'ctrl.status.session', { id: sessionId || t(lang, 'ctrl.session.none') }));
500
515
  if (title) lines.push(t(lang, 'ctrl.status.title', { title }));
@@ -1230,6 +1245,15 @@ export async function handleControl(ctx) {
1230
1245
  if (installed && latest && installed !== latest) lines.push(t(lang, 'ctrl.version.update', { v: latest }));
1231
1246
  lines.push(t(lang, 'ctrl.version.root', { path: where }));
1232
1247
  lines.push(t(lang, 'ctrl.version.hint'));
1248
+ // The number above comes from package.json on disk; the code actually
1249
+ // answering this came from the files as they were at process start. When
1250
+ // ./sync-runtime.mjs (or /update) has since replaced them, saying so
1251
+ // beats a version that reads as live while it is not.
1252
+ const started = Date.now() - process.uptime() * 1000;
1253
+ const newest = newestModuleMtime(where);
1254
+ if (newest && newest > started + 2000) {
1255
+ lines.push(t(lang, 'ctrl.version.stale', { when: stamp(newest) }));
1256
+ }
1233
1257
  say(lines.join('\n'));
1234
1258
  return true;
1235
1259
  }
@@ -1317,6 +1341,19 @@ function bridgeVersion() {
1317
1341
  }
1318
1342
  }
1319
1343
 
1344
+ /** Newest mtime among the modules a bridge install is made of, or 0. */
1345
+ function newestModuleMtime(root) {
1346
+ let newest = 0;
1347
+ try {
1348
+ for (const name of readdirSync(root)) {
1349
+ if (!name.endsWith('.mjs')) continue;
1350
+ const at = statSync(join(root, name)).mtimeMs;
1351
+ if (at > newest) newest = at;
1352
+ }
1353
+ } catch {}
1354
+ return newest;
1355
+ }
1356
+
1320
1357
  /** Latest published version of an npm package, or '' when npm is unreachable. */
1321
1358
  function npmLatest(name) {
1322
1359
  try {
package/i18n.mjs CHANGED
@@ -136,6 +136,7 @@ const DICT = {
136
136
  'ctrl.version.offline': 'unreachable',
137
137
  'ctrl.version.update': 'Update available: /update, then /update confirm',
138
138
  'ctrl.version.root': 'Bridge directory: {path}',
139
+ 'ctrl.version.stale': 'Files are newer than this process ({when}) — /restart confirm loads them.',
139
140
  'ctrl.version.hint': 'The new code loads after /restart confirm; the current chat keeps running until then.',
140
141
  'ctrl.update.available': 'Version {from} is running, {to} is on npm.\nInstall it: /update confirm.\nEverything keeps working on the old code until /restart confirm.',
141
142
  'ctrl.update.current': 'Already on {v} — the latest published version.',
@@ -408,6 +409,7 @@ const DICT = {
408
409
  'ctrl.version.offline': 'недоступен',
409
410
  'ctrl.version.update': 'Есть обновление: /update, затем /update confirm',
410
411
  'ctrl.version.root': 'Каталог моста: {path}',
412
+ 'ctrl.version.stale': 'Файлы новее запуска ({when}) — /restart confirm загрузит их.',
411
413
  'ctrl.version.hint': 'Новый код включится после /restart confirm — до этого чат работает как есть.',
412
414
  'ctrl.update.available': 'Работает {from}, на npm уже {to}.\nПоставить: /update confirm.\nДо /restart confirm всё работает на старом коде.',
413
415
  'ctrl.update.current': 'Уже стоит {v} — это последняя опубликованная версия.',
@@ -680,6 +682,7 @@ const DICT = {
680
682
  'ctrl.version.offline': '不可达',
681
683
  'ctrl.version.update': '有更新:/update,然后 /update confirm',
682
684
  'ctrl.version.root': '桥接目录:{path}',
685
+ 'ctrl.version.stale': '文件比本进程更新({when})—— /restart confirm 后生效。',
683
686
  'ctrl.version.hint': '新代码在 /restart confirm 之后生效;在此之前聊天照常运行。',
684
687
  'ctrl.update.available': '当前 {from},npm 上已是 {to}。\n安装:/update confirm。\n在 /restart confirm 之前一切仍用旧代码。',
685
688
  'ctrl.update.current': '已经是 {v} —— 最新发布版本。',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-tg-bridge",
3
- "version": "1.7.4",
3
+ "version": "1.7.6",
4
4
  "description": "Telegram bridge for DeepSeek Harness: text, voice, photos and project-per-topic sessions without opening the desktop app",
5
5
  "type": "module",
6
6
  "main": "plugin-bridge.mjs",