079project 1.0.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.
Files changed (67) hide show
  1. package/GroupStarter.cjs +647 -0
  2. package/LICENSE +165 -0
  3. package/PropagateSignalUseJsWorker.js +92 -0
  4. package/README.md +102 -0
  5. package/Redis-8.0.3-Windows-x64-cygwin-with-Service/README.md +52 -0
  6. package/Redis-8.0.3-Windows-x64-cygwin-with-Service/README.zh_CN.md +59 -0
  7. package/Redis-8.0.3-Windows-x64-cygwin-with-Service/RedisService.exe +0 -0
  8. package/Redis-8.0.3-Windows-x64-cygwin-with-Service/cygcrypto-3.dll +0 -0
  9. package/Redis-8.0.3-Windows-x64-cygwin-with-Service/cyggcc_s-seh-1.dll +0 -0
  10. package/Redis-8.0.3-Windows-x64-cygwin-with-Service/cygssl-3.dll +0 -0
  11. package/Redis-8.0.3-Windows-x64-cygwin-with-Service/cygstdc++-6.dll +0 -0
  12. package/Redis-8.0.3-Windows-x64-cygwin-with-Service/cygwin1.dll +0 -0
  13. package/Redis-8.0.3-Windows-x64-cygwin-with-Service/cygz.dll +0 -0
  14. package/Redis-8.0.3-Windows-x64-cygwin-with-Service/dump.rdb +0 -0
  15. package/Redis-8.0.3-Windows-x64-cygwin-with-Service/install_redis_service.bat +100 -0
  16. package/Redis-8.0.3-Windows-x64-cygwin-with-Service/redis-benchmark.exe +0 -0
  17. package/Redis-8.0.3-Windows-x64-cygwin-with-Service/redis-check-aof.exe +0 -0
  18. package/Redis-8.0.3-Windows-x64-cygwin-with-Service/redis-check-rdb.exe +0 -0
  19. package/Redis-8.0.3-Windows-x64-cygwin-with-Service/redis-cli.exe +0 -0
  20. package/Redis-8.0.3-Windows-x64-cygwin-with-Service/redis-full.conf +376 -0
  21. package/Redis-8.0.3-Windows-x64-cygwin-with-Service/redis-sentinel.exe +0 -0
  22. package/Redis-8.0.3-Windows-x64-cygwin-with-Service/redis-server.exe +0 -0
  23. package/Redis-8.0.3-Windows-x64-cygwin-with-Service/redis.conf +2348 -0
  24. package/Redis-8.0.3-Windows-x64-cygwin-with-Service/sentinel.conf +361 -0
  25. package/Redis-8.0.3-Windows-x64-cygwin-with-Service/start.bat +4 -0
  26. package/Redis-8.0.3-Windows-x64-cygwin-with-Service/uninstall_redis_service.bat +30 -0
  27. package/boot.py +51 -0
  28. package/chat_Client.js +29 -0
  29. package/controller.cjs +118 -0
  30. package/enhancedForwarder.js +378 -0
  31. package/forwarder.js +1456 -0
  32. package/groupmanager.cjs +143 -0
  33. package/howToStart.txt +8 -0
  34. package/lemma.csv +210 -0
  35. package/load.py +35 -0
  36. package/mainManager.cjs +81 -0
  37. package/mainStarter.cjs +535 -0
  38. package/main_Serve.cjs +2745 -0
  39. package/main_Study.cjs +3230 -0
  40. package/memeMergeWorker.cjs +55 -0
  41. package/model_RNN.py +117 -0
  42. package/note.txt +5 -0
  43. package/notebook.txt +8 -0
  44. package/npminstall-debug.log +206 -0
  45. package/package.json +48 -0
  46. package/public/chat_straight.html +90 -0
  47. package/public/index.html +247 -0
  48. package/public/indexmain.html +136 -0
  49. package/public/monitor.html +194 -0
  50. package/robots/wikitext-something.txt +25 -0
  51. package/runtime.proto +24 -0
  52. package/runtime_data.json +766294 -0
  53. package/serializer_seq2seq.h5 +0 -0
  54. package/start.js +46 -0
  55. package/tests/test_FIrststep1.txt +1224 -0
  56. package/tests/test_FIrststep2.txt +2956 -0
  57. package/tests/test_FIrststep3.txt +1224 -0
  58. package/tests/test_FIrststep4.txt +1396 -0
  59. package/tests/test_FIrststep5.txt +2852 -0
  60. package/tests/test_FIrststep6.txt +1516 -0
  61. package/tests/test_FirstStep7.txt +1748 -0
  62. package/tests/test_Firstsetp8.txt +2672 -0
  63. package/tokenizer.json +1 -0
  64. package/vocabularySplitter.js +253 -0
  65. package/wikitext/.gitattributes +27 -0
  66. package/wikitext/README.md +344 -0
  67. package/wikitext/describtion.txt +1 -0
@@ -0,0 +1,361 @@
1
+ # Example sentinel.conf
2
+
3
+ # By default protected mode is disabled in sentinel mode. Sentinel is reachable
4
+ # from interfaces different than localhost. Make sure the sentinel instance is
5
+ # protected from the outside world via firewalling or other means.
6
+ protected-mode no
7
+
8
+ # port <sentinel-port>
9
+ # The port that this sentinel instance will run on
10
+ port 26379
11
+
12
+ # By default Redis Sentinel does not run as a daemon. Use 'yes' if you need it.
13
+ # Note that Redis will write a pid file in /var/run/redis-sentinel.pid when
14
+ # daemonized.
15
+ daemonize no
16
+
17
+ # When running daemonized, Redis Sentinel writes a pid file in
18
+ # /var/run/redis-sentinel.pid by default. You can specify a custom pid file
19
+ # location here.
20
+ pidfile /var/run/redis-sentinel.pid
21
+
22
+ # Specify the server verbosity level.
23
+ # This can be one of:
24
+ # debug (a lot of information, useful for development/testing)
25
+ # verbose (many rarely useful info, but not a mess like the debug level)
26
+ # notice (moderately verbose, what you want in production probably)
27
+ # warning (only very important / critical messages are logged)
28
+ # nothing (nothing is logged)
29
+ loglevel notice
30
+
31
+ # Specify the log file name. Also the empty string can be used to force
32
+ # Sentinel to log on the standard output. Note that if you use standard
33
+ # output for logging but daemonize, logs will be sent to /dev/null
34
+ logfile ""
35
+
36
+ # To enable logging to the system logger, just set 'syslog-enabled' to yes,
37
+ # and optionally update the other syslog parameters to suit your needs.
38
+ # syslog-enabled no
39
+
40
+ # Specify the syslog identity.
41
+ # syslog-ident sentinel
42
+
43
+ # Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7.
44
+ # syslog-facility local0
45
+
46
+ # sentinel announce-ip <ip>
47
+ # sentinel announce-port <port>
48
+ #
49
+ # The above two configuration directives are useful in environments where,
50
+ # because of NAT, Sentinel is reachable from outside via a non-local address.
51
+ #
52
+ # When announce-ip is provided, the Sentinel will claim the specified IP address
53
+ # in HELLO messages used to gossip its presence, instead of auto-detecting the
54
+ # local address as it usually does.
55
+ #
56
+ # Similarly when announce-port is provided and is valid and non-zero, Sentinel
57
+ # will announce the specified TCP port.
58
+ #
59
+ # The two options don't need to be used together, if only announce-ip is
60
+ # provided, the Sentinel will announce the specified IP and the server port
61
+ # as specified by the "port" option. If only announce-port is provided, the
62
+ # Sentinel will announce the auto-detected local IP and the specified port.
63
+ #
64
+ # Example:
65
+ #
66
+ # sentinel announce-ip 1.2.3.4
67
+
68
+ # dir <working-directory>
69
+ # Every long running process should have a well-defined working directory.
70
+ # For Redis Sentinel to chdir to /tmp at startup is the simplest thing
71
+ # for the process to don't interfere with administrative tasks such as
72
+ # unmounting filesystems.
73
+ dir /tmp
74
+
75
+ # sentinel monitor <master-name> <ip> <redis-port> <quorum>
76
+ #
77
+ # Tells Sentinel to monitor this master, and to consider it in O_DOWN
78
+ # (Objectively Down) state only if at least <quorum> sentinels agree.
79
+ #
80
+ # Note that whatever is the ODOWN quorum, a Sentinel will require to
81
+ # be elected by the majority of the known Sentinels in order to
82
+ # start a failover, so no failover can be performed in minority.
83
+ #
84
+ # Replicas are auto-discovered, so you don't need to specify replicas in
85
+ # any way. Sentinel itself will rewrite this configuration file adding
86
+ # the replicas using additional configuration options.
87
+ # Also note that the configuration file is rewritten when a
88
+ # replica is promoted to master.
89
+ #
90
+ # Note: master name should not include special characters or spaces.
91
+ # The valid charset is A-z 0-9 and the three characters ".-_".
92
+ sentinel monitor mymaster 127.0.0.1 6379 2
93
+
94
+ # sentinel auth-pass <master-name> <password>
95
+ #
96
+ # Set the password to use to authenticate with the master and replicas.
97
+ # Useful if there is a password set in the Redis instances to monitor.
98
+ #
99
+ # Note that the master password is also used for replicas, so it is not
100
+ # possible to set a different password in masters and replicas instances
101
+ # if you want to be able to monitor these instances with Sentinel.
102
+ #
103
+ # However you can have Redis instances without the authentication enabled
104
+ # mixed with Redis instances requiring the authentication (as long as the
105
+ # password set is the same for all the instances requiring the password) as
106
+ # the AUTH command will have no effect in Redis instances with authentication
107
+ # switched off.
108
+ #
109
+ # Example:
110
+ #
111
+ # sentinel auth-pass mymaster MySUPER--secret-0123passw0rd
112
+
113
+ # sentinel auth-user <master-name> <username>
114
+ #
115
+ # This is useful in order to authenticate to instances having ACL capabilities,
116
+ # that is, running Redis 6.0 or greater. When just auth-pass is provided the
117
+ # Sentinel instance will authenticate to Redis using the old "AUTH <pass>"
118
+ # method. When also an username is provided, it will use "AUTH <user> <pass>".
119
+ # In the Redis servers side, the ACL to provide just minimal access to
120
+ # Sentinel instances, should be configured along the following lines:
121
+ #
122
+ # user sentinel-user >somepassword +client +subscribe +publish \
123
+ # +ping +info +multi +slaveof +config +client +exec on
124
+
125
+ # sentinel down-after-milliseconds <master-name> <milliseconds>
126
+ #
127
+ # Number of milliseconds the master (or any attached replica or sentinel) should
128
+ # be unreachable (as in, not acceptable reply to PING, continuously, for the
129
+ # specified period) in order to consider it in S_DOWN state (Subjectively
130
+ # Down).
131
+ #
132
+ # Default is 30 seconds.
133
+ sentinel down-after-milliseconds mymaster 30000
134
+
135
+ # IMPORTANT NOTE: starting with Redis 6.2 ACL capability is supported for
136
+ # Sentinel mode, please refer to the Redis website https://redis.io/docs/latest/operate/oss_and_stack/management/security/acl/
137
+ # for more details.
138
+
139
+ # Sentinel's ACL users are defined in the following format:
140
+ #
141
+ # user <username> ... acl rules ...
142
+ #
143
+ # For example:
144
+ #
145
+ # user worker +@admin +@connection ~* on >ffa9203c493aa99
146
+ #
147
+ # For more information about ACL configuration please refer to the Redis
148
+ # website at https://redis.io/docs/latest/operate/oss_and_stack/management/security/acl/ and redis server configuration
149
+ # template redis.conf.
150
+
151
+ # ACL LOG
152
+ #
153
+ # The ACL Log tracks failed commands and authentication events associated
154
+ # with ACLs. The ACL Log is useful to troubleshoot failed commands blocked
155
+ # by ACLs. The ACL Log is stored in memory. You can reclaim memory with
156
+ # ACL LOG RESET. Define the maximum entry length of the ACL Log below.
157
+ acllog-max-len 128
158
+
159
+ # Using an external ACL file
160
+ #
161
+ # Instead of configuring users here in this file, it is possible to use
162
+ # a stand-alone file just listing users. The two methods cannot be mixed:
163
+ # if you configure users here and at the same time you activate the external
164
+ # ACL file, the server will refuse to start.
165
+ #
166
+ # The format of the external ACL user file is exactly the same as the
167
+ # format that is used inside redis.conf to describe users.
168
+ #
169
+ # aclfile /etc/redis/sentinel-users.acl
170
+
171
+ # requirepass <password>
172
+ #
173
+ # You can configure Sentinel itself to require a password, however when doing
174
+ # so Sentinel will try to authenticate with the same password to all the
175
+ # other Sentinels. So you need to configure all your Sentinels in a given
176
+ # group with the same "requirepass" password. Check the following documentation
177
+ # for more info: https://redis.io/docs/latest/operate/oss_and_stack/management/sentinel/
178
+ #
179
+ # IMPORTANT NOTE: starting with Redis 6.2 "requirepass" is a compatibility
180
+ # layer on top of the ACL system. The option effect will be just setting
181
+ # the password for the default user. Clients will still authenticate using
182
+ # AUTH <password> as usually, or more explicitly with AUTH default <password>
183
+ # if they follow the new protocol: both will work.
184
+ #
185
+ # New config files are advised to use separate authentication control for
186
+ # incoming connections (via ACL), and for outgoing connections (via
187
+ # sentinel-user and sentinel-pass)
188
+ #
189
+ # The requirepass is not compatible with aclfile option and the ACL LOAD
190
+ # command, these will cause requirepass to be ignored.
191
+
192
+ # sentinel sentinel-user <username>
193
+ #
194
+ # You can configure Sentinel to authenticate with other Sentinels with specific
195
+ # user name.
196
+
197
+ # sentinel sentinel-pass <password>
198
+ #
199
+ # The password for Sentinel to authenticate with other Sentinels. If sentinel-user
200
+ # is not configured, Sentinel will use 'default' user with sentinel-pass to authenticate.
201
+
202
+ # sentinel parallel-syncs <master-name> <numreplicas>
203
+ #
204
+ # How many replicas we can reconfigure to point to the new replica simultaneously
205
+ # during the failover. Use a low number if you use the replicas to serve query
206
+ # to avoid that all the replicas will be unreachable at about the same
207
+ # time while performing the synchronization with the master.
208
+ sentinel parallel-syncs mymaster 1
209
+
210
+ # sentinel failover-timeout <master-name> <milliseconds>
211
+ #
212
+ # Specifies the failover timeout in milliseconds. It is used in many ways:
213
+ #
214
+ # - The time needed to re-start a failover after a previous failover was
215
+ # already tried against the same master by a given Sentinel, is two
216
+ # times the failover timeout.
217
+ #
218
+ # - The time needed for a replica replicating to a wrong master according
219
+ # to a Sentinel current configuration, to be forced to replicate
220
+ # with the right master, is exactly the failover timeout (counting since
221
+ # the moment a Sentinel detected the misconfiguration).
222
+ #
223
+ # - The time needed to cancel a failover that is already in progress but
224
+ # did not produced any configuration change (SLAVEOF NO ONE yet not
225
+ # acknowledged by the promoted replica).
226
+ #
227
+ # - The maximum time a failover in progress waits for all the replicas to be
228
+ # reconfigured as replicas of the new master. However even after this time
229
+ # the replicas will be reconfigured by the Sentinels anyway, but not with
230
+ # the exact parallel-syncs progression as specified.
231
+ #
232
+ # Default is 3 minutes.
233
+ sentinel failover-timeout mymaster 180000
234
+
235
+ # SCRIPTS EXECUTION
236
+ #
237
+ # sentinel notification-script and sentinel reconfig-script are used in order
238
+ # to configure scripts that are called to notify the system administrator
239
+ # or to reconfigure clients after a failover. The scripts are executed
240
+ # with the following rules for error handling:
241
+ #
242
+ # If script exits with "1" the execution is retried later (up to a maximum
243
+ # number of times currently set to 10).
244
+ #
245
+ # If script exits with "2" (or an higher value) the script execution is
246
+ # not retried.
247
+ #
248
+ # If script terminates because it receives a signal the behavior is the same
249
+ # as exit code 1.
250
+ #
251
+ # A script has a maximum running time of 60 seconds. After this limit is
252
+ # reached the script is terminated with a SIGKILL and the execution retried.
253
+
254
+ # NOTIFICATION SCRIPT
255
+ #
256
+ # sentinel notification-script <master-name> <script-path>
257
+ #
258
+ # Call the specified notification script for any sentinel event that is
259
+ # generated in the WARNING level (for instance -sdown, -odown, and so forth).
260
+ # This script should notify the system administrator via email, SMS, or any
261
+ # other messaging system, that there is something wrong with the monitored
262
+ # Redis systems.
263
+ #
264
+ # The script is called with just two arguments: the first is the event type
265
+ # and the second the event description.
266
+ #
267
+ # The script must exist and be executable in order for sentinel to start if
268
+ # this option is provided.
269
+ #
270
+ # Example:
271
+ #
272
+ # sentinel notification-script mymaster /var/redis/notify.sh
273
+
274
+ # CLIENTS RECONFIGURATION SCRIPT
275
+ #
276
+ # sentinel client-reconfig-script <master-name> <script-path>
277
+ #
278
+ # When the master changed because of a failover a script can be called in
279
+ # order to perform application-specific tasks to notify the clients that the
280
+ # configuration has changed and the master is at a different address.
281
+ #
282
+ # The following arguments are passed to the script:
283
+ #
284
+ # <master-name> <role> <state> <from-ip> <from-port> <to-ip> <to-port>
285
+ #
286
+ # <state> is currently always "start"
287
+ # <role> is either "leader" or "observer"
288
+ #
289
+ # The arguments from-ip, from-port, to-ip, to-port are used to communicate
290
+ # the old address of the master and the new address of the elected replica
291
+ # (now a master).
292
+ #
293
+ # This script should be resistant to multiple invocations.
294
+ #
295
+ # Example:
296
+ #
297
+ # sentinel client-reconfig-script mymaster /var/redis/reconfig.sh
298
+
299
+ # SECURITY
300
+ #
301
+ # By default SENTINEL SET will not be able to change the notification-script
302
+ # and client-reconfig-script at runtime. This avoids a trivial security issue
303
+ # where clients can set the script to anything and trigger a failover in order
304
+ # to get the program executed.
305
+
306
+ sentinel deny-scripts-reconfig yes
307
+
308
+ # REDIS COMMANDS RENAMING (DEPRECATED)
309
+ #
310
+ # WARNING: avoid using this option if possible, instead use ACLs.
311
+ #
312
+ # Sometimes the Redis server has certain commands, that are needed for Sentinel
313
+ # to work correctly, renamed to unguessable strings. This is often the case
314
+ # of CONFIG and SLAVEOF in the context of providers that provide Redis as
315
+ # a service, and don't want the customers to reconfigure the instances outside
316
+ # of the administration console.
317
+ #
318
+ # In such case it is possible to tell Sentinel to use different command names
319
+ # instead of the normal ones. For example if the master "mymaster", and the
320
+ # associated replicas, have "CONFIG" all renamed to "GUESSME", I could use:
321
+ #
322
+ # SENTINEL rename-command mymaster CONFIG GUESSME
323
+ #
324
+ # After such configuration is set, every time Sentinel would use CONFIG it will
325
+ # use GUESSME instead. Note that there is no actual need to respect the command
326
+ # case, so writing "config guessme" is the same in the example above.
327
+ #
328
+ # SENTINEL SET can also be used in order to perform this configuration at runtime.
329
+ #
330
+ # In order to set a command back to its original name (undo the renaming), it
331
+ # is possible to just rename a command to itself:
332
+ #
333
+ # SENTINEL rename-command mymaster CONFIG CONFIG
334
+
335
+ # HOSTNAMES SUPPORT
336
+ #
337
+ # Normally Sentinel uses only IP addresses and requires SENTINEL MONITOR
338
+ # to specify an IP address. Also, it requires the Redis replica-announce-ip
339
+ # keyword to specify only IP addresses.
340
+ #
341
+ # You may enable hostnames support by enabling resolve-hostnames. Note
342
+ # that you must make sure your DNS is configured properly and that DNS
343
+ # resolution does not introduce very long delays.
344
+ #
345
+ SENTINEL resolve-hostnames no
346
+
347
+ # When resolve-hostnames is enabled, Sentinel still uses IP addresses
348
+ # when exposing instances to users, configuration files, etc. If you want
349
+ # to retain the hostnames when announced, enable announce-hostnames below.
350
+ #
351
+ SENTINEL announce-hostnames no
352
+
353
+ # When master_reboot_down_after_period is set to 0, Sentinel does not fail over
354
+ # when receiving a -LOADING response from a master. This was the only supported
355
+ # behavior before version 7.0.
356
+ #
357
+ # Otherwise, Sentinel will use this value as the time (in ms) it is willing to
358
+ # accept a -LOADING response after a master has been rebooted, before failing
359
+ # over.
360
+
361
+ SENTINEL master-reboot-down-after-period mymaster 0
@@ -0,0 +1,4 @@
1
+ @echo off
2
+ cd /d %~dp0
3
+ redis-server.exe redis.conf
4
+ pause
@@ -0,0 +1,30 @@
1
+ @echo off
2
+ SET REDIS_PATH=%~dp0
3
+
4
+ :: BatchGotAdmin
5
+ :-------------------------------------
6
+ REM --> Check for permissions
7
+ >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
8
+
9
+ REM --> If error flag set, we do not have admin.
10
+ if '%errorlevel%' NEQ '0' (
11
+ echo Requesting administrative privileges...
12
+ goto UACPrompt
13
+ ) else ( goto gotAdmin )
14
+
15
+ :UACPrompt
16
+ echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
17
+ echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
18
+ "%temp%\getadmin.vbs"
19
+ exit /B
20
+
21
+ :gotAdmin
22
+ if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
23
+ pushd "%CD%"
24
+ CD /D "%REDIS_PATH%"
25
+ :--------------------------------------
26
+
27
+ sc stop "Redis"
28
+ sc delete "Redis"
29
+
30
+ pause
package/boot.py ADDED
@@ -0,0 +1,51 @@
1
+ import subprocess
2
+ import time
3
+ import threading
4
+ import sys
5
+ import os
6
+
7
+ node_path = "node"
8
+ serve_script = "main_Serve.cjs"
9
+ study_script = "main_Study.cjs"
10
+ ai_ports = [9001, 9002, 9003]
11
+ study_port = 9004
12
+
13
+ processes = []
14
+
15
+ def start_workers():
16
+ # 启动学习进程
17
+ cmd = [node_path, '--max-old-space-size=16384','--expose-gc',study_script, str(study_port), str(study_port - 1000)]
18
+ print(f"启动学习进程: {cmd}")
19
+ p = subprocess.Popen(cmd, creationflags=subprocess.CREATE_NEW_CONSOLE if os.name == 'nt' else 0)
20
+ processes.append(p)
21
+ # 启动AI服务进程
22
+ for port in ai_ports:
23
+ cmd = [node_path,'--max-old-space-size=16384','--expose-gc',serve_script, str(port), str(port - 1000)]
24
+ print(f"启动服务进程: {cmd}")
25
+ # Windows下新控制台,Linux/macOS可去掉 creationflags
26
+ p = subprocess.Popen(cmd, creationflags=subprocess.CREATE_NEW_CONSOLE if os.name == 'nt' else 0)
27
+ processes.append(p)
28
+ time.sleep(10)
29
+ cmd = [node_path,'./forwarder.js']
30
+ print(f"启动服务进程: {cmd}")
31
+ # Windows下新控制台,Linux/macOS可去掉 creationflags
32
+ p = subprocess.Popen(cmd, creationflags=subprocess.CREATE_NEW_CONSOLE if os.name == 'nt' else 0)
33
+ processes.append(p)
34
+
35
+
36
+ def console_interface():
37
+ while True:
38
+ cmd = input("输入 exit 或 quit 关闭所有进程 > ").strip().lower()
39
+ if cmd in ("exit", "quit"):
40
+ print("正在关闭所有进程...")
41
+ for p in processes:
42
+ p.terminate()
43
+ print("所有进程已关闭。")
44
+ break
45
+
46
+ if __name__ == "__main__":
47
+ start_workers()
48
+ print(f"已启动 {len(processes)} 个进程。")
49
+ t = threading.Thread(target=console_interface)
50
+ t.start()
51
+ t.join()
package/chat_Client.js ADDED
@@ -0,0 +1,29 @@
1
+ const express = require('express');
2
+ const axios = require('axios');
3
+ const path = require('path');
4
+
5
+ const app = express();
6
+ app.use(express.json());
7
+ app.use(express.static(path.join(__dirname, 'public')));
8
+
9
+ // 简单API转发
10
+ app.post('/api/chat', async (req, res) => {
11
+ const { message, port } = req.body;
12
+ if (!message || !port) return res.status(400).json({ error: '缺少消息或端口' });
13
+ try {
14
+ const resp = await axios.post(`http://localhost:${port}/api/chat`, { message });
15
+ res.json({ response: resp.data.response });
16
+ } catch (e) {
17
+ res.status(502).json({ error: e.message });
18
+ }
19
+ });
20
+
21
+ // 前端页面
22
+ app.get('/', (req, res) => {
23
+ res.sendFile(path.join(__dirname, 'public', 'chat_straight.html'));
24
+ });
25
+
26
+ const PORT = process.env.CHAT_CLIENT_PORT || 3000;
27
+ app.listen(PORT, () => {
28
+ console.log(`Chat Client running at http://localhost:${PORT}/`);
29
+ });
package/controller.cjs ADDED
@@ -0,0 +1,118 @@
1
+ const readline = require('readline');
2
+ const os = require('os');
3
+ const chalk = require('chalk');
4
+ const { execSync } = require('child_process');
5
+
6
+ const startTime = Date.now();
7
+ const studyPID = process.argv[2];
8
+ const servePIDs = process.argv.slice(3);
9
+
10
+ // 记录内存历史
11
+ const memHistory = [];
12
+ const maxPoints = 40; // 横向图表宽度
13
+
14
+ function getMem(pid) {
15
+ try {
16
+ if (process.platform === 'win32') {
17
+ const out = execSync(`wmic process where ProcessId=${pid} get WorkingSetSize`).toString();
18
+ const mem = parseInt(out.split('\n')[1]) || 0;
19
+ return (mem / 1024 / 1024).toFixed(2);
20
+ } else {
21
+ const out = execSync(`ps -p ${pid} -o rss=`).toString();
22
+ return (parseInt(out.trim()) / 1024).toFixed(2);
23
+ }
24
+ } catch {
25
+ return 'N/A';
26
+ }
27
+ }
28
+
29
+ function getCPU(pid) {
30
+ try {
31
+ if (process.platform === 'win32') {
32
+ return 'N/A';
33
+ } else {
34
+ const out = execSync(`ps -p ${pid} -o %cpu=`).toString();
35
+ return out.trim();
36
+ }
37
+ } catch {
38
+ return 'N/A';
39
+ }
40
+ }
41
+
42
+ function drawMemChart() {
43
+ if (memHistory.length === 0) return '';
44
+ const maxMem = Math.max(...memHistory, 100);
45
+ let chart = chalk.bold('内存占用历史(横向):\n');
46
+ chart += chalk.gray('[');
47
+ memHistory.forEach(val => {
48
+ const barLen = Math.round((val / maxMem) * 8);
49
+ chart += chalk.bgGreen(' '.repeat(barLen)) + chalk.bgGray(' '.repeat(8 - barLen));
50
+ });
51
+ chart += chalk.gray(']');
52
+ chart += ` 最新:${memHistory[memHistory.length-1].toFixed(1)}MB`;
53
+ return chart;
54
+ }
55
+
56
+ function drawStatus() {
57
+ process.stdout.write('\x1Bc');
58
+ console.log(chalk.bold.bgBlue(' AI Controller 状态面板 '));
59
+ const mins = ((Date.now() - startTime) / 60000).toFixed(2);
60
+ console.log(`运行时间: ${chalk.green(mins + ' 分钟')}`);
61
+ console.log(`学习进程PID: ${chalk.yellow(studyPID)}`);
62
+ servePIDs.forEach((pid, idx) => {
63
+ console.log(`服务进程${idx + 1} PID: ${chalk.yellow(pid)}`);
64
+ });
65
+ console.log(chalk.bold('进程资源占用:'));
66
+ const mem = parseFloat(getMem(studyPID));
67
+ if (!isNaN(mem)) {
68
+ if (memHistory.length >= maxPoints) memHistory.shift();
69
+ memHistory.push(mem);
70
+ }
71
+ console.log(` 学习进程: 内存 ${chalk.magenta(mem + ' MB')} | CPU ${chalk.cyan(getCPU(studyPID) + ' %')}`);
72
+ servePIDs.forEach((pid, idx) => {
73
+ console.log(` 服务进程${idx + 1}: 内存 ${chalk.magenta(getMem(pid) + ' MB')} | CPU ${chalk.cyan(getCPU(pid) + ' %')}`);
74
+ });
75
+ console.log(drawMemChart());
76
+ console.log('\n输入 help 查看命令,输入 status 刷新状态');
77
+ }
78
+
79
+ const rl = readline.createInterface({
80
+ input: process.stdin,
81
+ output: process.stdout,
82
+ prompt: chalk.bold('[TUI] > ')
83
+ });
84
+
85
+ drawStatus();
86
+ rl.prompt();
87
+
88
+ // 自动刷新
89
+ setInterval(drawStatus, 3000);
90
+
91
+ rl.on('line', async (line) => {
92
+ const cmd = line.trim();
93
+ if (cmd === 'status') {
94
+ drawStatus();
95
+ } else if (cmd === 'help') {
96
+ console.log(chalk.bold('可用命令:'));
97
+ console.log(' status 刷新状态面板');
98
+ console.log(' kill [PID] 杀死指定进程');
99
+ console.log(' exit 退出监控');
100
+ console.log(' help 显示帮助');
101
+ } else if (cmd.startsWith('kill')) {
102
+ const pid = cmd.split(' ')[1];
103
+ if (pid) {
104
+ try {
105
+ process.kill(pid);
106
+ console.log(chalk.red(`[TUI] 已杀死进程 ${pid}`));
107
+ } catch (e) {
108
+ console.log(chalk.red(`[TUI] 杀死失败: ${e.message}`));
109
+ }
110
+ }
111
+ } else if (cmd === 'exit') {
112
+ console.log(chalk.red('[TUI] 即将退出监控...'));
113
+ process.exit(0);
114
+ } else {
115
+ console.log(chalk.yellow('[TUI] 未知命令,输入 help 查看帮助'));
116
+ }
117
+ rl.prompt();
118
+ });