|
@@ -228,10 +228,17 @@ def git_branch(input_val: Any) -> str:
|
|
|
|
|
|
|
|
def _parse_input(input_val: Any) -> dict:
|
|
def _parse_input(input_val: Any) -> dict:
|
|
|
if isinstance(input_val, dict):
|
|
if isinstance(input_val, dict):
|
|
|
|
|
+ # Extract nested "input" from ReAct format: {"action":"Bash","input":{...}}
|
|
|
|
|
+ if "input" in input_val and ("action" in input_val or "tool" in input_val):
|
|
|
|
|
+ inner = input_val["input"]
|
|
|
|
|
+ return json.loads(inner) if isinstance(inner, str) else inner if isinstance(inner, dict) else {"command": str(inner)}
|
|
|
return input_val
|
|
return input_val
|
|
|
if isinstance(input_val, str):
|
|
if isinstance(input_val, str):
|
|
|
try:
|
|
try:
|
|
|
- return json.loads(input_val)
|
|
|
|
|
|
|
+ parsed = json.loads(input_val)
|
|
|
|
|
+ if isinstance(parsed, dict):
|
|
|
|
|
+ return _parse_input(parsed) # recurse to handle nested format
|
|
|
|
|
+ return {"command": input_val}
|
|
|
except (json.JSONDecodeError, ValueError):
|
|
except (json.JSONDecodeError, ValueError):
|
|
|
return {"command": input_val}
|
|
return {"command": input_val}
|
|
|
return {}
|
|
return {}
|