@midscene/web 0.16.5 → 0.16.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/es/agent.js +78 -14
  2. package/dist/es/agent.js.map +1 -1
  3. package/dist/es/bridge-mode-browser.js +3 -3
  4. package/dist/es/bridge-mode-browser.js.map +1 -1
  5. package/dist/es/bridge-mode.js +100 -21
  6. package/dist/es/bridge-mode.js.map +1 -1
  7. package/dist/es/chrome-extension.js +79 -15
  8. package/dist/es/chrome-extension.js.map +1 -1
  9. package/dist/es/index.js +110 -14
  10. package/dist/es/index.js.map +1 -1
  11. package/dist/es/midscene-playground.js +78 -14
  12. package/dist/es/midscene-playground.js.map +1 -1
  13. package/dist/es/playground.js +78 -14
  14. package/dist/es/playground.js.map +1 -1
  15. package/dist/es/playwright.js +110 -14
  16. package/dist/es/playwright.js.map +1 -1
  17. package/dist/es/puppeteer-agent-launcher.js +78 -14
  18. package/dist/es/puppeteer-agent-launcher.js.map +1 -1
  19. package/dist/es/puppeteer.js +78 -14
  20. package/dist/es/puppeteer.js.map +1 -1
  21. package/dist/es/ui-utils.js.map +1 -1
  22. package/dist/lib/agent.js +77 -10
  23. package/dist/lib/agent.js.map +1 -1
  24. package/dist/lib/bridge-mode-browser.js +3 -3
  25. package/dist/lib/bridge-mode-browser.js.map +1 -1
  26. package/dist/lib/bridge-mode.js +99 -18
  27. package/dist/lib/bridge-mode.js.map +1 -1
  28. package/dist/lib/chrome-extension.js +78 -11
  29. package/dist/lib/chrome-extension.js.map +1 -1
  30. package/dist/lib/index.js +109 -10
  31. package/dist/lib/index.js.map +1 -1
  32. package/dist/lib/midscene-playground.js +77 -10
  33. package/dist/lib/midscene-playground.js.map +1 -1
  34. package/dist/lib/playground.js +77 -10
  35. package/dist/lib/playground.js.map +1 -1
  36. package/dist/lib/playwright.js +109 -10
  37. package/dist/lib/playwright.js.map +1 -1
  38. package/dist/lib/puppeteer-agent-launcher.js +77 -10
  39. package/dist/lib/puppeteer-agent-launcher.js.map +1 -1
  40. package/dist/lib/puppeteer.js +77 -10
  41. package/dist/lib/puppeteer.js.map +1 -1
  42. package/dist/lib/ui-utils.js.map +1 -1
  43. package/dist/types/agent.d.ts +8 -0
  44. package/dist/types/bridge-mode-browser.d.ts +1 -1
  45. package/dist/types/bridge-mode.d.ts +1 -2
  46. package/dist/types/{browser-0beaa7a7.d.ts → browser-a8afbca5.d.ts} +1 -2
  47. package/dist/types/playwright.d.ts +16 -0
  48. package/dist/types/ui-utils.d.ts +1 -1
  49. package/package.json +4 -3
@@ -258,7 +258,7 @@ function sleep(ms) {
258
258
  var ChromeExtensionProxyPage = class {
259
259
  constructor(forceSameTabNavigation) {
260
260
  this.pageType = "chrome-extension-proxy";
261
- this.version = "0.16.5";
261
+ this.version = "0.16.6";
262
262
  this.activeTabId = null;
263
263
  this.tabIdOfDebuggerAttached = null;
264
264
  this.attachingDebugger = null;
@@ -704,7 +704,7 @@ var BridgeClient = class {
704
704
  this.socket = ClientIO(this.endpoint, {
705
705
  reconnection: false,
706
706
  query: {
707
- version: "0.16.5"
707
+ version: "0.16.6"
708
708
  }
709
709
  });
710
710
  const timeout = setTimeout(() => {
@@ -845,7 +845,7 @@ var ExtensionBridgePageBrowserSide = class extends ChromeExtensionProxyPage {
845
845
  );
846
846
  await this.bridgeClient.connect();
847
847
  this.onLogMessage(
848
- `Bridge connected, cli-side version v${this.bridgeClient.serverVersion}, browser-side version v${"0.16.5"}`,
848
+ `Bridge connected, cli-side version v${this.bridgeClient.serverVersion}, browser-side version v${"0.16.6"}`,
849
849
  "log"
850
850
  );
851
851
  }
@@ -1 +1 @@
1
- {"version":3,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAKA,SAAS,UAAAA,eAAc;;;ACqHhB,IAAM,wBAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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AoB;AAC3C,cAAM,OAAO,KAAK,OAAO,KAAK;AAAA,MAChC;AACA,WAAK,qBAAqB,CAAC;AAAA,IAC7B;AAEA,UAAM,MAAM,QAAQ;AAEpB,QAAI,KAAK,cAAc;AACrB,WAAK,aAAa,WAAW;AAC7B,WAAK,eAAe;AACpB,WAAK,aAAa;AAAA,IACpB;AAAA,EACF;AACF","names":["assert","error","e"],"ignoreList":[],"sources":["../../src/bridge-mode/page-browser-side.ts","../../src/common/ui-utils.ts","../../src/chrome-extension/page.ts","../../src/chrome-extension/cdpInput.ts","../../src/chrome-extension/dynamic-scripts.ts","../../src/bridge-mode/common.ts","../../src/bridge-mode/io-client.ts"],"sourcesContent":["import type {\n ChromePageDestroyOptions,\n KeyboardAction,\n MouseAction,\n} from '@/page';\nimport { assert } from '@midscene/shared/utils';\nimport ChromeExtensionProxyPage from '../chrome-extension/page';\nimport {\n type BridgeConnectTabOptions,\n BridgeEvent,\n DefaultBridgeServerPort,\n KeyboardEvent,\n MouseEvent,\n} from './common';\nimport { BridgeClient } from './io-client';\n\ndeclare const __VERSION__: string;\n\nexport class ExtensionBridgePageBrowserSide extends ChromeExtensionProxyPage {\n public bridgeClient: BridgeClient | null = null;\n\n private destroyOptions?: ChromePageDestroyOptions;\n\n private newlyCreatedTabIds: number[] = [];\n\n constructor(\n public onDisconnect: () => void = () => {},\n public onLogMessage: (\n message: string,\n type: 'log' | 'status',\n ) => void = () => {},\n forceSameTabNavigation = true,\n ) {\n super(forceSameTabNavigation);\n }\n\n private async setupBridgeClient() {\n this.bridgeClient = new BridgeClient(\n `ws://localhost:${DefaultBridgeServerPort}`,\n async (method, args: any[]) => {\n console.log('bridge call from cli side', method, args);\n if (method === BridgeEvent.ConnectNewTabWithUrl) {\n return this.connectNewTabWithUrl.apply(\n this,\n args as unknown as [string],\n );\n }\n\n if (method === BridgeEvent.GetBrowserTabList) {\n return this.getBrowserTabList.apply(this, args as any);\n }\n\n if (method === BridgeEvent.SetActiveTabId) {\n return this.setActiveTabId.apply(this, args as any);\n }\n\n if (method === BridgeEvent.ConnectCurrentTab) {\n return this.connectCurrentTab.apply(this, args as any);\n }\n\n if (method === BridgeEvent.UpdateAgentStatus) {\n return this.onLogMessage(args[0] as string, 'status');\n }\n\n const tabId = await this.getActiveTabId();\n if (!tabId || tabId === 0) {\n throw new Error('no tab is connected');\n }\n\n // this.onLogMessage(`calling method: ${method}`);\n\n if (method.startsWith(MouseEvent.PREFIX)) {\n const actionName = method.split('.')[1] as keyof MouseAction;\n if (actionName === 'drag') {\n return this.mouse[actionName].apply(this.mouse, args as any);\n }\n return this.mouse[actionName].apply(this.mouse, args as any);\n }\n\n if (method.startsWith(KeyboardEvent.PREFIX)) {\n const actionName = method.split('.')[1] as keyof KeyboardAction;\n if (actionName === 'press') {\n return this.keyboard[actionName].apply(this.keyboard, args as any);\n }\n return this.keyboard[actionName].apply(this.keyboard, args as any);\n }\n\n try {\n // @ts-expect-error\n const result = await this[method as keyof ChromeExtensionProxyPage](\n ...args,\n );\n return result;\n } catch (e) {\n const errorMessage = e instanceof Error ? e.message : 'Unknown error';\n console.error('error calling method', method, args, e);\n this.onLogMessage(\n `Error calling method: ${method}, ${errorMessage}`,\n 'log',\n );\n throw new Error(errorMessage, { cause: e });\n }\n },\n // on disconnect\n () => {\n return this.destroy();\n },\n );\n await this.bridgeClient.connect();\n this.onLogMessage(\n `Bridge connected, cli-side version v${this.bridgeClient.serverVersion}, browser-side version v${__VERSION__}`,\n 'log',\n );\n }\n\n public async connect() {\n return await this.setupBridgeClient();\n }\n\n public async connectNewTabWithUrl(\n url: string,\n options: BridgeConnectTabOptions = {\n forceSameTabNavigation: true,\n },\n ) {\n const tab = await chrome.tabs.create({ url });\n const tabId = tab.id;\n assert(tabId, 'failed to get tabId after creating a new tab');\n\n // new tab\n this.onLogMessage(`Creating new tab: ${url}`, 'log');\n this.newlyCreatedTabIds.push(tabId);\n\n if (options?.forceSameTabNavigation) {\n this.forceSameTabNavigation = true;\n }\n\n await this.setActiveTabId(tabId);\n }\n\n public async connectCurrentTab(\n options: BridgeConnectTabOptions = {\n forceSameTabNavigation: true,\n },\n ) {\n const tabs = await chrome.tabs.query({ active: true, currentWindow: true });\n console.log('current tab', tabs);\n const tabId = tabs[0]?.id;\n assert(tabId, 'failed to get tabId');\n\n this.onLogMessage(`Connected to current tab: ${tabs[0]?.url}`, 'log');\n\n if (options?.forceSameTabNavigation) {\n this.forceSameTabNavigation = true;\n }\n\n await this.setActiveTabId(tabId);\n }\n\n public async setDestroyOptions(options: ChromePageDestroyOptions) {\n this.destroyOptions = options;\n }\n\n async destroy() {\n if (this.destroyOptions?.closeTab && this.newlyCreatedTabIds.length > 0) {\n this.onLogMessage('Closing all newly created tabs by bridge...', 'log');\n for (const tabId of this.newlyCreatedTabIds) {\n await chrome.tabs.remove(tabId);\n }\n this.newlyCreatedTabIds = [];\n }\n\n await super.destroy();\n\n if (this.bridgeClient) {\n this.bridgeClient.disconnect();\n this.bridgeClient = null;\n this.onDisconnect();\n }\n }\n}\n","import type {\n DetailedLocateParam,\n ExecutionTask,\n ExecutionTaskAction,\n ExecutionTaskInsightAssertion,\n ExecutionTaskInsightLocate,\n ExecutionTaskInsightQuery,\n ExecutionTaskPlanning,\n PlanningActionParamScroll,\n} from '@midscene/core';\n\nexport function typeStr(task: ExecutionTask) {\n return task.subType ? `${task.type} / ${task.subType || ''}` : task.type;\n}\n\nexport function getKeyCommands(\n value: string | string[],\n): Array<{ key: string; command?: string }> {\n // Ensure value is an array of keys\n const keys = Array.isArray(value) ? value : [value];\n\n // Process each key to attach a corresponding command if needed, based on the presence of 'Meta' or 'Control' in the keys array.\n // ref: https://github.com/puppeteer/puppeteer/pull/9357/files#diff-32cf475237b000f980eb214a0a823e45a902bddb7d2426d677cae96397aa0ae4R94\n return keys.reduce((acc: Array<{ key: string; command?: string }>, k) => {\n const includeMeta = keys.includes('Meta') || keys.includes('Control');\n if (includeMeta && (k === 'a' || k === 'A')) {\n return acc.concat([{ key: k, command: 'SelectAll' }]);\n }\n if (includeMeta && (k === 'c' || k === 'C')) {\n return acc.concat([{ key: k, command: 'Copy' }]);\n }\n if (includeMeta && (k === 'v' || k === 'V')) {\n return acc.concat([{ key: k, command: 'Paste' }]);\n }\n return acc.concat([{ key: k }]);\n }, []);\n}\n\nexport function locateParamStr(locate?: DetailedLocateParam) {\n if (!locate) {\n return '';\n }\n\n if (typeof locate === 'string') {\n return locate;\n }\n\n return locate.prompt;\n}\n\nexport function scrollParamStr(scrollParam?: PlanningActionParamScroll) {\n if (!scrollParam) {\n return '';\n }\n return `${scrollParam.direction || 'down'}, ${scrollParam.scrollType || 'once'}, ${scrollParam.distance || 'distance-not-set'}`;\n}\n\nexport function taskTitleStr(\n type:\n | 'Tap'\n | 'Hover'\n | 'Input'\n | 'KeyboardPress'\n | 'Scroll'\n | 'Action'\n | 'Query'\n | 'Assert'\n | 'WaitFor',\n prompt: string,\n) {\n if (prompt) {\n return `${type} - ${prompt}`;\n }\n return type;\n}\n\nexport function paramStr(task: ExecutionTask) {\n let value: string | undefined | object;\n if (task.type === 'Planning') {\n value = (task as ExecutionTaskPlanning)?.param?.userInstruction;\n }\n\n if (task.type === 'Insight') {\n value =\n (task as ExecutionTaskInsightLocate)?.param?.prompt ||\n (task as ExecutionTaskInsightLocate)?.param?.id ||\n (task as ExecutionTaskInsightQuery)?.param?.dataDemand ||\n (task as ExecutionTaskInsightAssertion)?.param?.assertion;\n }\n\n if (task.type === 'Action') {\n const locate = (task as ExecutionTaskAction)?.locate;\n const locateStr = locate ? locateParamStr(locate) : '';\n\n value = task.thought || '';\n if (typeof (task as ExecutionTaskAction)?.param?.timeMs === 'number') {\n value = `${(task as ExecutionTaskAction)?.param?.timeMs}ms`;\n } else if (\n typeof (task as ExecutionTaskAction)?.param?.scrollType === 'string'\n ) {\n value = scrollParamStr((task as ExecutionTaskAction)?.param);\n } else if (\n typeof (task as ExecutionTaskAction)?.param?.value !== 'undefined'\n ) {\n value = (task as ExecutionTaskAction)?.param?.value;\n }\n\n if (locateStr) {\n if (value) {\n value = `${locateStr} - ${value}`;\n } else {\n value = locateStr;\n }\n }\n }\n\n if (typeof value === 'undefined') return '';\n return typeof value === 'string'\n ? value\n : JSON.stringify(value, undefined, 2);\n}\n\nexport const limitOpenNewTabScript = `\nif (!window.__MIDSCENE_NEW_TAB_INTERCEPTOR_INITIALIZED__) {\n window.__MIDSCENE_NEW_TAB_INTERCEPTOR_INITIALIZED__ = true;\n\n // Intercept the window.open method (only once)\n window.open = function(url) {\n console.log('Blocked window.open:', url);\n window.location.href = url;\n return null;\n };\n\n // Block all a tag clicks with target=\"_blank\" (only once)\n document.addEventListener('click', function(e) {\n const target = e.target.closest('a');\n if (target && target.target === '_blank') {\n e.preventDefault();\n console.log('Blocked new tab:', target.href);\n window.location.href = target.href;\n target.removeAttribute('target');\n }\n }, true);\n}\n`;\n","/// <reference types=\"chrome\" />\n\n/*\n It is used to interact with the page tab from the chrome extension.\n The page must be active when interacting with it.\n*/\n\nimport type { WebKeyInput } from '@/common/page';\nimport { limitOpenNewTabScript } from '@/common/ui-utils';\nimport type { AbstractPage, ChromePageDestroyOptions } from '@/page';\nimport type { ElementTreeNode, Point, Size } from '@midscene/core';\nimport type { ElementInfo } from '@midscene/shared/extractor';\nimport { treeToList } from '@midscene/shared/extractor';\nimport { assert } from '@midscene/shared/utils';\nimport type { Protocol as CDPTypes } from 'devtools-protocol';\nimport { CdpKeyboard } from './cdpInput';\nimport {\n getHtmlElementScript,\n injectStopWaterFlowAnimation,\n injectWaterFlowAnimation,\n} from './dynamic-scripts';\n\nfunction sleep(ms: number) {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\ndeclare const __VERSION__: string;\n\nexport default class ChromeExtensionProxyPage implements AbstractPage {\n pageType = 'chrome-extension-proxy';\n\n public forceSameTabNavigation: boolean;\n private version: string = __VERSION__;\n\n private viewportSize?: Size;\n\n private activeTabId: number | null = null;\n\n private tabIdOfDebuggerAttached: number | null = null;\n\n private attachingDebugger: Promise<void> | null = null;\n\n private destroyed = false;\n\n constructor(forceSameTabNavigation: boolean) {\n this.forceSameTabNavigation = forceSameTabNavigation;\n }\n\n public async setActiveTabId(tabId: number) {\n if (this.activeTabId) {\n throw new Error(\n `Active tab id is already set, which is ${this.activeTabId}, cannot set it to ${tabId}`,\n );\n }\n await chrome.tabs.update(tabId, { active: true });\n this.activeTabId = tabId;\n }\n\n public async getActiveTabId() {\n return this.activeTabId;\n }\n\n /**\n * Get a list of current tabs\n * @returns {Promise<Array<{id: number, title: string, url: string}>>}\n */\n public async getBrowserTabList(): Promise<\n { id: string; title: string; url: string; currentActiveTab: boolean }[]\n > {\n const tabs = await chrome.tabs.query({ currentWindow: true });\n return tabs\n .map((tab) => ({\n id: `${tab.id}`,\n title: tab.title,\n url: tab.url,\n currentActiveTab: tab.active,\n }))\n .filter((tab) => tab.id && tab.title && tab.url) as {\n id: string;\n title: string;\n url: string;\n currentActiveTab: boolean;\n }[];\n }\n\n public async getTabIdOrConnectToCurrentTab() {\n if (this.activeTabId) {\n // alway keep on the connected tab\n return this.activeTabId;\n }\n const tabId = await chrome.tabs\n .query({ active: true, currentWindow: true })\n .then((tabs) => tabs[0]?.id);\n this.activeTabId = tabId || 0;\n return this.activeTabId;\n }\n\n private async attachDebugger() {\n assert(!this.destroyed, 'Page is destroyed');\n\n // If already attaching, wait for it to complete\n if (this.attachingDebugger) {\n await this.attachingDebugger;\n return;\n }\n\n // Create new attaching promise\n this.attachingDebugger = (async () => {\n const url = await this.url();\n let error: Error | null = null;\n if (url.startsWith('chrome://')) {\n throw new Error(\n 'Cannot attach debugger to chrome:// pages, please use Midscene in a normal page with http://, https:// or file://',\n );\n }\n\n try {\n const currentTabId = await this.getTabIdOrConnectToCurrentTab();\n\n if (this.tabIdOfDebuggerAttached === currentTabId) {\n // already attached\n return;\n }\n if (\n this.tabIdOfDebuggerAttached &&\n this.tabIdOfDebuggerAttached !== currentTabId\n ) {\n // detach the previous tab\n console.log(\n 'detach the previous tab',\n this.tabIdOfDebuggerAttached,\n '->',\n currentTabId,\n );\n try {\n await this.detachDebugger(this.tabIdOfDebuggerAttached);\n } catch (error) {\n console.error('Failed to detach debugger', error);\n }\n }\n\n // detach any debugger attached to the tab\n console.log('attaching debugger', currentTabId);\n await chrome.debugger.attach({ tabId: currentTabId }, '1.3');\n // wait util the debugger banner in Chrome appears\n await sleep(500);\n\n this.tabIdOfDebuggerAttached = currentTabId;\n\n await this.enableWaterFlowAnimation();\n } catch (e) {\n console.error('Failed to attach debugger', e);\n error = e as Error;\n } finally {\n this.attachingDebugger = null;\n }\n if (error) {\n throw error;\n }\n })();\n\n await this.attachingDebugger;\n }\n\n private async showMousePointer(x: number, y: number) {\n // update mouse pointer while redirecting\n const pointerScript = `(() => {\n if(typeof window.midsceneWaterFlowAnimation !== 'undefined') {\n window.midsceneWaterFlowAnimation.enable();\n window.midsceneWaterFlowAnimation.showMousePointer(${x}, ${y});\n } else {\n console.log('midsceneWaterFlowAnimation is not defined');\n }\n })()`;\n\n await this.sendCommandToDebugger('Runtime.evaluate', {\n expression: `${pointerScript}`,\n });\n }\n\n private async hideMousePointer() {\n await this.sendCommandToDebugger('Runtime.evaluate', {\n expression: `(() => {\n if(typeof window.midsceneWaterFlowAnimation !== 'undefined') {\n window.midsceneWaterFlowAnimation.hideMousePointer();\n }\n })()`,\n });\n }\n\n private async detachDebugger(tabId?: number) {\n const tabIdToDetach = tabId || this.tabIdOfDebuggerAttached;\n console.log('detaching debugger', tabIdToDetach);\n if (!tabIdToDetach) {\n console.warn('No tab id to detach');\n return;\n }\n\n try {\n await this.disableWaterFlowAnimation(tabIdToDetach);\n await sleep(200); // wait for the animation to stop\n } catch (error) {\n console.warn('Failed to disable water flow animation', error);\n }\n\n try {\n await chrome.debugger.detach({ tabId: tabIdToDetach });\n } catch (error) {\n // maybe tab is closed ?\n console.warn('Failed to detach debugger', error);\n }\n this.tabIdOfDebuggerAttached = null;\n }\n\n private async enableWaterFlowAnimation() {\n // limit open page in new tab\n if (this.forceSameTabNavigation) {\n await chrome.debugger.sendCommand(\n { tabId: this.tabIdOfDebuggerAttached! },\n 'Runtime.evaluate',\n {\n expression: limitOpenNewTabScript,\n },\n );\n }\n\n const script = await injectWaterFlowAnimation();\n // we will call this function in sendCommandToDebugger, so we have to use the chrome.debugger.sendCommand\n await chrome.debugger.sendCommand(\n { tabId: this.tabIdOfDebuggerAttached! },\n 'Runtime.evaluate',\n {\n expression: script,\n },\n );\n }\n\n private async disableWaterFlowAnimation(tabId: number) {\n const script = await injectStopWaterFlowAnimation();\n\n await chrome.debugger.sendCommand({ tabId }, 'Runtime.evaluate', {\n expression: script,\n });\n }\n\n private async sendCommandToDebugger<ResponseType = any, RequestType = any>(\n command: string,\n params: RequestType,\n ): Promise<ResponseType> {\n await this.attachDebugger();\n\n assert(this.tabIdOfDebuggerAttached, 'Debugger is not attached');\n\n // wo don't have to await it\n this.enableWaterFlowAnimation();\n return (await chrome.debugger.sendCommand(\n { tabId: this.tabIdOfDebuggerAttached! },\n command,\n params as any,\n )) as ResponseType;\n }\n\n private async getPageContentByCDP() {\n const script = await getHtmlElementScript();\n\n // check tab url\n await this.sendCommandToDebugger<\n CDPTypes.Runtime.EvaluateResponse,\n CDPTypes.Runtime.EvaluateRequest\n >('Runtime.evaluate', {\n expression: script,\n });\n\n const expression = () => {\n return {\n tree: (window as any).midscene_element_inspector.webExtractNodeTree(),\n size: {\n width: document.documentElement.clientWidth,\n height: document.documentElement.clientHeight,\n dpr: window.devicePixelRatio,\n },\n };\n };\n const returnValue = await this.sendCommandToDebugger<\n CDPTypes.Runtime.EvaluateResponse,\n CDPTypes.Runtime.EvaluateRequest\n >('Runtime.evaluate', {\n expression: `(${expression.toString()})()`,\n returnByValue: true,\n });\n\n if (!returnValue.result.value) {\n const errorDescription =\n returnValue.exceptionDetails?.exception?.description || '';\n if (!errorDescription) {\n console.error('returnValue from cdp', returnValue);\n }\n throw new Error(\n `Failed to get page content from page, error: ${errorDescription}`,\n );\n }\n // console.log('returnValue', returnValue.result.value);\n return returnValue.result.value as {\n tree: ElementTreeNode<ElementInfo>;\n size: Size;\n };\n }\n\n public async evaluateJavaScript(script: string) {\n return this.sendCommandToDebugger('Runtime.evaluate', {\n expression: script,\n });\n }\n\n // current implementation is wait until domReadyState is complete\n public async waitUntilNetworkIdle() {\n const timeout = 10000;\n const startTime = Date.now();\n let lastReadyState = '';\n while (Date.now() - startTime < timeout) {\n const result = await this.sendCommandToDebugger('Runtime.evaluate', {\n expression: 'document.readyState',\n });\n lastReadyState = result.result.value;\n if (lastReadyState === 'complete') {\n await new Promise((resolve) => setTimeout(resolve, 300));\n return;\n }\n await new Promise((resolve) => setTimeout(resolve, 300));\n }\n throw new Error(\n `Failed to wait until network idle, last readyState: ${lastReadyState}`,\n );\n }\n\n async getElementsInfo() {\n const tree = await this.getElementsNodeTree();\n return treeToList(tree);\n }\n\n async getElementsNodeTree() {\n await this.hideMousePointer();\n const content = await this.getPageContentByCDP();\n if (content?.size) {\n this.viewportSize = content.size;\n }\n\n return content?.tree || { node: null, children: [] };\n }\n\n async size() {\n if (this.viewportSize) return this.viewportSize;\n const content = await this.getPageContentByCDP();\n return content.size;\n }\n\n async screenshotBase64() {\n // screenshot by cdp\n await this.hideMousePointer();\n const base64 = await this.sendCommandToDebugger('Page.captureScreenshot', {\n format: 'jpeg',\n quality: 90,\n });\n return `data:image/jpeg;base64,${base64.data}`;\n }\n\n async url() {\n const tabId = await this.getTabIdOrConnectToCurrentTab();\n const url = await chrome.tabs.get(tabId).then((tab) => tab.url);\n return url || '';\n }\n\n async scrollUntilTop(startingPoint?: Point) {\n if (startingPoint) {\n await this.mouse.move(startingPoint.left, startingPoint.top);\n }\n return this.mouse.wheel(0, -9999999);\n }\n\n async scrollUntilBottom(startingPoint?: Point) {\n if (startingPoint) {\n await this.mouse.move(startingPoint.left, startingPoint.top);\n }\n return this.mouse.wheel(0, 9999999);\n }\n\n async scrollUntilLeft(startingPoint?: Point) {\n if (startingPoint) {\n await this.mouse.move(startingPoint.left, startingPoint.top);\n }\n return this.mouse.wheel(-9999999, 0);\n }\n\n async scrollUntilRight(startingPoint?: Point) {\n if (startingPoint) {\n await this.mouse.move(startingPoint.left, startingPoint.top);\n }\n return this.mouse.wheel(9999999, 0);\n }\n\n async scrollUp(distance?: number, startingPoint?: Point) {\n const { height } = await this.size();\n const scrollDistance = distance || height * 0.7;\n return this.mouse.wheel(\n 0,\n -scrollDistance,\n startingPoint?.left,\n startingPoint?.top,\n );\n }\n\n async scrollDown(distance?: number, startingPoint?: Point) {\n const { height } = await this.size();\n const scrollDistance = distance || height * 0.7;\n return this.mouse.wheel(\n 0,\n scrollDistance,\n startingPoint?.left,\n startingPoint?.top,\n );\n }\n\n async scrollLeft(distance?: number, startingPoint?: Point) {\n const { width } = await this.size();\n const scrollDistance = distance || width * 0.7;\n return this.mouse.wheel(\n -scrollDistance,\n 0,\n startingPoint?.left,\n startingPoint?.top,\n );\n }\n\n async scrollRight(distance?: number, startingPoint?: Point) {\n const { width } = await this.size();\n const scrollDistance = distance || width * 0.7;\n return this.mouse.wheel(\n scrollDistance,\n 0,\n startingPoint?.left,\n startingPoint?.top,\n );\n }\n\n async clearInput(element: ElementInfo) {\n if (!element) {\n console.warn('No element to clear input');\n return;\n }\n\n await this.mouse.click(element.center[0], element.center[1]);\n\n await this.sendCommandToDebugger('Input.dispatchKeyEvent', {\n type: 'keyDown',\n commands: ['selectAll'],\n });\n\n await this.sendCommandToDebugger('Input.dispatchKeyEvent', {\n type: 'keyUp',\n commands: ['selectAll'],\n });\n\n await sleep(100);\n\n await this.keyboard.press({\n key: 'Backspace',\n });\n }\n\n private latestMouseX = 100;\n private latestMouseY = 100;\n\n mouse = {\n click: async (x: number, y: number) => {\n await this.mouse.move(x, y);\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mousePressed',\n x,\n y,\n button: 'left',\n clickCount: 1,\n });\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mouseReleased',\n x,\n y,\n button: 'left',\n clickCount: 1,\n });\n },\n wheel: async (\n deltaX: number,\n deltaY: number,\n startX?: number,\n startY?: number,\n ) => {\n const finalX = startX || this.latestMouseX;\n const finalY = startY || this.latestMouseY;\n await this.showMousePointer(finalX, finalY);\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mouseWheel',\n x: finalX,\n y: finalY,\n deltaX,\n deltaY,\n });\n this.latestMouseX = finalX;\n this.latestMouseY = finalY;\n },\n move: async (x: number, y: number) => {\n await this.showMousePointer(x, y);\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mouseMoved',\n x,\n y,\n });\n this.latestMouseX = x;\n this.latestMouseY = y;\n },\n drag: async (\n from: { x: number; y: number },\n to: { x: number; y: number },\n ) => {\n await this.mouse.move(from.x, from.y);\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mousePressed',\n x: from.x,\n y: from.y,\n button: 'left',\n clickCount: 1,\n });\n await this.mouse.move(to.x, to.y);\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mouseReleased',\n x: to.x,\n y: to.y,\n button: 'left',\n clickCount: 1,\n });\n },\n };\n\n keyboard = {\n type: async (text: string) => {\n const cdpKeyboard = new CdpKeyboard({\n send: this.sendCommandToDebugger.bind(this),\n });\n await cdpKeyboard.type(text, { delay: 0 });\n },\n press: async (\n action:\n | { key: WebKeyInput; command?: string }\n | { key: WebKeyInput; command?: string }[],\n ) => {\n const cdpKeyboard = new CdpKeyboard({\n send: this.sendCommandToDebugger.bind(this),\n });\n const keys = Array.isArray(action) ? action : [action];\n for (const k of keys) {\n const commands = k.command ? [k.command] : [];\n await cdpKeyboard.down(k.key, { commands });\n }\n for (const k of [...keys].reverse()) {\n await cdpKeyboard.up(k.key);\n }\n },\n };\n\n async destroy(): Promise<void> {\n this.activeTabId = null;\n await this.detachDebugger();\n this.destroyed = true;\n }\n}\n","// From https://github.com/puppeteer/puppeteer/blob/15abcc390862fd08cc3475532f2d9a11284aee6b/packages/puppeteer-core/src/cdp/Input.ts#L55\n// with some modifications to fit the session type\n/**\n * @license\n * Copyright 2017 Google Inc.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n type KeyDefinition,\n type KeyInput,\n _keyDefinitions,\n} from '@midscene/shared/keyboard-layout';\nimport { assert } from '@midscene/shared/utils';\n\ntype KeyDescription = Required<\n Pick<KeyDefinition, 'keyCode' | 'key' | 'text' | 'code' | 'location'>\n>;\n\n/**\n * @public\n */\nexport interface KeyDownOptions {\n /**\n * @deprecated Do not use. This is automatically handled.\n */\n text?: string;\n /**\n * @deprecated Do not use. This is automatically handled.\n */\n commands?: string[];\n}\n\n/**\n * @public\n */\nexport interface KeyboardTypeOptions {\n delay?: number;\n}\n\n/**\n * @public\n */\nexport type KeyPressOptions = KeyDownOptions & KeyboardTypeOptions;\n\ntype InternalCDPSession = {\n send: (command: string, params: any) => Promise<void>;\n};\n\n/**\n * @internal\n */\nexport class CdpKeyboard {\n #pressedKeys = new Set<string>();\n\n #client: InternalCDPSession;\n\n _modifiers = 0;\n\n constructor(client: InternalCDPSession) {\n this.#client = client;\n }\n\n updateClient(client: InternalCDPSession): void {\n this.#client = client;\n }\n\n async down(\n key: KeyInput,\n options: Readonly<KeyDownOptions> = {\n text: undefined,\n commands: [],\n },\n ): Promise<void> {\n const description = this.#keyDescriptionForString(key);\n\n const autoRepeat = this.#pressedKeys.has(description.code);\n this.#pressedKeys.add(description.code);\n this._modifiers |= this.#modifierBit(description.key);\n\n const text = options.text === undefined ? description.text : options.text;\n await this.#client.send('Input.dispatchKeyEvent', {\n type: text ? 'keyDown' : 'rawKeyDown',\n modifiers: this._modifiers,\n windowsVirtualKeyCode: description.keyCode,\n code: description.code,\n key: description.key,\n text: text,\n unmodifiedText: text,\n autoRepeat,\n location: description.location,\n isKeypad: description.location === 3,\n commands: options.commands,\n });\n }\n\n #modifierBit(key: string): number {\n if (key === 'Alt') {\n return 1;\n }\n if (key === 'Control') {\n return 2;\n }\n if (key === 'Meta') {\n return 4;\n }\n if (key === 'Shift') {\n return 8;\n }\n return 0;\n }\n\n #keyDescriptionForString(keyString: KeyInput): KeyDescription {\n const shift = this._modifiers & 8;\n const description = {\n key: '',\n keyCode: 0,\n code: '',\n text: '',\n location: 0,\n };\n\n const definition = _keyDefinitions[keyString];\n\n assert(definition, `Unknown key: \"${keyString}\"`);\n\n if (definition.key) {\n description.key = definition.key;\n }\n if (shift && definition.shiftKey) {\n description.key = definition.shiftKey;\n }\n\n if (definition.keyCode) {\n description.keyCode = definition.keyCode;\n }\n if (shift && definition.shiftKeyCode) {\n description.keyCode = definition.shiftKeyCode;\n }\n\n if (definition.code) {\n description.code = definition.code;\n }\n\n if (definition.location) {\n description.location = definition.location;\n }\n\n if (description.key.length === 1) {\n description.text = description.key;\n }\n\n if (definition.text) {\n description.text = definition.text;\n }\n if (shift && definition.shiftText) {\n description.text = definition.shiftText;\n }\n\n // if any modifiers besides shift are pressed, no text should be sent\n if (this._modifiers & ~8) {\n description.text = '';\n }\n\n return description;\n }\n\n async up(key: KeyInput): Promise<void> {\n const description = this.#keyDescriptionForString(key);\n\n this._modifiers &= ~this.#modifierBit(description.key);\n this.#pressedKeys.delete(description.code);\n await this.#client.send('Input.dispatchKeyEvent', {\n type: 'keyUp',\n modifiers: this._modifiers,\n key: description.key,\n windowsVirtualKeyCode: description.keyCode,\n code: description.code,\n location: description.location,\n });\n }\n\n async sendCharacter(char: string): Promise<void> {\n await this.#client.send('Input.insertText', { text: char });\n }\n\n private charIsKey(char: string): char is KeyInput {\n return !!_keyDefinitions[char as KeyInput];\n }\n\n async type(\n text: string,\n options: Readonly<KeyboardTypeOptions> = {},\n ): Promise<void> {\n const delay = options.delay || undefined;\n for (const char of text) {\n if (this.charIsKey(char)) {\n await this.press(char, { delay });\n } else {\n if (delay) {\n await new Promise((f) => {\n return setTimeout(f, delay);\n });\n }\n await this.sendCharacter(char);\n }\n }\n }\n\n async press(\n key: KeyInput | KeyInput[],\n options: Readonly<KeyPressOptions> = {},\n ): Promise<void> {\n const { delay = null } = options;\n const keys = Array.isArray(key) ? key : [key];\n\n for (const k of keys) {\n await this.down(k, options);\n }\n\n if (delay) {\n await new Promise((f) => {\n return setTimeout(f, options.delay);\n });\n }\n\n for (const k of [...keys].reverse()) {\n await this.up(k);\n }\n }\n}\n","import fs from 'node:fs';\nimport { ifInBrowser } from '@midscene/shared/utils';\n\n// remember to include this file into extension's package\n// extract html element from page\nlet scriptFileContentCache: string | null = null;\nexport const getHtmlElementScript = async () => {\n const scriptFileToRetrieve = chrome.runtime.getURL('scripts/htmlElement.js');\n if (scriptFileContentCache) return scriptFileContentCache;\n if (ifInBrowser) {\n const script = await fetch(scriptFileToRetrieve);\n scriptFileContentCache = await script.text();\n return scriptFileContentCache;\n }\n return fs.readFileSync(scriptFileToRetrieve, 'utf8');\n};\n\n// inject water flow animation\nlet waterFlowScriptFileContentCache: string | null = null;\nexport const injectWaterFlowAnimation = async () => {\n const waterFlowScriptFileToRetrieve = chrome.runtime.getURL(\n 'scripts/water-flow.js',\n );\n if (waterFlowScriptFileContentCache) return waterFlowScriptFileContentCache;\n if (ifInBrowser) {\n const script = await fetch(waterFlowScriptFileToRetrieve);\n waterFlowScriptFileContentCache = await script.text();\n return waterFlowScriptFileContentCache;\n }\n return fs.readFileSync(waterFlowScriptFileToRetrieve, 'utf8');\n};\n\n// inject stop water flow animation\nlet stopWaterFlowScriptFileContentCache: string | null = null;\nexport const injectStopWaterFlowAnimation = async () => {\n const stopWaterFlowScriptFileToRetrieve = chrome.runtime.getURL(\n 'scripts/stop-water-flow.js',\n );\n if (stopWaterFlowScriptFileContentCache)\n return stopWaterFlowScriptFileContentCache;\n if (ifInBrowser) {\n const script = await fetch(stopWaterFlowScriptFileToRetrieve);\n stopWaterFlowScriptFileContentCache = await script.text();\n return stopWaterFlowScriptFileContentCache;\n }\n return fs.readFileSync(stopWaterFlowScriptFileToRetrieve, 'utf8');\n};\n","export const DefaultBridgeServerPort = 3766;\nexport const DefaultLocalEndpoint = `http://127.0.0.1:${DefaultBridgeServerPort}`;\nexport const BridgeCallTimeout = 30000;\n\nexport enum BridgeEvent {\n Call = 'bridge-call',\n CallResponse = 'bridge-call-response',\n UpdateAgentStatus = 'bridge-update-agent-status',\n Message = 'bridge-message',\n Connected = 'bridge-connected',\n Refused = 'bridge-refused',\n ConnectNewTabWithUrl = 'connectNewTabWithUrl',\n ConnectCurrentTab = 'connectCurrentTab',\n GetBrowserTabList = 'getBrowserTabList',\n SetDestroyOptions = 'setDestroyOptions',\n SetActiveTabId = 'setActiveTabId',\n}\n\nexport interface BridgeConnectTabOptions {\n /**\n * If true, the page will always track the active tab.\n * @default true\n */\n forceSameTabNavigation?: boolean;\n}\n\nexport enum MouseEvent {\n PREFIX = 'mouse.',\n Click = 'mouse.click',\n Wheel = 'mouse.wheel',\n Move = 'mouse.move',\n Drag = 'mouse.drag',\n}\n\nexport enum KeyboardEvent {\n PREFIX = 'keyboard.',\n Type = 'keyboard.type',\n Press = 'keyboard.press',\n}\n\nexport const BridgePageType = 'page-over-chrome-extension-bridge';\n\nexport const BridgeErrorCodeNoClientConnected = 'no-client-connected';\n\nexport interface BridgeCall {\n method: string;\n args: any[];\n response: any;\n callTime: number;\n responseTime: number;\n callback: (error: Error | undefined, response: any) => void;\n error?: Error;\n}\n\nexport interface BridgeCallRequest {\n id: string;\n method: string;\n args: any[];\n}\n\nexport interface BridgeCallResponse {\n id: string;\n response: any;\n error?: any;\n}\n\nexport interface BridgeConnectedEventPayload {\n version: string;\n}\n","import { assert } from '@midscene/shared/utils';\nimport { io as ClientIO, type Socket as ClientSocket } from 'socket.io-client';\nimport {\n type BridgeCallRequest,\n type BridgeCallResponse,\n type BridgeConnectedEventPayload,\n BridgeEvent,\n} from './common';\n\ndeclare const __VERSION__: string;\n\n// ws client, this is where the request is processed\nexport class BridgeClient {\n private socket: ClientSocket | null = null;\n public serverVersion: string | null = null;\n constructor(\n public endpoint: string,\n public onBridgeCall: (method: string, args: any[]) => Promise<any>,\n public onDisconnect?: () => void,\n ) {}\n\n async connect() {\n return new Promise((resolve, reject) => {\n this.socket = ClientIO(this.endpoint, {\n reconnection: false,\n query: {\n version: __VERSION__,\n },\n });\n\n const timeout = setTimeout(() => {\n try {\n this.socket?.offAny();\n this.socket?.close();\n } catch (e) {\n console.warn('got error when offing socket', e);\n }\n this.socket = null;\n reject(new Error('failed to connect to bridge server after timeout'));\n }, 1 * 1000);\n\n // on disconnect\n this.socket.on('disconnect', (reason: string) => {\n // console.log('bridge-disconnected, reason:', reason);\n this.socket = null;\n this.onDisconnect?.();\n });\n\n this.socket.on('connect_error', (e: any) => {\n console.error('bridge-connect-error', e);\n reject(new Error(e || 'bridge connect error'));\n });\n\n this.socket.on(\n BridgeEvent.Connected,\n (payload: BridgeConnectedEventPayload) => {\n clearTimeout(timeout);\n this.serverVersion = payload?.version || 'unknown';\n resolve(this.socket);\n },\n );\n this.socket.on(BridgeEvent.Refused, (e: any) => {\n console.error('bridge-refused', e);\n try {\n this.socket?.disconnect();\n } catch (e) {\n // console.warn('got error when disconnecting socket', e);\n }\n reject(new Error(e || 'bridge refused'));\n });\n this.socket.on(BridgeEvent.Call, (call: BridgeCallRequest) => {\n const id = call.id;\n assert(typeof id !== 'undefined', 'call id is required');\n (async () => {\n let response: any;\n try {\n response = await this.onBridgeCall(call.method, call.args);\n } catch (e: any) {\n const errorContent = `Error from bridge client when calling, method: ${call.method}, args: ${call.args}, error: ${e?.message || e}\\n${e?.stack || ''}`;\n console.error(errorContent);\n return this.socket?.emit(BridgeEvent.CallResponse, {\n id,\n error: errorContent,\n } as BridgeCallResponse);\n }\n this.socket?.emit(BridgeEvent.CallResponse, {\n id,\n response,\n } as BridgeCallResponse);\n })();\n });\n });\n }\n\n disconnect() {\n this.socket?.disconnect();\n this.socket = null;\n }\n}\n"]}
1
+ {"version":3,"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAKA,SAAS,UAAAA,eAAc;;;ACyHhB,IAAM,wBA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,gBAAgB,YAAY,KAAK,mBAAmB,SAAS,GAAG;AACvE,WAAK,aAAa,+CAA+C,KAAK;AACtE,iBAAW,SAAS,KAAK,oBAAoB;AAC3C,cAAM,OAAO,KAAK,OAAO,KAAK;AAAA,MAChC;AACA,WAAK,qBAAqB,CAAC;AAAA,IAC7B;AAEA,UAAM,MAAM,QAAQ;AAEpB,QAAI,KAAK,cAAc;AACrB,WAAK,aAAa,WAAW;AAC7B,WAAK,eAAe;AACpB,WAAK,aAAa;AAAA,IACpB;AAAA,EACF;AACF","names":["assert","error","e"],"ignoreList":[],"sources":["../../src/bridge-mode/page-browser-side.ts","../../src/common/ui-utils.ts","../../src/chrome-extension/page.ts","../../src/chrome-extension/cdpInput.ts","../../src/chrome-extension/dynamic-scripts.ts","../../src/bridge-mode/common.ts","../../src/bridge-mode/io-client.ts"],"sourcesContent":["import type {\n ChromePageDestroyOptions,\n KeyboardAction,\n MouseAction,\n} from '@/page';\nimport { assert } from '@midscene/shared/utils';\nimport ChromeExtensionProxyPage from '../chrome-extension/page';\nimport {\n type BridgeConnectTabOptions,\n BridgeEvent,\n DefaultBridgeServerPort,\n KeyboardEvent,\n MouseEvent,\n} from './common';\nimport { BridgeClient } from './io-client';\n\ndeclare const __VERSION__: string;\n\nexport class ExtensionBridgePageBrowserSide extends ChromeExtensionProxyPage {\n public bridgeClient: BridgeClient | null = null;\n\n private destroyOptions?: ChromePageDestroyOptions;\n\n private newlyCreatedTabIds: number[] = [];\n\n constructor(\n public onDisconnect: () => void = () => {},\n public onLogMessage: (\n message: string,\n type: 'log' | 'status',\n ) => void = () => {},\n forceSameTabNavigation = true,\n ) {\n super(forceSameTabNavigation);\n }\n\n private async setupBridgeClient() {\n this.bridgeClient = new BridgeClient(\n `ws://localhost:${DefaultBridgeServerPort}`,\n async (method, args: any[]) => {\n console.log('bridge call from cli side', method, args);\n if (method === BridgeEvent.ConnectNewTabWithUrl) {\n return this.connectNewTabWithUrl.apply(\n this,\n args as unknown as [string],\n );\n }\n\n if (method === BridgeEvent.GetBrowserTabList) {\n return this.getBrowserTabList.apply(this, args as any);\n }\n\n if (method === BridgeEvent.SetActiveTabId) {\n return this.setActiveTabId.apply(this, args as any);\n }\n\n if (method === BridgeEvent.ConnectCurrentTab) {\n return this.connectCurrentTab.apply(this, args as any);\n }\n\n if (method === BridgeEvent.UpdateAgentStatus) {\n return this.onLogMessage(args[0] as string, 'status');\n }\n\n const tabId = await this.getActiveTabId();\n if (!tabId || tabId === 0) {\n throw new Error('no tab is connected');\n }\n\n // this.onLogMessage(`calling method: ${method}`);\n\n if (method.startsWith(MouseEvent.PREFIX)) {\n const actionName = method.split('.')[1] as keyof MouseAction;\n if (actionName === 'drag') {\n return this.mouse[actionName].apply(this.mouse, args as any);\n }\n return this.mouse[actionName].apply(this.mouse, args as any);\n }\n\n if (method.startsWith(KeyboardEvent.PREFIX)) {\n const actionName = method.split('.')[1] as keyof KeyboardAction;\n if (actionName === 'press') {\n return this.keyboard[actionName].apply(this.keyboard, args as any);\n }\n return this.keyboard[actionName].apply(this.keyboard, args as any);\n }\n\n try {\n // @ts-expect-error\n const result = await this[method as keyof ChromeExtensionProxyPage](\n ...args,\n );\n return result;\n } catch (e) {\n const errorMessage = e instanceof Error ? e.message : 'Unknown error';\n console.error('error calling method', method, args, e);\n this.onLogMessage(\n `Error calling method: ${method}, ${errorMessage}`,\n 'log',\n );\n throw new Error(errorMessage, { cause: e });\n }\n },\n // on disconnect\n () => {\n return this.destroy();\n },\n );\n await this.bridgeClient.connect();\n this.onLogMessage(\n `Bridge connected, cli-side version v${this.bridgeClient.serverVersion}, browser-side version v${__VERSION__}`,\n 'log',\n );\n }\n\n public async connect() {\n return await this.setupBridgeClient();\n }\n\n public async connectNewTabWithUrl(\n url: string,\n options: BridgeConnectTabOptions = {\n forceSameTabNavigation: true,\n },\n ) {\n const tab = await chrome.tabs.create({ url });\n const tabId = tab.id;\n assert(tabId, 'failed to get tabId after creating a new tab');\n\n // new tab\n this.onLogMessage(`Creating new tab: ${url}`, 'log');\n this.newlyCreatedTabIds.push(tabId);\n\n if (options?.forceSameTabNavigation) {\n this.forceSameTabNavigation = true;\n }\n\n await this.setActiveTabId(tabId);\n }\n\n public async connectCurrentTab(\n options: BridgeConnectTabOptions = {\n forceSameTabNavigation: true,\n },\n ) {\n const tabs = await chrome.tabs.query({ active: true, currentWindow: true });\n console.log('current tab', tabs);\n const tabId = tabs[0]?.id;\n assert(tabId, 'failed to get tabId');\n\n this.onLogMessage(`Connected to current tab: ${tabs[0]?.url}`, 'log');\n\n if (options?.forceSameTabNavigation) {\n this.forceSameTabNavigation = true;\n }\n\n await this.setActiveTabId(tabId);\n }\n\n public async setDestroyOptions(options: ChromePageDestroyOptions) {\n this.destroyOptions = options;\n }\n\n async destroy() {\n if (this.destroyOptions?.closeTab && this.newlyCreatedTabIds.length > 0) {\n this.onLogMessage('Closing all newly created tabs by bridge...', 'log');\n for (const tabId of this.newlyCreatedTabIds) {\n await chrome.tabs.remove(tabId);\n }\n this.newlyCreatedTabIds = [];\n }\n\n await super.destroy();\n\n if (this.bridgeClient) {\n this.bridgeClient.disconnect();\n this.bridgeClient = null;\n this.onDisconnect();\n }\n }\n}\n","import type {\n DetailedLocateParam,\n ExecutionTask,\n ExecutionTaskAction,\n ExecutionTaskInsightAssertion,\n ExecutionTaskInsightLocate,\n ExecutionTaskInsightQuery,\n ExecutionTaskPlanning,\n PlanningActionParamScroll,\n} from '@midscene/core';\n\nexport function typeStr(task: ExecutionTask) {\n return task.subType ? `${task.type} / ${task.subType || ''}` : task.type;\n}\n\nexport function getKeyCommands(\n value: string | string[],\n): Array<{ key: string; command?: string }> {\n // Ensure value is an array of keys\n const keys = Array.isArray(value) ? value : [value];\n\n // Process each key to attach a corresponding command if needed, based on the presence of 'Meta' or 'Control' in the keys array.\n // ref: https://github.com/puppeteer/puppeteer/pull/9357/files#diff-32cf475237b000f980eb214a0a823e45a902bddb7d2426d677cae96397aa0ae4R94\n return keys.reduce((acc: Array<{ key: string; command?: string }>, k) => {\n const includeMeta = keys.includes('Meta') || keys.includes('Control');\n if (includeMeta && (k === 'a' || k === 'A')) {\n return acc.concat([{ key: k, command: 'SelectAll' }]);\n }\n if (includeMeta && (k === 'c' || k === 'C')) {\n return acc.concat([{ key: k, command: 'Copy' }]);\n }\n if (includeMeta && (k === 'v' || k === 'V')) {\n return acc.concat([{ key: k, command: 'Paste' }]);\n }\n return acc.concat([{ key: k }]);\n }, []);\n}\n\nexport function locateParamStr(locate?: DetailedLocateParam) {\n if (!locate) {\n return '';\n }\n\n if (typeof locate === 'string') {\n return locate;\n }\n\n return locate.prompt;\n}\n\nexport function scrollParamStr(scrollParam?: PlanningActionParamScroll) {\n if (!scrollParam) {\n return '';\n }\n return `${scrollParam.direction || 'down'}, ${scrollParam.scrollType || 'once'}, ${scrollParam.distance || 'distance-not-set'}`;\n}\n\nexport function taskTitleStr(\n type:\n | 'Tap'\n | 'Hover'\n | 'Input'\n | 'KeyboardPress'\n | 'Scroll'\n | 'Action'\n | 'Query'\n | 'Assert'\n | 'WaitFor'\n | 'Locate'\n | 'Boolean'\n | 'Number'\n | 'String',\n prompt: string,\n) {\n if (prompt) {\n return `${type} - ${prompt}`;\n }\n return type;\n}\n\nexport function paramStr(task: ExecutionTask) {\n let value: string | undefined | object;\n if (task.type === 'Planning') {\n value = (task as ExecutionTaskPlanning)?.param?.userInstruction;\n }\n\n if (task.type === 'Insight') {\n value =\n (task as ExecutionTaskInsightLocate)?.param?.prompt ||\n (task as ExecutionTaskInsightLocate)?.param?.id ||\n (task as ExecutionTaskInsightQuery)?.param?.dataDemand ||\n (task as ExecutionTaskInsightAssertion)?.param?.assertion;\n }\n\n if (task.type === 'Action') {\n const locate = (task as ExecutionTaskAction)?.locate;\n const locateStr = locate ? locateParamStr(locate) : '';\n\n value = task.thought || '';\n if (typeof (task as ExecutionTaskAction)?.param?.timeMs === 'number') {\n value = `${(task as ExecutionTaskAction)?.param?.timeMs}ms`;\n } else if (\n typeof (task as ExecutionTaskAction)?.param?.scrollType === 'string'\n ) {\n value = scrollParamStr((task as ExecutionTaskAction)?.param);\n } else if (\n typeof (task as ExecutionTaskAction)?.param?.value !== 'undefined'\n ) {\n value = (task as ExecutionTaskAction)?.param?.value;\n }\n\n if (locateStr) {\n if (value) {\n value = `${locateStr} - ${value}`;\n } else {\n value = locateStr;\n }\n }\n }\n\n if (typeof value === 'undefined') return '';\n return typeof value === 'string'\n ? value\n : JSON.stringify(value, undefined, 2);\n}\n\nexport const limitOpenNewTabScript = `\nif (!window.__MIDSCENE_NEW_TAB_INTERCEPTOR_INITIALIZED__) {\n window.__MIDSCENE_NEW_TAB_INTERCEPTOR_INITIALIZED__ = true;\n\n // Intercept the window.open method (only once)\n window.open = function(url) {\n console.log('Blocked window.open:', url);\n window.location.href = url;\n return null;\n };\n\n // Block all a tag clicks with target=\"_blank\" (only once)\n document.addEventListener('click', function(e) {\n const target = e.target.closest('a');\n if (target && target.target === '_blank') {\n e.preventDefault();\n console.log('Blocked new tab:', target.href);\n window.location.href = target.href;\n target.removeAttribute('target');\n }\n }, true);\n}\n`;\n","/// <reference types=\"chrome\" />\n\n/*\n It is used to interact with the page tab from the chrome extension.\n The page must be active when interacting with it.\n*/\n\nimport type { WebKeyInput } from '@/common/page';\nimport { limitOpenNewTabScript } from '@/common/ui-utils';\nimport type { AbstractPage, ChromePageDestroyOptions } from '@/page';\nimport type { ElementTreeNode, Point, Size } from '@midscene/core';\nimport type { ElementInfo } from '@midscene/shared/extractor';\nimport { treeToList } from '@midscene/shared/extractor';\nimport { assert } from '@midscene/shared/utils';\nimport type { Protocol as CDPTypes } from 'devtools-protocol';\nimport { CdpKeyboard } from './cdpInput';\nimport {\n getHtmlElementScript,\n injectStopWaterFlowAnimation,\n injectWaterFlowAnimation,\n} from './dynamic-scripts';\n\nfunction sleep(ms: number) {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\ndeclare const __VERSION__: string;\n\nexport default class ChromeExtensionProxyPage implements AbstractPage {\n pageType = 'chrome-extension-proxy';\n\n public forceSameTabNavigation: boolean;\n private version: string = __VERSION__;\n\n private viewportSize?: Size;\n\n private activeTabId: number | null = null;\n\n private tabIdOfDebuggerAttached: number | null = null;\n\n private attachingDebugger: Promise<void> | null = null;\n\n private destroyed = false;\n\n constructor(forceSameTabNavigation: boolean) {\n this.forceSameTabNavigation = forceSameTabNavigation;\n }\n\n public async setActiveTabId(tabId: number) {\n if (this.activeTabId) {\n throw new Error(\n `Active tab id is already set, which is ${this.activeTabId}, cannot set it to ${tabId}`,\n );\n }\n await chrome.tabs.update(tabId, { active: true });\n this.activeTabId = tabId;\n }\n\n public async getActiveTabId() {\n return this.activeTabId;\n }\n\n /**\n * Get a list of current tabs\n * @returns {Promise<Array<{id: number, title: string, url: string}>>}\n */\n public async getBrowserTabList(): Promise<\n { id: string; title: string; url: string; currentActiveTab: boolean }[]\n > {\n const tabs = await chrome.tabs.query({ currentWindow: true });\n return tabs\n .map((tab) => ({\n id: `${tab.id}`,\n title: tab.title,\n url: tab.url,\n currentActiveTab: tab.active,\n }))\n .filter((tab) => tab.id && tab.title && tab.url) as {\n id: string;\n title: string;\n url: string;\n currentActiveTab: boolean;\n }[];\n }\n\n public async getTabIdOrConnectToCurrentTab() {\n if (this.activeTabId) {\n // alway keep on the connected tab\n return this.activeTabId;\n }\n const tabId = await chrome.tabs\n .query({ active: true, currentWindow: true })\n .then((tabs) => tabs[0]?.id);\n this.activeTabId = tabId || 0;\n return this.activeTabId;\n }\n\n private async attachDebugger() {\n assert(!this.destroyed, 'Page is destroyed');\n\n // If already attaching, wait for it to complete\n if (this.attachingDebugger) {\n await this.attachingDebugger;\n return;\n }\n\n // Create new attaching promise\n this.attachingDebugger = (async () => {\n const url = await this.url();\n let error: Error | null = null;\n if (url.startsWith('chrome://')) {\n throw new Error(\n 'Cannot attach debugger to chrome:// pages, please use Midscene in a normal page with http://, https:// or file://',\n );\n }\n\n try {\n const currentTabId = await this.getTabIdOrConnectToCurrentTab();\n\n if (this.tabIdOfDebuggerAttached === currentTabId) {\n // already attached\n return;\n }\n if (\n this.tabIdOfDebuggerAttached &&\n this.tabIdOfDebuggerAttached !== currentTabId\n ) {\n // detach the previous tab\n console.log(\n 'detach the previous tab',\n this.tabIdOfDebuggerAttached,\n '->',\n currentTabId,\n );\n try {\n await this.detachDebugger(this.tabIdOfDebuggerAttached);\n } catch (error) {\n console.error('Failed to detach debugger', error);\n }\n }\n\n // detach any debugger attached to the tab\n console.log('attaching debugger', currentTabId);\n await chrome.debugger.attach({ tabId: currentTabId }, '1.3');\n // wait util the debugger banner in Chrome appears\n await sleep(500);\n\n this.tabIdOfDebuggerAttached = currentTabId;\n\n await this.enableWaterFlowAnimation();\n } catch (e) {\n console.error('Failed to attach debugger', e);\n error = e as Error;\n } finally {\n this.attachingDebugger = null;\n }\n if (error) {\n throw error;\n }\n })();\n\n await this.attachingDebugger;\n }\n\n private async showMousePointer(x: number, y: number) {\n // update mouse pointer while redirecting\n const pointerScript = `(() => {\n if(typeof window.midsceneWaterFlowAnimation !== 'undefined') {\n window.midsceneWaterFlowAnimation.enable();\n window.midsceneWaterFlowAnimation.showMousePointer(${x}, ${y});\n } else {\n console.log('midsceneWaterFlowAnimation is not defined');\n }\n })()`;\n\n await this.sendCommandToDebugger('Runtime.evaluate', {\n expression: `${pointerScript}`,\n });\n }\n\n private async hideMousePointer() {\n await this.sendCommandToDebugger('Runtime.evaluate', {\n expression: `(() => {\n if(typeof window.midsceneWaterFlowAnimation !== 'undefined') {\n window.midsceneWaterFlowAnimation.hideMousePointer();\n }\n })()`,\n });\n }\n\n private async detachDebugger(tabId?: number) {\n const tabIdToDetach = tabId || this.tabIdOfDebuggerAttached;\n console.log('detaching debugger', tabIdToDetach);\n if (!tabIdToDetach) {\n console.warn('No tab id to detach');\n return;\n }\n\n try {\n await this.disableWaterFlowAnimation(tabIdToDetach);\n await sleep(200); // wait for the animation to stop\n } catch (error) {\n console.warn('Failed to disable water flow animation', error);\n }\n\n try {\n await chrome.debugger.detach({ tabId: tabIdToDetach });\n } catch (error) {\n // maybe tab is closed ?\n console.warn('Failed to detach debugger', error);\n }\n this.tabIdOfDebuggerAttached = null;\n }\n\n private async enableWaterFlowAnimation() {\n // limit open page in new tab\n if (this.forceSameTabNavigation) {\n await chrome.debugger.sendCommand(\n { tabId: this.tabIdOfDebuggerAttached! },\n 'Runtime.evaluate',\n {\n expression: limitOpenNewTabScript,\n },\n );\n }\n\n const script = await injectWaterFlowAnimation();\n // we will call this function in sendCommandToDebugger, so we have to use the chrome.debugger.sendCommand\n await chrome.debugger.sendCommand(\n { tabId: this.tabIdOfDebuggerAttached! },\n 'Runtime.evaluate',\n {\n expression: script,\n },\n );\n }\n\n private async disableWaterFlowAnimation(tabId: number) {\n const script = await injectStopWaterFlowAnimation();\n\n await chrome.debugger.sendCommand({ tabId }, 'Runtime.evaluate', {\n expression: script,\n });\n }\n\n private async sendCommandToDebugger<ResponseType = any, RequestType = any>(\n command: string,\n params: RequestType,\n ): Promise<ResponseType> {\n await this.attachDebugger();\n\n assert(this.tabIdOfDebuggerAttached, 'Debugger is not attached');\n\n // wo don't have to await it\n this.enableWaterFlowAnimation();\n return (await chrome.debugger.sendCommand(\n { tabId: this.tabIdOfDebuggerAttached! },\n command,\n params as any,\n )) as ResponseType;\n }\n\n private async getPageContentByCDP() {\n const script = await getHtmlElementScript();\n\n // check tab url\n await this.sendCommandToDebugger<\n CDPTypes.Runtime.EvaluateResponse,\n CDPTypes.Runtime.EvaluateRequest\n >('Runtime.evaluate', {\n expression: script,\n });\n\n const expression = () => {\n return {\n tree: (window as any).midscene_element_inspector.webExtractNodeTree(),\n size: {\n width: document.documentElement.clientWidth,\n height: document.documentElement.clientHeight,\n dpr: window.devicePixelRatio,\n },\n };\n };\n const returnValue = await this.sendCommandToDebugger<\n CDPTypes.Runtime.EvaluateResponse,\n CDPTypes.Runtime.EvaluateRequest\n >('Runtime.evaluate', {\n expression: `(${expression.toString()})()`,\n returnByValue: true,\n });\n\n if (!returnValue.result.value) {\n const errorDescription =\n returnValue.exceptionDetails?.exception?.description || '';\n if (!errorDescription) {\n console.error('returnValue from cdp', returnValue);\n }\n throw new Error(\n `Failed to get page content from page, error: ${errorDescription}`,\n );\n }\n // console.log('returnValue', returnValue.result.value);\n return returnValue.result.value as {\n tree: ElementTreeNode<ElementInfo>;\n size: Size;\n };\n }\n\n public async evaluateJavaScript(script: string) {\n return this.sendCommandToDebugger('Runtime.evaluate', {\n expression: script,\n });\n }\n\n // current implementation is wait until domReadyState is complete\n public async waitUntilNetworkIdle() {\n const timeout = 10000;\n const startTime = Date.now();\n let lastReadyState = '';\n while (Date.now() - startTime < timeout) {\n const result = await this.sendCommandToDebugger('Runtime.evaluate', {\n expression: 'document.readyState',\n });\n lastReadyState = result.result.value;\n if (lastReadyState === 'complete') {\n await new Promise((resolve) => setTimeout(resolve, 300));\n return;\n }\n await new Promise((resolve) => setTimeout(resolve, 300));\n }\n throw new Error(\n `Failed to wait until network idle, last readyState: ${lastReadyState}`,\n );\n }\n\n async getElementsInfo() {\n const tree = await this.getElementsNodeTree();\n return treeToList(tree);\n }\n\n async getElementsNodeTree() {\n await this.hideMousePointer();\n const content = await this.getPageContentByCDP();\n if (content?.size) {\n this.viewportSize = content.size;\n }\n\n return content?.tree || { node: null, children: [] };\n }\n\n async size() {\n if (this.viewportSize) return this.viewportSize;\n const content = await this.getPageContentByCDP();\n return content.size;\n }\n\n async screenshotBase64() {\n // screenshot by cdp\n await this.hideMousePointer();\n const base64 = await this.sendCommandToDebugger('Page.captureScreenshot', {\n format: 'jpeg',\n quality: 90,\n });\n return `data:image/jpeg;base64,${base64.data}`;\n }\n\n async url() {\n const tabId = await this.getTabIdOrConnectToCurrentTab();\n const url = await chrome.tabs.get(tabId).then((tab) => tab.url);\n return url || '';\n }\n\n async scrollUntilTop(startingPoint?: Point) {\n if (startingPoint) {\n await this.mouse.move(startingPoint.left, startingPoint.top);\n }\n return this.mouse.wheel(0, -9999999);\n }\n\n async scrollUntilBottom(startingPoint?: Point) {\n if (startingPoint) {\n await this.mouse.move(startingPoint.left, startingPoint.top);\n }\n return this.mouse.wheel(0, 9999999);\n }\n\n async scrollUntilLeft(startingPoint?: Point) {\n if (startingPoint) {\n await this.mouse.move(startingPoint.left, startingPoint.top);\n }\n return this.mouse.wheel(-9999999, 0);\n }\n\n async scrollUntilRight(startingPoint?: Point) {\n if (startingPoint) {\n await this.mouse.move(startingPoint.left, startingPoint.top);\n }\n return this.mouse.wheel(9999999, 0);\n }\n\n async scrollUp(distance?: number, startingPoint?: Point) {\n const { height } = await this.size();\n const scrollDistance = distance || height * 0.7;\n return this.mouse.wheel(\n 0,\n -scrollDistance,\n startingPoint?.left,\n startingPoint?.top,\n );\n }\n\n async scrollDown(distance?: number, startingPoint?: Point) {\n const { height } = await this.size();\n const scrollDistance = distance || height * 0.7;\n return this.mouse.wheel(\n 0,\n scrollDistance,\n startingPoint?.left,\n startingPoint?.top,\n );\n }\n\n async scrollLeft(distance?: number, startingPoint?: Point) {\n const { width } = await this.size();\n const scrollDistance = distance || width * 0.7;\n return this.mouse.wheel(\n -scrollDistance,\n 0,\n startingPoint?.left,\n startingPoint?.top,\n );\n }\n\n async scrollRight(distance?: number, startingPoint?: Point) {\n const { width } = await this.size();\n const scrollDistance = distance || width * 0.7;\n return this.mouse.wheel(\n scrollDistance,\n 0,\n startingPoint?.left,\n startingPoint?.top,\n );\n }\n\n async clearInput(element: ElementInfo) {\n if (!element) {\n console.warn('No element to clear input');\n return;\n }\n\n await this.mouse.click(element.center[0], element.center[1]);\n\n await this.sendCommandToDebugger('Input.dispatchKeyEvent', {\n type: 'keyDown',\n commands: ['selectAll'],\n });\n\n await this.sendCommandToDebugger('Input.dispatchKeyEvent', {\n type: 'keyUp',\n commands: ['selectAll'],\n });\n\n await sleep(100);\n\n await this.keyboard.press({\n key: 'Backspace',\n });\n }\n\n private latestMouseX = 100;\n private latestMouseY = 100;\n\n mouse = {\n click: async (x: number, y: number) => {\n await this.mouse.move(x, y);\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mousePressed',\n x,\n y,\n button: 'left',\n clickCount: 1,\n });\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mouseReleased',\n x,\n y,\n button: 'left',\n clickCount: 1,\n });\n },\n wheel: async (\n deltaX: number,\n deltaY: number,\n startX?: number,\n startY?: number,\n ) => {\n const finalX = startX || this.latestMouseX;\n const finalY = startY || this.latestMouseY;\n await this.showMousePointer(finalX, finalY);\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mouseWheel',\n x: finalX,\n y: finalY,\n deltaX,\n deltaY,\n });\n this.latestMouseX = finalX;\n this.latestMouseY = finalY;\n },\n move: async (x: number, y: number) => {\n await this.showMousePointer(x, y);\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mouseMoved',\n x,\n y,\n });\n this.latestMouseX = x;\n this.latestMouseY = y;\n },\n drag: async (\n from: { x: number; y: number },\n to: { x: number; y: number },\n ) => {\n await this.mouse.move(from.x, from.y);\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mousePressed',\n x: from.x,\n y: from.y,\n button: 'left',\n clickCount: 1,\n });\n await this.mouse.move(to.x, to.y);\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mouseReleased',\n x: to.x,\n y: to.y,\n button: 'left',\n clickCount: 1,\n });\n },\n };\n\n keyboard = {\n type: async (text: string) => {\n const cdpKeyboard = new CdpKeyboard({\n send: this.sendCommandToDebugger.bind(this),\n });\n await cdpKeyboard.type(text, { delay: 0 });\n },\n press: async (\n action:\n | { key: WebKeyInput; command?: string }\n | { key: WebKeyInput; command?: string }[],\n ) => {\n const cdpKeyboard = new CdpKeyboard({\n send: this.sendCommandToDebugger.bind(this),\n });\n const keys = Array.isArray(action) ? action : [action];\n for (const k of keys) {\n const commands = k.command ? [k.command] : [];\n await cdpKeyboard.down(k.key, { commands });\n }\n for (const k of [...keys].reverse()) {\n await cdpKeyboard.up(k.key);\n }\n },\n };\n\n async destroy(): Promise<void> {\n this.activeTabId = null;\n await this.detachDebugger();\n this.destroyed = true;\n }\n}\n","// From https://github.com/puppeteer/puppeteer/blob/15abcc390862fd08cc3475532f2d9a11284aee6b/packages/puppeteer-core/src/cdp/Input.ts#L55\n// with some modifications to fit the session type\n/**\n * @license\n * Copyright 2017 Google Inc.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n type KeyDefinition,\n type KeyInput,\n _keyDefinitions,\n} from '@midscene/shared/keyboard-layout';\nimport { assert } from '@midscene/shared/utils';\n\ntype KeyDescription = Required<\n Pick<KeyDefinition, 'keyCode' | 'key' | 'text' | 'code' | 'location'>\n>;\n\n/**\n * @public\n */\nexport interface KeyDownOptions {\n /**\n * @deprecated Do not use. This is automatically handled.\n */\n text?: string;\n /**\n * @deprecated Do not use. This is automatically handled.\n */\n commands?: string[];\n}\n\n/**\n * @public\n */\nexport interface KeyboardTypeOptions {\n delay?: number;\n}\n\n/**\n * @public\n */\nexport type KeyPressOptions = KeyDownOptions & KeyboardTypeOptions;\n\ntype InternalCDPSession = {\n send: (command: string, params: any) => Promise<void>;\n};\n\n/**\n * @internal\n */\nexport class CdpKeyboard {\n #pressedKeys = new Set<string>();\n\n #client: InternalCDPSession;\n\n _modifiers = 0;\n\n constructor(client: InternalCDPSession) {\n this.#client = client;\n }\n\n updateClient(client: InternalCDPSession): void {\n this.#client = client;\n }\n\n async down(\n key: KeyInput,\n options: Readonly<KeyDownOptions> = {\n text: undefined,\n commands: [],\n },\n ): Promise<void> {\n const description = this.#keyDescriptionForString(key);\n\n const autoRepeat = this.#pressedKeys.has(description.code);\n this.#pressedKeys.add(description.code);\n this._modifiers |= this.#modifierBit(description.key);\n\n const text = options.text === undefined ? description.text : options.text;\n await this.#client.send('Input.dispatchKeyEvent', {\n type: text ? 'keyDown' : 'rawKeyDown',\n modifiers: this._modifiers,\n windowsVirtualKeyCode: description.keyCode,\n code: description.code,\n key: description.key,\n text: text,\n unmodifiedText: text,\n autoRepeat,\n location: description.location,\n isKeypad: description.location === 3,\n commands: options.commands,\n });\n }\n\n #modifierBit(key: string): number {\n if (key === 'Alt') {\n return 1;\n }\n if (key === 'Control') {\n return 2;\n }\n if (key === 'Meta') {\n return 4;\n }\n if (key === 'Shift') {\n return 8;\n }\n return 0;\n }\n\n #keyDescriptionForString(keyString: KeyInput): KeyDescription {\n const shift = this._modifiers & 8;\n const description = {\n key: '',\n keyCode: 0,\n code: '',\n text: '',\n location: 0,\n };\n\n const definition = _keyDefinitions[keyString];\n\n assert(definition, `Unknown key: \"${keyString}\"`);\n\n if (definition.key) {\n description.key = definition.key;\n }\n if (shift && definition.shiftKey) {\n description.key = definition.shiftKey;\n }\n\n if (definition.keyCode) {\n description.keyCode = definition.keyCode;\n }\n if (shift && definition.shiftKeyCode) {\n description.keyCode = definition.shiftKeyCode;\n }\n\n if (definition.code) {\n description.code = definition.code;\n }\n\n if (definition.location) {\n description.location = definition.location;\n }\n\n if (description.key.length === 1) {\n description.text = description.key;\n }\n\n if (definition.text) {\n description.text = definition.text;\n }\n if (shift && definition.shiftText) {\n description.text = definition.shiftText;\n }\n\n // if any modifiers besides shift are pressed, no text should be sent\n if (this._modifiers & ~8) {\n description.text = '';\n }\n\n return description;\n }\n\n async up(key: KeyInput): Promise<void> {\n const description = this.#keyDescriptionForString(key);\n\n this._modifiers &= ~this.#modifierBit(description.key);\n this.#pressedKeys.delete(description.code);\n await this.#client.send('Input.dispatchKeyEvent', {\n type: 'keyUp',\n modifiers: this._modifiers,\n key: description.key,\n windowsVirtualKeyCode: description.keyCode,\n code: description.code,\n location: description.location,\n });\n }\n\n async sendCharacter(char: string): Promise<void> {\n await this.#client.send('Input.insertText', { text: char });\n }\n\n private charIsKey(char: string): char is KeyInput {\n return !!_keyDefinitions[char as KeyInput];\n }\n\n async type(\n text: string,\n options: Readonly<KeyboardTypeOptions> = {},\n ): Promise<void> {\n const delay = options.delay || undefined;\n for (const char of text) {\n if (this.charIsKey(char)) {\n await this.press(char, { delay });\n } else {\n if (delay) {\n await new Promise((f) => {\n return setTimeout(f, delay);\n });\n }\n await this.sendCharacter(char);\n }\n }\n }\n\n async press(\n key: KeyInput | KeyInput[],\n options: Readonly<KeyPressOptions> = {},\n ): Promise<void> {\n const { delay = null } = options;\n const keys = Array.isArray(key) ? key : [key];\n\n for (const k of keys) {\n await this.down(k, options);\n }\n\n if (delay) {\n await new Promise((f) => {\n return setTimeout(f, options.delay);\n });\n }\n\n for (const k of [...keys].reverse()) {\n await this.up(k);\n }\n }\n}\n","import fs from 'node:fs';\nimport { ifInBrowser } from '@midscene/shared/utils';\n\n// remember to include this file into extension's package\n// extract html element from page\nlet scriptFileContentCache: string | null = null;\nexport const getHtmlElementScript = async () => {\n const scriptFileToRetrieve = chrome.runtime.getURL('scripts/htmlElement.js');\n if (scriptFileContentCache) return scriptFileContentCache;\n if (ifInBrowser) {\n const script = await fetch(scriptFileToRetrieve);\n scriptFileContentCache = await script.text();\n return scriptFileContentCache;\n }\n return fs.readFileSync(scriptFileToRetrieve, 'utf8');\n};\n\n// inject water flow animation\nlet waterFlowScriptFileContentCache: string | null = null;\nexport const injectWaterFlowAnimation = async () => {\n const waterFlowScriptFileToRetrieve = chrome.runtime.getURL(\n 'scripts/water-flow.js',\n );\n if (waterFlowScriptFileContentCache) return waterFlowScriptFileContentCache;\n if (ifInBrowser) {\n const script = await fetch(waterFlowScriptFileToRetrieve);\n waterFlowScriptFileContentCache = await script.text();\n return waterFlowScriptFileContentCache;\n }\n return fs.readFileSync(waterFlowScriptFileToRetrieve, 'utf8');\n};\n\n// inject stop water flow animation\nlet stopWaterFlowScriptFileContentCache: string | null = null;\nexport const injectStopWaterFlowAnimation = async () => {\n const stopWaterFlowScriptFileToRetrieve = chrome.runtime.getURL(\n 'scripts/stop-water-flow.js',\n );\n if (stopWaterFlowScriptFileContentCache)\n return stopWaterFlowScriptFileContentCache;\n if (ifInBrowser) {\n const script = await fetch(stopWaterFlowScriptFileToRetrieve);\n stopWaterFlowScriptFileContentCache = await script.text();\n return stopWaterFlowScriptFileContentCache;\n }\n return fs.readFileSync(stopWaterFlowScriptFileToRetrieve, 'utf8');\n};\n","export const DefaultBridgeServerPort = 3766;\nexport const DefaultLocalEndpoint = `http://127.0.0.1:${DefaultBridgeServerPort}`;\nexport const BridgeCallTimeout = 30000;\n\nexport enum BridgeEvent {\n Call = 'bridge-call',\n CallResponse = 'bridge-call-response',\n UpdateAgentStatus = 'bridge-update-agent-status',\n Message = 'bridge-message',\n Connected = 'bridge-connected',\n Refused = 'bridge-refused',\n ConnectNewTabWithUrl = 'connectNewTabWithUrl',\n ConnectCurrentTab = 'connectCurrentTab',\n GetBrowserTabList = 'getBrowserTabList',\n SetDestroyOptions = 'setDestroyOptions',\n SetActiveTabId = 'setActiveTabId',\n}\n\nexport interface BridgeConnectTabOptions {\n /**\n * If true, the page will always track the active tab.\n * @default true\n */\n forceSameTabNavigation?: boolean;\n}\n\nexport enum MouseEvent {\n PREFIX = 'mouse.',\n Click = 'mouse.click',\n Wheel = 'mouse.wheel',\n Move = 'mouse.move',\n Drag = 'mouse.drag',\n}\n\nexport enum KeyboardEvent {\n PREFIX = 'keyboard.',\n Type = 'keyboard.type',\n Press = 'keyboard.press',\n}\n\nexport const BridgePageType = 'page-over-chrome-extension-bridge';\n\nexport const BridgeErrorCodeNoClientConnected = 'no-client-connected';\n\nexport interface BridgeCall {\n method: string;\n args: any[];\n response: any;\n callTime: number;\n responseTime: number;\n callback: (error: Error | undefined, response: any) => void;\n error?: Error;\n}\n\nexport interface BridgeCallRequest {\n id: string;\n method: string;\n args: any[];\n}\n\nexport interface BridgeCallResponse {\n id: string;\n response: any;\n error?: any;\n}\n\nexport interface BridgeConnectedEventPayload {\n version: string;\n}\n","import { assert } from '@midscene/shared/utils';\nimport { io as ClientIO, type Socket as ClientSocket } from 'socket.io-client';\nimport {\n type BridgeCallRequest,\n type BridgeCallResponse,\n type BridgeConnectedEventPayload,\n BridgeEvent,\n} from './common';\n\ndeclare const __VERSION__: string;\n\n// ws client, this is where the request is processed\nexport class BridgeClient {\n private socket: ClientSocket | null = null;\n public serverVersion: string | null = null;\n constructor(\n public endpoint: string,\n public onBridgeCall: (method: string, args: any[]) => Promise<any>,\n public onDisconnect?: () => void,\n ) {}\n\n async connect() {\n return new Promise((resolve, reject) => {\n this.socket = ClientIO(this.endpoint, {\n reconnection: false,\n query: {\n version: __VERSION__,\n },\n });\n\n const timeout = setTimeout(() => {\n try {\n this.socket?.offAny();\n this.socket?.close();\n } catch (e) {\n console.warn('got error when offing socket', e);\n }\n this.socket = null;\n reject(new Error('failed to connect to bridge server after timeout'));\n }, 1 * 1000);\n\n // on disconnect\n this.socket.on('disconnect', (reason: string) => {\n // console.log('bridge-disconnected, reason:', reason);\n this.socket = null;\n this.onDisconnect?.();\n });\n\n this.socket.on('connect_error', (e: any) => {\n console.error('bridge-connect-error', e);\n reject(new Error(e || 'bridge connect error'));\n });\n\n this.socket.on(\n BridgeEvent.Connected,\n (payload: BridgeConnectedEventPayload) => {\n clearTimeout(timeout);\n this.serverVersion = payload?.version || 'unknown';\n resolve(this.socket);\n },\n );\n this.socket.on(BridgeEvent.Refused, (e: any) => {\n console.error('bridge-refused', e);\n try {\n this.socket?.disconnect();\n } catch (e) {\n // console.warn('got error when disconnecting socket', e);\n }\n reject(new Error(e || 'bridge refused'));\n });\n this.socket.on(BridgeEvent.Call, (call: BridgeCallRequest) => {\n const id = call.id;\n assert(typeof id !== 'undefined', 'call id is required');\n (async () => {\n let response: any;\n try {\n response = await this.onBridgeCall(call.method, call.args);\n } catch (e: any) {\n const errorContent = `Error from bridge client when calling, method: ${call.method}, args: ${call.args}, error: ${e?.message || e}\\n${e?.stack || ''}`;\n console.error(errorContent);\n return this.socket?.emit(BridgeEvent.CallResponse, {\n id,\n error: errorContent,\n } as BridgeCallResponse);\n }\n this.socket?.emit(BridgeEvent.CallResponse, {\n id,\n response,\n } as BridgeCallResponse);\n })();\n });\n });\n }\n\n disconnect() {\n this.socket?.disconnect();\n this.socket = null;\n }\n}\n"]}
@@ -296,10 +296,7 @@ import { sleep } from "@midscene/core/utils";
296
296
  import { UITarsModelVersion } from "@midscene/shared/env";
297
297
  import { uiTarsModelVersion } from "@midscene/shared/env";
298
298
  import { vlLocateMode } from "@midscene/shared/env";
299
- import {
300
- imageInfo,
301
- resizeImgBase64 as resizeImgBase642
302
- } from "@midscene/shared/img";
299
+ import { imageInfo, resizeImgBase64 as resizeImgBase642 } from "@midscene/shared/img";
303
300
  import { getDebug as getDebug2 } from "@midscene/shared/logger";
304
301
  import { assert as assert4 } from "@midscene/shared/utils";
305
302
 
@@ -1485,17 +1482,23 @@ var PageTaskExecutor = class {
1485
1482
  executor: taskExecutor
1486
1483
  };
1487
1484
  }
1488
- async query(demand) {
1489
- const description = typeof demand === "string" ? demand : JSON.stringify(demand);
1490
- const taskExecutor = new Executor(taskTitleStr("Query", description), {
1491
- onTaskStart: this.onTaskStartCallback
1492
- });
1485
+ async createTypeQueryTask(type, demand) {
1486
+ const taskExecutor = new Executor(
1487
+ taskTitleStr(
1488
+ type,
1489
+ typeof demand === "string" ? demand : JSON.stringify(demand)
1490
+ ),
1491
+ {
1492
+ onTaskStart: this.onTaskStartCallback
1493
+ }
1494
+ );
1493
1495
  const queryTask = {
1494
1496
  type: "Insight",
1495
- subType: "Query",
1497
+ subType: type,
1496
1498
  locate: null,
1497
1499
  param: {
1498
1500
  dataDemand: demand
1501
+ // for user param presentation in report right sidebar
1499
1502
  },
1500
1503
  executor: async (param) => {
1501
1504
  let insightDump;
@@ -1503,11 +1506,21 @@ var PageTaskExecutor = class {
1503
1506
  insightDump = dump;
1504
1507
  };
1505
1508
  this.insight.onceDumpUpdatedFn = dumpCollector;
1506
- const { data, usage } = await this.insight.extract(
1507
- param.dataDemand
1508
- );
1509
+ const ifTypeRestricted = type !== "Query";
1510
+ let demandInput = demand;
1511
+ if (ifTypeRestricted) {
1512
+ demandInput = {
1513
+ result: `${type}, ${demand}`
1514
+ };
1515
+ }
1516
+ const { data, usage } = await this.insight.extract(demandInput);
1517
+ let outputResult = data;
1518
+ if (ifTypeRestricted) {
1519
+ assert4(data?.result !== void 0, "No result in query data");
1520
+ outputResult = data.result;
1521
+ }
1509
1522
  return {
1510
- output: data,
1523
+ output: outputResult,
1511
1524
  log: { dump: insightDump },
1512
1525
  usage
1513
1526
  };
@@ -1520,6 +1533,18 @@ var PageTaskExecutor = class {
1520
1533
  executor: taskExecutor
1521
1534
  };
1522
1535
  }
1536
+ async query(demand) {
1537
+ return this.createTypeQueryTask("Query", demand);
1538
+ }
1539
+ async boolean(prompt) {
1540
+ return this.createTypeQueryTask("Boolean", prompt);
1541
+ }
1542
+ async number(prompt) {
1543
+ return this.createTypeQueryTask("Number", prompt);
1544
+ }
1545
+ async string(prompt) {
1546
+ return this.createTypeQueryTask("String", prompt);
1547
+ }
1523
1548
  async assert(assertion) {
1524
1549
  const description = `assert: ${assertion}`;
1525
1550
  const taskExecutor = new Executor(taskTitleStr("Assert", description), {
@@ -1706,6 +1731,16 @@ function buildPlans(type, locateParam, param) {
1706
1731
  };
1707
1732
  returnPlans = [sleepPlan];
1708
1733
  }
1734
+ if (type === "Locate") {
1735
+ assert5(locateParam, `missing locate info for action "${type}"`);
1736
+ const locatePlan2 = {
1737
+ type,
1738
+ param: locateParam,
1739
+ locate: locateParam,
1740
+ thought: ""
1741
+ };
1742
+ returnPlans = [locatePlan2];
1743
+ }
1709
1744
  if (returnPlans) {
1710
1745
  debug3("buildPlans", returnPlans);
1711
1746
  return returnPlans;
@@ -1905,6 +1940,35 @@ ${errorTask?.errorStack}`);
1905
1940
  this.afterTaskRunning(executor);
1906
1941
  return output;
1907
1942
  }
1943
+ async aiBoolean(prompt) {
1944
+ const { output, executor } = await this.taskExecutor.boolean(prompt);
1945
+ this.afterTaskRunning(executor);
1946
+ return output;
1947
+ }
1948
+ async aiNumber(prompt) {
1949
+ const { output, executor } = await this.taskExecutor.number(prompt);
1950
+ this.afterTaskRunning(executor);
1951
+ return output;
1952
+ }
1953
+ async aiString(prompt) {
1954
+ const { output, executor } = await this.taskExecutor.string(prompt);
1955
+ this.afterTaskRunning(executor);
1956
+ return output;
1957
+ }
1958
+ async aiLocate(prompt, opt) {
1959
+ const detailedLocateParam = this.buildDetailedLocateParam(prompt, opt);
1960
+ const plans = buildPlans("Locate", detailedLocateParam);
1961
+ const { executor, output } = await this.taskExecutor.runPlans(
1962
+ taskTitleStr("Locate", locateParamStr(detailedLocateParam)),
1963
+ plans
1964
+ );
1965
+ this.afterTaskRunning(executor);
1966
+ const { element } = output;
1967
+ return {
1968
+ rect: element?.rect,
1969
+ center: element?.center
1970
+ };
1971
+ }
1908
1972
  async aiAssert(assertion, msg, opt) {
1909
1973
  const { output, executor } = await this.taskExecutor.assert(assertion);
1910
1974
  this.afterTaskRunning(executor, true);
@@ -1990,6 +2054,7 @@ var BridgeErrorCodeNoClientConnected = "no-client-connected";
1990
2054
 
1991
2055
  // src/bridge-mode/io-server.ts
1992
2056
  import { logMsg as logMsg2 } from "@midscene/shared/utils";
2057
+ import fkill from "fkill";
1993
2058
  import { Server } from "socket.io";
1994
2059
  var BridgeServer = class {
1995
2060
  constructor(port, onConnect, onDisconnect) {
@@ -2010,7 +2075,10 @@ var BridgeServer = class {
2010
2075
  };
2011
2076
  }
2012
2077
  async listen(opts = {}) {
2013
- const { timeout = 3e4 } = opts;
2078
+ const { timeout = 3e4, forceCloseServer = false } = opts;
2079
+ if (forceCloseServer) {
2080
+ await this.killPort();
2081
+ }
2014
2082
  return new Promise((resolve2, reject) => {
2015
2083
  if (this.listeningTimerFlag) {
2016
2084
  return reject(new Error("already listening"));
@@ -2055,7 +2123,7 @@ var BridgeServer = class {
2055
2123
  this.socket = socket;
2056
2124
  const clientVersion = socket.handshake.query.version;
2057
2125
  logMsg2(
2058
- `Bridge connected, cli-side version v${"0.16.5"}, browser-side version v${clientVersion}`
2126
+ `Bridge connected, cli-side version v${"0.16.6"}, browser-side version v${clientVersion}`
2059
2127
  );
2060
2128
  socket.on("bridge-call-response" /* CallResponse */, (params) => {
2061
2129
  const id = params.id;
@@ -2086,7 +2154,7 @@ var BridgeServer = class {
2086
2154
  setTimeout(() => {
2087
2155
  this.onConnect?.();
2088
2156
  const payload = {
2089
- version: "0.16.5"
2157
+ version: "0.16.6"
2090
2158
  };
2091
2159
  socket.emit("bridge-connected" /* Connected */, payload);
2092
2160
  Promise.resolve().then(() => {
@@ -2108,6 +2176,14 @@ var BridgeServer = class {
2108
2176
  });
2109
2177
  });
2110
2178
  }
2179
+ async killPort() {
2180
+ if (!this.listeningTimerFlag) {
2181
+ try {
2182
+ await fkill(this.port);
2183
+ } catch (e) {
2184
+ }
2185
+ }
2186
+ }
2111
2187
  async triggerCallResponseCallback(id, error, response) {
2112
2188
  const call = this.calls[id];
2113
2189
  if (!call) {
@@ -2177,10 +2253,11 @@ var BridgeServer = class {
2177
2253
 
2178
2254
  // src/bridge-mode/agent-cli-side.ts
2179
2255
  var sleep2 = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
2180
- var getBridgePageInCliSide = (timeout) => {
2256
+ var getBridgePageInCliSide = (forceCloseServer, timeout) => {
2181
2257
  const server = new BridgeServer(DefaultBridgeServerPort);
2182
2258
  server.listen({
2183
- timeout
2259
+ timeout,
2260
+ forceCloseServer
2184
2261
  });
2185
2262
  const bridgeCaller = (method) => {
2186
2263
  return async (...args) => {
@@ -2244,7 +2321,10 @@ var getBridgePageInCliSide = (timeout) => {
2244
2321
  };
2245
2322
  var AgentOverChromeBridge = class extends PageAgent {
2246
2323
  constructor(opts) {
2247
- const page = getBridgePageInCliSide(opts?.serverListeningTimeout);
2324
+ const page = getBridgePageInCliSide(
2325
+ opts?.forceCloseServer,
2326
+ opts?.serverListeningTimeout
2327
+ );
2248
2328
  super(
2249
2329
  page,
2250
2330
  Object.assign(opts || {}, {
@@ -2300,7 +2380,6 @@ var AgentOverChromeBridge = class extends PageAgent {
2300
2380
  import { overrideAIConfig, allConfigFromEnv } from "@midscene/shared/env";
2301
2381
  export {
2302
2382
  AgentOverChromeBridge,
2303
- DefaultBridgeServerPort,
2304
2383
  allConfigFromEnv,
2305
2384
  overrideAIConfig
2306
2385
  };