搜索

PythonReactSEOPDF
GitHub Skill

ax-provider-browser

Use when modifying browser automation providers — sandboxed Playwright, page snapshots, or element interaction in src/providers/browser/

project-ax☆ 2 仓库 Stars0 仓库 Forks

安装与使用

请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。

查看来源 ↗使用指南

技能说明

Overview

Browser providers handle sandboxed web automation, exposing structured commands (navigate, snapshot, click, type, screenshot) instead of raw JS execution. All page content is external and must be taint-tagged at the IPC boundary.

Interface

// src/providers/browser/types.ts
interface BrowserConfig {
  headless?: boolean;
  viewport?: { width?: number; height?: number };
}

interface BrowserSession { id: string; }

interface PageSnapshot {
  title: string;
  url: string;
  text: string;                                    // innerText, capped at 50k chars
  refs: { ref: number; tag: string; text: string }[];  // interactive elements, max 200
}

interface BrowserProvider {
  launch(config: BrowserConfig): Promise<BrowserSession>;
  navigate(session: string, url: string): Promise<void>;
  snapshot(session: string): Promise<PageSnapshot>;
  click(session: string, ref: number): Promise<void>;
  type(session: string, ref: number, text: string): Promise<void>;
  screenshot(session: string): Promise<Buffer>;
  close(session: string): Promise<void>;
}

Implementations

Name File Status
container src/providers/browser/container.ts Active -- sandboxed Playwright (Chromium); domain allowlist via AX_BROWSER_ALLOWED_DOMAINS env var; optional dep dynamically imported
none src/providers/browser/none.ts Stub -- returns disabledProvider() proxy; used when Playwright is not installed

Common Tasks: Adding a New Browser Provider

  1. Create src/providers/browser/<name>.ts exporting create(config: Config): Promise<BrowserProvider>.
  2. Implement all 7 methods from BrowserProvider. Use randomUUID() for session IDs.
  3. Cap text at MAX_TEXT_CHARS and refs at MAX_REFS in snapshot() to bound payload size.
  4. Add the entry to the static allowlist in src/host/provider-map.ts.
  5. Add tests in tests/providers/browser/<name>.test.ts.
  6. Use safePath() if the provider reads any files from config-derived paths.

Gotchas

  • Browser actions route through IPC. The agent never has direct browser access -- all calls go host-side via IPC actions. Page content returned to the agent must be taint-tagged as external.
  • Domain allowlist is enforced in navigate(). Set AX_BROWSER_ALLOWED_DOMAINS (comma-separated) to restrict navigation. When unset, all domains are allowed.
  • Playwright is optional. container.ts dynamically imports playwright and falls back to the none provider on import failure. Never add a top-level Playwright import.
  • No raw JS exposed to agent. page.evaluate() is used internally for snapshot extraction only -- the agent interface is structured commands (click(ref), type(ref, text)), not arbitrary script execution.
  • Ref indices are positional. refs[i] corresponds to the i-th element matching INTERACTIVE_SELECTOR at snapshot time. Refs are invalidated by any page mutation (navigation, click, type).

使用示例

查看来源仓库中的使用示例与配置说明。

查看来源 ↗

来源历史

收录时间
2026-03-11
索引更新时间
2026-03-11
Branch
main

收录与同步日期属于本站记录。源码修改历史请查看来源仓库。

GitHub ↗

chat Comments (0)

chat_bubble_outline

No comments yet. Be the first to share your thoughts!