script_engine/skill/SKILL.md

1.8 KiB
Raw Blame History

name description
script_engine 逻辑编程(脚本/规则引擎)模块——脚本表 CRUD + execute_script/validate_script 接口,通过 load_script_engine() 挂载。脚本类型 0=Python / 1=JavaScript / 2=规则表达式。

script_engine 模块

脚本/规则引擎:脚本表(scriptCRUD + 执行/校验接口。独立模块,无业务依赖。

数据模型

  • scriptid(str32 PK)、script_name(str100 not null)、script_type(str32 default '0')、content(text not null)、description(str255)、status(str32 default '1')、created_atupdated_at
  • 索引:idx_script_nameidx_script_type
  • 编码:script_type → appcodes_kv parentid='script_type'status → appcodes_kv parentid='script_status'

关键接口ServerEnv 注册函数,.dspy 直接调用)

  • create_script / update_script / delete_script / get_script / list_scripts
  • execute_scriptid 或 content+script_type校验后执行
  • validate_script_api(仅校验,不落库不执行)
  • 复数别名 create_scripts/update_scripts/delete_scripts 与单数同实现CRUD 框架约定)

错误结构与分页

  • 统一 {code, message, field, detail}code=0 成功
  • 分页 {list, total}list_scripts 返回 data.list / data.total

陷阱

  • 取库名用 ServerEnv().get_module_dbname('script_engine'),禁止硬编码 DBNAME
  • 非法输入(空名/超长/非法类型/语法错误/受限语法/危险调用100% 拦截,不落库不执行
  • Python 执行受限命名空间:仅内置白名单函数,禁 import/类/λ/async/await/对象方法调用
  • .dspy 无 import/print/uuid/f-string显式 returnhelper 在 init.py
  • init/data.json 为 Format B appcodesparentid + items幂等落库

依赖

  • 无业务依赖;依赖基础包 sqlor / ahserver / appPublic