Skip to content

Latest commit

 

History

History
104 lines (76 loc) · 3.31 KB

README_TH.md

File metadata and controls

104 lines (76 loc) · 3.31 KB

browser-cli

เครื่องมือ 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 แล้ว (v3 output + --input) แต่ write-boundary enforcement ยัง partial
  • text output: clean whitespace เป็นค่า default ปิดได้ด้วย --clean=false หรือ @clean=false
  • snapshot globals ใช้ config snapshot.globals และค่า default เป็น empty

ติดตั้ง

npm install
npm run install-browsers

เริ่มใช้เร็ว

node 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 -

หลัก Trinity

Trust artifacts, not claims.

AI agent ไม่ควรถูกเชื่อเพราะบอกว่าเห็นหน้าเว็บแล้ว แต่ควรมี artifact เช่น JSON response, screenshot, log, หรือ verifier evidence ให้ตรวจได้

ทดสอบ

npm test

CDP smoke test ต้องเปิด Chrome ก่อน:

./scripts/start-chrome-debug.sh
node tests/cdp.js --smoke