@goodandready/dsh-messenger-gateway 0.3.22 → 0.4.1
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/LICENSE +1 -1
- package/cordis.patch.yml +1 -1
- package/lib/adapters/discord.js +1 -1
- package/lib/adapters/slack.js +1 -1
- package/lib/adapters/telegram-inbound.js +141 -0
- package/lib/adapters/telegram.js +35 -151
- package/lib/alerts.js +42 -1
- package/lib/api-health.js +38 -0
- package/lib/artifacts.js +118 -118
- package/lib/ask.js +203 -152
- package/lib/client.js +1698 -1631
- package/lib/commands.js +52 -0
- package/lib/documents.js +1 -1
- package/lib/file-manager.js +27 -1
- package/lib/forum-mirror.js +105 -0
- package/lib/gateway-callbacks.js +187 -0
- package/lib/gateway-commands.js +584 -0
- package/lib/gateway-turn.js +285 -0
- package/lib/gateway.js +58 -1240
- package/lib/http.js +12 -1
- package/lib/index.js +13 -5
- package/lib/integrations.js +1 -1
- package/lib/media.js +1 -9
- package/lib/models.js +6 -3
- package/lib/outbound.js +1 -1
- package/lib/pairing.js +8 -4
- package/lib/personas.js +8 -4
- package/lib/photos.js +1 -1
- package/lib/scheduler.js +14 -4
- package/lib/stream.js +115 -115
- package/lib/topics.js +0 -14
- package/lib/tts.js +0 -10
- package/lib/voice-prefs.js +8 -4
- package/package.json +6 -2
package/lib/client.js
CHANGED
|
@@ -1,1631 +1,1698 @@
|
|
|
1
|
-
// dsh-messenger-gateway — browser (client) half.
|
|
2
|
-
// Settings card on Plugins → Plugin settings tab (settings.plugin.item).
|
|
3
|
-
// Config managed via reactive ctx.settingsScope snapshot.
|
|
4
|
-
|
|
5
|
-
window.__ModuleLoader__.load({
|
|
6
|
-
id: '@goodandready/dsh-messenger-gateway',
|
|
7
|
-
factory: (require) => {
|
|
8
|
-
var module = { exports: {} }
|
|
9
|
-
var exports = module.exports
|
|
10
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' })
|
|
11
|
-
const React = require('react')
|
|
12
|
-
|
|
13
|
-
const NS = 'dsh-messenger-gateway'
|
|
14
|
-
const ROUTE_PREFIX = '/dsh-messenger-gateway'
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
'
|
|
24
|
-
'
|
|
25
|
-
'
|
|
26
|
-
'
|
|
27
|
-
'
|
|
28
|
-
'badge.
|
|
29
|
-
'badge.
|
|
30
|
-
'badge.
|
|
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
|
-
'updater.
|
|
125
|
-
'updater.
|
|
126
|
-
'updater.
|
|
127
|
-
'updater.
|
|
128
|
-
'updater.
|
|
129
|
-
'updater.
|
|
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
|
-
|
|
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
|
-
'
|
|
260
|
-
'
|
|
261
|
-
'
|
|
262
|
-
'
|
|
263
|
-
'
|
|
264
|
-
'
|
|
265
|
-
'
|
|
266
|
-
|
|
267
|
-
'updater.
|
|
268
|
-
'updater.
|
|
269
|
-
'updater.
|
|
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
|
-
.msgw-
|
|
342
|
-
.msgw-
|
|
343
|
-
.msgw-
|
|
344
|
-
|
|
345
|
-
.msgw-
|
|
346
|
-
|
|
347
|
-
.msgw-
|
|
348
|
-
.msgw-
|
|
349
|
-
|
|
350
|
-
.msgw-
|
|
351
|
-
|
|
352
|
-
.msgw-
|
|
353
|
-
.msgw-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
.msgw-
|
|
357
|
-
.msgw-
|
|
358
|
-
.msgw-
|
|
359
|
-
.msgw-
|
|
360
|
-
|
|
361
|
-
.msgw-
|
|
362
|
-
.msgw-
|
|
363
|
-
|
|
364
|
-
.msgw-
|
|
365
|
-
|
|
366
|
-
.msgw-
|
|
367
|
-
|
|
368
|
-
.msgw-
|
|
369
|
-
.msgw-
|
|
370
|
-
.msgw-
|
|
371
|
-
.msgw-
|
|
372
|
-
|
|
373
|
-
.msgw-
|
|
374
|
-
|
|
375
|
-
.msgw-
|
|
376
|
-
.msgw-
|
|
377
|
-
.msgw-
|
|
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
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
botToken:
|
|
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
|
-
const [
|
|
545
|
-
const [
|
|
546
|
-
const [
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
const
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
const
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
)
|
|
566
|
-
|
|
567
|
-
const
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
const
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
const
|
|
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
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
})
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
})
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
'div',
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
?
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
:
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
{ className: 'msgw-section-
|
|
868
|
-
React.createElement(
|
|
869
|
-
'div',
|
|
870
|
-
{ className: 'msgw-
|
|
871
|
-
React.createElement('span',
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
),
|
|
883
|
-
React.createElement('div', { className: 'msgw-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
React.createElement(
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
React.createElement('
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
},
|
|
981
|
-
|
|
982
|
-
)
|
|
983
|
-
)
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
'
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
React.createElement(
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
className: 'msgw-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
)
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
},
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
value:
|
|
1099
|
-
onChange: (e) => setCfg({ ...cfg, agent: { ...cfg.agent,
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
React.createElement(
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
React.createElement(
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
)
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
React.createElement(
|
|
1185
|
-
'
|
|
1186
|
-
{
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
},
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
React.createElement(
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
{
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
React.createElement(
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
React.createElement(
|
|
1276
|
-
'
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
const
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
}
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1
|
+
// dsh-messenger-gateway — browser (client) half.
|
|
2
|
+
// Settings card on Plugins → Plugin settings tab (settings.plugin.item).
|
|
3
|
+
// Config managed via reactive ctx.settingsScope snapshot.
|
|
4
|
+
|
|
5
|
+
window.__ModuleLoader__.load({
|
|
6
|
+
id: '@goodandready/dsh-messenger-gateway',
|
|
7
|
+
factory: (require) => {
|
|
8
|
+
var module = { exports: {} }
|
|
9
|
+
var exports = module.exports
|
|
10
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' })
|
|
11
|
+
const React = require('react')
|
|
12
|
+
|
|
13
|
+
const NS = 'dsh-messenger-gateway'
|
|
14
|
+
const ROUTE_PREFIX = '/dsh-messenger-gateway'
|
|
15
|
+
// Plugins page row seat: key = '<package name>#<row id>', row id as cordis.patch.yml declares it.
|
|
16
|
+
const PKG = '@goodandready/dsh-messenger-gateway'
|
|
17
|
+
const ROW_ID = 'dsh-messenger-gateway'
|
|
18
|
+
const ROW_CONFIG_KEY = PKG + '#' + ROW_ID
|
|
19
|
+
|
|
20
|
+
const en = {
|
|
21
|
+
title: 'Messenger gateway',
|
|
22
|
+
description: 'Telegram bot: text, voice, photos, documents, and interactive asks.',
|
|
23
|
+
'settings.loading': 'Loading Messenger gateway settings…',
|
|
24
|
+
'settings.retry': 'Retry',
|
|
25
|
+
'settings.unavailable': 'Settings unavailable (host namespace is not ready).',
|
|
26
|
+
'header.title': 'Telegram & Multi-Messenger Gateway',
|
|
27
|
+
'header.sub': 'Bridge between DeepSeek Harness and Telegram: sessions, steer, forum topics, inline buttons, and optional voice notes.',
|
|
28
|
+
'badge.online': 'Telegram online (@{username})',
|
|
29
|
+
'badge.running': 'Running',
|
|
30
|
+
'badge.stopped': 'Stopped',
|
|
31
|
+
'badge.token_ok': 'Token ✓',
|
|
32
|
+
'badge.token_missing': 'Token missing',
|
|
33
|
+
'badge.pairing_count': 'Pairing: {count}',
|
|
34
|
+
'badge.transport': 'Transport: {mode}',
|
|
35
|
+
save: 'Save Changes',
|
|
36
|
+
saved: 'Settings saved successfully',
|
|
37
|
+
saving: 'Saving…',
|
|
38
|
+
showAdvanced: '⚙️ Advanced connection & polling settings',
|
|
39
|
+
hideAdvanced: 'Hide advanced settings',
|
|
40
|
+
telegram: 'Telegram Bot Configuration',
|
|
41
|
+
telegramSub: 'Main bot credentials, whitelist, and message delivery settings.',
|
|
42
|
+
agent: 'Agent & Reasoning Execution',
|
|
43
|
+
agentSub: 'Model routing, instruction overrides, and turn timeout control.',
|
|
44
|
+
media: 'Media & File Limits',
|
|
45
|
+
mediaSub: 'Document extraction and image upload limits.',
|
|
46
|
+
tts: 'Voice Replies (dsh-tts)',
|
|
47
|
+
ttsSub: 'Synthesize spoken replies for Telegram voice messages.',
|
|
48
|
+
advanced: 'Connection & Polling Internals',
|
|
49
|
+
botToken: 'Telegram Bot Token',
|
|
50
|
+
botTokenHint: 'Obtained via @BotFather. Leave empty to keep existing configured token.',
|
|
51
|
+
allowedIds: 'Allowed Telegram User IDs',
|
|
52
|
+
allowedIdsHint: 'Comma-separated list of user IDs. Leave empty to allow all users (pairing requests enabled).',
|
|
53
|
+
textFormat: 'Text Format Rendering',
|
|
54
|
+
textFormatHtml: 'Markdown → Telegram HTML (recommended)',
|
|
55
|
+
textFormatPlain: 'Plain text (no formatting)',
|
|
56
|
+
disableTelegram: 'Disable Telegram Bot',
|
|
57
|
+
enableTelegram: 'Enable Telegram Bot',
|
|
58
|
+
provider: 'Provider Override',
|
|
59
|
+
providerHint: 'Leave empty to use DSH default provider',
|
|
60
|
+
model: 'Model Override',
|
|
61
|
+
modelHint: 'Leave empty to use DSH default model',
|
|
62
|
+
photoOnly: 'Photo without Caption Behavior',
|
|
63
|
+
photoPrompt: 'Wait for question (recommended)',
|
|
64
|
+
photoRun: 'Reply immediately',
|
|
65
|
+
instruction: 'Extra Agent Instruction',
|
|
66
|
+
instructionHint: 'Prepended to each inbound messenger message',
|
|
67
|
+
instructionPlaceholder: 'Empty = built-in relay instruction (Russian, concise)',
|
|
68
|
+
maxMessageLength: 'Max Reply Length (characters)',
|
|
69
|
+
turnTimeout: 'Agent Turn Timeout (seconds)',
|
|
70
|
+
maxDocMb: 'Max Document Size (MB)',
|
|
71
|
+
maxImageMb: 'Max Photo Size (MB)',
|
|
72
|
+
maxTextKb: 'Max Extracted Text from Document (KB)',
|
|
73
|
+
ttsEnable: 'Enable Voice Replies (requires dsh-tts)',
|
|
74
|
+
ttsMaxChars: 'Max Spoken Characters per Voice Note',
|
|
75
|
+
pollTimeout: 'Long Poll Timeout (seconds)',
|
|
76
|
+
pollInterval: 'Long Poll Interval (ms)',
|
|
77
|
+
idleTimeout: 'Idle Chat Timeout (seconds)',
|
|
78
|
+
pairing: 'Pairing Requests & Authorization',
|
|
79
|
+
pairingSub: 'Authorize new users when whitelist is restricted.',
|
|
80
|
+
pairingEmpty: 'No pending pairing codes',
|
|
81
|
+
pairingApprove: 'Approve',
|
|
82
|
+
pairingReject: 'Reject',
|
|
83
|
+
pairingRefresh: 'Refresh List',
|
|
84
|
+
groupsEnable: 'Respond in Telegram Groups & Supergroups',
|
|
85
|
+
groupMention: 'Require @mention, reply, or /command in groups',
|
|
86
|
+
reactionsEnable: 'React with 👀 while processing turn',
|
|
87
|
+
progressEnable: 'Progress status message (Thinking → Delete → Final)',
|
|
88
|
+
statusIndicator: 'Bot Status Description Indicator (Online/Offline)',
|
|
89
|
+
statusIndicatorHint: 'Sets bot short description via Telegram API (visible to all users).',
|
|
90
|
+
transport: 'Telegram Transport Mode',
|
|
91
|
+
transportPoll: 'Long poll (getUpdates)',
|
|
92
|
+
transportWebhook: 'Webhook (HTTPS)',
|
|
93
|
+
webhookUrl: 'Public Webhook HTTPS URL',
|
|
94
|
+
webhookUrlHint: 'Public endpoint where Telegram sends updates',
|
|
95
|
+
webhookSecret: 'Webhook Secret Token',
|
|
96
|
+
webhookSecretHint: 'Leave empty to keep current configured secret',
|
|
97
|
+
webhookSecretConfigured: 'Secret set',
|
|
98
|
+
webhookSecretRequired: 'Secret required',
|
|
99
|
+
sessionScope: 'Group Session Scope',
|
|
100
|
+
sessionScopeChat: 'Shared per chat/topic',
|
|
101
|
+
sessionScopeUser: 'Per-user session (recommended)',
|
|
102
|
+
voiceMode: 'Voice Reply Mode',
|
|
103
|
+
voiceModeMirror: 'Mirror inbound voice (reply voice only if input was voice)',
|
|
104
|
+
voiceModeAlways: 'Always synthesize voice note',
|
|
105
|
+
voiceModeOff: 'Off (unless explicitly toggled via /voice)',
|
|
106
|
+
notifyBridge: 'Notify Bridge → Telegram Home',
|
|
107
|
+
notifyBridgeHint: 'Forward task_done/error events from web sessions into designated Telegram home',
|
|
108
|
+
notifyHome: 'Notify Target Home Name',
|
|
109
|
+
quickActions: 'Quick Actions Keyboard (/new, /stop, /voice, /status)',
|
|
110
|
+
artifactPreviews: 'Render diagram and table previews in Telegram',
|
|
111
|
+
'diag.title': '⚡ Diagnostics & Telegram Smoke Test',
|
|
112
|
+
'diag.desc': 'Test connection to Telegram Bot API, measure network latency, and verify bot identity.',
|
|
113
|
+
'diag.smoke_btn': 'Run Telegram Smoke Test (Ping)',
|
|
114
|
+
'diag.smoke_testing': 'Testing Telegram API…',
|
|
115
|
+
'diag.smoke_ok': 'Telegram API OK! Latency: {latency} ms (@{username}, ID: {id})',
|
|
116
|
+
'diag.smoke_err': 'Smoke test failed: {error}',
|
|
117
|
+
'stats.title': '📊 Gateway Telemetry & Session Counters',
|
|
118
|
+
'stats.desc': 'Real-time counters from the running gateway process.',
|
|
119
|
+
'stats.sent': 'Messages Delivered',
|
|
120
|
+
'stats.errors': 'Delivery Errors',
|
|
121
|
+
'stats.uptime': 'Gateway Uptime',
|
|
122
|
+
'stats.active_chats': 'Active Chats in Memory',
|
|
123
|
+
// Updater
|
|
124
|
+
'updater.title': 'Plugin Self-Updater',
|
|
125
|
+
'updater.desc': 'Check npmjs registry for updates and upgrade in-place.',
|
|
126
|
+
'updater.current': 'Current version: {version}',
|
|
127
|
+
'updater.checking': 'Checking for updates…',
|
|
128
|
+
'updater.available': 'Update available: v{version}',
|
|
129
|
+
'updater.upToDate': 'Up to date',
|
|
130
|
+
'updater.btn_check': 'Check for Updates',
|
|
131
|
+
'updater.btn_update': 'Update to v{version}',
|
|
132
|
+
'updater.updating': 'Updating…',
|
|
133
|
+
'updater.success': 'Updated to v{version}! Please restart DSH service if required.',
|
|
134
|
+
'updater.failed': 'Update failed: {error}',
|
|
135
|
+
'updater.check_failed': 'Update check failed: {error}',
|
|
136
|
+
// Discord
|
|
137
|
+
discord: 'Discord Gateway',
|
|
138
|
+
discordSub: 'Discord bot and outbound webhook delivery settings.',
|
|
139
|
+
enableDiscord: 'Enable Discord',
|
|
140
|
+
disableDiscord: 'Disable Discord',
|
|
141
|
+
discordToken: 'Discord Bot Token',
|
|
142
|
+
discordTokenHint: 'From Discord Developer Portal. Leave empty to keep existing.',
|
|
143
|
+
discordWebhook: 'Discord Webhook URL',
|
|
144
|
+
discordWebhookHint: 'Incoming webhook for sending messages/notifications.',
|
|
145
|
+
discordChannels: 'Allowed Discord Channel IDs',
|
|
146
|
+
discordChannelsHint: 'Comma-separated channel IDs. Leave empty to allow all configured.',
|
|
147
|
+
// Slack
|
|
148
|
+
slack: 'Slack Gateway',
|
|
149
|
+
slackSub: 'Slack bot and incoming webhook settings.',
|
|
150
|
+
enableSlack: 'Enable Slack',
|
|
151
|
+
disableSlack: 'Disable Slack',
|
|
152
|
+
slackToken: 'Slack Bot Token (xoxb-…)',
|
|
153
|
+
slackTokenHint: 'Bot User OAuth Token. Leave empty to keep existing.',
|
|
154
|
+
slackWebhook: 'Slack Webhook URL',
|
|
155
|
+
slackWebhookHint: 'Incoming webhook URL for channel notifications.',
|
|
156
|
+
slackDefaultChannel: 'Slack Default Channel',
|
|
157
|
+
slackDefaultChannelHint: 'Default channel or member ID for outbound messages (e.g. #general or C12345).',
|
|
158
|
+
// Cron badge
|
|
159
|
+
'badge.cron_count': 'Cron: {count}',
|
|
160
|
+
'badge.api_degraded': 'Telegram API degraded ({count})',
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const zh = {
|
|
164
|
+
title: 'Messenger gateway',
|
|
165
|
+
description: 'Telegram 机器人:文本、语音、图片、文档和交互式询问。',
|
|
166
|
+
'settings.loading': '正在加载 Messenger gateway 设置…',
|
|
167
|
+
'settings.retry': '重试',
|
|
168
|
+
'settings.unavailable': '设置不可用(主机命名空间未就绪)。',
|
|
169
|
+
'header.title': 'Telegram 与多消息平台网关',
|
|
170
|
+
'header.sub': 'DeepSeek Harness 与 Telegram 之间的桥梁:会话、转向提示、论坛话题、内联按钮和可选语音。',
|
|
171
|
+
'badge.online': 'Telegram 在线 (@{username})',
|
|
172
|
+
'badge.running': '运行中',
|
|
173
|
+
'badge.stopped': '已停止',
|
|
174
|
+
'badge.token_ok': '令牌有效 ✓',
|
|
175
|
+
'badge.token_missing': '缺少令牌',
|
|
176
|
+
'badge.pairing_count': '配对: {count}',
|
|
177
|
+
'badge.transport': '传输方式: {mode}',
|
|
178
|
+
save: '保存更改',
|
|
179
|
+
saved: '设置保存成功',
|
|
180
|
+
saving: '保存中…',
|
|
181
|
+
showAdvanced: '⚙️ 高级连接与轮询设置',
|
|
182
|
+
hideAdvanced: '隐藏高级设置',
|
|
183
|
+
telegram: 'Telegram 机器人设置',
|
|
184
|
+
telegramSub: '主机器人凭证、白名单与消息发送设置。',
|
|
185
|
+
agent: '智能体与推理行为',
|
|
186
|
+
agentSub: '模型路由、附加指令与轮次超时设置。',
|
|
187
|
+
media: '媒体与文件限制',
|
|
188
|
+
mediaSub: '文档提取与图片上传限制。',
|
|
189
|
+
tts: '语音回复 (dsh-tts)',
|
|
190
|
+
ttsSub: '为 Telegram 语音消息合成语音回复。',
|
|
191
|
+
advanced: '连接与轮询内部设置',
|
|
192
|
+
botToken: 'Telegram 机器人令牌',
|
|
193
|
+
botTokenHint: '从 @BotFather 获取。留空保持现有配置。',
|
|
194
|
+
allowedIds: '允许的 Telegram 用户 ID',
|
|
195
|
+
allowedIdsHint: '逗号分隔的用户 ID 列表。留空允许所有用户(启用配对请求)。',
|
|
196
|
+
textFormat: '文本格式化渲染',
|
|
197
|
+
textFormatHtml: 'Markdown → Telegram HTML (推荐)',
|
|
198
|
+
textFormatPlain: '纯文本 (无格式化)',
|
|
199
|
+
disableTelegram: '停用 Telegram 机器人',
|
|
200
|
+
enableTelegram: '启用 Telegram 机器人',
|
|
201
|
+
provider: '提供商覆盖',
|
|
202
|
+
providerHint: '留空使用 DSH 默认提供商',
|
|
203
|
+
model: '模型覆盖',
|
|
204
|
+
modelHint: '留空使用 DSH 默认模型',
|
|
205
|
+
photoOnly: '无附言图片处理方式',
|
|
206
|
+
photoPrompt: '等待问题 (推荐)',
|
|
207
|
+
photoRun: '立即回复',
|
|
208
|
+
instruction: '额外智能体指令',
|
|
209
|
+
instructionHint: '添加到每条来自网关的消息前',
|
|
210
|
+
instructionPlaceholder: '留空 = 内置指令',
|
|
211
|
+
maxMessageLength: '最大回复长度 (字符)',
|
|
212
|
+
turnTimeout: '智能体轮次超时 (秒)',
|
|
213
|
+
maxDocMb: '最大文档大小 (MB)',
|
|
214
|
+
maxImageMb: '最大图片大小 (MB)',
|
|
215
|
+
maxTextKb: '文档提取最大文本量 (KB)',
|
|
216
|
+
ttsEnable: '启用语音回复 (需 dsh-tts)',
|
|
217
|
+
ttsMaxChars: '每条语音消息最大字数',
|
|
218
|
+
pollTimeout: '长轮询超时 (秒)',
|
|
219
|
+
pollInterval: '长轮询间隔 (毫秒)',
|
|
220
|
+
idleTimeout: '空闲会话超时 (秒)',
|
|
221
|
+
pairing: '配对请求与授权',
|
|
222
|
+
pairingSub: '受限白名单下授权新用户。',
|
|
223
|
+
pairingEmpty: '暂无待处理配对码',
|
|
224
|
+
pairingApprove: '批准',
|
|
225
|
+
pairingReject: '拒绝',
|
|
226
|
+
pairingRefresh: '刷新列表',
|
|
227
|
+
groupsEnable: '在群组和超级群组中响应',
|
|
228
|
+
groupMention: '群组中需 @提及、回复或 /命令',
|
|
229
|
+
reactionsEnable: '处理中添加 👀 表情反应',
|
|
230
|
+
progressEnable: '进度状态提示 (思考中 → 删除 → 最终回复)',
|
|
231
|
+
statusIndicator: '机器人状态描述指示器 (Online/Offline)',
|
|
232
|
+
statusIndicatorHint: '通过 Telegram API 设置机器人简介(所有人可见)。',
|
|
233
|
+
transport: 'Telegram 传输模式',
|
|
234
|
+
transportPoll: '长轮询 (getUpdates)',
|
|
235
|
+
transportWebhook: 'Webhook (HTTPS)',
|
|
236
|
+
webhookUrl: '公开 Webhook HTTPS 地址',
|
|
237
|
+
webhookUrlHint: 'Telegram 投递更新的公开端点',
|
|
238
|
+
webhookSecret: 'Webhook 密钥令牌',
|
|
239
|
+
webhookSecretHint: '留空保持当前配置的密钥',
|
|
240
|
+
webhookSecretConfigured: '密钥已设置',
|
|
241
|
+
webhookSecretRequired: '必须设置密钥',
|
|
242
|
+
sessionScope: '群组会话范围',
|
|
243
|
+
sessionScopeChat: '每个聊天/话题共享',
|
|
244
|
+
sessionScopeUser: '每用户独立会话 (推荐)',
|
|
245
|
+
voiceMode: '语音回复模式',
|
|
246
|
+
voiceModeMirror: '镜像输入语音 (仅语音输入时回复语音)',
|
|
247
|
+
voiceModeAlways: '始终合成语音回复',
|
|
248
|
+
voiceModeOff: '关闭 (除非通过 /voice 启用)',
|
|
249
|
+
notifyBridge: '通知网桥 → Telegram Home',
|
|
250
|
+
notifyBridgeHint: '将 Web 会话的 task_done/error 事件转发至指定频道/话题',
|
|
251
|
+
notifyHome: '目标频道名称 (Home)',
|
|
252
|
+
quickActions: '快捷操作键盘 (/new, /stop, /voice, /status)',
|
|
253
|
+
artifactPreviews: '在 Telegram 中预览图表与表格',
|
|
254
|
+
'diag.title': '⚡ 诊断与连通性检查 (Smoke test)',
|
|
255
|
+
'diag.desc': '检查 Telegram Bot API 连接、测量延迟并验证机器人名称。',
|
|
256
|
+
'diag.smoke_btn': '测试 Telegram 连接 (Ping)',
|
|
257
|
+
'diag.smoke_testing': '正在连接 Telegram API…',
|
|
258
|
+
'diag.smoke_ok': 'Telegram API 连接成功!延迟: {latency} 毫秒 (@{username}, ID: {id})',
|
|
259
|
+
'diag.smoke_err': '连通性检查失败: {error}',
|
|
260
|
+
'stats.title': '📊 网关遥测与计数器',
|
|
261
|
+
'stats.desc': '运行中网关进程的实时统计。',
|
|
262
|
+
'stats.sent': '已发送消息',
|
|
263
|
+
'stats.errors': '发送错误数',
|
|
264
|
+
'stats.uptime': '运行时间',
|
|
265
|
+
'stats.active_chats': '内存中活跃聊天数',
|
|
266
|
+
// Updater
|
|
267
|
+
'updater.title': '插件自更新',
|
|
268
|
+
'updater.desc': '从 npmjs 仓库检查更新并直接就地升级。',
|
|
269
|
+
'updater.current': '当前版本: {version}',
|
|
270
|
+
'updater.checking': '正在检查更新…',
|
|
271
|
+
'updater.available': '发现新版本: v{version}',
|
|
272
|
+
'updater.upToDate': '已是最新版本',
|
|
273
|
+
'updater.btn_check': '检查更新',
|
|
274
|
+
'updater.btn_update': '更新至 v{version}',
|
|
275
|
+
'updater.updating': '正在更新…',
|
|
276
|
+
'updater.success': '已更新至 v{version}!如需生效请重启 DSH 服务。',
|
|
277
|
+
'updater.failed': '更新失败: {error}',
|
|
278
|
+
'updater.check_failed': '检查更新失败: {error}',
|
|
279
|
+
// Discord
|
|
280
|
+
discord: 'Discord 网关',
|
|
281
|
+
discordSub: 'Discord 机器人与出站 Webhook 设置。',
|
|
282
|
+
enableDiscord: '启用 Discord',
|
|
283
|
+
disableDiscord: '停用 Discord',
|
|
284
|
+
discordToken: 'Discord 机器人令牌',
|
|
285
|
+
discordTokenHint: '从 Discord 开发者平台获取。留空保持现有配置。',
|
|
286
|
+
discordWebhook: 'Discord Webhook URL',
|
|
287
|
+
discordWebhookHint: '用于发送消息或通知的传入 Webhook。',
|
|
288
|
+
discordChannels: '允许的 Discord 频道 ID',
|
|
289
|
+
discordChannelsHint: '逗号分隔的频道 ID。留空允许所有已配置频道。',
|
|
290
|
+
// Slack
|
|
291
|
+
slack: 'Slack 网关',
|
|
292
|
+
slackSub: 'Slack 机器人与 Webhook 设置。',
|
|
293
|
+
enableSlack: '启用 Slack',
|
|
294
|
+
disableSlack: '停用 Slack',
|
|
295
|
+
slackToken: 'Slack 机器人令牌 (xoxb-…)',
|
|
296
|
+
slackTokenHint: 'Bot 用户 OAuth 令牌。留空保持现有配置。',
|
|
297
|
+
slackWebhook: 'Slack Webhook URL',
|
|
298
|
+
slackWebhookHint: '用于频道通知的传入 Webhook URL。',
|
|
299
|
+
slackDefaultChannel: 'Slack 默认频道',
|
|
300
|
+
slackDefaultChannelHint: '出站消息的默认频道或成员 ID (例如 #general 或 C12345)。',
|
|
301
|
+
// Cron badge
|
|
302
|
+
'badge.cron_count': '定时任务: {count}',
|
|
303
|
+
'badge.api_degraded': 'Telegram API 异常 ({count} 次连续错误)',
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function useActiveLocale(ctx) {
|
|
307
|
+
const loc = ctx?.get?.('locale') || ctx?.locale
|
|
308
|
+
return React.useSyncExternalStore(
|
|
309
|
+
React.useMemo(() => (cb) => (loc ? loc.subscribe(cb) : () => {}), [loc]),
|
|
310
|
+
React.useCallback(() => {
|
|
311
|
+
if (loc) {
|
|
312
|
+
const active = loc.getSnapshot?.()?.active
|
|
313
|
+
if (typeof active === 'string' && active) return active
|
|
314
|
+
}
|
|
315
|
+
return typeof navigator !== 'undefined' ? String(navigator.language || '').slice(0, 2) : 'en'
|
|
316
|
+
}, [loc]),
|
|
317
|
+
)
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function makeT(locale) {
|
|
321
|
+
const DICT = String(locale || '').startsWith('zh') ? zh : en
|
|
322
|
+
return (key, params) => {
|
|
323
|
+
let text = DICT[key] || en[key] || key
|
|
324
|
+
if (params && typeof params === 'object') {
|
|
325
|
+
for (const k of Object.keys(params)) {
|
|
326
|
+
text = text.replace(new RegExp('\\{' + k + '\\}', 'g'), String(params[k]))
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return text
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
function ensureCss() {
|
|
334
|
+
if (typeof document === 'undefined') return
|
|
335
|
+
const id = 'dsh-messenger-gateway-full-css'
|
|
336
|
+
if (document.getElementById(id)) return
|
|
337
|
+
const style = document.createElement('style')
|
|
338
|
+
style.id = id
|
|
339
|
+
style.dataset.dshPlugin = NS
|
|
340
|
+
style.textContent = `
|
|
341
|
+
.msgw-page{display:flex;flex-direction:column;gap:16px;color:var(--dsw-alias-label-primary);font-family:inherit}
|
|
342
|
+
.msgw-page-seat{padding:0}
|
|
343
|
+
.msgw-header{display:flex;flex-direction:column;gap:4px;padding-bottom:12px;border-bottom:1px solid var(--dsw-alias-border-l2)}
|
|
344
|
+
.msgw-page-title{font-size:18px;font-weight:700;display:flex;align-items:center;gap:10px;flex-wrap:wrap;color:var(--dsw-alias-label-primary)}
|
|
345
|
+
.msgw-page-sub{font-size:13px;color:var(--dsw-alias-label-secondary);line-height:1.4}
|
|
346
|
+
|
|
347
|
+
.msgw-badge{font-size:11px;font-weight:600;padding:2px 8px;border-radius:12px;display:inline-flex;align-items:center;gap:4px;white-space:nowrap}
|
|
348
|
+
.msgw-badge-ok{background:var(--dsw-alias-state-success-bg, var(--dsw-alias-bg-layer-2));color:var(--dsw-alias-state-success-primary);border:1px solid var(--dsw-alias-state-success-border, var(--dsw-alias-border-l2))}
|
|
349
|
+
.msgw-badge-warn{background:var(--dsw-alias-state-warning-bg, var(--dsw-alias-bg-layer-2));color:var(--dsw-alias-state-warning-primary);border:1px solid var(--dsw-alias-state-warning-border, var(--dsw-alias-border-l2))}
|
|
350
|
+
.msgw-badge-bad{background:var(--dsw-alias-state-error-bg, var(--dsw-alias-bg-layer-2));color:var(--dsw-alias-state-error-primary);border:1px solid var(--dsw-alias-state-error-border, var(--dsw-alias-border-l2))}
|
|
351
|
+
|
|
352
|
+
.msgw-section-card{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);border-radius:12px;padding:16px;display:flex;flex-direction:column;gap:12px}
|
|
353
|
+
.msgw-section-title{font-size:14px;font-weight:600;color:var(--dsw-alias-label-primary);display:flex;align-items:center;justify-content:space-between}
|
|
354
|
+
.msgw-section-desc{font-size:12px;color:var(--dsw-alias-label-secondary);line-height:1.4;margin-top:-6px}
|
|
355
|
+
|
|
356
|
+
.msgw-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
|
|
357
|
+
.msgw-field{display:flex;flex-direction:column;gap:6px}
|
|
358
|
+
.msgw-label{font-size:13px;font-weight:500;color:var(--dsw-alias-label-primary)}
|
|
359
|
+
.msgw-hint{font-size:12px;color:var(--dsw-alias-label-secondary);line-height:1.3}
|
|
360
|
+
|
|
361
|
+
.msgw-input,.msgw-select,.msgw-textarea{width:100%;box-sizing:border-box;height:34px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);border-radius:8px;padding:0 12px;font:inherit;font-size:13px;outline:none;transition:border-color .15s}
|
|
362
|
+
.msgw-input:focus,.msgw-select:focus,.msgw-textarea:focus{border-color:var(--dsw-alias-label-primary)}
|
|
363
|
+
.msgw-textarea{height:auto;min-height:72px;padding:8px 12px}
|
|
364
|
+
.msgw-check{display:flex;gap:8px;align-items:center;cursor:pointer;font-size:13px;color:var(--dsw-alias-label-primary);user-select:none}
|
|
365
|
+
|
|
366
|
+
.msgw-btn{appearance:none;font:inherit;cursor:pointer;border:1px solid var(--dsw-alias-border-l2);border-radius:8px;padding:7px 14px;font-size:13px;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font-weight:500;display:inline-flex;align-items:center;justify-content:center;gap:6px;transition:all .15s ease}
|
|
367
|
+
.msgw-btn:hover:not(:disabled){background:var(--dsw-alias-bg-layer-4, var(--dsw-alias-bg-layer-2));border-color:var(--dsw-alias-label-dimmed, var(--dsw-alias-border-l2))}
|
|
368
|
+
.msgw-btn-primary{background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3);border-color:transparent}
|
|
369
|
+
.msgw-btn-primary:hover:not(:disabled){opacity:0.88}
|
|
370
|
+
.msgw-btn-danger{color:var(--dsw-alias-state-error-primary);border-color:var(--dsw-alias-state-error-border, var(--dsw-alias-border-l2))}
|
|
371
|
+
.msgw-btn-danger:hover:not(:disabled){background:var(--dsw-alias-state-error-bg, var(--dsw-alias-bg-hover));border-color:var(--dsw-alias-state-error-primary)}
|
|
372
|
+
.msgw-btn-mini{padding:4px 10px;font-size:12px;border-radius:6px}
|
|
373
|
+
.msgw-btn:disabled{opacity:0.5;cursor:not-allowed}
|
|
374
|
+
|
|
375
|
+
.msgw-alert-ok{padding:10px 14px;border-radius:8px;background:var(--dsw-alias-state-success-bg, var(--dsw-alias-bg-layer-2));color:var(--dsw-alias-state-success-primary);font-size:13px;border:1px solid var(--dsw-alias-state-success-border, var(--dsw-alias-border-l2))}
|
|
376
|
+
.msgw-alert-err{padding:10px 14px;border-radius:8px;background:var(--dsw-alias-state-error-bg, var(--dsw-alias-bg-layer-2));color:var(--dsw-alias-state-error-primary);font-size:13px;border:1px solid var(--dsw-alias-state-error-border, var(--dsw-alias-border-l2))}
|
|
377
|
+
.msgw-banner-warning{padding:12px 16px;border-radius:8px;background:var(--dsw-alias-state-warning-bg, var(--dsw-alias-bg-layer-2));border:1px solid var(--dsw-alias-state-warning-border, var(--dsw-alias-state-warning-primary));color:var(--dsw-alias-state-warning-primary);font-size:13px;display:flex;align-items:center;gap:10px;font-weight:500}
|
|
378
|
+
|
|
379
|
+
.msgw-stat-grid{display:grid;grid-template-columns:repeat(auto-fit, minmax(140px, 1fr));gap:10px}
|
|
380
|
+
.msgw-stat-box{padding:12px 14px;border:1px solid var(--dsw-alias-border-l2);border-radius:8px;background:var(--dsw-alias-bg-layer-2);display:flex;flex-direction:column;gap:4px}
|
|
381
|
+
.msgw-stat-val{font-size:18px;font-weight:700;color:var(--dsw-alias-label-primary)}
|
|
382
|
+
.msgw-stat-lbl{font-size:12px;color:var(--dsw-alias-label-secondary)}
|
|
383
|
+
|
|
384
|
+
.msgw-table{width:100%;border-collapse:collapse;margin-top:4px}
|
|
385
|
+
.msgw-table th{text-align:left;font-size:12px;color:var(--dsw-alias-label-secondary);padding:6px 8px;border-bottom:1px solid var(--dsw-alias-border-l2);font-weight:600}
|
|
386
|
+
.msgw-table td{padding:8px;border-bottom:1px solid var(--dsw-alias-border-l2);font-size:13px;color:var(--dsw-alias-label-primary)}
|
|
387
|
+
.msgw-table tr:hover{background:var(--dsw-alias-bg-layer-2)}
|
|
388
|
+
.msgw-preview{padding:12px;border-radius:8px;background:var(--dsw-alias-bg-layer-2);font-family:monospace;font-size:12px;white-space:pre-wrap;word-break:break-all;border:1px solid var(--dsw-alias-border-l2)}
|
|
389
|
+
`
|
|
390
|
+
document.head.appendChild(style)
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
function createErrorBoundary() {
|
|
394
|
+
if (!React || typeof React.Component !== 'function') {
|
|
395
|
+
return function NoopBoundary(props) { return props?.children || null }
|
|
396
|
+
}
|
|
397
|
+
return class ErrorBoundary extends React.Component {
|
|
398
|
+
constructor(props) {
|
|
399
|
+
super(props)
|
|
400
|
+
this.state = { hasError: false, error: null }
|
|
401
|
+
}
|
|
402
|
+
static getDerivedStateFromError(error) {
|
|
403
|
+
return { hasError: true, error }
|
|
404
|
+
}
|
|
405
|
+
componentDidCatch(error, errorInfo) {
|
|
406
|
+
console.error('[dsh-messenger-gateway] React UI Error:', error, errorInfo)
|
|
407
|
+
}
|
|
408
|
+
render() {
|
|
409
|
+
if (this.state.hasError) {
|
|
410
|
+
return React.createElement(
|
|
411
|
+
'div',
|
|
412
|
+
{ className: 'msgw-alert-err', style: { margin: '12px 0', padding: '14px', borderRadius: '8px' } },
|
|
413
|
+
React.createElement('div', { style: { fontWeight: 600, marginBottom: '6px' } }, '⚠️ Messenger Gateway UI Error:'),
|
|
414
|
+
React.createElement('div', { style: { fontSize: '12px', wordBreak: 'break-all' } }, String(this.state.error?.message || this.state.error)),
|
|
415
|
+
React.createElement(
|
|
416
|
+
'button',
|
|
417
|
+
{
|
|
418
|
+
type: 'button',
|
|
419
|
+
className: 'msgw-btn msgw-btn-mini',
|
|
420
|
+
style: { marginTop: '10px' },
|
|
421
|
+
onClick: () => this.setState({ hasError: false, error: null }),
|
|
422
|
+
},
|
|
423
|
+
'Retry'
|
|
424
|
+
)
|
|
425
|
+
)
|
|
426
|
+
}
|
|
427
|
+
return this.props?.children || null
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
const ErrorBoundary = createErrorBoundary()
|
|
432
|
+
|
|
433
|
+
function FallbackChevron() {
|
|
434
|
+
return React.createElement(
|
|
435
|
+
'svg',
|
|
436
|
+
{ width: 16, height: 16, viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: 2, strokeLinecap: 'round', strokeLinejoin: 'round' },
|
|
437
|
+
React.createElement('polyline', { points: '6 9 12 15 18 9' })
|
|
438
|
+
)
|
|
439
|
+
}
|
|
440
|
+
const Chevron = FallbackChevron
|
|
441
|
+
|
|
442
|
+
function idsToText(ids) { return (Array.isArray(ids) ? ids : []).map(String).filter(Boolean).join(', ') }
|
|
443
|
+
function textToIds(text) {
|
|
444
|
+
return String(text || '').split(/[\s,]+/).map((s) => s.trim()).filter(Boolean).map(Number).filter((n) => Number.isFinite(n))
|
|
445
|
+
}
|
|
446
|
+
function bytesToMb(n) { return Math.round(Number(n || 0) / (1024 * 1024)) }
|
|
447
|
+
function mbToBytes(n) { return Math.max(1, Math.round(Number(n || 1))) * 1024 * 1024 }
|
|
448
|
+
|
|
449
|
+
function Field({ label, hint, children }) {
|
|
450
|
+
return React.createElement('div', { className: 'msgw-field' },
|
|
451
|
+
React.createElement('label', { className: 'msgw-label' }, label),
|
|
452
|
+
hint ? React.createElement('div', { className: 'msgw-hint' }, hint) : null,
|
|
453
|
+
children,
|
|
454
|
+
)
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
const SETTINGS_KEYS = ['enabled', 'telegram', 'discord', 'slack', 'agent', 'media', 'tts']
|
|
458
|
+
|
|
459
|
+
function draftFromStored(s) {
|
|
460
|
+
const src = (s && typeof s === 'object') ? s : {}
|
|
461
|
+
const t = src.telegram || {}
|
|
462
|
+
const d = src.discord || {}
|
|
463
|
+
const sl = src.slack || {}
|
|
464
|
+
const a = src.agent || {}
|
|
465
|
+
const m = src.media || {}
|
|
466
|
+
const tts = src.tts || {}
|
|
467
|
+
return {
|
|
468
|
+
enabled: src.enabled !== false,
|
|
469
|
+
telegram: {
|
|
470
|
+
enabled: t.enabled === true,
|
|
471
|
+
allowedUserIds: Array.isArray(t.allowedUserIds) ? t.allowedUserIds : [],
|
|
472
|
+
pollTimeoutSeconds: Number(t.pollTimeoutSeconds) || 50,
|
|
473
|
+
pollIntervalMs: Number(t.pollIntervalMs) || 500,
|
|
474
|
+
commands: Array.isArray(t.commands) ? t.commands : [],
|
|
475
|
+
textFormat: t.textFormat === 'plain' ? 'plain' : 'html',
|
|
476
|
+
homeChatId: t.homeChatId != null ? t.homeChatId : '',
|
|
477
|
+
homeThreadId: Number(t.homeThreadId) || 0,
|
|
478
|
+
homes: Array.isArray(t.homes) ? t.homes : [],
|
|
479
|
+
pairingEnabled: t.pairingEnabled !== false,
|
|
480
|
+
streaming: t.streaming === true,
|
|
481
|
+
streamEditIntervalMs: Number(t.streamEditIntervalMs) || 1200,
|
|
482
|
+
progressEnabled: t.progressEnabled !== false,
|
|
483
|
+
approvalsEnabled: t.approvalsEnabled !== false,
|
|
484
|
+
groupsEnabled: t.groupsEnabled !== false,
|
|
485
|
+
groupRequireMention: t.groupRequireMention !== false,
|
|
486
|
+
reactionsEnabled: t.reactionsEnabled !== false,
|
|
487
|
+
statusIndicator: t.statusIndicator === true,
|
|
488
|
+
statusOnline: t.statusOnline || 'Online',
|
|
489
|
+
statusOffline: t.statusOffline || 'Offline',
|
|
490
|
+
transport: t.transport === 'webhook' ? 'webhook' : 'poll',
|
|
491
|
+
webhookUrl: t.webhookUrl || '',
|
|
492
|
+
webhookPath: t.webhookPath || '/dsh-messenger-gateway/telegram/webhook',
|
|
493
|
+
voiceMode: t.voiceMode || 'mirror',
|
|
494
|
+
quickActions: t.quickActions === true,
|
|
495
|
+
artifactPreviews: t.artifactPreviews !== false,
|
|
496
|
+
notifyBridge: t.notifyBridge || { enabled: false, events: ['task_done', 'error'], home: 'default', excludeSessionPrefixes: ['msgw-'] },
|
|
497
|
+
alerts: t.alerts || { enabled: false, chatId: '', threadId: 0, home: '', events: ['error', 'pairing'] },
|
|
498
|
+
botToken: t.botToken || '',
|
|
499
|
+
webhookSecret: t.webhookSecret || '',
|
|
500
|
+
},
|
|
501
|
+
discord: {
|
|
502
|
+
enabled: d.enabled === true,
|
|
503
|
+
botToken: d.botToken || '',
|
|
504
|
+
webhookUrl: d.webhookUrl || '',
|
|
505
|
+
allowedChannelIds: Array.isArray(d.allowedChannelIds) ? d.allowedChannelIds : [],
|
|
506
|
+
},
|
|
507
|
+
slack: {
|
|
508
|
+
enabled: sl.enabled === true,
|
|
509
|
+
botToken: sl.botToken || '',
|
|
510
|
+
webhookUrl: sl.webhookUrl || '',
|
|
511
|
+
defaultChannel: sl.defaultChannel || '',
|
|
512
|
+
},
|
|
513
|
+
agent: {
|
|
514
|
+
provider: a.provider || '',
|
|
515
|
+
model: a.model || '',
|
|
516
|
+
instructionPrefix: a.instructionPrefix || '',
|
|
517
|
+
maxMessageLength: Number(a.maxMessageLength) || 4000,
|
|
518
|
+
turnTimeoutMs: Number(a.turnTimeoutMs) || 600000,
|
|
519
|
+
idleTimeoutMs: Number(a.idleTimeoutMs) || 3600000,
|
|
520
|
+
photoOnlyMode: a.photoOnlyMode || 'prompt',
|
|
521
|
+
sessionScope: a.sessionScope || 'user',
|
|
522
|
+
},
|
|
523
|
+
media: {
|
|
524
|
+
maxDocBytes: Number(m.maxDocBytes) || 20971520,
|
|
525
|
+
maxImageBytes: Number(m.maxImageBytes) || 20971520,
|
|
526
|
+
maxTextInjectBytes: Number(m.maxTextInjectBytes) || 102400,
|
|
527
|
+
},
|
|
528
|
+
tts: {
|
|
529
|
+
enabled: tts.enabled === true,
|
|
530
|
+
maxChars: Number(tts.maxChars) || 4000,
|
|
531
|
+
voiceSummary: tts.voiceSummary === true,
|
|
532
|
+
},
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
function SettingsPage(props) {
|
|
537
|
+
const ctx = props?.ctx
|
|
538
|
+
const t = props?.t || makeT(props?.locale)
|
|
539
|
+
|
|
540
|
+
const [token, setToken] = React.useState('')
|
|
541
|
+
const [webhookSecret, setWebhookSecret] = React.useState('')
|
|
542
|
+
const [allowText, setAllowText] = React.useState('')
|
|
543
|
+
const [discordToken, setDiscordToken] = React.useState('')
|
|
544
|
+
const [slackToken, setSlackToken] = React.useState('')
|
|
545
|
+
const [discordChannelsText, setDiscordChannelsText] = React.useState('')
|
|
546
|
+
const [updateState, setUpdateState] = React.useState({
|
|
547
|
+
checking: false,
|
|
548
|
+
updating: false,
|
|
549
|
+
currentVersion: '',
|
|
550
|
+
latestVersion: '',
|
|
551
|
+
updateAvailable: false,
|
|
552
|
+
error: '',
|
|
553
|
+
notice: '',
|
|
554
|
+
})
|
|
555
|
+
const [pending, setPending] = React.useState([])
|
|
556
|
+
const [status, setStatus] = React.useState(null)
|
|
557
|
+
const [smokeResult, setSmokeResult] = React.useState(null)
|
|
558
|
+
const [err, setErr] = React.useState('')
|
|
559
|
+
const [msg, setMsg] = React.useState('')
|
|
560
|
+
const [busy, setBusy] = React.useState('')
|
|
561
|
+
const [showAdvanced, setShowAdvanced] = React.useState(false)
|
|
562
|
+
|
|
563
|
+
React.useEffect(() => {
|
|
564
|
+
ensureCss()
|
|
565
|
+
}, [])
|
|
566
|
+
|
|
567
|
+
const scope = React.useMemo(() => {
|
|
568
|
+
const settingsScope = ctx?.get?.('settingsScope') || ctx?.settingsScope
|
|
569
|
+
return settingsScope ? settingsScope.bind({ namespace: NS }) : undefined
|
|
570
|
+
}, [ctx])
|
|
571
|
+
|
|
572
|
+
const snapshot = React.useSyncExternalStore(
|
|
573
|
+
React.useMemo(() => (cb) => (scope ? scope.subscribe(cb) : () => {}), [scope]),
|
|
574
|
+
React.useCallback(() => (scope ? scope.getSnapshot() : { status: 'loading' }), [scope]),
|
|
575
|
+
React.useCallback(() => ({ status: 'loading' }), []),
|
|
576
|
+
)
|
|
577
|
+
|
|
578
|
+
const snapStatus = (snapshot && snapshot.status) || 'loading'
|
|
579
|
+
const stored = (snapshot && snapshot.value) || {}
|
|
580
|
+
const [cfg, setCfg] = React.useState(null)
|
|
581
|
+
|
|
582
|
+
React.useEffect(() => {
|
|
583
|
+
if (snapStatus === 'ready' && cfg === null) {
|
|
584
|
+
setCfg(draftFromStored(stored))
|
|
585
|
+
setAllowText(idsToText(stored?.telegram?.allowedUserIds))
|
|
586
|
+
setDiscordChannelsText(idsToText(stored?.discord?.allowedChannelIds))
|
|
587
|
+
}
|
|
588
|
+
}, [snapStatus, stored, cfg])
|
|
589
|
+
|
|
590
|
+
const loadStatus = React.useCallback(async () => {
|
|
591
|
+
try {
|
|
592
|
+
const res = await fetch(`${ROUTE_PREFIX}/status`, { cache: 'no-store' })
|
|
593
|
+
const data = await res.json().catch(() => ({}))
|
|
594
|
+
if (res.ok && data.ok) {
|
|
595
|
+
setStatus(data)
|
|
596
|
+
}
|
|
597
|
+
} catch (err) {
|
|
598
|
+
console.debug?.('[dsh-messenger-gateway] client status poll error:', err?.message || err)
|
|
599
|
+
}
|
|
600
|
+
}, [])
|
|
601
|
+
|
|
602
|
+
const loadPairing = React.useCallback(async () => {
|
|
603
|
+
try {
|
|
604
|
+
const res = await fetch(`${ROUTE_PREFIX}/pairing`, { credentials: 'same-origin', cache: 'no-store' })
|
|
605
|
+
const data = await res.json().catch(() => ({}))
|
|
606
|
+
if (res.ok && data.ok) setPending(Array.isArray(data.pending) ? data.pending : [])
|
|
607
|
+
} catch (err) {
|
|
608
|
+
console.debug?.('[dsh-messenger-gateway] client pairing poll error:', err?.message || err)
|
|
609
|
+
}
|
|
610
|
+
}, [])
|
|
611
|
+
|
|
612
|
+
React.useEffect(() => {
|
|
613
|
+
loadStatus()
|
|
614
|
+
loadPairing()
|
|
615
|
+
const timer = setInterval(() => {
|
|
616
|
+
loadStatus()
|
|
617
|
+
loadPairing()
|
|
618
|
+
}, 10000)
|
|
619
|
+
return () => clearInterval(timer)
|
|
620
|
+
}, [loadStatus, loadPairing])
|
|
621
|
+
|
|
622
|
+
const loadUpdateStatus = React.useCallback(async () => {
|
|
623
|
+
setUpdateState((s) => ({ ...s, checking: true, error: '' }))
|
|
624
|
+
try {
|
|
625
|
+
const res = await fetch(`${ROUTE_PREFIX}/update`, { cache: 'no-store' })
|
|
626
|
+
const data = await res.json().catch(() => ({}))
|
|
627
|
+
if (res.ok && data.ok) {
|
|
628
|
+
setUpdateState((s) => ({
|
|
629
|
+
...s,
|
|
630
|
+
checking: false,
|
|
631
|
+
currentVersion: data.currentVersion || '',
|
|
632
|
+
latestVersion: data.latestVersion || '',
|
|
633
|
+
updateAvailable: !!data.updateAvailable,
|
|
634
|
+
}))
|
|
635
|
+
} else {
|
|
636
|
+
setUpdateState((s) => ({ ...s, checking: false, error: data.error || `HTTP ${res.status}` }))
|
|
637
|
+
}
|
|
638
|
+
} catch (e) {
|
|
639
|
+
setUpdateState((s) => ({ ...s, checking: false, error: String(e.message || e) }))
|
|
640
|
+
}
|
|
641
|
+
}, [])
|
|
642
|
+
|
|
643
|
+
const handleTriggerUpdate = async () => {
|
|
644
|
+
if (updateState.updating) return
|
|
645
|
+
setUpdateState((s) => ({ ...s, updating: true, error: '', notice: '' }))
|
|
646
|
+
try {
|
|
647
|
+
const res = await fetch(`${ROUTE_PREFIX}/update`, {
|
|
648
|
+
method: 'POST',
|
|
649
|
+
credentials: 'same-origin',
|
|
650
|
+
headers: {
|
|
651
|
+
'Content-Type': 'application/json',
|
|
652
|
+
'x-dsh-plugin-update': '1',
|
|
653
|
+
},
|
|
654
|
+
})
|
|
655
|
+
const data = await res.json().catch(() => ({}))
|
|
656
|
+
if (!res.ok || !data.ok) throw new Error(data.error || `HTTP ${res.status}`)
|
|
657
|
+
setUpdateState((s) => ({
|
|
658
|
+
...s,
|
|
659
|
+
updating: false,
|
|
660
|
+
updateAvailable: false,
|
|
661
|
+
currentVersion: data.updatedVersion || s.latestVersion,
|
|
662
|
+
notice: t('updater.success', { version: data.updatedVersion || s.latestVersion }),
|
|
663
|
+
}))
|
|
664
|
+
} catch (e) {
|
|
665
|
+
setUpdateState((s) => ({
|
|
666
|
+
...s,
|
|
667
|
+
updating: false,
|
|
668
|
+
error: t('updater.failed', { error: String(e.message || e) }),
|
|
669
|
+
}))
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
React.useEffect(() => {
|
|
674
|
+
loadUpdateStatus()
|
|
675
|
+
}, [loadUpdateStatus])
|
|
676
|
+
|
|
677
|
+
const handleSmoke = async () => {
|
|
678
|
+
setBusy('smoke')
|
|
679
|
+
setErr('')
|
|
680
|
+
setMsg('')
|
|
681
|
+
setSmokeResult(null)
|
|
682
|
+
try {
|
|
683
|
+
const res = await fetch(`${ROUTE_PREFIX}/smoke`, {
|
|
684
|
+
method: 'POST',
|
|
685
|
+
credentials: 'same-origin',
|
|
686
|
+
headers: { 'Content-Type': 'application/json' },
|
|
687
|
+
body: JSON.stringify({ timeoutMs: 8000 }),
|
|
688
|
+
})
|
|
689
|
+
const data = await res.json().catch(() => ({}))
|
|
690
|
+
if (!data.ok) throw new Error(data.error || `HTTP ${res.status}`)
|
|
691
|
+
setSmokeResult(data)
|
|
692
|
+
setMsg(t('diag.smoke_ok', { latency: data.latencyMs, username: data.botUsername, id: data.botId }))
|
|
693
|
+
await loadStatus()
|
|
694
|
+
} catch (e) {
|
|
695
|
+
setErr(t('diag.smoke_err', { error: String(e.message || e) }))
|
|
696
|
+
} finally {
|
|
697
|
+
setBusy('')
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
const mergePatch = (base, patch) => ({
|
|
702
|
+
...base,
|
|
703
|
+
...patch,
|
|
704
|
+
telegram: { ...base.telegram, ...(patch.telegram || {}) },
|
|
705
|
+
discord: { ...base.discord, ...(patch.discord || {}) },
|
|
706
|
+
slack: { ...base.slack, ...(patch.slack || {}) },
|
|
707
|
+
tts: { ...base.tts, ...(patch.tts || {}) },
|
|
708
|
+
agent: { ...base.agent, ...(patch.agent || {}) },
|
|
709
|
+
media: { ...base.media, ...(patch.media || {}) },
|
|
710
|
+
})
|
|
711
|
+
|
|
712
|
+
const save = async (patch = {}) => {
|
|
713
|
+
if (!scope || !cfg) return
|
|
714
|
+
setBusy('save')
|
|
715
|
+
setErr('')
|
|
716
|
+
setMsg('')
|
|
717
|
+
try {
|
|
718
|
+
let next = mergePatch(cfg, patch)
|
|
719
|
+
if (token.trim()) next.telegram = { ...next.telegram, botToken: token.trim() }
|
|
720
|
+
if (webhookSecret.trim()) next.telegram = { ...next.telegram, webhookSecret: webhookSecret.trim() }
|
|
721
|
+
next.telegram.allowedUserIds = textToIds(allowText)
|
|
722
|
+
if (discordToken.trim()) next.discord = { ...next.discord, botToken: discordToken.trim() }
|
|
723
|
+
if (slackToken.trim()) next.slack = { ...next.slack, botToken: slackToken.trim() }
|
|
724
|
+
next.discord.allowedChannelIds = textToIds(discordChannelsText)
|
|
725
|
+
|
|
726
|
+
const broken = []
|
|
727
|
+
for (const key of SETTINGS_KEYS) {
|
|
728
|
+
if (next[key] !== undefined) {
|
|
729
|
+
try {
|
|
730
|
+
await scope.set(key, next[key])
|
|
731
|
+
} catch (e) {
|
|
732
|
+
broken.push(key + ': ' + (e && e.message || String(e)))
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
if (broken.length) {
|
|
737
|
+
setErr('Save failed — ' + broken.join('; '))
|
|
738
|
+
return
|
|
739
|
+
}
|
|
740
|
+
setCfg(next)
|
|
741
|
+
setToken('')
|
|
742
|
+
setWebhookSecret('')
|
|
743
|
+
setDiscordToken('')
|
|
744
|
+
setSlackToken('')
|
|
745
|
+
setMsg(t('saved'))
|
|
746
|
+
setTimeout(() => setMsg(''), 3000)
|
|
747
|
+
await loadPairing()
|
|
748
|
+
await loadStatus()
|
|
749
|
+
} catch (e) {
|
|
750
|
+
setErr(String(e.message || e))
|
|
751
|
+
} finally {
|
|
752
|
+
setBusy('')
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
if (snapStatus === 'loading') {
|
|
757
|
+
return React.createElement('div', { className: 'msgw-page' }, t('settings.loading'))
|
|
758
|
+
}
|
|
759
|
+
if (snapStatus !== 'ready') {
|
|
760
|
+
return React.createElement('div', { className: 'msgw-page' },
|
|
761
|
+
React.createElement('div', { className: 'msgw-banner-warning' }, t('settings.unavailable'))
|
|
762
|
+
)
|
|
763
|
+
}
|
|
764
|
+
if (!cfg) {
|
|
765
|
+
return React.createElement('div', { className: 'msgw-page' }, t('settings.loading'))
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
const isRunning = Boolean(status?.running)
|
|
769
|
+
const botUsername = status?.botUsername || (status?.config?.telegram?.botUsername) || ''
|
|
770
|
+
const hasToken = Boolean(status?.config?.telegram?.botTokenConfigured || cfg.telegram?.botTokenConfigured || token.trim())
|
|
771
|
+
const transportMode = cfg.telegram?.transport || 'poll'
|
|
772
|
+
const pendingCount = pending.length
|
|
773
|
+
|
|
774
|
+
return React.createElement(
|
|
775
|
+
'div',
|
|
776
|
+
{ className: 'msgw-page' },
|
|
777
|
+
|
|
778
|
+
// Header with badges
|
|
779
|
+
React.createElement(
|
|
780
|
+
'div',
|
|
781
|
+
{ className: 'msgw-header' },
|
|
782
|
+
React.createElement(
|
|
783
|
+
'div',
|
|
784
|
+
{ className: 'msgw-page-title' },
|
|
785
|
+
`💬 ${t('header.title')}`,
|
|
786
|
+
React.createElement(
|
|
787
|
+
'span',
|
|
788
|
+
{ className: `msgw-badge ${isRunning ? 'msgw-badge-ok' : 'msgw-badge-bad'}` },
|
|
789
|
+
isRunning
|
|
790
|
+
? (botUsername ? t('badge.online', { username: botUsername }) : t('badge.running'))
|
|
791
|
+
: t('badge.stopped')
|
|
792
|
+
),
|
|
793
|
+
React.createElement(
|
|
794
|
+
'span',
|
|
795
|
+
{ className: `msgw-badge ${hasToken ? 'msgw-badge-ok' : 'msgw-badge-warn'}` },
|
|
796
|
+
hasToken ? t('badge.token_ok') : t('badge.token_missing')
|
|
797
|
+
),
|
|
798
|
+
React.createElement(
|
|
799
|
+
'span',
|
|
800
|
+
{ className: 'msgw-badge msgw-badge-ok' },
|
|
801
|
+
t('badge.transport', { mode: transportMode })
|
|
802
|
+
),
|
|
803
|
+
pendingCount > 0
|
|
804
|
+
? React.createElement(
|
|
805
|
+
'span',
|
|
806
|
+
{ className: 'msgw-badge msgw-badge-warn' },
|
|
807
|
+
t('badge.pairing_count', { count: pendingCount })
|
|
808
|
+
)
|
|
809
|
+
: null,
|
|
810
|
+
(status?.scheduledCount > 0)
|
|
811
|
+
? React.createElement(
|
|
812
|
+
'span',
|
|
813
|
+
{ className: 'msgw-badge msgw-badge-ok' },
|
|
814
|
+
t('badge.cron_count', { count: status.scheduledCount })
|
|
815
|
+
)
|
|
816
|
+
: null,
|
|
817
|
+
status?.apiHealth?.degraded
|
|
818
|
+
? React.createElement(
|
|
819
|
+
'span',
|
|
820
|
+
{ className: 'msgw-badge msgw-badge-bad' },
|
|
821
|
+
t('badge.api_degraded', { count: status.apiHealth.consecutiveFailures })
|
|
822
|
+
)
|
|
823
|
+
: null
|
|
824
|
+
),
|
|
825
|
+
React.createElement('div', { className: 'msgw-page-sub' }, t('header.sub'))
|
|
826
|
+
),
|
|
827
|
+
|
|
828
|
+
// Global Alert banners
|
|
829
|
+
err ? React.createElement('div', { className: 'msgw-alert-err' }, err) : null,
|
|
830
|
+
msg ? React.createElement('div', { className: 'msgw-alert-ok' }, msg) : null,
|
|
831
|
+
|
|
832
|
+
// Self-Updater Card
|
|
833
|
+
React.createElement(
|
|
834
|
+
'div',
|
|
835
|
+
{ className: 'msgw-section-card' },
|
|
836
|
+
React.createElement(
|
|
837
|
+
'div',
|
|
838
|
+
{ className: 'msgw-section-title' },
|
|
839
|
+
React.createElement('span', null, `🚀 ${t('updater.title')}`),
|
|
840
|
+
React.createElement(
|
|
841
|
+
'div',
|
|
842
|
+
{ className: 'msgw-row' },
|
|
843
|
+
React.createElement(
|
|
844
|
+
'button',
|
|
845
|
+
{
|
|
846
|
+
type: 'button',
|
|
847
|
+
className: 'msgw-btn msgw-btn-mini',
|
|
848
|
+
disabled: updateState.checking || updateState.updating,
|
|
849
|
+
onClick: loadUpdateStatus,
|
|
850
|
+
},
|
|
851
|
+
updateState.checking ? t('updater.checking') : t('updater.btn_check')
|
|
852
|
+
),
|
|
853
|
+
updateState.updateAvailable
|
|
854
|
+
? React.createElement(
|
|
855
|
+
'button',
|
|
856
|
+
{
|
|
857
|
+
type: 'button',
|
|
858
|
+
className: 'msgw-btn msgw-btn-mini msgw-btn-primary',
|
|
859
|
+
disabled: updateState.updating,
|
|
860
|
+
onClick: handleTriggerUpdate,
|
|
861
|
+
},
|
|
862
|
+
updateState.updating ? t('updater.updating') : t('updater.btn_update', { version: updateState.latestVersion })
|
|
863
|
+
)
|
|
864
|
+
: null
|
|
865
|
+
)
|
|
866
|
+
),
|
|
867
|
+
React.createElement('div', { className: 'msgw-section-desc' }, t('updater.desc')),
|
|
868
|
+
React.createElement(
|
|
869
|
+
'div',
|
|
870
|
+
{ className: 'msgw-row', style: { fontSize: '13px' } },
|
|
871
|
+
React.createElement('span', { style: { color: 'var(--dsw-alias-label-secondary)' } },
|
|
872
|
+
t('updater.current', { version: updateState.currentVersion || status?.version || '...' })
|
|
873
|
+
),
|
|
874
|
+
updateState.checking
|
|
875
|
+
? React.createElement('span', { className: 'msgw-badge msgw-badge-warn' }, t('updater.checking'))
|
|
876
|
+
: updateState.updateAvailable
|
|
877
|
+
? React.createElement('span', { className: 'msgw-badge msgw-badge-warn' }, t('updater.available', { version: updateState.latestVersion }))
|
|
878
|
+
: updateState.currentVersion && !updateState.error
|
|
879
|
+
? React.createElement('span', { className: 'msgw-badge msgw-badge-ok' }, `✓ ${t('updater.upToDate')}`)
|
|
880
|
+
: null
|
|
881
|
+
),
|
|
882
|
+
updateState.notice ? React.createElement('div', { className: 'msgw-alert-ok' }, updateState.notice) : null,
|
|
883
|
+
updateState.error ? React.createElement('div', { className: 'msgw-alert-err' }, updateState.error) : null
|
|
884
|
+
),
|
|
885
|
+
|
|
886
|
+
// Card 1: Telegram Connection & Bot
|
|
887
|
+
React.createElement(
|
|
888
|
+
'div',
|
|
889
|
+
{ className: 'msgw-section-card' },
|
|
890
|
+
React.createElement(
|
|
891
|
+
'div',
|
|
892
|
+
{ className: 'msgw-section-title' },
|
|
893
|
+
React.createElement('span', null, `🤖 ${t('telegram')}`),
|
|
894
|
+
React.createElement(
|
|
895
|
+
'button',
|
|
896
|
+
{
|
|
897
|
+
type: 'button',
|
|
898
|
+
className: `msgw-btn msgw-btn-mini ${cfg.telegram.enabled ? 'msgw-btn-danger' : 'msgw-btn-primary'}`,
|
|
899
|
+
disabled: !!busy,
|
|
900
|
+
onClick: () => save({ telegram: { enabled: !cfg.telegram.enabled } }),
|
|
901
|
+
},
|
|
902
|
+
cfg.telegram.enabled ? t('disableTelegram') : t('enableTelegram')
|
|
903
|
+
)
|
|
904
|
+
),
|
|
905
|
+
React.createElement('div', { className: 'msgw-section-desc' }, t('telegramSub')),
|
|
906
|
+
React.createElement(Field, { label: t('botToken'), hint: t('botTokenHint') },
|
|
907
|
+
React.createElement('input', {
|
|
908
|
+
type: 'password',
|
|
909
|
+
className: 'msgw-input',
|
|
910
|
+
value: token,
|
|
911
|
+
placeholder: hasToken ? '••••••••••••••••••••' : '123456789:ABCdefGHI...',
|
|
912
|
+
onChange: (e) => setToken(e.target.value),
|
|
913
|
+
})
|
|
914
|
+
),
|
|
915
|
+
React.createElement(Field, { label: t('allowedIds'), hint: t('allowedIdsHint') },
|
|
916
|
+
React.createElement('textarea', {
|
|
917
|
+
className: 'msgw-textarea',
|
|
918
|
+
value: allowText,
|
|
919
|
+
onChange: (e) => setAllowText(e.target.value),
|
|
920
|
+
rows: 2,
|
|
921
|
+
placeholder: '108191529, 987654321',
|
|
922
|
+
})
|
|
923
|
+
),
|
|
924
|
+
React.createElement(Field, { label: t('textFormat') },
|
|
925
|
+
React.createElement(
|
|
926
|
+
'select',
|
|
927
|
+
{
|
|
928
|
+
className: 'msgw-select',
|
|
929
|
+
value: cfg.telegram?.textFormat || 'html',
|
|
930
|
+
onChange: (e) => setCfg({ ...cfg, telegram: { ...cfg.telegram, textFormat: e.target.value } }),
|
|
931
|
+
},
|
|
932
|
+
React.createElement('option', { value: 'html' }, t('textFormatHtml')),
|
|
933
|
+
React.createElement('option', { value: 'plain' }, t('textFormatPlain'))
|
|
934
|
+
)
|
|
935
|
+
),
|
|
936
|
+
React.createElement('label', { className: 'msgw-check' },
|
|
937
|
+
React.createElement('input', {
|
|
938
|
+
type: 'checkbox',
|
|
939
|
+
checked: cfg.telegram?.groupsEnabled !== false,
|
|
940
|
+
onChange: (e) => setCfg({ ...cfg, telegram: { ...cfg.telegram, groupsEnabled: e.target.checked } }),
|
|
941
|
+
}),
|
|
942
|
+
t('groupsEnable')
|
|
943
|
+
),
|
|
944
|
+
React.createElement('label', { className: 'msgw-check' },
|
|
945
|
+
React.createElement('input', {
|
|
946
|
+
type: 'checkbox',
|
|
947
|
+
checked: cfg.telegram?.groupRequireMention !== false,
|
|
948
|
+
onChange: (e) => setCfg({ ...cfg, telegram: { ...cfg.telegram, groupRequireMention: e.target.checked } }),
|
|
949
|
+
}),
|
|
950
|
+
t('groupMention')
|
|
951
|
+
),
|
|
952
|
+
React.createElement('label', { className: 'msgw-check' },
|
|
953
|
+
React.createElement('input', {
|
|
954
|
+
type: 'checkbox',
|
|
955
|
+
checked: cfg.telegram?.reactionsEnabled !== false,
|
|
956
|
+
onChange: (e) => setCfg({ ...cfg, telegram: { ...cfg.telegram, reactionsEnabled: e.target.checked } }),
|
|
957
|
+
}),
|
|
958
|
+
t('reactionsEnable')
|
|
959
|
+
),
|
|
960
|
+
React.createElement('label', { className: 'msgw-check' },
|
|
961
|
+
React.createElement('input', {
|
|
962
|
+
type: 'checkbox',
|
|
963
|
+
checked: cfg.telegram?.progressEnabled !== false,
|
|
964
|
+
onChange: (e) => setCfg({ ...cfg, telegram: { ...cfg.telegram, progressEnabled: e.target.checked } }),
|
|
965
|
+
}),
|
|
966
|
+
t('progressEnable')
|
|
967
|
+
),
|
|
968
|
+
React.createElement('label', { className: 'msgw-check' },
|
|
969
|
+
React.createElement('input', {
|
|
970
|
+
type: 'checkbox',
|
|
971
|
+
checked: cfg.telegram?.quickActions !== false,
|
|
972
|
+
onChange: (e) => setCfg({ ...cfg, telegram: { ...cfg.telegram, quickActions: e.target.checked } }),
|
|
973
|
+
}),
|
|
974
|
+
t('quickActions')
|
|
975
|
+
),
|
|
976
|
+
React.createElement('label', { className: 'msgw-check' },
|
|
977
|
+
React.createElement('input', {
|
|
978
|
+
type: 'checkbox',
|
|
979
|
+
checked: cfg.telegram?.artifactPreviews !== false,
|
|
980
|
+
onChange: (e) => setCfg({ ...cfg, telegram: { ...cfg.telegram, artifactPreviews: e.target.checked } }),
|
|
981
|
+
}),
|
|
982
|
+
t('artifactPreviews')
|
|
983
|
+
)
|
|
984
|
+
),
|
|
985
|
+
|
|
986
|
+
// Card 2: Diagnostics & Telegram Smoke Test
|
|
987
|
+
React.createElement(
|
|
988
|
+
'div',
|
|
989
|
+
{ className: 'msgw-section-card' },
|
|
990
|
+
React.createElement('div', { className: 'msgw-section-title' }, t('diag.title')),
|
|
991
|
+
React.createElement('div', { className: 'msgw-section-desc' }, t('diag.desc')),
|
|
992
|
+
React.createElement(
|
|
993
|
+
'div',
|
|
994
|
+
{ className: 'msgw-row' },
|
|
995
|
+
React.createElement(
|
|
996
|
+
'button',
|
|
997
|
+
{
|
|
998
|
+
type: 'button',
|
|
999
|
+
className: 'msgw-btn msgw-btn-primary',
|
|
1000
|
+
disabled: !!busy || !hasToken,
|
|
1001
|
+
onClick: handleSmoke,
|
|
1002
|
+
},
|
|
1003
|
+
busy === 'smoke' ? t('diag.smoke_testing') : t('diag.smoke_btn')
|
|
1004
|
+
)
|
|
1005
|
+
),
|
|
1006
|
+
smokeResult
|
|
1007
|
+
? React.createElement(
|
|
1008
|
+
'div',
|
|
1009
|
+
{ className: 'msgw-preview' },
|
|
1010
|
+
`✅ Latency: ${smokeResult.latencyMs} ms | Bot: @${smokeResult.botUsername || 'unknown'} (ID: ${smokeResult.botId})`
|
|
1011
|
+
)
|
|
1012
|
+
: null
|
|
1013
|
+
),
|
|
1014
|
+
|
|
1015
|
+
// Card 3: Telemetry & Gateway Counters
|
|
1016
|
+
status?.stats ? React.createElement(
|
|
1017
|
+
'div',
|
|
1018
|
+
{ className: 'msgw-section-card' },
|
|
1019
|
+
React.createElement('div', { className: 'msgw-section-title' }, t('stats.title')),
|
|
1020
|
+
React.createElement('div', { className: 'msgw-section-desc' }, t('stats.desc')),
|
|
1021
|
+
React.createElement(
|
|
1022
|
+
'div',
|
|
1023
|
+
{ className: 'msgw-stat-grid' },
|
|
1024
|
+
React.createElement(
|
|
1025
|
+
'div',
|
|
1026
|
+
{ className: 'msgw-stat-box' },
|
|
1027
|
+
React.createElement('div', { className: 'msgw-stat-val' }, String(status.stats.sent || 0)),
|
|
1028
|
+
React.createElement('div', { className: 'msgw-stat-lbl' }, t('stats.sent'))
|
|
1029
|
+
),
|
|
1030
|
+
React.createElement(
|
|
1031
|
+
'div',
|
|
1032
|
+
{ className: 'msgw-stat-box' },
|
|
1033
|
+
React.createElement('div', { className: 'msgw-stat-val' }, String(status.stats.errors || 0)),
|
|
1034
|
+
React.createElement('div', { className: 'msgw-stat-lbl' }, t('stats.errors'))
|
|
1035
|
+
),
|
|
1036
|
+
React.createElement(
|
|
1037
|
+
'div',
|
|
1038
|
+
{ className: 'msgw-stat-box' },
|
|
1039
|
+
React.createElement('div', { className: 'msgw-stat-val' }, String(status.activeChats || 0)),
|
|
1040
|
+
React.createElement('div', { className: 'msgw-stat-lbl' }, t('stats.active_chats'))
|
|
1041
|
+
),
|
|
1042
|
+
React.createElement(
|
|
1043
|
+
'div',
|
|
1044
|
+
{ className: 'msgw-stat-box' },
|
|
1045
|
+
React.createElement('div', { className: 'msgw-stat-val' }, `${status.uptimeSec || 0}s`),
|
|
1046
|
+
React.createElement('div', { className: 'msgw-stat-lbl' }, t('stats.uptime'))
|
|
1047
|
+
)
|
|
1048
|
+
)
|
|
1049
|
+
) : null,
|
|
1050
|
+
|
|
1051
|
+
// Card 4: Agent & Turn Execution
|
|
1052
|
+
React.createElement(
|
|
1053
|
+
'div',
|
|
1054
|
+
{ className: 'msgw-section-card' },
|
|
1055
|
+
React.createElement('div', { className: 'msgw-section-title' }, `🧠 ${t('agent')}`),
|
|
1056
|
+
React.createElement('div', { className: 'msgw-section-desc' }, t('agentSub')),
|
|
1057
|
+
React.createElement(Field, { label: t('provider'), hint: t('providerHint') },
|
|
1058
|
+
React.createElement('input', {
|
|
1059
|
+
className: 'msgw-input',
|
|
1060
|
+
value: cfg.agent?.provider || '',
|
|
1061
|
+
onChange: (e) => setCfg({ ...cfg, agent: { ...cfg.agent, provider: e.target.value } }),
|
|
1062
|
+
})
|
|
1063
|
+
),
|
|
1064
|
+
React.createElement(Field, { label: t('model'), hint: t('modelHint') },
|
|
1065
|
+
React.createElement('input', {
|
|
1066
|
+
className: 'msgw-input',
|
|
1067
|
+
value: cfg.agent?.model || '',
|
|
1068
|
+
onChange: (e) => setCfg({ ...cfg, agent: { ...cfg.agent, model: e.target.value } }),
|
|
1069
|
+
})
|
|
1070
|
+
),
|
|
1071
|
+
React.createElement(Field, { label: t('photoOnly') },
|
|
1072
|
+
React.createElement(
|
|
1073
|
+
'select',
|
|
1074
|
+
{
|
|
1075
|
+
className: 'msgw-select',
|
|
1076
|
+
value: cfg.agent?.photoOnlyMode || 'prompt',
|
|
1077
|
+
onChange: (e) => setCfg({ ...cfg, agent: { ...cfg.agent, photoOnlyMode: e.target.value } }),
|
|
1078
|
+
},
|
|
1079
|
+
React.createElement('option', { value: 'prompt' }, t('photoPrompt')),
|
|
1080
|
+
React.createElement('option', { value: 'run' }, t('photoRun'))
|
|
1081
|
+
)
|
|
1082
|
+
),
|
|
1083
|
+
React.createElement(Field, { label: t('sessionScope') },
|
|
1084
|
+
React.createElement(
|
|
1085
|
+
'select',
|
|
1086
|
+
{
|
|
1087
|
+
className: 'msgw-select',
|
|
1088
|
+
value: cfg.agent?.sessionScope || 'user',
|
|
1089
|
+
onChange: (e) => setCfg({ ...cfg, agent: { ...cfg.agent, sessionScope: e.target.value } }),
|
|
1090
|
+
},
|
|
1091
|
+
React.createElement('option', { value: 'user' }, t('sessionScopeUser')),
|
|
1092
|
+
React.createElement('option', { value: 'chat' }, t('sessionScopeChat'))
|
|
1093
|
+
)
|
|
1094
|
+
),
|
|
1095
|
+
React.createElement(Field, { label: t('instruction'), hint: t('instructionHint') },
|
|
1096
|
+
React.createElement('textarea', {
|
|
1097
|
+
className: 'msgw-textarea',
|
|
1098
|
+
value: cfg.agent?.instructionPrefix || '',
|
|
1099
|
+
onChange: (e) => setCfg({ ...cfg, agent: { ...cfg.agent, instructionPrefix: e.target.value } }),
|
|
1100
|
+
rows: 3,
|
|
1101
|
+
placeholder: t('instructionPlaceholder'),
|
|
1102
|
+
})
|
|
1103
|
+
),
|
|
1104
|
+
React.createElement(Field, { label: t('maxMessageLength') },
|
|
1105
|
+
React.createElement('input', {
|
|
1106
|
+
type: 'number',
|
|
1107
|
+
className: 'msgw-input',
|
|
1108
|
+
min: 500,
|
|
1109
|
+
max: 8000,
|
|
1110
|
+
value: cfg.agent?.maxMessageLength ?? 4000,
|
|
1111
|
+
onChange: (e) => setCfg({ ...cfg, agent: { ...cfg.agent, maxMessageLength: Number(e.target.value) || 4000 } }),
|
|
1112
|
+
})
|
|
1113
|
+
),
|
|
1114
|
+
React.createElement(Field, { label: t('turnTimeout') },
|
|
1115
|
+
React.createElement('input', {
|
|
1116
|
+
type: 'number',
|
|
1117
|
+
className: 'msgw-input',
|
|
1118
|
+
min: 30,
|
|
1119
|
+
max: 3600,
|
|
1120
|
+
value: Math.round((cfg.agent?.turnTimeoutMs ?? 600000) / 1000),
|
|
1121
|
+
onChange: (e) => setCfg({ ...cfg, agent: { ...cfg.agent, turnTimeoutMs: (Number(e.target.value) || 600) * 1000 } }),
|
|
1122
|
+
})
|
|
1123
|
+
)
|
|
1124
|
+
),
|
|
1125
|
+
|
|
1126
|
+
// Card 5: Media & TTS
|
|
1127
|
+
React.createElement(
|
|
1128
|
+
'div',
|
|
1129
|
+
{ className: 'msgw-section-card' },
|
|
1130
|
+
React.createElement('div', { className: 'msgw-section-title' }, `📎 ${t('media')}`),
|
|
1131
|
+
React.createElement('div', { className: 'msgw-section-desc' }, t('mediaSub')),
|
|
1132
|
+
React.createElement(Field, { label: t('maxDocMb') },
|
|
1133
|
+
React.createElement('input', {
|
|
1134
|
+
type: 'number',
|
|
1135
|
+
className: 'msgw-input',
|
|
1136
|
+
min: 1,
|
|
1137
|
+
max: 50,
|
|
1138
|
+
value: bytesToMb(cfg.media?.maxDocBytes),
|
|
1139
|
+
onChange: (e) => setCfg({ ...cfg, media: { ...cfg.media, maxDocBytes: mbToBytes(e.target.value) } }),
|
|
1140
|
+
})
|
|
1141
|
+
),
|
|
1142
|
+
React.createElement(Field, { label: t('maxImageMb') },
|
|
1143
|
+
React.createElement('input', {
|
|
1144
|
+
type: 'number',
|
|
1145
|
+
className: 'msgw-input',
|
|
1146
|
+
min: 1,
|
|
1147
|
+
max: 50,
|
|
1148
|
+
value: bytesToMb(cfg.media?.maxImageBytes),
|
|
1149
|
+
onChange: (e) => setCfg({ ...cfg, media: { ...cfg.media, maxImageBytes: mbToBytes(e.target.value) } }),
|
|
1150
|
+
})
|
|
1151
|
+
),
|
|
1152
|
+
React.createElement(Field, { label: t('maxTextKb') },
|
|
1153
|
+
React.createElement('input', {
|
|
1154
|
+
type: 'number',
|
|
1155
|
+
className: 'msgw-input',
|
|
1156
|
+
min: 16,
|
|
1157
|
+
max: 512,
|
|
1158
|
+
value: Math.round((cfg.media?.maxTextInjectBytes ?? 102400) / 1024),
|
|
1159
|
+
onChange: (e) => setCfg({ ...cfg, media: { ...cfg.media, maxTextInjectBytes: (Number(e.target.value) || 100) * 1024 } }),
|
|
1160
|
+
})
|
|
1161
|
+
),
|
|
1162
|
+
React.createElement('div', { style: { height: '8px' } }),
|
|
1163
|
+
React.createElement('div', { className: 'msgw-section-title' }, `🔊 ${t('tts')}`),
|
|
1164
|
+
React.createElement('div', { className: 'msgw-section-desc' }, t('ttsSub')),
|
|
1165
|
+
React.createElement('label', { className: 'msgw-check' },
|
|
1166
|
+
React.createElement('input', {
|
|
1167
|
+
type: 'checkbox',
|
|
1168
|
+
checked: !!cfg.tts?.enabled,
|
|
1169
|
+
onChange: (e) => setCfg({ ...cfg, tts: { ...cfg.tts, enabled: e.target.checked } }),
|
|
1170
|
+
}),
|
|
1171
|
+
t('ttsEnable')
|
|
1172
|
+
),
|
|
1173
|
+
cfg.tts?.enabled ? React.createElement(Field, { label: t('ttsMaxChars') },
|
|
1174
|
+
React.createElement('input', {
|
|
1175
|
+
type: 'number',
|
|
1176
|
+
className: 'msgw-input',
|
|
1177
|
+
min: 100,
|
|
1178
|
+
max: 8000,
|
|
1179
|
+
value: cfg.tts?.maxChars ?? 4000,
|
|
1180
|
+
onChange: (e) => setCfg({ ...cfg, tts: { ...cfg.tts, maxChars: Number(e.target.value) || 4000 } }),
|
|
1181
|
+
})
|
|
1182
|
+
) : null,
|
|
1183
|
+
React.createElement(Field, { label: t('voiceMode') },
|
|
1184
|
+
React.createElement(
|
|
1185
|
+
'select',
|
|
1186
|
+
{
|
|
1187
|
+
className: 'msgw-select',
|
|
1188
|
+
value: cfg.telegram?.voiceMode || 'mirror',
|
|
1189
|
+
onChange: (e) => setCfg({ ...cfg, telegram: { ...cfg.telegram, voiceMode: e.target.value } }),
|
|
1190
|
+
},
|
|
1191
|
+
React.createElement('option', { value: 'mirror' }, t('voiceModeMirror')),
|
|
1192
|
+
React.createElement('option', { value: 'always' }, t('voiceModeAlways')),
|
|
1193
|
+
React.createElement('option', { value: 'off' }, t('voiceModeOff'))
|
|
1194
|
+
)
|
|
1195
|
+
)
|
|
1196
|
+
),
|
|
1197
|
+
|
|
1198
|
+
// Card: Discord Gateway
|
|
1199
|
+
React.createElement(
|
|
1200
|
+
'div',
|
|
1201
|
+
{ className: 'msgw-section-card' },
|
|
1202
|
+
React.createElement(
|
|
1203
|
+
'div',
|
|
1204
|
+
{ className: 'msgw-section-title' },
|
|
1205
|
+
React.createElement('span', null, `🎮 ${t('discord')}`),
|
|
1206
|
+
React.createElement(
|
|
1207
|
+
'button',
|
|
1208
|
+
{
|
|
1209
|
+
type: 'button',
|
|
1210
|
+
className: `msgw-btn msgw-btn-mini ${cfg.discord?.enabled ? 'msgw-btn-danger' : 'msgw-btn-primary'}`,
|
|
1211
|
+
disabled: !!busy,
|
|
1212
|
+
onClick: () => save({ discord: { enabled: !cfg.discord?.enabled } }),
|
|
1213
|
+
},
|
|
1214
|
+
cfg.discord?.enabled ? t('disableDiscord') : t('enableDiscord')
|
|
1215
|
+
)
|
|
1216
|
+
),
|
|
1217
|
+
React.createElement('div', { className: 'msgw-section-desc' }, t('discordSub')),
|
|
1218
|
+
React.createElement(Field, { label: t('discordToken'), hint: t('discordTokenHint') },
|
|
1219
|
+
React.createElement('input', {
|
|
1220
|
+
type: 'password',
|
|
1221
|
+
className: 'msgw-input',
|
|
1222
|
+
value: discordToken,
|
|
1223
|
+
placeholder: (status?.config?.discord?.botTokenConfigured || cfg.discord?.botTokenConfigured) ? '••••••••••••••••' : 'Discord Bot Token',
|
|
1224
|
+
onChange: (e) => setDiscordToken(e.target.value),
|
|
1225
|
+
})
|
|
1226
|
+
),
|
|
1227
|
+
React.createElement(Field, { label: t('discordWebhook'), hint: t('discordWebhookHint') },
|
|
1228
|
+
React.createElement('input', {
|
|
1229
|
+
className: 'msgw-input',
|
|
1230
|
+
value: cfg.discord?.webhookUrl || '',
|
|
1231
|
+
placeholder: 'https://discord.com/api/webhooks/...',
|
|
1232
|
+
onChange: (e) => setCfg({ ...cfg, discord: { ...cfg.discord, webhookUrl: e.target.value } }),
|
|
1233
|
+
})
|
|
1234
|
+
),
|
|
1235
|
+
React.createElement(Field, { label: t('discordChannels'), hint: t('discordChannelsHint') },
|
|
1236
|
+
React.createElement('textarea', {
|
|
1237
|
+
className: 'msgw-textarea',
|
|
1238
|
+
value: discordChannelsText,
|
|
1239
|
+
onChange: (e) => setDiscordChannelsText(e.target.value),
|
|
1240
|
+
rows: 2,
|
|
1241
|
+
placeholder: '123456789012345678, 987654321098765432',
|
|
1242
|
+
})
|
|
1243
|
+
)
|
|
1244
|
+
),
|
|
1245
|
+
|
|
1246
|
+
// Card: Slack Gateway
|
|
1247
|
+
React.createElement(
|
|
1248
|
+
'div',
|
|
1249
|
+
{ className: 'msgw-section-card' },
|
|
1250
|
+
React.createElement(
|
|
1251
|
+
'div',
|
|
1252
|
+
{ className: 'msgw-section-title' },
|
|
1253
|
+
React.createElement('span', null, `💼 ${t('slack')}`),
|
|
1254
|
+
React.createElement(
|
|
1255
|
+
'button',
|
|
1256
|
+
{
|
|
1257
|
+
type: 'button',
|
|
1258
|
+
className: `msgw-btn msgw-btn-mini ${cfg.slack?.enabled ? 'msgw-btn-danger' : 'msgw-btn-primary'}`,
|
|
1259
|
+
disabled: !!busy,
|
|
1260
|
+
onClick: () => save({ slack: { enabled: !cfg.slack?.enabled } }),
|
|
1261
|
+
},
|
|
1262
|
+
cfg.slack?.enabled ? t('disableSlack') : t('enableSlack')
|
|
1263
|
+
)
|
|
1264
|
+
),
|
|
1265
|
+
React.createElement('div', { className: 'msgw-section-desc' }, t('slackSub')),
|
|
1266
|
+
React.createElement(Field, { label: t('slackToken'), hint: t('slackTokenHint') },
|
|
1267
|
+
React.createElement('input', {
|
|
1268
|
+
type: 'password',
|
|
1269
|
+
className: 'msgw-input',
|
|
1270
|
+
value: slackToken,
|
|
1271
|
+
placeholder: (status?.config?.slack?.botTokenConfigured || cfg.slack?.botTokenConfigured) ? '••••••••••••••••' : 'xoxb-...',
|
|
1272
|
+
onChange: (e) => setSlackToken(e.target.value),
|
|
1273
|
+
})
|
|
1274
|
+
),
|
|
1275
|
+
React.createElement(Field, { label: t('slackWebhook'), hint: t('slackWebhookHint') },
|
|
1276
|
+
React.createElement('input', {
|
|
1277
|
+
className: 'msgw-input',
|
|
1278
|
+
value: cfg.slack?.webhookUrl || '',
|
|
1279
|
+
placeholder: 'https://hooks.slack.com/services/...',
|
|
1280
|
+
onChange: (e) => setCfg({ ...cfg, slack: { ...cfg.slack, webhookUrl: e.target.value } }),
|
|
1281
|
+
})
|
|
1282
|
+
),
|
|
1283
|
+
React.createElement(Field, { label: t('slackDefaultChannel'), hint: t('slackDefaultChannelHint') },
|
|
1284
|
+
React.createElement('input', {
|
|
1285
|
+
className: 'msgw-input',
|
|
1286
|
+
value: cfg.slack?.defaultChannel || '',
|
|
1287
|
+
placeholder: '#general or C12345678',
|
|
1288
|
+
onChange: (e) => setCfg({ ...cfg, slack: { ...cfg.slack, defaultChannel: e.target.value } }),
|
|
1289
|
+
})
|
|
1290
|
+
)
|
|
1291
|
+
),
|
|
1292
|
+
|
|
1293
|
+
// Card 6: Pairing Requests
|
|
1294
|
+
React.createElement(
|
|
1295
|
+
'div',
|
|
1296
|
+
{ className: 'msgw-section-card' },
|
|
1297
|
+
React.createElement(
|
|
1298
|
+
'div',
|
|
1299
|
+
{ className: 'msgw-section-title' },
|
|
1300
|
+
React.createElement('span', null, `🔑 ${t('pairing')}`),
|
|
1301
|
+
React.createElement(
|
|
1302
|
+
'button',
|
|
1303
|
+
{
|
|
1304
|
+
type: 'button',
|
|
1305
|
+
className: 'msgw-btn msgw-btn-mini',
|
|
1306
|
+
disabled: !!busy,
|
|
1307
|
+
onClick: loadPairing,
|
|
1308
|
+
},
|
|
1309
|
+
t('pairingRefresh')
|
|
1310
|
+
)
|
|
1311
|
+
),
|
|
1312
|
+
React.createElement('div', { className: 'msgw-section-desc' }, t('pairingSub')),
|
|
1313
|
+
!(pending && pending.length)
|
|
1314
|
+
? React.createElement('div', { className: 'msgw-hint' }, t('pairingEmpty'))
|
|
1315
|
+
: React.createElement(
|
|
1316
|
+
'table',
|
|
1317
|
+
{ className: 'msgw-table' },
|
|
1318
|
+
React.createElement(
|
|
1319
|
+
'tbody',
|
|
1320
|
+
null,
|
|
1321
|
+
pending.map((row) =>
|
|
1322
|
+
React.createElement(
|
|
1323
|
+
'tr',
|
|
1324
|
+
{ key: row.code },
|
|
1325
|
+
React.createElement('td', null, row.username ? `@${row.username}` : '—'),
|
|
1326
|
+
React.createElement('td', null, `ID: ${row.userId}`),
|
|
1327
|
+
React.createElement('td', { style: { fontFamily: 'monospace', fontWeight: 600 } }, row.code),
|
|
1328
|
+
React.createElement(
|
|
1329
|
+
'td',
|
|
1330
|
+
{ style: { textAlign: 'right' } },
|
|
1331
|
+
React.createElement(
|
|
1332
|
+
'button',
|
|
1333
|
+
{
|
|
1334
|
+
type: 'button',
|
|
1335
|
+
className: 'msgw-btn msgw-btn-mini msgw-btn-primary',
|
|
1336
|
+
style: { marginRight: '6px' },
|
|
1337
|
+
disabled: !!busy,
|
|
1338
|
+
onClick: async () => {
|
|
1339
|
+
setBusy('approve')
|
|
1340
|
+
setErr('')
|
|
1341
|
+
try {
|
|
1342
|
+
const res = await fetch(`${ROUTE_PREFIX}/pairing/approve`, {
|
|
1343
|
+
method: 'POST',
|
|
1344
|
+
credentials: 'same-origin',
|
|
1345
|
+
headers: { 'Content-Type': 'application/json' },
|
|
1346
|
+
body: JSON.stringify({ code: row.code }),
|
|
1347
|
+
})
|
|
1348
|
+
const data = await res.json()
|
|
1349
|
+
if (!res.ok || !data.ok) throw new Error(data.error || res.status)
|
|
1350
|
+
await loadPairing()
|
|
1351
|
+
} catch (e) {
|
|
1352
|
+
setErr(String(e.message || e))
|
|
1353
|
+
} finally {
|
|
1354
|
+
setBusy('')
|
|
1355
|
+
}
|
|
1356
|
+
},
|
|
1357
|
+
},
|
|
1358
|
+
t('pairingApprove')
|
|
1359
|
+
),
|
|
1360
|
+
React.createElement(
|
|
1361
|
+
'button',
|
|
1362
|
+
{
|
|
1363
|
+
type: 'button',
|
|
1364
|
+
className: 'msgw-btn msgw-btn-mini msgw-btn-danger',
|
|
1365
|
+
disabled: !!busy,
|
|
1366
|
+
onClick: async () => {
|
|
1367
|
+
setBusy('reject')
|
|
1368
|
+
setErr('')
|
|
1369
|
+
try {
|
|
1370
|
+
const res = await fetch(`${ROUTE_PREFIX}/pairing/reject`, {
|
|
1371
|
+
method: 'POST',
|
|
1372
|
+
credentials: 'same-origin',
|
|
1373
|
+
headers: { 'Content-Type': 'application/json' },
|
|
1374
|
+
body: JSON.stringify({ code: row.code }),
|
|
1375
|
+
})
|
|
1376
|
+
const data = await res.json()
|
|
1377
|
+
if (!res.ok || !data.ok) throw new Error(data.error || res.status)
|
|
1378
|
+
await loadPairing()
|
|
1379
|
+
} catch (e) {
|
|
1380
|
+
setErr(String(e.message || e))
|
|
1381
|
+
} finally {
|
|
1382
|
+
setBusy('')
|
|
1383
|
+
}
|
|
1384
|
+
},
|
|
1385
|
+
},
|
|
1386
|
+
t('pairingReject')
|
|
1387
|
+
)
|
|
1388
|
+
)
|
|
1389
|
+
)
|
|
1390
|
+
)
|
|
1391
|
+
)
|
|
1392
|
+
)
|
|
1393
|
+
),
|
|
1394
|
+
|
|
1395
|
+
// Card 7: Advanced Connection & Webhook
|
|
1396
|
+
React.createElement(
|
|
1397
|
+
'div',
|
|
1398
|
+
{ className: 'msgw-section-card' },
|
|
1399
|
+
React.createElement(
|
|
1400
|
+
'button',
|
|
1401
|
+
{
|
|
1402
|
+
type: 'button',
|
|
1403
|
+
className: 'msgw-btn',
|
|
1404
|
+
style: { width: '100%', justifyContent: 'space-between' },
|
|
1405
|
+
onClick: () => setShowAdvanced((v) => !v),
|
|
1406
|
+
},
|
|
1407
|
+
React.createElement('span', null, showAdvanced ? t('hideAdvanced') : t('showAdvanced')),
|
|
1408
|
+
React.createElement('span', { style: { transform: showAdvanced ? 'rotate(180deg)' : 'none', transition: 'transform .16s' } },
|
|
1409
|
+
React.createElement(Chevron)
|
|
1410
|
+
)
|
|
1411
|
+
),
|
|
1412
|
+
showAdvanced ? React.createElement(
|
|
1413
|
+
'div',
|
|
1414
|
+
{ style: { display: 'flex', flexDirection: 'column', gap: '12px', marginTop: '12px' } },
|
|
1415
|
+
React.createElement(Field, { label: t('transport') },
|
|
1416
|
+
React.createElement(
|
|
1417
|
+
'select',
|
|
1418
|
+
{
|
|
1419
|
+
className: 'msgw-select',
|
|
1420
|
+
value: cfg.telegram?.transport || 'poll',
|
|
1421
|
+
onChange: (e) => setCfg({ ...cfg, telegram: { ...cfg.telegram, transport: e.target.value } }),
|
|
1422
|
+
},
|
|
1423
|
+
React.createElement('option', { value: 'poll' }, t('transportPoll')),
|
|
1424
|
+
React.createElement('option', { value: 'webhook' }, t('transportWebhook'))
|
|
1425
|
+
)
|
|
1426
|
+
),
|
|
1427
|
+
React.createElement(Field, { label: t('webhookUrl'), hint: t('webhookUrlHint') },
|
|
1428
|
+
React.createElement('input', {
|
|
1429
|
+
className: 'msgw-input',
|
|
1430
|
+
value: cfg.telegram?.webhookUrl || '',
|
|
1431
|
+
onChange: (e) => setCfg({ ...cfg, telegram: { ...cfg.telegram, webhookUrl: e.target.value } }),
|
|
1432
|
+
})
|
|
1433
|
+
),
|
|
1434
|
+
React.createElement(Field, {
|
|
1435
|
+
label: React.createElement('span', { style: { display: 'inline-flex', alignItems: 'center', gap: '8px' } },
|
|
1436
|
+
t('webhookSecret'),
|
|
1437
|
+
cfg.telegram?.webhookSecretConfigured
|
|
1438
|
+
? React.createElement('span', { className: 'msgw-badge msgw-badge-ok' }, t('webhookSecretConfigured'))
|
|
1439
|
+
: (cfg.telegram?.transport === 'webhook'
|
|
1440
|
+
? React.createElement('span', { className: 'msgw-badge msgw-badge-bad' }, t('webhookSecretRequired'))
|
|
1441
|
+
: null)
|
|
1442
|
+
),
|
|
1443
|
+
hint: t('webhookSecretHint')
|
|
1444
|
+
},
|
|
1445
|
+
React.createElement('input', {
|
|
1446
|
+
type: 'password',
|
|
1447
|
+
className: 'msgw-input',
|
|
1448
|
+
value: webhookSecret,
|
|
1449
|
+
placeholder: cfg.telegram?.webhookSecretConfigured ? '••••••••••••••••' : '',
|
|
1450
|
+
onChange: (e) => setWebhookSecret(e.target.value),
|
|
1451
|
+
})
|
|
1452
|
+
),
|
|
1453
|
+
React.createElement(Field, { label: t('pollTimeout') },
|
|
1454
|
+
React.createElement('input', {
|
|
1455
|
+
type: 'number',
|
|
1456
|
+
className: 'msgw-input',
|
|
1457
|
+
min: 10,
|
|
1458
|
+
max: 60,
|
|
1459
|
+
value: cfg.telegram?.pollTimeoutSeconds ?? 50,
|
|
1460
|
+
onChange: (e) => setCfg({ ...cfg, telegram: { ...cfg.telegram, pollTimeoutSeconds: Number(e.target.value) || 50 } }),
|
|
1461
|
+
})
|
|
1462
|
+
),
|
|
1463
|
+
React.createElement(Field, { label: t('pollInterval') },
|
|
1464
|
+
React.createElement('input', {
|
|
1465
|
+
type: 'number',
|
|
1466
|
+
className: 'msgw-input',
|
|
1467
|
+
min: 100,
|
|
1468
|
+
max: 5000,
|
|
1469
|
+
value: cfg.telegram?.pollIntervalMs ?? 500,
|
|
1470
|
+
onChange: (e) => setCfg({ ...cfg, telegram: { ...cfg.telegram, pollIntervalMs: Number(e.target.value) || 500 } }),
|
|
1471
|
+
})
|
|
1472
|
+
),
|
|
1473
|
+
React.createElement(Field, { label: t('idleTimeout') },
|
|
1474
|
+
React.createElement('input', {
|
|
1475
|
+
type: 'number',
|
|
1476
|
+
className: 'msgw-input',
|
|
1477
|
+
min: 300,
|
|
1478
|
+
max: 86400,
|
|
1479
|
+
value: Math.round((cfg.agent?.idleTimeoutMs ?? 3600000) / 1000),
|
|
1480
|
+
onChange: (e) => setCfg({ ...cfg, agent: { ...cfg.agent, idleTimeoutMs: (Number(e.target.value) || 3600) * 1000 } }),
|
|
1481
|
+
})
|
|
1482
|
+
)
|
|
1483
|
+
) : null
|
|
1484
|
+
),
|
|
1485
|
+
|
|
1486
|
+
// Sticky Footer
|
|
1487
|
+
React.createElement(
|
|
1488
|
+
'div',
|
|
1489
|
+
{
|
|
1490
|
+
className: 'msgw-foot',
|
|
1491
|
+
style: {
|
|
1492
|
+
display: 'flex',
|
|
1493
|
+
justifyContent: 'flex-end',
|
|
1494
|
+
gap: '10px',
|
|
1495
|
+
paddingTop: '12px',
|
|
1496
|
+
borderTop: '1px solid var(--dsw-alias-border-l2)',
|
|
1497
|
+
},
|
|
1498
|
+
},
|
|
1499
|
+
React.createElement(
|
|
1500
|
+
'button',
|
|
1501
|
+
{
|
|
1502
|
+
type: 'button',
|
|
1503
|
+
className: 'msgw-btn msgw-btn-primary',
|
|
1504
|
+
disabled: !!busy,
|
|
1505
|
+
onClick: () => save({}),
|
|
1506
|
+
},
|
|
1507
|
+
busy === 'save' ? t('saving') : t('save')
|
|
1508
|
+
)
|
|
1509
|
+
)
|
|
1510
|
+
)
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
function PluginCard(props) {
|
|
1514
|
+
const [open, setOpen] = React.useState(false)
|
|
1515
|
+
const t = props?.t || makeT(props?.locale)
|
|
1516
|
+
React.useEffect(() => {
|
|
1517
|
+
ensureCss()
|
|
1518
|
+
}, [])
|
|
1519
|
+
|
|
1520
|
+
// Plugins page row seat ('plugins.row.config'): the host page draws the title,
|
|
1521
|
+
// icon and crumb and provides its own padding, so view 'page' renders the form
|
|
1522
|
+
// bare (no card chrome, which would double the border and clip the left edge)
|
|
1523
|
+
// and view 'summary' renders the one-line state under the row title.
|
|
1524
|
+
if (props && props.view === 'summary') {
|
|
1525
|
+
return React.createElement('div', { className: 'msgw-sub' }, t('description'))
|
|
1526
|
+
}
|
|
1527
|
+
if (props && props.view === 'page') {
|
|
1528
|
+
return React.createElement(
|
|
1529
|
+
'div',
|
|
1530
|
+
{ className: 'msgw-page-seat' },
|
|
1531
|
+
React.createElement(ErrorBoundary, null,
|
|
1532
|
+
React.createElement(SettingsPage, { ...props, ctx: (props && props.ctx) || ctx, t })
|
|
1533
|
+
)
|
|
1534
|
+
)
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
return React.createElement(
|
|
1538
|
+
'li',
|
|
1539
|
+
{ className: 'msgw-card msgw-section-card', style: { listStyle: 'none', marginBottom: '12px' } },
|
|
1540
|
+
React.createElement(
|
|
1541
|
+
'button',
|
|
1542
|
+
{
|
|
1543
|
+
type: 'button',
|
|
1544
|
+
className: 'msgw-head',
|
|
1545
|
+
style: {
|
|
1546
|
+
background: 'none',
|
|
1547
|
+
border: 'none',
|
|
1548
|
+
cursor: 'pointer',
|
|
1549
|
+
display: 'flex',
|
|
1550
|
+
alignItems: 'center',
|
|
1551
|
+
width: '100%',
|
|
1552
|
+
padding: 0,
|
|
1553
|
+
textAlign: 'left',
|
|
1554
|
+
},
|
|
1555
|
+
'aria-expanded': open,
|
|
1556
|
+
onClick: () => setOpen((v) => !v),
|
|
1557
|
+
},
|
|
1558
|
+
React.createElement(
|
|
1559
|
+
'div',
|
|
1560
|
+
{ className: 'msgw-headText', style: { flex: 1 } },
|
|
1561
|
+
React.createElement('div', { className: 'msgw-title', style: { fontWeight: 600, fontSize: '15px' } }, t('title')),
|
|
1562
|
+
React.createElement('div', { className: 'msgw-sub', style: { fontSize: '13px', color: 'var(--dsw-alias-label-secondary)' } }, t('description'))
|
|
1563
|
+
),
|
|
1564
|
+
React.createElement(
|
|
1565
|
+
'span',
|
|
1566
|
+
{ className: 'msgw-chev', style: { transform: open ? 'rotate(180deg)' : 'none', transition: 'transform .16s' } },
|
|
1567
|
+
React.createElement(Chevron)
|
|
1568
|
+
)
|
|
1569
|
+
),
|
|
1570
|
+
open
|
|
1571
|
+
? React.createElement(
|
|
1572
|
+
'div',
|
|
1573
|
+
{ className: 'msgw-body', style: { marginTop: '16px' } },
|
|
1574
|
+
React.createElement(
|
|
1575
|
+
ErrorBoundary,
|
|
1576
|
+
null,
|
|
1577
|
+
React.createElement(SettingsPage, { ...props, ctx: (props && props.ctx) || ctx, t })
|
|
1578
|
+
)
|
|
1579
|
+
)
|
|
1580
|
+
: null
|
|
1581
|
+
)
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1584
|
+
function refreshMirrorUntilVisible(ctx) {
|
|
1585
|
+
const visible = () => {
|
|
1586
|
+
try {
|
|
1587
|
+
const s = (ctx?.get && ctx.get('lanSettings')) || (ctx?.get && ctx.get('settingsScope')) || ctx?.settingsScope
|
|
1588
|
+
const view = s?.describe?.()?.getSnapshot?.()?.view
|
|
1589
|
+
return !!view && Array.isArray(view.namespaces) && view.namespaces.some((row) => row.ns === NS)
|
|
1590
|
+
} catch (_) {
|
|
1591
|
+
return false
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
if (visible()) return () => {}
|
|
1595
|
+
let tries = 0
|
|
1596
|
+
const timer = setInterval(() => {
|
|
1597
|
+
if (visible() || tries >= 15) { clearInterval(timer); return }
|
|
1598
|
+
tries += 1
|
|
1599
|
+
try {
|
|
1600
|
+
const s = (ctx?.get && ctx.get('lanSettings')) || (ctx?.get && ctx.get('settingsScope')) || ctx?.settingsScope
|
|
1601
|
+
s?.describe?.()?.load?.()
|
|
1602
|
+
} catch (_) {
|
|
1603
|
+
/* safe fallback if settingsScope is not yet attached to container */
|
|
1604
|
+
}
|
|
1605
|
+
}, 1000)
|
|
1606
|
+
return () => clearInterval(timer)
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
function apply(ctx) {
|
|
1610
|
+
try {
|
|
1611
|
+
if (typeof ctx.effect === 'function') {
|
|
1612
|
+
ctx.effect(() => {
|
|
1613
|
+
try {
|
|
1614
|
+
const loc = ctx?.get?.('locale') || ctx?.locale
|
|
1615
|
+
if (loc?.register) {
|
|
1616
|
+
loc.register(NS, { en, zh })
|
|
1617
|
+
}
|
|
1618
|
+
} catch (taken) {
|
|
1619
|
+
console.warn('[dsh-messenger-gateway] dictionary already registered:', taken && taken.message)
|
|
1620
|
+
}
|
|
1621
|
+
}, 'dsh-messenger-gateway: dictionaries')
|
|
1622
|
+
} else {
|
|
1623
|
+
const loc = ctx?.get?.('locale') || ctx?.locale
|
|
1624
|
+
if (loc?.register) {
|
|
1625
|
+
loc.register(NS, { en, zh })
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
} catch (err) {
|
|
1629
|
+
console.warn('[dsh-messenger-gateway] dictionary registration error:', err && err.message)
|
|
1630
|
+
}
|
|
1631
|
+
|
|
1632
|
+
if (typeof ctx.effect === 'function') {
|
|
1633
|
+
ctx.effect(
|
|
1634
|
+
() => refreshMirrorUntilVisible(ctx),
|
|
1635
|
+
'dsh-messenger-gateway: re-read the settings mirror until our namespace appears',
|
|
1636
|
+
)
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
function registerSlotWhenReady(slotName, registerFn) {
|
|
1640
|
+
const slots = ctx?.get?.('slots') || ctx?.slots
|
|
1641
|
+
if (!slots) return
|
|
1642
|
+
if (typeof slots.inject === 'function') {
|
|
1643
|
+
try {
|
|
1644
|
+
slots.inject(slotName, () => {
|
|
1645
|
+
try {
|
|
1646
|
+
return registerFn()
|
|
1647
|
+
} catch (err) {
|
|
1648
|
+
console.warn('[dsh-messenger-gateway] Error registering slot ' + slotName + ':', err)
|
|
1649
|
+
}
|
|
1650
|
+
})
|
|
1651
|
+
return
|
|
1652
|
+
} catch (err) {
|
|
1653
|
+
console.warn('[dsh-messenger-gateway] Failed to inject slot ' + slotName + ':', err)
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
if (typeof slots.register === 'function') {
|
|
1657
|
+
try {
|
|
1658
|
+
registerFn()
|
|
1659
|
+
} catch (err) {
|
|
1660
|
+
console.warn('[dsh-messenger-gateway] Failed direct registration for ' + slotName + ':', err)
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
// Row seat on the Plugins page (current core): the plugin's row gains a
|
|
1666
|
+
// configure control whose page is the settings form. Registered first; the
|
|
1667
|
+
// legacy seats below stay as fallbacks so settings never become unreachable.
|
|
1668
|
+
registerSlotWhenReady('plugins.row.config', () => {
|
|
1669
|
+
const slots = ctx?.get?.('slots') || ctx?.slots
|
|
1670
|
+
return slots.register(
|
|
1671
|
+
{
|
|
1672
|
+
name: 'plugins.row.config',
|
|
1673
|
+
key: ROW_CONFIG_KEY,
|
|
1674
|
+
locale: NS,
|
|
1675
|
+
inject: () => ({ ctx }),
|
|
1676
|
+
},
|
|
1677
|
+
(props) => React.createElement(ErrorBoundary, null, React.createElement(PluginCard, { ...props, ctx: (props && props.ctx) || ctx }))
|
|
1678
|
+
)
|
|
1679
|
+
})
|
|
1680
|
+
|
|
1681
|
+
registerSlotWhenReady('settings.plugin.item', () => {
|
|
1682
|
+
const slots = ctx?.get?.('slots') || ctx?.slots
|
|
1683
|
+
return slots.register(
|
|
1684
|
+
{
|
|
1685
|
+
name: 'settings.plugin.item',
|
|
1686
|
+
key: NS,
|
|
1687
|
+
locale: NS,
|
|
1688
|
+
inject: () => ({ ctx }),
|
|
1689
|
+
},
|
|
1690
|
+
(props) => React.createElement(ErrorBoundary, null, React.createElement(PluginCard, { ...props, ctx: (props && props.ctx) || ctx }))
|
|
1691
|
+
)
|
|
1692
|
+
})
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1695
|
+
module.exports = { apply, inject: ['slots', 'locale', 'settingsScope'] }
|
|
1696
|
+
return module.exports
|
|
1697
|
+
},
|
|
1698
|
+
})
|