会议模式:类型化引脚(exec 不传数据)+ 值节点 + 连线可删除

用户四条:端点分 bool/str/num/exec、exec 不传递数据、值可以传 str/bool/num、
连线要能删除。

【1. 类型化引脚】
引脚种类从"exec / data"细化成 **exec / str / bool / num**,和蓝图一样强类型:
连错类型直接接不上。

   节点        数据入        数据出
   start       ——            str
   value       ——            节点上选(str / bool / num)
   agent       str           str
   judge       str           bool(判断结果可以直接喂给 while)
   var         str           ——(存进去的值不从它往下传)
   readvar     ——            str
   while       bool          ——
   end         str           ——

保存时按引脚类型校验,不匹配的边**直接丢掉**。

【2. exec 执行链不传递数据】
这一条把我之前的一个偷懒设计去掉了:原来留了个"没有数据入边时就用 exec
上游的输出"的回退 —— 那等于**让 exec 偷偷传数据**,于是"接一根 exec 线"
和"接一根数据线"效果一样,类型也没法校验。

现在数据**只**沿数据线走。代价是老会议里"一根线连到底"的图不再自动传值,
得补一根数据线 —— 但这是对的:顺序和取值本来就不该是同一件事。

【3. 值节点】
新增 `值`(纯节点,只有一个数据输出),类型可选 str / bool / num。
实测:开始事件(str) + 值节点(str) → 智能体,两个数据源都进了智能体;
而 num 类型的值节点接到 str 输入上**被正确拒绝**。

取值统一走 _pure_value():纯节点(读变量 / 值)**现取现值**,
而不是去 outputs 里找 —— 它们可能压根没被执行链走到过。

【4. 连线可删除】
蓝图里是 Alt+点引脚 断开;手机上没键盘,改成**点线选中、再点删除**:
  - 点中连线 → 变蓝加粗带光晕,底部出现「已选中一条连线(str 数据线)· 删除 / 取消」
  - 点删除 → 连线消失并落盘
连线是曲线,不能像节点那样用矩形判,所以沿贝塞尔采样 24 段找最近的
(命中半径 14dp,手指没那么准)。
**实测:7 条连线 → 删除 → 5 条**,界面上那条线确实没了。

【验证】
- 引擎回归 40/40,Node 与 Python **16/16 逐用例一致**
- 会议 HTTP 端到端 13/13 ×2
- 类型校验实测:num → str 的连接被丢掉
- 删除连线实测:7 → 5 条(模拟器截图确认)

★ 测试用例里加了 withDataEdges():老用例的边都是"一根线既排顺序又传值"的
  老写法,现在要补一条并行的 str 数据线。这正是用户在界面上迁移时要做的事,
  所以放在测试宿主里统一处理,比改 29 处数据干净。
  两边变量用例还各补了一条之前缺的数据线(写变量要拿到上游的值必须有数据线)。

【还没做的】
- **Node 侧引擎的 while 节点**:Python 有了,Node 还没有(要把它那边的
  runMeeting 也改成可递归的 walk)。两边 exec/data 和类型化都同步了,对拍一致。
- while 的配置面板说明文字、值节点的验收用例。
This commit is contained in:
l
2026-10-10 21:38:12 +08:00
parent a7cc069f1e
commit ae2024a053
5 changed files with 344 additions and 50 deletions

View File

@@ -106,12 +106,19 @@ const graph = {
{ id: 'f', type: 'agent', x: 200, y: 50, title: '别的专家', agentId: '', outputControl: '一句话' },
{ id: 'e', type: 'end', x: 300, y: 0 },
],
// ★ exec 排顺序、str 数据线传值 —— 判断节点要拿到内容必须有数据线。
// 老写法"一根线既排顺序又传值"在类型化之后不成立了。
edges: [
{ from: 's', to: 'j' },
{ from: 'j', to: 't', branch: 'true' },
{ from: 'j', to: 'f', branch: 'false' },
{ from: 't', to: 'e' },
{ from: 'f', to: 'e' },
{ from: 's', to: 'j', kind: 'exec' },
{ from: 's', to: 'j', kind: 'str' },
{ from: 'j', to: 't', kind: 'exec', branch: 'true' },
{ from: 'j', to: 'f', kind: 'exec', branch: 'false' },
{ from: 'j', to: 't', kind: 'str' },
{ from: 'j', to: 'f', kind: 'str' },
{ from: 't', to: 'e', kind: 'exec' },
{ from: 'f', to: 'e', kind: 'exec' },
{ from: 't', to: 'e', kind: 'str' },
{ from: 'f', to: 'e', kind: 'str' },
],
};
const saved = await api(`/api/meetings/${meetingId}`, {

View File

@@ -204,6 +204,9 @@ const cases = [
// 数据线:e 从读变量拉值(rd 是纯节点,不在执行链上)
edges: [
{ from: 's', to: 'w', kind: 'exec' },
// ★ 写变量要拿到上游的值,必须有**数据线** ——
// exec 只排顺序、不传数据。这正是类型化之后和以前最大的区别。
{ from: 's', to: 'w', kind: 'str' },
{ from: 'w', to: 'e', kind: 'exec' },
{ from: 'rd', to: 'e', kind: 'data' },
],
@@ -221,6 +224,9 @@ const cases = [
],
edges: [
{ from: 's', to: 'w', kind: 'exec' },
// ★ 写变量要拿到上游的值,必须有**数据线** ——
// exec 只排顺序、不传数据。这正是类型化之后和以前最大的区别。
{ from: 's', to: 'w', kind: 'str' },
{ from: 'w', to: 'e', kind: 'exec' },
{ from: 'rd', to: 'e', kind: 'data' },
],
@@ -309,6 +315,24 @@ const cases = [
/* ------------------------------------------------- 跑一份实现,收集事件 */
/**
* 给用例图补上数据线。
*
* ★ exec 现在**不传数据**了(照 UE 蓝图:exec 只排顺序,值走类型化的数据线)。
* 老用例里的边都是"一根线既排顺序又传值"的老写法,所以要给每条没有 kind
* 的边补一条并行的 str 数据线 —— 这正是用户在界面上迁移时会做的事。
*
* 用例里**显式写了 kind 的边不动**(那些是在测类型校验本身)。
*/
function withDataEdges(meeting) {
const edges = [];
for (const e of meeting.edges || []) {
edges.push(e);
if (!e.kind) edges.push({ ...e, kind: 'str' });
}
return { ...meeting, edges };
}
async function runOne(impl, cs) {
const order = [];
const events = [];
@@ -329,7 +353,7 @@ async function runOne(impl, cs) {
return base + extra;
};
const out = await runMeeting({
meeting: cs.meeting,
meeting: withDataEdges(cs.meeting),
settings: {},
userInput: '',
emit: (e) => {
@@ -390,7 +414,7 @@ print(json.dumps(out, ensure_ascii=False))
`;
const res = spawnSync(PY, ['-c', script], {
input: JSON.stringify(cases.map((c) => ({
meeting: c.meeting,
meeting: withDataEdges(c.meeting),
stopAfter: c.stopAfter || null,
}))),
encoding: 'utf8',