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
+4
View File
@@ -156,6 +156,8 @@ export class PageAgent extends EventTarget {
let step = 0
while (true) {
if (this.config.onBeforeStep) await this.config.onBeforeStep.call(this, step)
console.group(`step: ${step + 1}`)
// abort
@@ -209,6 +211,8 @@ export class PageAgent extends EventTarget {
console.log(chalk.green('Step finished:'), actionName)
console.groupEnd()
if (this.config.onAfterStep) await this.config.onAfterStep.call(this, step, this.history)
step++
if (step > MAX_STEPS) {
this.#onDone('Step count exceeded maximum limit', false)