feat: 后端工具和 MCP 模块更新
- main.go: 更新工作空间目录,添加 MCP 模型迁移 - tool.go: 添加 description_cn 字段 - auth_service, tool_service: 优化 - 更新 Swagger 文档 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -193,8 +193,8 @@ func (s *AuthService) createUserWorkspace(username string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// 创建子目录
|
||||
subDirs := []string{"projects", "files", "temp"}
|
||||
// 创建子目录: skills(技能), scripts(脚本), sandbox(沙盒), files(文件), temp(临时)
|
||||
subDirs := []string{"skills", "scripts", "sandbox", "files", "temp"}
|
||||
for _, dir := range subDirs {
|
||||
if err := os.MkdirAll(filepath.Join(workspacePath, dir), 0755); err != nil {
|
||||
return err
|
||||
|
||||
@@ -58,12 +58,12 @@ func (s *ToolService) DeleteTool(id string) error {
|
||||
func (s *ToolService) InitDefaultTools() error {
|
||||
log.Println("[ToolService] Starting init default tools...")
|
||||
|
||||
// 获取默认工具
|
||||
tools := s.getDefaultTools()
|
||||
|
||||
// 删除现有的系统工具,重新插入
|
||||
s.toolRepo.DB().Where("provider = ?", "system").Delete(&model.Tool{})
|
||||
log.Printf("[ToolService] Deleted existing system tools, inserting %d default tools...", len(tools))
|
||||
|
||||
// 插入默认工具
|
||||
tools := s.getDefaultTools()
|
||||
log.Printf("[ToolService] Inserting %d default tools...", len(tools))
|
||||
|
||||
for _, tool := range tools {
|
||||
if err := s.toolRepo.Create(&tool); err != nil {
|
||||
@@ -83,6 +83,7 @@ func (s *ToolService) getDefaultTools() []model.Tool {
|
||||
{
|
||||
Name: "read_file",
|
||||
Description: "Read the contents of a file from the filesystem.",
|
||||
DescriptionCN: "读取文件系统的文件内容。",
|
||||
Category: "file",
|
||||
SecurityLevel: "safe",
|
||||
RequireApproval: false,
|
||||
@@ -93,6 +94,7 @@ func (s *ToolService) getDefaultTools() []model.Tool {
|
||||
{
|
||||
Name: "write_file",
|
||||
Description: "Write content to a file. Creates the file if it doesn't exist, overwrites if it does.",
|
||||
DescriptionCN: "写入内容到文件。如果文件不存在则创建,存在则覆盖。",
|
||||
Category: "file",
|
||||
SecurityLevel: "review",
|
||||
RequireApproval: true,
|
||||
@@ -103,6 +105,7 @@ func (s *ToolService) getDefaultTools() []model.Tool {
|
||||
{
|
||||
Name: "list_dir",
|
||||
Description: "List the contents of a directory.",
|
||||
DescriptionCN: "列出目录的内容。",
|
||||
Category: "file",
|
||||
SecurityLevel: "safe",
|
||||
RequireApproval: false,
|
||||
@@ -113,6 +116,7 @@ func (s *ToolService) getDefaultTools() []model.Tool {
|
||||
{
|
||||
Name: "delete_file",
|
||||
Description: "Delete a file or directory.",
|
||||
DescriptionCN: "删除文件或目录。",
|
||||
Category: "file",
|
||||
SecurityLevel: "danger",
|
||||
RequireApproval: true,
|
||||
@@ -123,6 +127,7 @@ func (s *ToolService) getDefaultTools() []model.Tool {
|
||||
{
|
||||
Name: "search_files",
|
||||
Description: "Search for files by name pattern or content.",
|
||||
DescriptionCN: "按文件名模式或内容搜索文件。",
|
||||
Category: "file",
|
||||
SecurityLevel: "safe",
|
||||
RequireApproval: false,
|
||||
@@ -134,6 +139,7 @@ func (s *ToolService) getDefaultTools() []model.Tool {
|
||||
{
|
||||
Name: "execute_python",
|
||||
Description: "Execute Python code in a sandboxed environment.",
|
||||
DescriptionCN: "在沙盒环境中执行Python代码。",
|
||||
Category: "executor",
|
||||
SecurityLevel: "review",
|
||||
RequireApproval: true,
|
||||
@@ -144,6 +150,7 @@ func (s *ToolService) getDefaultTools() []model.Tool {
|
||||
{
|
||||
Name: "execute_javascript",
|
||||
Description: "Execute JavaScript code in a sandboxed environment.",
|
||||
DescriptionCN: "在沙盒环境中执行JavaScript代码。",
|
||||
Category: "executor",
|
||||
SecurityLevel: "review",
|
||||
RequireApproval: true,
|
||||
@@ -154,6 +161,7 @@ func (s *ToolService) getDefaultTools() []model.Tool {
|
||||
{
|
||||
Name: "execute_bash",
|
||||
Description: "Execute a bash command in a sandboxed environment.",
|
||||
DescriptionCN: "在沙盒环境中执行Bash命令。",
|
||||
Category: "executor",
|
||||
SecurityLevel: "danger",
|
||||
RequireApproval: true,
|
||||
@@ -165,6 +173,7 @@ func (s *ToolService) getDefaultTools() []model.Tool {
|
||||
{
|
||||
Name: "web_fetch",
|
||||
Description: "Fetch content from a web URL.",
|
||||
DescriptionCN: "从网页URL获取内容。",
|
||||
Category: "web",
|
||||
SecurityLevel: "safe",
|
||||
RequireApproval: false,
|
||||
@@ -175,6 +184,7 @@ func (s *ToolService) getDefaultTools() []model.Tool {
|
||||
{
|
||||
Name: "web_search",
|
||||
Description: "Search the web for information.",
|
||||
DescriptionCN: "在网络上搜索信息。",
|
||||
Category: "web",
|
||||
SecurityLevel: "safe",
|
||||
RequireApproval: false,
|
||||
@@ -186,6 +196,7 @@ func (s *ToolService) getDefaultTools() []model.Tool {
|
||||
{
|
||||
Name: "http_request",
|
||||
Description: "Make HTTP requests to APIs.",
|
||||
DescriptionCN: "向API发送HTTP请求。",
|
||||
Category: "http",
|
||||
SecurityLevel: "safe",
|
||||
RequireApproval: false,
|
||||
@@ -197,6 +208,7 @@ func (s *ToolService) getDefaultTools() []model.Tool {
|
||||
{
|
||||
Name: "send_notification",
|
||||
Description: "Send notifications via email, webhook, dingtalk, or slack.",
|
||||
DescriptionCN: "通过邮件、webhook、钉钉或Slack发送通知。",
|
||||
Category: "notification",
|
||||
SecurityLevel: "safe",
|
||||
RequireApproval: false,
|
||||
@@ -208,6 +220,7 @@ func (s *ToolService) getDefaultTools() []model.Tool {
|
||||
{
|
||||
Name: "get_current_time",
|
||||
Description: "Get the current date and time.",
|
||||
DescriptionCN: "获取当前日期和时间。",
|
||||
Category: "system",
|
||||
SecurityLevel: "safe",
|
||||
RequireApproval: false,
|
||||
|
||||
Reference in New Issue
Block a user