{"version":3,"file":"agent/actions/builder.mjs","sources":["webpack://@agent-infra/browser-use/./src/agent/actions/builder.ts"],"sourcesContent":["/**\n * The following code is modified based on\n * https://github.com/nanobrowser/nanobrowser/blob/master/chrome-extension/src/background/agent/actions/builder.ts\n *\n * Apache-2.0 License\n * Copyright (c) 2024 alexchenzl\n * https://github.com/nanobrowser/nanobrowser/blob/master/LICENSE\n */\nimport { ActionResult, type AgentContext } from '../types';\nimport {\n  clickElementActionSchema,\n  doneActionSchema,\n  extractContentActionSchema,\n  goBackActionSchema,\n  goToUrlActionSchema,\n  inputTextActionSchema,\n  openTabActionSchema,\n  searchGoogleActionSchema,\n  switchTabActionSchema,\n  type ActionSchema,\n  scrollDownActionSchema,\n  scrollUpActionSchema,\n  sendKeysActionSchema,\n  scrollToTextActionSchema,\n  cacheContentActionSchema,\n} from './schemas';\nimport { z } from 'zod';\nimport { createLogger } from '../../utils';\nimport { PromptTemplate } from '@langchain/core/prompts';\nimport type { BaseChatModel } from '@langchain/core/language_models/chat_models';\nimport { ExecutionState, Actors } from '../event/types';\n\nconst logger = createLogger('Action');\n\nexport class InvalidInputError extends Error {\n  constructor(message: string) {\n    super(message);\n    this.name = 'InvalidInputError';\n  }\n}\n\n/**\n * An action is a function that takes an input and returns an ActionResult\n */\nexport class Action {\n  constructor(\n    // eslint-disable-next-line @typescript-eslint/no-explicit-any\n    private readonly handler: (input: any) => Promise<ActionResult>,\n    public readonly schema: ActionSchema,\n  ) {}\n\n  async call(input: unknown): Promise<ActionResult> {\n    // Validate input before calling the handler\n    const schema = this.schema.schema;\n\n    // check if the schema is schema: z.object({}), if so, ignore the input\n    const isEmptySchema =\n      schema instanceof z.ZodObject &&\n      Object.keys(\n        (schema as z.ZodObject<Record<string, z.ZodTypeAny>>).shape || {},\n      ).length === 0;\n\n    if (isEmptySchema) {\n      return await this.handler({});\n    }\n\n    const parsedArgs = this.schema.schema.safeParse(input);\n    if (!parsedArgs.success) {\n      const errorMessage = parsedArgs.error.message;\n      throw new InvalidInputError(errorMessage);\n    }\n    return await this.handler(parsedArgs.data);\n  }\n\n  name() {\n    return this.schema.name;\n  }\n\n  /**\n   * Returns the prompt for the action\n   * @returns {string} The prompt for the action\n   */\n  prompt() {\n    // eslint-disable-next-line @typescript-eslint/no-explicit-any\n    const schemaShape = (this.schema.schema as z.ZodObject<any>).shape || {};\n    const schemaProperties = Object.entries(schemaShape).map(([key, value]) => {\n      const zodValue = value as z.ZodTypeAny;\n      return `'${key}': {'type': '${zodValue.description}', ${zodValue.isOptional() ? \"'optional': true\" : \"'required': true\"}}`;\n    });\n\n    const schemaStr =\n      schemaProperties.length > 0\n        ? `{${this.name()}: {${schemaProperties.join(', ')}}}`\n        : `{${this.name()}: {}}`;\n\n    return `${this.schema.description}:\\n${schemaStr}`;\n  }\n}\n\n// TODO: can not make every action optional, don't know why\nexport function buildDynamicActionSchema(actions: Action[]): z.ZodType {\n  let schema = z.object({});\n  for (const action of actions) {\n    // create a schema for the action, it could be action.schema.schema or null\n    // but don't use default: null as it causes issues with Google Generative AI\n    const actionSchema = action.schema.schema.nullable();\n    schema = schema.extend({\n      [action.name()]: actionSchema,\n    });\n  }\n  return schema.partial().nullable();\n}\n\nexport class ActionBuilder {\n  private readonly context: AgentContext;\n  private readonly extractorLLM: BaseChatModel;\n\n  constructor(context: AgentContext, extractorLLM: BaseChatModel) {\n    this.context = context;\n    this.extractorLLM = extractorLLM;\n  }\n\n  buildDefaultActions() {\n    const actions = [];\n\n    const done = new Action(\n      async (input: z.infer<typeof doneActionSchema.schema>) => {\n        this.context.emitEvent(\n          Actors.NAVIGATOR,\n          ExecutionState.ACT_START,\n          doneActionSchema.name,\n        );\n        this.context.emitEvent(\n          Actors.NAVIGATOR,\n          ExecutionState.ACT_OK,\n          input.text,\n        );\n        return new ActionResult({\n          isDone: true,\n          extractedContent: input.text,\n        });\n      },\n      doneActionSchema,\n    );\n    actions.push(done);\n\n    const searchGoogle = new Action(async (input: { query: string }) => {\n      const msg = `Searching for \"${input.query}\" in Google`;\n      this.context.emitEvent(Actors.NAVIGATOR, ExecutionState.ACT_START, msg);\n\n      const page = await this.context.browserContext.getCurrentPage();\n      await page.navigateTo(`https://www.google.com/search?q=${input.query}`);\n\n      const msg2 = `Searched for \"${input.query}\" in Google`;\n      this.context.emitEvent(Actors.NAVIGATOR, ExecutionState.ACT_OK, msg2);\n      return new ActionResult({\n        extractedContent: msg2,\n        includeInMemory: true,\n      });\n    }, searchGoogleActionSchema);\n    actions.push(searchGoogle);\n\n    const goToUrl = new Action(async (input: { url: string }) => {\n      const msg = `Navigating to ${input.url}`;\n      this.context.emitEvent(Actors.NAVIGATOR, ExecutionState.ACT_START, msg);\n\n      await this.context.browserContext.navigateTo(input.url);\n      const msg2 = `Navigated to ${input.url}`;\n      this.context.emitEvent(Actors.NAVIGATOR, ExecutionState.ACT_OK, msg2);\n      return new ActionResult({\n        extractedContent: msg2,\n        includeInMemory: true,\n      });\n    }, goToUrlActionSchema);\n    actions.push(goToUrl);\n\n    // eslint-disable-next-line @typescript-eslint/no-unused-vars\n    const goBack = new Action(async (_input = {}) => {\n      const msg = 'Navigating back';\n      this.context.emitEvent(Actors.NAVIGATOR, ExecutionState.ACT_START, msg);\n\n      const page = await this.context.browserContext.getCurrentPage();\n      await page.goBack();\n      const msg2 = 'Navigated back';\n      this.context.emitEvent(Actors.NAVIGATOR, ExecutionState.ACT_OK, msg2);\n      return new ActionResult({\n        extractedContent: msg2,\n        includeInMemory: true,\n      });\n    }, goBackActionSchema);\n    actions.push(goBack);\n\n    // Element Interaction Actions\n    const clickElement = new Action(\n      async (input: z.infer<typeof clickElementActionSchema.schema>) => {\n        const todo = input.desc || `Click element with index ${input.index}`;\n        this.context.emitEvent(\n          Actors.NAVIGATOR,\n          ExecutionState.ACT_START,\n          todo,\n        );\n\n        const page = await this.context.browserContext.getCurrentPage();\n        const state = await page.getState();\n\n        const elementNode = state?.selectorMap.get(input.index);\n        if (!elementNode) {\n          throw new Error(\n            `Element with index ${input.index} does not exist - retry or use alternative actions`,\n          );\n        }\n\n        // Check if element is a file uploader\n        if (await page.isFileUploader(elementNode)) {\n          const msg = `Index ${input.index} - has an element which opens file upload dialog. To upload files please use a specific function to upload files`;\n          logger.info(msg);\n          return new ActionResult({\n            extractedContent: msg,\n            includeInMemory: true,\n          });\n        }\n\n        try {\n          // const initialTabIds =\n          //   await this.context.browserContext.getAllTabIds();\n          console.log('elementNode', elementNode);\n          await page.clickElementNode(\n            this.context.options.useVision,\n            elementNode,\n          );\n          const msg = `Clicked button with index ${input.index}: ${elementNode.getAllTextTillNextClickableElement(2)}`;\n          logger.info(msg);\n\n          // TODO: could be optimized by chrome extension tab api\n          // const currentTabIds =\n          //   await this.context.browserContext.getAllTabIds();\n          // if (currentTabIds.size > initialTabIds.size) {\n          //   const newTabMsg = 'New tab opened - switching to it';\n          //   msg += ` - ${newTabMsg}`;\n          //   logger.info(newTabMsg);\n          //   // find the tab id that is not in the initial tab ids\n          //   const newTabId = Array.from(currentTabIds).find(\n          //     (id) => !initialTabIds.has(id),\n          //   );\n          //   if (newTabId) {\n          //     await this.context.browserContext.switchTab(newTabId);\n          //   }\n          // }\n          this.context.emitEvent(Actors.NAVIGATOR, ExecutionState.ACT_OK, msg);\n          return new ActionResult({\n            extractedContent: msg,\n            includeInMemory: true,\n          });\n        } catch (error) {\n          const msg = `Element no longer available with index ${input.index} - most likely the page changed`;\n          this.context.emitEvent(\n            Actors.NAVIGATOR,\n            ExecutionState.ACT_FAIL,\n            msg,\n          );\n          return new ActionResult({\n            error: error instanceof Error ? error.message : String(error),\n          });\n        }\n      },\n      clickElementActionSchema,\n    );\n    actions.push(clickElement);\n\n    const inputText = new Action(\n      async (input: z.infer<typeof inputTextActionSchema.schema>) => {\n        const todo = input.desc || `Input text into index ${input.index}`;\n        this.context.emitEvent(\n          Actors.NAVIGATOR,\n          ExecutionState.ACT_START,\n          todo,\n        );\n\n        const page = await this.context.browserContext.getCurrentPage();\n        const state = await page.getState();\n\n        const elementNode = state?.selectorMap.get(input.index);\n        if (!elementNode) {\n          throw new Error(\n            `Element with index ${input.index} does not exist - retry or use alternative actions`,\n          );\n        }\n\n        await page.inputTextElementNode(\n          this.context.options.useVision,\n          elementNode,\n          input.text,\n        );\n        const msg = `Input ${input.text} into index ${input.index}`;\n        this.context.emitEvent(Actors.NAVIGATOR, ExecutionState.ACT_OK, msg);\n        return new ActionResult({\n          extractedContent: msg,\n          includeInMemory: true,\n        });\n      },\n      inputTextActionSchema,\n    );\n    actions.push(inputText);\n\n    // Tab Management Actions\n    const switchTab = new Action(\n      async (input: z.infer<typeof switchTabActionSchema.schema>) => {\n        this.context.emitEvent(\n          Actors.NAVIGATOR,\n          ExecutionState.ACT_START,\n          `Switching to tab ${input.tab_id}`,\n        );\n        await this.context.browserContext.switchTab(input.tab_id);\n        const msg = `Switched to tab ${input.tab_id}`;\n        this.context.emitEvent(Actors.NAVIGATOR, ExecutionState.ACT_OK, msg);\n        return new ActionResult({\n          extractedContent: msg,\n          includeInMemory: true,\n        });\n      },\n      switchTabActionSchema,\n    );\n    actions.push(switchTab);\n\n    const openTab = new Action(\n      async (input: z.infer<typeof openTabActionSchema.schema>) => {\n        this.context.emitEvent(\n          Actors.NAVIGATOR,\n          ExecutionState.ACT_START,\n          `Opening ${input.url} in new tab`,\n        );\n        await this.context.browserContext.openTab(input.url);\n        const msg = `Opened ${input.url} in new tab`;\n        this.context.emitEvent(Actors.NAVIGATOR, ExecutionState.ACT_OK, msg);\n        return new ActionResult({\n          extractedContent: msg,\n          includeInMemory: true,\n        });\n      },\n      openTabActionSchema,\n    );\n    actions.push(openTab);\n\n    // Content Actions\n    // TODO: this is not used currently, need to improve on input size\n    const extractContent = new Action(\n      async (input: z.infer<typeof extractContentActionSchema.schema>) => {\n        const goal = input.goal;\n        const page = await this.context.browserContext.getCurrentPage();\n        const content = await page.getReadabilityContent();\n        const promptTemplate = PromptTemplate.fromTemplate(\n          'Your task is to extract the content of the page. You will be given a page and a goal and you should extract all relevant information around this goal from the page. If the goal is vague, summarize the page. Respond in json format. Extraction goal: {goal}, Page: {page}',\n        );\n        const prompt = await promptTemplate.invoke({\n          goal,\n          page: content?.content,\n        });\n\n        try {\n          const output = await this.extractorLLM.invoke(prompt);\n          const msg = `📄  Extracted from page\\n: ${output.content}\\n`;\n          return new ActionResult({\n            extractedContent: msg,\n            includeInMemory: true,\n          });\n        } catch (error) {\n          logger.error(\n            `Error extracting content: ${error instanceof Error ? error.message : String(error)}`,\n          );\n          const msg =\n            'Failed to extract content from page, you need to extract content from the current state of the page and store it in the memory. Then scroll down if you still need more information.';\n          return new ActionResult({\n            extractedContent: msg,\n            includeInMemory: true,\n          });\n        }\n      },\n      extractContentActionSchema,\n    );\n    actions.push(extractContent);\n\n    // cache content for future use\n    const cacheContent = new Action(\n      async (input: z.infer<typeof cacheContentActionSchema.schema>) => {\n        this.context.emitEvent(\n          Actors.NAVIGATOR,\n          ExecutionState.ACT_START,\n          cacheContentActionSchema.name,\n        );\n\n        const msg = `Cached findings: ${input.content}`;\n        this.context.emitEvent(Actors.NAVIGATOR, ExecutionState.ACT_OK, msg);\n        return new ActionResult({\n          extractedContent: msg,\n          includeInMemory: true,\n        });\n      },\n      cacheContentActionSchema,\n    );\n    actions.push(cacheContent);\n\n    const scrollDown = new Action(\n      async (input: z.infer<typeof scrollDownActionSchema.schema>) => {\n        const todo = input.desc || 'Scroll down the page';\n        this.context.emitEvent(\n          Actors.NAVIGATOR,\n          ExecutionState.ACT_START,\n          todo,\n        );\n\n        const page = await this.context.browserContext.getCurrentPage();\n        await page.scrollDown(input.amount);\n        const amount =\n          input.amount !== undefined ? `${input.amount} pixels` : 'one page';\n        const msg = `Scrolled down the page by ${amount}`;\n        this.context.emitEvent(Actors.NAVIGATOR, ExecutionState.ACT_OK, msg);\n        return new ActionResult({\n          extractedContent: msg,\n          includeInMemory: true,\n        });\n      },\n      scrollDownActionSchema,\n    );\n    actions.push(scrollDown);\n\n    const scrollUp = new Action(\n      async (input: z.infer<typeof scrollUpActionSchema.schema>) => {\n        const todo = input.desc || 'Scroll up the page';\n        this.context.emitEvent(\n          Actors.NAVIGATOR,\n          ExecutionState.ACT_START,\n          todo,\n        );\n\n        const page = await this.context.browserContext.getCurrentPage();\n        await page.scrollUp(input.amount);\n        const amount =\n          input.amount !== undefined ? `${input.amount} pixels` : 'one page';\n        const msg = `Scrolled up the page by ${amount}`;\n        this.context.emitEvent(Actors.NAVIGATOR, ExecutionState.ACT_OK, msg);\n        return new ActionResult({\n          extractedContent: msg,\n          includeInMemory: true,\n        });\n      },\n      scrollUpActionSchema,\n    );\n    actions.push(scrollUp);\n\n    // Keyboard Actions\n    const sendKeys = new Action(\n      async (input: z.infer<typeof sendKeysActionSchema.schema>) => {\n        const todo = input.desc || `Send keys: ${input.keys}`;\n        this.context.emitEvent(\n          Actors.NAVIGATOR,\n          ExecutionState.ACT_START,\n          todo,\n        );\n\n        const page = await this.context.browserContext.getCurrentPage();\n        await page.sendKeys(input.keys);\n        const msg = `Sent keys: ${input.keys}`;\n        this.context.emitEvent(Actors.NAVIGATOR, ExecutionState.ACT_OK, msg);\n        return new ActionResult({\n          extractedContent: msg,\n          includeInMemory: true,\n        });\n      },\n      sendKeysActionSchema,\n    );\n    actions.push(sendKeys);\n\n    const scrollToText = new Action(\n      async (input: z.infer<typeof scrollToTextActionSchema.schema>) => {\n        const todo = input.desc || `Scroll to text: ${input.text}`;\n        this.context.emitEvent(\n          Actors.NAVIGATOR,\n          ExecutionState.ACT_START,\n          todo,\n        );\n\n        const page = await this.context.browserContext.getCurrentPage();\n        try {\n          const scrolled = await page.scrollToText(input.text);\n          const msg = scrolled\n            ? `Scrolled to text: ${input.text}`\n            : `Text '${input.text}' not found or not visible on page`;\n          this.context.emitEvent(Actors.NAVIGATOR, ExecutionState.ACT_OK, msg);\n          return new ActionResult({\n            extractedContent: msg,\n            includeInMemory: true,\n          });\n        } catch (error) {\n          const msg = `Failed to scroll to text: ${error instanceof Error ? error.message : String(error)}`;\n          this.context.emitEvent(\n            Actors.NAVIGATOR,\n            ExecutionState.ACT_FAIL,\n            msg,\n          );\n          return new ActionResult({ error: msg, includeInMemory: true });\n        }\n      },\n      scrollToTextActionSchema,\n    );\n    actions.push(scrollToText);\n\n    return actions;\n  }\n}\n"],"names":["logger","createLogger","InvalidInputError","Error","message","Action","input","schema","isEmptySchema","z","Object","parsedArgs","errorMessage","schemaShape","schemaProperties","key","value","zodValue","schemaStr","handler","buildDynamicActionSchema","actions","action","actionSchema","ActionBuilder","done","Actors","ExecutionState","doneActionSchema","ActionResult","searchGoogle","msg","page","msg2","searchGoogleActionSchema","goToUrl","goToUrlActionSchema","goBack","_input","goBackActionSchema","clickElement","todo","state","elementNode","console","error","String","clickElementActionSchema","inputText","inputTextActionSchema","switchTab","switchTabActionSchema","openTab","openTabActionSchema","extractContent","goal","content","promptTemplate","PromptTemplate","prompt","output","extractContentActionSchema","cacheContent","cacheContentActionSchema","scrollDown","amount","undefined","scrollDownActionSchema","scrollUp","scrollUpActionSchema","sendKeys","sendKeysActionSchema","scrollToText","scrolled","scrollToTextActionSchema","context","extractorLLM"],"mappings":";;;;;;;;;;AAOC;;;;;;;;;;AAyBD,MAAMA,SAASC,aAAa;AAErB,MAAMC,0BAA0BC;IACrC,YAAYC,OAAe,CAAE;QAC3B,KAAK,CAACA;QACN,IAAI,CAAC,IAAI,GAAG;IACd;AACF;AAKO,MAAMC;IAOX,MAAM,KAAKC,KAAc,EAAyB;QAEhD,MAAMC,SAAS,IAAI,CAAC,MAAM,CAAC,MAAM;QAGjC,MAAMC,gBACJD,kBAAkBE,EAAE,SAAS,IAC7BC,AAEa,MAFbA,OAAO,IAAI,CACRH,OAAqD,KAAK,IAAI,CAAC,GAChE,MAAM;QAEV,IAAIC,eACF,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC;QAG7B,MAAMG,aAAa,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAACL;QAChD,IAAI,CAACK,WAAW,OAAO,EAAE;YACv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