change: remove call function tool

This commit is contained in:
lilong.129
2025-05-26 00:43:01 +08:00
parent a888022cbc
commit 778344c826
5 changed files with 1 additions and 64 deletions

View File

@@ -1 +1 @@
v5.0.0-beta-2505260035
v5.0.0-beta-2505260043

View File

@@ -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{

View File

@@ -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
}

View File

@@ -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{}

View File

@@ -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"