fix: remove unnecessary IgnoreNotFoundError and MaxRetryTimes from coordinate-based tap tools

- Removed IgnoreNotFoundError and MaxRetryTimes parameters from TapRequest, TapAbsXYRequest, and DoubleTapXYRequest structures
- Updated corresponding tool implementations to remove references to these non-existent fields
- These parameters are not applicable to coordinate-based operations as they don't involve element searching
- Only OCR/CV-based operations need these error handling parameters

This ensures that only relevant tools have the ignore_NotFoundError functionality,
making the API more consistent and avoiding confusion.
This commit is contained in:
lilong.129
2025-05-26 22:10:08 +08:00
parent df65f9a828
commit 77f5683f9a
3 changed files with 9 additions and 31 deletions
+1 -1
View File
@@ -1 +1 @@
v5.0.0-beta-2505262202 v5.0.0-beta-2505262210
-16
View File
@@ -316,18 +316,10 @@ func (t *ToolTapXY) Implement() server.ToolHandlerFunc {
// Build action options from request structure // Build action options from request structure
var opts []option.ActionOption var opts []option.ActionOption
// Add boolean options
if tapReq.IgnoreNotFoundError {
opts = append(opts, option.WithIgnoreNotFoundError(true))
}
// Add numeric options // Add numeric options
if tapReq.Duration > 0 { if tapReq.Duration > 0 {
opts = append(opts, option.WithDuration(tapReq.Duration)) opts = append(opts, option.WithDuration(tapReq.Duration))
} }
if tapReq.MaxRetryTimes > 0 {
opts = append(opts, option.WithMaxRetryTimes(tapReq.MaxRetryTimes))
}
// Add default options // Add default options
opts = append(opts, option.WithPreMarkOperation(true)) opts = append(opts, option.WithPreMarkOperation(true))
@@ -394,18 +386,10 @@ func (t *ToolTapAbsXY) Implement() server.ToolHandlerFunc {
// Build action options from request structure // Build action options from request structure
var opts []option.ActionOption var opts []option.ActionOption
// Add boolean options
if tapAbsReq.IgnoreNotFoundError {
opts = append(opts, option.WithIgnoreNotFoundError(true))
}
// Add numeric options // Add numeric options
if tapAbsReq.Duration > 0 { if tapAbsReq.Duration > 0 {
opts = append(opts, option.WithDuration(tapAbsReq.Duration)) opts = append(opts, option.WithDuration(tapAbsReq.Duration))
} }
if tapAbsReq.MaxRetryTimes > 0 {
opts = append(opts, option.WithMaxRetryTimes(tapAbsReq.MaxRetryTimes))
}
// Tap absolute XY action logic // Tap absolute XY action logic
log.Info().Float64("x", tapAbsReq.X).Float64("y", tapAbsReq.Y).Msg("tapping at absolute coordinates") log.Info().Float64("x", tapAbsReq.X).Float64("y", tapAbsReq.Y).Msg("tapping at absolute coordinates")
-6
View File
@@ -19,8 +19,6 @@ type TapRequest struct {
X float64 `json:"x" binding:"required" desc:"X coordinate (0.0~1.0 for percent, or absolute pixel value)"` X float64 `json:"x" binding:"required" desc:"X coordinate (0.0~1.0 for percent, or absolute pixel value)"`
Y float64 `json:"y" binding:"required" desc:"Y coordinate (0.0~1.0 for percent, or absolute pixel value)"` Y float64 `json:"y" binding:"required" desc:"Y coordinate (0.0~1.0 for percent, or absolute pixel value)"`
Duration float64 `json:"duration" desc:"Tap duration in seconds (optional)"` Duration float64 `json:"duration" desc:"Tap duration in seconds (optional)"`
IgnoreNotFoundError bool `json:"ignore_NotFoundError" desc:"Ignore error if target element not found"`
MaxRetryTimes int `json:"max_retry_times" desc:"Maximum retry times for the tap action"`
} }
type DragRequest struct { type DragRequest struct {
@@ -160,8 +158,6 @@ type TapAbsXYRequest struct {
X float64 `json:"x" binding:"required" desc:"Absolute X coordinate in pixels"` X float64 `json:"x" binding:"required" desc:"Absolute X coordinate in pixels"`
Y float64 `json:"y" binding:"required" desc:"Absolute Y coordinate in pixels"` Y float64 `json:"y" binding:"required" desc:"Absolute Y coordinate in pixels"`
Duration float64 `json:"duration" desc:"Tap duration in seconds (optional)"` Duration float64 `json:"duration" desc:"Tap duration in seconds (optional)"`
IgnoreNotFoundError bool `json:"ignore_NotFoundError" desc:"Ignore error if target element not found"`
MaxRetryTimes int `json:"max_retry_times" desc:"Maximum retry times for the tap action"`
} }
type TapByOCRRequest struct { type TapByOCRRequest struct {
@@ -187,8 +183,6 @@ type DoubleTapXYRequest struct {
TargetDeviceRequest TargetDeviceRequest
X float64 `json:"x" binding:"required" desc:"X coordinate (0.0~1.0 for percent, or absolute pixel value)"` X float64 `json:"x" binding:"required" desc:"X coordinate (0.0~1.0 for percent, or absolute pixel value)"`
Y float64 `json:"y" binding:"required" desc:"Y coordinate (0.0~1.0 for percent, or absolute pixel value)"` Y float64 `json:"y" binding:"required" desc:"Y coordinate (0.0~1.0 for percent, or absolute pixel value)"`
IgnoreNotFoundError bool `json:"ignore_NotFoundError" desc:"Ignore error if target element not found"`
MaxRetryTimes int `json:"max_retry_times" desc:"Maximum retry times for the tap action"`
} }
type SwipeAdvancedRequest struct { type SwipeAdvancedRequest struct {