dsh-workflow-canvas 1.0.0 → 1.0.2

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/client.js CHANGED
@@ -1,4 +1,6 @@
1
1
  window.__ModuleLoader__.load({
2
+ // Must stay identical to the published package name; DSH matches the sidebar
3
+ // client bundle by this id and silently skips loading if it drifts.
2
4
  id: 'dsh-workflow-canvas',
3
5
  factory(require) {
4
6
  const React = require('react');
@@ -42,6 +44,8 @@ window.__ModuleLoader__.load({
42
44
 
43
45
  const FX_KEY = STORAGE_PREFIX + 'fx';
44
46
  const FX_LEVELS = ['minimal', 'standard', 'vivid'];
47
+ const PARALLEL_KEY = STORAGE_PREFIX + 'maxParallel';
48
+ const PARALLEL_STEPS = [1, 2, 4, 6, 8];
45
49
  const STYLE_ID = 'dsh-workflow-canvas-styles';
46
50
 
47
51
  /** Inject scoped CSS keyframes once; never touches host selectors. */
@@ -184,6 +188,8 @@ window.__ModuleLoader__.load({
184
188
  fxMinimal: '极简',
185
189
  fxStandard: '标准',
186
190
  fxVivid: '炫酷',
191
+ maxParallelLabel: '最大并发',
192
+ tipMaxParallel: '默认 4 路并行(可选 1 / 2 / 4 / 6 / 8)。并发过高容易触发 API 限流(429)、增加多子代理同时写同一工作区的文件冲突,并放大单轮报错时的额度消耗;纯只读调研可适当调高。',
187
193
  tipLeadReady: '上游节点已全部完成,正等待在对话里拍板继续',
188
194
  stDeadEnd: '无出边',
189
195
  tipDeadEnd: '该子代理没有下游连线,运行时不生效;请连入下游节点或终审 Lead',
@@ -294,6 +300,8 @@ window.__ModuleLoader__.load({
294
300
  fxMinimal: 'Minimal',
295
301
  fxStandard: 'Standard',
296
302
  fxVivid: 'Vivid',
303
+ maxParallelLabel: 'Max parallel',
304
+ tipMaxParallel: 'Default 4 concurrent subagents (1 / 2 / 4 / 6 / 8). Higher concurrency can trigger API rate limits (429), increase workspace file-edit conflicts, and widen token spend on failure; raising it is safest for read-only research.',
297
305
  tipLeadReady: 'Upstream steps are done; waiting for Lead in chat',
298
306
  stDeadEnd: 'No out-link',
299
307
  tipDeadEnd: 'This subagent has no outgoing link and is skipped at run time; wire it into a downstream node or Lead',
@@ -1043,7 +1051,7 @@ window.__ModuleLoader__.load({
1043
1051
  }
1044
1052
 
1045
1053
  /** Everything the Host executor needs; no prompts are pre-rendered here. */
1046
- function buildPlan(nodes, edges) {
1054
+ function buildPlan(nodes, edges, opts) {
1047
1055
  const entry = nodes.find((n) => n.id === 'lead');
1048
1056
  if (!entry) return { error: '缺少入口 Lead 节点' };
1049
1057
  const task = String(entry.task || '').trim();
@@ -1067,9 +1075,14 @@ window.__ModuleLoader__.load({
1067
1075
  .filter((e) => (e.from === 'lead' || activeIds.has(e.from)) && activeIds.has(e.to))
1068
1076
  .map((e) => ({ from: e.from, to: e.to, type: e.type || 'prompt' }));
1069
1077
 
1078
+ const maxParallel = opts && Number.isFinite(Number(opts.maxParallel))
1079
+ ? Math.max(1, Math.min(8, Math.floor(Number(opts.maxParallel))))
1080
+ : 4;
1081
+
1070
1082
  return {
1071
1083
  plan: {
1072
1084
  task,
1085
+ maxParallel,
1073
1086
  skipped: skipped.map((n) => n.label || n.id),
1074
1087
  nodes: active.map((n) => ({
1075
1088
  id: n.id,
@@ -1129,6 +1142,25 @@ window.__ModuleLoader__.load({
1129
1142
  return FX_LEVELS[(idx + 1) % FX_LEVELS.length];
1130
1143
  }
1131
1144
 
1145
+ function loadMaxParallel() {
1146
+ try {
1147
+ const raw = Number(window.localStorage.getItem(PARALLEL_KEY));
1148
+ if (Number.isFinite(raw) && raw >= 1 && raw <= 8) return Math.floor(raw);
1149
+ } catch (_e) { /* ignore */ }
1150
+ return 4;
1151
+ }
1152
+
1153
+ function saveMaxParallel(n) {
1154
+ try {
1155
+ if (Number.isFinite(n) && n >= 1 && n <= 8) window.localStorage.setItem(PARALLEL_KEY, String(Math.floor(n)));
1156
+ } catch (_e) { /* ignore */ }
1157
+ }
1158
+
1159
+ function nextMaxParallel(cur) {
1160
+ const idx = PARALLEL_STEPS.indexOf(Number(cur));
1161
+ return PARALLEL_STEPS[(idx + 1) % PARALLEL_STEPS.length];
1162
+ }
1163
+
1132
1164
  /** Compute the next `{ k, x, y }` keeping the content point under `(mx, my)` fixed. */
1133
1165
  function zoomAroundPoint(cur, mx, my, deltaY, deltaMode) {
1134
1166
  if (!deltaY) return cur;
@@ -1259,6 +1291,9 @@ window.__ModuleLoader__.load({
1259
1291
  const [helpOpen, setHelpOpen] = useState(false);
1260
1292
  const [cutMode, setCutMode] = useState(loadCutMode);
1261
1293
  const [fxLevel, setFxLevel] = useState(loadEffectLevel);
1294
+ const [maxParallel, setMaxParallel] = useState(loadMaxParallel);
1295
+ const maxParallelRef = useRef(maxParallel);
1296
+ maxParallelRef.current = maxParallel;
1262
1297
  useEffect(() => { ensureStyles(); }, []);
1263
1298
  const cutRef = useRef(null);
1264
1299
  /** Timestamp of the remote document being applied, so saving it does not bump the clock. */
@@ -1321,8 +1356,12 @@ window.__ModuleLoader__.load({
1321
1356
  saveDoc(sessionId, { nodes, edges, enabled }, stamp === null ? undefined : stamp);
1322
1357
  }, [sessionId, nodes, edges, enabled]);
1323
1358
 
1324
- const planSig = (nextEnabled, curNodes, curEdges) => {
1325
- const res = buildPlan(curNodes, curEdges);
1359
+ // Plan signature excludes visual (x, y) coordinates so dragging nodes does
1360
+ // not trigger false "unsaved changes" warnings; `skipDirtyOnce` suppresses
1361
+ // the dirty flag when applying a canvas written by the Host itself.
1362
+ const planSig = (nextEnabled, curNodes, curEdges, overrideParallel) => {
1363
+ const mp = typeof overrideParallel === 'number' ? overrideParallel : maxParallelRef.current;
1364
+ const res = buildPlan(curNodes, curEdges, { maxParallel: mp });
1326
1365
  const payload = res.error
1327
1366
  ? { enabled: nextEnabled, error: res.error }
1328
1367
  : { enabled: nextEnabled, plan: res.plan };
@@ -1386,13 +1425,13 @@ window.__ModuleLoader__.load({
1386
1425
  // Publishing costs one visible command row in the conversation, so it only
1387
1426
  // happens when the user enables the canvas, loads a preset/import, clears,
1388
1427
  // or asks for it explicitly.
1389
- const pushPlan = (nextEnabled, overrideNodes, overrideEdges) => {
1428
+ const pushPlan = (nextEnabled, overrideNodes, overrideEdges, overrideParallel) => {
1390
1429
  try {
1391
1430
  const face = sessionFace(sessionId);
1392
1431
  if (!face || typeof face.command !== 'function') { flash(t('syncFailed')); return; }
1393
1432
  const curNodes = Array.isArray(overrideNodes) ? overrideNodes : nodesRef.current;
1394
1433
  const curEdges = Array.isArray(overrideEdges) ? overrideEdges : edgesRef.current;
1395
- const sig = planSig(nextEnabled, curNodes, curEdges);
1434
+ const sig = planSig(nextEnabled, curNodes, curEdges, overrideParallel);
1396
1435
  if (sig === lastSync.current) { setDirty(false); flash(t('upToDate')); return; }
1397
1436
  const line = '/canvas-sync ' + encodeURIComponent(sig);
1398
1437
  const hasStandardAgent = nextEnabled && curNodes.some((n) => n && n.kind !== 'lead' && (n.preset || 'standard') !== 'minimal');
@@ -2791,9 +2830,12 @@ window.__ModuleLoader__.load({
2791
2830
  const soloLeadIds = soloLeadNodeIds(nodes, edges);
2792
2831
  const deadEndIds = deadEndNodeIds(nodes, edges);
2793
2832
 
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.
2833
+ // Lead nodes are never spawned, so their status is derived from graph state:
2834
+ // - Intermediate Lead (has downstream): glows "Ready" until any child starts,
2835
+ // then settles to "Done".
2836
+ // - Terminal Lead (no downstream): Host finishes in one shot, so it glows only
2837
+ // while the main conversation is still streaming (`sessionRunning`), then
2838
+ // settles to "Done" once the turn ends.
2797
2839
  const leadReadyIds = new Set();
2798
2840
  const leadDoneIds = new Set();
2799
2841
  if (enabled) {
@@ -3049,6 +3091,32 @@ window.__ModuleLoader__.load({
3049
3091
  flash(t('fxLabel') + t('sep') + fxName(next));
3050
3092
  },
3051
3093
  }, t('fxLabel') + t('sep') + fxName(fxLevel)),
3094
+ h('div', {
3095
+ style: { ...S.moreRow, display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: '8px' },
3096
+ title: t('tipMaxParallel'),
3097
+ onMouseEnter: (e) => { e.currentTarget.style.background = C.hover; },
3098
+ onMouseLeave: (e) => { e.currentTarget.style.background = 'transparent'; },
3099
+ onClick: () => {
3100
+ const next = nextMaxParallel(maxParallel);
3101
+ setMaxParallel(next);
3102
+ maxParallelRef.current = next;
3103
+ saveMaxParallel(next);
3104
+ if (enabled) pushPlan(true, undefined, undefined, next);
3105
+ else flash(t('maxParallelLabel') + t('sep') + next);
3106
+ },
3107
+ },
3108
+ h('span', null, t('maxParallelLabel') + t('sep') + maxParallel),
3109
+ h('span', {
3110
+ title: t('tipMaxParallel'),
3111
+ style: {
3112
+ display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
3113
+ width: '14px', height: '14px', borderRadius: '50%',
3114
+ border: '1px solid ' + (maxParallel > 4 ? '#d29922' : C.dim),
3115
+ color: maxParallel > 4 ? '#d29922' : C.dim,
3116
+ fontSize: '10px', fontWeight: 700, lineHeight: '12px', flex: '0 0 auto',
3117
+ },
3118
+ }, '!'),
3119
+ ),
3052
3120
  h('div', {
3053
3121
  style: S.moreRow,
3054
3122
  onMouseEnter: (e) => { e.currentTarget.style.background = C.hover; },
@@ -3477,7 +3545,7 @@ window.__ModuleLoader__.load({
3477
3545
  try { console.error('[workflow-canvas] apply failed', error); } catch (_e) { /* ignore */ }
3478
3546
  }
3479
3547
  },
3480
- __test: { topoOrder, wouldCycle, soloLeadNodeIds, layoutGraph, builtinTemplates, deadEndNodeIds, nextEffectLevel, zoomAroundPoint, scrubZoom, buildPlan, loadDoc, saveDoc, storageKey, socketCenterY, distanceToEdge, edgeCurve },
3548
+ __test: { topoOrder, wouldCycle, soloLeadNodeIds, layoutGraph, builtinTemplates, deadEndNodeIds, nextEffectLevel, nextMaxParallel, zoomAroundPoint, scrubZoom, buildPlan, loadDoc, saveDoc, storageKey, socketCenterY, distanceToEdge, edgeCurve },
3481
3549
  };
3482
3550
  },
3483
3551
  });
package/index.js CHANGED
@@ -24,9 +24,16 @@ import { fileURLToPath } from 'node:url';
24
24
  const canvasBySession = new Map();
25
25
  /** In-flight run progress per Session id. */
26
26
  const runBySession = new Map();
27
- /** node id → child session id, so `keepSession` can resume previous work. */
27
+ /** Snapshot of the last completed/halted run per Session id (enables partial retry). */
28
+ const lastRunBySession = new Map();
29
+ /**
30
+ * Two separate maps by design:
31
+ * - `childByNode`: persisted memory slot written ONLY when `keepSession` is ON,
32
+ * so temporary `keepSession=false` runs never overwrite saved memory.
33
+ * - `liveChild`: latest child id in this process (updated even when Memory is OFF)
34
+ * so downstream `session-ref` purple links can always continue the upstream run.
35
+ */
28
36
  const childByNode = new Map();
29
- /** node id → child id created in this process, safe to resume. */
30
37
  const liveChild = new Map();
31
38
 
32
39
  function storePath() {
@@ -716,8 +723,9 @@ function sessionIdFromContext(assembleCtx) {
716
723
 
717
724
  /**
718
725
  * Per-turn runtime prompt context injected ONLY for the session whose canvas is
719
- * currently enabled. Returns '' for disabled canvases, unrelated sessions, and
720
- * subagent sessions (zero token overhead and no recursive triggering).
726
+ * currently enabled. DSH invokes `systemPrompt.context` for both main chats AND
727
+ * spawned subagents, so strict `sid` matching (returning '' on miss) is required
728
+ * to prevent leaking canvas instructions into subagents and causing recursion.
721
729
  */
722
730
  function buildActiveCanvasContext(sid) {
723
731
  if (!sid) return '';
@@ -762,6 +770,17 @@ function buildActiveCanvasContext(sid) {
762
770
  if (stdCount >= 2) {
763
771
  lines.push('- 本画布包含 ' + stdCount + ' 个可写/命令型(standard)子代理,受主对话权限上限约束;若任务涉及改代码、写文件或跑终端命令且当前主对话权限偏严格,请先简短提醒用户放开主对话权限再调 `canvas_workflow`,避免中途报错白耗额度。');
764
772
  }
773
+ const prevRun = lastRunBySession.get(String(sid));
774
+ if (prevRun) {
775
+ const badNames = [
776
+ ...Object.values(prevRun.failed || {}).map((f) => f.label || f.id),
777
+ ...Object.values(prevRun.emptyOutputs || {}).map((e) => e.label || e.id),
778
+ ].filter((v, i, arr) => v && arr.indexOf(v) === i);
779
+ if (prevRun.halted || badNames.length) {
780
+ lines.push('- 上次运行存在失败/熔断节点(' + (badNames.join('、') || '部分未完成')
781
+ + '):若用户要求只重跑失败部分或继续未完成段,请调用 `canvas_workflow({ retryFailed: true })` 局部续跑(自动复用已成功节点缓存,零重复消耗);也可传 `fromNodes: ["节点id"]` 指定从某个节点开始重跑。');
782
+ }
783
+ }
765
784
  return lines.join('\n');
766
785
  }
767
786
 
@@ -817,25 +836,97 @@ async function executePlan(scope, plan, args, exec) {
817
836
  }
818
837
  if (opts.reset === true && sid) {
819
838
  runBySession.delete(sid);
839
+ lastRunBySession.delete(sid);
820
840
  }
821
841
 
842
+ const byId = new Map(runnable.map((n) => [n.id, n]));
843
+ const labelOf = new Map(order.map((n) => [n.id, n.label || n.id]));
822
844
  const sig = JSON.stringify(plan);
823
845
  let state = runBySession.get(sid);
846
+ const wantRetryFailed = opts.retryFailed === true;
847
+ const rawFromNodes = Array.isArray(opts.fromNodes) ? opts.fromNodes.filter((x) => typeof x === 'string' && x.trim()) : [];
848
+ const wantPartial = wantRetryFailed || rawFromNodes.length > 0;
849
+ let reused = [];
850
+
851
+ if (wantPartial && sid) {
852
+ const base = state || lastRunBySession.get(sid);
853
+ if (base) {
854
+ state = {
855
+ sig,
856
+ done: new Set(Array.from(base.done || []).filter((id) => byId.has(id))),
857
+ results: { ...(base.results || {}) },
858
+ labels: { ...(base.labels || {}) },
859
+ failed: { ...(base.failed || {}) },
860
+ emptyOutputs: { ...(base.emptyOutputs || {}) },
861
+ waitingLead: null,
862
+ };
863
+ // Build forward adjacency to invalidate seed nodes and all their downstream dependents.
864
+ const fwd = new Map();
865
+ for (const e of plan.edges || []) {
866
+ if (!e || !e.from || !e.to) continue;
867
+ if (!fwd.has(e.from)) fwd.set(e.from, []);
868
+ fwd.get(e.from).push(e.to);
869
+ }
870
+ const seeds = new Set();
871
+ if (wantRetryFailed) {
872
+ for (const id of Object.keys(state.failed)) seeds.add(id);
873
+ for (const id of Object.keys(state.emptyOutputs)) seeds.add(id);
874
+ }
875
+ for (const ref of rawFromNodes) {
876
+ const trimmed = ref.trim();
877
+ if (byId.has(trimmed)) seeds.add(trimmed);
878
+ else {
879
+ const match = runnable.find((n) => n.label === trimmed);
880
+ if (match) seeds.add(match.id);
881
+ }
882
+ }
883
+ const invalid = new Set(seeds);
884
+ const q = Array.from(seeds);
885
+ for (let i = 0; i < q.length; i += 1) {
886
+ for (const next of fwd.get(q[i]) || []) {
887
+ if (!invalid.has(next)) { invalid.add(next); q.push(next); }
888
+ }
889
+ }
890
+ for (const id of invalid) {
891
+ state.done.delete(id);
892
+ delete state.results[id];
893
+ delete state.labels[id];
894
+ delete state.failed[id];
895
+ delete state.emptyOutputs[id];
896
+ }
897
+ reused = Array.from(state.done).map((id) => labelOf.get(id) || id);
898
+ runBySession.set(sid, state);
899
+ }
900
+ }
901
+
824
902
  if (!state || state.sig !== sig) {
825
903
  state = { sig, done: new Set(), results: {}, labels: {}, failed: {}, emptyOutputs: {}, waitingLead: null };
826
904
  runBySession.set(sid, state);
827
905
  }
828
906
  if (!state.emptyOutputs) state.emptyOutputs = {};
829
907
 
830
- const byId = new Map(runnable.map((n) => [n.id, n]));
831
- const labelOf = new Map(order.map((n) => [n.id, n.label || n.id]));
908
+ const snapshotLastRun = (haltedFlag) => {
909
+ if (!sid) return;
910
+ lastRunBySession.set(sid, {
911
+ sig: state.sig,
912
+ done: new Set(state.done),
913
+ results: { ...state.results },
914
+ labels: { ...state.labels },
915
+ failed: { ...state.failed },
916
+ emptyOutputs: { ...state.emptyOutputs },
917
+ halted: Boolean(haltedFlag),
918
+ });
919
+ };
832
920
  const depsOf = (node) => (plan.edges || [])
833
921
  .filter((e) => e.to === node.id && e.from !== 'lead')
834
922
  .map((e) => e.from)
835
923
  .filter((id) => byId.has(id));
836
924
 
837
925
  let leadResult = typeof opts.leadResult === 'string' ? opts.leadResult : undefined;
838
- const MAX_PARALLEL = 4;
926
+ const rawMaxParallel = opts.maxParallel !== undefined ? opts.maxParallel : plan.maxParallel;
927
+ const MAX_PARALLEL = Number.isFinite(Number(rawMaxParallel))
928
+ ? Math.max(1, Math.min(8, Math.floor(Number(rawMaxParallel))))
929
+ : 4;
839
930
  // Event-driven concurrency pool: as soon as any node finishes, newly unblocked
840
931
  // downstream agents start immediately instead of waiting for slower siblings.
841
932
  const inFlight = new Map();
@@ -867,21 +958,27 @@ async function executePlan(scope, plan, args, exec) {
867
958
  if (sid) runBySession.delete(sid);
868
959
  return { error: '工作流执行已取消。' };
869
960
  }
961
+ // On circuit-break halt, stop launching new downstream waves immediately,
962
+ // but let already in-flight siblings settle so no orphan promises or partial
963
+ // results are dropped before returning the halted report.
870
964
  if (haltedReason && inFlight.size === 0) {
965
+ snapshotLastRun(true);
871
966
  if (sid) runBySession.delete(sid);
872
967
  saveStore();
873
968
  return {
874
969
  status: 'halted',
875
- error: haltedReason,
970
+ error: haltedReason + '(放开权限后可调用 canvas_workflow({ retryFailed: true }) 只重跑失败与未完成节点)',
876
971
  results: state.results,
877
972
  labels: state.labels,
878
973
  failed: Object.values(state.failed),
879
974
  emptyOutputs: Object.values(state.emptyOutputs),
975
+ reused,
880
976
  skipped,
881
977
  };
882
978
  }
883
979
  const remaining = runnable.filter((n) => !state.done.has(n.id));
884
980
  if (!remaining.length) {
981
+ snapshotLastRun(false);
885
982
  runBySession.delete(sid);
886
983
  saveStore();
887
984
  return {
@@ -890,6 +987,7 @@ async function executePlan(scope, plan, args, exec) {
890
987
  labels: state.labels,
891
988
  failed: Object.values(state.failed),
892
989
  emptyOutputs: Object.values(state.emptyOutputs),
990
+ reused,
893
991
  skipped,
894
992
  };
895
993
  }
@@ -939,6 +1037,7 @@ async function executePlan(scope, plan, args, exec) {
939
1037
  if (!hasDownstreamWork && leadResult === undefined) {
940
1038
  // Terminal Lead: zero downstream nodes remain, so complete the run directly
941
1039
  // and hand off final review/delivery to the Lead without a redundant extra turn.
1040
+ snapshotLastRun(false);
942
1041
  if (sid) runBySession.delete(sid);
943
1042
  saveStore();
944
1043
  return {
@@ -953,6 +1052,7 @@ async function executePlan(scope, plan, args, exec) {
953
1052
  failed: Object.values(state.failed),
954
1053
  emptyOutputs: Object.values(state.emptyOutputs),
955
1054
  sessions: leadSessions,
1055
+ reused,
956
1056
  skipped,
957
1057
  hint: '所有子代理已完成。最后一步由你(Lead 本体)按要求完成终审/汇总后直接向用户交付即可,无需再次调用 canvas_workflow。',
958
1058
  };
@@ -1184,6 +1284,7 @@ export function apply(ctx) {
1184
1284
  },
1185
1285
  });
1186
1286
  runBySession.delete(sid);
1287
+ lastRunBySession.delete(sid);
1187
1288
  saveStore();
1188
1289
  }
1189
1290
  return { canvas, delivered, warnings };
@@ -1347,7 +1448,10 @@ export function apply(ctx) {
1347
1448
  leadResult: { type: 'string', description: 'Your own output for the Lead step that was just requested.' },
1348
1449
  task: { type: 'string', description: 'Optional overall task overriding the entry Lead task for this run (useful for reusing a preset).' },
1349
1450
  reset: { type: 'boolean', description: 'Discard any paused run progress and start from the beginning.' },
1451
+ retryFailed: { type: 'boolean', description: 'Reuse succeeded nodes from the previous run and re-run only failed, empty, or unfinished nodes along with their downstream.' },
1452
+ fromNodes: { type: 'array', items: { type: 'string' }, description: 'Re-run only the specified node ids (or labels) and their downstream, reusing all other succeeded nodes from the previous run.' },
1350
1453
  clearMemory: { type: 'boolean', description: 'Forget saved subagent sessions (keepSession memory) for this session before running so every node starts fresh.' },
1454
+ maxParallel: { type: 'integer', minimum: 1, maximum: 8, description: 'Optional concurrency limit override (1–8, default 4).' },
1351
1455
  },
1352
1456
  additionalProperties: false,
1353
1457
  },
@@ -1363,6 +1467,7 @@ export function apply(ctx) {
1363
1467
  failed: { type: 'array' },
1364
1468
  emptyOutputs: { type: 'array' },
1365
1469
  sessions: { type: 'array' },
1470
+ reused: { type: 'array' },
1366
1471
  skipped: { type: 'array' },
1367
1472
  hint: { type: 'string' },
1368
1473
  error: { type: 'string' },
@@ -1407,6 +1512,9 @@ export function apply(ctx) {
1407
1512
  const skip = Array.isArray(v.skipped) && v.skipped.length
1408
1513
  ? '\n\n已跳过(未连线):' + v.skipped.join('、')
1409
1514
  : '';
1515
+ const reusedNote = Array.isArray(v.reused) && v.reused.length
1516
+ ? '\n\n已复用上次成功缓存(未重复消耗):' + v.reused.join('、')
1517
+ : '';
1410
1518
  if (v.finalLead) {
1411
1519
  const fl = v.finalLead;
1412
1520
  const handed = Array.isArray(v.sessions) ? v.sessions.filter((s) => s && s.childId) : [];
@@ -1422,11 +1530,12 @@ export function apply(ctx) {
1422
1530
  + emptyList
1423
1531
  + '\n\n已完成节点的结果:\n' + body
1424
1532
  + handover
1533
+ + reusedNote
1425
1534
  + skip
1426
1535
  + '\n\n' + (v.hint || ''),
1427
1536
  }];
1428
1537
  }
1429
- return [{ type: 'text', text: '画布执行完成。' + failedList + emptyList + '\n\n' + body + skip }];
1538
+ return [{ type: 'text', text: '画布执行完成。' + failedList + emptyList + '\n\n' + body + reusedNote + skip }];
1430
1539
  }
1431
1540
  return [{ type: 'text', text: JSON.stringify(v) }];
1432
1541
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-workflow-canvas",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "A visual subagent-workflow canvas for DeepSeek Harness, docked in the sidebar.",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -50,7 +50,7 @@ Links only join matching types. Nodes the entry Lead cannot reach are skipped at
50
50
  ## Running
51
51
 
52
52
  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.
53
- 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, and `clearMemory: true` to forget saved `keepSession` child sessions so every node starts fresh.
53
+ 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.
54
54
  3. Solo chained Lead nodes (zero subagent upstream) and dangling dead-end subagents (zero outgoing edges while an active downstream Lead exists) are rendered dashed on the canvas and skipped at run time. Wiring a Lead + Subagent together into a downstream Lead is valid and active.
55
55
  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.
56
56
  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.