Computer use agents

From findscripter/everything-skills · View interactive version

Computer use agents is an AI agent skill from the GitHub repository findscripter/everything-skills. 当需要构建像人一样看屏幕、移鼠标、点击、输入的计算机操作型智能体时使用;做感知-推理-执行循环、Docker 沙箱隔离、敏感操作确认、动作日志与成本/上下文控制的可落地方案(含 Anthropic Computer Use、Playwright 浏览器自动化);不适用于纯文本/纯 API 任务,也不适用于直接在真实主机上裸跑智能体。触发词:computer use、桌面自动化、屏幕控制 AI、视觉智能体、浏览器智能体、GUI 自动化、Operator

How to use this skill

Skill file

何时使用

需要构建「像人一样操作计算机」的智能体:截屏看界面、移动光标、点击按钮、键盘输入,覆盖 Anthropic Computer Use、OpenAI Operator/CUA 及开源方案。典型场景:

不该用:

步骤

  1. 搭好感知-推理-执行循环:截屏 → 视觉模型决策 → 执行动作 → 观察结果,循环至完成。必须设 max_steps(建议 50)防失控。
  2. 用 Docker 沙箱隔离运行:非 root 用户、--cap-drop ALL、网络白名单或 --network none、只读根文件系统、CPU/内存/超时上限。
  3. 选实现方式:全桌面控制用 Anthropic Computer Use(带 betas=["computer-use-2024-10-22"],screenshot/mouse/keyboard/bash/text_editor 工具);纯网页用 Playwright 走可访问性树 + 可交互元素列表,更快更省更准。
  4. 在敏感动作前加确认门(ConfirmationGate):按 LOW/MEDIUM/HIGH/CRITICAL 分级,购买、登录、输密码、转账等强制人工确认。
  5. 全程动作日志:时间戳、动作参数(脱敏)、前后截图、成败、模型推理,落 JSONL,便于审计与回放。
  6. 控成本与上下文:降分辨率(1280×800 或更低)、必要时 JPEG、裁剪、按需才传截图;只保留近 N 张截图,长任务做 checkpoint 或拆子任务。

指令

docker run -it --rm \
    --security-opt no-new-privileges \
    --cap-drop ALL \
    --network none \
    --read-only \
    --tmpfs /tmp \
    --memory 2g --cpus 1 \
    computer-use-sandbox

示例

最小感知-推理-执行循环(pyautogui 版要点):

class ComputerUseAgent:
    def __init__(self, client, model="claude-sonnet-4-20250514"):
        self.client, self.model = client, model
        self.max_steps, self.action_delay = 50, 0.5

    def capture_screenshot(self):
        s = pyautogui.screenshot().resize((1280, 800), Image.LANCZOS)
        buf = io.BytesIO(); s.save(buf, format="PNG")
        return base64.b64encode(buf.getvalue()).decode()

    def run(self, task):
        # 每步:截屏 -> 带图发模型 -> 解析 JSON 动作 -> 执行 -> sleep
        # 动作类型: click / type / key / scroll / done
        ...

浏览器结构化方案(Playwright)核心:用 page.accessibility.snapshot() + querySelectorAll('a,button,input,select,textarea,[role="button"]') 取可交互元素(截断前 50 个省 token),喂给模型按 id>name>class>文本 选 CSS 选择器执行 navigate/click/type/extract。

人性化抗检测(视觉智能体会精准点中心,易被反爬识别):

def humanized_click(x, y):
    return x + int(random.gauss(0, 5)), y + int(random.gauss(0, 5))
def humanized_delay():
    d = random.uniform(0.3, 0.8)
    if random.random() < 0.2: d += random.uniform(0.5, 2.0)
    time.sleep(d)

注意事项

互见


采编自 sickn33/antigravity-awesome-skills(MIT)。

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.