Files
ai-agent/internal/builders/skill_builder.go
T
t 2bbf42b741 refactor(auth): delegate access control to be-system
Remove Agent Desk users, roles, login sessions, tokens, and local permission persistence. Expose the backend as an embeddable ai-agent module with host-provided subject lookup and operation authorization callbacks, and complete the frontend/backend repository split.
2026-08-21 00:41:07 +08:00

43 lines
1.2 KiB
Go

package builders
import (
"encoding/json"
"code.tczkiot.com/wlw/ai-agent/internal/models"
"code.tczkiot.com/wlw/ai-agent/internal/pkg/dto/response"
"code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
)
func BuildSkillDefinitionResponse(item *models.SkillDefinition) response.SkillDefinitionResponse {
examples := make([]string, 0)
if raw := item.Examples; raw != "" {
_ = json.Unmarshal([]byte(raw), &examples)
}
toolWhitelist := make([]string, 0)
if raw := item.ToolWhitelist; raw != "" {
_ = json.Unmarshal([]byte(raw), &toolWhitelist)
}
return response.SkillDefinitionResponse{
ID: item.ID,
Name: item.Name,
Description: item.Description,
Instruction: item.Instruction,
Examples: examples,
ToolWhitelist: toolWhitelist,
Status: int(item.Status),
StatusName: getSkillStatusName(item.Status),
Remark: item.Remark,
CreatedAt: item.CreatedAt,
UpdatedAt: item.UpdatedAt,
CreateUserName: item.CreateUserName,
UpdateUserName: item.UpdateUserName,
}
}
func getSkillStatusName(status enums.Status) string {
if label := enums.GetStatusLabel(status); label != "" {
return label
}
return "未知"
}