mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-04-15 00:27:29 +08:00
align tool naming and message action schema with openclaw compatibility
This commit is contained in:
39
pkg/tools/compat_alias.go
Normal file
39
pkg/tools/compat_alias.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package tools
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
// AliasTool exposes OpenClaw-compatible tool names while forwarding to existing implementations.
|
||||
type AliasTool struct {
|
||||
name string
|
||||
description string
|
||||
base Tool
|
||||
argMap map[string]string
|
||||
}
|
||||
|
||||
func NewAliasTool(name, description string, base Tool, argMap map[string]string) *AliasTool {
|
||||
return &AliasTool{name: name, description: description, base: base, argMap: argMap}
|
||||
}
|
||||
|
||||
func (t *AliasTool) Name() string { return t.name }
|
||||
func (t *AliasTool) Description() string {
|
||||
if t.description != "" {
|
||||
return t.description
|
||||
}
|
||||
return t.base.Description()
|
||||
}
|
||||
func (t *AliasTool) Parameters() map[string]interface{} { return t.base.Parameters() }
|
||||
|
||||
func (t *AliasTool) Execute(ctx context.Context, args map[string]interface{}) (string, error) {
|
||||
if len(t.argMap) > 0 {
|
||||
for from, to := range t.argMap {
|
||||
if v, ok := args[from]; ok {
|
||||
if _, exists := args[to]; !exists {
|
||||
args[to] = v
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return t.base.Execute(ctx, args)
|
||||
}
|
||||
Reference in New Issue
Block a user