SCIOT 闭环架构设计文档
1. 架构总览
1.1 三个闭环的定义
SCIOT 系统采用三层闭环架构设计,确保规则、能力和运维的持续自我进化:
┌─────────────────────────────────────────────────────────────────────────────┐
│ SCIOT 三层闭环架构 │
├─────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────┐ ┌─────────────────────┐ ┌─────────────────┐ │
│ │ 闭环1:规则/模板 │ │ 闭环2:六大能力 │ │ 闭环3:数字员工 │ │
│ │ /提示词生命周期 │───▶│ 闭环 │───▶│ 自运维 │ │
│ └─────────────────────┘ └─────────────────────┘ └─────────────────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌─────────────────────┐ ┌─────────────────────┐ ┌─────────────────┐ │
│ │ sciot_templates │ │ CapabilityRuntime │ │ EvolutionSched │ │
│ │ sciot_rules_v2 │ │ RuleEngine │ │ FeedbackEngine │ │
│ │ prompt_templates │ │ LLM Brain │ │ StaffManager │ │
│ └─────────────────────┘ └─────────────────────┘ └─────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────┘
1.2 数据流向图
SCSAI PLM Server
│
▼ (AML/SOAP)
┌─────────────────┐
│ Template Sync │ ◄── 从 SCSAI 同步 ItemType Schema
│ Service │
└────────┬────────┘
│
▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ sciot_templates │────▶│ sciot_rules_v2 │────▶│ prompt_templates│
│ (1205条) │ │ (2285条) │ │ (2817条) │
└────────┬────────┘ └────────┬────────┘ └─────────────────┘
│ │
▼ ▼
┌─────────────────┐ ┌─────────────────┐
│ /api/sciot/ │ │ CapabilityRuntime│
│ type-template │ │ (6大能力执行) │
└─────────────────┘ └────────┬────────┘
│
┌────────────┼────────────┐
▼ ▼ ▼
┌─────────┐ ┌─────────┐ ┌─────────┐
│ identify│ │ create │ │ repair │
│ validate│ │ optimize│ │ compare │
│ generate│ │ inspect │ │ │
└────┬────┘ └────┬────┘ └────┬────┘
│ │ │
└────────────┼────────────┘
▼
┌─────────────────────┐
│ sciot_creation_logs │
│ (创建执行日志) │
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ FeedbackEngine │
│ (分析 + 生成建议) │
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ sciot_evolution_logs│
│ (进化历史) │
└──────────┬──────────┘
│
▼
┌─────────────────────┐
│ SQL Migration │
│ (规则/模板更新) │
└─────────────────────┘
1.3 闭环关系
- 闭环1 为闭环2提供规则、模板和提示词基础数据
- 闭环2 的执行结果写入闭环3的日志系统
- 闭环3 分析日志并生成优化建议,通过 SQL Migration 反哺闭环1
- 三个闭环形成完整的自进化飞轮
2. 闭环1:规则/模板/提示词生命周期
2.1 导入(Import)
流程:从 SCSAI 同步 ItemType Schema → 本地 sciot_templates
实现:server/services/template-sync-service.js
SCSAI ItemType ──▶ fetchAllItemTypeMap() ──▶ syncItemTypeFromAras()
│
▼
┌───────────────┐
│ sciot_item_types│ (元数据缓存)
│ sciot_properties │ (属性定义)
│ sciot_relationships│ (关系类型)
│ sciot_lifecycle_maps│ (生命周期)
│ sciot_list_values │ (下拉选项值)
└───────────────┘
│
▼
┌───────────────┐
│ sciot_templates │ (生成规则 + 字段分类)
│ llm_fields │ (LLM生成字段)
│ auto_fields │ (系统自动字段)
│ generation_rules│ (子对象/关系生成规则)
└───────────────┘
关键特性:
- 支持单条同步和全量批量同步(
syncAllItemTypes) - 自动推断字段分类:系统字段/只读字段/隐藏字段 →
auto_fields,其余 →llm_fields - 自动构建
generation_rules.child_objects关系生成规则 - 全量同步使用事务批次(每50个类型一次事务)
2.2 创建(Create)
流程:LLM 生成 generation_rules → 人工审核 → 入库
入口:POST /api/aml/sciot/templates 或 POST /api/aml/sciot/rules
用户描述 ──▶ LLM 生成规则草稿 ──▶ 人工审核界面 ──▶ 确认入库
│
▼
┌──────────────┐
│ 规则格式校验 │
│ 字段存在性检查│
│ 条件语法验证 │
└──────────────┘
generation_rules 结构示例:
{
"version": "1.0",
"item_properties": {
"name": { "required": true, "max_length": 128 },
"item_number": { "auto_generate": "sequence" }
},
"child_objects": [
{
"relationship_name": "Part BOM",
"target_type": "Part",
"generate_child": true,
"llm_fields": ["name", "quantity"],
"auto_fields": ["item_number"]
}
],
"validation_rules": [
{ "field": "name", "rule": "required", "message": "名称不能为空" }
]
}
2.3 维护(Maintain)
流程:SQL 迁移脚本管理,manual 标记保护
实现:scripts/apply-sql-migrations.js + server/data/sql-migrations/
管理原则:
- 只追加,不修改已执行的脚本
- 所有修改通过 SQL 脚本,不手工修改 SQLite
- 脚本可版本控制,整个目录可提交到 Git
- 兼容 SQLite 和 MySQL
manual 标记保护机制:
// template-sync-service.js
const isManual = existingGr.includes('"_source":"manual"');
if (isManual) {
// 只更新 llm_fields 和 auto_fields(自动推断的,可安全更新)
// 跳过 generation_rules 更新
}
迁移脚本示例:
-- 001-fix-product-generation-rules.sql
UPDATE sciot_templates
SET generation_rules = json_set(generation_rules, '$.default_properties', '{"is_template": 0}')
WHERE item_type_name = 'Product';
2.4 使用(Use)
流程:前端通过 /api/sciot/type-template/{type} 读取完整模板
返回数据结构:
{
"item_type": { "name": "Part", "label": "零件", ... },
"properties": [ { "name": "item_number", "data_type": "string", "list_values": [...] } ],
"relationships": [ { "name": "Part BOM", "related_item_type": "Part", "properties": [...] } ],
"methods": [ { "name": "onAfterAdd", "method_type": "JavaScript" } ],
"lifecycle": { "name": "Part_LC", "states": [...] },
"sequence": { "name": "Part", "initial_value": 1000 },
"llm_fields": ["name", "description", "classification"],
"auto_fields": ["id", "config_id", "created_on"],
"generation_rules": { "child_objects": [...] }
}
2.5 进化(Evolve)
流程:feedback-engine 分析日志 → 生成优化建议 → SQL migration
组件:
server/services/feedback-engine.js— 分析引擎server/services/evolution-scheduler.js— 调度器
分析维度:
- 成功率统计:按类型统计 success/fail 率
- 高频失败类型:连续失败3次以上
- LLM 重试率:超过50%视为需要优化提示词
- 耗时分析:超过平均值2倍视为过慢
- 错误模式识别:从 error_message 提取相似错误
生成建议类型:
| 类型 | 严重程度 | 目标表 | 自动修复 |
|------|---------|--------|---------|
| high_failure | critical | sciot_templates.generation_rules | 有条件 |
| high_llm_retry | warning | sciot_templates.prompt_template | 有条件 |
| slow_duration | info | sciot_templates.generation_rules | 否 |
| error_pattern | warning/critical | sciot_templates.generation_rules | 有条件 |
3. 闭环2:6大能力闭环
3.1 能力总览
| 能力 | 英文 | 核心方法 | 降级策略 |
|------|------|---------|---------|
| 识别 | Identify | executeIdentify() | LLM 识别 |
| 创建 | Create | createItem() | LLM 生成 + AML组装 |
| 修复 | Repair | executeRepair() | LLM 分析 |
| 优化 | Optimize | executeOptimize() | LLM 建议 |
| 比对 | Compare | executeCompare() | LLM 影响分析 |
| 生成 | Generate | execute('transform') | LLM 生成 |
统一执行原则:规则引擎优先 → LLM 降级 → 人工兜底
3.2 识别(Identify)
输入:{ item_type, query_type, filters, generate_report }
query_type 支持:
single— 单对象查询(by id)list— 列表查询(by filters)cross— 跨对象查询(通过关系遍历)stats— 统计查询(group_by + metrics)report— 报告生成
规则引擎流程:
execute(RULE_SCOPES.IDENTIFY) ──▶ 匹配识别规则 ──▶ 应用结果转换器
│
▼ (无规则匹配)
LLM 识别 ──▶ thinkJson() ──▶ 返回结构化结果
API 端点:POST /api/capability/identify
3.3 创建(Create)
完整生命周期:
1. validate ──▶ 2. create_pre ──▶ 3. 组装AML ──▶ 4. 提交SCSAI ──▶ 5. create_post
│ │ │ │
▼ ▼ ▼ ▼
必填检查 序列号生成 buildAML() applyAML()
格式校验 默认值填充 关系构建 更新序列
唯一性检查 子对象预创建
降级策略:
- 主流程:规则引擎
createItem()→ 成功返回 item_id - 降级1:LLM 生成属性 JSON → 规则引擎 AML 生成器 → 提交 SCSAI
- 降级2:基础
buildAML()直接组装 - 文件上传:Vault Server 通道 (
/api/sciot/vault-create-file)
API 端点:POST /api/capability/create
3.4 修复(Repair)
流程:
executeRepair(context)
├── 1. 如无 issues,先执行 executeIdentify() 发现问题
├── 2. 加载 REPAIR 范围规则
├── 3. 对每个 issue 评估条件 → 执行修复动作
├── 4. 收集 changes → 构建 Repair AML
└── 5. 提交 SCSAI (如配置了 arasClient)
输出:{ issues_found, repairs_applied, repairs[], aras_result }
API 端点:POST /api/capability/repair
3.5 优化(Optimize)
流程:
executeOptimize(context)
├── 1. 加载 OPTIMIZE 范围规则
├── 2. 评估条件 → 执行优化动作
└── 3. 按优先级排序返回优化建议
典型应用场景:
- BOM 成本优化(替代料推荐)
- 流程优化(审批路径简化)
- 数据标准化(字段格式统一)
API 端点:POST /api/capability/optimize
3.6 比对(Compare)
流程:
executeCompare(context)
├── 1. 查询两个对象的完整数据
├── 2. _computeFieldDiffs() 计算字段差异
├── 3. 加载 COMPARE 范围规则
├── 4. 执行比对规则
└── 5. 如配置了 llmClient,生成影响分析
输出:{ summary: { added, removed, modified }, field_diffs[], compare_results[], impact_analysis }
API 端点:POST /api/capability/compare
3.7 生成(Generate)
流程:
execute('transform')
├── 1. 加载 TRANSFORM 范围规则
├── 2. 规则命中 → 模板化生成
└── 3. 无规则 → LLM 生成
批量生成支持:
- 通过
generation_rules.child_objects定义子对象生成策略 - 支持嵌套深度控制 (
nested_depth) - 支持关系数量提示 (
quantity_hint: dynamic/fixed)
API 端点:POST /api/capability/generate
3.8 各能力输入/输出/API端点汇总
| 能力 | 方法 | 核心输入 | 核心输出 | API 端点 |
|---|---|---|---|---|
| identify | executeIdentify | item_type, query_type, filters | query_result, rule_results | POST /api/capability/identify |
| validate | execute('validate') | item_type, data | decision, confidence, riskLevel | POST /api/capability/validate |
| create | createItem | item_type, properties, relationships | item_id, aml, rule_results | POST /api/capability/create |
| repair | executeRepair | item_type, data, issues | repairs_applied, repairs[] | POST /api/capability/repair |
| optimize | executeOptimize | item_type, data | optimizations_found, optimizations[] | POST /api/capability/optimize |
| compare | executeCompare | item_type, item_a, item_b | field_diffs[], impact_analysis | POST /api/capability/compare |
| generate | execute('transform') | item_type, data, template_id | content, summary | POST /api/capability/generate |
| inspect | executeInspect | item_type, priority, scope | issues[], fix_aml[] | POST /api/capability/inspect |
4. 闭环3:数字员工自运维
4.1 自运维循环
┌─────────────────────────────────────────────────────────────┐
│ 数字员工自运维循环 │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ 任务接收 │───▶│ 能力选择 │───▶│ 规则执行 │ │
│ │ (Intent) │ │ (Router) │ │ (Engine) │ │
│ └──────────┘ └──────────┘ └────┬─────┘ │
│ │ │
│ ▼ │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ 规则进化 │◄───│ 反馈分析 │◄───│ 日志记录 │ │
│ │ (Evolve) │ │ (Analyze)│ │ (Log) │ │
│ └──────────┘ └──────────┘ └──────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘
4.2 任务接收与能力选择
实现:server/core/intent-engine.js
流程:
- 接收自然语言指令
- 意图识别(Intent Classification)
- 匹配数字员工(Staff Routing)
- 选择对应能力(Capability Selection)
4.3 执行与日志记录
执行日志表:staff_execution_logs
CREATE TABLE staff_execution_logs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
staff_id TEXT NOT NULL,
task_id TEXT DEFAULT '',
action TEXT DEFAULT '',
duration_ms INTEGER DEFAULT 0,
status TEXT DEFAULT 'success',
message TEXT DEFAULT '',
created_at TEXT
);
创建日志表:sciot_creation_logs
CREATE TABLE sciot_creation_logs (
id TEXT PRIMARY KEY,
item_type TEXT NOT NULL,
item_id TEXT,
action TEXT DEFAULT 'create',
success INTEGER,
error_message TEXT,
duration_ms INTEGER,
llm_called INTEGER DEFAULT 0,
llm_model TEXT,
llm_tokens INTEGER,
llm_retry_count INTEGER DEFAULT 0,
llm_retry_success INTEGER DEFAULT 0,
prompt_source TEXT,
aml_used TEXT,
created_at TEXT DEFAULT CURRENT_TIMESTAMP
);
4.4 反馈分析
实现:server/services/feedback-engine.js
FeedbackAnalyzer 核心方法:
analyzeCreationLogs(db)— 分析最近7天日志generateOptimizationSuggestions(db, analysis)— 生成优化建议executeAutoEvolution(db, suggestions, options)— 执行自动进化getEvolutionHistory(db, options)— 查询进化历史
分析配置:
const DEFAULT_OPTIONS = {
timeWindowDays: 7, // 分析最近7天
highFailureThreshold: 3, // 连续失败3次以上视为高频失败
llmRetryThreshold: 0.5, // LLM 重试率超过50%需要优化
durationPercentile: 90, // 耗时百分位阈值
durationSlowMultiplier: 2, // 耗时超过平均值2倍视为过慢
minSampleSize: 5, // 最小样本量
};
4.5 EvolutionScheduler 调度器
实现:server/services/evolution-scheduler.js
配置:
const DEFAULT_OPTIONS = {
intervalMs: 30 * 60 * 1000, // 检查间隔:30分钟
minLogsToAnalyze: 10, // 最少日志数量才触发分析
autoApplyCritical: false, // 是否自动应用 critical 建议
sqlOutputDir: null, // SQL 脚本输出目录
dryRun: true, // 默认试运行
};
调度流程:
start(db) ──▶ 设置定时器 ──▶ 每30分钟检查
│
▼
_countNewLogs() >= minLogsToAnalyze?
│
是 ──▶ _runFullAnalysis()
│
├── 1. analyzeCreationLogs()
├── 2. generateOptimizationSuggestions()
└── 3. executeAutoEvolution()
4.6 健康度评分算法
实现:server/boss-scheduler/workers/system-health.js
检查维度:
| 检查项 | 权重 | 通过标准 |
|--------|------|---------|
| 数据库可用性 | 25% | sciot_import.db 可打开 |
| SCSAI 连接 | 25% | ArasClient 可初始化 |
| 模板覆盖率 | 20% | 缺失模板 < 50 个 |
| 规则引擎 | 15% | sciot_rules_v2 > 0 |
| 配置一致性 | 15% | 无 ERROR 级别问题 |
评分计算:
const checks = ['database', 'aras_connection', 'template_coverage', 'rules_v2', 'consistency'];
const allOk = errors.length === 0 && checks.every(c => c.status === 'ok');
// 健康度 = (通过检查数 / 总检查数) * 100
自愈机制:
- 当
capability === 'repair'时,自动调用capability.repair()修复发现的问题 - 修复结果记录到
staff_execution_logs
5. 数据模型
5.1 核心表结构
#### sciot_templates(模板表)— 1205条
| 字段 | 类型 | 说明 |
|------|------|------|
| id | INTEGER PK | 自增ID |
| template_type | TEXT | 模板类型(synced/manual) |
| item_type_name | TEXT | 对象类型名称 |
| item_type_label | TEXT | 显示标签 |
| llm_fields | TEXT(JSON) | LLM生成字段列表 |
| auto_fields | TEXT(JSON) | 系统自动字段列表 |
| generation_rules | TEXT(JSON) | 生成规则(含child_objects) |
| required_fields | TEXT(JSON) | 必填字段 |
| optional_fields | TEXT(JSON) | 可选字段 |
#### sciot_rules_v2(规则表)— 2285条
| 字段 | 类型 | 说明 |
|------|------|------|
| id | TEXT PK | 规则ID |
| name | TEXT | 规则名称 |
| scope | TEXT | 作用范围(identify/create/repair/optimize/compare/validate) |
| item_type_name | TEXT | 适用对象类型 |
| property_name | TEXT | 适用属性名 |
| rule_type | TEXT | 规则类型(required/format/range/unique/custom) |
| condition | TEXT(JSON) | 条件定义 |
| action_type | TEXT | 动作类型(block/warn/auto_fix/suggest) |
| severity | TEXT | 严重程度(error/warning/info) |
| priority | TEXT | 优先级(P0/P1/P2/P3) |
| is_active | INTEGER | 是否启用 |
| prompt_template | TEXT | 关联提示词模板 |
| prompt_template_id | TEXT | 关联提示词模板ID |
#### prompt_templates(提示词表)— 2817条
| 字段 | 类型 | 说明 |
|------|------|------|
| id | TEXT PK | 模板ID |
| name | TEXT | 模板名称 |
| content | TEXT | 用户提示词内容 |
| system_prompt | TEXT | 系统提示词 |
| prompt_type | TEXT | 类型(system/user) |
| item_type_name | TEXT | 关联对象类型 |
| operation_type | TEXT | 操作类型(generate/create/validate) |
| version | TEXT | 版本号 |
| status | TEXT | 状态(active/draft/deprecated) |
| usage_count | INTEGER | 使用次数 |
#### sciot_creation_logs(创建日志)
| 字段 | 类型 | 说明 |
|------|------|------|
| id | TEXT PK | 日志ID |
| item_type | TEXT | 对象类型 |
| item_id | TEXT | 创建的对象ID |
| success | INTEGER | 是否成功 |
| error_message | TEXT | 错误信息 |
| duration_ms | INTEGER | 耗时(毫秒) |
| llm_called | INTEGER | 是否调用了LLM |
| llm_retry_count | INTEGER | LLM重试次数 |
| llm_retry_success | INTEGER | 重试是否成功 |
| prompt_source | TEXT | 提示词来源 |
| aml_used | TEXT | 使用的AML |
| created_at | TEXT | 创建时间 |
#### sciot_evolution_logs(进化日志)
| 字段 | 类型 | 说明 |
|------|------|------|
| id | TEXT PK | 进化记录ID |
| suggestion_type | TEXT | 建议类型 |
| target_type | TEXT | 目标对象类型 |
| target_table | TEXT | 目标表 |
| target_field | TEXT | 目标字段 |
| old_value | TEXT | 原始值 |
| new_value | TEXT | 建议新值 |
| auto_generated | INTEGER | 是否自动生成 |
| status | TEXT | 状态(pending/approved/applied/rejected) |
| applied_at | TEXT | 应用时间 |
| created_at | TEXT | 创建时间 |
#### sciot_migration_logs(迁移记录)
| 字段 | 类型 | 说明 |
|------|------|------|
| id | INTEGER PK | 自增ID |
| filename | TEXT | 脚本文件名 |
| applied_at | TEXT | 执行时间 |
| checksum | TEXT | MD5校验和 |
| status | TEXT | 状态(success/failed) |
| error_message | TEXT | 错误信息 |
5.2 辅助表
| 表名 | 说明 |
|---|---|
| sciot_item_types | 对象类型元数据 |
| sciot_properties | 属性定义 |
| sciot_relationships | 关系类型定义 |
| sciot_lifecycle_maps | 生命周期映射 |
| sciot_lifecycle_states | 生命周期状态 |
| sciot_list_values | 下拉列表值 |
| sciot_sequences | 自动编号序列 |
| digital_staff | 数字员工配置 |
| staff_tasks | 数字员工任务 |
| staff_execution_logs | 执行日志 |
| inspection_logs | 巡检日志 |
| inspection_issues | 巡检问题 |
6. API 清单
6.1 模板/规则 API
| 方法 | 路径 | 功能 |
|---|---|---|
| GET | /api/sciot/type-template/:name | 获取对象类完整模板 |
| GET | /api/sciot/system-templates | 获取系统对象模板定义 |
| POST | /api/sciot/build-system-aml | 组装完整 AML 包 |
| GET | /api/sciot/permissions | 获取权限配置 |
| GET | /api/sciot/permissions/:type | 获取指定类型权限模板 |
| GET | /api/sciot/type-list-values/:name | 获取对象类 list 字段值 |
| GET | /api/sciot/type-relationships/:name | 获取对象类关系类型 |
| GET | /api/aml/sciot/templates | 模板列表/统计 |
| GET | /api/aml/sciot/templates/:name | 单模板详情 |
| POST | /api/aml/sciot/templates | 创建/更新模板 |
| GET | /api/aml/sciot/rules | 规则列表/统计 |
| GET | /api/aml/sciot/rules/:name | 单类型规则详情 |
| POST | /api/aml/sciot/rules/batch-update | 批量更新规则状态 |
| DELETE | /api/aml/sciot/rules/batch-delete | 批量删除规则 |
| GET | /api/aml/sciot/prompts | 提示词列表 |
| POST | /api/aml/sciot/prompts/update | 更新提示词 |
| POST | /api/aml/sciot/prompts/generate-from-template | 从模板生成提示词 |
6.2 六大能力 API
| 方法 | 路径 | 功能 |
|---|---|---|
| POST | /api/capability/identify | 识别/查询 |
| POST | /api/capability/validate | 校验/审核 |
| POST | /api/capability/create | 创建对象 |
| POST | /api/capability/repair | 修复问题 |
| POST | /api/capability/optimize | 优化改善 |
| POST | /api/capability/compare | 对比分析 |
| POST | /api/capability/generate | 内容生成 |
| POST | /api/capability/inspect | 巡检检查 |
| GET | /api/capability/status | 能力状态 |
6.3 SCIO 专用 API
| 方法 | 路径 | 功能 |
|---|---|---|
| POST | /api/sciot/recognize | LLM智能识别对象类 |
| POST | /api/sciot/repair | 修复引擎 |
| POST | /api/sciot/repair/apply | 应用修复AML |
| POST | /api/sciot/optimize | 优化引擎 |
| POST | /api/sciot/compare | 比对引擎 |
| POST | /api/sciot/content-prompt | 内容生成提示词 |
| POST | /api/sciot/generate-itemtype | 生成新ItemType定义 |
| POST | /api/sciot/create-itemtype-in-aras | 创建ItemType到SCSAI |
| POST | /api/sciot/apply-item | 直接发送AML到SCSAI |
| POST | /api/sciot/vault-create-file | Vault Server创建文件 |
| POST | /api/sciot/query-list-values | 查询list字段可选值 |
6.4 数字员工 API
| 方法 | 路径 | 功能 |
|---|---|---|
| GET | /api/digital-staff | 数字员工列表 |
| GET | /api/digital-staff/:id | 单员工详情 |
| POST | /api/digital-staff | 创建员工 |
| PUT | /api/digital-staff/:id | 更新员工 |
| DELETE | /api/digital-staff/:id | 删除员工 |
| POST | /api/digital-staff/:id/enable | 启用/禁用 |
| GET | /api/digital-staff/:id/tasks | 任务列表 |
| POST | /api/digital-staff/:id/tasks | 创建任务 |
| GET | /api/digital-staff/:id/logs | 执行日志 |
| POST | /api/digital-staff/:id/execute | 手动执行任务 |
7. 文件清单
7.1 核心引擎文件
| 文件路径 | 职责 |
|---|---|
| server/core/rule-engine.js | 统一规则引擎(UnifiedRuleEngine),支持9大scope |
| server/core/capability-runtime.js | 六能力运行时 SDK,规则引擎优先+LLM降级 |
| server/core/aml-generator.js | AML 生成器,根据 LLM 输出组装 AML |
| server/core/unified-schema.js | 统一 Schema 构建器 |
| server/core/intent-engine.js | 意图识别引擎 |
| server/core/prompt-template-manager.js | 提示词模板管理器 |
| server/core/unified-validator.js | 统一校验器 |
| server/core/rule-engine-core.js | 规则引擎核心(已整合到 rule-engine.js) |
7.2 服务层文件
| 文件路径 | 职责 |
|---|---|
| server/services/template-sync-service.js | 从 SCSAI 同步模板数据 |
| server/services/feedback-engine.js | 闭环反馈分析引擎 |
| server/services/evolution-scheduler.js | 自动进化调度器 |
| server/services/unified-dispatch.js | 统一调度服务 |
| server/services/llm.js | LLM 服务封装 |
| server/services/plm-adapter.js | PLM 适配器 |
| server/services/content-engine.js | 内容生成引擎 |
| server/services/auto-fixer.js | 自动修复服务 |
| server/services/compliance-inspector.js | 合规检查服务 |
7.3 数字员工文件
| 文件路径 | 职责 |
|---|---|
| server/digital-staff/index.js | 数字员工入口 |
| server/digital-staff/staff-manager.js | 员工配置管理器 |
| server/digital-staff/llm-brain.js | LLM 智能核心 |
| server/routes/digital-staff-routes.js | 数字员工 HTTP API |
| server/boss-scheduler/lite-scheduler.js | 轻量调度器 |
| server/boss-scheduler/workers/system-health.js | 系统健康巡检 |
| server/boss-scheduler/lib/consistency-check.js | 一致性检查库 |
7.4 路由文件
| 文件路径 | 职责 |
|---|---|
| server/routes/aml.js | AML 主路由(模板/规则/提示词/SCIO API) |
| server/routes/capability-api.js | 六大能力 HTTP API |
| server/routes/rule-engine.js | 规则引擎路由 |
| server/routes/ai-inspector.js | AI 巡检路由 |
| server/routes/assemble.router.js | AML 组装路由 |
| server/routes/itemtype.router.js | ItemType 管理路由 |
| server/routes/import-export.router.js | 导入导出路由 |
7.5 脚本工具
| 文件路径 | 职责 |
|---|---|
| scripts/apply-sql-migrations.js | SQL 迁移执行器 |
| scripts/export-rules-sql.js | 导出规则为 SQL |
| scripts/sync-to-mysql.js | 同步到 MySQL |
| scripts/verify-manual.js | 验证 manual 标记 |
| scripts/check-consistency.js | 一致性检查 |
| scripts/generate-rules-from-aras.js | 从 SCSAI 生成规则 |
| scripts/import-aml-v2.js | AML 导入工具 |
7.6 数据库迁移
| 文件路径 | 职责 |
|---|---|
| server/data/sql-migrations/001-fix-product-generation-rules.sql | 修复 Product 生成规则 |
| server/data/sql-migrations/002-mark-manual-rules.sql | 标记 manual 规则 |
| server/data/sql-migrations/003-ensure-creation-logs-schema.sql | 创建日志表 |
| server/data/sql-migrations/004-ensure-evolution-logs-schema.sql | 进化日志表 |
| server/data/sql-migrations/README.md | 迁移管理说明 |
7.7 前端组合式函数
| 文件路径 | 职责 |
|---|---|
| src/composables/useCapabilityCreate.js | 创建能力前端逻辑 |
| src/views/StaffCapabilities.vue | 数字员工能力界面 |
| src/utils/rule-validator.js | 规则校验工具 |
| src/utils/PromptBuilder.js | 提示词构建器 |
附录:术语表
| 术语 | 说明 |
|---|---|
| SCSAI | PLM 系统服务端 |
| AML | SCSAI Markup Language,SCSAI 的数据操作语言 |
| SCIOT | Smart Connected Industrial Object Technology |
| LLM | 大语言模型 |
| ItemType | SCSAI 中的对象类型定义 |
| generation_rules | 对象生成规则(JSON格式) |
| prompt_template | LLM 提示词模板 |
| Vault Server | SCSAI 文件存储服务器 |
| MTCLAW | 本地 LLM 加速代理 |
| ECR | Engineering Change Request,工程变更请求 |
| BOM | Bill of Materials,物料清单 |
BossAgents