fix: demo not showing panel; docs updated

This commit is contained in:
Simon
2026-01-21 00:44:09 +08:00
parent 22516dec74
commit efe131660a
4 changed files with 8 additions and 21 deletions

View File

@@ -72,28 +72,14 @@ const pageInfo = await this.pageController.getPageInfo()
3. **LLM Processing**: AI returns action plans (page-agent)
4. **Indexed Operations**: PageAgent calls PageController by element index
### IIFE Builds (`packages/page-agent/dist/iife/`)
Two IIFE builds for script tag usage:
| Build | File | Description |
| ----- | -------------------- | -------------------------------- |
| Demo | `page-agent.demo.js` | Auto-init with built-in test API |
| Full | `page-agent.js` | Exposes `PageAgent` class only |
Demo build supports query params (e.g., `?model=gpt-4&lang=en-US`).
Build with `npm run build:iife --workspace=page-agent`.
## Key Files Reference
### Page Agent (`packages/page-agent/`)
| File | Description |
| ------------------------ | -------------------------------------------- |
| ------------------ | -------------------------------------------- |
| `src/PageAgent.ts` | ⭐ Main class with UI, extends PageAgentCore |
| `src/entry-iife.ts` | IIFE entry (exposes PageAgent class) |
| `src/entry-iife-demo.ts` | IIFE demo entry (auto-init with demo API) |
| `src/demo.ts` | IIFE demo entry (auto-init with demo API) |
### Core (`packages/core/`)

View File

@@ -122,13 +122,13 @@ npm start
- Start and serve a local `iife` script
```bash
npm run dev:iife # Serving IIFE with auto rebuild at http://localhost:5174/page-agent.js
npm run dev:demo # Serving IIFE with auto rebuild at http://localhost:5174/page-agent.demo.js
```
- Add a new bookmark
```javascript
javascript:(function(){var s=document.createElement('script');s.src=`http://localhost:5174/page-agent.js?t=${Math.random()}`;s.onload=()=>console.log(%27PageAgent ready!%27);document.head.appendChild(s);})();
javascript:(function(){var s=document.createElement('script');s.src=`http://localhost:5174/page-agent.demo.js?t=${Math.random()}`;s.onload=()=>console.log(%27PageAgent ready!%27);document.head.appendChild(s);})();
```
- Click the bookmark on any page to load Page-Agent

View File

@@ -29,7 +29,7 @@
"build:website": "npm run build:website --workspace=@page-agent/website",
"build:libs": "npm run build --workspaces --if-present",
"build": "npm run build:libs && npm run build:website",
"dev:iife": "npm run dev:iife --workspace=page-agent",
"dev:demo": "npm run dev:demo --workspace=page-agent",
"version": "node scripts/sync-version.js",
"lint": "eslint .",
"prepare": "husky"

View File

@@ -41,6 +41,7 @@ setTimeout(() => {
// Create agent
window.pageAgent = new PageAgent(config)
window.pageAgent.panel.show()
console.log('🚀 page-agent.js initialized with config:', window.pageAgent.config)
})