Documentation
¶
Overview ¶
Package mobai provides a client for the MobAI HTTP API. It supports device listing, app installation, launching, and port forwarding.
Index ¶
- Constants
- type APIError
- type Client
- func (c *Client) DebugStream(ctx context.Context, deviceID, bundleID string, config *DebugConfig) (<-chan DebugOutput, *websocket.Conn, error)
- func (c *Client) ForwardPort(ctx context.Context, deviceID string, req PortForwardRequest) (*PortForwardResponse, error)
- func (c *Client) Health(ctx context.Context) error
- func (c *Client) InstallApp(ctx context.Context, deviceID string, req InstallAppRequest) (*InstallAppResponse, error)
- func (c *Client) ListDevices(ctx context.Context) ([]Device, error)
- type DebugConfig
- type DebugOutput
- type Device
- type InstallAppRequest
- type InstallAppResponse
- type PortForwardRequest
- type PortForwardResponse
Constants ¶
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
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a 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) InstallApp ¶
func (c *Client) InstallApp(ctx context.Context, deviceID string, req InstallAppRequest) (*InstallAppResponse, error)
InstallApp installs an app on the specified device
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