@shliamb/dsh-telegram-bot 0.2.5 β 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 +43 -11
- package/README.ru.md +42 -11
- package/lib/index.d.ts +6 -2
- package/lib/index.js +224 -68
- package/package.json +1 -1
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:**
|
|
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
|
|
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
|
+

|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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,13 +229,15 @@ 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.
|
|
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
|
|
|
236
|
+
Where the prompt appears is decided by the Telegram binding. If the request belongs to the Session currently open in the bot, Telegram claims it and shows the buttons. Any other Session keeps the prompt in Web; if Web has not settled it within 15 seconds, the bot sends a plain text notice naming the workspace and Session. This keeps Web as the primary surface while a deliberately opened Telegram Session takes over its own questions and approvals.
|
|
237
|
+
|
|
209
238
|
### Compaction, sound and stop
|
|
210
239
|
|
|
211
|
-
- **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.
|
|
212
241
|
- **Sound** is stored per chat. When it is off, answers, progress edits and the startup greeting use `disable_notification`.
|
|
213
242
|
- **Stop** asks for confirmation, then cancels the current turn with `agent.cancel({ kind: 'user' })`.
|
|
214
243
|
|
|
@@ -283,6 +312,7 @@ pnpm pack --pack-destination dist
|
|
|
283
312
|
src/index.ts Host plugin: config, bot runtime, menus, commands
|
|
284
313
|
src/client/index.tsx Web settings page (token + admin ID)
|
|
285
314
|
src/client/locales.ts Russian and English UI strings
|
|
315
|
+
images/ README screenshots
|
|
286
316
|
src/state/index.ts Chat bindings in the storageDomain
|
|
287
317
|
src/logging/index.ts JSONL file log with rotation
|
|
288
318
|
src/*/SPEC.md Module contracts and data formats
|
|
@@ -299,13 +329,15 @@ dist/ Prebuilt install archive
|
|
|
299
329
|
- Web settings expose only the token and the admin ID; `lowBalanceUsd`, `rich` and `apiRoot` are configured through `cordis.patch.yml`.
|
|
300
330
|
- No voice or file handling: Telegram transcribes voice messages itself.
|
|
301
331
|
- No proxy configuration.
|
|
302
|
-
-
|
|
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.
|
|
303
333
|
- Progress tracking is in memory, so a Host restart in the middle of a turn can leave a stale progress message.
|
|
304
334
|
|
|
305
335
|
## Roadmap
|
|
306
336
|
|
|
307
|
-
-
|
|
308
|
-
-
|
|
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.
|
|
309
341
|
|
|
310
342
|
## License
|
|
311
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
|
-
> **Π‘ΡΠ°ΡΡΡ:**
|
|
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
|
+

|
|
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.
|
|
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.
|
|
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.
|
|
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,13 +229,15 @@ ID Π°Π΄ΠΌΠΈΠ½Π° Ρ
ΡΠ°Π½ΠΈΡΡΡ Π² ΠΊΠΎΠ½ΡΠΈΠ³Π΅ ΠΏΠ»Π°Π³ΠΈΠ½Π°. ΠΡΠ»ΠΈ `all
|
|
|
202
229
|
|
|
203
230
|
### ΠΠΎΠ΄ΡΠ²Π΅ΡΠΆΠ΄Π΅Π½ΠΈΡ ΠΈ Π²ΠΎΠΏΡΠΎΡΡ
|
|
204
231
|
|
|
205
|
-
ΠΠΎΠ³Π΄Π° Π°Π³Π΅Π½Ρ ΠΏΡΠΎΡΠΈΡ ΠΏΠΎΠ΄ΡΠ²Π΅ΡΠ΄ΠΈΡΡ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½Ρ, Π±ΠΎΡ ΠΏΡΠΈΡΡΠ»Π°Π΅Ρ inline-ΠΊΠ½ΠΎΠΏΠΊΠΈ **Β«Π Π°Π·ΡΠ΅ΡΠΈΡΡΒ»** / **Β«ΠΠ°ΠΏΡΠ΅ΡΠΈΡΡΒ»**. ΠΠΎΠ³Π΄Π° Π°Π³Π΅Π½Ρ Π·Π°Π΄Π°ΡΡ Π²ΠΎΠΏΡΠΎΡ Ρ Π³ΠΎΡΠΎΠ²ΡΠΌΠΈ Π²Π°ΡΠΈΠ°Π½ΡΠ°ΠΌΠΈ, ΠΎΡΠ²Π΅ΡΡ ΡΠΎΠΆΠ΅ ΠΏΡΠΈΡ
ΠΎΠ΄ΡΡ ΠΊΠ½ΠΎΠΏΠΊΠ°ΠΌΠΈ.
|
|
232
|
+
ΠΠΎΠ³Π΄Π° Π°Π³Π΅Π½Ρ ΠΏΡΠΎΡΠΈΡ ΠΏΠΎΠ΄ΡΠ²Π΅ΡΠ΄ΠΈΡΡ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½Ρ, Π±ΠΎΡ ΠΏΡΠΈΡΡΠ»Π°Π΅Ρ inline-ΠΊΠ½ΠΎΠΏΠΊΠΈ **Β«Π Π°Π·ΡΠ΅ΡΠΈΡΡΒ»** / **Β«ΠΠ°ΠΏΡΠ΅ΡΠΈΡΡΒ»**. ΠΠΎΠ³Π΄Π° Π°Π³Π΅Π½Ρ Π·Π°Π΄Π°ΡΡ Π²ΠΎΠΏΡΠΎΡ Ρ Π³ΠΎΡΠΎΠ²ΡΠΌΠΈ Π²Π°ΡΠΈΠ°Π½ΡΠ°ΠΌΠΈ, ΠΎΡΠ²Π΅ΡΡ ΡΠΎΠΆΠ΅ ΠΏΡΠΈΡ
ΠΎΠ΄ΡΡ ΠΊΠ½ΠΎΠΏΠΊΠ°ΠΌΠΈ. Π Telegram ΠΊΠ°ΡΡΠΎΡΠΊΠ° Π·Π°ΠΊΡΡΠ²Π°Π΅ΡΡΡ ΡΠ΅ΡΠ΅Π· 10 ΠΌΠΈΠ½ΡΡ; Π²ΠΎΠΏΡΠΎΡ Π±Π΅Π· ΠΎΡΠ²Π΅ΡΠ° Π²ΠΎΠ·Π²ΡΠ°ΡΠ°Π΅ΡΡΡ ΠΊΠ°ΠΊ ΠΏΡΠΎΠΏΡΡΠ΅Π½Π½ΡΠΉ.
|
|
206
233
|
|
|
207
234
|
ΠΠΎΠ΄ΡΠ²Π΅ΡΠΆΠ΄Π΅Π½ΠΈΡ ΠΈ Π²ΠΎΠΏΡΠΎΡΡ ΠΎΡΠ²Π΅ΡΠ°ΡΡΡΡ Π΄Π»Ρ ΠΏΡΠΈΠ²ΡΠ·Π°Π½Π½ΠΎΠΉ ΡΠ΅ΡΡΠΈΠΈ. ΠΠΎΡ Π·Π°Π΄Π°ΡΡ Π²ΠΎΠΏΡΠΎΡΡ ΠΏΠΎ ΠΎΠ΄Π½ΠΎΠΌΡ. Π single-select Π½Π°ΠΆΠ°ΡΠΈΠ΅ Π²Π°ΡΠΈΠ°Π½ΡΠ° ΡΡΠ°Π·Ρ ΠΎΡΠΏΡΠ°Π²Π»ΡΠ΅Ρ ΠΎΡΠ²Π΅Ρ; Π² multi-select ΠΎΡΠΌΠ΅ΡΡ Π²Π°ΡΠΈΠ°Π½ΡΡ ΠΈ Π½Π°ΠΆΠΌΠΈ **Β«ΠΠΎΡΠΎΠ²ΠΎΒ»**. Π’Π΅ΠΊΡΡ, ΠΎΡΠΏΡΠ°Π²Π»Π΅Π½Π½ΡΠΉ ΠΏΡΠΈ ΠΎΡΠΊΡΡΡΠΎΠΌ Π²ΠΎΠΏΡΠΎΡΠ΅, ΡΡ
ΠΎΠ΄ΠΈΡ ΠΊΠ°ΠΊ Β«ΡΠ²ΠΎΠΉ ΠΎΡΠ²Π΅ΡΒ» (Π² multi-select Π΄ΠΎΠΏΠΎΠ»Π½ΡΠ΅Ρ Π²ΡΠ±ΡΠ°Π½Π½ΡΠ΅ Π²Π°ΡΠΈΠ°Π½ΡΡ), Π° **Β«ΠΡΠΎΠΏΡΡΡΠΈΡΡΒ»** ΠΎΡΡΠ°Π²Π»ΡΠ΅Ρ Π²ΠΎΠΏΡΠΎΡ Π±Π΅Π· ΠΎΡΠ²Π΅ΡΠ°. ΠΠΎΠΊΠ° Π²ΠΎΠΏΡΠΎΡ ΠΈΠ»ΠΈ approval ΠΎΡΠΊΡΡΡ, ΠΎΠ±ΡΡΠ½ΡΠΉ ΡΠ΅ΠΊΡΡ Π½Π΅ ΡΡΠ°Π²ΠΈΡΡΡ Π² ΠΎΡΠ΅ΡΠ΅Π΄Ρ ΠΊΠ°ΠΊ Π½ΠΎΠ²Π°Ρ Π·Π°Π΄Π°ΡΠ°.
|
|
208
235
|
|
|
236
|
+
ΠΡΠ΄Π° ΠΏΡΠΈΠ΄ΡΡ Π·Π°ΠΏΡΠΎΡ, ΡΠ΅ΡΠ°Π΅Ρ ΠΏΡΠΈΠ²ΡΠ·ΠΊΠ° Telegram. ΠΡΠ»ΠΈ Π·Π°ΠΏΡΠΎΡ ΠΎΡΠ½ΠΎΡΠΈΡΡΡ ΠΊ ΡΠ΅ΡΡΠΈΠΈ, ΠΊΠΎΡΠΎΡΠ°Ρ ΡΠ΅ΠΉΡΠ°Ρ ΠΎΡΠΊΡΡΡΠ° Π² Π±ΠΎΡΠ΅, Telegram Π·Π°Π±ΠΈΡΠ°Π΅Ρ Π΅Π³ΠΎ ΠΈ ΠΏΠΎΠΊΠ°Π·ΡΠ²Π°Π΅Ρ ΠΊΠ½ΠΎΠΏΠΊΠΈ. ΠΡΠ±Π°Ρ Π΄ΡΡΠ³Π°Ρ ΡΠ΅ΡΡΠΈΡ ΠΎΡΡΠ°Π²Π»ΡΠ΅Ρ Π·Π°ΠΏΡΠΎΡ Π² Web; Π΅ΡΠ»ΠΈ Web Π½Π΅ ΠΎΡΠ²Π΅ΡΠΈΠ» Π·Π° 15 ΡΠ΅ΠΊΡΠ½Π΄, Π±ΠΎΡ ΠΏΡΠΈΡΡΠ»Π°Π΅Ρ ΠΎΠ±ΡΡΠ½ΠΎΠ΅ ΡΠ΅ΠΊΡΡΠΎΠ²ΠΎΠ΅ ΡΠ²Π΅Π΄ΠΎΠΌΠ»Π΅Π½ΠΈΠ΅ Ρ Π½Π°Π·Π²Π°Π½ΠΈΠ΅ΠΌ ΠΏΡΠΎΡΡΡΠ°Π½ΡΡΠ²Π° ΠΈ ΡΠ΅ΡΡΠΈΠΈ. Π’Π°ΠΊ Web ΠΎΡΡΠ°ΡΡΡΡ ΠΎΡΠ½ΠΎΠ²Π½ΡΠΌ ΡΠΊΡΠ°Π½ΠΎΠΌ, Π° ΡΠΏΠ΅ΡΠΈΠ°Π»ΡΠ½ΠΎ ΠΎΡΠΊΡΡΡΠ°Ρ ΡΠ΅ΡΡΠΈΡ Π² Telegram Π·Π°Π±ΠΈΡΠ°Π΅Ρ ΡΠ²ΠΎΠΈ Π²ΠΎΠΏΡΠΎΡΡ ΠΈ ΠΏΠΎΠ΄ΡΠ²Π΅ΡΠΆΠ΄Π΅Π½ΠΈΡ.
|
|
237
|
+
|
|
209
238
|
### Π‘ΠΆΠ°ΡΠΈΠ΅, Π·Π²ΡΠΊ ΠΈ ΠΎΡΡΠ°Π½ΠΎΠ²ΠΊΠ°
|
|
210
239
|
|
|
211
|
-
- **Β«Π‘ΠΆΠ°ΡΡΒ»** ΠΏΠΎΠΊΠ°Π·ΡΠ²Π°Π΅Ρ ΡΠ΅ΠΊΡΡΠΈΠΉ ΠΏΡΠΎΡΠ΅Π½Ρ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ° ΠΈ ΠΏΡΠΎΡΠΈΡ ΠΏΠΎΠ΄ΡΠ²Π΅ΡΠΆΠ΄Π΅Π½ΠΈΠ΅. ΠΠ»Π°Π³ΠΈΠ½ Π²ΡΠ·ΡΠ²Π°Π΅Ρ preset-ΠΊΠΎΠΌΠ°Π½Π΄Ρ `/compact` ΡΠ΅ΡΠ΅Π· ΡΠ΅ΡΠ²ΠΈΡ `commands`, Π·Π°ΡΠ΅ΠΌ ΠΏΠΎΠΊΠ°Π·ΡΠ²Π°Π΅Ρ Π»ΠΎΠΊΠ°Π»ΠΈΠ·ΠΎΠ²Π°Π½Π½ΡΠΉ ΡΠ΅Π·ΡΠ»ΡΡΠ°Ρ ΠΈ Π½ΠΎΠ²ΡΠΉ ΠΏΡΠΎΡΠ΅Π½Ρ. ΠΡΠ»ΠΈ Π°Π³Π΅Π½Ρ Π·Π°Π½ΡΡ, ΡΠΆΠ°ΡΠΈΠ΅ ΠΎΡΠΊΠ»ΠΎΠ½ΡΠ΅ΡΡΡ.
|
|
240
|
+
- **Β«Π‘ΠΆΠ°ΡΡΒ»** ΠΏΠΎΠΊΠ°Π·ΡΠ²Π°Π΅Ρ ΡΠ΅ΠΊΡΡΠΈΠΉ ΠΏΡΠΎΡΠ΅Π½Ρ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ° ΠΈ ΠΏΡΠΎΡΠΈΡ ΠΏΠΎΠ΄ΡΠ²Π΅ΡΠΆΠ΄Π΅Π½ΠΈΠ΅. ΠΠΎΡΠ»Π΅ Π½Π°ΠΆΠ°ΡΠΈΡ **Β«Π‘ΠΆΠ°ΡΡΒ»** ΠΊΠ°ΡΡΠΎΡΠΊΠ° Π·Π°ΠΌΠ΅Π½ΡΠ΅ΡΡΡ ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΠ΅ΠΌ Β«ΠΠΆΠΈΠ΄Π°ΠΉΡΠ΅Β», Π° ΠΊΠ½ΠΎΠΏΠΊΠΈ ΠΈΡΡΠ΅Π·Π°ΡΡ, ΠΏΠΎΡΡΠΎΠΌΡ ΠΏΠΎΠ²ΡΠΎΡΠ½ΡΠ΅ Π½Π°ΠΆΠ°ΡΠΈΡ Π½ΠΈΡΠ΅Π³ΠΎ Π½Π΅ Π΄Π΅Π»Π°ΡΡ. ΠΠ»Π°Π³ΠΈΠ½ Π²ΡΠ·ΡΠ²Π°Π΅Ρ preset-ΠΊΠΎΠΌΠ°Π½Π΄Ρ `/compact` ΡΠ΅ΡΠ΅Π· ΡΠ΅ΡΠ²ΠΈΡ `commands`, Π·Π°ΡΠ΅ΠΌ ΠΏΠΎΠΊΠ°Π·ΡΠ²Π°Π΅Ρ Π»ΠΎΠΊΠ°Π»ΠΈΠ·ΠΎΠ²Π°Π½Π½ΡΠΉ ΡΠ΅Π·ΡΠ»ΡΡΠ°Ρ ΠΈ Π½ΠΎΠ²ΡΠΉ ΠΏΡΠΎΡΠ΅Π½Ρ. ΠΡΠ»ΠΈ Π°Π³Π΅Π½Ρ Π·Π°Π½ΡΡ, ΡΠΆΠ°ΡΠΈΠ΅ ΠΎΡΠΊΠ»ΠΎΠ½ΡΠ΅ΡΡΡ.
|
|
212
241
|
- **Β«ΠΠ²ΡΠΊΒ»** Ρ
ΡΠ°Π½ΠΈΡΡΡ Π΄Π»Ρ ΠΊΠ°ΠΆΠ΄ΠΎΠ³ΠΎ ΡΠ°ΡΠ°. ΠΠΎΠ³Π΄Π° ΠΎΠ½ Π²ΡΠΊΠ»ΡΡΠ΅Π½, ΠΎΡΠ²Π΅ΡΡ, ΠΏΡΠ°Π²ΠΊΠΈ progress ΠΈ ΠΏΡΠΈΠ²Π΅ΡΡΡΠ²ΠΈΠ΅ ΠΏΡΠΈ ΡΡΠ°ΡΡΠ΅ ΠΈΠ΄ΡΡ Ρ `disable_notification`.
|
|
213
242
|
- **Β«Π‘ΡΠΎΠΏΒ»** ΠΏΡΠΎΡΠΈΡ ΠΏΠΎΠ΄ΡΠ²Π΅ΡΠΆΠ΄Π΅Π½ΠΈΠ΅, Π·Π°ΡΠ΅ΠΌ ΠΎΡΠΌΠ΅Π½ΡΠ΅Ρ ΡΠ΅ΠΊΡΡΠΈΠΉ Ρ
ΠΎΠ΄ ΡΠ΅ΡΠ΅Π· `agent.cancel({ kind: 'user' })`.
|
|
214
243
|
|
|
@@ -283,6 +312,7 @@ pnpm pack --pack-destination dist
|
|
|
283
312
|
src/index.ts Host-ΠΏΠ»Π°Π³ΠΈΠ½: ΠΊΠΎΠ½ΡΠΈΠ³, runtime Π±ΠΎΡΠ°, ΠΌΠ΅Π½Ρ, ΠΊΠΎΠΌΠ°Π½Π΄Ρ
|
|
284
313
|
src/client/index.tsx Web-ΡΡΡΠ°Π½ΠΈΡΠ° Π½Π°ΡΡΡΠΎΠ΅ΠΊ (ΡΠΎΠΊΠ΅Π½ + ID Π°Π΄ΠΌΠΈΠ½Π°)
|
|
285
314
|
src/client/locales.ts Π ΡΡΡΠΊΠΈΠ΅ ΠΈ Π°Π½Π³Π»ΠΈΠΉΡΠΊΠΈΠ΅ ΡΡΡΠΎΠΊΠΈ ΠΈΠ½ΡΠ΅ΡΡΠ΅ΠΉΡΠ°
|
|
315
|
+
images/ Π‘ΠΊΡΠΈΠ½ΡΠΎΡΡ Π΄Π»Ρ README
|
|
286
316
|
src/state/index.ts ΠΡΠΈΠ²ΡΠ·ΠΊΠΈ ΡΠ°ΡΠΎΠ² Π² storageDomain
|
|
287
317
|
src/logging/index.ts JSONL-Π»ΠΎΠ³ Ρ ΡΠΎΡΠ°ΡΠΈΠ΅ΠΉ
|
|
288
318
|
src/*/SPEC.md ΠΠΎΠ½ΡΡΠ°ΠΊΡΡ ΠΌΠΎΠ΄ΡΠ»Π΅ΠΉ ΠΈ ΡΠΎΡΠΌΠ°ΡΡ Π΄Π°Π½Π½ΡΡ
|
|
@@ -299,13 +329,14 @@ dist/ ΠΠΎΡΠΎΠ²ΡΠΉ ΡΡΡΠ°Π½ΠΎΠ²ΠΎΡΠ½ΡΠΉ Π°ΡΡ
ΠΈΠ²
|
|
|
299
329
|
- Π Web-Π½Π°ΡΡΡΠΎΠΉΠΊΠ°Ρ
ΡΠΎΠ»ΡΠΊΠΎ ΡΠΎΠΊΠ΅Π½ ΠΈ ID Π°Π΄ΠΌΠΈΠ½Π°; `lowBalanceUsd`, `rich` ΠΈ `apiRoot` Π·Π°Π΄Π°ΡΡΡΡ ΡΠ΅ΡΠ΅Π· `cordis.patch.yml`.
|
|
300
330
|
- ΠΠ΅Ρ Π³ΠΎΠ»ΠΎΡΠΎΠ²ΡΡ
ΠΈ ΡΠ°ΠΉΠ»ΠΎΠ²: Telegram ΡΠ°ΠΌ ΡΡΠ°Π½ΡΠΊΡΠΈΠ±ΠΈΡΡΠ΅Ρ Π³ΠΎΠ»ΠΎΡ.
|
|
301
331
|
- ΠΠ΅Ρ Π½Π°ΡΡΡΠΎΠΉΠΊΠΈ ΠΏΡΠΎΠΊΡΠΈ.
|
|
302
|
-
-
|
|
332
|
+
- ΠΠΎΠΏΡΠΎΡΡ ΠΈ ΠΏΠΎΠ΄ΡΠ²Π΅ΡΠΆΠ΄Π΅Π½ΠΈΡ Π°ΠΊΡΠΈΠ²Π½ΠΎΠΉ Telegram-ΡΠ΅ΡΡΠΈΠΈ ΠΏΠΎΠΊΠ°Π·ΡΠ²Π°ΡΡΡΡ ΡΠΎΠ»ΡΠΊΠΎ Π² Telegram; ΠΎΡΡΠ°Π»ΡΠ½ΡΠ΅ ΡΠ΅ΡΡΠΈΠΈ ΠΎΡΡΠ°ΡΡΡΡ Π² Web Ρ ΠΎΡΠ»ΠΎΠΆΠ΅Π½Π½ΡΠΌ ΡΠ΅ΠΊΡΡΠΎΠ²ΡΠΌ ΡΠ²Π΅Π΄ΠΎΠΌΠ»Π΅Π½ΠΈΠ΅ΠΌ. Telegram ΠΏΠΎΠ΄Π΄Π΅ΡΠΆΠΈΠ²Π°Π΅Ρ single-select, multi-select, ΡΠ²ΠΎΠΉ ΡΠ΅ΠΊΡΡ ΠΈ ΠΏΡΠΎΠΏΡΡΠΊ.
|
|
303
333
|
- ΠΡΡΠ»Π΅ΠΆΠΈΠ²Π°Π½ΠΈΠ΅ progress ΠΆΠΈΠ²ΡΡ Π² ΠΏΠ°ΠΌΡΡΠΈ, ΠΏΠΎΡΡΠΎΠΌΡ ΠΏΠ΅ΡΠ΅Π·Π°ΠΏΡΡΠΊ Host ΠΏΠΎΡΡΠ΅Π΄ΠΈ Ρ
ΠΎΠ΄Π° ΠΌΠΎΠΆΠ΅Ρ ΠΎΡΡΠ°Π²ΠΈΡΡ ΡΡΡΠ°ΡΠ΅Π²ΡΠ΅Π΅ progress-ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΠ΅.
|
|
304
334
|
|
|
305
335
|
## Roadmap
|
|
306
336
|
|
|
307
|
-
-
|
|
308
|
-
-
|
|
337
|
+
- ΠΠΎΡΠΎΠ²ΠΎ Π² 0.2.5: ΠΏΡΠΎΡΠ΅Π½Ρ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ° ΠΏΠΎ `projectedTokens`, ΠΏΠ΅ΡΠ΅ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠ΅ ΠΏΡΡΡΡΡ
ΡΠ΅ΡΡΠΈΠΉ, `β
` ΡΠ΅ΠΊΡΡΠ΅ΠΉ ΡΠ΅ΡΡΠΈΠΈ, Π°Π½Π³Π»ΠΈΠΉΡΠΊΠΈΠΉ fallback ΠΊΠΎΠΌΠ°Π½Π΄, ΡΠΈΠ½Ρ
ΡΠΎΠ½ΠΈΠ·Π°ΡΠΈΡ Π»ΠΎΠΊΠ°Π»ΠΈ.
|
|
338
|
+
- ΠΠΎΡΠΎΠ²ΠΎ Π² 0.2.6: ΠΌΠ°ΡΡΡΡΡΠΈΠ·Π°ΡΠΈΡ Π²ΠΎΠΏΡΠΎΡΠΎΠ² ΠΈ ΠΏΠΎΠ΄ΡΠ²Π΅ΡΠΆΠ΄Π΅Π½ΠΈΠΉ ΠΏΠΎ Π°ΠΊΡΠΈΠ²Π½ΠΎΠΉ ΡΠ΅ΡΡΠΈΠΈ, ΡΠ΅ΠΊΡΡΠΎΠ²ΠΎΠ΅ ΡΠ²Π΅Π΄ΠΎΠΌΠ»Π΅Π½ΠΈΠ΅ Web ΡΠ΅ΡΠ΅Π· 15 ΡΠ΅ΠΊΡΠ½Π΄, Π΄ΠΈΠ°Π³Π½ΠΎΡΡΠΈΠΊΠ°.
|
|
339
|
+
- ΠΠ°Π»ΡΡΠ΅: ΡΠ±ΡΠ°ΡΡ Π»ΠΈΡΠ½ΡΡ ΠΎΡΠΈΡΡΠΊΡ ΠΊΠ»Π°Π²ΠΈΠ°ΡΡΡΡ Π²ΠΎΠΏΡΠΎΡΠ°; `/history`; ΠΌΠ°ΡΡΡΡΡΠΈΠ·Π°ΡΠΈΡ ΠΎΡΠ²Π΅ΡΠΎΠ²; ΡΠ²Π΅Π΄ΠΎΠΌΠ»Π΅Π½ΠΈΡ ΠΎ Π·Π°Π²Π΅ΡΡΠ΅Π½ΠΈΠΈ Π² Π΄ΡΡΠ³ΠΈΡ
ΡΠ΅ΡΡΠΈΡΡ
; ΠΊΠ°ΡΠ°Π»ΠΎΠ³ ΠΏΠ»Π°Π³ΠΈΠ½ΠΎΠ².
|
|
309
340
|
|
|
310
341
|
## ΠΠΈΡΠ΅Π½Π·ΠΈΡ
|
|
311
342
|
|
package/lib/index.d.ts
CHANGED
|
@@ -70,6 +70,10 @@ interface DshSessionEvent {
|
|
|
70
70
|
readonly type: string;
|
|
71
71
|
readonly data: Record<string, unknown>;
|
|
72
72
|
}
|
|
73
|
+
interface ListenerOptions {
|
|
74
|
+
/** Add this listener ahead of listeners registered earlier for the event. */
|
|
75
|
+
prepend?: boolean;
|
|
76
|
+
}
|
|
73
77
|
interface HarnessContext {
|
|
74
78
|
readonly logger: Logger;
|
|
75
79
|
get(name: string): unknown;
|
|
@@ -77,8 +81,8 @@ interface HarnessContext {
|
|
|
77
81
|
on(event: 'session/event', listener: (session: DshSession, event: DshSessionEvent) => void): () => void;
|
|
78
82
|
on(event: 'credentials/reference-updated', listener: (ref: string) => void): () => void;
|
|
79
83
|
on(event: 'settings/document-updated', listener: (namespace: string, revision: number) => void): () => void;
|
|
80
|
-
on(event: 'approval/request', listener: (request: ApprovalRequest, next: () => Promise<ApprovalOutcome>) => Promise<ApprovalOutcome
|
|
81
|
-
on(event: 'user-questions/request', listener: (request: AskQuestionRequest, next: () => Promise<AskQuestionAnswer>) => Promise<AskQuestionAnswer
|
|
84
|
+
on(event: 'approval/request', listener: (request: ApprovalRequest, next: () => Promise<ApprovalOutcome>) => Promise<ApprovalOutcome>, options?: ListenerOptions): () => void;
|
|
85
|
+
on(event: 'user-questions/request', listener: (request: AskQuestionRequest, next: () => Promise<AskQuestionAnswer>) => Promise<AskQuestionAnswer>, options?: ListenerOptions): () => void;
|
|
82
86
|
}
|
|
83
87
|
/**
|
|
84
88
|
* Loader/settings schema. Only `adminUserId` is volatile: it is the one field
|
package/lib/index.js
CHANGED
|
@@ -59,6 +59,9 @@ const STRINGS = {
|
|
|
59
59
|
selectSession: 'ΠΡΠ±Π΅ΡΠΈ ΡΠ΅ΡΡΠΈΡ:',
|
|
60
60
|
noSessions: 'Π ΡΡΠΎΠΌ ΠΏΡΠΎΡΡΡΠ°Π½ΡΡΠ²Π΅ ΠΏΠΎΠΊΠ° Π½Π΅Ρ ΡΠ΅ΡΡΠΈΠΉ. ΠΠ°ΠΆΠΌΠΈ Β«ΠΠΎΠ²Π°Ρ ΡΠ΅ΡΡΠΈΡΒ» ΠΈΠ»ΠΈ ΠΏΡΠΎΡΡΠΎ Π½Π°ΠΏΠΈΡΠΈ ΡΠ΅ΠΊΡΡ.',
|
|
61
61
|
sessionLegend: 'β
β ΡΠ΅ΠΊΡΡΠ°Ρ, π’ β ΡΠ°Π±ΠΎΡΠ°Π΅Ρ, βͺ β ΠΎΠΆΠΈΠ΄Π°Π΅Ρ',
|
|
62
|
+
webWaitingQuestion: 'β³ Π Web ΠΎΠΆΠΈΠ΄Π°Π΅ΡΡΡ ΠΎΡΠ²Π΅Ρ',
|
|
63
|
+
webWaitingApproval: 'β³ Π Web ΠΎΠΆΠΈΠ΄Π°Π΅ΡΡΡ ΠΏΠΎΠ΄ΡΠ²Π΅ΡΠΆΠ΄Π΅Π½ΠΈΠ΅',
|
|
64
|
+
webWaitingHint: 'ΠΡΠΊΡΠΎΠΉ Web, ΡΡΠΎΠ±Ρ ΠΏΡΠΎΠ΄ΠΎΠ»ΠΆΠΈΡΡ.',
|
|
62
65
|
sessions: 'π Π‘Π΅ΡΡΠΈΠΈ',
|
|
63
66
|
backToWorkspaces: 'βοΈ ΠΡΠΎΡΡΡΠ°Π½ΡΡΠ²Π°',
|
|
64
67
|
newSession: 'β ΠΠΎΠ²Π°Ρ ΡΠ΅ΡΡΠΈΡ',
|
|
@@ -81,6 +84,8 @@ const STRINGS = {
|
|
|
81
84
|
compactNoHistory: 'ΠΠ΅ΡΠ΅Π³ΠΎ ΡΠΆΠΈΠΌΠ°ΡΡ.',
|
|
82
85
|
compactConfirm: 'Π‘ΡΠ°ΡΠ°Ρ ΠΈΡΡΠΎΡΠΈΡ Π±ΡΠ΄Π΅Ρ Π·Π°ΠΌΠ΅Π½Π΅Π½Π° ΠΊΡΠ°ΡΠΊΠΈΠΌ ΡΠ΅Π·ΡΠΌΠ΅.',
|
|
83
86
|
compactDone: 'ΠΡΡΠΎΡΠΈΡ ΡΠΆΠ°ΡΠ°.',
|
|
87
|
+
compactWorking: 'β³ Π‘ΠΆΠΈΠΌΠ°Ρ ΠΈΡΡΠΎΡΠΈΡβ¦\nΠΠΎΠ΄ΠΎΠΆΠ΄ΠΈΡΠ΅, ΠΏΠΎΠΆΠ°Π»ΡΠΉΡΡΠ°.',
|
|
88
|
+
compactResultTitle: 'Π‘ΠΆΠ°ΡΠΈΠ΅ ΠΈΡΡΠΎΡΠΈΠΈ',
|
|
84
89
|
stop: 'βΉ Π‘ΡΠΎΠΏ',
|
|
85
90
|
stopDone: 'ΠΡΡΠ°Π½ΠΎΠ²Π»Π΅Π½ΠΎ.',
|
|
86
91
|
stopIdle: 'ΠΠ΅ΡΠ΅Π³ΠΎ ΠΎΡΡΠ°Π½Π°Π²Π»ΠΈΠ²Π°ΡΡ.',
|
|
@@ -173,6 +178,9 @@ const STRINGS = {
|
|
|
173
178
|
selectSession: 'Choose a session:',
|
|
174
179
|
noSessions: 'No sessions in this workspace yet. Tap New session or just send text.',
|
|
175
180
|
sessionLegend: 'β
current, π’ running, βͺ idle',
|
|
181
|
+
webWaitingQuestion: 'β³ Web is waiting for an answer',
|
|
182
|
+
webWaitingApproval: 'β³ Web is waiting for approval',
|
|
183
|
+
webWaitingHint: 'Open Web to continue.',
|
|
176
184
|
sessions: 'π Sessions',
|
|
177
185
|
backToWorkspaces: 'βοΈ Workspaces',
|
|
178
186
|
newSession: 'β New session',
|
|
@@ -195,6 +203,8 @@ const STRINGS = {
|
|
|
195
203
|
compactNoHistory: 'No compactable history.',
|
|
196
204
|
compactConfirm: 'Older history will be replaced by a short summary.',
|
|
197
205
|
compactDone: 'History compacted.',
|
|
206
|
+
compactWorking: 'β³ Compacting historyβ¦\nPlease wait.',
|
|
207
|
+
compactResultTitle: 'History compaction',
|
|
198
208
|
stop: 'βΉ Stop',
|
|
199
209
|
stopDone: 'Stopped.',
|
|
200
210
|
stopIdle: 'Nothing to stop.',
|
|
@@ -493,7 +503,7 @@ async function getBalance(runtime, locale, force = false) {
|
|
|
493
503
|
}
|
|
494
504
|
try {
|
|
495
505
|
const result = await runtime.account.getBalance({
|
|
496
|
-
version: '@shliamb/dsh-telegram-bot/0.2.
|
|
506
|
+
version: '@shliamb/dsh-telegram-bot/0.2.7',
|
|
497
507
|
locale,
|
|
498
508
|
timezoneOffsetSeconds: -new Date().getTimezoneOffset() * 60,
|
|
499
509
|
});
|
|
@@ -525,28 +535,45 @@ async function getBalance(runtime, locale, force = false) {
|
|
|
525
535
|
return cache.value === undefined ? {} : { display: cache.value, amount: cache.amount, currency: cache.currency };
|
|
526
536
|
}
|
|
527
537
|
}
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
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
|
+
}
|
|
534
555
|
}
|
|
556
|
+
catch (error) {
|
|
557
|
+
runtime.logger.warn('context-projection-failed', messageOf(error));
|
|
558
|
+
}
|
|
559
|
+
return runtime.tokenMeter?.contextPressure(session);
|
|
560
|
+
}
|
|
561
|
+
async function getSessionContextLabel(runtime, sessionId) {
|
|
535
562
|
try {
|
|
536
563
|
const result = await runtime.sessions.resolveAgent(sessionId);
|
|
537
564
|
if (result.agent === undefined)
|
|
538
565
|
return undefined;
|
|
539
|
-
const pressure = runtime
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
//
|
|
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.
|
|
543
571
|
const used = pressure.projectedTokens ?? pressure.pressureTokens;
|
|
544
572
|
const percent = used !== undefined
|
|
545
573
|
&& pressure.contextWindow !== undefined
|
|
546
574
|
&& pressure.contextWindow > 0
|
|
547
|
-
? Math.round(100 * used / pressure.contextWindow)
|
|
575
|
+
? Math.min(100, Math.round(100 * used / pressure.contextWindow))
|
|
548
576
|
: undefined;
|
|
549
|
-
runtime.contextCache.set(sessionId, { percent, at: Date.now() });
|
|
550
577
|
return percent === undefined ? undefined : `${percent}%`;
|
|
551
578
|
}
|
|
552
579
|
catch (error) {
|
|
@@ -559,10 +586,10 @@ async function getContextLabel(runtime, binding) {
|
|
|
559
586
|
return undefined;
|
|
560
587
|
return getSessionContextLabel(runtime, binding.activeSessionId);
|
|
561
588
|
}
|
|
562
|
-
async function getMenuState(runtime, chatId, locale) {
|
|
589
|
+
async function getMenuState(runtime, chatId, locale, forceBalance = false) {
|
|
563
590
|
const binding = runtime.store.get(chatId);
|
|
564
591
|
const [balance, context] = await Promise.all([
|
|
565
|
-
getBalance(runtime, locale),
|
|
592
|
+
getBalance(runtime, locale, forceBalance),
|
|
566
593
|
getContextLabel(runtime, binding),
|
|
567
594
|
]);
|
|
568
595
|
return {
|
|
@@ -649,7 +676,6 @@ async function runCompact(runtime, chatId, locale, sessionId) {
|
|
|
649
676
|
// The preset that owns the session registers /compact together with its
|
|
650
677
|
// isolated compaction backend; calling the command uses the same path as Web.
|
|
651
678
|
const execution = await commands.execute(result.agent, '/compact', [], AbortSignal.timeout(300_000));
|
|
652
|
-
runtime.contextCache.delete(sessionId);
|
|
653
679
|
if (execution === undefined)
|
|
654
680
|
return t(locale, 'compactUnavailable');
|
|
655
681
|
runtime.logger.info('compact-result', 'manual compaction finished', {
|
|
@@ -673,7 +699,7 @@ async function runCompact(runtime, chatId, locale, sessionId) {
|
|
|
673
699
|
async function statusText(runtime, chatId, locale) {
|
|
674
700
|
const binding = runtime.store.get(chatId);
|
|
675
701
|
const workspace = binding?.activeWorkspaceId === undefined ? undefined : runtime.workspaces.get(binding.activeWorkspaceId);
|
|
676
|
-
const balance = await getBalance(runtime, locale);
|
|
702
|
+
const balance = await getBalance(runtime, locale, true);
|
|
677
703
|
const context = await getContextLabel(runtime, binding);
|
|
678
704
|
let agentStatus = 'β';
|
|
679
705
|
if (binding?.activeSessionId !== undefined) {
|
|
@@ -866,29 +892,49 @@ function buildQuestionResultView(question, answer, outcome, locale) {
|
|
|
866
892
|
}
|
|
867
893
|
return { html: html.join('\n'), text: text.join('\n'), keyboard: new InlineKeyboard() };
|
|
868
894
|
}
|
|
869
|
-
async function clearQuestionKeyboard(runtime, chatId, messageId) {
|
|
870
|
-
try {
|
|
871
|
-
await runtime.bot.api.editMessageReplyMarkup(chatId, messageId, { reply_markup: new InlineKeyboard() });
|
|
872
|
-
}
|
|
873
|
-
catch (error) {
|
|
874
|
-
runtime.logger.warn('question-keyboard-clear-failed', messageOf(error), { chatId });
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
895
|
async function handleApproval(runtime, request, next) {
|
|
878
896
|
if (request.signal?.aborted === true)
|
|
879
897
|
return 'cancelled';
|
|
880
|
-
const
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
898
|
+
const sessionId = request.agent.session.id;
|
|
899
|
+
const target = answerTargetForSession(runtime, sessionId);
|
|
900
|
+
if (target === undefined) {
|
|
901
|
+
runtime.logger.info('approval-delegated', 'session is not bound to a Telegram chat', {
|
|
902
|
+
sessionId,
|
|
903
|
+
toolName: request.toolName,
|
|
904
|
+
reason: 'unbound',
|
|
905
|
+
});
|
|
906
|
+
const answer = next();
|
|
907
|
+
scheduleWebWaitingNotice(runtime, undefined, sessionId, 'approval', answer, request.toolName);
|
|
908
|
+
return answer;
|
|
909
|
+
}
|
|
910
|
+
const { chatId, binding, active } = target;
|
|
887
911
|
const locale = binding?.locale ?? 'ru';
|
|
912
|
+
if (!active) {
|
|
913
|
+
runtime.logger.info('approval-delegated', 'session is not active in Telegram', {
|
|
914
|
+
chatId,
|
|
915
|
+
sessionId,
|
|
916
|
+
toolName: request.toolName,
|
|
917
|
+
reason: 'not-active',
|
|
918
|
+
});
|
|
919
|
+
const answer = next();
|
|
920
|
+
scheduleWebWaitingNotice(runtime, target, sessionId, 'approval', answer, request.toolName);
|
|
921
|
+
return answer;
|
|
922
|
+
}
|
|
923
|
+
runtime.logger.info('approval-claimed', 'approval claimed for Telegram', {
|
|
924
|
+
chatId,
|
|
925
|
+
sessionId,
|
|
926
|
+
toolName: request.toolName,
|
|
927
|
+
});
|
|
888
928
|
const token = randomUUID().slice(0, 8);
|
|
889
929
|
const messageId = await sendRich(runtime, chatId, buildApprovalView(request, token, locale), binding?.sound === false);
|
|
890
|
-
if (messageId === undefined)
|
|
930
|
+
if (messageId === undefined) {
|
|
931
|
+
runtime.logger.info('approval-delegated', 'could not send approval to Telegram', {
|
|
932
|
+
chatId,
|
|
933
|
+
sessionId,
|
|
934
|
+
reason: 'send-failed',
|
|
935
|
+
});
|
|
891
936
|
return next();
|
|
937
|
+
}
|
|
892
938
|
return await new Promise((resolve) => {
|
|
893
939
|
let settled = false;
|
|
894
940
|
let timer;
|
|
@@ -985,7 +1031,6 @@ async function askQuestion(runtime, chatId, sessionId, locale, question, questio
|
|
|
985
1031
|
const result = buildQuestionResultView(question, answer, outcome, locale);
|
|
986
1032
|
void (async () => {
|
|
987
1033
|
await editRich(runtime, chatId, messageId, result);
|
|
988
|
-
await clearQuestionKeyboard(runtime, chatId, messageId);
|
|
989
1034
|
})();
|
|
990
1035
|
runtime.logger.info('question-closed', 'agent question closed', {
|
|
991
1036
|
chatId,
|
|
@@ -1016,8 +1061,10 @@ async function askQuestion(runtime, chatId, sessionId, locale, question, questio
|
|
|
1016
1061
|
return await answerPromise;
|
|
1017
1062
|
}
|
|
1018
1063
|
async function handleQuestion(runtime, request, next) {
|
|
1019
|
-
if (request.agent === undefined)
|
|
1064
|
+
if (request.agent === undefined) {
|
|
1065
|
+
runtime.logger.info('question-delegated', 'question has no owning agent', { reason: 'no-agent' });
|
|
1020
1066
|
return next();
|
|
1067
|
+
}
|
|
1021
1068
|
if (request.questions.length === 0)
|
|
1022
1069
|
return next();
|
|
1023
1070
|
const aborted = () => request.signal?.aborted === true;
|
|
@@ -1026,15 +1073,36 @@ async function handleQuestion(runtime, request, next) {
|
|
|
1026
1073
|
});
|
|
1027
1074
|
if (aborted())
|
|
1028
1075
|
return skippedAll();
|
|
1029
|
-
const
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1076
|
+
const sessionId = request.agent.session.id;
|
|
1077
|
+
const target = answerTargetForSession(runtime, sessionId);
|
|
1078
|
+
if (target === undefined) {
|
|
1079
|
+
runtime.logger.info('question-delegated', 'session is not bound to a Telegram chat', {
|
|
1080
|
+
sessionId,
|
|
1081
|
+
reason: 'unbound',
|
|
1082
|
+
});
|
|
1083
|
+
const answer = next();
|
|
1084
|
+
scheduleWebWaitingNotice(runtime, undefined, sessionId, 'question', answer);
|
|
1085
|
+
return answer;
|
|
1086
|
+
}
|
|
1087
|
+
const { chatId, binding, active } = target;
|
|
1036
1088
|
const locale = binding?.locale ?? 'ru';
|
|
1037
1089
|
const silent = binding?.sound === false;
|
|
1090
|
+
if (!active) {
|
|
1091
|
+
runtime.logger.info('question-delegated', 'session is not active in Telegram', {
|
|
1092
|
+
chatId,
|
|
1093
|
+
sessionId,
|
|
1094
|
+
reason: 'not-active',
|
|
1095
|
+
questions: request.questions.length,
|
|
1096
|
+
});
|
|
1097
|
+
const answer = next();
|
|
1098
|
+
scheduleWebWaitingNotice(runtime, target, sessionId, 'question', answer);
|
|
1099
|
+
return answer;
|
|
1100
|
+
}
|
|
1101
|
+
runtime.logger.info('question-claimed', 'question claimed for Telegram', {
|
|
1102
|
+
chatId,
|
|
1103
|
+
sessionId,
|
|
1104
|
+
questions: request.questions.length,
|
|
1105
|
+
});
|
|
1038
1106
|
// Serialize whole question batches per chat. A second Session can ask while
|
|
1039
1107
|
// the first batch is between questions; let it wait for the visible batch
|
|
1040
1108
|
// instead of overtaking or cancelling it.
|
|
@@ -1042,7 +1110,7 @@ async function handleQuestion(runtime, request, next) {
|
|
|
1042
1110
|
if (previousBatch !== undefined) {
|
|
1043
1111
|
runtime.logger.info('question-batch-queued', 'waiting for the visible question batch', {
|
|
1044
1112
|
chatId,
|
|
1045
|
-
sessionId
|
|
1113
|
+
sessionId,
|
|
1046
1114
|
});
|
|
1047
1115
|
await previousBatch;
|
|
1048
1116
|
if (aborted())
|
|
@@ -1061,10 +1129,16 @@ async function handleQuestion(runtime, request, next) {
|
|
|
1061
1129
|
continue;
|
|
1062
1130
|
}
|
|
1063
1131
|
try {
|
|
1064
|
-
const item = await askQuestion(runtime, chatId,
|
|
1132
|
+
const item = await askQuestion(runtime, chatId, sessionId, locale, question, index, request.questions.length, silent, request.signal, deadline);
|
|
1065
1133
|
if (item === undefined) {
|
|
1066
|
-
if (answers.length === 0)
|
|
1134
|
+
if (answers.length === 0) {
|
|
1135
|
+
runtime.logger.info('question-delegated', 'could not send question to Telegram', {
|
|
1136
|
+
chatId,
|
|
1137
|
+
sessionId,
|
|
1138
|
+
reason: 'send-failed',
|
|
1139
|
+
});
|
|
1067
1140
|
return next();
|
|
1141
|
+
}
|
|
1068
1142
|
answers.push({ id: question.id, selected: [] });
|
|
1069
1143
|
}
|
|
1070
1144
|
else {
|
|
@@ -1074,7 +1148,7 @@ async function handleQuestion(runtime, request, next) {
|
|
|
1074
1148
|
catch (error) {
|
|
1075
1149
|
runtime.logger.error('question-failed', messageOf(error), {
|
|
1076
1150
|
chatId,
|
|
1077
|
-
sessionId
|
|
1151
|
+
sessionId,
|
|
1078
1152
|
questionId: question.id,
|
|
1079
1153
|
});
|
|
1080
1154
|
answers.push({ id: question.id, selected: [] });
|
|
@@ -1221,8 +1295,8 @@ async function sendPlain(runtime, chatId, text, silent = false) {
|
|
|
1221
1295
|
runtime.logger.error('send-failed', messageOf(error), { chatId });
|
|
1222
1296
|
}
|
|
1223
1297
|
}
|
|
1224
|
-
async function sendMainMenu(runtime, chatId, locale, editMessageId) {
|
|
1225
|
-
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);
|
|
1226
1300
|
const view = buildMainMenu(runtime.workspaces.list(), state, locale);
|
|
1227
1301
|
if (editMessageId !== undefined)
|
|
1228
1302
|
await editRich(runtime, chatId, editMessageId, view);
|
|
@@ -1277,6 +1351,25 @@ function buildCompactView(state, locale) {
|
|
|
1277
1351
|
const keyboard = new InlineKeyboard().text(t(locale, 'compact'), 'compact:yes').text(t(locale, 'back'), 'menu:home');
|
|
1278
1352
|
return { html, text, keyboard };
|
|
1279
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
|
+
}
|
|
1280
1373
|
function sessionTitle(session, locale) {
|
|
1281
1374
|
if (session.blank)
|
|
1282
1375
|
return t(locale, 'newSessionTitle');
|
|
@@ -1536,6 +1629,67 @@ function chatForSession(runtime, sessionId) {
|
|
|
1536
1629
|
return String(tracked);
|
|
1537
1630
|
return runtime.store.sessionChat(sessionId);
|
|
1538
1631
|
}
|
|
1632
|
+
function answerTargetForSession(runtime, sessionId) {
|
|
1633
|
+
const chatIdRaw = chatForSession(runtime, sessionId);
|
|
1634
|
+
if (chatIdRaw === undefined)
|
|
1635
|
+
return undefined;
|
|
1636
|
+
const chatId = Number(chatIdRaw);
|
|
1637
|
+
if (!Number.isSafeInteger(chatId))
|
|
1638
|
+
return undefined;
|
|
1639
|
+
const binding = runtime.store.get(chatIdRaw);
|
|
1640
|
+
return { chatId, binding, active: binding?.activeSessionId === sessionId };
|
|
1641
|
+
}
|
|
1642
|
+
function workspaceTitleFor(runtime, sessionId) {
|
|
1643
|
+
return runtime.workspaces.list().find(workspace => workspace.sessionIds.includes(sessionId))?.title;
|
|
1644
|
+
}
|
|
1645
|
+
/**
|
|
1646
|
+
* Tell the Telegram chat that a question or approval for another Session is
|
|
1647
|
+
* waiting in Web. This never claims the request: the Web answerer still gets it
|
|
1648
|
+
* through `next()`.
|
|
1649
|
+
*/
|
|
1650
|
+
async function notifyWebWaiting(runtime, target, locale, sessionId, kind, toolName) {
|
|
1651
|
+
const workspace = workspaceTitleFor(runtime, sessionId) ?? 'β';
|
|
1652
|
+
const place = `${workspace} / ${t(locale, 'session')} ${sessionId.slice(0, 8)}`;
|
|
1653
|
+
const head = kind === 'question' ? t(locale, 'webWaitingQuestion') : t(locale, 'webWaitingApproval');
|
|
1654
|
+
const subject = kind === 'approval' && toolName !== undefined ? ` (${toolName})` : '';
|
|
1655
|
+
const text = `${head}${subject}: ${place}\n${t(locale, 'webWaitingHint')}`;
|
|
1656
|
+
await sendPlain(runtime, target.chatId, text, target.binding?.sound === false);
|
|
1657
|
+
}
|
|
1658
|
+
/** Sessions without their own Telegram route still report to the admin chat. */
|
|
1659
|
+
function webNoticeTarget(runtime, target) {
|
|
1660
|
+
if (target !== undefined)
|
|
1661
|
+
return target;
|
|
1662
|
+
const admin = runtime.adminUserId;
|
|
1663
|
+
if (admin === undefined)
|
|
1664
|
+
return undefined;
|
|
1665
|
+
return { chatId: admin, binding: runtime.store.get(String(admin)), active: false };
|
|
1666
|
+
}
|
|
1667
|
+
const WEB_WAITING_NOTICE_MS = 15_000;
|
|
1668
|
+
/**
|
|
1669
|
+
* Ping the Telegram chat only when Web has not settled the request quickly.
|
|
1670
|
+
* If the user is already answering in Web, the notice is cancelled, so the
|
|
1671
|
+
* bot does not duplicate every Web card.
|
|
1672
|
+
*/
|
|
1673
|
+
function scheduleWebWaitingNotice(runtime, target, sessionId, kind, answered, toolName, delayMs = WEB_WAITING_NOTICE_MS) {
|
|
1674
|
+
const noticeTarget = webNoticeTarget(runtime, target);
|
|
1675
|
+
if (noticeTarget === undefined)
|
|
1676
|
+
return;
|
|
1677
|
+
const locale = noticeTarget.binding?.locale ?? 'ru';
|
|
1678
|
+
let settled = false;
|
|
1679
|
+
const timer = setTimeout(() => {
|
|
1680
|
+
if (settled)
|
|
1681
|
+
return;
|
|
1682
|
+
runtime.logger.info('web-waiting-notice', 'notifying Telegram about a Web request', {
|
|
1683
|
+
chatId: noticeTarget.chatId,
|
|
1684
|
+
sessionId,
|
|
1685
|
+
kind,
|
|
1686
|
+
...(toolName === undefined ? {} : { toolName }),
|
|
1687
|
+
});
|
|
1688
|
+
void notifyWebWaiting(runtime, noticeTarget, locale, sessionId, kind, toolName);
|
|
1689
|
+
}, delayMs);
|
|
1690
|
+
timer.unref?.();
|
|
1691
|
+
void answered.then(() => { settled = true; clearTimeout(timer); }, () => { settled = true; clearTimeout(timer); });
|
|
1692
|
+
}
|
|
1539
1693
|
async function handleSessionEvent(runtime, session, event) {
|
|
1540
1694
|
if (session.header.origin === 'subagent')
|
|
1541
1695
|
return;
|
|
@@ -1580,11 +1734,6 @@ async function handleSessionEvent(runtime, session, event) {
|
|
|
1580
1734
|
void maybeWarnLowBalance(runtime, chatId, locale, silent);
|
|
1581
1735
|
break;
|
|
1582
1736
|
}
|
|
1583
|
-
case 'compaction/end':
|
|
1584
|
-
// Compaction can also be started from Web; drop the cached percentage
|
|
1585
|
-
// so the next menu reads the updated projection immediately.
|
|
1586
|
-
runtime.contextCache.delete(session.id);
|
|
1587
|
-
break;
|
|
1588
1737
|
default:
|
|
1589
1738
|
break;
|
|
1590
1739
|
}
|
|
@@ -1651,6 +1800,7 @@ async function runBot(ctx, config, workspaces, sessions, credentials, logger, si
|
|
|
1651
1800
|
}
|
|
1652
1801
|
const account = ctx.get('accountController');
|
|
1653
1802
|
const tokenMeter = ctx.get('tokenMeter');
|
|
1803
|
+
const sessionProjections = ctx.get('sessionProjections');
|
|
1654
1804
|
const commands = ctx.get('commands');
|
|
1655
1805
|
const runtime = {
|
|
1656
1806
|
bot,
|
|
@@ -1659,6 +1809,7 @@ async function runBot(ctx, config, workspaces, sessions, credentials, logger, si
|
|
|
1659
1809
|
sessions,
|
|
1660
1810
|
account,
|
|
1661
1811
|
tokenMeter,
|
|
1812
|
+
sessionProjections,
|
|
1662
1813
|
commands,
|
|
1663
1814
|
adminUserId,
|
|
1664
1815
|
allowedUserIds: [...allowedUserIds],
|
|
@@ -1673,7 +1824,6 @@ async function runBot(ctx, config, workspaces, sessions, credentials, logger, si
|
|
|
1673
1824
|
pendingQuestionChats: new Map(),
|
|
1674
1825
|
questionQueues: new Map(),
|
|
1675
1826
|
balanceCache: { at: 0 },
|
|
1676
|
-
contextCache: new Map(),
|
|
1677
1827
|
lowBalanceWarnedAt: new Map(),
|
|
1678
1828
|
rich: config.rich !== false,
|
|
1679
1829
|
lowBalanceUsd: config.lowBalanceUsd ?? 1,
|
|
@@ -1685,8 +1835,11 @@ async function runBot(ctx, config, workspaces, sessions, credentials, logger, si
|
|
|
1685
1835
|
logger.error('event-failed', messageOf(error), { sessionId: session.id, event: event.type });
|
|
1686
1836
|
});
|
|
1687
1837
|
}));
|
|
1688
|
-
|
|
1689
|
-
|
|
1838
|
+
// Answerers run as a waterfall, and the Web bridge is registered earlier.
|
|
1839
|
+
// Prepending lets the bot decide first: it claims questions for the active
|
|
1840
|
+
// Telegram Session and delegates everything else to Web.
|
|
1841
|
+
disposers.push(ctx.on('approval/request', (request, next) => handleApproval(runtime, request, next), { prepend: true }));
|
|
1842
|
+
disposers.push(ctx.on('user-questions/request', (request, next) => handleQuestion(runtime, request, next), { prepend: true }));
|
|
1690
1843
|
// Log Telegram API failures once per method per 30 seconds; polling can
|
|
1691
1844
|
// otherwise flood the file during a network outage.
|
|
1692
1845
|
const lastApiError = new Map();
|
|
@@ -1746,14 +1899,14 @@ async function runBot(ctx, config, workspaces, sessions, credentials, logger, si
|
|
|
1746
1899
|
if (binding !== undefined) {
|
|
1747
1900
|
await store.set({ ...binding, locale, updatedAt: Date.now() });
|
|
1748
1901
|
}
|
|
1749
|
-
await sendMainMenu(runtime, chatId, locale);
|
|
1902
|
+
await sendMainMenu(runtime, chatId, locale, undefined, true);
|
|
1750
1903
|
});
|
|
1751
1904
|
bot.command('menu', async (grammyCtx) => {
|
|
1752
1905
|
const chatId = grammyCtx.chat?.id;
|
|
1753
1906
|
if (chatId === undefined)
|
|
1754
1907
|
return;
|
|
1755
1908
|
const locale = localeOf(grammyCtx.from?.language_code);
|
|
1756
|
-
await sendMainMenu(runtime, chatId, locale);
|
|
1909
|
+
await sendMainMenu(runtime, chatId, locale, undefined, true);
|
|
1757
1910
|
});
|
|
1758
1911
|
bot.command('new', async (grammyCtx) => {
|
|
1759
1912
|
const chatId = grammyCtx.chat?.id;
|
|
@@ -1805,8 +1958,13 @@ async function runBot(ctx, config, workspaces, sessions, credentials, logger, si
|
|
|
1805
1958
|
await grammyCtx.reply(t(locale, 'noActiveSession'));
|
|
1806
1959
|
return;
|
|
1807
1960
|
}
|
|
1808
|
-
|
|
1809
|
-
await
|
|
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);
|
|
1810
1968
|
});
|
|
1811
1969
|
bot.callbackQuery(/^ws:(.+)$/, async (grammyCtx) => {
|
|
1812
1970
|
const workspaceId = grammyCtx.match[1];
|
|
@@ -1925,7 +2083,7 @@ async function runBot(ctx, config, workspaces, sessions, credentials, logger, si
|
|
|
1925
2083
|
return;
|
|
1926
2084
|
const locale = localeOf(grammyCtx.from?.language_code);
|
|
1927
2085
|
await grammyCtx.answerCallbackQuery().catch(() => undefined);
|
|
1928
|
-
await sendMainMenu(runtime, chatId, locale, grammyCtx.callbackQuery?.message?.message_id);
|
|
2086
|
+
await sendMainMenu(runtime, chatId, locale, grammyCtx.callbackQuery?.message?.message_id, true);
|
|
1929
2087
|
});
|
|
1930
2088
|
bot.callbackQuery('menu:sound', async (grammyCtx) => {
|
|
1931
2089
|
const chatId = grammyCtx.chat?.id;
|
|
@@ -1993,14 +2151,12 @@ async function runBot(ctx, config, workspaces, sessions, credentials, logger, si
|
|
|
1993
2151
|
await grammyCtx.answerCallbackQuery({ text: t(locale, 'noActiveSession') }).catch(() => undefined);
|
|
1994
2152
|
return;
|
|
1995
2153
|
}
|
|
1996
|
-
await grammyCtx.answerCallbackQuery(
|
|
1997
|
-
const text = await runCompact(runtime, chatId, locale, binding.activeSessionId);
|
|
1998
|
-
const view = {
|
|
1999
|
-
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>`,
|
|
2000
|
-
text,
|
|
2001
|
-
keyboard: new InlineKeyboard().text(t(locale, 'home'), 'menu:home'),
|
|
2002
|
-
};
|
|
2154
|
+
await grammyCtx.answerCallbackQuery().catch(() => undefined);
|
|
2003
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);
|
|
2004
2160
|
if (messageId !== undefined)
|
|
2005
2161
|
await editRich(runtime, chatId, messageId, view);
|
|
2006
2162
|
else
|