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 +38 -9
- {aient-1.1.25.dist-info → aient-1.1.26.dist-info}/METADATA +1 -1
- {aient-1.1.25.dist-info → aient-1.1.26.dist-info}/RECORD +6 -6
- {aient-1.1.25.dist-info → aient-1.1.26.dist-info}/WHEEL +0 -0
- {aient-1.1.25.dist-info → aient-1.1.26.dist-info}/licenses/LICENSE +0 -0
- {aient-1.1.25.dist-info → aient-1.1.26.dist-info}/top_level.txt +0 -0
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
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
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(
|
254
|
-
code = compile(f.read(),
|
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
|
@@ -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=
|
42
|
-
aient-1.1.
|
43
|
-
aient-1.1.
|
44
|
-
aient-1.1.
|
45
|
-
aient-1.1.
|
46
|
-
aient-1.1.
|
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
|
File without changes
|
File without changes
|