import { siChromewebstore, siGithub } from 'simple-icons' import CodeEditor from '@/components/CodeEditor' import { useLanguage } from '@/i18n/context' export default function ChromeExtension() { const { isZh } = useLanguage() const chromeWebStoreUrl = 'https://chromewebstore.google.com/detail/page-agent-ext/akldabonmimlicnjlflnapfeklbfemhj' const githubReleasesUrl = 'https://github.com/alibaba/page-agent/releases' return (

{isZh ? 'Chrome 扩展' : 'Chrome Extension'}

{isZh ? '可选的 Chrome 扩展。PageAgent.js 继续负责页面内自动化;扩展 API 额外提供多页面任务、浏览器级控制,以及从浏览器外部发起任务的能力。' : 'An optional Chrome extension. PageAgent.js keeps handling in-page automation, while the extension API adds multi-page tasks, browser-level control, and tasks initiated from outside the browser.'}

{/* Features */}

{isZh ? '核心特性' : 'Key Features'}

🔓 {isZh ? '多页任务' : 'Multi-Page Tasks'}

{isZh ? '跨多个页面和标签页连续执行任务,不再受限于单页上下文。' : 'Run tasks across multiple pages and tabs without being limited to a single page context.'}

🧭 {isZh ? '浏览器级控制' : 'Browser-Level Control'}

{isZh ? '支持跨标签导航、页面切换和更完整的浏览器自动化能力。' : 'Enable richer browser automation, including cross-tab navigation and page switching.'}

🔌 {isZh ? '开放集成接口' : 'Open Integration API'}

{isZh ? '用户主动授权后,页面 JS、本地 Agent 或云端 Agent 可通过扩展发起多页面任务。' : 'With explicit user authorization, page JS, local agents, or cloud agents can trigger multi-page tasks through the extension.'}

{/* Install */}

{isZh ? '获取扩展' : 'Get the Extension'}

{isZh ? '从 Chrome 应用商店安装' : 'Install from Chrome Web Store'} {isZh ? 'GitHub Releases(更新版本)' : 'GitHub Releases (faster updates)'}
{/* Relationship with PageAgent.js */}

{isZh ? '与 PageAgent.js 的关系' : 'How It Relates to PageAgent.js'}

{isZh ? 'PageAgent.js 本身即可在页面内完成自动化。Chrome 扩展是可选的能力扩展。' : 'PageAgent.js already works for in-page automation. The Chrome extension is optional, not a dependency.'}

{isZh ? '通过扩展,你可以执行多页面任务、控制浏览器,以及从浏览器外部(本地服务或云端服务)发起任务。' : 'With the extension, you can perform multi-page tasks, browser-level control, and tasks triggered outside the browser (local or cloud services).'}

{/* Third-party Integration */}

{isZh ? '第三方接入' : 'Third-Party Integration'}

{isZh ? '通过页面 JavaScript 调用 `window.PAGE_AGENT_EXT`,你的应用可以发起跨页面任务并控制浏览器行为。' : 'By calling `window.PAGE_AGENT_EXT` from page JavaScript, your app can trigger multi-page tasks and control browser behavior.'}

{isZh ? '授权与安全' : 'Authorization and Security'}

{isZh ? '扩展权限范围较广(例如页面访问、导航、多标签控制)。若被滥用,可能危害用户隐私。为此,调用能力由 Token 保护,用户必须主动将 Token 提供给其信任的应用。' : 'The extension has broad permissions (such as page access, navigation, and multi-tab control). If abused, it can harm user privacy. That is why access is protected by a token, and users must actively share the token only with applications they trust.'}

')` : `// 1) Get auth token from the extension side panel // 2) Set it only in trusted applications // 3) After token match, extension exposes window.PAGE_AGENT_EXT // ⚠️ Never provide the token to untrusted pages or scripts localStorage.setItem('PageAgentExtUserAuthToken', '')` } language="javascript" />
{/* API Reference */}

{isZh ? 'API 参考' : 'API Reference'}

{/* AI Assistant Instructions */}

🤖 {isZh ? '给 AI 编程助手的文档' : 'Instructions for Your AI Assistant'}

{isZh ? '如果你在使用 AI 编程助手(如 Cursor、GitHub Copilot),可以将以下文档链接提供给它,让它更好地理解和使用 Page Agent 扩展 API:' : 'If you are using an AI coding assistant (like Cursor, GitHub Copilot), share these documentation links with it for better understanding of Page Agent Extension API:'}

📄 {isZh ? 'API 文档' : 'API Documentation'}
{/* TypeScript Declaration */}

{isZh ? 'TypeScript 类型声明' : 'TypeScript Declaration'}

{isZh ? '推荐把 `execute` 的类型声明加入你的项目,获得完整类型提示。' : 'Add this `execute` declaration to your project for full type support.'}

void onActivity?: (activity: AgentActivity) => void onHistoryUpdate?: (history: HistoricalEvent[]) => void } type Execute = (task: string, config: ExecuteConfig) => Promise declare global { interface Window { PAGE_AGENT_EXT_VERSION?: string PAGE_AGENT_EXT?: { version: string execute: Execute stop: () => void } } }` : `import type { AgentActivity, AgentStatus, ExecutionResult, HistoricalEvent } from '@page-agent/core' interface ExecuteConfig { baseURL: string // LLM API endpoint apiKey: string // API key model: string // Model name includeInitialTab?: boolean onStatusChange?: (status: AgentStatus) => void onActivity?: (activity: AgentActivity) => void onHistoryUpdate?: (history: HistoricalEvent[]) => void } type Execute = (task: string, config: ExecuteConfig) => Promise declare global { interface Window { PAGE_AGENT_EXT_VERSION?: string PAGE_AGENT_EXT?: { version: string execute: Execute stop: () => void } } }` } language="typescript" />

PAGE_AGENT_EXT.execute(task, config)

console.log('状态变化:', status), onActivity: activity => console.log('活动:', activity), onHistoryUpdate: history => console.log('历史更新:', history) } ) console.log(result) // 任务执行结果` : `// Execute a task with configuration const result = await window.PAGE_AGENT_EXT.execute( 'Search for "page-agent" on GitHub and open the first result', { baseURL: 'https://api.openai.com/v1', apiKey: 'your-api-key', model: 'gpt-5.2', // includeInitialTab: false, // Set to false to exclude initial tab onStatusChange: status => console.log('Status change:', status), onActivity: activity => console.log('Activity:', activity), onHistoryUpdate: history => console.log('History update:', history) } ) console.log(result) // Task execution result` } language="javascript" />

PAGE_AGENT_EXT.stop()

{isZh ? '停止当前正在运行的任务。' : 'Stop the current running task.'}

{/* Integration Guide */}

{isZh ? '将 MultiPageAgent 集成你自己的插件' : 'Integrate MultiPageAgent into Your Extension'}

@TODO

{isZh ? '建议先阅读扩展 API 文档,再参考 background entry implementation。' : 'Start with the extension API docs, then use the background entry implementation as a reference.'} packages/extension/src/entrypoints/background.ts

) }