feat: add hooks for step lifecycle

This commit is contained in:
Simon
2025-10-21 19:39:06 +08:00
parent 50ccd30433
commit 5716966b6d
3 changed files with 11 additions and 0 deletions
+6
View File
@@ -1,3 +1,4 @@
import type { AgentHistory, PageAgent } from '@/PageAgent'
import type { DomConfig } from '@/dom'
import type { SupportedLanguage } from '@/i18n'
import type { PageAgentTool } from '@/tools'
@@ -47,6 +48,11 @@ export interface UIConfig {
* }
*/
customTools?: Record<string, PageAgentTool | null>
// hooks
onBeforeStep?: (this: PageAgent, stepCnt: number) => Promise<void> | void
onAfterStep?: (this: PageAgent, stepCnt: number, history: AgentHistory[]) => Promise<void> | void
}
export type PageAgentConfig = LLMConfig & DomConfig & UIConfig