dsh-tg-bridge 1.8.1 → 1.9.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 CHANGED
@@ -16,8 +16,8 @@ blocks.
16
16
  - **Project per topic**: `/cd my-app`, and all turns run from that directory.
17
17
  - **Goal and checklist per topic**: `/goal`, `/task`; both survive restarts and are prepended to every turn.
18
18
  - **Live progress**: one edited message per turn — steps, a timer and the cache hit rate, plus
19
- the model's reasoning in a collapsed block you can tap open (no extra messages, the whole
20
- trail stays with the turn).
19
+ the model's reasoning in a collapsed block you can tap open. A long turn adds a second
20
+ collapsed block with every tool call, so the whole run stays in the chat as one message.
21
21
  - **No lost messages**: a journal with acknowledgement and replay.
22
22
  - **Fail-fast**: when the quota runs out it switches to a free model right away.
23
23
  - **`dsh-tg check`**: diagnostics in one command, no changes to the system.
@@ -269,6 +269,9 @@ rate-limits edits), escaped, and trimmed to its tail when a turn thinks longer t
269
269
  can hold; the panel never exceeds one message. If the API refuses the markup, the same content
270
270
  is retried as plain text.
271
271
 
272
+ **The steps.** Three calls fit inline. A turn that makes more moves its complete step list into
273
+ a second collapsed block, so "what did it actually run" is one tap away instead of a count.
274
+
272
275
  **The agent's own notes.** The agent can add a short decision trail:
273
276
 
274
277
  ```bash
package/i18n.mjs CHANGED
@@ -31,7 +31,8 @@ const DICT = {
31
31
  'msg.transcribing': '🎤 Transcribing…',
32
32
  'status.steps': 'steps',
33
33
  'status.thinking': 'waiting for the model',
34
- 'status.thinkTitle': 'Reasoning',
34
+ 'status.thinkTitle': 'Reasoning',
35
+ 'status.stepsTitle': 'Steps',
35
36
  'status.thinkCut': 'earlier reasoning hidden',
36
37
  'err.timeout': 'no activity for {min} min — turn interrupted',
37
38
  'err.generic': 'something went wrong',
@@ -394,7 +395,8 @@ const DICT = {
394
395
  'msg.transcribing': '🎤 Расшифровываю…',
395
396
  'status.steps': 'шагов',
396
397
  'status.thinking': 'жду модель',
397
- 'status.thinkTitle': 'Размышления',
398
+ 'status.thinkTitle': 'Размышления',
399
+ 'status.stepsTitle': 'Шаги',
398
400
  'status.thinkCut': 'начало скрыто',
399
401
  'err.timeout': 'нет активности {min} мин — ход прерван',
400
402
  'err.generic': 'что-то пошло не так',
@@ -757,7 +759,8 @@ const DICT = {
757
759
  'msg.transcribing': '🎤 正在转写…',
758
760
  'status.steps': '步',
759
761
  'status.thinking': '等待模型',
760
- 'status.thinkTitle': '推理',
762
+ 'status.thinkTitle': '推理',
763
+ 'status.stepsTitle': '步骤',
761
764
  'status.thinkCut': '前文已省略',
762
765
  'err.timeout': '{min} 分钟无活动 — 已中断',
763
766
  'err.generic': '出现错误',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-tg-bridge",
3
- "version": "1.8.1",
3
+ "version": "1.9.0",
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
@@ -18,18 +18,28 @@ function secondsUnit(lang) {
18
18
  return lang === 'en' ? 's' : lang === 'zh' ? '秒' : 'с';
19
19
  }
20
20
 
21
- /** How much of the reasoning stream the panel keeps; the tail is the useful end. */
22
- const THINKING_MAX = 2400;
21
+ /** How much of the reasoning stream a block keeps; the tail is the useful end. */
22
+ const THINKING_MAX = 2000;
23
23
  /** Telegram rejects a message over 4096 characters; the rest needs room too. */
24
24
  const PANEL_MAX = 3900;
25
+ /** Steps stay short lines, so a long turn can show all of them. */
26
+ const STEPS_MAX = 1600;
27
+
28
+ /** Collapse `text` to its tail, saying so when something was dropped. */
29
+ function tailOf(text, room) {
30
+ if (text.length <= room) return { text, cut: false };
31
+ return { text: text.slice(-room), cut: true };
32
+ }
25
33
 
26
34
  /**
27
35
  * One status message per turn, rewritten in place.
28
36
  *
29
- * `thinking` is the model's reasoning for this turn. It sits inside Telegram's
30
- * native `<blockquote expandable>`: collapsed it is one line, tapped it shows
31
- * the whole trail, and it never floods the chat. `plain` is the same content
32
- * without markup, for the fallback path when the parser refuses a message.
37
+ * Long content lives in Telegram's native `<blockquote expandable>`: collapsed it
38
+ * is one line, tapped it shows the whole trail, and it never floods the chat. Two
39
+ * blocks at most — the model's reasoning and, when a turn makes more than three
40
+ * tool calls, the full step list — so the chat still reads as one message per
41
+ * turn. `plain` is the same content without markup, for the fallback path when
42
+ * the parser refuses a message and for `plainText` installs.
33
43
  */
34
44
  export function progressPanel({
35
45
  lang = 'ru', seconds = 0, final = false, steps = [], thoughts = [], thinking = '', cache = '',
@@ -38,33 +48,38 @@ export function progressPanel({
38
48
  ? `✅ ${t(lang, 'status.done')} · ${seconds} ${secondsUnit(lang)}`
39
49
  : `⏳ ${t(lang, 'status.working')}… ${seconds} ${secondsUnit(lang)}`;
40
50
  const mind = thoughts.map((line) => `💭 ${line}`);
41
- // Three recent steps is enough to see the shape of the work; six lines of
42
- // shell commands read as noise on a phone.
43
- const tail = steps.slice(-3).map((line) => `• ${line}`);
44
- const more = steps.length > 3 ? t(lang, 'status.more', { n: steps.length - 3 }) : '';
45
- const fixed = [head, ...mind, ...tail, more, cache].filter(Boolean).join('\n').length;
46
- const room = Math.max(400, Math.min(THINKING_MAX, PANEL_MAX - fixed - 80));
47
- let body = String(thinking || '').trim();
48
- let cut = false;
49
- if (body.length > room) {
50
- body = body.slice(-room);
51
- cut = true;
52
- }
53
- const label = `🧠 ${t(lang, 'status.thinkTitle')}${cut ? ` · ${t(lang, 'status.thinkCut')}` : ''}`;
51
+ const base = [head, ...mind, cache].filter(Boolean).join('\n').length;
52
+
53
+ // Up to three steps fit inline and read better there; a longer turn would turn
54
+ // the panel into a wall of shell commands, so its steps move into a block.
55
+ const many = steps.length > 3;
56
+ const inline = many ? [] : steps.map((line) => `• ${line}`);
57
+ const stepsRoom = Math.max(0, Math.min(STEPS_MAX, PANEL_MAX - base - 1200));
58
+ const all = many
59
+ ? tailOf(steps.map((line) => `• ${line}`).join('\n'), stepsRoom)
60
+ : { text: '', cut: false };
61
+ const stepsLabel = `🛠 ${t(lang, 'status.stepsTitle')} · ${steps.length}`
62
+ + `${all.cut ? ` · ${t(lang, 'status.thinkCut')}` : ''}`;
63
+
64
+ const fixed = base + inline.join('\n').length + all.text.length + 120;
65
+ const room = Math.max(400, Math.min(THINKING_MAX, PANEL_MAX - fixed));
66
+ const body = tailOf(String(thinking || '').trim(), room);
67
+ const thinkLabel = `🧠 ${t(lang, 'status.thinkTitle')}${body.cut ? ` · ${t(lang, 'status.thinkCut')}` : ''}`;
68
+
54
69
  const html = [
55
70
  head,
56
71
  ...mind.map((line) => escapeHtml(line)),
57
- body ? `<blockquote expandable>${escapeHtml(label)}\n${escapeHtml(body)}</blockquote>` : '',
58
- ...tail.map((line) => escapeHtml(line)),
59
- escapeHtml(more),
72
+ body.text ? `<blockquote expandable>${escapeHtml(thinkLabel)}\n${escapeHtml(body.text)}</blockquote>` : '',
73
+ ...inline.map((line) => escapeHtml(line)),
74
+ all.text ? `<blockquote expandable>${escapeHtml(stepsLabel)}\n${escapeHtml(all.text)}</blockquote>` : '',
60
75
  escapeHtml(cache),
61
76
  ].filter(Boolean).join('\n');
62
77
  const plain = [
63
78
  head,
64
79
  ...mind,
65
- body ? `${label}\n${body}` : '',
66
- ...tail,
67
- more,
80
+ body.text ? `${thinkLabel}\n${body.text}` : '',
81
+ ...inline,
82
+ all.text ? `${stepsLabel}\n${all.text}` : '',
68
83
  cache,
69
84
  ].filter(Boolean).join('\n');
70
85
  return { html, plain };