dsh-workflow-canvas 0.2.4 → 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 +217 -170
- 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 +144 -51
- package/package.json +1 -1
- package/skills/workflow-canvas/SKILL.md +3 -1
package/docs/DETAIL.md
CHANGED
|
@@ -9,14 +9,16 @@ are performed by the conversation itself.
|
|
|
9
9
|
|
|
10
10
|
- **Subagent node** (green top bar): spawns a child agent with its own
|
|
11
11
|
`provider` / `model` / `reasoning effort` / capability scope (`standard` or
|
|
12
|
-
`minimal
|
|
13
|
-
**Fallback** retries once on another model.
|
|
12
|
+
`minimal`, bounded by the main chat permission mode). Optional **Memory** reuses
|
|
13
|
+
the node's child session; optional **Fallback** retries once on another model.
|
|
14
14
|
- **Lead node** (blue top bar): performed by the conversation, never spawned. The
|
|
15
|
-
entry node carries the overall task;
|
|
15
|
+
entry node carries the overall task; intermediate Lead nodes pause for your
|
|
16
|
+
decision, and a terminal Lead finishes in one shot without an extra callback.
|
|
16
17
|
- **Sockets are typed** (`prompt` / `structured` / `session`); a link only joins
|
|
17
18
|
the same type (either direction), and cycles are blocked immediately. Drag a
|
|
18
19
|
connected input away to detach.
|
|
19
|
-
-
|
|
20
|
+
- Inactive nodes (unreachable from entry, solo chained Leads with no subagent
|
|
21
|
+
upstream, or dangling dead-end subagents) are drawn dashed and skipped at run time.
|
|
20
22
|
- Wheel zooms around the cursor; middle-drag (or `Space` + drag) pans; `⊡ Fit`
|
|
21
23
|
fits all nodes into the visible viewport; the percentage button resets to 100%
|
|
22
24
|
on the Lead.
|
|
@@ -45,12 +47,13 @@ node positions survive.
|
|
|
45
47
|
|
|
46
48
|
## Running
|
|
47
49
|
|
|
48
|
-
Subagent nodes run in
|
|
49
|
-
supports `task` (override the entry task for template
|
|
50
|
-
(discard a paused run)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
Subagent nodes run in an event-driven concurrency pool (up to 4) via
|
|
51
|
+
`canvas_workflow`, which supports `task` (override the entry task for template
|
|
52
|
+
reuse), `reset: true` (discard a paused run), and `clearMemory: true` (forget
|
|
53
|
+
saved `keepSession` memories). While enabled, a per-session runtime context
|
|
54
|
+
notifies the agent automatically. Intermediate Lead nodes pause with
|
|
55
|
+
`status: "need-lead"` and report `failed` / `emptyOutputs` plus `session`
|
|
56
|
+
handovers; a terminal Lead completes directly with `status: "done"` and `finalLead`.
|
|
54
57
|
|
|
55
58
|
## Memory
|
|
56
59
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/index.js
CHANGED
|
@@ -222,8 +222,10 @@ async function spawnOnce(scope, plan, node, results, parent, signal, route, forc
|
|
|
222
222
|
}
|
|
223
223
|
try {
|
|
224
224
|
if (activation && activation.childId) {
|
|
225
|
-
childByNode.set(childKey(node.id), activation.childId);
|
|
226
225
|
liveChild.set(childKey(node.id), activation.childId);
|
|
226
|
+
// Only overwrite the persisted memory slot when Memory is ON, so a
|
|
227
|
+
// temporary keepSession=false experiment never destroys saved memory.
|
|
228
|
+
if (node.keepSession) childByNode.set(childKey(node.id), activation.childId);
|
|
227
229
|
}
|
|
228
230
|
let result;
|
|
229
231
|
try {
|
|
@@ -257,19 +259,20 @@ async function spawnOnce(scope, plan, node, results, parent, signal, route, forc
|
|
|
257
259
|
/* activation refused (e.g. cold session gone): fall through to a fresh session */
|
|
258
260
|
}
|
|
259
261
|
|
|
260
|
-
// Memory: prefer
|
|
261
|
-
//
|
|
262
|
-
//
|
|
262
|
+
// Memory: prefer an explicitly pinned `memoryChildId` from the node dropdown,
|
|
263
|
+
// then the saved memory slot (`childByNode`), then this process's live child.
|
|
264
|
+
// A cold resume that the Host refuses falls through to a fresh session.
|
|
263
265
|
if (node.keepSession) {
|
|
266
|
+
const pinned = typeof node.memoryChildId === 'string' ? node.memoryChildId.trim() : '';
|
|
267
|
+
const saved = childByNode.get(childKey(node.id));
|
|
264
268
|
const inProcess = liveChild.get(childKey(node.id));
|
|
265
|
-
const
|
|
266
|
-
const previous = inProcess || fromDisk;
|
|
269
|
+
const previous = pinned || saved || inProcess;
|
|
267
270
|
if (previous) {
|
|
268
271
|
const resumed = await run(previous);
|
|
269
272
|
if (resumed.ok) return resumed;
|
|
270
273
|
if (resumed.reason === 'activation-failed') {
|
|
271
|
-
liveChild.delete(childKey(node.id));
|
|
272
|
-
childByNode.delete(childKey(node.id));
|
|
274
|
+
if (previous === inProcess) liveChild.delete(childKey(node.id));
|
|
275
|
+
if (previous === saved) childByNode.delete(childKey(node.id));
|
|
273
276
|
} else {
|
|
274
277
|
return resumed;
|
|
275
278
|
}
|
|
@@ -310,40 +313,51 @@ async function spawnNode(scope, plan, node, results, parent, signal, sid, failed
|
|
|
310
313
|
return { ok: false, empty: false, reason, text: retry.text + '\n(重试仍失败:' + reason + ')' };
|
|
311
314
|
}
|
|
312
315
|
|
|
313
|
-
/** Ids reachable from the entry Lead; every other node is skipped at run time. */
|
|
316
|
+
/** Ids reachable from the entry Lead via O(V + E) BFS; every other node is skipped at run time. */
|
|
314
317
|
function reachableFrom(plan) {
|
|
318
|
+
const adj = new Map();
|
|
319
|
+
for (const e of (plan && plan.edges) || []) {
|
|
320
|
+
if (!e || !e.from || !e.to) continue;
|
|
321
|
+
if (!adj.has(e.from)) adj.set(e.from, []);
|
|
322
|
+
adj.get(e.from).push(e.to);
|
|
323
|
+
}
|
|
315
324
|
const set = new Set(['lead']);
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
for (const
|
|
320
|
-
if (
|
|
325
|
+
const queue = ['lead'];
|
|
326
|
+
for (let i = 0; i < queue.length; i += 1) {
|
|
327
|
+
const cur = queue[i];
|
|
328
|
+
for (const next of adj.get(cur) || []) {
|
|
329
|
+
if (!set.has(next)) { set.add(next); queue.push(next); }
|
|
321
330
|
}
|
|
322
331
|
}
|
|
323
332
|
return set;
|
|
324
333
|
}
|
|
325
334
|
|
|
326
335
|
/**
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
330
|
-
*
|
|
336
|
+
* Classify inactive nodes that are rendered dashed on the canvas and skipped at run time:
|
|
337
|
+
* - unreachable orphans
|
|
338
|
+
* - solo chained Leads (zero reachable subagent upstream)
|
|
339
|
+
* - dangling dead-end subagents (zero outgoing edges while an active non-ancestor downstream Lead exists)
|
|
331
340
|
*/
|
|
332
|
-
function
|
|
341
|
+
function inactiveNodeSets(nodes, edges) {
|
|
333
342
|
const list = withoutEntry(nodes);
|
|
334
343
|
const linkList = Array.isArray(edges) ? edges : [];
|
|
335
|
-
const warnings = [];
|
|
336
|
-
if (!list.length) return warnings;
|
|
337
|
-
|
|
338
344
|
const reachable = reachableFrom({ edges: linkList });
|
|
339
|
-
const
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
345
|
+
const byId = new Map(list.map((n) => [n.id, n]));
|
|
346
|
+
|
|
347
|
+
const soloLeads = new Set();
|
|
348
|
+
for (const n of list) {
|
|
349
|
+
if (n.kind !== 'lead' || !reachable.has(n.id)) continue;
|
|
350
|
+
const hasAgentUp = linkList.some((e) => {
|
|
351
|
+
if (!e || e.to !== n.id || !reachable.has(e.from) || e.from === 'lead') return false;
|
|
352
|
+
const src = byId.get(e.from);
|
|
353
|
+
return Boolean(src && src.kind !== 'lead');
|
|
354
|
+
});
|
|
355
|
+
if (!hasAgentUp) soloLeads.add(n.id);
|
|
343
356
|
}
|
|
344
357
|
|
|
345
|
-
const
|
|
346
|
-
|
|
358
|
+
const deadEnds = new Set();
|
|
359
|
+
const activeLeads = list.filter((n) => n.kind === 'lead' && reachable.has(n.id) && !soloLeads.has(n.id));
|
|
360
|
+
if (activeLeads.length) {
|
|
347
361
|
const hasOut = new Set(linkList.map((e) => e.from));
|
|
348
362
|
const parents = new Map();
|
|
349
363
|
for (const e of linkList) {
|
|
@@ -361,16 +375,44 @@ function analyzeCanvasWarnings(nodes, edges) {
|
|
|
361
375
|
}
|
|
362
376
|
return seen;
|
|
363
377
|
};
|
|
364
|
-
const
|
|
365
|
-
if (n.kind === 'lead' || !reachable.has(n.id) || hasOut.has(n.id))
|
|
378
|
+
for (const n of list) {
|
|
379
|
+
if (n.kind === 'lead' || !reachable.has(n.id) || hasOut.has(n.id)) continue;
|
|
366
380
|
const anc = ancestorsOf(n.id);
|
|
367
|
-
|
|
368
|
-
});
|
|
369
|
-
if (deadEnds.length) {
|
|
370
|
-
warnings.push('以下子代理节点没有出边,产出未显式连入下游或终审 Lead:'
|
|
371
|
-
+ deadEnds.map((n) => (n.label || n.id) + '(' + n.id + ')').join('、'));
|
|
381
|
+
if (activeLeads.some((ln) => !anc.has(ln.id))) deadEnds.add(n.id);
|
|
372
382
|
}
|
|
373
383
|
}
|
|
384
|
+
return { reachable, soloLeads, deadEnds };
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Detect structural warnings on a canvas plan (all three classes are rendered
|
|
389
|
+
* dashed on the canvas and skipped at run time):
|
|
390
|
+
* 1. Unreachable nodes.
|
|
391
|
+
* 2. Solo chained Lead nodes with zero subagent upstream.
|
|
392
|
+
* 3. Dangling dead-end subagent nodes with zero outgoing edges.
|
|
393
|
+
*/
|
|
394
|
+
function analyzeCanvasWarnings(nodes, edges) {
|
|
395
|
+
const list = withoutEntry(nodes);
|
|
396
|
+
const linkList = Array.isArray(edges) ? edges : [];
|
|
397
|
+
const warnings = [];
|
|
398
|
+
if (!list.length) return warnings;
|
|
399
|
+
|
|
400
|
+
const { reachable, soloLeads, deadEnds } = inactiveNodeSets(list, linkList);
|
|
401
|
+
const orphans = list.filter((n) => !reachable.has(n.id));
|
|
402
|
+
if (orphans.length) {
|
|
403
|
+
warnings.push('以下节点未从入口 Lead 连通,运行时会被跳过:'
|
|
404
|
+
+ orphans.map((n) => (n.label || n.id) + '(' + n.id + ')').join('、'));
|
|
405
|
+
}
|
|
406
|
+
const soloList = list.filter((n) => soloLeads.has(n.id));
|
|
407
|
+
if (soloList.length) {
|
|
408
|
+
warnings.push('以下 Lead 节点仅串联了其他 Lead、未连入子代理,运行时不生效:'
|
|
409
|
+
+ soloList.map((n) => (n.label || n.id) + '(' + n.id + ')').join('、'));
|
|
410
|
+
}
|
|
411
|
+
const deadList = list.filter((n) => deadEnds.has(n.id));
|
|
412
|
+
if (deadList.length) {
|
|
413
|
+
warnings.push('以下子代理节点没有出边,产出未连入下游或终审 Lead,运行时不生效:'
|
|
414
|
+
+ deadList.map((n) => (n.label || n.id) + '(' + n.id + ')').join('、'));
|
|
415
|
+
}
|
|
374
416
|
return warnings;
|
|
375
417
|
}
|
|
376
418
|
|
|
@@ -521,7 +563,7 @@ function normalizeCanvas(args) {
|
|
|
521
563
|
function applyPatch(plan, args) {
|
|
522
564
|
const nodes = withoutEntry(plan.nodes).map((n) => ({ ...n }));
|
|
523
565
|
const byId = new Map(nodes.map((n) => [n.id, n]));
|
|
524
|
-
const ALLOWED = ['label', 'role', 'provider', 'model', 'reasoning', 'preset', 'keepSession', 'structured', 'fallbackModel', 'fallbackProvider'];
|
|
566
|
+
const ALLOWED = ['label', 'role', 'provider', 'model', 'reasoning', 'preset', 'keepSession', 'memoryChildId', 'structured', 'fallbackModel', 'fallbackProvider'];
|
|
525
567
|
const touched = [];
|
|
526
568
|
for (const patch of args && Array.isArray(args.nodes) ? args.nodes : []) {
|
|
527
569
|
// 'lead' is the reserved entry node and is never edited here.
|
|
@@ -702,7 +744,9 @@ function buildActiveCanvasContext(sid) {
|
|
|
702
744
|
.map((n) => (n.kind === 'lead' ? '〔Lead〕' : '') + (n.label || n.id))
|
|
703
745
|
.join(' → ') + (nodes.length > 8 ? ' …' : '');
|
|
704
746
|
const hasTask = Boolean(String((plan && plan.task) || '').trim());
|
|
705
|
-
|
|
747
|
+
const prefix = String(sid) + '::';
|
|
748
|
+
const hasMemory = nodes.some((n) => n.keepSession && (liveChild.has(prefix + n.id) || childByNode.has(prefix + n.id)));
|
|
749
|
+
const lines = [
|
|
706
750
|
'[Workflow Canvas Active]',
|
|
707
751
|
'当前会话的右侧工作流画布处于「● 已启用」状态(共 ' + nodes.length + ' 个执行节点:' + preview + ';入口总任务:' + (hasTask ? '已填写' : '未填写') + ')。',
|
|
708
752
|
'- 若用户发出任务请求、布置工作或说「开始 / 执行 / 跑一次」:请直接调用 `canvas_workflow` 按画布编排执行('
|
|
@@ -710,7 +754,25 @@ function buildActiveCanvasContext(sid) {
|
|
|
710
754
|
+ '),不要绕过画布直接自己完成。',
|
|
711
755
|
'- 若用户在讨论或要求修改画布结构、模型、分工或连线:请先 `canvas_inspect` 再用 `canvas_patch` 就地修改,不要直接运行。',
|
|
712
756
|
'- 仅当用户明确只是闲聊、问无关问题或要求先停用画布时,才无需调用 `canvas_workflow`。',
|
|
713
|
-
]
|
|
757
|
+
];
|
|
758
|
+
if (hasMemory) {
|
|
759
|
+
lines.push('- 本会话已有开启「记忆」节点的历史子代理会话:若用户说「再跑一次 / 换个任务重跑」,请先简短询问用户是保留上次记忆继续(reset: true)还是清空记忆全新开跑(reset: true, clearMemory: true)。');
|
|
760
|
+
}
|
|
761
|
+
const stdCount = nodes.filter((n) => n.kind !== 'lead' && n.preset !== 'minimal').length;
|
|
762
|
+
if (stdCount >= 2) {
|
|
763
|
+
lines.push('- 本画布包含 ' + stdCount + ' 个可写/命令型(standard)子代理,受主对话权限上限约束;若任务涉及改代码、写文件或跑终端命令且当前主对话权限偏严格,请先简短提醒用户放开主对话权限再调 `canvas_workflow`,避免中途报错白耗额度。');
|
|
764
|
+
}
|
|
765
|
+
return lines.join('\n');
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
/** Detect permission / sandbox denial outcomes so we can circuit-break before burning downstream tokens. */
|
|
769
|
+
const PERMISSION_ERR_RE = /permission denied|access is denied|sandbox-local|windows-acl|win32error|eacces|eperm|approval required|not permitted|拒绝访问|权限不足|无权执行|沙箱拒绝/i;
|
|
770
|
+
function isPermissionFailure(outcome) {
|
|
771
|
+
if (!outcome) return false;
|
|
772
|
+
const text = String(outcome.text || '');
|
|
773
|
+
if (!outcome.ok && PERMISSION_ERR_RE.test(text)) return true;
|
|
774
|
+
if (text.includes('【未完全交付】') && PERMISSION_ERR_RE.test(text)) return true;
|
|
775
|
+
return false;
|
|
714
776
|
}
|
|
715
777
|
|
|
716
778
|
/** Takes a plan directly so tests can feed any plan shape (sync, generate, patch). */
|
|
@@ -735,19 +797,24 @@ async function executePlan(scope, plan, args, exec) {
|
|
|
735
797
|
const order = orderNodes(plan);
|
|
736
798
|
if (!order) return { error: '存在环,无法执行有向无环图。' };
|
|
737
799
|
|
|
738
|
-
// Defense in depth: unreachable
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
800
|
+
// Defense in depth: unreachable orphans, solo chained Leads, and dangling
|
|
801
|
+
// dead-end subagents are skipped instead of wasting tokens or stalling.
|
|
802
|
+
const { reachable, soloLeads, deadEnds } = inactiveNodeSets(plan.nodes, plan.edges);
|
|
803
|
+
const isInactive = (n) => !reachable.has(n.id) || soloLeads.has(n.id) || deadEnds.has(n.id);
|
|
804
|
+
const runnable = order.filter((n) => !isInactive(n));
|
|
805
|
+
const skipped = order.filter((n) => isInactive(n)).map((n) => n.label || n.id);
|
|
806
|
+
if (!runnable.length) return { error: '没有从入口 Lead 连通的有效节点,无法执行。' };
|
|
807
|
+
|
|
808
|
+
if (opts.clearMemory === true && sid) {
|
|
809
|
+
const prefix = String(sid) + '::';
|
|
810
|
+
for (const key of Array.from(childByNode.keys())) {
|
|
811
|
+
if (key.startsWith(prefix)) childByNode.delete(key);
|
|
812
|
+
}
|
|
813
|
+
for (const key of Array.from(liveChild.keys())) {
|
|
814
|
+
if (key.startsWith(prefix)) liveChild.delete(key);
|
|
745
815
|
}
|
|
816
|
+
saveStore();
|
|
746
817
|
}
|
|
747
|
-
const runnable = order.filter((n) => reachable.has(n.id));
|
|
748
|
-
const skipped = order.filter((n) => !reachable.has(n.id)).map((n) => n.label || n.id);
|
|
749
|
-
if (!runnable.length) return { error: '没有从入口 Lead 连通的节点,无法执行。' };
|
|
750
|
-
|
|
751
818
|
if (opts.reset === true && sid) {
|
|
752
819
|
runBySession.delete(sid);
|
|
753
820
|
}
|
|
@@ -774,15 +841,18 @@ async function executePlan(scope, plan, args, exec) {
|
|
|
774
841
|
const inFlight = new Map();
|
|
775
842
|
|
|
776
843
|
const isAborted = () => Boolean(exec && exec.signal && exec.signal.aborted);
|
|
844
|
+
const permBlocked = [];
|
|
845
|
+
let activationFailCount = 0;
|
|
846
|
+
let haltedReason = '';
|
|
777
847
|
|
|
778
848
|
const launchReadyAgents = () => {
|
|
779
|
-
if (isAborted() || inFlight.size >= MAX_PARALLEL) return;
|
|
849
|
+
if (isAborted() || haltedReason || inFlight.size >= MAX_PARALLEL) return;
|
|
780
850
|
const candidates = runnable.filter((n) => n.kind !== 'lead'
|
|
781
851
|
&& !state.done.has(n.id)
|
|
782
852
|
&& !inFlight.has(n.id)
|
|
783
853
|
&& depsOf(n).every((id) => state.done.has(id)));
|
|
784
854
|
for (const node of candidates) {
|
|
785
|
-
if (isAborted() || inFlight.size >= MAX_PARALLEL) break;
|
|
855
|
+
if (isAborted() || haltedReason || inFlight.size >= MAX_PARALLEL) break;
|
|
786
856
|
const promise = spawnNode(scope, plan, node, state.results, agent, exec.signal, sid, state.failed)
|
|
787
857
|
.then(
|
|
788
858
|
(outcome) => ({ node, outcome }),
|
|
@@ -797,6 +867,19 @@ async function executePlan(scope, plan, args, exec) {
|
|
|
797
867
|
if (sid) runBySession.delete(sid);
|
|
798
868
|
return { error: '工作流执行已取消。' };
|
|
799
869
|
}
|
|
870
|
+
if (haltedReason && inFlight.size === 0) {
|
|
871
|
+
if (sid) runBySession.delete(sid);
|
|
872
|
+
saveStore();
|
|
873
|
+
return {
|
|
874
|
+
status: 'halted',
|
|
875
|
+
error: haltedReason,
|
|
876
|
+
results: state.results,
|
|
877
|
+
labels: state.labels,
|
|
878
|
+
failed: Object.values(state.failed),
|
|
879
|
+
emptyOutputs: Object.values(state.emptyOutputs),
|
|
880
|
+
skipped,
|
|
881
|
+
};
|
|
882
|
+
}
|
|
800
883
|
const remaining = runnable.filter((n) => !state.done.has(n.id));
|
|
801
884
|
if (!remaining.length) {
|
|
802
885
|
runBySession.delete(sid);
|
|
@@ -824,9 +907,17 @@ async function executePlan(scope, plan, args, exec) {
|
|
|
824
907
|
state.labels[node.id] = node.label;
|
|
825
908
|
if (!outcome.ok) {
|
|
826
909
|
state.failed[node.id] = { id: node.id, label: node.label, reason: outcome.reason || 'unknown' };
|
|
910
|
+
if (outcome.reason === 'activation-failed') activationFailCount += 1;
|
|
827
911
|
} else if (outcome.empty) {
|
|
828
912
|
state.emptyOutputs[node.id] = { id: node.id, label: node.label };
|
|
829
913
|
}
|
|
914
|
+
if (isPermissionFailure(outcome)) {
|
|
915
|
+
permBlocked.push(node.label || node.id);
|
|
916
|
+
haltedReason = '检测到权限/沙箱受限导致节点失败(' + permBlocked.join('、')
|
|
917
|
+
+ '),已熔断停止启动后续节点以防继续消耗额度。请先检查主对话左下角权限模式,放开后重新运行。';
|
|
918
|
+
} else if (activationFailCount >= 2 && !haltedReason) {
|
|
919
|
+
haltedReason = '连续 ' + activationFailCount + ' 个子代理启动失败,已熔断停止后续节点以防继续消耗额度。请检查模型配置或主对话权限后重试。';
|
|
920
|
+
}
|
|
830
921
|
state.done.add(node.id);
|
|
831
922
|
continue;
|
|
832
923
|
}
|
|
@@ -1256,6 +1347,7 @@ export function apply(ctx) {
|
|
|
1256
1347
|
leadResult: { type: 'string', description: 'Your own output for the Lead step that was just requested.' },
|
|
1257
1348
|
task: { type: 'string', description: 'Optional overall task overriding the entry Lead task for this run (useful for reusing a preset).' },
|
|
1258
1349
|
reset: { type: 'boolean', description: 'Discard any paused run progress and start from the beginning.' },
|
|
1350
|
+
clearMemory: { type: 'boolean', description: 'Forget saved subagent sessions (keepSession memory) for this session before running so every node starts fresh.' },
|
|
1259
1351
|
},
|
|
1260
1352
|
additionalProperties: false,
|
|
1261
1353
|
},
|
|
@@ -1362,6 +1454,7 @@ export {
|
|
|
1362
1454
|
inspectPlan,
|
|
1363
1455
|
sessionIdFromContext,
|
|
1364
1456
|
buildActiveCanvasContext,
|
|
1457
|
+
isPermissionFailure,
|
|
1365
1458
|
runPlan,
|
|
1366
1459
|
executePlan,
|
|
1367
1460
|
};
|
package/package.json
CHANGED
|
@@ -50,7 +50,9 @@ 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),
|
|
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.
|
|
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
|
+
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.
|
|
54
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.
|
|
55
57
|
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.
|
|
56
58
|
5. A **terminal** Lead node (zero remaining downstream nodes) finishes directly with `status: "done"` and `finalLead`: complete the review/summary and reply directly to the user — no extra `canvas_workflow` callback is needed.
|