chore: clean up
This commit is contained in:
@@ -223,7 +223,7 @@ export class PageAgentCore extends EventTarget {
|
||||
|
||||
await onBeforeStep?.(this, step)
|
||||
|
||||
// observe (update browser state and other observations)
|
||||
// observe
|
||||
|
||||
console.log(chalk.blue.bold('👀 Observing...'))
|
||||
|
||||
@@ -249,7 +249,7 @@ export class PageAgentCore extends EventTarget {
|
||||
normalizeResponse,
|
||||
})
|
||||
|
||||
// assemble history event
|
||||
// assemble history
|
||||
|
||||
const macroResult = result.toolResult as MacroToolResult
|
||||
const input = macroResult.input
|
||||
@@ -362,7 +362,7 @@ export class PageAgentCore extends EventTarget {
|
||||
// abort
|
||||
if (this.#abortController.signal.aborted) throw new Error('AbortError')
|
||||
|
||||
console.log(chalk.blue.bold('MacroTool execute'), input)
|
||||
console.log(chalk.blue.bold('MacroTool input'), input)
|
||||
const action = input.action
|
||||
|
||||
const toolName = Object.keys(action)[0]
|
||||
@@ -383,7 +383,7 @@ export class PageAgentCore extends EventTarget {
|
||||
|
||||
// Find the corresponding tool
|
||||
const tool = tools.get(toolName)
|
||||
assert(tool, `Tool ${toolName} not found. (@note should have been caught before this!!!)`)
|
||||
assert(tool, `Tool ${toolName} not found`)
|
||||
|
||||
console.log(chalk.blue.bold(`Executing tool: ${toolName}`), toolInput)
|
||||
|
||||
|
||||
@@ -2,28 +2,6 @@ import chalk from 'chalk'
|
||||
|
||||
export { normalizeResponse } from './autoFixer'
|
||||
|
||||
/**
|
||||
* Wait until condition becomes true
|
||||
* @returns Returns when condition becomes true, throws otherwise
|
||||
* @param timeout Timeout in milliseconds, default 0 means no timeout, throws error on timeout
|
||||
*/
|
||||
export async function waitUntil(check: () => boolean, timeout = 60 * 60_1000): Promise<boolean> {
|
||||
if (check()) return true
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const start = Date.now()
|
||||
const interval = setInterval(() => {
|
||||
if (check()) {
|
||||
clearInterval(interval)
|
||||
resolve(true)
|
||||
} else if (Date.now() - start > timeout) {
|
||||
clearInterval(interval)
|
||||
reject(new Error('Timeout waiting for condition to become true'))
|
||||
}
|
||||
}, 100)
|
||||
})
|
||||
}
|
||||
|
||||
export async function waitFor(seconds: number): Promise<void> {
|
||||
await new Promise((resolve) => setTimeout(resolve, seconds * 1000))
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ export function useAgent(): UseAgentResult {
|
||||
|
||||
const execute = useCallback(async (task: string) => {
|
||||
const agent = agentRef.current
|
||||
console.log('Fire task:', task, agent)
|
||||
console.log('🚀 [useAgent] start executing task:', task)
|
||||
if (!agent) throw new Error('Agent not initialized')
|
||||
|
||||
setCurrentTask(task)
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
export { Panel, type PanelConfig } from './panel/Panel'
|
||||
export type { AgentActivity, PanelAgentAdapter } from './panel/types'
|
||||
export { I18n, type SupportedLanguage, type TranslationKey } from './i18n'
|
||||
|
||||
Reference in New Issue
Block a user