auto-sync: 2026-05-26 10:46:55

This commit is contained in:
cfdaily
2026-05-26 10:46:55 +08:00
parent 4be319b522
commit 4ac9ff8f1a
+10 -3
View File
@@ -834,19 +834,26 @@ curl -X POST http://{api_host}:{api_port}/api/projects/{project_id}/tasks/{task_
@staticmethod
def _parse_stdout_json(stdout_text: str) -> dict:
"""解析 openclaw agent --json 的 stdout 输出"""
"""解析 openclaw agent --json 的 stdout 输出
openclaw agent --json 输出格式:
{ "kind": "agent-response", "response": { "meta": { "transport": ..., ... } } }
"""
text = stdout_text.strip()
if not text:
return {}
try:
data = json.loads(text)
return data.get("meta", {})
# 正确路径:data.response.meta
response = data.get("response", data)
return response.get("meta", {})
except json.JSONDecodeError:
# 多行输出,找最后一个 JSON
for line in reversed(text.splitlines()):
try:
data = json.loads(line)
return data.get("meta", {})
response = data.get("response", data)
return response.get("meta", {})
except json.JSONDecodeError:
continue
return {}