align tool naming and message action schema with openclaw compatibility

This commit is contained in:
DBT
2026-02-24 06:40:14 +00:00
parent 141b6a2ccb
commit 1e9b543f5e
3 changed files with 81 additions and 9 deletions

View File

@@ -23,16 +23,28 @@ func (t *MessageTool) Name() string {
}
func (t *MessageTool) Description() string {
return "Send a message to user on a chat channel. Use this when you want to communicate something."
return "Channel actions tool. Supports action=send (default). OpenClaw-compatible fields: action, message/content, to/chat_id, channel."
}
func (t *MessageTool) Parameters() map[string]interface{} {
return map[string]interface{}{
"type": "object",
"properties": map[string]interface{}{
"action": map[string]interface{}{
"type": "string",
"description": "Action type: send (supported), edit/delete/react (reserved)",
},
"message": map[string]interface{}{
"type": "string",
"description": "The message content to send (OpenClaw-compatible)",
},
"content": map[string]interface{}{
"type": "string",
"description": "The message content to send",
"description": "Alias of message",
},
"to": map[string]interface{}{
"type": "string",
"description": "Optional target id (alias of chat_id)",
},
"channel": map[string]interface{}{
"type": "string",
@@ -58,7 +70,7 @@ func (t *MessageTool) Parameters() map[string]interface{} {
},
},
},
"required": []string{"content"},
"required": []string{},
}
}
@@ -72,13 +84,27 @@ func (t *MessageTool) SetSendCallback(callback SendCallback) {
}
func (t *MessageTool) Execute(ctx context.Context, args map[string]interface{}) (string, error) {
content, ok := args["content"].(string)
if !ok {
return "", fmt.Errorf("content is required")
action, _ := args["action"].(string)
if action == "" {
action = "send"
}
if action != "send" {
return fmt.Sprintf("Unsupported action: %s (currently only send is implemented)", action), nil
}
content, _ := args["content"].(string)
if msg, _ := args["message"].(string); msg != "" {
content = msg
}
if content == "" {
return "", fmt.Errorf("message/content is required for action=send")
}
channel, _ := args["channel"].(string)
chatID, _ := args["chat_id"].(string)
if to, _ := args["to"].(string); to != "" {
chatID = to
}
if channel == "" {
channel = t.defaultChannel