dsh-gallery 1.2.0 → 1.3.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/CHANGELOG.md +54 -0
- package/README.md +37 -13
- package/client.js +194 -9
- package/host/http.js +8 -1
- package/host/tools.js +128 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,57 @@
|
|
|
1
|
+
## v1.3.0 · 回环自动化(2026-11-19)
|
|
2
|
+
|
|
3
|
+
**补上闭环的"回来"那一段**:Agent 改完图,新终稿在资产台高亮、批示回到反馈栏,人点头核准才算完成。
|
|
4
|
+
现有的「改标签附意见 → Agent 自动取回」主力路径保持不变;反馈篮保留备用。两条交互同时有效。
|
|
5
|
+
|
|
6
|
+
### 新增
|
|
7
|
+
1. **第 4 个 Agent 工具 `gallery_reply`**:Agent 执行完改图后显式调用,把「做了什么、请验收」的批示写进反馈篮
|
|
8
|
+
(`kind=agent-reply`,一次性消息)。写前校验 relPath 非空/在产出根内/文件真实存在,防挂错图。
|
|
9
|
+
红线:只写批示,**不 ack、不发送、不 cancel、不碰资产**。前三个工具仍只读。
|
|
10
|
+
2. **这批刚产出的终稿高亮**:`fs.watch` 感知到新增批次后,把该批 `category=final` 的资产高亮(绿框+「新」角标),
|
|
11
|
+
按 mtime 取最新 3 张。只认 `added>0`,删除/改标签不触发。高亮是纯前端渲染,不新增落盘文件。
|
|
12
|
+
3. **反馈栏批示卡片 + 核准/驳回**:批示单独成块显示(不占 Annotation N 序号、不进草稿),
|
|
13
|
+
人点「核准」清掉批示,点「驳回」清批示并写一条人的驳回意见供 Agent 下次取回。全程零自动发送。
|
|
14
|
+
4. 台面打开时低频(5 秒)只读轮询批示,Agent 是另一个进程写批示时无需刷新即可出现。
|
|
15
|
+
|
|
16
|
+
### 不变的
|
|
17
|
+
- 三个只读工具、前后对比、遮罩/裁剪/音视频、排序口径、四处同步与行尾纪律全部不动。
|
|
18
|
+
- 不新增落盘文件(撤销了早期草案里的 review-queue),README 隐私段的五个文件清单仍准确。
|
|
19
|
+
|
|
20
|
+
### 验证
|
|
21
|
+
全量 303/303(原 290 + 新增 13 条 reply-tool 回归),node --check 三文件通过,
|
|
22
|
+
hooks-tdz + client-render-smoke 通过(含一次真实捕获并修掉的 locale 作用域 ReferenceError)。
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## v1.2.1 · 勘误(2026-11-18;**未单独发布**,已随 1.3.0 一并上线)
|
|
27
|
+
|
|
28
|
+
> 这一版只改了文档、没有单独发 npm。下述三处更正从 1.3.0 起生效;
|
|
29
|
+
> npm 上的版本序列是 1.1.0 → 1.2.0 → 1.3.0,**不存在 1.2.1**。
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
**纯文档勘误,功能与 1.2.0 完全相同,一行代码都没动。** 第三方评估指出 README 的安全声明
|
|
33
|
+
低估了真实执行面,核实属实 —— 1.2.0 发布时 README 写「唯一的 `spawn` 是资源管理器定位」,
|
|
34
|
+
但代码实际会按需调起四类本机程序。这不是代码缺陷(四类调用都是固定程序名、参数受约束、须用户主动触发),
|
|
35
|
+
是说明书漏写;但按错误说明书评估出的风险等级会比实际低一档,所以单独发一版把这处讲清楚。
|
|
36
|
+
|
|
37
|
+
### 更正三处
|
|
38
|
+
|
|
39
|
+
1. **安全段**(原「风险等级:低 / 不执行任何文件 / 唯一的 spawn」):改为「低~中」,如实列出四类外部进程——
|
|
40
|
+
`powershell.exe`(复制目录项时读写 CF_HDROP 剪贴板)、`explorer.exe` / `open` / `xdg-open`(定位 / 播放)、
|
|
41
|
+
`ffmpeg` / `ffprobe`(音视频选段)、`execFile(python + PIL/numpy)`(框选裁剪与遮罩)。
|
|
42
|
+
强调均为固定程序名、JSON 传参或受约束参数、须用户主动操作,不经 shell 拼命令、不执行任意脚本;
|
|
43
|
+
并说明缺 python / ffmpeg 时降级而非静默失败。
|
|
44
|
+
2. **删除入口自相矛盾**:进度表原写「删磁盘入口已停用」,但右键菜单有「🗑 删除文件」、
|
|
45
|
+
代码 `op === 'delete'` 也是活的三层闸门。统一为「删除可用(三层保护)」,隐藏才不动磁盘。
|
|
46
|
+
3. **build 指令**:原教 `npm run build`,但 npm 包内无 `scripts` 字段、无 `src/`、无构建脚本。
|
|
47
|
+
改为说明「npm 包只含构建产物、无需也无法在包内重建,改源码请去 GitHub 源码仓库」。
|
|
48
|
+
|
|
49
|
+
### 顺带核对
|
|
50
|
+
|
|
51
|
+
- 逐条核实第三方评估其余五条:发版节奏快、耦合宿主内部实现、规模阈值、可审计性弱、功能蔓延 ——
|
|
52
|
+
均属实但属设计取舍 / 已知边界,不是 bug,本次不改代码。
|
|
53
|
+
- 全量回归 **290/290**(无代码改动);包内 41 文件与源码逐文件零差异;零运行时依赖。
|
|
54
|
+
|
|
1
55
|
## v1.2.0 · 正式发布(2026-11-18)
|
|
2
56
|
|
|
3
57
|
局部重绘之后要拿「改前 / 改后」对一眼,原来只能开大图翻来翻去,或者自己拼图。
|
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
> 视频音频能在面板里直接播放并拖进度条,
|
|
9
9
|
> **让你在任务进行中就能看到产出、当场校验,而不是结束后才发现做错了。**
|
|
10
10
|
>
|
|
11
|
-
> 📌 **版本状态(2026-11-
|
|
11
|
+
> 📌 **版本状态(2026-11-19)**:当前版本 `1.3.0`(回环自动化:新终稿高亮 + Agent 批示回反馈栏 + 人核准)。
|
|
12
12
|
> 1.2.0 新增**前后对比**:两张图叠在同一位置,中间一条滑块左右拖;**放大后两张锁在同一处、分割线留在屏幕上不动**,
|
|
13
13
|
> 也能切平铺并排看。批量选两张即可进对比,也可在查看器里挑,候选里带遮罩关系的会排前面。
|
|
14
14
|
> 实时看见、当场校验、就地处置已可用;能给 ComfyUI 工作流画遮罩、直接把素材粘进来剪短;
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
> 图上**批注框跟随缩放平移**(放大后圈选仍落在原图同一处);**标注态按住鼠标中键拖动**即可平移图片、已画框跟着走。
|
|
24
24
|
> **`Ctrl+V` 直接在资产区粘贴素材**(图片/文件都行,标「素材」),**落在鼠标所指的那个对话组**;图片查看器有**带取色放大镜的裁剪**(绿框八向手柄、显示裁剪尺寸与光标处坐标色值),音视频播放器有**入点/出点选段裁剪**,产物归素材来源的那个对话、自动标「素材」。
|
|
25
25
|
|
|
26
|
-
[](#)
|
|
27
27
|
[](LICENSE)
|
|
28
28
|
[](#技术说明给想改代码的人)
|
|
29
29
|
[](#兼容性)
|
|
@@ -341,7 +341,7 @@ github:Hope2023Dcr/dsh-gallery
|
|
|
341
341
|
> ```
|
|
342
342
|
|
|
343
343
|
> 上面那个 commit 是 **v0.14.1** 的历史基线(表态层当时还在)。正式版可用
|
|
344
|
-
> `git+https://github.com/Hope2023Dcr/dsh-gallery.git#v1.
|
|
344
|
+
> `git+https://github.com/Hope2023Dcr/dsh-gallery.git#v1.3.0` 锁定版本。
|
|
345
345
|
> **更推荐直接用 npm**(`npm i dsh-gallery`)—— 版本号跟着 `latest` 走,不用每次手工核对哈希。
|
|
346
346
|
|
|
347
347
|
> ⚠️ 这种方式需要**能访问 GitHub**。DSH 的「国内镜像」只代理 npm 包,不代替 GitHub 下载。
|
|
@@ -495,17 +495,20 @@ config:
|
|
|
495
495
|
|
|
496
496
|
## 安全
|
|
497
497
|
|
|
498
|
-
|
|
498
|
+
**风险等级:低~中。** 插件只操作本机产出目录、不上传任何数据;但**按需会调起四类本机程序**——
|
|
499
|
+
都不是「任意命令执行」(固定程序名 / 内置脚本、参数受约束、须你主动操作才触发)。
|
|
500
|
+
旧版这里写「唯一的 `spawn` 是资源管理器定位」,低估了真实执行面,现已按下表更正。
|
|
499
501
|
|
|
500
502
|
| 能力 | 做法 |
|
|
501
503
|
|---|---|
|
|
502
|
-
| **文件预览** |
|
|
503
|
-
|
|
|
504
|
+
| **文件预览** | 委托 DSH **原生侧栏预览器**(走 `dsh-resource://` 文档路由);音视频因宿主转发剥掉 `Content-Length` 导致 `seekable=[0,0]`,改走 blob 直读 |
|
|
505
|
+
| **调起本机程序(四类,均按需触发)** | ① `powershell.exe`:仅在你复制「目录」类剪贴板项时读写 Windows CF_HDROP;② `explorer.exe` / macOS `open` / Linux `xdg-open`:你点「打开所在文件夹 / 播放」时按系统关联打开;③ `ffmpeg` / `ffprobe`:你点「音视频选段保存」时切段与量时长;④ `python`(PIL/numpy):框选导出遮罩 / 裁剪时跑**内置脚本**算像素矩形与生成裁剪图,JSON 文件传参、带超时。**全部固定程序名、不经 shell 拼命令、不执行你指定的任意脚本或可执行文件** |
|
|
504
506
|
| **删除操作** | 三层保护:前端二次确认 → API 强制 `confirm: true` → 路径越界校验(`isInside(root)`) |
|
|
505
507
|
| **路径穿越防护** | 所有文件操作都经 `isInside(root, absolute)` 校验,只允许在扫描目录内 |
|
|
506
508
|
| **HTTP 路由** | `POST /api/dsh-gallery`(走 DSH `/api` 网关,需认证)负责列表与操作;另有**一条独立 `GET/HEAD` 媒体路由**用于缩略图抽取与分段读取(详见下方「媒体路由的安全边界」)。**面板内播放的整包读取也走 `/api` 网关的 `raw` 分支**,不经 `dsh-app://` 媒体管线 |
|
|
507
509
|
|
|
508
510
|
**删文件是唯一不可逆操作**,所以做了三层保护;隐藏只是从列表移除,文件不动。
|
|
511
|
+
上述四类外部程序都只在对应操作触发时运行,插件不会自行执行任意命令;但没有 python / ffmpeg 的环境会降级(只给坐标、不生成裁剪图;找不到 ffmpeg 直接报「无法裁剪」),不会静默失败。
|
|
509
512
|
|
|
510
513
|
#### 媒体路由的安全边界
|
|
511
514
|
|
|
@@ -700,6 +703,27 @@ Annotation 1:按框选区域修改 —— 后视图.png
|
|
|
700
703
|
> **两层的正确用法**:一轮出 20 张 → 扫一遍改标签(不花钱、不自动说话)→
|
|
701
704
|
> 需要 Agent 真动手时,改标签或圈批注进反馈篮,人工审核合并后发送。标签是状态,反馈才是指令。
|
|
702
705
|
|
|
706
|
+
### 回环自动化:让结果自己回来(v1.3.0)
|
|
707
|
+
|
|
708
|
+
前面讲的是「人怎么把意见给 Agent」;这一节讲「Agent 改完,结果怎么回到人眼前」。
|
|
709
|
+
|
|
710
|
+
- **新终稿高亮**:Agent 改完图落盘后,资产台会把这批刚产出的终稿(定稿分类)用绿框和「新」角标高亮,
|
|
711
|
+
最多 3 张。只认真正新增的资产,删除或改标签不会触发。你不用再自己找"它到底改了哪张"。
|
|
712
|
+
- **Agent 批示回反馈栏**:Agent 执行完会调第 4 个工具 `gallery_reply`,把「做了什么、请验收」写成一条批示。
|
|
713
|
+
批示单独出现在反馈栏顶部,**不占你的反馈序号、也不会被当成你的话发回去**。
|
|
714
|
+
- **人核准才闭环**:每条批示有「核准 / 驳回」两个按钮。核准=认可这次改动;驳回=清掉批示并写一条你的意见,
|
|
715
|
+
Agent 下次取回的就是它。台面开着时会低频自动检查批示,不用手动刷新。
|
|
716
|
+
|
|
717
|
+
两条交互**同时有效、互不干扰**:
|
|
718
|
+
|
|
719
|
+
| 路径 | 意见怎么进 | 结果怎么回 |
|
|
720
|
+
|---|---|---|
|
|
721
|
+
| A(主力,未改) | 改标签时附意见 → Agent 自动取回 | 新图高亮(共用);意见已随标签取回,不重复写批示 |
|
|
722
|
+
| B(备用,保留) | 反馈篮意见 → Agent 取回执行 | 新图高亮 + 批示进反馈栏 + 你核准 |
|
|
723
|
+
|
|
724
|
+
`gallery_reply` 与前三个工具不同,是**唯一会写入**的工具,但它只往反馈篮写一条待处理批示 ——
|
|
725
|
+
不碰资产、不替你确认、不发送任何消息。**零自动发送、人确认闸门这条红线不变。**
|
|
726
|
+
|
|
703
727
|
## 完成态与当前进度
|
|
704
728
|
|
|
705
729
|
### 最终要做成什么样
|
|
@@ -731,7 +755,8 @@ Annotation 1:按框选区域修改 —— 后视图.png
|
|
|
731
755
|
| 会话状态标注:左侧还开着的不乱标,「打开对话」始终可点 | ✅ **v0.14.3** |
|
|
732
756
|
| 图上框选批注 → 进反馈篮 → 进决策草稿(带区域) | ✅ **v0.14.1** |
|
|
733
757
|
| 反馈篮多动作 + 零自动发送 | ✅ 已实现 |
|
|
734
|
-
| 批量改标签 /
|
|
758
|
+
| 批量改标签 / 批量处置 | ✅ 已实现 |
|
|
759
|
+
| 右键删磁盘文件(三层闸门:二次确认 → `confirm:true` → 路径越界) | ✅ 可用;隐藏则不动磁盘文件 |
|
|
735
760
|
| **批注落盘(重启 / 刷新不丢)** | ❌ 只存内存 |
|
|
736
761
|
| **批注跟随图片缩放平移;标注态中键移动不脱框** | ✅ **v0.14.4**(1:1 与放大都对齐,中键平移框跟随) |
|
|
737
762
|
| **矩形框 → ComfyUI RGBA 遮罩(选区内 alpha=0、RGB 保留原图)** | ✅ **v0.15.0** |
|
|
@@ -773,14 +798,13 @@ DSH 生态里有几类「产出管理」插件,容易混淆。**本插件的
|
|
|
773
798
|
|
|
774
799
|
## 开发:改源码后必须构建
|
|
775
800
|
|
|
776
|
-
`client.js`
|
|
801
|
+
`client.js` 是**构建产物**,改源码后不构建,改动不会生效。
|
|
777
802
|
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
npm run build
|
|
781
|
-
```
|
|
803
|
+
> ⚠️ **npm 包里只有构建产物,不含 `src/` 与构建脚本**,`package.json` 也没有 `scripts` 字段——
|
|
804
|
+
> 本包无需、也无法在包内重新构建。要改源码请在 **GitHub 源码仓库** 里进行(那里有 `src/` 分片和构建脚本),
|
|
805
|
+
> 别在 npm 包目录里找 `npm run build`。直接用本包的话,`client.js` 改完刷新页面即生效。
|
|
782
806
|
|
|
783
|
-
|
|
807
|
+
源码仓库里的分片布局:
|
|
784
808
|
|
|
785
809
|
| 路径 | 内容 |
|
|
786
810
|
|---|---|
|
package/client.js
CHANGED
|
@@ -3045,6 +3045,18 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
3045
3045
|
}
|
|
3046
3046
|
.dg-feedback .dg-btnSmall { padding: 3px 9px; font-size: 11px; }
|
|
3047
3047
|
|
|
3048
|
+
/* v1.3.0:Agent 批示区块(独立于表态/批注序号,不进草稿) */
|
|
3049
|
+
.dg-replyBlock { border: 1px solid #00e676; border-radius: 8px; padding: 8px; margin: 8px 0; background: rgba(0, 230, 118, 0.06); }
|
|
3050
|
+
.dg-replyHead { color: #00e676; font-size: 12px; font-weight: 600; margin-bottom: 6px; }
|
|
3051
|
+
.dg-replyList { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
|
|
3052
|
+
.dg-replyItem { border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 6px; padding: 7px 8px; background: #222831; }
|
|
3053
|
+
.dg-replyText { color: #e8eaed; font-size: 12px; line-height: 1.5; margin-bottom: 4px; word-break: break-word; }
|
|
3054
|
+
.dg-replyMeta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 11px; color: #a9b1bd; margin-bottom: 6px; }
|
|
3055
|
+
.dg-replyName { color: #cdd4de; }
|
|
3056
|
+
.dg-replyOps { display: flex; gap: 6px; justify-content: flex-end; }
|
|
3057
|
+
.dg-feedback .dg-replyApprove { background: #1d7a4d; color: #ffffff; border-color: #1d7a4d; }
|
|
3058
|
+
.dg-feedback .dg-replyApprove:hover:not(:disabled) { background: #249a60; border-color: #249a60; }
|
|
3059
|
+
|
|
3048
3060
|
.dg-feedbackActions {
|
|
3049
3061
|
display: flex; justify-content: flex-end; gap: 8px;
|
|
3050
3062
|
padding: 10px 14px; border-top: 1px solid rgba(255, 255, 255, 0.10);
|
|
@@ -3106,6 +3118,14 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
3106
3118
|
|
|
3107
3119
|
/* 卡片包装层 + 确认角标 + 多选框 */
|
|
3108
3120
|
.dg-cardWrap { position: relative; }
|
|
3121
|
+
/* v1.3.0:这批刚产出的终稿高亮(上限 3 张)。用外发光+角标,不动 ::after border(避免和选中态打架)。 */
|
|
3122
|
+
.dg-cardWrap.dg-cardFreshFinal { box-shadow: 0 0 0 2px #00e676, 0 0 12px rgba(0, 230, 118, 0.35); border-radius: 6px; }
|
|
3123
|
+
.dg-cardWrap.dg-cardFreshFinal::before {
|
|
3124
|
+
content: '新';
|
|
3125
|
+
position: absolute; top: 4px; right: 4px; z-index: 7;
|
|
3126
|
+
background: #00e676; color: #04220f; font-size: 11px; font-weight: 600;
|
|
3127
|
+
padding: 0 6px; border-radius: 8px; line-height: 16px;
|
|
3128
|
+
}
|
|
3109
3129
|
/* 结论角标(左上):人的表态,优先于右上角的机器预判角标 */
|
|
3110
3130
|
.dg-verdictBadge {
|
|
3111
3131
|
position: absolute; top: 6px; left: 6px; z-index: 5;
|
|
@@ -4331,7 +4351,8 @@ function serializeFeedback(feedback) {
|
|
|
4331
4351
|
*/
|
|
4332
4352
|
function FeedbackBasket({ t, items, currentSessionId, targetSessionTitle,
|
|
4333
4353
|
onClose, onRemove, onEdit, onClear, onEditSave,
|
|
4334
|
-
onRemoveAnnotation, onClearAll, onAck
|
|
4354
|
+
onRemoveAnnotation, onClearAll, onAck,
|
|
4355
|
+
onAckReply, onRejectReply }) {
|
|
4335
4356
|
// 语言判断:用 t 探测一个已知键 —— 命中中文就按 zh 渲染,否则 en。
|
|
4336
4357
|
// (不引入 detectLocale,插件没有这个工具函数)
|
|
4337
4358
|
const [locale] = React.useState(() => {
|
|
@@ -4350,6 +4371,8 @@ function serializeFeedback(feedback) {
|
|
|
4350
4371
|
const rows = React.useMemo(() => {
|
|
4351
4372
|
const out = []
|
|
4352
4373
|
for (const it of Array.isArray(items) ? items : []) {
|
|
4374
|
+
// v1.3.0:Agent 批示单独渲染在列表顶部,不进 Annotation N 序号、不进草稿
|
|
4375
|
+
if (it.reply !== undefined && it.reply !== null) continue
|
|
4353
4376
|
if (it.mark !== undefined && it.mark !== null) out.push({ kind: 'mark', it })
|
|
4354
4377
|
const annots = Array.isArray(it.annotations) ? it.annotations : []
|
|
4355
4378
|
for (const a of annots) out.push({ kind: 'annot', it, a })
|
|
@@ -4357,6 +4380,11 @@ function serializeFeedback(feedback) {
|
|
|
4357
4380
|
return out
|
|
4358
4381
|
}, [items])
|
|
4359
4382
|
const annotCount = rows.filter((r) => r.kind === 'annot').length
|
|
4383
|
+
// v1.3.0:Agent 批示条目(单独区块,独立于表态/批注序号)
|
|
4384
|
+
const replyRows = React.useMemo(
|
|
4385
|
+
() => (Array.isArray(items) ? items : []).filter((it) => it.reply !== undefined && it.reply !== null),
|
|
4386
|
+
[items],
|
|
4387
|
+
)
|
|
4360
4388
|
// 编辑弹窗:正在编辑的条目 + 三个字段的草稿值
|
|
4361
4389
|
const [editing, setEditing] = React.useState(null)
|
|
4362
4390
|
const [editReason, setEditReason] = React.useState('')
|
|
@@ -4421,7 +4449,11 @@ function serializeFeedback(feedback) {
|
|
|
4421
4449
|
*/
|
|
4422
4450
|
if (typeof onAck === 'function') {
|
|
4423
4451
|
try {
|
|
4424
|
-
|
|
4452
|
+
// v1.3.0:Agent 批示不随普通草稿被清 —— 它有自己的核准/驳回入口
|
|
4453
|
+
const humanPaths = items
|
|
4454
|
+
.filter((it) => it.reply === undefined || it.reply === null)
|
|
4455
|
+
.map((it) => it.relPath)
|
|
4456
|
+
await onAck(humanPaths)
|
|
4425
4457
|
} catch { /* ack 失败不影响草稿已经写进去这个事实 */ }
|
|
4426
4458
|
}
|
|
4427
4459
|
} else {
|
|
@@ -4471,6 +4503,48 @@ function serializeFeedback(feedback) {
|
|
|
4471
4503
|
format(t('feedbackAnnotHint'), { n: annotCount }))
|
|
4472
4504
|
: null,
|
|
4473
4505
|
|
|
4506
|
+
// v1.3.0:Agent 批示区块(独立于下面的表态/批注序号,不进草稿)
|
|
4507
|
+
// 每条批示 = Agent 改完图后的回报,人在这里核准或驳回;驳回会带着意见再回去。
|
|
4508
|
+
replyRows.length > 0
|
|
4509
|
+
? h('div', { className: 'dg-replyBlock', key: 'replies', 'data-gallery-agent-replies': replyRows.length }, [
|
|
4510
|
+
h('div', { className: 'dg-replyHead', key: 'h' },
|
|
4511
|
+
locale === 'en' ? 'Agent replies · pending your approval' : 'Agent 批示 · 待您核准'),
|
|
4512
|
+
h('ul', { className: 'dg-replyList', key: 'l' },
|
|
4513
|
+
replyRows.map((it) => {
|
|
4514
|
+
const r = it.reply
|
|
4515
|
+
const fileName = it.relPath.split('/').pop() ?? it.relPath
|
|
4516
|
+
return h('li', {
|
|
4517
|
+
className: 'dg-replyItem',
|
|
4518
|
+
key: 'reply:' + it.relPath,
|
|
4519
|
+
'data-gallery-reply-item': it.relPath,
|
|
4520
|
+
}, [
|
|
4521
|
+
h('div', { className: 'dg-replyText', key: 'text' },
|
|
4522
|
+
(locale === 'en' ? 'Agent: ' : 'Agent:') + String(r.text ?? '')),
|
|
4523
|
+
h('div', { className: 'dg-replyMeta', key: 'meta' }, [
|
|
4524
|
+
h('span', { className: 'dg-replyName', key: 'name', title: it.relPath }, fileName),
|
|
4525
|
+
r.replyOf
|
|
4526
|
+
? h('span', { className: 'dg-feedbackDim', key: 'of' },
|
|
4527
|
+
(locale === 'en' ? 're: ' : '回应:') + (r.replyOf.split('/').pop() ?? r.replyOf))
|
|
4528
|
+
: null,
|
|
4529
|
+
]),
|
|
4530
|
+
h('div', { className: 'dg-replyOps', key: 'ops' }, [
|
|
4531
|
+
h('button', {
|
|
4532
|
+
type: 'button', className: 'dg-btn dg-btnSmall dg-replyApprove', key: 'ok',
|
|
4533
|
+
'data-gallery-reply-approve': it.relPath,
|
|
4534
|
+
onClick: () => { if (typeof onAckReply === 'function') onAckReply(it.relPath) },
|
|
4535
|
+
}, locale === 'en' ? 'Approve' : '核准'),
|
|
4536
|
+
h('button', {
|
|
4537
|
+
type: 'button', className: 'dg-btn dg-btnSmall', key: 'no',
|
|
4538
|
+
'data-gallery-reply-reject': it.relPath,
|
|
4539
|
+
onClick: () => { if (typeof onRejectReply === 'function') onRejectReply(it.relPath) },
|
|
4540
|
+
}, locale === 'en' ? 'Reject' : '驳回'),
|
|
4541
|
+
]),
|
|
4542
|
+
])
|
|
4543
|
+
})
|
|
4544
|
+
),
|
|
4545
|
+
])
|
|
4546
|
+
: null,
|
|
4547
|
+
|
|
4474
4548
|
rows.length === 0
|
|
4475
4549
|
? h('p', { className: 'dg-status', key: 'empty' }, t('feedbackBasketEmpty'))
|
|
4476
4550
|
: h('ul', { className: 'dg-feedbackList', key: 'list' },
|
|
@@ -8956,6 +9030,9 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
8956
9030
|
* 两者混同就会重演「删一条反馈把定好的标签也撤了」的错。
|
|
8957
9031
|
*/
|
|
8958
9032
|
const [pendingCount, setPendingCount] = React.useState(0)
|
|
9033
|
+
// v1.3.0:Agent 批示(gallery_reply 写进 feedback.json,kind='agent-reply')。
|
|
9034
|
+
// 每项 = { relPath, text, replyOf, markedAt };只在反馈栏显示,不进草稿、不自动清。
|
|
9035
|
+
const [agentReplies, setAgentReplies] = React.useState({})
|
|
8959
9036
|
// 编辑中的条目(null 表示不编辑)
|
|
8960
9037
|
const [editingItem, setEditingItem] = React.useState(null)
|
|
8961
9038
|
// 网格滚动位置:打开查看器前记录,关闭后恢复,让视图停在原缩略图处
|
|
@@ -8978,13 +9055,32 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
8978
9055
|
})
|
|
8979
9056
|
.catch((error) => console.warn('dsh-gallery: getLabels 失败', error))
|
|
8980
9057
|
// v0.16.4 · B 档:台面打开时读一次待处理条数(纯读,不标记已读)
|
|
8981
|
-
|
|
8982
|
-
|
|
8983
|
-
|
|
8984
|
-
|
|
8985
|
-
}
|
|
9058
|
+
// v1.3.0:顺带提取 Agent 批示(kind='agent-reply')供反馈栏显示
|
|
9059
|
+
const applyPending = (payload) => {
|
|
9060
|
+
if (!alive || payload?.ok === false) return
|
|
9061
|
+
setPendingCount(Number.isFinite(payload?.count) ? payload.count : 0)
|
|
9062
|
+
const replies = {}
|
|
9063
|
+
for (const it of (Array.isArray(payload?.items) ? payload.items : [])) {
|
|
9064
|
+
if (String(it?.kind ?? '') !== 'agent-reply') continue
|
|
9065
|
+
const rel = String(it?.relPath ?? '')
|
|
9066
|
+
if (rel === '') continue
|
|
9067
|
+
replies[rel] = {
|
|
9068
|
+
relPath: rel,
|
|
9069
|
+
text: String(it?.replyText ?? ''),
|
|
9070
|
+
replyOf: String(it?.replyOf ?? ''),
|
|
9071
|
+
markedAt: Number(it?.markedAt) || 0,
|
|
9072
|
+
}
|
|
9073
|
+
}
|
|
9074
|
+
setAgentReplies(replies)
|
|
9075
|
+
}
|
|
9076
|
+
callHost('getPendingFeedback', {}).then(applyPending)
|
|
8986
9077
|
.catch((error) => console.warn('dsh-gallery: getPendingFeedback 失败', error))
|
|
8987
|
-
|
|
9078
|
+
// v1.3.0:Agent 是另一个进程,改完图写批示时台面可能一直开着 —— 低频轮询让批示自己出现。
|
|
9079
|
+
// 只读、不清零;人核准走显式 ackFeedback。
|
|
9080
|
+
const replyTimer = setInterval(() => {
|
|
9081
|
+
callHost('getPendingFeedback', {}).then(applyPending).catch(() => {})
|
|
9082
|
+
}, 5000)
|
|
9083
|
+
return () => { alive = false; clearInterval(replyTimer) }
|
|
8988
9084
|
}, [])
|
|
8989
9085
|
|
|
8990
9086
|
/** 手动标签覆写:只读独立 labels 文件,与反馈篮条目互不影响。 */
|
|
@@ -9096,6 +9192,49 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
9096
9192
|
}
|
|
9097
9193
|
}, [])
|
|
9098
9194
|
|
|
9195
|
+
/**
|
|
9196
|
+
* v1.3.0:核准 Agent 批示 —— 清掉该条批示,本地 state 同步移除。
|
|
9197
|
+
* 只 ack 这一条批示,不碰同图的人写反馈(setFeedback 按 relPath 存,同 path 只有一条,
|
|
9198
|
+
* 这里 ack 后若人还有意见会重新写;批示与人意见同 path 时本就以最新为准)。
|
|
9199
|
+
*/
|
|
9200
|
+
const ackAgentReply = React.useCallback(async (relPath) => {
|
|
9201
|
+
await ackPending([relPath])
|
|
9202
|
+
setAgentReplies((prev) => {
|
|
9203
|
+
if (!(relPath in prev)) return prev
|
|
9204
|
+
const next = { ...prev }
|
|
9205
|
+
delete next[relPath]
|
|
9206
|
+
return next
|
|
9207
|
+
})
|
|
9208
|
+
}, [ackPending])
|
|
9209
|
+
|
|
9210
|
+
/**
|
|
9211
|
+
* v1.3.0:驳回 Agent 批示 —— 先清批示,再把该图标成「交付不合格」让人补一句意见,
|
|
9212
|
+
* 这样 Agent 下次取回的就是人的驳回意见,而不是那条已完成的批示。全程不发送。
|
|
9213
|
+
*/
|
|
9214
|
+
const rejectAgentReply = React.useCallback(async (relPath) => {
|
|
9215
|
+
const reply = agentReplies[relPath]
|
|
9216
|
+
// 先清批示,再写人的驳回表态 —— 顺序不能反,否则 recordPendingFeedback 会把批示覆盖掉
|
|
9217
|
+
await ackPending([relPath])
|
|
9218
|
+
setAgentReplies((prev) => {
|
|
9219
|
+
if (!(relPath in prev)) return prev
|
|
9220
|
+
const next = { ...prev }
|
|
9221
|
+
delete next[relPath]
|
|
9222
|
+
return next
|
|
9223
|
+
})
|
|
9224
|
+
// 这个回调在 GalleryBody 作用域,没有 locale 变量 —— 用 t 探测一次(与 FeedbackBasket 同口径)
|
|
9225
|
+
let isEn = false
|
|
9226
|
+
try { isEn = !/[\u4e00-\u9fa5]/.test(String(t('feedbackBasketTitle') ?? '')) } catch { isEn = false }
|
|
9227
|
+
const reason = (isEn ? 'Rejected the agent reply. ' : '驳回 Agent 的这次修改。')
|
|
9228
|
+
+ (reply?.text ? (isEn ? 'Reply was: ' : '原批示:') + reply.text : '')
|
|
9229
|
+
const mark = { action: 'reject', reason, markedAt: Date.now() }
|
|
9230
|
+
setMarks((prev) => ({ ...prev, [relPath]: mark }))
|
|
9231
|
+
try {
|
|
9232
|
+
await callHost('marks', { path: relPath, mark })
|
|
9233
|
+
} catch { /* 写回失败不阻断本地状态 */ }
|
|
9234
|
+
// 同步待处理反馈:人驳回=一条新的待处理意见,Agent 下次取回的就是它
|
|
9235
|
+
await recordPendingFeedback([{ path: relPath, item: { action: 'reject', reason } }])
|
|
9236
|
+
}, [ackPending, agentReplies, t, recordPendingFeedback])
|
|
9237
|
+
|
|
9099
9238
|
/**
|
|
9100
9239
|
* 手动改标签的主逻辑(v0.14.2)。
|
|
9101
9240
|
*
|
|
@@ -9845,6 +9984,9 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
9845
9984
|
// 局部替换时其它组对象引用保持不变,React 就不会重绘它们。
|
|
9846
9985
|
const changesVersionRef = React.useRef(0)
|
|
9847
9986
|
const changesBusyRef = React.useRef(false)
|
|
9987
|
+
// v1.3.0:最近一批「新增资产」的时间戳 —— 用来高亮这批刚产出的终稿。
|
|
9988
|
+
// 只认 added>0 的变动,避免删除/改标签也触发高亮。state 让卡片重绘。
|
|
9989
|
+
const [lastBatchAt, setLastBatchAt] = React.useState(0)
|
|
9848
9990
|
// 写操作后主动催一次检查(不等 1 秒轮询),用户点了就该立刻看到结果
|
|
9849
9991
|
const changesKickRef = React.useRef(null)
|
|
9850
9992
|
|
|
@@ -9864,6 +10006,13 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
9864
10006
|
changesVersionRef.current = v
|
|
9865
10007
|
const changed = Array.isArray(r.changed) ? r.changed : []
|
|
9866
10008
|
|
|
10009
|
+
// v1.3.0:记下这批新增的时间,供卡片高亮「刚产出的终稿」
|
|
10010
|
+
const addTimes = changed
|
|
10011
|
+
.filter((c) => Number(c?.added) > 0)
|
|
10012
|
+
.map((c) => Number(c?.at) || 0)
|
|
10013
|
+
.filter((t) => t > 0)
|
|
10014
|
+
if (addTimes.length > 0) setLastBatchAt(Math.max(...addTimes))
|
|
10015
|
+
|
|
9867
10016
|
// 决定「能不能局部刷」:只有分组视图且每个变动都有明确会话才能局部。
|
|
9868
10017
|
// 读 viewRef(不是 view)拿最新值,避免闭包过期。
|
|
9869
10018
|
const cur = viewRef.current
|
|
@@ -10021,6 +10170,33 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
10021
10170
|
const groupsRef = React.useRef(null)
|
|
10022
10171
|
groupsRef.current = Array.isArray(data?.groups) ? data.groups : null
|
|
10023
10172
|
|
|
10173
|
+
/**
|
|
10174
|
+
* v1.3.0:这批刚产出的终稿(用于资产台高亮,上限 3 张)。
|
|
10175
|
+
* 口径:全视图(含分组)里 category=final 且 mtime 落在最近新增批次内的资产,
|
|
10176
|
+
* 按 mtime 取最新 3 个。lastBatchAt=0 时不高亮任何卡片(初始没有"这批")。
|
|
10177
|
+
*/
|
|
10178
|
+
const freshFinalSet = React.useMemo(() => {
|
|
10179
|
+
if (!lastBatchAt || lastBatchAt <= 0) return new Set()
|
|
10180
|
+
const all = [
|
|
10181
|
+
...(Array.isArray(items) ? items : []),
|
|
10182
|
+
...(Array.isArray(data?.groups) ? data.groups.flatMap((g) => (Array.isArray(g?.files) ? g.files : [])) : []),
|
|
10183
|
+
]
|
|
10184
|
+
const seen = new Set()
|
|
10185
|
+
const fresh = []
|
|
10186
|
+
for (const it of all) {
|
|
10187
|
+
const rel = String(it?.relPath ?? '')
|
|
10188
|
+
if (rel === '' || seen.has(rel)) continue
|
|
10189
|
+
if (String(it?.category ?? '') !== 'final') continue
|
|
10190
|
+
const mt = Number(it?.mtime) || 0
|
|
10191
|
+
// 5 秒容差:fs.watch 的 at 与文件 mtime 可能差几秒
|
|
10192
|
+
if (mt < lastBatchAt - 5000) continue
|
|
10193
|
+
seen.add(rel)
|
|
10194
|
+
fresh.push({ rel, mt })
|
|
10195
|
+
}
|
|
10196
|
+
fresh.sort((a, b) => b.mt - a.mt)
|
|
10197
|
+
return new Set(fresh.slice(0, 3).map((x) => x.rel))
|
|
10198
|
+
}, [items, data, lastBatchAt])
|
|
10199
|
+
|
|
10024
10200
|
// 分组首次渲染时,默认展开「当前对话」那一组(没有则展开第一组)。
|
|
10025
10201
|
// 只做一次:之后用户手动收起/展开都保留。
|
|
10026
10202
|
React.useEffect(() => {
|
|
@@ -10498,8 +10674,11 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
10498
10674
|
const showCheckbox = selectMode || checked
|
|
10499
10675
|
const manual = manualLabelOf(item.relPath)
|
|
10500
10676
|
const isManual = manual !== null && manual !== undefined
|
|
10677
|
+
// v1.3.0:这批刚产出的终稿加高亮 class(上限 3 张,由 freshFinalSet 控制)
|
|
10678
|
+
const isFreshFinal = freshFinalSet.has(item.relPath)
|
|
10501
10679
|
return h('div', {
|
|
10502
|
-
className: `dg-cardWrap${checked ? ' dg-cardChecked' : ''}${selectMode ? ' dg-cardSelectable' : ''}`,
|
|
10680
|
+
className: `dg-cardWrap${checked ? ' dg-cardChecked' : ''}${selectMode ? ' dg-cardSelectable' : ''}${isFreshFinal ? ' dg-cardFreshFinal' : ''}`,
|
|
10681
|
+
'data-gallery-fresh-final': isFreshFinal ? '1' : '0',
|
|
10503
10682
|
key: key + ':wrap',
|
|
10504
10683
|
'data-gallery-card-wrap': item.relPath,
|
|
10505
10684
|
'data-gallery-bucket': bucket,
|
|
@@ -11069,6 +11248,7 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
11069
11248
|
const feedbackPaths = Array.from(new Set([
|
|
11070
11249
|
...Object.keys(marks),
|
|
11071
11250
|
...Object.keys(annotations),
|
|
11251
|
+
...Object.keys(agentReplies),
|
|
11072
11252
|
]))
|
|
11073
11253
|
const markedList = feedbackPaths.map((relPath) => {
|
|
11074
11254
|
// 从当前视图里找该条目,拿 category / sessionId
|
|
@@ -11086,6 +11266,8 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
11086
11266
|
maskOf: maskBySource.get(relPath) ?? found?.maskOf,
|
|
11087
11267
|
mark: marks[relPath],
|
|
11088
11268
|
annotations: Array.isArray(annotations[relPath]) ? annotations[relPath] : [],
|
|
11269
|
+
// v1.3.0:Agent 批示(只在反馈栏显示成卡片,不进草稿、不参与序号)
|
|
11270
|
+
reply: agentReplies[relPath] ?? null,
|
|
11089
11271
|
}
|
|
11090
11272
|
})
|
|
11091
11273
|
const feedbackLayer = basketOpen && markedList.length >= 0
|
|
@@ -11115,6 +11297,9 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
11115
11297
|
},
|
|
11116
11298
|
// v0.16.4:草稿进 composer 后把待处理清零(人已处理完这批)
|
|
11117
11299
|
onAck: (paths) => { void ackPending(paths) },
|
|
11300
|
+
// v1.3.0:Agent 批示的核准 / 驳回(独立于普通草稿流程)
|
|
11301
|
+
onAckReply: (relPath) => { void ackAgentReply(relPath) },
|
|
11302
|
+
onRejectReply: (relPath) => { void rejectAgentReply(relPath) },
|
|
11118
11303
|
})
|
|
11119
11304
|
: null
|
|
11120
11305
|
|
package/host/http.js
CHANGED
|
@@ -1431,6 +1431,11 @@ export function registerOpsRoute(ctx, config) {
|
|
|
1431
1431
|
// v0.16.4:带上分类与归属会话 —— Agent 拿到就能判断该改哪个文件、归哪条对话
|
|
1432
1432
|
category: String(item.category ?? 'unknown'),
|
|
1433
1433
|
sessionId: String(item.sessionId ?? ''),
|
|
1434
|
+
// v1.3.0:Agent 批示(gallery_reply 写入)。前端据此在反馈栏渲染批示卡片;
|
|
1435
|
+
// 不是批示的条目这些字段为空字符串,不影响既有渲染与草稿。
|
|
1436
|
+
kind: String(item.kind ?? ''),
|
|
1437
|
+
replyText: String(item.text ?? ''),
|
|
1438
|
+
replyOf: String(item.replyOf ?? ''),
|
|
1434
1439
|
}
|
|
1435
1440
|
const flatAction = String(item.action ?? '')
|
|
1436
1441
|
const annots = Array.isArray(item.annotations)
|
|
@@ -1472,7 +1477,9 @@ export function registerOpsRoute(ctx, config) {
|
|
|
1472
1477
|
let draft = ''
|
|
1473
1478
|
try {
|
|
1474
1479
|
const locale = body?.locale === 'en' ? 'en' : 'zh'
|
|
1475
|
-
|
|
1480
|
+
// v1.3.0:Agent 批示只在反馈栏给人看,不进「发给 Agent」的草稿 —— 否则等于把它自己的话再发回去。
|
|
1481
|
+
const draftItems = items.filter((it) => String(it?.kind ?? '') !== 'agent-reply')
|
|
1482
|
+
draft = renderFeedbackText(makeFeedback({ sessionId: '', items: draftItems }), { locale })
|
|
1476
1483
|
} catch { draft = '' }
|
|
1477
1484
|
return json({ ok: true, schema: 1, count: items.length, items, draft })
|
|
1478
1485
|
} catch (error) {
|
package/host/tools.js
CHANGED
|
@@ -16,10 +16,13 @@
|
|
|
16
16
|
* · 同名 tool 在同一层重复注册会抛错 —— 未捕获会让整个插件不激活,
|
|
17
17
|
* 所以注册必须包 try/catch(deep-view 源码注释里踩过这个坑)
|
|
18
18
|
*
|
|
19
|
-
*
|
|
19
|
+
* 红线:gallery_find / gallery_context / gallery_regions 三个**只读**,不改资产、不替用户发送。
|
|
20
|
+
* 第四个工具 gallery_reply(2026-11-19)是唯一的写入口:只往反馈篮写一条「Agent 批示」,
|
|
21
|
+
* 仍然不碰资产、不 ack、不替用户发送任何东西 —— 人确认闸门不变。
|
|
20
22
|
*/
|
|
21
23
|
import path from 'node:path'
|
|
22
24
|
import { statSync } from 'node:fs'
|
|
25
|
+
import { isInside } from './fsutil.js'
|
|
23
26
|
import { scanGallery } from './scan.js'
|
|
24
27
|
import { applyAssetFilter, sortByRelevance } from './http.js'
|
|
25
28
|
import { resolveOptions } from './settings.js'
|
|
@@ -33,12 +36,13 @@ import { buildLinkedMaskIndex } from './frames.js'
|
|
|
33
36
|
// 区域感知(2026-11-16):把「人在这张图上框了哪儿」直接告诉模型。
|
|
34
37
|
// 起因是实测:用户框选后说「把框里的字母改掉」,模型拿不到框的位置,
|
|
35
38
|
// 只能翻 frames.json / 临时目录满地找,光找就花了 97 秒。
|
|
36
|
-
import { readFeedback } from './feedback.js'
|
|
39
|
+
import { readFeedback, setFeedback } from './feedback.js'
|
|
37
40
|
import { annotationsFor, latestAnnotationAt, materializeRegions, materializeMaskRegion } from './regions.js'
|
|
38
41
|
|
|
39
42
|
const TOOL_NAME = 'gallery_find'
|
|
40
43
|
const CONTEXT_TOOL_NAME = 'gallery_context'
|
|
41
44
|
const REGIONS_TOOL_NAME = 'gallery_regions'
|
|
45
|
+
const REPLY_TOOL_NAME = 'gallery_reply'
|
|
42
46
|
const MAX_LIMIT = 100
|
|
43
47
|
const DEFAULT_LIMIT = 20
|
|
44
48
|
// 第二档:gallery_context 一次列多少张「最近看过的」。
|
|
@@ -784,6 +788,125 @@ export function buildRegionsToolDefinition(config) {
|
|
|
784
788
|
}
|
|
785
789
|
}
|
|
786
790
|
|
|
791
|
+
/**
|
|
792
|
+
* renderReply:把写入确认渲染成给模型的一段话。
|
|
793
|
+
* 与另外三个工具一样是纯渲染,不触发任何副作用。
|
|
794
|
+
*/
|
|
795
|
+
function renderReply(args, value) {
|
|
796
|
+
if (value?.error) return [{ type: 'text', text: `批示写回反馈栏失败:${value.error}` }]
|
|
797
|
+
const name = String(value?.relPath ?? '').split('/').pop() ?? String(value?.relPath ?? '')
|
|
798
|
+
const lines = []
|
|
799
|
+
lines.push(`已把批示写回反馈栏,针对的资产:${name}`)
|
|
800
|
+
lines.push(`批示:${value?.text ?? ''}`)
|
|
801
|
+
lines.push('这条批示现在显示在用户的反馈栏里,资产台也会高亮这张新图。')
|
|
802
|
+
lines.push('用户点头核准前不要当作已完成;如用户驳回,会带着补充意见再次回来。')
|
|
803
|
+
if (value?.hint) lines.push(value.hint)
|
|
804
|
+
return [{ type: 'text', text: lines.join('\n') }]
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
/**
|
|
808
|
+
* gallery_reply(2026-11-19):Agent 执行完改图后,把「批示」写回反馈栏。
|
|
809
|
+
*
|
|
810
|
+
* 为什么需要:前三个工具全只读,Agent 干完活没有任何通道把结果告诉人 ——
|
|
811
|
+
* 人得自己去资产台找新图、重新框、重新说一遍。本工具让 Agent 显式报一句批示,
|
|
812
|
+
* 结构化地落进反馈篮(kind:'agent-reply'),人点头核准才闭环。
|
|
813
|
+
*
|
|
814
|
+
* 红线:
|
|
815
|
+
* · 只往 feedback.json 写一条待处理批示,绝不 ack(不替人清)、绝不 cancel、绝不发送
|
|
816
|
+
* · 写之前校验 relPath 非空 + 落在产出根内 + 文件真实存在 —— 防止批示挂到错图
|
|
817
|
+
* · 同一路径再次写会覆盖旧批示(沿用 setFeedback 语义):一件事只留一条当前批示
|
|
818
|
+
*/
|
|
819
|
+
export function buildReplyToolDefinition(config) {
|
|
820
|
+
return {
|
|
821
|
+
name: REPLY_TOOL_NAME,
|
|
822
|
+
description: 'Agent 执行完图片修改后,用本工具把「做了什么、请验收」的批示写回用户的反馈栏。'
|
|
823
|
+
+ '凡是改完图需要用户看结果、点头确认时使用;写完后用户反馈栏会出现这条批示、资产台会高亮这张新图。'
|
|
824
|
+
+ 'relPath 必须填写这次实际产出(改好)的那张图的相对路径 —— 只写真实存在的资产,'
|
|
825
|
+
+ '写错路径会报错。本工具只写一条待用户核准的批示,不会替用户确认、清空或发送任何东西。',
|
|
826
|
+
parameters: {
|
|
827
|
+
type: 'object',
|
|
828
|
+
properties: {
|
|
829
|
+
relPath: {
|
|
830
|
+
type: 'string',
|
|
831
|
+
description: '这次改好、需要用户验收的新图相对路径(相对某个产出根,用 / 分隔)',
|
|
832
|
+
},
|
|
833
|
+
text: {
|
|
834
|
+
type: 'string',
|
|
835
|
+
description: '批示正文:简述做了哪些改动、哪些按「锁死」保持原样,请用户验收',
|
|
836
|
+
},
|
|
837
|
+
replyOf: {
|
|
838
|
+
type: 'string',
|
|
839
|
+
description: '可选:这条批示回应的是用户哪条原意见的相对路径,便于用户对照',
|
|
840
|
+
},
|
|
841
|
+
},
|
|
842
|
+
required: ['relPath', 'text'],
|
|
843
|
+
},
|
|
844
|
+
output: {
|
|
845
|
+
schema: {
|
|
846
|
+
type: 'object',
|
|
847
|
+
properties: {
|
|
848
|
+
ok: { type: 'boolean' },
|
|
849
|
+
relPath: { type: 'string' },
|
|
850
|
+
text: { type: 'string' },
|
|
851
|
+
hint: { type: 'string' },
|
|
852
|
+
error: { type: 'string' },
|
|
853
|
+
},
|
|
854
|
+
required: ['ok', 'relPath', 'text'],
|
|
855
|
+
},
|
|
856
|
+
render: renderReply,
|
|
857
|
+
},
|
|
858
|
+
async execute(args) {
|
|
859
|
+
const relPath = String(args?.relPath ?? '').replace(/\\/g, '/').trim()
|
|
860
|
+
const text = String(args?.text ?? '').trim().slice(0, 2000)
|
|
861
|
+
if (relPath === '') {
|
|
862
|
+
return { ok: false, relPath: '', text: '', error: '缺少 relPath(要验收的新图路径)' }
|
|
863
|
+
}
|
|
864
|
+
if (text === '') {
|
|
865
|
+
return { ok: false, relPath, text: '', error: '批示正文 text 不能为空' }
|
|
866
|
+
}
|
|
867
|
+
try {
|
|
868
|
+
const opts = resolveOptions(config)
|
|
869
|
+
const roots = Array.isArray(opts.roots) ? opts.roots : []
|
|
870
|
+
// 校验 relPath:必须落在某个产出根内且文件真实存在,防止批示挂到错图/恶意路径
|
|
871
|
+
let absPath = ''
|
|
872
|
+
let verified = false
|
|
873
|
+
for (const root of roots) {
|
|
874
|
+
const base = path.resolve(String(root ?? ''))
|
|
875
|
+
if (base === '') continue
|
|
876
|
+
const candidate = path.resolve(base, relPath)
|
|
877
|
+
if (!isInside(base, candidate)) continue
|
|
878
|
+
try {
|
|
879
|
+
if (statSync(candidate).isFile()) { absPath = candidate; verified = true; break }
|
|
880
|
+
} catch { /* 这个文件不在本根下,试下一个 */ }
|
|
881
|
+
}
|
|
882
|
+
if (!verified) {
|
|
883
|
+
return {
|
|
884
|
+
ok: false, relPath, text,
|
|
885
|
+
error: `找不到这张资产或路径越界:${relPath}(请确认是这次实际产出的图)`,
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
const replyOf = String(args?.replyOf ?? '').replace(/\\/g, '/').trim()
|
|
889
|
+
const item = {
|
|
890
|
+
kind: 'agent-reply',
|
|
891
|
+
action: 'review-reply',
|
|
892
|
+
text,
|
|
893
|
+
reason: text,
|
|
894
|
+
status: 'pending',
|
|
895
|
+
markedAt: Date.now(),
|
|
896
|
+
}
|
|
897
|
+
if (replyOf !== '') item.replyOf = replyOf
|
|
898
|
+
await setFeedback(opts.settingsFile, relPath, item)
|
|
899
|
+
return {
|
|
900
|
+
ok: true, relPath, text,
|
|
901
|
+
hint: `已写到反馈栏,指向 ${absPath}`,
|
|
902
|
+
}
|
|
903
|
+
} catch (error) {
|
|
904
|
+
return { ok: false, relPath, text, error: String(error?.message ?? error) }
|
|
905
|
+
}
|
|
906
|
+
},
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
|
|
787
910
|
/**
|
|
788
911
|
* 在插件 apply() 里调用。
|
|
789
912
|
* 返回 disposer;任何失败都吞掉并记日志 —— 绝不能因为 tool 注册失败
|
|
@@ -794,6 +917,7 @@ export function registerTools(ctx, config) {
|
|
|
794
917
|
buildToolDefinition(config),
|
|
795
918
|
buildContextToolDefinition(config),
|
|
796
919
|
buildRegionsToolDefinition(config),
|
|
920
|
+
buildReplyToolDefinition(config),
|
|
797
921
|
]
|
|
798
922
|
if (!ctx?.tools || typeof ctx.tools.register !== 'function') {
|
|
799
923
|
ctx?.logger?.warn?.('dsh-gallery: ctx.tools 不可用,Agent 工具未注册')
|
|
@@ -813,4 +937,5 @@ export function registerTools(ctx, config) {
|
|
|
813
937
|
return () => { for (const d of disposers) { try { d() } catch { /* 忽略 */ } } }
|
|
814
938
|
}
|
|
815
939
|
|
|
816
|
-
export { TOOL_NAME, CONTEXT_TOOL_NAME, REGIONS_TOOL_NAME,
|
|
940
|
+
export { TOOL_NAME, CONTEXT_TOOL_NAME, REGIONS_TOOL_NAME, REPLY_TOOL_NAME,
|
|
941
|
+
rootOf, toRow, renderRows, renderContext, renderRegions, renderReply }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-gallery",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "产出台:图片 / 文件 / 音视频实时可见、当场校验;原生产出标签(素材 / 过程稿 / 定稿 / 未归类)可手动改且持久生效,改标签动作与图上圈选批注攒进反馈篮,由人审核合并后发送,全程零自动发送;视频「截取当前帧」自动存入当前对话资产;图上左键拖矩形、左键逐点圈不规则区域直接进反馈篮、右键逐点闭合成实心多边形导出 ComfyUI 直接可用的 RGBA 遮罩(选区内 alpha=0、RGB 保留原图),另出红 / 绿 / 蓝纯色半透明填充预览供目视核对;同一张图可连框多处,每处各带说明一并交给助手;内置三个只读工具——按关键词或对话标题查资产、读到「你此刻正在看哪张」与最近看过的十几张、给出你框选区域的整图像素矩形与外扩裁剪图并可直接取用你已画好的遮罩;图片查看器带像素级放大镜裁剪(绿框八向手柄、裁剪尺寸、光标处坐标与色值);分类显隐按图片 / 文件 / 音视频各记各的,支持多个扫描目录;把图拖进对话框会自动带上文件名与绝对路径(含对应主遮罩名),助手不必扫目录找图;图片查看器带前后对比——两张图叠在同一处用滑块左右拖动、放大后仍像素级对齐、也能切平铺并排看,批量选两张即可进对比,候选按遮罩关系/同尺寸智能推荐配对。Output gallery for DeepSeek Harness: live image/file/audio/video preview, persistent manual asset labels, region annotations and label changes queued in a human-approved feedback basket, one-click video frame capture filed into the current session, rectangle / multi-point polygon / irregular region selections, ComfyUI-ready RGBA mask export (alpha=0 inside the selection, original RGB kept) plus a colored translucent fill preview, three read-only agent tools (keyword or conversation search, what you are viewing right now, and pixel rects plus expanded crops of your selections with direct reuse of a mask you already painted), pixel-level magnifier crop in the viewer, multi-root scanning, and drag-to-chat that carries the file name and absolute path so agents need no directory scan; before/after comparison in the viewer — two images stacked with a draggable slider that stays pixel-aligned when zoomed, or side-by-side tiles, batch-select two or pick from smart-ranked candidates by mask relation and matching size.",
|
|
6
6
|
"repository": {
|