refactor(ext): improve folder structure

This commit is contained in:
Simon
2026-01-28 13:15:34 +08:00
parent e425a3ed9f
commit 55ffbb8f08
8 changed files with 31 additions and 39 deletions

View File

@@ -1,8 +1,8 @@
import { PageAgentConfig, PageAgentCore } from '@page-agent/core'
import { type PageAgentConfig, PageAgentCore } from '@page-agent/core'
import SYSTEM_PROMPT from '../prompts/system_prompt.md?raw'
import { RemotePageController } from './RemotePageController'
import { TabsController } from './TabsController'
import SYSTEM_PROMPT from './system_prompt.md?raw'
import { createTabTools } from './tabTools'
export class MultiPageAgent extends PageAgentCore {

View File

@@ -1,8 +1,6 @@
import type { BrowserState, PageController } from '@page-agent/page-controller'
import type { BrowserState } from '@page-agent/page-controller'
import { isContentScriptAllowed } from '@/utils'
import { TabsController } from './TabsController'
import type { TabsController } from './TabsController'
/**
* Agent side page controller.
@@ -168,3 +166,25 @@ interface DomActionReturn {
success: boolean
message: string
}
/**
* Check if a URL can run content scripts.
*/
export function isContentScriptAllowed(url: string | undefined): boolean {
if (!url) return false
const restrictedPatterns = [
/^chrome:\/\//,
/^chrome-extension:\/\//,
/^about:/,
/^edge:\/\//,
/^brave:\/\//,
/^opera:\/\//,
/^vivaldi:\/\//,
/^file:\/\//,
/^view-source:/,
/^devtools:\/\//,
]
return !restrictedPatterns.some((pattern) => pattern.test(url))
}

View File

@@ -92,7 +92,7 @@ You must call the `done` action in one of three cases:
- When you have fully completed the USER REQUEST.
- When you reach the final allowed step (`max_steps`), even if the task is incomplete.
- When you feel stuck or unable to solve user request. Or user request is not clear or contains inappropriate content.
- If it is ABSOLUTELY IMPOSSIBLE to continue.
- When it is ABSOLUTELY IMPOSSIBLE to continue.
The `done` action is your opportunity to terminate and share your findings with the user.
- Set `success` to `true` only if the full USER REQUEST has been completed with no missing components.

View File

@@ -2,10 +2,10 @@
* React hook for using AgentController
*/
import type { AgentActivity, AgentStatus, HistoricalEvent } from '@page-agent/core'
import type { LLMConfig } from '@page-agent/llms'
import { useCallback, useEffect, useRef, useState } from 'react'
import { LLMConfig } from '@/utils'
import { DEMO_API_KEY, DEMO_BASE_URL, DEMO_MODEL } from '@/utils/constants'
import { DEMO_API_KEY, DEMO_BASE_URL, DEMO_MODEL } from '@/agent/constants'
import { MultiPageAgent } from './MultiPageAgent'

View File

@@ -1,10 +1,10 @@
import type { LLMConfig } from '@page-agent/llms'
import { Loader2 } from 'lucide-react'
import { useEffect, useState } from 'react'
import { DEMO_API_KEY, DEMO_BASE_URL, DEMO_MODEL } from '@/agent/constants'
import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
import type { LLMConfig } from '@/utils'
import { DEMO_API_KEY, DEMO_BASE_URL, DEMO_MODEL } from '@/utils/constants'
interface ConfigPanelProps {
config: LLMConfig | null

View File

@@ -1,28 +0,0 @@
/**
* Check if a URL can run content scripts.
*/
export function isContentScriptAllowed(url: string | undefined): boolean {
if (!url) return false
const restrictedPatterns = [
/^chrome:\/\//,
/^chrome-extension:\/\//,
/^about:/,
/^edge:\/\//,
/^brave:\/\//,
/^opera:\/\//,
/^vivaldi:\/\//,
/^file:\/\//,
/^view-source:/,
/^devtools:\/\//,
]
return !restrictedPatterns.some((pattern) => pattern.test(url))
}
/** LLM configuration */
export interface LLMConfig {
apiKey: string
baseURL: string
model: string
}