wuying-agentbay-sdk-inner-test
v0.1.2-beta.20250928180413
Published
TypeScript SDK for interacting with the Wuying AgentBay cloud runtime environment
Downloads
35
Maintainers
Readme
AgentBay SDK for TypeScript
Execute commands, manipulate files, and run code in cloud environments
📦 Installation
npm install wuying-agentbay-sdk🚀 Prerequisites
Before using the SDK, you need to:
- Register an Alibaba Cloud account: https://aliyun.com
- Get API credentials: AgentBay Console
- Set environment variable:
export AGENTBAY_API_KEY=your_api_key
🚀 Quick Start
import { AgentBay } from 'wuying-agentbay-sdk';
async function main() {
// Create session
const agentBay = new AgentBay();
const result = await agentBay.create();
if (result.success) {
const session = result.session;
// Execute command
const cmdResult = await session.command.executeCommand("ls -la");
console.log(cmdResult.output);
// File operations
await session.fileSystem.writeFile("/tmp/test.txt", "Hello World");
const content = await session.fileSystem.readFile("/tmp/test.txt");
console.log(content.data);
}
}
main().catch(console.error);📖 Complete Documentation
🆕 New Users
- 📚 Quick Start Tutorial - Get started in 5 minutes
- 🎯 Core Concepts - Understanding cloud environments and sessions
- 💡 Best Practices - Common patterns and techniques
🚀 Experienced Users
- 📖 Feature Guides - Complete feature introduction
- 🔧 TypeScript API Reference - Detailed API documentation
- 💻 TypeScript Examples - Complete example code
🆘 Need Help
- 🔧 Troubleshooting - Problem diagnosis
- 🔧 TypeScript API Reference - Local API documentation
- 💡 TypeScript Examples - Local example code
🔧 Core Features Quick Reference
Session Management
// Create session
const session = (await agentBay.create()).session;
// List sessions
const sessions = await agentBay.list();
// Connect to existing session
const session = await agentBay.connect("session_id");File Operations
// Read and write files
await session.fileSystem.writeFile("/path/file.txt", "content");
const content = await session.fileSystem.readFile("/path/file.txt");
// List directory
const files = await session.fileSystem.listDirectory("/path");Command Execution
// Execute command
const result = await session.command.executeCommand("node script.js");
console.log(result.output);Data Persistence
// Create context
const context = (await agentBay.context.get("my-project", true)).context;
// Create session with context
import { ContextSync, SyncPolicy } from 'wuying-agentbay-sdk';
const contextSync = new ContextSync({
contextId: context.id,
path: "/tmp/data",
policy: SyncPolicy.default()
});
const session = (await agentBay.create({ contextSync: [contextSync] })).session;🆘 Get Help
📄 License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
