5d7c10aeab
- Updated runtime configuration to use __CS_AI_AGENT_WIDGET_CONFIG__ instead of __CS_AGENT_WIDGET_CONFIG__. - Changed message types in support host bridge from "cs-agent" to "cs-ai-agent". - Minified SDK script updated to reflect new AI agent naming conventions. - Adjusted scrollbar styles in main.scss to use .cs-ai-agent-scrollbar instead of .cs-agent-scrollbar.
54 lines
1.8 KiB
Go
54 lines
1.8 KiB
Go
package services
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"strings"
|
|
|
|
"cs-ai-agent/internal/pkg/dto/request"
|
|
"cs-ai-agent/internal/pkg/dto/response"
|
|
"cs-ai-agent/internal/pkg/errorsx"
|
|
)
|
|
|
|
var SkillRuntimeService = newSkillRuntimeService()
|
|
var SkillDebugRunHook func(ctx context.Context, req request.SkillDebugRunRequest) (*response.SkillDebugRunResponse, error)
|
|
var SkillDebugResumeHook func(ctx context.Context, req request.SkillDebugResumeRequest) (*response.SkillDebugRunResponse, error)
|
|
|
|
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不能为空")
|
|
}
|
|
if SkillDebugRunHook == nil {
|
|
return nil, fmt.Errorf("skill debug runner is not initialized")
|
|
}
|
|
return SkillDebugRunHook(ctx, req)
|
|
}
|
|
|
|
func (s *skillRuntimeService) DebugResume(ctx context.Context, req request.SkillDebugResumeRequest) (*response.SkillDebugRunResponse, error) {
|
|
if req.AIAgentID <= 0 {
|
|
return nil, errorsx.InvalidParam("aiAgentId不能为空")
|
|
}
|
|
if strings.TrimSpace(req.CheckPointID) == "" {
|
|
return nil, errorsx.InvalidParam("checkPointId不能为空")
|
|
}
|
|
if strings.TrimSpace(req.UserMessage) == "" {
|
|
return nil, errorsx.InvalidParam("userMessage不能为空")
|
|
}
|
|
if SkillDebugResumeHook == nil {
|
|
return nil, fmt.Errorf("skill debug resume runner is not initialized")
|
|
}
|
|
return SkillDebugResumeHook(ctx, req)
|
|
}
|