jarvis-ai-assistant 0.3.34__py3-none-any.whl → 0.4.1__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.
Files changed (30) hide show
  1. jarvis/__init__.py +1 -1
  2. jarvis/jarvis_agent/__init__.py +44 -12
  3. jarvis/jarvis_agent/agent_manager.py +14 -10
  4. jarvis/jarvis_agent/config.py +2 -1
  5. jarvis/jarvis_agent/edit_file_handler.py +2 -2
  6. jarvis/jarvis_agent/jarvis.py +305 -1
  7. jarvis/jarvis_agent/rewrite_file_handler.py +143 -0
  8. jarvis/jarvis_agent/run_loop.py +5 -4
  9. jarvis/jarvis_agent/stdio_redirect.py +296 -0
  10. jarvis/jarvis_agent/utils.py +5 -1
  11. jarvis/jarvis_agent/web_bridge.py +189 -0
  12. jarvis/jarvis_agent/web_output_sink.py +53 -0
  13. jarvis/jarvis_agent/web_server.py +745 -0
  14. jarvis/jarvis_code_agent/code_agent.py +10 -12
  15. jarvis/jarvis_code_analysis/code_review.py +0 -1
  16. jarvis/jarvis_data/config_schema.json +5 -0
  17. jarvis/jarvis_multi_agent/__init__.py +205 -25
  18. jarvis/jarvis_multi_agent/main.py +10 -2
  19. jarvis/jarvis_platform/base.py +16 -6
  20. jarvis/jarvis_tools/sub_agent.py +11 -38
  21. jarvis/jarvis_tools/sub_code_agent.py +3 -1
  22. jarvis/jarvis_utils/config.py +12 -2
  23. {jarvis_ai_assistant-0.3.34.dist-info → jarvis_ai_assistant-0.4.1.dist-info}/METADATA +1 -1
  24. {jarvis_ai_assistant-0.3.34.dist-info → jarvis_ai_assistant-0.4.1.dist-info}/RECORD +28 -25
  25. jarvis/jarvis_tools/edit_file.py +0 -208
  26. jarvis/jarvis_tools/rewrite_file.py +0 -191
  27. {jarvis_ai_assistant-0.3.34.dist-info → jarvis_ai_assistant-0.4.1.dist-info}/WHEEL +0 -0
  28. {jarvis_ai_assistant-0.3.34.dist-info → jarvis_ai_assistant-0.4.1.dist-info}/entry_points.txt +0 -0
  29. {jarvis_ai_assistant-0.3.34.dist-info → jarvis_ai_assistant-0.4.1.dist-info}/licenses/LICENSE +0 -0
  30. {jarvis_ai_assistant-0.3.34.dist-info → jarvis_ai_assistant-0.4.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,53 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ WebSocketOutputSink: 将 PrettyOutput 的输出事件通过 WebBridge 广播给前端(WebSocket 客户端)
4
+
5
+ 用法:
6
+ - 在 Web 模式启动时,注册该 Sink:
7
+ from jarvis.jarvis_utils.output import PrettyOutput
8
+ from jarvis.jarvis_agent.web_output_sink import WebSocketOutputSink
9
+ PrettyOutput.add_sink(WebSocketOutputSink())
10
+
11
+ - Web 端收到的消息结构:
12
+ {
13
+ "type": "output",
14
+ "payload": {
15
+ "text": "...",
16
+ "output_type": "INFO" | "ERROR" | ...,
17
+ "timestamp": true/false,
18
+ "lang": "markdown" | "python" | ... | null,
19
+ "traceback": false,
20
+ "section": null | "标题",
21
+ "context": { ... } | null
22
+ }
23
+ }
24
+ """
25
+ from __future__ import annotations
26
+
27
+ from typing import Any, Dict
28
+
29
+ from jarvis.jarvis_utils.output import OutputSink, OutputEvent
30
+ from jarvis.jarvis_agent.web_bridge import WebBridge
31
+
32
+
33
+ class WebSocketOutputSink(OutputSink):
34
+ """将输出事件广播到 WebSocket 前端的 OutputSink 实现。"""
35
+
36
+ def emit(self, event: OutputEvent) -> None:
37
+ try:
38
+ payload: Dict[str, Any] = {
39
+ "type": "output",
40
+ "payload": {
41
+ "text": event.text,
42
+ "output_type": event.output_type.value,
43
+ "timestamp": bool(event.timestamp),
44
+ "lang": event.lang,
45
+ "traceback": bool(event.traceback),
46
+ "section": event.section,
47
+ "context": event.context,
48
+ },
49
+ }
50
+ WebBridge.instance().broadcast(payload)
51
+ except Exception:
52
+ # 广播过程中的异常不应影响其他输出后端
53
+ pass