neuro-simulator 0.6.2__py3-none-any.whl → 0.6.3__py3-none-any.whl
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.
- neuro_simulator/agent/memory/core_memory.json +33 -6
- neuro_simulator/client/assets/index-vrP1Bqp5.js +7 -0
- neuro_simulator/client/index.html +1 -1
- neuro_simulator/client/neuro_start.mp4 +0 -0
- neuro_simulator/core/application.py +110 -28
- neuro_simulator/dashboard/assets/{AgentView-DGut3feB.js → AgentView-iU5hsY94.js} +2 -2
- neuro_simulator/dashboard/assets/{ChatBotView-bvwHe8hJ.js → ChatBotView-nOYkrVxt.js} +2 -2
- neuro_simulator/dashboard/assets/{ConfigView-DLy2_6Tx.js → ConfigView-Bl6IeKb4.js} +2 -2
- neuro_simulator/dashboard/assets/ContextTab-B2h9psAa.js +1 -0
- neuro_simulator/dashboard/assets/ContextTab-Cf-FBreH.css +1 -0
- neuro_simulator/dashboard/assets/{ControlView-BVJk6r1d.js → ControlView-DUubzbkq.js} +1 -1
- neuro_simulator/dashboard/assets/{FieldRenderer-xMOXYQeU.js → FieldRenderer-CzisHAil.js} +1 -1
- neuro_simulator/dashboard/assets/{LogsTab-C7r21Vcz.js → LogsTab-D6Rjw8zO.js} +1 -1
- neuro_simulator/dashboard/assets/{LogsView-DF62M8uv.js → LogsView-B_b_F2PW.js} +1 -1
- neuro_simulator/dashboard/assets/{MemoryTab-BMDqRcHX.js → MemoryTab-D49sjqDT.js} +1 -1
- neuro_simulator/dashboard/assets/{ToolsTab-Ds4M2VeQ.js → ToolsTab-DbZ5EIry.js} +1 -1
- neuro_simulator/dashboard/assets/{index-Sav9Djr5.js → index-CAD8DrUm.js} +18 -18
- neuro_simulator/dashboard/assets/{index-D2ait7Ff.css → index-w6MKUyz9.css} +1 -1
- neuro_simulator/dashboard/index.html +2 -2
- neuro_simulator/utils/websocket.py +12 -1
- {neuro_simulator-0.6.2.dist-info → neuro_simulator-0.6.3.dist-info}/METADATA +2 -1
- {neuro_simulator-0.6.2.dist-info → neuro_simulator-0.6.3.dist-info}/RECORD +26 -26
- requirements.txt +1 -0
- neuro_simulator/client/assets/index-BHgW05Wx.js +0 -7
- neuro_simulator/dashboard/assets/ContextTab-Cv2a7xRF.js +0 -1
- neuro_simulator/dashboard/assets/ContextTab-DyPsixHQ.css +0 -1
- {neuro_simulator-0.6.2.dist-info → neuro_simulator-0.6.3.dist-info}/WHEEL +0 -0
- {neuro_simulator-0.6.2.dist-info → neuro_simulator-0.6.3.dist-info}/entry_points.txt +0 -0
- {neuro_simulator-0.6.2.dist-info → neuro_simulator-0.6.3.dist-info}/licenses/LICENSE +0 -0
@@ -5,8 +5,8 @@
|
|
5
5
|
<link rel="icon" href="/dashboard/favicon.ico">
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7
7
|
<title>𝐯𝐞𝐝𝐚𝐥𝟗𝟖𝟕 𝐒𝐢𝐦𝐮𝐥𝐚𝐭𝐨𝐫</title>
|
8
|
-
<script type="module" crossorigin src="/dashboard/assets/index-
|
9
|
-
<link rel="stylesheet" crossorigin href="/dashboard/assets/index-
|
8
|
+
<script type="module" crossorigin src="/dashboard/assets/index-CAD8DrUm.js"></script>
|
9
|
+
<link rel="stylesheet" crossorigin href="/dashboard/assets/index-w6MKUyz9.css">
|
10
10
|
</head>
|
11
11
|
<body>
|
12
12
|
<div id="app"></div>
|
@@ -40,11 +40,22 @@ class WebSocketManager:
|
|
40
40
|
await self.send_personal_message(message, connection)
|
41
41
|
|
42
42
|
async def broadcast_to_admins(self, message: dict):
|
43
|
+
dead_connections = []
|
43
44
|
for connection in self.admin_connections:
|
44
45
|
try:
|
45
|
-
|
46
|
+
if connection.client_state == WebSocketState.CONNECTED:
|
47
|
+
await connection.send_json(message)
|
48
|
+
else:
|
49
|
+
dead_connections.append(connection)
|
50
|
+
except (WebSocketDisconnect, ConnectionResetError):
|
51
|
+
dead_connections.append(connection)
|
46
52
|
except Exception as e:
|
47
53
|
logger.error(f"Failed to send message to admin connection: {e}")
|
54
|
+
dead_connections.append(connection)
|
55
|
+
|
56
|
+
for connection in dead_connections:
|
57
|
+
if connection in self.admin_connections:
|
58
|
+
self.admin_connections.remove(connection)
|
48
59
|
|
49
60
|
# Global singleton instance
|
50
61
|
connection_manager = WebSocketManager()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: neuro_simulator
|
3
|
-
Version: 0.6.
|
3
|
+
Version: 0.6.3
|
4
4
|
Summary: Neuro Simulator Server
|
5
5
|
Project-URL: Homepage, https://github.com/Moha-Master/neuro-simulator
|
6
6
|
Project-URL: Repository, https://github.com/Moha-Master/neuro-simulator
|
@@ -21,6 +21,7 @@ Requires-Python: >=3.8
|
|
21
21
|
Requires-Dist: azure-cognitiveservices-speech
|
22
22
|
Requires-Dist: fastapi
|
23
23
|
Requires-Dist: google-genai
|
24
|
+
Requires-Dist: httpx
|
24
25
|
Requires-Dist: jinja2
|
25
26
|
Requires-Dist: mutagen
|
26
27
|
Requires-Dist: openai
|
@@ -1,6 +1,6 @@
|
|
1
1
|
README.md,sha256=7pb9WxHIsbrrzlXps_W5ejL147vIu0ak3VTeDjIcfvU,6058
|
2
2
|
WEBSOCKET_API.md,sha256=LkItXviJL-0DGqX85CSB9LAmcnj2cAnBzETvPIjRY8U,9203
|
3
|
-
requirements.txt,sha256=
|
3
|
+
requirements.txt,sha256=YhzaOtVW_vk10JGQOBkXgUQYK3MsQ2E201qIA6pR-Io,122
|
4
4
|
neuro_simulator/__init__.py,sha256=-tposzyvg6UckPcfSvtc03UjxBa9oCe_zRvlKf8splk,31
|
5
5
|
neuro_simulator/cli.py,sha256=nG2-Ih7yF6ipxwoLrpfFORHHIC-DgqPEldipDecZH48,4261
|
6
6
|
neuro_simulator/agent/__init__.py,sha256=t52CZlyTGWqcGjMs90qvpFpRckY2WSSlO7r_H3K_mSY,32
|
@@ -10,7 +10,7 @@ neuro_simulator/agent/memory_prompt.txt,sha256=wdpdnbOYhMKgPJnnGlcSejGdt2uItrXzD
|
|
10
10
|
neuro_simulator/agent/neuro_prompt.txt,sha256=WSN5Fa6AwVnJaSFhz98fQTb2EtQ35U6w2qga_C-s1Go,1438
|
11
11
|
neuro_simulator/agent/memory/__init__.py,sha256=YJ7cynQJI6kD7vjyv3rKc-CZqmoYSuGQtRZl_XdGEps,39
|
12
12
|
neuro_simulator/agent/memory/chat_history.json,sha256=p4jwS2DJbzTvZinDddlrJilOHHwXSy_eZPDdNvRP84I,412
|
13
|
-
neuro_simulator/agent/memory/core_memory.json,sha256=
|
13
|
+
neuro_simulator/agent/memory/core_memory.json,sha256=AMQhNwFteUb7NaM8TFcAmx7Byey3JL9rBlFcErk9OyQ,5141
|
14
14
|
neuro_simulator/agent/memory/init_memory.json,sha256=JdjEmZz4lAkawFeJGKSnj_wdtaJJBZ-xoAdctR3GjWk,3184
|
15
15
|
neuro_simulator/agent/memory/manager.py,sha256=R9OsPTt8lXsc2Z95lYRJCmKAOghOtHARzpOtqOnU_Wg,6214
|
16
16
|
neuro_simulator/agent/memory/temp_memory.json,sha256=ZZPzk0IwtWzJKVVsINfZCEMiDqKEDvFVQ3fke70HD-M,148
|
@@ -55,7 +55,7 @@ neuro_simulator/chatbot/tools/post_chat_message.py,sha256=lchGCSQKzPZgb1z__MIDkG
|
|
55
55
|
neuro_simulator/core/__init__.py,sha256=-ojq25c8XA0CU25b0OxcGjH4IWFEDHR-HXSRSZIuKe8,57
|
56
56
|
neuro_simulator/core/agent_factory.py,sha256=jX7wRyTS7Jd-qfIGj0kGs_0pblx5zUcyVAyRETIUhvw,1359
|
57
57
|
neuro_simulator/core/agent_interface.py,sha256=ZXUCtkQUvsBQ5iCb0gTILJaShn5KmSrEgKhd7PK18HE,2794
|
58
|
-
neuro_simulator/core/application.py,sha256=
|
58
|
+
neuro_simulator/core/application.py,sha256=ZUsZvTymnhVzMYztd5SQLm3_Kl2Fk9ViYg7R8yN3uO4,34427
|
59
59
|
neuro_simulator/core/config.py,sha256=eH5LdTm7gtLBqV7bbiUulYTW2abKYUmK934x3zOS19w,4766
|
60
60
|
neuro_simulator/core/path_manager.py,sha256=_MK3S5ab30zT9zDISC-noDbVE8Axs5y1A3WgImqD-wI,4284
|
61
61
|
neuro_simulator/services/__init__.py,sha256=s3ZrAHg5TpJakadAAGY1h0wDw_xqN4Je4aJwJyRBmk4,61
|
@@ -67,7 +67,7 @@ neuro_simulator/utils/logging.py,sha256=fAM8mW4czr0RLgAUS6oN-YTWKj5daqwc5g7yjyAg
|
|
67
67
|
neuro_simulator/utils/process.py,sha256=9OYWx8fzaJZqmFUcjQX37AnBhl7YWvrLxDWBa30vqwU,3192
|
68
68
|
neuro_simulator/utils/queue.py,sha256=fJ0c7pwdAoUrLGC0qudehABkoBB7-pzROvmj_nA9D1c,2690
|
69
69
|
neuro_simulator/utils/state.py,sha256=DdBqSAYfjOFtJfB1hEGhYPh32r1ZvFuVlN_-29_-luA,664
|
70
|
-
neuro_simulator/utils/websocket.py,sha256=
|
70
|
+
neuro_simulator/utils/websocket.py,sha256=PcbmNom49El4c6SLvpKsuc2P_YfwJC_WnBJmkpo0DH4,2566
|
71
71
|
neuro_simulator/client/avatar.webp,sha256=gLkJF8g-akjXPXBzr_FRYmTt9RM9oXEmDnIEh12DkZs,25884
|
72
72
|
neuro_simulator/client/background.webp,sha256=JD9OFItvxSm0xQ8jRJZ9eiXLZ1R-1xZXd7EMWr4b170,1174858
|
73
73
|
neuro_simulator/client/background_old.webp,sha256=10Jv9ElOAvpysZUTPw24tC7kKi2-oi6x7KuvI9bE9aU,51214
|
@@ -75,15 +75,15 @@ neuro_simulator/client/banner.jpeg,sha256=LFqSS0alXwQPilUnHNZ4qkx63Jbc5VYF0HsJOi
|
|
75
75
|
neuro_simulator/client/channel_points.png,sha256=Tmy9kmKQWNfK-gPMKVvUYrpEiT3CsPgSx6V1-PJRBhI,11509
|
76
76
|
neuro_simulator/client/error.mp3,sha256=ovZ-JXAHrqYUkjFshP48_3ZQcoRi7gUxO_ZkShoeIyA,24048
|
77
77
|
neuro_simulator/client/favicon.ico,sha256=8mR4U-Ufv6l8_Md9C6yqbv6mZ0WV9DRLSPpms8WKp4g,370418
|
78
|
-
neuro_simulator/client/index.html,sha256=
|
79
|
-
neuro_simulator/client/neuro_start.mp4,sha256=
|
78
|
+
neuro_simulator/client/index.html,sha256=qdw4WnM37-VldXdT5D2Glx7IAuDpufLWujG3-XeIM9A,22417
|
79
|
+
neuro_simulator/client/neuro_start.mp4,sha256=nIxX0Ki58IzBX3-KwFKcNXgWRLYblDgaKBVQVkoN4BQ,8080037
|
80
80
|
neuro_simulator/client/neurosama.png,sha256=FTyEEEu0XwRxicKtmQXQONiRVhYKgTsPqlOO2Ymbp1c,1447110
|
81
81
|
neuro_simulator/client/sc_pink.png,sha256=bmC1Wn8I27nsc9lkQJ8-LeacL6Y-eOZor_JkmXy9Om0,56768
|
82
82
|
neuro_simulator/client/sc_purple.png,sha256=XUs6fB0CHPTzQQ3npS1rje5gcigy-T4uao8k3RxOk50,57224
|
83
83
|
neuro_simulator/client/sub_badge.svg,sha256=-Es6Nz9sd7c3sJ4Mys2q0vSd7AZVC9uE-Sq4ipCsioo,825
|
84
84
|
neuro_simulator/client/user_avatar.jpg,sha256=j2MZCFm0MYmigPPOLsuFqA8PhvQ5SWb0GTpqb9VKqvY,29625
|
85
|
-
neuro_simulator/client/assets/index-BHgW05Wx.js,sha256=5sAhfYAN0xKCbG6iZv20bjA7CaXr4zmqR57wd5ko14o,37340
|
86
85
|
neuro_simulator/client/assets/index-rmyQl8Tr.css,sha256=ischTFPWjCjy3-vCQ863InoM-wjMuybtesUP0vaY-XA,27865
|
86
|
+
neuro_simulator/client/assets/index-vrP1Bqp5.js,sha256=vTzGaevLne-HptHxemLWRNWw5ZsCqVLDrG8FNO1YQFI,37629
|
87
87
|
neuro_simulator/client/assets/inter-cyrillic-400-normal-BLGc9T1a.woff2,sha256=Y20TqrBe2fpJ3xnFf93btvPQhPRjdD7lJXVJ27cSQAU,7712
|
88
88
|
neuro_simulator/client/assets/inter-cyrillic-400-normal-alAqRL36.woff,sha256=GmDEQlTts7GpPN_vX-7Kqig5IarhIL_nICL6SWvtq5Y,9780
|
89
89
|
neuro_simulator/client/assets/inter-cyrillic-ext-400-normal-BE2fNs0E.woff,sha256=RHF2hsw99YHFTevMHQw7zGUUaXtPsetnWZbP0cfZaYA,13336
|
@@ -104,33 +104,33 @@ neuro_simulator/client/fonts/first-coffee.woff2,sha256=pUBfpDh_6HQ20V9EuKWq2UFLn
|
|
104
104
|
neuro_simulator/client/fonts/noto-sans-sc.woff2,sha256=KsZkKouZc8g1eQ_5wzOWuGkIcSYzGGsHYZJhyu0hFDg,4182468
|
105
105
|
neuro_simulator/dashboard/favicon.ico,sha256=8mR4U-Ufv6l8_Md9C6yqbv6mZ0WV9DRLSPpms8WKp4g,370418
|
106
106
|
neuro_simulator/dashboard/first-coffee.woff2,sha256=pUBfpDh_6HQ20V9EuKWq2UFLnMi9RPHigLN2rOU9Jps,11496
|
107
|
-
neuro_simulator/dashboard/index.html,sha256=
|
108
|
-
neuro_simulator/dashboard/assets/AgentView-DGut3feB.js,sha256=QGHJMgIWiRVX8C4Ctd7KNqbeWrxsm5vNfb6l3mjYtoU,2413
|
107
|
+
neuro_simulator/dashboard/index.html,sha256=2EEXrZPFdXMVKSewGW6WMxO3SFNadHcN9yuh6HcKx8Y,519
|
109
108
|
neuro_simulator/dashboard/assets/AgentView-TDgmx5bK.css,sha256=UjBaTbzD4yiDxAHXC5rSSgY-tDFyBfVYS_O1VNcmoYU,361
|
109
|
+
neuro_simulator/dashboard/assets/AgentView-iU5hsY94.js,sha256=RKTlDJqtGABAKyCh4TrW4lD-P5JmqpZJybIYxPzhDX4,2413
|
110
110
|
neuro_simulator/dashboard/assets/ChatBotView-Dyd6g14G.css,sha256=61Z9sVqq9scsOWZJaOslumxe8Q0I_leQGY4jxy1Zm9o,367
|
111
|
-
neuro_simulator/dashboard/assets/ChatBotView-
|
112
|
-
neuro_simulator/dashboard/assets/ConfigView-
|
111
|
+
neuro_simulator/dashboard/assets/ChatBotView-nOYkrVxt.js,sha256=KxdRT8A5BhLWw-upTDNVdrmVzy9bC9qJtI8lEe4xxes,2246
|
112
|
+
neuro_simulator/dashboard/assets/ConfigView-Bl6IeKb4.js,sha256=2oZAXRAF08moPhsIwgY2S_HjmngSuGuXjwDjj_F3KgM,2932
|
113
113
|
neuro_simulator/dashboard/assets/ConfigView-aFribfyR.css,sha256=ubCvxhHoetmZ-Dr1BhA5WzniPouxSTHrVNUF_ernK8E,51
|
114
|
-
neuro_simulator/dashboard/assets/ContextTab-
|
115
|
-
neuro_simulator/dashboard/assets/ContextTab-
|
114
|
+
neuro_simulator/dashboard/assets/ContextTab-B2h9psAa.js,sha256=DuEMp3MsqAjYcvMpHAvlzasW_KDPOqbzEFuod8t50JE,1224
|
115
|
+
neuro_simulator/dashboard/assets/ContextTab-Cf-FBreH.css,sha256=fIqARaEdmcJNOZbl5j1Ia2m86-wNMplrs9KaZcm41_Y,306
|
116
116
|
neuro_simulator/dashboard/assets/ControlView-BUCt3umR.css,sha256=Nspx07838NWMuUKrWJCRgwRBdjl-zezVBzUSfdDBsiU,108
|
117
|
-
neuro_simulator/dashboard/assets/ControlView-
|
118
|
-
neuro_simulator/dashboard/assets/FieldRenderer-
|
119
|
-
neuro_simulator/dashboard/assets/LogsTab-
|
117
|
+
neuro_simulator/dashboard/assets/ControlView-DUubzbkq.js,sha256=YEUrUbmLDOmJzIKkl-ZUBiNSta08IuEhWjrEFAy4e6o,1549
|
118
|
+
neuro_simulator/dashboard/assets/FieldRenderer-CzisHAil.js,sha256=Iy23BdjpYrhKUyM0IIBg7zjRqbaEgsSQR4XlGrXmYH0,7598
|
119
|
+
neuro_simulator/dashboard/assets/LogsTab-D6Rjw8zO.js,sha256=2WUW_8GxQ-rjM6FgPr5n_JWWysYhNboe1RXDZsWwaQ8,542
|
120
120
|
neuro_simulator/dashboard/assets/LogsTab-wg3i3S6b.css,sha256=hRDoXwSnuvWe9vt-lh8XbMiJTS-WV-HTHf3-JOmkfuE,254
|
121
|
+
neuro_simulator/dashboard/assets/LogsView-B_b_F2PW.js,sha256=n08Nj8txzmVGa-uJVsVt2eVg0cq0j8r9D24v90O_6QU,788
|
121
122
|
neuro_simulator/dashboard/assets/LogsView-D2F8f-Mc.css,sha256=69G8eFicz4WLe-f3mnn7YMfo-odPHM7gcRT160oNgGo,254
|
122
|
-
neuro_simulator/dashboard/assets/
|
123
|
-
neuro_simulator/dashboard/assets/MemoryTab-BMDqRcHX.js,sha256=_e9Dl5qzgERWcfZ13wdJqQF6Wa3kVoj0ks77FDsffR4,9508
|
123
|
+
neuro_simulator/dashboard/assets/MemoryTab-D49sjqDT.js,sha256=paiZH63CXPLu0Om9kIkwRtFMIhJUanDflEjqynYqkZk,9508
|
124
124
|
neuro_simulator/dashboard/assets/MemoryTab-DPthi6jg.css,sha256=yZNqQVtHqNjjsKz3eCRmcuuYi4kKQFMTUHiWEHbOeHY,151
|
125
|
-
neuro_simulator/dashboard/assets/ToolsTab-
|
126
|
-
neuro_simulator/dashboard/assets/index-
|
127
|
-
neuro_simulator/dashboard/assets/index-
|
125
|
+
neuro_simulator/dashboard/assets/ToolsTab-DbZ5EIry.js,sha256=AWjnKERRjl_0A86CUSpLsezuH2PfaBToVEnqgG9ODtU,3694
|
126
|
+
neuro_simulator/dashboard/assets/index-CAD8DrUm.js,sha256=KyJ4pjphhKkLdCiSpcUw8wxrWnm6-fu3XEmURw4hAq4,629148
|
127
|
+
neuro_simulator/dashboard/assets/index-w6MKUyz9.css,sha256=wSK-tcF7Ip4EssJZqKvGRNa_hhBqPY250zZtXjUeg5I,804994
|
128
128
|
neuro_simulator/dashboard/assets/materialdesignicons-webfont-B7mPwVP_.ttf,sha256=YeirpaTpgf4iz3yOi82-oAR251xiw38Bv37jM2HWhCg,1307660
|
129
129
|
neuro_simulator/dashboard/assets/materialdesignicons-webfont-CSr8KVlo.eot,sha256=CxgxBNL8XyYZbnc8d72vLgVQn9QlnS0V7O3Kebh-hPk,1307880
|
130
130
|
neuro_simulator/dashboard/assets/materialdesignicons-webfont-Dp5v-WZN.woff2,sha256=Zi_vqPL4qVwYWI0hd0eJwQfGTnccvmWmmvRikcQxGvw,403216
|
131
131
|
neuro_simulator/dashboard/assets/materialdesignicons-webfont-PXm3-2wK.woff,sha256=pZKKDVwvYk5G-Y2bFcL2AEU3f3xZTdeKF1kTLqO0Y-s,587984
|
132
|
-
neuro_simulator-0.6.
|
133
|
-
neuro_simulator-0.6.
|
134
|
-
neuro_simulator-0.6.
|
135
|
-
neuro_simulator-0.6.
|
136
|
-
neuro_simulator-0.6.
|
132
|
+
neuro_simulator-0.6.3.dist-info/METADATA,sha256=GeJ_Pd2pppBhTpe93t49bJ_k6s7eKdI8nDoBv5xAd5o,12396
|
133
|
+
neuro_simulator-0.6.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
134
|
+
neuro_simulator-0.6.3.dist-info/entry_points.txt,sha256=qVd5ypnRRgU8Cw7rWfZ7o0OXyS9P9hgY-cRoN_mgz9g,51
|
135
|
+
neuro_simulator-0.6.3.dist-info/licenses/LICENSE,sha256=cPsKhVNOnNSSva44vcCU-SDDFf8iE-EhpGXCiUK9tAM,1072
|
136
|
+
neuro_simulator-0.6.3.dist-info/RECORD,,
|
requirements.txt
CHANGED
@@ -1,7 +0,0 @@
|
|
1
|
-
var U=Object.defineProperty;var N=(a,e,t)=>e in a?U(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var o=(a,e,t)=>N(a,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))s(n);new MutationObserver(n=>{for(const i of n)if(i.type==="childList")for(const r of i.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&s(r)}).observe(document,{childList:!0,subtree:!0});function t(n){const i={};return n.integrity&&(i.integrity=n.integrity),n.referrerPolicy&&(i.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?i.credentials="include":n.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function s(n){if(n.ep)return;n.ep=!0;const i=t(n);fetch(n.href,i)}})();window.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll("[data-tooltip]").forEach(e=>{const t=document.createElement("div");t.className="tooltip",t.textContent=e.getAttribute("data-tooltip")||"",document.body.appendChild(t);function s(){const i=e.getBoundingClientRect(),r=window.pageXOffset,d=window.pageYOffset,h=50;let m,O;if(i.top<h)m=i.bottom+d+8,O="translateX(-50%)",t.classList.add("tooltip-arrow-up"),t.classList.remove("tooltip-arrow-down");else{t.style.left=i.left+i.width/2+r+"px",t.style.top=i.top+d+"px",t.style.transform="translateX(-50%)",t.classList.add("show");const R=t.offsetHeight;m=i.top+d-R-8,t.classList.remove("show"),t.style.top=m+"px",t.classList.add("tooltip-arrow-down"),t.classList.remove("tooltip-arrow-up")}t.style.left=i.left+i.width/2+r+"px",t.style.top=m+"px",t.style.transform=O,t.classList.add("show")}function n(){t.classList.remove("show")}e.addEventListener("mouseenter",s),e.addEventListener("mouseleave",n)})});window.addEventListener("DOMContentLoaded",()=>{const a="https://twitchtracker.com/api/channels/summary/vedal987",e=document.getElementById("avg-viewers");let t=0;const s=1;let n=null;async function i(){try{const r=new AbortController,d=setTimeout(()=>r.abort(),3e3),h=await fetch(a,{signal:r.signal});if(clearTimeout(d),!h.ok)throw new Error(`HTTP error! status: ${h.status}`);const m=await h.json();if(m&&typeof m.avg_viewers=="number")e.textContent=m.avg_viewers.toLocaleString(),t=0,n&&clearTimeout(n),n=setTimeout(i,5*60*60*1e3);else throw new Error("接口数据格式异常")}catch(r){console.warn("获取 avg_viewers 失败:",r.message),t++,t>s?(console.log("停止获取,1分钟后重试..."),setTimeout(()=>{t=0,i()},60*1e3)):i()}}i()});const p=document.getElementById("chat-messages"),y=document.getElementById("twitch-chat-overlay"),g=document.getElementById("highlight-message-overlay"),x="One_of_Swarm";class F{constructor(){p?console.log("ChatDisplay initialized."):console.error("ChatDisplay: Required chat messages container not found in DOM!")}appendChatMessage(e){if(!p){console.error("ChatDisplay: Cannot append message, container not found.");return}const t=document.createElement("div");t.className="chat-line__message";const s=document.createElement("div");s.className="chat-line__message-container",e.username===x&&e.is_user_message?t.classList.add("user-sent-message"):e.username==="System"?t.classList.add("system-message"):t.classList.add("audience-ai-message");const n=document.createElement("span");n.className="chat-line__username",n.style.color=e.username===x?"#9147FF":this.getRandomChatColor();const i=document.createElement("span");i.className="chat-author__display-name",i.textContent=e.username,n.appendChild(i);const r=document.createElement("span");r.textContent=": ",r.style.marginRight="0.3rem",r.className="text-fragment";const d=document.createElement("span");if(d.className="text-fragment",d.textContent=e.text,s.appendChild(n),s.appendChild(r),s.appendChild(d),t.appendChild(s),p.appendChild(t),y){const h=t.cloneNode(!0);y.appendChild(h),this.scrollToBottomOverlay()}this.scrollToBottom()}clearChat(){p&&(p.innerHTML="",console.log("Chat display cleared.")),y&&(y.innerHTML="")}scrollToBottom(){p&&(p.scrollTop=p.scrollHeight)}scrollToBottomOverlay(){y&&(y.scrollTop=y.scrollHeight)}getRandomChatColor(){const e=["#FF0000","#00FF00","#0000FF","#00FFFF","#FF00FF","#FF4500","#ADFF2F","#1E90FF","#FFD700","#8A2BE2","#00CED1","#FF69B4","#DA70D6","#BA55D3","#87CEEB","#32CD32","#CD853F"];return e[Math.floor(Math.random()*e.length)]}}function $(a,e,t){if(!g)return;const s=t==="bits"?"/sc_purple.png":"/sc_pink.png";g.innerHTML=`
|
2
|
-
<img src="${s}" class="sc-background-image" alt="Super Chat background">
|
3
|
-
<div class="sc-content">
|
4
|
-
<div class="sc-user">${a}</div>
|
5
|
-
<div class="sc-message">${e}</div>
|
6
|
-
</div>
|
7
|
-
`;const n=g.querySelector(".sc-message");n&&(n.style.color=t==="bits"?"var(--sc-purple-bg-color)":"var(--sc-pink-bg-color)"),g.classList.remove("hidden"),g.offsetHeight,g.classList.add("is-visible"),setTimeout(()=>{g.classList.remove("is-visible"),setTimeout(()=>{g.classList.add("hidden")},1e3)},9e3)}class W{constructor(e){o(this,"ws",null);o(this,"options");o(this,"reconnectAttempts",0);o(this,"reconnectTimeout",null);o(this,"explicitlyClosed",!1);this.options={reconnectInterval:3e3,maxReconnectAttempts:10,...e}}connect(){if(!this.options.url){console.warn("WebSocket URL is not set. Connection aborted.");return}if(this.ws&&(this.ws.readyState===WebSocket.OPEN||this.ws.readyState===WebSocket.CONNECTING)){console.warn(`WebSocket for ${this.options.url} is already connected or connecting.`);return}this.explicitlyClosed=!1,console.log(`Connecting to WebSocket: ${this.options.url}`),this.ws=new WebSocket(this.options.url),this.ws.onopen=()=>{var e,t;console.log(`WebSocket connected: ${this.options.url}`),this.reconnectAttempts=0,this.reconnectTimeout&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null),(t=(e=this.options).onOpen)==null||t.call(e)},this.ws.onmessage=e=>{var t,s;try{const n=JSON.parse(e.data);n.type==="processing_superchat"&&$(n.data.username,n.data.text,n.data.sc_type),(s=(t=this.options).onMessage)==null||s.call(t,n)}catch(n){console.error(`Error parsing message from ${this.options.url}:`,n,e.data)}},this.ws.onclose=e=>{var t,s,n,i;console.warn(`WebSocket closed: ${this.options.url}. Code: ${e.code}, Reason: ${e.reason}`),this.ws=null,(s=(t=this.options).onClose)==null||s.call(t,e),this.explicitlyClosed||((i=(n=this.options).onDisconnect)==null||i.call(n),this.options.autoReconnect&&e.code!==1e3&&this.tryReconnect())},this.ws.onerror=e=>{var t,s;console.error(`WebSocket error: ${this.options.url}`,e),(s=(t=this.options).onError)==null||s.call(t,e)}}tryReconnect(){if(this.options.maxReconnectAttempts===-1||this.reconnectAttempts<this.options.maxReconnectAttempts){this.reconnectAttempts++;const t=this.options.maxReconnectAttempts===-1?`(attempt ${this.reconnectAttempts})`:`(attempt ${this.reconnectAttempts}/${this.options.maxReconnectAttempts})`;console.log(`Attempting to reconnect to ${this.options.url} in ${this.options.reconnectInterval/1e3} seconds... ${t}`),this.reconnectTimeout=setTimeout(()=>{this.connect()},this.options.reconnectInterval)}else console.error(`Max reconnect attempts reached for ${this.options.url}.`)}send(e){this.ws&&this.ws.readyState===WebSocket.OPEN?this.ws.send(JSON.stringify(e)):console.warn(`WebSocket for ${this.options.url} is not open. Message not sent.`)}disconnect(){this.explicitlyClosed=!0,this.reconnectTimeout&&clearTimeout(this.reconnectTimeout),this.ws&&this.ws.close(1e3,"Client initiated disconnect")}updateOptions(e){console.log("WebSocket client options updated:",e),this.options={...this.options,...e}}getUrl(){return this.options.url}}const c=document.getElementById("neuro-caption"),T=document.getElementById("stream-display-area"),z=16,q=2,B=.4;function M(){if(!c||!T)return;c.style.fontSize="";const a=T.offsetHeight;if(c.textContent===""||a===0)return;if(c.offsetHeight>a*B){const t=window.getComputedStyle(c);let s=parseFloat(t.fontSize);for(;c.offsetHeight>a*B&&s>z;)s-=q,c.style.fontSize=`${s}px`;c.offsetHeight>a*B&&(c.style.fontSize=`${z}px`)}}let I=null,C=null;const H=3e3;function D(a,e){if(c)if(c.classList.add("show"),e&&a.trim().length>0){const t=a.split(/\s+/).filter(r=>r.length>0);if(t.length===0){c.textContent+=(c.textContent?" ":"")+a,M();return}const s=a.length;let n=c.textContent||"";const i=r=>{if(r<t.length){const d=t[r],h=d.length/s*e*1.01,m=Math.max(50,h*1e3);n+=(n.length>0?" ":"")+d,c.textContent=n,M(),I=setTimeout(()=>i(r+1),m)}else I=null};i(0),console.log(`Starting word-by-word caption for: "${a.substring(0,30)}..." (duration: ${e}s)`)}else c.textContent+=(c.textContent?" ":"")+a,M(),console.log(`Displaying full caption: "${a.substring(0,30)}..."`)}function A(){c&&(I&&(clearTimeout(I),I=null),C&&(clearTimeout(C),C=null),c.classList.remove("show"),c.textContent="",c.style.fontSize="",console.log("NeuroCaption hidden and cleared."))}function V(){C&&clearTimeout(C),C=setTimeout(()=>{A()},H)}!c||!T?console.error("neuroCaption.ts: Could not find #neuro-caption or #stream-display-area element."):console.log("NeuroCaption module initialized.");class j{constructor(){o(this,"audioQueue",[]);o(this,"isPlayingAudio",!1);o(this,"currentPlayingAudio",null);o(this,"allSegmentsReceived",!1);o(this,"errorSound");o(this,"lastSegmentEnd",!0);this.errorSound=new Audio("/error.mp3"),console.log("AudioPlayer initialized.")}playErrorSound(){this.stopAllAudio(),console.log("Playing dedicated error sound..."),this.errorSound.play().catch(e=>{console.error("Error playing dedicated error sound:",e)})}addAudioSegment(e,t,s){this.lastSegmentEnd&&A(),this.lastSegmentEnd=!1;const n=new Audio("data:audio/mp3;base64,"+t);try{const r=f.getAppInitializer().getMuteButton();n.muted=r.getIsMuted()}catch(i){console.warn("Could not get mute state, defaulting to muted:",i),n.muted=!0}this.audioQueue.push({text:e,audio:n,duration:s}),console.log(`Audio segment added to queue. Queue size: ${this.audioQueue.length}`),this.isPlayingAudio||this.playNextAudioSegment()}playNextAudioSegment(){if(this.audioQueue.length>0&&!this.isPlayingAudio){this.isPlayingAudio=!0;const e=this.audioQueue.shift();this.currentPlayingAudio=e.audio,D(e.text,e.duration),this.currentPlayingAudio.play().catch(t=>{console.error("Error playing audio segment:",t),this.isPlayingAudio=!1,this.currentPlayingAudio=null,this.playNextAudioSegment()}),this.currentPlayingAudio.addEventListener("ended",()=>{this.isPlayingAudio=!1,this.currentPlayingAudio=null,this.playNextAudioSegment()},{once:!0})}else if(this.audioQueue.length===0&&this.allSegmentsReceived){console.log("Neuro's full audio response played. Starting caption timeout and resetting zoom."),V();try{f.getAppInitializer().getNeuroAvatar().resetZoom()}catch(e){console.warn("Could not reset neuro avatar zoom at end of speech",e)}}}setAllSegmentsReceived(){this.allSegmentsReceived=!0,this.lastSegmentEnd=!0}stopAllAudio(){this.currentPlayingAudio&&(this.currentPlayingAudio.pause(),this.currentPlayingAudio.currentTime=0,this.currentPlayingAudio=null),this.audioQueue.length=0,this.isPlayingAudio=!1,this.allSegmentsReceived=!1,A();try{f.getAppInitializer().getNeuroAvatar().resetZoom()}catch(e){console.warn("Could not reset neuro avatar zoom on stop",e)}console.log("Neuro audio playback stopped, queue cleared.")}updateMuteState(){if(this.currentPlayingAudio)try{const t=f.getAppInitializer().getMuteButton();this.currentPlayingAudio.muted=t.getIsMuted()}catch(e){console.warn("Could not update current audio mute state:",e)}for(const e of this.audioQueue)try{const s=f.getAppInitializer().getMuteButton();e.audio.muted=s.getIsMuted()}catch(t){console.warn("Could not update queued audio mute state:",t)}}}const b=document.getElementById("startup-video-overlay"),u=document.getElementById("startup-video");class Q{constructor(){!b||!u?console.error("VideoPlayer: Required video elements not found in DOM!"):console.log("VideoPlayer initialized.")}showAndPlayVideo(e=0){if(!b||!u){console.error("VideoPlayer: Cannot show and play video, elements are missing.");return}b.classList.remove("hidden"),b.style.zIndex="10";const s=f.getAppInitializer().getMuteButton(),n=()=>{isFinite(u.duration)&&e>.1&&e<u.duration&&(u.currentTime=e,console.log(`Seeked to: ${e.toFixed(2)}s.`))};u.muted=!1;const i=u.play();i!==void 0&&i.then(()=>{console.log("Unmuted autoplay successful."),n()}).catch(r=>{console.warn("Unmuted autoplay failed. Showing unmute prompt and falling back to muted playback.",r),s.show(),u.muted=!0,u.play().then(()=>{console.log("Muted fallback playback started."),n()}).catch(h=>{console.error("Muted fallback playback also failed. This is unexpected.",h)})})}pauseAndMute(){u&&(u.pause(),u.muted=!0,console.log("Startup video paused and muted."))}hide(){b&&(b.classList.add("hidden"),console.log("Startup video overlay hidden."))}getVideoDuration(){return u&&!isNaN(u.duration)?u.duration:0}}const v={HIDDEN:"hidden",STEP1:"step1",STEP2:"step2"},l=document.getElementById("neuro-static-avatar-container");class J{constructor(){l?(console.log("NeuroAvatar initialized."),this.setStage(v.HIDDEN,!0)):console.error("NeuroAvatar: Required avatar container element not found in DOM!")}startIntroAnimation(e){console.log("Starting Neuro intro animation sequence..."),this.setStage(v.STEP1),setTimeout(()=>{console.log("Animating to Step 2..."),this.setStage(v.STEP2),setTimeout(()=>{console.log("Neuro intro animation sequence finished."),e&&e()},1e3)},2e3)}setStage(e,t=!1){if(!l)return;const s="transform 0.5s ease-in-out";switch(t?(l.style.transition="none",l.offsetHeight):e===v.STEP2?l.style.transition=`bottom 1s cubic-bezier(0.4, 0.0, 1, 1), ${s}`:l.style.transition=s,e){case v.HIDDEN:l.style.visibility="hidden",l.style.bottom="-207%",l.style.left="70%",l.style.zIndex="10";break;case v.STEP1:l.style.visibility="visible",l.style.bottom="-207%",l.style.left="70%",l.style.zIndex="15";break;case v.STEP2:l.style.visibility="visible",l.style.bottom="-125%",l.style.left="70%",l.style.zIndex="15";break}}triggerSpin(){l&&(console.log("Triggering avatar spin animation."),l.classList.add("spin-animation"),setTimeout(()=>{l.classList.remove("spin-animation"),console.log("Avatar spin animation finished.")},1e3))}triggerZoom(){l&&(console.log("Triggering avatar zoom-in animation."),l.classList.add("zoom-in"))}resetZoom(){l&&l.classList.contains("zoom-in")&&(console.log("Resetting avatar zoom."),l.classList.remove("zoom-in"))}}const k=document.getElementById("chat-input"),P=document.getElementById("send-button"),w=document.getElementById("sc-bits-button"),E=document.getElementById("sc-points-button");class X{constructor(){o(this,"onSendMessageCallback",null);!k||!P||!w||!E?console.error("UserInput: Required input elements not found in DOM!"):(this.setupEventListeners(),console.log("UserInput initialized."))}onSendMessage(e){this.onSendMessageCallback=e}setupEventListeners(){P.addEventListener("click",()=>this.handleSendMessage()),k.addEventListener("keypress",e=>{e.key==="Enter"&&this.handleSendMessage()}),w.addEventListener("click",()=>this.toggleSuperchatButton(w)),E.addEventListener("click",()=>this.toggleSuperchatButton(E))}toggleSuperchatButton(e){const t=e===w?E:w;e.classList.contains("selected")?e.classList.remove("selected"):(e.classList.add("selected"),t.classList.remove("selected"))}handleSendMessage(){const e=k.value.trim();if(!e){console.warn("Attempted to send empty message.");return}let t;const s=w.classList.contains("selected"),n=E.classList.contains("selected");s||n?t={type:"superchat",text:e,sc_type:s?"bits":"points"}:t={type:"user_message",text:e},this.onSendMessageCallback?this.onSendMessageCallback(t):console.warn("No callback registered for sending message."),k.value="",this.clearSuperchatSelection()}clearSuperchatSelection(){w.classList.remove("selected"),E.classList.remove("selected")}setInputDisabled(e){k.disabled=e,P.disabled=e,console.log(`User input elements disabled: ${e}`)}}class Z{constructor(){o(this,"viewportElement");o(this,"areaElement");o(this,"resizeObserver");if(this.viewportElement=document.getElementById("stream-display-viewport"),this.areaElement=document.getElementById("stream-display-area"),!this.viewportElement||!this.areaElement)throw new Error("LayoutManager: Required viewport or area element not found in DOM!");this.resizeObserver=new ResizeObserver(this.handleResize.bind(this))}handleResize(e){for(const t of e){const{width:s,height:n}=t.contentRect;this.updateLayout(s,n)}}updateLayout(e,t){if(e===0||t===0)return;const s=e/t,n=16/9;let i,r;s>n?(r=t,i=r*n):(i=e,r=i/n),this.areaElement.style.width=`${i}px`,this.areaElement.style.height=`${r}px`}start(){this.resizeObserver.observe(this.viewportElement),this.updateLayout(this.viewportElement.clientWidth,this.viewportElement.clientHeight),console.log("LayoutManager started and observing.")}stop(){this.resizeObserver.disconnect(),console.log("LayoutManager stopped.")}}class G{constructor(){o(this,"timerElement");o(this,"intervalId",null);o(this,"streamStartTime",0);if(this.timerElement=document.getElementById("stream-duration-text"),!this.timerElement)throw new Error("StreamTimer: Duration element '#stream-duration-text' not found!");this.reset()}formatTime(e){const t=Math.floor(e/3600),s=Math.floor(e%3600/60),n=Math.floor(e%60),i=r=>String(r).padStart(2,"0");return t>0?`${t}:${i(s)}:${i(n)}`:`${s}:${i(n)}`}updateDisplay(){if(this.streamStartTime>0){const t=(Date.now()-this.streamStartTime)/1e3;this.timerElement.textContent=this.formatTime(Math.max(0,t))}}start(e=0){this.stop(),this.streamStartTime=Date.now()-e*1e3,this.updateDisplay(),this.intervalId=window.setInterval(()=>this.updateDisplay(),1e3),console.log(`Stream timer started with initial ${e.toFixed(2)}s.`)}stop(){this.intervalId!==null&&(clearInterval(this.intervalId),this.intervalId=null,console.log("Stream timer stopped."))}reset(){this.stop(),this.streamStartTime=0,this.timerElement.textContent="0:00",console.log("Stream timer reset.")}}class Y{constructor(){o(this,"sidebarElement");o(this,"toggleButton");o(this,"showChatButton");o(this,"isCollapsed",!1);o(this,"bodyElement");if(this.sidebarElement=document.getElementById("chat-sidebar"),this.toggleButton=document.getElementById("toggle-chat-button"),this.showChatButton=document.getElementById("show-chat-button"),this.bodyElement=document.body,!this.sidebarElement||!this.toggleButton||!this.showChatButton)throw new Error("ChatSidebar: Required elements not found in DOM!");this.setupEventListeners(),this.setCollapsed(!1,!0),console.log("ChatSidebar initialized.")}setupEventListeners(){this.toggleButton.addEventListener("click",()=>this.toggleCollapse()),this.showChatButton.addEventListener("click",()=>this.toggleCollapse())}toggleCollapse(){this.setCollapsed(!this.isCollapsed)}setCollapsed(e,t=!1){this.isCollapsed=e,this.isCollapsed?this.bodyElement.classList.add("chat-collapsed"):this.bodyElement.classList.remove("chat-collapsed"),t?(this.sidebarElement.style.transition="none",this.toggleButton.style.transition="none",this.showChatButton.style.transition="none"):(this.sidebarElement.style.transition="width 0.3s ease-in-out, min-width 0.3s ease-in-out",this.toggleButton.style.transition="transform 0.3s ease-in-out, background-color 0.2s, color 0.2s",this.showChatButton.style.transition="opacity 0.3s ease-in-out, visibility 0.3s ease-in-out"),this.isCollapsed?(this.sidebarElement.classList.add("collapsed"),this.toggleButton.setAttribute("aria-label","展开聊天"),this.sidebarElement.querySelectorAll(":scope > *:not(.chat-sidebar-header)").forEach(s=>{s.style.opacity="0",s.style.pointerEvents="none"}),console.log("Chat sidebar collapsed.")):(this.sidebarElement.classList.remove("collapsed"),this.toggleButton.setAttribute("aria-label","重叠聊天"),this.sidebarElement.querySelectorAll(":scope > *:not(.chat-sidebar-header)").forEach(s=>{s.style.opacity="1",s.style.pointerEvents="auto"}),console.log("Chat sidebar expanded.")),t&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.sidebarElement.style.transition="",this.toggleButton.style.transition="",this.showChatButton.style.transition=""})})}getIsCollapsed(){return this.isCollapsed}}class K{constructor(){o(this,"indicatorElement");if(this.indicatorElement=document.querySelector(".live-indicator-rect"),!this.indicatorElement)throw new Error("LiveIndicator: Required .live-indicator-rect element not found in DOM!");this.hide()}show(){this.indicatorElement.classList.remove("hidden")}hide(){this.indicatorElement.classList.add("hidden")}}class ee{constructor(){o(this,"nicknameElement");o(this,"titleElement");o(this,"categoryElement");o(this,"tagsContainer");if(this.nicknameElement=document.getElementById("streamer-nickname"),this.titleElement=document.getElementById("stream-title-full"),this.categoryElement=document.querySelector(".stream-category"),this.tagsContainer=document.querySelector(".stream-tags"),!this.nicknameElement||!this.titleElement||!this.categoryElement||!this.tagsContainer)throw new Error("StreamInfoDisplay: One or more required elements not found in DOM!");console.log("StreamInfoDisplay initialized.")}update(e){this.nicknameElement.textContent=e.streamer_nickname,this.titleElement.textContent=e.stream_title,this.categoryElement.textContent=e.stream_category,this.tagsContainer.innerHTML="",e.stream_tags.forEach(t=>{const s=document.createElement("a");s.href="#",s.className="stream-tag",s.textContent=t,this.tagsContainer.appendChild(s)}),console.log("Stream info display updated with new metadata.")}}class te{constructor(){o(this,"wakeLockSentinel",null);o(this,"isSupported");this.isSupported="wakeLock"in navigator,this.isSupported?console.log("WakeLockManager initialized. API is supported."):console.warn("Wake Lock API is not supported in this browser. The device may go to sleep during playback.")}async requestWakeLock(){if(!(!this.isSupported||this.wakeLockSentinel))try{this.wakeLockSentinel=await navigator.wakeLock.request("screen"),this.wakeLockSentinel.addEventListener("release",()=>{console.log("Wake Lock was released by the browser."),this.wakeLockSentinel=null}),console.log("Wake Lock is active."),document.addEventListener("visibilitychange",this.handleVisibilityChange.bind(this))}catch(e){console.error(`Failed to acquire Wake Lock: ${e.name}, ${e.message}`),this.wakeLockSentinel=null}}async releaseWakeLock(){this.wakeLockSentinel&&(await this.wakeLockSentinel.release(),this.wakeLockSentinel=null,console.log("Wake Lock has been released.")),document.removeEventListener("visibilitychange",this.handleVisibilityChange.bind(this))}async handleVisibilityChange(){this.wakeLockSentinel===null&&document.visibilityState==="visible"&&(console.log("Page is visible again, re-acquiring Wake Lock..."),await this.requestWakeLock())}}class L{constructor(e){o(this,"modalContainer");o(this,"overlay");o(this,"closeButton");o(this,"saveButton");o(this,"usernameInput");o(this,"backendUrlInput");o(this,"avatarPreview");o(this,"avatarUploadInput");o(this,"avatarUploadButton");o(this,"reconnectAttemptsInput");o(this,"onSave");if(this.onSave=e,this.modalContainer=document.getElementById("settings-modal"),this.overlay=document.getElementById("settings-modal-overlay"),this.closeButton=document.getElementById("settings-close-button"),this.saveButton=document.getElementById("settings-save-button"),this.usernameInput=document.getElementById("username-setting-input"),this.backendUrlInput=document.getElementById("backend-url-input"),this.avatarPreview=document.getElementById("avatar-setting-preview"),this.avatarUploadInput=document.getElementById("avatar-setting-upload"),this.avatarUploadButton=document.getElementById("avatar-upload-button"),this.reconnectAttemptsInput=document.getElementById("reconnect-attempts-input"),!this.modalContainer)throw new Error("Settings modal container not found!");this.setupEventListeners(),console.log("SettingsModal initialized.")}setupEventListeners(){this.closeButton.addEventListener("click",()=>this.close()),this.overlay.addEventListener("click",()=>this.close()),this.saveButton.addEventListener("click",()=>this.handleSave()),this.avatarUploadButton.addEventListener("click",()=>this.avatarUploadInput.click()),this.avatarUploadInput.addEventListener("change",e=>this.handleAvatarUpload(e))}handleAvatarUpload(e){const t=e.target;if(t.files&&t.files[0]){const s=new FileReader;s.onload=n=>{var i;(i=n.target)!=null&&i.result&&(this.avatarPreview.src=n.target.result)},s.readAsDataURL(t.files[0])}}handleSave(){const e={username:this.usernameInput.value.trim()||"User",avatarDataUrl:this.avatarPreview.src,backendUrl:this.backendUrlInput.value.trim(),reconnectAttempts:parseInt(this.reconnectAttemptsInput.value,10)||-1};localStorage.setItem("neuro_settings",JSON.stringify(e)),this.onSave(e),this.close()}open(){this.loadSettings(),this.modalContainer.classList.remove("hidden")}close(){this.modalContainer.classList.add("hidden")}loadSettings(){const e=L.getSettings();this.usernameInput.value=e.username,this.avatarPreview.src=e.avatarDataUrl,this.backendUrlInput.value=e.backendUrl,this.reconnectAttemptsInput.value=String(e.reconnectAttempts)}static getSettings(){const e=localStorage.getItem("neuro_settings");if(e)try{return JSON.parse(e)}catch(t){console.error("Failed to parse settings from localStorage, returning defaults.",t)}return{username:"One_of_Swarm",avatarDataUrl:"/user_avatar.jpg",backendUrl:"ws://127.0.0.1:8000",reconnectAttempts:-1}}}class se{constructor(){o(this,"button",null);o(this,"isMuted",!0)}create(){return this.button=document.getElementById("mute-button"),this.button?this.button.addEventListener("click",e=>{e.stopPropagation(),this.unmute()}):console.error("Mute button element not found in DOM!"),this.button}show(){this.button&&(this.button.style.display="flex")}hide(){this.button&&(this.button.style.display="none")}unmute(){this.isMuted=!1,this.hide(),this.updateMediaElements()}updateMediaElements(){const e=document.getElementById("startup-video");e&&(e.muted=this.isMuted);try{f.getAppInitializer().getAudioPlayer().updateMuteState()}catch(t){console.warn("Could not update audio player mute state:",t)}}getElement(){return this.button}getIsMuted(){return this.isMuted}}async function ne(a,e={},t){return window.__TAURI_INTERNALS__.invoke(a,e,t)}const ie=typeof window<"u"&&window.__TAURI__!==void 0,oe="3546729368520811",ae="4281748";async function re(){var a,e;try{if(ie)return console.log("Running in Tauri, invoking 'get_latest_replay_video' command..."),await ne("get_latest_replay_video");{console.log("Running in Web, fetching from proxy...");const t=`/bilibili-api/x/series/archives?mid=${oe}&series_id=${ae}&ps=1&pn=1`,s=await fetch(t);if(!s.ok)throw new Error(`Failed to fetch from proxy: ${s.statusText}`);const n=await s.json();if(n.code!==0)throw new Error(`Bilibili API error: ${n.message}`);const i=(e=(a=n==null?void 0:n.data)==null?void 0:a.archives)==null?void 0:e[0];if(i&&i.bvid&&i.aid)return i;throw new Error("No matching video found in API response.")}}catch(t){return console.error("Failed to get latest replay video:",t),null}}function le(a){const e="//www.bilibili.com/blackboard/html5mobileplayer.html",t=new URLSearchParams({bvid:a.bvid,aid:String(a.aid),p:"1",autoplay:"1",danmaku:"0",hasMuteButton:"1",hideCoverInfo:"0",fjw:"0",high_quality:"1"});return`${e}?${t.toString()}`}class ce{constructor(){o(this,"wsClient");o(this,"audioPlayer");o(this,"videoPlayer");o(this,"neuroAvatar");o(this,"chatDisplay");o(this,"userInput");o(this,"layoutManager");o(this,"streamTimer");o(this,"chatSidebar");o(this,"liveIndicator");o(this,"streamInfoDisplay");o(this,"wakeLockManager");o(this,"settingsModal");o(this,"currentSettings");o(this,"muteButton");o(this,"resizeObserver",null);o(this,"offlinePlayerSrc",null);o(this,"isStarted",!1);o(this,"currentPhase","offline");o(this,"adjustOfflineLayout",()=>{if(this.currentPhase!=="offline")return;const e=document.getElementById("offline-content-container"),t=document.querySelector(".offline-video-player"),s=document.querySelector(".offline-info-card");if(!e||!t||!s)return;if(window.innerWidth<=767)e.style.flexWrap="wrap",s.style.width=t.offsetWidth+"px",s.style.height="auto",s.style.flex="0 0 auto";else{e.style.flexWrap="nowrap";const i=t.offsetHeight;i>0&&(s.style.height=`${i}px`,s.style.width=`${i}px`),s.style.flex="0 1 auto"}});this.layoutManager=new Z,this.streamTimer=new G,this.muteButton=new se,this.currentSettings=L.getSettings(),this.settingsModal=new L(t=>this.handleSettingsUpdate(t)),this.wsClient=null,this.audioPlayer=new j,this.videoPlayer=new Q,this.neuroAvatar=new J,this.chatDisplay=new F,this.userInput=new X,this.userInput.onSendMessage(t=>this.sendUserMessage(t)),this.chatSidebar=new Y,this.liveIndicator=new K,this.streamInfoDisplay=new ee,this.wakeLockManager=new te,this.setupSettingsModalTrigger(),this.setupMuteButton();const e=document.querySelector(".offline-video-player");e&&(this.offlinePlayerSrc=e.src),this.updateOfflinePlayerSrc()}start(){this.isStarted||(this.isStarted=!0,this.probeForIntegratedServer(),this.layoutManager.start(),this.goOffline(),this.updateUiWithSettings())}setupSettingsModalTrigger(){const e=document.querySelector(".nav-user-avatar-button");e&&e.addEventListener("click",()=>{this.settingsModal.open()})}setupMuteButton(){if(this.muteButton.create()){this.muteButton.show();const t=()=>{this.muteButton.unmute(),document.removeEventListener("click",t)};document.addEventListener("click",t)}}getMuteButton(){return this.muteButton}getAudioPlayer(){return this.audioPlayer}getNeuroAvatar(){return this.neuroAvatar}handleSettingsUpdate(e){if(console.log("Settings updated. Re-initializing connection with new settings:",e),this.currentSettings=e,this.updateUiWithSettings(),this.wsClient){const t=e.backendUrl?`${e.backendUrl}/ws/stream`:"";this.wsClient.updateOptions({url:t,maxReconnectAttempts:e.reconnectAttempts}),this.wsClient.disconnect(),setTimeout(()=>{this.wsClient&&this.wsClient.getUrl()?this.wsClient.connect():console.warn("Cannot connect: Backend URL is empty after update or WebSocket client not ready.")},500)}else console.warn("WebSocket client not initialized, cannot update settings.")}initWebSocketClient(e){const t=e?`${e}/ws/stream`:"",s=n=>this.handleWebSocketMessage(n);this.wsClient?(this.wsClient.updateOptions({url:t,autoReconnect:!0,maxReconnectAttempts:this.currentSettings.reconnectAttempts,onMessage:s,onOpen:()=>this.goOnline(),onDisconnect:()=>this.goOffline()}),t&&(this.wsClient.disconnect(),setTimeout(()=>{this.wsClient.connect()},500))):this.wsClient=new W({url:t,autoReconnect:!0,maxReconnectAttempts:this.currentSettings.reconnectAttempts,onMessage:s,onOpen:()=>this.goOnline(),onDisconnect:()=>this.goOffline()})}async probeForIntegratedServer(){const e=L.getSettings();console.log("Probing for integrated server. Stored settings:",e);try{const t=new URL("/api/system/health",window.location.origin).toString();console.log("Probing integrated server at:",t);const s=await fetch(t);if(s.ok){console.log("Integrated server detected via health check. Auto-connecting...");const n=window.location.origin;this.currentSettings={...this.currentSettings,backendUrl:n},localStorage.setItem("neuro_settings",JSON.stringify(this.currentSettings)),this.initWebSocketClient(n),this.wsClient&&n&&this.wsClient.connect();return}else console.log("Health check failed, not an integrated server. Status:",s.status)}catch(t){console.log("Failed to probe for integrated server, assuming standalone mode.",t)}console.log("Falling back to stored backend URL:",e.backendUrl),this.initWebSocketClient(e.backendUrl),this.wsClient&&e.backendUrl?this.wsClient.connect():e.backendUrl||(console.warn("Backend URL is not configured via probe or stored settings. Opening settings modal."),this.settingsModal.open())}updateUiWithSettings(){document.querySelectorAll(".user-avatar-img").forEach(t=>t.src=this.currentSettings.avatarDataUrl),console.log(`UI updated with username: ${this.currentSettings.username} and avatar.`)}async updateOfflinePlayerSrc(){console.log("Attempting to fetch the latest replay video...");const e=await re();if(e){const t=le(e);if(this.offlinePlayerSrc=t,console.log("Successfully updated offline player src to:",t),this.currentPhase==="offline"){const s=document.querySelector(".offline-video-player");s&&(s.src=this.offlinePlayerSrc)}}else console.log("Failed to fetch latest replay video, using default fallback.")}goOnline(){var s,n,i,r;console.log("Entering ONLINE state."),this.updateUiWithSettings();const e=document.querySelector(".offline-video-player");e&&(e.src="about:blank"),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),window.removeEventListener("resize",this.adjustOfflineLayout);const t=document.querySelector(".offline-info-card");t&&(t.style.height="",t.style.width=""),(s=document.getElementById("offline-content-container"))==null||s.classList.add("hidden"),(n=document.getElementById("stream-display-viewport"))==null||n.classList.remove("hidden"),(i=document.querySelector(".stream-info-details-row"))==null||i.classList.remove("hidden"),(r=document.getElementById("chat-sidebar"))==null||r.classList.remove("hidden"),this.showStreamContent(),this.chatDisplay.clearChat(),this.liveIndicator.show(),this.wakeLockManager.requestWakeLock()}goOffline(){var s,n,i,r;console.log("Entering OFFLINE state."),this.currentPhase="offline";const e=document.querySelector(".offline-video-player");e&&this.offlinePlayerSrc&&(e.src=this.offlinePlayerSrc),(s=document.getElementById("offline-content-container"))==null||s.classList.remove("hidden"),(n=document.getElementById("stream-display-viewport"))==null||n.classList.add("hidden"),(i=document.querySelector(".stream-info-details-row"))==null||i.classList.add("hidden"),(r=document.getElementById("chat-sidebar"))==null||r.classList.add("hidden"),this.hideStreamContent(),this.audioPlayer.stopAllAudio(),this.videoPlayer.hide(),this.neuroAvatar.setStage("hidden",!0),A(),this.streamTimer.stop(),this.streamTimer.reset(),this.chatDisplay.clearChat(),this.liveIndicator.hide(),this.wakeLockManager.releaseWakeLock(),this.muteButton.show();const t=()=>{this.muteButton.unmute(),document.removeEventListener("click",t)};document.addEventListener("click",t),setTimeout(()=>{this.adjustOfflineLayout();const d=document.querySelector(".offline-video-player");d&&!this.resizeObserver&&(this.resizeObserver=new ResizeObserver(this.adjustOfflineLayout),this.resizeObserver.observe(d),window.addEventListener("resize",this.adjustOfflineLayout))},0)}handleWebSocketMessage(e){switch(this.currentPhase==="offline"&&["play_welcome_video","start_avatar_intro","enter_live_phase"].includes(e.type)&&(console.log("Connection successful, transitioning from OFFLINE to active state."),this.goOnline()),e.elapsed_time_sec!==void 0&&this.streamTimer.start(e.elapsed_time_sec),e.type){case"offline":this.goOffline();break;case"model_spin":this.neuroAvatar.triggerSpin();break;case"model_zoom":this.neuroAvatar.triggerZoom();break;case"update_stream_metadata":this.streamInfoDisplay.update(e);break;case"play_welcome_video":this.currentPhase="initializing",this.videoPlayer.showAndPlayVideo(parseFloat(e.progress));break;case"start_avatar_intro":this.currentPhase="avatar_intro",this.videoPlayer.pauseAndMute(),this.neuroAvatar.startIntroAnimation(()=>{this.videoPlayer.hide()});break;case"enter_live_phase":this.currentPhase="live",this.videoPlayer.hide(),this.neuroAvatar.setStage("step2");break;case"neuro_is_speaking":break;case"neuro_speech_segment":const t=e;t.is_end?this.audioPlayer.setAllSegmentsReceived():t.audio_base64&&t.text&&typeof t.duration=="number"?this.audioPlayer.addAudioSegment(t.text,t.audio_base64,t.duration):console.warn("Received neuro_speech_segment message with missing audio/text/duration:",t);break;case"neuro_error_signal":console.warn("Received neuro_error_signal from backend."),D("Someone tell Vedal there is a problem with my AI."),this.audioPlayer.playErrorSound();break;case"chat_message":(!this.chatSidebar.getIsCollapsed()||e.is_user_message)&&this.chatDisplay.appendChatMessage(e);break;case"error":this.chatDisplay.appendChatMessage({type:"chat_message",username:"System",text:`后端错误: ${e.message}`,is_user_message:!1});break}}sendUserMessage(e){const t={username:this.currentSettings.username,...e};this.wsClient?this.wsClient.send(t):console.warn("Cannot send message: WebSocket client is not initialized.")}showStreamContent(){const e=document.getElementById("stream-display-area");e&&(e.style.visibility="visible",e.style.opacity="1")}hideStreamContent(){const e=document.getElementById("stream-display-area");e&&(e.style.visibility="hidden",e.style.opacity="0")}}const S=class S{constructor(){o(this,"appInitializerInstance",null)}static getInstance(){return S.instance||(S.instance=new S),S.instance}getAppInitializer(){return this.appInitializerInstance?console.log("Returning existing AppInitializer instance."):(console.log("Creating new AppInitializer instance..."),this.appInitializerInstance=new ce),this.appInitializerInstance}};o(S,"instance");let _=S;const f=_.getInstance();document.addEventListener("DOMContentLoaded",()=>{console.log("DOMContentLoaded event fired."),f.getAppInitializer().start()});console.log("main.ts loaded. Waiting for DOMContentLoaded to initialize the app.");
|
@@ -1 +0,0 @@
|
|
1
|
-
import{d as m,k as g,A as x,a as v,x as f,b as C,n as o,o as s,g as r,e as h,t as l,h as p,F as y,p as b,f as w,_ as k}from"./index-Sav9Djr5.js";const V={class:"d-flex align-center mb-4"},S={key:0,class:"context-prompt-view"},A={key:1,class:"context-conversation-view"},M=m({__name:"ContextTab",setup(B){const t=g(!1),n=x(),c=v();async function i(){if(c.isConnected)if(t.value)try{const e=await c.sendAdminWsMessage("get_last_prompt");n.agentContext=e.prompt}catch(e){console.error("获取最新Prompt失败:",e),n.agentContext=`获取提示词失败: ${e}`}else try{const e=await c.sendAdminWsMessage("get_agent_context");n.agentContext=e}catch(e){console.error("获取上下文失败:",e)}}return f(t,i),i(),(e,d)=>{const u=C("v-switch");return s(),o("div",null,[r("div",V,[h(u,{modelValue:t.value,"onUpdate:modelValue":d[0]||(d[0]=a=>t.value=a),label:"上下文模式",color:"primary","hide-details":""},null,8,["modelValue"])]),t.value?(s(),o("div",S,[r("pre",null,l(p(n).agentContext),1)])):(s(),o("div",A,[(s(!0),o(y,null,b(p(n).agentContext,(a,_)=>(s(),o("div",{key:_,class:"message-item"},[r("p",null,[r("strong",null,l(a.role)+":",1),w(" "+l(a.content),1)])]))),128))]))])}}}),T=k(M,[["__scopeId","data-v-dd6969bb"]]);export{T as default};
|
@@ -1 +0,0 @@
|
|
1
|
-
.context-prompt-view pre[data-v-dd6969bb]{background-color:#1e1e1e;color:#d4d4d4;font-family:Courier New,Courier,monospace;padding:16px;border-radius:4px;white-space:pre-wrap;word-wrap:break-word;max-height:70vh;overflow-y:auto}.message-item[data-v-dd6969bb]{padding:8px 0;border-bottom:1px solid #e0e0e0}
|
File without changes
|
File without changes
|
File without changes
|