mobai

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package mobai provides a client for the MobAI HTTP API. It supports device listing, app installation, launching, and port forwarding.

Index

Constants

View Source
const (
	// DefaultBaseURL is the default MobAI API base URL
	DefaultBaseURL = "http://localhost:8686"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Error   string `json:"error"`
	Message string `json:"message,omitempty"`
	Code    int    `json:"code,omitempty"`
}

APIError represents an error response from the MobAI API

func (*APIError) String

func (e *APIError) String() string

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a MobAI API client

func NewClient

func NewClient(baseURL string) *Client

NewClient creates a new MobAI API client

func (*Client) DebugStream

func (c *Client) DebugStream(ctx context.Context, deviceID, bundleID string, config *DebugConfig) (<-chan DebugOutput, *websocket.Conn, error)

DebugStream connects to the debug WebSocket endpoint to launch an app with debugger and stream stdout. Returns a channel for debug output and the WebSocket connection (which should be closed when done to stop the debugger).

func (*Client) ForwardPort

func (c *Client) ForwardPort(ctx context.Context, deviceID string, req PortForwardRequest) (*PortForwardResponse, error)

ForwardPort forwards a device port to a host port

func (*Client) Health added in v0.2.1

func (c *Client) Health(ctx context.Context) error

Health checks if MobAI is running

func (*Client) InstallApp

func (c *Client) InstallApp(ctx context.Context, deviceID string, req InstallAppRequest) (*InstallAppResponse, error)

InstallApp installs an app on the specified device

func (*Client) ListDevices

func (c *Client) ListDevices(ctx context.Context) ([]Device, error)

ListDevices returns all connected devices

type DebugConfig added in v0.2.0

type DebugConfig struct {
	Environment map[string]string `json:"environment,omitempty"`
	Arguments   []string          `json:"arguments,omitempty"`
}

DebugConfig is the configuration sent to the debug WebSocket after connecting

type DebugOutput

type DebugOutput struct {
	Type    string `json:"type"`    // "stdout", "stderr", "error", "exit"
	Data    string `json:"data"`    // Output data
	Message string `json:"message"` // Additional message
}

DebugOutput represents a message from the debug WebSocket stream

type Device

type Device struct {
	ID            string `json:"id"`
	Name          string `json:"name"`
	Platform      string `json:"platform"`
	Model         string `json:"model"`
	OSVersion     string `json:"osVersion"`
	BridgeRunning bool   `json:"bridgeRunning"`
	Virtual       bool   `json:"virtual"`
}

Device represents a connected mobile device

type InstallAppRequest

type InstallAppRequest struct {
	Path     string `json:"path"`
	Resign   bool   `json:"resign,omitempty"`
	AppleID  string `json:"appleId,omitempty"`
	Password string `json:"password,omitempty"`
}

InstallAppRequest is the request body for installing an app

type InstallAppResponse

type InstallAppResponse struct {
	Success bool `json:"success"`
	Data    struct {
		BundleID  string `json:"bundleId"`
		SignedIPA string `json:"signedIpa"`
		TeamID    string `json:"teamId"`
	} `json:"data"`
}

InstallAppResponse is the response from installing an app

type PortForwardRequest

type PortForwardRequest struct {
	DevicePort int `json:"devicePort"`
	HostPort   int `json:"hostPort,omitempty"` // 0 means auto-assign
}

PortForwardRequest is the request body for forwarding a port

type PortForwardResponse

type PortForwardResponse struct {
	ID         string `json:"id"`
	HostPort   int    `json:"hostPort"`
	DevicePort int    `json:"devicePort"`
}

PortForwardResponse is the response from forwarding a port

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL