From 778344c82627bb38be2b626e467db44f4697e0c2 Mon Sep 17 00:00:00 2001 From: "lilong.129" Date: Mon, 26 May 2025 00:43:01 +0800 Subject: [PATCH] change: remove call function tool --- internal/version/VERSION | 2 +- step_ui.go | 10 -------- uixt/driver_action.go | 1 - uixt/mcp_server.go | 51 ---------------------------------------- uixt/option/action.go | 1 - 5 files changed, 1 insertion(+), 64 deletions(-) diff --git a/internal/version/VERSION b/internal/version/VERSION index 43d5b073..d0c33a75 100644 --- a/internal/version/VERSION +++ b/internal/version/VERSION @@ -1 +1 @@ -v5.0.0-beta-2505260035 +v5.0.0-beta-2505260043 diff --git a/step_ui.go b/step_ui.go index 9482fbd7..b9d04fc3 100644 --- a/step_ui.go +++ b/step_ui.go @@ -447,16 +447,6 @@ func (s *StepMobile) ClosePopups(opts ...option.ActionOption) *StepMobile { return s } -func (s *StepMobile) Call(name string, fn func(), opts ...option.ActionOption) *StepMobile { - s.obj().Actions = append(s.obj().Actions, uixt.MobileAction{ - Method: option.ACTION_CallFunction, - Params: name, // function description - Fn: fn, - Options: option.NewActionOptions(opts...), - }) - return s -} - // Validate switches to step validation. func (s *StepMobile) Validate() *StepMobileUIValidation { return &StepMobileUIValidation{ diff --git a/uixt/driver_action.go b/uixt/driver_action.go index 16c7f9cc..84b3510a 100644 --- a/uixt/driver_action.go +++ b/uixt/driver_action.go @@ -7,7 +7,6 @@ import ( type MobileAction struct { Method option.ActionMethod `json:"method,omitempty" yaml:"method,omitempty"` Params interface{} `json:"params,omitempty" yaml:"params,omitempty"` - Fn func() `json:"-" yaml:"-"` // used for function action, not serialized Options *option.ActionOptions `json:"options,omitempty" yaml:"options,omitempty"` option.ActionOptions } diff --git a/uixt/mcp_server.go b/uixt/mcp_server.go index d87d7490..19604a50 100644 --- a/uixt/mcp_server.go +++ b/uixt/mcp_server.go @@ -142,7 +142,6 @@ func (s *MCPServer4XTDriver) registerTools() { s.registerTool(&ToolSetIme{}) s.registerTool(&ToolGetSource{}) s.registerTool(&ToolClosePopups{}) - s.registerTool(&ToolCallFunction{}) s.registerTool(&ToolAIAction{}) // PC/Web actions @@ -2102,56 +2101,6 @@ func (t *ToolClosePopups) ConvertActionToCallToolRequest(action MobileAction) (m return buildMCPCallToolRequest(t.Name(), map[string]any{}), nil } -// ToolCallFunction implements the call_function tool call. -type ToolCallFunction struct{} - -func (t *ToolCallFunction) Name() option.ActionMethod { - return option.ACTION_CallFunction -} - -func (t *ToolCallFunction) Description() string { - return "Call a custom function with description" -} - -func (t *ToolCallFunction) Options() []mcp.ToolOption { - return option.NewMCPOptions(option.CallFunctionRequest{}) -} - -func (t *ToolCallFunction) Implement() server.ToolHandlerFunc { - return func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { - driverExt, err := setupXTDriver(ctx, request.Params.Arguments) - if err != nil { - return nil, fmt.Errorf("setup driver failed: %w", err) - } - - var funcReq option.CallFunctionRequest - if err := mapToStruct(request.Params.Arguments, &funcReq); err != nil { - return nil, fmt.Errorf("parse parameters error: %w", err) - } - - // Call function action logic - // Note: The function (fn) parameter is not available in MCP calls - // This is a simplified implementation that only logs the description - log.Info().Str("description", funcReq.Description).Msg("calling function") - err = driverExt.Call(funcReq.Description, nil) - if err != nil { - return mcp.NewToolResultError(fmt.Sprintf("Call function failed: %s", err.Error())), nil - } - - return mcp.NewToolResultText(fmt.Sprintf("Successfully called function: %s", funcReq.Description)), nil - } -} - -func (t *ToolCallFunction) ConvertActionToCallToolRequest(action MobileAction) (mcp.CallToolRequest, error) { - if description, ok := action.Params.(string); ok { - arguments := map[string]any{ - "description": description, - } - return buildMCPCallToolRequest(t.Name(), arguments), nil - } - return mcp.CallToolRequest{}, fmt.Errorf("invalid call function params: %v", action.Params) -} - // ToolAIAction implements the ai_action tool call. type ToolAIAction struct{} diff --git a/uixt/option/action.go b/uixt/option/action.go index 6eb05a84..72d80a84 100644 --- a/uixt/option/action.go +++ b/uixt/option/action.go @@ -29,7 +29,6 @@ const ( ACTION_SetIme ActionMethod = "set_ime" ACTION_GetSource ActionMethod = "get_source" ACTION_GetForegroundApp ActionMethod = "get_foreground_app" - ACTION_CallFunction ActionMethod = "call_function" // UI handling ACTION_Home ActionMethod = "home"