============================ 新功能 (2026-05) ============================ 新增 23 個功能,涵蓋更聰明的定位器、更深的 IDE / 維運工具、兩個新平台後端, 以及幾個新整合。每個功能都遵循框架既有模式:headless Python API、 ``AC_*`` executor 命令、``ac_*`` MCP 工具,以及(適用時)Qt GUI 分頁。 .. contents:: :local: :depth: 2 定位器與選擇器智慧化 ==================== 自我修復定位器 -------------- ``影像樣板 → VLM 後備`` 並寫入 JSON-lines 稽核記錄,方便長期調校 不穩定的定位器:: from je_auto_control import self_heal_click outcome = self_heal_click( template_path="submit.png", description="綠色的 Submit 按鈕", ) Executor:``AC_self_heal_locate / _click / _log_list / _log_clear``。 MCP:``ac_self_heal_*``。GUI:**Self-Healing** 分頁。 錨點定位器 ---------- 依「相對於錨點 A 的空間關係」找到元素 B。錨點與目標可以使用不同 backend — 每一部分挑成本最低、能唯一識別的方式:: from je_auto_control import ( anchor_locate, image_locator, ocr_locator, ) outcome = anchor_locate( anchor=ocr_locator("Username"), target=image_locator("submit_green.png"), relation="below", ) 關係:``above``、``below``、``left_of``、``right_of``、``near``。 Executor:``AC_anchor_locate / _click``。 結構化 OCR ---------- 把 OCR 原始 match 聚合為 rows、tables(欄位對齊的 row 集合)以及 form-field ``label:value`` 對:: from je_auto_control import ocr_read_structure result = ocr_read_structure(region=[0, 0, 1280, 800]) for field in result.fields: print(field.label, "=", field.value) Executor:``AC_ocr_read_structure``。 智慧等待 -------- 用 frame-diff 取代 ``time.sleep``:: from je_auto_control import wait_until_screen_stable wait_until_screen_stable(timeout_s=10.0, stable_for_s=0.5) 輔助函式:``wait_until_screen_stable``、``wait_until_pixel_changes``、 ``wait_until_region_idle``。Executor:``AC_wait_screen_stable``、 ``AC_wait_pixel_changes``、``AC_wait_region_idle``。 A/B 定位器框架 -------------- 對同一目標並行跑 N 種策略,並推薦歷史上最佳的:: from je_auto_control import ab_locate, ab_best_strategy outcome = ab_locate( target_id="submit_button", strategies={ "image": image_locator("submit.png"), "ocr": ocr_locator("Submit"), "vlm": vlm_locator("綠色的 Submit 按鈕"), }, ) print("歷史最佳:", ab_best_strategy("submit_button")) 成績存放於 ``~/.je_auto_control/ab_locator_stats.json``。 Executor:``AC_ab_locate / _report / _best_strategy / _clear``。 維運與觀察性 ============ 成本遙測 -------- 每次 LLM 呼叫的 token / USD 紀錄,並按天 / 模型 / 提供者彙總:: from je_auto_control import record_llm_call, summarise_llm_costs record_llm_call( provider="anthropic", model="claude-opus-4-7", input_tokens=512, output_tokens=128, label="vlm_locate", ) summary = summarise_llm_costs() print(summary.total_usd, summary.by_model) 內建價格表涵蓋 Claude 4.x 與 OpenAI;可單次呼叫覆寫。 Executor:``AC_costs_record / _summary / _list / _clear``。 追蹤重播 UI ----------- 在現有的 time-travel 錄影上建構可拖曳時間軸 — 讀取含 ``manifest.json`` + ``actions.jsonl`` 的目錄,逐 frame 倒退並 旁列當時執行的動作。``TraceReplayController`` 提供純 Python 介面 供非 GUI 使用;**Trace Replay** 分頁則是其上的薄殼。 失敗 → 工單自動化 ------------------ 當排程任務、觸發器或 REST 工作失敗時,將失敗報告分送 Jira / Linear / GitHub Issues:: from je_auto_control import ( FailureReport, GitHubBackend, default_failure_hook_manager, ) default_failure_hook_manager.register( GitHubBackend(owner="acme", repo="ops", token=os.environ["GH_TOKEN"]), ) Executor:``AC_failure_hook_fire / _list / _clear``。 容器化 CI 模板 -------------- * ``.github/workflows/docker.yml`` — 在 Xvfb 容器內建置鏡像、跑 headless pytest、smoke-test REST entrypoint。 * ``ci_templates/.gitlab-ci.yml`` — 透過 Docker-in-Docker 的同等 GitLab pipeline。 * ``docker/Dockerfile.xfce`` — XFCE4 桌面 + x11vnc 變體,給需要 真實 WM 的流程使用。 完整指南:``docs/source/getting_started/run_in_ci.rst``。 跨主機 DAG 編排 --------------- 每個節點攜帶 ``(host, actions | action_file, depends_on)``。``local`` 節點在本機 in-process 執行;其他節點透過 admin console REST client 分派。失敗會層層下游 cascade — 後續節點直接報告為 ``skipped``, 不會被嘗試:: je_auto_control.run_dag({ "nodes": [ {"id": "step1", "host": "local", "actions": [...]}, {"id": "step2", "host": "machine-a", "action_file": "x.json", "depends_on": ["step1"]}, ], }) Executor:``AC_run_dag``。GUI:**DAG Runner** 分頁。 多 viewer 名單 -------------- 為 multi-viewer 遠端桌面提供觀察者名單與「控制者 / 觀察者」角色。 純 Python 的 ``PresenceRegistry`` 獨立發佈,input dispatch 的角色 門禁可獨立單元測試(無需 aiortc)。 Executor:``AC_presence_register / _unregister / _update_cursor / _set_role / _list / _clear``。GUI:**Viewer Roster** 分頁。 代理與整合 ========== Computer-use 高階 API --------------------- 封裝 :class:`ComputerUseAgentBackend` + :class:`AgentLoop`,一次呼叫 即可驅動 Anthropic 官方 ``computer_20250124`` tool:: from je_auto_control import run_computer_use result = run_computer_use( "開啟計算機,計算 12 * 7,截圖結果", max_steps=15, wall_seconds=120.0, ) 自動偵測螢幕大小;以 ``max_steps`` + ``wall_seconds`` 為預算上限, 避免失控的 loop 把 API 額度耗光。Executor:``AC_computer_use``。 GUI:**Computer Use** 分頁。 WebRunner 接入 executor + MCP ----------------------------- 在既有 ``je_web_runner`` 橋接之上提供新的便利命令:: je_auto_control.web_open("https://example.com") je_auto_control.web_screenshot("loaded.png") je_auto_control.web_quit() Executor:``AC_web_open / _quit / _screenshot / _current_url`` (加上既有的 ``AC_web_run``)。MCP 同步以 ``ac_web_*`` 暴露。 GUI:**WebRunner** 分頁。 Chat-ops 機器人 ---------------- 傳輸層中立的 ``CommandRouter`` 加上 Slack polling adapter, ``/run