Skip to content

Latest commit

 

History

History
108 lines (80 loc) · 3.3 KB

README.md

File metadata and controls

108 lines (80 loc) · 3.3 KB

AgentBay SDK for Python

Execute commands, operate files, and run code in cloud environments

📦 Installation

pip install wuying-agentbay-sdk

🚀 Prerequisites

Before using the SDK, you need to:

  1. Register an Alibaba Cloud account: https://aliyun.com
  2. Get API credentials: AgentBay Console
  3. Set environment variable: export AGENTBAY_API_KEY=your_api_key

🚀 Quick Start

from agentbay import AgentBay

# Create session
agent_bay = AgentBay()
result = agent_bay.create()

if result.success:
    session = result.session
    
    # Execute command
    cmd_result = session.command.execute_command("ls -la")
    print(cmd_result.output)
    
    # File operations
    session.file_system.write_file("/tmp/test.txt", "Hello World")
    content = session.file_system.read_file("/tmp/test.txt")
    print(content.content)

📖 Complete Documentation

🆕 New Users

🚀 Experienced Users

🆘 Need Help

🔧 Core Features Quick Reference

Session Management

# Create session
result = agent_bay.create()
if result.success:
    session = result.session

# List sessions
sessions = agent_bay.list()

# Connect to existing session
session = agent_bay.connect("session_id")

File Operations

# Read/write files
session.file_system.write_file("/path/file.txt", "content")
content = session.file_system.read_file("/path/file.txt")

# List directory
files = session.file_system.list_directory("/path")

Command Execution

# Execute command
result = session.command.execute_command("python script.py")
print(result.output)

Data Persistence

# Create context
context = agent_bay.context.get("my-project", create=True).context

# Create session with context
from agentbay.session_params import CreateSessionParams
from agentbay.context_sync import ContextSync, SyncPolicy
context_sync = ContextSync.new(context.id, "/mnt/data", SyncPolicy.default())
session = agent_bay.create(CreateSessionParams(context_syncs=[context_sync])).session

🆘 Get Help

📄 License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.