dsh-tg-bridge 1.9.0 → 1.9.2

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/bridge.mjs CHANGED
@@ -33,7 +33,7 @@ import { handleControl, CONTROL_COMMANDS, modelOf, reasoningOf } from './control
33
33
  import { drainGoalJobs, goalOf, renderPromptBlock } from './goals.mjs';
34
34
  import { renderPrices } from './prices.mjs';
35
35
  import { t, resolveLang } from './i18n.mjs';
36
- import { progressPanel } from './panel.mjs';
36
+ import { progressPanel, stepLine, addStep } from './panel.mjs';
37
37
 
38
38
  const HOME = homedir();
39
39
  const DSH_HOME = process.env.DSH_HOME || join(HOME, '.dsh');
@@ -925,22 +925,6 @@ function killTurn(key) {
925
925
  }
926
926
  }
927
927
 
928
- /** Short, human one-liner for a tool call, mirroring what Hermes shows. */
929
- function toolLine(event) {
930
- const tool = event.tool || 'tool';
931
- const input = event.input ?? {};
932
- const pick = input.command ?? input.description ?? input.file_path ?? input.path ?? input.pattern ?? input.query ?? input.url ?? '';
933
- let text = String(pick).replace(/\s+/g, ' ').trim();
934
- if (input.command) {
935
- // A shell command is a wall of text; keep the first statement and its
936
- // verb, so the line reads "pwsh: git status" instead of the whole script.
937
- text = text.split(';')[0].trim();
938
- text = text.replace(/^(pwsh|powershell|cmd|bash)(\.exe)?\s+(-\S+\s+)*/i, '');
939
- const verb = text.match(/^([A-Za-z0-9_.\-]+(?:\s+[a-z][a-z0-9-]*)?)/);
940
- if (verb) text = verb[1];
941
- }
942
- return text ? `${tool}: ${text.slice(0, 48)}` : tool;
943
- }
944
928
 
945
929
  /**
946
930
  * One editable status message per turn.
@@ -1086,7 +1070,7 @@ async function startProgress(chatId, threadId, lang = 'ru') {
1086
1070
  },
1087
1071
  handle(event) {
1088
1072
  if (event.type === 'tool_call') {
1089
- steps.push(toolLine(event));
1073
+ addStep(steps, stepLine(event));
1090
1074
  schedule();
1091
1075
  return;
1092
1076
  }
@@ -1531,7 +1515,7 @@ ${t(lang, 'help.body')}`,
1531
1515
  if (event.type === 'tool_call') {
1532
1516
  telemetry.tools += 1;
1533
1517
  telemetry.steps += 1;
1534
- log(` tool[${telemetry.steps}] ${toolLine(event).slice(0, 140)}`);
1518
+ log(` tool[${telemetry.steps}] ${(stepLine(event) || event.tool || 'tool').slice(0, 140)}`);
1535
1519
  } else if (event.type === 'tool_result') {
1536
1520
  const failed = event.status && event.status !== 'completed';
1537
1521
  log(` tool[${telemetry.steps}] ${failed ? 'ОШИБКА' : 'ok'} ${String(event.tool || '').slice(0, 40)}`);
package/control.mjs CHANGED
@@ -1066,7 +1066,7 @@ export async function handleControl(ctx) {
1066
1066
  return t(lang, 'ctrl.remind.inDay', { n: Math.round(hours / 24) });
1067
1067
  };
1068
1068
 
1069
- if (!input) {
1069
+ if (!input || input === 'list') {
1070
1070
  if (ahead.length === 0) {
1071
1071
  say([t(lang, 'ctrl.remind.title'), t(lang, 'ctrl.remind.empty'), t(lang, 'ctrl.remind.hint')].join('\n'));
1072
1072
  return true;
@@ -1692,7 +1692,7 @@ export async function handleControl(ctx) {
1692
1692
  return true;
1693
1693
  }
1694
1694
  const file = sessionFile(join(DSH_HOME, 'sessions'), sessionId);
1695
- const text = file ? lastTurnReasoning(file, { maxChars: 4000 }) : '';
1695
+ const text = file ? lastTurnReasoning(file, { maxChars: 20000 }) : '';
1696
1696
  if (!text) {
1697
1697
  // Not every turn plans: a one-word answer has no reasoning part at all.
1698
1698
  // Saying "here is what the last turn answered" beats a dead end that
@@ -1703,7 +1703,16 @@ export async function handleControl(ctx) {
1703
1703
  : t(lang, 'ctrl.thoughts.none'));
1704
1704
  return true;
1705
1705
  }
1706
- say(t(lang, 'ctrl.thoughts.title', { chars: text.length }) + '\n\n' + text);
1706
+ // A message caps at 4096 characters; a long plan goes out in parts instead
1707
+ // of being cut at the first one with a "…" that hides the rest.
1708
+ const title = t(lang, 'ctrl.thoughts.title', { chars: text.length });
1709
+ const parts = [];
1710
+ for (let at = 0; at < text.length; at += 3600) parts.push(text.slice(at, at + 3600));
1711
+ parts.forEach((part, index) => {
1712
+ say(parts.length > 1
1713
+ ? `${title} (${index + 1}/${parts.length})\n\n${part}`
1714
+ : `${title}\n\n${part}`);
1715
+ });
1707
1716
  return true;
1708
1717
  }
1709
1718
 
package/i18n.mjs CHANGED
@@ -19,7 +19,7 @@ const DICT = {
19
19
  'status.failed': 'Turn failed',
20
20
  'status.queued': 'queued',
21
21
  'status.stop': 'Stop',
22
- 'help.body': "Write the task as plain text. Each forum topic is its own session:\n\nWork: /cd \u003cproject\u003e · /new · /stop · /send \u003cfile\u003e · /seed \u003ctext\u003e\nGoals: /goal · /task\nSessions: /status · /sessions [n] · /resume \u003cid\u003e\nAgents: /agents · /agents \u003cid\u003e\nModels: /model · /model \u003cid\u003e · /prices · /thoughts\nTuning: /effort · /permissions · /preset · /plan · /jobs · /remind\nExtensions: /skills · /plugins · /plugin add|remove · /soul\nVersions: /version · /update · /update confirm\nOther: /lang · /reasoning · /doctor · /logs [errors|N] · /app · /restart · /help",
22
+ 'help.body': "Write the task as plain text. Each forum topic is its own session:\n\nWork: /cd \u003cproject\u003e · /new · /stop · /send \u003cfile\u003e · /seed \u003ctext\u003e\nGoals: /goal · /task\nSessions: /status · /sessions [n] · /resume \u003cid\u003e\nAgents: /agents · /agents set model|depth|filter … @tool\nModels: /model · /model \u003cid\u003e · /prices · /thoughts\nTuning: /effort · /permissions · /preset · /plan · /jobs · /remind\nExtensions: /skills · /plugins · /plugin add|remove · /soul\nVersions: /version · /update · /update confirm\nOther: /lang · /reasoning · /doctor · /logs [errors|N] · /app · /restart · /help",
23
23
  'btn.stop': 'Stop',
24
24
  'btn.logs': 'Logs',
25
25
  'btn.retry': 'Retry',
@@ -314,7 +314,7 @@ const DICT = {
314
314
  'bridge.cb.denied': 'Denied',
315
315
  'bridge.cb.unknown': 'Unknown button',
316
316
  'ctrl.agents.setUsage': 'Usage:\n/agents set model <id> [@tool]\n/agents set depth <n|default> [@tool]\n/agents set filter none|<tool,tool> [@tool]\nWithout @tool every delegation row changes; @subagent or @subagent_fork picks one.',
317
- 'ctrl.agents.setDone': '✅ {name}: delegation rows written.',
317
+ 'ctrl.agents.setDone': '✅ {name}: delegation written.',
318
318
  'ctrl.agents.setSame': 'Already in that state — nothing to write.',
319
319
  'ctrl.agents.setUnknownModel': 'No model "{model}" in this profile. Available: {list}',
320
320
  'ctrl.agents.setBadDepth': 'Depth must be 1–10, or "default" to follow the host.',
@@ -363,7 +363,7 @@ const DICT = {
363
363
  'ctrl.remind.title': '⏰ Reminders',
364
364
  'ctrl.remind.empty': 'Nothing scheduled.',
365
365
  'ctrl.remind.line': '{n}. {when} ({left}) — {text}',
366
- 'ctrl.remind.hint': 'Add: /remind +15m text · /remind 09:30 text · remove: /remind del 1 · clear: /remind clear',
366
+ 'ctrl.remind.hint': 'List: /remind list · Add: /remind +15m text · /remind 09:30 text · remove: /remind del 1 · clear: /remind clear',
367
367
  'ctrl.remind.added': '⏰ {when} — {text}',
368
368
  'ctrl.remind.delDone': 'Removed reminder {n} ({text}).',
369
369
  'ctrl.remind.delUsage': 'Which one? /remind del <number from the list>.',
@@ -383,7 +383,7 @@ const DICT = {
383
383
  'status.failed': 'Ход не удался',
384
384
  'status.queued': 'в очереди',
385
385
  'status.stop': 'Стоп',
386
- 'help.body': "Задачу можно писать обычным текстом. Каждая ветка форума — отдельная сессия:\n\nРабота: /cd \u003cпроект\u003e · /new · /stop · /send \u003cфайл\u003e · /seed \u003cтекст\u003e\nЦели: /goal · /task\nСессии: /status · /sessions [n] · /resume \u003cid\u003e\nАгенты: /agents · /agents \u003cid\u003e\nМодели: /model · /model \u003cid\u003e · /prices · /thoughts\nНастройка: /effort · /permissions · /preset · /plan · /jobs · /remind\nРасширения: /skills · /plugins · /plugin add|remove · /soul\nВерсии: /version · /update · /update confirm\nПрочее: /lang · /reasoning · /doctor · /logs [errors|N] · /app · /restart · /help",
386
+ 'help.body': "Задачу можно писать обычным текстом. Каждая ветка форума — отдельная сессия:\n\nРабота: /cd \u003cпроект\u003e · /new · /stop · /send \u003cфайл\u003e · /seed \u003cтекст\u003e\nЦели: /goal · /task\nСессии: /status · /sessions [n] · /resume \u003cid\u003e\nАгенты: /agents · /agents set model|depth|filter … @tool\nМодели: /model · /model \u003cid\u003e · /prices · /thoughts\nНастройка: /effort · /permissions · /preset · /plan · /jobs · /remind\nРасширения: /skills · /plugins · /plugin add|remove · /soul\nВерсии: /version · /update · /update confirm\nПрочее: /lang · /reasoning · /doctor · /logs [errors|N] · /app · /restart · /help",
387
387
  'btn.stop': 'Стоп',
388
388
  'btn.logs': 'Логи',
389
389
  'btn.retry': 'Повторить',
@@ -678,7 +678,7 @@ const DICT = {
678
678
  'bridge.cb.denied': 'Запрещено',
679
679
  'bridge.cb.unknown': 'Неизвестная кнопка',
680
680
  'ctrl.agents.setUsage': 'Как:\n/agents set model <id> [@инструмент]\n/agents set depth <n|default> [@инструмент]\n/agents set filter none|<инструмент,инструмент> [@инструмент]\nБез @инструмент меняются все строки делегирования; @subagent или @subagent_fork выбирает одну.',
681
- 'ctrl.agents.setDone': '✅ {name}: строки делегирования записаны.',
681
+ 'ctrl.agents.setDone': '✅ {name}: делегирование записано.',
682
682
  'ctrl.agents.setSame': 'Уже так — записывать нечего.',
683
683
  'ctrl.agents.setUnknownModel': 'В этом профиле нет модели «{model}». Доступны: {list}',
684
684
  'ctrl.agents.setBadDepth': 'Глубина — от 1 до 10, либо «default», чтобы следовать хосту.',
@@ -727,7 +727,7 @@ const DICT = {
727
727
  'ctrl.remind.title': '⏰ Напоминания',
728
728
  'ctrl.remind.empty': 'Ничего не запланировано.',
729
729
  'ctrl.remind.line': '{n}. {when} ({left}) — {text}',
730
- 'ctrl.remind.hint': 'Добавить: /remind +15m текст · /remind 09:30 текст · убрать: /remind del 1 · очистить: /remind clear',
730
+ 'ctrl.remind.hint': 'Список: /remind list · добавить: /remind +15m текст · /remind 09:30 текст · убрать: /remind del 1 · очистить: /remind clear',
731
731
  'ctrl.remind.added': '⏰ {when} — {text}',
732
732
  'ctrl.remind.delDone': 'Напоминание {n} убрано ({text}).',
733
733
  'ctrl.remind.delUsage': 'Какое? /remind del <номер из списка>.',
@@ -747,7 +747,7 @@ const DICT = {
747
747
  'status.failed': '运行失败',
748
748
  'status.queued': '排队中',
749
749
  'status.stop': '停止',
750
- 'help.body': "任务直接以文本发送。每个论坛话题是一个独立会话:\n\n工作: /cd \u003c项目\u003e · /new · /stop · /send \u003c文件\u003e · /seed \u003c文本\u003e\n目标: /goal · /task\n会话: /status · /sessions [n] · /resume \u003cid\u003e\n智能体: /agents · /agents \u003cid\u003e\n模型: /model · /model \u003cid\u003e · /prices · /thoughts\n调优: /effort · /permissions · /preset · /plan · /jobs · /remind\n扩展: /skills · /plugins · /plugin add|remove · /soul\n版本: /version · /update · /update confirm\n其他: /lang · /reasoning · /doctor · /logs [errors|N] · /app · /restart · /help",
750
+ 'help.body': "任务直接以文本发送。每个论坛话题是一个独立会话:\n\n工作: /cd \u003c项目\u003e · /new · /stop · /send \u003c文件\u003e · /seed \u003c文本\u003e\n目标: /goal · /task\n会话: /status · /sessions [n] · /resume \u003cid\u003e\n智能体: /agents · /agents set model|depth|filter … @tool\n模型: /model · /model \u003cid\u003e · /prices · /thoughts\n调优: /effort · /permissions · /preset · /plan · /jobs · /remind\n扩展: /skills · /plugins · /plugin add|remove · /soul\n版本: /version · /update · /update confirm\n其他: /lang · /reasoning · /doctor · /logs [errors|N] · /app · /restart · /help",
751
751
  'btn.stop': '停止',
752
752
  'btn.logs': '日志',
753
753
  'btn.retry': '重试',
@@ -1042,7 +1042,7 @@ const DICT = {
1042
1042
  'bridge.cb.denied': '已拒绝',
1043
1043
  'bridge.cb.unknown': '未知按钮',
1044
1044
  'ctrl.agents.setUsage': '用法:\n/agents set model <id> [@工具]\n/agents set depth <n|default> [@工具]\n/agents set filter none|<工具,工具> [@工具]\n省略 @工具 则改动全部委派行;@subagent 或 @subagent_fork 只改一行。',
1045
- 'ctrl.agents.setDone': '✅ {name}:委派行已写入。',
1045
+ 'ctrl.agents.setDone': '✅ {name}:委派设置已写入。',
1046
1046
  'ctrl.agents.setSame': '已经是这样——无需写入。',
1047
1047
  'ctrl.agents.setUnknownModel': '此配置档没有模型「{model}」。可用:{list}',
1048
1048
  'ctrl.agents.setBadDepth': '深度为 1–10,或 default 表示跟随宿主。',
@@ -1091,7 +1091,7 @@ const DICT = {
1091
1091
  'ctrl.remind.title': '⏰ 提醒',
1092
1092
  'ctrl.remind.empty': '没有安排。',
1093
1093
  'ctrl.remind.line': '{n}. {when}({left})— {text}',
1094
- 'ctrl.remind.hint': '添加:/remind +15m 文本 · /remind 09:30 文本 · 删除:/remind del 1 · 清空:/remind clear',
1094
+ 'ctrl.remind.hint': '列表:/remind list · 添加:/remind +15m 文本 · /remind 09:30 文本 · 删除:/remind del 1 · 清空:/remind clear',
1095
1095
  'ctrl.remind.added': '⏰ {when} — {text}',
1096
1096
  'ctrl.remind.delDone': '已删除提醒 {n}({text})。',
1097
1097
  'ctrl.remind.delUsage': '哪一个?/remind del <列表中的编号>。',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-tg-bridge",
3
- "version": "1.9.0",
3
+ "version": "1.9.2",
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",
package/panel.mjs CHANGED
@@ -31,6 +31,48 @@ function tailOf(text, room) {
31
31
  return { text: text.slice(-room), cut: true };
32
32
  }
33
33
 
34
+ /**
35
+ * One line for a tool call in the panel.
36
+ *
37
+ * The harness runs every call in a fresh shell, so most commands start with
38
+ * `cd <dir>`; that prefix says nothing about the work. Strip it (and the shell
39
+ * wrapper) and keep the statement that does something, with its arguments — a
40
+ * list of bare verbs (`pwsh: cd`, `pwsh: node`) is what made the panel read as
41
+ * noise. A call that only changed directory returns '' and is not shown.
42
+ */
43
+ export function stepLine(event) {
44
+ const tool = event.tool || 'tool';
45
+ const input = event.input ?? {};
46
+ const pick = input.command ?? input.description ?? input.file_path ?? input.path
47
+ ?? input.pattern ?? input.query ?? input.url ?? '';
48
+ let text = String(pick).replace(/\r?\n/g, ' ; ').replace(/\s+/g, ' ').trim();
49
+ if (input.command) {
50
+ text = text.replace(/^(pwsh|powershell|cmd|bash)(\.exe)?\s+(-\S+\s+)*/i, '');
51
+ text = text.replace(/^(cd\s+("[^"]*"|'[^']*'|\S+)\s*(?:&&|;)\s*)+/i, '');
52
+ text = text.replace(/^cd\s+("[^"]*"|'[^']*'|\S+)\s*$/i, '').trim();
53
+ text = text.replace(/\s*(?:&&|;|\|\|)\s*[\s\S]*$/, '').trim();
54
+ if (!text) return '';
55
+ }
56
+ return `${tool}: ${text.slice(0, 64)}`;
57
+ }
58
+
59
+ /** Push a step, folding a repeat into the line above it: `×3`, not three rows. */
60
+ export function addStep(steps, line) {
61
+ if (!line) return steps;
62
+ const at = steps.length - 1;
63
+ const prev = at >= 0 ? /^(.*) ×(\d+)$/.exec(steps[at]) : null;
64
+ if (at >= 0 && steps[at] === line) {
65
+ steps[at] = `${line} ×2`;
66
+ return steps;
67
+ }
68
+ if (prev && prev[1] === line) {
69
+ steps[at] = `${line} ×${Number(prev[2]) + 1}`;
70
+ return steps;
71
+ }
72
+ steps.push(line);
73
+ return steps;
74
+ }
75
+
34
76
  /**
35
77
  * One status message per turn, rewritten in place.
36
78
  *
@@ -64,7 +106,10 @@ export function progressPanel({
64
106
  const fixed = base + inline.join('\n').length + all.text.length + 120;
65
107
  const room = Math.max(400, Math.min(THINKING_MAX, PANEL_MAX - fixed));
66
108
  const body = tailOf(String(thinking || '').trim(), room);
67
- const thinkLabel = `🧠 ${t(lang, 'status.thinkTitle')}${body.cut ? ` · ${t(lang, 'status.thinkCut')}` : ''}`;
109
+ // A cut block starts mid-sentence; say so and point at the one command that
110
+ // still has the whole text, otherwise the reasoning reads as broken.
111
+ const thinkLabel = `🧠 ${t(lang, 'status.thinkTitle')}`
112
+ + `${body.cut ? ` · ${t(lang, 'status.thinkCut')} · /thoughts` : ''}`;
68
113
 
69
114
  const html = [
70
115
  head,