@xrn1997/dsh-session-delete 0.6.1 → 0.8.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.
Files changed (69) hide show
  1. package/README.md +18 -10
  2. package/THIRD_PARTY_NOTICES.md +179 -0
  3. package/cordis.patch.yml +1 -1
  4. package/docs/screenshots/screenshot-01.png +0 -0
  5. package/docs/screenshots/screenshot-02.png +0 -0
  6. package/docs/screenshots/screenshot-03.png +0 -0
  7. package/icon.svg +24 -18
  8. package/lib/client.js +3117 -1324
  9. package/lib/index.js +593 -254
  10. package/lib/types/api/attachment.d.ts +2 -2
  11. package/lib/types/api/connection-route.d.ts +1 -1
  12. package/lib/types/api/dispatch.d.ts +1 -1
  13. package/lib/types/api/route-table.d.ts +14 -9
  14. package/lib/types/client/batch-bar.d.ts +2 -4
  15. package/lib/types/client/batch-confirm.d.ts +6 -7
  16. package/lib/types/client/busy-gate.d.ts +12 -5
  17. package/lib/types/client/config-settings.d.ts +13 -0
  18. package/lib/types/client/confirm-dialog.d.ts +23 -0
  19. package/lib/types/client/context-menu-actions.d.ts +11 -5
  20. package/lib/types/client/context.d.ts +3 -0
  21. package/lib/types/client/copy.d.ts +46 -7
  22. package/lib/types/client/delete-confirm.d.ts +2 -2
  23. package/lib/types/client/delete-menu-item.d.ts +2 -2
  24. package/lib/types/client/detail-blocks.d.ts +25 -0
  25. package/lib/types/client/index.d.ts +3 -2
  26. package/lib/types/client/maintenance-settings.d.ts +6 -7
  27. package/lib/types/client/plugin.d.ts +6 -0
  28. package/lib/types/client/prompt-rail.d.ts +22 -0
  29. package/lib/types/client/remote.d.ts +64 -87
  30. package/lib/types/client/reset-client-state.d.ts +1 -0
  31. package/lib/types/client/session-live.d.ts +31 -0
  32. package/lib/types/client/settings-cards.d.ts +19 -0
  33. package/lib/types/client/settings-view.d.ts +9 -0
  34. package/lib/types/client/trash-detail.d.ts +14 -4
  35. package/lib/types/client/trash-snapshot.d.ts +51 -0
  36. package/lib/types/client/trash-view.d.ts +33 -6
  37. package/lib/types/client/ui/icons.d.ts +23 -7
  38. package/lib/types/client/ui/recipe.d.ts +2 -0
  39. package/lib/types/client/ui/styles.d.ts +2 -0
  40. package/lib/types/client/undo-notices.d.ts +4 -4
  41. package/lib/types/client/undo-toast.d.ts +1 -2
  42. package/lib/types/client/use-detail-pager.d.ts +37 -0
  43. package/lib/types/client/use-maintenance-section.d.ts +29 -18
  44. package/lib/types/client/use-maintenance.d.ts +14 -5
  45. package/lib/types/client/use-prefetch.d.ts +14 -0
  46. package/lib/types/client/use-prompt-rail.d.ts +60 -0
  47. package/lib/types/client/use-trash-detail-reader.d.ts +33 -0
  48. package/lib/types/client/use-trash-panel-controller.d.ts +6 -4
  49. package/lib/types/client/use-trash-query.d.ts +14 -7
  50. package/lib/types/client/write-seats.d.ts +17 -17
  51. package/lib/types/client/write-settlement.d.ts +3 -3
  52. package/lib/types/client/write.d.ts +9 -7
  53. package/lib/types/config.d.ts +10 -11
  54. package/lib/types/deps.d.ts +11 -3
  55. package/lib/types/index.d.ts +3 -1
  56. package/lib/types/log/session-log.d.ts +2 -0
  57. package/lib/types/ports/agent-handles.d.ts +10 -2
  58. package/lib/types/ports/fs-port.d.ts +23 -2
  59. package/lib/types/ports/host-port.d.ts +18 -10
  60. package/lib/types/shared/project-key.d.ts +28 -0
  61. package/lib/types/shared/wire.d.ts +92 -24
  62. package/lib/types/trash/attachments.d.ts +3 -3
  63. package/lib/types/trash/detail.d.ts +4 -2
  64. package/lib/types/trash/display-name.d.ts +16 -0
  65. package/lib/types/trash/entry.d.ts +4 -2
  66. package/lib/types/verbs/config.d.ts +25 -0
  67. package/locale/en.json +1 -1
  68. package/locale/zh.json +6 -6
  69. package/package.json +20 -14
@@ -1,3 +1,4 @@
1
+ import { escapeProjectKey } from '../shared/project-key.js';
1
2
  /** 摘内存的三种落地(见 {@link HostPort.evictLive}):`not-live` / `evicted` 都意味着**宿主列表已经不含它**;
2
3
  * `unknown` 意味着读不到或摘不掉,**不能**据此通告客户端(发了就是假话,重连后那一行会自己长回来)。 */
3
4
  export type EvictionOutcome = 'evicted' | 'not-live' | 'unknown';
@@ -12,8 +13,11 @@ export interface HostIdentityPort {
12
13
  * header 走公开 live/持久化读面;与 `workspaceOf` 同一口径:**未命中是正常的 no-op,不是故障**
13
14
  * (存储真故障照抛)。 */
14
15
  projectDirOf(sessionId: string): Promise<string | undefined>;
15
- /** 删除时**尽力**取的会话标题;取不到返回空串,绝不因此让删除失败。
16
- * 标题只存在于宿主自己的账本/缓存里(`FsPort` 不直读文件)⇒ 取数面归宿主端口,接官方投影缓存 API;
16
+ /** 删除时**尽力**取的会话显示名,**与宿主工作中同名**:子会话(`subagent` 投影有 label)取 label
17
+ * (委派 `subagent` 时的 `description`),其余取 `title` 投影;取不到返回空串,绝不因此让删除失败。
18
+ * 为什么子会话不按 `title` 投影起名:那是主会话那套起名法(LLM 标题 / 首句提示词截断兜底),
19
+ * 同批子会话会撞成同名分不清(ADR-0058)。
20
+ * 名字只存在于宿主自己的账本/缓存里(`FsPort` 不直读文件)⇒ 取数面归宿主端口,接官方投影缓存 API;
17
21
  * header 与 `projectDirOf` 走同一个公开读面。 */
18
22
  titleOf(sessionId: string): Promise<string>;
19
23
  isLive(sessionId: string): Promise<boolean>;
@@ -89,15 +93,19 @@ export interface SubagentMember {
89
93
  readonly sessionId: string;
90
94
  readonly projectDir: string;
91
95
  }
92
- /** 无 cwd 的会话落在 `_no-cwd/`;`projectDirOf` 与回收站对账共用这个字面量。
93
- * 出处:asar `dsh-session-persistence-jsonl/lib/index.js` 的 `projectDir`(`if (cwd === void 0) return join(root, "_no-cwd");`)。 */
94
- export declare const NO_CWD_PROJECT_DIR = "_no-cwd";
95
- /** 宿主 `projectKey(cwd)` 的逐字镜像:跨插件不能 import,宿主也没把它暴露成服务。
96
- * 出处:asar `dsh-session-persistence-jsonl/lib/index.js` 的 `projectKey`;调用链
97
- * `locate` → `logPath` → `projectDir` → `projectKey`。本机实测 `D:/develop/GitHub/dsh-session-delete`
98
- * → `--D-develop-GitHub-dsh-session-delete--`。`projectDirOf` 与回收站对账重建共用这一份;
96
+ /** 宿主 `projectKey(cwd)` 的逐字镜像:编码与解码配对住在 `src/shared/project-key.ts`
97
+ * (字母表只有一份;解码给浏览器半渲染回收站组头)。`projectDirOf` 与回收站对账重建共用这一份;
99
98
  * 宿主换代先复核算法。 */
100
- export declare function projectKey(cwd: string): string;
99
+ export declare const projectKey: typeof escapeProjectKey;
100
+ /**
101
+ * cwd(可缺席)→ 会话落盘的项目目录名:**只有缺席**(`undefined`)落 `_no-cwd`;
102
+ * 空串照常编码——`''` 不是"没有这一格",它是读到了一个空路径。宿主的 `projectDir`
103
+ * (`cwd === void 0` 才走 `_no-cwd`)就是这一支。
104
+ *
105
+ * 删除计划、会话列表投影与对账重建**共用这一处**:三处各自写一遍三元式,`''` 迟早有一处
106
+ * 落成 `_no-cwd`,同一条会话在删除、恢复与孤儿扫描里就会指向两个目录。
107
+ */
108
+ export declare function projectDirOfCwd(cwd: string | undefined): string;
101
109
  /** 这次失败是不是"账本里没那个工作区"(而不是另有故障)。恢复侧靠它把两种失败分开:
102
110
  * 前者按「未分组」收,后者照旧回滚报 `io`——不给真故障静默改归属的机会。 */
103
111
  export declare function isWorkspaceMissingError(error: unknown): boolean;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * 宿主 `projectKey(cwd)` 的**编码与解码一对**:字母表、转义与包裹规则只住这一份。
3
+ *
4
+ * - 编码是宿主实现的逐字镜像(跨插件不能 import,宿主也没把它暴露成服务)。出处:asar
5
+ * `dsh-session-persistence-jsonl/lib/index.js` 的 `projectKey`;调用链
6
+ * `locate` → `logPath` → `projectDir` → `projectKey`。本机实测
7
+ * `D:/develop/GitHub/dsh-session-delete` → `--D-develop-GitHub-dsh-session-delete--`。
8
+ * 宿主换代先复核算法。
9
+ * 唯一有意偏离:宿主对空串直接抛(`cannot encode an empty project path`),这里把它编成
10
+ * `--root--`——宿主写日志时不会产生空 cwd,读面碰到的是手工改过的 header;这里只做兜底,
11
+ * 不让一条坏 header 把整次对账/列表读挂掉。
12
+ * - 解码给浏览器半渲染回收站组头用;配对关系由 `tests/assembly.test.ts` 的往返用例钉住。
13
+ * - **空串照常编码**(得到 `--root--`):`''` 不是"没有这格",它是读到了一个空路径。只有
14
+ * **缺席** cwd 才落 `NO_CWD_PROJECT_DIR`,那一条判据住 `src/ports/host-port.ts` 的 `projectDirOfCwd`
15
+ * (删除计划、列表投影与对账重建共用同一处)。宿主的 `projectDir` 在 cwd 缺席时用同名目录,
16
+ * 浏览器半渲染组头时也要认它——所以字面量住这里,两半共用。宿主换代先复核算法。
17
+ *
18
+ * **只还原可还原的那部分**:不在 `[A-Za-z0-9._-]` 里、又不是 `~` 的字符编成 `~` + 4 位大写十六进制
19
+ * 码元,字面 `~` 自己编成 `~007E` ⇒ `~XXXX` 不含歧义。而**分隔符(`/` `\` `:`)被折成一个 `-`,
20
+ * 那一段是有损的**,解码还原不回来——调用方按"尽力显示"用它,别拿它反推真实路径。
21
+ */
22
+ /** 无 cwd 的会话落在 `_no-cwd/`(宿主 `projectDir` 原文:`if (cwd === void 0) return join(root, "_no-cwd");`)。
23
+ * Node 半用它合成目录名,浏览器半用它把组头念成「未记录项目」——同一事实只有这一份。 */
24
+ export declare const NO_CWD_PROJECT_DIR = "_no-cwd";
25
+ /** cwd → 项目目录名(宿主 `projectKey` 的逐字镜像)。 */
26
+ export declare function escapeProjectKey(cwd: string): string;
27
+ /** 项目目录名 → 可读文本(只还原 `~XXXX`,分隔符折叠的那一段不还原)。 */
28
+ export declare function unescapeProjectKey(encoded: string): string;
@@ -1,12 +1,12 @@
1
1
  /**
2
- * 跨半 wire 契约:前缀、九个端点、请求/响应形状与失败码。
2
+ * 跨半 wire 契约:前缀、十个端点、请求/响应形状与失败码。
3
3
  * Node 半(src/api/dispatch.ts)与浏览器半(src/client/remote.ts)共用这一份,不各写字面量。
4
4
  *
5
5
  * 构建约束:本文件零运行时依赖、无 import;浏览器半把整个文件 inline 进 bundle。
6
6
  * 信封 {ok:true,value} / {ok:false,error:{code,message,details?}} 也是两半的共同契约。
7
7
  */
8
8
  /**
9
- * 插件专属前缀(九段相对它命名)。
9
+ * 插件专属前缀(十段相对它命名)。
10
10
  *
11
11
  * 为什么必须带插件名:宿主 `connection.fetch.register` 对**重复的精确路径**直接抛错
12
12
  * (`connection: exact Fetch route "…" is already registered`),撞了就是整棵插件树 boot 失败——
@@ -14,14 +14,19 @@
14
14
  */
15
15
  export declare const SESSION_DELETE_API_PREFIX = "/dsh-session-delete-api";
16
16
  /**
17
- * 唯一的取数基础路径:宿主 `/api` + 插件前缀。九段 exact Fetch 路由、客户端探测与附件 URL
17
+ * 唯一的取数基础路径:宿主 `/api` + 插件前缀。十段 exact Fetch 路由、客户端探测与附件 URL
18
18
  * 都从它起;`SESSION_DELETE_API_PREFIX` 只作为段名的相对前缀与错误原文。
19
19
  */
20
20
  export declare const OFFICIAL_SESSION_DELETE_API_PREFIX = "/api/dsh-session-delete-api";
21
- /** 九个段名(相对前缀)。**每项 `{ path, method }` 两键**:某段用什么方法也是线上形状的一部分
22
- * (ADR-0003),家就在这一张表——路由记录(`src/api/route-table.ts`)逐行投影(`ROUTES.x.method`),
23
- * 浏览器半的 GET 段同样投影、写段把 `ROUTES.x.method` 交给 `src/client/remote.ts` 的 `post()`,
24
- * 两半都不逐段手写一份。
21
+ /** 请求体的线上形状。`none` = 没有字段(GET,或只带空对象的 POST);`query` = GET 查询串(二进制段);
22
+ * 其余是 JSON 体的字段组。**读这一格的是 Node 半**:`src/api/route-table.ts` 的 `bodyOf` 据此决定
23
+ * 分发器要不要预读 JSON。浏览器半的入参形状由 `src/client/remote.ts` 的 interface 签名决定,只投影
24
+ * 这一格的**配对事实**(有 JSON 字段的段必然是 POST),配对由 `tests/wire-shape.test.ts` 钉住。 */
25
+ export type RouteBody = 'none' | 'query' | 'config' | 'entry' | 'apply';
26
+ /** 十段段名(相对前缀)。**每项 `{ path, method, body }` 三键**:某段用什么方法、带什么请求体也是线上
27
+ * 形状的一部分(ADR-0003),家就在这一张表——路由记录(`src/api/route-table.ts`)逐行投影
28
+ * (`ROUTES.x.method` / `bodyOf(ROUTES.x)`),浏览器半的取数通道(`src/client/remote.ts`)从同一格
29
+ * 投影路径与方法,两半都不逐段手写一份字面量。
25
30
  * 写动作统一走一段 `/apply`:一次 HTTP 带一组 id、逐条回结果;
26
31
  * 单条就是长度为 1 的批量,仓里不留第二条执行路径。
27
32
  * - `list`:对账并读清单(`session-trash/` 里的目录是准)。
@@ -31,58 +36,100 @@ export declare const OFFICIAL_SESSION_DELETE_API_PREFIX = "/api/dsh-session-dele
31
36
  * - `empty`:清空回收站(聚合回执,不按条回)。
32
37
  * - `orphans`:无主子会话的扫描报告(纯读)。清理是 `/apply` 的第五个动作,
33
38
  * 这一段只负责"有多少、在哪、多大"。
34
- * - `attachment`:附件原始字节(全仓唯一的二进制响应段;失败仍回 JSON 信封)。
39
+ * - `attachment`:附件原始字节(全仓唯一的二进制响应段;按查询串寻址,失败仍回 JSON 信封)。
35
40
  * - `attachmentOrphans`:无引用图片对象的扫描报告(纯读;数量/字节 + 供预览的对象清单)。
36
- * - `attachmentClean`:清掉报告那一刻无引用的图片对象(聚合回执 `AttachmentCleanupWire`)。 */
41
+ * - `attachmentClean`:清掉报告那一刻无引用的图片对象(聚合回执 `AttachmentCleanupWire`)。
42
+ * - `config`:三只可调项的读/写共用一段——空体读当前值,带字段写回 profile 的 patch 层。 */
37
43
  export declare const ROUTES: {
38
44
  readonly list: {
39
45
  readonly path: "/list";
40
46
  readonly method: "GET";
47
+ readonly body: "none";
41
48
  };
42
49
  /** 通道的"在不在"专用:没有入参、没有副作用、没有磁盘读。 */
43
50
  readonly ping: {
44
51
  readonly path: "/ping";
45
52
  readonly method: "GET";
53
+ readonly body: "none";
54
+ };
55
+ /** 可调项:空体读(与 `/detail` 同法,用 POST 表达一个读);带字段写,写必须进到达序链。 */
56
+ readonly config: {
57
+ readonly path: "/config";
58
+ readonly method: "POST";
59
+ readonly body: "config";
46
60
  };
47
61
  /** 单条详情(读回收站目录里那条会话自己的日志)。 */
48
62
  readonly detail: {
49
63
  readonly path: "/detail";
50
64
  readonly method: "POST";
65
+ readonly body: "entry";
51
66
  };
52
67
  /** 一组 id 上的同一个动作;删除确认框那句「含 N 个子会话」也走这里(`action: 'count'`,纯读语义)。 */
53
68
  readonly apply: {
54
69
  readonly path: "/apply";
55
70
  readonly method: "POST";
71
+ readonly body: "apply";
56
72
  };
57
73
  /** 清空回收站。 */
58
74
  readonly empty: {
59
75
  readonly path: "/empty";
60
76
  readonly method: "POST";
77
+ readonly body: "none";
61
78
  };
62
79
  /** 纯读:扫描回收站之外的无主子会话(父已不在语料/清册)。 */
63
80
  readonly orphans: {
64
81
  readonly path: "/orphans";
65
82
  readonly method: "GET";
83
+ readonly body: "none";
66
84
  };
67
- /** 附件字节(图片/普通文件):全仓唯一的二进制响应段,读的是宿主附件库。 */
85
+ /** 附件字节(图片/普通文件):全仓唯一的二进制响应段,按查询串寻址。 */
68
86
  readonly attachment: {
69
87
  readonly path: "/attachment";
70
88
  readonly method: "GET";
89
+ readonly body: "query";
71
90
  };
72
91
  /** 纯读:扫全部引用源与附件库 `objects`,报无引用图片的数量、字节与预览清单。 */
73
92
  readonly attachmentOrphans: {
74
93
  readonly path: "/attachment-orphans";
75
94
  readonly method: "GET";
95
+ readonly body: "none";
76
96
  };
77
97
  /** 聚合清理:只删 `objects` 下无引用的图片,回 `AttachmentCleanupWire`。 */
78
98
  readonly attachmentClean: {
79
99
  readonly path: "/attachment-clean";
80
100
  readonly method: "POST";
101
+ readonly body: "none";
81
102
  };
82
103
  };
83
104
  /** 段名 → 那一段的路径。从结构化段名表派生:加一段只在上面加一项,`Record<RouteName, …>` 类型闸
84
105
  * (`src/api/route-table.ts`)与运行期键集比对(`tests/route-table.test.ts`)都跟着这一格走。 */
85
106
  export type RouteName = (typeof ROUTES)[keyof typeof ROUTES]['path'];
107
+ /** 三只可调项的线上形状。Node 半的 `SessionDeleteConfig`(`src/config.ts`)是它的别名:
108
+ * 这一格固定线上字段名与接受范围({@link CONFIG_LIMITS}),默认值与归一在 `src/config.ts`。 */
109
+ export interface SessionDeleteConfigWire {
110
+ /** 设置页「孤儿附件」预览清单最多列多少条(数量与字节仍按全量报告)。 */
111
+ orphanPreviewLimit: number;
112
+ /** `GET /attachment` 单次响应字节上限(服务路径与直接 fs fallback 共用)。 */
113
+ maxAttachmentBytes: number;
114
+ /** 附件引用扫描里单个 JSON 引用源的字节上限;超过就按「读不出」fail closed。 */
115
+ maxJsonRefBytes: number;
116
+ }
117
+ /** 三只可调项的接受范围(闭区间整数)。Node 半的归一与浏览器半的表单共用这一格:
118
+ * 两处各写一份范围就会「表单说能存、宿主激活时说越界」。 */
119
+ export declare const CONFIG_LIMITS: {
120
+ readonly orphanPreviewLimit: {
121
+ readonly min: 1;
122
+ readonly max: 10000;
123
+ };
124
+ readonly maxAttachmentBytes: {
125
+ readonly min: 1;
126
+ readonly max: number;
127
+ };
128
+ readonly maxJsonRefBytes: {
129
+ readonly min: 1;
130
+ readonly max: number;
131
+ };
132
+ };
86
133
  /** `/apply` 的五个动作。id 的含义随动作走:`delete`/`count`/`orphan-clean` 是**宿主会话 id**
87
134
  * (前两个还没进回收站,第三个压根没有回收站行),`restore`/`purge` 是**回收站条目 id**。
88
135
  * 两域都是 string(线上形状);这里不引入品牌类型——错域不靠类型拦,交给各动词在运行期按自己的
@@ -127,6 +174,13 @@ export interface TrashEntryWire {
127
174
  title: string;
128
175
  sizeBytes: number;
129
176
  parentEntryId?: string;
177
+ /** **子会话的显示名**(委派 `subagent` 时的 `description`,与宿主工作中同名;ADR-0058)。
178
+ * 只在详情 `subagents` 行过线:它是**日志里读出来的事实**——通常是父日志 `subagent/catalog`
179
+ * 的 label;没有 catalog 登记、清册标题又和父/兄弟撞名的 fork 孩子,是它自己日志的当前标题
180
+ * (fork 没有 descriptor)。清册里没有这格——`/list` 的 `toWire` 不发它(缺席 = 没读到名字,
181
+ * 界面回落 `title`)。与 `logTitle` 同一类兜底:清册标题是删除那一刻的快照,label 补的是
182
+ * 快照起错名的存量条目。 */
183
+ label?: string;
130
184
  }
131
185
  /**
132
186
  * `GET /list` 真正发出去的那一行:清册那一行 + 六个**现算现给**的只读数(ADR-0003)。
@@ -208,6 +262,17 @@ export interface TrashDetailToolBlockWire {
208
262
  attachments: TrashDetailAttachmentWire[];
209
263
  }
210
264
  export type TrashDetailBlockWire = TrashDetailTextBlockWire | TrashDetailInjectionBlockWire | TrashDetailToolBlockWire;
265
+ /** 详情右缘「提问轨」的一行:**整条会话**里的一句用户提问,与当前分页窗口无关。
266
+ *
267
+ * `id` 就是那块在整条日志里的序号(与 `blocks[].id` 同一套),所以「跳到这句」在已加载窗口里
268
+ * 按它直接找;没加载就照 `olderCursor` 一页页往回补到它进窗(`src/client/use-prompt-rail.ts`
269
+ * 的跳转循环),不另发一次定向读。`preview` 有界(空白折叠、超长带省略号):它是导航用的标签,
270
+ * 不是正文的第二份抄本。 */
271
+ export interface TrashDetailPromptWire {
272
+ id: string;
273
+ at: number;
274
+ preview: string;
275
+ }
211
276
  /** 回收站单条详情的线上形状(`POST /detail`)。
212
277
  *
213
278
  * 正文按块分页:`blocks` 是当前这一页(从新往旧取),`olderCursor` 指向更早一页的边界;
@@ -220,6 +285,12 @@ export interface TrashDetailWire {
220
285
  lastActivity: number;
221
286
  /** 日志内 `session/title` 那条记录;清册标题为空串时客户端拿它兜底。 */
222
287
  logTitle: string;
288
+ /** **这条会话自己的显示名**(与宿主工作中同名)。只在详情读时从被读的这条日志折出:
289
+ * 子会话取 `subagent/descriptor` 的 `label`(值来自委派 `description`);fork 子会话没有 descriptor,header 有
290
+ * `parentSession` 时取它自己日志的当前 `session/title`。它补的是没有父详情可兜的独立子会话
291
+ * ——那种条目的清册 `title` 是主会话那套起名法,`logTitle` 单看也是错的。
292
+ * 缺席 = 主会话、或没有 descriptor 也没有 `parentSession` 的会话,界面回落清册标题。 */
293
+ label?: string;
223
294
  models: string[];
224
295
  turnCount: number;
225
296
  userMessageCount: number;
@@ -231,6 +302,9 @@ export interface TrashDetailWire {
231
302
  blocks: TrashDetailBlockWire[];
232
303
  /** 更早一页的块序号;`null` = 已经到顶。把它原样回传给 `POST /detail` 的 `before`。 */
233
304
  olderCursor: number | null;
305
+ /** 整条会话的提问索引,按日志顺序;**只在首次读(不带 `before`)时出线**——它不随分页变化,
306
+ * 跟着详情账本走,后续翻页不重复搬。没有用户提问时是空数组(缺席 = 这一读没带,不是"没有")。 */
307
+ prompts?: TrashDetailPromptWire[];
234
308
  /** 跟着这条父条目一起进回收站、并**折进这一行**的孩子(清册里 `parentEntryId` 指向它,
235
309
  * 且组语义接得住——折的判据复用 `src/trash/groups.ts` 的 `visibleGroups`),按清册原序。
236
310
  * 确有孩子时出线;**缺席 = 没有孩子**,不是空数组。孩子的详情仍按 `entryId` 走同一个 `/detail`。
@@ -240,6 +314,9 @@ export interface TrashDetailWire {
240
314
  subagents?: TrashEntryWire[];
241
315
  /** 子会话总数;**只在 `subagents` 被条数闸截断时出线**(缺席 = 上面就是全部)。 */
242
316
  subagentsTotal?: number;
317
+ /** **全部**折进来的孩子的清册 `sizeBytes` 合计;有孩子时出线(即使未被条数闸截断)。
318
+ * 摘要条报「清册大小合计」用它——不要拿 `subagents` 已列行自己求和,那只是前 N 条。 */
319
+ subagentsSizeBytes?: number;
243
320
  }
244
321
  /** 一次永久删除顺带、或一次孤儿附件清理的附件读数。`skipped` 有值 = 这一轮**部分或整体没清**:
245
322
  * 有候选日志或剩余引用源读不出(原因上屏)。此时 `removed` 仍可能 > 0——损坏的只是某一组候选,
@@ -337,8 +414,11 @@ export type RemoteResult<T> = {
337
414
  * 位名与判法取自宿主网关客户端面的原文:
338
415
  * `if (typeof value === "object" && value !== null && value.isDSHRemoteError === true && typeof value.code === "string") return value`。
339
416
  *
340
- * 线上递过来的是**一段 JSON**(标记位不跟着过线)⇒ 落到哪一端,由那端的构造处就地补上标记:
341
- * 浏览器半是 `src/client/remote.ts` 的 `throwRemoteFailure`。
417
+ * 线上递过来的是**一段 JSON**(标记位不跟着过线)⇒ 标记位只由**宿主服务抛出的 `RemoteError`** 自带,
418
+ * 本仓生产侧不造它:Node 半的 `toRemoteFailure`(`src/remote/map-error.ts`)只**消费**它,产出的
419
+ * `RemoteFailure` 是普通过线对象;浏览器半的取数通道**不抛失败、也不补标记**——信封原样当数据交回
420
+ * (`RemoteOutcome`),通道自己造的诊断(打不通 / 非信封 / 401·403)是普通失败对象,不进这条判别;
421
+ * 测试假件同样只消费(`tests/client/support/fake-remote.ts` 的 `failureOf`)。
342
422
  */
343
423
  export declare function isDSHRemoteError(value: unknown): value is RemoteFailure;
344
424
  /**
@@ -373,15 +453,3 @@ export declare function verbCodeOf(error: unknown): VerbCode | undefined;
373
453
  export declare const TRASH_DIR_NAME = "session-trash";
374
454
  /** 页脚/文案里带尾斜杠的那一版(`splitOn` 按它切一刀再把目录名包成 code)。 */
375
455
  export declare const TRASH_DIR_LABEL = "session-trash/";
376
- /**
377
- * 宿主 `projectKey` 的 **`~XXXX` 转义还原**。
378
- *
379
- * 编码那一半在 Node 侧(`src/ports/host-port.ts` 的 `projectKey`,逐字镜像宿主实现);这里放与它配对的
380
- * 解码,客户端渲染回收站组头用它——**字母表只有这一份**,两边不会各自漂移(配对关系由
381
- * `tests/assembly.test.ts` 的往返用例钉住)。
382
- *
383
- * **只还原可还原的那部分**:不在 `[A-Za-z0-9._-]` 里、又不是 `~` 的字符编成 `~` + 4 位大写十六进制码元,
384
- * 字面 `~` 自己编成 `~007E` ⇒ `~XXXX` 不含歧义。而**分隔符(`/` `\` `:`)被折成一个 `-`,那一段是有损的**,
385
- * 这里还原不回来——调用方按"尽力显示"用它,别拿它反推真实路径。
386
- */
387
- export declare function unescapeProjectKey(encoded: string): string;
@@ -1,5 +1,5 @@
1
1
  import { isAbsentPath } from '../ports/fs-port.js';
2
- import type { FsPort } from '../ports/fs-port.js';
2
+ import type { FsReferenceScanPort, FsReferenceScanRemovalPort } from '../ports/fs-port.js';
3
3
  import type { SessionDeleteConfig } from '../config.js';
4
4
  import { type AttachmentCleanupWire } from '../shared/wire.js';
5
5
  export interface ImageRef {
@@ -32,12 +32,12 @@ export declare function attachmentPathOf(home: string, kind: 'image' | 'file', i
32
32
  /** 一条消息的 `content[]` 里的附件块;畸形 id / 非附件段一律跳过。 */
33
33
  export declare function attachmentsInContent(content: unknown): AttachmentRef[];
34
34
  export interface AttachmentReadDeps {
35
- fs: Pick<FsPort, 'exists' | 'listFiles' | 'listDirs' | 'readFile' | 'statFile' | 'realpath'>;
35
+ fs: FsReferenceScanPort;
36
36
  home: string;
37
37
  config: Pick<SessionDeleteConfig, 'maxJsonRefBytes'>;
38
38
  }
39
39
  export interface AttachmentRemovalDeps extends AttachmentReadDeps {
40
- fs: Pick<FsPort, 'exists' | 'listFiles' | 'listDirs' | 'readFile' | 'statFile' | 'realpath' | 'removeFile'>;
40
+ fs: FsReferenceScanRemovalPort;
41
41
  }
42
42
  /** 一个会话目录里的图片引用;`unreadable` 有值 = 这一组不可知(调用方按"跳过它"处理)。
43
43
  *
@@ -23,7 +23,7 @@
23
23
  * "少了几张图"与"这块被截断"不是同一件事,拿一个数兼报会让两个数都对不上。
24
24
  */
25
25
  import { type TrashEntry } from './entry.js';
26
- import type { FsPort } from '../ports/fs-port.js';
26
+ import type { FsDetailPort } from '../ports/fs-port.js';
27
27
  import type { TrashDetailWire } from '../shared/wire.js';
28
28
  /** 每块文字的上限(字符)。正文、工具参数、工具结果各自吃这一刀。 */
29
29
  export declare const PER_BLOCK_CHAR_CAP = 16000;
@@ -31,12 +31,14 @@ export declare const PER_BLOCK_CHAR_CAP = 16000;
31
31
  export declare const PAGE_BLOCK_LIMIT = 30;
32
32
  /** 一页正文的总字符上限(块按日志顺序累计;单块超闸时仍保留一块)。 */
33
33
  export declare const PAGE_CHAR_LIMIT = 500000;
34
+ /** 提问轨预览的字符上限:它是导航标签,不是正文的第二份抄本。 */
35
+ export declare const PROMPT_PREVIEW_LIMIT = 80;
34
36
  /** 子会话摘要最多列多少条;超出时只过线前 N 条,总数另走 `subagentsTotal`。 */
35
37
  export declare const SUBAGENT_SUMMARY_LIMIT = 200;
36
38
  export type TrashDetail = TrashDetailWire;
37
39
  export type DetailDeps = {
38
40
  /** 详情自己直接要的三件(判目录在不在、挑日志、读日志)。对账不在这条路上,所以不需要 `listDirs`。 */
39
- fs: Pick<FsPort, 'exists' | 'listFiles' | 'readFile'>;
41
+ fs: FsDetailPort;
40
42
  /** 路由交来的清册 **raw 行**:`/detail` 声明为 pure,读一次不能顺手对账——对账会写清册行,那是写动作,
41
43
  * 必须排在到达序链上。读面由路由记录选好(`read: 'raw'`),这里只消费行,不再自己挑 `list()` / `raw()`。
42
44
  * 代价是有意的:只有目录、清册还没这一行的手工搬入条目读不到(`/list` 对账后可见)。 */
@@ -0,0 +1,16 @@
1
+ /** `subagent/descriptor` 的 label;空/缺席 = 这条 descriptor 没有名字(one-shot 可以不给)。 */
2
+ export declare function descriptorLabelOf(data: Record<string, unknown>): string;
3
+ export interface LogDisplayName {
4
+ /** 最后一条 descriptor 的 label;空串 = 没有。 */
5
+ readonly label: string;
6
+ /** 最后一条 `session/title`;空串 = 没有。 */
7
+ readonly title: string;
8
+ }
9
+ /**
10
+ * 走一遍日志,折出**这条会话自己**的 descriptor label 与最后一条日志标题。
11
+ *
12
+ * 折叠语义与宿主 `subagent` 投影一致:每遇一条 descriptor 就覆盖(空 label 也覆盖),
13
+ * 所以 fork 种子里祖先的 descriptor 会被子会话自己的那条盖掉。日志标题取**最后一条**:
14
+ * 它是会话改名 / 兜底标题之后的当前值。
15
+ */
16
+ export declare function displayNameOfLog(raw: Buffer): LogDisplayName;
@@ -14,8 +14,10 @@ export interface TrashEntry {
14
14
  * 旧条目迁移用它区分“删除时被我们归档的”(false 且当前仍归档)与“用户删前自己归档的”(true)。 */
15
15
  wasArchived: boolean;
16
16
  deletedAt: number;
17
- /** 删除时**尽力**取的会话标题(来源:宿主 projection cache 服务;底层是
18
- * `storages/session_projcache/sessions/<会话id>.json` 里的 `title` 投影)。取不到存空串,绝不因此让删除失败。 */
17
+ /** 删除时**尽力**取的**显示名**(与工作中同名:子会话取 `subagent` 投影的 label,其余取 `title`
18
+ * 投影;判据住 `src/ports/host-port.ts` 的 `titleOf`,ADR-0058。底层是
19
+ * `storages/session_projcache/sessions/<会话id>.json` 里的投影行)。取不到存空串,绝不因此让删除失败。
20
+ * 存量条目的读时兜底(父日志 catalog / 子会话自己的日志)不回写这一格,见 `src/trash/detail.ts`。 */
19
21
  title: string;
20
22
  /** 删除时用 `fs.sizeOfDir` 量到的会话目录字节数。 */
21
23
  sizeBytes: number;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * `/config` 的读/写动词:三只可调项的当前值与写回。
3
+ *
4
+ * 读是免费快照(`apply` 归一后的那一份),写才碰宿主:
5
+ * - 先按 `src/config.ts` 的 `normalizeConfig` 校验(未知键 / 非整数 / 越界回 400,不拿半套值写盘);
6
+ * - 再走宿主 `configEditor.edit(entry, change)`:完整 raw config 落进 profile 的 patch 层,
7
+ * 由编辑器串行化、校验并让这一行重启(字段不是 volatile,重启是它给的语义)。
8
+ * - `configEditor` / `entry` 缺席(老宿主、嵌套上下文)回 `io` 并在原文里说清替代路径——
9
+ * 不静默假装保存成功。
10
+ *
11
+ * `entry` 由组合根从 `ctx.fiber.entry` 取(见 `src/index.ts`);本文件不碰 ctx。
12
+ */
13
+ import { type SessionDeleteConfig } from '../config.js';
14
+ import type { ConfigEditorLike } from '../deps.js';
15
+ /** `/config` 的写支需要的三件;读支只要 `config`。 */
16
+ export interface ConfigRouteDeps {
17
+ readonly config: SessionDeleteConfig;
18
+ readonly configEditor?: ConfigEditorLike;
19
+ readonly entry?: unknown;
20
+ }
21
+ /** `/config` 的请求体:`null` 或 `{}` 是读;只要带一个键就当写(未知键由 {@link normalizeConfig} 400 拒掉)。
22
+ * 路由表按同一句话定纯度,所以别在别处再写一遍这个判据。 */
23
+ export declare function configPatchOf(body: Record<string, unknown> | null): Record<string, unknown> | undefined;
24
+ /** 空体 = 读当前值;带字段 = 写。请求体已经由适配器解析成对象或 null。 */
25
+ export declare function readOrSaveConfig(deps: ConfigRouteDeps, body: Record<string, unknown> | null): SessionDeleteConfig | Promise<SessionDeleteConfig>;
package/locale/en.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
- "title": "Session Delete",
3
+ "title": "Session delete",
4
4
  "description": "Delete sessions: delete moves them to a recoverable trash, with an explicit permanent delete."
5
5
  }
6
6
  }
package/locale/zh.json CHANGED
@@ -1,6 +1,6 @@
1
- {
2
- "meta": {
3
- "title": "会话删除",
4
- "description": "删除会话:删除 = 移入回收站(可恢复),另设显式的彻底删除。"
5
- }
6
- }
1
+ {
2
+ "meta": {
3
+ "title": "会话删除",
4
+ "description": "删除会话:删除 = 移入回收站(可恢复),另设显式的彻底删除。"
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xrn1997/dsh-session-delete",
3
- "version": "0.6.1",
3
+ "version": "0.8.0",
4
4
  "description": "在 DeepSeek Harness 里删除会话:删除=移入回收站(可恢复),另设显式彻底删除",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@11.25.0",
@@ -27,7 +27,9 @@
27
27
  "icon.svg",
28
28
  "cordis.patch.yml",
29
29
  "README.md",
30
- "LICENSE"
30
+ "LICENSE",
31
+ "THIRD_PARTY_NOTICES.md",
32
+ "docs/screenshots"
31
33
  ],
32
34
  "engines": {
33
35
  "node": ">=24",
@@ -44,12 +46,15 @@
44
46
  "gates": "pnpm typecheck && pnpm lint && pnpm test && pnpm build && pnpm run pack:dry"
45
47
  },
46
48
  "peerDependencies": {
47
- "@deepseek-ai/cordis": "^4.0.4",
48
- "react": "^18.3.1"
49
+ "react": "^18.3.1",
50
+ "react-dom": "18.3.1"
49
51
  },
50
52
  "peerDependenciesMeta": {
51
53
  "react": {
52
54
  "optional": true
55
+ },
56
+ "react-dom": {
57
+ "optional": true
53
58
  }
54
59
  },
55
60
  "devDependencies": {
@@ -77,6 +82,7 @@
77
82
  "vitest": "3.2.7"
78
83
  },
79
84
  "dsh": {
85
+ "manifestVersion": 1,
80
86
  "bundle": {
81
87
  "patch": "./cordis.patch.yml"
82
88
  },
@@ -86,16 +92,16 @@
86
92
  "@deepseek-ai/dsh-client-ui-context-menu"
87
93
  ],
88
94
  "platform": "web"
89
- },
90
- "compatibility": {
91
- "dshReleases": {
92
- "0.2.0-rc.2": "compatible",
93
- "0.2.1-rc.1": "compatible",
94
- "0.2.1-rc.2": "compatible",
95
- "0.2.1-rc.3": "compatible",
96
- "0.2.1-rc.5": "compatible",
97
- "0.2.2-rc.1": "compatible"
98
- }
95
+ }
96
+ },
97
+ "xrn1997": {
98
+ "dshReleases": {
99
+ "0.2.0-rc.2": "compatible",
100
+ "0.2.1-rc.1": "compatible",
101
+ "0.2.1-rc.2": "compatible",
102
+ "0.2.1-rc.3": "compatible",
103
+ "0.2.1-rc.5": "compatible",
104
+ "0.2.2-rc.1": "compatible"
99
105
  }
100
106
  },
101
107
  "publishConfig": {