fix: inline_eval exec() exception escaping crash; update schema description
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
"type": {"type": "string", "enum": ["python", "powershell"], "description": "Code type", "default": "python"},
|
"type": {"type": "string", "enum": ["python", "powershell"], "description": "Code type", "default": "python"},
|
||||||
"timeout": {"type": "integer", "description": "in seconds", "default": 60},
|
"timeout": {"type": "integer", "description": "in seconds", "default": 60},
|
||||||
"cwd": {"type": "string", "description": "Working directory, defaults to cwd"},
|
"cwd": {"type": "string", "description": "Working directory, defaults to cwd"},
|
||||||
"inline_eval": {"type": "boolean", "description": "Only when usage is explicitly specified."}}}
|
"inline_eval": {"type": "boolean", "description": "DO NOT USE except explicitly specified."}}}
|
||||||
}},
|
}},
|
||||||
{"type": "function", "function": {
|
{"type": "function", "function": {
|
||||||
"name": "file_read",
|
"name": "file_read",
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
"type": {"type": "string", "enum": ["python", "powershell"], "description": "代码类型", "default": "python"},
|
"type": {"type": "string", "enum": ["python", "powershell"], "description": "代码类型", "default": "python"},
|
||||||
"timeout": {"type": "integer", "description": "执行超时时间(秒)", "default": 60},
|
"timeout": {"type": "integer", "description": "执行超时时间(秒)", "default": 60},
|
||||||
"cwd": {"type": "string", "description": "工作目录,默认为当前工作目录"},
|
"cwd": {"type": "string", "description": "工作目录,默认为当前工作目录"},
|
||||||
"inline_eval": {"type": "boolean", "description": "仅在明确要求时使用"}}}
|
"inline_eval": {"type": "boolean", "description": "不允许使用除非明确要求"}}}
|
||||||
}},
|
}},
|
||||||
{"type": "function", "function": {
|
{"type": "function", "function": {
|
||||||
"name": "file_read",
|
"name": "file_read",
|
||||||
|
|||||||
1
ga.py
1
ga.py
@@ -290,6 +290,7 @@ class GenericAgentHandler(BaseHandler):
|
|||||||
old_cwd = os.getcwd()
|
old_cwd = os.getcwd()
|
||||||
try:
|
try:
|
||||||
os.chdir(cwd)
|
os.chdir(cwd)
|
||||||
|
try:
|
||||||
try: result = repr(eval(code, ns))
|
try: result = repr(eval(code, ns))
|
||||||
except SyntaxError: exec(code, ns); result = ns.get('_r', 'OK')
|
except SyntaxError: exec(code, ns); result = ns.get('_r', 'OK')
|
||||||
except Exception as e: result = f'Error: {e}'
|
except Exception as e: result = f'Error: {e}'
|
||||||
|
|||||||
Reference in New Issue
Block a user