jarvis-ai-assistant 0.1.149__py3-none-any.whl → 0.1.151__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.
Potentially problematic release.
This version of jarvis-ai-assistant might be problematic. Click here for more details.
- jarvis/__init__.py +1 -1
- jarvis/jarvis_agent/jarvis.py +7 -5
- jarvis/jarvis_git_utils/git_commiter.py +7 -0
- jarvis/jarvis_lsp/registry.py +2 -1
- jarvis/jarvis_mcp/__init__.py +65 -0
- jarvis/jarvis_mcp/local_mcp_client.py +326 -0
- jarvis/jarvis_mcp/remote_mcp_client.py +590 -0
- jarvis/jarvis_platform/kimi.py +3 -2
- jarvis/jarvis_platform/registry.py +2 -4
- jarvis/jarvis_platform/yuanbao.py +4 -4
- jarvis/jarvis_tools/ask_codebase.py +3 -10
- jarvis/jarvis_tools/file_operation.py +7 -26
- jarvis/jarvis_tools/methodology.py +2 -1
- jarvis/jarvis_tools/registry.py +168 -21
- jarvis/jarvis_utils/config.py +15 -9
- jarvis/jarvis_utils/embedding.py +2 -2
- jarvis/jarvis_utils/file_processors.py +0 -262
- jarvis/jarvis_utils/input.py +7 -1
- jarvis/jarvis_utils/methodology.py +4 -4
- jarvis/jarvis_utils/utils.py +5 -5
- {jarvis_ai_assistant-0.1.149.dist-info → jarvis_ai_assistant-0.1.151.dist-info}/METADATA +43 -18
- {jarvis_ai_assistant-0.1.149.dist-info → jarvis_ai_assistant-0.1.151.dist-info}/RECORD +26 -23
- {jarvis_ai_assistant-0.1.149.dist-info → jarvis_ai_assistant-0.1.151.dist-info}/WHEEL +1 -1
- {jarvis_ai_assistant-0.1.149.dist-info → jarvis_ai_assistant-0.1.151.dist-info}/entry_points.txt +0 -0
- {jarvis_ai_assistant-0.1.149.dist-info → jarvis_ai_assistant-0.1.151.dist-info/licenses}/LICENSE +0 -0
- {jarvis_ai_assistant-0.1.149.dist-info → jarvis_ai_assistant-0.1.151.dist-info}/top_level.txt +0 -0
jarvis/__init__.py
CHANGED
jarvis/jarvis_agent/jarvis.py
CHANGED
|
@@ -4,6 +4,7 @@ import sys
|
|
|
4
4
|
|
|
5
5
|
from typing import Dict # 仅保留实际使用的类型导入
|
|
6
6
|
|
|
7
|
+
from jarvis.jarvis_utils.config import get_data_dir
|
|
7
8
|
from prompt_toolkit import prompt
|
|
8
9
|
import yaml
|
|
9
10
|
from yaspin import yaspin
|
|
@@ -25,13 +26,14 @@ def _load_tasks() -> Dict[str, str]:
|
|
|
25
26
|
"""Load tasks from .jarvis files in user home and current directory."""
|
|
26
27
|
tasks: Dict[str, str] = {}
|
|
27
28
|
|
|
28
|
-
# Check
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
# Check pre-command in data directory
|
|
30
|
+
data_dir = get_data_dir()
|
|
31
|
+
pre_command_path = os.path.join(data_dir, "pre-command")
|
|
32
|
+
if os.path.exists(pre_command_path):
|
|
33
|
+
spinner_text = f"从{pre_command_path}加载预定义任务..."
|
|
32
34
|
with yaspin(text=spinner_text, color="cyan") as spinner:
|
|
33
35
|
try:
|
|
34
|
-
with open(
|
|
36
|
+
with open(pre_command_path, "r", encoding="utf-8", errors="ignore") as f:
|
|
35
37
|
user_tasks = yaml.safe_load(f)
|
|
36
38
|
if isinstance(user_tasks, dict):
|
|
37
39
|
for name, desc in user_tasks.items():
|
|
@@ -177,6 +177,13 @@ class GitCommitTool:
|
|
|
177
177
|
# 如果成功提取,就跳出循环
|
|
178
178
|
if commit_message:
|
|
179
179
|
break
|
|
180
|
+
prompt = f"""格式错误,请按照以下格式重新生成提交信息:
|
|
181
|
+
{ot("COMMIT_MESSAGE")}
|
|
182
|
+
<类型>(<范围>): <主题>
|
|
183
|
+
|
|
184
|
+
[可选] 详细描述变更内容和原因
|
|
185
|
+
{ct("COMMIT_MESSAGE")}
|
|
186
|
+
"""
|
|
180
187
|
spinner.write("✅ 生成提交消息")
|
|
181
188
|
|
|
182
189
|
# 执行提交
|
jarvis/jarvis_lsp/registry.py
CHANGED
|
@@ -6,6 +6,7 @@ import sys
|
|
|
6
6
|
from typing import Dict, Type, Optional, List
|
|
7
7
|
from jarvis.jarvis_lsp.base import BaseLSP
|
|
8
8
|
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
9
|
+
from jarvis.jarvis_utils.config import get_data_dir
|
|
9
10
|
|
|
10
11
|
REQUIRED_METHODS = [
|
|
11
12
|
('initialize', ['workspace_path']),
|
|
@@ -21,7 +22,7 @@ class LSPRegistry:
|
|
|
21
22
|
@staticmethod
|
|
22
23
|
def get_lsp_dir() -> str:
|
|
23
24
|
"""Get LSP implementation directory."""
|
|
24
|
-
user_lsp_dir = os.path.
|
|
25
|
+
user_lsp_dir = os.path.join(get_data_dir(), "lsp")
|
|
25
26
|
if not os.path.exists(user_lsp_dir):
|
|
26
27
|
try:
|
|
27
28
|
os.makedirs(user_lsp_dir)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from typing import Any, Dict, List
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class McpClient(ABC):
|
|
6
|
+
"""MCP客户端抽象基类"""
|
|
7
|
+
|
|
8
|
+
@abstractmethod
|
|
9
|
+
def get_tool_list(self) -> List[Dict[str, Any]]:
|
|
10
|
+
"""获取工具列表
|
|
11
|
+
|
|
12
|
+
返回:
|
|
13
|
+
List[Dict[str, Any]]: 工具列表,每个工具包含以下字段:
|
|
14
|
+
- name: str - 工具名称
|
|
15
|
+
- description: str - 工具描述
|
|
16
|
+
- parameters: Dict - 工具参数
|
|
17
|
+
"""
|
|
18
|
+
pass
|
|
19
|
+
|
|
20
|
+
@abstractmethod
|
|
21
|
+
def execute(self, tool_name: str, arguments: Dict[str, Any]) -> Dict[str, Any]:
|
|
22
|
+
"""执行工具
|
|
23
|
+
|
|
24
|
+
参数:
|
|
25
|
+
tool_name: 工具名称
|
|
26
|
+
arguments: 参数字典,包含工具执行所需的参数
|
|
27
|
+
|
|
28
|
+
返回:
|
|
29
|
+
Dict[str, Any]: 执行结果,包含以下字段:
|
|
30
|
+
- success: bool - 是否执行成功
|
|
31
|
+
- stdout: str - 标准输出
|
|
32
|
+
- stderr: str - 标准错误
|
|
33
|
+
"""
|
|
34
|
+
pass
|
|
35
|
+
|
|
36
|
+
@abstractmethod
|
|
37
|
+
def get_resource_list(self) -> List[Dict[str, Any]]:
|
|
38
|
+
"""获取资源列表
|
|
39
|
+
|
|
40
|
+
返回:
|
|
41
|
+
List[Dict[str, Any]]: 资源列表,每个资源包含以下字段:
|
|
42
|
+
- uri: str - 资源的唯一标识符
|
|
43
|
+
- name: str - 资源的名称
|
|
44
|
+
- description: str - 资源的描述(可选)
|
|
45
|
+
- mimeType: str - 资源的MIME类型(可选)
|
|
46
|
+
"""
|
|
47
|
+
pass
|
|
48
|
+
|
|
49
|
+
@abstractmethod
|
|
50
|
+
def get_resource(self, uri: str) -> Dict[str, Any]:
|
|
51
|
+
"""获取指定资源的内容
|
|
52
|
+
|
|
53
|
+
参数:
|
|
54
|
+
uri: str - 资源的URI标识符
|
|
55
|
+
|
|
56
|
+
返回:
|
|
57
|
+
Dict[str, Any]: 资源内容,包含以下字段:
|
|
58
|
+
- uri: str - 资源的URI
|
|
59
|
+
- mimeType: str - 资源的MIME类型(可选)
|
|
60
|
+
- text: str - 文本内容(如果是文本资源)
|
|
61
|
+
- blob: str - 二进制内容(如果是二进制资源,base64编码)
|
|
62
|
+
"""
|
|
63
|
+
pass
|
|
64
|
+
|
|
65
|
+
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
from typing import Any, Dict, List
|
|
2
|
+
import subprocess
|
|
3
|
+
import os
|
|
4
|
+
import json
|
|
5
|
+
from jarvis.jarvis_utils.output import OutputType, PrettyOutput
|
|
6
|
+
from . import McpClient
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class LocalMcpClient(McpClient):
|
|
10
|
+
"""本地MCP客户端实现
|
|
11
|
+
|
|
12
|
+
参数:
|
|
13
|
+
config: 配置字典(command、args、env)
|
|
14
|
+
"""
|
|
15
|
+
def __init__(self, config: Dict[str, Any]):
|
|
16
|
+
self.config = config
|
|
17
|
+
self.process = None
|
|
18
|
+
self.protocol_version = "2025-03-26" # MCP协议版本
|
|
19
|
+
self._start_process()
|
|
20
|
+
self._initialize()
|
|
21
|
+
|
|
22
|
+
def _start_process(self) -> None:
|
|
23
|
+
"""启动MCP进程"""
|
|
24
|
+
try:
|
|
25
|
+
# 构建命令和参数
|
|
26
|
+
command = self.config.get('command', '')
|
|
27
|
+
if not command:
|
|
28
|
+
raise ValueError('No command specified in config')
|
|
29
|
+
|
|
30
|
+
# 获取参数列表
|
|
31
|
+
args = self.config.get('args', [])
|
|
32
|
+
if not isinstance(args, list):
|
|
33
|
+
args = [str(args)]
|
|
34
|
+
|
|
35
|
+
# 获取环境变量
|
|
36
|
+
env = os.environ.copy()
|
|
37
|
+
env.update(self.config.get('env', {}))
|
|
38
|
+
|
|
39
|
+
# 启动进程
|
|
40
|
+
self.process = subprocess.Popen(
|
|
41
|
+
[command] + args,
|
|
42
|
+
stdin=subprocess.PIPE,
|
|
43
|
+
stdout=subprocess.PIPE,
|
|
44
|
+
stderr=subprocess.PIPE,
|
|
45
|
+
env=env,
|
|
46
|
+
text=True
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
except Exception as e:
|
|
50
|
+
PrettyOutput.print(f"启动MCP进程失败: {str(e)}", OutputType.ERROR)
|
|
51
|
+
raise
|
|
52
|
+
|
|
53
|
+
def _initialize(self) -> None:
|
|
54
|
+
"""初始化MCP连接"""
|
|
55
|
+
try:
|
|
56
|
+
# 发送初始化请求
|
|
57
|
+
response = self._send_request('initialize', {
|
|
58
|
+
'processId': os.getpid(),
|
|
59
|
+
'clientInfo': {
|
|
60
|
+
'name': 'jarvis',
|
|
61
|
+
'version': '1.0.0'
|
|
62
|
+
},
|
|
63
|
+
'capabilities': {},
|
|
64
|
+
'protocolVersion': self.protocol_version
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
# 验证服务器响应
|
|
68
|
+
if 'result' not in response:
|
|
69
|
+
raise RuntimeError(f"初始化失败: {response.get('error', 'Unknown error')}")
|
|
70
|
+
|
|
71
|
+
result = response['result']
|
|
72
|
+
|
|
73
|
+
# 发送initialized通知 - 使用正确的方法名格式
|
|
74
|
+
self._send_notification('notifications/initialized', {})
|
|
75
|
+
|
|
76
|
+
except Exception as e:
|
|
77
|
+
PrettyOutput.print(f"MCP初始化失败: {str(e)}", OutputType.ERROR)
|
|
78
|
+
raise
|
|
79
|
+
|
|
80
|
+
def _send_request(self, method: str, params: Dict[str, Any]) -> Dict[str, Any]:
|
|
81
|
+
"""发送请求到MCP进程
|
|
82
|
+
|
|
83
|
+
参数:
|
|
84
|
+
method: 请求方法
|
|
85
|
+
params: 请求参数
|
|
86
|
+
|
|
87
|
+
返回:
|
|
88
|
+
Dict[str, Any]: 响应结果
|
|
89
|
+
"""
|
|
90
|
+
if not self.process:
|
|
91
|
+
raise RuntimeError('MCP process not started')
|
|
92
|
+
|
|
93
|
+
try:
|
|
94
|
+
# 构建请求
|
|
95
|
+
request = {
|
|
96
|
+
'jsonrpc': '2.0',
|
|
97
|
+
'method': method,
|
|
98
|
+
'params': params,
|
|
99
|
+
'id': 1
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
# 发送请求
|
|
103
|
+
self.process.stdin.write(json.dumps(request) + '\n') # type: ignore
|
|
104
|
+
self.process.stdin.flush() # type: ignore
|
|
105
|
+
|
|
106
|
+
# 读取响应
|
|
107
|
+
response = self.process.stdout.readline() # type: ignore
|
|
108
|
+
return json.loads(response)
|
|
109
|
+
|
|
110
|
+
except Exception as e:
|
|
111
|
+
PrettyOutput.print(f"发送请求失败: {str(e)}", OutputType.ERROR)
|
|
112
|
+
raise
|
|
113
|
+
|
|
114
|
+
def _send_notification(self, method: str, params: Dict[str, Any]) -> None:
|
|
115
|
+
"""发送通知到MCP进程(不需要响应)
|
|
116
|
+
|
|
117
|
+
参数:
|
|
118
|
+
method: 通知方法
|
|
119
|
+
params: 通知参数
|
|
120
|
+
"""
|
|
121
|
+
if not self.process:
|
|
122
|
+
raise RuntimeError('MCP process not started')
|
|
123
|
+
|
|
124
|
+
try:
|
|
125
|
+
# 构建通知
|
|
126
|
+
notification = {
|
|
127
|
+
'jsonrpc': '2.0',
|
|
128
|
+
'method': method,
|
|
129
|
+
'params': params
|
|
130
|
+
}
|
|
131
|
+
# 发送通知
|
|
132
|
+
self.process.stdin.write(json.dumps(notification) + '\n') # type: ignore
|
|
133
|
+
self.process.stdin.flush() # type: ignore
|
|
134
|
+
|
|
135
|
+
except Exception as e:
|
|
136
|
+
PrettyOutput.print(f"发送通知失败: {str(e)}", OutputType.ERROR)
|
|
137
|
+
raise
|
|
138
|
+
|
|
139
|
+
def get_tool_list(self) -> List[Dict[str, Any]]:
|
|
140
|
+
"""获取工具列表
|
|
141
|
+
|
|
142
|
+
返回:
|
|
143
|
+
List[Dict[str, Any]]: 工具列表,每个工具包含以下字段:
|
|
144
|
+
- name: str - 工具名称
|
|
145
|
+
- description: str - 工具描述
|
|
146
|
+
- parameters: Dict - 工具参数
|
|
147
|
+
"""
|
|
148
|
+
try:
|
|
149
|
+
response = self._send_request('tools/list', {})
|
|
150
|
+
if 'result' in response and 'tools' in response['result']:
|
|
151
|
+
# 注意这里: 响应结构是 response['result']['tools']
|
|
152
|
+
tools = response['result']['tools']
|
|
153
|
+
# 将MCP协议字段转换为内部格式
|
|
154
|
+
formatted_tools = []
|
|
155
|
+
for tool in tools:
|
|
156
|
+
# 从inputSchema中提取参数定义
|
|
157
|
+
input_schema = tool.get('inputSchema', {})
|
|
158
|
+
parameters = {}
|
|
159
|
+
if 'properties' in input_schema:
|
|
160
|
+
parameters = input_schema['properties']
|
|
161
|
+
|
|
162
|
+
formatted_tools.append({
|
|
163
|
+
'name': tool.get('name', ''),
|
|
164
|
+
'description': tool.get('description', ''),
|
|
165
|
+
'parameters': parameters
|
|
166
|
+
})
|
|
167
|
+
return formatted_tools
|
|
168
|
+
else:
|
|
169
|
+
error_msg = "获取工具列表失败"
|
|
170
|
+
if 'error' in response:
|
|
171
|
+
error_msg += f": {response['error']}"
|
|
172
|
+
elif 'result' in response:
|
|
173
|
+
error_msg += f": 响应格式不正确 - {response['result']}"
|
|
174
|
+
else:
|
|
175
|
+
error_msg += ": 未知错误"
|
|
176
|
+
|
|
177
|
+
PrettyOutput.print(error_msg, OutputType.ERROR)
|
|
178
|
+
return []
|
|
179
|
+
except Exception as e:
|
|
180
|
+
PrettyOutput.print(f"获取工具列表失败: {str(e)}", OutputType.ERROR)
|
|
181
|
+
return []
|
|
182
|
+
|
|
183
|
+
def execute(self, tool_name: str, arguments: Dict[str, Any]) -> Dict[str, Any]:
|
|
184
|
+
"""执行工具
|
|
185
|
+
|
|
186
|
+
参数:
|
|
187
|
+
tool_name: 工具名称
|
|
188
|
+
arguments: 参数字典,包含工具执行所需的参数
|
|
189
|
+
|
|
190
|
+
返回:
|
|
191
|
+
Dict[str, Any]: 执行结果,包含以下字段:
|
|
192
|
+
- success: bool - 是否执行成功
|
|
193
|
+
- stdout: str - 标准输出
|
|
194
|
+
- stderr: str - 标准错误
|
|
195
|
+
"""
|
|
196
|
+
try:
|
|
197
|
+
response = self._send_request('tools/call', {
|
|
198
|
+
'name': tool_name,
|
|
199
|
+
'arguments': arguments
|
|
200
|
+
})
|
|
201
|
+
if 'result' in response:
|
|
202
|
+
result = response['result']
|
|
203
|
+
# 从content中提取输出信息
|
|
204
|
+
stdout = ''
|
|
205
|
+
stderr = ''
|
|
206
|
+
for content in result.get('content', []):
|
|
207
|
+
if content.get('type') == 'text':
|
|
208
|
+
stdout += content.get('text', '')
|
|
209
|
+
elif content.get('type') == 'error':
|
|
210
|
+
stderr += content.get('text', '')
|
|
211
|
+
|
|
212
|
+
return {
|
|
213
|
+
'success': True,
|
|
214
|
+
'stdout': stdout,
|
|
215
|
+
'stderr': stderr
|
|
216
|
+
}
|
|
217
|
+
else:
|
|
218
|
+
return {
|
|
219
|
+
'success': False,
|
|
220
|
+
'stdout': '',
|
|
221
|
+
'stderr': response.get('error', 'Unknown error')
|
|
222
|
+
}
|
|
223
|
+
except Exception as e:
|
|
224
|
+
PrettyOutput.print(f"执行工具失败: {str(e)}", OutputType.ERROR)
|
|
225
|
+
return {
|
|
226
|
+
'success': False,
|
|
227
|
+
'stdout': '',
|
|
228
|
+
'stderr': str(e)
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
def get_resource_list(self) -> List[Dict[str, Any]]:
|
|
232
|
+
"""获取资源列表
|
|
233
|
+
|
|
234
|
+
返回:
|
|
235
|
+
List[Dict[str, Any]]: 资源列表,每个资源包含以下字段:
|
|
236
|
+
- uri: str - 资源的唯一标识符
|
|
237
|
+
- name: str - 资源的名称
|
|
238
|
+
- description: str - 资源的描述(可选)
|
|
239
|
+
- mimeType: str - 资源的MIME类型(可选)
|
|
240
|
+
"""
|
|
241
|
+
try:
|
|
242
|
+
response = self._send_request('resources/list', {})
|
|
243
|
+
if 'result' in response and 'resources' in response['result']:
|
|
244
|
+
return response['result']['resources']
|
|
245
|
+
else:
|
|
246
|
+
error_msg = "获取资源列表失败"
|
|
247
|
+
if 'error' in response:
|
|
248
|
+
error_msg += f": {response['error']}"
|
|
249
|
+
else:
|
|
250
|
+
error_msg += ": 未知错误"
|
|
251
|
+
PrettyOutput.print(error_msg, OutputType.ERROR)
|
|
252
|
+
return []
|
|
253
|
+
except Exception as e:
|
|
254
|
+
PrettyOutput.print(f"获取资源列表失败: {str(e)}", OutputType.ERROR)
|
|
255
|
+
return []
|
|
256
|
+
|
|
257
|
+
def get_resource(self, uri: str) -> Dict[str, Any]:
|
|
258
|
+
"""获取指定资源的内容
|
|
259
|
+
|
|
260
|
+
参数:
|
|
261
|
+
uri: str - 资源的URI标识符
|
|
262
|
+
|
|
263
|
+
返回:
|
|
264
|
+
Dict[str, Any]: 执行结果,包含以下字段:
|
|
265
|
+
- success: bool - 是否执行成功
|
|
266
|
+
- stdout: str - 资源内容(文本或base64编码的二进制内容)
|
|
267
|
+
- stderr: str - 错误信息
|
|
268
|
+
"""
|
|
269
|
+
try:
|
|
270
|
+
response = self._send_request('resources/read', {
|
|
271
|
+
'uri': uri
|
|
272
|
+
})
|
|
273
|
+
if 'result' in response and 'contents' in response['result']:
|
|
274
|
+
contents = response['result']['contents']
|
|
275
|
+
if contents:
|
|
276
|
+
content = contents[0] # 获取第一个资源内容
|
|
277
|
+
# 根据资源类型返回内容
|
|
278
|
+
if 'text' in content:
|
|
279
|
+
return {
|
|
280
|
+
'success': True,
|
|
281
|
+
'stdout': content['text'],
|
|
282
|
+
'stderr': ''
|
|
283
|
+
}
|
|
284
|
+
elif 'blob' in content:
|
|
285
|
+
return {
|
|
286
|
+
'success': True,
|
|
287
|
+
'stdout': content['blob'],
|
|
288
|
+
'stderr': ''
|
|
289
|
+
}
|
|
290
|
+
return {
|
|
291
|
+
'success': False,
|
|
292
|
+
'stdout': '',
|
|
293
|
+
'stderr': '资源内容为空'
|
|
294
|
+
}
|
|
295
|
+
else:
|
|
296
|
+
error_msg = "获取资源内容失败"
|
|
297
|
+
if 'error' in response:
|
|
298
|
+
error_msg += f": {response['error']}"
|
|
299
|
+
else:
|
|
300
|
+
error_msg += ": 未知错误"
|
|
301
|
+
PrettyOutput.print(error_msg, OutputType.ERROR)
|
|
302
|
+
return {
|
|
303
|
+
'success': False,
|
|
304
|
+
'stdout': '',
|
|
305
|
+
'stderr': error_msg
|
|
306
|
+
}
|
|
307
|
+
except Exception as e:
|
|
308
|
+
error_msg = f"获取资源内容失败: {str(e)}"
|
|
309
|
+
PrettyOutput.print(error_msg, OutputType.ERROR)
|
|
310
|
+
return {
|
|
311
|
+
'success': False,
|
|
312
|
+
'stdout': '',
|
|
313
|
+
'stderr': error_msg
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
def __del__(self):
|
|
317
|
+
"""清理资源"""
|
|
318
|
+
if self.process:
|
|
319
|
+
try:
|
|
320
|
+
# 发送退出通知 - 使用通知而非请求
|
|
321
|
+
self._send_notification('notifications/exit', {})
|
|
322
|
+
# 等待进程结束
|
|
323
|
+
self.process.wait(timeout=1)
|
|
324
|
+
except:
|
|
325
|
+
# 如果进程没有正常退出,强制终止
|
|
326
|
+
self.process.kill()
|