@shliamb/dsh-telegram-bot 0.2.6 β†’ 0.2.7

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
@@ -6,7 +6,7 @@ Package: [`@shliamb/dsh-telegram-bot`](https://www.npmjs.com/package/@shliamb/ds
6
6
 
7
7
  Telegram bridge for **DeepSeek Harness**. The plugin runs inside the Harness Host as an external bundle: you talk to the agent from a private Telegram chat, choose a workspace and session, follow long turns with a live progress message, and manage the Host remotely.
8
8
 
9
- > **Status:** Phase 2.2, early alpha. The bundle targets DeepSeek Harness `0.2.2-alpha.3` and the `web` profile.
9
+ > **Status:** 0.2.7, early beta. The bundle targets DeepSeek Harness `0.2.2-alpha.3` and the `web` profile.
10
10
 
11
11
  ## Features
12
12
 
@@ -16,10 +16,26 @@ Telegram bridge for **DeepSeek Harness**. The plugin runs inside the Harness Hos
16
16
  - One editable progress message per turn (`πŸ’­ thinking`, `πŸ”§ tool`, `✍️ writing`, `βœ… done`) instead of a stream of bash output.
17
17
  - Parallel turns: switch to another workspace while an older turn keeps updating. Its final answer still arrives in the same chat.
18
18
  - Tool approvals and agent questions as inline buttons; typed text answers as custom, including multi-select.
19
+ - Questions and approvals follow the active Telegram session: the bot claims them for that session; every other session stays in Web and gets a text notice after 15 seconds.
19
20
  - Main menu with account balance, workspace, session, context usage and colored buttons.
21
+ - Context percentage matches the Web meter, including right after compaction, and refreshes every time you open `/start` or `/menu`.
22
+ - Draft sessions are hidden and reused, so pressing **New session** twice does not create duplicates; the current session is marked `βœ…`.
20
23
  - Sound on/off per chat, history compaction via `/compact`, and a confirmed stop.
21
24
  - Admin screen with log download and remote Harness restart.
22
- - Russian or English UI, chosen from the Telegram client language (`ru*` β†’ Russian, otherwise English).
25
+ - Russian or English UI automatically, chosen from the Telegram interface language (`ru*` β†’ Russian, any other β†’ English). Menus, buttons, progress, questions, approvals and command descriptions follow it; the Web settings page follows the Web UI locale.
26
+
27
+ ## Screenshots
28
+
29
+ ![Telegram main menu in Russian](https://raw.githubusercontent.com/shliamb/HarnessBot/main/images/telegram-menu-ru.jpg)
30
+
31
+ The main menu in Russian: balance, active workspace and session, context usage, and action buttons.
32
+
33
+ ## What's new
34
+
35
+ - **0.2.7 β€” fresh context and calm compaction.** The menu reads the projection view (`projectedTokens`), so the percentage is correct immediately after compaction and on every `/start`; pressing **Compact** replaces the confirmation with a waiting message and removes the buttons.
36
+ - **0.2.6 β€” routing.** Questions and approvals belong to the Session currently open in Telegram. Other Sessions stay in Web, and after 15 seconds the bot sends a text notice with the workspace and Session name.
37
+ - **0.2.5 β€” context and sessions.** The context percentage now matches Web after compaction (`projectedTokens`), empty draft Sessions are reused and hidden, and the current Session is marked `βœ…`.
38
+ - **Languages.** The whole bot follows Telegram's interface language: `ru*` β†’ Russian, any other β†’ English. The binding locale is refreshed on every update, so a language change applies to progress, answers, questions and approvals immediately.
23
39
 
24
40
  ## Requirements
25
41
 
@@ -29,6 +45,13 @@ Telegram bridge for **DeepSeek Harness**. The plugin runs inside the Harness Hos
29
45
  - Your numeric Telegram user ID, for example from [@userinfobot](https://t.me/userinfobot).
30
46
  - A running Host. One bot token can be polled by only one Host process at a time (otherwise Telegram returns `409 Conflict`).
31
47
 
48
+ ## Stack
49
+
50
+ - DeepSeek Harness `web` profile, installed as an external Cordis bundle (`cordis.patch.yml`).
51
+ - TypeScript on Node.js `>= 24.9`; grammY for long polling.
52
+ - React settings page registered through DSH client slots.
53
+ - No runtime imports of `@deepseek-ai/dsh-*`: Host services are described by local types.
54
+
32
55
  ## Installation
33
56
 
34
57
  The package is published on npm as **`@shliamb/dsh-telegram-bot`**. The short name `dsh-telegram-bot` is already used by another project, so use the scoped name.
@@ -59,13 +82,13 @@ Adding a new bundle requires a Host restart. Chat sessions and bindings survive
59
82
  The repository also contains a ready-to-install archive:
60
83
 
61
84
  ```text
62
- dist/shliamb-dsh-telegram-bot-0.2.6.tgz
85
+ dist/shliamb-dsh-telegram-bot-0.2.7.tgz
63
86
  ```
64
87
 
65
88
  If the `dsh` CLI is on your `PATH`, run this from the repository root:
66
89
 
67
90
  ```bash
68
- dsh plugin --profile web add ./dist/shliamb-dsh-telegram-bot-0.2.6.tgz
91
+ dsh plugin --profile web add ./dist/shliamb-dsh-telegram-bot-0.2.7.tgz
69
92
  dsh web
70
93
  ```
71
94
 
@@ -73,7 +96,7 @@ If you run Harness from a source checkout, use `pnpm dsh` from that checkout and
73
96
 
74
97
  ```bash
75
98
  cd /path/to/deepseek-harness
76
- pnpm dsh plugin --profile web add /path/to/HarnessBot/dist/shliamb-dsh-telegram-bot-0.2.6.tgz
99
+ pnpm dsh plugin --profile web add /path/to/HarnessBot/dist/shliamb-dsh-telegram-bot-0.2.7.tgz
77
100
  pnpm dsh web
78
101
  ```
79
102
 
@@ -160,7 +183,7 @@ On a fresh Host start the bot sends the admin a single **β€œHarness is online”
160
183
 
161
184
  ### Commands
162
185
 
163
- Only `/start` is shown in Telegram's command menu. The other commands are hidden but still work when typed manually.
186
+ Only `/start` is shown in Telegram's command menu. `/admin` is additionally scoped to the admin chat; the other commands are hidden but still work when typed manually.
164
187
 
165
188
  | Command | Description |
166
189
  | --- | --- |
@@ -174,6 +197,10 @@ Only `/start` is shown in Telegram's command menu. The other commands are hidden
174
197
 
175
198
  Final answers are sent as separate rich messages. Long text is split into parts that fit Telegram's message limit. If rich formatting fails, the plugin retries with rich HTML and then with plain text, so the answer is not lost.
176
199
 
200
+ ### Languages
201
+
202
+ The bot follows Telegram's interface language: a `ru*` code selects Russian, any other code selects English. The binding locale is refreshed on every update, so progress, final answers, questions and approvals switch immediately after you change Telegram's language. Command descriptions use the same rule. The Web settings page follows the Web UI locale. Agent-produced text is left as the agent wrote it.
203
+
177
204
  ### Workspaces and sessions
178
205
 
179
206
  After you choose a workspace:
@@ -202,7 +229,7 @@ Turn tracking lives in Host memory. If the Host is restarted in the middle of a
202
229
 
203
230
  ### Approvals and questions
204
231
 
205
- When the agent requests a tool approval, the bot sends an inline **Allow** / **Deny** keyboard. When the agent asks a question with predefined options, the answers are inline buttons as well. Requests time out after 10 minutes.
232
+ When the agent requests a tool approval, the bot sends an inline **Allow** / **Deny** keyboard. When the agent asks a question with predefined options, the answers are inline buttons as well. In Telegram the card is closed after 10 minutes; an unanswered question is returned as skipped.
206
233
 
207
234
  Approvals and questions are answered for the bound session. The bot asks one question at a time. For a single-select question, tapping an option answers immediately; for a multi-select question, toggle the options and tap **Done**. Typing text while a question is open sends it as the custom answer (for multi-select it supplements the selected options), and **Skip** leaves the question unanswered. While a question or approval is open, ordinary text is not queued as a new prompt.
208
235
 
@@ -210,7 +237,7 @@ Where the prompt appears is decided by the Telegram binding. If the request belo
210
237
 
211
238
  ### Compaction, sound and stop
212
239
 
213
- - **Compact** shows the current context percentage and asks for confirmation. The plugin calls the preset-scoped `/compact` command through the `commands` service and reports the localized result and the new percentage. If the agent is busy, compaction is refused.
240
+ - **Compact** shows the current context percentage and asks for confirmation. Pressing **Compact** replaces the card with a waiting message and removes the buttons, so repeated taps do nothing. The plugin calls the preset-scoped `/compact` command through the `commands` service and reports the localized result and the new percentage. If the agent is busy, compaction is refused.
214
241
  - **Sound** is stored per chat. When it is off, answers, progress edits and the startup greeting use `disable_notification`.
215
242
  - **Stop** asks for confirmation, then cancels the current turn with `agent.cancel({ kind: 'user' })`.
216
243
 
@@ -285,6 +312,7 @@ pnpm pack --pack-destination dist
285
312
  src/index.ts Host plugin: config, bot runtime, menus, commands
286
313
  src/client/index.tsx Web settings page (token + admin ID)
287
314
  src/client/locales.ts Russian and English UI strings
315
+ images/ README screenshots
288
316
  src/state/index.ts Chat bindings in the storageDomain
289
317
  src/logging/index.ts JSONL file log with rotation
290
318
  src/*/SPEC.md Module contracts and data formats
@@ -301,13 +329,15 @@ dist/ Prebuilt install archive
301
329
  - Web settings expose only the token and the admin ID; `lowBalanceUsd`, `rich` and `apiRoot` are configured through `cordis.patch.yml`.
302
330
  - No voice or file handling: Telegram transcribes voice messages itself.
303
331
  - No proxy configuration.
304
- - Approvals and questions are tied to the bound session. An unbound or unsupported question is answered in the Web UI; Telegram supports single-select, multi-select, custom text and skip.
332
+ - Questions and approvals for the active Telegram session appear only in Telegram; other sessions stay in Web with a delayed text notice. Telegram supports single-select, multi-select, custom text and skip.
305
333
  - Progress tracking is in memory, so a Host restart in the middle of a turn can leave a stale progress message.
306
334
 
307
335
  ## Roadmap
308
336
 
309
- - Phase 2.2: `/history`, reply routing, completion notifications for other sessions.
310
- - Phase 3.2: npm package and listing in the plugin catalog.
337
+ - Done in 0.2.5: context meter from `projectedTokens`, draft-session reuse, `βœ…` current session, English command fallback, locale sync.
338
+ - Done in 0.2.6: active-session routing for questions and approvals, 15-second Web-waiting text notice, diagnostics.
339
+ - Done in 0.2.7: context from the projection snapshot, forced refresh on menu open, compact waiting state, removed the redundant question-keyboard clear call.
340
+ - Next: `/history`; reply routing; completion notifications for other sessions; plugin catalog listing.
311
341
 
312
342
  ## License
313
343
 
package/README.ru.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  Telegram-мост для **DeepSeek Harness**. Плагин устанавливаСтся Π² ΠΏΡ€ΠΎΡ„ΠΈΠ»ΡŒ `web` ΠΊΠ°ΠΊ внСшний Π±Π°Π½Π΄Π» ΠΈ Ρ€Π°Π±ΠΎΡ‚Π°Π΅Ρ‚ Π²Π½ΡƒΡ‚Ρ€ΠΈ Host-процСсса: Π²Ρ‹ ΠΎΠ±Ρ‰Π°Π΅Ρ‚Π΅ΡΡŒ с Π°Π³Π΅Π½Ρ‚ΠΎΠΌ ΠΈΠ· ΠΏΡ€ΠΈΠ²Π°Ρ‚Π½ΠΎΠ³ΠΎ Ρ‡Π°Ρ‚Π° Telegram, Π²Ρ‹Π±ΠΈΡ€Π°Π΅Ρ‚Π΅ пространство ΠΈ сСссию, слСдитС Π·Π° Π΄Π»ΠΈΠ½Π½Ρ‹ΠΌΠΈ Ρ…ΠΎΠ΄Π°ΠΌΠΈ Ρ‡Π΅Ρ€Π΅Π· ΠΎΠ΄Π½ΠΎ progress-сообщСниС ΠΈ управляСтС Host ΡƒΠ΄Π°Π»Ρ‘Π½Π½ΠΎ.
8
8
 
9
- > **Бтатус:** Phase 2.2, ранняя Π°Π»ΡŒΡ„Π°. Π‘Π°Π½Π΄Π» рассчитан Π½Π° DeepSeek Harness `0.2.2-alpha.3` ΠΈ ΠΏΡ€ΠΎΡ„ΠΈΠ»ΡŒ `web`.
9
+ > **Бтатус:** 0.2.7, ранняя Π±Π΅Ρ‚Π°. Π‘Π°Π½Π΄Π» рассчитан Π½Π° DeepSeek Harness `0.2.2-alpha.3` ΠΈ ΠΏΡ€ΠΎΡ„ΠΈΠ»ΡŒ `web`.
10
10
 
11
11
  ## ВозмоТности
12
12
 
@@ -16,10 +16,26 @@ Telegram-мост для **DeepSeek Harness**. Плагин устанавлив
16
16
  - Одно Ρ€Π΅Π΄Π°ΠΊΡ‚ΠΈΡ€ΡƒΠ΅ΠΌΠΎΠ΅ progress-сообщСниС Π½Π° Ρ…ΠΎΠ΄ (`πŸ’­ Π΄ΡƒΠΌΠ°Π΅Ρ‚`, `πŸ”§ инструмСнт`, `✍️ ΠΏΠΈΡˆΠ΅Ρ‚`, `βœ… Π³ΠΎΡ‚ΠΎΠ²ΠΎ`) вмСсто ΠΏΠΎΡ‚ΠΎΠΊΠ° bash-Π²Ρ‹Π²ΠΎΠ΄Π°.
17
17
  - ΠŸΠ°Ρ€Π°Π»Π»Π΅Π»ΡŒΠ½Ρ‹Π΅ Ρ…ΠΎΠ΄Ρ‹: ΠΌΠΎΠΆΠ½ΠΎ ΠΏΠ΅Ρ€Π΅ΠΊΠ»ΡŽΡ‡ΠΈΡ‚ΡŒΡΡ Π² Π΄Ρ€ΡƒΠ³ΠΎΠ΅ пространство, Π° староС progress-сообщСниС ΠΏΡ€ΠΎΠ΄ΠΎΠ»ΠΆΠΈΡ‚ ΠΎΠ±Π½ΠΎΠ²Π»ΡΡ‚ΡŒΡΡ. Π€ΠΈΠ½Π°Π»ΡŒΠ½Ρ‹ΠΉ ΠΎΡ‚Π²Π΅Ρ‚ всё Ρ€Π°Π²Π½ΠΎ ΠΏΡ€ΠΈΠ΄Ρ‘Ρ‚ Π² Ρ‚ΠΎΡ‚ ΠΆΠ΅ Ρ‡Π°Ρ‚.
18
18
  - ΠŸΠΎΠ΄Ρ‚Π²Π΅Ρ€ΠΆΠ΄Π΅Π½ΠΈΡ инструмСнтов ΠΈ вопросы Π°Π³Π΅Π½Ρ‚Π° ΠΊΠ½ΠΎΠΏΠΊΠ°ΠΌΠΈ; тСкст принимаСтся ΠΊΠ°ΠΊ «свой ΠΎΡ‚Π²Π΅Ρ‚Β», Π²ΠΊΠ»ΡŽΡ‡Π°Ρ ΠΌΡƒΠ»ΡŒΡ‚ΠΈΠ²Ρ‹Π±ΠΎΡ€.
19
+ - Вопросы ΠΈ подтвСрТдСния ΠΈΠ΄ΡƒΡ‚ Π² Ρ‚Ρƒ сСссию, которая ΠΎΡ‚ΠΊΡ€Ρ‹Ρ‚Π° Π² Telegram; ΠΎΡΡ‚Π°Π»ΡŒΠ½Ρ‹Π΅ сСссии ΠΎΡΡ‚Π°ΡŽΡ‚ΡΡ Π² Web ΠΈ Ρ‡Π΅Ρ€Π΅Π· 15 сСкунд ΠΏΠΎΠ»ΡƒΡ‡Π°ΡŽΡ‚ тСкстовоС ΡƒΠ²Π΅Π΄ΠΎΠΌΠ»Π΅Π½ΠΈΠ΅.
19
20
  - Π“Π»Π°Π²Π½ΠΎΠ΅ мСню с балансом, пространством, сСссиСй, ΠΏΡ€ΠΎΡ†Π΅Π½Ρ‚ΠΎΠΌ контСкста ΠΈ Ρ†Π²Π΅Ρ‚Π½Ρ‹ΠΌΠΈ ΠΊΠ½ΠΎΠΏΠΊΠ°ΠΌΠΈ.
21
+ - ΠŸΡ€ΠΎΡ†Π΅Π½Ρ‚ контСкста совпадаСт с Web, Π² Ρ‚ΠΎΠΌ числС сразу послС сТатия, ΠΈ обновляСтся ΠΏΡ€ΠΈ ΠΊΠ°ΠΆΠ΄ΠΎΠΌ ΠΎΡ‚ΠΊΡ€Ρ‹Ρ‚ΠΈΠΈ `/start` ΠΈΠ»ΠΈ `/menu`.
22
+ - ΠŸΡƒΡΡ‚Ρ‹Π΅ сСссии скрыты ΠΈ ΠΏΠ΅Ρ€Π΅ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΡŽΡ‚ΡΡ: ΠΏΠΎΠ²Ρ‚ΠΎΡ€Π½ΠΎΠ΅ Π½Π°ΠΆΠ°Ρ‚ΠΈΠ΅ «Новая сСссия» Π½Π΅ ΠΏΠ»ΠΎΠ΄ΠΈΡ‚ Π΄ΡƒΠ±Π»ΠΈ, тСкущая ΠΏΠΎΠΌΠ΅Ρ‡Π΅Π½Π° `βœ…`.
20
23
  - Π—Π²ΡƒΠΊ on/off для Ρ‡Π°Ρ‚Π°, сТатиС истории Ρ‡Π΅Ρ€Π΅Π· `/compact`, остановка с ΠΏΠΎΠ΄Ρ‚Π²Π΅Ρ€ΠΆΠ΄Π΅Π½ΠΈΠ΅ΠΌ.
21
24
  - Админ-экран с Π»ΠΎΠ³Π°ΠΌΠΈ Π΄ΠΎΠΊΡƒΠΌΠ΅Π½Ρ‚ΠΎΠΌ ΠΈ ΡƒΠ΄Π°Π»Ρ‘Π½Π½Ρ‹ΠΌ пСрСзапуском Harness.
22
- - Русский ΠΈΠ»ΠΈ английский интСрфСйс ΠΏΠΎ языку Telegram (`ru*` β†’ русский, ΠΈΠ½Π°Ρ‡Π΅ английский).
25
+ - Русский ΠΈΠ»ΠΈ английский интСрфСйс автоматичСски ΠΏΠΎ языку Telegram (`ru*` β†’ русский, любой Π΄Ρ€ΡƒΠ³ΠΎΠΉ β†’ английский). МСню, ΠΊΠ½ΠΎΠΏΠΊΠΈ, progress, вопросы, подтвСрТдСния ΠΈ описания ΠΊΠΎΠΌΠ°Π½Π΄ ΡΠ»Π΅Π΄ΡƒΡŽΡ‚ этому ΠΏΡ€Π°Π²ΠΈΠ»Ρƒ; страница настроСк Π² Web β€” языку Web-интСрфСйса.
26
+
27
+ ## Π‘ΠΊΡ€ΠΈΠ½ΡˆΠΎΡ‚Ρ‹
28
+
29
+ ![Π“Π»Π°Π²Π½ΠΎΠ΅ мСню Telegram Π½Π° русском](https://raw.githubusercontent.com/shliamb/HarnessBot/main/images/telegram-menu-ru.jpg)
30
+
31
+ Π“Π»Π°Π²Π½ΠΎΠ΅ мСню Π½Π° русском: баланс, Π°ΠΊΡ‚ΠΈΠ²Π½ΠΎΠ΅ пространство ΠΈ сСссия, ΠΏΡ€ΠΎΡ†Π΅Π½Ρ‚ контСкста ΠΈ ΠΊΠ½ΠΎΠΏΠΊΠΈ дСйствий.
32
+
33
+ ## Π§Ρ‚ΠΎ Π½ΠΎΠ²ΠΎΠ³ΠΎ
34
+
35
+ - **0.2.7 β€” свСТий контСкст ΠΈ спокойноС сТатиС.** МСню Ρ‡ΠΈΡ‚Π°Π΅Ρ‚ projection view (`projectedTokens`), поэтому ΠΏΡ€ΠΎΡ†Π΅Π½Ρ‚ Π²Π΅Ρ€Π½Ρ‹ΠΉ сразу послС сТатия ΠΈ ΠΏΡ€ΠΈ ΠΊΠ°ΠΆΠ΄ΠΎΠΌ `/start`; Π½Π°ΠΆΠ°Ρ‚ΠΈΠ΅ **Β«Π‘ΠΆΠ°Ρ‚ΡŒΒ»** замСняСт ΠΏΠΎΠ΄Ρ‚Π²Π΅Ρ€ΠΆΠ΄Π΅Π½ΠΈΠ΅ сообщСниСм Β«ΠžΠΆΠΈΠ΄Π°ΠΉΡ‚Π΅Β» ΠΈ ΡƒΠ±ΠΈΡ€Π°Π΅Ρ‚ ΠΊΠ½ΠΎΠΏΠΊΠΈ.
36
+ - **0.2.6 β€” ΠΌΠ°Ρ€ΡˆΡ€ΡƒΡ‚ΠΈΠ·Π°Ρ†ΠΈΡ.** Вопросы ΠΈ подтвСрТдСния ΠΏΡ€ΠΈΠ½Π°Π΄Π»Π΅ΠΆΠ°Ρ‚ сСссии, которая сСйчас ΠΎΡ‚ΠΊΡ€Ρ‹Ρ‚Π° Π² Telegram. ΠžΡΡ‚Π°Π»ΡŒΠ½Ρ‹Π΅ сСссии ΠΎΡΡ‚Π°ΡŽΡ‚ΡΡ Π² Web, Π° Ρ‡Π΅Ρ€Π΅Π· 15 сСкунд Π±ΠΎΡ‚ присылаСт тСкст с Π½Π°Π·Π²Π°Π½ΠΈΠ΅ΠΌ пространства ΠΈ сСссии.
37
+ - **0.2.5 β€” контСкст ΠΈ сСссии.** ΠŸΡ€ΠΎΡ†Π΅Π½Ρ‚ контСкста совпадаСт с Web послС сТатия (`projectedTokens`), пустыС Ρ‡Π΅Ρ€Π½ΠΎΠ²ΠΈΠΊΠΈ сСссий скрыты ΠΈ ΠΏΠ΅Ρ€Π΅ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΡŽΡ‚ΡΡ, тСкущая ΠΏΠΎΠΌΠ΅Ρ‡Π΅Π½Π° `βœ…`.
38
+ - **Π―Π·Ρ‹ΠΊΠΈ.** Π’Π΅ΡΡŒ Π±ΠΎΡ‚ слСдуСт языку интСрфСйса Telegram: `ru*` β†’ русский, любой Π΄Ρ€ΡƒΠ³ΠΎΠΉ β†’ английский. Π›ΠΎΠΊΠ°Π»ΡŒ привязки обновляСтся Π½Π° ΠΊΠ°ΠΆΠ΄ΠΎΠΌ сообщСнии, поэтому смСна языка сразу примСняСтся ΠΊ progress, ΠΎΡ‚Π²Π΅Ρ‚Π°ΠΌ, вопросам ΠΈ подтвСрТдСниям.
23
39
 
24
40
  ## ВрСбования
25
41
 
@@ -29,6 +45,13 @@ Telegram-мост для **DeepSeek Harness**. Плагин устанавлив
29
45
  - Числовой Telegram ID, Π½Π°ΠΏΡ€ΠΈΠΌΠ΅Ρ€ ΠΈΠ· [@userinfobot](https://t.me/userinfobot).
30
46
  - Π—Π°ΠΏΡƒΡ‰Π΅Π½Π½Ρ‹ΠΉ Host. Один Ρ‚ΠΎΠΊΠ΅Π½ ΠΌΠΎΠΆΠ΅Ρ‚ ΠΎΠΏΡ€Π°ΡˆΠΈΠ²Π°Ρ‚ΡŒ Ρ‚ΠΎΠ»ΡŒΠΊΠΎ ΠΎΠ΄ΠΈΠ½ Host-процСсс (ΠΈΠ½Π°Ρ‡Π΅ Telegram Π²Π΅Ρ€Π½Ρ‘Ρ‚ `409 Conflict`).
31
47
 
48
+ ## Π‘Ρ‚Π΅ΠΊ
49
+
50
+ - DeepSeek Harness, ΠΏΡ€ΠΎΡ„ΠΈΠ»ΡŒ `web`, установка внСшним Cordis-Π±Π°Π½Π΄Π»ΠΎΠΌ (`cordis.patch.yml`).
51
+ - TypeScript, Node.js `>= 24.9`, grammY для long polling.
52
+ - React-страница настроСк Ρ‡Π΅Ρ€Π΅Π· client slots DSH.
53
+ - Π‘Π΅Π· runtime-ΠΈΠΌΠΏΠΎΡ€Ρ‚ΠΎΠ² `@deepseek-ai/dsh-*`: сСрвисы Host описаны Π»ΠΎΠΊΠ°Π»ΡŒΠ½Ρ‹ΠΌΠΈ Ρ‚ΠΈΠΏΠ°ΠΌΠΈ.
54
+
32
55
  ## Установка
33
56
 
34
57
  ΠŸΠ°ΠΊΠ΅Ρ‚ ΠΎΠΏΡƒΠ±Π»ΠΈΠΊΠΎΠ²Π°Π½ Π² npm ΠΊΠ°ΠΊ **`@shliamb/dsh-telegram-bot`**. ΠšΠΎΡ€ΠΎΡ‚ΠΊΠΎΠ΅ имя `dsh-telegram-bot` ΡƒΠΆΠ΅ занято Π΄Ρ€ΡƒΠ³ΠΈΠΌ ΠΏΡ€ΠΎΠ΅ΠΊΡ‚ΠΎΠΌ, поэтому ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΠΉΡ‚Π΅ имя со scope.
@@ -59,13 +82,13 @@ pnpm dsh web
59
82
  Π’ Ρ€Π΅ΠΏΠΎΠ·ΠΈΡ‚ΠΎΡ€ΠΈΠΈ Ρ‚Π°ΠΊΠΆΠ΅ Π»Π΅ΠΆΠΈΡ‚ Π³ΠΎΡ‚ΠΎΠ²Ρ‹ΠΉ ΠΊ установкС Π°Ρ€Ρ…ΠΈΠ²:
60
83
 
61
84
  ```text
62
- dist/shliamb-dsh-telegram-bot-0.2.6.tgz
85
+ dist/shliamb-dsh-telegram-bot-0.2.7.tgz
63
86
  ```
64
87
 
65
88
  Если ΠΊΠΎΠΌΠ°Π½Π΄Π° `dsh` доступна Π² `PATH`, Π²Ρ‹ΠΏΠΎΠ»Π½ΠΈΡ‚Π΅ ΠΈΠ· корня рСпозитория:
66
89
 
67
90
  ```bash
68
- dsh plugin --profile web add ./dist/shliamb-dsh-telegram-bot-0.2.6.tgz
91
+ dsh plugin --profile web add ./dist/shliamb-dsh-telegram-bot-0.2.7.tgz
69
92
  dsh web
70
93
  ```
71
94
 
@@ -73,7 +96,7 @@ dsh web
73
96
 
74
97
  ```bash
75
98
  cd /path/to/deepseek-harness
76
- pnpm dsh plugin --profile web add /path/to/HarnessBot/dist/shliamb-dsh-telegram-bot-0.2.6.tgz
99
+ pnpm dsh plugin --profile web add /path/to/HarnessBot/dist/shliamb-dsh-telegram-bot-0.2.7.tgz
77
100
  pnpm dsh web
78
101
  ```
79
102
 
@@ -160,7 +183,7 @@ ID Π°Π΄ΠΌΠΈΠ½Π° хранится Π² ΠΊΠΎΠ½Ρ„ΠΈΠ³Π΅ ΠΏΠ»Π°Π³ΠΈΠ½Π°. Если `all
160
183
 
161
184
  ### ΠšΠΎΠΌΠ°Π½Π΄Ρ‹
162
185
 
163
- Π’ мСню ΠΊΠΎΠΌΠ°Π½Π΄ Telegram Π²ΠΈΠ΄Π½Π° Ρ‚ΠΎΠ»ΡŒΠΊΠΎ `/start`. ΠžΡΡ‚Π°Π»ΡŒΠ½Ρ‹Π΅ ΠΊΠΎΠΌΠ°Π½Π΄Ρ‹ скрыты, Π½ΠΎ Ρ€Π°Π±ΠΎΡ‚Π°ΡŽΡ‚ ΠΏΡ€ΠΈ Π²Π²ΠΎΠ΄Π΅ Π²Ρ€ΡƒΡ‡Π½ΡƒΡŽ.
186
+ Π’ мСню ΠΊΠΎΠΌΠ°Π½Π΄ Telegram Π²ΠΈΠ΄Π½Π° Ρ‚ΠΎΠ»ΡŒΠΊΠΎ `/start`. `/admin` Π΄ΠΎΠΏΠΎΠ»Π½ΠΈΡ‚Π΅Π»ΡŒΠ½ΠΎ доступСн Ρ‚ΠΎΠ»ΡŒΠΊΠΎ Π² Ρ‡Π°Ρ‚Π΅ Π°Π΄ΠΌΠΈΠ½Π°; ΠΎΡΡ‚Π°Π»ΡŒΠ½Ρ‹Π΅ ΠΊΠΎΠΌΠ°Π½Π΄Ρ‹ скрыты, Π½ΠΎ Ρ€Π°Π±ΠΎΡ‚Π°ΡŽΡ‚ ΠΏΡ€ΠΈ Π²Π²ΠΎΠ΄Π΅ Π²Ρ€ΡƒΡ‡Π½ΡƒΡŽ.
164
187
 
165
188
  | Команда | ОписаниС |
166
189
  | --- | --- |
@@ -174,6 +197,10 @@ ID Π°Π΄ΠΌΠΈΠ½Π° хранится Π² ΠΊΠΎΠ½Ρ„ΠΈΠ³Π΅ ΠΏΠ»Π°Π³ΠΈΠ½Π°. Если `all
174
197
 
175
198
  Π€ΠΈΠ½Π°Π»ΡŒΠ½Ρ‹Π΅ ΠΎΡ‚Π²Π΅Ρ‚Ρ‹ приходят ΠΎΡ‚Π΄Π΅Π»ΡŒΠ½Ρ‹ΠΌΠΈ rich-сообщСниями. Π”Π»ΠΈΠ½Π½Ρ‹ΠΉ тСкст дСлится Π½Π° части ΠΏΠΎ Π»ΠΈΠΌΠΈΡ‚Ρƒ Telegram. Если rich-Ρ„ΠΎΡ€ΠΌΠ°Ρ‚ΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅ Π½Π΅ ΡƒΠ΄Π°Π»ΠΎΡΡŒ, ΠΏΠ»Π°Π³ΠΈΠ½ повторяСт ΠΏΠΎΠΏΡ‹Ρ‚ΠΊΡƒ с rich HTML, Π·Π°Ρ‚Π΅ΠΌ с ΠΎΠ±Ρ‹Ρ‡Π½Ρ‹ΠΌ тСкстом, поэтому ΠΎΡ‚Π²Π΅Ρ‚ Π½Π΅ тСряСтся.
176
199
 
200
+ ### Π―Π·Ρ‹ΠΊΠΈ
201
+
202
+ Π‘ΠΎΡ‚ слСдуСт языку интСрфСйса Telegram: ΠΊΠΎΠ΄ `ru*` Π²ΠΊΠ»ΡŽΡ‡Π°Π΅Ρ‚ русский, любой Π΄Ρ€ΡƒΠ³ΠΎΠΉ β€” английский. Π›ΠΎΠΊΠ°Π»ΡŒ привязки обновляСтся Π½Π° ΠΊΠ°ΠΆΠ΄ΠΎΠΌ сообщСнии, поэтому progress, Ρ„ΠΈΠ½Π°Π»ΡŒΠ½Ρ‹Π΅ ΠΎΡ‚Π²Π΅Ρ‚Ρ‹, вопросы ΠΈ подтвСрТдСния сразу ΠΏΠ΅Ρ€Π΅ΠΊΠ»ΡŽΡ‡Π°ΡŽΡ‚ΡΡ послС смСны языка Π² Telegram. Описания ΠΊΠΎΠΌΠ°Π½Π΄ ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΡŽΡ‚ Ρ‚ΠΎ ΠΆΠ΅ ΠΏΡ€Π°Π²ΠΈΠ»ΠΎ. Π‘Ρ‚Ρ€Π°Π½ΠΈΡ†Π° настроСк Π² Web слСдуСт языку Web-интСрфСйса. ВСкст, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹ΠΉ ΠΏΠΈΡˆΠ΅Ρ‚ Π°Π³Π΅Π½Ρ‚, остаётся Π½Π° языкС Π°Π³Π΅Π½Ρ‚Π°.
203
+
177
204
  ### ΠŸΡ€ΠΎΡΡ‚Ρ€Π°Π½ΡΡ‚Π²Π° ΠΈ сСссии
178
205
 
179
206
  ПослС Π²Ρ‹Π±ΠΎΡ€Π° пространства:
@@ -202,7 +229,7 @@ ID Π°Π΄ΠΌΠΈΠ½Π° хранится Π² ΠΊΠΎΠ½Ρ„ΠΈΠ³Π΅ ΠΏΠ»Π°Π³ΠΈΠ½Π°. Если `all
202
229
 
203
230
  ### ΠŸΠΎΠ΄Ρ‚Π²Π΅Ρ€ΠΆΠ΄Π΅Π½ΠΈΡ ΠΈ вопросы
204
231
 
205
- Когда Π°Π³Π΅Π½Ρ‚ просит ΠΏΠΎΠ΄Ρ‚Π²Π΅Ρ€Π΄ΠΈΡ‚ΡŒ инструмСнт, Π±ΠΎΡ‚ присылаСт inline-ΠΊΠ½ΠΎΠΏΠΊΠΈ **Β«Π Π°Π·Ρ€Π΅ΡˆΠΈΡ‚ΡŒΒ»** / **Β«Π—Π°ΠΏΡ€Π΅Ρ‚ΠΈΡ‚ΡŒΒ»**. Когда Π°Π³Π΅Π½Ρ‚ Π·Π°Π΄Π°Ρ‘Ρ‚ вопрос с Π³ΠΎΡ‚ΠΎΠ²Ρ‹ΠΌΠΈ Π²Π°Ρ€ΠΈΠ°Π½Ρ‚Π°ΠΌΠΈ, ΠΎΡ‚Π²Π΅Ρ‚Ρ‹ Ρ‚ΠΎΠΆΠ΅ приходят ΠΊΠ½ΠΎΠΏΠΊΠ°ΠΌΠΈ. Π’Π°ΠΉΠΌΠ°ΡƒΡ‚ запроса β€” 10 ΠΌΠΈΠ½ΡƒΡ‚.
232
+ Когда Π°Π³Π΅Π½Ρ‚ просит ΠΏΠΎΠ΄Ρ‚Π²Π΅Ρ€Π΄ΠΈΡ‚ΡŒ инструмСнт, Π±ΠΎΡ‚ присылаСт inline-ΠΊΠ½ΠΎΠΏΠΊΠΈ **Β«Π Π°Π·Ρ€Π΅ΡˆΠΈΡ‚ΡŒΒ»** / **Β«Π—Π°ΠΏΡ€Π΅Ρ‚ΠΈΡ‚ΡŒΒ»**. Когда Π°Π³Π΅Π½Ρ‚ Π·Π°Π΄Π°Ρ‘Ρ‚ вопрос с Π³ΠΎΡ‚ΠΎΠ²Ρ‹ΠΌΠΈ Π²Π°Ρ€ΠΈΠ°Π½Ρ‚Π°ΠΌΠΈ, ΠΎΡ‚Π²Π΅Ρ‚Ρ‹ Ρ‚ΠΎΠΆΠ΅ приходят ΠΊΠ½ΠΎΠΏΠΊΠ°ΠΌΠΈ. Π’ Telegram ΠΊΠ°Ρ€Ρ‚ΠΎΡ‡ΠΊΠ° закрываСтся Ρ‡Π΅Ρ€Π΅Π· 10 ΠΌΠΈΠ½ΡƒΡ‚; вопрос Π±Π΅Π· ΠΎΡ‚Π²Π΅Ρ‚Π° возвращаСтся ΠΊΠ°ΠΊ ΠΏΡ€ΠΎΠΏΡƒΡ‰Π΅Π½Π½Ρ‹ΠΉ.
206
233
 
207
234
  ΠŸΠΎΠ΄Ρ‚Π²Π΅Ρ€ΠΆΠ΄Π΅Π½ΠΈΡ ΠΈ вопросы ΠΎΡ‚Π²Π΅Ρ‡Π°ΡŽΡ‚ΡΡ для привязанной сСссии. Π‘ΠΎΡ‚ Π·Π°Π΄Π°Ρ‘Ρ‚ вопросы ΠΏΠΎ ΠΎΠ΄Π½ΠΎΠΌΡƒ. Π’ single-select Π½Π°ΠΆΠ°Ρ‚ΠΈΠ΅ Π²Π°Ρ€ΠΈΠ°Π½Ρ‚Π° сразу отправляСт ΠΎΡ‚Π²Π΅Ρ‚; Π² multi-select ΠΎΡ‚ΠΌΠ΅Ρ‚ΡŒ Π²Π°Ρ€ΠΈΠ°Π½Ρ‚Ρ‹ ΠΈ Π½Π°ΠΆΠΌΠΈ **Β«Π“ΠΎΡ‚ΠΎΠ²ΠΎΒ»**. ВСкст, ΠΎΡ‚ΠΏΡ€Π°Π²Π»Π΅Π½Π½Ρ‹ΠΉ ΠΏΡ€ΠΈ ΠΎΡ‚ΠΊΡ€Ρ‹Ρ‚ΠΎΠΌ вопросС, ΡƒΡ…ΠΎΠ΄ΠΈΡ‚ ΠΊΠ°ΠΊ «свой ΠΎΡ‚Π²Π΅Ρ‚Β» (Π² multi-select дополняСт Π²Ρ‹Π±Ρ€Π°Π½Π½Ρ‹Π΅ Π²Π°Ρ€ΠΈΠ°Π½Ρ‚Ρ‹), Π° **Β«ΠŸΡ€ΠΎΠΏΡƒΡΡ‚ΠΈΡ‚ΡŒΒ»** оставляСт вопрос Π±Π΅Π· ΠΎΡ‚Π²Π΅Ρ‚Π°. Пока вопрос ΠΈΠ»ΠΈ approval ΠΎΡ‚ΠΊΡ€Ρ‹Ρ‚, ΠΎΠ±Ρ‹Ρ‡Π½Ρ‹ΠΉ тСкст Π½Π΅ ставится Π² ΠΎΡ‡Π΅Ρ€Π΅Π΄ΡŒ ΠΊΠ°ΠΊ новая Π·Π°Π΄Π°Ρ‡Π°.
208
235
 
@@ -210,7 +237,7 @@ ID Π°Π΄ΠΌΠΈΠ½Π° хранится Π² ΠΊΠΎΠ½Ρ„ΠΈΠ³Π΅ ΠΏΠ»Π°Π³ΠΈΠ½Π°. Если `all
210
237
 
211
238
  ### Π‘ΠΆΠ°Ρ‚ΠΈΠ΅, Π·Π²ΡƒΠΊ ΠΈ остановка
212
239
 
213
- - **Β«Π‘ΠΆΠ°Ρ‚ΡŒΒ»** ΠΏΠΎΠΊΠ°Π·Ρ‹Π²Π°Π΅Ρ‚ Ρ‚Π΅ΠΊΡƒΡ‰ΠΈΠΉ ΠΏΡ€ΠΎΡ†Π΅Π½Ρ‚ контСкста ΠΈ просит ΠΏΠΎΠ΄Ρ‚Π²Π΅Ρ€ΠΆΠ΄Π΅Π½ΠΈΠ΅. Плагин Π²Ρ‹Π·Ρ‹Π²Π°Π΅Ρ‚ preset-ΠΊΠΎΠΌΠ°Π½Π΄Ρƒ `/compact` Ρ‡Π΅Ρ€Π΅Π· сСрвис `commands`, Π·Π°Ρ‚Π΅ΠΌ ΠΏΠΎΠΊΠ°Π·Ρ‹Π²Π°Π΅Ρ‚ Π»ΠΎΠΊΠ°Π»ΠΈΠ·ΠΎΠ²Π°Π½Π½Ρ‹ΠΉ Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚ ΠΈ Π½ΠΎΠ²Ρ‹ΠΉ ΠΏΡ€ΠΎΡ†Π΅Π½Ρ‚. Если Π°Π³Π΅Π½Ρ‚ занят, сТатиС отклоняСтся.
240
+ - **Β«Π‘ΠΆΠ°Ρ‚ΡŒΒ»** ΠΏΠΎΠΊΠ°Π·Ρ‹Π²Π°Π΅Ρ‚ Ρ‚Π΅ΠΊΡƒΡ‰ΠΈΠΉ ΠΏΡ€ΠΎΡ†Π΅Π½Ρ‚ контСкста ΠΈ просит ΠΏΠΎΠ΄Ρ‚Π²Π΅Ρ€ΠΆΠ΄Π΅Π½ΠΈΠ΅. ПослС наТатия **Β«Π‘ΠΆΠ°Ρ‚ΡŒΒ»** ΠΊΠ°Ρ€Ρ‚ΠΎΡ‡ΠΊΠ° замСняСтся сообщСниСм Β«ΠžΠΆΠΈΠ΄Π°ΠΉΡ‚Π΅Β», Π° ΠΊΠ½ΠΎΠΏΠΊΠΈ ΠΈΡΡ‡Π΅Π·Π°ΡŽΡ‚, поэтому ΠΏΠΎΠ²Ρ‚ΠΎΡ€Π½Ρ‹Π΅ наТатия Π½ΠΈΡ‡Π΅Π³ΠΎ Π½Π΅ Π΄Π΅Π»Π°ΡŽΡ‚. Плагин Π²Ρ‹Π·Ρ‹Π²Π°Π΅Ρ‚ preset-ΠΊΠΎΠΌΠ°Π½Π΄Ρƒ `/compact` Ρ‡Π΅Ρ€Π΅Π· сСрвис `commands`, Π·Π°Ρ‚Π΅ΠΌ ΠΏΠΎΠΊΠ°Π·Ρ‹Π²Π°Π΅Ρ‚ Π»ΠΎΠΊΠ°Π»ΠΈΠ·ΠΎΠ²Π°Π½Π½Ρ‹ΠΉ Ρ€Π΅Π·ΡƒΠ»ΡŒΡ‚Π°Ρ‚ ΠΈ Π½ΠΎΠ²Ρ‹ΠΉ ΠΏΡ€ΠΎΡ†Π΅Π½Ρ‚. Если Π°Π³Π΅Π½Ρ‚ занят, сТатиС отклоняСтся.
214
241
  - **Β«Π—Π²ΡƒΠΊΒ»** хранится для ΠΊΠ°ΠΆΠ΄ΠΎΠ³ΠΎ Ρ‡Π°Ρ‚Π°. Когда ΠΎΠ½ Π²Ρ‹ΠΊΠ»ΡŽΡ‡Π΅Π½, ΠΎΡ‚Π²Π΅Ρ‚Ρ‹, ΠΏΡ€Π°Π²ΠΊΠΈ progress ΠΈ привСтствиС ΠΏΡ€ΠΈ стартС ΠΈΠ΄ΡƒΡ‚ с `disable_notification`.
215
242
  - **Β«Π‘Ρ‚ΠΎΠΏΒ»** просит ΠΏΠΎΠ΄Ρ‚Π²Π΅Ρ€ΠΆΠ΄Π΅Π½ΠΈΠ΅, Π·Π°Ρ‚Π΅ΠΌ отмСняСт Ρ‚Π΅ΠΊΡƒΡ‰ΠΈΠΉ Ρ…ΠΎΠ΄ Ρ‡Π΅Ρ€Π΅Π· `agent.cancel({ kind: 'user' })`.
216
243
 
@@ -285,6 +312,7 @@ pnpm pack --pack-destination dist
285
312
  src/index.ts Host-ΠΏΠ»Π°Π³ΠΈΠ½: ΠΊΠΎΠ½Ρ„ΠΈΠ³, runtime Π±ΠΎΡ‚Π°, мСню, ΠΊΠΎΠΌΠ°Π½Π΄Ρ‹
286
313
  src/client/index.tsx Web-страница настроСк (Ρ‚ΠΎΠΊΠ΅Π½ + ID Π°Π΄ΠΌΠΈΠ½Π°)
287
314
  src/client/locales.ts РусскиС ΠΈ английскиС строки интСрфСйса
315
+ images/ Π‘ΠΊΡ€ΠΈΠ½ΡˆΠΎΡ‚Ρ‹ для README
288
316
  src/state/index.ts ΠŸΡ€ΠΈΠ²ΡΠ·ΠΊΠΈ Ρ‡Π°Ρ‚ΠΎΠ² Π² storageDomain
289
317
  src/logging/index.ts JSONL-Π»ΠΎΠ³ с Ρ€ΠΎΡ‚Π°Ρ†ΠΈΠ΅ΠΉ
290
318
  src/*/SPEC.md ΠšΠΎΠ½Ρ‚Ρ€Π°ΠΊΡ‚Ρ‹ ΠΌΠΎΠ΄ΡƒΠ»Π΅ΠΉ ΠΈ Ρ„ΠΎΡ€ΠΌΠ°Ρ‚Ρ‹ Π΄Π°Π½Π½Ρ‹Ρ…
@@ -301,13 +329,14 @@ dist/ Π“ΠΎΡ‚ΠΎΠ²Ρ‹ΠΉ установочный Π°Ρ€Ρ…ΠΈΠ²
301
329
  - Π’ Web-настройках Ρ‚ΠΎΠ»ΡŒΠΊΠΎ Ρ‚ΠΎΠΊΠ΅Π½ ΠΈ ID Π°Π΄ΠΌΠΈΠ½Π°; `lowBalanceUsd`, `rich` ΠΈ `apiRoot` Π·Π°Π΄Π°ΡŽΡ‚ΡΡ Ρ‡Π΅Ρ€Π΅Π· `cordis.patch.yml`.
302
330
  - НСт голосовых ΠΈ Ρ„Π°ΠΉΠ»ΠΎΠ²: Telegram сам транскрибируСт голос.
303
331
  - НСт настройки прокси.
304
- - ΠŸΠΎΠ΄Ρ‚Π²Π΅Ρ€ΠΆΠ΄Π΅Π½ΠΈΡ ΠΈ вопросы привязаны ΠΊ Π²Ρ‹Π±Ρ€Π°Π½Π½ΠΎΠΉ сСссии. НСпривязанный ΠΈΠ»ΠΈ Π½Π΅ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΈΠ²Π°Π΅ΠΌΡ‹ΠΉ вопрос отвСчаСтся Π² Web; Π² Telegram Ρ€Π°Π±ΠΎΡ‚Π°ΡŽΡ‚ single-select, multi-select, свой тСкст ΠΈ пропуск.
332
+ - Вопросы ΠΈ подтвСрТдСния Π°ΠΊΡ‚ΠΈΠ²Π½ΠΎΠΉ Telegram-сСссии ΠΏΠΎΠΊΠ°Π·Ρ‹Π²Π°ΡŽΡ‚ΡΡ Ρ‚ΠΎΠ»ΡŒΠΊΠΎ Π² Telegram; ΠΎΡΡ‚Π°Π»ΡŒΠ½Ρ‹Π΅ сСссии ΠΎΡΡ‚Π°ΡŽΡ‚ΡΡ Π² Web с ΠΎΡ‚Π»ΠΎΠΆΠ΅Π½Π½Ρ‹ΠΌ тСкстовым ΡƒΠ²Π΅Π΄ΠΎΠΌΠ»Π΅Π½ΠΈΠ΅ΠΌ. Telegram ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΈΠ²Π°Π΅Ρ‚ single-select, multi-select, свой тСкст ΠΈ пропуск.
305
333
  - ΠžΡ‚ΡΠ»Π΅ΠΆΠΈΠ²Π°Π½ΠΈΠ΅ progress ΠΆΠΈΠ²Ρ‘Ρ‚ Π² памяти, поэтому пСрСзапуск Host посрСди Ρ…ΠΎΠ΄Π° ΠΌΠΎΠΆΠ΅Ρ‚ ΠΎΡΡ‚Π°Π²ΠΈΡ‚ΡŒ ΡƒΡΡ‚Π°Ρ€Π΅Π²ΡˆΠ΅Π΅ progress-сообщСниС.
306
334
 
307
335
  ## Roadmap
308
336
 
309
- - Phase 2.2: `/history`, ΠΌΠ°Ρ€ΡˆΡ€ΡƒΡ‚ΠΈΠ·Π°Ρ†ΠΈΡ ΠΎΡ‚Π²Π΅Ρ‚ΠΎΠ², увСдомлСния ΠΎ Π·Π°Π²Π΅Ρ€ΡˆΠ΅Π½ΠΈΠΈ Π² Π΄Ρ€ΡƒΠ³ΠΈΡ… сСссиях.
310
- - Phase 3.2: npm-ΠΏΠ°ΠΊΠ΅Ρ‚ ΠΈ публикация Π² ΠΊΠ°Ρ‚Π°Π»ΠΎΠ³Π΅ ΠΏΠ»Π°Π³ΠΈΠ½ΠΎΠ².
337
+ - Π“ΠΎΡ‚ΠΎΠ²ΠΎ Π² 0.2.5: ΠΏΡ€ΠΎΡ†Π΅Π½Ρ‚ контСкста ΠΏΠΎ `projectedTokens`, ΠΏΠ΅Ρ€Π΅ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Π½ΠΈΠ΅ пустых сСссий, `βœ…` Ρ‚Π΅ΠΊΡƒΡ‰Π΅ΠΉ сСссии, английский fallback ΠΊΠΎΠΌΠ°Π½Π΄, синхронизация Π»ΠΎΠΊΠ°Π»ΠΈ.
338
+ - Π“ΠΎΡ‚ΠΎΠ²ΠΎ Π² 0.2.6: ΠΌΠ°Ρ€ΡˆΡ€ΡƒΡ‚ΠΈΠ·Π°Ρ†ΠΈΡ вопросов ΠΈ ΠΏΠΎΠ΄Ρ‚Π²Π΅Ρ€ΠΆΠ΄Π΅Π½ΠΈΠΉ ΠΏΠΎ Π°ΠΊΡ‚ΠΈΠ²Π½ΠΎΠΉ сСссии, тСкстовоС ΡƒΠ²Π΅Π΄ΠΎΠΌΠ»Π΅Π½ΠΈΠ΅ Web Ρ‡Π΅Ρ€Π΅Π· 15 сСкунд, диагностика.
339
+ - Π”Π°Π»ΡŒΡˆΠ΅: ΡƒΠ±Ρ€Π°Ρ‚ΡŒ лишнюю очистку ΠΊΠ»Π°Π²ΠΈΠ°Ρ‚ΡƒΡ€Ρ‹ вопроса; `/history`; ΠΌΠ°Ρ€ΡˆΡ€ΡƒΡ‚ΠΈΠ·Π°Ρ†ΠΈΡ ΠΎΡ‚Π²Π΅Ρ‚ΠΎΠ²; увСдомлСния ΠΎ Π·Π°Π²Π΅Ρ€ΡˆΠ΅Π½ΠΈΠΈ Π² Π΄Ρ€ΡƒΠ³ΠΈΡ… сСссиях; ΠΊΠ°Ρ‚Π°Π»ΠΎΠ³ ΠΏΠ»Π°Π³ΠΈΠ½ΠΎΠ².
311
340
 
312
341
  ## ЛицСнзия
313
342
 
package/lib/index.js CHANGED
@@ -84,6 +84,8 @@ const STRINGS = {
84
84
  compactNoHistory: 'НСчСго ΡΠΆΠΈΠΌΠ°Ρ‚ΡŒ.',
85
85
  compactConfirm: 'Бтарая история Π±ΡƒΠ΄Π΅Ρ‚ Π·Π°ΠΌΠ΅Π½Π΅Π½Π° ΠΊΡ€Π°Ρ‚ΠΊΠΈΠΌ Ρ€Π΅Π·ΡŽΠΌΠ΅.',
86
86
  compactDone: 'Π˜ΡΡ‚ΠΎΡ€ΠΈΡ сТата.',
87
+ compactWorking: '⏳ БТимаю ΠΈΡΡ‚ΠΎΡ€ΠΈΡŽβ€¦\nΠŸΠΎΠ΄ΠΎΠΆΠ΄ΠΈΡ‚Π΅, поТалуйста.',
88
+ compactResultTitle: 'Π‘ΠΆΠ°Ρ‚ΠΈΠ΅ истории',
87
89
  stop: '⏹ Π‘Ρ‚ΠΎΠΏ',
88
90
  stopDone: 'ΠžΡΡ‚Π°Π½ΠΎΠ²Π»Π΅Π½ΠΎ.',
89
91
  stopIdle: 'НСчСго ΠΎΡΡ‚Π°Π½Π°Π²Π»ΠΈΠ²Π°Ρ‚ΡŒ.',
@@ -201,6 +203,8 @@ const STRINGS = {
201
203
  compactNoHistory: 'No compactable history.',
202
204
  compactConfirm: 'Older history will be replaced by a short summary.',
203
205
  compactDone: 'History compacted.',
206
+ compactWorking: '⏳ Compacting history…\nPlease wait.',
207
+ compactResultTitle: 'History compaction',
204
208
  stop: '⏹ Stop',
205
209
  stopDone: 'Stopped.',
206
210
  stopIdle: 'Nothing to stop.',
@@ -499,7 +503,7 @@ async function getBalance(runtime, locale, force = false) {
499
503
  }
500
504
  try {
501
505
  const result = await runtime.account.getBalance({
502
- version: '@shliamb/dsh-telegram-bot/0.2.4',
506
+ version: '@shliamb/dsh-telegram-bot/0.2.7',
503
507
  locale,
504
508
  timezoneOffsetSeconds: -new Date().getTimezoneOffset() * 60,
505
509
  });
@@ -531,28 +535,45 @@ async function getBalance(runtime, locale, force = false) {
531
535
  return cache.value === undefined ? {} : { display: cache.value, amount: cache.amount, currency: cache.currency };
532
536
  }
533
537
  }
534
- async function getSessionContextLabel(runtime, sessionId) {
535
- if (runtime.tokenMeter === undefined)
536
- return undefined;
537
- const cached = runtime.contextCache.get(sessionId);
538
- if (cached !== undefined && Date.now() - cached.at < 15_000) {
539
- return cached.percent === undefined ? undefined : `${cached.percent}%`;
538
+ /**
539
+ * Read the client-facing context pressure. The projection view is the only
540
+ * place that carries `projectedTokens`, which already accounts for compaction;
541
+ * the token-meter facade returns the provider sample alone and therefore
542
+ * looks stale until the next request.
543
+ */
544
+ function readContextPressure(runtime, session) {
545
+ try {
546
+ const snapshot = runtime.sessionProjections?.snapshot(session, ['contextPressure']);
547
+ const value = asRecord(snapshot?.values['contextPressure']);
548
+ if (value !== undefined) {
549
+ return {
550
+ ...(typeof value['pressureTokens'] === 'number' ? { pressureTokens: value['pressureTokens'] } : {}),
551
+ ...(typeof value['projectedTokens'] === 'number' ? { projectedTokens: value['projectedTokens'] } : {}),
552
+ ...(typeof value['contextWindow'] === 'number' ? { contextWindow: value['contextWindow'] } : {}),
553
+ };
554
+ }
555
+ }
556
+ catch (error) {
557
+ runtime.logger.warn('context-projection-failed', messageOf(error));
540
558
  }
559
+ return runtime.tokenMeter?.contextPressure(session);
560
+ }
561
+ async function getSessionContextLabel(runtime, sessionId) {
541
562
  try {
542
563
  const result = await runtime.sessions.resolveAgent(sessionId);
543
564
  if (result.agent === undefined)
544
565
  return undefined;
545
- const pressure = runtime.tokenMeter.contextPressure(result.agent.session);
546
- // `pressureTokens` is the last request's prompt size and cannot see a
547
- // compaction. `projectedTokens` applies the surface delta since that
548
- // sample, matching the Web context meter.
566
+ const pressure = readContextPressure(runtime, result.agent.session);
567
+ if (pressure === undefined)
568
+ return undefined;
569
+ // Match the Web meter: `projectedTokens` is what the next request would
570
+ // carry, so compaction is visible immediately.
549
571
  const used = pressure.projectedTokens ?? pressure.pressureTokens;
550
572
  const percent = used !== undefined
551
573
  && pressure.contextWindow !== undefined
552
574
  && pressure.contextWindow > 0
553
- ? Math.round(100 * used / pressure.contextWindow)
575
+ ? Math.min(100, Math.round(100 * used / pressure.contextWindow))
554
576
  : undefined;
555
- runtime.contextCache.set(sessionId, { percent, at: Date.now() });
556
577
  return percent === undefined ? undefined : `${percent}%`;
557
578
  }
558
579
  catch (error) {
@@ -565,10 +586,10 @@ async function getContextLabel(runtime, binding) {
565
586
  return undefined;
566
587
  return getSessionContextLabel(runtime, binding.activeSessionId);
567
588
  }
568
- async function getMenuState(runtime, chatId, locale) {
589
+ async function getMenuState(runtime, chatId, locale, forceBalance = false) {
569
590
  const binding = runtime.store.get(chatId);
570
591
  const [balance, context] = await Promise.all([
571
- getBalance(runtime, locale),
592
+ getBalance(runtime, locale, forceBalance),
572
593
  getContextLabel(runtime, binding),
573
594
  ]);
574
595
  return {
@@ -655,7 +676,6 @@ async function runCompact(runtime, chatId, locale, sessionId) {
655
676
  // The preset that owns the session registers /compact together with its
656
677
  // isolated compaction backend; calling the command uses the same path as Web.
657
678
  const execution = await commands.execute(result.agent, '/compact', [], AbortSignal.timeout(300_000));
658
- runtime.contextCache.delete(sessionId);
659
679
  if (execution === undefined)
660
680
  return t(locale, 'compactUnavailable');
661
681
  runtime.logger.info('compact-result', 'manual compaction finished', {
@@ -679,7 +699,7 @@ async function runCompact(runtime, chatId, locale, sessionId) {
679
699
  async function statusText(runtime, chatId, locale) {
680
700
  const binding = runtime.store.get(chatId);
681
701
  const workspace = binding?.activeWorkspaceId === undefined ? undefined : runtime.workspaces.get(binding.activeWorkspaceId);
682
- const balance = await getBalance(runtime, locale);
702
+ const balance = await getBalance(runtime, locale, true);
683
703
  const context = await getContextLabel(runtime, binding);
684
704
  let agentStatus = 'β€”';
685
705
  if (binding?.activeSessionId !== undefined) {
@@ -872,14 +892,6 @@ function buildQuestionResultView(question, answer, outcome, locale) {
872
892
  }
873
893
  return { html: html.join('\n'), text: text.join('\n'), keyboard: new InlineKeyboard() };
874
894
  }
875
- async function clearQuestionKeyboard(runtime, chatId, messageId) {
876
- try {
877
- await runtime.bot.api.editMessageReplyMarkup(chatId, messageId, { reply_markup: new InlineKeyboard() });
878
- }
879
- catch (error) {
880
- runtime.logger.warn('question-keyboard-clear-failed', messageOf(error), { chatId });
881
- }
882
- }
883
895
  async function handleApproval(runtime, request, next) {
884
896
  if (request.signal?.aborted === true)
885
897
  return 'cancelled';
@@ -1019,7 +1031,6 @@ async function askQuestion(runtime, chatId, sessionId, locale, question, questio
1019
1031
  const result = buildQuestionResultView(question, answer, outcome, locale);
1020
1032
  void (async () => {
1021
1033
  await editRich(runtime, chatId, messageId, result);
1022
- await clearQuestionKeyboard(runtime, chatId, messageId);
1023
1034
  })();
1024
1035
  runtime.logger.info('question-closed', 'agent question closed', {
1025
1036
  chatId,
@@ -1284,8 +1295,8 @@ async function sendPlain(runtime, chatId, text, silent = false) {
1284
1295
  runtime.logger.error('send-failed', messageOf(error), { chatId });
1285
1296
  }
1286
1297
  }
1287
- async function sendMainMenu(runtime, chatId, locale, editMessageId) {
1288
- const state = await getMenuState(runtime, chatId, locale);
1298
+ async function sendMainMenu(runtime, chatId, locale, editMessageId, forceBalance = false) {
1299
+ const state = await getMenuState(runtime, chatId, locale, forceBalance);
1289
1300
  const view = buildMainMenu(runtime.workspaces.list(), state, locale);
1290
1301
  if (editMessageId !== undefined)
1291
1302
  await editRich(runtime, chatId, editMessageId, view);
@@ -1340,6 +1351,25 @@ function buildCompactView(state, locale) {
1340
1351
  const keyboard = new InlineKeyboard().text(t(locale, 'compact'), 'compact:yes').text(t(locale, 'back'), 'menu:home');
1341
1352
  return { html, text, keyboard };
1342
1353
  }
1354
+ function buildCompactWaitingView(locale) {
1355
+ const text = t(locale, 'compactWorking');
1356
+ return {
1357
+ html: `<p>${escapeHtml(text).replaceAll('\n', '<br>')}</p>`,
1358
+ text,
1359
+ keyboard: new InlineKeyboard(),
1360
+ };
1361
+ }
1362
+ function buildCompactResultView(text, locale) {
1363
+ return {
1364
+ html: [
1365
+ `<h2>${escapeHtml(t(locale, 'compactResultTitle'))}</h2>`,
1366
+ `<p>${escapeHtml(text).replaceAll('\n', '<br>')}</p>`,
1367
+ `<tg-button-row align="left"><tg-button type="callback_data" style="primary" data="menu:home">${escapeHtml(t(locale, 'home'))}</tg-button></tg-button-row>`,
1368
+ ].join('\n'),
1369
+ text,
1370
+ keyboard: new InlineKeyboard().text(t(locale, 'home'), 'menu:home'),
1371
+ };
1372
+ }
1343
1373
  function sessionTitle(session, locale) {
1344
1374
  if (session.blank)
1345
1375
  return t(locale, 'newSessionTitle');
@@ -1704,11 +1734,6 @@ async function handleSessionEvent(runtime, session, event) {
1704
1734
  void maybeWarnLowBalance(runtime, chatId, locale, silent);
1705
1735
  break;
1706
1736
  }
1707
- case 'compaction/end':
1708
- // Compaction can also be started from Web; drop the cached percentage
1709
- // so the next menu reads the updated projection immediately.
1710
- runtime.contextCache.delete(session.id);
1711
- break;
1712
1737
  default:
1713
1738
  break;
1714
1739
  }
@@ -1775,6 +1800,7 @@ async function runBot(ctx, config, workspaces, sessions, credentials, logger, si
1775
1800
  }
1776
1801
  const account = ctx.get('accountController');
1777
1802
  const tokenMeter = ctx.get('tokenMeter');
1803
+ const sessionProjections = ctx.get('sessionProjections');
1778
1804
  const commands = ctx.get('commands');
1779
1805
  const runtime = {
1780
1806
  bot,
@@ -1783,6 +1809,7 @@ async function runBot(ctx, config, workspaces, sessions, credentials, logger, si
1783
1809
  sessions,
1784
1810
  account,
1785
1811
  tokenMeter,
1812
+ sessionProjections,
1786
1813
  commands,
1787
1814
  adminUserId,
1788
1815
  allowedUserIds: [...allowedUserIds],
@@ -1797,7 +1824,6 @@ async function runBot(ctx, config, workspaces, sessions, credentials, logger, si
1797
1824
  pendingQuestionChats: new Map(),
1798
1825
  questionQueues: new Map(),
1799
1826
  balanceCache: { at: 0 },
1800
- contextCache: new Map(),
1801
1827
  lowBalanceWarnedAt: new Map(),
1802
1828
  rich: config.rich !== false,
1803
1829
  lowBalanceUsd: config.lowBalanceUsd ?? 1,
@@ -1873,14 +1899,14 @@ async function runBot(ctx, config, workspaces, sessions, credentials, logger, si
1873
1899
  if (binding !== undefined) {
1874
1900
  await store.set({ ...binding, locale, updatedAt: Date.now() });
1875
1901
  }
1876
- await sendMainMenu(runtime, chatId, locale);
1902
+ await sendMainMenu(runtime, chatId, locale, undefined, true);
1877
1903
  });
1878
1904
  bot.command('menu', async (grammyCtx) => {
1879
1905
  const chatId = grammyCtx.chat?.id;
1880
1906
  if (chatId === undefined)
1881
1907
  return;
1882
1908
  const locale = localeOf(grammyCtx.from?.language_code);
1883
- await sendMainMenu(runtime, chatId, locale);
1909
+ await sendMainMenu(runtime, chatId, locale, undefined, true);
1884
1910
  });
1885
1911
  bot.command('new', async (grammyCtx) => {
1886
1912
  const chatId = grammyCtx.chat?.id;
@@ -1932,8 +1958,13 @@ async function runBot(ctx, config, workspaces, sessions, credentials, logger, si
1932
1958
  await grammyCtx.reply(t(locale, 'noActiveSession'));
1933
1959
  return;
1934
1960
  }
1935
- await grammyCtx.reply(await runCompact(runtime, chatId, locale, binding.activeSessionId));
1936
- await sendMainMenu(runtime, chatId, locale);
1961
+ const waitingId = await sendRich(runtime, chatId, buildCompactWaitingView(locale), binding.sound === false);
1962
+ const text = await runCompact(runtime, chatId, locale, binding.activeSessionId);
1963
+ if (waitingId === undefined)
1964
+ await grammyCtx.reply(text);
1965
+ else
1966
+ await editRich(runtime, chatId, waitingId, buildCompactResultView(text, locale));
1967
+ await sendMainMenu(runtime, chatId, locale, undefined, true);
1937
1968
  });
1938
1969
  bot.callbackQuery(/^ws:(.+)$/, async (grammyCtx) => {
1939
1970
  const workspaceId = grammyCtx.match[1];
@@ -2052,7 +2083,7 @@ async function runBot(ctx, config, workspaces, sessions, credentials, logger, si
2052
2083
  return;
2053
2084
  const locale = localeOf(grammyCtx.from?.language_code);
2054
2085
  await grammyCtx.answerCallbackQuery().catch(() => undefined);
2055
- await sendMainMenu(runtime, chatId, locale, grammyCtx.callbackQuery?.message?.message_id);
2086
+ await sendMainMenu(runtime, chatId, locale, grammyCtx.callbackQuery?.message?.message_id, true);
2056
2087
  });
2057
2088
  bot.callbackQuery('menu:sound', async (grammyCtx) => {
2058
2089
  const chatId = grammyCtx.chat?.id;
@@ -2120,14 +2151,12 @@ async function runBot(ctx, config, workspaces, sessions, credentials, logger, si
2120
2151
  await grammyCtx.answerCallbackQuery({ text: t(locale, 'noActiveSession') }).catch(() => undefined);
2121
2152
  return;
2122
2153
  }
2123
- await grammyCtx.answerCallbackQuery({ text: t(locale, 'compact') }).catch(() => undefined);
2124
- const text = await runCompact(runtime, chatId, locale, binding.activeSessionId);
2125
- const view = {
2126
- html: `<h2>${escapeHtml(t(locale, 'compactHistory'))}</h2><p>${escapeHtml(text)}</p><tg-button-row align="left"><tg-button type="callback_data" style="primary" data="menu:home">${escapeHtml(t(locale, 'home'))}</tg-button></tg-button-row>`,
2127
- text,
2128
- keyboard: new InlineKeyboard().text(t(locale, 'home'), 'menu:home'),
2129
- };
2154
+ await grammyCtx.answerCallbackQuery().catch(() => undefined);
2130
2155
  const messageId = grammyCtx.callbackQuery?.message?.message_id;
2156
+ if (messageId !== undefined)
2157
+ await editRich(runtime, chatId, messageId, buildCompactWaitingView(locale));
2158
+ const text = await runCompact(runtime, chatId, locale, binding.activeSessionId);
2159
+ const view = buildCompactResultView(text, locale);
2131
2160
  if (messageId !== undefined)
2132
2161
  await editRich(runtime, chatId, messageId, view);
2133
2162
  else
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shliamb/dsh-telegram-bot",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "Telegram bridge for DeepSeek Harness",
5
5
  "keywords": [
6
6
  "deepseek-harness",