-- Studio 相关枚举初始化。
-- 保持 sys_enum 现有 catalog/type/name/value/strvalue/sort/remark 格式不变。

INSERT INTO sys_enum (catalog, type, name, value, strvalue, sort, version, remark)
VALUES
    ('studio', 'environment', '开发环境', 1, 'DEV', 1, 1, 'Studio环境'),
    ('studio', 'environment', '测试环境', 2, 'TEST', 2, 1, 'Studio环境'),
    ('studio', 'environment', '生产环境', 3, 'PROD', 3, 1, 'Studio环境'),
    ('studio', 'publish_status', '草稿', 1, 'DRAFT', 1, 1, '发布状态'),
    ('studio', 'publish_status', '已发布', 2, 'PUBLISHED', 2, 1, '发布状态'),
    ('studio', 'publish_status', '已归档', 3, 'ARCHIVED', 3, 1, '发布状态'),
    ('workflow', 'status', '草稿', 1, 'DRAFT', 1, 1, 'Workflow状态'),
    ('workflow', 'status', '启用', 2, 'ENABLED', 2, 1, 'Workflow状态'),
    ('workflow', 'status', '停用', 3, 'DISABLED', 3, 1, 'Workflow状态'),
    ('workflow', 'run_status', '排队中', 1, 'QUEUED', 1, 1, 'Workflow运行状态'),
    ('workflow', 'run_status', '运行中', 2, 'RUNNING', 2, 1, 'Workflow运行状态'),
    ('workflow', 'run_status', '成功', 3, 'SUCCESS', 3, 1, 'Workflow运行状态'),
    ('workflow', 'run_status', '失败', 4, 'FAILED', 4, 1, 'Workflow运行状态'),
    ('workflow', 'run_status', '取消', 5, 'CANCELED', 5, 1, 'Workflow运行状态'),
    ('workflow', 'node_type', '开始', 1, 'START', 1, 1, 'Workflow节点类型'),
    ('workflow', 'node_type', '大模型', 2, 'LLM', 2, 1, 'Workflow节点类型'),
    ('workflow', 'node_type', '知识检索', 3, 'KNOWLEDGE_RETRIEVAL', 3, 1, 'Workflow节点类型'),
    ('workflow', 'node_type', 'MCP工具', 4, 'MCP_TOOL', 4, 1, 'Workflow节点类型'),
    ('workflow', 'node_type', 'Skill', 5, 'SKILL', 5, 1, 'Workflow节点类型'),
    ('workflow', 'node_type', '条件', 6, 'CONDITION', 6, 1, 'Workflow节点类型'),
    ('workflow', 'node_type', '回答', 7, 'ANSWER', 7, 1, 'Workflow节点类型'),
    ('agent', 'session_status', '活跃', 1, 'ACTIVE', 1, 1, 'Agent会话状态'),
    ('agent', 'session_status', '已关闭', 2, 'CLOSED', 2, 1, 'Agent会话状态'),
    ('agent', 'session_status', '异常终止', 3, 'FAILED', 3, 1, 'Agent会话状态'),
    ('agent', 'message_role', '用户', 1, 'USER', 1, 1, 'Agent消息角色'),
    ('agent', 'message_role', '助手', 2, 'ASSISTANT', 2, 1, 'Agent消息角色'),
    ('agent', 'message_role', '系统', 3, 'SYSTEM', 3, 1, 'Agent消息角色'),
    ('agent', 'message_role', '工具', 4, 'TOOL', 4, 1, 'Agent消息角色'),
    ('mcp', 'import_type', 'URL导入', 1, 'URL', 1, 1, 'MCP导入方式'),
    ('mcp', 'import_type', 'npm包导入', 2, 'NPM_PACKAGE', 2, 1, 'MCP导入方式'),
    ('mcp', 'import_type', 'JSON声明导入', 3, 'JSON_MANIFEST', 3, 1, 'MCP导入方式'),
    ('mcp', 'capability_type', '工具', 1, 'TOOL', 1, 1, 'MCP能力类型'),
    ('mcp', 'capability_type', '资源', 2, 'RESOURCE', 2, 1, 'MCP能力类型'),
    ('mcp', 'capability_type', '提示词', 3, 'PROMPT', 3, 1, 'MCP能力类型'),
    ('mcp', 'health_status', '未知', 1, 'UNKNOWN', 1, 1, 'MCP健康状态'),
    ('mcp', 'health_status', '健康', 2, 'HEALTHY', 2, 1, 'MCP健康状态'),
    ('mcp', 'health_status', '异常', 3, 'UNHEALTHY', 3, 1, 'MCP健康状态'),
    ('skill', 'skill_type', '提示词', 1, 'PROMPT', 1, 1, 'Skill类型'),
    ('skill', 'skill_type', '代码', 2, 'CODE', 2, 1, 'Skill类型'),
    ('skill', 'skill_type', '混合', 3, 'MIXED', 3, 1, 'Skill类型'),
    ('skill', 'status', '草稿', 1, 'DRAFT', 1, 1, 'Skill状态'),
    ('skill', 'status', '已发布', 2, 'PUBLISHED', 2, 1, 'Skill状态'),
    ('skill', 'status', '已归档', 3, 'ARCHIVED', 3, 1, 'Skill状态'),
    ('agent', 'capability_owner_type', 'Agent', 1, 'AGENT', 1, 1, '能力绑定主体类型'),
    ('agent', 'capability_owner_type', 'Workflow', 2, 'WORKFLOW', 2, 1, '能力绑定主体类型'),
    ('agent', 'capability_type', '知识库', 1, 'RAG_STORE', 1, 1, '能力绑定能力类型'),
    ('agent', 'capability_type', 'MCP能力', 2, 'MCP_CAPABILITY', 2, 1, '能力绑定能力类型'),
    ('agent', 'capability_type', 'Skill', 3, 'SKILL', 3, 1, '能力绑定能力类型')
ON CONFLICT (catalog, type, name)
DO UPDATE SET
    value = EXCLUDED.value,
    strvalue = EXCLUDED.strvalue,
    sort = EXCLUDED.sort,
    remark = EXCLUDED.remark,
    update_time = CURRENT_TIMESTAMP;
