aient 1.1.25__py3-none-any.whl → 1.1.26__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.
aient/utils/scripts.py CHANGED
@@ -241,17 +241,46 @@ def _sandboxed_open(file, mode='r', *args, **kwargs):
241
241
 
242
242
  builtins.open = _sandboxed_open
243
243
 
244
- # 2. 智能判断原始命令是脚本还是模块,并执行
244
+ # 2. 智能判断原始命令是脚本、模块还是代码字符串,并执行
245
245
  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
246
+
247
+ action = None
248
+ action_arg = None
249
+ passthrough_args = []
250
+ i = 0
251
+ while i < len(original_argv):
252
+ arg = original_argv[i]
253
+ if arg == '-m':
254
+ action = 'module'
255
+ if i + 1 < len(original_argv):
256
+ action_arg = original_argv[i+1]
257
+ passthrough_args = original_argv[i+2:]
258
+ break
259
+ elif arg == '-c':
260
+ action = 'command'
261
+ if i + 1 < len(original_argv):
262
+ action_arg = original_argv[i+1]
263
+ passthrough_args = original_argv[i+2:]
264
+ break
265
+ elif arg.startswith('-'):
266
+ i += 1
267
+ else:
268
+ action = 'file'
269
+ action_arg = arg
270
+ passthrough_args = original_argv[i+1:]
271
+ break
272
+
273
+ if action == 'module' and action_arg:
274
+ sys.argv = [action_arg] + passthrough_args
275
+ runpy.run_module(action_arg, run_name='__main__')
276
+ elif action == 'command' and action_arg:
277
+ sys.argv = ['-c'] + passthrough_args
278
+ exec(action_arg, {'__name__': '__main__'})
279
+ elif action == 'file' and action_arg:
280
+ sys.argv = [action_arg] + passthrough_args
252
281
  # 使用原始的 open 来读取要执行的脚本,因为它本身不应受沙箱限制
253
- with original_open(target_path, 'r') as f:
254
- code = compile(f.read(), target_path, 'exec')
282
+ with original_open(action_arg, 'r') as f:
283
+ code = compile(f.read(), action_arg, 'exec')
255
284
  exec(code, {'__name__': '__main__'})
256
285
  else:
257
286
  pass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aient
3
- Version: 1.1.25
3
+ Version: 1.1.26
4
4
  Summary: Aient: The Awakening of Agent.
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -38,9 +38,9 @@ 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=l8_NrwIRYxvzxPFg-vSJz120swdnxxGfgBcQRogJ4nI,36154
42
+ aient-1.1.26.dist-info/licenses/LICENSE,sha256=XNdbcWldt0yaNXXWB_Bakoqnxb3OVhUft4MgMA_71ds,1051
43
+ aient-1.1.26.dist-info/METADATA,sha256=CAiFkA5V7mMkXr5LvzzEL8pko1NEEcfOTnfUPN5g9yI,4968
44
+ aient-1.1.26.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
45
+ aient-1.1.26.dist-info/top_level.txt,sha256=3oXzrP5sAVvyyqabpeq8A2_vfMtY554r4bVE-OHBrZk,6
46
+ aient-1.1.26.dist-info/RECORD,,
File without changes