48 lines
2.1 KiB
Bash
48 lines
2.1 KiB
Bash
#!/usr/bin/env bash
|
||
set -euo pipefail
|
||
APP_TOKEN="SZ4ebCKU3a9OdfspetxcSeg1n4g"
|
||
TABLE_ID="tblzuMy85WiRAUX5"
|
||
TS="$(date +%F_%H:%M:%S)"
|
||
MSG1="调用 feishu_bitable_list_records,app_token=${APP_TOKEN},table_id=${TABLE_ID},page_size=3。返回记录数量和前3条文本字段。"
|
||
MSG2="调用 feishu_bitable_create_record,app_token=${APP_TOKEN},table_id=${TABLE_ID},fields={\"文本\":\"OpenClaw联调测试-${TS}\"}。返回新建record_id和写入内容。"
|
||
MSG3="再次调用 feishu_bitable_list_records,app_token=${APP_TOKEN},table_id=${TABLE_ID},page_size=5。返回最近5条的文本字段。"
|
||
|
||
/usr/bin/openclaw agent --session-id feishu-e2e-$(date +%s)-1 --message "$MSG1" --json --timeout 120 > /tmp/feishu_test_step1.out 2>&1 || true
|
||
/usr/bin/openclaw agent --session-id feishu-e2e-$(date +%s)-2 --message "$MSG2" --json --timeout 120 > /tmp/feishu_test_step2.out 2>&1 || true
|
||
/usr/bin/openclaw agent --session-id feishu-e2e-$(date +%s)-3 --message "$MSG3" --json --timeout 120 > /tmp/feishu_test_step3.out 2>&1 || true
|
||
|
||
python3 - <<'PY'
|
||
import json
|
||
from pathlib import Path
|
||
|
||
|
||
def parse(path):
|
||
raw = Path(path).read_text(encoding="utf-8", errors="ignore").strip()
|
||
dec = json.JSONDecoder()
|
||
data = None
|
||
try:
|
||
data, _ = dec.raw_decode(raw)
|
||
except Exception:
|
||
idx = raw.find('{')
|
||
while idx != -1:
|
||
try:
|
||
data, _ = dec.raw_decode(raw[idx:])
|
||
break
|
||
except Exception:
|
||
idx = raw.find('{', idx + 1)
|
||
if not isinstance(data, dict):
|
||
return {"ok": False, "raw": raw[:600]}
|
||
payloads = data.get("result", {}).get("payloads", [])
|
||
text = "\n".join(p.get("text", "") for p in payloads if isinstance(p, dict) and p.get("text"))
|
||
return {"ok": True, "text": text[:2000], "status": data.get("status"), "summary": data.get("summary")}
|
||
|
||
for i in (1, 2, 3):
|
||
r = parse(f"/tmp/feishu_test_step{i}.out")
|
||
print(f"===== STEP {i} =====")
|
||
if not r.get("ok"):
|
||
print("PARSE_FAIL", r.get("raw"))
|
||
else:
|
||
print("status=", r.get("status"), "summary=", r.get("summary"))
|
||
print(r.get("text") or "<empty>")
|
||
PY
|