a03675113a
- .claude/agents/fn-orquestador/SKILL.md - .claude/commands/fn_claude.md - .claude/rules/INDEX.md - .claude/rules/cpp_apps.md - .claude/rules/ids_naming.md - CHANGELOG.md - apps/dag_engine/README.md - apps/dag_engine/api.go - apps/dag_engine/dags_migrated/example.yaml - apps/dag_engine/dags_migrated/example_lineage_tracking.yaml - ... Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3.0 KiB
3.0 KiB
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
| name | kind | lang | domain | version | purity | signature | description | tags | uses_functions | uses_types | returns | returns_optional | error_type | imports | params | output | tested | tests | test_file_path | file_path | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| cdp_get_ax_tree | pipeline | py | pipelines | 1.0.0 | impure | def cdp_get_ax_tree(debug_port: int, tab_id: str, depth: int = -1) -> list[dict] | Conecta a Chrome via CDP WebSocket, habilita Accessibility y devuelve el AX tree completo del tab indicado. Usa websocket-client si está disponible, sino websockets async. |
|
|
false | error_go_core |
|
|
Lista de AXNode en formato CDP. Lista vacía si la página no tiene contenido accesible. | false | python/functions/pipelines/cdp_get_ax_tree.py |
Ejemplo
import urllib.request, json
from pipelines.cdp_get_ax_tree import cdp_get_ax_tree
from core.trim_ax_tree import trim_ax_tree
from core.chunk_ax_tree import chunk_ax_tree
# 1. Listar tabs para obtener tab_id
with urllib.request.urlopen("http://127.0.0.1:9222/json/list") as r:
tabs = json.loads(r.read())
tab_id = tabs[0]["id"]
# 2. Obtener AX tree
nodes = cdp_get_ax_tree(debug_port=9222, tab_id=tab_id)
# 3. Reducir y chunkear para LLM
trimmed = trim_ax_tree(nodes)
chunks = chunk_ax_tree(trimmed, max_chars=25000)
print(f"{len(nodes)} nodos → {len(trimmed)} trimmed → {len(chunks)} chunks")
Cuando usarla
Cuando necesitas obtener el árbol de accesibilidad de una página Chrome ya abierta para procesarlo con un LLM o para automatización accesible (más estable que selectores CSS). Requiere Chrome lanzado con --remote-debugging-port=PORT.
Gotchas
- Chrome debe estar corriendo con
--remote-debugging-port=<port>y--no-sandboxen CI. - En WSL2 usar
--remote-debugging-address=0.0.0.0y conectar al IP del host Windows, no a 127.0.0.1. - El tab no puede tener otro debugger adjunto (DevTools abierto) — cierra DevTools antes de llamar.
Accessibility.getFullAXTreepuede tardar 2-5s en páginas grandes.- Timeout total de 15s — aumentar si la página es muy pesada.
- Tests automáticos requieren Chrome corriendo. Para probar manualmente:
# Lanzar Chrome en WSL2 chrome.exe --remote-debugging-port=9222 --headless=new https://example.com # Verificar curl http://127.0.0.1:9222/json/list | python3 -m json.tool # Ejecutar python3 -c " import json, urllib.request from pipelines.cdp_get_ax_tree import cdp_get_ax_tree with urllib.request.urlopen('http://127.0.0.1:9222/json/list') as r: tabs = json.loads(r.read()) nodes = cdp_get_ax_tree(9222, tabs[0]['id']) print(f'{len(nodes)} nodos') "