dsh-tg-bridge 1.19.10 → 1.19.11

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
@@ -1146,6 +1146,21 @@ function killTurn(key) {
1146
1146
  }
1147
1147
 
1148
1148
 
1149
+ /**
1150
+ * Average generation speed of a turn, in tokens per second, or 0 when unknown.
1151
+ *
1152
+ * Output tokens over wall time, not over "time spent generating": the bridge
1153
+ * sees one stream and cannot separate thinking from tool calls, and the honest
1154
+ * question the number answers is "is this turn moving", not "how fast is the
1155
+ * provider". A turn younger than a couple of seconds says nothing — one token
1156
+ * in one second is not a measurement.
1157
+ */
1158
+ function speedOf(outputTokens, ms) {
1159
+ if (!Number.isFinite(outputTokens) || outputTokens <= 0) return 0;
1160
+ if (!Number.isFinite(ms) || ms < 3000) return 0;
1161
+ return Math.round(outputTokens / (ms / 1000));
1162
+ }
1163
+
1149
1164
  /**
1150
1165
  * One editable status message per turn.
1151
1166
  *
@@ -1165,7 +1180,7 @@ async function startProgress(chatId, threadId, lang = config.lang || 'en', task
1165
1180
  const steps = [];
1166
1181
  const thinkingParts = [];
1167
1182
  /** Last reported token usage for this turn, for the cache line. */
1168
- const usage = { inputTokens: 0, cacheReadTokens: 0 };
1183
+ const usage = { inputTokens: 0, cacheReadTokens: 0, outputTokens: 0 };
1169
1184
  let messageId = 0;
1170
1185
  let lastEdit = 0;
1171
1186
  let dirty = false;
@@ -1216,6 +1231,11 @@ async function startProgress(chatId, threadId, lang = config.lang || 'en', task
1216
1231
  // name comes from Telegram, cached: one API call per topic per process.
1217
1232
  topic: threadId ? t(lang, 'bridge.progress.topic', { n: threadId, name: topicName(chatId, threadId) || t(lang, 'bridge.progress.topicNoName') }) : '',
1218
1233
  seconds: Math.round((Date.now() - started) / 1000),
1234
+ // How fast this turn is actually generating, in tokens per second. The
1235
+ // number is the turn's average — output tokens over wall time — because
1236
+ // that is what "долго" means to the reader: a slow provider and a turn
1237
+ // that spends its minutes in tools look identical without it.
1238
+ speed: speedOf(usage.outputTokens, Date.now() - started),
1219
1239
  final,
1220
1240
  steps,
1221
1241
  thoughts,
@@ -1330,10 +1350,14 @@ async function startProgress(chatId, threadId, lang = config.lang || 'en', task
1330
1350
  return;
1331
1351
  }
1332
1352
  // Usage rides on the status events; keep the latest numbers so the final
1333
- // line can show the cache hit rate of this very turn.
1353
+ // line can show the cache hit rate of this very turn, and so the head can
1354
+ // show how fast it is going — "долго" is usually either a slow provider or
1355
+ // a turn that spends its time in tools, and the panel could not tell them
1356
+ // apart.
1334
1357
  if (event.type === 'status' && event.usage) {
1335
1358
  if (Number.isFinite(event.usage.inputTokens)) usage.inputTokens = event.usage.inputTokens;
1336
1359
  if (Number.isFinite(event.usage.cacheReadTokens)) usage.cacheReadTokens = event.usage.cacheReadTokens;
1360
+ if (Number.isFinite(event.usage.outputTokens)) usage.outputTokens = event.usage.outputTokens;
1337
1361
  schedule();
1338
1362
  return;
1339
1363
  }
@@ -2068,6 +2092,12 @@ function steerRunningTurn(msg, text, sessionId, thread) {
2068
2092
  say: SAY,
2069
2093
  });
2070
2094
  log(`steer ${job.id} -> ${sessionId} (${text.length} chars)`);
2095
+ // Confirm the moment the job is written, not 90 seconds later. The plugin
2096
+ // hands it to the running agent at its next step, and a step can be a
2097
+ // six-minute test run: without this line the addition looked lost, which is
2098
+ // exactly what "steer стала хуже" describes. The wait notice below then only
2099
+ // speaks when the job really has not been picked up.
2100
+ send(msg.chat.id, t(lang, 'steer.queued'), thread).catch(() => {});
2071
2101
  watchSteer(job, msg, text, thread, lang);
2072
2102
  return job;
2073
2103
  }
package/i18n/en.mjs CHANGED
@@ -197,6 +197,7 @@ export default {
197
197
  'btn.doctor': 'Doctor',
198
198
  'status.cache': 'cache',
199
199
  'status.more': '…and {n} more',
200
+ 'status.speed': 'tok/s',
200
201
  'status.cacheLine': '🧠 cache: {pct}% ({k}k from cache)',
201
202
  'msg.topicLog': '📌 New topic: {preview}\n→ work happens in the topic, this is the log.',
202
203
  'msg.transcribing': '🎤 Transcribing…',
@@ -209,6 +210,7 @@ export default {
209
210
  'err.generic': 'something went wrong',
210
211
  'msg.busy.since': '⏳ The previous turn has been running for {min} min — your message is queued.\nIf it stalls, /stop interrupts it and I take yours right away.',
211
212
  'msg.busy.now': '⏳ The previous turn is still running — your message is queued.\nIf it stalls, /stop interrupts it and I take yours right away.',
213
+ 'steer.queued': '↪ Addition received — I will fold it in at the next step of this turn.',
212
214
  'steer.ackFallback': '↪ Got the addition — folding it into this turn.',
213
215
  'msg.started': 'Telegram bridge for DSH is running (headless). Send a task; /help for commands.',
214
216
  'msg.restarted': 'Bridge restarted — back online (pid {pid}).\nThe topic and session are the same; keep going.',
package/i18n/ru.mjs CHANGED
@@ -197,6 +197,7 @@ export default {
197
197
  'btn.doctor': 'Диагноз',
198
198
  'status.cache': 'кэш',
199
199
  'status.more': '…и ещё {n}',
200
+ 'status.speed': 'т/с',
200
201
  'status.cacheLine': '🧠 кэш: {pct}% ({k}k из кэша)',
201
202
  'msg.topicLog': '📌 Новая тема: {preview}\n→ работа идёт в теме, здесь — лог.',
202
203
  'msg.transcribing': '🎤 Расшифровываю…',
@@ -209,6 +210,7 @@ export default {
209
210
  'err.generic': 'что-то пошло не так',
210
211
  'msg.busy.since': '⏳ Предыдущий ход идёт уже {min} мин — твоё сообщение в очереди.\nЕсли это затянулось, /stop прервёт ход, и я сразу возьмусь за твоим.',
211
212
  'msg.busy.now': '⏳ Предыдущий ход ещё идёт — твоё сообщение в очереди.\nЕсли это затянулось, /stop прервёт ход, и я сразу возьмусь за твоим.',
213
+ 'steer.queued': '↪ Дополнение принято — передам его на следующем шаге этого хода.',
212
214
  'steer.ackFallback': '↪ Принял дополнение — учту его в этом же ходе.',
213
215
  'msg.started': 'Telegram-мост DSH запущен (headless). Пиши задачу; /help — команды.',
214
216
  'msg.restarted': 'Мост перезапущен — на связи (pid {pid}).\nТема и сессия прежние, можно продолжать.',
package/i18n/zh.mjs CHANGED
@@ -197,6 +197,7 @@ export default {
197
197
  'btn.doctor': '诊断',
198
198
  'status.cache': '缓存',
199
199
  'status.more': '…还有 {n} 条',
200
+ 'status.speed': 'tok/s',
200
201
  'status.cacheLine': '🧠 缓存:{pct}%({k}k 来自缓存)',
201
202
  'msg.topicLog': '📌 新主题:{preview}\n→ 工作在主题里进行,这里是日志。',
202
203
  'msg.transcribing': '🎤 正在转写…',
@@ -209,6 +210,7 @@ export default {
209
210
  'err.generic': '出现错误',
210
211
  'msg.busy.since': '⏳ 上一轮已运行 {min} 分钟 —— 你的消息在队列中。\n如果太久,/stop 会中断它,我马上处理你的消息。',
211
212
  'msg.busy.now': '⏳ 上一轮还在运行 —— 你的消息在队列中。\n如果太久,/stop 会中断它,我马上处理你的消息。',
213
+ 'steer.queued': '↪ 已收到补充 — 会在这一轮的下一步并入。',
212
214
  'steer.ackFallback': '↪ 收到补充,会在本轮里一并处理。',
213
215
  'msg.started': 'DSH 的 Telegram 桥已启动(headless)。直接发送任务;/help 查看命令。',
214
216
  'msg.restarted': '桥已重启,连接正常(pid {pid})。\n主题和会话不变,可以继续。',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-tg-bridge",
3
- "version": "1.19.10",
3
+ "version": "1.19.11",
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
@@ -101,15 +101,21 @@ export function progressPanel({
101
101
  // group can run two topics at once and the cards look identical; the head is
102
102
  // the only part that survives the card being quoted or forwarded.
103
103
  topic = '',
104
+ // Average generation speed of this turn in tokens per second, 0 when unknown.
105
+ // It rides in the head next to the clock: the clock alone cannot tell a slow
106
+ // provider from a turn that spends its minutes in tools.
107
+ speed = 0,
104
108
  } = {}) {
105
109
  const snippet = String(task).replace(/\s+/g, ' ').trim().slice(0, 48);
106
110
  const mark = String(chip).trim() ? ` · ${String(chip).trim()}` : '';
107
111
  const where = String(topic || '').trim() ? `\n${String(topic).trim()}` : '';
112
+ // The speed sits right after the clock so the two read as one measurement.
113
+ const rate = Number(speed) > 0 ? ` · ${Math.round(Number(speed))} ${t(lang, 'status.speed')}` : '';
108
114
  const head = final
109
- ? `✅ ${t(lang, 'status.done')} · ${seconds} ${secondsUnit(lang)}${mark}${where}`
115
+ ? `✅ ${t(lang, 'status.done')} · ${seconds} ${secondsUnit(lang)}${rate}${mark}${where}`
110
116
  : snippet
111
- ? `⏳ ${t(lang, 'status.accepted')}: «${snippet}${String(task).trim().length > 48 ? '…' : ''}» · ${seconds} ${secondsUnit(lang)}${mark}${where}`
112
- : `⏳ ${t(lang, 'status.working')}… ${seconds} ${secondsUnit(lang)}${mark}${where}`;
117
+ ? `⏳ ${t(lang, 'status.accepted')}: «${snippet}${String(task).trim().length > 48 ? '…' : ''}» · ${seconds} ${secondsUnit(lang)}${rate}${mark}${where}`
118
+ : `⏳ ${t(lang, 'status.working')}… ${seconds} ${secondsUnit(lang)}${rate}${mark}${where}`;
113
119
  const mind = thoughts.map((line) => `💭 ${line}`);
114
120
  const base = [head, ...mind, cache].filter(Boolean).join('\n').length;
115
121