2026-04-09 10:01:23 +08:00
|
|
|
package services
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
2026-04-09 11:58:04 +08:00
|
|
|
"fmt"
|
2026-04-09 10:01:23 +08:00
|
|
|
"strings"
|
|
|
|
|
|
|
|
|
|
"cs-agent/internal/pkg/dto/request"
|
|
|
|
|
"cs-agent/internal/pkg/dto/response"
|
|
|
|
|
"cs-agent/internal/pkg/errorsx"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var SkillRuntimeService = newSkillRuntimeService()
|
2026-04-09 11:58:04 +08:00
|
|
|
var SkillDebugRunHook func(ctx context.Context, req request.SkillDebugRunRequest) (*response.SkillDebugRunResponse, error)
|
2026-04-09 10:01:23 +08:00
|
|
|
|
|
|
|
|
func newSkillRuntimeService() *skillRuntimeService {
|
|
|
|
|
return &skillRuntimeService{}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type skillRuntimeService struct{}
|
|
|
|
|
|
|
|
|
|
func (s *skillRuntimeService) DebugRun(ctx context.Context, req request.SkillDebugRunRequest) (*response.SkillDebugRunResponse, error) {
|
|
|
|
|
if req.AIAgentID <= 0 {
|
|
|
|
|
return nil, errorsx.InvalidParam("aiAgentId不能为空")
|
|
|
|
|
}
|
|
|
|
|
if strings.TrimSpace(req.SkillCode) == "" {
|
|
|
|
|
return nil, errorsx.InvalidParam("skillCode不能为空")
|
|
|
|
|
}
|
|
|
|
|
if strings.TrimSpace(req.UserMessage) == "" {
|
|
|
|
|
return nil, errorsx.InvalidParam("userMessage不能为空")
|
|
|
|
|
}
|
2026-04-09 11:58:04 +08:00
|
|
|
if SkillDebugRunHook == nil {
|
|
|
|
|
return nil, fmt.Errorf("skill debug runner is not initialized")
|
2026-04-09 10:01:23 +08:00
|
|
|
}
|
2026-04-09 11:58:04 +08:00
|
|
|
return SkillDebugRunHook(ctx, req)
|
2026-04-09 10:01:23 +08:00
|
|
|
}
|