neuro-simulator 0.3.1__py3-none-any.whl → 0.3.2__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.
@@ -6,6 +6,7 @@ import time
6
6
 
7
7
  from ..core.config import config_manager
8
8
 
9
+
9
10
  router = APIRouter(tags=["System & Utilities"])
10
11
 
11
12
 
@@ -57,4 +58,6 @@ async def root():
57
58
  "message": "Neuro-Sama Simulator Backend",
58
59
  "version": "2.0",
59
60
  "api_docs": "/docs",
60
- }
61
+ }
62
+
63
+
@@ -287,6 +287,10 @@ async def websocket_admin_endpoint(websocket: WebSocket):
287
287
  initial_context = await agent.get_message_history()
288
288
  await websocket.send_json({"type": "agent_context", "action": "update", "messages": initial_context})
289
289
 
290
+ # Send initial stream status
291
+ status = {"is_running": process_manager.is_running, "backend_status": "running" if process_manager.is_running else "stopped"}
292
+ await websocket.send_json({"type": "stream_status", "payload": status})
293
+
290
294
  # Main loop for receiving messages from the client and pushing log updates
291
295
  while websocket.client_state == WebSocketState.CONNECTED:
292
296
  # Check for incoming messages
@@ -391,17 +395,29 @@ async def handle_admin_ws_message(websocket: WebSocket, data: dict):
391
395
  if not process_manager.is_running:
392
396
  process_manager.start_live_processes()
393
397
  response["payload"] = {"status": "success", "message": "Stream started"}
398
+ # Broadcast stream status update
399
+ from ..utils.websocket import connection_manager
400
+ status = {"is_running": process_manager.is_running, "backend_status": "running" if process_manager.is_running else "stopped"}
401
+ await connection_manager.broadcast_to_admins({"type": "stream_status", "payload": status})
394
402
 
395
403
  elif action == "stop_stream":
396
404
  if process_manager.is_running:
397
405
  await process_manager.stop_live_processes()
398
406
  response["payload"] = {"status": "success", "message": "Stream stopped"}
407
+ # Broadcast stream status update
408
+ from ..utils.websocket import connection_manager
409
+ status = {"is_running": process_manager.is_running, "backend_status": "running" if process_manager.is_running else "stopped"}
410
+ await connection_manager.broadcast_to_admins({"type": "stream_status", "payload": status})
399
411
 
400
412
  elif action == "restart_stream":
401
413
  await process_manager.stop_live_processes()
402
414
  await asyncio.sleep(1)
403
415
  process_manager.start_live_processes()
404
416
  response["payload"] = {"status": "success", "message": "Stream restarted"}
417
+ # Broadcast stream status update
418
+ from ..utils.websocket import connection_manager
419
+ status = {"is_running": process_manager.is_running, "backend_status": "running" if process_manager.is_running else "stopped"}
420
+ await connection_manager.broadcast_to_admins({"type": "stream_status", "payload": status})
405
421
 
406
422
  elif action == "get_stream_status":
407
423
  status = {"is_running": process_manager.is_running, "backend_status": "running" if process_manager.is_running else "stopped"}
@@ -432,6 +448,24 @@ async def handle_admin_ws_message(websocket: WebSocket, data: dict):
432
448
  context = await agent.get_message_history()
433
449
  response["payload"] = context
434
450
 
451
+ elif action == "get_last_prompt":
452
+ # Check if the agent supports prompt generation introspection
453
+ agent_instance = getattr(agent, 'agent_instance', None) if hasattr(agent, 'agent_instance') else agent
454
+ if not hasattr(agent_instance, 'memory_manager') or not hasattr(agent_instance.memory_manager, 'get_recent_chat') or not hasattr(agent_instance, '_build_neuro_prompt'):
455
+ response["payload"] = {"status": "error", "message": "The active agent does not support prompt generation introspection."}
456
+ else:
457
+ recent_history = await agent_instance.memory_manager.get_recent_chat(entries=10)
458
+ messages_for_prompt = []
459
+ for entry in recent_history:
460
+ if entry.get('role') == 'user':
461
+ parts = entry.get('content', '').split(':', 1)
462
+ if len(parts) == 2:
463
+ messages_for_prompt.append({'username': parts[0].strip(), 'text': parts[1].strip()})
464
+ else:
465
+ messages_for_prompt.append({'username': 'user', 'text': entry.get('content', '')})
466
+ prompt = await agent_instance._build_neuro_prompt(messages_for_prompt)
467
+ response["payload"] = {"prompt": prompt}
468
+
435
469
  elif action == "reset_agent_memory":
436
470
  await agent.reset_memory()
437
471
  response["payload"] = {"status": "success"}
@@ -33,6 +33,7 @@ class ProcessManager:
33
33
  from ..core.application import generate_audience_chat_task, neuro_response_cycle, broadcast_events_task
34
34
  from ..utils.queue import clear_all_queues
35
35
  from ..core.agent_factory import create_agent
36
+ from ..utils.websocket import connection_manager
36
37
 
37
38
  asyncio.create_task(create_agent())
38
39
 
@@ -45,6 +46,9 @@ class ProcessManager:
45
46
  self._tasks.append(asyncio.create_task(neuro_response_cycle()))
46
47
 
47
48
  self._is_running = True
49
+ # Broadcast stream status update
50
+ status = {"is_running": self._is_running, "backend_status": "running" if self._is_running else "stopped"}
51
+ asyncio.create_task(connection_manager.broadcast_to_admins({"type": "stream_status", "payload": status}))
48
52
  logger.info(f"Core processes started: {len(self._tasks)} tasks.")
49
53
 
50
54
  async def stop_live_processes(self):
@@ -66,6 +70,10 @@ class ProcessManager:
66
70
 
67
71
  live_stream_manager.reset_stream_state()
68
72
 
73
+ # Broadcast stream status update
74
+ status = {"is_running": self._is_running, "backend_status": "running" if self._is_running else "stopped"}
75
+ await connection_manager.broadcast_to_admins({"type": "stream_status", "payload": status})
76
+
69
77
  logger.info("All core tasks have been stopped.")
70
78
 
71
79
  # Global singleton instance
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: neuro_simulator
3
- Version: 0.3.1
3
+ Version: 0.3.2
4
4
  Summary: Neuro Simulator Server
5
5
  Author-email: Moha-Master <hongkongreporter@outlook.com>
6
6
  License-Expression: MIT
@@ -11,11 +11,11 @@ neuro_simulator/agent/tools/__init__.py,sha256=1WZy6PADfi6o1avyy1y-ThWBFAPJ_bBqt
11
11
  neuro_simulator/agent/tools/core.py,sha256=o6Oyis-HFD-g6Z_u3T--tkmr9ylKJvybKqMRSMUwi1Q,5555
12
12
  neuro_simulator/api/__init__.py,sha256=5LWyDSayPGdQS8Rv13nmAKLyhPnMVPyTYDdvoMPB4xw,56
13
13
  neuro_simulator/api/stream.py,sha256=hM66flSUygpE-NH9X-ZOV6SiGipBzN1-wjd_wZRpQm4,94
14
- neuro_simulator/api/system.py,sha256=TV_3DzP-VgLnHdue0pKYFFQNOV_V7tr4aMuxL802vQg,1783
14
+ neuro_simulator/api/system.py,sha256=W05Q41BYAFrw-MTnJ5YJrBG2S1SmTcByoex77GfUaFQ,1787
15
15
  neuro_simulator/core/__init__.py,sha256=-ojq25c8XA0CU25b0OxcGjH4IWFEDHR-HXSRSZIuKe8,57
16
16
  neuro_simulator/core/agent_factory.py,sha256=qMFidwT5IrOkyNHwmpO8_fRv20KLbaIBfWF-VTFCLNA,1742
17
17
  neuro_simulator/core/agent_interface.py,sha256=ZXUCtkQUvsBQ5iCb0gTILJaShn5KmSrEgKhd7PK18HE,2794
18
- neuro_simulator/core/application.py,sha256=lhTn5KR7ek8-kuyD1qWtppImUUz8pOExH9KRNW1SQ3M,21115
18
+ neuro_simulator/core/application.py,sha256=zQ6QRUU-dyFW2GDKyBxiTO1BKh-Yt6j169YS-MLpalk,23734
19
19
  neuro_simulator/core/config.py,sha256=brA8kiekV_995mpz04JiGj1swIWbZZuWWLNYtbroMyE,14884
20
20
  neuro_simulator/services/__init__.py,sha256=s3ZrAHg5TpJakadAAGY1h0wDw_xqN4Je4aJwJyRBmk4,61
21
21
  neuro_simulator/services/audience.py,sha256=0phlhsujh_GMXm_UMiyOntY-ZMtoseRa_FroIfc5A6w,5028
@@ -25,12 +25,12 @@ neuro_simulator/services/letta.py,sha256=6jBvOTsLMlRILDv-fvX9fhHMONSYeu-ImJGFcKU
25
25
  neuro_simulator/services/stream.py,sha256=dG7RuNI_ICohPkqKZ-zlBppo54BgWm_KYBs-ezzc73E,5907
26
26
  neuro_simulator/utils/__init__.py,sha256=xSEFzjT827W81mNyQ_DLtr00TgFlttqfFgpz9pSxFXQ,58
27
27
  neuro_simulator/utils/logging.py,sha256=BO-q_cCcoeamsc8eJqq2-L3Z8nhApze_v6LnmD-O8Ww,3411
28
- neuro_simulator/utils/process.py,sha256=9w2JQH59Wy6L8ADrig2QF88iajdykGPZIYJVJe6Al2Y,2603
28
+ neuro_simulator/utils/process.py,sha256=9OYWx8fzaJZqmFUcjQX37AnBhl7YWvrLxDWBa30vqwU,3192
29
29
  neuro_simulator/utils/queue.py,sha256=vSkh-BrgfsGN_gDAx2mfK44ydmMapdVyLsDG-7LIJZQ,1643
30
30
  neuro_simulator/utils/state.py,sha256=DdBqSAYfjOFtJfB1hEGhYPh32r1ZvFuVlN_-29_-luA,664
31
31
  neuro_simulator/utils/websocket.py,sha256=1gtVoH1hafBUfVYmwkVDAbjwETeqyC3sWx706nQzSRo,2085
32
- neuro_simulator-0.3.1.dist-info/METADATA,sha256=lQv9x0KvOZJAA8NwZ8byIaHYTVnSxuHRPyhUyqLC6vw,8643
33
- neuro_simulator-0.3.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
34
- neuro_simulator-0.3.1.dist-info/entry_points.txt,sha256=qVd5ypnRRgU8Cw7rWfZ7o0OXyS9P9hgY-cRoN_mgz9g,51
35
- neuro_simulator-0.3.1.dist-info/top_level.txt,sha256=V8awSKpcrFnjJDiJxSfy7jtOrnuE2BgAR9hLmfMDWK8,16
36
- neuro_simulator-0.3.1.dist-info/RECORD,,
32
+ neuro_simulator-0.3.2.dist-info/METADATA,sha256=HBAqQoRRJmPcm1IxQwderrq7cTO-UhF-ulzqixLNPh8,8643
33
+ neuro_simulator-0.3.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
34
+ neuro_simulator-0.3.2.dist-info/entry_points.txt,sha256=qVd5ypnRRgU8Cw7rWfZ7o0OXyS9P9hgY-cRoN_mgz9g,51
35
+ neuro_simulator-0.3.2.dist-info/top_level.txt,sha256=V8awSKpcrFnjJDiJxSfy7jtOrnuE2BgAR9hLmfMDWK8,16
36
+ neuro_simulator-0.3.2.dist-info/RECORD,,