Three-tier system design for rules, templates, and prompts

Documentation for the Rule/Template/Prompt Three-tier System Design

1. Architecture Overview

The Rule, Template, and Prompt employ a unified three-tier storage system:

SCSAI 服务端 (源端)
    ↕  同步 (template-sync-service: SCSAI 元数据 → rule_engine.db)
    ↕  导入 (phase1-import: SQLite → SCSAI ItemType)
本地标准库 (sciot_import.db)
    ↕  同步 (sync-service: 标准库 → 用户库)
用户私有库 (user_<userId>.db)

三层定位:

  • SCSAI Server: The authoritative data source. All standard rules/templates/prompts are persisted in five custom ItemTypes within SCSAI.
  • Local Standard Library (sciot_import.db): A local SQLite cache of SCSAI data for offline queries and LLM calls.
  • User Private Library (user_.db): A personalized copy for each user, allowing overriding of standard data, creation of custom entries, and submission for review.

2. SCSAI Server — Involved ItemTypes

2.1 BossAgent_Rule (Rule)

| SCSAI Attribute | Label | Type | Description |

|-----------|------|------|------|

| item_number | Number | string(32) | Rule ID, corresponding to the 'id' in SQLite |

| name | Rule Name | string(256) | Rule name |

| description | Rule Description | text | Detailed rule explanation |

| bossagent_scope | Scope | list | validate/create_pre/identify/get/add/edit/delete/generate/inspect/optimize/compare |

| bossagent_item_type | Associated Object Class | string(128) | Applicable SCSAI ItemType name |

| bossagent_severity | Severity Level | list | error/warning/info/hint |

| bossagent_category | Rule Category | list | Rule functional classification |

| bossagent_priority | Priority | string(10) | 0=P0 ~ 3=P3 |

| bossagent_condition_script | Condition Script | text | Trigger condition (JS script or configuration JSON) |

| bossagent_action_type | Action Type | list | auto_fix/suggest/block/warn/reference/generate |

| bossagent_action_config | Action Configuration | text | Action parameter JSON |

| bossagent_is_active | Enabled | boolean | 1=Enabled, 0=Disabled |

| bossagent_is_builtin | Built-in | boolean | 1=System built-in, 0=User-created |

| bossagent_source | Source | list | manual/aml_import/SCSAI_sync/builtin |

| bossagent_version | Version | integer | Version number |

| bossagent_tags | Tags | string(512) | Comma-separated tags |

| bossagent_generated_aml | Generated AML | text | AML content generated by rules |

| bossagent_natural_language | Natural Language Description | text | Natural language rule description |

Creation method: phase0-create-itemtypes.js:57-117

Import method: phase1-import-to-SCSAI.js — Import 2367 records from sciot_rules_v2 table

2.2 BossAgent_Template (Template)

| SCSAI Attribute | Label | Type | Description |

|-----------|------|------|------|

| item_number | Number | string(32) | Template ID |

| name | Template Name | string(128) | Corresponds to item_type_name |

| bossagent_label | Display Name | string(128) | Chinese/English label |

| bossagent_template_type | Template Type | list | object/relationship/manual |

| bossagent_aml_content | AML Template | text | XML for creating ItemType AML template |

| bossagent_variables | Variable Definitions | text | {"llm_fields":[...], "auto_fields":[...]} |

| bossagent_required_fields | Required Fields | text | Required fields JSON array |

| bossagent_optional_fields | Optional Fields | text | Optional fields JSON array |

| bossagent_relationship_types | Relationship Types | text | Relationship types JSON array |

| bossagent_lifecycle | Lifecycle | string(128) | Default lifecycle name |

| bossagent_form | Default Form | string(128) | Default form name |

| bossagent_generation_rules | Generation Rules | text | {"child_objects":[], "nested_depth":0, "relationship_config":{}} |

| bossagent_version | Version Number | integer | Version number |

| bossagent_is_builtin | Is Built-in | boolean | Whether it is system built-in |

Creation method: phase0-create-itemtypes.js:119-150

Import method: phase1-import-to-SCSAI.js — Import 1205 records from sciot_templates table

2.3 BossAgent_Prompt (Prompt)

| SCSAI Attribute | Label | Type | Description |

|-----------|------|------|------|

| item_number | Number | string(256) | Prompt ID (note length 256, not default 32) |

| name | Name | string(256) | Prompt name |

| bossagent_content | Prompt Content | text | Full prompt text (supports {{variables}}) |

| bossagent_system_prompt | System Prompt | text | System prompt content |

| bossagent_item_type | Associated Object Class | string(128) | Applicable ItemType |

| bossagent_operation | Operation Type | list | add/create_pre/edit/identify/validate/compare, etc. |

| bossagent_scope | Scope | list | create/validate/identify, etc. |

| bossagent_version | Version | integer | Version number |

| bossagent_is_builtin | Is Built-in | boolean | 1=System built-in, 0=User-created |

| bossagent_status | Status | list | active/deprecated/testing |

Creation method: phase0-create-itemtypes.js:151-159

Import method: phase1-import-prompt.js — Import 2817 records from the prompt_templates table

Note: The item_number column width must be nvarchar(256), otherwise UUID format IDs (36 characters) will be truncated and fail.

2.4 BossAgent_BizPrompt (Business Prompt)

| SCSAI Attribute | Label | Type | Description |

|-----------|------|------|------|

| item_number | Number | string(32) | Business Prompt ID |

| name | Name | string(128) | Business System Name |

| bossagent_system_id | System ID | string(128) | Business System Identifier |

| bossagent_system_prompt | System Prompt | text | The system prompt for the business system |

| bossagent_context_json | Context JSON | text | Business context configuration |

| bossagent_capabilities | Capabilities List | text | JSON array describing capabilities |

Creation method: phase0-create-itemtypes.js

Import method: phase1-import-prompt.js — import 46 records from the sciot_business_prompts table

2.5 BossAgent_RuleContribution (Rule Contribution/Review)

| SCSAI Attribute | Label | Type | Description |

|-----------|------|------|------|

| item_number | Number | string(32) | Submission ID |

| name | Name | string(128) | Submission Title |

| bossagent_submitter | Submitter | string(128) | Submitter |

| bossagent_object_type | Object Type | list | rule/template/prompt |

| bossagent_original_id | Original Standard ID | string(256) | Corresponding standard library ID |

| bossagent_content | Complete Content | text | Submitted full object JSON |

| bossagent_description | Description | text | Submission description |

| bossagent_status | Status | list | pending/approved/rejected |

| bossagent_review_comment | Review Comment | text | Review comment |

Creation method: phase0-create-itemtypes.js

Purpose: Corresponds to the local sync_submissions table, used to submit user modifications back to SCSAI for review


3. Local Standard Library — Involved SQLite files

3.1 File List

server/
├── sciot_import.db          (35.8 MB)   ← 本地标准库(完整数据源,勿覆盖)
├── data/
│   ├── sciot_import.db      (35.8 MB)   ← 标准库副本(供 sync-service 读取)
│   ├── rule_engine.db       (0.4 MB)    ← SCSAI 元数据缓存(ItemTypes/Properties 等)
│   ├── core_runtime.db        (1.6 MB)    ← 业务数据缓存
│   ├── user_libraries/
│   │   └── user_<userId>.db             ← 每用户私有库
│   └── enterprise_store.db              ← 企业私有库

3.2 sciot_import.db(标准库)— 核心表

| 表名 | 行数 | 说明 |

|------|------|------|

| sciot_rules_v2 | 2,367 | Rules master table |

| sciot_templates | 1,205 | Templates master table (one per ItemType) |

| prompt_templates | 2,817 | Prompt templates master table |

| sciot_business_prompts | 46 | Business prompts master table |

Auxiliary tables (29+):

sciot_item_types (928), sciot_properties (40,854), sciot_relationships (587),

sciot_lifecycle_maps (98), sciot_lifecycle_states (362), sciot_lists (427),

sciot_list_values (6,206), sciot_methods (2,236), sciot_method_rules (6,155),

sciot_forms (722), sciot_form_fields (3,110), sciot_business_objects (442), etc.

3.3 sciot_rules_v2 Table Structure

CREATE TABLE sciot_rules_v2 (
    id            TEXT  PRIMARY KEY,      -- 规则 ID
    name          TEXT  NOT NULL,           -- 规则名称
    description   TEXT,                     -- 规则描述
    scope         TEXT  NOT NULL,           -- 作用范围
    item_type_name TEXT,                    -- 适用 ItemType
    severity      TEXT  DEFAULT 'warning',  -- 严重级别
    priority      INTEGER DEFAULT 2,        -- 优先级 (0-3)
    condition     TEXT,                     -- 条件配置 JSON
    condition_script TEXT,                  -- 条件 JS 脚本
    action_type   TEXT,                     -- 动作类型
    action_config TEXT,                     -- 动作配置 JSON
    action_script TEXT,                     -- 自定义动作 JS
    prompt_template TEXT,                   -- 内联提示词模板
    prompt_template_id TEXT,                -- 关联 prompt_templates.id
    is_active     INTEGER DEFAULT 1,        -- 是否启用
    is_builtin    INTEGER DEFAULT 0,        -- 是否内置
    source        TEXT DEFAULT 'manual',    -- 来源
    version       INTEGER DEFAULT 1,        -- 版本号
    tags          TEXT,                     -- 标签
    category      TEXT,                     -- Category
    created_at    TEXT,                     -- 创建时间
    updated_at    TEXT                      -- 更新时间
);

3.4 sciot_templates 表结构

CREATE TABLE sciot_templates (
    id                INTEGER PRIMARY KEY AUTOINCREMENT, -- 模板 ID
    template_type     TEXT  NOT NULL DEFAULT 'object',    -- 模板类型
    item_type_name    TEXT  NOT NULL UNIQUE,              -- 目标 ItemType
    item_type_label   TEXT  DEFAULT '',                   -- 显示标签
    aml_template      TEXT  DEFAULT '',                   -- AML 模板 XML
    required_fields   TEXT  DEFAULT '[]',                 -- 必填字段
    optional_fields   TEXT  DEFAULT '[]',                 -- 可选字段
    keyed_field       TEXT  DEFAULT '',                   -- 键名字段
    relationship_types TEXT DEFAULT '[]',                  -- 关联类型
    lifecycle         TEXT  DEFAULT '',                   -- 生命周期
    form              TEXT  DEFAULT '',                   -- 默认表单
    llm_fields        TEXT  DEFAULT '[]',                 -- LLM 可生成字段
    auto_fields       TEXT  DEFAULT '[]',                 -- 系统自动填充字段
    generation_rules  TEXT  DEFAULT '{}',                 -- 生成规则 JSON
    created_at        TEXT                                -- 创建时间
);

3.5 prompt_templates 表结构

CREATE TABLE prompt_templates (
    id             TEXT  PRIMARY KEY,        -- 提示词 ID
    name           TEXT  NOT NULL,            -- 名称
    description    TEXT,                      -- 描述
    content        TEXT  NOT NULL,            -- 提示词正文
    variables      TEXT,                      -- 变量列表 JSON
    prompt_type    TEXT  DEFAULT 'creation',  -- 类型
    item_type_name TEXT,                      -- 适用 ItemType
    version        INTEGER DEFAULT 1,         -- 版本号
    status         TEXT  DEFAULT 'active',    -- 状态
    parent_id      TEXT,                      -- A/B 测试父级
    score          REAL  DEFAULT 0,           -- 质量评分
    usage_count    INTEGER DEFAULT 0,         -- 使用次数
    operation_type TEXT,                      -- 操作类型(追加列)
    system_prompt  TEXT,                      -- 系统提示词(追加列)
    scope          TEXT,                      -- 作用范围(追加列)
    is_builtin     INTEGER DEFAULT 0,         -- 是否内置(追加列)
    created_at     TEXT,                      -- 创建时间
    updated_at     TEXT                       -- 更新时间
);

3.6 sciot_business_prompts 表结构

CREATE TABLE sciot_business_prompts (
    id                   INTEGER PRIMARY KEY AUTOINCREMENT, -- ID
    system_id            TEXT  NOT NULL UNIQUE,              -- 业务系统标识
    system_name          TEXT  DEFAULT '',                   -- 系统名称
    system_prompt        TEXT  DEFAULT '',                   -- 系统提示词
    user_prompt_template TEXT  DEFAULT '',                   -- 用户提示词模板
    capabilities         TEXT  DEFAULT '[]',                 -- 能力描述 JSON
    created_at           TEXT                                -- 创建时间
);

4. 用户私有库 — 涉及的库和表

4.1 数据库位置

server/data/user_libraries/user_<userId>.db

每个用户一个独立 SQLite 文件,首次访问时自动创建。

4.2 user_rules Table

CREATE TABLE user_rules (
    id               TEXT  PRIMARY KEY,      -- 唯一 ID
    standard_id      TEXT,                    -- 对应标准库 ID(用于覆盖)
    name             TEXT  NOT NULL,          -- 规则名称
    category         TEXT  DEFAULT '',        -- Category
    item_type_name   TEXT  DEFAULT '',        -- 适用 ItemType
    description      TEXT  DEFAULT '',        -- 描述
    tags             TEXT  DEFAULT '',        -- 标签
    condition        TEXT  DEFAULT '',        -- 条件
    condition_script TEXT  DEFAULT '',        -- 条件脚本
    action_type      TEXT  DEFAULT '',        -- 动作类型
    action_config    TEXT  DEFAULT '',        -- 动作配置
    priority         INTEGER DEFAULT 0,       -- 优先级
    severity         TEXT  DEFAULT 'info',    -- 严重级别
    scope            TEXT  DEFAULT '',        -- 作用范围
    enabled          INTEGER DEFAULT 1,       -- 启用状态
    is_builtin       INTEGER DEFAULT 0,       -- 是否内置
    source           TEXT  DEFAULT 'custom',  -- 来源 (custom/standard_copy/modified)
    origin_version   INTEGER DEFAULT 0,       -- 原始版本号
    current_version  INTEGER DEFAULT 1,       -- 当前版本号
    synced_to_server INTEGER DEFAULT 0,       -- 已提交到审核
    sync_status      TEXT  DEFAULT 'none',    -- 同步状态
    created_at       TEXT,                    -- 创建时间
    updated_at       TEXT,                    -- 更新时间
    local_modified_at TEXT                    -- 本地修改时间
);

4.3 user_templates 表

CREATE TABLE user_templates (
    id                 TEXT  PRIMARY KEY,     -- 唯一 ID
    standard_id        TEXT,                   -- 标准 ID
    name               TEXT  NOT NULL,         -- 模板名称
    type               TEXT  DEFAULT '',       -- 模板类型
    item_type_name     TEXT  DEFAULT '',       -- 适用 ItemType
    item_type_label    TEXT  DEFAULT '',       -- 显示标签
    description        TEXT  DEFAULT '',       -- 描述
    tags               TEXT  DEFAULT '',       -- 标签
    content            TEXT  DEFAULT '',       -- 内容
    variables          TEXT  DEFAULT '[]',     -- 变量定义
    category           TEXT  DEFAULT '',       -- Category
    aml_template       TEXT  DEFAULT '',       -- AML 模板
    required_fields    TEXT  DEFAULT '[]',     -- 必填字段
    optional_fields    TEXT  DEFAULT '[]',     -- 可选字段
    keyed_field        TEXT  DEFAULT '',       -- 键名字段
    relationship_types TEXT  DEFAULT '[]',     -- 关联类型
    lifecycle          TEXT  DEFAULT '',       -- 生命周期
    form               TEXT  DEFAULT '',       -- 表单
    llm_fields         TEXT  DEFAULT '[]',     -- LLM 字段
    auto_fields        TEXT  DEFAULT '[]',     -- 自动字段
    generation_rules   TEXT  DEFAULT '{}',     -- 生成规则
    source             TEXT  DEFAULT 'custom', -- 来源
    origin_version     INTEGER DEFAULT 0,      -- 原始版本
    current_version    INTEGER DEFAULT 1,      -- 当前版本
    synced_to_server   INTEGER DEFAULT 0,      -- 已提交
    sync_status        TEXT  DEFAULT 'none',   -- 同步状态
    created_at         TEXT,                   -- 创建时间
    updated_at         TEXT,                   -- 更新时间
    local_modified_at  TEXT                    -- 本地修改时间
);

4.4 user_prompts 表

CREATE TABLE user_prompts (
    id               TEXT  PRIMARY KEY,       -- 唯一 ID
    standard_id      TEXT,                     -- 标准 ID
    name             TEXT  NOT NULL,           -- 提示词名称
    type             TEXT  DEFAULT '',         -- 类型
    item_type_name   TEXT  DEFAULT '',         -- 适用 ItemType
    description      TEXT  DEFAULT '',         -- 描述
    content          TEXT  DEFAULT '',         -- 提示词正文
    system_prompt    TEXT  DEFAULT '',         -- 系统提示词
    operation_type   TEXT  DEFAULT '',         -- 操作类型
    variables        TEXT  DEFAULT '[]',       -- 变量列表
    temperature      REAL  DEFAULT 0.3,       -- LLM 温度
    scope            TEXT  DEFAULT 'create',   -- 作用范围
    version          INTEGER DEFAULT 1,        -- 版本号
    status           TEXT  DEFAULT 'active',   -- 状态
    is_builtin       INTEGER DEFAULT 0,        -- 是否内置
    source           TEXT  DEFAULT 'custom',   -- 来源
    origin_version   INTEGER DEFAULT 0,        -- 原始版本
    current_version  INTEGER DEFAULT 1,        -- 当前版本
    synced_to_server INTEGER DEFAULT 0,        -- 已提交
    sync_status      TEXT  DEFAULT 'none',     -- 同步状态
    created_at       TEXT,                     -- 创建时间
    updated_at       TEXT,                     -- 更新时间
    local_modified_at TEXT                     -- 本地修改时间
);

4.5 辅助表

sync_submissions — 用户提交审核记录

CREATE TABLE sync_submissions (
    id             TEXT  PRIMARY KEY,
    user_id        TEXT  DEFAULT 'default',
    object_type    TEXT  NOT NULL,         -- rule/template/prompt
    object_id      TEXT  NOT NULL,
    original_id    TEXT,                    -- 对应的 standard_id
    content        TEXT  DEFAULT '{}',      -- 完整对象 JSON
    description    TEXT  DEFAULT '',
    status         TEXT  DEFAULT 'pending', -- pending/approved/rejected
    review_comment TEXT  DEFAULT '',
    submitted_at   TEXT,
    reviewed_at    TEXT
);

sync_state — 同步状态跟踪

CREATE TABLE sync_state (
    user_id          TEXT  PRIMARY KEY,
    last_sync_at     TEXT,
    standard_version TEXT  DEFAULT '0',
    rules_count      INTEGER DEFAULT 0,
    templates_count  INTEGER DEFAULT 0,
    prompts_count    INTEGER DEFAULT 0
);

5. 同步机制详解

5.1 数据流向总览

┌──────────────────────┐     phase1-import-to-SCSAI.js
│  SCSAI 服务端          │  ◄──────────────────────────────
│  BossAgent_Rule      │         AML (ApplyItem)
│  BossAgent_Template  │
│  BossAgent_Prompt    │
│  BossAgent_BizPrompt │
└──────────┬───────────┘
           │
           │  template-sync-service.js (SCSAI 元数据同步)
           │  GET /api/private-library/sync/:type (企业库同步)
           ▼
┌──────────────────────┐
│  本地标准库            │  sciot_import.db (35.8MB)
│  sciot_import.db      │  含: sciot_rules_v2, sciot_templates,
│                       │       prompt_templates, sciot_business_prompts
└──────────┬───────────┘
           │
           │  sync-service.js (syncStandardToUser)
           │  POST /api/user-library/sync/standard
           ▼
┌──────────────────────┐
│  用户私有库            │  server/data/user_libraries/user_<id>.db
│  user_<userId>.db    │  含: user_rules, user_templates, user_prompts
│                       │       sync_submissions, sync_state
└──────────────────────┘

5.2 三条同步路径

#### 路径 A:SQLite → SCSAI(Phase 1 导入)

Execution Timing: One-time batch import

Scripts: scripts/phase1-import-to-SCSAI.js, scripts/phase1-import-prompt.js

Method: Invoke SCSAI ApplyItem AML one by one

Mapping Relationships:

| SQLite Table | SCSAI ItemType | Import Count |

|-----------|---------------|----------|

| sciot_rules_v2 | BossAgent_Rule | 2,367 |

| sciot_templates | BossAgent_Template | 1,205 |

| prompt_templates | BossAgent_Prompt | 2,817 |

| sciot_business_prompts | BossAgent_BizPrompt | 46 |

Key implementation details:

  • Pagination read (SELECT * FROM ... ORDER BY id), commit in batches according to BATCH_SIZE (50)
  • Because the default 30s timeout in SCSAI is insufficient for a batch of 50 items, changed to per-item submission with a 20ms interval between each
  • The item_number column in SCSAI SQL defaults to nvarchar(32), but UUID format IDs (36 characters) would be truncated → need to change to nvarchar(256)
  • Uses the ApplyItem SOAP call (/server/agentServer.aspx), not Service.asmx
  • item_number is not unique in SCSAI; importing the same ID repeatedly creates duplicate rows

#### Path B: SCSAI Metadata → rule_engine.db (Incremental Sync)

Execution timing: On server startup + on-demand calls

Script: server/services/template-sync-service.js

Method: SCSAI OData query → Write to SQLite

Sync content:

  • ItemType list (name, label, config_id, etc.)
  • Property definitions (grouped by source_id)
  • Relationship types (by source_id)
  • Lifecycle & Status
  • List values
  • Templates

Note: This path synchronizes SCSAI metadata (ItemTypes/Properties structure), not the actual rule/template/prompt data imported in Phase 1. The main body of rule/template/prompt data is only imported in Path A.

#### Path C: Standard Library → User Private Library (sync-service)

Execution Timing: On-demand (POST /api/user-library/sync/standard)

Code: server/services/sync-service.js → syncStandardToUser(userId, options)

Method:

function syncStandardToUser(userId, options) {
    // 1. 读取标准库 sciot_import.db 中的全部数据
    //    - loadStandardRules()   → 2367 条
    //    - loadStandardTemplates() → 1205 条
    //    - loadStandardPrompts() → 2863 条 (2817+46)
    
    // 2. 对每条数据,检查用户库中是否已有 standard_id
    //    - 已有: 若 force=true 且来源为 standard_copy,则 UPDATE
    //    - 没有: INSERT,source='standard_copy'
    
    // 3. 更新 sync_state 表
}

差异化参数:

  • force: true — Force update existing standard copies (does not overwrite user-modified ones)
  • type: 'rules'|'templates'|'prompts' — Only sync the specified type

5.3 Override/Merge Mechanism

The user private library supports two override modes:

Standard Override (Override): If an item in the user library has a standard_id, it automatically overrides the standard item with the same standard_id

  • All getEffective*() functions first collect user overrides, then merge standard data
  • Rules are sorted in descending order of priority

Custom Items (Custom): Items in the user library without a standard_id

  • Appended to the end of the effective list
  • Source marked as 'custom' or 'modified'

5.4 Submission Review Process

用户修改/Create → POST /api/user-library/submit
                       │
                       ▼
                sync_submissions 表
                (status='pending')
                       │
         ┌─────────────┴─────────────┐
         ▼                           ▼
  POST .../approve           POST .../reject
  (status→'approved')        (status→'rejected')
         │                           │
         ▼                           ▼
  sync_status='approved'     sync_status='rejected'

当前限制: approve/reject 仅更新本地状态标记。实际回写到 sciot_import.db 或提交到 SCSAI BossAgent_RuleContribution 的功能尚未实现。


6. Main Code Files Involved

| File | Role | Function |

|------|------|------|

| scripts/phase0-create-itemtypes.js | Infrastructure | Creates 5 BossAgent ItemTypes along with their properties, lists, and permissions |

scripts/phase1-import-to-SCSAI.js | Data Import | sciot_rules_v2 → BossAgent_Rule, sciot_templates → BossAgent_Template

scripts/phase1-import-prompt.js | Data Import | prompt_templates → BossAgent_Prompt, sciot_business_prompts → BossAgent_BizPrompt

scripts/_clean_rules.js | Data Cleansing | Remove duplicate rules

scripts/_fix_columns.js | Data Cleansing | Fix ITEM_NUMBER column width

server/services/sync-service.js | Synchronization Service | Standard Library → User Library synchronization (includes full field mapping)

server/services/user-library.js | User Library Service | User library CRUD, overwrite/merge, submit for review

server/routes/user-library-routes.js | REST API | 21 user library endpoints (search/CRUD/sync/review)

| server/routes/private-library.js | REST API | 9 Endpoints for Enterprise Private Library |

| server/routes/unified-create.js | Creation Service | 7-Step Unified Creation Process |

| server/services/template-sync-service.js | Metadata Synchronization | SCSAI ItemType Structure → rule_engine.db |

| server/sqlite-compat.js | Infrastructure | sql.js Compatibility Layer (Replaces better-sqlite3) |


7. REST API Endpoint Summary

7.1 User Private Library /api/user-library/*

MethodPathDescription
GET/statsUser Library Statistics (Counts by Source Category)
GET/rules[?filter]Rule List (Supports filtering by category/source/item_type/scope/severity/search/enabled)
GET/rules/:idSingle Rule
POST/rulesCreate New Rule
PUT/rules/:idUpdate Rule
DELETE/rules/:idDelete Rule
GET/templates[?filter]Template List
GET/templates/:idSingle Template
POST/templatesCreate Template
PUT/templates/:idUpdate Template
DELETE/templates/:idDelete Template
GET/prompts[?filter]Prompt List
GET/prompts/:idSingle Prompt
POST/promptsCreate Prompt
PUT/prompts/:idUpdate Prompt
DELETE/prompts/:idDelete Prompt
POST/sync/standardTrigger Standard Library Sync
POST/submitSubmit for Review
GET/submissions/pendingPending Review List
POST/submissions/approveApprove Submission
POST/submissions/rejectReject Submission
GET/search?q=&type=Unified Search (Across Rules/Templates/Prompts)

7.2 Enterprise Private Library /api/private-library/*

MethodPathDescription
GET/statsEnterprise library statistics
GET/typesObject type list
GET/search?q=Search objects
GET/objects[?type=&page=&size=]Paginated object list
GET/objects/:idSingle object details
POST/objectsCreate/Save object
PUT/objects/:idUpdate object
DELETE/objects/:idDelete object
POST/sync/:typeSync from SCSAI

7.3 Unified Creation /api/unified/*

MethodPathDescription
GET/type-template/:nameGet type template
GET/item-typesList of creatable ItemTypes
POST/create7-step core creation
POST/generate-propsLLM property generation
POST/apply-amlLightweight AML forwarding

8. Frequently Asked Questions and Notes

  1. item_number column width: SCSAI SQL table defaults to nvarchar(32), but BossAgent_Prompt IDs contain UUIDs (36 characters). Change to nvarchar(256) to avoid import failures.
  1. item_number not unique: SCSAI does not enforce uniqueness for item_number; importing the same ID repeatedly will create duplicate rows.
  1. Batch AML timeout: The default 30-second timeout in SCSAI is insufficient for batches of 50 items. It is recommended to submit items individually (per-item) or increase the timeout to 120 seconds.
  1. sql.js compatibility layer bug: The Statement.all() method in sqlite-compat.js may return 0 rows when using explicit column names combined with a WHERE clause. It is recommended to use SELECT * and filter the results in JavaScript.
  1. User library routes not mounted: The APIs in user-library-routes.js have been implemented but are not registered in server.js.
  1. Review write-back not implemented: approveSubmission and rejectSubmission only update the local state and do not write back to the standard library or SCSAI.
  1. Two sciot_import.db files: server/sciot_import.db (35.8 MB, complete data) and server/data/sciot_import.db (original 0.4 MB, incomplete). sync-service.js now automatically detects and prioritizes the use of the complete version.
← 返回案例列表

Try 左帮右臂 Industrial Agent — your digital workforce

Available as a WeChat mini program, web app (ylxt.chat) and desktop client. Start from whichever fits your workflow.

🌐 Web App 💻 Desktop Download 📞 Call 189-8606-6876
WeChat mini program QR
Scan for the WeChat mini program
Share:
🤖 Try Now →
🤖
🎁