feat: enable testing button

This commit is contained in:
Simon
2025-10-21 17:05:38 +08:00
parent f8caf352d2
commit 712f0bdf0a
3 changed files with 35 additions and 34 deletions

View File

@@ -13,6 +13,8 @@ The development progress and future plans for PageAgent.
- [x] **Remove ai-sdk** - Only one function is being used - [x] **Remove ai-sdk** - Only one function is being used
- [x] **Robust LLM output** - [x] **Robust LLM output**
- [x] **Working homepage with live LLM API** - [x] **Working homepage with live LLM API**
- [x] **~~free~~ CDN**
- [x] **Free evaluation plan?**
- [ ] **Hooks for Task and HITL** - [ ] **Hooks for Task and HITL**
- [ ] **Hijacking `page_open` event** - [ ] **Hijacking `page_open` event**
- [ ] **Custom knowledge base and instructions** - [ ] **Custom knowledge base and instructions**
@@ -20,8 +22,6 @@ The development progress and future plans for PageAgent.
- [ ] **Data-masking** - [ ] **Data-masking**
- [ ] **Custom actions** - [ ] **Custom actions**
- [ ] **Optimize for popular UI frameworks** - [ ] **Optimize for popular UI frameworks**
- [ ] **Free evaluation plan?**
- [ ] **free CDN**
- [ ] **Testing suits** - [ ] **Testing suits**
- [ ] **Support custom llm fetch** - [ ] **Support custom llm fetch**
- [ ] **Refactor: Separate Agent and Page-Controller** - Agent can run w/o dom - [ ] **Refactor: Separate Agent and Page-Controller** - Agent can run w/o dom

View File

@@ -7,12 +7,12 @@ import { PageAgent } from '@/PageAgent.js'
import Footer from './components/Footer' import Footer from './components/Footer'
import Header from './components/Header' import Header from './components/Header'
const injection = encodeURI( const DEMO_MODEL = 'PAGE-AGENT-FREE-TESTING-RANDOM'
"javascript:(function(){var s=document.createElement('script');s.src=`https://dev.g.alicdn.com/dt/page-use.js/0.0.1/lib/page-agent.umd.cjs?t=${Math.random()}`;s.setAttribute('crossorigin', true);s.onload=()=>console.log('PageAgent ready!');document.head.appendChild(s);})();" const DEMO_BASE_URL = 'https://hwcxiuzfylggtcktqgij.supabase.co/functions/v1/llm-testing-proxy'
) const DEMO_API_KEY = 'PAGE-AGENT-FREE-TESTING-RANDOM'
const injectionQwen = encodeURI( const injection = encodeURI(
"javascript:(function(){var s=document.createElement('script');s.src=`https://dev.g.alicdn.com/dt/page-use.js/0.0.1/lib/page-agent.umd.cjs?t=${Math.random()}&model=qwen-plus-latest`;s.setAttribute('crossorigin', true);s.onload=()=>console.log('PageAgent ready!');document.head.appendChild(s);})();" "javascript:(function(){var s=document.createElement('script');s.src=`https://hwcxiuzfylggtcktqgij.supabase.co/storage/v1/object/public/demo-public/v0.0.1/page-agent.js?t=${Math.random()}`;s.setAttribute('crossorigin', true);s.type=`text/javascript`;s.onload=()=>console.log('PageAgent script loaded!');document.body.appendChild(s);})();"
) )
const injectionA = ` const injectionA = `
@@ -20,19 +20,12 @@ const injectionA = `
href=${injection} href=${injection}
class="inline-flex items-center text-xs px-3 py-2 bg-blue-500 text-white font-medium rounded-lg hover:shadow-md transform hover:scale-105 transition-all duration-200 cursor-move border-2 border-dashed border-green-300" class="inline-flex items-center text-xs px-3 py-2 bg-blue-500 text-white font-medium rounded-lg hover:shadow-md transform hover:scale-105 transition-all duration-200 cursor-move border-2 border-dashed border-green-300"
draggable="true" draggable="true"
onclick="return false;"
title="拖拽我到收藏夹栏" title="拖拽我到收藏夹栏"
> >
✨PageAgent ✨PageAgent
</a> </a>
<a
href=${injectionQwen}
class="inline-flex items-center text-xs px-3 py-2 bg-purple-500 text-white font-medium rounded-lg hover:shadow-md transform hover:scale-105 transition-all duration-200 cursor-move border-2 border-dashed border-green-300"
draggable="true"
title="拖拽我到收藏夹栏"
>
✨PageAgent (Qwen)
</a>
` `
export default function HomePage() { export default function HomePage() {
@@ -58,9 +51,9 @@ export default function HomePage() {
// testing server // testing server
// @note: rate limit. prompt limit. // @note: rate limit. prompt limit.
model: 'PAGE-AGENT-FREE-TESTING-RANDOM', model: DEMO_MODEL,
baseURL: 'https://hwcxiuzfylggtcktqgij.supabase.co/functions/v1/llm-testing-proxy', baseURL: DEMO_BASE_URL,
apiKey: 'PAGE-AGENT-FREE-TESTING-RANDOM', apiKey: DEMO_API_KEY,
}) })
window.pageAgent = pageAgent window.pageAgent = pageAgent
} }
@@ -190,17 +183,17 @@ export default function HomePage() {
<span className="font-semibold"> 2:</span>{' '} <span className="font-semibold"> 2:</span>{' '}
</p> </p>
{/* <div <div
className="flex items-center justify-center gap-2 text-gray-500 dark:text-gray-400" className="flex items-center justify-center gap-2 text-gray-500 dark:text-gray-400"
dangerouslySetInnerHTML={{ __html: injectionA }} dangerouslySetInnerHTML={{ __html: injectionA }}
></div> */} ></div>
</div> </div>
{/* Usage Instructions */} {/* Usage Instructions */}
<div className="bg-purple-50 dark:bg-gray-700 p-4 rounded-lg"> <div className="bg-purple-50 dark:bg-gray-700 p-4 rounded-lg">
<p className="text-gray-700 dark:text-gray-300 text-sm"> <p className="text-gray-700 dark:text-gray-300 text-sm">
<span className="font-semibold"> 3:</span>{' '} <span className="font-semibold"> 3:</span>{' '}
使 使
</p> </p>
</div> </div>
</div> </div>
@@ -213,7 +206,15 @@ export default function HomePage() {
<ul className="space-y-2 text-sm text-gray-700 dark:text-gray-300"> <ul className="space-y-2 text-sm text-gray-700 dark:text-gray-300">
<li className="flex items-start text-left"> <li className="flex items-start text-left">
<span className="w-1.5 h-1.5 bg-yellow-500 rounded-full mt-2 mr-2 flex-shrink-0 "></span> <span className="w-1.5 h-1.5 bg-yellow-500 rounded-full mt-2 mr-2 flex-shrink-0 "></span>
</li>
<li className="flex items-start text-left">
<span className="w-1.5 h-1.5 bg-yellow-500 rounded-full mt-2 mr-2 flex-shrink-0 "></span>
使 DeepSeek DeepSeek
</li>
<li className="flex items-start text-left">
<span className="w-1.5 h-1.5 bg-yellow-500 rounded-full mt-2 mr-2 flex-shrink-0 "></span>
</li> </li>
<li className="flex items-start text-left"> <li className="flex items-start text-left">
<span className="w-1.5 h-1.5 bg-yellow-500 rounded-full mt-2 mr-2 flex-shrink-0 "></span> <span className="w-1.5 h-1.5 bg-yellow-500 rounded-full mt-2 mr-2 flex-shrink-0 "></span>
@@ -233,14 +234,6 @@ export default function HomePage() {
</Link> </Link>
</li> </li>
<li className="flex items-start text-left">
<span className="w-1.5 h-1.5 bg-yellow-500 rounded-full mt-2 mr-2 flex-shrink-0 "></span>
CSP
</li>
<li className="flex items-start text-left">
<span className="w-1.5 h-1.5 bg-yellow-500 rounded-full mt-2 mr-2 flex-shrink-0 "></span>
使 gpt-4.1-mini qwen
</li>
</ul> </ul>
</div> </div>
</div> </div>

View File

@@ -12,18 +12,26 @@ if (window.pageAgent) {
window.PageAgent = PageAgent window.PageAgent = PageAgent
// Export for ES module usage // Export for ES module usage
export { PageAgent } // export { PageAgent }
console.log('🚀 page-agent.js loaded!') console.log('🚀 page-agent.js loaded!')
const DEMO_MODEL = 'PAGE-AGENT-FREE-TESTING-RANDOM'
const DEMO_BASE_URL = 'https://hwcxiuzfylggtcktqgij.supabase.co/functions/v1/llm-testing-proxy'
const DEMO_API_KEY = 'PAGE-AGENT-FREE-TESTING-RANDOM'
const currentScript = document.currentScript as HTMLScriptElement | null const currentScript = document.currentScript as HTMLScriptElement | null
if (currentScript) { if (currentScript) {
console.log('🚀 page-agent.js detected current script:', currentScript.src)
const url = new URL(currentScript.src) const url = new URL(currentScript.src)
const model = url.searchParams.get('model') const model = url.searchParams.get('model') || DEMO_MODEL
const baseURL = url.searchParams.get('baseURL') || DEMO_BASE_URL
const apiKey = url.searchParams.get('apiKey') || DEMO_API_KEY
const language = (url.searchParams.get('lang') as 'zh-CN' | 'en-US') || 'zh-CN' const language = (url.searchParams.get('lang') as 'zh-CN' | 'en-US') || 'zh-CN'
const config = { model, language } as PageAgentConfig const config: PageAgentConfig = { model, baseURL, apiKey, language }
window.pageAgent = new PageAgent(config) window.pageAgent = new PageAgent(config)
} else { } else {
console.log('🚀 page-agent.js no current script detected, using default demo config')
window.pageAgent = new PageAgent() window.pageAgent = new PageAgent()
} }