Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:A9T9 RPA AnthropicService

From Leeroopedia
Knowledge Sources
Domains AI_Agent, API_Client
Last Updated 2026-10-22 00:00 GMT

Overview

Concrete tool for communicating with the Anthropic Claude API for vision-based element location, provided by the Ui.Vision Anthropic service.

Description

The AnthropicService class (`src/services/ai/anthropic/anthropic.service.ts`) is a wrapper around the `@anthropic-ai/sdk` client for the Anthropic Messages API. It is configured with `dangerouslyAllowBrowser: true` so it can run in the extension context. It handles API key validation, error mapping (E351 for missing key, E352 for API errors), and coordinate parsing from Claude's text responses.

The `parseCoordinates` method extracts `(x, y)` coordinate pairs from Claude's response text (separated by `|||`), which is used for AI vision-based element location — the AI is shown a screenshot and asked to return the coordinates of a target element.

This service is used by the AI macro agent and the AI vision prompt service as a fallback element-location mechanism.

Usage

Instantiate `AnthropicService` with an API key. Use it when the AI macro agent or vision prompt service needs to call the Claude API for screenshot-based element location.

Code Reference

Source Location

  • Repository: A9T9/RPA
  • File: src/services/ai/anthropic/anthropic.service.ts
  • Lines: L28-L487 (AnthropicService class)

Signature

class AnthropicService {
  MAX_WIDTH = 1280
  MAX_HEIGHT = 800
  MAX_TOKENS = 1024
  MAX_PIXELS = 1191888

  constructor(apiKey: string)

  parseCoordinates(responseText: string): Coordinates
  uivError(error: any): Error
  // Methods for sending screenshots and prompts to the Claude API
}

Import

import { AnthropicService } from '@/services/ai/anthropic'

I/O Contract

Inputs

Name Type Required Description
apiKey string Yes Anthropic API key
responseText string Yes (parseCoordinates) Claude response text with coordinate pairs

Outputs

Name Type Description
Coordinates object { coords: {x,y}[], isSinglePoint: boolean }

Usage Examples

Parse Coordinates from a Claude Response

import { AnthropicService } from '@/services/ai/anthropic'

const service = new AnthropicService('sk-ant-...')
const coords = service.parseCoordinates('120, 340 ||| 200, 180')
// { coords: [{x:120,y:340}, {x:200,y:180}], isSinglePoint: false }

Related Pages

Implements Principle

Requires Environment

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment