dsh-workflow-canvas 1.4.1 → 1.5.5

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 CHANGED
@@ -10,7 +10,7 @@ English | [中文](README.zh.md) | [Mechanism & Architecture](docs/MECHANISM.md)
10
10
  Turn multi-agent orchestration in DSH into a visual node graph: each card is an AI role, each wire defines who feeds whom, and pressing **● ON** lets you run the whole pipeline straight from chat.
11
11
 
12
12
  - **Real parallelism**: Independent nodes run concurrently (default 4, configurable 1–8 under `⋯`), and newly unblocked downstream nodes start the instant their inputs finish.
13
- - **Conditional branching**: Drop a **Condition** node anywhere to route downstream along `✓ Yes` or `✕ No` based on upstream results — the unchosen branch is skipped automatically without spawning.
13
+ - **Conditional branching & controlled retry loops**: Drop a **Condition** node anywhere to route downstream (`✓ Yes` / `✕ No` or multi-way `switch/case`), or wire a branch back upstream (or right-click selected nodes → **`↺ Create loop`**) for bounded feedback-driven retries that circuit-break to Lead when exhausted.
14
14
  - **Human-in-the-loop**: Drop a **Lead** card anywhere in the flow to pause automatically for your decision before continuing.
15
15
  - **Zero black box**: Click any subagent card to open its live chat transcript and inspect its exact output.
16
16
  - **Don't want to draw by hand?** Describe the workflow in one sentence in chat — the agent sketches the graph for you and can patch it in place anytime.
@@ -78,15 +78,21 @@ Every subagent node can be configured independently:
78
78
 
79
79
  ---
80
80
 
81
- ### 4. Conditional branching & dynamic pruning
81
+ ### 4. Conditional branching, dynamic pruning & retry loops
82
82
 
83
- Drop a **Condition** node anywhere in the graph to route downstream automatically based on upstream outputs:
83
+ Drop a **Condition** node anywhere in the graph to route downstream automatically or loop back with feedback on failure:
84
84
 
85
85
  - Supports default binary **`Yes / No`**, multi-way **`switch/case`** via **`+ Case`** (e.g. `Pass / Minor Fix / Rewrite`), and **`Single / Multi`** match modes.
86
86
  - Unchosen branches are pruned automatically without spawning; if zero branches match or the condition node itself fails, it never guesses — it skips intermediate branches and hands off to the nearest downstream Lead.
87
87
  - Once judged, a compact verdict pill appears right under the condition card (click to inspect the full verdict reason), while unchosen branch edges and skipped nodes dim automatically.
88
+ - **Controlled retry loops (`↺`)**:
89
+ - **Two ways to create**: Select one or more connected nodes → right-click **`↺ Create loop`** (auto-inserts a lightweight condition gate if the tail is a regular subagent), or drag a condition branch wire directly back to a strict ancestor node.
90
+ - **Clear visuals & free limit control**: Loop members get a color-coded outer dashed outline & `↺` badge (never clashing with running/done/failed borders), connected by an outer bypass rail; click the midpoint **`↺ ×3`** pill to adjust max retries (`1–10`) or remove the loop.
91
+ - **Feedback & circuit-break**: Retries reset only strict loop members (bypass nodes are never re-run), inject the condition's rejection reason while reusing healthy warm sessions, and circuit-break at max retries by handing all round summaries to the nearest downstream Lead.
88
92
  - **Per-node & global `+ Refs` list**: Click **`+ Refs`** in the top-right title bar of any node (Entry Lead global refs, downstream Leads, Subagents, or Condition nodes) to attach up to 16 reference file paths, URLs, or constraints — deduplicated and injected into prompts automatically at run time.
89
93
 
94
+ ![Controlled retry loop: Implement → Test & Verify → Checks Passed ↺ Auto-fix](docs/images/retry-loop-en.png)
95
+
90
96
  ![3-way switch/case conditional routing and automatic branch pruning](docs/images/condition-switch-run.gif)
91
97
 
92
98
  ---
@@ -97,6 +103,7 @@ Press **`● ON`** at the top-left of the canvas, then either click **`▶ Run`*
97
103
 
98
104
  - If the entry Lead's task is blank, `▶ Run` stays disabled with a hint and you can still send your chat message directly as `task`.
99
105
  - At an intermediate **Lead** node, the canvas shows **`⏸ Ready`** (and Entry Lead shows `⏸ Awaiting Lead`) while handing control to chat; once you reply, downstream nodes resume automatically through the final Lead review.
106
+ - **Unified `⏹ Stop` button**: Whenever a run is active or paused at **`⏸ Awaiting Lead`**, a red **`⏹ Stop`** button appears beside `● ON` and on the Entry Lead card — clicking it immediately cancels the root turn, interrupts all live subagents, clears any Lead pause, and preserves completed-node cache (you can also ask in chat to cancel via `canvas_workflow({ cancel: true })`).
100
107
  - Re-running in the same chat supports `reset: true`; if any node has saved **Memory**, the agent confirms whether to keep memory or clear it (`clearMemory: true`).
101
108
 
102
109
  ![Auto-run enabled canvas, pause at Lead decision, and finish](docs/images/lead-pause-resume.gif)
@@ -125,16 +132,16 @@ Active nodes glow blue with animated flow wires and turn green when done. **Clic
125
132
  | `Shift+A` / Drag-wire drop | Add a node at cursor, or drag from an output socket onto blank canvas to create & auto-connect (`1` Subagent, `2` Lead, `3` Condition) |
126
133
  | Middle-drag / `Space` + left-drag | Pan the canvas |
127
134
  | Wheel / bottom-right `⊡` & `100%` pill | Zoom around cursor / fit all nodes / click to reset 100%, drag left-right to scrub zoom |
128
- | `⇄ Horiz` / `⇅ Vert` | Switch canvas direction and auto-layout (vertical mode uses top-in / bottom-out vertical curves for narrow sidebars; Condition nodes support `Out R / Out L` side toggle) |
135
+ | `⇄ Horiz` / `⇅ Vert` | Switch canvas direction and auto-layout, **remembered as the default for new sessions** (vertical mode uses top-in / bottom-out curves; Condition nodes support `Out R / Out L` side toggle) |
129
136
  | Marquee / `Shift`/`Ctrl` click + `Shift+D` / `Delete` | Multi-select move, duplicate (with settings & internal links), or batch delete |
130
- | Right-click node / edge / canvas | Context menu (edit role, manage refs, insert node on wire, add nodes, layout, undo/redo) |
137
+ | Right-click node / edge / canvas | Context menu (edit role, manage refs, insert node on wire, create loop, add nodes, layout, undo/redo) |
131
138
  | Right-drag across wires | Cut links (activates at ≥ 6px drag without conflicting with context menu; toggle under `⋯`) |
132
- | `Ctrl+Z` / `Ctrl+Shift+Z` (`Ctrl+Y`) / `Esc` | Undo / redo structural edit / close popups |
133
- | `⋯` menu | Undo, Fit, Import / Copy JSON, Auto layout, Clear canvas, Visual effects, Max parallel, Language, Shortcuts |
139
+ | Toolbar `↶ / ↷` / `Ctrl+Z` / `Ctrl+Shift+Z` (`Ctrl+Y`) / `Esc` | Undo / redo (covers structural edits, node drags & layout flips) / close popups |
140
+ | `⋯` menu | Undo, Fit, Import / Copy JSON (preserves direction), Auto layout, Clear canvas, Visual effects, Max parallel, Language, Shortcuts |
134
141
 
135
142
  ## Presets, sharing & limits
136
143
 
137
- - **Presets & cross-session reuse**: Click `☰ Presets` to save the current canvas at the top of the menu (immediately available in any new chat), or load one of the 4 starter templates and **New blank canvas**. Custom presets live in browser storage — use `⋯ → ⇧ Copy JSON` and `⇩ Import` to share across devices.
144
+ - **Presets & cross-session reuse**: Click `☰ Presets` to save the current canvas (including its horizontal/vertical layout direction) — **already-open sessions stay in sync live** with a manual `↻` refresh button — or load one of the 5 starter templates (including conditional branching & retry loop, adapting to the active layout direction) and **New blank canvas**. Custom presets live in browser storage — use `⋯ → ⇧ Copy JSON` and `⇩ Import` to share across devices.
138
145
  - **Partial resume & concurrency**: If a mid-flow node fails, call `retryFailed: true` or `fromNodes` to reuse succeeded outputs and re-run only the failed segment and its downstream; adjust max concurrency (1 / 2 / 4 / 6 / 8, default 4) under `⋯`.
139
146
  - **How this differs from other canvas plugins**: Built for **multi-subagent orchestration + conditional routing + conversation Lead gates**; for `ctx.workflows` low-level tool pipelines, see [`@piedpiper911/dsh-workflow-canvas`](https://github.com/PiedPiper911/dsh-workflow-canvas).
140
147
  - **Limits**: Per-node `Scope` only narrows tools within the main chat's permission/sandbox ceiling.
package/README.zh.md CHANGED
@@ -10,7 +10,7 @@
10
10
  把 DSH 的多智能体协作画成一张直观的流程图:每个卡片是一名负责具体工作的 AI,连线决定「谁先做、结果交给谁」,点一下启用就能在聊天里直接开跑。
11
11
 
12
12
  - **真并行**:互相不依赖的卡片会自动同时开工(默认 4 路并发,可在 `⋯` 菜单按需调节 1–8 路),跑完一个立刻推进下游,不用干等。
13
- - **条件分支**:放入 **条件节点** 即可根据上游执行结果自动分流(`✓ 是` / `✕ 否`),未命中的分支自动跳过、不消耗额外额度。
13
+ - **条件分支 & 失败回环重试**:放入 **条件节点** 即可根据上游执行结果自动分流(`✓ 是` / `✕ 否` 或多路 `switch/case`),更支持将条件分支连回上游(或多选节点右键「`↺ 设为回环`」)组成**带反馈的受控重试循环**,达上限自动熔断并汇总转交 Lead。
14
14
  - **人机协同**:在关键节点放一个 **Lead 卡片**,跑到那一步会自动停下来问你拍板,确认后再继续往下跑。
15
15
  - **完全白盒**:每个子代理的对话记录都能直接点开看,不用猜黑盒里发生了什么。
16
16
  - **懒得手动画?** 直接在聊天里用一句话描述分工,AI 会帮你把整张图搭好,之后还能随时说一句让它原地修改。
@@ -78,15 +78,21 @@
78
78
 
79
79
  ---
80
80
 
81
- ### 4. 条件分支与动态剪枝
81
+ ### 4. 条件分支、动态剪枝与受控回环
82
82
 
83
- 在流程中放入 **条件节点**,即可根据上游子代理或 Lead 的实际输出自动路由:
83
+ 在流程中放入 **条件节点**,即可根据上游子代理或 Lead 的实际输出自动路由或触发带反馈的自动重试:
84
84
 
85
85
  - 支持默认二分支 **`是 / 否`**、点击 **`+ 分支`** 扩展多路 **`switch/case`**(如 `通过 / 小修 / 重做`),以及 **`单选 / 多选`** 两种匹配模式。
86
86
  - 未命中的分支自动剪枝跳过、不消耗额度;所有分支均未命中或条件节点自身失败时,不擅自乱选,直接转交最近下游 Lead 处理。
87
87
  - 判决完成后,条件节点下方会直接显示命中分支标签(点击可查看完整判断理由),未命中的分支连线与被跳过节点自动淡化标示。
88
+ - **受控回环重试(`↺` 失败带反馈重做)**:
89
+ - **两种创建方式**:框选或 `Shift`/`Ctrl` 点选一组节点 → 右键 **「↺ 设为回环」**(若末尾是普通子代理,自动补一个「是否通过?」条件判断节点并接好回环);或直接从条件节点的分支出口拖线连回上游祖先节点。
90
+ - **视觉高亮与调参**:环内节点自动套上同色外圈虚线轮廓与 `↺` 角标(不遮挡运行蓝/绿/红边框),回环边自动绕开卡片外侧走圆角虚线弧线;点击弧线中点 **`↺ ×3`** 徽章即可用 `− / +` 或直接输入自由调整最大重试次数(`1–10`)或取消回环。
91
+ - **带反馈修正与熔断**:每次打回只重置环内节点(环外旁路绝不重复执行),把条件节点的打回理由注入回环起点,并智能复用健康热会话原地修正;超过上限自动熔断,将 `1..N` 轮失败摘要转交最近下游 Lead 拍板。
88
92
  - **节点 `+ 参考` 清单**:所有节点(包括入口 Lead 全局参考、下游 Lead、子代理、条件节点)标题栏右上角均提供 **`+ 参考`** 按钮,可附带文件路径、URL 或规范约束(最多 16 条),运行时自动去重注入提示词。
89
93
 
94
+ ![受控回环重试:编写实现 → 测试与检查 → 是否通过 ↺ 自动修复](docs/images/retry-loop-zh.png)
95
+
90
96
  ![三路 switch/case 条件分支判断与自动剪枝](docs/images/condition-switch-run.gif)
91
97
 
92
98
  ---
@@ -97,6 +103,7 @@
97
103
 
98
104
  - 入口 Lead 的任务栏可填可不填;点卡片 **`▶ 运行`** 需已启用且任务非空,留空时也可直接在聊天框发送任务作为 `task` 传入。
99
105
  - 跑到中间 Lead 时,画布亮起 **`⏸ 待拍板`**(入口按钮同步变为 `⏸ 等待决策`)并交回主对话;回复后下游自动续跑到终审完成。
106
+ - **一键统一终止(`⏹ 终止`)**:任务运行中或停在 **`⏸ 待拍板`** 状态时,画布左上角 `● 已启用` 旁和入口 Lead 卡片左下角均会自动显示红色 **`⏹ 终止`** 按钮——点一下即可并发中止主回合与全部运行中的子代理、解除等待拍板状态并保留已完成节点的缓存(聊天里也可直接要求取消,触发 `canvas_workflow({ cancel: true })`)。
100
107
  - 同一对话重跑支持 `reset: true`;若画布含已产生历史会话的记忆节点,Agent 会在重跑前确认保留记忆还是清空记忆(`clearMemory: true`)。
101
108
 
102
109
  ![启用即跑、Lead 暂停拍板与自动续跑交付](docs/images/lead-pause-resume.gif)
@@ -126,16 +133,16 @@
126
133
  | `Shift+A` / 拖线松手 | 在光标处新建节点,或从输出口拖线至空白处松手就地新建并自动连线(`1` 子代理,`2` Lead,`3` 条件) |
127
134
  | 鼠标中键拖拽 / `Space` + 左键拖拽 | 平移画布 |
128
135
  | 滚轮 / 右下角 `⊡` & `100%` 浮条 | 光标处缩放 / 一键居中看全图 / 点击回 100%,左右拖可连续缩放 |
129
- | `⇄ 横排` / `⇅ 竖排` | 一键切换画布流向并自动重排(竖排为顶入底出 + 垂直曲线,更适合窄侧边栏;条件节点支持 `右出 / 左出` 切换) |
136
+ | `⇄ 横排` / `⇅ 竖排` | 一键切换画布流向并自动重排,**自动记住为新会话默认布局**(竖排为顶入底出 + 垂直曲线,更适合窄侧边栏;条件节点支持 `右出 / 左出` 切换) |
130
137
  | 左键框选 / `Shift`/`Ctrl` 点选 + `Shift+D` / `Delete` | 批量移动、批量复制(连同参数配置与内部连线)或批量删除 |
131
- | 右键单击节点 / 连线 / 空白处 | 打开右键上下文菜单(编辑分工、管理参考、在连线中间插入节点、新建/排版/撤销重做等) |
138
+ | 右键单击节点 / 连线 / 空白处 | 打开右键上下文菜单(编辑分工、管理参考、在连线中间插入节点、设为回环、新建/排版/撤销重做等) |
132
139
  | 右键按住划过连线 | 切断连线(移动 ≥ 6px 触发,与右键菜单不冲突;可在 `⋯` 菜单开关) |
133
- | `Ctrl+Z` / `Ctrl+Shift+Z`(`Ctrl+Y`) / `Esc` | 撤销 / 重做上一步改动 / 关闭菜单弹窗 |
134
- | `⋯` 更多菜单 | 撤销、全览、导入 / 复制 JSON、自动排版、清空画布、动效档位、最大并发、语言切换、快捷键设置 |
140
+ | 顶栏 `↶ / ↷` / `Ctrl+Z` / `Ctrl+Shift+Z`(`Ctrl+Y`) / `Esc` | 撤销 / 重做(涵盖结构改动、节点拖拽位置与横竖排切换)/ 关闭菜单弹窗 |
141
+ | `⋯` 更多菜单 | 撤销、全览、导入 / 复制 JSON(保留布局方向)、自动排版、清空画布、动效档位、最大并发、语言切换、快捷键设置 |
135
142
 
136
143
  ## 预设、分享与限制
137
144
 
138
- - **预设与跨会话复用**:点右上角 `☰ 预设` 即可在顶部将当前画布保存为自定义预设(跨会话通用,新对话一键载入),下方还内置 4 套开箱即用模板(含条件分支)和「新建空白画布」。自定义预设保存在本地浏览器存储中,跨设备分享请用 `⋯ → ⇧ 复制 JSON` 与 `⇩ 导入`。
145
+ - **预设与跨会话复用**:点右上角 `☰ 预设` 即可在顶部将当前画布(连同横/竖排方向)保存为自定义预设,**已打开的其它会话实时同步**并支持点 `↻` 手动刷新;下方还内置 5 套开箱即用模板(含条件分支与循环重试,随当前布局方向自适应排版)和「新建空白画布」。自定义预设保存在本地浏览器存储中,跨设备分享请用 `⋯ → ⇧ 复制 JSON` 与 `⇩ 导入`。
139
146
  - **局部重跑与并发调节**:中间节点失败后支持 `retryFailed: true` 或 `fromNodes` 只重跑失败段及下游、复用已成功节点缓存;`⋯` 菜单可调整最大并发数(1 / 2 / 4 / 6 / 8,默认 4)。
140
147
  - **与其它画布插件的区别**:本项目专注**多子代理编排 + 条件分流 + 对话本体拍板**;如果你需要的是把底层工具调用编译为 `ctx.workflows` 的管线,可看 [`@piedpiper911/dsh-workflow-canvas`](https://github.com/PiedPiper911/dsh-workflow-canvas)。
141
148
  - **运行限制**:子代理的「能力」受主对话权限/沙箱上限约束。