wuying-agentbay-sdk

repository·main·Indexed 22 days ago

https://github.com/agentbay-ai/wuying-agentbay-sdk

SDK for AgentBay, a cloud sandbox platform providing isolated environments for browser, desktop, mobile, and code execution for AI agents. The SDK enables agents to perform complex tasks such as web automation, software testing, and code development. It includes a cookbook for an E-commerce Inspector Agent that demonstrates AI-powered structured data extraction using Pydantic schemas, LangChain integration, and automated browser session management.

Tokens
434.6K
Snippets
1.3K
Records
1.9K
Agent score
76%

What's inside wuying-agentbay-sdk

  1. Overview of Mobile Use for Android Automation

    main

    Mobile Use is AgentBay's specialized environment designed for automating Android devices. It allows developers to manage mobile applications, automate UI interactions via touch gestures, configure mobile sessions, simulate specific device characteristics, and control devices through ADB (Android Debug Bridge).

    While the documentation primarily uses Python for examples, the core concepts and API patterns are consistent across all supported SDK languages:

    • Python
    • TypeScript
    • Golang
    • Java
  2. Overview of AgentBay SDK feature categories

    main

    The Golang SDK supports several specialized environments:

    • Common Features: Available in all environments. Includes Session Management, Command Execution, File Operations, Context Management (persistent data), and the AI-powered Agent Module.
    • Browser Use: Cloud-based browser automation via Playwright. Supports custom configurations, stealth mode, and fingerprinting.
    • Mobile Use: Android UI automation. Includes ADB URL retrieval and remote debugging.
    • Computer Use: Windows desktop automation for application and UI management.
    • CodeSpace: Cloud-based development environments for code execution and automation workflows.
  3. Overview of the Auto Testing Agent

    main
    The Auto Testing Agent is a demonstration project that shows how to build a testing agent using LangChain and the AgentBay SDK. The agent automates the testing lifecycle by scanning Python projects, generating test cases via LLMs, and executing those tests within isolated AgentBay cloud environments. It is designed to be modular, allowing for different agent frameworks and execution patterns (synchronous vs. asynchronous).
  4. Overview of AgentBay Computer Use

    main

    Computer Use is AgentBay's desktop automation environment designed for Windows and Linux systems. It allows agents to interact with the operating system through application management, window control, and UI automation (mouse and keyboard).

    While the primary documentation uses Python for examples, the core concepts and API patterns are consistent across all supported SDKs: Python, TypeScript, Golang, and Java.

  5. Overview of the E-commerce Inspector Agent

    main

    The E-commerce Inspector Agent is a demonstration project built with the AgentBay SDK. It automates the process of visiting e-commerce websites, navigating to product listing pages, and extracting structured product information (names, prices, and links) along with screenshots.

    Key Capabilities:

    • Automatic Navigation: Finds product catalogs, shops, or stores and handles popups, cookie banners, and overlays.
    • AI-Powered Extraction: Uses structured extraction to pull data from complex web layouts.
    • Data Integrity: Normalizes relative URLs to absolute URLs and validates product data.
    • Batch Processing: Supports inspecting multiple websites in a single run.
    • Output: Generates structured JSON data and verification screenshots.
  6. Overview of AgentBay Common Features

    main

    The AgentBay SDK provides a consistent set of features across all environment types, including browser, computer, mobile, and codespace. These features are categorized into Basics (fundamental lifecycle and file operations) and Advanced (AI automation, OSS integration, and metrics).

    Core Feature Categories

    Basics

    • Session Management: Lifecycle (create, get, pause, resume), label management, and keep-alive operations.
    • Command & Terminal: Shell command execution and interactive PTY terminal operations (streaming).
    • File System: Reading/writing files, directory operations, and file transfers between local and cloud environments.
    • Context Management: Creating contexts, data storage/retrieval, cross-session sharing, and context-based file transfers via presigned URLs.
    • Data Persistence: Configuring SyncPolicy and RecyclePolicy for data across sessions.
    • Environment & Tools: Managing environment variables and direct MCP tool calls.

    Advanced

    • Agent Modules: Using AI agents for natural language task execution and automation.
    • OSS Management: Integration with Object Storage Service (upload/download/anonymous access).
    • Monitoring: Capturing screenshots and collecting session usage metrics.
  7. Configure AgentBay SDK settings

    main

    AgentBay SDK configuration options and settings are consistent across all supported languages, including Python, TypeScript, Golang, and Java. To properly set up your environment, you must configure:

    1. SDK Configuration: Manage your API keys, gateway regions, and specific endpoints.
    2. Logging: Control log levels, output destinations, and enable data masking for security.
  8. Configure Browser automation features

    main

    The AgentBay Browser Use environment (browser_latest) supports several advanced configuration options for web automation:

    • Browser Types: Select between Chrome, Chromium, or Default configurations.
    • Stealth Mode: Enables fingerprint randomization and anti-detection techniques to avoid being flagged as a bot.
    • Cookie Persistence: Uses Browser Context to maintain sessions and cookies across multiple automation runs.
    • Proxy Support: Supports HTTP, HTTPS, and SOCKS proxy configurations for network routing.
    • Extension Support: Ability to load and manage browser extensions during automation.
    • Viewport Configuration: Set custom screen resolutions and device emulation for responsive testing.
    • Custom Arguments: Pass custom browser launch arguments for performance, security, or feature flags.
  9. Explore AgentBay environment-specific features

    main

    AgentBay provides specialized automation capabilities depending on the environment you choose:

    • Browser Use: Web scraping, testing, and form filling. Includes features like CAPTCHA handling, browser fingerprint simulation, proxy configuration, and session replay.
    • Computer Use: Windows desktop automation. Includes application management (start/stop/list), window operations (maximize/minimize/resize), and UI automation.
    • Mobile Use: Android UI automation. Includes mobile app management, gesture simulation (touch/swipe), and ADB connection/debugging.
    • CodeSpace: A development environment for executing Python and JavaScript code, running shell commands, and managing files/packages (pip, npm).
  10. Perform Git operations in AgentBay

    main

    The Git module provides high-level operations for managing repositories within an AgentBay cloud environment. It wraps git CLI commands and executes them via the Command module.

    Prerequisites:

    1. An active AgentBay session using an image with git pre-installed (e.g., code_latest or linux_latest).
    2. A valid AgentBay API Key.

    Core Capabilities:

    • Repository Management: Clone, initialize, and manage repositories.
    • Branch Operations: Create, checkout, list, and delete branches.
    • Staging & Committing: Add files, create commits, and view status/history.
    • Remote Management: Add remotes, pull changes, and configure URLs.
    • Configuration: Set user identity and arbitrary git config values.
    • Error Classification: Typed exceptions for auth, conflicts, and more.
    import os
    from agentbay import AgentBay
    from agentbay import CreateSessionParams
    
    agent_bay = AgentBay(api_key=os.getenv("AGENTBAY_API_KEY"))
    params = CreateSessionParams(image_id="code_latest")
    result = agent_bay.create(params)
    session = result.session
    
    try:
        # Git operations are accessed via session.git
        clone_result = session.git.clone("https://github.com/user/repo.git")
        print(f"Cloned to: {clone_result.path}")
    finally:
        agent_bay.delete(session)