Implement Apex Agent MVP scaffold

This commit is contained in:
2026-07-06 13:22:15 +08:00
commit 02ef4d23f2
49 changed files with 2767 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
from __future__ import annotations
from core.models import Bounds, SceneElement
from vision.scene_builder import bbox_iou, build_scene
def test_scene_builder_merges_overlapping_ocr_into_ui_element() -> None:
ui_button = SceneElement(
id="ui-button",
type="button",
text=None,
bounds=Bounds(10, 10, 100, 40),
confidence=1.0,
source="ui",
)
ocr_label = SceneElement(
id="ocr-label",
type="text",
text="Search",
bounds=Bounds(12, 12, 96, 36),
confidence=0.92,
source="ocr",
)
ocr_only = SceneElement(
id="ocr-only",
type="text",
text="Footer",
bounds=Bounds(0, 100, 40, 20),
confidence=0.8,
source="ocr",
)
scene = build_scene(
screen_width=120,
screen_height=140,
ui_elements=[ui_button],
ocr_elements=[ocr_label, ocr_only],
)
assert len(scene.elements) == 2
assert scene.elements[0].type == "button"
assert scene.elements[0].text == "Search"
assert scene.elements[1].text == "Footer"
assert bbox_iou(ui_button.bounds, ocr_label.bounds) > 0.5