dsh-workflow-canvas 1.3.0 → 1.4.1
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 +11 -8
- package/README.zh.md +11 -8
- package/client.js +1099 -297
- package/index.js +87 -13
- package/package.json +20 -2
- package/skills/workflow-canvas/SKILL.md +4 -3
package/index.js
CHANGED
|
@@ -138,6 +138,28 @@ function normalizeKind(rawKind) {
|
|
|
138
138
|
return 'agent';
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
+
/**
|
|
142
|
+
* Normalize a reference list (paths, URLs, or rules attached to a node or entry Lead).
|
|
143
|
+
* Accepts string arrays or `{ text | path }` objects; capped at 16 unique non-empty items.
|
|
144
|
+
*/
|
|
145
|
+
function normalizeRefs(rawRefs) {
|
|
146
|
+
if (!Array.isArray(rawRefs) || !rawRefs.length) return null;
|
|
147
|
+
const out = [];
|
|
148
|
+
const seen = new Set();
|
|
149
|
+
for (const raw of rawRefs) {
|
|
150
|
+
if (out.length >= 16) break;
|
|
151
|
+
let s = '';
|
|
152
|
+
if (typeof raw === 'string') s = raw.trim();
|
|
153
|
+
else if (raw && typeof raw === 'object') {
|
|
154
|
+
s = String(raw.text !== undefined ? raw.text : (raw.path !== undefined ? raw.path : '')).trim();
|
|
155
|
+
}
|
|
156
|
+
if (!s || seen.has(s)) continue;
|
|
157
|
+
seen.add(s);
|
|
158
|
+
out.push(s);
|
|
159
|
+
}
|
|
160
|
+
return out.length ? out : null;
|
|
161
|
+
}
|
|
162
|
+
|
|
141
163
|
function normalizeBranch(rawBranch) {
|
|
142
164
|
if (rawBranch === true) return 'true';
|
|
143
165
|
if (rawBranch === false) return 'false';
|
|
@@ -334,6 +356,14 @@ function briefFor(plan, node, results, failedMap, prunedSet) {
|
|
|
334
356
|
head.push('【下游】' + (downs.length ? downs.join('、') + ' 会使用你的输出。' : '你是终点,结果会直接交付给用户。'));
|
|
335
357
|
head.push('【要求】只完成你这一步;最终回复只输出简洁、可直接被下游或 Lead 消费的交付报告(结论、改动清单、关键接口/路径),不要包含思考独白、过程叙述或对其他并行节点的评价。若因环境或权限受限未能生成预期产物,必须在开头显式标注「【未完全交付】」并列出缺失项,不得把仅写脚本汇报为已完成。');
|
|
336
358
|
}
|
|
359
|
+
const mergedRefs = [];
|
|
360
|
+
const seenRefs = new Set();
|
|
361
|
+
for (const r of (normalizeRefs(plan && plan.refs) || []).concat(normalizeRefs(node && node.refs) || [])) {
|
|
362
|
+
if (!seenRefs.has(r)) { seenRefs.add(r); mergedRefs.push(r); }
|
|
363
|
+
}
|
|
364
|
+
if (mergedRefs.length) {
|
|
365
|
+
head.push('【参考资料 / 约束】\n' + mergedRefs.map((r) => '- ' + r).join('\n'));
|
|
366
|
+
}
|
|
337
367
|
let text = head.join('\n') + '\n';
|
|
338
368
|
for (const u of ups) {
|
|
339
369
|
const value = results[u.from.id];
|
|
@@ -470,6 +500,7 @@ async function spawnOnce(scope, plan, node, results, parent, signal, route, forc
|
|
|
470
500
|
text: outText,
|
|
471
501
|
reason: result && result.stopReason,
|
|
472
502
|
empty: isEmptyOutput(result),
|
|
503
|
+
childId: activation && activation.childId ? String(activation.childId) : '',
|
|
473
504
|
};
|
|
474
505
|
if (isCondition) {
|
|
475
506
|
outcome.decision = parseConditionDecision(result, outText, node);
|
|
@@ -531,7 +562,7 @@ async function spawnNode(scope, plan, node, results, parent, signal, sid, failed
|
|
|
531
562
|
if (continueFrom) {
|
|
532
563
|
const continued = await spawnOnce(scope, plan, node, results, parent, signal, undefined, continueFrom, sid, failedMap, prunedSet);
|
|
533
564
|
if (continued.ok) {
|
|
534
|
-
const out = { ok: true, empty: Boolean(continued.empty), text: continued.text + '\n(已在上游会话中继续)' };
|
|
565
|
+
const out = { ok: true, empty: Boolean(continued.empty), text: continued.text + '\n(已在上游会话中继续)', childId: continued.childId || continueFrom };
|
|
535
566
|
if (continued.decision) out.decision = continued.decision;
|
|
536
567
|
return out;
|
|
537
568
|
}
|
|
@@ -539,25 +570,25 @@ async function spawnNode(scope, plan, node, results, parent, signal, sid, failed
|
|
|
539
570
|
|
|
540
571
|
const first = await spawnOnce(scope, plan, node, results, parent, signal, undefined, undefined, sid, failedMap, prunedSet);
|
|
541
572
|
if (first.ok) {
|
|
542
|
-
const out = { ok: true, empty: Boolean(first.empty), text: first.text };
|
|
573
|
+
const out = { ok: true, empty: Boolean(first.empty), text: first.text, childId: first.childId || '' };
|
|
543
574
|
if (first.decision) out.decision = first.decision;
|
|
544
575
|
return out;
|
|
545
576
|
}
|
|
546
577
|
if (!node.fallbackModel && !node.fallbackProvider) {
|
|
547
578
|
const reason = first.reason || 'unknown';
|
|
548
|
-
return { ok: false, empty: false, reason, text: first.text + '\n(失败原因:' + reason + ',未配置备用模型)' };
|
|
579
|
+
return { ok: false, empty: false, reason, text: first.text + '\n(失败原因:' + reason + ',未配置备用模型)', childId: first.childId || '' };
|
|
549
580
|
}
|
|
550
581
|
const retry = await spawnOnce(scope, plan, node, results, parent, signal, {
|
|
551
582
|
provider: node.fallbackProvider,
|
|
552
583
|
model: node.fallbackModel,
|
|
553
584
|
}, undefined, sid, failedMap, prunedSet);
|
|
554
585
|
if (retry.ok) {
|
|
555
|
-
const out = { ok: true, empty: Boolean(retry.empty), text: retry.text + '\n(已用备用模型重试成功)' };
|
|
586
|
+
const out = { ok: true, empty: Boolean(retry.empty), text: retry.text + '\n(已用备用模型重试成功)', childId: retry.childId || '' };
|
|
556
587
|
if (retry.decision) out.decision = retry.decision;
|
|
557
588
|
return out;
|
|
558
589
|
}
|
|
559
590
|
const reason = retry.reason || 'unknown';
|
|
560
|
-
return { ok: false, empty: false, reason, text: retry.text + '\n(重试仍失败:' + reason + ')' };
|
|
591
|
+
return { ok: false, empty: false, reason, text: retry.text + '\n(重试仍失败:' + reason + ')', childId: retry.childId || first.childId || '' };
|
|
561
592
|
}
|
|
562
593
|
|
|
563
594
|
/** Ids reachable from the entry Lead via O(V + E) BFS; every other node is skipped at run time. */
|
|
@@ -599,7 +630,8 @@ function inactiveNodeSets(nodes, edges) {
|
|
|
599
630
|
const src = byId.get(e.from);
|
|
600
631
|
return Boolean(src && src.kind !== 'lead');
|
|
601
632
|
});
|
|
602
|
-
|
|
633
|
+
const hasRole = Boolean(String(n.role || '').trim());
|
|
634
|
+
if (!hasAgentUp && !hasRole) soloLeads.add(n.id);
|
|
603
635
|
}
|
|
604
636
|
|
|
605
637
|
const deadEnds = new Set();
|
|
@@ -652,7 +684,7 @@ function analyzeCanvasWarnings(nodes, edges) {
|
|
|
652
684
|
}
|
|
653
685
|
const soloList = list.filter((n) => soloLeads.has(n.id));
|
|
654
686
|
if (soloList.length) {
|
|
655
|
-
warnings.push('以下 Lead
|
|
687
|
+
warnings.push('以下 Lead 节点未连入子代理且未填写分工(role),运行时不生效:'
|
|
656
688
|
+ soloList.map((n) => (n.label || n.id) + '(' + n.id + ')').join('、'));
|
|
657
689
|
}
|
|
658
690
|
const deadList = list.filter((n) => deadEnds.has(n.id));
|
|
@@ -713,6 +745,8 @@ function normalizeCanvas(args) {
|
|
|
713
745
|
x: 0,
|
|
714
746
|
y: 0,
|
|
715
747
|
};
|
|
748
|
+
const normRefs = normalizeRefs(raw.refs);
|
|
749
|
+
if (normRefs) nodeObj.refs = normRefs;
|
|
716
750
|
if (nodeObj.kind === 'condition') {
|
|
717
751
|
const customBranches = normalizeBranches(raw.branches);
|
|
718
752
|
if (customBranches) nodeObj.branches = customBranches;
|
|
@@ -770,6 +804,8 @@ function normalizeCanvas(args) {
|
|
|
770
804
|
} else if (!entry.task) {
|
|
771
805
|
entry.task = String(args.task || '') || entry.role;
|
|
772
806
|
}
|
|
807
|
+
const topRefs = normalizeRefs(args && args.refs);
|
|
808
|
+
if (topRefs && !entry.refs) entry.refs = topRefs;
|
|
773
809
|
|
|
774
810
|
// If entry Lead still has no outgoing edges, auto-wire it to all root nodes so
|
|
775
811
|
// a freshly generated canvas is never dead/unreachable on arrival.
|
|
@@ -842,6 +878,11 @@ function applyPatch(plan, args) {
|
|
|
842
878
|
if (patch.multiMatch) existing.multiMatch = true;
|
|
843
879
|
else delete existing.multiMatch;
|
|
844
880
|
}
|
|
881
|
+
if (patch.refs !== undefined) {
|
|
882
|
+
const nr = normalizeRefs(patch.refs);
|
|
883
|
+
if (nr) existing.refs = nr;
|
|
884
|
+
else delete existing.refs;
|
|
885
|
+
}
|
|
845
886
|
touched.push(patch.id);
|
|
846
887
|
} else {
|
|
847
888
|
const created = {
|
|
@@ -862,6 +903,10 @@ function applyPatch(plan, args) {
|
|
|
862
903
|
if (created.kind === 'condition' && patch.multiMatch === true) {
|
|
863
904
|
created.multiMatch = true;
|
|
864
905
|
}
|
|
906
|
+
if (patch.refs !== undefined) {
|
|
907
|
+
const nr = normalizeRefs(patch.refs);
|
|
908
|
+
if (nr) created.refs = nr;
|
|
909
|
+
}
|
|
865
910
|
nodes.push(created);
|
|
866
911
|
byId.set(created.id, created);
|
|
867
912
|
touched.push(created.id);
|
|
@@ -901,10 +946,16 @@ function applyPatch(plan, args) {
|
|
|
901
946
|
}
|
|
902
947
|
const taskPatched = typeof (args && args.task) === 'string';
|
|
903
948
|
const nextTask = taskPatched ? args.task : String(plan.task || '');
|
|
949
|
+
const refsPatched = args && args.refs !== undefined;
|
|
950
|
+
const nextRefs = refsPatched ? normalizeRefs(args.refs) : normalizeRefs(plan.refs);
|
|
951
|
+
const nextPlan = { ...plan, task: nextTask, nodes: keptNodes, edges };
|
|
952
|
+
if (nextRefs) nextPlan.refs = nextRefs;
|
|
953
|
+
else delete nextPlan.refs;
|
|
904
954
|
return {
|
|
905
|
-
plan:
|
|
955
|
+
plan: nextPlan,
|
|
906
956
|
touched,
|
|
907
957
|
taskPatched,
|
|
958
|
+
refsPatched,
|
|
908
959
|
removed: Array.from(removed),
|
|
909
960
|
removeEdges: rawRemoveEdges
|
|
910
961
|
.filter((r) => r && typeof r.from === 'string' && typeof r.to === 'string')
|
|
@@ -1004,6 +1055,8 @@ function inspectPlan(sid) {
|
|
|
1004
1055
|
if (nb) item.branches = nb;
|
|
1005
1056
|
if (n.multiMatch) item.multiMatch = true;
|
|
1006
1057
|
}
|
|
1058
|
+
const nr = normalizeRefs(n.refs);
|
|
1059
|
+
if (nr) item.refs = nr;
|
|
1007
1060
|
return item;
|
|
1008
1061
|
});
|
|
1009
1062
|
const edges = Array.isArray(plan.edges) ? plan.edges.map((e) => {
|
|
@@ -1016,6 +1069,7 @@ function inspectPlan(sid) {
|
|
|
1016
1069
|
if (branch) out.branch = branch;
|
|
1017
1070
|
return out;
|
|
1018
1071
|
}) : [];
|
|
1072
|
+
const planRefs = normalizeRefs(plan.refs);
|
|
1019
1073
|
const out = {
|
|
1020
1074
|
hasCanvas: true,
|
|
1021
1075
|
enabled: Boolean(payload.enabled),
|
|
@@ -1025,6 +1079,7 @@ function inspectPlan(sid) {
|
|
|
1025
1079
|
warnings: analyzeCanvasWarnings(nodes, edges),
|
|
1026
1080
|
paused: Boolean(sid && runBySession.get(sid) && runBySession.get(sid).waitingLead),
|
|
1027
1081
|
};
|
|
1082
|
+
if (planRefs) out.refs = planRefs;
|
|
1028
1083
|
// Never attach `error: undefined`: DSH's lossless JSON validator rejects keys with undefined values.
|
|
1029
1084
|
if (payload.error) out.error = String(payload.error);
|
|
1030
1085
|
return out;
|
|
@@ -1252,6 +1307,7 @@ async function executePlan(scope, plan, args, exec) {
|
|
|
1252
1307
|
if (!sid) return;
|
|
1253
1308
|
publishRunState(scope, sid, {
|
|
1254
1309
|
status,
|
|
1310
|
+
done: Array.from(state.done || []),
|
|
1255
1311
|
decisions: { ...state.decisions },
|
|
1256
1312
|
pruned: Array.from(state.pruned || []),
|
|
1257
1313
|
blockedEdges: Array.from(state.blockedEdges || []),
|
|
@@ -1639,6 +1695,7 @@ async function executePlan(scope, plan, args, exec) {
|
|
|
1639
1695
|
if (!hasDownstreamWork && leadResult === undefined) {
|
|
1640
1696
|
// Terminal Lead: zero downstream nodes remain, so complete the run directly
|
|
1641
1697
|
// and hand off final review/delivery to the Lead without a redundant extra turn.
|
|
1698
|
+
state.done.add(leadNode.id);
|
|
1642
1699
|
snapshotLastRun(false);
|
|
1643
1700
|
emitRunState('done', null);
|
|
1644
1701
|
if (sid) runBySession.delete(sid);
|
|
@@ -1649,6 +1706,7 @@ async function executePlan(scope, plan, args, exec) {
|
|
|
1649
1706
|
label: leadNode.label,
|
|
1650
1707
|
role: leadNode.role || leadNode.label,
|
|
1651
1708
|
needs: depsOf(leadNode).map((id) => byId.get(id).label),
|
|
1709
|
+
...(normalizeRefs(leadNode.refs) ? { refs: normalizeRefs(leadNode.refs) } : {}),
|
|
1652
1710
|
},
|
|
1653
1711
|
results: state.results,
|
|
1654
1712
|
labels: state.labels,
|
|
@@ -1676,6 +1734,7 @@ async function executePlan(scope, plan, args, exec) {
|
|
|
1676
1734
|
label: leadNode.label,
|
|
1677
1735
|
role: leadNode.role || leadNode.label,
|
|
1678
1736
|
needs: depsOf(leadNode).map((id) => byId.get(id).label),
|
|
1737
|
+
...(normalizeRefs(leadNode.refs) ? { refs: normalizeRefs(leadNode.refs) } : {}),
|
|
1679
1738
|
},
|
|
1680
1739
|
results: state.results,
|
|
1681
1740
|
labels: state.labels,
|
|
@@ -1801,6 +1860,7 @@ export function apply(ctx) {
|
|
|
1801
1860
|
type: 'object',
|
|
1802
1861
|
properties: {
|
|
1803
1862
|
task: { type: 'string', description: 'Overall task written into the auto-created entry Lead node (id="lead").' },
|
|
1863
|
+
refs: { type: 'array', description: 'Optional global reference files, URLs, or rules attached to the entry Lead and injected into all subagents.', items: { type: 'string' } },
|
|
1804
1864
|
nodes: {
|
|
1805
1865
|
type: 'array',
|
|
1806
1866
|
description: 'Nodes in any order (do not include an entry Lead — wire from "lead" instead). Give each an id or ref so edges can point at it.',
|
|
@@ -1822,6 +1882,11 @@ export function apply(ctx) {
|
|
|
1822
1882
|
keepSession: { type: 'boolean' },
|
|
1823
1883
|
fallbackModel: { type: 'string' },
|
|
1824
1884
|
fallbackProvider: { type: 'string' },
|
|
1885
|
+
refs: {
|
|
1886
|
+
type: 'array',
|
|
1887
|
+
description: 'Optional reference files, paths, or rules attached to this node and injected into its brief.',
|
|
1888
|
+
items: { type: 'string' },
|
|
1889
|
+
},
|
|
1825
1890
|
branches: {
|
|
1826
1891
|
type: 'array',
|
|
1827
1892
|
description: 'Optional (condition nodes only): custom switch/case branch names (strings or { id, label }, 2 or more). Omit for default true/false.',
|
|
@@ -1898,13 +1963,17 @@ export function apply(ctx) {
|
|
|
1898
1963
|
const canvas = { nodes: result.nodes, edges: result.edges, enabled: nextEnabled };
|
|
1899
1964
|
const delivered = sid ? publishCanvas(scope, sid, canvas) : false;
|
|
1900
1965
|
if (sid) {
|
|
1966
|
+
const entryNode = canvas.nodes.find((n) => n && n.id === 'lead');
|
|
1967
|
+
const planObj = {
|
|
1968
|
+
task: String(result.task || (args && args.task) || ''),
|
|
1969
|
+
nodes: withoutEntry(canvas.nodes),
|
|
1970
|
+
edges: canvas.edges,
|
|
1971
|
+
};
|
|
1972
|
+
const entryRefs = normalizeRefs(entryNode && entryNode.refs);
|
|
1973
|
+
if (entryRefs) planObj.refs = entryRefs;
|
|
1901
1974
|
canvasBySession.set(sid, {
|
|
1902
1975
|
enabled: nextEnabled,
|
|
1903
|
-
plan:
|
|
1904
|
-
task: String(result.task || (args && args.task) || ''),
|
|
1905
|
-
nodes: withoutEntry(canvas.nodes),
|
|
1906
|
-
edges: canvas.edges,
|
|
1907
|
-
},
|
|
1976
|
+
plan: planObj,
|
|
1908
1977
|
});
|
|
1909
1978
|
runBySession.delete(sid);
|
|
1910
1979
|
lastRunBySession.delete(sid);
|
|
@@ -1931,6 +2000,7 @@ export function apply(ctx) {
|
|
|
1931
2000
|
type: 'object',
|
|
1932
2001
|
properties: {
|
|
1933
2002
|
task: { type: 'string', description: 'Optional: update the overall task in the entry Lead node.' },
|
|
2003
|
+
refs: { type: 'array', description: 'Optional: replace global reference files/rules on the entry Lead node.', items: { type: 'string' } },
|
|
1934
2004
|
nodes: { type: 'array', description: 'Nodes to update or add. Existing ids are merged field by field.', items: { type: 'object' } },
|
|
1935
2005
|
removeNodes: { type: 'array', description: 'Node ids to delete.', items: { type: 'string' } },
|
|
1936
2006
|
edges: { type: 'array', description: 'Links to add.', items: { type: 'object' } },
|
|
@@ -1976,6 +2046,7 @@ export function apply(ctx) {
|
|
|
1976
2046
|
removeEdges: patched.removeEdges,
|
|
1977
2047
|
};
|
|
1978
2048
|
if (patched.taskPatched) patchDoc.task = nextPlan.task;
|
|
2049
|
+
if (patched.refsPatched) patchDoc.refs = nextPlan.refs || [];
|
|
1979
2050
|
const delivered = publishCanvas(scope, sid, patchDoc);
|
|
1980
2051
|
const warnings = analyzeCanvasWarnings(nextPlan.nodes, nextPlan.edges);
|
|
1981
2052
|
const summary = '已更新 ' + patched.touched.length + ' 个节点'
|
|
@@ -2009,6 +2080,7 @@ export function apply(ctx) {
|
|
|
2009
2080
|
hasCanvas: { type: 'boolean' },
|
|
2010
2081
|
enabled: { type: 'boolean' },
|
|
2011
2082
|
task: { type: 'string' },
|
|
2083
|
+
refs: { type: 'array', items: { type: 'string' } },
|
|
2012
2084
|
nodes: { type: 'array' },
|
|
2013
2085
|
edges: { type: 'array' },
|
|
2014
2086
|
warnings: { type: 'array', items: { type: 'string' } },
|
|
@@ -2038,6 +2110,7 @@ export function apply(ctx) {
|
|
|
2038
2110
|
: ''));
|
|
2039
2111
|
if (n.multiMatch) flags.push('多选');
|
|
2040
2112
|
}
|
|
2113
|
+
if (Array.isArray(n.refs) && n.refs.length) flags.push('参考×' + n.refs.length);
|
|
2041
2114
|
if (n.model) flags.push(n.model);
|
|
2042
2115
|
if (n.reasoning) flags.push('reasoning=' + n.reasoning);
|
|
2043
2116
|
if (n.preset === 'minimal') flags.push('minimal');
|
|
@@ -2215,6 +2288,7 @@ export {
|
|
|
2215
2288
|
downstreamLabels,
|
|
2216
2289
|
briefFor,
|
|
2217
2290
|
normalizeBranches,
|
|
2291
|
+
normalizeRefs,
|
|
2218
2292
|
parseConditionDecision,
|
|
2219
2293
|
withoutEntry,
|
|
2220
2294
|
analyzeCanvasWarnings,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-workflow-canvas",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "A visual
|
|
3
|
+
"version": "1.4.1",
|
|
4
|
+
"description": "A visual multi-agent workflow canvas for DeepSeek Harness — parallel subagents, conditional branching & Lead decision gates in the sidebar.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"exports": {
|
|
@@ -24,6 +24,24 @@
|
|
|
24
24
|
"README.zh.md"
|
|
25
25
|
],
|
|
26
26
|
"license": "MIT",
|
|
27
|
+
"author": "Wasabi2575",
|
|
28
|
+
"homepage": "https://github.com/Wasabi2575/dsh-workflow-canvas#readme",
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/Wasabi2575/dsh-workflow-canvas/issues"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"dsh",
|
|
34
|
+
"deepseek-harness",
|
|
35
|
+
"dsh-plugin",
|
|
36
|
+
"deepseek",
|
|
37
|
+
"workflow",
|
|
38
|
+
"multi-agent",
|
|
39
|
+
"subagent",
|
|
40
|
+
"canvas",
|
|
41
|
+
"node-graph",
|
|
42
|
+
"ai-agents",
|
|
43
|
+
"agent-orchestration"
|
|
44
|
+
],
|
|
27
45
|
"repository": {
|
|
28
46
|
"type": "git",
|
|
29
47
|
"url": "git+https://github.com/Wasabi2575/dsh-workflow-canvas.git"
|
|
@@ -10,9 +10,10 @@ A canvas is a DAG of agents the user can see and edit.
|
|
|
10
10
|
## Node kinds
|
|
11
11
|
|
|
12
12
|
- **Entry Lead** (`id: "lead"`, blue top bar) — created automatically by `canvas_generate` to hold the overall `task`. **Do not author a separate entry Lead node** — wire first-wave nodes directly from `from: "lead"`. The entry Lead **never** triggers `need-lead` (it does not pause before Wave 1).
|
|
13
|
-
- **Downstream Lead** (`kind: "lead"`, blue top bar) — performed by the conversation itself, never spawned. Any added non-entry Lead node holds a `role` and pauses the run (`status: "need-lead"`) so you can decide, review, or integrate before continuing.
|
|
13
|
+
- **Downstream Lead** (`kind: "lead"`, blue top bar) — performed by the conversation itself, never spawned. Any added non-entry Lead node holds a `role` and pauses the run (`status: "need-lead"`) so you can decide, review, or integrate before continuing. Direct `Lead → Lead` stage chains are supported (zero subagents spawned) as long as each chained Lead has a non-empty `role` describing its main-conversation stage.
|
|
14
14
|
- **Subagent** (`kind: "agent"`, green top bar) — spawned as a child agent with its own model, reasoning effort, capability scope, fallback model and memory switch. Wire every subagent's output into a downstream node or final Lead so nothing becomes a dead end.
|
|
15
15
|
- **Condition** (`kind: "condition"`, amber top bar) — lightweight read-only (`minimal`) branch judge that evaluates upstream outputs (including failure/incomplete flags) against `role`. Defaults to binary `if/else` (`branch: "true"` / `"false"`, returning `{ pass, reason }`); set `branches: ["通过", "小修", "重做"]` (2+ entries) for multi-way `switch/case` routing (`{ branches: [...], reason }`), with optional `multiMatch: true` to run all matching branches in parallel (and returning `[]` skips all downstream branches when none match). Unchosen branches are pruned automatically without spawning (even when a side `session-ref` wire connects an upstream ancestor into a pruned branch), and branches can converge back into a shared downstream node or terminal Lead.
|
|
16
|
+
- **References** (`refs: string[]`) — attach up to 16 reference file paths, URLs, or shared rules to Entry Lead (global `refs`, injected into every subagent) or any individual node (`node.refs`), cleanly replacing boilerplate read-only loader nodes.
|
|
16
17
|
|
|
17
18
|
## Which tool to call
|
|
18
19
|
|
|
@@ -27,7 +28,7 @@ Prefer `canvas_patch` for edits: it merges by node id, so renamed, re-roled or r
|
|
|
27
28
|
|
|
28
29
|
## Node fields
|
|
29
30
|
|
|
30
|
-
`id` (stable handle, never reuse it for a different node), `kind` (`lead`, `agent`, or `condition`), `label` (display name), `role` (what this step must do, or for `condition` nodes the routing rule), `branches` (optional for `condition` nodes: 2–
|
|
31
|
+
`id` (stable handle, never reuse it for a different node), `kind` (`lead`, `agent`, or `condition`), `label` (display name), `role` (what this step must do, or for `condition` nodes the routing rule), `refs` (optional up to 16 reference paths/URLs/rules; also accepted at top level for Entry Lead), `branches` (optional for `condition` nodes: 2–16 branch names for `switch/case`), `provider` / `model`, `reasoning` (an effort id declared by that model), `preset` (`standard` or `minimal`), `keepSession`, `fallbackModel` / `fallbackProvider`.
|
|
31
32
|
|
|
32
33
|
Fill `role` for every node. A node with an empty role still runs, but it invents its own task and may wander.
|
|
33
34
|
|
|
@@ -52,7 +53,7 @@ Output sockets determine link type; every non-entry node has a single universal
|
|
|
52
53
|
|
|
53
54
|
1. The canvas must be enabled (the pill over the canvas); `canvas_workflow` refuses while it is disabled. While enabled, the host automatically injects a per-session runtime context reminder on each turn.
|
|
54
55
|
2. You may pass `task` to override the entry Lead's task (handy when reusing a preset), `reset: true` to discard a paused run and start from scratch, `retryFailed: true` to reuse succeeded nodes and re-run only failed/empty/unfinished nodes plus their downstream, `fromNodes: [...]` to re-run from specific node ids/labels, `clearMemory: true` to forget saved `keepSession` child sessions, and `maxParallel` (1–8) to adjust concurrency.
|
|
55
|
-
3.
|
|
56
|
+
3. Chained Lead nodes with **both** zero subagent upstream **and** an empty `role` — as well as dangling dead-end subagents (zero outgoing edges while an active downstream Lead exists) — are rendered dashed on the canvas and skipped at run time. Chained `Lead → Lead` stages with a non-empty `role` (or Lead + Subagent → Lead) are valid and active.
|
|
56
57
|
4. Subagent capability (`preset: standard | minimal`) narrows the toolset within the main chat's permission ceiling; it cannot elevate past the parent session's sandbox/approval mode.
|
|
57
58
|
3. Subagent nodes run in a dynamic concurrency pool of up to four: as soon as any node finishes, newly unblocked downstream subagents start immediately without waiting for slower siblings.
|
|
58
59
|
4. Intermediate downstream Lead nodes pause the run (`status: "need-lead"`). Complete that Lead step yourself, then call `canvas_workflow` again with `leadResult` to resume downstream nodes — do not spawn an agent for it.
|