@browserbasehq/orca 3.7.0-preview.1 → 3.7.2-gemini-cua
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.
- package/dist/cjs/lib/modelUtils.d.ts +10 -0
- package/dist/cjs/lib/modelUtils.js +11 -0
- package/dist/cjs/lib/modelUtils.js.map +1 -1
- package/dist/cjs/lib/v3/agent/AgentProvider.js +3 -0
- package/dist/cjs/lib/v3/agent/AgentProvider.js.map +1 -1
- package/dist/cjs/lib/v3/agent/GoogleCUAClient.d.ts +23 -0
- package/dist/cjs/lib/v3/agent/GoogleCUAClient.js +363 -206
- package/dist/cjs/lib/v3/agent/GoogleCUAClient.js.map +1 -1
- package/dist/cjs/lib/v3/agent/tools/click.js +16 -5
- package/dist/cjs/lib/v3/agent/tools/click.js.map +1 -1
- package/dist/cjs/lib/v3/agent/tools/clickAndHold.js +1 -1
- package/dist/cjs/lib/v3/agent/tools/clickAndHold.js.map +1 -1
- package/dist/cjs/lib/v3/agent/tools/dragAndDrop.js +2 -2
- package/dist/cjs/lib/v3/agent/tools/dragAndDrop.js.map +1 -1
- package/dist/cjs/lib/v3/agent/tools/fillFormVision.js +18 -7
- package/dist/cjs/lib/v3/agent/tools/fillFormVision.js.map +1 -1
- package/dist/cjs/lib/v3/agent/tools/scroll.js +1 -1
- package/dist/cjs/lib/v3/agent/tools/scroll.js.map +1 -1
- package/dist/cjs/lib/v3/agent/tools/type.js +13 -4
- package/dist/cjs/lib/v3/agent/tools/type.js.map +1 -1
- package/dist/cjs/lib/v3/agent/utils/coordinateNormalization.d.ts +5 -2
- package/dist/cjs/lib/v3/agent/utils/coordinateNormalization.js +5 -7
- package/dist/cjs/lib/v3/agent/utils/coordinateNormalization.js.map +1 -1
- package/dist/cjs/lib/v3/agent/utils/handleDoneToolCall.js +3 -1
- package/dist/cjs/lib/v3/agent/utils/handleDoneToolCall.js.map +1 -1
- package/dist/cjs/lib/v3/api.d.ts +1 -1
- package/dist/cjs/lib/v3/api.js +11 -1
- package/dist/cjs/lib/v3/api.js.map +1 -1
- package/dist/cjs/lib/v3/cache/AgentCache.js +6 -1
- package/dist/cjs/lib/v3/cache/AgentCache.js.map +1 -1
- package/dist/cjs/lib/v3/external_clients/aisdk.js +2 -0
- package/dist/cjs/lib/v3/external_clients/aisdk.js.map +1 -1
- package/dist/cjs/lib/v3/handlers/handlerUtils/actHandlerUtils.js +20 -0
- package/dist/cjs/lib/v3/handlers/handlerUtils/actHandlerUtils.js.map +1 -1
- package/dist/cjs/lib/v3/handlers/v3AgentHandler.js +5 -4
- package/dist/cjs/lib/v3/handlers/v3AgentHandler.js.map +1 -1
- package/dist/cjs/lib/v3/handlers/v3CuaAgentHandler.d.ts +4 -0
- package/dist/cjs/lib/v3/handlers/v3CuaAgentHandler.js +126 -20
- package/dist/cjs/lib/v3/handlers/v3CuaAgentHandler.js.map +1 -1
- package/dist/cjs/lib/v3/index.d.ts +1 -1
- package/dist/cjs/lib/v3/launch/local.js +1 -1
- package/dist/cjs/lib/v3/launch/local.js.map +1 -1
- package/dist/cjs/lib/v3/llm/LLMProvider.js +9 -2
- package/dist/cjs/lib/v3/llm/LLMProvider.js.map +1 -1
- package/dist/cjs/lib/v3/llm/aisdk.js +5 -3
- package/dist/cjs/lib/v3/llm/aisdk.js.map +1 -1
- package/dist/cjs/lib/v3/llm/providerOptions.d.ts +7 -0
- package/dist/cjs/lib/v3/llm/providerOptions.js +9 -0
- package/dist/cjs/lib/v3/llm/providerOptions.js.map +1 -0
- package/dist/cjs/lib/v3/runtimePaths.js +0 -1
- package/dist/cjs/lib/v3/runtimePaths.js.map +1 -1
- package/dist/cjs/lib/v3/types/private/agent.d.ts +1 -1
- package/dist/cjs/lib/v3/types/private/agent.js +1 -0
- package/dist/cjs/lib/v3/types/private/agent.js.map +1 -1
- package/dist/cjs/lib/v3/types/public/agent.d.ts +1 -1
- package/dist/cjs/lib/v3/types/public/agent.js +3 -0
- package/dist/cjs/lib/v3/types/public/agent.js.map +1 -1
- package/dist/cjs/lib/v3/types/public/api.d.ts +53 -0
- package/dist/cjs/lib/v3/types/public/api.js +8 -0
- package/dist/cjs/lib/v3/types/public/api.js.map +1 -1
- package/dist/cjs/lib/v3/types/public/model.d.ts +12 -0
- package/dist/cjs/lib/v3/types/public/model.js.map +1 -1
- package/dist/cjs/lib/v3/types/public/options.d.ts +13 -0
- package/dist/cjs/lib/v3/types/public/options.js.map +1 -1
- package/dist/cjs/lib/v3/understudy/a11y/snapshot/capture.js +4 -3
- package/dist/cjs/lib/v3/understudy/a11y/snapshot/capture.js.map +1 -1
- package/dist/cjs/lib/v3/understudy/a11y/snapshot/coordinateResolver.js +39 -1
- package/dist/cjs/lib/v3/understudy/a11y/snapshot/coordinateResolver.js.map +1 -1
- package/dist/cjs/lib/v3/understudy/locator.d.ts +12 -0
- package/dist/cjs/lib/v3/understudy/locator.js +44 -0
- package/dist/cjs/lib/v3/understudy/locator.js.map +1 -1
- package/dist/cjs/lib/v3/understudy/page.d.ts +22 -3
- package/dist/cjs/lib/v3/understudy/page.js +55 -1
- package/dist/cjs/lib/v3/understudy/page.js.map +1 -1
- package/dist/cjs/lib/v3/v3.d.ts +14 -0
- package/dist/cjs/lib/v3/v3.js +81 -16
- package/dist/cjs/lib/v3/v3.js.map +1 -1
- package/dist/cjs/lib/v3/verifier/types.d.ts +3 -2
- package/dist/cjs/lib/v3/verifier/types.js.map +1 -1
- package/dist/cjs/lib/version.d.ts +1 -1
- package/dist/cjs/lib/version.js +1 -1
- package/dist/cjs/lib/version.js.map +1 -1
- package/dist/esm/lib/modelUtils.d.ts +10 -0
- package/dist/esm/lib/modelUtils.js +9 -0
- package/dist/esm/lib/modelUtils.js.map +1 -1
- package/dist/esm/lib/v3/agent/AgentProvider.js +3 -0
- package/dist/esm/lib/v3/agent/AgentProvider.js.map +1 -1
- package/dist/esm/lib/v3/agent/GoogleCUAClient.d.ts +23 -0
- package/dist/esm/lib/v3/agent/GoogleCUAClient.js +363 -206
- package/dist/esm/lib/v3/agent/GoogleCUAClient.js.map +1 -1
- package/dist/esm/lib/v3/agent/tools/click.js +16 -5
- package/dist/esm/lib/v3/agent/tools/click.js.map +1 -1
- package/dist/esm/lib/v3/agent/tools/clickAndHold.js +1 -1
- package/dist/esm/lib/v3/agent/tools/clickAndHold.js.map +1 -1
- package/dist/esm/lib/v3/agent/tools/dragAndDrop.js +2 -2
- package/dist/esm/lib/v3/agent/tools/dragAndDrop.js.map +1 -1
- package/dist/esm/lib/v3/agent/tools/fillFormVision.js +19 -8
- package/dist/esm/lib/v3/agent/tools/fillFormVision.js.map +1 -1
- package/dist/esm/lib/v3/agent/tools/scroll.js +1 -1
- package/dist/esm/lib/v3/agent/tools/scroll.js.map +1 -1
- package/dist/esm/lib/v3/agent/tools/type.js +13 -4
- package/dist/esm/lib/v3/agent/tools/type.js.map +1 -1
- package/dist/esm/lib/v3/agent/utils/coordinateNormalization.d.ts +5 -2
- package/dist/esm/lib/v3/agent/utils/coordinateNormalization.js +5 -7
- package/dist/esm/lib/v3/agent/utils/coordinateNormalization.js.map +1 -1
- package/dist/esm/lib/v3/agent/utils/handleDoneToolCall.js +3 -1
- package/dist/esm/lib/v3/agent/utils/handleDoneToolCall.js.map +1 -1
- package/dist/esm/lib/v3/api.d.ts +1 -1
- package/dist/esm/lib/v3/api.js +11 -1
- package/dist/esm/lib/v3/api.js.map +1 -1
- package/dist/esm/lib/v3/cache/AgentCache.js +6 -1
- package/dist/esm/lib/v3/cache/AgentCache.js.map +1 -1
- package/dist/esm/lib/v3/external_clients/aisdk.js +2 -0
- package/dist/esm/lib/v3/external_clients/aisdk.js.map +1 -1
- package/dist/esm/lib/v3/handlers/handlerUtils/actHandlerUtils.js +20 -0
- package/dist/esm/lib/v3/handlers/handlerUtils/actHandlerUtils.js.map +1 -1
- package/dist/esm/lib/v3/handlers/v3AgentHandler.js +5 -4
- package/dist/esm/lib/v3/handlers/v3AgentHandler.js.map +1 -1
- package/dist/esm/lib/v3/handlers/v3CuaAgentHandler.d.ts +4 -0
- package/dist/esm/lib/v3/handlers/v3CuaAgentHandler.js +126 -20
- package/dist/esm/lib/v3/handlers/v3CuaAgentHandler.js.map +1 -1
- package/dist/esm/lib/v3/index.d.ts +1 -1
- package/dist/esm/lib/v3/launch/local.js +1 -1
- package/dist/esm/lib/v3/launch/local.js.map +1 -1
- package/dist/esm/lib/v3/llm/LLMProvider.js +9 -2
- package/dist/esm/lib/v3/llm/LLMProvider.js.map +1 -1
- package/dist/esm/lib/v3/llm/aisdk.js +5 -3
- package/dist/esm/lib/v3/llm/aisdk.js.map +1 -1
- package/dist/esm/lib/v3/llm/providerOptions.d.ts +7 -0
- package/dist/esm/lib/v3/llm/providerOptions.js +6 -0
- package/dist/esm/lib/v3/llm/providerOptions.js.map +1 -0
- package/dist/esm/lib/v3/runtimePaths.js +0 -1
- package/dist/esm/lib/v3/runtimePaths.js.map +1 -1
- package/dist/esm/lib/v3/types/private/agent.d.ts +1 -1
- package/dist/esm/lib/v3/types/private/agent.js +1 -0
- package/dist/esm/lib/v3/types/private/agent.js.map +1 -1
- package/dist/esm/lib/v3/types/public/agent.d.ts +1 -1
- package/dist/esm/lib/v3/types/public/agent.js +3 -0
- package/dist/esm/lib/v3/types/public/agent.js.map +1 -1
- package/dist/esm/lib/v3/types/public/api.d.ts +53 -0
- package/dist/esm/lib/v3/types/public/api.js +8 -0
- package/dist/esm/lib/v3/types/public/api.js.map +1 -1
- package/dist/esm/lib/v3/types/public/model.d.ts +12 -0
- package/dist/esm/lib/v3/types/public/model.js.map +1 -1
- package/dist/esm/lib/v3/types/public/options.d.ts +13 -0
- package/dist/esm/lib/v3/types/public/options.js.map +1 -1
- package/dist/esm/lib/v3/understudy/a11y/snapshot/capture.js +4 -3
- package/dist/esm/lib/v3/understudy/a11y/snapshot/capture.js.map +1 -1
- package/dist/esm/lib/v3/understudy/a11y/snapshot/coordinateResolver.js +39 -1
- package/dist/esm/lib/v3/understudy/a11y/snapshot/coordinateResolver.js.map +1 -1
- package/dist/esm/lib/v3/understudy/locator.d.ts +12 -0
- package/dist/esm/lib/v3/understudy/locator.js +44 -0
- package/dist/esm/lib/v3/understudy/locator.js.map +1 -1
- package/dist/esm/lib/v3/understudy/page.d.ts +22 -3
- package/dist/esm/lib/v3/understudy/page.js +55 -1
- package/dist/esm/lib/v3/understudy/page.js.map +1 -1
- package/dist/esm/lib/v3/v3.d.ts +14 -0
- package/dist/esm/lib/v3/v3.js +82 -17
- package/dist/esm/lib/v3/v3.js.map +1 -1
- package/dist/esm/lib/v3/verifier/types.d.ts +3 -2
- package/dist/esm/lib/v3/verifier/types.js.map +1 -1
- package/dist/esm/lib/version.d.ts +1 -1
- package/dist/esm/lib/version.js +1 -1
- package/dist/esm/lib/version.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GoogleCUAClient.js","sourceRoot":"","sources":["../../../../../lib/v3/agent/GoogleCUAClient.ts"],"names":[],"mappings":";;;AAAA,yCASuB;AAYvB,qDAA+C;AAC/C,+DAIsC;AACtC,+CAA6D;AAC7D,qEAA+E;AAC/E,+DAA8D;AAC9D,mFAI4C;AAE5C,+DAIqC;AACrC,+BAAoC;AAEpC;;;GAGG;AACH,MAAa,eAAgB,SAAQ,4BAAW;IACtC,MAAM,CAAS;IACf,MAAM,CAAc;IACpB,eAAe,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;IAC/C,UAAU,CAAU;IACpB,kBAAkB,CAA2C;IAC7D,aAAa,CAA0C;IACvD,OAAO,GAAc,EAAE,CAAC;IACxB,WAAW,GACjB,qBAAqB,CAAC;IAChB,qBAAqB,CAAwB;IAC7C,KAAK,CAAW;IAChB,OAAO,CAAU;IACjB,yBAAyB,CAA6B;IAC9D,YACE,IAAe,EACf,SAAiB,EACjB,wBAAiC,EACjC,aAA6B,EAC7B,KAAe;QAEf,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,wBAAwB,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AI,CAAC,KAAK,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC;SAC/D,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,OAIvB;QACC,iCAAiC;QACjC,IAAI,OAAO,EAAE,UAAU,EAAE,CAAC;YACxB,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACvC,CAAC;QAED,oCAAoC;QACpC,IAAI,OAAO,EAAE,WAAW,EAAE,CAAC;YACzB,OAAO;gBACL,MAAM,EAAE,OAAO,CAAC,WAAW;gBAC3B,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,WAAW;aAC5C,CAAC;QACJ,CAAC;QAED,2CAA2C;QAC3C,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC5B,IAAI,CAAC;gBACH,OAAO,MAAM,IAAI,CAAC,kBAAkB,EAAE,CAAC;YACzC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;gBACpD,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;QAED,MAAM,IAAI,2CAA4B,CACpC,yCAAyC;YACvC,gHAAgH,CACnH,CAAC;IACJ,CAAC;CACF;AA1nCD,0CA0nCC","sourcesContent":["import {\n GoogleGenAI,\n Content,\n Part,\n GenerateContentResponse,\n FunctionCall,\n GenerateContentConfig,\n Tool,\n GoogleGenAIOptions,\n} from \"@google/genai\";\nimport { LogLine } from \"../types/public/logs.js\";\nimport {\n AgentAction,\n AgentResult,\n AgentType,\n AgentExecutionOptions,\n SafetyCheck,\n SafetyConfirmationHandler,\n ScreenshotProviderResult,\n} from \"../types/public/agent.js\";\nimport { ClientOptions } from \"../types/public/model.js\";\nimport { AgentClient } from \"./AgentClient.js\";\nimport {\n AgentScreenshotProviderError,\n LLMResponseError,\n StagehandClosedError,\n} from \"../types/public/sdkErrors.js\";\nimport { buildGoogleCUASystemPrompt } from \"../../prompt.js\";\nimport { compressGoogleConversationImages } from \"./utils/imageCompression.js\";\nimport { mapKeyToPlaywright } from \"./utils/cuaKeyMapping.js\";\nimport {\n executeGoogleCustomTool,\n isCustomTool,\n convertToolSetToFunctionDeclarations,\n} from \"./utils/googleCustomToolHandler.js\";\nimport { ToolSet } from \"ai\";\nimport {\n FlowLogger,\n extractLlmCuaPromptSummary,\n extractLlmCuaResponseSummary,\n} from \"../flowlogger/FlowLogger.js\";\nimport { v7 as uuidv7 } from \"uuid\";\n\n/**\n * Client for Google's Computer Use Assistant API\n * This implementation uses the Google Generative AI SDK for Computer Use\n */\nexport class GoogleCUAClient extends AgentClient {\n private apiKey: string;\n private client: GoogleGenAI;\n private currentViewport = { width: 1288, height: 711 };\n private currentUrl?: string;\n private screenshotProvider?: () => Promise<ScreenshotProviderResult>;\n private actionHandler?: (action: AgentAction) => Promise<void>;\n private history: Content[] = [];\n private environment: \"ENVIRONMENT_BROWSER\" | \"ENVIRONMENT_DESKTOP\" =\n \"ENVIRONMENT_BROWSER\";\n private generateContentConfig: GenerateContentConfig;\n private tools?: ToolSet;\n private baseURL?: string;\n private safetyConfirmationHandler?: SafetyConfirmationHandler;\n constructor(\n type: AgentType,\n modelName: string,\n userProvidedInstructions?: string,\n clientOptions?: ClientOptions,\n tools?: ToolSet,\n ) {\n super(type, modelName, userProvidedInstructions);\n\n this.tools = tools;\n // Process client options\n this.apiKey =\n (clientOptions?.apiKey as string) ||\n process.env.GEMINI_API_KEY ||\n process.env.GOOGLE_GENERATIVE_AI_API_KEY ||\n process.env.GOOGLE_API_KEY ||\n \"\";\n this.baseURL = clientOptions?.baseURL as string | undefined;\n\n // Initialize the Google Generative AI client\n const genAIOptions: GoogleGenAIOptions = {\n apiKey: this.apiKey,\n ...(this.baseURL ? { httpOptions: { baseUrl: this.baseURL } } : {}),\n };\n this.client = new GoogleGenAI(genAIOptions);\n\n // Get environment if specified\n if (\n clientOptions?.environment &&\n typeof clientOptions.environment === \"string\"\n ) {\n this.environment = clientOptions.environment as typeof this.environment;\n }\n\n this.generateContentConfig = {\n temperature: 1,\n topP: 0.95,\n topK: 40,\n maxOutputTokens: 8192,\n // systemInstruction: this.userProvidedInstructions\n // ? { parts: [{ text: this.userProvidedInstructions }] }\n // : { parts: [{ text: buildGoogleCUASystemPrompt() }] },\n tools: [\n {\n computerUse: {\n environment: this.environment,\n },\n } as Tool,\n ],\n };\n\n // Store client options for reference\n this.clientOptions = {\n apiKey: this.apiKey,\n ...(this.baseURL ? { baseURL: this.baseURL } : {}),\n };\n\n // Initialize tools if provided\n if (this.tools && Object.keys(this.tools).length > 0) {\n this.updateGenerateContentConfig();\n }\n }\n\n public setViewport(width: number, height: number): void {\n this.currentViewport = { width, height };\n }\n\n setCurrentUrl(url: string): void {\n this.currentUrl = url;\n }\n\n setScreenshotProvider(\n provider: () => Promise<ScreenshotProviderResult>,\n ): void {\n this.screenshotProvider = provider;\n }\n\n setActionHandler(handler: (action: AgentAction) => Promise<void>): void {\n this.actionHandler = handler;\n }\n\n setTools(tools: ToolSet): void {\n this.tools = tools;\n this.updateGenerateContentConfig();\n }\n\n setSafetyConfirmationHandler(handler?: SafetyConfirmationHandler): void {\n this.safetyConfirmationHandler = handler;\n }\n\n private async handleSafetyConfirmation(\n safetyDecision: unknown,\n logger: (message: LogLine) => void,\n ): Promise<string | undefined> {\n const safetyMessage =\n typeof safetyDecision === \"object\"\n ? JSON.stringify(safetyDecision, null, 2)\n : String(safetyDecision);\n\n const safetyChecks: SafetyCheck[] = [\n {\n id: \"google-safety-decision\",\n code: \"safety_decision\",\n message: safetyMessage,\n },\n ];\n\n if (this.safetyConfirmationHandler) {\n logger({\n category: \"agent\",\n message: `Requesting safety confirmation for Google safety decision: ${safetyMessage}`,\n level: 1,\n });\n\n const response = await this.safetyConfirmationHandler(safetyChecks);\n\n if (response.acknowledged) {\n logger({\n category: \"agent\",\n message: `Safety decision acknowledged by user`,\n level: 1,\n });\n return \"true\";\n } else {\n logger({\n category: \"agent\",\n message: `Safety decision rejected by user`,\n level: 1,\n });\n return undefined;\n }\n }\n\n logger({\n category: \"agent\",\n message: `Auto-acknowledging Google safety decision`,\n level: 2,\n });\n return \"true\";\n }\n\n /**\n * Update the generateContentConfig with current tools\n */\n private updateGenerateContentConfig(): void {\n const functionDeclarations =\n this.tools && Object.keys(this.tools).length > 0\n ? convertToolSetToFunctionDeclarations(this.tools)\n : [];\n\n this.generateContentConfig = {\n ...this.generateContentConfig,\n tools: [\n {\n computerUse: {\n environment: this.environment,\n },\n ...(functionDeclarations.length > 0 ? { functionDeclarations } : {}),\n } as Tool,\n ],\n };\n }\n\n /**\n * Execute a task with the Google CUA\n * This is the main entry point for the agent\n * @implements AgentClient.execute\n */\n async execute(executionOptions: AgentExecutionOptions): Promise<AgentResult> {\n const { options, logger } = executionOptions;\n const { instruction } = options;\n const maxSteps = options.maxSteps || 10;\n\n let currentStep = 0;\n let completed = false;\n const actions: AgentAction[] = [];\n const messageList: string[] = [];\n let finalMessage = \"\";\n this.history = []; // Clear history for new execution\n\n // Start with the initial instruction\n await this.initializeHistory(instruction);\n\n let totalInputTokens = 0;\n let totalOutputTokens = 0;\n let totalReasoningTokens = 0;\n let totalCachedInputTokens = 0;\n let totalInferenceTime = 0;\n\n try {\n // Execute steps until completion or max steps reached\n while (!completed && currentStep < maxSteps) {\n await this.preStepHook?.();\n\n logger({\n category: \"agent\",\n message: `Executing step ${currentStep + 1}/${maxSteps}`,\n level: 1,\n });\n\n const result = await this.executeStep(logger);\n totalInputTokens += result.usage.input_tokens;\n totalOutputTokens += result.usage.output_tokens;\n totalReasoningTokens += result.usage.reasoning_tokens;\n totalCachedInputTokens += result.usage.cached_input_tokens;\n totalInferenceTime += result.usage.inference_time_ms;\n\n // Add actions to the list\n actions.push(...result.actions);\n\n // Update completion status\n completed = result.completed;\n\n // Record any message for this step\n if (result.message) {\n messageList.push(result.message);\n finalMessage = result.message;\n }\n\n // Increment step counter\n currentStep++;\n }\n\n // Return the final result\n return {\n success: completed,\n actions,\n message: finalMessage,\n completed,\n usage: {\n input_tokens: totalInputTokens,\n output_tokens: totalOutputTokens,\n reasoning_tokens: totalReasoningTokens,\n cached_input_tokens: totalCachedInputTokens,\n inference_time_ms: totalInferenceTime,\n },\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n logger({\n category: \"agent\",\n message: `Error executing agent task: ${errorMessage}`,\n level: 0,\n });\n\n return {\n success: false,\n actions,\n message: `Failed to execute task: ${errorMessage}`,\n completed: false,\n usage: {\n input_tokens: totalInputTokens,\n output_tokens: totalOutputTokens,\n reasoning_tokens: totalReasoningTokens,\n cached_input_tokens: totalCachedInputTokens,\n inference_time_ms: totalInferenceTime,\n },\n };\n }\n }\n\n /**\n * Initialize conversation history with the initial instruction\n */\n private async initializeHistory(instruction: string): Promise<void> {\n const parts: Part[] = [{ text: instruction }];\n\n // Note: The Python implementation doesn't include the initial screenshot\n // Following the same pattern here\n\n const systemPromptContent = this.userProvidedInstructions\n ? this.userProvidedInstructions\n : buildGoogleCUASystemPrompt().content;\n\n this.history = [\n {\n role: \"user\",\n parts: [\n {\n text: \"System prompt: \" + systemPromptContent,\n },\n ],\n },\n {\n role: \"user\",\n parts,\n },\n ];\n }\n\n /**\n * Execute a single step of the agent\n */\n async executeStep(logger: (message: LogLine) => void): Promise<{\n actions: AgentAction[];\n message: string;\n completed: boolean;\n usage: {\n input_tokens: number;\n output_tokens: number;\n reasoning_tokens: number;\n cached_input_tokens: number;\n inference_time_ms: number;\n };\n }> {\n try {\n const startTime = Date.now();\n\n // Compress images in conversation history before sending to the model\n const compressedResult = compressGoogleConversationImages(\n this.history,\n 2,\n );\n const compressedHistory = compressedResult.items;\n\n // Use the SDK's generateContent method with retry logic (matching Python's get_model_response)\n const maxRetries = 5;\n const baseDelayS = 1;\n let lastError: Error | null = null;\n let response: GenerateContentResponse | null = null;\n\n // Log LLM request\n const llmRequestId = uuidv7();\n FlowLogger.logLlmRequest({\n requestId: llmRequestId,\n model: this.modelName,\n prompt: extractLlmCuaPromptSummary(compressedHistory),\n });\n\n for (let attempt = 0; attempt < maxRetries; attempt++) {\n try {\n // Add exponential backoff delay for retries\n if (attempt > 0) {\n const delay = baseDelayS * Math.pow(2, attempt) * 1000; // Convert to ms\n logger({\n category: \"agent\",\n message: `Generating content failed on attempt ${attempt + 1}. Retrying in ${delay / 1000} seconds...`,\n level: 2,\n });\n await new Promise((resolve) => setTimeout(resolve, delay));\n }\n\n // Use the SDK's generateContent method - following Python SDK pattern\n response = await this.client.models.generateContent({\n model: this.modelName,\n contents: compressedHistory,\n config: this.generateContentConfig,\n });\n\n // Check if we have valid response content\n if (!response.candidates || response.candidates.length === 0) {\n throw new LLMResponseError(\"agent\", \"Response has no candidates!\");\n }\n\n const candidate = response.candidates[0];\n if (!candidate.content || !candidate.content.parts) {\n const reason = candidate.finishReason || \"unknown\";\n throw new LLMResponseError(\n \"agent\",\n `Response has no content (finish reason: ${reason})`,\n );\n }\n\n // Success - we have a valid response\n break;\n } catch (error) {\n lastError = error instanceof Error ? error : new Error(String(error));\n logger({\n category: \"agent\",\n message: `API call error: ${lastError.message}`,\n level: 2,\n });\n\n // If this was the last attempt, throw the error\n if (attempt === maxRetries - 1) {\n logger({\n category: \"agent\",\n message: `Generating content failed after ${maxRetries} attempts.`,\n level: 0,\n });\n throw lastError;\n }\n }\n }\n\n if (!response) {\n throw (\n lastError || new Error(\"Failed to get response after all retries\")\n );\n }\n\n const endTime = Date.now();\n const elapsedMs = endTime - startTime;\n const { usageMetadata } = response;\n\n // Log LLM response\n FlowLogger.logLlmResponse({\n requestId: llmRequestId,\n model: this.modelName,\n output: extractLlmCuaResponseSummary(response),\n inputTokens: usageMetadata?.promptTokenCount,\n outputTokens: usageMetadata?.candidatesTokenCount,\n });\n\n // Process the response\n const result = await this.processResponse(response, logger);\n\n // Add model response to history\n if (response.candidates && response.candidates[0]) {\n // Sanitize any out-of-range coordinates in function calls before adding to history\n const sanitizedContent = JSON.parse(\n JSON.stringify(response.candidates[0].content),\n );\n if (sanitizedContent.parts) {\n for (const part of sanitizedContent.parts) {\n if (part.functionCall?.args) {\n if (\n typeof part.functionCall.args.x === \"number\" &&\n part.functionCall.args.x > 999\n ) {\n part.functionCall.args.x = 999;\n }\n if (\n typeof part.functionCall.args.y === \"number\" &&\n part.functionCall.args.y > 999\n ) {\n part.functionCall.args.y = 999;\n }\n }\n }\n }\n this.history.push(sanitizedContent);\n }\n\n // Execute actions and collect function responses\n const functionResponses: Part[] = [];\n\n // Always process the model's response, even when it produced no\n // executable action (e.g. a standalone take_screenshot). The model\n // expects exactly one function response — a fresh screenshot — per\n // computer-use call; skipping it when there are 0 actions leaves the\n // model blind and it gives up after one empty turn.\n {\n let hasError = false;\n\n // Execute all actions (a no-op when there are none).\n for (let i = 0; i < result.actions.length; i++) {\n const action = result.actions[i];\n\n logger({\n category: \"agent\",\n message: `Executing action ${i + 1}/${result.actions.length}: ${action.type}`,\n level: 2,\n });\n\n // Special handling for open_web_browser - don't execute it\n if (action.type === \"open_web_browser\") {\n // Set pageUrl for open_web_browser since it doesn't go through action handler\n action.pageUrl = this.currentUrl;\n logger({\n category: \"agent\",\n message: \"Skipping open_web_browser action\",\n level: 2,\n });\n } else if (action.type === \"screenshot\") {\n // No interaction to perform — the screenshot captured below is\n // returned to the model as this call's function response.\n logger({\n category: \"agent\",\n message: \"take_screenshot: capturing current page\",\n level: 2,\n });\n } else if (action.type === \"custom_tool\") {\n const toolName = action.name as string;\n const toolArgs = action.arguments as Record<string, unknown>;\n\n if (this.tools && toolName in this.tools) {\n const correspondingFunctionCall = result.functionCalls.find(\n (fc) => fc.name === toolName,\n );\n\n if (correspondingFunctionCall) {\n const executionResult = await executeGoogleCustomTool(\n toolName,\n toolArgs,\n this.tools,\n correspondingFunctionCall,\n logger,\n );\n\n functionResponses.push(executionResult.functionResponse);\n\n if (!executionResult.success) {\n hasError = true;\n }\n }\n }\n } else if (this.actionHandler) {\n try {\n await this.actionHandler(action);\n\n // Add a delay between actions to ensure they complete properly\n // Longer delay for typing actions to ensure fields are ready\n if (i < result.actions.length - 1) {\n const nextAction = result.actions[i + 1];\n const isTypingAction =\n action.type === \"type\" || nextAction.type === \"type\";\n const delay = isTypingAction ? 500 : 200;\n await new Promise((resolve) => setTimeout(resolve, delay));\n }\n } catch (actionError) {\n if (actionError instanceof StagehandClosedError) {\n throw actionError;\n }\n logger({\n category: \"agent\",\n message: `Error executing action ${action.type}: ${actionError}`,\n level: 0,\n });\n hasError = true;\n // Continue processing other actions even if one fails\n }\n }\n }\n\n // Create function responses for computer use actions (non-custom tools)\n // We need exactly one response per function call, regardless of how many actions were generated\n if (result.functionCalls.length > 0 || hasError) {\n // Filter out custom tool function calls as they've already been handled\n const computerUseFunctionCalls = result.functionCalls.filter(\n (fc) => !isCustomTool(fc, this.tools),\n );\n\n if (computerUseFunctionCalls.length > 0) {\n try {\n logger({\n category: \"agent\",\n message: `Taking screenshot after executing ${result.actions.length} actions${hasError ? \" (with errors)\" : \"\"}`,\n level: 2,\n });\n\n const screenshot = await this.captureScreenshot();\n const base64Data = screenshot.base64;\n\n // Create one function response for each computer use function call\n // Following Python SDK pattern: FunctionResponse with parts containing inline_data\n for (const functionCall of computerUseFunctionCalls) {\n let safetyAcknowledgement: string | undefined;\n if (functionCall.args?.safety_decision) {\n safetyAcknowledgement = await this.handleSafetyConfirmation(\n functionCall.args.safety_decision,\n logger,\n );\n }\n\n const functionResponsePart: Part = {\n functionResponse: {\n name: functionCall.name,\n response: {\n url: this.currentUrl || \"\",\n ...(safetyAcknowledgement !== undefined\n ? {\n safety_acknowledgement: safetyAcknowledgement,\n }\n : {}),\n },\n parts: [\n {\n inlineData: {\n mimeType: screenshot.mediaType,\n data: base64Data,\n },\n },\n ],\n },\n };\n functionResponses.push(functionResponsePart);\n }\n } catch (error) {\n logger({\n category: \"agent\",\n message: `Error capturing screenshot: ${error}`,\n level: 0,\n });\n }\n }\n }\n\n // Add all function responses to history in a single user message\n if (functionResponses.length > 0) {\n logger({\n category: \"agent\",\n message: `Adding ${functionResponses.length} function responses to history`,\n level: 2,\n });\n this.history.push({\n role: \"user\",\n parts: functionResponses,\n });\n }\n }\n\n return {\n actions: result.actions,\n message: result.message,\n completed: result.completed,\n usage: {\n // promptTokenCount is the TOTAL input and already includes the\n // cached portion; cachedContentTokenCount is the cache-hit subset\n // (tracked separately for visibility, not additive). thoughtsTokenCount\n // is Gemini's thinking/reasoning output.\n input_tokens: usageMetadata?.promptTokenCount || 0,\n output_tokens: usageMetadata?.candidatesTokenCount || 0,\n reasoning_tokens: usageMetadata?.thoughtsTokenCount || 0,\n cached_input_tokens: usageMetadata?.cachedContentTokenCount || 0,\n inference_time_ms: elapsedMs,\n },\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n logger({\n category: \"agent\",\n message: `Error executing step: ${errorMessage}`,\n level: 0,\n });\n\n throw error;\n }\n }\n\n /**\n * Process the response from Google's API\n */\n private async processResponse(\n response: GenerateContentResponse,\n logger: (message: LogLine) => void,\n ): Promise<{\n actions: AgentAction[];\n message: string;\n completed: boolean;\n functionCalls: FunctionCall[];\n }> {\n const actions: AgentAction[] = [];\n let message = \"\";\n const functionCalls: FunctionCall[] = [];\n\n if (!response.candidates || response.candidates.length === 0) {\n return {\n actions: [],\n message: \"No candidates in response\",\n completed: true,\n functionCalls: [],\n };\n }\n const candidate = response.candidates[0];\n\n // Log the raw response for debugging\n logger({\n category: \"agent\",\n message: `Raw response from Google: ${JSON.stringify(candidate.content, null, 2)}`,\n level: 2,\n });\n\n // Process all parts - Google can send multiple function calls\n for (const part of candidate.content.parts) {\n if (part.text) {\n message += part.text + \"\\n\";\n logger({\n category: \"agent\",\n message: `Reasoning: ${part.text}`,\n level: 1,\n });\n }\n if (part.functionCall) {\n functionCalls.push(part.functionCall);\n logger({\n category: \"agent\",\n message: `Found function call: ${part.functionCall.name} with args: ${JSON.stringify(part.functionCall.args)}`,\n level: 2,\n });\n\n // Convert function call to action(s)\n const action = this.convertFunctionCallToAction(\n part.functionCall,\n logger,\n );\n if (action) {\n // Special handling for type actions. gemini-2.5 type_text_at carries\n // coordinates (click the field first); gemini-3.x `type` has none and\n // types into the element the model already focused.\n if (action.type === \"type\") {\n logger({\n category: \"agent\",\n message: `Adding action: ${JSON.stringify(action)}`,\n level: 2,\n });\n // Click the target first only when coordinates are provided.\n if (typeof action.x === \"number\" && typeof action.y === \"number\") {\n actions.push({\n type: \"click\",\n x: action.x,\n y: action.y,\n button: \"left\",\n });\n }\n\n // If clear_before_typing is true (default), add a select all\n if (action.clearBeforeTyping) {\n // Select all text in the field\n actions.push({\n type: \"keypress\",\n keys: [\"ControlOrMeta+A\"],\n });\n actions.push({\n type: \"keypress\",\n keys: [\"Backspace\"],\n });\n }\n\n // Then add the type action\n actions.push(action);\n if (action.pressEnter) {\n actions.push({\n type: \"keypress\",\n keys: [\"Enter\"],\n });\n }\n } else {\n actions.push(action);\n }\n } else {\n logger({\n category: \"agent\",\n message: `Warning: Could not convert function call ${part.functionCall.name} to action`,\n level: 1,\n });\n }\n }\n }\n\n // Log summary of what we found\n logger({\n category: \"agent\",\n message: `Found ${functionCalls.length} function calls, converted to ${actions.length} actions`,\n level: 2,\n });\n\n // Check if task is completed\n const completed =\n functionCalls.length === 0 ||\n (candidate.finishReason && candidate.finishReason !== \"STOP\");\n\n return {\n actions,\n message: message.trim(),\n completed,\n functionCalls,\n };\n }\n\n /**\n * Convert Google function call to Stagehand action\n */\n private convertFunctionCallToAction(\n functionCall: FunctionCall,\n logger?: (message: LogLine) => void,\n ): AgentAction | null {\n const { name: rawName } = functionCall;\n // Default args to an empty object so no-argument predefined functions\n // (e.g. take_screenshot, go_back) are not rejected by the guard below.\n const args = functionCall.args ?? {};\n\n if (!rawName) {\n return null;\n }\n\n // The gemini-3.x computer-use tool renamed several of the predefined\n // functions that gemini-2.5-computer-use-preview used, and adds a\n // descriptive `intent` arg to every call. The argument fields are otherwise\n // unchanged (confirmed for click/navigate). Normalize the 3.x names to the\n // canonical 2.5 names so a single set of handlers serves both generations;\n // `intent` is ignored since handlers only read the args they need.\n // NOTE: click and take_screenshot are confirmed from live gemini-3.5-flash\n // traffic; the rest are inferred from the same drop-the-qualifier pattern\n // and are safe aliases (any unmapped name still hits the warning below).\n // gemini-3.x renamed several predefined functions vs gemini-2.5. Alias the\n // 3.x names whose behavior maps cleanly onto a 2.5 canonical handler. Click\n // variants that carry distinct semantics (double/triple/right/middle click,\n // move) are NOT aliased here — they have dedicated cases below so the click\n // count and button are preserved. 2.5 never emits any of these names, so\n // the 2.5 handlers are unaffected.\n const NAME_ALIASES: Record<string, string> = {\n click: \"click_at\",\n left_click: \"click_at\",\n type: \"type_text_at\",\n type_text: \"type_text_at\",\n hover: \"hover_at\",\n scroll: \"scroll_at\",\n drag: \"drag_and_drop\",\n key: \"key_combination\",\n keys: \"key_combination\",\n key_press: \"key_combination\",\n press_key: \"key_combination\",\n press_keys: \"key_combination\",\n hotkey: \"key_combination\",\n screenshot: \"take_screenshot\",\n wait: \"wait_5_seconds\",\n };\n const name = NAME_ALIASES[rawName] ?? rawName;\n\n // Predefined computer-use tools take precedence over custom tools. If a\n // custom tool was registered under a reserved (aliased) name, note that the\n // predefined tool wins rather than silently dropping the custom one.\n if (rawName in NAME_ALIASES && isCustomTool(functionCall, this.tools)) {\n logger?.({\n category: \"agent\",\n message: `Custom tool \"${rawName}\" collides with a predefined Google CUA function; using the predefined tool. Rename the custom tool to avoid the conflict.`,\n level: 2,\n });\n }\n\n switch (name) {\n case \"open_web_browser\":\n return {\n type: \"open_web_browser\",\n timestamp: Date.now(),\n };\n\n case \"take_screenshot\":\n // No UI interaction. The step loop captures a fresh screenshot and\n // returns it to the model as this call's function response; marked as a\n // recognized action (not null) so it isn't dropped, and skipped in the\n // executor like open_web_browser.\n return {\n type: \"screenshot\",\n timestamp: Date.now(),\n };\n\n case \"click_at\": {\n // x/y are required; reject a malformed call rather than normalizing\n // undefined/NaN/Infinity into bad coordinates. (gemini-3.x `click`\n // aliases here.)\n if (\n !GoogleCUAClient.isFiniteCoord(args.x) ||\n !GoogleCUAClient.isFiniteCoord(args.y)\n ) {\n return null;\n }\n const { x, y } = this.normalizeCoordinates(args.x, args.y);\n return {\n type: \"click\",\n x,\n y,\n button: args.button || \"left\",\n };\n }\n\n // gemini-3.x click family. The executor natively supports double/triple\n // click and right/middle button, so preserve those semantics rather than\n // collapsing to a single left click. All require integer coordinates;\n // drop the call (return null) on a malformed payload so the executor is\n // never handed NaN.\n case \"double_click\":\n case \"triple_click\":\n case \"right_click\":\n case \"middle_click\":\n case \"move\": {\n if (\n !GoogleCUAClient.isFiniteCoord(args.x) ||\n !GoogleCUAClient.isFiniteCoord(args.y)\n ) {\n return null;\n }\n const { x, y } = this.normalizeCoordinates(args.x, args.y);\n if (name === \"move\") {\n return { type: \"move\", x, y };\n }\n if (name === \"double_click\" || name === \"triple_click\") {\n return { type: name, x, y };\n }\n return {\n type: \"click\",\n x,\n y,\n button: name === \"right_click\" ? \"right\" : \"middle\",\n };\n }\n\n case \"type_text_at\": {\n // text is required; reject a malformed call rather than typing\n // \"undefined\". An empty string is valid (e.g. clear the field).\n if (typeof args.text !== \"string\") {\n return null;\n }\n // press_enter and clear_before_typing are shared across generations.\n const pressEnter = (args.press_enter as boolean) ?? false;\n const clearBeforeTyping = (args.clear_before_typing as boolean) ?? true;\n const base = {\n type: \"type\" as const,\n text: args.text as string,\n pressEnter,\n clearBeforeTyping,\n };\n\n // gemini-2.5 type_text_at carries x/y (click the field, then type).\n // gemini-3.x `type` has no coordinates and types into the element the\n // model already focused with a preceding click. Only attach coords when\n // present so the executor doesn't click at NaN.\n if (typeof args.x === \"number\" && typeof args.y === \"number\") {\n const { x, y } = this.normalizeCoordinates(args.x, args.y);\n return { ...base, x, y };\n }\n return base;\n }\n\n case \"key_combination\": {\n // gemini-2.5 key_combination sends `keys` as a \"+\"-joined string;\n // gemini-3.x `hotkey` sends a `keys` array, and `press_key` sends a\n // single `key`. Accept all three.\n const raw = args.keys !== undefined ? args.keys : args.key;\n const parts = Array.isArray(raw)\n ? (raw as string[])\n : String(raw ?? \"\").split(\"+\");\n const keys = parts\n .map((key) => String(key).trim())\n .filter(Boolean)\n .map((key) => mapKeyToPlaywright(key));\n if (keys.length === 0) {\n return null;\n }\n return {\n type: \"keypress\",\n keys,\n };\n }\n\n case \"scroll_document\": {\n const direction = (args.direction as string).toLowerCase();\n return {\n type: \"keypress\",\n keys: [direction === \"up\" ? \"PageUp\" : \"PageDown\"],\n };\n }\n\n case \"scroll_at\": {\n // A coordinate-less (or malformed) `scroll` alias (gemini-3.x) scrolls\n // the document via PageUp/PageDown.\n if (\n !GoogleCUAClient.isFiniteCoord(args.x) ||\n !GoogleCUAClient.isFiniteCoord(args.y)\n ) {\n const dir = ((args.direction as string) || \"down\").toLowerCase();\n return {\n type: \"keypress\",\n keys: [dir === \"up\" ? \"PageUp\" : \"PageDown\"],\n };\n }\n const { x, y } = this.normalizeCoordinates(args.x, args.y);\n const direction = ((args.direction as string) || \"down\").toLowerCase();\n // 2.5 uses `magnitude`; gemini-3.x `scroll` uses `magnitude_in_pixels`.\n const magnitude = GoogleCUAClient.isFiniteCoord(args.magnitude)\n ? args.magnitude\n : GoogleCUAClient.isFiniteCoord(args.magnitude_in_pixels)\n ? args.magnitude_in_pixels\n : 800;\n\n let scroll_x = 0;\n let scroll_y = 0;\n if (direction === \"up\") {\n scroll_y = -magnitude;\n } else if (direction === \"down\") {\n scroll_y = magnitude;\n } else if (direction === \"left\") {\n scroll_x = -magnitude;\n } else if (direction === \"right\") {\n scroll_x = magnitude;\n } else {\n // Default to down if unknown direction\n scroll_y = magnitude;\n }\n\n return {\n type: \"scroll\",\n x,\n y,\n scroll_x,\n scroll_y,\n };\n }\n\n case \"navigate\":\n // url is required; reject a malformed call rather than navigating to\n // \"undefined\".\n if (typeof args.url !== \"string\" || args.url.length === 0) {\n return null;\n }\n return {\n type: \"goto\",\n url: args.url,\n };\n\n case \"go_back\":\n return {\n type: \"back\",\n };\n\n case \"go_forward\":\n return {\n type: \"forward\",\n };\n\n case \"wait_5_seconds\":\n return {\n type: \"wait\",\n timeMs: 5000, // Google CUA waits for 5 seconds\n };\n\n case \"hover_at\": {\n const { x, y } = this.normalizeCoordinates(\n args.x as number,\n args.y as number,\n );\n return {\n type: \"move\",\n x,\n y,\n };\n }\n\n case \"search\":\n return {\n type: \"goto\",\n url: \"https://www.google.com\",\n };\n\n case \"drag_and_drop\": {\n // 2.5 uses x/y + destination_x/destination_y; gemini-3.x `drag_and_drop`\n // uses start_x/start_y + end_x/end_y. Accept either.\n const sx = args.x ?? args.start_x;\n const sy = args.y ?? args.start_y;\n const ex = args.destination_x ?? args.end_x;\n const ey = args.destination_y ?? args.end_y;\n if (\n !GoogleCUAClient.isFiniteCoord(sx) ||\n !GoogleCUAClient.isFiniteCoord(sy) ||\n !GoogleCUAClient.isFiniteCoord(ex) ||\n !GoogleCUAClient.isFiniteCoord(ey)\n ) {\n return null;\n }\n const startPoint = this.normalizeCoordinates(sx, sy);\n const endPoint = this.normalizeCoordinates(ex, ey);\n return {\n type: \"drag\",\n path: [\n { x: startPoint.x, y: startPoint.y },\n { x: endPoint.x, y: endPoint.y },\n ],\n };\n }\n\n default:\n if (isCustomTool(functionCall, this.tools)) {\n return {\n type: \"custom_tool\",\n name,\n arguments: args,\n timestamp: Date.now(),\n pageUrl: this.currentUrl,\n };\n }\n console.warn(`Unsupported Google CUA function: ${name}`);\n return null;\n }\n }\n\n /**\n * True only for a usable coordinate/number: rejects undefined, non-numbers,\n * and the numeric edge cases NaN and Infinity (both `typeof \"number\"`), so\n * malformed function calls are dropped instead of normalizing into NaN.\n */\n private static isFiniteCoord(value: unknown): value is number {\n return typeof value === \"number\" && Number.isFinite(value);\n }\n\n /**\n * Normalize coordinates from Google's 0-1000 range to viewport dimensions\n */\n private normalizeCoordinates(x: number, y: number): { x: number; y: number } {\n const clampedX = Math.min(999, Math.max(0, x));\n const clampedY = Math.min(999, Math.max(0, y));\n return {\n x: Math.floor((clampedX / 1000) * this.currentViewport.width),\n y: Math.floor((clampedY / 1000) * this.currentViewport.height),\n };\n }\n\n async captureScreenshot(options?: {\n base64Image?: string;\n mediaType?: \"image/png\" | \"image/jpeg\";\n currentUrl?: string;\n }): Promise<ScreenshotProviderResult> {\n // Update current URL if provided\n if (options?.currentUrl) {\n this.currentUrl = options.currentUrl;\n }\n\n // Use provided options if available\n if (options?.base64Image) {\n return {\n base64: options.base64Image,\n mediaType: options.mediaType ?? \"image/png\",\n };\n }\n\n // Use the screenshot provider if available\n if (this.screenshotProvider) {\n try {\n return await this.screenshotProvider();\n } catch (error) {\n console.error(\"Error capturing screenshot:\", error);\n throw error;\n }\n }\n\n throw new AgentScreenshotProviderError(\n \"`screenshotProvider` has not been set. \" +\n \"Please call `setScreenshotProvider()` with a valid function that returns a base64-encoded image and media type\",\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"GoogleCUAClient.js","sourceRoot":"","sources":["../../../../../lib/v3/agent/GoogleCUAClient.ts"],"names":[],"mappings":";;;AAAA,yCASuB;AAYvB,qDAA+C;AAC/C,+DAIsC;AACtC,+CAA6D;AAC7D,qEAA+E;AAC/E,+DAA8D;AAC9D,mFAI4C;AAE5C,+DAIqC;AACrC,+BAAoC;AA2CpC,2EAA2E;AAC3E,SAAS,gBAAgB,CAAC,KAAc;IACtC,MAAM,MAAM,GAAI,KAA8B,EAAE,MAAM,CAAC;IACvD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,MAAM,KAAK,GAAG,IAAI,MAAM,IAAI,GAAG,CAAC;IACzC,CAAC;IACD,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvE,OAAO,8DAA8D,CAAC,IAAI,CACxE,OAAO,CACR,CAAC;AACJ,CAAC;AAED;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,KAAK,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC;SAC/D,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,OAIvB;QACC,iCAAiC;QACjC,IAAI,OAAO,EAAE,UAAU,EAAE,CAAC;YACxB,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACvC,CAAC;QAED,oCAAoC;QACpC,IAAI,OAAO,EAAE,WAAW,EAAE,CAAC;YACzB,OAAO;gBACL,MAAM,EAAE,OAAO,CAAC,WAAW;gBAC3B,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,WAAW;aAC5C,CAAC;QACJ,CAAC;QAED,2CAA2C;QAC3C,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC5B,IAAI,CAAC;gBACH,OAAO,MAAM,IAAI,CAAC,kBAAkB,EAAE,CAAC;YACzC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;gBACpD,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;QAED,MAAM,IAAI,2CAA4B,CACpC,yCAAyC;YACvC,gHAAgH,CACnH,CAAC;IACJ,CAAC;CACF;AAjzCD,0CAizCC","sourcesContent":["import {\n GoogleGenAI,\n Content,\n Part,\n GenerateContentResponse,\n FunctionCall,\n GenerateContentConfig,\n Tool,\n GoogleGenAIOptions,\n} from \"@google/genai\";\nimport { LogLine } from \"../types/public/logs.js\";\nimport {\n AgentAction,\n AgentResult,\n AgentType,\n AgentExecutionOptions,\n SafetyCheck,\n SafetyConfirmationHandler,\n ScreenshotProviderResult,\n} from \"../types/public/agent.js\";\nimport { ClientOptions } from \"../types/public/model.js\";\nimport { AgentClient } from \"./AgentClient.js\";\nimport {\n AgentScreenshotProviderError,\n LLMResponseError,\n StagehandClosedError,\n} from \"../types/public/sdkErrors.js\";\nimport { buildGoogleCUASystemPrompt } from \"../../prompt.js\";\nimport { compressGoogleConversationImages } from \"./utils/imageCompression.js\";\nimport { mapKeyToPlaywright } from \"./utils/cuaKeyMapping.js\";\nimport {\n executeGoogleCustomTool,\n isCustomTool,\n convertToolSetToFunctionDeclarations,\n} from \"./utils/googleCustomToolHandler.js\";\nimport { ToolSet } from \"ai\";\nimport {\n FlowLogger,\n extractLlmCuaPromptSummary,\n extractLlmCuaResponseSummary,\n} from \"../flowlogger/FlowLogger.js\";\nimport { v7 as uuidv7 } from \"uuid\";\n\n/** One model function call and the executor actions it expands into. */\ninterface PlannedCall {\n functionCall: FunctionCall;\n actions: AgentAction[];\n /** Set when the call could not be converted into executable actions. */\n error?: string;\n}\n\n/** Interactions API input step (only the shapes this client sends). */\ntype InteractionStep = {\n type: \"function_result\";\n call_id: string;\n name?: string;\n is_error?: boolean;\n result: Array<\n | { type: \"text\"; text: string }\n | { type: \"image\"; data: string; mime_type?: string }\n >;\n};\n\n/** Interactions API response (only the fields this client reads). */\ninterface InteractionResponse {\n id?: string;\n status?: string;\n output_text?: string;\n steps?: Array<{\n type: string;\n id?: string;\n name?: string;\n arguments?: Record<string, unknown>;\n content?: Array<{ type: string; text?: string }>;\n }>;\n usage?: {\n total_input_tokens?: number;\n total_output_tokens?: number;\n total_thought_tokens?: number;\n total_cached_tokens?: number;\n };\n error?: { message?: string; code?: string };\n}\n\n/** Errors worth retrying: rate limits, server errors, network failures. */\nfunction isTransientError(error: unknown): boolean {\n const status = (error as { status?: unknown })?.status;\n if (typeof status === \"number\") {\n return status === 429 || status >= 500;\n }\n const message = error instanceof Error ? error.message : String(error);\n return /network|timeout|timed out|fetch failed|econn|socket hang up/i.test(\n message,\n );\n}\n\n/**\n * Client for Google's Computer Use Assistant API\n * This implementation uses the Google Generative AI SDK for Computer Use\n */\nexport class GoogleCUAClient extends AgentClient {\n private apiKey: string;\n private client: GoogleGenAI;\n private currentViewport = { width: 1288, height: 711 };\n private currentUrl?: string;\n private screenshotProvider?: () => Promise<ScreenshotProviderResult>;\n private actionHandler?: (action: AgentAction) => Promise<void>;\n private history: Content[] = [];\n private environment: \"ENVIRONMENT_BROWSER\" | \"ENVIRONMENT_DESKTOP\" =\n \"ENVIRONMENT_BROWSER\";\n private generateContentConfig: GenerateContentConfig;\n private tools?: ToolSet;\n private baseURL?: string;\n private safetyConfirmationHandler?: SafetyConfirmationHandler;\n /**\n * Request API. \"interactions\" uses the stateful Interactions API (server-side\n * history via previous_interaction_id) instead of generateContent.\n */\n private api: \"generateContent\" | \"interactions\" = \"generateContent\";\n private previousInteractionId?: string;\n private pendingInteractionInput?: string | InteractionStep[];\n constructor(\n type: AgentType,\n modelName: string,\n userProvidedInstructions?: string,\n clientOptions?: ClientOptions,\n tools?: ToolSet,\n ) {\n super(type, modelName, userProvidedInstructions);\n\n this.tools = tools;\n // Process client options\n this.apiKey =\n (clientOptions?.apiKey as string) ||\n process.env.GEMINI_API_KEY ||\n process.env.GOOGLE_GENERATIVE_AI_API_KEY ||\n process.env.GOOGLE_API_KEY ||\n \"\";\n this.baseURL = clientOptions?.baseURL as string | undefined;\n\n // Initialize the Google Generative AI client\n const genAIOptions: GoogleGenAIOptions = {\n apiKey: this.apiKey,\n ...(this.baseURL ? { httpOptions: { baseUrl: this.baseURL } } : {}),\n };\n this.client = new GoogleGenAI(genAIOptions);\n\n if (clientOptions?.googleApi === \"interactions\") {\n this.api = \"interactions\";\n }\n\n // Get environment if specified\n if (\n clientOptions?.environment &&\n typeof clientOptions.environment === \"string\"\n ) {\n this.environment = clientOptions.environment as typeof this.environment;\n }\n\n // No maxOutputTokens: thinking tokens count against it on gemini-3.x, so a\n // fixed cap truncates turns (finishReason MAX_TOKENS). Use the model max.\n this.generateContentConfig = {\n temperature: 1,\n topP: 0.95,\n topK: 40,\n systemInstruction: this.userProvidedInstructions\n ? this.userProvidedInstructions\n : buildGoogleCUASystemPrompt().content,\n tools: [\n {\n computerUse: {\n environment: this.environment,\n },\n } as Tool,\n ],\n };\n\n // Store client options for reference\n this.clientOptions = {\n apiKey: this.apiKey,\n ...(this.baseURL ? { baseURL: this.baseURL } : {}),\n };\n\n // Initialize tools if provided\n if (this.tools && Object.keys(this.tools).length > 0) {\n this.updateGenerateContentConfig();\n }\n }\n\n public setViewport(width: number, height: number): void {\n this.currentViewport = { width, height };\n }\n\n setCurrentUrl(url: string): void {\n this.currentUrl = url;\n }\n\n setScreenshotProvider(\n provider: () => Promise<ScreenshotProviderResult>,\n ): void {\n this.screenshotProvider = provider;\n }\n\n setActionHandler(handler: (action: AgentAction) => Promise<void>): void {\n this.actionHandler = handler;\n }\n\n setTools(tools: ToolSet): void {\n this.tools = tools;\n this.updateGenerateContentConfig();\n }\n\n setSafetyConfirmationHandler(handler?: SafetyConfirmationHandler): void {\n this.safetyConfirmationHandler = handler;\n }\n\n private async handleSafetyConfirmation(\n safetyDecision: unknown,\n logger: (message: LogLine) => void,\n ): Promise<string | undefined> {\n const safetyMessage =\n typeof safetyDecision === \"object\"\n ? JSON.stringify(safetyDecision, null, 2)\n : String(safetyDecision);\n\n const safetyChecks: SafetyCheck[] = [\n {\n id: \"google-safety-decision\",\n code: \"safety_decision\",\n message: safetyMessage,\n },\n ];\n\n if (this.safetyConfirmationHandler) {\n logger({\n category: \"agent\",\n message: `Requesting safety confirmation for Google safety decision: ${safetyMessage}`,\n level: 1,\n });\n\n const response = await this.safetyConfirmationHandler(safetyChecks);\n\n if (response.acknowledged) {\n logger({\n category: \"agent\",\n message: `Safety decision acknowledged by user`,\n level: 1,\n });\n return \"true\";\n } else {\n logger({\n category: \"agent\",\n message: `Safety decision rejected by user`,\n level: 1,\n });\n return undefined;\n }\n }\n\n logger({\n category: \"agent\",\n message: `Auto-acknowledging Google safety decision`,\n level: 2,\n });\n return \"true\";\n }\n\n /**\n * Update the generateContentConfig with current tools\n */\n private updateGenerateContentConfig(): void {\n const functionDeclarations =\n this.tools && Object.keys(this.tools).length > 0\n ? convertToolSetToFunctionDeclarations(this.tools)\n : [];\n\n this.generateContentConfig = {\n ...this.generateContentConfig,\n tools: [\n {\n computerUse: {\n environment: this.environment,\n },\n ...(functionDeclarations.length > 0 ? { functionDeclarations } : {}),\n } as Tool,\n ],\n };\n }\n\n /**\n * Execute a task with the Google CUA\n * This is the main entry point for the agent\n * @implements AgentClient.execute\n */\n async execute(executionOptions: AgentExecutionOptions): Promise<AgentResult> {\n const { options, logger } = executionOptions;\n const { instruction } = options;\n const maxSteps = options.maxSteps || 10;\n\n let currentStep = 0;\n let completed = false;\n let declined = false;\n const actions: AgentAction[] = [];\n const messageList: string[] = [];\n let finalMessage = \"\";\n this.history = []; // Clear history for new execution\n\n // Start with the initial instruction\n await this.initializeHistory(instruction);\n\n let totalInputTokens = 0;\n let totalOutputTokens = 0;\n let totalReasoningTokens = 0;\n let totalCachedInputTokens = 0;\n let totalInferenceTime = 0;\n\n try {\n // Execute steps until completion or max steps reached\n while (!completed && currentStep < maxSteps) {\n await this.preStepHook?.();\n\n logger({\n category: \"agent\",\n message: `Executing step ${currentStep + 1}/${maxSteps}`,\n level: 1,\n });\n\n const result = await this.executeStep(logger);\n totalInputTokens += result.usage.input_tokens;\n totalOutputTokens += result.usage.output_tokens;\n totalReasoningTokens += result.usage.reasoning_tokens;\n totalCachedInputTokens += result.usage.cached_input_tokens;\n totalInferenceTime += result.usage.inference_time_ms;\n\n // Add actions to the list\n actions.push(...result.actions);\n\n // Update completion status\n completed = result.completed;\n if (result.stopped) {\n declined = true;\n }\n\n // Record any message for this step\n if (result.message) {\n messageList.push(result.message);\n finalMessage = result.message;\n }\n\n // Increment step counter\n currentStep++;\n }\n\n // Return the final result\n return {\n success: completed && !declined,\n actions,\n message: finalMessage,\n completed,\n usage: {\n input_tokens: totalInputTokens,\n output_tokens: totalOutputTokens,\n reasoning_tokens: totalReasoningTokens,\n cached_input_tokens: totalCachedInputTokens,\n inference_time_ms: totalInferenceTime,\n },\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n logger({\n category: \"agent\",\n message: `Error executing agent task: ${errorMessage}`,\n level: 0,\n });\n\n return {\n success: false,\n actions,\n message: `Failed to execute task: ${errorMessage}`,\n completed: false,\n usage: {\n input_tokens: totalInputTokens,\n output_tokens: totalOutputTokens,\n reasoning_tokens: totalReasoningTokens,\n cached_input_tokens: totalCachedInputTokens,\n inference_time_ms: totalInferenceTime,\n },\n };\n }\n }\n\n /**\n * Initialize conversation history with the initial instruction\n */\n private async initializeHistory(instruction: string): Promise<void> {\n const parts: Part[] = [{ text: instruction }];\n\n this.previousInteractionId = undefined;\n this.pendingInteractionInput = instruction;\n\n // Note: The Python implementation doesn't include the initial screenshot\n // Following the same pattern here. The system prompt travels in\n // generateContentConfig.systemInstruction.\n this.history = [\n {\n role: \"user\",\n parts,\n },\n ];\n }\n\n /**\n * Execute a single step of the agent\n */\n async executeStep(logger: (message: LogLine) => void): Promise<{\n actions: AgentAction[];\n message: string;\n completed: boolean;\n /** True when the run must end without success (user declined a safety check). */\n stopped: boolean;\n usage: {\n input_tokens: number;\n output_tokens: number;\n reasoning_tokens: number;\n cached_input_tokens: number;\n inference_time_ms: number;\n };\n }> {\n try {\n const startTime = Date.now();\n\n // Compress images in conversation history before sending to the model\n const compressedResult = compressGoogleConversationImages(\n this.history,\n 2,\n );\n const compressedHistory = compressedResult.items;\n\n // Use the SDK's generateContent method, retrying only transient failures\n // (rate limits, 5xx, network, empty candidates). Anything else — a 400,\n // or a candidate that stopped for a non-STOP reason — fails fast.\n const maxRetries = 5;\n const baseDelayS = 1;\n let lastError: Error | null = null;\n let response: GenerateContentResponse | null = null;\n let emptyResponse = false;\n\n // Log LLM request\n const llmRequestId = uuidv7();\n FlowLogger.logLlmRequest({\n requestId: llmRequestId,\n model: this.modelName,\n prompt: extractLlmCuaPromptSummary(compressedHistory),\n });\n\n for (let attempt = 0; attempt < maxRetries; attempt++) {\n try {\n // Add exponential backoff delay for retries\n if (attempt > 0) {\n const delay = baseDelayS * Math.pow(2, attempt) * 1000; // Convert to ms\n logger({\n category: \"agent\",\n message: `Generating content failed on attempt ${attempt + 1}. Retrying in ${delay / 1000} seconds...`,\n level: 2,\n });\n await new Promise((resolve) => setTimeout(resolve, delay));\n }\n\n // Use the SDK's generateContent method - following Python SDK pattern\n response = await this.requestModel(compressedHistory);\n\n // An empty response is treated as transient and retried; an early\n // stop (non-STOP finish reason) is not — it is rejected below.\n if (!response.candidates || response.candidates.length === 0) {\n emptyResponse = true;\n throw new LLMResponseError(\"agent\", \"Response has no candidates!\");\n }\n const first = response.candidates[0];\n const stoppedEarly =\n first.finishReason && first.finishReason !== \"STOP\";\n if (!stoppedEarly && !first.content?.parts?.length) {\n emptyResponse = true;\n throw new LLMResponseError(\n \"agent\",\n `Response has no content (finish reason: ${first.finishReason || \"unknown\"})`,\n );\n }\n\n // Success - validated below, outside the retry loop\n break;\n } catch (error) {\n lastError = error instanceof Error ? error : new Error(String(error));\n logger({\n category: \"agent\",\n message: `API call error: ${lastError.message}`,\n level: 2,\n });\n\n const retryable = emptyResponse || isTransientError(error);\n emptyResponse = false;\n if (!retryable) {\n throw lastError;\n }\n\n // If this was the last attempt, throw the error\n if (attempt === maxRetries - 1) {\n logger({\n category: \"agent\",\n message: `Generating content failed after ${maxRetries} attempts.`,\n level: 0,\n });\n throw lastError;\n }\n }\n }\n\n if (!response) {\n throw (\n lastError || new Error(\"Failed to get response after all retries\")\n );\n }\n\n // A candidate that stopped for any reason other than STOP (MAX_TOKENS,\n // SAFETY, MALFORMED_FUNCTION_CALL, ...) is incomplete: fail the run\n // rather than executing its calls or reporting its text as the answer.\n const candidate = response.candidates![0];\n if (candidate.finishReason && candidate.finishReason !== \"STOP\") {\n throw new LLMResponseError(\n \"agent\",\n `Model response stopped early (finish reason: ${candidate.finishReason})`,\n );\n }\n\n const endTime = Date.now();\n const elapsedMs = endTime - startTime;\n const { usageMetadata } = response;\n\n // Log LLM response\n FlowLogger.logLlmResponse({\n requestId: llmRequestId,\n model: this.modelName,\n output: extractLlmCuaResponseSummary(response),\n inputTokens: usageMetadata?.promptTokenCount,\n outputTokens: usageMetadata?.candidatesTokenCount,\n });\n\n // Process the response\n const result = await this.processResponse(response, logger);\n\n // Add model response to history\n if (response.candidates && response.candidates[0]) {\n // Sanitize any out-of-range coordinates in function calls before adding to history\n const sanitizedContent = JSON.parse(\n JSON.stringify(response.candidates[0].content),\n );\n if (sanitizedContent.parts) {\n for (const part of sanitizedContent.parts) {\n if (part.functionCall?.args) {\n if (\n typeof part.functionCall.args.x === \"number\" &&\n part.functionCall.args.x > 999\n ) {\n part.functionCall.args.x = 999;\n }\n if (\n typeof part.functionCall.args.y === \"number\" &&\n part.functionCall.args.y > 999\n ) {\n part.functionCall.args.y = 999;\n }\n }\n }\n }\n this.history.push(sanitizedContent);\n }\n\n // Execute each function call and answer it with its own function\n // response: the call's outcome (output or error text), the URL, and a\n // fresh screenshot taken after that call. The model expects exactly one\n // response per call, including calls with nothing to execute (e.g. a\n // standalone take_screenshot) and calls that could not be converted.\n const functionResponses: Part[] = [];\n let stopped: string | undefined;\n\n for (const call of result.calls) {\n const { functionCall } = call;\n\n if (call.actions[0]?.type === \"custom_tool\") {\n const action = call.actions[0];\n const toolName = action.name as string;\n if (this.tools && toolName in this.tools) {\n const executionResult = await executeGoogleCustomTool(\n toolName,\n action.arguments as Record<string, unknown>,\n this.tools,\n functionCall,\n logger,\n );\n functionResponses.push(executionResult.functionResponse);\n }\n continue;\n }\n\n // Ask for confirmation BEFORE acting. If the user declines, the\n // action is not executed and the run stops.\n let safetyAcknowledgement: string | undefined;\n if (functionCall.args?.safety_decision) {\n safetyAcknowledgement = await this.handleSafetyConfirmation(\n functionCall.args.safety_decision,\n logger,\n );\n if (safetyAcknowledgement === undefined) {\n stopped = `Stopped: the user declined to confirm \"${functionCall.name}\".`;\n break;\n }\n }\n\n let error = call.error;\n if (!error) {\n for (let i = 0; i < call.actions.length; i++) {\n const action = call.actions[i];\n\n logger({\n category: \"agent\",\n message: `Executing action ${i + 1}/${call.actions.length} for ${functionCall.name}: ${action.type}`,\n level: 2,\n });\n\n // open_web_browser and take_screenshot have nothing to execute;\n // the screenshot captured below is the call's result.\n if (action.type === \"open_web_browser\") {\n action.pageUrl = this.currentUrl;\n continue;\n }\n if (action.type === \"screenshot\" || !this.actionHandler) {\n continue;\n }\n\n try {\n await this.actionHandler(action);\n\n // Add a delay between actions to ensure they complete properly\n // Longer delay for typing actions to ensure fields are ready\n if (i < call.actions.length - 1) {\n const nextAction = call.actions[i + 1];\n const isTypingAction =\n action.type === \"type\" || nextAction.type === \"type\";\n const delay = isTypingAction ? 500 : 200;\n await new Promise((resolve) => setTimeout(resolve, delay));\n }\n } catch (actionError) {\n if (actionError instanceof StagehandClosedError) {\n throw actionError;\n }\n error =\n actionError instanceof Error\n ? actionError.message\n : String(actionError);\n logger({\n category: \"agent\",\n message: `Error executing action ${action.type}: ${error}`,\n level: 0,\n });\n // Skip the rest of this call; report the failure to the model.\n break;\n }\n }\n }\n\n let screenshot: ScreenshotProviderResult | undefined;\n let screenshotError: string | undefined;\n try {\n screenshot = await this.captureScreenshot();\n } catch (screenshotFailure) {\n if (screenshotFailure instanceof StagehandClosedError) {\n throw screenshotFailure;\n }\n screenshotError =\n screenshotFailure instanceof Error\n ? screenshotFailure.message\n : String(screenshotFailure);\n logger({\n category: \"agent\",\n message: `Error capturing screenshot: ${screenshotError}`,\n level: 0,\n });\n }\n\n functionResponses.push({\n functionResponse: {\n ...(functionCall.id ? { id: functionCall.id } : {}),\n name: functionCall.name,\n response: {\n url: this.currentUrl || \"\",\n ...(error ? { error } : {}),\n ...(screenshotError ? { screenshot_error: screenshotError } : {}),\n ...(safetyAcknowledgement !== undefined\n ? { safety_acknowledgement: safetyAcknowledgement }\n : {}),\n },\n ...(screenshot\n ? {\n parts: [\n {\n inlineData: {\n mimeType: screenshot.mediaType,\n data: screenshot.base64,\n },\n },\n ],\n }\n : {}),\n },\n });\n }\n\n // The Interactions API keeps history server-side: the next request sends\n // only these results, chained by previous_interaction_id.\n if (this.api === \"interactions\" && !stopped) {\n this.pendingInteractionInput = functionResponses.map(\n GoogleCUAClient.toFunctionResult,\n );\n }\n\n // Add all function responses to history in a single user message\n if (!stopped && functionResponses.length > 0) {\n logger({\n category: \"agent\",\n message: `Adding ${functionResponses.length} function responses to history`,\n level: 2,\n });\n this.history.push({\n role: \"user\",\n parts: functionResponses,\n });\n }\n\n return {\n actions: result.actions,\n message: stopped ?? result.message,\n completed: stopped ? true : result.completed,\n stopped: stopped !== undefined,\n usage: {\n // promptTokenCount is the TOTAL input and already includes the\n // cached portion; cachedContentTokenCount is the cache-hit subset\n // (tracked separately for visibility, not additive). thoughtsTokenCount\n // is Gemini's thinking/reasoning output.\n input_tokens: usageMetadata?.promptTokenCount || 0,\n output_tokens: usageMetadata?.candidatesTokenCount || 0,\n reasoning_tokens: usageMetadata?.thoughtsTokenCount || 0,\n cached_input_tokens: usageMetadata?.cachedContentTokenCount || 0,\n inference_time_ms: elapsedMs,\n },\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n logger({\n category: \"agent\",\n message: `Error executing step: ${errorMessage}`,\n level: 0,\n });\n\n throw error;\n }\n }\n\n /** Send one model request on the configured API. */\n private async requestModel(\n contents: Content[],\n ): Promise<GenerateContentResponse> {\n if (this.api === \"interactions\") {\n return this.createInteraction();\n }\n return this.client.models.generateContent({\n model: this.modelName,\n contents,\n config: this.generateContentConfig,\n });\n }\n\n /**\n * Create an interaction (Interactions API, REST) continuing the previous one,\n * and map it onto the generateContent response shape the step loop expects.\n */\n private async createInteraction(): Promise<GenerateContentResponse> {\n const baseUrl = (\n this.baseURL ?? \"https://generativelanguage.googleapis.com\"\n ).replace(/\\/+$/, \"\");\n const body = {\n model: this.modelName.replace(/^models\\//, \"\"),\n input: this.pendingInteractionInput,\n system_instruction: this.generateContentConfig.systemInstruction,\n tools: [\n {\n type: \"computer_use\",\n environment:\n this.environment === \"ENVIRONMENT_DESKTOP\" ? \"desktop\" : \"browser\",\n },\n ],\n ...(this.previousInteractionId\n ? { previous_interaction_id: this.previousInteractionId }\n : {}),\n };\n\n const res = await fetch(`${baseUrl}/v1beta/interactions`, {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n \"x-goog-api-key\": this.apiKey,\n },\n body: JSON.stringify(body),\n });\n const json = (await res.json().catch(() => ({}))) as InteractionResponse;\n if (!res.ok || !json.id) {\n const { message = res.statusText, code } = json.error ?? {};\n // code \"safety\": Google's input classifier rejected the turn. Not\n // transient (status 400), so it fails the run instead of retrying.\n throw Object.assign(\n new Error(\n code === \"safety\"\n ? `Gemini blocked the request (safety): ${message}`\n : `Interactions API error ${res.status}: ${message}`,\n ),\n { status: res.status },\n );\n }\n\n const parts: Part[] = [];\n for (const step of json.steps ?? []) {\n if (step.type === \"function_call\" && step.name) {\n parts.push({\n functionCall: { id: step.id, name: step.name, args: step.arguments },\n });\n } else if (step.type === \"model_output\") {\n for (const content of step.content ?? []) {\n if (content.type === \"text\" && content.text) {\n parts.push({ text: content.text });\n }\n }\n }\n }\n if (parts.length === 0 && json.output_text) {\n parts.push({ text: json.output_text });\n }\n this.previousInteractionId = json.id;\n\n // requires_action (calls to answer) and completed are normal stops; any\n // other status (incomplete, failed, budget_exceeded, ...) is an early stop.\n const finishReason =\n json.status === \"requires_action\" || json.status === \"completed\"\n ? \"STOP\"\n : String(json.status).toUpperCase();\n\n return {\n candidates: [{ content: { role: \"model\", parts }, finishReason }],\n usageMetadata: {\n promptTokenCount: json.usage?.total_input_tokens,\n candidatesTokenCount: json.usage?.total_output_tokens,\n thoughtsTokenCount: json.usage?.total_thought_tokens,\n cachedContentTokenCount: json.usage?.total_cached_tokens,\n },\n } as GenerateContentResponse;\n }\n\n /** Convert a generateContent function response into an Interactions result. */\n private static toFunctionResult(part: Part): InteractionStep {\n const fr = part.functionResponse!;\n const response: Record<string, unknown> = { ...(fr.response ?? {}) };\n // The Interactions API takes a boolean acknowledgement.\n if (response.safety_acknowledgement !== undefined) {\n response.safety_acknowledgement = true;\n }\n const image = fr.parts?.[0]?.inlineData;\n return {\n type: \"function_result\",\n call_id: fr.id ?? \"\",\n name: fr.name,\n ...(response.error ? { is_error: true } : {}),\n result: [\n { type: \"text\", text: JSON.stringify(response) },\n ...(image?.data\n ? [\n {\n type: \"image\" as const,\n data: image.data,\n mime_type: image.mimeType,\n },\n ]\n : []),\n ],\n };\n }\n\n /**\n * Process the response from Google's API\n */\n private async processResponse(\n response: GenerateContentResponse,\n logger: (message: LogLine) => void,\n ): Promise<{\n actions: AgentAction[];\n message: string;\n completed: boolean;\n calls: PlannedCall[];\n }> {\n const calls: PlannedCall[] = [];\n let message = \"\";\n\n if (!response.candidates || response.candidates.length === 0) {\n return {\n actions: [],\n message: \"No candidates in response\",\n completed: true,\n calls: [],\n };\n }\n const candidate = response.candidates[0];\n\n // Log the raw response for debugging\n logger({\n category: \"agent\",\n message: `Raw response from Google: ${JSON.stringify(candidate.content, null, 2)}`,\n level: 2,\n });\n\n // Process all parts - Google can send multiple function calls\n for (const part of candidate.content.parts) {\n if (part.text) {\n message += part.text + \"\\n\";\n logger({\n category: \"agent\",\n message: `Reasoning: ${part.text}`,\n level: 1,\n });\n }\n if (part.functionCall) {\n const functionCall = part.functionCall;\n logger({\n category: \"agent\",\n message: `Found function call: ${functionCall.name} with args: ${JSON.stringify(functionCall.args)}`,\n level: 2,\n });\n\n const action = this.convertFunctionCallToAction(functionCall, logger);\n if (!action) {\n logger({\n category: \"agent\",\n message: `Warning: Could not convert function call ${functionCall.name} to action`,\n level: 1,\n });\n calls.push({\n functionCall,\n actions: [],\n error: `Unsupported or malformed computer-use action \"${functionCall.name}\" with args ${JSON.stringify(functionCall.args ?? {})}`,\n });\n continue;\n }\n\n calls.push({ functionCall, actions: this.expandAction(action) });\n }\n }\n\n const actions = calls.flatMap((call) => call.actions);\n\n // Log summary of what we found\n logger({\n category: \"agent\",\n message: `Found ${calls.length} function calls, converted to ${actions.length} actions`,\n level: 2,\n });\n\n if (calls.length === 0 && !message.trim()) {\n throw new LLMResponseError(\n \"agent\",\n \"Response has neither function calls nor text\",\n );\n }\n\n // Early stops (non-STOP finish reasons) are rejected in executeStep, so a\n // turn is complete exactly when the model made no function calls.\n return {\n actions,\n message: message.trim(),\n completed: calls.length === 0,\n calls,\n };\n }\n\n /**\n * Expand a converted action into the executor steps it needs. Typing may\n * click the field first, clear it, and press Enter afterwards.\n */\n private expandAction(action: AgentAction): AgentAction[] {\n if (action.type !== \"type\") {\n return [action];\n }\n const steps: AgentAction[] = [];\n // Click the target first only when coordinates are provided.\n if (typeof action.x === \"number\" && typeof action.y === \"number\") {\n steps.push({ type: \"click\", x: action.x, y: action.y, button: \"left\" });\n }\n if (action.clearBeforeTyping) {\n steps.push({ type: \"keypress\", keys: [\"ControlOrMeta+A\"] });\n steps.push({ type: \"keypress\", keys: [\"Backspace\"] });\n }\n steps.push(action);\n if (action.pressEnter) {\n steps.push({ type: \"keypress\", keys: [\"Enter\"] });\n }\n return steps;\n }\n\n /**\n * Convert Google function call to Stagehand action\n */\n private convertFunctionCallToAction(\n functionCall: FunctionCall,\n logger?: (message: LogLine) => void,\n ): AgentAction | null {\n const { name: rawName } = functionCall;\n // Default args to an empty object so no-argument predefined functions\n // (e.g. take_screenshot, go_back) are not rejected by the guard below.\n const args = functionCall.args ?? {};\n\n if (!rawName) {\n return null;\n }\n\n // The gemini-3.x computer-use tool renamed several of the predefined\n // functions that gemini-2.5-computer-use-preview used, and adds a\n // descriptive `intent` arg to every call. The argument fields are otherwise\n // unchanged (confirmed for click/navigate). Normalize the 3.x names to the\n // canonical 2.5 names so a single set of handlers serves both generations;\n // `intent` is ignored since handlers only read the args they need.\n // NOTE: click and take_screenshot are confirmed from live gemini-3.5-flash\n // traffic; the rest are inferred from the same drop-the-qualifier pattern\n // and are safe aliases (any unmapped name still hits the warning below).\n // gemini-3.x renamed several predefined functions vs gemini-2.5. Alias the\n // 3.x names whose behavior maps cleanly onto a 2.5 canonical handler. Click\n // variants that carry distinct semantics (double/triple/right/middle click,\n // move) are NOT aliased here — they have dedicated cases below so the click\n // count and button are preserved. 2.5 never emits any of these names, so\n // the 2.5 handlers are unaffected.\n const NAME_ALIASES: Record<string, string> = {\n click: \"click_at\",\n left_click: \"click_at\",\n type: \"type_text_at\",\n type_text: \"type_text_at\",\n hover: \"hover_at\",\n scroll: \"scroll_at\",\n drag: \"drag_and_drop\",\n key: \"key_combination\",\n keys: \"key_combination\",\n key_press: \"key_combination\",\n press_key: \"key_combination\",\n press_keys: \"key_combination\",\n hotkey: \"key_combination\",\n screenshot: \"take_screenshot\",\n };\n const name = NAME_ALIASES[rawName] ?? rawName;\n\n // Predefined computer-use tools take precedence over custom tools. If a\n // custom tool was registered under a reserved (aliased) name, note that the\n // predefined tool wins rather than silently dropping the custom one.\n if (rawName in NAME_ALIASES && isCustomTool(functionCall, this.tools)) {\n logger?.({\n category: \"agent\",\n message: `Custom tool \"${rawName}\" collides with a predefined Google CUA function; using the predefined tool. Rename the custom tool to avoid the conflict.`,\n level: 2,\n });\n }\n\n switch (name) {\n case \"open_web_browser\":\n return {\n type: \"open_web_browser\",\n timestamp: Date.now(),\n };\n\n case \"take_screenshot\":\n // No UI interaction. The step loop captures a fresh screenshot and\n // returns it to the model as this call's function response; marked as a\n // recognized action (not null) so it isn't dropped, and skipped in the\n // executor like open_web_browser.\n return {\n type: \"screenshot\",\n timestamp: Date.now(),\n };\n\n case \"click_at\": {\n // x/y are required; reject a malformed call rather than normalizing\n // undefined/NaN/Infinity into bad coordinates. (gemini-3.x `click`\n // aliases here.)\n if (\n !GoogleCUAClient.isFiniteCoord(args.x) ||\n !GoogleCUAClient.isFiniteCoord(args.y)\n ) {\n return null;\n }\n const { x, y } = this.normalizeCoordinates(args.x, args.y);\n return {\n type: \"click\",\n x,\n y,\n button: args.button || \"left\",\n };\n }\n\n // gemini-3.x click family. The executor natively supports double/triple\n // click and right/middle button, so preserve those semantics rather than\n // collapsing to a single left click. All require integer coordinates;\n // drop the call (return null) on a malformed payload so the executor is\n // never handed NaN.\n case \"double_click\":\n case \"triple_click\":\n case \"right_click\":\n case \"middle_click\":\n case \"move\": {\n if (\n !GoogleCUAClient.isFiniteCoord(args.x) ||\n !GoogleCUAClient.isFiniteCoord(args.y)\n ) {\n return null;\n }\n const { x, y } = this.normalizeCoordinates(args.x, args.y);\n if (name === \"move\") {\n return { type: \"move\", x, y };\n }\n if (name === \"double_click\" || name === \"triple_click\") {\n return { type: name, x, y };\n }\n return {\n type: \"click\",\n x,\n y,\n button: name === \"right_click\" ? \"right\" : \"middle\",\n };\n }\n\n // gemini-3.x press/release primitives (e.g. a manual drag or a\n // modifier held across clicks).\n case \"mouse_down\":\n case \"mouse_up\": {\n if (\n !GoogleCUAClient.isFiniteCoord(args.x) ||\n !GoogleCUAClient.isFiniteCoord(args.y)\n ) {\n return null;\n }\n const { x, y } = this.normalizeCoordinates(args.x, args.y);\n return { type: name, x, y };\n }\n\n case \"key_down\":\n case \"key_up\": {\n if (typeof args.key !== \"string\" || !args.key.trim()) {\n return null;\n }\n return { type: name, key: args.key.trim() };\n }\n\n case \"type_text_at\": {\n // text is required; reject a malformed call rather than typing\n // \"undefined\". An empty string is valid (e.g. clear the field).\n if (typeof args.text !== \"string\") {\n return null;\n }\n // gemini-2.5 type_text_at clears the field by default\n // (clear_before_typing). gemini-3.x `type` has no such arg and types\n // into the focused element, so only clear when asked or when the call\n // targets a field by coordinates.\n const hasCoords =\n typeof args.x === \"number\" && typeof args.y === \"number\";\n const pressEnter = (args.press_enter as boolean) ?? false;\n const clearBeforeTyping =\n (args.clear_before_typing as boolean) ?? hasCoords;\n const base = {\n type: \"type\" as const,\n text: args.text as string,\n pressEnter,\n clearBeforeTyping,\n };\n\n // gemini-2.5 type_text_at carries x/y (click the field, then type).\n // gemini-3.x `type` has no coordinates and types into the element the\n // model already focused with a preceding click. Only attach coords when\n // present so the executor doesn't click at NaN.\n if (hasCoords) {\n const { x, y } = this.normalizeCoordinates(\n args.x as number,\n args.y as number,\n );\n return { ...base, x, y };\n }\n return base;\n }\n\n case \"key_combination\": {\n // gemini-2.5 key_combination sends `keys` as a \"+\"-joined string;\n // gemini-3.x `hotkey` sends a `keys` array, and `press_key` sends a\n // single `key`. Accept all three.\n const raw = args.keys !== undefined ? args.keys : args.key;\n const parts = Array.isArray(raw)\n ? (raw as string[])\n : String(raw ?? \"\").split(\"+\");\n const keys = parts\n .map((key) => String(key).trim())\n .filter(Boolean)\n .map((key) => mapKeyToPlaywright(key));\n if (keys.length === 0) {\n return null;\n }\n return {\n type: \"keypress\",\n keys,\n };\n }\n\n case \"scroll_document\": {\n const direction = (args.direction as string).toLowerCase();\n return {\n type: \"keypress\",\n keys: [direction === \"up\" ? \"PageUp\" : \"PageDown\"],\n };\n }\n\n case \"scroll_at\": {\n // A coordinate-less (or malformed) `scroll` alias (gemini-3.x) scrolls\n // the document via PageUp/PageDown.\n if (\n !GoogleCUAClient.isFiniteCoord(args.x) ||\n !GoogleCUAClient.isFiniteCoord(args.y)\n ) {\n const dir = ((args.direction as string) || \"down\").toLowerCase();\n return {\n type: \"keypress\",\n keys: [dir === \"up\" ? \"PageUp\" : \"PageDown\"],\n };\n }\n const { x, y } = this.normalizeCoordinates(args.x, args.y);\n const direction = ((args.direction as string) || \"down\").toLowerCase();\n // 2.5 uses `magnitude` (default 800); gemini-3.x `scroll` uses\n // `magnitude_in_pixels` (default 300).\n const magnitude = GoogleCUAClient.isFiniteCoord(args.magnitude)\n ? args.magnitude\n : GoogleCUAClient.isFiniteCoord(args.magnitude_in_pixels)\n ? args.magnitude_in_pixels\n : rawName === \"scroll\"\n ? 300\n : 800;\n\n let scroll_x = 0;\n let scroll_y = 0;\n if (direction === \"up\") {\n scroll_y = -magnitude;\n } else if (direction === \"down\") {\n scroll_y = magnitude;\n } else if (direction === \"left\") {\n scroll_x = -magnitude;\n } else if (direction === \"right\") {\n scroll_x = magnitude;\n } else {\n // Default to down if unknown direction\n scroll_y = magnitude;\n }\n\n return {\n type: \"scroll\",\n x,\n y,\n scroll_x,\n scroll_y,\n };\n }\n\n case \"navigate\":\n // url is required; reject a malformed call rather than navigating to\n // \"undefined\".\n if (typeof args.url !== \"string\" || args.url.length === 0) {\n return null;\n }\n return {\n type: \"goto\",\n url: args.url,\n };\n\n case \"go_back\":\n return {\n type: \"back\",\n };\n\n case \"go_forward\":\n return {\n type: \"forward\",\n };\n\n case \"wait_5_seconds\":\n return {\n type: \"wait\",\n timeMs: 5000, // Google CUA waits for 5 seconds\n };\n\n case \"wait\": {\n // gemini-3.x `wait` takes optional `seconds` (default 1).\n const seconds =\n GoogleCUAClient.isFiniteCoord(args.seconds) && args.seconds >= 0\n ? args.seconds\n : 1;\n return {\n type: \"wait\",\n timeMs: Math.round(seconds * 1000),\n };\n }\n\n case \"hover_at\": {\n const { x, y } = this.normalizeCoordinates(\n args.x as number,\n args.y as number,\n );\n return {\n type: \"move\",\n x,\n y,\n };\n }\n\n case \"search\":\n return {\n type: \"goto\",\n url: \"https://www.google.com\",\n };\n\n case \"drag_and_drop\": {\n // 2.5 uses x/y + destination_x/destination_y; gemini-3.x `drag_and_drop`\n // uses start_x/start_y + end_x/end_y. Accept either.\n const sx = args.x ?? args.start_x;\n const sy = args.y ?? args.start_y;\n const ex = args.destination_x ?? args.end_x;\n const ey = args.destination_y ?? args.end_y;\n if (\n !GoogleCUAClient.isFiniteCoord(sx) ||\n !GoogleCUAClient.isFiniteCoord(sy) ||\n !GoogleCUAClient.isFiniteCoord(ex) ||\n !GoogleCUAClient.isFiniteCoord(ey)\n ) {\n return null;\n }\n const startPoint = this.normalizeCoordinates(sx, sy);\n const endPoint = this.normalizeCoordinates(ex, ey);\n return {\n type: \"drag\",\n path: [\n { x: startPoint.x, y: startPoint.y },\n { x: endPoint.x, y: endPoint.y },\n ],\n };\n }\n\n default:\n if (isCustomTool(functionCall, this.tools)) {\n return {\n type: \"custom_tool\",\n name,\n arguments: args,\n timestamp: Date.now(),\n pageUrl: this.currentUrl,\n };\n }\n console.warn(`Unsupported Google CUA function: ${name}`);\n return null;\n }\n }\n\n /**\n * True only for a usable coordinate/number: rejects undefined, non-numbers,\n * and the numeric edge cases NaN and Infinity (both `typeof \"number\"`), so\n * malformed function calls are dropped instead of normalizing into NaN.\n */\n private static isFiniteCoord(value: unknown): value is number {\n return typeof value === \"number\" && Number.isFinite(value);\n }\n\n /**\n * Normalize coordinates from Google's 0-1000 range to viewport dimensions\n */\n private normalizeCoordinates(x: number, y: number): { x: number; y: number } {\n const clampedX = Math.min(999, Math.max(0, x));\n const clampedY = Math.min(999, Math.max(0, y));\n return {\n x: Math.floor((clampedX / 1000) * this.currentViewport.width),\n y: Math.floor((clampedY / 1000) * this.currentViewport.height),\n };\n }\n\n async captureScreenshot(options?: {\n base64Image?: string;\n mediaType?: \"image/png\" | \"image/jpeg\";\n currentUrl?: string;\n }): Promise<ScreenshotProviderResult> {\n // Update current URL if provided\n if (options?.currentUrl) {\n this.currentUrl = options.currentUrl;\n }\n\n // Use provided options if available\n if (options?.base64Image) {\n return {\n base64: options.base64Image,\n mediaType: options.mediaType ?? \"image/png\",\n };\n }\n\n // Use the screenshot provider if available\n if (this.screenshotProvider) {\n try {\n return await this.screenshotProvider();\n } catch (error) {\n console.error(\"Error capturing screenshot:\", error);\n throw error;\n }\n }\n\n throw new AgentScreenshotProviderError(\n \"`screenshotProvider` has not been set. \" +\n \"Please call `setScreenshotProvider()` with a valid function that returns a base64-encoded image and media type\",\n );\n }\n}\n"]}
|
|
@@ -19,7 +19,7 @@ const clickTool = (v3, provider) => (0, ai_1.tool)({
|
|
|
19
19
|
execute: async ({ describe, coordinates }) => {
|
|
20
20
|
try {
|
|
21
21
|
const page = await v3.context.awaitActivePage();
|
|
22
|
-
const processed = (0, coordinateNormalization_js_1.processCoordinates)(coordinates[0], coordinates[1], provider, v3);
|
|
22
|
+
const processed = await (0, coordinateNormalization_js_1.processCoordinates)(coordinates[0], coordinates[1], provider, v3);
|
|
23
23
|
v3.logger({
|
|
24
24
|
category: "agent",
|
|
25
25
|
message: `Agent calling tool: click`,
|
|
@@ -33,9 +33,18 @@ const clickTool = (v3, provider) => (0, ai_1.tool)({
|
|
|
33
33
|
});
|
|
34
34
|
// Only request XPath when caching is enabled to avoid unnecessary computation
|
|
35
35
|
const shouldCollectXpath = v3.isAgentReplayActive();
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
// On a touch session, actuate as a trusted tap rather than a mouse click:
|
|
37
|
+
// mobile layouts commonly gate their handlers on touch/pointer events, where
|
|
38
|
+
// a synthesized mouse click never registers (a size selector highlights but
|
|
39
|
+
// still reports "please choose a size"). Mirrors the CUA handler's routing.
|
|
40
|
+
const useTouch = v3.usesTouch;
|
|
41
|
+
const xpath = useTouch
|
|
42
|
+
? await page.tap(processed.x, processed.y, {
|
|
43
|
+
returnXpath: shouldCollectXpath,
|
|
44
|
+
})
|
|
45
|
+
: await page.click(processed.x, processed.y, {
|
|
46
|
+
returnXpath: shouldCollectXpath,
|
|
47
|
+
});
|
|
39
48
|
const screenshotBase64 = await (0, screenshotHandler_js_1.waitAndCaptureScreenshot)(page);
|
|
40
49
|
// Record as an "act" step with proper Action for deterministic replay (only when caching)
|
|
41
50
|
if (shouldCollectXpath) {
|
|
@@ -44,7 +53,9 @@ const clickTool = (v3, provider) => (0, ai_1.tool)({
|
|
|
44
53
|
const action = {
|
|
45
54
|
selector: normalizedXpath,
|
|
46
55
|
description: describe,
|
|
47
|
-
|
|
56
|
+
// Replay the same input kind that was recorded, so a cached mobile
|
|
57
|
+
// run does not silently fall back to a mouse click.
|
|
58
|
+
method: useTouch ? "tap" : "click",
|
|
48
59
|
arguments: [],
|
|
49
60
|
};
|
|
50
61
|
v3.recordAgentReplayStep({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"click.js","sourceRoot":"","sources":["../../../../../../lib/v3/agent/tools/click.ts"],"names":[],"mappings":";;;AAAA,2BAA0B;AAC1B,6BAAwB;AAOxB,oFAAyE;AACzE,gDAAgD;AAChD,wEAAyE;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AAE,OAAO;gBACb,SAAS,EAAE,WAAW;gBACtB,IAAI,EAAE,MAAM,CAAC,gBAAgB;aAC9B,CAAC,CAAC;QACL,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;IAC7C,CAAC;CACF,CAAC,CAAC;AAlHQ,QAAA,SAAS,aAkHjB","sourcesContent":["import { tool } from \"ai\";\nimport { z } from \"zod\";\nimport type { V3 } from \"../../v3.js\";\nimport type { Action } from \"../../types/public/methods.js\";\nimport type {\n ClickToolResult,\n ModelOutputContentItem,\n} from \"../../types/public/agent.js\";\nimport { processCoordinates } from \"../utils/coordinateNormalization.js\";\nimport { ensureXPath } from \"../utils/xpath.js\";\nimport { waitAndCaptureScreenshot } from \"../utils/screenshotHandler.js\";\n\nexport const clickTool = (v3: V3, provider?: string) =>\n tool({\n description:\n \"Click on an element using its coordinates (this is the most reliable way to click on an element, always use this over act, unless the element is not visible in the screenshot, but shown in ariaTree)\",\n inputSchema: z.object({\n describe: z\n .string()\n .describe(\n \"Describe the element to click on in a short, specific phrase that mentions the element type and a good visual description\",\n ),\n coordinates: z\n .array(z.number())\n .describe(\"The (x, y) coordinates to click on\"),\n }),\n execute: async ({ describe, coordinates }): Promise<ClickToolResult> => {\n try {\n const page = await v3.context.awaitActivePage();\n const processed = await processCoordinates(\n coordinates[0],\n coordinates[1],\n provider,\n v3,\n );\n\n v3.logger({\n category: \"agent\",\n message: `Agent calling tool: click`,\n level: 1,\n auxiliary: {\n arguments: {\n value: JSON.stringify({ describe }),\n type: \"object\",\n },\n },\n });\n\n // Only request XPath when caching is enabled to avoid unnecessary computation\n const shouldCollectXpath = v3.isAgentReplayActive();\n // On a touch session, actuate as a trusted tap rather than a mouse click:\n // mobile layouts commonly gate their handlers on touch/pointer events, where\n // a synthesized mouse click never registers (a size selector highlights but\n // still reports \"please choose a size\"). Mirrors the CUA handler's routing.\n const useTouch = v3.usesTouch;\n const xpath = useTouch\n ? await page.tap(processed.x, processed.y, {\n returnXpath: shouldCollectXpath,\n })\n : await page.click(processed.x, processed.y, {\n returnXpath: shouldCollectXpath,\n });\n\n const screenshotBase64 = await waitAndCaptureScreenshot(page);\n\n // Record as an \"act\" step with proper Action for deterministic replay (only when caching)\n if (shouldCollectXpath) {\n const normalizedXpath = ensureXPath(xpath);\n if (normalizedXpath) {\n const action: Action = {\n selector: normalizedXpath,\n description: describe,\n // Replay the same input kind that was recorded, so a cached mobile\n // run does not silently fall back to a mouse click.\n method: useTouch ? \"tap\" : \"click\",\n arguments: [],\n };\n v3.recordAgentReplayStep({\n type: \"act\",\n instruction: describe,\n actions: [action],\n actionDescription: describe,\n });\n }\n }\n\n return {\n success: true,\n describe,\n coordinates: [processed.x, processed.y],\n screenshotBase64,\n };\n } catch (error) {\n return {\n success: false,\n error: `Error clicking: ${error.message}`,\n };\n }\n },\n toModelOutput: (result) => {\n if (result.success === false || result.error !== undefined) {\n return {\n type: \"content\",\n value: [{ type: \"text\", text: JSON.stringify(result) }],\n };\n }\n\n const content: ModelOutputContentItem[] = [\n {\n type: \"text\",\n text: JSON.stringify({\n success: result.success,\n describe: result.describe,\n coordinates: result.coordinates,\n }),\n },\n ];\n if (result.screenshotBase64) {\n content.push({\n type: \"media\",\n mediaType: \"image/png\",\n data: result.screenshotBase64,\n });\n }\n return { type: \"content\", value: content };\n },\n });\n"]}
|
|
@@ -21,7 +21,7 @@ const clickAndHoldTool = (v3, provider) => (0, ai_1.tool)({
|
|
|
21
21
|
execute: async ({ describe, coordinates, duration }) => {
|
|
22
22
|
try {
|
|
23
23
|
const page = await v3.context.awaitActivePage();
|
|
24
|
-
const processed = (0, coordinateNormalization_js_1.processCoordinates)(coordinates[0], coordinates[1], provider, v3);
|
|
24
|
+
const processed = await (0, coordinateNormalization_js_1.processCoordinates)(coordinates[0], coordinates[1], provider, v3);
|
|
25
25
|
v3.logger({
|
|
26
26
|
category: "agent",
|
|
27
27
|
message: `Agent calling tool: clickAndHold`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clickAndHold.js","sourceRoot":"","sources":["../../../../../../lib/v3/agent/tools/clickAndHold.ts"],"names":[],"mappings":";;;AAAA,2BAA0B;AAC1B,6BAAwB;AAGxB,oFAAyE;AACzE,gDAAgD;AAEzC,MAAM,gBAAgB,GAAG,CAAC,EAAM,EAAE,QAAiB,EAAE,EAAE,CAC5D,IAAA,SAAI,EAAC;IACH,WAAW,EAAE,oDAAoD;IACjE,WAAW,EAAE,OAAC,CAAC,MAAM,CAAC;QACpB,QAAQ,EAAE,OAAC;aACR,MAAM,EAAE;aACR,QAAQ,CACP,2HAA2H,CAC5H;QACH,QAAQ,EAAE,OAAC;aACR,MAAM,EAAE;aACR,QAAQ,CAAC,kDAAkD,CAAC;QAC/D,WAAW,EAAE,OAAC;aACX,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC;aACjB,QAAQ,CAAC,oCAAoC,CAAC;KAClD,CAAC;IACF,OAAO,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,EAAE;QACrD,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC;YAChD,MAAM,SAAS,GAAG,IAAA,+CAAkB,
|
|
1
|
+
{"version":3,"file":"clickAndHold.js","sourceRoot":"","sources":["../../../../../../lib/v3/agent/tools/clickAndHold.ts"],"names":[],"mappings":";;;AAAA,2BAA0B;AAC1B,6BAAwB;AAGxB,oFAAyE;AACzE,gDAAgD;AAEzC,MAAM,gBAAgB,GAAG,CAAC,EAAM,EAAE,QAAiB,EAAE,EAAE,CAC5D,IAAA,SAAI,EAAC;IACH,WAAW,EAAE,oDAAoD;IACjE,WAAW,EAAE,OAAC,CAAC,MAAM,CAAC;QACpB,QAAQ,EAAE,OAAC;aACR,MAAM,EAAE;aACR,QAAQ,CACP,2HAA2H,CAC5H;QACH,QAAQ,EAAE,OAAC;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,MAAM,GAAW;wBACrB,QAAQ,EAAE,eAAe;wBACzB,WAAW,EAAE,QAAQ;wBACrB,MAAM,EAAE,cAAc;wBACtB,SAAS,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;qBAC9B,CAAC;oBACF,EAAE,CAAC,qBAAqB,CAAC;wBACvB,IAAI,EAAE,KAAK;wBACX,WAAW,EAAE,QAAQ;wBACrB,OAAO,EAAE,CAAC,MAAM,CAAC;wBACjB,iBAAiB,EAAE,QAAQ;qBAC5B,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;YAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;QACrC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,+BAA+B,KAAK,CAAC,OAAO,EAAE;aACtD,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC,CAAC;AAhFQ,QAAA,gBAAgB,oBAgFxB","sourcesContent":["import { tool } from \"ai\";\nimport { z } from \"zod\";\nimport type { V3 } from \"../../v3.js\";\nimport type { Action } from \"../../types/public/methods.js\";\nimport { processCoordinates } from \"../utils/coordinateNormalization.js\";\nimport { ensureXPath } from \"../utils/xpath.js\";\n\nexport const clickAndHoldTool = (v3: V3, provider?: string) =>\n tool({\n description: \"Click and hold on an element using its coordinates\",\n inputSchema: z.object({\n describe: z\n .string()\n .describe(\n \"Describe the element to click on in a short, specific phrase that mentions the element type and a good visual description\",\n ),\n duration: z\n .number()\n .describe(\"The duration to hold the element in milliseconds\"),\n coordinates: z\n .array(z.number())\n .describe(\"The (x, y) coordinates to click on\"),\n }),\n execute: async ({ describe, coordinates, duration }) => {\n try {\n const page = await v3.context.awaitActivePage();\n const processed = await processCoordinates(\n coordinates[0],\n coordinates[1],\n provider,\n v3,\n );\n\n v3.logger({\n category: \"agent\",\n message: `Agent calling tool: clickAndHold`,\n level: 1,\n auxiliary: {\n arguments: {\n value: JSON.stringify({\n describe,\n duration,\n }),\n type: \"object\",\n },\n },\n });\n\n // Only request XPath when caching is enabled to avoid unnecessary computation\n const shouldCollectXpath = v3.isAgentReplayActive();\n\n // Use dragAndDrop from same point to same point with delay to simulate click and hold\n const [xpath] = await page.dragAndDrop(\n processed.x,\n processed.y,\n processed.x,\n processed.y,\n { delay: duration, returnXpath: shouldCollectXpath },\n );\n\n // Record as \"act\" step with proper Action for deterministic replay (only when caching)\n if (shouldCollectXpath) {\n const normalizedXpath = ensureXPath(xpath);\n if (normalizedXpath) {\n const action: Action = {\n selector: normalizedXpath,\n description: describe,\n method: \"clickAndHold\",\n arguments: [String(duration)],\n };\n v3.recordAgentReplayStep({\n type: \"act\",\n instruction: describe,\n actions: [action],\n actionDescription: describe,\n });\n }\n }\n\n return { success: true, describe };\n } catch (error) {\n return {\n success: false,\n error: `Error clicking and holding: ${error.message}`,\n };\n }\n },\n });\n"]}
|
|
@@ -20,8 +20,8 @@ const dragAndDropTool = (v3, provider) => (0, ai_1.tool)({
|
|
|
20
20
|
execute: async ({ describe, startCoordinates, endCoordinates, }) => {
|
|
21
21
|
try {
|
|
22
22
|
const page = await v3.context.awaitActivePage();
|
|
23
|
-
const processedStart = (0, coordinateNormalization_js_1.processCoordinates)(startCoordinates[0], startCoordinates[1], provider, v3);
|
|
24
|
-
const processedEnd = (0, coordinateNormalization_js_1.processCoordinates)(endCoordinates[0], endCoordinates[1], provider, v3);
|
|
23
|
+
const processedStart = await (0, coordinateNormalization_js_1.processCoordinates)(startCoordinates[0], startCoordinates[1], provider, v3);
|
|
24
|
+
const processedEnd = await (0, coordinateNormalization_js_1.processCoordinates)(endCoordinates[0], endCoordinates[1], provider, v3);
|
|
25
25
|
v3.logger({
|
|
26
26
|
category: "agent",
|
|
27
27
|
message: `Agent calling tool: dragAndDrop`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dragAndDrop.js","sourceRoot":"","sources":["../../../../../../lib/v3/agent/tools/dragAndDrop.ts"],"names":[],"mappings":";;;AAAA,2BAA0B;AAC1B,6BAAwB;AAOxB,oFAAyE;AACzE,gDAAgD;AAChD,wEAAyE;AAElE,MAAM,eAAe,GAAG,CAAC,EAAM,EAAE,QAAiB,EAAE,EAAE,CAC3D,IAAA,SAAI,EAAC;IACH,WAAW,EACT,kNAAkN;IACpN,WAAW,EAAE,OAAC,CAAC,MAAM,CAAC;QACpB,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,uCAAuC,CAAC;QACtE,gBAAgB,EAAE,OAAC;aAChB,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC;aACjB,QAAQ,CAAC,wDAAwD,CAAC;QACrE,cAAc,EAAE,OAAC;aACd,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC;aACjB,QAAQ,CAAC,oDAAoD,CAAC;KAClE,CAAC;IACF,OAAO,EAAE,KAAK,EAAE,EACd,QAAQ,EACR,gBAAgB,EAChB,cAAc,GACf,EAAkC,EAAE;QACnC,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC;YAChD,MAAM,cAAc,GAAG,IAAA,+CAAkB,
|
|
1
|
+
{"version":3,"file":"dragAndDrop.js","sourceRoot":"","sources":["../../../../../../lib/v3/agent/tools/dragAndDrop.ts"],"names":[],"mappings":";;;AAAA,2BAA0B;AAC1B,6BAAwB;AAOxB,oFAAyE;AACzE,gDAAgD;AAChD,wEAAyE;AAElE,MAAM,eAAe,GAAG,CAAC,EAAM,EAAE,QAAiB,EAAE,EAAE,CAC3D,IAAA,SAAI,EAAC;IACH,WAAW,EACT,kNAAkN;IACpN,WAAW,EAAE,OAAC,CAAC,MAAM,CAAC;QACpB,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,uCAAuC,CAAC;QACtE,gBAAgB,EAAE,OAAC;aAChB,KAAK,CAAC,OAAC,CAAC,M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;oBACnB,OAAO,EAAE,MAAM,CAAC,OAAO;oBACvB,QAAQ,EAAE,MAAM,CAAC,QAAQ;iBAC1B,CAAC;aACH;SACF,CAAC;QACF,IAAI,MAAM,CAAC,gBAAgB,EAAE,CAAC;YAC5B,OAAO,CAAC,IAAI,CAAC;gBACX,IAAI,EAAE,OAAO;gBACb,SAAS,EAAE,WAAW;gBACtB,IAAI,EAAE,MAAM,CAAC,gBAAgB;aAC9B,CAAC,CAAC;QACL,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;IAC7C,CAAC;CACF,CAAC,CAAC;AArHQ,QAAA,eAAe,mBAqHvB","sourcesContent":["import { tool } from \"ai\";\nimport { z } from \"zod\";\nimport type { V3 } from \"../../v3.js\";\nimport type { Action } from \"../../types/public/methods.js\";\nimport type {\n DragAndDropToolResult,\n ModelOutputContentItem,\n} from \"../../types/public/agent.js\";\nimport { processCoordinates } from \"../utils/coordinateNormalization.js\";\nimport { ensureXPath } from \"../utils/xpath.js\";\nimport { waitAndCaptureScreenshot } from \"../utils/screenshotHandler.js\";\n\nexport const dragAndDropTool = (v3: V3, provider?: string) =>\n tool({\n description:\n \"Drag and drop an element using its coordinates (this is the most reliable way to drag and drop an element, always use this over act, unless the element is not visible in the screenshot, but shown in ariaTree)\",\n inputSchema: z.object({\n describe: z.string().describe(\"Describe the element to drag and drop\"),\n startCoordinates: z\n .array(z.number())\n .describe(\"The (x, y) coordinates to start the drag and drop from\"),\n endCoordinates: z\n .array(z.number())\n .describe(\"The (x, y) coordinates to end the drag and drop at\"),\n }),\n execute: async ({\n describe,\n startCoordinates,\n endCoordinates,\n }): Promise<DragAndDropToolResult> => {\n try {\n const page = await v3.context.awaitActivePage();\n const processedStart = await processCoordinates(\n startCoordinates[0],\n startCoordinates[1],\n provider,\n v3,\n );\n const processedEnd = await processCoordinates(\n endCoordinates[0],\n endCoordinates[1],\n provider,\n v3,\n );\n\n v3.logger({\n category: \"agent\",\n message: `Agent calling tool: dragAndDrop`,\n level: 1,\n auxiliary: {\n arguments: {\n value: JSON.stringify({\n describe,\n }),\n type: \"object\",\n },\n },\n });\n\n // Only request XPath when caching is enabled to avoid unnecessary computation\n const shouldCollectXpath = v3.isAgentReplayActive();\n const [fromXpath, toXpath] = await page.dragAndDrop(\n processedStart.x,\n processedStart.y,\n processedEnd.x,\n processedEnd.y,\n { returnXpath: shouldCollectXpath },\n );\n\n const screenshotBase64 = await waitAndCaptureScreenshot(page);\n\n // Record as \"act\" step with proper Action for deterministic replay (only when caching)\n if (shouldCollectXpath) {\n const normalizedFrom = ensureXPath(fromXpath);\n const normalizedTo = ensureXPath(toXpath);\n if (normalizedFrom && normalizedTo) {\n const action: Action = {\n selector: normalizedFrom,\n description: describe,\n method: \"dragAndDrop\",\n arguments: [normalizedTo],\n };\n v3.recordAgentReplayStep({\n type: \"act\",\n instruction: describe,\n actions: [action],\n actionDescription: describe,\n });\n }\n }\n\n return {\n success: true,\n describe,\n screenshotBase64,\n };\n } catch (error) {\n return {\n success: false,\n error: `Error dragging: ${error.message}`,\n };\n }\n },\n toModelOutput: (result) => {\n if (result.success === false || result.error !== undefined) {\n return {\n type: \"content\",\n value: [{ type: \"text\", text: JSON.stringify(result) }],\n };\n }\n\n const content: ModelOutputContentItem[] = [\n {\n type: \"text\",\n text: JSON.stringify({\n success: result.success,\n describe: result.describe,\n }),\n },\n ];\n if (result.screenshotBase64) {\n content.push({\n type: \"media\",\n mediaType: \"image/png\",\n data: result.screenshotBase64,\n });\n }\n return { type: \"content\", value: content };\n },\n });\n"]}
|
|
@@ -49,19 +49,22 @@ MANDATORY USE CASES (always use fillFormVision for these):
|
|
|
49
49
|
execute: async ({ fields }) => {
|
|
50
50
|
try {
|
|
51
51
|
const page = await v3.context.awaitActivePage();
|
|
52
|
+
const viewport = (0, coordinateNormalization_js_1.isGoogleProvider)(provider)
|
|
53
|
+
? await v3.resolveViewport()
|
|
54
|
+
: undefined;
|
|
52
55
|
// Process coordinates per field. Keep the original `value` (with any
|
|
53
56
|
// `%variableName%` tokens) so substituted secrets never leak through
|
|
54
57
|
// the tool result, replay cache, returned AgentResult.actions, or
|
|
55
58
|
// anything that logs the action. Variables are substituted only at
|
|
56
59
|
// typing time below.
|
|
57
|
-
const safeFields = fields.map((field) => {
|
|
58
|
-
const processed = (0, coordinateNormalization_js_1.processCoordinates)(field.coordinates.x, field.coordinates.y, provider, v3);
|
|
60
|
+
const safeFields = await Promise.all(fields.map(async (field) => {
|
|
61
|
+
const processed = await (0, coordinateNormalization_js_1.processCoordinates)(field.coordinates.x, field.coordinates.y, provider, v3, viewport);
|
|
59
62
|
return {
|
|
60
63
|
action: field.action,
|
|
61
64
|
value: field.value,
|
|
62
65
|
coordinates: { x: processed.x, y: processed.y },
|
|
63
66
|
};
|
|
64
|
-
});
|
|
67
|
+
}));
|
|
65
68
|
v3.logger({
|
|
66
69
|
category: "agent",
|
|
67
70
|
message: `Agent calling tool: fillFormVision`,
|
|
@@ -77,10 +80,18 @@ MANDATORY USE CASES (always use fillFormVision for these):
|
|
|
77
80
|
const shouldCollectXpath = v3.isAgentReplayActive();
|
|
78
81
|
const actions = [];
|
|
79
82
|
for (const field of safeFields) {
|
|
80
|
-
//
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
// Focus the field, only requesting XPath when caching is enabled. On a
|
|
84
|
+
// touch session this must be a trusted tap — a synthesized mouse click
|
|
85
|
+
// never registers on touch-gated mobile layouts, so the field would stay
|
|
86
|
+
// unfocused and the value go nowhere. The recorded step stays a "type",
|
|
87
|
+
// whose replay focuses via the selector rather than a pointer event.
|
|
88
|
+
const xpath = v3.usesTouch
|
|
89
|
+
? await page.tap(field.coordinates.x, field.coordinates.y, {
|
|
90
|
+
returnXpath: shouldCollectXpath,
|
|
91
|
+
})
|
|
92
|
+
: await page.click(field.coordinates.x, field.coordinates.y, {
|
|
93
|
+
returnXpath: shouldCollectXpath,
|
|
94
|
+
});
|
|
84
95
|
// Substitute variables only at the moment of typing so the resolved
|
|
85
96
|
// value never leaves this scope.
|
|
86
97
|
await page.type((0, variables_js_1.substituteVariables)(field.value, variables));
|