From 3ce4d8e3fe9a49372104605458467818f250f940 Mon Sep 17 00:00:00 2001 From: Simon <10131203+gaomeng1900@users.noreply.github.com> Date: Mon, 19 Jan 2026 16:47:48 +0800 Subject: [PATCH] docs: update instructions. add `advanced` section --- AGENTS.md | 31 +- CONTRIBUTING.md | 7 +- README-zh.md | 3 +- README.md | 3 +- .../src/components/ui/api-reference.tsx | 167 +++++++ .../website/src/i18n/locales/en-US/common.ts | 4 +- .../website/src/i18n/locales/zh-CN/common.ts | 4 +- packages/website/src/pages/docs/Layout.tsx | 8 +- .../docs/advanced/page-agent-core/page.tsx | 465 ++++++++++++++++++ .../pages/docs/advanced/page-agent/page.tsx | 246 +++++++++ packages/website/src/pages/docs/index.tsx | 21 +- .../docs/integration/configuration/page.tsx | 199 -------- 12 files changed, 935 insertions(+), 223 deletions(-) create mode 100644 packages/website/src/components/ui/api-reference.tsx create mode 100644 packages/website/src/pages/docs/advanced/page-agent-core/page.tsx create mode 100644 packages/website/src/pages/docs/advanced/page-agent/page.tsx delete mode 100644 packages/website/src/pages/docs/integration/configuration/page.tsx diff --git a/AGENTS.md b/AGENTS.md index 5cc25a4..c2f688b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -4,11 +4,12 @@ This is a **monorepo** with npm workspaces: -- **Core Library** (`packages/page-agent/`) - AI agent for browser DOM automation, published as `page-agent` on npm +- **Page Agent** (`packages/page-agent/`) - Main entry with built-in UI Panel, published as `page-agent` on npm - **Website** (`packages/website/`) - React docs and landing page. **When working on website, follow `packages/website/AGENTS.md`** Internal packages: +- **Core** (`packages/core/`) - PageAgentCore without UI (npm: `@page-agent/core`) - **CDN** (`packages/cdn/`) - IIFE builds for script tag usage (npm: `@page-agent/cdn`) - **LLMs** (`packages/llms/`) - LLM client with reflection-before-action mental model - **Page Controller** (`packages/page-controller/`) - DOM operations and visual feedback (SimulatorMask), independent of LLM @@ -31,7 +32,8 @@ Simple monorepo solution: TypeScript references + Vite aliases. Update tsconfig ``` packages/ -├── page-agent/ # npm: "page-agent" ⭐ MAIN +├── page-agent/ # npm: "page-agent" ⭐ MAIN (with Panel UI) +├── core/ # npm: "@page-agent/core" (headless, no UI) ├── cdn/ # npm: "@page-agent/cdn" (IIFE builds) ├── website/ # @page-agent/website (private) ├── llms/ # @page-agent/llms @@ -43,9 +45,10 @@ packages/ ### Module Boundaries -- **Page Agent**: Core lib. Imports from `@page-agent/llms`, `@page-agent/page-controller`, `@page-agent/ui` +- **Page Agent**: Main entry with UI. Extends PageAgentCore and adds Panel. Imports from `@page-agent/core`, `@page-agent/ui` +- **Core**: PageAgentCore without UI. Imports from `@page-agent/llms`, `@page-agent/page-controller` - **LLMs**: LLM client with MacroToolInput contract. No dependency on page-agent -- **UI**: Panel and i18n. No dependency on page-agent +- **UI**: Panel and i18n. Decoupled from PageAgent via PanelAgentAdapter interface - **Page Controller**: DOM operations with optional visual feedback (SimulatorMask). No LLM dependency. Enable mask via `enableMask: true` config ### PageController ↔ PageAgent Communication @@ -86,11 +89,19 @@ Demo build supports query params (e.g., `?model=gpt-4&lang=en-US`). ### Page Agent (`packages/page-agent/`) -| File | Description | -| ------------------ | --------------------------------------- | -| `src/PageAgent.ts` | ⭐ Main AI agent class | -| `src/umd.ts` | CDN/UMD entry with auto-init | -| `src/tools/` | Tool definitions calling PageController | +| File | Description | +| ------------------ | ---------------------------------------------- | +| `src/PageAgent.ts` | ⭐ Main class with UI, extends PageAgentCore | +| `src/iife.ts` | IIFE/CDN entry | + +### Core (`packages/core/`) + +| File | Description | +| ----------------------- | ------------------------------------------- | +| `src/PageAgentCore.ts` | ⭐ Core agent class without UI | +| `src/tools/` | Tool definitions calling PageController | +| `src/config/` | Configuration types and constants | +| `src/prompts/` | System prompt templates | ### LLMs (`packages/llms/`) @@ -113,7 +124,7 @@ Demo build supports query params (e.g., `?model=gpt-4&lang=en-US`). ### New Agent Tool -1. Implement in `packages/page-agent/src/tools/index.ts` +1. Implement in `packages/core/src/tools/index.ts` 2. If tool needs DOM ops, add method to PageController first 3. Tool calls `this.pageController.methodName()` for DOM interactions diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2cdd2a4..500da7b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,10 +20,11 @@ Thank you for your interest in contributing to Page-Agent! We welcome contributi ### Project Structure -This is a **monorepo** with npm workspaces containing **two main packages**: +This is a **monorepo** with npm workspaces containing **3 main packages**: -1. **Core Library** (`packages/page-agent/`) - Pure JavaScript/TypeScript AI agent library for browser DOM automation, published as `page-agent` on npm -2. **Website** (`packages/website/`) - React documentation and landing page. Also as demo and test page for the core lib. private package `@page-agent/website` +- **Page Agent** (`packages/page-agent/`) - Main entry with built-in UI Panel, published as `page-agent` on npm +- **Core** (`packages/core/`) - Core agent logic without UI (npm: `@page-agent/core`) +- **Website** (`packages/website/`) - React documentation and landing page. Also as demo and test page for the core lib. private package `@page-agent/website` We use a simplified monorepo solution with `native npm-workspace + ts reference + vite alias`. No fancy tooling. Hoisting is required. diff --git a/README-zh.md b/README-zh.md index 4bf929f..c1655b8 100644 --- a/README-zh.md +++ b/README-zh.md @@ -76,7 +76,8 @@ PageAgent adopts a simplified monorepo structure: ``` packages/ -├── page-agent/ # AI agent (npm: page-agent) +├── page-agent/ # AI agent with UI Panel(npm: page-agent) +├── core/ # Agent core logic without UI(npm: @page-agent/core) ├── llms/ # LLM 客户端 (npm: @page-agent/llms) ├── page-controller/ # DOM 操作 & 蒙层 & 模拟鼠标 (npm: @page-agent/page-controller) ├── ui/ # 面板 & i18n (npm: @page-agent/ui) diff --git a/README.md b/README.md index 26518bf..fcccb86 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,8 @@ PageAgent adopts a simplified monorepo structure: ``` packages/ -├── page-agent/ # AI agent (npm: page-agent) +├── page-agent/ # AI agent with UI Panel(npm: page-agent) +├── core/ # Agent core logic without UI(npm: @page-agent/core) ├── llms/ # LLM client (npm: @page-agent/llms) ├── page-controller/ # DOM operations & Visual Mask (npm: @page-agent/page-controller) ├── ui/ # Panel & i18n (npm: @page-agent/ui) diff --git a/packages/website/src/components/ui/api-reference.tsx b/packages/website/src/components/ui/api-reference.tsx new file mode 100644 index 0000000..a505cd6 --- /dev/null +++ b/packages/website/src/components/ui/api-reference.tsx @@ -0,0 +1,167 @@ +/** + * API Reference component for displaying TypeScript interface definitions + * + * Provides a beautiful, readable table for documenting API interfaces + */ +import * as React from 'react' + +import { cn } from '@/lib/utils' + +import { Badge } from './badge' + +// ============================================================================ +// Types +// ============================================================================ + +export interface PropDefinition { + /** Property name */ + name: string + /** TypeScript type (can include generics, unions, etc.) */ + type: string + /** Whether the property is required */ + required?: boolean + /** Default value if any */ + defaultValue?: string + /** Description of the property */ + description: React.ReactNode + /** Mark as experimental/deprecated */ + status?: 'experimental' | 'deprecated' +} + +export interface APIReferenceProps { + /** Title for the API section */ + title?: string + /** Optional description */ + description?: React.ReactNode + /** Property definitions */ + properties: PropDefinition[] + /** Additional CSS classes */ + className?: string +} + +// ============================================================================ +// Component +// ============================================================================ + +export function APIReference({ title, description, properties, className }: APIReferenceProps) { + return ( +
+ {title && ( +

{title}

+ )} + {description && ( +

{description}

+ )} + +
+ + + + + + + + + + + {properties.map((prop) => ( + + ))} + +
+ Property + + Type + + Default + + Description +
+
+
+ ) +} + +function PropRow({ name, type, required, defaultValue, description, status }: PropDefinition) { + return ( + + {/* Property name */} + +
+ + {name} + + {required && ( + + required + + )} + {status === 'experimental' && ( + + experimental + + )} + {status === 'deprecated' && ( + + deprecated + + )} +
+ + + {/* Type */} + + + {type} + + + + {/* Default value */} + + {defaultValue ? ( + {defaultValue} + ) : ( + - + )} + + + {/* Description */} + {description} + + ) +} + +// ============================================================================ +// Utility Components +// ============================================================================ + +/** Code inline span for type references in descriptions */ +export function TypeRef({ children }: { children: React.ReactNode }) { + return ( + + {children} + + ) +} + +/** Section divider for grouping related APIs */ +export function APIDivider({ title }: { title: string }) { + return ( +
+
+ + {title} + +
+
+ ) +} diff --git a/packages/website/src/i18n/locales/en-US/common.ts b/packages/website/src/i18n/locales/en-US/common.ts index e43059a..8a3db3d 100644 --- a/packages/website/src/i18n/locales/en-US/common.ts +++ b/packages/website/src/i18n/locales/en-US/common.ts @@ -24,6 +24,7 @@ export default { introduction: 'Introduction', features: 'Features', integration: 'Integration', + advanced: 'Advanced', overview: 'Overview', quick_start: 'Quick Start', limitations: 'Limitations', @@ -32,9 +33,10 @@ export default { knowledge_injection: 'Instructions', data_masking: 'Data Masking', cdn_setup: 'CDN Setup', - configuration: 'Configuration', best_practices: 'Best Practices', third_party_agent: 'Third-party Agent', security_permissions: 'Security & Permissions', + page_agent: 'PageAgent', + page_agent_core: 'PageAgentCore', }, } diff --git a/packages/website/src/i18n/locales/zh-CN/common.ts b/packages/website/src/i18n/locales/zh-CN/common.ts index ed818d2..e0df8e1 100644 --- a/packages/website/src/i18n/locales/zh-CN/common.ts +++ b/packages/website/src/i18n/locales/zh-CN/common.ts @@ -23,6 +23,7 @@ export default { introduction: '介绍', features: '功能特性', integration: '集成指南', + advanced: '高级', overview: '概览', quick_start: '快速开始', limitations: '使用限制', @@ -31,9 +32,10 @@ export default { knowledge_injection: '知识注入', data_masking: '数据脱敏', cdn_setup: 'CDN 引入', - configuration: '配置选项', best_practices: '最佳实践', third_party_agent: '接入第三方 Agent', security_permissions: '安全与权限', + page_agent: 'PageAgent', + page_agent_core: 'PageAgentCore', }, } diff --git a/packages/website/src/pages/docs/Layout.tsx b/packages/website/src/pages/docs/Layout.tsx index 25838f9..36d2e6a 100644 --- a/packages/website/src/pages/docs/Layout.tsx +++ b/packages/website/src/pages/docs/Layout.tsx @@ -41,7 +41,6 @@ export default function DocsLayout({ children }: DocsLayoutProps) { { title: t('nav.integration'), items: [ - { title: t('nav.configuration'), path: '/integration/configuration' }, { title: t('nav.third_party_agent'), path: '/integration/third-party-agent' }, { title: t('nav.cdn_setup'), path: '/integration/cdn-setup' }, { @@ -51,6 +50,13 @@ export default function DocsLayout({ children }: DocsLayoutProps) { { title: '🚧 ' + t('nav.best_practices'), path: '/integration/best-practices' }, ], }, + { + title: t('nav.advanced'), + items: [ + { title: t('nav.page_agent'), path: '/advanced/page-agent' }, + { title: t('nav.page_agent_core'), path: '/advanced/page-agent-core' }, + ], + }, ] return ( diff --git a/packages/website/src/pages/docs/advanced/page-agent-core/page.tsx b/packages/website/src/pages/docs/advanced/page-agent-core/page.tsx new file mode 100644 index 0000000..179cc35 --- /dev/null +++ b/packages/website/src/pages/docs/advanced/page-agent-core/page.tsx @@ -0,0 +1,465 @@ +import { useTranslation } from 'react-i18next' + +import CodeEditor from '@/components/CodeEditor' +import { APIDivider, APIReference, TypeRef } from '@/components/ui/api-reference' + +export default function PageAgentCoreDocs() { + const { i18n } = useTranslation() + const isZh = i18n.language === 'zh-CN' + + return ( +
+

PageAgentCore

+ +

+ {isZh + ? 'PageAgentCore 是不带 UI 的核心 Agent 类。用于需要自定义 UI 或无头运行的场景。' + : 'PageAgentCore is the core Agent class without UI. Use it for custom UI or headless scenarios.'} +

+ + {/* When to use */} +
+

+ {isZh ? '何时使用 PageAgentCore' : 'When to Use PageAgentCore'} +

+
    +
  • {isZh ? '需要自定义 UI 界面' : 'Need a custom UI interface'}
  • +
  • {isZh ? '在自动化测试中无头运行' : 'Running headless in automated tests'}
  • +
  • + {isZh + ? '在非浏览器环境运行(需自定义 PageController)' + : 'Running in non-browser environments (requires custom PageController)'} +
  • +
  • + {isZh + ? '将 PageAgent 嵌入其他 Agent 系统' + : 'Embedding PageAgent in other agent systems'} +
  • +
+
+ + {/* Basic Usage */} +
+

{isZh ? '基本用法' : 'Basic Usage'}

+ { + console.log('Status:', agent.status) +}) + +agent.addEventListener('historychange', () => { + console.log('History:', agent.history) +}) + +agent.addEventListener('activity', (e) => { + const activity = (e as CustomEvent).detail + console.log('Activity:', activity.type) +}) + +// Execute task +const result = await agent.execute('Fill in the form with test data')`} + /> +
+ + + + {/* LLM Configuration */} +
+

LLMConfig

+

+ {isZh + ? '配置与大语言模型的连接参数。支持 OpenAI 兼容的 API。' + : 'Configure connection parameters for the language model. Supports OpenAI-compatible APIs.'} +

+ +
+ + {/* Agent Configuration */} +
+

AgentConfig

+

+ {isZh + ? '配置 Agent 的行为、生命周期钩子和扩展能力。' + : 'Configure agent behavior, lifecycle hooks, and extension capabilities.'} +

+ ', + status: 'experimental', + description: isZh + ? '自定义工具,可扩展或覆盖内置工具。设为 null 可移除工具。' + : 'Custom tools to extend or override built-in tools. Set to null to remove a tool.', + }, + { + name: 'instructions', + type: 'InstructionsConfig', + description: isZh + ? '指导 Agent 行为的指令配置' + : 'Instructions to guide agent behavior', + }, + { + name: 'transformPageContent', + type: '(content: string) => string | Promise', + description: isZh + ? '发送给 LLM 前转换页面内容,可用于数据脱敏' + : 'Transform page content before sending to LLM, useful for data masking', + }, + { + name: 'experimentalScriptExecutionTool', + type: 'boolean', + defaultValue: 'false', + status: 'experimental', + description: isZh + ? '启用实验性 JavaScript 执行工具' + : 'Enable experimental JavaScript execution tool', + }, + ]} + /> + +

InstructionsConfig

+ string | undefined | null', + description: isZh + ? '动态页面级指令回调,在每个步骤前调用' + : 'Dynamic page-level instructions callback, called before each step', + }, + ]} + /> +
+ + {/* Lifecycle Hooks */} +
+

{isZh ? '生命周期钩子' : 'Lifecycle Hooks'}

+ void | Promise', + description: isZh ? '每个步骤执行前调用' : 'Called before each step execution', + status: 'experimental', + }, + { + name: 'onAfterStep', + type: '(history: HistoricalEvent[]) => void | Promise', + description: isZh ? '每个步骤执行后调用' : 'Called after each step execution', + status: 'experimental', + }, + { + name: 'onBeforeTask', + type: '() => void | Promise', + description: isZh ? '任务开始前调用' : 'Called before task starts', + status: 'experimental', + }, + { + name: 'onAfterTask', + type: '(result: ExecutionResult) => void | Promise', + description: isZh ? '任务结束后调用' : 'Called after task ends', + status: 'experimental', + }, + { + name: 'onDispose', + type: '(reason?: string) => void', + description: isZh ? 'Agent 销毁时调用' : 'Called when agent is disposed', + status: 'experimental', + }, + ]} + /> +
+ + {/* PageController Configuration */} +
+

PageControllerConfig

+

+ {isZh + ? '配置 DOM 提取、元素交互和视觉反馈。' + : 'Configure DOM extraction, element interaction, and visual feedback.'} +

+ Element))[]', + description: isZh ? '要排除的交互元素列表' : 'Elements to exclude from interaction', + }, + { + name: 'interactiveWhitelist', + type: '(Element | (() => Element))[]', + description: isZh + ? '要强制包含的交互元素列表' + : 'Elements to force include for interaction', + }, + { + name: 'include_attributes', + type: 'string[]', + description: isZh + ? '在 DOM 提取中包含的额外属性' + : 'Additional attributes to include in DOM extraction', + }, + ]} + /> +
+ + + + {/* Properties */} +
+

{isZh ? '属性' : 'Properties'}

+ ', + description: isZh ? '可用工具的 Map' : 'Map of available tools', + }, + { + name: 'onAskUser', + type: '(question: string) => Promise', + description: isZh + ? 'Agent 需要用户输入时的回调。未设置则禁用 ask_user 工具。' + : 'Callback when agent needs user input. If not set, ask_user tool is disabled.', + }, + ]} + /> +
+ + {/* Methods */} +
+

{isZh ? '方法' : 'Methods'}

+ ', + description: isZh + ? '执行任务并返回结果。包含 success、data 和 history 字段。' + : 'Execute a task and return result. Contains success, data, and history fields.', + }, + { + name: 'pushObservation(content: string)', + type: 'void', + description: isZh + ? '向历史流推送一个观察事件,会在下一步时被 LLM 看到' + : 'Push an observation to history stream, will be seen by LLM in next step', + }, + { + name: 'emitActivity(activity: AgentActivity)', + type: 'void', + description: isZh + ? '发出活动事件用于 UI 反馈' + : 'Emit activity event for UI feedback', + }, + { + name: 'dispose(reason?: string)', + type: 'void', + description: isZh + ? '销毁 Agent 并清理资源' + : 'Dispose the agent and clean up resources', + }, + ]} + /> +
+ + {/* Events */} +
+

{isZh ? '事件' : 'Events'}

+

+ {isZh ? ( + <> + PageAgentCore 继承自 EventTarget,提供以下事件: + + ) : ( + <> + PageAgentCore extends EventTarget and provides the following + events: + + )} +

+ ', + description: isZh + ? '实时活动反馈(短暂状态,仅用于 UI)。类型包括:thinking, executing, executed, retrying, error' + : 'Real-time activity feedback (transient, UI only). Types: thinking, executing, executed, retrying, error', + }, + { + name: 'dispose', + type: 'Event', + description: isZh ? 'Agent 被销毁时触发' : 'Fired when agent is disposed', + }, + ]} + /> +
+ + + + {/* ExecutionResult */} +
+

ExecutionResult

+ +
+ + {/* AgentActivity */} +
+

AgentActivity

+ +
+ + {/* */} +
+ ) +} diff --git a/packages/website/src/pages/docs/advanced/page-agent/page.tsx b/packages/website/src/pages/docs/advanced/page-agent/page.tsx new file mode 100644 index 0000000..0aecff7 --- /dev/null +++ b/packages/website/src/pages/docs/advanced/page-agent/page.tsx @@ -0,0 +1,246 @@ +import { useTranslation } from 'react-i18next' +import { Link } from 'wouter' + +import CodeEditor from '@/components/CodeEditor' +import { APIReference, TypeRef } from '@/components/ui/api-reference' + +export default function PageAgentDocs() { + const { i18n } = useTranslation() + const isZh = i18n.language === 'zh-CN' + + return ( +
+

PageAgent

+ +

+ {isZh + ? 'PageAgent 是带有内置 UI 面板的完整 Agent 类。它继承自 PageAgentCore,并自动创建交互面板。' + : 'PageAgent is the complete Agent class with built-in UI panel. It extends PageAgentCore and automatically creates an interactive panel.'} +

+ + {/* When to use */} +
+

+ {isZh ? '何时使用 PageAgent' : 'When to Use PageAgent'} +

+

+ {isZh + ? '在大多数场景下,你应该使用 PageAgent。它提供了开箱即用的完整体验:' + : 'In most cases, you should use PageAgent. It provides a complete out-of-the-box experience:'} +

+
    +
  • + {isZh + ? '内置 UI 面板,显示任务进度、Agent 思考过程和操作结果' + : 'Built-in UI panel showing task progress, agent thinking, and action results'} +
  • +
  • + {isZh + ? '支持 ask_user 工具,Agent 可以向用户提问' + : 'Supports ask_user tool for agent to ask questions to users'} +
  • +
+
+ + {/* Basic Usage */} +
+

{isZh ? '基本用法' : 'Basic Usage'}

+ +
+ + {/* Class Definition */} +
+

{isZh ? '类定义' : 'Class Definition'}

+ +

+ {isZh ? ( + <> + PageAgent 继承自{' '} + + PageAgentCore + + ,所有核心方法和事件都可用。详细的 API 参考请查看 PageAgentCore 文档。 + + ) : ( + <> + PageAgent extends{' '} + + PageAgentCore + + . All core methods and events are available. See PageAgentCore docs for detailed API + reference. + + )} +

+
+ + {/* Configuration */} +
+

{isZh ? '配置' : 'Configuration'}

+

+ {isZh + ? 'PageAgent 使用与 PageAgentCore 相同的配置接口。' + : 'PageAgent uses the same configuration interface as PageAgentCore.'} +

+

+ {isZh ? ( + <> + 完整配置请参考{' '} + + PageAgentCore 配置文档 + + 。 + + ) : ( + <> + See{' '} + + PageAgentCore configuration docs + {' '} + for complete reference. + + )} +

+
+ + {/* Panel Property */} +
+

{isZh ? 'Panel 属性' : 'Panel Property'}

+

+ {isZh + ? 'PageAgent 自动创建一个 Panel 实例。你可以通过 panel 属性访问它来控制 UI:' + : 'PageAgent automatically creates a Panel instance. You can access it via the panel property to control the UI:'} +

+ + + +

{isZh ? 'Panel 方法' : 'Panel Methods'}

+ +
+ + {/* Comparison with PageAgentCore */} +
+

+ {isZh ? 'PageAgent vs PageAgentCore' : 'PageAgent vs PageAgentCore'} +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ {isZh ? '特性' : 'Feature'} + + PageAgent + + PageAgentCore +
+ {isZh ? 'UI 面板' : 'UI Panel'} + -
+ {isZh ? 'Headless 模式' : 'Headless Mode'} + -
+ {isZh ? '自定义 PageController' : 'Custom PageController'} +
+ {isZh ? '适用场景' : 'Use Case'} + + {isZh ? '网页集成' : 'Web integration'} + + {isZh ? '自定义 UI / 无头' : 'Custom UI / Headless'} +
+
+
+
+ ) +} diff --git a/packages/website/src/pages/docs/index.tsx b/packages/website/src/pages/docs/index.tsx index 75e45e7..d875ade 100644 --- a/packages/website/src/pages/docs/index.tsx +++ b/packages/website/src/pages/docs/index.tsx @@ -3,6 +3,9 @@ import { Route, Switch } from 'wouter' import Header from '../../components/Header' import DocsLayout from './Layout' +import PageAgentCoreDocs from './advanced/page-agent-core/page' +// Advanced +import PageAgentDocs from './advanced/page-agent/page' import Instructions from './features/custom-instructions/page' // Features import CustomTools from './features/custom-tools/page' @@ -11,7 +14,6 @@ import Models from './features/models/page' import BestPractices from './integration/best-practices/page' // Integration import CdnSetup from './integration/cdn-setup/page' -import Configuration from './integration/configuration/page' import SecurityPermissions from './integration/security-permissions/page' import ThirdPartyAgent from './integration/third-party-agent/page' import Limitations from './introduction/limitations/page' @@ -83,11 +85,6 @@ export default function DocsRouter() { - - - - - @@ -99,6 +96,18 @@ export default function DocsRouter() { + {/* Advanced */} + + + + + + + + + + + {/* Default redirect or 404 */} diff --git a/packages/website/src/pages/docs/integration/configuration/page.tsx b/packages/website/src/pages/docs/integration/configuration/page.tsx deleted file mode 100644 index 491c7f6..0000000 --- a/packages/website/src/pages/docs/integration/configuration/page.tsx +++ /dev/null @@ -1,199 +0,0 @@ -import { useTranslation } from 'react-i18next' - -import CodeEditor from '@/components/CodeEditor' - -export default function Configuration() { - const { i18n } = useTranslation() - const isZh = i18n.language === 'zh-CN' - - return ( -
-

{isZh ? '配置选项' : 'Configuration'}

- -

- {isZh - ? 'PageAgent 的完整配置接口定义。' - : 'Complete configuration interface for PageAgent.'} -

- - {/* LLM Configuration */} -
-

{isZh ? 'LLM 配置' : 'LLM Configuration'}

-

- {isZh - ? '配置与大语言模型的连接参数。' - : 'Configure connection parameters for the language model.'} -

- -
- - {/* Agent Configuration */} -
-

- {isZh ? 'Agent 配置' : 'Agent Configuration'} -

-

- {isZh - ? '配置 Agent 的行为、生命周期钩子和扩展能力。' - : 'Configure agent behavior, lifecycle hooks, and extension capabilities.'} -

- - - /** Instructions to guide the agent's behavior */ - instructions?: { - /** Global system-level instructions, applied to all tasks */ - system?: string - - /** Dynamic page-level instructions callback */ - getPageInstructions?: (url: string) => string | undefined | null - } - - // Lifecycle hooks (with \`this\` bound to PageAgent instance) - onBeforeStep?: (this: PageAgent, stepCnt: number) => Promise | void - onAfterStep?: (this: PageAgent, stepCnt: number, history: HistoryEvent[]) => Promise | void - onBeforeTask?: (this: PageAgent) => Promise | void - onAfterTask?: (this: PageAgent, result: ExecutionResult) => Promise | void - onDispose?: (this: PageAgent, reason?: string) => void - - /** - * Transform page content before sending to LLM. - * Use cases: inspect extraction results, modify page info, mask sensitive data. - */ - transformPageContent?: (content: string) => Promise | string - - /** @experimental Enable JavaScript execution tool */ - experimentalScriptExecutionTool?: boolean -}`} - /> -
- - {/* PageController Configuration */} -
-

- {isZh ? 'PageController 配置' : 'PageController Configuration'} -

-

- {isZh - ? '配置 DOM 提取、元素交互和视觉高亮的细节。' - : 'Configure DOM extraction, element interaction, and visual highlighting.'} -

- Element))[] - - /** Elements to force include for interaction */ - interactiveWhitelist?: (Element | (() => Element))[] - - /** Additional attributes to include in DOM extraction */ - include_attributes?: string[] - - /** Highlight overlay opacity (0-1) */ - highlightOpacity?: number - - /** Highlight label opacity (0-1) */ - highlightLabelOpacity?: number -} - -interface PageControllerConfig extends DomConfig { - /** Viewport expansion in pixels */ - viewportExpansion?: number - - /** Enable visual mask overlay during operations (default: false) */ - enableMask?: boolean -}`} - /> -
- - {/* Complete Type */} -
-

{isZh ? '完整类型' : 'Complete Type'}

- -
- - {/* Programmatic Usage Example */} -
-

- {isZh ? '程序化使用配置' : 'Programmatic Usage'} -

-

- {isZh - ? '对于程序化集成场景,可以禁用 UI。' - : 'For programmatic integration, you can disable UI.'} -

- -
-
- ) -}