feat: implement UI automation test history isolation

- Add ResetHistory option to PlanningOptions and ActionOptions
- Implement task completion detection with isTaskFinished() method
- Add executeActions() method to separate action execution logic
- Modify ConversationHistory.Clear() to completely clear all messages including system message
- Refactor StartToGoal() to automatically reset history on first attempt
- Add WithResetHistory() option function for consistent API
- Consolidate test files into driver_ext_ai_test.go with comprehensive test coverage
This commit is contained in:
lilong.129
2025-06-06 15:26:25 +08:00
parent 6e1bd5bbe2
commit b642ea004e
6 changed files with 306 additions and 48 deletions

View File

@@ -53,6 +53,7 @@ const (
ACTION_SetIme ActionName = "set_ime"
ACTION_GetSource ActionName = "get_source"
ACTION_GetForegroundApp ActionName = "get_foreground_app"
ACTION_AppInfo ActionName = "app_info" // get app info action
// UI handling
ACTION_Home ActionName = "home"
@@ -85,7 +86,6 @@ const (
ACTION_Upload ActionName = "upload" // upload action
ACTION_PushMedia ActionName = "push_media" // push media action
ACTION_CreateBrowser ActionName = "create_browser" // create browser action
ACTION_AppInfo ActionName = "app_info" // get app info action
// device actions
ACTION_ListAvailableDevices ActionName = "list_available_devices"
@@ -183,10 +183,11 @@ type ActionOptions struct {
Params []float64 `json:"params,omitempty" yaml:"params,omitempty" desc:"Generic parameter array"`
// AI related
Prompt string `json:"prompt,omitempty" yaml:"prompt,omitempty" desc:"AI action prompt"`
Content string `json:"content,omitempty" yaml:"content,omitempty" desc:"Content for finished action"`
LLMService string `json:"llm_service,omitempty" yaml:"llm_service,omitempty" desc:"LLM service type for AI actions"`
CVService string `json:"cv_service,omitempty" yaml:"cv_service,omitempty" desc:"Computer vision service type for AI actions"`
Prompt string `json:"prompt,omitempty" yaml:"prompt,omitempty" desc:"AI action prompt"`
Content string `json:"content,omitempty" yaml:"content,omitempty" desc:"Content for finished action"`
LLMService string `json:"llm_service,omitempty" yaml:"llm_service,omitempty" desc:"LLM service type for AI actions"`
CVService string `json:"cv_service,omitempty" yaml:"cv_service,omitempty" desc:"Computer vision service type for AI actions"`
ResetHistory bool `json:"reset_history,omitempty" yaml:"reset_history,omitempty" desc:"Whether to reset conversation history before AI planning"`
// Time related
Seconds float64 `json:"seconds,omitempty" yaml:"seconds,omitempty" desc:"Sleep duration in seconds"`
@@ -550,6 +551,12 @@ func WithAntiRisk(antiRisk bool) ActionOption {
}
}
func WithResetHistory(resetHistory bool) ActionOption {
return func(o *ActionOptions) {
o.ResetHistory = resetHistory
}
}
// HTTP API direct usage methods
// ValidateForHTTPAPI validates the request for HTTP API usage