Skip to content

lybic/lybic-sdk-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

95 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Lybic Logo

Lybic SDK for Golang

License Documentation Golanglint GitHub Release

Developing, testing, and deploying GUI-based AI agents is complex. Developers waste precious time wrestling with cloud instances, VNC servers, and environment configurations instead of focusing on what matters: building intelligent agents.

Lybic is the infrastructure layer for your GUI agents.

Lybic (/ˈlaΙͺbΙͺk/) provides a robust, on-demand infrastructure platform designed specifically for the AI agent development lifecycle. This SDK for Go is your command center for programmatically controlling the entire Lybic ecosystem, empowering you to build, test, and scale your agents with unprecedented speed and simplicity.

πŸš€ Getting Started

1. Installation

First, install the package from the Go package repository:

go get github.com/lybic/lybic-sdk-go

2. Initialization & Configuration

Initialize the client in your Go application. You can pass nil to the NewClient function to configure the client from environment variables, or provide a lybic.Config struct for programmatic configuration.

Basic Initialization

This example initializes the client using environment variables.

package main

import (
	"context"
	"fmt"

	"github.com/lybic/lybic-sdk-go"
)

func main() {
	// Passing nil initializes a client with environment variables
	client, err := lybic.NewClient(nil)
	if err != nil {
		panic(err)
	}

	ctx := context.Background()
	sandboxes, err := client.ListSandboxes(ctx)
	if err != nil {
		fmt.Printf("Error listing sandboxes: %v", err)
		return
	}
	fmt.Printf("sandboxes: %+v", sandboxes)
}

Programmatic Configuration

You can also configure the client programmatically by creating a Config object.

config := lybic.NewConfig() // Initializes with defaults and env variables
config.OrgId = "your-org-id"
config.ApiKey = "your-api-key"
config.Timeout = 20 // seconds

client, err := lybic.NewClient(config)
if err != nil {
    panic(err)
}

Configuration Options

The client can be configured with the following options, either through the Config struct or environment variables:

Struct Field Environment Variable Description Default Value
OrgId LYBIC_ORG_ID Required. Your organization ID. ""
ApiKey LYBIC_API_KEY Your API key for authentication. ""
Endpoint LYBIC_API_ENDPOINT The API endpoint URL. https://api.lybic.cn
Timeout - HTTP request timeout in seconds. 10
ExtraHeaders - A map of extra HTTP headers to send with each request. nil
Logger - A custom logger instance. See the Logging section. nil (disabled)

✨ Platform API Features

The Lybic SDK provides a comprehensive client for interacting with all major platform features.

All examples are available in the examples.md

Sandbox Management

  • ListSandboxes(ctx): Retrieve a list of all available sandboxes.
  • CreateSandbox(ctx, dto): Create a new sandbox.
  • GetSandbox(ctx, sandboxId): Retrieve details for a specific sandbox.
  • DeleteSandbox(ctx, sandboxId): Delete a sandbox.
  • ExtendSandbox(ctx, sandboxId, dto): Extend or modify a sandbox.

Sandbox Interaction

  • ExecuteComputerUseAction(ctx, sandboxId, dto): Perform an action (e.g., mouse click, keyboard input) on a sandbox.
  • PreviewSandbox(ctx, sandboxId): Generate a preview (screenshot) of the sandbox state.

Project Management

  • ListProjects(ctx): Get a list of all projects.
  • CreateProject(ctx, dto): Create a new project.
  • DeleteProject(ctx, projectId): Delete a project.

Other Utilities

  • GetStats(ctx): Retrieve current platform statistics.
  • ParseComputerUse(ctx, dto): Parse and validate computer use actions.

πŸ€– Using the MCP Client

For interacting with the Model Context Protocol (MCP), which enables tool calling, you need to initialize a separate McpClient.

MCP Client Initialization

The NewMcpClient function creates a client for MCP services. It requires an McpOption struct, which can be configured in several ways.

Example 1: Initialize with a Lybic Config

You can initialize the McpClient directly from a lybic.Config object. The client will be created internally.

import (
    "context"

    "github.com/lybic/lybic-sdk-go"
)

func main() {
    // Config can be loaded from environment variables
    lybicConfig := lybic.NewConfig()

    mcpOpt := lybic.McpOption{
        UsingClientConfig: lybicConfig,
    }
    mcpClient, err := lybic.NewMcpClient(context.Background(), mcpOpt)
    if err != nil {
        panic(err)
    }
    defer mcpClient.Close()
    
    // ... use the mcpClient
}

Example 2: Initialize with an Existing Lybic Client

If you already have an instance of the main lybic.Client, you can reuse it.

client, err := lybic.NewClient(nil) // Main client
if err != nil {
    panic(err)
}

mcpOpt := lybic.McpOption{
    UsingClient: client,
}
mcpClient, err := lybic.NewMcpClient(context.Background(), mcpOpt)
if err != nil {
    panic(err)
}
defer mcpClient.Close()

MCP Client Features

Tool Calling

  • CallTools(ctx, args, service): Call a tool service like computer-use with the specified arguments.

MCP Server Management

  • ListMcpServers(ctx): Get a list of all MCP servers.
  • CreateMcpServer(ctx, dto): Create a new MCP server.
  • GetDefaultMcpServer(ctx): Retrieve the default MCP server.
  • DeleteMcpServer(ctx, mcpServerId): Delete an MCP server.
  • SetMcpServerToSandbox(ctx, mcpServerId, dto): Associate an MCP server with a sandbox.

πŸ€– Using the Agent Client

The Lybic Go SDK also provides a client for interacting with the Lybic Agent Cluster, which allows for more advanced control and automation of your GUI-based AI agents.

For detailed instructions and code examples, please see the Agent Service Documentation.

πŸ“ Logging

The SDK uses a flexible logging interface that allows you to integrate your own preferred logging library. Any logger that implements the lybic.Logger interface is supported. The interface is compatible with popular libraries like zap (SugaredLogger), logrus, zerolog, and slog.

The lybic.Logger interface is defined as:

type Logger interface {
	Debug(...interface{})
	Info(...interface{})
	Warn(...interface{})
	Error(...interface{})

	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warnf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
}

Example: Using Logrus

import (
    "github.com/lybic/lybic-sdk-go"
    "github.com/sirupsen/logrus"
)

func main() {
    // Create a new logrus logger
    customLogger := logrus.New()
    customLogger.SetLevel(logrus.DebugLevel)

    // Create a new Lybic client configuration
    config := lybic.NewConfig()
    config.OrgId = "your-org-id"
    config.ApiKey = "your-api-key"
    config.Logger = customLogger // Set the custom logger

    // Initialize the client
    client, err := lybic.NewClient(config)
    if err != nil {
        customLogger.Fatalf("Failed to create Lybic client: %v", err)
    }
    
    // ... use the client
}

If no logger is provided, logging will be disabled.

πŸ“š Full Documentation & API Reference

This README provides a high-level overview. For detailed, up-to-date code examples, tutorials, and a complete API reference, please visit our official documentation site.

🀝 Contributing

We welcome contributions from the community! Please see our Contributing Guidelines for more details on how to get involved.

πŸ“„ License

This project is licensed under the MIT License. See the LICENSE file for details.

About

Lybic sdk for Golang

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages