dsh-claude-subscription 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +19 -5
- package/LICENSE +20 -20
- package/README.en.md +117 -100
- package/README.md +109 -93
- package/cordis.patch.yml +5 -5
- package/docs/assets/README.md +11 -11
- package/lib/client.js +838 -792
- package/lib/composer-quota.js +20 -0
- package/lib/credential-store.js +151 -0
- package/lib/external-url.js +57 -0
- package/lib/index.js +183 -863
- package/lib/login-coordinator.js +282 -0
- package/lib/money.js +9 -0
- package/lib/pi-ai-runtime.js +61 -0
- package/lib/settings-contract.js +3 -0
- package/lib/types/client.d.ts +1 -0
- package/lib/types/composer-quota.d.ts +17 -0
- package/lib/types/credential-store.d.ts +45 -0
- package/lib/types/external-url.d.ts +17 -0
- package/lib/types/index.d.ts +85 -0
- package/lib/types/login-coordinator.d.ts +66 -0
- package/lib/types/money.d.ts +1 -0
- package/lib/types/pi-ai-runtime.d.ts +22 -0
- package/lib/types/settings-contract.d.ts +6 -0
- package/lib/types/usage.d.ts +90 -0
- package/lib/usage.js +303 -0
- package/package.json +57 -21
package/lib/client.js
CHANGED
|
@@ -1,792 +1,838 @@
|
|
|
1
|
-
window.__ModuleLoader__.load({
|
|
2
|
-
id: "dsh-claude-subscription",
|
|
3
|
-
factory: (require) => {
|
|
4
|
-
var module = { exports: {} };
|
|
5
|
-
var exports = module.exports;
|
|
6
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
-
let react = require("react");
|
|
8
|
-
let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
9
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
|
-
//#region src/composer-quota.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
.
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
.
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
.
|
|
134
|
-
.
|
|
135
|
-
.
|
|
136
|
-
.
|
|
137
|
-
.
|
|
138
|
-
.
|
|
139
|
-
.
|
|
140
|
-
.
|
|
141
|
-
.
|
|
142
|
-
.
|
|
143
|
-
.
|
|
144
|
-
.
|
|
145
|
-
.
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
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
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "dsh-claude-subscription",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
+
let react = require("react");
|
|
8
|
+
let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
9
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
|
+
//#region src/composer-quota.ts
|
|
11
|
+
function isDisplayableWindow(window) {
|
|
12
|
+
return (Number.isFinite(window?.remainingPercent) &&
|
|
13
|
+
window.remainingPercent >= 0 &&
|
|
14
|
+
window.remainingPercent <= 100);
|
|
15
|
+
}
|
|
16
|
+
/** Pick the tightest API-reported quota window that applies to the model. */
|
|
17
|
+
function selectModelQuota(usage, model) {
|
|
18
|
+
const windows = Array.isArray(usage?.windows)
|
|
19
|
+
? usage.windows.filter((window) => (window.appliesTo === "all" || window.appliesTo === model) &&
|
|
20
|
+
isDisplayableWindow(window))
|
|
21
|
+
: [];
|
|
22
|
+
if (windows.length === 0)
|
|
23
|
+
return undefined;
|
|
24
|
+
const selected = windows.reduce((lowest, candidate) => candidate.remainingPercent < lowest.remainingPercent ? candidate : lowest);
|
|
25
|
+
return {
|
|
26
|
+
id: selected.id,
|
|
27
|
+
remainingPercent: selected.remainingPercent,
|
|
28
|
+
...(Number.isSafeInteger(selected.resetsAt) ? { resetsAt: selected.resetsAt } : {}),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/settings-contract.ts
|
|
33
|
+
const SETTINGS_NAMESPACE = "claude-subscription";
|
|
34
|
+
const QUICK_QUOTA_FIELD = "quickQuotaVisible";
|
|
35
|
+
Object.freeze({ [QUICK_QUOTA_FIELD]: false });
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/money.ts
|
|
38
|
+
function money(value, currency, decimalPlaces) {
|
|
39
|
+
return new Intl.NumberFormat(undefined, {
|
|
40
|
+
style: "currency",
|
|
41
|
+
currency,
|
|
42
|
+
currencyDisplay: "code",
|
|
43
|
+
minimumFractionDigits: decimalPlaces,
|
|
44
|
+
maximumFractionDigits: decimalPlaces,
|
|
45
|
+
}).format(value / 10 ** decimalPlaces);
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/client.ts
|
|
49
|
+
const inject = [
|
|
50
|
+
"slots",
|
|
51
|
+
"locale",
|
|
52
|
+
"connection",
|
|
53
|
+
"remote",
|
|
54
|
+
"settingsScope",
|
|
55
|
+
"modelDirectories"
|
|
56
|
+
];
|
|
57
|
+
const NS = "settings.claudeSubscription";
|
|
58
|
+
const CHANNEL = "/claude-subscription";
|
|
59
|
+
const PROVIDER = "anthropic";
|
|
60
|
+
const QUICK_QUOTA_REFRESH_EVENT = "dsh-claude-subscription:refresh-quick-quota";
|
|
61
|
+
const QUICK_QUOTA_REFRESH_MS = 6e4;
|
|
62
|
+
const zh = {
|
|
63
|
+
nav: "Claude 訂閱",
|
|
64
|
+
title: "Claude 訂閱",
|
|
65
|
+
connected: "已登入",
|
|
66
|
+
disconnected: "未登入",
|
|
67
|
+
accountLoading: "正在讀取帳戶狀態…",
|
|
68
|
+
browserLogin: "瀏覽器登入",
|
|
69
|
+
logout: "登出",
|
|
70
|
+
cancel: "取消",
|
|
71
|
+
submit: "提交授權碼",
|
|
72
|
+
openLogin: "開啟登入頁",
|
|
73
|
+
manualCode: "若瀏覽器回呼沒有自動完成,請貼上授權碼或完整的重新導向網址。",
|
|
74
|
+
waiting: "正在等待登入完成…",
|
|
75
|
+
failed: "登入失敗,請重試。",
|
|
76
|
+
loadFailed: "無法讀取 Claude 狀態。",
|
|
77
|
+
quickQuotaSetting: "輸入框額度",
|
|
78
|
+
quickQuotaBeta: "Beta",
|
|
79
|
+
quickQuotaStatus: "Claude 剩餘額度 {value}%",
|
|
80
|
+
preferenceFailed: "無法更新設定,請重試。",
|
|
81
|
+
usage: "訂閱額度",
|
|
82
|
+
refresh: "重新整理",
|
|
83
|
+
refreshing: "重新整理中…",
|
|
84
|
+
noUsage: "登入後可讀取 Anthropic 回報的額度視窗。",
|
|
85
|
+
usageLoading: "正在讀取額度…",
|
|
86
|
+
usageEmpty: "此帳戶沒有回傳可顯示的額度視窗。請稍後重新整理;這不代表額度為零。",
|
|
87
|
+
usageUpdated: "更新於 {value}",
|
|
88
|
+
remaining: "剩餘 {value}%",
|
|
89
|
+
resets: "重置於 {value}",
|
|
90
|
+
resetUnknown: "重置時間未提供",
|
|
91
|
+
extraUsage: "額外用量",
|
|
92
|
+
extraUsageOff: "未啟用",
|
|
93
|
+
extraUsageUsed: "已用 {used} / {limit}",
|
|
94
|
+
extraUsageUsedOnly: "已用 {used}",
|
|
95
|
+
extraUsageUnknown: "暫無數據"
|
|
96
|
+
};
|
|
97
|
+
const en = {
|
|
98
|
+
nav: "Claude",
|
|
99
|
+
title: "Claude subscription",
|
|
100
|
+
connected: "Signed in",
|
|
101
|
+
disconnected: "Not signed in",
|
|
102
|
+
accountLoading: "Reading account status…",
|
|
103
|
+
browserLogin: "Browser sign-in",
|
|
104
|
+
logout: "Sign out",
|
|
105
|
+
cancel: "Cancel",
|
|
106
|
+
submit: "Submit authorization code",
|
|
107
|
+
openLogin: "Open sign-in page",
|
|
108
|
+
manualCode: "If the browser callback did not finish automatically, paste the code or full redirect URL.",
|
|
109
|
+
waiting: "Waiting for sign-in to finish…",
|
|
110
|
+
failed: "Sign-in failed. Try again.",
|
|
111
|
+
loadFailed: "Could not read Claude status.",
|
|
112
|
+
quickQuotaSetting: "Composer quota",
|
|
113
|
+
quickQuotaBeta: "Beta",
|
|
114
|
+
quickQuotaStatus: "Claude quota: {value}% remaining",
|
|
115
|
+
preferenceFailed: "Could not update the setting. Try again.",
|
|
116
|
+
usage: "Subscription quota",
|
|
117
|
+
refresh: "Refresh",
|
|
118
|
+
refreshing: "Refreshing…",
|
|
119
|
+
noUsage: "Sign in to read the quota windows reported by Anthropic.",
|
|
120
|
+
usageLoading: "Reading quota…",
|
|
121
|
+
usageEmpty: "This account returned no displayable quota windows. Refresh later; this does not mean zero quota.",
|
|
122
|
+
usageUpdated: "Updated {value}",
|
|
123
|
+
remaining: "{value}% remaining",
|
|
124
|
+
resets: "Resets {value}",
|
|
125
|
+
resetUnknown: "Reset time not provided",
|
|
126
|
+
extraUsage: "Extra usage",
|
|
127
|
+
extraUsageOff: "Not enabled",
|
|
128
|
+
extraUsageUsed: "{used} / {limit} used",
|
|
129
|
+
extraUsageUsedOnly: "{used} used",
|
|
130
|
+
extraUsageUnknown: "No data yet"
|
|
131
|
+
};
|
|
132
|
+
const STYLE = `
|
|
133
|
+
.claudeSubscription{display:flex;flex-direction:column;gap:10px;max-width:720px;color:var(--dsw-alias-label-primary);container-type:inline-size}
|
|
134
|
+
.claudeSubscription h2,.claudeSubscription h3,.claudeSubscription p{margin:0}
|
|
135
|
+
.claudeSubscription h2{font-size:16px;line-height:24px;font-weight:500}.claudeSubscription h3{font-size:14px;line-height:22px;font-weight:500}
|
|
136
|
+
.claudeSubscriptionTag{border:1px solid var(--dsw-alias-border-l3);border-radius:4px;padding:1px 6px;font-size:11px;line-height:16px;color:var(--dsw-alias-label-secondary)}
|
|
137
|
+
.claudeSubscriptionCard{border:1px solid var(--dsw-alias-border-l2);border-radius:12px;background:var(--dsw-alias-bg-layer-1);padding:14px 16px;display:flex;flex-direction:column;gap:12px}
|
|
138
|
+
.claudeSubscriptionUsageCard{padding:12px 14px;gap:9px}.claudeSubscriptionPreferencesCard{padding:12px 14px;gap:10px}
|
|
139
|
+
.claudeSubscriptionPreference{min-height:32px;box-sizing:border-box;display:flex;align-items:center;justify-content:space-between;gap:12px;font-size:13px;line-height:20px}
|
|
140
|
+
.claudeSubscriptionPreferenceLabel{display:flex;align-items:center;gap:6px;min-width:0}
|
|
141
|
+
.claudeSubscriptionSwitch{position:relative;flex:0 0 auto;width:32px;height:18px;padding:0;border:1px solid var(--dsw-alias-border-l3);border-radius:999px;background:var(--dsw-alias-bg-module-platform);cursor:pointer}.claudeSubscriptionSwitch:disabled{cursor:not-allowed;opacity:.5}.claudeSubscriptionSwitch[aria-checked=true]{background:var(--dsw-alias-label-secondary);border-color:var(--dsw-alias-label-secondary)}
|
|
142
|
+
.claudeSubscriptionSwitchKnob{position:absolute;top:2px;left:2px;width:12px;height:12px;border-radius:50%;background:var(--dsw-alias-bg-layer-1);transition:transform 120ms var(--ds-ease-in-out)}.claudeSubscriptionSwitch[aria-checked=true] .claudeSubscriptionSwitchKnob{transform:translateX(14px)}
|
|
143
|
+
.claudeSubscriptionAccountRow,.claudeSubscriptionSectionHead{display:flex;align-items:center;justify-content:space-between;gap:12px}
|
|
144
|
+
.claudeSubscriptionStatus{display:flex;align-items:center;gap:8px;font-size:14px;line-height:22px;font-weight:500}
|
|
145
|
+
.claudeSubscriptionDot{width:8px;height:8px;border-radius:50%;background:var(--dsw-alias-label-dimmed)}.claudeSubscriptionDot[data-state=connected]{background:var(--dsw-alias-state-success-primary)}.claudeSubscriptionDot[data-state=disconnected]{background:var(--dsw-alias-state-error-primary)}
|
|
146
|
+
.claudeSubscriptionActions{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
|
|
147
|
+
.claudeSubscriptionFlow{display:flex;flex-direction:column;gap:10px;padding:12px 14px;border-radius:10px;background:var(--dsw-alias-bg-module-platform)}
|
|
148
|
+
.claudeSubscriptionFlow p{font-size:13px;line-height:20px;color:var(--dsw-alias-label-secondary)}
|
|
149
|
+
.claudeSubscriptionInput{width:100%;box-sizing:border-box}
|
|
150
|
+
.claudeSubscriptionError{font-size:13px;line-height:20px;color:var(--dsw-alias-state-error-primary)}
|
|
151
|
+
.claudeSubscriptionSectionTitle{display:flex;flex:1;min-width:0;flex-direction:column;gap:2px}.claudeSubscriptionFreshness{font-size:11px;line-height:17px;color:var(--dsw-alias-label-tertiary)}
|
|
152
|
+
.claudeSubscriptionRefresh{flex:0 0 auto;min-width:72px;width:max-content;white-space:nowrap!important;word-break:keep-all!important}
|
|
153
|
+
.claudeSubscriptionEmpty{padding:18px;border:1px dashed var(--dsw-alias-border-l3);border-radius:10px;text-align:center;font-size:13px;line-height:20px;color:var(--dsw-alias-label-tertiary)}
|
|
154
|
+
.claudeSubscriptionLimits{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:6px}
|
|
155
|
+
.claudeSubscriptionLimit{min-width:0;border-radius:10px;padding:9px 12px;background:var(--dsw-alias-bg-module-platform);display:flex;flex-direction:column;gap:6px}
|
|
156
|
+
.claudeSubscriptionLimitTop{display:flex;align-items:baseline;justify-content:space-between;gap:12px}
|
|
157
|
+
.claudeSubscriptionLimitLabel{font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary)}
|
|
158
|
+
.claudeSubscriptionLimit strong{font:600 18px/24px ui-monospace,SFMono-Regular,Consolas,monospace;font-variant-numeric:tabular-nums}
|
|
159
|
+
.claudeSubscriptionLimit progress{width:100%;height:4px;border:0;border-radius:999px;overflow:hidden;background:var(--dsw-alias-border-l3);accent-color:var(--dsw-alias-brand-primary,#3964fe);-webkit-appearance:none;appearance:none}
|
|
160
|
+
.claudeSubscriptionLimit progress::-webkit-progress-bar{background:var(--dsw-alias-border-l3);border-radius:999px}.claudeSubscriptionLimit progress::-webkit-progress-value{background:var(--dsw-alias-brand-primary,#3964fe);border-radius:999px}.claudeSubscriptionLimit progress::-moz-progress-bar{background:var(--dsw-alias-brand-primary,#3964fe);border-radius:999px}
|
|
161
|
+
.claudeSubscriptionLimitMeta{display:flex;justify-content:space-between;gap:10px;flex-wrap:wrap;font-size:11px;line-height:17px;color:var(--dsw-alias-label-tertiary)}
|
|
162
|
+
.claudeSubscriptionExtra{display:flex;align-items:baseline;justify-content:space-between;gap:12px;border-radius:10px;padding:9px 12px;background:var(--dsw-alias-bg-module-platform);font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary)}
|
|
163
|
+
.claudeSubscriptionExtra strong{font:600 14px/20px ui-monospace,SFMono-Regular,Consolas,monospace;font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-primary)}
|
|
164
|
+
.claudeComposerQuota{display:inline-flex;align-items:center;flex:0 0 auto;height:28px;box-sizing:border-box;margin-right:-4px;padding:0;color:var(--dsw-alias-label-secondary);font-family:inherit;font-size:12px;line-height:20px;font-weight:500;font-variant-numeric:tabular-nums;white-space:nowrap;user-select:none}
|
|
165
|
+
@container (max-width:480px){.claudeSubscriptionAccountRow,.claudeSubscriptionSectionHead{align-items:flex-start;flex-direction:column}.claudeSubscriptionActions{width:100%}}
|
|
166
|
+
@media(max-width:640px){.claudeSubscriptionCard{padding:14px}}
|
|
167
|
+
`;
|
|
168
|
+
const unwrap = (response) => {
|
|
169
|
+
if (!response?.ok)
|
|
170
|
+
throw new Error(response?.error?.message ?? "Claude RPC failed");
|
|
171
|
+
return response.value;
|
|
172
|
+
};
|
|
173
|
+
const fill = (text, values) => Object.entries(values).reduce((next, [key, value]) => next.replace(`{${key}}`, String(value)), text);
|
|
174
|
+
const percent = (value) => Number(value).toLocaleString(void 0, { maximumFractionDigits: 1 });
|
|
175
|
+
const windowLabel = (window) => window.label ?? window.id;
|
|
176
|
+
const validDate = (value) => {
|
|
177
|
+
const date = new Date(value);
|
|
178
|
+
return Number.isFinite(date.getTime()) ? date : void 0;
|
|
179
|
+
};
|
|
180
|
+
const notifyQuickQuota = () => window.dispatchEvent(new Event(QUICK_QUOTA_REFRESH_EVENT));
|
|
181
|
+
/**
|
|
182
|
+
* Read the toggle from the settings scope, and fall back to the host RPC
|
|
183
|
+
* while the settings document is still unavailable.
|
|
184
|
+
*/
|
|
185
|
+
function createPreferenceController(scope, rpc) {
|
|
186
|
+
let updating = false;
|
|
187
|
+
let error = false;
|
|
188
|
+
let fallbackStatus = "loading";
|
|
189
|
+
let fallback;
|
|
190
|
+
let generation = 0;
|
|
191
|
+
const nativeSnapshot = () => scope.getSnapshot();
|
|
192
|
+
const read = () => {
|
|
193
|
+
const native = nativeSnapshot();
|
|
194
|
+
const current = native.status === "ready" ? native : fallbackStatus === "ready" ? fallback : native;
|
|
195
|
+
return Object.freeze({
|
|
196
|
+
status: updating ? "updating" : current.status,
|
|
197
|
+
visible: current.value?.[QUICK_QUOTA_FIELD] === true,
|
|
198
|
+
writable: !updating && current.status === "ready" && current.writable === true,
|
|
199
|
+
error
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
let snapshot = read();
|
|
203
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
204
|
+
const publish = () => {
|
|
205
|
+
snapshot = read();
|
|
206
|
+
for (const listener of listeners)
|
|
207
|
+
listener();
|
|
208
|
+
};
|
|
209
|
+
const disposeScope = scope.subscribe(() => {
|
|
210
|
+
error = false;
|
|
211
|
+
publish();
|
|
212
|
+
});
|
|
213
|
+
const acceptFallback = (value) => {
|
|
214
|
+
fallbackStatus = "ready";
|
|
215
|
+
fallback = {
|
|
216
|
+
status: "ready",
|
|
217
|
+
value: { [QUICK_QUOTA_FIELD]: value?.[QUICK_QUOTA_FIELD] === true },
|
|
218
|
+
writable: value?.writable === true
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
const load = async () => {
|
|
222
|
+
const current = ++generation;
|
|
223
|
+
updating = false;
|
|
224
|
+
fallbackStatus = "loading";
|
|
225
|
+
fallback = void 0;
|
|
226
|
+
error = false;
|
|
227
|
+
publish();
|
|
228
|
+
if (nativeSnapshot().status === "ready")
|
|
229
|
+
return;
|
|
230
|
+
try {
|
|
231
|
+
const value = unwrap(await rpc.call(CHANNEL, "preferences/status", {}));
|
|
232
|
+
if (current !== generation || nativeSnapshot().status === "ready")
|
|
233
|
+
return;
|
|
234
|
+
acceptFallback(value);
|
|
235
|
+
publish();
|
|
236
|
+
}
|
|
237
|
+
catch {
|
|
238
|
+
if (current !== generation || nativeSnapshot().status === "ready")
|
|
239
|
+
return;
|
|
240
|
+
fallbackStatus = "unavailable";
|
|
241
|
+
publish();
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
const set = async (value) => {
|
|
245
|
+
if (snapshot.status !== "ready" || snapshot.writable !== true)
|
|
246
|
+
return;
|
|
247
|
+
const current = ++generation;
|
|
248
|
+
updating = true;
|
|
249
|
+
error = false;
|
|
250
|
+
publish();
|
|
251
|
+
try {
|
|
252
|
+
if (nativeSnapshot().status === "ready") {
|
|
253
|
+
await scope.set(QUICK_QUOTA_FIELD, value);
|
|
254
|
+
if (current !== generation)
|
|
255
|
+
return;
|
|
256
|
+
error = nativeSnapshot().value?.[QUICK_QUOTA_FIELD] !== value;
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
const accepted = unwrap(await rpc.call(CHANNEL, "preferences/update", { [QUICK_QUOTA_FIELD]: value }));
|
|
260
|
+
if (current !== generation)
|
|
261
|
+
return;
|
|
262
|
+
acceptFallback(accepted);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
catch {
|
|
266
|
+
if (current === generation)
|
|
267
|
+
error = true;
|
|
268
|
+
}
|
|
269
|
+
finally {
|
|
270
|
+
if (current === generation) {
|
|
271
|
+
updating = false;
|
|
272
|
+
publish();
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
return {
|
|
277
|
+
getSnapshot: () => snapshot,
|
|
278
|
+
subscribe: (listener) => {
|
|
279
|
+
listeners.add(listener);
|
|
280
|
+
return () => listeners.delete(listener);
|
|
281
|
+
},
|
|
282
|
+
load,
|
|
283
|
+
set,
|
|
284
|
+
dispose: disposeScope
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
const usePreferenceSnapshot = (preference) => react.useSyncExternalStore(preference.subscribe, preference.getSnapshot);
|
|
288
|
+
function useQuickQuota(rpc, enabled, model) {
|
|
289
|
+
const [quota, setQuota] = react.useState(undefined);
|
|
290
|
+
react.useEffect(() => {
|
|
291
|
+
if (!enabled) {
|
|
292
|
+
setQuota(void 0);
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
let live = true;
|
|
296
|
+
let loading = false;
|
|
297
|
+
const load = async () => {
|
|
298
|
+
if (loading)
|
|
299
|
+
return;
|
|
300
|
+
loading = true;
|
|
301
|
+
try {
|
|
302
|
+
const account = unwrap(await rpc.call(CHANNEL, "status", {}));
|
|
303
|
+
if (!live)
|
|
304
|
+
return;
|
|
305
|
+
if (account?.authenticated !== true) {
|
|
306
|
+
setQuota(void 0);
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
const usage = unwrap(await rpc.call(CHANNEL, "usage", { force: false }));
|
|
310
|
+
if (live)
|
|
311
|
+
setQuota(selectModelQuota(usage, model));
|
|
312
|
+
}
|
|
313
|
+
catch {
|
|
314
|
+
if (live)
|
|
315
|
+
setQuota(void 0);
|
|
316
|
+
}
|
|
317
|
+
finally {
|
|
318
|
+
loading = false;
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
const refresh = () => {
|
|
322
|
+
load();
|
|
323
|
+
};
|
|
324
|
+
load();
|
|
325
|
+
const timer = window.setInterval(refresh, QUICK_QUOTA_REFRESH_MS);
|
|
326
|
+
window.addEventListener(QUICK_QUOTA_REFRESH_EVENT, refresh);
|
|
327
|
+
return () => {
|
|
328
|
+
live = false;
|
|
329
|
+
window.clearInterval(timer);
|
|
330
|
+
window.removeEventListener(QUICK_QUOTA_REFRESH_EVENT, refresh);
|
|
331
|
+
};
|
|
332
|
+
}, [
|
|
333
|
+
rpc,
|
|
334
|
+
enabled,
|
|
335
|
+
model
|
|
336
|
+
]);
|
|
337
|
+
return quota;
|
|
338
|
+
}
|
|
339
|
+
function ClaudeComposerQuota({ preference, rpc, t, directory }) {
|
|
340
|
+
const preferenceSnapshot = usePreferenceSnapshot(preference);
|
|
341
|
+
const current = react.useSyncExternalStore((listener) => directory.subscribe(listener), () => directory.getSnapshot()).current;
|
|
342
|
+
const enabled = preferenceSnapshot.status === "ready" && preferenceSnapshot.visible && current?.provider === PROVIDER;
|
|
343
|
+
const quota = useQuickQuota(rpc, enabled, current?.model);
|
|
344
|
+
if (!enabled || quota === void 0)
|
|
345
|
+
return null;
|
|
346
|
+
const value = percent(quota.remainingPercent);
|
|
347
|
+
const label = fill(t("quickQuotaStatus"), { value });
|
|
348
|
+
return /* @__PURE__ */ react_jsx_runtime.jsxs("span", {
|
|
349
|
+
className: "claudeComposerQuota",
|
|
350
|
+
role: "status",
|
|
351
|
+
"aria-label": label,
|
|
352
|
+
title: label,
|
|
353
|
+
children: [value, "%"]
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
function PreferencesCard({ preference, t }) {
|
|
357
|
+
const snapshot = usePreferenceSnapshot(preference);
|
|
358
|
+
const visible = snapshot.visible;
|
|
359
|
+
const writable = snapshot.status === "ready" && snapshot.writable === true;
|
|
360
|
+
return /* @__PURE__ */ react_jsx_runtime.jsxs("div", {
|
|
361
|
+
className: "claudeSubscriptionCard claudeSubscriptionPreferencesCard",
|
|
362
|
+
children: [/* @__PURE__ */ react_jsx_runtime.jsxs("div", {
|
|
363
|
+
className: "claudeSubscriptionPreference",
|
|
364
|
+
children: [/* @__PURE__ */ react_jsx_runtime.jsxs("span", {
|
|
365
|
+
className: "claudeSubscriptionPreferenceLabel",
|
|
366
|
+
children: [t("quickQuotaSetting"), /* @__PURE__ */ react_jsx_runtime.jsx("span", {
|
|
367
|
+
className: "claudeSubscriptionTag",
|
|
368
|
+
children: t("quickQuotaBeta")
|
|
369
|
+
})]
|
|
370
|
+
}), /* @__PURE__ */ react_jsx_runtime.jsx("button", {
|
|
371
|
+
className: "claudeSubscriptionSwitch",
|
|
372
|
+
type: "button",
|
|
373
|
+
role: "switch",
|
|
374
|
+
"aria-checked": visible,
|
|
375
|
+
"aria-label": t("quickQuotaSetting"),
|
|
376
|
+
disabled: !writable,
|
|
377
|
+
onClick: () => {
|
|
378
|
+
preference.set(!visible);
|
|
379
|
+
},
|
|
380
|
+
children: /* @__PURE__ */ react_jsx_runtime.jsx("span", {
|
|
381
|
+
className: "claudeSubscriptionSwitchKnob",
|
|
382
|
+
"aria-hidden": "true"
|
|
383
|
+
})
|
|
384
|
+
})]
|
|
385
|
+
}), snapshot.error ? /* @__PURE__ */ react_jsx_runtime.jsx("p", {
|
|
386
|
+
className: "claudeSubscriptionError",
|
|
387
|
+
role: "alert",
|
|
388
|
+
children: t("preferenceFailed")
|
|
389
|
+
}) : null]
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
function AccountCard({ rpc, t, account, setAccount, onSignedOut }) {
|
|
393
|
+
const [flow, setFlow] = react.useState(undefined);
|
|
394
|
+
const [manualCode, setManualCode] = react.useState("");
|
|
395
|
+
const [busy, setBusy] = react.useState(false);
|
|
396
|
+
const [error, setError] = react.useState(undefined);
|
|
397
|
+
const call = (endpoint, payload = {}) => rpc.call(CHANNEL, endpoint, payload).then(unwrap);
|
|
398
|
+
react.useEffect(() => {
|
|
399
|
+
if (flow?.id === void 0 || [
|
|
400
|
+
"authenticated",
|
|
401
|
+
"failed",
|
|
402
|
+
"cancelled"
|
|
403
|
+
].includes(flow.phase))
|
|
404
|
+
return void 0;
|
|
405
|
+
const timer = window.setInterval(() => {
|
|
406
|
+
call("login/status", { id: flow.id }).then((next) => {
|
|
407
|
+
setFlow(next);
|
|
408
|
+
if (next.phase === "authenticated")
|
|
409
|
+
call("status").then((account) => {
|
|
410
|
+
setAccount(account);
|
|
411
|
+
notifyQuickQuota();
|
|
412
|
+
}).catch(() => setError(t("failed")));
|
|
413
|
+
}).catch(() => setError(t("failed")));
|
|
414
|
+
}, 800);
|
|
415
|
+
return () => window.clearInterval(timer);
|
|
416
|
+
}, [flow?.id, flow?.phase]);
|
|
417
|
+
const begin = () => {
|
|
418
|
+
setBusy(true);
|
|
419
|
+
setError(void 0);
|
|
420
|
+
call("login/start", {
|
|
421
|
+
method: "browser",
|
|
422
|
+
openExternal: true
|
|
423
|
+
}).then(setFlow).catch(() => setError(t("failed"))).finally(() => setBusy(false));
|
|
424
|
+
};
|
|
425
|
+
const cancel = () => {
|
|
426
|
+
if (flow?.id === void 0)
|
|
427
|
+
return;
|
|
428
|
+
setBusy(true);
|
|
429
|
+
call("login/cancel", { id: flow.id }).then(setFlow).finally(() => setBusy(false));
|
|
430
|
+
};
|
|
431
|
+
const submit = (event) => {
|
|
432
|
+
event.preventDefault();
|
|
433
|
+
if (flow?.id === void 0 || manualCode.trim() === "")
|
|
434
|
+
return;
|
|
435
|
+
setBusy(true);
|
|
436
|
+
call("login/submit", {
|
|
437
|
+
id: flow.id,
|
|
438
|
+
value: manualCode.trim()
|
|
439
|
+
}).then((next) => {
|
|
440
|
+
setManualCode("");
|
|
441
|
+
setFlow(next);
|
|
442
|
+
}).catch(() => setError(t("failed"))).finally(() => setBusy(false));
|
|
443
|
+
};
|
|
444
|
+
const logout = () => {
|
|
445
|
+
setBusy(true);
|
|
446
|
+
setError(void 0);
|
|
447
|
+
call("logout").then((next) => {
|
|
448
|
+
setAccount(next);
|
|
449
|
+
setFlow(void 0);
|
|
450
|
+
onSignedOut();
|
|
451
|
+
notifyQuickQuota();
|
|
452
|
+
}).catch(() => setError(t("failed"))).finally(() => setBusy(false));
|
|
453
|
+
};
|
|
454
|
+
const signedIn = account?.authenticated === true;
|
|
455
|
+
const accountReady = account !== void 0;
|
|
456
|
+
return /* @__PURE__ */ react_jsx_runtime.jsxs("div", {
|
|
457
|
+
className: "claudeSubscriptionCard",
|
|
458
|
+
children: [
|
|
459
|
+
/* @__PURE__ */ react_jsx_runtime.jsxs("div", {
|
|
460
|
+
className: "claudeSubscriptionAccountRow",
|
|
461
|
+
children: [/* @__PURE__ */ react_jsx_runtime.jsxs("div", {
|
|
462
|
+
className: "claudeSubscriptionStatus",
|
|
463
|
+
role: "status",
|
|
464
|
+
"aria-live": "polite",
|
|
465
|
+
children: [/* @__PURE__ */ react_jsx_runtime.jsx("span", {
|
|
466
|
+
className: "claudeSubscriptionDot",
|
|
467
|
+
"data-state": accountReady ? signedIn ? "connected" : "disconnected" : "loading",
|
|
468
|
+
"aria-hidden": "true"
|
|
469
|
+
}), accountReady ? signedIn ? t("connected") : t("disconnected") : t("accountLoading")]
|
|
470
|
+
}), /* @__PURE__ */ react_jsx_runtime.jsx("div", {
|
|
471
|
+
className: "claudeSubscriptionActions",
|
|
472
|
+
children: signedIn ? /* @__PURE__ */ react_jsx_runtime.jsx(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
473
|
+
type: "button",
|
|
474
|
+
variant: "outline",
|
|
475
|
+
disabled: busy,
|
|
476
|
+
onClick: logout,
|
|
477
|
+
children: t("logout")
|
|
478
|
+
}) : accountReady && (flow === void 0 || ["failed", "cancelled"].includes(flow.phase)) ? /* @__PURE__ */ react_jsx_runtime.jsx(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
479
|
+
type: "button",
|
|
480
|
+
variant: "primary",
|
|
481
|
+
disabled: busy,
|
|
482
|
+
onClick: begin,
|
|
483
|
+
children: t("browserLogin")
|
|
484
|
+
}) : null
|
|
485
|
+
})]
|
|
486
|
+
}),
|
|
487
|
+
!signedIn && flow?.phase === "waiting_input" ? /* @__PURE__ */ react_jsx_runtime.jsxs("form", {
|
|
488
|
+
className: "claudeSubscriptionFlow",
|
|
489
|
+
onSubmit: submit,
|
|
490
|
+
children: [
|
|
491
|
+
/* @__PURE__ */ react_jsx_runtime.jsx("p", { children: t("manualCode") }),
|
|
492
|
+
/* @__PURE__ */ react_jsx_runtime.jsx(_deepseek_ai_dsh_client_ui_primitives.Input, {
|
|
493
|
+
className: "claudeSubscriptionInput",
|
|
494
|
+
value: manualCode,
|
|
495
|
+
onChange: (event) => setManualCode(event.currentTarget.value),
|
|
496
|
+
autoComplete: "off",
|
|
497
|
+
spellCheck: false
|
|
498
|
+
}),
|
|
499
|
+
/* @__PURE__ */ react_jsx_runtime.jsxs("div", {
|
|
500
|
+
className: "claudeSubscriptionActions",
|
|
501
|
+
children: [/* @__PURE__ */ react_jsx_runtime.jsx(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
502
|
+
type: "submit",
|
|
503
|
+
variant: "primary",
|
|
504
|
+
disabled: busy || manualCode.trim() === "",
|
|
505
|
+
children: t("submit")
|
|
506
|
+
}), /* @__PURE__ */ react_jsx_runtime.jsx(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
507
|
+
type: "button",
|
|
508
|
+
variant: "outline",
|
|
509
|
+
disabled: busy,
|
|
510
|
+
onClick: cancel,
|
|
511
|
+
children: t("cancel")
|
|
512
|
+
})]
|
|
513
|
+
})
|
|
514
|
+
]
|
|
515
|
+
}) : null,
|
|
516
|
+
!signedIn && flow !== void 0 && ["starting", "waiting_browser"].includes(flow.phase) ? /* @__PURE__ */ react_jsx_runtime.jsxs("div", {
|
|
517
|
+
className: "claudeSubscriptionFlow",
|
|
518
|
+
children: [
|
|
519
|
+
/* @__PURE__ */ react_jsx_runtime.jsx("p", { children: t("waiting") }),
|
|
520
|
+
flow.authUrl === void 0 ? null : /* @__PURE__ */ react_jsx_runtime.jsx("a", {
|
|
521
|
+
href: flow.authUrl,
|
|
522
|
+
target: "_blank",
|
|
523
|
+
rel: "noreferrer",
|
|
524
|
+
children: t("openLogin")
|
|
525
|
+
}),
|
|
526
|
+
/* @__PURE__ */ react_jsx_runtime.jsx(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
527
|
+
type: "button",
|
|
528
|
+
variant: "outline",
|
|
529
|
+
disabled: busy,
|
|
530
|
+
onClick: cancel,
|
|
531
|
+
children: t("cancel")
|
|
532
|
+
})
|
|
533
|
+
]
|
|
534
|
+
}) : null,
|
|
535
|
+
flow?.phase === "failed" || error !== void 0 ? /* @__PURE__ */ react_jsx_runtime.jsx("p", {
|
|
536
|
+
className: "claudeSubscriptionError",
|
|
537
|
+
role: "alert",
|
|
538
|
+
children: error ?? t("failed")
|
|
539
|
+
}) : null
|
|
540
|
+
]
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
function ResetTime({ resetsAt, t }) {
|
|
544
|
+
const date = Number.isSafeInteger(resetsAt) ? validDate(resetsAt * 1e3) : void 0;
|
|
545
|
+
if (date === void 0)
|
|
546
|
+
return /* @__PURE__ */ react_jsx_runtime.jsx("span", { children: t("resetUnknown") });
|
|
547
|
+
const value = date.toLocaleString(void 0, {
|
|
548
|
+
month: "numeric",
|
|
549
|
+
day: "numeric",
|
|
550
|
+
hour: "2-digit",
|
|
551
|
+
minute: "2-digit"
|
|
552
|
+
});
|
|
553
|
+
return /* @__PURE__ */ react_jsx_runtime.jsx("time", {
|
|
554
|
+
dateTime: date.toISOString(),
|
|
555
|
+
title: date.toLocaleString(),
|
|
556
|
+
children: fill(t("resets"), { value })
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
function ExtraUsageRow({ extraUsage, t }) {
|
|
560
|
+
const amount = (value) => money(value, extraUsage.currency, extraUsage.decimalPlaces);
|
|
561
|
+
const hasExactAmount = extraUsage.usedCredits !== void 0 && extraUsage.currency !== void 0 && extraUsage.decimalPlaces !== void 0;
|
|
562
|
+
const detail = !extraUsage.enabled ? t("extraUsageOff") : !hasExactAmount ? t("extraUsageUnknown") : extraUsage.monthlyLimit === void 0 ? fill(t("extraUsageUsedOnly"), { used: amount(extraUsage.usedCredits) }) : fill(t("extraUsageUsed"), {
|
|
563
|
+
used: amount(extraUsage.usedCredits),
|
|
564
|
+
limit: amount(extraUsage.monthlyLimit)
|
|
565
|
+
});
|
|
566
|
+
return /* @__PURE__ */ react_jsx_runtime.jsxs("div", {
|
|
567
|
+
className: "claudeSubscriptionExtra",
|
|
568
|
+
children: [/* @__PURE__ */ react_jsx_runtime.jsx("span", { children: t("extraUsage") }), /* @__PURE__ */ react_jsx_runtime.jsx("strong", { children: detail })]
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
function UsageCard({ rpc, t, signedIn, resetKey }) {
|
|
572
|
+
const [usage, setUsage] = react.useState(undefined);
|
|
573
|
+
const [busy, setBusy] = react.useState(false);
|
|
574
|
+
const [error, setError] = react.useState(undefined);
|
|
575
|
+
const request = react.useRef(0);
|
|
576
|
+
const load = (force) => {
|
|
577
|
+
if (!signedIn)
|
|
578
|
+
return;
|
|
579
|
+
const id = ++request.current;
|
|
580
|
+
setBusy(true);
|
|
581
|
+
setError(void 0);
|
|
582
|
+
rpc.call(CHANNEL, "usage", { force }).then(unwrap).then((next) => {
|
|
583
|
+
if (request.current === id) {
|
|
584
|
+
setUsage(next);
|
|
585
|
+
if (force)
|
|
586
|
+
notifyQuickQuota();
|
|
587
|
+
}
|
|
588
|
+
}).catch((error) => {
|
|
589
|
+
if (request.current === id)
|
|
590
|
+
setError(error.message);
|
|
591
|
+
}).finally(() => {
|
|
592
|
+
if (request.current === id)
|
|
593
|
+
setBusy(false);
|
|
594
|
+
});
|
|
595
|
+
};
|
|
596
|
+
react.useEffect(() => {
|
|
597
|
+
if (signedIn)
|
|
598
|
+
load(false);
|
|
599
|
+
else {
|
|
600
|
+
request.current += 1;
|
|
601
|
+
setUsage(void 0);
|
|
602
|
+
setError(void 0);
|
|
603
|
+
setBusy(false);
|
|
604
|
+
}
|
|
605
|
+
return () => {
|
|
606
|
+
request.current += 1;
|
|
607
|
+
};
|
|
608
|
+
}, [signedIn, resetKey]);
|
|
609
|
+
const visibleUsage = signedIn ? usage : void 0;
|
|
610
|
+
const windows = visibleUsage?.windows ?? [];
|
|
611
|
+
const hasDetails = windows.length > 0 || visibleUsage?.extraUsage !== void 0;
|
|
612
|
+
const fetchedAt = typeof visibleUsage?.fetchedAt === "number" ? validDate(visibleUsage.fetchedAt) : void 0;
|
|
613
|
+
return /* @__PURE__ */ react_jsx_runtime.jsxs("div", {
|
|
614
|
+
className: "claudeSubscriptionCard claudeSubscriptionUsageCard",
|
|
615
|
+
children: [
|
|
616
|
+
/* @__PURE__ */ react_jsx_runtime.jsxs("div", {
|
|
617
|
+
className: "claudeSubscriptionSectionHead",
|
|
618
|
+
children: [/* @__PURE__ */ react_jsx_runtime.jsxs("div", {
|
|
619
|
+
className: "claudeSubscriptionSectionTitle",
|
|
620
|
+
children: [/* @__PURE__ */ react_jsx_runtime.jsx("h3", { children: t("usage") }), fetchedAt === void 0 ? null : /* @__PURE__ */ react_jsx_runtime.jsx("time", {
|
|
621
|
+
className: "claudeSubscriptionFreshness",
|
|
622
|
+
dateTime: fetchedAt.toISOString(),
|
|
623
|
+
children: fill(t("usageUpdated"), { value: fetchedAt.toLocaleString() })
|
|
624
|
+
})]
|
|
625
|
+
}), /* @__PURE__ */ react_jsx_runtime.jsx(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
626
|
+
className: "claudeSubscriptionRefresh",
|
|
627
|
+
type: "button",
|
|
628
|
+
variant: "outline",
|
|
629
|
+
disabled: !signedIn || busy,
|
|
630
|
+
"aria-busy": busy,
|
|
631
|
+
onClick: () => load(true),
|
|
632
|
+
children: busy ? t("refreshing") : t("refresh")
|
|
633
|
+
})]
|
|
634
|
+
}),
|
|
635
|
+
/* @__PURE__ */ react_jsx_runtime.jsxs("div", {
|
|
636
|
+
"aria-live": "polite",
|
|
637
|
+
children: [
|
|
638
|
+
!signedIn ? /* @__PURE__ */ react_jsx_runtime.jsx("p", {
|
|
639
|
+
className: "claudeSubscriptionEmpty",
|
|
640
|
+
children: t("noUsage")
|
|
641
|
+
}) : null,
|
|
642
|
+
signedIn && busy && usage === void 0 ? /* @__PURE__ */ react_jsx_runtime.jsx("p", {
|
|
643
|
+
className: "claudeSubscriptionEmpty",
|
|
644
|
+
role: "status",
|
|
645
|
+
children: t("usageLoading")
|
|
646
|
+
}) : null,
|
|
647
|
+
signedIn && !busy && error === void 0 && usage !== void 0 && !hasDetails ? /* @__PURE__ */ react_jsx_runtime.jsx("p", {
|
|
648
|
+
className: "claudeSubscriptionEmpty",
|
|
649
|
+
role: "status",
|
|
650
|
+
children: t("usageEmpty")
|
|
651
|
+
}) : null
|
|
652
|
+
]
|
|
653
|
+
}),
|
|
654
|
+
error === void 0 ? null : /* @__PURE__ */ react_jsx_runtime.jsx("p", {
|
|
655
|
+
className: "claudeSubscriptionError",
|
|
656
|
+
role: "alert",
|
|
657
|
+
children: error
|
|
658
|
+
}),
|
|
659
|
+
windows.length === 0 ? null : /* @__PURE__ */ react_jsx_runtime.jsx("div", {
|
|
660
|
+
className: "claudeSubscriptionLimits",
|
|
661
|
+
children: windows.map((window) => /* @__PURE__ */ react_jsx_runtime.jsxs("div", {
|
|
662
|
+
className: "claudeSubscriptionLimit",
|
|
663
|
+
children: [
|
|
664
|
+
/* @__PURE__ */ react_jsx_runtime.jsxs("div", {
|
|
665
|
+
className: "claudeSubscriptionLimitTop",
|
|
666
|
+
children: [/* @__PURE__ */ react_jsx_runtime.jsx("span", {
|
|
667
|
+
className: "claudeSubscriptionLimitLabel",
|
|
668
|
+
children: windowLabel(window)
|
|
669
|
+
}), /* @__PURE__ */ react_jsx_runtime.jsxs("strong", { children: [percent(window.remainingPercent), "%"] })]
|
|
670
|
+
}),
|
|
671
|
+
/* @__PURE__ */ react_jsx_runtime.jsx("progress", {
|
|
672
|
+
max: "100",
|
|
673
|
+
value: window.remainingPercent,
|
|
674
|
+
"aria-label": `${windowLabel(window)} ${fill(t("remaining"), { value: percent(window.remainingPercent) })}`
|
|
675
|
+
}),
|
|
676
|
+
/* @__PURE__ */ react_jsx_runtime.jsx("div", {
|
|
677
|
+
className: "claudeSubscriptionLimitMeta",
|
|
678
|
+
children: /* @__PURE__ */ react_jsx_runtime.jsx(ResetTime, {
|
|
679
|
+
resetsAt: window.resetsAt,
|
|
680
|
+
t
|
|
681
|
+
})
|
|
682
|
+
})
|
|
683
|
+
]
|
|
684
|
+
}, window.id))
|
|
685
|
+
}),
|
|
686
|
+
visibleUsage?.extraUsage === void 0 ? null : /* @__PURE__ */ react_jsx_runtime.jsx(ExtraUsageRow, {
|
|
687
|
+
extraUsage: visibleUsage.extraUsage,
|
|
688
|
+
t
|
|
689
|
+
})
|
|
690
|
+
]
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
function ClaudeProviderAuth({ provider, rpc, t }) {
|
|
694
|
+
const [account, setAccount] = react.useState(undefined);
|
|
695
|
+
const [error, setError] = react.useState(undefined);
|
|
696
|
+
const isClaude = provider?.provider === PROVIDER;
|
|
697
|
+
react.useEffect(() => {
|
|
698
|
+
if (!isClaude)
|
|
699
|
+
return;
|
|
700
|
+
let live = true;
|
|
701
|
+
rpc.call(CHANNEL, "status", {}).then(unwrap).then((next) => {
|
|
702
|
+
if (live)
|
|
703
|
+
setAccount(next);
|
|
704
|
+
}).catch(() => {
|
|
705
|
+
if (live)
|
|
706
|
+
setError(t("loadFailed"));
|
|
707
|
+
});
|
|
708
|
+
return () => {
|
|
709
|
+
live = false;
|
|
710
|
+
};
|
|
711
|
+
}, [isClaude, rpc, t]);
|
|
712
|
+
if (!isClaude)
|
|
713
|
+
return null;
|
|
714
|
+
return /* @__PURE__ */ react_jsx_runtime.jsxs(react_jsx_runtime.Fragment, {
|
|
715
|
+
children: [/* @__PURE__ */ react_jsx_runtime.jsx(AccountCard, {
|
|
716
|
+
rpc,
|
|
717
|
+
t,
|
|
718
|
+
account,
|
|
719
|
+
setAccount,
|
|
720
|
+
onSignedOut: () => void 0
|
|
721
|
+
}), error === void 0 ? null : /* @__PURE__ */ react_jsx_runtime.jsx("p", {
|
|
722
|
+
className: "claudeSubscriptionError",
|
|
723
|
+
role: "alert",
|
|
724
|
+
children: error
|
|
725
|
+
})]
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
function ClaudeSection({ preference, rpc, t }) {
|
|
729
|
+
const [account, setAccount] = react.useState(undefined);
|
|
730
|
+
const [error, setError] = react.useState(undefined);
|
|
731
|
+
const [resetKey, setResetKey] = react.useState(0);
|
|
732
|
+
react.useEffect(() => {
|
|
733
|
+
let live = true;
|
|
734
|
+
rpc.call(CHANNEL, "status", {}).then(unwrap).then((next) => {
|
|
735
|
+
if (live)
|
|
736
|
+
setAccount(next);
|
|
737
|
+
}).catch(() => {
|
|
738
|
+
if (live)
|
|
739
|
+
setError(t("loadFailed"));
|
|
740
|
+
});
|
|
741
|
+
return () => {
|
|
742
|
+
live = false;
|
|
743
|
+
};
|
|
744
|
+
}, []);
|
|
745
|
+
return /* @__PURE__ */ react_jsx_runtime.jsxs("section", {
|
|
746
|
+
className: "claudeSubscription",
|
|
747
|
+
children: [
|
|
748
|
+
/* @__PURE__ */ react_jsx_runtime.jsx("h2", { children: t("title") }),
|
|
749
|
+
/* @__PURE__ */ react_jsx_runtime.jsx(AccountCard, {
|
|
750
|
+
rpc,
|
|
751
|
+
t,
|
|
752
|
+
account,
|
|
753
|
+
setAccount,
|
|
754
|
+
onSignedOut: () => setResetKey((value) => value + 1)
|
|
755
|
+
}),
|
|
756
|
+
/* @__PURE__ */ react_jsx_runtime.jsx(PreferencesCard, {
|
|
757
|
+
preference,
|
|
758
|
+
t
|
|
759
|
+
}),
|
|
760
|
+
/* @__PURE__ */ react_jsx_runtime.jsx(UsageCard, {
|
|
761
|
+
rpc,
|
|
762
|
+
t,
|
|
763
|
+
signedIn: account?.authenticated === true,
|
|
764
|
+
resetKey
|
|
765
|
+
}),
|
|
766
|
+
error === void 0 ? null : /* @__PURE__ */ react_jsx_runtime.jsx("p", {
|
|
767
|
+
className: "claudeSubscriptionError",
|
|
768
|
+
role: "alert",
|
|
769
|
+
children: error
|
|
770
|
+
})
|
|
771
|
+
]
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
function apply(ctx) {
|
|
775
|
+
ctx.effect(() => ctx.locale.register(NS, {
|
|
776
|
+
zh,
|
|
777
|
+
en
|
|
778
|
+
}), "claude-subscription: copy");
|
|
779
|
+
ctx.effect(() => {
|
|
780
|
+
const tag = document.createElement("style");
|
|
781
|
+
tag.dataset.plugin = "dsh-claude-subscription";
|
|
782
|
+
tag.textContent = STYLE;
|
|
783
|
+
document.head.append(tag);
|
|
784
|
+
return () => tag.remove();
|
|
785
|
+
}, "claude-subscription: style");
|
|
786
|
+
const connection = ctx.get("connection");
|
|
787
|
+
const preference = createPreferenceController(ctx.settingsScope.bind({ namespace: SETTINGS_NAMESPACE }), connection.rpc);
|
|
788
|
+
ctx.effect(() => {
|
|
789
|
+
preference.load();
|
|
790
|
+
const disposeReset = ctx.on("connection/reset", () => {
|
|
791
|
+
preference.load();
|
|
792
|
+
});
|
|
793
|
+
return () => {
|
|
794
|
+
disposeReset?.();
|
|
795
|
+
preference.dispose();
|
|
796
|
+
};
|
|
797
|
+
}, "claude-subscription: preferences");
|
|
798
|
+
const t = ctx.locale.bind(NS);
|
|
799
|
+
ctx.slots.inject("settings.section", () => ctx.slots.register({
|
|
800
|
+
name: "settings.section",
|
|
801
|
+
id: "claude-subscription",
|
|
802
|
+
order: 16,
|
|
803
|
+
label: () => t("nav"),
|
|
804
|
+
locale: NS,
|
|
805
|
+
inject: () => ({
|
|
806
|
+
preference,
|
|
807
|
+
rpc: connection.rpc,
|
|
808
|
+
t
|
|
809
|
+
})
|
|
810
|
+
}, ClaudeSection));
|
|
811
|
+
ctx.slots.inject("settings.models.provider-card", () => ctx.slots.register({
|
|
812
|
+
name: "settings.models.provider-card",
|
|
813
|
+
key: "llm-pi-ai",
|
|
814
|
+
locale: NS,
|
|
815
|
+
inject: () => ({
|
|
816
|
+
rpc: connection.rpc,
|
|
817
|
+
t
|
|
818
|
+
})
|
|
819
|
+
}, ClaudeProviderAuth));
|
|
820
|
+
ctx.slots.inject("conversation.input.right", () => ctx.slots.register({
|
|
821
|
+
name: "conversation.input.right",
|
|
822
|
+
id: "claude-subscription-quota",
|
|
823
|
+
order: 16,
|
|
824
|
+
locale: NS,
|
|
825
|
+
inject: (sessionId) => ({
|
|
826
|
+
preference,
|
|
827
|
+
rpc: connection.rpc,
|
|
828
|
+
t,
|
|
829
|
+
directory: ctx.modelDirectories.directoryFor(sessionId).store
|
|
830
|
+
})
|
|
831
|
+
}, ClaudeComposerQuota));
|
|
832
|
+
}
|
|
833
|
+
//#endregion
|
|
834
|
+
exports.apply = apply;
|
|
835
|
+
exports.inject = inject;
|
|
836
|
+
return module.exports;
|
|
837
|
+
}
|
|
838
|
+
});
|