feat: #27 插件系统 — 第三方节点扩展

- NodePlugin 模型: manifest规范(name/version/node_type/inputs_schema/outputs_schema)
- plugin_loader 服务: manifest校验、代码加载/卸载、沙箱执行(subprocess隔离+超时30s)
- plugins API: CRUD、启用/禁用、市场浏览、安装计数、沙箱测试执行
- PluginMarket.vue: 插件市场上传/浏览/安装/启用禁用/删除/测试
- 注册 register_external_tool 到 tool_registry,供工作流编辑器使用

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
renjianbo
2026-05-06 21:44:45 +08:00
parent 1b5f9deb44
commit 3c102ed5f9
9 changed files with 1029 additions and 3 deletions

View File

@@ -0,0 +1,48 @@
"""
插件模型 — 第三方节点扩展
"""
from sqlalchemy import Column, String, Text, Boolean, DateTime, JSON, Integer, func
from sqlalchemy.dialects.mysql import CHAR
from app.core.database import Base
import uuid
class NodePlugin(Base):
"""第三方节点插件"""
__tablename__ = "node_plugins"
id = Column(CHAR(36), primary_key=True, default=lambda: str(uuid.uuid4()), comment="插件ID")
name = Column(String(128), nullable=False, unique=True, comment="插件名称(唯一)")
version = Column(String(32), nullable=False, default="1.0.0", comment="版本号")
description = Column(Text, comment="描述")
author = Column(String(128), comment="作者")
node_type = Column(String(64), nullable=False, comment="节点类型标识(如 custom_http、custom_data")
node_label = Column(String(128), comment="节点显示名称")
category = Column(String(64), default="custom", comment="分类: custom/http/data/ai/tool")
# manifest.json 原始内容
manifest = Column(JSON, comment="manifest.json 完整内容")
# 输入/输出定义
inputs_schema = Column(JSON, comment="输入参数 schema")
outputs_schema = Column(JSON, comment="输出参数 schema")
# 代码
code = Column(Text, comment="插件执行代码Python")
# 状态
enabled = Column(Boolean, default=True, comment="是否启用")
is_public = Column(Boolean, default=False, comment="是否公开到插件市场")
install_count = Column(Integer, default=0, comment="安装次数")
rating_avg = Column(Integer, default=0, comment="平均评分")
# 元数据
icon = Column(String(256), comment="图标URL")
tags = Column(JSON, comment="标签列表")
user_id = Column(CHAR(36), nullable=True, comment="上传者ID")
created_at = Column(DateTime, default=func.now(), comment="创建时间")
updated_at = Column(DateTime, default=func.now(), onupdate=func.now(), comment="更新时间")
def __repr__(self):
return f"<NodePlugin(id={self.id}, name={self.name}, type={self.node_type})>"