{"version":3,"file":"agent/agents/navigator.mjs","sources":["webpack://@agent-infra/browser-use/./src/agent/agents/navigator.ts"],"sourcesContent":["/**\n * The following code is modified based on\n * https://github.com/nanobrowser/nanobrowser/blob/master/chrome-extension/src/background/agent/agents/navigator.ts\n *\n * Apache-2.0 License\n * Copyright (c) 2024 alexchenzl\n * https://github.com/nanobrowser/nanobrowser/blob/master/LICENSE\n */\nimport { z } from 'zod';\nimport {\n  BaseAgent,\n  type BaseAgentOptions,\n  type ExtraAgentOptions,\n} from './base';\nimport { ActionResult, type AgentOutput } from '../types';\nimport type { Action } from '../actions/builder';\nimport { buildDynamicActionSchema } from '../actions/builder';\nimport { agentBrainSchema } from '../types';\nimport { type BaseMessage, HumanMessage } from '@langchain/core/messages';\nimport { Actors, ExecutionState } from '../event/types';\nimport { isAuthenticationError, createLogger } from '../../utils';\nimport { ChatModelAuthError } from './errors';\nimport { jsonNavigatorOutputSchema } from '../actions/json_schema';\nimport { geminiNavigatorOutputSchema } from '../actions/json_gemini';\nimport { jsonrepair } from 'jsonrepair';\nconst logger = createLogger('NavigatorAgent');\n\nexport class NavigatorActionRegistry {\n  private actions: Record<string, Action> = {};\n\n  constructor(actions: Action[]) {\n    for (const action of actions) {\n      this.registerAction(action);\n    }\n  }\n\n  registerAction(action: Action): void {\n    this.actions[action.name()] = action;\n  }\n\n  unregisterAction(name: string): void {\n    delete this.actions[name];\n  }\n\n  getAction(name: string): Action | undefined {\n    return this.actions[name];\n  }\n\n  setupModelOutputSchema(): z.ZodType {\n    const actionSchema = buildDynamicActionSchema(Object.values(this.actions));\n    return z.object({\n      current_state: agentBrainSchema,\n      action: z.array(actionSchema),\n    });\n  }\n}\n\nexport interface NavigatorResult {\n  done: boolean;\n}\n\nexport class NavigatorAgent extends BaseAgent<z.ZodType, NavigatorResult> {\n  private actionRegistry: NavigatorActionRegistry;\n\n  constructor(\n    actionRegistry: NavigatorActionRegistry,\n    options: BaseAgentOptions,\n    extraOptions?: Partial<ExtraAgentOptions>,\n  ) {\n    super(actionRegistry.setupModelOutputSchema(), options, {\n      ...extraOptions,\n      id: 'navigator',\n    });\n\n    this.actionRegistry = actionRegistry;\n  }\n\n  async invoke(inputMessages: BaseMessage[]): Promise<this['ModelOutput']> {\n    logger.info('invoke this.chatLLM', this.withStructuredOutput);\n    // Use structured output\n    if (this.withStructuredOutput) {\n      // For Google Generative AI, we need to use the modelOutputSchema directly\n      // but make sure it doesn't have any 'default' properties that cause issues\n\n      const schema =\n        this.chatModelLibrary === 'ChatGoogleGenerativeAI'\n          ? geminiNavigatorOutputSchema\n          : jsonNavigatorOutputSchema;\n\n      // TODO: don't know why zod can not generate the same schema. Use the json schema exported from browser-use as a workaround for now, need to fix it\n      const structuredLlm = this.chatLLM.withStructuredOutput(schema, {\n        includeRaw: true,\n      });\n\n      console.log('structuredLlm', structuredLlm);\n\n      const response = await structuredLlm.invoke(inputMessages, {\n        ...this.callOptions,\n      });\n      logger.info('invoke structuredLlm response', response);\n\n      if (response.parsed) {\n        return response.parsed;\n      } else {\n        return response.raw;\n      }\n      // throw new Error('Could not parse response');\n    }\n\n    // Without structured output support, need to extract JSON from model output manually\n    const response = await this.chatLLM.invoke(inputMessages, {\n      ...this.callOptions,\n    });\n    logger.info('invoke response', response);\n    if (typeof response.content === 'string') {\n      response.content = this.removeThinkTags(response.content);\n      try {\n        const extractedJson = this.extractJsonFromModelOutput(response.content);\n        const parsed = this.validateModelOutput(extractedJson);\n        if (parsed) {\n          return parsed;\n        }\n      } catch (error) {\n        logger.error('Could not parse response', response);\n        throw new Error('Could not parse response');\n      }\n    }\n    throw new Error('Could not parse response');\n  }\n\n  async execute(): Promise<AgentOutput<NavigatorResult>> {\n    const agentOutput: AgentOutput<NavigatorResult> = {\n      id: this.id,\n    };\n\n    let cancelled = false;\n\n    try {\n      this.context.emitEvent(\n        Actors.NAVIGATOR,\n        ExecutionState.STEP_START,\n        'Navigating...',\n      );\n\n      const messageManager = this.context.messageManager;\n      // add the browser state message\n      await this.addStateMessageToMemory();\n      // check if the task is paused or stopped\n      if (this.context.paused || this.context.stopped) {\n        cancelled = true;\n        return agentOutput;\n      }\n\n      // call the model to get the actions to take\n      const inputMessages = messageManager.getMessages();\n      const modelOutput = await this.invoke(inputMessages);\n      logger.info('modelOutput', modelOutput);\n\n      // check if the task is paused or stopped\n      if (this.context.paused || this.context.stopped) {\n        cancelled = true;\n        return agentOutput;\n      }\n      // remove the last state message from memory before adding the model output\n      this.removeLastStateMessageFromMemory();\n      this.addModelOutputToMemory(modelOutput);\n\n      // @ts-ignore\n      logger.info('modelOutput.action', modelOutput.action);\n\n      // take the actions\n      const actionResults = await this.doMultiAction(modelOutput);\n      logger.info('actionResults', actionResults);\n      this.context.actionResults = actionResults;\n\n      // check if the task is paused or stopped\n      if (this.context.paused || this.context.stopped) {\n        cancelled = true;\n        return agentOutput;\n      }\n      // emit event\n      this.context.emitEvent(\n        Actors.NAVIGATOR,\n        ExecutionState.STEP_OK,\n        'Navigation done',\n      );\n      let done = false;\n      if (\n        actionResults.length > 0 &&\n        actionResults[actionResults.length - 1].isDone\n      ) {\n        done = true;\n      }\n      agentOutput.result = { done };\n      return agentOutput;\n    } catch (error) {\n      logger.error('execute error', error);\n      this.removeLastStateMessageFromMemory();\n      // Check if this is an authentication error\n      if (isAuthenticationError(error)) {\n        throw new ChatModelAuthError(\n          'Navigator API Authentication failed. Please verify your API key',\n          error,\n        );\n      }\n\n      const errorMessage =\n        error instanceof Error ? error.message : String(error);\n      const errorString = `Navigation failed: ${errorMessage}`;\n      logger.error(errorString);\n      this.context.emitEvent(\n        Actors.NAVIGATOR,\n        ExecutionState.STEP_FAIL,\n        errorString,\n      );\n      agentOutput.error = errorMessage;\n      return agentOutput;\n    } finally {\n      // if the task is cancelled, remove the last state message from memory and emit event\n      if (cancelled) {\n        this.removeLastStateMessageFromMemory();\n        this.context.emitEvent(\n          Actors.NAVIGATOR,\n          ExecutionState.STEP_CANCEL,\n          'Navigation cancelled',\n        );\n      }\n    }\n  }\n\n  /**\n   * Add the state message to the memory\n   */\n  public async addStateMessageToMemory() {\n    if (this.context.stateMessageAdded) {\n      return;\n    }\n\n    const messageManager = this.context.messageManager;\n    const options = this.context.options;\n    // Handle results that should be included in memory\n    if (this.context.actionResults.length > 0) {\n      let index = 0;\n      for (const r of this.context.actionResults) {\n        if (r.includeInMemory) {\n          if (r.extractedContent) {\n            const msg = new HumanMessage(\n              `Action result: ${r.extractedContent}`,\n            );\n            // logger.info('Adding action result to memory', msg.content);\n            messageManager.addMessageWithTokens(msg);\n          }\n          if (r.error) {\n            const msg = new HumanMessage(\n              `Action error: ${r.error.toString().slice(-options.maxErrorLength)}`,\n            );\n            logger.info('Adding action error to memory', msg.content);\n            messageManager.addMessageWithTokens(msg);\n          }\n          // reset this action result to empty, we dont want to add it again in the state message\n          this.context.actionResults[index] = new ActionResult();\n        }\n        index++;\n      }\n    }\n\n    const state = await this.prompt.getUserMessage(this.context);\n    messageManager.addStateMessage(state);\n    this.context.stateMessageAdded = true;\n  }\n\n  /**\n   * Remove the last state message from the memory\n   */\n  protected async removeLastStateMessageFromMemory() {\n    if (!this.context.stateMessageAdded) return;\n    const messageManager = this.context.messageManager;\n    messageManager.removeLastStateMessage();\n    this.context.stateMessageAdded = false;\n  }\n\n  private async doMultiAction(\n    response: this['ModelOutput'],\n  ): Promise<ActionResult[]> {\n    const results: ActionResult[] = [];\n    let errCount = 0;\n\n    // @ts-ignore\n    logger.info('doMultiAction_Actions', response.action);\n    // sometimes response.action is a string, but not an array as expected, so we need to parse it as an array\n    let actions: Record<string, unknown>[] = [];\n    // @ts-ignore\n    if (Array.isArray(response.action)) {\n      // if the item is null, skip it\n      // @ts-ignore\n      actions = response.action.filter((item: unknown) => item !== null);\n      if (actions.length === 0) {\n        // @ts-ignore\n        logger.warning('No valid actions found', response.action);\n      }\n      // @ts-ignore\n    } else if (typeof response.action === 'string') {\n      try {\n        // @ts-ignore\n        logger.warning('Unexpected action format', response.action);\n        // @ts-ignore\n        const repaired = jsonrepair(response.action);\n        // try to parse the action as an JSON object\n        actions = JSON.parse(repaired);\n      } catch (error) {\n        // @ts-ignore\n        logger.error('Invalid action format', response.action);\n        throw new Error('Invalid action output format');\n      }\n    } else {\n      // if the action is neither an array nor a string, it should be an object\n      // @ts-ignore\n      actions = [response.action];\n    }\n\n    for (const action of actions) {\n      const actionName = Object.keys(action)[0];\n      const actionArgs = action[actionName];\n      try {\n        // check if the task is paused or stopped\n        if (this.context.paused || this.context.stopped) {\n          return results;\n        }\n\n        const result = await this.actionRegistry\n          .getAction(actionName)\n          ?.call(actionArgs);\n        if (result === undefined) {\n          throw new Error(\n            `Action ${actionName} not exists or returned undefined`,\n          );\n        }\n        results.push(result);\n        // check if the task is paused or stopped\n        if (this.context.paused || this.context.stopped) {\n          return results;\n        }\n        // TODO: wait for 1 second for now, need to optimize this to avoid unnecessary waiting\n        await new Promise((resolve) => setTimeout(resolve, 1000));\n      } catch (error) {\n        const errorMessage =\n          error instanceof Error ? error.message : String(error);\n        logger.error('doAction error', errorMessage);\n        // unexpected error, emit event\n        this.context.emitEvent(\n          Actors.NAVIGATOR,\n          ExecutionState.ACT_FAIL,\n          errorMessage,\n        );\n        errCount++;\n        if (errCount > 3) {\n          throw new Error('Too many errors in actions');\n        }\n        results.push(\n          new ActionResult({\n            error: errorMessage,\n            isDone: false,\n            includeInMemory: true,\n          }),\n        );\n      }\n    }\n    return results;\n  }\n}\n"],"names":["logger","createLogger","NavigatorActionRegistry","action","name","actionSchema","buildDynamicActionSchema","Object","z","agentBrainSchema","actions","NavigatorAgent","BaseAgent","inputMessages","schema","geminiNavigatorOutputSchema","jsonNavigatorOutputSchema","structuredLlm","console","response","extractedJson","parsed","error","Error","agentOutput","cancelled","Actors","ExecutionState","messageManager","modelOutput","actionResults","done","isAuthenticationError","ChatModelAuthError","errorMessage","String","errorString","options","index","r","msg","HumanMessage","ActionResult","state","results","errCount","Array","item","repaired","jsonrepair","JSON","actionName","actionArgs","_this_actionRegistry_getAction","result","undefined","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