feat: refactor tool catalog to use NewRuntimeStaticTool for dynamic tool creation
This commit is contained in:
@@ -21,20 +21,13 @@ func newToolCatalog() *toolCatalog {
|
||||
}
|
||||
|
||||
func buildRuntimeStaticTools() []registry.Tool {
|
||||
builders := map[string]func() registry.Tool{
|
||||
toolx.GraphTriageServiceRequest.Code: func() registry.Tool { return tools.NewTriageServiceRequestTool() },
|
||||
toolx.GraphAnalyzeConversation.Code: func() registry.Tool { return tools.NewAnalyzeConversationTool() },
|
||||
toolx.GraphPrepareTicketDraft.Code: func() registry.Tool { return tools.NewPrepareTicketDraftTool() },
|
||||
toolx.GraphCreateTicketConfirm.Code: func() registry.Tool { return tools.NewCreateTicketGraphTool() },
|
||||
toolx.GraphHandoffConversation.Code: func() registry.Tool { return tools.NewHandoffGraphTool() },
|
||||
}
|
||||
ret := make([]registry.Tool, 0, len(builders))
|
||||
ret := make([]registry.Tool, 0, len(toolx.ListRuntimeStaticToolSpecs()))
|
||||
for _, spec := range toolx.ListRuntimeStaticToolSpecs() {
|
||||
build := builders[strings.TrimSpace(spec.Code)]
|
||||
if build == nil {
|
||||
tool := tools.NewRuntimeStaticTool(spec.Code)
|
||||
if tool == nil {
|
||||
continue
|
||||
}
|
||||
ret = append(ret, build())
|
||||
ret = append(ret, tool)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@ package tools
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"cs-agent/internal/ai/runtime/registry"
|
||||
"cs-agent/internal/pkg/toolx"
|
||||
)
|
||||
|
||||
type Decision string
|
||||
@@ -61,3 +64,20 @@ func getInt64Value(data map[string]any, key string) int64 {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
func NewRuntimeStaticTool(toolCode string) registry.Tool {
|
||||
switch toolx.NormalizeToolCodeAlias(strings.TrimSpace(toolCode)) {
|
||||
case toolx.GraphTriageServiceRequest.Code:
|
||||
return NewTriageServiceRequestTool()
|
||||
case toolx.GraphAnalyzeConversation.Code:
|
||||
return NewAnalyzeConversationTool()
|
||||
case toolx.GraphPrepareTicketDraft.Code:
|
||||
return NewPrepareTicketDraftTool()
|
||||
case toolx.GraphCreateTicketConfirm.Code:
|
||||
return NewCreateTicketGraphTool()
|
||||
case toolx.GraphHandoffConversation.Code:
|
||||
return NewHandoffGraphTool()
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user