เครื่องมือ browser automation แบบ CLI สำหรับ AI agent
browser-cli รับคำสั่งผ่าน stdin แล้วตอบกลับเป็น JSON ผ่าน stdout พร้อม policy tiers, log, artifact, screenshot, download และ CDP mode สำหรับ reuse Chrome เดิมที่เปิดอยู่
หลักคิดคือให้ boundary ตรวจสอบได้:
stdin command -> browser-cli -> stdout JSON
-> stderr diagnostics
-> files/artifacts/logs
-> exit code
ใช้ร่วมกับ Trinity ได้ในฐานะ browser organ แต่ repo นี้ยังเป็น public clean export ระยะแรก ไม่รวม private configs, screenshots, session data หรือเอกสารที่ ผูกกับโปรเจกต์จริง
- Public clean export:
v0.3.0 - Runtime: Node.js + Playwright
- Trinity Tool Contract: implement บางส่วนของ v1.0 แล้ว (
v3output +--input) แต่ write-boundary enforcement ยัง partial textoutput: clean whitespace เป็นค่า default ปิดได้ด้วย--clean=falseหรือ@clean=false- snapshot globals ใช้ config
snapshot.globalsและค่า default เป็น empty
npm install
npm run install-browsersnode index.js --config configs/example.json --cmd "goto /"แบบ pipe:
printf "goto /\ntitle\nscreenshot example-home.png\nexit\n" \
| node index.js --config configs/example.json --response-schema=v2ใช้ Chrome ที่เปิด CDP อยู่:
./scripts/start-chrome-debug.sh
node index.js --cdp http://localhost:9222 \
--config configs/example.json \
--reuse-tab \
--cmd "outline"เปลี่ยน viewport ระหว่าง session เดียวได้ทันที:
printf "goto /\nviewport 375x667\nscreenshot mobile.png\nviewport 1440x900\nscreenshot desktop.png\nexit\n" \
| node index.js --config configs/example.json --response-schema=v2อ่าน text แบบลด whitespace noise เป็นค่า default:
node index.js --config configs/example.json --cmd "text body"
node index.js --config configs/example.json --clean=false --cmd "text body"ใช้ Trinity Tool Contract envelope:
node index.js --config configs/example.json --response-schema=v3 --cmd "text body"
node index.js --config configs/example.json --input request.json
cat request.json | node index.js --config configs/example.json --input -Trust artifacts, not claims.
AI agent ไม่ควรถูกเชื่อเพราะบอกว่าเห็นหน้าเว็บแล้ว แต่ควรมี artifact เช่น JSON response, screenshot, log, หรือ verifier evidence ให้ตรวจได้
npm testCDP smoke test ต้องเปิด Chrome ก่อน:
./scripts/start-chrome-debug.sh
node tests/cdp.js --smoke