Object Creation Function Analysis Document
I. Overall Architecture
用户输入 "Create..."
│
├── 业务对象列表(硬编码 itemType)
│ └── AiCapabilityBar → useCapabilityCreate.create(itemType, description)
│ ├── GET /api/aml/unified/schema/:itemType (获取字段定义)
│ ├── GET /api/sciot/type-template/:itemType (获取模板)
│ ├── POST /api/llm/chat (调用LLM生成数据)
│ ├── POST /api/private-library/objects (双库查重)
│ ├── POST /SCSAI-api/ApplyItem (创建主对象)
│ ├── POST /SCSAI-api/ApplyItem (创建关系)
│ └── POST /api/rule-engine/execute-create-post (后置规则)
│
├── 对话框(硬编码 itemType)
│ └── 同上
│
├── 小程序(用户手选类型)
│ └── POST /api/unified/create → handleCreate()
│
└── Digital Staff(关键词匹配)
└── executePipeline() → createObject()
二、已验证的基础核心:useCapabilityCreate.create()
位置: src/composables/useCapabilityCreate.js L448-2045
Verified: Business objects such as Product, BOM, Part, Project, Supplier, including relationships, Item attributes, List attributes, and Sequence numbering.
Complete Process (17 Steps)
| Step | API Call | Description |
|---|---|---|
| 1. Get Schema | GET /api/aml/unified/schema/:itemType | Get field types, list values, validation rules |
| 2. Get Template | GET /api/sciot/type-template/:itemType | Get extended field metadata, relationship definitions, generation rules |
| 3. Get Subtype Schemas | GET /api/sciot/type-template/:relatedType × N | Fetch field definitions for related target types in parallel |
| 4. Get Item Attribute Schemas | GET /api/sciot/type-template/:targetType × N | Get field definitions for item/foreign attribute target types |
| 5. Get System Templates | GET /api/sciot/system-templates | Retrieve system object templates such as Permissions/Identities |
| 6. Build Prompt | (Local) Call PromptBuilder.buildCreationPrompt() | Assemble LLM creation instruction |
| 7. Call LLM | POST /api/llm/chat | Generate object attributes + relationships + sub-objects |
| 8. Parse JSON | (Local) Compatible with 3 formats | Standard / Legacy main / Flattened |
| 9. Dual-DB Deduplication | POST /SCSAI-api/ApplyItem (First query SCSAI exact → fuzzy → query standard DB) | Exact match → suggest → copy → create |
| 10. Sequence Numbering | POST /SCSAI-api/ApplyItem (getNextValue / get+edit) | Obtain SCSAI native Sequence or manually increment |
| 11. Pre-create item properties | POST /SCSAI-api/ApplyItem × N | Create child objects first then reference (e.g., Method for scheduling_method) |
| 12. Pre-create relationship objects | POST /SCSAI-api/ApplyItem × N | Recursively pre-create all nested child objects |
| 13. Build AML | (Local) Call AmlBuilder.buildAML() | Assemble the complete AML XML |
| 14. Create main object | POST /SCSAI-api/ApplyItem (with full Relationships) | Submit to SCSAI |
| 15. Duplicate name retry | POST /SCSAI-api/ApplyItem | If PropertiesAreNotUnique, auto-retry with suffix |
| 16. AI error correction retry | POST /api/llm/chat → Recreate | Max 3 attempts, LLM analyzes errors and makes corrections |
| 17. Create relationships + post-processing | POST /SCSAI-api/ApplyItem × N + create_post rules | Create relationships stepwise, execute post-processing rules |
Key Dependencies
- Frontend: AmlBuilder.js (AML build), PromptBuilder.js (Prompt build)
- Backend: /api/aml/unified/schema/, /api/sciot/type-template/, /api/llm/chat, /SCSAI-api/ApplyItem
- SCSAI Proxy: /SCSAI-api/ApplyItem → Node.js constructs SOAP → SCSAI InnovatorServer.aspx
3. Four Entry Points and Current Status Verification
| Entry Point | Call Chain | itemType Source | Verified? |
|---|---|---|---|
| Business Object List | AiCapabilityBar → useCapabilityCreate.create() | Hardcoded in Page | ✅ Verified |
| Dialog Box | Same as Above | Hardcoded in Page | ❌ Pending Test |
| Mini Program | POST /api/unified/create → handleCreate() | User Manual Selection | ❌ Pending Test |
| Digital Employee | executePipeline() → createObject() | detectItemType | ❌ Pending Test |
Current Test Verification
| Test Item | Result |
|---|---|
| Server Running (port 3006) | ✅ PID 23324 |
| SCSAI Connection (ai-inspector/itemtypes) | ✅ Returns Real ItemType Data |
| Schema API (/api/aml/unified/schema/Product) | ✅ Returns Field Definitions |
| Type Template (/api/sciot/type-template/Product) | ✅ Returns Property + Relationship Definitions |
| Dual Library Duplicate Check (/api/private-library/objects) | ✅ Returns Private Library Data |
| Frontend SCSAI-api Proxy (/SCSAI-api/ApplyItem) | ✅ Returns Real SCSAI Part Data ("Clamp") |
| Sequence API (/api/sciot/apply-item) | ❌ Route Does Not Exist (tocConfigRouter Not Registered) |
4. Existing Issues
P0 — "Type Does Not Exist → Create Type" Logic Completely Missing
detectItemType() (capability-pipeline.js L114-138) defaults to returning Part when type is not found, with no logic for "Create ItemType First".
object-modeler.defineObject (L44-89) exists and can define new object classes via LLM, but:
- There is no creation entry point that calls it.
- applyDefinition (L95-168) only writes to the local sciot_import.db and does not create an SCSAI ItemType.
- The intent recognition chain does not have a branch for "itemType does not exist → defineObject → applyDefinition → create ItemType → then create object".
P0 — Four entry points, three sets of execution logic.
| Implementation | Relationship Handling | Sequence | AI Retry | Dual-DB Deduplication | Lines |
|---|---|---|---|---|---|
| useCapabilityCreate.create() | Pre-create → Reference | ✅ getNextValue+fallback | ✅ Up to 3 times | ✅ Exact+Fuzzy+Standard Library | 2045 lines |
| unified-create.handleCreate() | Pre-create → Reference | ⚠️ resolveSequences simplified version | ❌ | ❌ | 250 lines |
| capability-pipeline.createObject() | Simple sendAML | ❌ | ❌ | ❌ | 110 lines |
P1 — Backend createObject lacks multiple capabilities.
createObject (capability-pipeline.js L490-600) vs. useCapabilityCreate.create():
- No AI error correction and retry (LLM analyzes errors and corrects).
- No dual-database deduplication.
- No automatic Sequence numbering.
- Simple relationship handling (only calls sendAML, does not pre-create child objects).
P2 — Intent recognition keyword mapping is too shallow.
TYPE_CHINESE_MAP has only 12 mappings; defaults to Part if not found.
V. Fix Plan
Target Architecture
用户输入 → 意图识别 → 类型存在?→ 是 → useCapabilityCreate.create()
→ 否 → ObjectModeler.defineObject → applyDefinition → CreateSCSAI ItemType → useCapabilityCreate.create()
最小改动(不改 useCapabilityCreate.create())
- capability-pipeline.identifyIntent — 检测到类型不存在时调用
ObjectModeler - object-modeler.applyDefinition — 加 SCSAI ItemType Create
- AiCapabilityBar — 支持 itemType="auto" 先意图识别再创建
- 小程序和Digital Staff — 最终都走
useCapabilityCreate.create()基核
六、测试结论
useCapabilityCreate.create() 依赖的 5 个后端 API 中 4 个已验证正常。前端 SCSAI-api 代理工作正常,SCSAI 连接正常。但无法直接在命令行测试前端 composable——需要浏览器环境。后端 capability-pipeline.createObject() 需要补全多项能力才能对标前端基核。
BossAgents