controller

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterAction

func RegisterAction[T, D any](
	r *Registry,
	name string,
	description string,
	function ActionFunc[T, D],
) error

Action registers a new action into the registry. should be called after registry initialization registry.Action("click_element_by_index", ClickElementFunc, "click action", paramModel, domains, pageFilter)

Types

type Action

type Action struct {
	Name string
	Tool *tool.Tool
}

func NewAction

func NewAction[T, D any](name string, description string, actionFunc ActionFunc[T, D]) (*Action, error)

type ActionFunc

type ActionFunc[T, D any] func(ctx context.Context, input T) (output D, err error)

type ActionResult

type ActionResult struct {
	IsDone           *bool   `json:"is_done,omitempty"`
	Success          *bool   `json:"success,omitempty"`
	ExtractedContent *string `json:"extracted_content,omitempty"`
	Error            *string `json:"error,omitempty"`
	IncludeInMemory  bool    `json:"include_in_memory"`
}

func NewActionResult

func NewActionResult() *ActionResult

type Controller

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

func NewController

func NewController(driver *appiumgo.WebDriver) *Controller

func (*Controller) ExecuteAction

func (c *Controller) ExecuteAction(
	ctx context.Context,
	action map[string]any,
	driver *appiumgo.WebDriver,
	model *llm.Instance,
	sensitiveData map[string]string,
	availableFilePaths []string,

) (*ActionResult, error)

ExecuteAction TODO

func (*Controller) LaunchApp

func (c *Controller) LaunchApp(ctx context.Context, params LaunchAppAction) (*ActionResult, error)

func (*Controller) PressKeyCode

func (c *Controller) PressKeyCode(ctx context.Context, params PressKeyCodeAction) (*ActionResult, error)

func (*Controller) Registry

func (c *Controller) Registry() *Registry

func (*Controller) Swipe

func (c *Controller) Swipe(ctx context.Context, params SwipeAction) (*ActionResult, error)

func (*Controller) TapByCoordinates

func (c *Controller) TapByCoordinates(ctx context.Context, params TapByCoordinatesAction) (*ActionResult, error)

type LaunchAppAction

type LaunchAppAction struct {
	PackageName  string `json:"package_name"`  // Package name (e.g., "com.android.settings")
	ActivityName string `json:"activity_name"` // Optional activity name
}

type PressKeyCodeAction

type PressKeyCodeAction struct {
	KeyCode int `json:"key_code"` // keycode: Android keycode to press(// Common keycodes:\n	- 3: HOME\n	- 4: BACK\n	- 24: VOLUME UP\n	- 25: VOLUME DOWN\n	- 26: POWER\n	- 82: MENU)

}

type Registry

type Registry struct {
	Actions        map[string]*Action
	ExcludeActions []string
}

The main service class that manages action registration and execution

func NewRegistry

func NewRegistry() *Registry

func (*Registry) AvailableActions

func (r *Registry) AvailableActions(includeActions []string) map[string]*Action

func (*Registry) ExecuteAction

func (r *Registry) ExecuteAction(
	ctx context.Context,
	actionName string,
	arguments string,
	sensitiveData map[string]string,
) (string, error)

Execute a registered action TODO(LOW): support Context

type ScreenshotAction

type ScreenshotAction struct {
	Path string `json:"path"`
}

type SwipeAction

type SwipeAction struct {
	StartX   int `json:"start_x"`
	StartY   int `json:"start_y"`
	EndX     int `json:"end_x"`
	EndY     int `json:"end_y"`
	Duration int `json:"duration"`
}

type TapByCoordinatesAction

type TapByCoordinatesAction struct {
	X        int `json:"x" jsonschema:"description=the percentage of the screen width from the left,required"`
	Y        int `json:"y" jsonschema:"description=the percentage of the screen height from the top,required"`
	Duration int `json:"duration" jsonschema:"description=duration of the tap,required"`
}

Jump to

Keyboard shortcuts

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