jarvis-ai-assistant 0.7.0__py3-none-any.whl → 0.7.8__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.
- jarvis/__init__.py +1 -1
- jarvis/jarvis_agent/__init__.py +243 -139
- jarvis/jarvis_agent/agent_manager.py +5 -10
- jarvis/jarvis_agent/builtin_input_handler.py +2 -6
- jarvis/jarvis_agent/config_editor.py +2 -7
- jarvis/jarvis_agent/event_bus.py +82 -12
- jarvis/jarvis_agent/file_context_handler.py +265 -15
- jarvis/jarvis_agent/file_methodology_manager.py +3 -4
- jarvis/jarvis_agent/jarvis.py +113 -98
- jarvis/jarvis_agent/language_extractors/__init__.py +57 -0
- jarvis/jarvis_agent/language_extractors/c_extractor.py +21 -0
- jarvis/jarvis_agent/language_extractors/cpp_extractor.py +21 -0
- jarvis/jarvis_agent/language_extractors/go_extractor.py +21 -0
- jarvis/jarvis_agent/language_extractors/java_extractor.py +84 -0
- jarvis/jarvis_agent/language_extractors/javascript_extractor.py +79 -0
- jarvis/jarvis_agent/language_extractors/python_extractor.py +21 -0
- jarvis/jarvis_agent/language_extractors/rust_extractor.py +21 -0
- jarvis/jarvis_agent/language_extractors/typescript_extractor.py +84 -0
- jarvis/jarvis_agent/language_support_info.py +486 -0
- jarvis/jarvis_agent/main.py +6 -12
- jarvis/jarvis_agent/memory_manager.py +7 -16
- jarvis/jarvis_agent/methodology_share_manager.py +10 -16
- jarvis/jarvis_agent/prompt_manager.py +1 -1
- jarvis/jarvis_agent/prompts.py +193 -171
- jarvis/jarvis_agent/protocols.py +8 -12
- jarvis/jarvis_agent/run_loop.py +77 -14
- jarvis/jarvis_agent/session_manager.py +2 -3
- jarvis/jarvis_agent/share_manager.py +12 -21
- jarvis/jarvis_agent/shell_input_handler.py +1 -2
- jarvis/jarvis_agent/task_analyzer.py +26 -4
- jarvis/jarvis_agent/task_manager.py +11 -27
- jarvis/jarvis_agent/tool_executor.py +2 -3
- jarvis/jarvis_agent/tool_share_manager.py +12 -24
- jarvis/jarvis_agent/web_server.py +55 -20
- jarvis/jarvis_c2rust/__init__.py +5 -5
- jarvis/jarvis_c2rust/cli.py +461 -499
- jarvis/jarvis_c2rust/collector.py +45 -53
- jarvis/jarvis_c2rust/constants.py +26 -0
- jarvis/jarvis_c2rust/library_replacer.py +264 -132
- jarvis/jarvis_c2rust/llm_module_agent.py +162 -190
- jarvis/jarvis_c2rust/loaders.py +207 -0
- jarvis/jarvis_c2rust/models.py +28 -0
- jarvis/jarvis_c2rust/optimizer.py +1592 -395
- jarvis/jarvis_c2rust/transpiler.py +1722 -1064
- jarvis/jarvis_c2rust/utils.py +385 -0
- jarvis/jarvis_code_agent/build_validation_config.py +2 -3
- jarvis/jarvis_code_agent/code_agent.py +394 -320
- jarvis/jarvis_code_agent/code_analyzer/__init__.py +3 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/base.py +4 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/cmake.py +17 -2
- jarvis/jarvis_code_agent/code_analyzer/build_validator/fallback.py +3 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/go.py +36 -4
- jarvis/jarvis_code_agent/code_analyzer/build_validator/java_gradle.py +9 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/java_maven.py +9 -0
- jarvis/jarvis_code_agent/code_analyzer/build_validator/makefile.py +12 -1
- jarvis/jarvis_code_agent/code_analyzer/build_validator/nodejs.py +22 -5
- jarvis/jarvis_code_agent/code_analyzer/build_validator/python.py +57 -32
- jarvis/jarvis_code_agent/code_analyzer/build_validator/rust.py +62 -6
- jarvis/jarvis_code_agent/code_analyzer/build_validator/validator.py +8 -9
- jarvis/jarvis_code_agent/code_analyzer/context_manager.py +290 -5
- jarvis/jarvis_code_agent/code_analyzer/language_support.py +21 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/__init__.py +21 -3
- jarvis/jarvis_code_agent/code_analyzer/languages/c_cpp_language.py +72 -4
- jarvis/jarvis_code_agent/code_analyzer/languages/go_language.py +35 -3
- jarvis/jarvis_code_agent/code_analyzer/languages/java_language.py +212 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/javascript_language.py +254 -0
- jarvis/jarvis_code_agent/code_analyzer/languages/python_language.py +52 -2
- jarvis/jarvis_code_agent/code_analyzer/languages/rust_language.py +73 -1
- jarvis/jarvis_code_agent/code_analyzer/languages/typescript_language.py +280 -0
- jarvis/jarvis_code_agent/code_analyzer/llm_context_recommender.py +306 -152
- jarvis/jarvis_code_agent/code_analyzer/structured_code.py +556 -0
- jarvis/jarvis_code_agent/code_analyzer/symbol_extractor.py +193 -18
- jarvis/jarvis_code_agent/code_analyzer/tree_sitter_extractor.py +18 -8
- jarvis/jarvis_code_agent/lint.py +258 -27
- jarvis/jarvis_code_agent/utils.py +0 -1
- jarvis/jarvis_code_analysis/code_review.py +19 -24
- jarvis/jarvis_data/config_schema.json +53 -26
- jarvis/jarvis_git_squash/main.py +4 -5
- jarvis/jarvis_git_utils/git_commiter.py +44 -49
- jarvis/jarvis_mcp/sse_mcp_client.py +20 -27
- jarvis/jarvis_mcp/stdio_mcp_client.py +11 -12
- jarvis/jarvis_mcp/streamable_mcp_client.py +15 -14
- jarvis/jarvis_memory_organizer/memory_organizer.py +55 -74
- jarvis/jarvis_methodology/main.py +32 -48
- jarvis/jarvis_multi_agent/__init__.py +79 -61
- jarvis/jarvis_multi_agent/main.py +3 -7
- jarvis/jarvis_platform/base.py +469 -199
- jarvis/jarvis_platform/human.py +7 -8
- jarvis/jarvis_platform/kimi.py +30 -36
- jarvis/jarvis_platform/openai.py +65 -27
- jarvis/jarvis_platform/registry.py +26 -10
- jarvis/jarvis_platform/tongyi.py +24 -25
- jarvis/jarvis_platform/yuanbao.py +31 -42
- jarvis/jarvis_platform_manager/main.py +66 -77
- jarvis/jarvis_platform_manager/service.py +8 -13
- jarvis/jarvis_rag/cli.py +49 -51
- jarvis/jarvis_rag/embedding_manager.py +13 -18
- jarvis/jarvis_rag/llm_interface.py +8 -9
- jarvis/jarvis_rag/query_rewriter.py +10 -21
- jarvis/jarvis_rag/rag_pipeline.py +24 -27
- jarvis/jarvis_rag/reranker.py +4 -5
- jarvis/jarvis_rag/retriever.py +28 -30
- jarvis/jarvis_sec/__init__.py +220 -3520
- jarvis/jarvis_sec/agents.py +143 -0
- jarvis/jarvis_sec/analysis.py +276 -0
- jarvis/jarvis_sec/cli.py +29 -6
- jarvis/jarvis_sec/clustering.py +1439 -0
- jarvis/jarvis_sec/file_manager.py +427 -0
- jarvis/jarvis_sec/parsers.py +73 -0
- jarvis/jarvis_sec/prompts.py +268 -0
- jarvis/jarvis_sec/report.py +83 -4
- jarvis/jarvis_sec/review.py +453 -0
- jarvis/jarvis_sec/utils.py +499 -0
- jarvis/jarvis_sec/verification.py +848 -0
- jarvis/jarvis_sec/workflow.py +7 -0
- jarvis/jarvis_smart_shell/main.py +38 -87
- jarvis/jarvis_stats/cli.py +1 -1
- jarvis/jarvis_stats/stats.py +7 -7
- jarvis/jarvis_stats/storage.py +15 -21
- jarvis/jarvis_tools/clear_memory.py +3 -20
- jarvis/jarvis_tools/cli/main.py +20 -23
- jarvis/jarvis_tools/edit_file.py +1066 -0
- jarvis/jarvis_tools/execute_script.py +42 -21
- jarvis/jarvis_tools/file_analyzer.py +6 -9
- jarvis/jarvis_tools/generate_new_tool.py +11 -20
- jarvis/jarvis_tools/lsp_client.py +1552 -0
- jarvis/jarvis_tools/methodology.py +2 -3
- jarvis/jarvis_tools/read_code.py +1525 -87
- jarvis/jarvis_tools/read_symbols.py +2 -3
- jarvis/jarvis_tools/read_webpage.py +7 -10
- jarvis/jarvis_tools/registry.py +370 -181
- jarvis/jarvis_tools/retrieve_memory.py +20 -19
- jarvis/jarvis_tools/rewrite_file.py +105 -0
- jarvis/jarvis_tools/save_memory.py +3 -15
- jarvis/jarvis_tools/search_web.py +3 -7
- jarvis/jarvis_tools/sub_agent.py +17 -6
- jarvis/jarvis_tools/sub_code_agent.py +14 -16
- jarvis/jarvis_tools/virtual_tty.py +54 -32
- jarvis/jarvis_utils/clipboard.py +7 -10
- jarvis/jarvis_utils/config.py +98 -63
- jarvis/jarvis_utils/embedding.py +5 -5
- jarvis/jarvis_utils/fzf.py +8 -8
- jarvis/jarvis_utils/git_utils.py +81 -67
- jarvis/jarvis_utils/input.py +24 -49
- jarvis/jarvis_utils/jsonnet_compat.py +465 -0
- jarvis/jarvis_utils/methodology.py +33 -35
- jarvis/jarvis_utils/utils.py +245 -202
- {jarvis_ai_assistant-0.7.0.dist-info → jarvis_ai_assistant-0.7.8.dist-info}/METADATA +205 -70
- jarvis_ai_assistant-0.7.8.dist-info/RECORD +218 -0
- jarvis/jarvis_agent/edit_file_handler.py +0 -584
- jarvis/jarvis_agent/rewrite_file_handler.py +0 -141
- jarvis/jarvis_agent/task_planner.py +0 -496
- jarvis/jarvis_platform/ai8.py +0 -332
- jarvis/jarvis_tools/ask_user.py +0 -54
- jarvis_ai_assistant-0.7.0.dist-info/RECORD +0 -192
- {jarvis_ai_assistant-0.7.0.dist-info → jarvis_ai_assistant-0.7.8.dist-info}/WHEEL +0 -0
- {jarvis_ai_assistant-0.7.0.dist-info → jarvis_ai_assistant-0.7.8.dist-info}/entry_points.txt +0 -0
- {jarvis_ai_assistant-0.7.0.dist-info → jarvis_ai_assistant-0.7.8.dist-info}/licenses/LICENSE +0 -0
- {jarvis_ai_assistant-0.7.0.dist-info → jarvis_ai_assistant-0.7.8.dist-info}/top_level.txt +0 -0
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
+
from jarvis.jarvis_utils.jsonnet_compat import loads as json_loads
|
|
2
3
|
import re
|
|
3
4
|
from typing import Any, Dict, List, Optional, Tuple, Union
|
|
4
5
|
|
|
5
|
-
import yaml
|
|
6
|
-
|
|
7
6
|
from jarvis.jarvis_agent import Agent
|
|
8
7
|
from jarvis.jarvis_agent.output_handler import OutputHandler
|
|
9
8
|
from jarvis.jarvis_tools.registry import ToolRegistry
|
|
10
|
-
from jarvis.jarvis_agent.edit_file_handler import EditFileHandler
|
|
11
|
-
from jarvis.jarvis_agent.rewrite_file_handler import RewriteFileHandler
|
|
12
|
-
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
13
9
|
from jarvis.jarvis_utils.tag import ct, ot
|
|
14
10
|
|
|
15
11
|
|
|
@@ -23,6 +19,24 @@ class MultiAgent(OutputHandler):
|
|
|
23
19
|
self.common_system_prompt: str = common_system_prompt
|
|
24
20
|
|
|
25
21
|
def prompt(self) -> str:
|
|
22
|
+
_multiline_example_msg = """ {
|
|
23
|
+
"content": |||
|
|
24
|
+
第一行:直接换行,无需 \\n
|
|
25
|
+
第二行:包含"双引号",无需转义
|
|
26
|
+
第三行:包含'单引号',直接写
|
|
27
|
+
第四行:支持缩进保留
|
|
28
|
+
|||
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
或使用 ``` 代替 |||:
|
|
32
|
+
{
|
|
33
|
+
"content": ```
|
|
34
|
+
第一行:直接换行,无需 \\n
|
|
35
|
+
第二行:包含"双引号",无需转义
|
|
36
|
+
第三行:包含'单引号',直接写
|
|
37
|
+
第四行:支持缩进保留
|
|
38
|
+
```
|
|
39
|
+
}"""
|
|
26
40
|
return f"""
|
|
27
41
|
# 多智能体消息发送
|
|
28
42
|
|
|
@@ -33,22 +47,25 @@ class MultiAgent(OutputHandler):
|
|
|
33
47
|
- **明确性原则**:清晰表达意图、需求和期望结果
|
|
34
48
|
- **上下文保留**:在消息中包含足够的背景信息
|
|
35
49
|
|
|
36
|
-
###
|
|
50
|
+
### 消息格式标准(Jsonnet)
|
|
37
51
|
```
|
|
38
52
|
{ot("SEND_MESSAGE")}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
{{
|
|
54
|
+
"to": "智能体名称",
|
|
55
|
+
"content": |||
|
|
56
|
+
# 消息主题
|
|
57
|
+
## 背景信息
|
|
58
|
+
[提供必要的上下文和背景]
|
|
59
|
+
## 具体需求
|
|
60
|
+
[明确表达期望完成的任务]
|
|
61
|
+
## 相关资源
|
|
62
|
+
[列出相关文档、数据或工具]
|
|
63
|
+
## 期望结果
|
|
64
|
+
[描述期望的输出格式和内容]
|
|
65
|
+
## 下一步计划
|
|
66
|
+
[描述下一步的计划和行动]
|
|
67
|
+
|||
|
|
68
|
+
}}
|
|
52
69
|
{ct("SEND_MESSAGE")}
|
|
53
70
|
```
|
|
54
71
|
|
|
@@ -56,14 +73,24 @@ content: |2
|
|
|
56
73
|
|
|
57
74
|
```
|
|
58
75
|
{ot("SEND_MESSAGE")}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
76
|
+
{{
|
|
77
|
+
"to": "智能体名称",
|
|
78
|
+
"content": |||
|
|
79
|
+
# 消息主题
|
|
80
|
+
## 任务结果
|
|
81
|
+
[任务完成结果,用于反馈]
|
|
82
|
+
|||
|
|
83
|
+
}}
|
|
64
84
|
{ct("SEND_MESSAGE")}
|
|
65
85
|
```
|
|
66
86
|
|
|
87
|
+
**Jsonnet 格式说明**:
|
|
88
|
+
- 可以使用双引号 "..." 或单引号 '...' 包裹字符串
|
|
89
|
+
- **多行字符串推荐使用 ||| 或 ``` 分隔符包裹**,直接换行无需转义,支持保留缩进
|
|
90
|
+
示例:
|
|
91
|
+
{_multiline_example_msg}
|
|
92
|
+
- 支持尾随逗号
|
|
93
|
+
|
|
67
94
|
## 可用智能体资源
|
|
68
95
|
{chr(10).join([f"- **{c['name']}**: {c.get('description', '')}" for c in self.agents_config])}
|
|
69
96
|
"""
|
|
@@ -97,12 +124,10 @@ content: |2
|
|
|
97
124
|
+ "\n修复建议:\n"
|
|
98
125
|
"- 必须包含 to 和 content 字段\n"
|
|
99
126
|
"- to: 目标智能体名称(字符串)\n"
|
|
100
|
-
"- content:
|
|
127
|
+
"- content: 发送内容(字符串)\n"
|
|
101
128
|
"示例:\n"
|
|
102
129
|
f"{ot('SEND_MESSAGE')}\n"
|
|
103
|
-
"to: 目标Agent
|
|
104
|
-
"content: |2\n"
|
|
105
|
-
" 这里填写要发送的消息内容\n"
|
|
130
|
+
'{{\n "to": "目标Agent名称",\n "content": "这里填写要发送的消息内容"\n}}\n'
|
|
106
131
|
f"{ct('SEND_MESSAGE')}"
|
|
107
132
|
)
|
|
108
133
|
return False, guidance
|
|
@@ -110,7 +135,7 @@ content: |2
|
|
|
110
135
|
if not isinstance(to_val, str):
|
|
111
136
|
return False, "SEND_MESSAGE 字段类型错误:to 必须为字符串。修复建议:将 to 改为字符串,如 to: ChapterPolisher"
|
|
112
137
|
if not isinstance(content_val, str):
|
|
113
|
-
return False, "SEND_MESSAGE 字段类型错误:content 必须为字符串。修复建议:将 content
|
|
138
|
+
return False, "SEND_MESSAGE 字段类型错误:content 必须为字符串。修复建议:将 content 改为字符串"
|
|
114
139
|
# 目标校验
|
|
115
140
|
if to_val not in self.agents_config_map:
|
|
116
141
|
available = ", ".join(self.agents_config_map.keys())
|
|
@@ -150,7 +175,7 @@ content: |2
|
|
|
150
175
|
" 这里填写要发送的消息内容\n"
|
|
151
176
|
f"{ct_tag}"
|
|
152
177
|
)
|
|
153
|
-
# 尝试提取原始块并指出
|
|
178
|
+
# 尝试提取原始块并指出 JSON 问题
|
|
154
179
|
import re as _re
|
|
155
180
|
pattern = _re.compile(
|
|
156
181
|
rf"{_re.escape(ot_tag)}[ \t]*\n(.*?)(?:\n)?[ \t]*{_re.escape(ct_tag)}",
|
|
@@ -167,21 +192,19 @@ content: |2
|
|
|
167
192
|
return (
|
|
168
193
|
False,
|
|
169
194
|
"SEND_MESSAGE 格式错误:未能识别完整的消息块。\n"
|
|
170
|
-
"修复建议:确保起止标签在单独行上,且中间内容为合法的
|
|
195
|
+
"修复建议:确保起止标签在单独行上,且中间内容为合法的 JSON,包含 to 与 content 字段。"
|
|
171
196
|
)
|
|
172
197
|
raw = blocks[0]
|
|
173
198
|
try:
|
|
174
|
-
msg_obj =
|
|
199
|
+
msg_obj = json_loads(raw)
|
|
175
200
|
if not isinstance(msg_obj, dict):
|
|
176
201
|
return (
|
|
177
202
|
False,
|
|
178
|
-
"SEND_MESSAGE 内容必须为
|
|
203
|
+
"SEND_MESSAGE 内容必须为 JSON 对象(键值对)。\n"
|
|
179
204
|
"修复建议:使用 to 与 content 字段构成的对象。\n"
|
|
180
205
|
"示例:\n"
|
|
181
206
|
f"{ot('SEND_MESSAGE')}\n"
|
|
182
|
-
"to: 目标Agent
|
|
183
|
-
"content: |2\n"
|
|
184
|
-
" 这里填写要发送的消息内容\n"
|
|
207
|
+
'{{\n "to": "目标Agent名称",\n "content": "这里填写要发送的消息内容"\n}}\n'
|
|
185
208
|
f"{ct('SEND_MESSAGE')}"
|
|
186
209
|
)
|
|
187
210
|
missing_keys = [k for k in ("to", "content") if k not in msg_obj]
|
|
@@ -192,16 +215,14 @@ content: |2
|
|
|
192
215
|
"修复建议:补充缺失字段。\n"
|
|
193
216
|
"示例:\n"
|
|
194
217
|
f"{ot('SEND_MESSAGE')}\n"
|
|
195
|
-
"to: 目标Agent
|
|
196
|
-
"content: |2\n"
|
|
197
|
-
" 这里填写要发送的消息内容\n"
|
|
218
|
+
'{{\n "to": "目标Agent名称",\n "content": "这里填写要发送的消息内容"\n}}\n'
|
|
198
219
|
f"{ct('SEND_MESSAGE')}"
|
|
199
220
|
)
|
|
200
221
|
# 针对值类型的提示(更细)
|
|
201
222
|
if not isinstance(msg_obj.get("to"), str):
|
|
202
223
|
return False, "SEND_MESSAGE 字段类型错误:to 必须为字符串。"
|
|
203
224
|
if not isinstance(msg_obj.get("content"), str):
|
|
204
|
-
return False, "SEND_MESSAGE 字段类型错误:content
|
|
225
|
+
return False, "SEND_MESSAGE 字段类型错误:content 必须为字符串。"
|
|
205
226
|
# 若到此仍未返回,说明结构基本正确,但 _extract_send_msg 未命中,给出泛化建议
|
|
206
227
|
return (
|
|
207
228
|
False,
|
|
@@ -209,26 +230,27 @@ content: |2
|
|
|
209
230
|
"修复建议:\n"
|
|
210
231
|
"- 确保起止标签各占一行\n"
|
|
211
232
|
"- 标签与内容之间保留换行\n"
|
|
212
|
-
"-
|
|
233
|
+
"- 使用正确的 Jsonnet 格式\n"
|
|
213
234
|
"示例:\n"
|
|
214
235
|
f"{ot('SEND_MESSAGE')}\n"
|
|
215
|
-
"to: 目标Agent
|
|
216
|
-
"content: |2\n"
|
|
217
|
-
" 这里填写要发送的消息内容\n"
|
|
236
|
+
'{{\n "to": "目标Agent名称",\n "content": "这里填写要发送的消息内容"\n}}\n'
|
|
218
237
|
f"{ct('SEND_MESSAGE')}"
|
|
219
238
|
)
|
|
220
239
|
except Exception as e:
|
|
221
240
|
return (
|
|
222
241
|
False,
|
|
223
|
-
f"SEND_MESSAGE
|
|
242
|
+
f"SEND_MESSAGE Jsonnet 解析失败:{str(e)}\n"
|
|
224
243
|
"修复建议:\n"
|
|
225
|
-
"-
|
|
226
|
-
"-
|
|
244
|
+
"- 检查 Jsonnet 格式是否正确(引号、逗号、大括号)\n"
|
|
245
|
+
"- 可以使用双引号 \"...\" 或单引号 '...' 包裹字符串\n"
|
|
246
|
+
"- 对于多行内容,推荐使用 ||| 或 ``` 分隔符包裹,直接换行无需转义,支持保留缩进\n"
|
|
227
247
|
"示例:\n"
|
|
228
248
|
f"{ot('SEND_MESSAGE')}\n"
|
|
229
|
-
"to: 目标Agent
|
|
230
|
-
"
|
|
231
|
-
"
|
|
249
|
+
'{{\n "to": "目标Agent名称",\n "content": "这里填写要发送的消息内容"\n}}\n'
|
|
250
|
+
f"{ct('SEND_MESSAGE')}\n"
|
|
251
|
+
"或使用多行字符串(推荐使用 ||| 或 ``` 分隔符):\n"
|
|
252
|
+
f"{ot('SEND_MESSAGE')}\n"
|
|
253
|
+
'{{\n "to": "目标Agent名称",\n "content": |||\n多行消息内容\n可以包含换行\n包含"双引号"和\'单引号\'都无需转义\n更清晰易读\n |||\n}}\n'
|
|
232
254
|
f"{ct('SEND_MESSAGE')}"
|
|
233
255
|
)
|
|
234
256
|
|
|
@@ -272,7 +294,7 @@ content: |2
|
|
|
272
294
|
ret = []
|
|
273
295
|
for item in data:
|
|
274
296
|
try:
|
|
275
|
-
msg =
|
|
297
|
+
msg = json_loads(item)
|
|
276
298
|
if isinstance(msg, dict) and "to" in msg and "content" in msg:
|
|
277
299
|
ret.append(msg)
|
|
278
300
|
except Exception:
|
|
@@ -308,7 +330,7 @@ content: |2
|
|
|
308
330
|
f"{system_prompt}\n\n# 原始问题\n{self.original_question}"
|
|
309
331
|
)
|
|
310
332
|
|
|
311
|
-
agent = Agent(output_handler=[ToolRegistry(),
|
|
333
|
+
agent = Agent(output_handler=[ToolRegistry(), self], **config)
|
|
312
334
|
self.agents[name] = agent
|
|
313
335
|
return agent
|
|
314
336
|
|
|
@@ -329,12 +351,12 @@ content: |2
|
|
|
329
351
|
|
|
330
352
|
if not isinstance(msg, Dict):
|
|
331
353
|
# Should not happen if agent.run() returns str or Dict
|
|
332
|
-
|
|
354
|
+
print(f"⚠️ 未知消息类型: {type(msg)}")
|
|
333
355
|
break
|
|
334
356
|
|
|
335
357
|
# Generate a brief summary via direct model call to avoid run-loop recursion
|
|
336
358
|
# 如果在配置中显式设置了 summary_on_send=False,则不生成摘要
|
|
337
|
-
sender_config = self.agents_config_map.get(last_agent_name, {})
|
|
359
|
+
sender_config = self.agents_config_map.get(last_agent_name, {})
|
|
338
360
|
summary_on_send = sender_config.get("summary_on_send", True)
|
|
339
361
|
summary_text = ""
|
|
340
362
|
if summary_on_send:
|
|
@@ -368,9 +390,7 @@ content: {msg['content']}
|
|
|
368
390
|
return "消息中未指定 `to` 字段"
|
|
369
391
|
|
|
370
392
|
if to_agent_name not in self.agents_config_map:
|
|
371
|
-
|
|
372
|
-
f"未找到智能体 {to_agent_name},正在重试...", OutputType.WARNING
|
|
373
|
-
)
|
|
393
|
+
print(f"⚠️ 未找到智能体 {to_agent_name},正在重试...")
|
|
374
394
|
agent = self._get_agent(last_agent_name)
|
|
375
395
|
if not agent:
|
|
376
396
|
return f"智能体 {last_agent_name} 未找到"
|
|
@@ -379,9 +399,7 @@ content: {msg['content']}
|
|
|
379
399
|
)
|
|
380
400
|
continue
|
|
381
401
|
|
|
382
|
-
|
|
383
|
-
f"{last_agent_name} 正在向 {to_agent_name} 发送消息...", OutputType.INFO
|
|
384
|
-
)
|
|
402
|
+
print(f"ℹ️ {last_agent_name} 正在向 {to_agent_name} 发送消息...")
|
|
385
403
|
|
|
386
404
|
# Keep a reference to the sender before switching to the receiver
|
|
387
405
|
sender_agent = agent
|
|
@@ -394,7 +412,7 @@ content: {msg['content']}
|
|
|
394
412
|
sender_config = self.agents_config_map.get(last_agent_name, {})
|
|
395
413
|
if sender_config.get("clear_after_send_message"):
|
|
396
414
|
if sender_agent:
|
|
397
|
-
|
|
415
|
+
print(f"ℹ️ 清除智能体 {last_agent_name} 在发送消息后的历史记录...")
|
|
398
416
|
sender_agent.clear_history()
|
|
399
417
|
|
|
400
418
|
last_agent_name = agent.name
|
|
@@ -9,7 +9,6 @@ from jarvis.jarvis_multi_agent import MultiAgent
|
|
|
9
9
|
from jarvis.jarvis_utils.input import get_multiline_input
|
|
10
10
|
from jarvis.jarvis_utils.utils import init_env
|
|
11
11
|
from jarvis.jarvis_utils.config import set_config
|
|
12
|
-
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
13
12
|
|
|
14
13
|
app = typer.Typer(help="多智能体系统启动器")
|
|
15
14
|
|
|
@@ -37,12 +36,9 @@ def cli(
|
|
|
37
36
|
# 注意:全局配置同步在 init_env 之后执行,避免被覆盖
|
|
38
37
|
# 非交互模式要求从命令行传入任务
|
|
39
38
|
if non_interactive and not (user_input and str(user_input).strip()):
|
|
40
|
-
|
|
41
|
-
"非交互模式已启用:必须使用 --input 传入任务内容,因多行输入不可用。",
|
|
42
|
-
OutputType.ERROR,
|
|
43
|
-
)
|
|
39
|
+
print("❌ 非交互模式已启用:必须使用 --input 传入任务内容,因多行输入不可用。")
|
|
44
40
|
raise typer.Exit(code=2)
|
|
45
|
-
init_env(
|
|
41
|
+
init_env()
|
|
46
42
|
|
|
47
43
|
# 在初始化环境后同步 CLI 选项到全局配置,避免被 init_env 覆盖
|
|
48
44
|
try:
|
|
@@ -85,7 +81,7 @@ def cli(
|
|
|
85
81
|
except typer.Exit:
|
|
86
82
|
return
|
|
87
83
|
except (ValueError, RuntimeError, yaml.YAMLError) as e:
|
|
88
|
-
|
|
84
|
+
print(f"❌ 错误: {str(e)}")
|
|
89
85
|
raise typer.Exit(code=1)
|
|
90
86
|
|
|
91
87
|
|