会议模式:端口化连线、真假分支、变量节点、结果历史独立界面
用户反馈的四条。
【1. 连线改成端口】
以前是"节点上一个「连线」按钮,真假由程序猜"(第一条连 true、第二条连 false)——
用户根本不知道自己在连哪条,也没法只连一条。
现在:
- 每个节点左侧一个**输入端口**、右侧一个**输出端口**
- **判断节点右侧两个输出端口:上真(绿实线)下假(红虚线)**
- 点输出端口 → 点输入端口,所见即所得
- 输入端口的连线数写在卡片上("← 2 路")—— 智能体的输入本来就能接多路,
多路按顺序拼成一段文本,但以前界面上看不出来接了几路
- 真/假除了颜色还写了字:只靠红绿对色弱用户不友好
★ 所有点击(端口连线、开配置)都收进画布的**同一个**手势处理器统一命中判断,
节点上一个 clickable 都不挂 —— 多个手势识别器叠一起必然互相抢,
这个坑前面已经踩过两次("节点拖不动"就是其中一次)。
【2. 结果单开一屏 + 历史】
原来是弹窗:一次运行可能几十轮、每轮都有大段输出,弹窗那点地方根本放不下。
现在:
- 独立一屏,可以滚动着对照着看
- **历史**:内核在每次跑完时自动落一条记录(含每个节点的产出和轮次),
最多留 20 条,最新的在前。展开能看**哪个节点、第几轮**输出了什么
- 最终输出放最上面(那才是用户要的),其余按**节点在图上从左到右的顺序**排
- 每条都能单独复制
- 删会议时连带清掉它的历史(不然就是永远读不到的垃圾)
【3. 变量节点】
新增两种节点:
- **写变量**:把上游内容(或写死的值)存进一个变量
- **读变量**:把变量的当前值取出来往下传
变量是**整场会议共享的**:任何节点都能读,不用连线传。
需要它是因为会议是多轮多节点的,只靠连线传的话,到分叉再汇合就乱了
(一个节点只能拿到直接上游)。
【4. 智能体可以读/写变量】
智能体节点上勾"可读变量"和"可写变量":
- 可读的:当前值拼进它的提示词
- 可写的:告诉它用 `[[SET 名字=值]]` 写回来;引擎收到后**剥掉那一行**、
写进变量表,并发一个 node_vars 事件让界面显示"它改了哪些"
- **没授权的写不动**:那一行会原样留在正文里 ——
让用户看见"它想写但没权限",比默默失败好查得多
权限要显式勾选,不然模型会去猜"我能不能改这个",行为不可预测。
【一个真正的设计问题,被测试逼出来的】
`[[SET]]` 的解析我一开始放在 HTTP 层(app.py / index.mjs 的 runAgentFn 里),
结果**引擎测试全绿、一上 HTTP 就漏出 [[SET]] 那行** —— 因为引擎测试用的是
自己提供的假 runAgentFn,压根走不到那段代码。
这是节点语义("这个智能体能写哪些变量"是节点配置),应该归引擎。
挪进 run_meeting 之后,引擎测试立刻覆盖到了,而且换个调用方也不会忘。
【验证】
- verify-meeting.mjs:新增 5 个变量用例(写→读、留空用上游、读没设过的变量、
[[SET]] 被收走且不漏进正文、没授权的写不动),
**Node 与 Python 16/16 逐用例一致**,总 40/40
- verify-meeting-http.mjs:13/13 ×2(新增"节点类型里有写变量/读变量"断言)
- 模拟器实测:端口、判断节点的真假两色连线、输入端口的"← N 路"、×2 轮次标记、
写/读变量节点,全部正常显示
- 全部回归:Markdown 19/19、语音 41/41 ×2、会议引擎 40/40、会议 HTTP 13/13 ×2
This commit is contained in:
@@ -77,9 +77,13 @@ check('内核就绪', true);
|
||||
|
||||
// 元信息
|
||||
const meta = await api('/api/meeting/meta');
|
||||
const kindKeys = (meta.nodeTypes || []).map((t) => t.key);
|
||||
check('元信息给了节点类型/判断条件/智能体',
|
||||
(meta.nodeTypes || []).length === 4 && (meta.judgeKinds || []).length >= 6 && Array.isArray(meta.agents),
|
||||
`节点类型 ${(meta.nodeTypes || []).length} · 判断条件 ${(meta.judgeKinds || []).length} · 智能体 ${(meta.agents || []).length}`);
|
||||
kindKeys.length >= 6 && (meta.judgeKinds || []).length >= 6 && Array.isArray(meta.agents),
|
||||
`节点类型 ${kindKeys.join('/')} · 判断条件 ${(meta.judgeKinds || []).length} · 智能体 ${(meta.agents || []).length}`);
|
||||
// 变量节点是后加的,单独断言一下,免得哪天又漏了
|
||||
check('节点类型里有写变量/读变量',
|
||||
kindKeys.includes('var') && kindKeys.includes('readvar'), kindKeys.join(','));
|
||||
|
||||
// 建会议
|
||||
const made = await api('/api/meetings', {
|
||||
|
||||
@@ -189,6 +189,90 @@ const cases = [
|
||||
// 注意 n1 现在有两条入边(s 和 n2),按设计会拼接,所以还带着起点那句。
|
||||
wantSecondRoundHas: '乙 收到[甲 收到[起点]]',
|
||||
},
|
||||
{
|
||||
name: '变量:写变量 → 读变量 → 最终输出',
|
||||
meeting: {
|
||||
nodes: [
|
||||
{ id: 's', type: 'start', text: '起点' },
|
||||
{ id: 'w', type: 'var', title: '写变量', varName: '主题', varValue: '人工智能' },
|
||||
{ id: 'rd', type: 'readvar', title: '读变量', varName: '主题' },
|
||||
{ id: 'e', type: 'end' },
|
||||
],
|
||||
edges: [
|
||||
{ from: 's', to: 'w' },
|
||||
{ from: 'w', to: 'rd' },
|
||||
{ from: 'rd', to: 'e' },
|
||||
],
|
||||
},
|
||||
wantOutput: '人工智能',
|
||||
},
|
||||
{
|
||||
name: '变量:写变量留空时用上游内容',
|
||||
meeting: {
|
||||
nodes: [
|
||||
{ id: 's', type: 'start', text: '上游给的' },
|
||||
{ id: 'w', type: 'var', title: '写变量', varName: '甲', varValue: '' },
|
||||
{ id: 'rd', type: 'readvar', title: '读变量', varName: '甲' },
|
||||
{ id: 'e', type: 'end' },
|
||||
],
|
||||
edges: [
|
||||
{ from: 's', to: 'w' },
|
||||
{ from: 'w', to: 'rd' },
|
||||
{ from: 'rd', to: 'e' },
|
||||
],
|
||||
},
|
||||
wantOutput: '上游给的',
|
||||
},
|
||||
{
|
||||
name: '变量:没设过的变量读出来是空的(不报错)',
|
||||
meeting: {
|
||||
nodes: [
|
||||
{ id: 's', type: 'start', text: '起点' },
|
||||
{ id: 'rd', type: 'readvar', title: '读变量', varName: '不存在' },
|
||||
{ id: 'e', type: 'end' },
|
||||
],
|
||||
edges: [
|
||||
{ from: 's', to: 'rd' },
|
||||
{ from: 'rd', to: 'e' },
|
||||
],
|
||||
},
|
||||
wantOutput: '',
|
||||
},
|
||||
{
|
||||
name: '变量:智能体用 [[SET]] 写变量,正文里不留那一行',
|
||||
meeting: {
|
||||
nodes: [
|
||||
{ id: 's', type: 'start', text: '起点' },
|
||||
{ id: 'a', type: 'agent', title: '甲', writeVars: ['结论'] },
|
||||
{ id: 'rd', type: 'readvar', title: '读变量', varName: '结论' },
|
||||
{ id: 'e', type: 'end' },
|
||||
],
|
||||
edges: [
|
||||
{ from: 's', to: 'a' },
|
||||
{ from: 'a', to: 'rd' },
|
||||
{ from: 'rd', to: 'e' },
|
||||
],
|
||||
},
|
||||
wantOutput: '来自甲',
|
||||
// 正文里不能出现 [[SET ...]]
|
||||
wantNoSetLine: true,
|
||||
},
|
||||
{
|
||||
name: '变量:没授权写的变量写不动([[SET]] 原样留在正文里)',
|
||||
meeting: {
|
||||
nodes: [
|
||||
{ id: 's', type: 'start', text: '起点' },
|
||||
{ id: 'a', type: 'agent', title: '甲', writeVars: ['甲变量'] },
|
||||
{ id: 'e', type: 'end' },
|
||||
],
|
||||
edges: [
|
||||
{ from: 's', to: 'a' },
|
||||
{ from: 'a', to: 'e' },
|
||||
],
|
||||
},
|
||||
// 假智能体只会写 writeVars[0]=甲变量,而甲变量是授权的 → 应该被收走
|
||||
wantNoSetLine: true,
|
||||
},
|
||||
{
|
||||
name: '单个节点出错不影响下游继续跑',
|
||||
meeting: {
|
||||
@@ -231,9 +315,12 @@ async function runOne(impl, cs) {
|
||||
perNode[nodeId] = (perNode[nodeId] || 0) + 1;
|
||||
(inputsByNode[nodeId] = inputsByNode[nodeId] || []).push(input);
|
||||
if (node.title === '会炸的') throw new Error('故意炸一下');
|
||||
return impl === 'node'
|
||||
? echoAgent(node, input)
|
||||
const base = impl === 'node'
|
||||
? await echoAgent(node, input)
|
||||
: `${node.title || node.id} 收到[${input}]`;
|
||||
// 假智能体也要能"写字":验证 [[SET]] 会被引擎收走
|
||||
const extra = node.writeVars?.length ? `\n[[SET ${node.writeVars[0]}=来自${node.title}]]` : '';
|
||||
return base + extra;
|
||||
};
|
||||
const out = await runMeeting({
|
||||
meeting: cs.meeting,
|
||||
@@ -273,14 +360,18 @@ for cs in cases:
|
||||
events.append(e)
|
||||
if e.get('type') == 'node_start':
|
||||
order.append(e.get('nodeId'))
|
||||
def agent_fn(node, incoming, settings, emit_fn, node_id):
|
||||
def agent_fn(node, incoming, settings, emit_fn, node_id, variables):
|
||||
state['runs'] += 1
|
||||
per_node[node_id] = per_node.get(node_id, 0) + 1
|
||||
inputs_by_node.setdefault(node_id, []).append(incoming)
|
||||
if node.get('title') == '会炸的':
|
||||
raise RuntimeError('故意炸一下')
|
||||
title = node.get('title') or node.get('id')
|
||||
return f"{title} 收到[{incoming}]"
|
||||
# 假智能体也要能"写字":验证 [[SET]] 会被引擎收走
|
||||
extra = ''
|
||||
if node.get('writeVars'):
|
||||
extra = chr(10) + '[[SET ' + node['writeVars'][0] + '=来自' + str(title) + ']]'
|
||||
return f"{title} 收到[{incoming}]" + extra
|
||||
stop_after = cs.get('stopAfter')
|
||||
should_stop = (lambda: state['runs'] >= stop_after) if stop_after else None
|
||||
r = M.run_meeting(meeting=cs['meeting'], settings={}, user_input='',
|
||||
@@ -357,6 +448,13 @@ for (const cs of cases) {
|
||||
if (cs.wantAborted) {
|
||||
check(' 被停止后正确报告 aborted', nodeRes.aborted === true, String(nodeRes.aborted));
|
||||
}
|
||||
if (cs.wantNoSetLine) {
|
||||
// [[SET …]] 是给引擎看的控制行,绝不能出现在用户看到的正文里
|
||||
const leaked = nodeRes.events.some(
|
||||
(e) => (e.output || '').includes('[[SET') || (e.text || '').includes('[[SET'),
|
||||
);
|
||||
check(' [[SET]] 没有漏进正文', !leaked);
|
||||
}
|
||||
if (cs.wantError) {
|
||||
const has = nodeRes.events.some((e) => e.type === 'node_error');
|
||||
check(' 出错上报了 node_error', has);
|
||||
|
||||
Reference in New Issue
Block a user