-
Notifications
You must be signed in to change notification settings - Fork 0
node catalog schema
TextFlow 的 workflow 节点 catalog 由 Python 后端驱动。内置节点和插件节点都通过同一套 definition 进入 registry,再序列化给桌面端。
节点的唯一真相源是:
services/python-engine/app/workflow/nodes/*.py
plugins/nodes/*.py
前端只保留通用画布、拖拽、连线、动态属性面板、slot 宿主和安全降级逻辑。不要在前端新增内置节点清单、节点尺寸、默认位置、默认配置或按节点类型分支的属性编辑器。
每个节点 definition 至少包含:
{
"type": "save_xlsx",
"title": "保存 XLSX",
"category": "output",
"description": "把上游表格结果整理成 Excel 文件。",
"hidden_from_toolbox": False,
"singleton": False,
"inputs": [
{"port_id": "table_in", "port_type": "AnyTable", "label": "表格输入", "allow_multiple": True}
],
"outputs": [
{"port_id": "artifact", "port_type": "ExportArtifact", "label": "导出产物", "artifact_kind": "export"}
],
"params": [
{"param_id": "file_prefix", "label": "文件名前缀", "kind": "string", "default_value": "tables"}
],
"runtime": {
"step_id": "export",
"executor": "export.save_xlsx",
"cacheable": False,
"previewable": True,
"output_node": True,
"parallel_safe": True,
},
"graph": {
"size": {"w": 280, "h": 210},
"default_position": {"x": 5340, "y": 360},
"toolbox_order": 420,
"starter_roles": ["table_export_sink"],
},
"ui": {
"schema_version": "1.0",
"summary_template": "XLSX · {file_prefix}",
"layout": [
{"widget": "text", "config_key": "file_prefix", "label": "文件名前缀"}
],
},
}params[*].default_value 会生成新节点的默认 config。graph 驱动画布尺寸、默认位置和工具箱排序。runtime.output_node 驱动前端和后端的 sink 判断。输出口上的 result_bundle_key、png_chart_ids、artifact_kind 会参与结果绑定、端口兼容和 artifact 写入。
ui.layout 只允许下面这些 widget:
texttextareanumberswitchselectmulti_textcondition_rowskey_value_rowsgrouprowhelpslot
条件显示使用 JSON DSL,不允许字符串 eval:
{"field": "mode", "op": "eq", "value": "filtered_subset"}支持的 op 是 eq、neq、in、not_in、truthy、falsy。
slot 只声明 component_id,不下发 JSX、HTML、CSS 或脚本。前端只渲染白名单组件,未知 slot 显示安全提示。
当前白名单:
corpus_scope_selectordictionary_binding_selectordictionary_table_selectoroverlay_rule_gridmetadata_condition_buildernamed_split_editorresult_table_selectorreview_task_selectorthreshold_gate_editor
插件文件放在 plugins/nodes 或 TEXTFLOW_NODE_PLUGIN_DIR 指向的目录:
def _execute(_context, _node, _inputs):
return {"demo_table": [{"term": "plugin"}]}
def register_nodes(builder):
builder.register_node(
{
"type": "demo_plugin_node",
"title": "Demo Plugin Node",
"category": "analysis",
"description": "Plugin node with dynamic UI.",
"inputs": [],
"outputs": [{"port_id": "demo_table", "port_type": "AnyTable", "label": "Demo Table"}],
"params": [
{"param_id": "limit", "label": "Limit", "kind": "number", "default_value": 10}
],
"runtime": {
"step_id": "analysis",
"executor": "plugin.demo",
"cacheable": False,
"previewable": True,
"output_node": False,
},
"graph": {
"size": {"w": 320, "h": 220},
"default_position": {"x": 120, "y": 220},
"toolbox_order": 900,
},
"ui": {
"schema_version": "1.0",
"layout": [{"widget": "number", "config_key": "limit", "label": "Limit"}],
},
},
executor=_execute,
)registry 会校验插件 definition。无效插件节点会被跳过,错误进入 plugin_errors,不会影响内置节点或其他插件节点。
常用验证命令:
npm run test:engine:fast
npm run test --workspace apps/desktop -- workflowNodeCatalog.test.ts DynamicNodeEditor.test.tsx pluginNodeCatalog.test.tsx workflow.test.ts修改默认样例、模板图、导出或 bootstrap 相关路径时,再运行:
npm run test:engine:full这套文档只描述当前仓库已经实现或已经被代码验证的能力,不再把历史方案、迁移草图和未来目标混写成“当前规格”。
- 当前现状 当前仓库能跑到什么程度、哪些部分稳定、哪些部分还在打磨。
- 产品范围与完成度 以 V1 目标为基线,逐项对照当前完成情况。
- 架构说明 说明桌面端、Python sidecar、项目存储、词表、运行记录和打包结构。
- 工作流与运行时 说明 workflow-only 持久化、native DAG、缓存和插件节点的当前关系。
- 开发与构建说明 开发环境、脚本、测试、打包、压测入口。
- 示例项目说明 首次启动从安装包内置模板恢复的 3 个官方 revised-flow 样例及用途。
- 内置场景样例 官方样例矩阵、seed 授权、存储形态和使用提醒。
- 大规模压测记录 当前仓库保留的万条级工作流压测数据与性能边界。
- 技术全景与架构设计 当前技术栈、前后端边界、节点 catalog、测试覆盖和已知差距的全景说明。
- 节点 Catalog Schema 后端驱动节点 definition、UI schema、slot 白名单和插件示例。
- ADR 架构决策记录,说明重要迁移和边界选择的背景。
- 插件节点说明 本地纯 Python 节点插件的加载方式、注册接口和当前运行边界。
-
docs/根目录放当前有效文档。 -
docs/archive/放历史方案、旧规格和旧计划,仅供追溯,不再作为当前实现依据。 -
plugins/nodes/README.md放插件节点接口说明,因为它直接对应插件目录本身。
旧版 PRD、线性流程规格、V2 迁移规格、画布布局草图和实施计划已移入归档区: