会议模式:引脚端点、类型隔离、值节点、开始事件

用户四条反馈,都在界面上落实了。

【1. 每个输入输出各有自己的端点,不挤到一点】
节点改成真正的蓝图长相:彩色标题栏 + **每条引脚各占一行、各有自己的端点**。
  - 行高从 18dp 加到 21dp,端点之间拉开
  - 左列输入(exec 在上、data 在下)、右列输出,标签紧贴引脚那一侧
  - 连线从**引脚的实际位置**出发/接入,不是从节点中心

【2. 执行端点只能连执行端点,不同类型不能连】
连接时按引脚种类匹配(exec↔exec、data↔data),种类不同直接不接。
而且**正在连线时,接不上的引脚会变淡** —— 蓝图里拖到不兼容的引脚会直接报错,
这里用变淡表示"这个接不了"。光靠"点了没反应"用户会以为程序坏了。

界面上的区分也做足了:
  - exec 执行引脚:**白色三角**(蓝图那种)
  - data 数据引脚:彩色圆点
  - exec 线:深色;data 线:淡蓝贝塞尔
  形状 + 颜色双重区分。只靠颜色的话,色弱用户或者图缩小之后就分不清了,
  而这两种线接错等于整套语义垮掉。

【3. 值节点】
新增 `值`(value)节点:**纯节点**,只有一个数据输出,谁需要谁拉它的值。
可以直接连到智能体的数据输入 —— 实测:
    开始事件(exec+data) + 值节点(data) → 智能体
    最终输出 = '收到[用户的话\n\n系统提示用的补充]'
两个数据源都进了智能体。

★ 和"读变量"归为同一类**纯节点**(蓝图里的 Get / 常量):
  没有 exec 引脚、不在执行链上。取值的地方统一走 _pure_value(),
  按节点类型现算(读变量取变量当前值、值节点取它写死的文本),
  而不是去 outputs 里找 —— 纯节点可能压根没被执行链走到过。

【4. 开始事件】
`start` 从「初始输入」正式改名为「开始事件」(从这开始),
引脚是 exec 出 + 数据出,是整张图的起点。

【顺带】
- while 节点的两条 exec 出线(循环体 ▶ / 结束 ▶)在界面上有了,
  节点配色也区分开了:开始事件绿、判断橙、最终输出紫、变量青、值淡紫、循环红
- 节点配色和标题的兜底表都补齐了新类型
- 默认布局的节点间距拉开(x 12 → 180 → 348):之前挨太近,
  exec 引脚三角、短连线、对面引脚挤在一起,看着像个蝴蝶结
- exec 线不再画箭头:exec 引脚本身就是三角,再画一个会叠一起;
  数据线保留箭头并往回收 4px

【验证】
- 引擎回归 40/40,Node 与 Python **16/16 逐用例一致**
- 会议 HTTP 端到端 13/13 ×2
- 值节点端到端实测(见上)
- 模拟器截图确认:开始事件/值/智能体/读变量/while/写变量的引脚与连线都正确,
  exec 深色线、data 淡蓝曲线一眼可分

【还没做的,如实说明】
- **Node 侧引擎的 while 节点还没写**(Python 有了)。exec/data 重构两边都做了,
  对拍一致;while 目前是 Python 独有。
- 值节点的验收用例还没加进 verify-meeting.mjs(手工验过,没进回归)。
- while 的界面上能看能连,但配置面板里还没有它的说明文字。
This commit is contained in:
l
2026-10-10 15:34:24 +08:00
parent 9fcef53c5f
commit a7cc069f1e
5 changed files with 124 additions and 66 deletions

View File

@@ -42,7 +42,7 @@ import paths
_lock = threading.Lock()
NODE_TYPES = ('start', 'agent', 'judge', 'end', 'var', 'readvar', 'while')
NODE_TYPES = ('start', 'agent', 'judge', 'end', 'var', 'readvar', 'while', 'value')
# 判断节点支持的条件。**结构化而不是表达式**,理由见文件头。
JUDGE_KINDS = (
@@ -420,7 +420,7 @@ def _sanitize_edges(edges: list, nodes: list) -> list:
# 存完继续往下走),所以这里只挡数据线
if str(e.get('kind') or '') == DATA:
continue
if by_id[dst]['type'] in ('start', 'readvar'):
# 纯节点(读变量 / 值)没有输入端口,不该被连进来\n if by_id[dst]['type'] in ('start', 'readvar', 'value'):
continue
kind = _kind(e)
@@ -494,6 +494,31 @@ def _data_out(edges: list, node_id: str) -> list:
return [e for e in _outgoing(edges, node_id) if _kind(e) == DATA]
# --------------------------------------------------------------------------- #
# 纯节点(蓝图里的 Get / 常量)
# --------------------------------------------------------------------------- #
#
# 纯节点**没有 exec 引脚**,不在执行链上:它的值是被需要的节点在运行时
# **拉取**的。所以它们的值不能从 outputs 里找(它们可能根本没被执行链走到过),
# 得在这里按节点类型现算。
#
# 现在有两种:
# readvar 读变量 —— 谁需要谁拿变量的当前值
# value 值/常量 —— 谁需要谁拿它自己写死的那个值
#
def _pure_value(node_id: str, by_id: dict, outputs: dict, variables: dict):
"""取一个上游节点的值。纯节点现算,普通节点取它执行时的输出。"""
node = by_id.get(node_id)
if not node:
return outputs.get(node_id, '')
kind = node['type']
if kind == 'readvar':
return variables.get(str(node.get('varName') or '').strip(), '')
if kind == 'value':
return node.get('text') or ''
return outputs.get(node_id, '')
def _reachable_exec(edges: list, seeds: list, stop: str = None) -> set:
"""
从 seeds 出发、只沿 **exec** 边走,能走到的所有节点。
@@ -522,12 +547,7 @@ def _collect_data_only(node_id: str, edges: list, outputs: dict, variables: dict
"""
parts = []
for e in _data_in(edges, node_id):
src = e.get('from')
node = by_id.get(src)
if node and node['type'] == 'readvar':
value = variables.get(str(node.get('varName') or '').strip(), '')
else:
value = outputs.get(src, '')
value = _pure_value(e.get('from'), by_id, outputs, variables)
if value:
parts.append(str(value))
return '\n\n'.join(parts).strip()
@@ -547,13 +567,8 @@ def _collect_input(node_id: str, edges: list, outputs: dict, variables: dict,
"""
parts = []
for e in _data_in(edges, node_id):
src = e.get('from')
node = by_id.get(src)
if node and node['type'] == 'readvar':
# 纯节点:现取现值
value = variables.get(str(node.get('varName') or '').strip(), '')
else:
value = outputs.get(src, '')
# 纯节点(读变量 / 值)现取现值,普通节点取它执行时的输出
value = _pure_value(e.get('from'), by_id, outputs, variables)
if value:
parts.append(str(value))
if parts:
@@ -629,7 +644,7 @@ def run_meeting(*, meeting: dict, settings: dict, user_input: str,
starts = [n for n in nodes if n['type'] == 'start']
if not starts:
starts = [n for n in nodes
if n['type'] != 'readvar' and not _exec_in(edges, n['id'])]
if n['type'] not in ('readvar', 'value') and not _exec_in(edges, n['id'])]
if not starts:
emit({'type': 'meeting_done', 'output': '', 'error': '这张图没有入口节点'})
return {'output': '', 'error': '这张图没有入口节点'}