dsh-tg-bridge 1.32.0 → 1.33.0
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 +657 -635
- package/callbacks.mjs +2 -2
- package/control/cmd-model.mjs +95 -0
- package/control/cmd-views.mjs +19 -32
- package/control/model-card.mjs +59 -25
- package/control/models.mjs +21 -5
- package/control/topic-route.mjs +74 -0
- package/i18n/en/core.mjs +1 -1
- package/i18n/en/ctrl.mjs +1 -0
- package/i18n/en/model.mjs +7 -0
- package/i18n/ru/core.mjs +1 -1
- package/i18n/ru/ctrl.mjs +1 -0
- package/i18n/ru/model.mjs +7 -0
- package/i18n/zh/core.mjs +1 -1
- package/i18n/zh/ctrl.mjs +1 -0
- package/i18n/zh/model.mjs +7 -0
- package/menu-card.mjs +2 -2
- package/package.json +4 -2
- package/profiles.mjs +66 -16
- package/run-command.mjs +2 -2
- package/turn.mjs +21 -0
package/README.md
CHANGED
|
@@ -1,635 +1,657 @@
|
|
|
1
|
-
# dsh-tg-bridge
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
- **
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
- **
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
|
149
|
-
|
|
150
|
-
|
|
|
151
|
-
|
|
|
152
|
-
| `
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
`
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
/
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
the
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
dsh-tg
|
|
260
|
-
|
|
261
|
-
dsh-tg
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
the
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
|
292
|
-
|
|
293
|
-
|
|
|
294
|
-
|
|
|
295
|
-
|
|
|
296
|
-
|
|
|
297
|
-
|
|
|
298
|
-
|
|
|
299
|
-
|
|
|
300
|
-
|
|
|
301
|
-
|
|
302
|
-
##
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
`
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
a
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
message
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
/
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
the
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
1
|
+
# dsh-tg-bridge
|
|
2
|
+
|
|
3
|
+
Drive [DeepSeek Harness](https://deepseek.com) from Telegram. It runs on the
|
|
4
|
+
machine that already has the harness, and it answers in the chat where you asked.
|
|
5
|
+
|
|
6
|
+
A forum topic is a project: its own session, working directory, model,
|
|
7
|
+
permissions and language. Two topics share the install and nothing else.
|
|
8
|
+
|
|
9
|
+
Never made a bot? [QUICKSTART.md](QUICKSTART.md) goes from "no account" to a bot
|
|
10
|
+
that answers, one step at a time.
|
|
11
|
+
|
|
12
|
+
## What it does
|
|
13
|
+
|
|
14
|
+
- **A model per topic.** `/model` lists the routes the profile declares — provider
|
|
15
|
+
and model together — and a tap switches this topic only. `/model <route> all`
|
|
16
|
+
moves the default the other topics follow; `/model auto` hands the topic back.
|
|
17
|
+
A chat for thinking out loud and a chat for engineering no longer share one model.
|
|
18
|
+
- **A topic is a project.** `/cd my-app`, and every turn runs from that directory —
|
|
19
|
+
on a permission-enabled profile the sandbox is narrowed to it too, so the agent
|
|
20
|
+
cannot write outside the project.
|
|
21
|
+
- **One edited message per turn.** Steps, a timer and the cache hit rate, plus the
|
|
22
|
+
reasoning in a collapsed block you can tap open. A long turn adds a second
|
|
23
|
+
collapsed block with every tool call. `/stop` is a button on that message.
|
|
24
|
+
- **`/diff` — review the turn, one hunk at a time.** The working tree is split into
|
|
25
|
+
files and hunks; every hunk gets two buttons: explain it, or revert just that
|
|
26
|
+
hunk. A button carries a hash of the hunk it was drawn from, so a press that
|
|
27
|
+
arrives after the file moved on is refused instead of touching a line nobody was
|
|
28
|
+
looking at. `/diff stat` is the file list alone.
|
|
29
|
+
- **An endpoint from the chat.** `/endpoint add <id> <https://url/v1> <KEY_ENV>
|
|
30
|
+
[model,model]` writes the provider without an AI turn, and the key itself is
|
|
31
|
+
never typed — only the name of the variable that holds it. The new models appear
|
|
32
|
+
on `/model` as routes.
|
|
33
|
+
- **Input: text, voice, photos.** Voice is local faster-whisper and the transcript
|
|
34
|
+
is shown before the answer. A photo is read by the turn's own model through
|
|
35
|
+
`read_image`, text and UI included; no second model is needed.
|
|
36
|
+
- **Goal and checklist per topic.** `/goal`, `/tasks`; both survive restarts and
|
|
37
|
+
are prepended to every turn.
|
|
38
|
+
- **Two scopes for every setting.** `/reasoning <mode> all` moves the default,
|
|
39
|
+
without `all` it moves this topic; language and pinning follow the same rule,
|
|
40
|
+
and `/crew use reviewer` gives one topic its own effort, permissions and agent
|
|
41
|
+
preset (four built-in sets, read-only, copyable).
|
|
42
|
+
- **It says what it cost.** A turn reports tokens and the cache hit rate; `/cost`
|
|
43
|
+
says what the session has spent and `/prices` shows the rates it used.
|
|
44
|
+
- **Out of quota is not a dead end.** When the quota runs out it switches to a
|
|
45
|
+
free model right away, and the answer says which route answered.
|
|
46
|
+
- **No lost messages.** A journal with acknowledgement and replay.
|
|
47
|
+
- **Knows how busy the computer is.** `/load` shows free space on the topic's disk,
|
|
48
|
+
free RAM and average CPU, plus how many turns are running and waiting. `/load on`
|
|
49
|
+
makes a prompt wait instead of starting while the machine is over a limit you set
|
|
50
|
+
— kept, never refused, and one press sends it anyway.
|
|
51
|
+
- **Languages.** Menus and service messages in `en`, `ru`, `zh`; `/lang` pins the
|
|
52
|
+
topic language, and without it a new topic takes the language of the message
|
|
53
|
+
itself (Cyrillic → `ru`, Han characters → `zh`), then the Telegram
|
|
54
|
+
`language_code`, then `en`.
|
|
55
|
+
- **"Stop" / "Retry" buttons and tool confirmations** sit in the message, so there
|
|
56
|
+
is no command to type to stop a run.
|
|
57
|
+
- **`/report`.** One command turns "it broke" into a redacted document: version,
|
|
58
|
+
profile, preset, model, directory, the last failure and the log tail, with keys
|
|
59
|
+
and home paths removed before the file is written.
|
|
60
|
+
- **`dsh-tg check`.** Diagnostics in one command, changing nothing on the system.
|
|
61
|
+
|
|
62
|
+
## Requirements
|
|
63
|
+
|
|
64
|
+
- Node.js ≥ 24 (the version DeepSeek Harness ships; sessions are zstd-compressed)
|
|
65
|
+
- DeepSeek Harness `0.2.1-rc.2` or newer in the `0.2.x` line (`>=0.2.1-rc.2 <0.3.0`)
|
|
66
|
+
- DeepSeek Harness installed (`~/.dsh/profiles/headless`)
|
|
67
|
+
- A Telegram bot token from [@BotFather](https://t.me/BotFather)
|
|
68
|
+
|
|
69
|
+
The supported harness range is declared in `engines.dsh`; that field decides
|
|
70
|
+
compatibility on its own (DSH ignores `peerDependencies` when it is present).
|
|
71
|
+
The range includes an explicit prerelease branch, because a plain `<0.3.0`
|
|
72
|
+
silently excludes `0.2.2-*` builds. A future `0.3.0` needs an explicit bump:
|
|
73
|
+
the bridge relies on the `0.2.x` CLI flags and profile layout.
|
|
74
|
+
|
|
75
|
+
## Ecosystem
|
|
76
|
+
|
|
77
|
+
The Chinese DSH community maintains the largest plugin catalogs and the
|
|
78
|
+
in-app markets that read them; this bridge follows their packaging rules so it
|
|
79
|
+
can be listed next to them:
|
|
80
|
+
|
|
81
|
+
- [awesome-dsh-plugin](https://awesome-dsh-plugin.com) — bilingual (English /
|
|
82
|
+
中文) plugin list and the `dsh-plugin-catalog` npm package
|
|
83
|
+
- [dsh-market](https://github.com/dsh-market/dsh-market) — the Chinese-built
|
|
84
|
+
in-app market with one-click install and themes
|
|
85
|
+
- [dsh-find-plugin](https://github.com/awesome-dsh-plugin/dsh-find-plugin) —
|
|
86
|
+
finds a plugin from chat instead of browsing a catalog
|
|
87
|
+
|
|
88
|
+
## Languages
|
|
89
|
+
|
|
90
|
+
- Menus (`/` in chat): three sets, `ru` by default, plus `en` and `zh`; a client whose locale matches neither gets the Russian set.
|
|
91
|
+
- Topic language: `/lang en|ru|zh`; stored in `state.json` and survives a restart.
|
|
92
|
+
- A new user gets the language from the Telegram `language_code`; anything that is not `ru`/`zh` → `en`.
|
|
93
|
+
- Translated so far: menus, the start message, turn status, errors, `/cd`, `/new`, `/stop`, `/lang`,
|
|
94
|
+
the reply to an unknown command. Long reports (`/status`, `/sessions`, `/model` and similar)
|
|
95
|
+
are still in Russian, that is the next pass.
|
|
96
|
+
|
|
97
|
+
## Installation
|
|
98
|
+
|
|
99
|
+
One command: your bot token and your numeric id. Nothing to edit by hand.
|
|
100
|
+
|
|
101
|
+
**Windows, macOS or Linux — Node.js 24 or newer.** `init` and the bridge run
|
|
102
|
+
anywhere; `setup` (stop, autostart, restart) is **Windows-only** today, so on
|
|
103
|
+
macOS and Linux use `sh install.sh`, which registers `launchd` or `systemd --user`.
|
|
104
|
+
`node setup.mjs --check` reports state on every platform.
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
npx dsh-tg-bridge@latest init --token 123456789:AA... --user 123456789
|
|
108
|
+
npx dsh-tg-bridge@latest setup
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
`init` writes the token, your id and the working directory; `setup` registers
|
|
112
|
+
autostart and starts the bridge.
|
|
113
|
+
|
|
114
|
+
### What it needs from DSH
|
|
115
|
+
|
|
116
|
+
The bridge is a client of the DSH CLI, and the surface it uses is small enough to
|
|
117
|
+
write down: `--profile`, `--json`, `--session-id`, `--expose-internals <cli.js>`
|
|
118
|
+
when the app binary runs the CLI, and the `{"type": ...}` JSON events on stdout.
|
|
119
|
+
Profiles are read as files (`cordis.patch.yml`, `package.json`) under
|
|
120
|
+
`~/.dsh/profiles`. `package.json` spells the supported range out in
|
|
121
|
+
`engines.dsh`, and it is capped below `0.3.0` on purpose: a minor bump may rename
|
|
122
|
+
an event, and a bridge that guesses is a bridge that answers with silence.
|
|
123
|
+
|
|
124
|
+
Two escape hatches, for a moved app or a DSH that ships differently:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
DSH_BIN=/usr/local/bin/dsh # the CLI itself, no entrypoint argument
|
|
128
|
+
DSH_CLI_JS=/opt/dsh/lib/cli.js # just the CLI entrypoint, run by DSH_BIN
|
|
129
|
+
DSH_APP_DIR=/opt/DeepSeek-Harness # where the desktop app is installed
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
`/doctor` prints the command a turn would actually run, so a machine where these
|
|
133
|
+
matter says so instead of failing with an empty answer.
|
|
134
|
+
|
|
135
|
+
**As a DSH plugin** (the package carries a `dsh.bundle`; the catalog entry is
|
|
136
|
+
pending review):
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
dsh plugin --profile desktop add dsh-tg-bridge
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
The plugin starts one bridge when DSH boots and stops it on shutdown; if a
|
|
143
|
+
bridge is already running (for example from the scheduled task), it leaves it
|
|
144
|
+
alone. Run `npx dsh-tg-bridge@latest init ...` first so a config exists.
|
|
145
|
+
|
|
146
|
+
What `init` does:
|
|
147
|
+
|
|
148
|
+
| What | Where |
|
|
149
|
+
|---|---|
|
|
150
|
+
| bot token | `~/.dsh/.credentials.yaml` → `refs.DSH_TELEGRAM_BOT_TOKEN`; other keys are left alone |
|
|
151
|
+
| your id and working directory | `~/.dsh/tg-bridge/config.json`; an existing file is not overwritten |
|
|
152
|
+
| `headless` profile | checked, with a hint on how to create it if missing |
|
|
153
|
+
|
|
154
|
+
`init` flags: `--cwd <path>` (default `~/Projects`), `--voice` (enable
|
|
155
|
+
voice transcription), `--dry-run` (show what would be written, change nothing).
|
|
156
|
+
|
|
157
|
+
Optional provider settings live in `config.json`:
|
|
158
|
+
|
|
159
|
+
| Key | Meaning |
|
|
160
|
+
|---|---|
|
|
161
|
+
| `providerKeys` | extra env var names to pass to a turn, read from `~/.dsh/.credentials.yaml`; default `[]` |
|
|
162
|
+
| `pricesUrl` | retired: `/prices` always reads OpenRouter's public list and labels the number as a reference for the model |
|
|
163
|
+
| `vision.patch` | opt-in overlay profile for photo turns; default `""` — the turn's own model reads images |
|
|
164
|
+
| `vision.enabled` | set `true` to run photo turns on `vision.patch` instead of the topic profile |
|
|
165
|
+
| `fallbackModels` | ordered failover chain; default `[]` — see below |
|
|
166
|
+
| `fallbackEnabled` | `false` switches the whole chain off without editing the list; `/fallback off` sets it |
|
|
167
|
+
| `maxParallel` | how many topics run at once, 1–8, default `3`; also `/jobs 5` in the chat |
|
|
168
|
+
| `replayWindowMs` | how old a journaled update may be and still be replayed after a restart; default `600000` (10 min) |
|
|
169
|
+
|
|
170
|
+
Each `fallbackModels` entry is one attempt, tried in order after the turn's own
|
|
171
|
+
model refuses:
|
|
172
|
+
|
|
173
|
+
```json
|
|
174
|
+
{
|
|
175
|
+
"provider": "router-a",
|
|
176
|
+
"model": "some-model",
|
|
177
|
+
"patch": "~/.dsh/tg-bridge/model-a.yml",
|
|
178
|
+
"free": false,
|
|
179
|
+
"off": false
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
`patch` is an overlay file with a single `agent-default-model` row
|
|
184
|
+
(`provider` + `model`); it is materialised once as its own profile, so the turn
|
|
185
|
+
keeps every other setting and only the model changes. `provider` is the id the
|
|
186
|
+
provider is written under in the profile — it decides whose key and host the
|
|
187
|
+
pre-flight probe asks, so the same model id on two routers stays two attempts.
|
|
188
|
+
`free` only adds `(free)` to the switch notice. `off` keeps an entry in the list
|
|
189
|
+
but out of the walk; an entry whose `patch` file is missing is skipped the same
|
|
190
|
+
way, and the chat says so instead of counting it.
|
|
191
|
+
|
|
192
|
+
The chain may mix companies: a 503 from one provider says nothing about another,
|
|
193
|
+
so a busy channel skips its own models and the next company is still tried. Put
|
|
194
|
+
models from different companies next to each other — two arms of one router are
|
|
195
|
+
one outage, not two chances — and keep the `:free` models at the end, as the
|
|
196
|
+
last resort.
|
|
197
|
+
|
|
198
|
+
**What starts a switch.** Anything the provider itself says no to: a 400/413/422
|
|
199
|
+
refusal (its own validator rejecting the request), 401/403 (key refused), 402 or
|
|
200
|
+
a quota/balance message (empty account), 404 (that model id is not carried),
|
|
201
|
+
429 (rate limit), 5xx and `get_channel_failed` / "all providers busy" (the pool
|
|
202
|
+
is down), a dropped connection or DNS/TLS failure, and an empty answer. A refusal
|
|
203
|
+
gets one other route, not the whole chain: it is replayed in full, and if the
|
|
204
|
+
second vendor refuses identically the request — not the route — is what is wrong,
|
|
205
|
+
so the reply says to start a fresh session with `/new`.
|
|
206
|
+
|
|
207
|
+
**What does not start a switch.** The turn time cap, `/stop`, a session or
|
|
208
|
+
directory error, a missing `dsh` binary: no other vendor changes those, and a
|
|
209
|
+
replay would cost a full turn to learn the same thing. They are listed in the
|
|
210
|
+
card so the distinction is visible instead of guessed.
|
|
211
|
+
|
|
212
|
+
### `/fallback` — the chain from the chat
|
|
213
|
+
|
|
214
|
+
```
|
|
215
|
+
/fallback the card: chain state, numbered routes, what starts a switch
|
|
216
|
+
/fallback on | off the whole chain (per route: /fallback off 3)
|
|
217
|
+
/fallback use 3 | skip 3 one route back in or out
|
|
218
|
+
/fallback up 3 | down 3 move a route in the order
|
|
219
|
+
/fallback test [3] ask each route (or one) with a 1-token request
|
|
220
|
+
/fallback add <provider>/<model> write an overlay and append the route
|
|
221
|
+
/fallback first <provider>/<model> put it at the head: tried before every other route
|
|
222
|
+
/fallback remove 3 drop a route from the list (its overlay file stays)
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Every line has a button on the card: `● n` switches a route, `↑ n` / `↓ n` move
|
|
226
|
+
it, and the card redraws in place after each press. `test` proves the key and the
|
|
227
|
+
channel are alive — not that the provider accepts this conversation, so a route
|
|
228
|
+
can answer `ping` and still refuse a long prompt with a 400. The card says that
|
|
229
|
+
in as many words.
|
|
230
|
+
|
|
231
|
+
`test` also times each route: how long it takes to produce the first token, and
|
|
232
|
+
which live route is fastest right now. Two routes that both answer are not
|
|
233
|
+
equally good — 400 ms and 9 s feel like different products — and the head of the
|
|
234
|
+
chain is the one a person picks on that number. A route that did not answer
|
|
235
|
+
prints no time, so `no balance · 120 ms` can never read as "works, just slow".
|
|
236
|
+
|
|
237
|
+
`first` exists because `add` appends: when the route you want should answer
|
|
238
|
+
*before* the primary, appending it means moving it up eight times and guessing
|
|
239
|
+
where the head is. `/fallback first router-a/deepseek-v4.1-flash` writes the
|
|
240
|
+
same overlay and puts it at position 1 — or moves it there if it is already in
|
|
241
|
+
the chain.
|
|
242
|
+
|
|
243
|
+
Get your id from [@userinfobot](https://t.me/userinfobot), the token from
|
|
244
|
+
[@BotFather](https://t.me/BotFather).
|
|
245
|
+
|
|
246
|
+
### Bot settings in Telegram
|
|
247
|
+
|
|
248
|
+
Three things without which the bot will stay silent in a group or work only halfway:
|
|
249
|
+
|
|
250
|
+
1. **Privacy mode → Disable** (`/setprivacy` in BotFather). Otherwise the bot sees
|
|
251
|
+
only commands, not regular text in a topic.
|
|
252
|
+
2. **Topics enabled** in the group settings (Edit → Topics). Without them all work
|
|
253
|
+
goes to a single chat and per-topic sessions are not created.
|
|
254
|
+
3. **Pin Messages** permission for the bot. Only needed to pin the first
|
|
255
|
+
message of a topic; without it the bridge keeps working but will not pin.
|
|
256
|
+
|
|
257
|
+
You do not need to set up the command menu by hand: `init` and `setup` install it
|
|
258
|
+
in Russian, English and Chinese at once. The menu is not refreshed by a plain
|
|
259
|
+
bridge restart, so after adding commands run `dsh-tg menu`. The full settings
|
|
260
|
+
table, permissions, checks and common errors are in
|
|
261
|
+
[docs/TELEGRAM-SETUP.md](https://github.com/aleksvega/dsh-tg-bridge/blob/master/docs/TELEGRAM-SETUP.md).
|
|
262
|
+
|
|
263
|
+
**Autostart** has two routes. `sh install.sh` writes `launchd` on macOS and
|
|
264
|
+
`systemd --user` on Linux; `dsh-tg setup` registers the `DSH-TG-Bridge` task on
|
|
265
|
+
Windows, which runs the guarded supervisor (the same launcher on logon and every
|
|
266
|
+
five minutes) so a crashed bridge comes back without a second poller. On macOS
|
|
267
|
+
and Linux `setup` declines and names `install.sh`, because it stops the old
|
|
268
|
+
bridge with `taskkill` and registers autostart through `schtasks`.
|
|
269
|
+
|
|
270
|
+
**Manual install** (if you want full control):
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
npm install -g dsh-tg-bridge
|
|
274
|
+
dsh-tg init --token 123456789:AA... --user 123456789
|
|
275
|
+
dsh-tg check # report only, changes nothing
|
|
276
|
+
dsh-tg setup # stop the old bridge and start the new one
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
If the bridge is already installed, `setup` restarts it on the new code and reinstalls
|
|
280
|
+
the command menu.
|
|
281
|
+
|
|
282
|
+
## Troubleshooting
|
|
283
|
+
|
|
284
|
+
Starting from nothing, or helping someone who is: [QUICKSTART.md](QUICKSTART.md)
|
|
285
|
+
has the same answers with the terminal output they will actually see.
|
|
286
|
+
|
|
287
|
+
Error replies end with a code, which tells you what to fix:
|
|
288
|
+
|
|
289
|
+
| Code | Meaning |
|
|
290
|
+
|---|---|
|
|
291
|
+
| `INSUFFICIENT_QUOTA` | provider balance is empty: top up or stay on free models (`/prices`, `/model`) |
|
|
292
|
+
| `TG_CONFLICT` | a second process is polling the same bot: `/doctor`, then `/restart` |
|
|
293
|
+
| `MISSING_CREDENTIAL` | no provider key in the profile: add it in the DSH app |
|
|
294
|
+
| `NO_DSH_CLI` | DeepSeek Harness CLI not found: check the app installation |
|
|
295
|
+
| `NETWORK` | no network to the provider: retry, check VPN/DNS |
|
|
296
|
+
| `SANDBOX_DENY` | DSH denied access to a file or directory: check the project path and permissions |
|
|
297
|
+
| `UNKNOWN_MODEL` | the model from the config is unavailable: `/model` lists the working ones |
|
|
298
|
+
| `EMPTY_RESPONSE` | the model returned nothing: retry or switch model (`/model`) |
|
|
299
|
+
| `TURN_TIME_CAP` | the turn hit its own time ceiling: the work is saved, press Continue |
|
|
300
|
+
| `TURN_FAILED` | cause not recognized: `/doctor` and `/logs errors` |
|
|
301
|
+
|
|
302
|
+
## Checks
|
|
303
|
+
|
|
304
|
+
Send the bot:
|
|
305
|
+
|
|
306
|
+
| Command | Expected |
|
|
307
|
+
|---|---|
|
|
308
|
+
| `/doctor` | report: pid, Telegram, disk, directory, session |
|
|
309
|
+
| `/update` | which bridge runs, what npm has, and whether a newer release exists (`/update confirm` installs it) |
|
|
310
|
+
| `/thoughts [file\|all\|off]` | the last turn's reasoning as a message; `file`/`all` send the full log as a Markdown document, `off` hides the block |
|
|
311
|
+
| `/help` | commands grouped by category |
|
|
312
|
+
| `/cd my-app` | topic bound to the project, and the sandbox narrowed to it |
|
|
313
|
+
| `/diff [stat]` | what the turn changed, one hunk at a time: every hunk has "explain" and "revert this hunk"; a stale button is refused |
|
|
314
|
+
| `/report` | a redacted bundle (version, profile, preset, model, cwd, last failure, log tail) sent to the owner as a document; in a group, the path only |
|
|
315
|
+
| `/prices` | what the current model costs, and whose price that is: your provider's, the same model on another gateway, or "no public price" when nobody publishes one |
|
|
316
|
+
|
|
317
|
+
## Commands
|
|
318
|
+
|
|
319
|
+
```
|
|
320
|
+
Work: /cd · /new · /stop · /send · /seed · /diff
|
|
321
|
+
Goals: /goal (plan + checklist) · /goal reopen · /tasks (checklist only) · /tasks done|rm|edit <n>
|
|
322
|
+
Sessions: /status · /sessions · /sessions <id> · /rewind [n|undo|fork [n]|branches]
|
|
323
|
+
Agents: /agents · /agents <id> · /agents set model|depth|filter
|
|
324
|
+
Models: /model · /model <route> · /model <route> all · /model auto · /endpoint · /prices
|
|
325
|
+
Tuning: /effort · /permissions · /preset · /plan · /jobs · /remind
|
|
326
|
+
Profiles: /profile · /profile <name> · /profile new <name> from <template>
|
|
327
|
+
Sets: /crew · /crew use|off|new|copy|rm · /crew model <v>
|
|
328
|
+
Extensions: /skills · /plugins · /plugins search <word> · /plugins disable|enable <id> · /soul
|
|
329
|
+
Updates: /update · /update confirm · /update on|off|check|auto · /subscribe on|off
|
|
330
|
+
Diagnostics: /doctor · /logs [errors|N|text] · /report
|
|
331
|
+
Service: /app · /restart · /help
|
|
332
|
+
Machine: /load · /load on|off · /load limit cpu|ram|disk <n>
|
|
333
|
+
Settings: /settings — the same switches as buttons, grouped in four tabs
|
|
334
|
+
Display: /lang · /reasoning off|card|chat · /pin on|off · /thoughts
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
### Settings as a card
|
|
338
|
+
|
|
339
|
+
`/settings` draws the same switches that the commands set, in one message with
|
|
340
|
+
four tabs: what the bot says, who answers and how hard it works, new releases,
|
|
341
|
+
and the health checks. Each row shows what the setting is now and what a tap
|
|
342
|
+
would change it to. A tap runs the command a person would have typed
|
|
343
|
+
(`/reasoning chat`, `/update on`), so the card cannot disagree with the command:
|
|
344
|
+
it is a view of them.
|
|
345
|
+
|
|
346
|
+
The card stays after a tap. It is edited in place — same message, same buttons,
|
|
347
|
+
the value in force marked with `●` and one `✓ row: value` line saying what just
|
|
348
|
+
changed — so a second setting is one more tap instead of a second `/settings`.
|
|
349
|
+
`✓ Done` removes the card when you are finished with it; nothing else deletes it.
|
|
350
|
+
|
|
351
|
+
`📌 Pin the progress card` (`/pin on`) keeps the running card pinned, so the
|
|
352
|
+
clock, the speed and the step list are one tap away instead of a scroll. Telegram
|
|
353
|
+
gives a chat one pinned message, so each turn's card replaces the last one. Off by
|
|
354
|
+
default: a bot that pins without being asked takes that slot in someone else's
|
|
355
|
+
chat, and a group needs the right to pin at all.
|
|
356
|
+
|
|
357
|
+
Nothing on the card is only available on the card. `/settings` is for people who
|
|
358
|
+
would rather press a labelled button than remember which of `/effort`,
|
|
359
|
+
`/preset` and `/crew` changes what.
|
|
360
|
+
|
|
361
|
+
Every command answers `/help` in the chat, in the language you write in: a
|
|
362
|
+
message written in Cyrillic or Han characters switches the topic to Russian or
|
|
363
|
+
Chinese even when the phone's menu is set to another language, and `/lang`
|
|
364
|
+
pins a choice above that. The Telegram menu shows the same list, minus
|
|
365
|
+
`/subscribe`: it is one line, and a person who turns it off should not have to
|
|
366
|
+
find it in a menu again.
|
|
367
|
+
|
|
368
|
+
## Updates
|
|
369
|
+
|
|
370
|
+
The npm tag `latest` is a label, not an updater: installing a package pins the
|
|
371
|
+
version on disk, and nothing moves until something moves it. Two switches, both
|
|
372
|
+
about this install (not about a topic, because it is the install that updates):
|
|
373
|
+
|
|
374
|
+
| Command | What it does |
|
|
375
|
+
|---|---|
|
|
376
|
+
| `/update` | one line: what runs here, what is published, which switches are set |
|
|
377
|
+
| `/update on` | tell me about new releases: one message per version, checked once a day |
|
|
378
|
+
| `/update off` | stop telling me; nothing installs, nothing moves |
|
|
379
|
+
| `/update auto` | besides telling me, install the release by itself (checked hourly) |
|
|
380
|
+
| `/update confirm` | install the new release now, by hand |
|
|
381
|
+
|
|
382
|
+
Nothing above installs except `confirm` and `auto`, and even those only change the
|
|
383
|
+
files: the running process keeps its old modules until `/restart confirm`, so a
|
|
384
|
+
bad release never lands mid-chat. `confirm` and `auto` copy the replaced files to
|
|
385
|
+
`update-backup-<date>` and print the path; copying that folder back is the way to
|
|
386
|
+
roll back, with no state to undo.
|
|
387
|
+
|
|
388
|
+
`/subscribe on|off` says the same thing as `/update on|off`, for people who do not
|
|
389
|
+
want to read `/update` first. It is not in the Telegram menu on purpose.
|
|
390
|
+
|
|
391
|
+
There are no notices about failures. The bridge cannot decide what counts as one
|
|
392
|
+
for you, and "something failed" that nobody can act on is noise; errors stay in
|
|
393
|
+
the chat where they happened, under `/doctor` and `/logs errors`.
|
|
394
|
+
|
|
395
|
+
## How it works
|
|
396
|
+
|
|
397
|
+
```
|
|
398
|
+
Telegram → bridge.mjs → dsh --profile headless --json → reply
|
|
399
|
+
│
|
|
400
|
+
├─ pending/ journal + ack (messages are not lost)
|
|
401
|
+
├─ per-topic queue (turns in topics run in parallel)
|
|
402
|
+
├─ progress + buttons (you can see the work is going)
|
|
403
|
+
└─ fail-fast on quota (free models as a fallback)
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
The bridge is a single process with long polling. Each turn spawns a separate
|
|
407
|
+
CLI process that exits after the answer, so "no DSH process" between
|
|
408
|
+
turns is normal, not a failure.
|
|
409
|
+
|
|
410
|
+
### Steering during a turn
|
|
411
|
+
|
|
412
|
+
If you write in a topic while a turn is still running, the message does not queue
|
|
413
|
+
behind it: the bridge drops the task into `~/.dsh/tg-bridge/steer/`, the `dsh-steer-inbox`
|
|
414
|
+
plugin hands it to the live agent on its next step, and the agent immediately replies with a short
|
|
415
|
+
line in the chat: what it is doing now and where it put the addition. If the agent stays silent
|
|
416
|
+
for 90 seconds, the bridge writes one neutral line itself so there is no silence.
|
|
417
|
+
|
|
418
|
+
Attachments work the same way. A voice note is transcribed first and its transcript is echoed in
|
|
419
|
+
the chat, then the text is steered into the running turn; a photo or a file is downloaded to a
|
|
420
|
+
local path and that path is steered, exactly as an idle turn would hand it over.
|
|
421
|
+
|
|
422
|
+
What each kind of attachment becomes inside a running turn:
|
|
423
|
+
|
|
424
|
+
| Sent | Inside the turn | Needs |
|
|
425
|
+
|---|---|---|
|
|
426
|
+
| voice note, audio file, audio sent as a document | transcript, echoed as `🎤 …` before the steer | `faster-whisper` on `PATH`, enabled with `init --voice`; **off by default** |
|
|
427
|
+
| small text file (`.md`, `.json`, `.csv`, `.py`, `.log`, … up to 60 KB) | the content itself between `<file>` markers — no tool call needed | nothing |
|
|
428
|
+
| PDF, archive, binary, anything bigger | its local path under `~/.dsh/tg-bridge/inbox/` | nothing; the agent opens it with its own tools |
|
|
429
|
+
| video, video note, animation | its path; the agent can pull frames or sound out with ffmpeg | ffmpeg, only if frames or audio are needed |
|
|
430
|
+
| photo | its path plus one honest line; the turn reads it with `read_image`, and says so in one line if it cannot | a model that accepts images |
|
|
431
|
+
|
|
432
|
+
Voice is the one row with a hidden prerequisite. Without `faster-whisper`
|
|
433
|
+
installed, a voice note still arrives — as a path the agent cannot read — so the
|
|
434
|
+
bridge says transcription is off instead of pretending it heard something. Run
|
|
435
|
+
`dsh-tg init --voice` after installing the transcriber; nothing else changes.
|
|
436
|
+
|
|
437
|
+
A caption does not turn the attachment into a text-only message: it is folded into the same
|
|
438
|
+
hand-over, so "why did this fail" plus a `.log` file arrives as one steer.
|
|
439
|
+
|
|
440
|
+
An album is one request, not ten. Telegram delivers it as one update per file, all sharing a
|
|
441
|
+
`media_group_id`; the bridge collects the group (1.2 s of quiet after the last item, at most
|
|
442
|
+
4 s) and hands it over once — one steer into a running turn, one turn when the topic is idle.
|
|
443
|
+
|
|
444
|
+
### When a turn hits the time ceiling
|
|
445
|
+
|
|
446
|
+
`turnTimeoutMs` (default 30 min, this install 75) is a ceiling, not a target: if a turn reaches
|
|
447
|
+
it, the bridge stops it with `⏱` instead of letting one runaway loop own the topic for hours.
|
|
448
|
+
Nothing is lost — the session and every file the turn produced stay in place — so the message
|
|
449
|
+
carries **⏵ Continue**, which asks the agent to check the state and go on from where it stopped.
|
|
450
|
+
That is deliberately not the same as **Retry**, which would redo the whole task from the start.
|
|
451
|
+
|
|
452
|
+
This needs the plugin from this repository:
|
|
453
|
+
|
|
454
|
+
```bash
|
|
455
|
+
dsh plugin --profile headless add link:<path-to-repository>/plugin/steer-inbox
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
and a line in `~/.dsh/profiles/headless/cordis.patch.yml`:
|
|
459
|
+
|
|
460
|
+
```yaml
|
|
461
|
+
- insert:
|
|
462
|
+
- id: steer-inbox
|
|
463
|
+
name: 'dsh-steer-inbox'
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
The bridge checks the profile itself: if the line is missing, it does not write the task
|
|
467
|
+
(it would just expire) and behaves as before, queueing the message.
|
|
468
|
+
|
|
469
|
+
### Live thoughts and reasoning
|
|
470
|
+
|
|
471
|
+
Two things land in the same progress message, and neither sends a chat message of its own.
|
|
472
|
+
|
|
473
|
+
**The model's reasoning.** Every `thinking` block the CLI commits is folded into one
|
|
474
|
+
Telegram `<blockquote expandable>`: collapsed it is a single line, tapped it opens the whole
|
|
475
|
+
trail of the turn, and it stays there after the turn ends — the same way the desktop app shows
|
|
476
|
+
a reasoning section you can expand. The block is written once, in the final edit of the turn,
|
|
477
|
+
and never touched again: Telegram re-collapses an expanded block on every edit of its message,
|
|
478
|
+
which used to yank the chat away from a half-read paragraph. While the turn runs the message
|
|
479
|
+
only gets a counter (`🧠 Размышления · 4821`) and the last three steps, so the live edits stay
|
|
480
|
+
short. Escaped, and trimmed to its tail when a turn thinks longer than a message can hold; the
|
|
481
|
+
panel never exceeds one message. A cut block says `… · начало скрыто · /thoughts file`, which
|
|
482
|
+
sends the whole log as a document. If the API refuses the markup, the same content is retried
|
|
483
|
+
as plain text.
|
|
484
|
+
|
|
485
|
+
**The steps.** Three calls fit inline. A turn that makes more moves its complete step list into
|
|
486
|
+
a second collapsed block, added in that same final edit, so "what did it actually run" is one
|
|
487
|
+
tap away instead of a count.
|
|
488
|
+
|
|
489
|
+
**The agent's own notes.** The agent can add a short decision trail:
|
|
490
|
+
|
|
491
|
+
```bash
|
|
492
|
+
node ~/.dsh/tg-bridge/say.mjs --thought "checking why the watchdog fired twice"
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
The note is appended to `~/.dsh/tg-bridge/thoughts/<chat>_<thread>.jsonl`; the progress
|
|
496
|
+
message shows the last two as `💭` lines. The command needs no ids: it falls back to the
|
|
497
|
+
newest turn's thought file, because tool shells do not inherit the bridge environment.
|
|
498
|
+
`--thought` sends a Telegram message of its own only in `/reasoning chat` mode.
|
|
499
|
+
|
|
500
|
+
A decision the person must know before the turn ends — a release shipped, a cause found,
|
|
501
|
+
a blocker — goes to the chat as one plain line instead:
|
|
502
|
+
|
|
503
|
+
```bash
|
|
504
|
+
node ~/.dsh/tg-bridge/say.mjs --note "1.10.1 is on npm; restart to load it"
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
`--note` sends a real message and takes the same no-ids fallback as `--thought`. The split
|
|
508
|
+
is deliberate: `--thought` is the working trail (inside the progress message, and in `chat`
|
|
509
|
+
mode also as its own messages), `--note` is the short line that changes what the reader
|
|
510
|
+
expects to happen next — useful in `card` and `off` mode, redundant in `chat`. The progress
|
|
511
|
+
message itself opens with the request echoed back (`⏳ Принял: «…» · 3 с`), so the first
|
|
512
|
+
thing the person sees after sending names their task rather than a generic spinner.
|
|
513
|
+
|
|
514
|
+
`/reasoning` is the switch for the 💭 mechanism, and it has three ends:
|
|
515
|
+
|
|
516
|
+
- `/reasoning card` (the default) — every turn carries a short instruction to leave one line
|
|
517
|
+
at each decision point (task clear, cause found, risky change, result checked), and the
|
|
518
|
+
progress message shows the last two;
|
|
519
|
+
- `/reasoning chat` — the same lines, each also posted as its own message, so a turn that
|
|
520
|
+
runs for twenty minutes is read as it happens instead of scrolled back to afterwards.
|
|
521
|
+
The prompt says so explicitly, so a line is written to stand alone;
|
|
522
|
+
- `/reasoning off` — drops the instruction and the `💭` lines for that topic, for when the
|
|
523
|
+
step list is all you want.
|
|
524
|
+
|
|
525
|
+
A topic switched to `chat` mid-turn does not dump the steps already in the card: forwarding
|
|
526
|
+
starts with the next line written. The setting lives in `state.json` per topic, so a chatty
|
|
527
|
+
research topic and a terse deploy topic can differ; a `true`/`false` written by an older
|
|
528
|
+
release still reads as `card`/`off`. The settings card offers the same three ends as buttons.
|
|
529
|
+
|
|
530
|
+
The reasoning block itself is model output; `/thoughts` is what reads it back:
|
|
531
|
+
|
|
532
|
+
- `/thoughts` — the last turn as a message, in parts, deleted after three minutes;
|
|
533
|
+
- `/thoughts file` — the **whole** last turn as `reasoning-<date>-file.md`, sent as a document
|
|
534
|
+
(a five-hour turn is tens of thousands of characters, which no chat message can hold);
|
|
535
|
+
- `/thoughts all` — every turn of the session in one file (a long session is a couple of MB);
|
|
536
|
+
- `/thoughts off` / `on` — keep the block out of the turn panel (the panel then shows
|
|
537
|
+
`🧠 Размышления · N · /thoughts file`) or bring it back.
|
|
538
|
+
|
|
539
|
+
The log is built from the session file on demand, so nothing is duplicated while a turn runs.
|
|
540
|
+
Files land in `~/.dsh/tg-bridge/thoughts/` and older ones are pruned after a week.
|
|
541
|
+
|
|
542
|
+
### Profiles per topic
|
|
543
|
+
|
|
544
|
+
The desktop app lets you build several profiles for different kinds of work, each with its own
|
|
545
|
+
plugin set and model. The same switch works from a topic:
|
|
546
|
+
|
|
547
|
+
```
|
|
548
|
+
/profile current profile, available ones, hints
|
|
549
|
+
/profile research run this topic's turns on another profile
|
|
550
|
+
/profile new research from web
|
|
551
|
+
create a profile from a shipped template and bind it
|
|
552
|
+
/profile default back to the install default
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
A new profile is written by `dsh <name> --from-default-profile <template> --dump-config`, so
|
|
556
|
+
nothing boots and no plugin is loaded at creation time; dependencies are installed by the
|
|
557
|
+
profile's first turn. The binding is per topic: `/plugins` manages that profile's rows, and
|
|
558
|
+
`/plugins search <word>` lists what the npm registry
|
|
559
|
+
has with the `dsh-plugin` keyword — the desktop app's plugin browser, from the chat. Each result
|
|
560
|
+
carries a plus button that runs `/plugins add <name>`.
|
|
561
|
+
|
|
562
|
+
`/model` is a step finer than the binding. A topic that never chose a model boots the profile
|
|
563
|
+
it is bound to; `/model <route>` stores the route for that topic alone, and the next turn boots a
|
|
564
|
+
copy of the profile with the `agent-default-model` row rewritten — provider, model and the other
|
|
565
|
+
keys of that row, `reasoningEffort` included, carried over. The copy is rebuilt whenever the
|
|
566
|
+
profile changes, so a provider added to the profile reaches the topics that had already chosen.
|
|
567
|
+
`/model <route> all` writes the profile itself, and `/model auto` deletes the topic's route.
|
|
568
|
+
|
|
569
|
+
### The directory a topic writes in
|
|
570
|
+
|
|
571
|
+
`/cd my-app` does two things, and they are worth separating because they used to
|
|
572
|
+
be one: the turn runs *in* that directory, and the sandbox *stops* at it. The
|
|
573
|
+
second half only works on a profile that has a permission table — the bridge
|
|
574
|
+
writes the row only when one exists, and never invents one for a profile that
|
|
575
|
+
opted out.
|
|
576
|
+
|
|
577
|
+
```
|
|
578
|
+
/cd my-app bind the topic: run here, and write only here
|
|
579
|
+
/cd ~/Projects/api wide run here, but do not narrow the sandbox
|
|
580
|
+
/cd reset unbind; the topic goes back to config.cwd
|
|
581
|
+
/cd what this topic is bound to, and how
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
| Sandbox mode | Writes inside the root | Writes outside the root |
|
|
585
|
+
|---|---|---|
|
|
586
|
+
| `read-only` | denied | denied |
|
|
587
|
+
| `workspace-write` | allowed | denied |
|
|
588
|
+
| `danger-full-access` | allowed | allowed |
|
|
589
|
+
|
|
590
|
+
`workspaceRoot` is the boundary, and it holds even when the turn switches its own
|
|
591
|
+
working directory: the refusal follows the configured root, not the directory the
|
|
592
|
+
agent moved to. That is the point — a model that wanders into another project
|
|
593
|
+
gets a refusal instead of a write.
|
|
594
|
+
|
|
595
|
+
Three things this table does **not** say, because measurement disagreed with the
|
|
596
|
+
obvious reading:
|
|
597
|
+
|
|
598
|
+
- the sandbox row alone changes nothing. `mode: read-only` in the
|
|
599
|
+
`sandbox-policy` row plus `defaultPreset: danger-full-access` in the permission
|
|
600
|
+
table still wrote outside the root. The permission table wins; the sandbox row
|
|
601
|
+
is a default for a profile that has no table.
|
|
602
|
+
- `danger-full-access` therefore has to be chosen on purpose, per topic
|
|
603
|
+
(`/permissions danger-full-access`), and it is the only mode that reaches
|
|
604
|
+
outside the root.
|
|
605
|
+
- a preset with `approval: ask` cannot be used from a chat at all: a headless
|
|
606
|
+
turn has no approval channel, so the escalation fails closed and the turn
|
|
607
|
+
errors. `/permissions` lists such a preset with the reason instead of letting
|
|
608
|
+
someone pick a trap.
|
|
609
|
+
|
|
610
|
+
Stock installs are not permission-enabled: `cordis.patch.yml` ships with the
|
|
611
|
+
`tg-bridge` plugin row only, so `/cd` binds the directory and `/permissions`
|
|
612
|
+
edits the profile-wide preset, exactly as before. The per-topic behaviour starts
|
|
613
|
+
the first time a profile gains a permission table.
|
|
614
|
+
|
|
615
|
+
### Goals and tasks
|
|
616
|
+
|
|
617
|
+
A topic carries its own goal and checklist, so the aim survives `/new`, a
|
|
618
|
+
restart and a different session:
|
|
619
|
+
|
|
620
|
+
```
|
|
621
|
+
/goal ship the release set or replace the goal
|
|
622
|
+
/goal show the goal and the checklist
|
|
623
|
+
/tasks write the migration add a task
|
|
624
|
+
/tasks done 2 tick it off
|
|
625
|
+
/tasks edit 2 shorter words rewrite it in place, same number
|
|
626
|
+
/tasks rm 2 remove it
|
|
627
|
+
/goal reopen open a closed goal again
|
|
628
|
+
/goal done close the goal (all tasks done)
|
|
629
|
+
/goal clear delete the goal and its tasks
|
|
630
|
+
```
|
|
631
|
+
|
|
632
|
+
The bridge prepends the goal and the list to every turn, with the exact command
|
|
633
|
+
that updates it (`goal.mjs`). The agent ticks tasks as it finishes them, and the
|
|
634
|
+
next turn sees the new state. The bridge is the only writer of `state.json`: the
|
|
635
|
+
agent drops a job file into `goal-jobs/` and the bridge applies it, so there is
|
|
636
|
+
no lock race and no lost update.
|
|
637
|
+
|
|
638
|
+
## Security
|
|
639
|
+
|
|
640
|
+
- `config.json`, `state.json`, `pending/`, logs are in `.gitignore` and never
|
|
641
|
+
end up in the repository.
|
|
642
|
+
- The token is stored in the DSH credentials store, not in code or config.
|
|
643
|
+
- The bridge only replies to ids in `allowedUserIds`.
|
|
644
|
+
|
|
645
|
+
## Documentation
|
|
646
|
+
|
|
647
|
+
- [docs/TELEGRAM-SETUP.md](https://github.com/aleksvega/dsh-tg-bridge/blob/master/docs/TELEGRAM-SETUP.md): BotFather settings, group and bot permissions
|
|
648
|
+
- [docs/SUPPORT.md](https://github.com/aleksvega/dsh-tg-bridge/blob/master/docs/SUPPORT.md): what to send with a bug report, what never to send, and the one-line answer for "the bot went silent"
|
|
649
|
+
- [docs/ROADMAP.md](https://github.com/aleksvega/dsh-tg-bridge/blob/master/docs/ROADMAP.md): what comes next
|
|
650
|
+
- [docs/UX-ANALYSIS.md](https://github.com/aleksvega/dsh-tg-bridge/blob/master/docs/UX-ANALYSIS.md): interactive UX review
|
|
651
|
+
- [docs/COST.md](https://github.com/aleksvega/dsh-tg-bridge/blob/master/docs/COST.md): what one turn costs and how to reduce it
|
|
652
|
+
- [docs/CHANGELOG.md](https://github.com/aleksvega/dsh-tg-bridge/blob/master/docs/CHANGELOG.md): change history
|
|
653
|
+
- [docs/RELEASE-CRITERIA.md](https://github.com/aleksvega/dsh-tg-bridge/blob/master/docs/RELEASE-CRITERIA.md): release readiness criteria
|
|
654
|
+
|
|
655
|
+
## License
|
|
656
|
+
|
|
657
|
+
MIT, see [LICENSE](LICENSE).
|