← 提示词库 OpenAI/Codex/control-chrome.md 原文 md
🌐 中英双语对照

name: control-chrome
description: "Control the user's Chrome browser for tasks that depend on existing Chrome state: tabs, logged-in sessions, cookies, or extensions. Prefer purpose-built connectors, APIs, or CLIs when available."

Chrome

Use this skill when the user mentions @chrome.

当用户提及 @chrome 时使用本 skill。

Use Chrome when the task requires the user's existing Chrome profile state or the user explicitly requests Chrome. Do not switch to Chrome solely because a preferred connector, API, or CLI has missing or expired authentication. Ask the user to fix authentication or explicitly approve Chrome as a fallback.

当任务需要用户既有的 Chrome 配置状态,或用户明确要求使用 Chrome 时,使用 Chrome。不要仅因为首选的连接器、API 或 CLI 缺少或已过期认证就切换到 Chrome。应请用户修复认证,或明确批准以 Chrome 作为后备方案。

Chrome is the routing touchpoint for the Codex Chrome Extension:

Chrome 是 Codex Chrome 扩展的路由接触点:

Start with the directions in the Bootstrap section below. Use await agent.documentation.get("<name>") when you need information about the specific topic they cover:

从下方 Bootstrap 章节的指引开始。当你需要某个专题的信息时,使用 await agent.documentation.get("<name>"):

For example, this will give you guidance about confirmations:

例如,下面的调用会给你关于确认(confirmations)的指引:

console.log(await agent.documentation.get("confirmations"));

Bootstrap / 引导启动

These setup details are internal. User-facing progress updates should be less technical in nature. Never mention Node REPL, node_repl, REPL, JavaScript sessions, module exports, reading documentation, or loading instructions unless a user is asking for that exact information. If setup or recovery is needed, describe it naturally as connecting to the browser or retrying the browser connection.

这些安装细节属于内部信息。面向用户的进度更新不应过于技术化。除非用户明确询问该信息,否则绝不提及 Node REPL、node_repl、REPL、JavaScript 会话、模块导出、阅读文档或加载指令等字眼。如果需要安装或恢复,自然地将其描述为"正在连接浏览器"或"正在重试浏览器连接"。

The browser-client module is the core entry point for browser use, and is available under scripts/browser-client.mjs in this plugin's root directory. ALWAYS import it using an absolute path.

browser-client 模块是浏览器使用的核心入口,位于本插件根目录下的 scripts/browser-client.mjs。必须始终使用绝对路径导入它。

IMPORTANT: If this path cannot be found, stop and report that this plugin is missing scripts/browser-client.mjs. NEVER use the built in browser-client library.

重要:如果找不到该路径,停止并报告本插件缺少 scripts/browser-client.mjs。绝不使用内置的 browser-client 库。

Run browser setup code through the Node REPL js tool. In this environment the callable tool id typically appears as mcp__node_repl__js. If it is not already available, use tool discovery for node_repl js without setting a result limit. You need the js execution tool: js_reset only clears state, and js_add_node_module_dir only changes package resolution. Do not call either helper while trying to expose js. If js is still not available, search again for node_repl js with limit: 10. Run this once per fresh node_repl session:

通过 Node REPL 的 js 工具运行浏览器安装代码。在此环境中,可调用工具的 id 通常显示为 mcp__node_repl__js。如果它尚不可用,使用工具发现搜索 node_repl js,且不设置结果数量上限。你需要的是 js 执行工具:js_reset 只会清除状态,js_add_node_module_dir 只会更改包解析。在尝试暴露 js 时不要调用这两个辅助工具。如果 js 仍不可用,以 limit: 10 再次搜索 node_repl js。每个全新的 node_repl 会话运行一次以下代码:

const { setupBrowserRuntime } = await import("<plugin root>/scripts/browser-client.mjs");
await setupBrowserRuntime({ globals: globalThis });
globalThis.browser = await agent.browsers.get("extension");
nodeRepl.write(await browser.documentation());

Use the browser bound to browser for tasks in this skill.

在本 skill 的任务中使用绑定到 browser 的浏览器。

The ability to interact directly with the browser is exposed through the browser-client runtime via the agent.browsers.* API. Before trying to interact with it, you MUST emit and read the complete documentation returned by await browser.documentation() in one go. For the initial documentation read, run the exact direct call nodeRepl.write(await browser.documentation()); shown above. Do not assign the documentation to a variable, inspect its length, slice it, truncate it, summarize it, or emit only an excerpt. Do not proactively split the documentation into pages or chunks. Only if the tool output itself explicitly reports that it was truncated may you emit and read smaller chunks until you have read the documentation in its entirety.

与浏览器直接交互的能力由 browser-client 运行时通过 agent.browsers.* API 暴露。在尝试与之交互之前,你必须一次性完整输出并阅读 await browser.documentation() 返回的全部文档。首次阅读文档时,运行上面展示的精确直接调用 nodeRepl.write(await browser.documentation());。不要把文档赋值给变量、检查其长度、切片、截断、总结,或只输出摘录。不要主动把文档拆分为多页或多个块。只有当工具输出本身明确报告被截断时,才可以分块输出并阅读,直到完整读完文档为止。

Only the Node REPL js tool (mcp__node_repl__js) can be used to control the Chrome extension. Do not use external MCP browser-control tools, separate browser automation servers, or other browser skills for this surface. References to Playwright mean the in-skill tab.playwright API after browser-client setup.

只有 Node REPL 的 js 工具(mcp__node_repl__js)可用于控制 Chrome 扩展。在此入口上不要使用外部 MCP 浏览器控制工具、独立的浏览器自动化服务器或其他浏览器 skill。文中提到的 Playwright 均指 browser-client 安装完成后的 skill 内 tab.playwright API。

Tab Management / 标签页管理

Session Naming / 会话命名

Tab Claiming / 标签页认领

Tab Cleanup / 标签页清理

API Use Behavior / API 使用行为

How to use the API / 如何使用该 API

General guidance / 通用指引

Browser Safety / 浏览器安全

【评论】该条款把"是否传输"的决定锚定在用户初始提示的明确授权上,属于典型的提示词注入防御:防止网页内容诱导浏览器外发数据。

Chrome Safety / Chrome 安全