dsh-workflow-canvas 0.2.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -111
- package/README.zh.md +78 -75
- package/client.js +339 -190
- package/docs/DETAIL.md +13 -10
- package/docs/images/add-node-shift-a.gif +0 -0
- package/docs/images/connect-and-cut.gif +0 -0
- package/docs/images/lead-pause-resume.gif +0 -0
- package/docs/images/node-config.gif +0 -0
- package/docs/images/node-entry-en.png +0 -0
- package/docs/images/node-entry-zh.png +0 -0
- package/docs/images/node-lead-en.png +0 -0
- package/docs/images/node-lead-zh.png +0 -0
- package/docs/images/node-subagent-en.png +0 -0
- package/docs/images/node-subagent-zh.png +0 -0
- package/docs/images/parallel-and-inspect.gif +0 -0
- package/index.js +281 -53
- package/package.json +1 -1
- package/skills/workflow-canvas/SKILL.md +6 -4
package/client.js
CHANGED
|
@@ -128,6 +128,7 @@ window.__ModuleLoader__.load({
|
|
|
128
128
|
savedPreset: '已保存预设', saveFailed: '保存失败(存储不可用)',
|
|
129
129
|
loadedPreset: '已载入预设', invalidPreset: '预设内容无效', deletedPreset: '已删除预设',
|
|
130
130
|
syncFailed: '同步失败', upToDate: '已是最新', syncedToHost: '已同步到 Host',
|
|
131
|
+
syncedWithStdWarn: '已同步(含可写/命令节点,请确认主对话权限已放开)',
|
|
131
132
|
cannotOpen: '无法打开会话', undoDone: '已撤销', undoNone: '没有可撤销的操作',
|
|
132
133
|
leadLocked: '入口 Lead 不能删除', modelsMissing: '模型列表未加载',
|
|
133
134
|
tipLead: 'Lead 步骤在对话里执行,画布不追踪其状态',
|
|
@@ -169,7 +170,11 @@ window.__ModuleLoader__.load({
|
|
|
169
170
|
exportFail: '复制失败(剪贴板不可用)',
|
|
170
171
|
autoLayoutBtn: '⊞ 自动排版',
|
|
171
172
|
layoutDone: '已自动整理布局',
|
|
173
|
+
clearCanvasBtn: '✕ 清空画布',
|
|
174
|
+
newBlankCanvas: '+ 新建空白画布',
|
|
175
|
+
clearedCanvas: '已清空画布(可用 ↶ 撤销)',
|
|
172
176
|
cycleBlocked: '不能形成环,已阻止连线',
|
|
177
|
+
leadToLeadBlocked: 'Lead 节点不能直接连到另一个 Lead,请在中间放入子代理',
|
|
173
178
|
builtinTemplates: '内置示例模板',
|
|
174
179
|
myPresets: '我的预设',
|
|
175
180
|
duplicatedNodes: '已复制节点',
|
|
@@ -181,7 +186,9 @@ window.__ModuleLoader__.load({
|
|
|
181
186
|
fxVivid: '炫酷',
|
|
182
187
|
tipLeadReady: '上游节点已全部完成,正等待在对话里拍板继续',
|
|
183
188
|
stDeadEnd: '无出边',
|
|
184
|
-
tipDeadEnd: '
|
|
189
|
+
tipDeadEnd: '该子代理没有下游连线,运行时不生效;请连入下游节点或终审 Lead',
|
|
190
|
+
stSoloLead: '未接子代理',
|
|
191
|
+
tipSoloLead: '该 Lead 仅串联了其他 Lead,未连入任何子代理,运行时不生效',
|
|
185
192
|
singleModelHint: '当前仅 1 个可用模型,暂无其它备用路由',
|
|
186
193
|
importNone: '剪贴板里没有可识别的画布数据',
|
|
187
194
|
importBad: '画布数据格式不对',
|
|
@@ -189,7 +196,12 @@ window.__ModuleLoader__.load({
|
|
|
189
196
|
tipUndo: '撤销上一步结构改动', tipSave: '把当前画布保存为预设',
|
|
190
197
|
tipPresets: '载入已保存的预设', tipModel: '推理等级(默认 = 该模型声明的 defaultEffort)',
|
|
191
198
|
tipMemory: '记忆:复用这个节点上一次的会话(跨运行及重启后可恢复)',
|
|
192
|
-
|
|
199
|
+
memLatest: '最新',
|
|
200
|
+
memLatestOpt: '自动(最新记忆)',
|
|
201
|
+
memRunOpt: '第 {n} 次会话',
|
|
202
|
+
memEmpty: '运行后这里会列出可选的历史会话',
|
|
203
|
+
tipMemoryPick: '选择要续接的历史子会话(默认自动沿用最新记忆)',
|
|
204
|
+
tipPreset: '能力范围(点一下切换,受主对话权限上限约束):standard = 全部工具(读写文件、跑命令、子代理、工作流、网页、办公);minimal = 只读思考(文件读写关闭,没有子代理/工作流/网页)',
|
|
193
205
|
tipFallback: '失败重试:该节点出错时自动换一个模型再跑一次',
|
|
194
206
|
tipStructured: 'JSON 输出:要求该节点返回 JSON 对象,structured 连线会把结果作为 JSON 传给下游',
|
|
195
207
|
lang: 'ZH',
|
|
@@ -226,6 +238,7 @@ window.__ModuleLoader__.load({
|
|
|
226
238
|
savedPreset: 'Saved preset', saveFailed: 'Save failed (storage unavailable)',
|
|
227
239
|
loadedPreset: 'Loaded preset', invalidPreset: 'Preset content is invalid', deletedPreset: 'Deleted preset',
|
|
228
240
|
syncFailed: 'Sync failed', upToDate: 'Already up to date', syncedToHost: 'Synced to host',
|
|
241
|
+
syncedWithStdWarn: 'Synced (has write/tool nodes — check main chat permission mode)',
|
|
229
242
|
cannotOpen: 'Cannot open the session', undoDone: 'Undone', undoNone: 'Nothing to undo',
|
|
230
243
|
leadLocked: 'The entry Lead cannot be deleted', modelsMissing: 'Model list is not loaded',
|
|
231
244
|
tipLead: 'Lead steps run in the chat; the canvas does not track them',
|
|
@@ -267,7 +280,11 @@ window.__ModuleLoader__.load({
|
|
|
267
280
|
exportFail: 'Copy failed (clipboard unavailable)',
|
|
268
281
|
autoLayoutBtn: '⊞ Auto layout',
|
|
269
282
|
layoutDone: 'Layout tidied',
|
|
283
|
+
clearCanvasBtn: '✕ Clear canvas',
|
|
284
|
+
newBlankCanvas: '+ New blank canvas',
|
|
285
|
+
clearedCanvas: 'Canvas cleared (use Undo to restore)',
|
|
270
286
|
cycleBlocked: 'Cannot create a cycle',
|
|
287
|
+
leadToLeadBlocked: 'Cannot link a Lead directly to another Lead; place a subagent in between',
|
|
271
288
|
builtinTemplates: 'Starter templates',
|
|
272
289
|
myPresets: 'Saved presets',
|
|
273
290
|
duplicatedNodes: 'Duplicated nodes',
|
|
@@ -279,7 +296,9 @@ window.__ModuleLoader__.load({
|
|
|
279
296
|
fxVivid: 'Vivid',
|
|
280
297
|
tipLeadReady: 'Upstream steps are done; waiting for Lead in chat',
|
|
281
298
|
stDeadEnd: 'No out-link',
|
|
282
|
-
tipDeadEnd: 'This subagent has no outgoing link
|
|
299
|
+
tipDeadEnd: 'This subagent has no outgoing link and is skipped at run time; wire it into a downstream node or Lead',
|
|
300
|
+
stSoloLead: 'Needs agent',
|
|
301
|
+
tipSoloLead: 'This Lead only chains from another Lead with no subagent upstream, so it is skipped at run time',
|
|
283
302
|
singleModelHint: 'Only 1 model available — no alternate fallback route',
|
|
284
303
|
importNone: 'No canvas data found in the clipboard',
|
|
285
304
|
importBad: 'Canvas data is malformed',
|
|
@@ -287,7 +306,12 @@ window.__ModuleLoader__.load({
|
|
|
287
306
|
tipUndo: 'Undo the last structural change', tipSave: 'Save this canvas as a preset',
|
|
288
307
|
tipPresets: 'Load a saved preset', tipModel: 'Reasoning effort (default = the model\'s defaultEffort)',
|
|
289
308
|
tipMemory: 'Memory: reuse this node\'s previous session (persisted across runs and restarts)',
|
|
290
|
-
|
|
309
|
+
memLatest: 'Latest',
|
|
310
|
+
memLatestOpt: 'Auto (latest)',
|
|
311
|
+
memRunOpt: 'Run #{n}',
|
|
312
|
+
memEmpty: 'Past runs appear here after running',
|
|
313
|
+
tipMemoryPick: 'Pick which past child session to resume (defaults to latest)',
|
|
314
|
+
tipPreset: 'Capability (click to toggle; bounded by the main chat permission mode): standard = all tools (files, shells, subagents, workflow, web, office); minimal = read-only thinking (no file writes, no subagents/workflow/web)',
|
|
291
315
|
tipFallback: 'Retry: when this node fails, rerun it once on another model',
|
|
292
316
|
tipStructured: 'JSON output: require an object result; structured links pass it downstream as JSON',
|
|
293
317
|
lang: 'EN',
|
|
@@ -719,120 +743,84 @@ window.__ModuleLoader__.load({
|
|
|
719
743
|
return out.length === nodes.length ? out : null;
|
|
720
744
|
}
|
|
721
745
|
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
const rest = nodes.filter((n) => n.id !== 'lead');
|
|
730
|
-
if (!rest.length) return { error: '画布上还没有可执行的节点' };
|
|
731
|
-
const task = String(entry.task || '').trim();
|
|
732
|
-
if (!task) return { error: '请先在 Lead 节点填写「本次任务」' };
|
|
733
|
-
|
|
734
|
-
const byIdAll = new Map(rest.map((n) => [n.id, n]));
|
|
735
|
-
|
|
736
|
-
const reachable = new Set([entry.id]);
|
|
737
|
-
let grew = true;
|
|
738
|
-
while (grew) {
|
|
739
|
-
grew = false;
|
|
740
|
-
for (const e of edges) {
|
|
741
|
-
if (reachable.has(e.from) && !reachable.has(e.to)) { reachable.add(e.to); grew = true; }
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
const orphan = rest.filter((n) => !reachable.has(n.id));
|
|
745
|
-
if (orphan.length) {
|
|
746
|
-
return { error: '这些节点没有从入口 Lead 连过来:' + orphan.map((n) => n.label).join('、') };
|
|
746
|
+
/** Ids reachable from the entry Lead via O(V + E) BFS; every other node is skipped at run time. */
|
|
747
|
+
function reachableFrom(nodes, edges) {
|
|
748
|
+
const adj = new Map();
|
|
749
|
+
for (const e of edges || []) {
|
|
750
|
+
if (!e || !e.from || !e.to) continue;
|
|
751
|
+
if (!adj.has(e.from)) adj.set(e.from, []);
|
|
752
|
+
adj.get(e.from).push(e.to);
|
|
747
753
|
}
|
|
748
|
-
|
|
749
|
-
const
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
for (const ln of leadNodes) {
|
|
755
|
-
if (dataEdgesAll.some((e) => e.from === ln.id)) {
|
|
756
|
-
return {
|
|
757
|
-
error: '中间 Lead 节点暂不支持(「' + ln.label + '」后面还有步骤)。'
|
|
758
|
-
+ '把中间这一步换成子代理,或把它移到流程末尾。',
|
|
759
|
-
};
|
|
754
|
+
const set = new Set(['lead']);
|
|
755
|
+
const queue = ['lead'];
|
|
756
|
+
for (let i = 0; i < queue.length; i += 1) {
|
|
757
|
+
const cur = queue[i];
|
|
758
|
+
for (const next of adj.get(cur) || []) {
|
|
759
|
+
if (!set.has(next)) { set.add(next); queue.push(next); }
|
|
760
760
|
}
|
|
761
761
|
}
|
|
762
|
+
return set;
|
|
763
|
+
}
|
|
762
764
|
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
const
|
|
772
|
-
|
|
773
|
-
const
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
const lines = [];
|
|
784
|
-
lines.push('// meta: ' + JSON.stringify({ name: 'workflow-canvas', description: 'Canvas-generated agent DAG', phases: [{ title: 'run' }] }));
|
|
785
|
-
for (const id of order) {
|
|
786
|
-
const node = byId.get(id);
|
|
787
|
-
const ups = upstream.get(id);
|
|
788
|
-
const isRoot = ups.length === 0;
|
|
789
|
-
const upsLabels = ups.map((e) => (byId.get(e.from) || {}).label).filter(Boolean);
|
|
790
|
-
const downs = dataEdgesAll.filter((e) => e.from === id).map((e) => (byIdAll.get(e.to) || {}).label).filter(Boolean);
|
|
791
|
-
const head = [];
|
|
792
|
-
head.push('【工作流节点】你在一个多步工作流里负责「' + node.label + '」这一步(子代理)。');
|
|
793
|
-
if (isRoot) head.push('【总任务】' + task);
|
|
794
|
-
head.push('【职责】' + (node.role || node.label || id));
|
|
795
|
-
if (upsLabels.length) head.push('【上游】' + upsLabels.join('、') + ' 已交付结果给你(见下文)。');
|
|
796
|
-
head.push('【下游】' + (downs.length ? downs.join('、') + ' 会使用你的输出。' : '你是终点,结果会直接交付给用户。'));
|
|
797
|
-
head.push('【要求】只完成你这一步;输出要能被下游直接使用,不要重复上游已完成的工作。');
|
|
798
|
-
const pieces = [JSON.stringify(head.join('\n') + '\n')];
|
|
799
|
-
for (const e of ups) {
|
|
800
|
-
const from = byId.get(e.from);
|
|
801
|
-
pieces.push(JSON.stringify('\n## 来自【' + from.label + '】(' + (e.type || 'prompt') + ')\n'));
|
|
802
|
-
pieces.push(varOf(e.from));
|
|
803
|
-
}
|
|
804
|
-
// The label carries the canvas node id so the client can match the
|
|
805
|
-
// spawned subagent session back to its node through the catalog.
|
|
806
|
-
const opts = ["label: " + JSON.stringify((node.label || id) + '#' + id), "phase: 'run'"];
|
|
807
|
-
if (node.provider) opts.push('provider: ' + JSON.stringify(node.provider));
|
|
808
|
-
if (node.model) opts.push('model: ' + JSON.stringify(node.model));
|
|
809
|
-
lines.push('const ' + varOf(id) + ' = await agent(' + pieces.join(' + ') + ', { ' + opts.join(', ') + ' });');
|
|
765
|
+
/**
|
|
766
|
+
* Reachable non-entry Lead nodes that have zero reachable subagent upstream
|
|
767
|
+
* (chained solely from another Lead). Rendered dashed and skipped at run time;
|
|
768
|
+
* connecting any subagent into them makes them active immediately.
|
|
769
|
+
*/
|
|
770
|
+
function soloLeadNodeIds(nodes, edges) {
|
|
771
|
+
const list = Array.isArray(nodes) ? nodes : [];
|
|
772
|
+
const linkList = Array.isArray(edges) ? edges : [];
|
|
773
|
+
const reachable = reachableFrom(list, linkList);
|
|
774
|
+
const byId = new Map(list.map((n) => [n.id, n]));
|
|
775
|
+
const out = new Set();
|
|
776
|
+
for (const n of list) {
|
|
777
|
+
if (n.kind !== 'lead' || n.id === 'lead' || !reachable.has(n.id)) continue;
|
|
778
|
+
const hasAgentUp = linkList.some((e) => {
|
|
779
|
+
if (!e || e.to !== n.id || !reachable.has(e.from) || e.from === 'lead') return false;
|
|
780
|
+
const src = byId.get(e.from);
|
|
781
|
+
return Boolean(src && src.kind !== 'lead');
|
|
782
|
+
});
|
|
783
|
+
if (!hasAgentUp) out.add(n.id);
|
|
810
784
|
}
|
|
811
|
-
|
|
812
|
-
const rets = delivered.map((id) => JSON.stringify(byId.get(id).label) + ': ' + varOf(id));
|
|
813
|
-
lines.push('return { ' + rets.join(', ') + ' };');
|
|
814
|
-
|
|
815
|
-
// These run in the conversation after the script returns.
|
|
816
|
-
const leadSteps = leadNodes.map((ln) => ({
|
|
817
|
-
label: ln.label,
|
|
818
|
-
role: ln.role || ln.label,
|
|
819
|
-
needs: dataEdgesAll.filter((e) => e.to === ln.id).map((e) => (byIdAll.get(e.from) || {}).label).filter(Boolean),
|
|
820
|
-
}));
|
|
821
|
-
|
|
822
|
-
return { script: lines.join('\n'), leadSteps };
|
|
785
|
+
return out;
|
|
823
786
|
}
|
|
824
787
|
|
|
825
|
-
/**
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
788
|
+
/**
|
|
789
|
+
* Reachable agent nodes with zero outgoing edges when the graph has at least
|
|
790
|
+
* one active downstream Lead that is NOT an ancestor of that agent (dangling
|
|
791
|
+
* branch whose output is never consumed). Rendered dashed and skipped at run time.
|
|
792
|
+
*/
|
|
793
|
+
function deadEndNodeIds(nodes, edges) {
|
|
794
|
+
const list = Array.isArray(nodes) ? nodes : [];
|
|
795
|
+
const linkList = Array.isArray(edges) ? edges : [];
|
|
796
|
+
const reachable = reachableFrom(list, linkList);
|
|
797
|
+
const soloLeads = soloLeadNodeIds(list, linkList);
|
|
798
|
+
const downstreamLeads = list.filter((n) => n.kind === 'lead' && n.id !== 'lead' && reachable.has(n.id) && !soloLeads.has(n.id));
|
|
799
|
+
if (!downstreamLeads.length) return new Set();
|
|
800
|
+
const hasOut = new Set(linkList.map((e) => e.from));
|
|
801
|
+
const parents = new Map();
|
|
802
|
+
for (const e of linkList) {
|
|
803
|
+
if (!parents.has(e.to)) parents.set(e.to, []);
|
|
804
|
+
parents.get(e.to).push(e.from);
|
|
805
|
+
}
|
|
806
|
+
const ancestorsOf = (id) => {
|
|
807
|
+
const seen = new Set();
|
|
808
|
+
const stack = [id];
|
|
809
|
+
while (stack.length) {
|
|
810
|
+
const cur = stack.pop();
|
|
811
|
+
for (const p of parents.get(cur) || []) {
|
|
812
|
+
if (!seen.has(p)) { seen.add(p); stack.push(p); }
|
|
813
|
+
}
|
|
833
814
|
}
|
|
815
|
+
return seen;
|
|
816
|
+
};
|
|
817
|
+
const out = new Set();
|
|
818
|
+
for (const n of list) {
|
|
819
|
+
if (n.kind === 'lead' || !reachable.has(n.id) || hasOut.has(n.id)) continue;
|
|
820
|
+
const anc = ancestorsOf(n.id);
|
|
821
|
+
if (downstreamLeads.some((ln) => !anc.has(ln.id))) out.add(n.id);
|
|
834
822
|
}
|
|
835
|
-
return
|
|
823
|
+
return out;
|
|
836
824
|
}
|
|
837
825
|
|
|
838
826
|
/** True when adding `fromId -> toId` would create a cycle or point into entry Lead. */
|
|
@@ -1022,6 +1010,7 @@ window.__ModuleLoader__.load({
|
|
|
1022
1010
|
{ id: 'n_b', kind: 'agent', label: en ? 'Option B (Bold)' : '方案 B(创新)', provider: '', model: '', reasoning: '', preset: 'minimal', keepSession: false, role: en ? 'Propose a high-leverage alternative with better long-term payoff.' : '提出上限更高、长期收益更大的进阶方案。' },
|
|
1023
1011
|
{ id: 'n_pick', kind: 'lead', label: en ? 'Lead Pick' : 'Lead 拍板', provider: '', model: '', role: en ? 'Compare both options and pick the direction to execute.' : '对比两份方案,选定最终路线并补充约束。' },
|
|
1024
1012
|
{ id: 'n_exec', kind: 'agent', label: en ? 'Execute' : '执行落地', provider: '', model: '', reasoning: '', preset: 'standard', keepSession: false, role: en ? 'Deliver the chosen solution end to end.' : '按照拍板路线完成最终交付。' },
|
|
1013
|
+
{ id: 'n_review', kind: 'lead', label: en ? 'Lead Review' : 'Lead 验收', provider: '', model: '', role: en ? 'Verify the deliverable matches the chosen direction and sign off.' : '核对最终产出是否符合拍板方向,确认无误后交付。' },
|
|
1025
1014
|
];
|
|
1026
1015
|
const abEdges = [
|
|
1027
1016
|
{ id: 'a1', from: 'lead', to: 'n_a', type: 'prompt' },
|
|
@@ -1029,6 +1018,7 @@ window.__ModuleLoader__.load({
|
|
|
1029
1018
|
{ id: 'a3', from: 'n_a', to: 'n_pick', type: 'prompt' },
|
|
1030
1019
|
{ id: 'a4', from: 'n_b', to: 'n_pick', type: 'prompt' },
|
|
1031
1020
|
{ id: 'a5', from: 'n_pick', to: 'n_exec', type: 'prompt' },
|
|
1021
|
+
{ id: 'a6', from: 'n_exec', to: 'n_review', type: 'prompt' },
|
|
1032
1022
|
];
|
|
1033
1023
|
return [
|
|
1034
1024
|
{
|
|
@@ -1045,7 +1035,7 @@ window.__ModuleLoader__.load({
|
|
|
1045
1035
|
},
|
|
1046
1036
|
{
|
|
1047
1037
|
id: 'tpl-ab',
|
|
1048
|
-
name: en ? 'Parallel Options → Decide → Execute' : '并行方案对比 → 拍板 → 执行',
|
|
1038
|
+
name: en ? 'Parallel Options → Decide → Execute → Review' : '并行方案对比 → 拍板 → 执行 → 验收',
|
|
1049
1039
|
nodes: layoutGraph(abNodes, abEdges),
|
|
1050
1040
|
edges: abEdges,
|
|
1051
1041
|
},
|
|
@@ -1059,22 +1049,24 @@ window.__ModuleLoader__.load({
|
|
|
1059
1049
|
const task = String(entry.task || '').trim();
|
|
1060
1050
|
const rest = nodes.filter((n) => n.id !== 'lead');
|
|
1061
1051
|
if (!rest.length) return { error: '画布上还没有可执行的节点' };
|
|
1062
|
-
//
|
|
1063
|
-
//
|
|
1052
|
+
// Unconnected nodes, solo Lead-to-Lead nodes, and dangling dead-end agents
|
|
1053
|
+
// are shown dashed on the canvas and skipped at run time.
|
|
1064
1054
|
const reachableIds = reachableFrom(nodes, edges);
|
|
1055
|
+
const soloLeads = soloLeadNodeIds(nodes, edges);
|
|
1056
|
+
const deadEnds = deadEndNodeIds(nodes, edges);
|
|
1057
|
+
const isInactive = (n) => !reachableIds.has(n.id) || soloLeads.has(n.id) || deadEnds.has(n.id);
|
|
1065
1058
|
|
|
1066
|
-
const
|
|
1067
|
-
const
|
|
1068
|
-
.filter((e) => (e.from === 'lead' || ids.has(e.from)) && ids.has(e.to))
|
|
1069
|
-
.map((e) => ({ from: e.from, to: e.to, type: e.type || 'prompt' }));
|
|
1070
|
-
|
|
1071
|
-
// Unconnected nodes are left out of the plan instead of blocking the run.
|
|
1072
|
-
const skipped = rest.filter((n) => !reachableIds.has(n.id));
|
|
1073
|
-
const active = rest.filter((n) => reachableIds.has(n.id));
|
|
1059
|
+
const skipped = rest.filter((n) => isInactive(n));
|
|
1060
|
+
const active = rest.filter((n) => !isInactive(n));
|
|
1074
1061
|
if (!active.length) {
|
|
1075
|
-
return { error: '没有从入口 Lead
|
|
1062
|
+
return { error: '没有从入口 Lead 连通的有效节点,无法执行' };
|
|
1076
1063
|
}
|
|
1077
1064
|
|
|
1065
|
+
const activeIds = new Set(active.map((n) => n.id));
|
|
1066
|
+
const planEdges = edges
|
|
1067
|
+
.filter((e) => (e.from === 'lead' || activeIds.has(e.from)) && activeIds.has(e.to))
|
|
1068
|
+
.map((e) => ({ from: e.from, to: e.to, type: e.type || 'prompt' }));
|
|
1069
|
+
|
|
1078
1070
|
return {
|
|
1079
1071
|
plan: {
|
|
1080
1072
|
task,
|
|
@@ -1089,6 +1081,7 @@ window.__ModuleLoader__.load({
|
|
|
1089
1081
|
reasoning: n.reasoning || '',
|
|
1090
1082
|
preset: n.preset === 'minimal' ? 'minimal' : 'standard',
|
|
1091
1083
|
keepSession: Boolean(n.keepSession),
|
|
1084
|
+
memoryChildId: n.memoryChildId || '',
|
|
1092
1085
|
// A structured link is the only thing that decides this: no separate switch.
|
|
1093
1086
|
structured: planEdges.some((e) => e.from === n.id && e.type === 'structured'),
|
|
1094
1087
|
fallbackModel: n.fallbackModel || '',
|
|
@@ -1302,6 +1295,7 @@ window.__ModuleLoader__.load({
|
|
|
1302
1295
|
viewRef.current = view;
|
|
1303
1296
|
const [statusById, setStatusById] = useState({});
|
|
1304
1297
|
const [runsById, setRunsById] = useState({});
|
|
1298
|
+
const [sessionRunning, setSessionRunning] = useState(false);
|
|
1305
1299
|
const [presets, setPresets] = useState(loadPresets);
|
|
1306
1300
|
const [presetOpen, setPresetOpen] = useState(null);
|
|
1307
1301
|
const [presetName, setPresetName] = useState('');
|
|
@@ -1327,14 +1321,28 @@ window.__ModuleLoader__.load({
|
|
|
1327
1321
|
saveDoc(sessionId, { nodes, edges, enabled }, stamp === null ? undefined : stamp);
|
|
1328
1322
|
}, [sessionId, nodes, edges, enabled]);
|
|
1329
1323
|
|
|
1324
|
+
const planSig = (nextEnabled, curNodes, curEdges) => {
|
|
1325
|
+
const res = buildPlan(curNodes, curEdges);
|
|
1326
|
+
const payload = res.error
|
|
1327
|
+
? { enabled: nextEnabled, error: res.error }
|
|
1328
|
+
: { enabled: nextEnabled, plan: res.plan };
|
|
1329
|
+
return JSON.stringify(payload);
|
|
1330
|
+
};
|
|
1331
|
+
|
|
1330
1332
|
// Any structural edit after enabling leaves the Host copy stale,
|
|
1331
|
-
// except
|
|
1333
|
+
// except pure position drags (same plan signature) or updates from Host.
|
|
1332
1334
|
useEffect(() => {
|
|
1333
1335
|
if (skipDirtyOnce.current) {
|
|
1334
1336
|
skipDirtyOnce.current = false;
|
|
1335
1337
|
return;
|
|
1336
1338
|
}
|
|
1337
|
-
if (enabled)
|
|
1339
|
+
if (!enabled) return;
|
|
1340
|
+
const sig = planSig(true, nodes, edges);
|
|
1341
|
+
if (lastSync.current && sig === lastSync.current) {
|
|
1342
|
+
setDirty(false);
|
|
1343
|
+
return;
|
|
1344
|
+
}
|
|
1345
|
+
setDirty(true);
|
|
1338
1346
|
}, [nodes, edges]);
|
|
1339
1347
|
|
|
1340
1348
|
// A disabled canvas shows no run status at all.
|
|
@@ -1376,24 +1384,24 @@ window.__ModuleLoader__.load({
|
|
|
1376
1384
|
}, [openModelFor]);
|
|
1377
1385
|
|
|
1378
1386
|
// Publishing costs one visible command row in the conversation, so it only
|
|
1379
|
-
// happens when the user enables the canvas
|
|
1380
|
-
|
|
1387
|
+
// happens when the user enables the canvas, loads a preset/import, clears,
|
|
1388
|
+
// or asks for it explicitly.
|
|
1389
|
+
const pushPlan = (nextEnabled, overrideNodes, overrideEdges) => {
|
|
1381
1390
|
try {
|
|
1382
1391
|
const face = sessionFace(sessionId);
|
|
1383
1392
|
if (!face || typeof face.command !== 'function') { flash(t('syncFailed')); return; }
|
|
1384
|
-
const
|
|
1385
|
-
const
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
const sig = JSON.stringify(payload);
|
|
1389
|
-
if (sig === lastSync.current) { flash(t('upToDate')); return; }
|
|
1393
|
+
const curNodes = Array.isArray(overrideNodes) ? overrideNodes : nodesRef.current;
|
|
1394
|
+
const curEdges = Array.isArray(overrideEdges) ? overrideEdges : edgesRef.current;
|
|
1395
|
+
const sig = planSig(nextEnabled, curNodes, curEdges);
|
|
1396
|
+
if (sig === lastSync.current) { setDirty(false); flash(t('upToDate')); return; }
|
|
1390
1397
|
const line = '/canvas-sync ' + encodeURIComponent(sig);
|
|
1398
|
+
const hasStandardAgent = nextEnabled && curNodes.some((n) => n && n.kind !== 'lead' && (n.preset || 'standard') !== 'minimal');
|
|
1391
1399
|
face.command(line).then((ack) => {
|
|
1392
1400
|
if (ack && ack.ok) {
|
|
1393
1401
|
lastSync.current = sig;
|
|
1394
1402
|
setDirty(false);
|
|
1395
1403
|
snapshotStaleCatalog();
|
|
1396
|
-
flash(t('syncedToHost'));
|
|
1404
|
+
flash(hasStandardAgent ? t('syncedWithStdWarn') : t('syncedToHost'));
|
|
1397
1405
|
} else {
|
|
1398
1406
|
flash(t('syncFailed'));
|
|
1399
1407
|
}
|
|
@@ -1479,11 +1487,17 @@ window.__ModuleLoader__.load({
|
|
|
1479
1487
|
const timing = timingProj && timingProj.values && timingProj.values.subagentTiming;
|
|
1480
1488
|
if (entry.id) {
|
|
1481
1489
|
const prev = nextRuns[nodeId];
|
|
1490
|
+
const prevHistory = prev && Array.isArray(prev.history) ? prev.history : [];
|
|
1491
|
+
const exists = prevHistory.some((hItem) => hItem.childId === entry.id);
|
|
1492
|
+
const history = exists
|
|
1493
|
+
? prevHistory
|
|
1494
|
+
: prevHistory.concat([{ childId: entry.id, label, index: prevHistory.length + 1 }]);
|
|
1482
1495
|
nextRuns[nodeId] = {
|
|
1483
1496
|
childId: entry.id,
|
|
1484
1497
|
label,
|
|
1485
1498
|
mode: entry.mode || 'continuable',
|
|
1486
|
-
count:
|
|
1499
|
+
count: history.length,
|
|
1500
|
+
history,
|
|
1487
1501
|
};
|
|
1488
1502
|
}
|
|
1489
1503
|
if (child && child.running) {
|
|
@@ -1517,6 +1531,7 @@ window.__ModuleLoader__.load({
|
|
|
1517
1531
|
const stop = () => { if (timer) { clearInterval(timer); timer = null; } };
|
|
1518
1532
|
let wasRunning = false;
|
|
1519
1533
|
try { wasRunning = Boolean(face.getSnapshot().running); } catch (_e) { wasRunning = false; }
|
|
1534
|
+
setSessionRunning(wasRunning);
|
|
1520
1535
|
read();
|
|
1521
1536
|
if (wasRunning) timer = setInterval(read, 700);
|
|
1522
1537
|
const onSnapshot = () => {
|
|
@@ -1524,6 +1539,7 @@ window.__ModuleLoader__.load({
|
|
|
1524
1539
|
try { running = Boolean(face.getSnapshot().running); } catch (_e) { running = false; }
|
|
1525
1540
|
const finished = !running && wasRunning;
|
|
1526
1541
|
wasRunning = running;
|
|
1542
|
+
setSessionRunning(running);
|
|
1527
1543
|
if (running && !timer) { read(); timer = setInterval(read, 700); }
|
|
1528
1544
|
if (!running && timer) { stop(); read(); }
|
|
1529
1545
|
if (finished && typeof sessions.refreshProjections === 'function') {
|
|
@@ -1856,6 +1872,28 @@ window.__ModuleLoader__.load({
|
|
|
1856
1872
|
flash(t('layoutDone'));
|
|
1857
1873
|
};
|
|
1858
1874
|
|
|
1875
|
+
const clearCanvas = () => {
|
|
1876
|
+
const blank = [{ id: 'lead', kind: 'lead', x: 40, y: 203, label: 'Lead', task: '', provider: '', model: '', role: '' }];
|
|
1877
|
+
pushSnapshot();
|
|
1878
|
+
if (enabled) {
|
|
1879
|
+
skipDirtyOnce.current = true;
|
|
1880
|
+
setEnabled(false);
|
|
1881
|
+
setDirty(false);
|
|
1882
|
+
pushPlan(false, blank, []);
|
|
1883
|
+
}
|
|
1884
|
+
setNodes(blank);
|
|
1885
|
+
setEdges([]);
|
|
1886
|
+
setSelectedIds([]);
|
|
1887
|
+
setRoleEditFor(null);
|
|
1888
|
+
setOpenModelFor(null);
|
|
1889
|
+
setPresetOpen(null);
|
|
1890
|
+
setMenuOpen(false);
|
|
1891
|
+
snapshotStaleCatalog();
|
|
1892
|
+
setRunsById({});
|
|
1893
|
+
setTimeout(() => centerOn(40 + NODE_W / 2, 203 + NODE_H / 2, 1), 0);
|
|
1894
|
+
flash(t('clearedCanvas'));
|
|
1895
|
+
};
|
|
1896
|
+
|
|
1859
1897
|
const exportToClipboard = () => {
|
|
1860
1898
|
const cleanNodes = nodesRef.current.map((n) => {
|
|
1861
1899
|
const { runs: _runs, ...rest } = n;
|
|
@@ -2225,6 +2263,7 @@ window.__ModuleLoader__.load({
|
|
|
2225
2263
|
const threshold = 12 / (viewRef.current.k || 1);
|
|
2226
2264
|
const from = cutRef.current;
|
|
2227
2265
|
const steps = Math.max(1, Math.ceil(Math.hypot(p.x - from.x, p.y - from.y) / 6));
|
|
2266
|
+
const nodeMap = new Map(nodes.map((n) => [n.id, n]));
|
|
2228
2267
|
for (let step = 1; step <= steps; step += 1) {
|
|
2229
2268
|
const t = step / steps;
|
|
2230
2269
|
const canvasSpot = {
|
|
@@ -2233,8 +2272,8 @@ window.__ModuleLoader__.load({
|
|
|
2233
2272
|
};
|
|
2234
2273
|
for (const edge of edges) {
|
|
2235
2274
|
if (cutHits.current.has(edge.id)) continue;
|
|
2236
|
-
const source =
|
|
2237
|
-
const target =
|
|
2275
|
+
const source = nodeMap.get(edge.from);
|
|
2276
|
+
const target = nodeMap.get(edge.to);
|
|
2238
2277
|
if (!source || !target) continue;
|
|
2239
2278
|
if (distanceToEdge(canvasSpot, source, target, edge.type) <= threshold) {
|
|
2240
2279
|
cutHits.current.add(edge.id);
|
|
@@ -2452,6 +2491,7 @@ window.__ModuleLoader__.load({
|
|
|
2452
2491
|
doc = JSON.parse(text.slice(start, end + 1));
|
|
2453
2492
|
} catch (_e) { flash(t('importBad')); return; }
|
|
2454
2493
|
if (!applyCanvasDoc(doc.canvas || doc)) { flash(t('importBad')); return; }
|
|
2494
|
+
if (enabled) setTimeout(() => pushPlan(true), 0);
|
|
2455
2495
|
flash(t('importOk') + (doc.canvas || doc).nodes.length);
|
|
2456
2496
|
};
|
|
2457
2497
|
try {
|
|
@@ -2467,6 +2507,10 @@ window.__ModuleLoader__.load({
|
|
|
2467
2507
|
const preset = presets[name];
|
|
2468
2508
|
if (!preset || !Array.isArray(preset.nodes) || !Array.isArray(preset.edges)) { flash(t('invalidPreset')); return; }
|
|
2469
2509
|
pushSnapshot();
|
|
2510
|
+
if (enabled) {
|
|
2511
|
+
skipDirtyOnce.current = true;
|
|
2512
|
+
pushPlan(true, preset.nodes, preset.edges);
|
|
2513
|
+
}
|
|
2470
2514
|
setNodes(preset.nodes);
|
|
2471
2515
|
setEdges(preset.edges);
|
|
2472
2516
|
setSelectedIds([]);
|
|
@@ -2482,6 +2526,10 @@ window.__ModuleLoader__.load({
|
|
|
2482
2526
|
const clonedNodes = tpl.nodes.map((n) => ({ ...n }));
|
|
2483
2527
|
const clonedEdges = tpl.edges.map((e) => ({ ...e }));
|
|
2484
2528
|
pushSnapshot();
|
|
2529
|
+
if (enabled) {
|
|
2530
|
+
skipDirtyOnce.current = true;
|
|
2531
|
+
pushPlan(true, clonedNodes, clonedEdges);
|
|
2532
|
+
}
|
|
2485
2533
|
setNodes(clonedNodes);
|
|
2486
2534
|
setEdges(clonedEdges);
|
|
2487
2535
|
setSelectedIds([]);
|
|
@@ -2589,13 +2637,66 @@ window.__ModuleLoader__.load({
|
|
|
2589
2637
|
isOpen && h('div', { style: S.menu, onMouseDown: (e) => e.stopPropagation() }, rows),
|
|
2590
2638
|
);
|
|
2591
2639
|
};
|
|
2592
|
-
const memoryToggle = (node) =>
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2640
|
+
const memoryToggle = (node) => {
|
|
2641
|
+
const runInfo = runsById[node.id];
|
|
2642
|
+
const history = (runInfo && Array.isArray(runInfo.history)) ? runInfo.history : [];
|
|
2643
|
+
const showPicker = Boolean(node.keepSession);
|
|
2644
|
+
const key = 'm:' + node.id;
|
|
2645
|
+
const isOpen = openModelFor === key;
|
|
2646
|
+
const pickedItem = node.memoryChildId
|
|
2647
|
+
? history.find((item) => item.childId === node.memoryChildId)
|
|
2648
|
+
: undefined;
|
|
2649
|
+
const pickLabel = !node.memoryChildId
|
|
2650
|
+
? t('memLatest')
|
|
2651
|
+
: (pickedItem ? ('#' + pickedItem.index) : String(node.memoryChildId).slice(-6));
|
|
2652
|
+
const toggleBtn = h('button', {
|
|
2653
|
+
style: showPicker
|
|
2654
|
+
? { ...(node.keepSession ? S.toggleSwitchOn : S.toggleSwitch), flex: '0 0 34px', width: '34px' }
|
|
2655
|
+
: (node.keepSession ? S.toggleSwitchOn : S.toggleSwitch),
|
|
2656
|
+
type: 'button',
|
|
2657
|
+
title: t('tipMemory'),
|
|
2658
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
2659
|
+
onClick: () => updateNode(node.id, { keepSession: !node.keepSession }),
|
|
2660
|
+
}, node.keepSession ? t('on') : t('off'));
|
|
2661
|
+
if (!showPicker) return toggleBtn;
|
|
2662
|
+
const rows = [
|
|
2663
|
+
h('div', {
|
|
2664
|
+
key: 'latest',
|
|
2665
|
+
style: !node.memoryChildId ? { ...S.menuRow, background: C.hover, color: C.accent } : S.menuRow,
|
|
2666
|
+
onMouseEnter: (e) => { e.currentTarget.style.background = C.hover; },
|
|
2667
|
+
onMouseLeave: (e) => { e.currentTarget.style.background = !node.memoryChildId ? C.hover : 'transparent'; },
|
|
2668
|
+
onClick: () => { updateNode(node.id, { memoryChildId: '' }); setOpenModelFor(null); },
|
|
2669
|
+
}, t('memLatestOpt')),
|
|
2670
|
+
...history.map((item) => {
|
|
2671
|
+
const selectedRow = node.memoryChildId === item.childId;
|
|
2672
|
+
return h('div', {
|
|
2673
|
+
key: item.childId,
|
|
2674
|
+
style: selectedRow ? { ...S.menuRow, background: C.hover, color: C.accent } : S.menuRow,
|
|
2675
|
+
title: item.childId,
|
|
2676
|
+
onMouseEnter: (e) => { e.currentTarget.style.background = C.hover; },
|
|
2677
|
+
onMouseLeave: (e) => { e.currentTarget.style.background = selectedRow ? C.hover : 'transparent'; },
|
|
2678
|
+
onClick: () => { updateNode(node.id, { memoryChildId: item.childId }); setOpenModelFor(null); },
|
|
2679
|
+
}, t('memRunOpt').replace('{n}', String(item.index)) + ' (' + String(item.childId).slice(-5) + ')');
|
|
2680
|
+
}),
|
|
2681
|
+
!history.length && h('div', { key: 'mem-empty', style: S.presetEmpty }, t('memEmpty')),
|
|
2682
|
+
];
|
|
2683
|
+
return h('div', { style: { display: 'flex', alignItems: 'center', gap: '4px', flex: '1 1 auto', minWidth: 0 } },
|
|
2684
|
+
toggleBtn,
|
|
2685
|
+
h('div', { ref: isOpen ? dropdownRef : undefined, style: { position: 'relative', flex: '1 1 auto', minWidth: 0 } },
|
|
2686
|
+
h('button', {
|
|
2687
|
+
style: S.selectBtn,
|
|
2688
|
+
type: 'button',
|
|
2689
|
+
title: t('tipMemoryPick'),
|
|
2690
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
2691
|
+
onClick: () => setOpenModelFor(isOpen ? null : key),
|
|
2692
|
+
},
|
|
2693
|
+
h('span', { style: S.selectText }, pickLabel),
|
|
2694
|
+
h('span', { style: S.caret }, '▾'),
|
|
2695
|
+
),
|
|
2696
|
+
isOpen && h('div', { style: S.menu, onMouseDown: (e) => e.stopPropagation() }, rows),
|
|
2697
|
+
),
|
|
2698
|
+
);
|
|
2699
|
+
};
|
|
2599
2700
|
|
|
2600
2701
|
const reasoningControl = (node) => {
|
|
2601
2702
|
const key = 'r:' + node.id;
|
|
@@ -2687,15 +2788,14 @@ window.__ModuleLoader__.load({
|
|
|
2687
2788
|
}
|
|
2688
2789
|
const reachableIds = reachableFrom(nodes, edges);
|
|
2689
2790
|
const nodeById = new Map(nodes.map((n) => [n.id, n]));
|
|
2690
|
-
const
|
|
2691
|
-
const
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
// Identify intermediate/final Lead nodes whose upstream subagents are all
|
|
2697
|
-
// finished and whose downstream has not started yet ("Ready for Lead").
|
|
2791
|
+
const soloLeadIds = soloLeadNodeIds(nodes, edges);
|
|
2792
|
+
const deadEndIds = deadEndNodeIds(nodes, edges);
|
|
2793
|
+
|
|
2794
|
+
// Identify intermediate Lead nodes waiting for a decision ("Ready for Lead")
|
|
2795
|
+
// and terminal Lead nodes: a terminal Lead glows only while the conversation
|
|
2796
|
+
// is still streaming its final review; once the turn finishes it settles to Done.
|
|
2698
2797
|
const leadReadyIds = new Set();
|
|
2798
|
+
const leadDoneIds = new Set();
|
|
2699
2799
|
if (enabled) {
|
|
2700
2800
|
for (const n of nodes) {
|
|
2701
2801
|
if (n.kind !== 'lead' || n.id === 'lead' || !reachableIds.has(n.id)) continue;
|
|
@@ -2705,10 +2805,17 @@ window.__ModuleLoader__.load({
|
|
|
2705
2805
|
if (!upIds.length) continue;
|
|
2706
2806
|
const upAgents = upIds.filter((id) => nodeById.get(id).kind !== 'lead');
|
|
2707
2807
|
if (!upAgents.length) continue;
|
|
2708
|
-
const allUpDone = upAgents.every((id) => statusById[id] === 'done');
|
|
2808
|
+
const allUpDone = upAgents.every((id) => statusById[id] === 'done' || statusById[id] === 'failed');
|
|
2809
|
+
if (!allUpDone) continue;
|
|
2709
2810
|
const downIds = edges.filter((e) => e.from === n.id).map((e) => e.to);
|
|
2710
|
-
|
|
2711
|
-
|
|
2811
|
+
if (!downIds.length) {
|
|
2812
|
+
if (sessionRunning) leadReadyIds.add(n.id);
|
|
2813
|
+
else leadDoneIds.add(n.id);
|
|
2814
|
+
} else {
|
|
2815
|
+
const anyDownStarted = downIds.some((id) => Boolean(statusById[id]));
|
|
2816
|
+
if (!anyDownStarted) leadReadyIds.add(n.id);
|
|
2817
|
+
else leadDoneIds.add(n.id);
|
|
2818
|
+
}
|
|
2712
2819
|
}
|
|
2713
2820
|
}
|
|
2714
2821
|
|
|
@@ -2724,28 +2831,64 @@ window.__ModuleLoader__.load({
|
|
|
2724
2831
|
const toRunning = enabled && statusById[edge.to] === 'running';
|
|
2725
2832
|
const fromReady = edge.from === 'lead'
|
|
2726
2833
|
|| from.kind === 'lead'
|
|
2727
|
-
|| statusById[edge.from] === 'done'
|
|
2834
|
+
|| statusById[edge.from] === 'done'
|
|
2835
|
+
|| statusById[edge.from] === 'failed';
|
|
2728
2836
|
const isFlowing = enabled && !highlighted && (
|
|
2729
2837
|
(toRunning && fromReady)
|
|
2730
|
-
|| (leadReadyIds.has(edge.to) && statusById[edge.from] === 'done')
|
|
2838
|
+
|| (leadReadyIds.has(edge.to) && (statusById[edge.from] === 'done' || statusById[edge.from] === 'failed'))
|
|
2731
2839
|
);
|
|
2732
|
-
const
|
|
2733
|
-
|
|
2840
|
+
const fromSettled = edge.from === 'lead'
|
|
2841
|
+
|| statusById[edge.from] === 'done'
|
|
2842
|
+
|| statusById[edge.from] === 'failed'
|
|
2843
|
+
|| leadDoneIds.has(edge.from);
|
|
2844
|
+
const toSettled = statusById[edge.to] === 'done'
|
|
2845
|
+
|| statusById[edge.to] === 'running'
|
|
2846
|
+
|| statusById[edge.to] === 'failed'
|
|
2847
|
+
|| leadReadyIds.has(edge.to)
|
|
2848
|
+
|| leadDoneIds.has(edge.to);
|
|
2849
|
+
const isCompletedLink = enabled && !highlighted && fromSettled && toSettled;
|
|
2734
2850
|
const dimmed = hasSel && !linkedToSel && !highlighted && !isFlowing;
|
|
2851
|
+
const strokeColor = highlighted ? '#e5534b' : color;
|
|
2735
2852
|
const baseWidth = highlighted ? 3 : (linkedToSel || isFlowing ? 2.6 : 2);
|
|
2736
2853
|
const baseOpacity = dimmed ? 0.26 : (isFlowing || linkedToSel ? 1 : (isCompletedLink ? 0.92 : 0.78));
|
|
2737
|
-
const useGlow = fxLevel === 'vivid' && !dimmed
|
|
2854
|
+
const useGlow = fxLevel === 'vivid' && !dimmed;
|
|
2738
2855
|
const showDashFlow = isFlowing && fxLevel !== 'minimal';
|
|
2739
2856
|
const showBead = isFlowing && fxLevel === 'vivid';
|
|
2740
2857
|
|
|
2741
2858
|
return h('g', { key: edge.id, style: { pointerEvents: 'none' } },
|
|
2859
|
+
// Vector halo layers instead of an SVG objectBoundingBox <filter>, which
|
|
2860
|
+
// Chromium clips to 0px height on strictly horizontal links (from.y === to.y).
|
|
2861
|
+
useGlow && h('path', {
|
|
2862
|
+
d,
|
|
2863
|
+
stroke: strokeColor,
|
|
2864
|
+
strokeWidth: baseWidth + 7,
|
|
2865
|
+
strokeOpacity: showDashFlow ? 0.1 : 0.16,
|
|
2866
|
+
strokeLinecap: 'round',
|
|
2867
|
+
fill: 'none',
|
|
2868
|
+
}),
|
|
2869
|
+
useGlow && h('path', {
|
|
2870
|
+
d,
|
|
2871
|
+
stroke: strokeColor,
|
|
2872
|
+
strokeWidth: baseWidth + 3.2,
|
|
2873
|
+
strokeOpacity: showDashFlow ? 0.18 : 0.3,
|
|
2874
|
+
strokeLinecap: 'round',
|
|
2875
|
+
fill: 'none',
|
|
2876
|
+
}),
|
|
2742
2877
|
h('path', {
|
|
2743
2878
|
d,
|
|
2744
|
-
stroke:
|
|
2879
|
+
stroke: strokeColor,
|
|
2745
2880
|
strokeWidth: baseWidth,
|
|
2746
2881
|
strokeOpacity: showDashFlow ? 0.35 : baseOpacity,
|
|
2747
2882
|
fill: 'none',
|
|
2748
|
-
|
|
2883
|
+
}),
|
|
2884
|
+
showDashFlow && fxLevel === 'vivid' && h('path', {
|
|
2885
|
+
d,
|
|
2886
|
+
className: 'dsh-wc-edge-flow',
|
|
2887
|
+
stroke: color,
|
|
2888
|
+
strokeWidth: 6.4,
|
|
2889
|
+
strokeOpacity: 0.28,
|
|
2890
|
+
strokeLinecap: 'round',
|
|
2891
|
+
fill: 'none',
|
|
2749
2892
|
}),
|
|
2750
2893
|
showDashFlow && h('path', {
|
|
2751
2894
|
d,
|
|
@@ -2754,13 +2897,10 @@ window.__ModuleLoader__.load({
|
|
|
2754
2897
|
strokeWidth: fxLevel === 'vivid' ? 2.8 : 2.4,
|
|
2755
2898
|
strokeLinecap: 'round',
|
|
2756
2899
|
fill: 'none',
|
|
2757
|
-
filter: fxLevel === 'vivid' ? 'url(#dsh-wc-glow)' : undefined,
|
|
2758
2900
|
}),
|
|
2759
|
-
showBead && h('
|
|
2760
|
-
r:
|
|
2761
|
-
fill: color,
|
|
2762
|
-
filter: 'url(#dsh-wc-glow)',
|
|
2763
|
-
},
|
|
2901
|
+
showBead && h('g', null,
|
|
2902
|
+
h('circle', { r: 6.5, fill: color, fillOpacity: 0.28 }),
|
|
2903
|
+
h('circle', { r: 3.3, fill: color }),
|
|
2764
2904
|
h('animateMotion', {
|
|
2765
2905
|
dur: '1.25s',
|
|
2766
2906
|
repeatCount: 'indefinite',
|
|
@@ -2892,6 +3032,12 @@ window.__ModuleLoader__.load({
|
|
|
2892
3032
|
onMouseLeave: (e) => { e.currentTarget.style.background = 'transparent'; },
|
|
2893
3033
|
onClick: () => { setMenuOpen(false); autoLayout(); },
|
|
2894
3034
|
}, t('autoLayoutBtn')),
|
|
3035
|
+
h('div', {
|
|
3036
|
+
style: { ...S.moreRow, color: '#e5534b' },
|
|
3037
|
+
onMouseEnter: (e) => { e.currentTarget.style.background = C.hover; },
|
|
3038
|
+
onMouseLeave: (e) => { e.currentTarget.style.background = 'transparent'; },
|
|
3039
|
+
onClick: () => { clearCanvas(); },
|
|
3040
|
+
}, t('clearCanvasBtn')),
|
|
2895
3041
|
h('div', {
|
|
2896
3042
|
style: S.moreRow,
|
|
2897
3043
|
onMouseEnter: (e) => { e.currentTarget.style.background = C.hover; },
|
|
@@ -2949,6 +3095,12 @@ window.__ModuleLoader__.load({
|
|
|
2949
3095
|
const names = Object.keys(presets);
|
|
2950
3096
|
const templates = builtinTemplates(lang);
|
|
2951
3097
|
return h('div', { style: S.presetMenu, onMouseDown: (e) => e.stopPropagation() },
|
|
3098
|
+
h('div', {
|
|
3099
|
+
style: { ...S.presetRow, color: C.accent, fontWeight: 500, borderBottom: '1px solid ' + C.border, marginBottom: '4px', paddingBottom: '6px', borderRadius: '4px 4px 0 0' },
|
|
3100
|
+
onMouseEnter: (e) => { e.currentTarget.style.background = C.hover; },
|
|
3101
|
+
onMouseLeave: (e) => { e.currentTarget.style.background = 'transparent'; },
|
|
3102
|
+
onClick: () => clearCanvas(),
|
|
3103
|
+
}, h('span', { style: S.presetRowText }, t('newBlankCanvas'))),
|
|
2952
3104
|
h('div', { style: S.menuHead }, t('builtinTemplates')),
|
|
2953
3105
|
templates.map((tpl) => h('div', {
|
|
2954
3106
|
key: tpl.id,
|
|
@@ -3048,15 +3200,6 @@ window.__ModuleLoader__.load({
|
|
|
3048
3200
|
},
|
|
3049
3201
|
},
|
|
3050
3202
|
h('svg', { width: contentW, height: contentH, style: { position: 'absolute', left: 0, top: 0, pointerEvents: 'none', overflow: 'visible' } },
|
|
3051
|
-
fxLevel === 'vivid' && h('defs', null,
|
|
3052
|
-
h('filter', { id: 'dsh-wc-glow', x: '-30%', y: '-30%', width: '160%', height: '160%' },
|
|
3053
|
-
h('feGaussianBlur', { stdDeviation: '2.2', result: 'blur' }),
|
|
3054
|
-
h('feMerge', null,
|
|
3055
|
-
h('feMergeNode', { in: 'blur' }),
|
|
3056
|
-
h('feMergeNode', { in: 'SourceGraphic' }),
|
|
3057
|
-
),
|
|
3058
|
-
),
|
|
3059
|
-
),
|
|
3060
3203
|
h('g', null, edgeEls),
|
|
3061
3204
|
cutPath.length > 1 && h('polyline', {
|
|
3062
3205
|
points: cutPath.map((pt) => (pt.x + WORLD_PAD) + ',' + (pt.y + WORLD_PAD)).join(' '),
|
|
@@ -3096,12 +3239,15 @@ window.__ModuleLoader__.load({
|
|
|
3096
3239
|
}),
|
|
3097
3240
|
);
|
|
3098
3241
|
const isOrphan = node.id !== 'lead' && !reachableIds.has(node.id);
|
|
3242
|
+
const isSoloLead = soloLeadIds.has(node.id);
|
|
3099
3243
|
const isDeadEnd = deadEndIds.has(node.id);
|
|
3244
|
+
const isInactive = isOrphan || isSoloLead || isDeadEnd;
|
|
3100
3245
|
const isSelected = selectedSet.has(node.id);
|
|
3101
3246
|
const nodeStatus = enabled ? statusById[node.id] : undefined;
|
|
3102
3247
|
const isLeadReady = leadReadyIds.has(node.id);
|
|
3248
|
+
const isLeadDone = leadDoneIds.has(node.id);
|
|
3103
3249
|
const isRunning = !isLeadKind && nodeStatus === 'running';
|
|
3104
|
-
const isDone = !isLeadKind && nodeStatus === 'done';
|
|
3250
|
+
const isDone = (!isLeadKind && nodeStatus === 'done') || isLeadDone;
|
|
3105
3251
|
const isFailed = !isLeadKind && nodeStatus === 'failed';
|
|
3106
3252
|
const isPulsing = (isRunning || isLeadReady) && fxLevel !== 'minimal';
|
|
3107
3253
|
const nodeClass = 'dsh-wc-node'
|
|
@@ -3131,10 +3277,10 @@ window.__ModuleLoader__.load({
|
|
|
3131
3277
|
left: node.x + WORLD_PAD,
|
|
3132
3278
|
top: node.y + WORLD_PAD,
|
|
3133
3279
|
...(isLeadKind ? S.leadNode : null),
|
|
3134
|
-
...(
|
|
3280
|
+
...(isInactive ? S.orphanNode : null),
|
|
3135
3281
|
...(stateStyle || null),
|
|
3136
3282
|
},
|
|
3137
|
-
title: isOrphan ? t('orphanTip') : undefined,
|
|
3283
|
+
title: isOrphan ? t('orphanTip') : (isSoloLead ? t('tipSoloLead') : (isDeadEnd ? t('tipDeadEnd') : undefined)),
|
|
3138
3284
|
onMouseDown: (e) => onNodeDown(e, node.id),
|
|
3139
3285
|
},
|
|
3140
3286
|
h('div', {
|
|
@@ -3154,30 +3300,33 @@ window.__ModuleLoader__.load({
|
|
|
3154
3300
|
(() => {
|
|
3155
3301
|
const latestRun = !isLeadKind ? runsById[node.id] : null;
|
|
3156
3302
|
const statusColor = isLeadReady ? '#2f81f7'
|
|
3157
|
-
:
|
|
3158
|
-
:
|
|
3159
|
-
: nodeStatus === '
|
|
3160
|
-
: nodeStatus === '
|
|
3303
|
+
: isLeadDone ? '#3fb950'
|
|
3304
|
+
: isLeadKind ? C.dim
|
|
3305
|
+
: nodeStatus === 'running' ? '#2f81f7'
|
|
3306
|
+
: nodeStatus === 'failed' ? '#e5534b'
|
|
3307
|
+
: nodeStatus === 'done' ? '#3fb950' : C.dim;
|
|
3161
3308
|
const statusTint = isLeadReady || nodeStatus === 'running'
|
|
3162
3309
|
? 'rgba(47,129,247,0.14)'
|
|
3163
3310
|
: nodeStatus === 'failed'
|
|
3164
3311
|
? 'rgba(229,83,75,0.14)'
|
|
3165
|
-
:
|
|
3312
|
+
: isDone
|
|
3166
3313
|
? 'rgba(63,185,80,0.14)'
|
|
3167
3314
|
: 'transparent';
|
|
3168
3315
|
const statusLabel = isOrphan ? t('stOrphan')
|
|
3169
|
-
:
|
|
3170
|
-
:
|
|
3171
|
-
:
|
|
3172
|
-
:
|
|
3173
|
-
: nodeStatus === '
|
|
3316
|
+
: isSoloLead ? t('stSoloLead')
|
|
3317
|
+
: isLeadReady ? t('stLeadReady')
|
|
3318
|
+
: isLeadDone ? t('stDone')
|
|
3319
|
+
: isLeadKind ? t('stLead')
|
|
3320
|
+
: nodeStatus === 'running' ? t('stRunning')
|
|
3321
|
+
: nodeStatus === 'failed' ? t('stFailed')
|
|
3322
|
+
: nodeStatus === 'done' ? t('stDone') : t('stPending');
|
|
3174
3323
|
const glyph = nodeStatus === 'running'
|
|
3175
3324
|
? h('span', {
|
|
3176
3325
|
className: fxLevel !== 'minimal' ? 'dsh-wc-dot-live' : undefined,
|
|
3177
3326
|
style: { width: '6px', height: '6px', borderRadius: '50%', background: statusColor, flex: '0 0 auto' },
|
|
3178
3327
|
})
|
|
3179
3328
|
: isLeadReady ? h('span', { className: fxLevel !== 'minimal' ? 'dsh-wc-dot-live' : undefined }, '⏸')
|
|
3180
|
-
:
|
|
3329
|
+
: isDone ? '✓'
|
|
3181
3330
|
: nodeStatus === 'failed' ? '✕' : null;
|
|
3182
3331
|
if (latestRun) {
|
|
3183
3332
|
const label = enabled ? statusLabel : t('openChat');
|
|
@@ -3328,7 +3477,7 @@ window.__ModuleLoader__.load({
|
|
|
3328
3477
|
try { console.error('[workflow-canvas] apply failed', error); } catch (_e) { /* ignore */ }
|
|
3329
3478
|
}
|
|
3330
3479
|
},
|
|
3331
|
-
__test: { topoOrder, wouldCycle, layoutGraph, builtinTemplates, nextEffectLevel, zoomAroundPoint, scrubZoom,
|
|
3480
|
+
__test: { topoOrder, wouldCycle, soloLeadNodeIds, layoutGraph, builtinTemplates, deadEndNodeIds, nextEffectLevel, zoomAroundPoint, scrubZoom, buildPlan, loadDoc, saveDoc, storageKey, socketCenterY, distanceToEdge, edgeCurve },
|
|
3332
3481
|
};
|
|
3333
3482
|
},
|
|
3334
3483
|
});
|