script_engine/README.md

25 lines
963 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# script_engine 模块
逻辑编程(脚本/规则引擎)模块:管理逻辑脚本/规则表 `script_engine`,提供脚本执行与语法校验接口。
## 功能
- `script_engine` 表 CRUD脚本名称、编码、所属世界/场景/绑定实体、脚本类型、触发事件、脚本内容、状态。
- `api/execute_script.dspy`:按 `script_type` 选择执行器执行脚本内容,返回 `{success, result}`
- `api/validate_script.dspy`:按 `script_type` 做语法/格式校验,返回 `{valid, message}`
## 数据表
- `script_engine`(逻辑脚本表),脚本内容 `content` 使用 `text` 字段。
## 脚本类型appcodes script_type
- `0` = Python 脚本(受限命名空间执行,通过 `result` 变量返回结果)
- `1` = 规则(JSON)(解析 JSON 作为结果)
- `2` = 表达式eval 求值)
## 挂载
宿主应用入口 `init()` 中调用 `load_script_engine()`
## 安装
```bash
pip install .
```