dsh-tg-bridge 1.2.1 → 1.2.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.
Files changed (3) hide show
  1. package/README.md +1 -0
  2. package/bridge.mjs +17 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -157,6 +157,7 @@ Telegram → bridge.mjs → dsh --profile headless --json → ответ
157
157
  - [docs/ROADMAP.md](docs/ROADMAP.md) — что дальше
158
158
  - [docs/UX-ANALYSIS.md](docs/UX-ANALYSIS.md) — разбор интерактива
159
159
  - [docs/ACCEPTANCE.md](docs/ACCEPTANCE.md) — критерии приёмки
160
+ - [docs/COST.md](docs/COST.md) — сколько стоит один ход и как это уменьшить
160
161
  - [docs/CHANGELOG.md](docs/CHANGELOG.md) — история изменений
161
162
  - [docs/RELEASE-CRITERIA.md](docs/RELEASE-CRITERIA.md) — критерии готовности релиза
162
163
 
package/bridge.mjs CHANGED
@@ -73,6 +73,8 @@ const config = {
73
73
  };
74
74
  /** Turns currently running, keyed like sessions — `/stop` kills one. */
75
75
  const activeTurns = new Map();
76
+ /** Wall-clock start of the running turn per session key, for the queue notice. */
77
+ const turnStartedAt = new Map();
76
78
  try {
77
79
  Object.assign(config, JSON.parse(readFileSync(join(DIR, 'config.json'), 'utf8')));
78
80
  } catch {}
@@ -1368,9 +1370,15 @@ function enqueue(key, task, onBusy) {
1368
1370
  const queued = queues.has(key);
1369
1371
  const run = prev
1370
1372
  .then(() => acquire())
1371
- .then(() => task())
1373
+ .then(() => {
1374
+ // Remember when the turn actually started: the queue notice has to say
1375
+ // "идёт уже 24 мин", not just "занято" — silence is what reads as a hang.
1376
+ turnStartedAt.set(key, Date.now());
1377
+ return task();
1378
+ })
1372
1379
  .catch((error) => log(`turn queue error ${key}: ${error.message}`))
1373
1380
  .finally(() => {
1381
+ turnStartedAt.delete(key);
1374
1382
  release();
1375
1383
  if (queues.get(key) === run) queues.delete(key);
1376
1384
  // A deferred restart waits for exactly this moment: the answer is out and
@@ -1669,7 +1677,14 @@ async function main() {
1669
1677
  ? async () => {
1670
1678
  await new Promise((resolve) => setTimeout(resolve, Number(config.busyNoticeMs ?? 45000)));
1671
1679
  if (!queues.has(queueKey)) return; // already finished
1672
- await send(msg.chat.id, '⏳ В этой теме ещё идёт предыдущий ход — твоё сообщение в очереди.', thread);
1680
+ const started = turnStartedAt.get(queueKey);
1681
+ const mins = started ? Math.max(1, Math.round((Date.now() - started) / 60000)) : 0;
1682
+ const howLong = mins > 0 ? `идёт уже ${mins} мин` : 'ещё идёт';
1683
+ await send(
1684
+ msg.chat.id,
1685
+ `⏳ Предыдущий ход ${howLong} — твоё сообщение в очереди.\nЕсли это затянулось, /stop прервёт ход, и я сразу возьмусь за твоим.`,
1686
+ thread,
1687
+ );
1673
1688
  }
1674
1689
  : undefined,
1675
1690
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-tg-bridge",
3
- "version": "1.2.1",
3
+ "version": "1.2.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": "bridge.mjs",