-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcat_chat_script.js
More file actions
5601 lines (5245 loc) · 242 KB
/
Copy pathcat_chat_script.js
File metadata and controls
5601 lines (5245 loc) · 242 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
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
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
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
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
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
// ====================== Constants ======================
const catEmojis = ['🐱','😺','😸','😹','😻','😼','😽','🙀','😿','😾','🐈','🐈⬛','🐾','🦁'];
const catColors = ['#f582ae','#ff8c42','#ffd803','#a8d8a8','#8bd3dd','#b8a9c9','#f6a6b2','#ffb347','#87ceeb','#dda0dd','#98d8c8','#f7dc6f'];
const CAT_BREED_AVATARS = [
{ breed:'英国短毛猫', icon:'🐱', imageUrl:'https://loremflickr.com/320/320/cat-face,closeup,portrait,british-shorthair?lock=101', name:'团子' },
{ breed:'美国短毛猫', icon:'🐱', imageUrl:'https://loremflickr.com/320/320/cat-face,closeup,portrait,american-shorthair?lock=102', name:'年糕' },
{ breed:'布偶猫', icon:'🐱', imageUrl:'https://loremflickr.com/320/320/cat-face,closeup,portrait,ragdoll?lock=103', name:'奶糖' },
{ breed:'暹罗猫', icon:'🐱', imageUrl:'https://loremflickr.com/320/320/cat-face,closeup,portrait,siamese?lock=104', name:'墨璃' },
{ breed:'波斯猫', icon:'🐱', imageUrl:'https://loremflickr.com/320/320/cat-face,closeup,portrait,persian-cat?lock=105' },
{ breed:'缅因猫', icon:'🐱', imageUrl:'https://loremflickr.com/320/320/cat-face,closeup,portrait,maine-coon?lock=106', name:'雷欧' },
{ breed:'挪威森林猫', icon:'🐱', imageUrl:'https://loremflickr.com/320/320/cat-face,closeup,portrait,norwegian-forest-cat?lock=107' },
{ breed:'俄罗斯蓝猫', icon:'🐱', imageUrl:'https://loremflickr.com/320/320/cat-face,closeup,portrait,russian-blue?lock=108' },
{ breed:'孟加拉猫', icon:'🐱', imageUrl:'https://loremflickr.com/320/320/cat-face,closeup,portrait,bengal-cat?lock=109' },
{ breed:'斯芬克斯猫', icon:'🐱', imageUrl:'https://loremflickr.com/320/320/cat-face,closeup,portrait,sphynx-cat?lock=110' },
{ breed:'阿比西尼亚猫', icon:'🐱', imageUrl:'https://loremflickr.com/320/320/cat-face,closeup,portrait,abyssinian-cat?lock=111' },
{ breed:'苏格兰折耳猫', icon:'🐱', imageUrl:'https://loremflickr.com/320/320/cat-face,closeup,portrait,scottish-fold?lock=112' }
];
const PROVIDERS = {
openai: { name:'OpenAI',icon:'🟢',defaultUrl:'https://api.openai.com/v1/chat/completions',urlHint:'支持所有 OpenAI 兼容接口',models:['gpt-4o','gpt-4o-mini','gpt-4-turbo','gpt-3.5-turbo','deepseek-chat','qwen-turbo'],defaultModel:'gpt-4o-mini',badgeClass:'openai' },
claude: { name:'Claude',icon:'🟠',defaultUrl:'https://api.anthropic.com/v1/messages',urlHint:'Anthropic 官方或代理地址',models:['claude-sonnet-4-20250514','claude-haiku-4-20250414','claude-3-5-sonnet-20241022','claude-3-opus-20240229'],defaultModel:'claude-sonnet-4-20250514',badgeClass:'claude' },
glm: { name:'GLM',icon:'🔵',defaultUrl:'https://open.bigmodel.cn/api/paas/v4/chat/completions',urlHint:'智谱 AI 开放平台',models:['glm-4-plus','glm-4-flash','glm-4-air','glm-4-long','glm-4'],defaultModel:'glm-4-flash',badgeClass:'glm' },
siliconflow: { name:'硅基流动',icon:'🟣',defaultUrl:'https://api.siliconflow.cn/v1/chat/completions',urlHint:'SiliconFlow OpenAI 兼容接口',models:['Pro/zai-org/GLM-4.7','deepseek-ai/DeepSeek-V3','Qwen/Qwen2.5-72B-Instruct','THUDM/glm-4-9b-chat'],defaultModel:'Pro/zai-org/GLM-4.7',badgeClass:'siliconflow' },
custom: { name:'自定义中转',icon:'⚙️',defaultUrl:'',urlHint:'填写你的中转站完整 URL(不自动补全路径)',models:[],defaultModel:'custom-model',badgeClass:'custom' }
};
const WEREWOLF_ROLES = [
{ id:'werewolf',name:'狼人',icon:'🐺',team:'wolf',desc:'每晚可以选择猎杀一名玩家' },
{ id:'villager',name:'村民',icon:'👨🌾',team:'good',desc:'没有特殊能力但投票至关重要' },
{ id:'seer',name:'预言家',icon:'🔮',team:'good',desc:'每晚可查验一名玩家身份' },
{ id:'witch',name:'女巫',icon:'🧪',team:'good',desc:'拥有一瓶解药和一瓶毒药' },
{ id:'hunter',name:'猎人',icon:'🏹',team:'good',desc:'被淘汰时可开枪带走一人' },
{ id:'guard',name:'守卫',icon:'🛡️',team:'good',desc:'每晚可以守护一名玩家' },
{ id:'fool',name:'白痴',icon:'🤹',team:'good',desc:'白天被放逐时可翻牌免死一次' }
];
const MONITOR_CONFIG_STORAGE_KEY = 'catchat.monitor.config.v1';
const TTS_VOICE_MAP_STORAGE_KEY = 'catchat.tts.voice.map.v1';
const TTS_SETTINGS_STORAGE_KEY = 'catchat.tts.settings.v1';
const PIPELINE_OUTPUT_DIR_STORAGE_KEY = 'catchat.pipeline.output.dir.v1';
const PIPELINE_TIMEOUT_SEC_STORAGE_KEY = 'catchat.pipeline.timeout.sec.v1';
const WEREWOLF_AUTO_ADVANCE_DELAY_MS = 12000;
const WEREWOLF_BACKEND_AUTO_ADVANCE_DELAY_MS = 1200;
// ====================== State ======================
let cats = [], messages = [];
let replyingTo = null; // { messageId, content, senderName } 当前正在回复的消息
let selectedEmoji = '🐱', selectedColor = '#f582ae', selectedProvider = 'openai';
let selectedCustomCompat = 'openai';
let selectedAvatarUrl = '';
let selectedBreed = CAT_BREED_AVATARS[0].breed;
let gameMode = 'discuss', judgeView = true;
let wfState = {
active:false,
phase:'idle',
round:0,
roles:{},
eliminated:[],
eliminatedCauseByCatId:{},
phaseMessages:[],
backendLinked:true,
linkedRoomId:'',
hideNightRoleForAudience:true
};
let wfAutoAdvanceTimer = null;
let plState = { active:false, phase:'idle', requirement:'', outputDir:'', timeoutMs:0, roles:{}, results:{}, useClaudeCodeCli:false, mood:3 };
let cliProxy = { enabled: false, url: 'http://localhost:3456', connected: false };
let dbState = { active:false, round:0, maxRounds:2, turnIndex:0, order:[], queue:[], speaking:false };
let monitorState = {
apiBase: 'http://127.0.0.1:8000',
roomId: '',
ownerId: 'cat_01',
playerCount: 11,
viewMode: 'god',
ws: null,
isConnected: false,
chatWs: null,
chatWsRoomId: '',
phaseLog: [],
speechTimeline: [],
speechSeenKeys: {},
speechRenderedKeys: {},
narrationSeenKeys: {},
lastStateOrder: -1,
wsLastEventId: 0,
pendingRoomState: null,
roomStateFlushScheduled: false,
phaseStatePullTimer: null,
pendingPhaseChangedPayload: null,
players: [],
playerMap: {},
playerBindings: {},
catOnlineById: {},
agentHost: 'http://127.0.0.1',
agentStartPort: 9101,
modelApiUrl: '',
modelApiKey: '',
modelName: '',
cliCommand: '',
aiGod: false,
godCatId: '',
hideNightRoleForAudience: true,
showThoughtInMonitor: true
};
let monitorForceApplying = false;
// ====================== Autonomous Chat State ======================
let autoChat = {
enabled: false,
idleSeconds: 30,
reactChance: 0.4,
idleTimer: null,
lastActivityTime: Date.now(),
consecutiveAuto: 0,
maxConsecutive: 3,
reacting: false
};
const AUTOCHAT_STORAGE_KEY = 'catchat.autochat.config.v1';
let ttsState = {
enabled: true,
rate: 1,
volume: 1,
initialized: false,
supported: typeof window !== 'undefined' && typeof window.speechSynthesis !== 'undefined' && typeof window.SpeechSynthesisUtterance !== 'undefined',
voices: [],
voiceMap: {}
};
function ttsSaveSettings() {
try {
localStorage.setItem(TTS_SETTINGS_STORAGE_KEY, JSON.stringify({
enabled: !!ttsState.enabled,
rate: Number(ttsState.rate || 1),
volume: Number(ttsState.volume || 1)
}));
} catch (_) {}
}
function ttsLoadSettings() {
try {
var raw = localStorage.getItem(TTS_SETTINGS_STORAGE_KEY);
if (!raw) return;
var parsed = JSON.parse(raw);
if (!parsed || typeof parsed !== 'object') return;
if (typeof parsed.enabled === 'boolean') ttsState.enabled = parsed.enabled;
if (Number.isFinite(parsed.rate)) ttsState.rate = Math.max(0.6, Math.min(1.6, Number(parsed.rate)));
if (Number.isFinite(parsed.volume)) ttsState.volume = Math.max(0, Math.min(1, Number(parsed.volume)));
} catch (_) {}
}
function ttsUpdateSettingsUI() {
var cb = document.getElementById('ttsEnabled');
var label = document.getElementById('ttsEnabledLabel');
var rate = document.getElementById('ttsRate');
var rateValue = document.getElementById('ttsRateValue');
var volume = document.getElementById('ttsVolume');
var volumeValue = document.getElementById('ttsVolumeValue');
if (!cb || !label || !rate || !rateValue || !volume || !volumeValue) return;
cb.checked = !!ttsState.enabled;
label.textContent = ttsState.enabled ? '已启用' : '未启用';
label.style.color = ttsState.enabled ? '#16a34a' : '';
rate.value = String(Number(ttsState.rate || 1));
rateValue.textContent = Number(ttsState.rate || 1).toFixed(2) + 'x';
volume.value = String(Number(ttsState.volume == null ? 1 : ttsState.volume));
volumeValue.textContent = Math.round(Number(ttsState.volume == null ? 1 : ttsState.volume) * 100) + '%';
var disabled = !ttsState.supported;
cb.disabled = disabled;
rate.disabled = disabled;
volume.disabled = disabled;
if (disabled) {
label.textContent = '浏览器不支持';
label.style.color = '#9ca3af';
}
}
function ttsHash(text) {
var raw = String(text || '');
var h = 0;
for (var i = 0; i < raw.length; i++) {
h = (h * 31 + raw.charCodeAt(i)) >>> 0;
}
return h;
}
function ttsLoadVoiceMap() {
try {
var raw = localStorage.getItem(TTS_VOICE_MAP_STORAGE_KEY);
if (!raw) return {};
var parsed = JSON.parse(raw);
return (parsed && typeof parsed === 'object') ? parsed : {};
} catch (_) {
return {};
}
}
function ttsSaveVoiceMap() {
try {
localStorage.setItem(TTS_VOICE_MAP_STORAGE_KEY, JSON.stringify(ttsState.voiceMap || {}));
} catch (_) {}
}
function ttsRefreshVoices() {
if (!ttsState.supported) return;
var all = window.speechSynthesis.getVoices() || [];
var zh = all.filter(function(v) { return /^zh/i.test(v.lang || ''); });
ttsState.voices = zh.length ? zh : all;
}
function ttsEnsureSpeakerAssignments() {
if (!ttsState.supported) return;
if (!Array.isArray(ttsState.voices) || !ttsState.voices.length) return;
var map = ttsState.voiceMap || {};
var keys = ['judge', 'owner'];
cats.forEach(function(cat) {
if (cat && cat.id) keys.push(cat.id);
});
keys.forEach(function(key) {
if (map[key]) return;
var idx = ttsHash(key) % ttsState.voices.length;
map[key] = ttsState.voices[idx].voiceURI;
});
ttsState.voiceMap = map;
ttsSaveVoiceMap();
}
function ttsInit() {
if (!ttsState.supported || ttsState.initialized) return;
ttsState.initialized = true;
ttsLoadSettings();
ttsState.voiceMap = ttsLoadVoiceMap();
ttsRefreshVoices();
ttsEnsureSpeakerAssignments();
if (typeof window.speechSynthesis.onvoiceschanged !== 'undefined') {
window.speechSynthesis.onvoiceschanged = function() {
ttsRefreshVoices();
ttsEnsureSpeakerAssignments();
};
}
document.addEventListener('click', function() {
try { window.speechSynthesis.resume(); } catch (_) {}
}, { once: true });
}
function ttsNormalizeText(text) {
var raw = String(text || '');
raw = raw.replace(/\[[^\]]+\]/g, '');
raw = raw.replace(/【[^】]{1,30}】/g, '');
raw = raw.replace(/[\[{((]\s*(?:第\s*\d+\s*[轮回局天夜]|第\s*\d+\s*轮|夜晚|白天|系统|旁白|公告|播报|阶段|回合|投票|讨论)\s*[\]}))]/g, '');
raw = raw.replace(/(?:^|[,。;、\s])(?:第\s*\d+\s*轮|第\s*\d+\s*[天夜]|夜晚|白天|系统|旁白|公告|播报|阶段|回合)\s*[::]/g, ' ');
raw = raw.replace(/[\u{1F300}-\u{1FAFF}\u{2600}-\u{27BF}\u{FE0F}]/gu, '');
raw = raw.replace(/[((]\s*(?:角色|身份|职业)\s*[::]\s*[^))]+[))]/g, '');
raw = raw.replace(/[((]\s*(?:狼人|村民|预言家|女巫|猎人|守卫|白痴|法官|上帝|AI法官)\s*[))]/g, '');
raw = raw.replace(/(?:^|[,。;、\s])(?:角色|身份|职业)\s*[::]\s*(?:狼人|村民|预言家|女巫|猎人|守卫|白痴|法官|上帝|AI法官)(?=$|[,。;、\s])/g, ' ');
raw = raw.replace(/^\s*(?:狼人|村民|预言家|女巫|猎人|守卫|白痴|法官|上帝|AI法官)\s*[::]\s*/g, '');
raw = raw.replace(/^\s*[^,。;、::]{1,20}[((]\s*(?:狼人|村民|预言家|女巫|猎人|守卫|白痴|法官|上帝|AI法官)\s*[))]\s*[::]?\s*/g, '');
raw = raw.replace(/\s*[((]\s*(?:狼人|村民|预言家|女巫|猎人|守卫|白痴|法官|上帝|AI法官)\s*[))]\s*/g, ' ');
raw = raw.replace(/^\s*(?:系统|旁白|公告|播报|阶段|回合|第\s*\d+\s*轮|第\s*\d+\s*[天夜])\s*[::\-—]+\s*/g, '');
raw = raw.replace(/^\s*(?:\d+\.|\d+、|[-•·])\s*/g, '');
raw = raw.replace(/[\r\n]+/g, ',');
raw = raw.replace(/\s+/g, ' ').trim();
if (raw.length > 1200) raw = raw.slice(0, 1200);
return raw;
}
function ttsSplitSegments(text) {
var normalized = String(text || '').trim();
if (!normalized) return [];
var parts = normalized.split(/(?<=[。!?!?;;])/);
var maxLen = 90;
var segments = [];
var current = '';
parts.forEach(function(part) {
var p = String(part || '').trim();
if (!p) return;
if (!current) {
current = p;
return;
}
if ((current + p).length <= maxLen) {
current += p;
} else {
segments.push(current);
current = p;
}
});
if (current) segments.push(current);
var flat = [];
segments.forEach(function(seg) {
if (seg.length <= maxLen) {
flat.push(seg);
return;
}
for (var i = 0; i < seg.length; i += maxLen) {
flat.push(seg.slice(i, i + maxLen));
}
});
return flat.slice(0, 20);
}
function ttsInferSystemSpeaker(text, cls) {
var t = String(text || '');
var c = String(cls || '');
if (/法官|AI法官|上帝视角/.test(t)) return { key: 'judge', name: '法官' };
if (/^⚖️|^🤖/.test(t)) return { key: 'judge', name: '法官' };
if (c.indexOf('pipeline-msg') !== -1 && /投票|出局|天亮|天黑/.test(t)) return { key: 'judge', name: '法官' };
return null;
}
function ttsSpeak(speakerKey, speakerName, text) {
if (!ttsState.supported || !ttsState.enabled) return;
var content = ttsNormalizeText(text);
if (!content) return;
if (!ttsState.voices.length) ttsRefreshVoices();
if (!ttsState.voices.length) return;
if (!ttsState.voiceMap[speakerKey]) {
var idx = ttsHash(speakerKey) % ttsState.voices.length;
ttsState.voiceMap[speakerKey] = ttsState.voices[idx].voiceURI;
ttsSaveVoiceMap();
}
var voice = ttsState.voices.find(function(v) {
return v.voiceURI === ttsState.voiceMap[speakerKey];
}) || ttsState.voices[0];
if (!voice) return;
var segments = ttsSplitSegments(content);
if (!segments.length) return;
segments.forEach(function(seg) {
var utter = new SpeechSynthesisUtterance(seg);
utter.voice = voice;
utter.lang = voice.lang || 'zh-CN';
utter.volume = Math.max(0, Math.min(1, Number(ttsState.volume == null ? 1 : ttsState.volume)));
if (speakerKey === 'judge') {
utter.rate = Math.max(0.6, Math.min(1.6, Number(ttsState.rate || 1) * 0.96));
utter.pitch = 0.9;
} else {
utter.rate = Math.max(0.6, Math.min(1.6, Number(ttsState.rate || 1)));
utter.pitch = 1.08;
}
try {
window.speechSynthesis.speak(utter);
} catch (_) {}
});
}
function monitorPhaseLabel(phase) {
var map = {
prepare: '准备阶段',
night_wolf_discuss: '夜晚·狼人讨论',
night_wolf: '夜晚·狼人行动',
night_guard: '夜晚·守卫行动',
night_witch: '夜晚·女巫行动',
night_seer: '夜晚·预言家查验',
day_announce: '白天·法官播报',
day_discuss: '白天·讨论阶段',
day_vote: '白天·投票阶段',
game_over: '游戏结束'
};
return map[phase] || phase || '未知阶段';
}
function monitorPhaseOrder(phase) {
var map = {
prepare: 0,
night_wolf_discuss: 1,
night_wolf: 2,
night_guard: 3,
night_witch: 4,
night_seer: 5,
day_announce: 6,
day_discuss: 7,
day_vote: 8,
game_over: 9
};
return map[phase] != null ? map[phase] : 99;
}
function monitorStateOrderValue(state) {
var roundNo = parseInt((state && state.round_no), 10);
if (isNaN(roundNo) || roundNo < 0) roundNo = 0;
return roundNo * 100 + monitorPhaseOrder((state && state.phase) || '');
}
function monitorSortSpeechHistory(rows) {
return (rows || []).slice().sort(function(a, b) {
var ta = Date.parse((a && a.timestamp) || '') || 0;
var tb = Date.parse((b && b.timestamp) || '') || 0;
if (ta !== tb) return ta - tb;
var pa = monitorPhaseOrder((a && a.phase) || '');
var pb = monitorPhaseOrder((b && b.phase) || '');
if (pa !== pb) return pa - pb;
var aa = (a && a.player_id) || '';
var bb = (b && b.player_id) || '';
return aa.localeCompare(bb);
});
}
function monitorDeathCauseLabel(cause) {
var map = {
wolf: '被狼人袭击',
poison: '被女巫毒杀',
vote: '被投票放逐',
hunter: '被猎人带走'
};
return map[cause] || cause || '未知原因';
}
function werewolfEliminatedCauseLabel(cause) {
var map = {
wolf: '被狼人刀',
poison: '被女巫毒杀',
vote: '被投死',
hunter: '被猎人带走'
};
return map[cause] || '淘汰';
}
function monitorPlayerName(state, playerId) {
var players = (state && state.players) || [];
var p = players.find(function(item) { return item.player_id === playerId; });
return (p && p.nickname) || playerId;
}
function monitorNarrateOnce(key, text, cls) {
if (!key || !text) return;
if (monitorState.narrationSeenKeys[key]) return;
monitorState.narrationSeenKeys[key] = true;
addSystemMessage(text, cls || 'vote-msg');
}
function monitorNarrateFromPhaseChanged(payload) {
if (!payload || !payload.god_view || monitorState.viewMode !== 'god') return;
var roomId = monitorState.roomId || '-';
var consensus = payload.god_view.consensus_target || '';
if (!consensus) return;
var key = ['godview', roomId, payload.phase || '-', consensus].join('|');
var prefix = payload.phase === 'night_wolf' ? '⚖️ 法官(上帝视角):狼人讨论后目标一致为 ' : '⚖️ 法官(上帝视角):狼人夜间目标倾向 ';
monitorNarrateOnce(key, prefix + consensus + '。', 'pipeline-msg');
}
function monitorNarrateFromRoomState(state) {
if (!state) return;
if (monitorState.aiGod) return;
var roomId = state.room_id || monitorState.roomId || '-';
var roundNo = state.round_no || 0;
var phase = state.phase || 'unknown';
var phaseKey = ['phase', roomId, roundNo, phase].join('|');
switch (phase) {
case 'night_wolf_discuss':
monitorNarrateOnce(phaseKey, '⚖️ 法官:天黑请闭眼,狼人请睁眼。先进入夜间讨论阶段,交换判断并达成一致目标。', 'pipeline-msg');
break;
case 'night_wolf':
monitorNarrateOnce(phaseKey, '⚖️ 法官:天黑请闭眼,狼人请睁眼并执行最终猎杀目标。', 'pipeline-msg');
break;
case 'night_guard':
monitorNarrateOnce(phaseKey, '⚖️ 法官:守卫请行动,选择今晚守护对象。', 'pipeline-msg');
break;
case 'night_witch':
monitorNarrateOnce(phaseKey, '⚖️ 法官:女巫请行动,决定是否使用解药或毒药。', 'pipeline-msg');
break;
case 'night_seer':
monitorNarrateOnce(phaseKey, '⚖️ 法官:预言家请查验一名玩家身份。', 'pipeline-msg');
break;
case 'day_announce':
monitorNarrateOnce(phaseKey, '⚖️ 法官:天亮了,现在公布昨夜结果。', 'pipeline-msg');
break;
case 'day_discuss':
monitorNarrateOnce(phaseKey, '⚖️ 法官:进入白天讨论环节,请各位依次发言。', 'pipeline-msg');
var aliveDiscuss = ((state.players || []).filter(function(p) { return !!p.alive; })).map(function(p) {
return p.nickname || p.player_id;
});
var discussOrderKey = ['discuss_order', roomId, roundNo].join('|');
if (aliveDiscuss.length > 0) {
monitorNarrateOnce(
discussOrderKey,
'⚖️ 法官点名发言顺序:' + aliveDiscuss.join(' → '),
'pipeline-msg'
);
}
break;
case 'day_vote':
monitorNarrateOnce(phaseKey, '⚖️ 法官:进入投票环节,请选择你要放逐的对象。', 'pipeline-msg');
var aliveVote = ((state.players || []).filter(function(p) { return !!p.alive && !!p.can_vote; })).map(function(p) {
return p.nickname || p.player_id;
});
var voteOptionKey = ['vote_options', roomId, roundNo].join('|');
if (aliveVote.length > 0) {
monitorNarrateOnce(
voteOptionKey,
'⚖️ 法官:当前可投票玩家:' + aliveVote.join('、'),
'vote-msg'
);
}
break;
}
if (phase === 'day_announce') {
var deaths = state.deaths_this_round || {};
var deathIds = Object.keys(deaths);
var deathKey = ['death', roomId, roundNo, deathIds.sort().join(',')].join('|');
if (deathIds.length === 0) {
monitorNarrateOnce(deathKey, '⚖️ 法官:昨夜是平安夜,无人出局。', 'vote-msg');
} else {
deathIds.forEach(function(playerId) {
var cause = deaths[playerId];
var text = '⚖️ 法官:' + monitorPlayerName(state, playerId) + ' 出局(' + monitorDeathCauseLabel(cause) + ')。';
var key = ['death', roomId, roundNo, playerId, cause].join('|');
monitorNarrateOnce(key, text, 'vote-msg');
});
}
}
if (state.game_over) {
var winner = state.winner || 'unknown';
var gameOverKey = ['game_over', roomId, winner].join('|');
var winnerText = winner === 'wolf' ? '狼人阵营' : (winner === 'good' ? '好人阵营' : winner);
monitorNarrateOnce(gameOverKey, '🏁 法官:游戏结束,' + winnerText + ' 获胜。', 'pipeline-msg');
}
}
function werewolfMapBackendPhase(phase) {
if (!phase) return 'night';
if (phase.indexOf('night_') === 0) return 'night';
if (phase === 'day_vote') return 'vote';
if (phase === 'day_announce' || phase === 'day_discuss') return 'day';
if (phase === 'game_over') return 'day';
return 'night';
}
function werewolfRoleMeta(roleId) {
var found = WEREWOLF_ROLES.find(function(item) { return item.id === roleId; });
if (found) return found;
return { id: roleId || 'unknown', name: roleId || '未知', icon: '🎭', team: 'good' };
}
function werewolfSyncButtonsByState() {
var startBtn = document.getElementById('wpStartBtn');
var nextBtn = document.getElementById('wpNextBtn');
var revealBtn = document.getElementById('wpRevealBtn');
var endBtn = document.getElementById('wpEndBtn');
if (!startBtn || !nextBtn || !revealBtn || !endBtn) return;
startBtn.disabled = wfState.active;
nextBtn.disabled = !wfState.active;
endBtn.disabled = !wfState.active;
revealBtn.disabled = true;
}
function werewolfAutoDelayMs() {
return WEREWOLF_BACKEND_AUTO_ADVANCE_DELAY_MS;
}
function werewolfStopAutoAdvance() {
if (wfAutoAdvanceTimer) {
clearTimeout(wfAutoAdvanceTimer);
wfAutoAdvanceTimer = null;
}
}
function werewolfScheduleAutoAdvance(delayMs) {
werewolfStopAutoAdvance();
if (!wfState.active) return;
var nextDelay = typeof delayMs === 'number' ? delayMs : werewolfAutoDelayMs();
wfAutoAdvanceTimer = setTimeout(function() {
if (!wfState.active) return;
werewolfNextPhase(true);
}, nextDelay);
}
function werewolfStartAutoAdvance() {
if (!wfState.active) return;
werewolfScheduleAutoAdvance(werewolfAutoDelayMs());
}
function werewolfRefreshLinkButton() {
return;
}
function werewolfShouldHideNightRoleBadge(isNight) {
return gameMode === 'werewolf' && !!isNight && !judgeView && !!wfState.hideNightRoleForAudience;
}
function werewolfSyncFromBackendState(state) {
if (wfState.linkedRoomId && state.room_id && state.room_id !== wfState.linkedRoomId) return;
var players = state.players || [];
wfState.active = !!state.started && !state.game_over;
wfState.phase = werewolfMapBackendPhase(state.phase);
wfState.round = state.round_no || wfState.round || 1;
var eliminated = [];
var eliminatedCauseByCatId = {};
var linkedRoles = {};
players.forEach(function(p, idx) {
var bound = monitorState.playerBindings[p.player_id] || {};
if (!bound.catId && p && p.nickname) {
var foundByName = cats.find(function(cat) { return (cat.name || '').trim() === (p.nickname || '').trim(); });
if (foundByName) {
bound = {
catId: foundByName.id,
nickname: foundByName.name,
breed: foundByName.breed,
color: foundByName.color,
emoji: foundByName.emoji,
avatarUrl: foundByName.avatarUrl || ''
};
monitorState.playerBindings[p.player_id] = bound;
}
}
if (!bound.catId) {
var catByIndex = cats[idx];
if (catByIndex) {
bound = {
catId: catByIndex.id,
nickname: catByIndex.name,
breed: catByIndex.breed,
color: catByIndex.color,
emoji: catByIndex.emoji,
avatarUrl: catByIndex.avatarUrl || ''
};
monitorState.playerBindings[p.player_id] = bound;
}
}
var catId = bound.catId;
if (catId) {
if (!p.alive) {
eliminated.push(catId);
if (p.death_cause) eliminatedCauseByCatId[catId] = p.death_cause;
}
if (p.role) linkedRoles[catId] = werewolfRoleMeta(p.role);
}
});
wfState.eliminated = eliminated;
wfState.eliminatedCauseByCatId = eliminatedCauseByCatId;
wfState.roles = linkedRoles;
werewolfSyncButtonsByState();
updateWerewolfStatus();
renderMembers();
if (state.game_over) {
werewolfStopAutoAdvance();
addSystemMessage('🏁 联动房间已结束,胜利方:' + (state.winner || '未知'), 'vote-msg');
}
}
function werewolfPseudoCat(playerId) {
var idx = Math.abs((playerId || '').split('').reduce(function(acc, ch) {
return acc + ch.charCodeAt(0);
}, 0)) % catColors.length;
var avatar = CAT_BREED_AVATARS[idx % CAT_BREED_AVATARS.length];
var mapped = monitorState.playerMap[playerId] || {};
var bound = monitorState.playerBindings[playerId] || {};
var roleMeta = null;
if (mapped.role) {
roleMeta = werewolfRoleMeta(mapped.role);
} else if (bound.catId && wfState.roles && wfState.roles[bound.catId]) {
roleMeta = wfState.roles[bound.catId];
}
return {
id: 'linked_' + playerId,
name: bound.nickname || mapped.nickname || playerId,
emoji: bound.emoji || avatar.icon,
color: bound.color || catColors[idx],
breed: bound.breed || mapped.breed || avatar.breed,
avatarUrl: bound.avatarUrl || '',
role: roleMeta
};
}
function monitorSanitizeDayDiscussDisplayText(text) {
var speech = String(text || '').trim();
if (!speech) return speech;
var replaced = speech;
[
['暴露狼人身份', '暴露真实身份'],
['狼人身份', '真实身份'],
['(狼人)', '(疑似狼人)'],
['就是狼人', '疑似狼人'],
['必是狼人', '疑似狼人'],
['是狼人', '疑似狼人'],
['为狼人', '疑似狼人']
].forEach(function(pair) {
replaced = replaced.split(pair[0]).join(pair[1]);
});
return replaced;
}
function werewolfRenderLinkedSpeech(entry) {
if (!entry) return;
// Handle god_narration entries from AI God Orchestrator
if (entry.event === 'god_narration') {
var godContent = (entry.content || '').trim();
if (!godContent) return;
var prefix = entry.is_fallback ? '⚖️ 法官(托管):' : '🤖 AI法官:';
addSystemMessage(prefix + godContent, 'pipeline-msg');
return;
}
if (entry.player_id === 'god') {
var settleContent = (entry.content || '').trim();
if (!settleContent) return;
addSystemMessage('⚖️ 法官结算:' + settleContent, 'judge-settle-msg');
return;
}
if (!entry.player_id) return;
var inWerewolfLinked = (gameMode === 'werewolf' && wfState.backendLinked);
var inMonitorMode = (gameMode === 'monitor');
if (!inWerewolfLinked && !inMonitorMode) return;
var cat = werewolfPseudoCat(entry.player_id);
var isNight = (entry.phase || '').indexOf('night_') === 0;
var phaseMap = {
night_wolf_discuss: '🌙 狼人讨论',
night_wolf: '🌙 狼人行动',
night_guard: '🌙 守卫行动',
night_witch: '🌙 女巫行动',
night_seer: '🌙 预言家查验',
day_discuss: '☀️ 白天讨论',
day_vote: '🗳️ 白天投票',
hunter_shot: '🏹 猎人开枪'
};
var phaseLabel = phaseMap[entry.phase] || monitorPhaseLabel(entry.phase);
var content = (entry.content || '').trim();
if (!content) content = '(无文本返回)';
if (entry.phase === 'day_discuss') {
content = monitorSanitizeDayDiscussDisplayText(content);
}
if (entry.phase === 'night_wolf_discuss') {
content = '【讨论】' + content;
}
if (entry.is_fallback) {
if (/^fallback\//i.test(content)) {
content = '系统降级托管:' + content.replace(/^fallback\//i, '');
}
if (entry.fallback_reason) {
content += '(fallback: ' + entry.fallback_reason + ')';
} else {
content += '(fallback)';
}
}
addCatMessage(cat, '【' + phaseLabel + '】' + content, isNight);
var thought = (entry.thought_content || '').trim();
var canShowThought = (gameMode === 'monitor' && !!monitorState.showThoughtInMonitor) || (gameMode === 'werewolf' && judgeView);
if (thought && canShowThought) {
addSystemMessage('🧠 ' + cat.name + '(仅法官可见思考):' + thought, 'pipeline-msg thought-msg', { speaker: { key: '' } });
monitorApplyThoughtVisibility();
}
}
function monitorApplyThoughtVisibility() {
var show = !(gameMode === 'monitor' && !monitorState.showThoughtInMonitor);
document.querySelectorAll('.thought-msg').forEach(function(el) {
el.style.display = show ? '' : 'none';
});
}
function monitorToggleThoughtVisibility() {
var el = document.getElementById('monitorShowThought');
monitorState.showThoughtInMonitor = !(el && el.checked === false);
monitorPersistConfig();
monitorApplyThoughtVisibility();
monitorRenderSpeech();
}
function wpToggleAiGod() {
if (wfState.active) {
var wpCb = document.getElementById('wpAiGodToggle');
if (wpCb) wpCb.checked = !!monitorState.aiGod;
showToast('⚠️ 游戏已开始,不能再切换 AI 法官模式');
return;
}
var checked = document.getElementById('wpAiGodToggle').checked;
var sec = document.getElementById('wpAiGodConfig');
if (sec) sec.style.display = checked ? 'block' : 'none';
// Sync to monitor panel checkbox
var mnCb = document.getElementById('monitorAiGod');
if (mnCb) mnCb.checked = checked;
var mnSec = document.getElementById('monitorGodConfig');
if (mnSec) mnSec.style.display = checked ? 'block' : 'none';
monitorState.aiGod = checked;
monitorSyncPlayerCountFromCats();
monitorPersistConfig();
renderMembers();
}
function wpToggleNightRoleMask() {
var el = document.getElementById('wpHideNightRole');
wfState.hideNightRoleForAudience = !(el && el.checked === false);
monitorState.hideNightRoleForAudience = !!wfState.hideNightRoleForAudience;
monitorPersistConfig();
refreshWerewolfVisibility();
}
function monitorRenderGodCatSelectors() {
var monitorSel = document.getElementById('monitorGodCatId');
var wpSel = document.getElementById('wpGodCatId');
if (!monitorSel && !wpSel) return;
var current = String(monitorState.godCatId || '');
var hasCurrent = cats.some(function(cat) { return cat && cat.id === current; });
if (!hasCurrent) {
current = cats.length ? cats[0].id : '';
monitorState.godCatId = current;
}
var options = cats.map(function(cat) {
return '<option value="' + escapeHtml(cat.id) + '">' + escapeHtml(cat.name) + '</option>';
}).join('');
if (!options) {
options = '<option value="">暂无猫猫</option>';
}
[monitorSel, wpSel].forEach(function(sel) {
if (!sel) return;
sel.innerHTML = options;
sel.value = current;
sel.disabled = cats.length === 0;
});
}
function monitorPlayableCats() {
if (!monitorState.aiGod || !monitorState.godCatId) return cats.slice();
return cats.filter(function(cat) {
return cat && cat.id !== monitorState.godCatId;
});
}
function monitorLockGodConfigIfStarted() {
var started = !!wfState.active;
['monitorAiGod', 'wpAiGodToggle', 'monitorGodCatId', 'wpGodCatId'].forEach(function(id) {
var el = document.getElementById(id);
if (!el) return;
el.disabled = started;
});
}
function monitorOnGodCatChange(source) {
if (wfState.active) {
showToast('⚠️ 游戏已开始,不能再修改 AI 法官');
monitorRenderGodCatSelectors();
return;
}
var from = source === 'wp' ? document.getElementById('wpGodCatId') : document.getElementById('monitorGodCatId');
var val = (from && from.value) ? from.value : '';
monitorState.godCatId = val;
var monitorSel = document.getElementById('monitorGodCatId');
var wpSel = document.getElementById('wpGodCatId');
if (monitorSel) monitorSel.value = val;
if (wpSel) wpSel.value = val;
monitorPersistConfig();
renderMembers();
}
function monitorJudgeModeLabel(data) {
var isAi = !!(data && data.ai_god);
if (!isAi) return '系统法官';
var judgeName = (data && data.god_cat_name) || '';
if (!judgeName) {
var judgeId = (data && data.god_cat_id) || monitorState.godCatId;
var found = cats.find(function(cat) { return cat && cat.id === judgeId; });
judgeName = found ? found.name : '';
}
return judgeName ? ('AI法官(' + judgeName + ')') : 'AI法官';
}
function werewolfToggleBackendLink() {
wfState.backendLinked = true;
werewolfSyncButtonsByState();
}
// Pipeline role definitions with preset system prompts
var PIPELINE_ROLES = {
developer: {
id:'developer', name:'架构师 & 开发工程师', icon:'🛠️', tag:'pp-role-dev',
systemPrompt: function(req) {
return '你是一位经验丰富的全栈开发工程师和架构师。你的职责是根据需求进行功能模块设计并完成代码开发。\n\n【工作规范】\n1. 先进行模块设计:分析需求,拆解功能模块,给出架构设计方案\n2. 再进行代码实现:输出完整的、可运行的代码\n3. 代码必须包含必要的注释和文档字符串\n4. 考虑边界场景和错误处理\n5. 遵循最佳实践和设计模式\n\n【输出格式】\n请按以下结构输出:\n## 📐 模块设计\n- 架构概述\n- 模块拆解\n- 接口设计\n\n## 💻 代码实现\n(完整的代码)\n\n## 📝 设计说明\n- 关键设计决策\n- 技术选型理由\n\n保持猫咪口吻,可以加入“喵”等语气词,但技术内容必须专业严谨。';
},
taskPrompt: function(req) {
return '【铲屎官需求】\n' + req + '\n\n请开始进行功能模块设计和代码开发。注意架构设计要清晰,代码要完整可运行。';
}
},
reviewer: {
id:'reviewer', name:'代码检视专家', icon:'🔍', tag:'pp-role-review',
systemPrompt: function(req) {
return '你是一位严谨的代码检视专家(Code Reviewer)。你的职责是对开发工程师提交的代码进行全面检视。\n\n【检视规范】\n1. 代码质量:可读性、命名规范、代码风格\n2. 架构设计:模块划分、职责分离、设计模式\n3. 潜在问题:BUG、安全漏洞、性能问题、资源泄漏\n4. 错误处理:异常处理是否完善、边界场景考虑\n5. 最佳实践:是否符合行业规范\n6. 建议改进:提出具体的优化建议和改进方案\n\n【输出格式】\n请按以下结构输出:\n## 🔍 代码检视报告\n\n### ✅ 优点\n(列举代码中做得好的部分)\n\n### ⚠️ 问题与建议\n(按严重程度排序,每个问题给出具体位置和修改建议)\n\n### 🚨 严重问题 (必须修复)\n### 🟡 一般问题 (建议修改)\n### 🟢 小问题 (可以优化)\n\n### 📊 总体评价\n(给出总体评分和结论:通过 / 有条件通过 / 不通过)\n\n保持猫咪口吻但内容必须专业严谹,每个问题要给出具体地方和代码建议。';
},
taskPrompt: function(req, devOutput) {
return '【原始需求】\n' + req + '\n\n【开发工程师提交的代码】\n' + devOutput + '\n\n请对以上代码进行全面的代码检视,给出专业详细的检视报告。';
}
},
tester: {
id:'tester', name:'测试工程师', icon:'🧪', tag:'pp-role-test',
systemPrompt: function(req) {
return '你是一位专业的软件测试工程师(QA Engineer)。你的职责是对开发工程师提交的代码进行全面测试并出具测试报告。\n\n【测试规范】\n1. 单元测试:编写关键函数的单元测试用例\n2. 功能测试:验证核心功能是否符合需求\n3. 边界测试:测试边界条件和异常情况\n4. 安全测试:检查常见安全漏洞\n5. 性能测试:评估基本性能指标\n\n【输出格式】\n请按以下结构输出测试报告:\n## 🧪 测试报告\n\n### 测试环境\n(描述测试预设环境)\n\n### 测试用例\n| 编号 | 测试项 | 输入 | 预期输出 | 结果 |\n|------|----------|------|----------|------|\n(列出具体测试用例)\n\n### 单元测试代码\n(提供可执行的测试代码)\n\n### 缺陷列表\n| 编号 | 严重程度 | 描述 | 复现步骤 |\n|------|----------|------|----------|\n(列出发现的缺陷)\n\n### 📊 测试总结\n- 通过率:XX%\n- 测试结论:通过 / 有条件通过 / 不通过\n- 风险评估\n\n保持猫咪口吻但内容必须专业严谹,测试用例要具体可执行。';
},
taskPrompt: function(req, devOutput, reviewOutput) {
return '【原始需求】\n' + req + '\n\n【开发工程师提交的代码】\n' + devOutput + '\n\n【代码检视意见】\n' + reviewOutput + '\n\n请对以上代码进行全面测试,编写测试用例和测试代码,并出具详细的测试报告。';
}
}
};
// ====================== Init ======================
function init() {
ttsInit();
ttsUpdateSettingsUI();
renderEmojiPicker();
renderColorPicker();
updateProviderUI('openai');
renderMembers();
addSystemMessage('欢迎来到喵星人聊天室!添加你的猫猫,开始聊天吧~ 🐾');
pipelineInitOutputDir();
pipelineInitTimeoutSec();
pipelineUpdateRoleAssign();
monitorInit();
monitorSyncPlayerCountFromCats();
loadCatsFromBackendEnvProfile();
autoChatLoadConfig();
autoChatUpdateUI();
if (autoChat.enabled) autoChatStartIdleTimer();
}
function pipelineInitOutputDir() {
var el = document.getElementById('pipelineOutputDir');
if (!el) return;
try {
var saved = localStorage.getItem(PIPELINE_OUTPUT_DIR_STORAGE_KEY) || '';
el.value = saved || 'auto_coding_mvp/src';
} catch (_) {
el.value = 'auto_coding_mvp/src';
}
if (!el.dataset.bound) {
el.addEventListener('change', function() {
try {
localStorage.setItem(PIPELINE_OUTPUT_DIR_STORAGE_KEY, String(el.value || '').trim());
} catch (_) {}
});
el.dataset.bound = '1';
}
}
function pipelineInitTimeoutSec() {
var el = document.getElementById('pipelineTimeoutSec');
if (!el) return;
el.value = '0';
}
function normalizeImportedCats(rawCats, startIndex) {
var idxSeed = startIndex || 0;
var list = [];
(rawCats || []).forEach(function(c, i) {
if (!c || !c.name || !c.provider) return;
var cfg = PROVIDERS[c.provider] || PROVIDERS.openai;
var fallbackPort = 3460 + ((idxSeed + i) % 5000);
var parsedPort = parseInt(c.pipelineCliPort, 10);
if (!Number.isFinite(parsedPort) || parsedPort < 1024 || parsedPort > 65535) {
parsedPort = fallbackPort;
}
list.push({
id: c.id || (Date.now().toString() + '_' + (idxSeed + i)),
name: c.name,
emoji: c.emoji || '🐱',
avatarUrl: c.avatarUrl || '',
breed: c.breed || '家猫',
color: c.color || '#f582ae',
personality: c.personality || '',
provider: c.provider,
customCompat: c.customCompat || 'openai',
apiUrl: c.apiUrl || cfg.defaultUrl,
apiKey: c.apiKey || '',
model: c.model || cfg.defaultModel,
claudeVersion: c.claudeVersion || '2023-06-01',
badgeClass: c.badgeClass || cfg.badgeClass,
pipelineSwitchCommand: String(c.pipelineSwitchCommand || '').trim(),
pipelineCliPort: parsedPort
});
});
return list;
}
function monitorProfilePayload() {
return {
cats: cats.map(function(c) {
return {
id: c.id,
name: c.name,
emoji: c.emoji,
avatarUrl: c.avatarUrl,
breed: c.breed,
color: c.color,
personality: c.personality,
provider: c.provider,
customCompat: c.customCompat,
apiUrl: c.apiUrl,
apiKey: c.apiKey,
model: c.model,
claudeVersion: c.claudeVersion,