aient 1.1.25__py3-none-any.whl → 1.1.27__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.
@@ -1,10 +1,9 @@
1
1
  import subprocess
2
2
  from .registry import register_tool
3
- from ..utils.scripts import sandbox
3
+ from ..utils.scripts import sandbox, unescape_html
4
4
 
5
5
  import re
6
6
  import os
7
- import html
8
7
  import select
9
8
 
10
9
  # 检查是否在 Unix-like 系统上 (pty 模块主要用于 Unix)
@@ -39,18 +38,6 @@ def compare_line(line: str) -> bool:
39
38
  # print(f"similarity: {similarity}")
40
39
  return similarity > 0.89
41
40
 
42
- def unescape_html(input_string: str) -> str:
43
- """
44
- 将字符串中的 HTML 实体(例如 &)转换回其原始字符(例如 &)。
45
-
46
- Args:
47
- input_string: 包含 HTML 实体的输入字符串。
48
-
49
- Returns:
50
- 转换后的字符串。
51
- """
52
- return html.unescape(input_string)
53
-
54
41
  def get_python_executable(command: str) -> str:
55
42
  """
56
43
  获取 Python 可执行文件的路径。
@@ -1,19 +1,7 @@
1
1
  from .registry import register_tool
2
+ from ..utils.scripts import unescape_html
2
3
 
3
4
  import os
4
- import html
5
-
6
- def unescape_html(input_string: str) -> str:
7
- """
8
- 将字符串中的 HTML 实体(例如 &)转换回其原始字符(例如 &)。
9
-
10
- Args:
11
- input_string: 包含 HTML 实体的输入字符串。
12
-
13
- Returns:
14
- 转换后的字符串。
15
- """
16
- return html.unescape(input_string)
17
5
 
18
6
  @register_tool()
19
7
  def write_to_file(path, content, mode='w'):
aient/utils/scripts.py CHANGED
@@ -202,6 +202,19 @@ def parse_tools_from_cursor_prompt(text):
202
202
  print(f"解析 JSON 时出错: {e}")
203
203
  return []
204
204
 
205
+ import html
206
+ def unescape_html(input_string: str) -> str:
207
+ """
208
+ 将字符串中的 HTML 实体(例如 &)转换回其原始字符(例如 &)。
209
+
210
+ Args:
211
+ input_string: 包含 HTML 实体的输入字符串。
212
+
213
+ Returns:
214
+ 转换后的字符串。
215
+ """
216
+ return html.unescape(input_string)
217
+
205
218
  import sys
206
219
  import shlex
207
220
  import builtins
@@ -241,17 +254,46 @@ def _sandboxed_open(file, mode='r', *args, **kwargs):
241
254
 
242
255
  builtins.open = _sandboxed_open
243
256
 
244
- # 2. 智能判断原始命令是脚本还是模块,并执行
257
+ # 2. 智能判断原始命令是脚本、模块还是代码字符串,并执行
245
258
  original_argv = sys.argv[1:]
246
- if original_argv and original_argv[0] == '-m':
247
- sys.argv = original_argv[1:]
248
- runpy.run_module(sys.argv[0], run_name='__main__')
249
- elif original_argv:
250
- target_path = original_argv[0]
251
- sys.argv = original_argv
259
+
260
+ action = None
261
+ action_arg = None
262
+ passthrough_args = []
263
+ i = 0
264
+ while i < len(original_argv):
265
+ arg = original_argv[i]
266
+ if arg == '-m':
267
+ action = 'module'
268
+ if i + 1 < len(original_argv):
269
+ action_arg = original_argv[i+1]
270
+ passthrough_args = original_argv[i+2:]
271
+ break
272
+ elif arg == '-c':
273
+ action = 'command'
274
+ if i + 1 < len(original_argv):
275
+ action_arg = original_argv[i+1]
276
+ passthrough_args = original_argv[i+2:]
277
+ break
278
+ elif arg.startswith('-'):
279
+ i += 1
280
+ else:
281
+ action = 'file'
282
+ action_arg = arg
283
+ passthrough_args = original_argv[i+1:]
284
+ break
285
+
286
+ if action == 'module' and action_arg:
287
+ sys.argv = [action_arg] + passthrough_args
288
+ runpy.run_module(action_arg, run_name='__main__')
289
+ elif action == 'command' and action_arg:
290
+ sys.argv = ['-c'] + passthrough_args
291
+ exec(action_arg, {'__name__': '__main__'})
292
+ elif action == 'file' and action_arg:
293
+ sys.argv = [action_arg] + passthrough_args
252
294
  # 使用原始的 open 来读取要执行的脚本,因为它本身不应受沙箱限制
253
- with original_open(target_path, 'r') as f:
254
- code = compile(f.read(), target_path, 'exec')
295
+ with original_open(action_arg, 'r') as f:
296
+ code = compile(f.read(), action_arg, 'exec')
255
297
  exec(code, {'__name__': '__main__'})
256
298
  else:
257
299
  pass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aient
3
- Version: 1.1.25
3
+ Version: 1.1.27
4
4
  Summary: Aient: The Awakening of Agent.
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -23,7 +23,7 @@ aient/models/vertex.py,sha256=qVD5l1Q538xXUPulxG4nmDjXE1VoV4yuAkTCpIeJVw0,16795
23
23
  aient/plugins/__init__.py,sha256=p3KO6Aa3Lupos4i2SjzLQw1hzQTigOAfEHngsldrsyk,986
24
24
  aient/plugins/arXiv.py,sha256=yHjb6PS3GUWazpOYRMKMzghKJlxnZ5TX8z9F6UtUVow,1461
25
25
  aient/plugins/config.py,sha256=QGyI9LlNaU36GUpY531o7UbTFBB39u7LfS6rrx_RTWw,7103
26
- aient/plugins/excute_command.py,sha256=-Meu3CcC8U8Oc2lYf4OpaVQQ3YrIjBmpPEJVgONDkyI,10313
26
+ aient/plugins/excute_command.py,sha256=ybkgoMlrXxfeRLA8gizxNL1KuVda0s9xSKTSzC8CKyU,10021
27
27
  aient/plugins/get_time.py,sha256=Ih5XIW5SDAIhrZ9W4Qe5Hs1k4ieKPUc_LAd6ySNyqZk,654
28
28
  aient/plugins/image.py,sha256=ZElCIaZznE06TN9xW3DrSukS7U3A5_cjk1Jge4NzPxw,2072
29
29
  aient/plugins/list_directory.py,sha256=JZVuImecMSfEv6jLqii-0uQJ1UCsrpMNmYlwW3PEDg4,1374
@@ -33,14 +33,14 @@ aient/plugins/readonly.py,sha256=qK5-kBM3NDH1b-otFxFHpAjV5BXEY_e7cTWBcpP7G5k,710
33
33
  aient/plugins/registry.py,sha256=YknzhieU_8nQ3oKlUSSWDB4X7t2Jx0JnqT2Jd9Xsvfk,3574
34
34
  aient/plugins/run_python.py,sha256=dgcUwBunMuDkaSKR5bToudVzSdrXVewktDDFUz_iIOQ,4589
35
35
  aient/plugins/websearch.py,sha256=llxy1U0vJiNMiKvamMr4p7IruLb3nnDR4YErz8TYimc,15215
36
- aient/plugins/write_file.py,sha256=ndMsQhfMuobvgbFuesxb17zIk9cQIYTd9Gdr6yiiZec,3896
36
+ aient/plugins/write_file.py,sha256=aWOCuKjtpzjl2JiJV9W6YBmPg_WivxyXD509xUHiuCc,3631
37
37
  aient/prompt/__init__.py,sha256=GBtn6-JDT8KHFCcuPpfSNE_aGddg5p4FEyMCy4BfwGs,20
38
38
  aient/prompt/agent.py,sha256=ebHYebxbgL-WEAKUs1NPNwxlUMucF3GNNoy3eNZrtIo,29737
39
39
  aient/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
40
40
  aient/utils/prompt.py,sha256=UcSzKkFE4-h_1b6NofI6xgk3GoleqALRKY8VBaXLjmI,11311
41
- aient/utils/scripts.py,sha256=9ihTL2W3z5q6Qh6ZqCYplTEoonL4oSj8MBzpRbvc5IE,35329
42
- aient-1.1.25.dist-info/licenses/LICENSE,sha256=XNdbcWldt0yaNXXWB_Bakoqnxb3OVhUft4MgMA_71ds,1051
43
- aient-1.1.25.dist-info/METADATA,sha256=Vl_t8k-8RDWtEcGzqhvbrto7O-MxZ4uHnajBG_T6Ndk,4968
44
- aient-1.1.25.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
45
- aient-1.1.25.dist-info/top_level.txt,sha256=3oXzrP5sAVvyyqabpeq8A2_vfMtY554r4bVE-OHBrZk,6
46
- aient-1.1.25.dist-info/RECORD,,
41
+ aient/utils/scripts.py,sha256=JVR6oNxYc9NnfQL0PGsL8QuhG43dwg0-rPS8NR_pyBM,36461
42
+ aient-1.1.27.dist-info/licenses/LICENSE,sha256=XNdbcWldt0yaNXXWB_Bakoqnxb3OVhUft4MgMA_71ds,1051
43
+ aient-1.1.27.dist-info/METADATA,sha256=a3i0FAh-ilxdSvPFbnnxhH0WxVTIWQGfBRlQtryTi-g,4968
44
+ aient-1.1.27.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
45
+ aient-1.1.27.dist-info/top_level.txt,sha256=3oXzrP5sAVvyyqabpeq8A2_vfMtY554r4bVE-OHBrZk,6
46
+ aient-1.1.27.dist-info/RECORD,,
File without changes