dsh-tg-bridge 1.19.11 → 1.19.12

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.
Files changed (2) hide show
  1. package/bridge.mjs +12 -5
  2. package/package.json +1 -1
package/bridge.mjs CHANGED
@@ -1180,7 +1180,7 @@ async function startProgress(chatId, threadId, lang = config.lang || 'en', task
1180
1180
  const steps = [];
1181
1181
  const thinkingParts = [];
1182
1182
  /** Last reported token usage for this turn, for the cache line. */
1183
- const usage = { inputTokens: 0, cacheReadTokens: 0, outputTokens: 0 };
1183
+ const usage = { inputTokens: 0, cacheReadTokens: 0, outputTokens: 0, outputTotal: 0 };
1184
1184
  let messageId = 0;
1185
1185
  let lastEdit = 0;
1186
1186
  let dirty = false;
@@ -1235,7 +1235,7 @@ async function startProgress(chatId, threadId, lang = config.lang || 'en', task
1235
1235
  // number is the turn's average — output tokens over wall time — because
1236
1236
  // that is what "долго" means to the reader: a slow provider and a turn
1237
1237
  // that spends its minutes in tools look identical without it.
1238
- speed: speedOf(usage.outputTokens, Date.now() - started),
1238
+ speed: speedOf(usage.outputTotal, Date.now() - started),
1239
1239
  final,
1240
1240
  steps,
1241
1241
  thoughts,
@@ -1357,7 +1357,14 @@ async function startProgress(chatId, threadId, lang = config.lang || 'en', task
1357
1357
  if (event.type === 'status' && event.usage) {
1358
1358
  if (Number.isFinite(event.usage.inputTokens)) usage.inputTokens = event.usage.inputTokens;
1359
1359
  if (Number.isFinite(event.usage.cacheReadTokens)) usage.cacheReadTokens = event.usage.cacheReadTokens;
1360
- if (Number.isFinite(event.usage.outputTokens)) usage.outputTokens = event.usage.outputTokens;
1360
+ // `outputTokens` is per step, not cumulative: a turn of twenty steps
1361
+ // reports twenty small numbers, and dividing the last one by the whole
1362
+ // turn would claim 0.6 tok/s for a turn that ran at eighty. Sum the
1363
+ // changes, and keep the last value so a repeated event adds nothing.
1364
+ if (Number.isFinite(event.usage.outputTokens) && event.usage.outputTokens > 0) {
1365
+ if (event.usage.outputTokens !== usage.outputTokens) usage.outputTotal += event.usage.outputTokens;
1366
+ usage.outputTokens = event.usage.outputTokens;
1367
+ }
1361
1368
  schedule();
1362
1369
  return;
1363
1370
  }
@@ -2887,8 +2894,8 @@ async function main() {
2887
2894
  // inside handleMessage: the steer branch below reaches the running agent
2888
2895
  // without going through handleMessage, so a stranger the bot can see used
2889
2896
  // to be able to inject text into the owner's live turn.
2890
- if (!allowedSender(msg)) {
2891
- log(`ignored update from ${msg.from?.id} (chat ${msg.chat?.id}${msg.message_thread_id ? ` topic=${msg.message_thread_id}` : ''})`);
2897
+ if (!allowedSender(msg, config)) {
2898
+ log(`ignored update from ${msg.from?.id} (chat ${msg.chat?.id}${msg.message_thread_id ? ` topic=${msg.message_thread_id}` : ''}) allowlist=${JSON.stringify(config.allowedUserIds ?? [])}`);
2892
2899
  ack(update.update_id);
2893
2900
  return;
2894
2901
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-tg-bridge",
3
- "version": "1.19.11",
3
+ "version": "1.19.12",
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",