@xrn1997/dsh-session-delete 0.8.0 → 0.10.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 +134 -173
- package/THIRD_PARTY_NOTICES.md +4 -2
- package/docs/DETAIL.md +1 -0
- package/docs/DETAIL.zh.md +1 -0
- package/docs/preview.svg +119 -0
- package/docs/preview.zh.svg +117 -0
- package/docs/screenshots/screenshot-01.png +0 -0
- package/lib/client.js +28630 -26493
- package/lib/index.js +2913 -1620
- package/lib/types/api/archive-rows.d.ts +7 -0
- package/lib/types/api/attachment-orphans.d.ts +3 -9
- package/lib/types/api/attachment.d.ts +4 -18
- package/lib/types/api/connection-route.d.ts +2 -6
- package/lib/types/api/route-table.d.ts +79 -31
- package/lib/types/api/trash-rows.d.ts +6 -22
- package/lib/types/client/api-base.d.ts +5 -12
- package/lib/types/client/archive-detail.d.ts +19 -0
- package/lib/types/client/archive-pane.d.ts +63 -0
- package/lib/types/client/archive-store.d.ts +10 -0
- package/lib/types/client/attachment-view.d.ts +3 -17
- package/lib/types/client/batch-bar.d.ts +4 -14
- package/lib/types/client/batch-confirm.d.ts +21 -17
- package/lib/types/client/batch-menu-item.d.ts +2 -10
- package/lib/types/client/batch-pick.d.ts +6 -13
- package/lib/types/client/batch-select.d.ts +10 -25
- package/lib/types/client/batch-selection-store.d.ts +21 -9
- package/lib/types/client/busy-gate.d.ts +2 -4
- package/lib/types/client/config-settings.d.ts +2 -3
- package/lib/types/client/confirm-dialog.d.ts +5 -8
- package/lib/types/client/context-menu-actions.d.ts +2 -8
- package/lib/types/client/context.d.ts +6 -15
- package/lib/types/client/copy.d.ts +86 -57
- package/lib/types/client/delete-confirm.d.ts +25 -13
- package/lib/types/client/delete-menu-item.d.ts +5 -9
- package/lib/types/client/detail-blocks.d.ts +5 -6
- package/lib/types/client/detail-ledger.d.ts +19 -0
- package/lib/types/client/detail-pane.d.ts +28 -0
- package/lib/types/client/host-archive-watch.d.ts +9 -0
- package/lib/types/client/host-rows.d.ts +32 -36
- package/lib/types/client/index.d.ts +5 -19
- package/lib/types/client/main-view.d.ts +25 -34
- package/lib/types/client/maintenance-parts.d.ts +2 -4
- package/lib/types/client/maintenance-settings.d.ts +3 -12
- package/lib/types/client/markdown.d.ts +4 -9
- package/lib/types/client/notice.d.ts +13 -0
- package/lib/types/client/orphan-maintenance.d.ts +8 -20
- package/lib/types/client/panel-tab.d.ts +39 -0
- package/lib/types/client/pending-open.d.ts +0 -1
- package/lib/types/client/plugin.d.ts +2 -4
- package/lib/types/client/prompt-rail.d.ts +1 -2
- package/lib/types/client/receipt.d.ts +14 -41
- package/lib/types/client/remote.d.ts +53 -88
- package/lib/types/client/scene.d.ts +41 -0
- package/lib/types/client/session-detail.d.ts +64 -0
- package/lib/types/client/session-list.d.ts +78 -0
- package/lib/types/client/session-live.d.ts +3 -13
- package/lib/types/client/settings-cards.d.ts +3 -6
- package/lib/types/client/settings-view.d.ts +1 -7
- package/lib/types/client/store.d.ts +6 -25
- package/lib/types/client/subagent-section.d.ts +36 -0
- package/lib/types/client/trash-confirm.d.ts +8 -9
- package/lib/types/client/trash-detail.d.ts +12 -66
- package/lib/types/client/trash-entry.d.ts +1 -1
- package/lib/types/client/trash-nav.d.ts +12 -18
- package/lib/types/client/trash-panel.d.ts +4 -6
- package/lib/types/client/trash-snapshot.d.ts +33 -41
- package/lib/types/client/trash-store.d.ts +12 -4
- package/lib/types/client/trash-tab.d.ts +22 -0
- package/lib/types/client/trash-view.d.ts +50 -50
- package/lib/types/client/ui/ErrorBoundary.d.ts +33 -0
- package/lib/types/client/ui/Modal.d.ts +3 -1
- package/lib/types/client/ui/Toast.d.ts +6 -3
- package/lib/types/client/ui/icons.d.ts +10 -4
- package/lib/types/client/undo-notices.d.ts +51 -20
- package/lib/types/client/undo-toast.d.ts +6 -9
- package/lib/types/client/use-archive-detail-reader.d.ts +27 -0
- package/lib/types/client/use-archive-panel-controller.d.ts +44 -0
- package/lib/types/client/use-archive-query.d.ts +31 -0
- package/lib/types/client/use-column-resize.d.ts +4 -11
- package/lib/types/client/use-detail-frame.d.ts +50 -0
- package/lib/types/client/use-detail-pager.d.ts +5 -13
- package/lib/types/client/use-detail-rail.d.ts +39 -0
- package/lib/types/client/use-detail-reader.d.ts +60 -0
- package/lib/types/client/use-gated-refresh.d.ts +27 -0
- package/lib/types/client/{use-trash-selection.d.ts → use-list-selection.d.ts} +16 -15
- package/lib/types/client/use-maintenance-section.d.ts +7 -12
- package/lib/types/client/use-maintenance.d.ts +11 -13
- package/lib/types/client/use-panel-child-view.d.ts +20 -0
- package/lib/types/client/use-panel-list-read.d.ts +51 -0
- package/lib/types/client/use-panel-selection.d.ts +36 -0
- package/lib/types/client/use-panel-tab.d.ts +134 -0
- package/lib/types/client/use-panel-width.d.ts +3 -11
- package/lib/types/client/use-prompt-rail.d.ts +8 -28
- package/lib/types/client/use-trash-detail-reader.d.ts +10 -23
- package/lib/types/client/use-trash-panel-controller.d.ts +17 -37
- package/lib/types/client/use-trash-query.d.ts +9 -25
- package/lib/types/client/use-write-progress.d.ts +26 -0
- package/lib/types/client/write-progress.d.ts +18 -0
- package/lib/types/client/write-seats.d.ts +64 -34
- package/lib/types/config.d.ts +8 -25
- package/lib/types/deps.d.ts +8 -10
- package/lib/types/domain/closure.d.ts +11 -30
- package/lib/types/errors.d.ts +21 -0
- package/lib/types/index.d.ts +9 -32
- package/lib/types/log/session-log.d.ts +42 -14
- package/lib/types/log/zstd-frames.d.ts +10 -25
- package/lib/types/ports/agent-handles.d.ts +10 -19
- package/lib/types/ports/attachments-port.d.ts +2 -6
- package/lib/types/ports/fs-port.d.ts +22 -24
- package/lib/types/ports/home.d.ts +7 -15
- package/lib/types/ports/host-port.d.ts +96 -59
- package/lib/types/ports/presence-port.d.ts +5 -12
- package/lib/types/remote/map-error.d.ts +4 -17
- package/lib/types/shared/apply-actions.d.ts +36 -0
- package/lib/types/shared/apply-values.d.ts +163 -0
- package/lib/types/shared/project-key.d.ts +5 -23
- package/lib/types/shared/session-path.d.ts +10 -0
- package/lib/types/shared/value-schema.d.ts +54 -0
- package/lib/types/shared/wire.d.ts +243 -197
- package/lib/types/trash/archive-detail.d.ts +16 -0
- package/lib/types/trash/attachments.d.ts +60 -43
- package/lib/types/trash/detail.d.ts +30 -26
- package/lib/types/trash/display-name.d.ts +2 -5
- package/lib/types/trash/entry.d.ts +22 -32
- package/lib/types/trash/groups.d.ts +17 -25
- package/lib/types/trash/ledger.d.ts +5 -9
- package/lib/types/trash/manifest.d.ts +4 -6
- package/lib/types/trash/projection-cache.d.ts +18 -0
- package/lib/types/trash/reconcile.d.ts +13 -23
- package/lib/types/trash/session-rows.d.ts +63 -0
- package/lib/types/trash/shrinking-view.d.ts +29 -0
- package/lib/types/trash/storage-manifest.d.ts +4 -7
- package/lib/types/trash/subagent-summary.d.ts +35 -0
- package/lib/types/verbs/batch-carried.d.ts +22 -2
- package/lib/types/verbs/batch.d.ts +39 -2
- package/lib/types/verbs/config.d.ts +3 -11
- package/lib/types/verbs/delete-session.d.ts +8 -13
- package/lib/types/verbs/empty-batch.d.ts +18 -0
- package/lib/types/verbs/live-admission.d.ts +3 -5
- package/lib/types/verbs/member-journal.d.ts +3 -7
- package/lib/types/verbs/member-presence.d.ts +7 -18
- package/lib/types/verbs/move-group.d.ts +2 -6
- package/lib/types/verbs/orphan-subagents.d.ts +23 -36
- package/lib/types/verbs/permanent-removal.d.ts +98 -81
- package/lib/types/verbs/restore-session.d.ts +10 -24
- package/lib/types/verbs/trash-scope.d.ts +21 -29
- package/lib/types/verbs/write-progress.d.ts +37 -0
- package/locale/en.json +7 -6
- package/locale/zh.json +2 -1
- package/package.json +135 -128
- package/lib/types/client/confirm-close.d.ts +0 -14
- package/lib/types/client/reset-client-state.d.ts +0 -1
- package/lib/types/client/write-settlement.d.ts +0 -66
- package/lib/types/client/write.d.ts +0 -66
- package/lib/types/verbs/errors.d.ts +0 -27
|
@@ -1,45 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* 信封 {ok:true,value} / {ok:false,error:{code,message,details?}} 也是两半的共同契约。
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* 插件专属前缀(十段相对它命名)。
|
|
10
|
-
*
|
|
11
|
-
* 为什么必须带插件名:宿主 `connection.fetch.register` 对**重复的精确路径**直接抛错
|
|
12
|
-
* (`connection: exact Fetch route "…" is already registered`),撞了就是整棵插件树 boot 失败——
|
|
13
|
-
* 所以这条路径是与生态的硬边界,不是显示好不好看的问题。
|
|
14
|
-
*/
|
|
1
|
+
/** 跨半 wire 契约:前缀、端点、请求/响应形状与失败码;两半共用这一份,不各写字面量。
|
|
2
|
+
* 零宿主依赖:只 import `shared/` 内的值形状 schema。信封仍是两半共同的落地形状。 */
|
|
3
|
+
import { APPLY_VALUE_SCHEMAS, ATTACHMENT_CLEANUP_SCHEMA, PURGE_STATS_SCHEMA, TRASH_ENTRY_SCHEMA } from './apply-values.js';
|
|
4
|
+
import type { Infer } from './value-schema.js';
|
|
5
|
+
/** 插件专属前缀(段名相对它命名)。必须带插件名:宿主 exact Fetch 路由重名直接抛错,撞了整棵插件树 boot 失败。 */
|
|
15
6
|
export declare const SESSION_DELETE_API_PREFIX = "/dsh-session-delete-api";
|
|
16
|
-
/**
|
|
17
|
-
* 唯一的取数基础路径:宿主 `/api` + 插件前缀。十段 exact Fetch 路由、客户端探测与附件 URL
|
|
18
|
-
* 都从它起;`SESSION_DELETE_API_PREFIX` 只作为段名的相对前缀与错误原文。
|
|
19
|
-
*/
|
|
7
|
+
/** 唯一的取数基础路径:宿主 `/api` + 插件前缀;全部段名与附件 URL 都从它起。 */
|
|
20
8
|
export declare const OFFICIAL_SESSION_DELETE_API_PREFIX = "/api/dsh-session-delete-api";
|
|
21
|
-
/**
|
|
22
|
-
*
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
* 形状的一部分(ADR-0003),家就在这一张表——路由记录(`src/api/route-table.ts`)逐行投影
|
|
28
|
-
* (`ROUTES.x.method` / `bodyOf(ROUTES.x)`),浏览器半的取数通道(`src/client/remote.ts`)从同一格
|
|
29
|
-
* 投影路径与方法,两半都不逐段手写一份字面量。
|
|
30
|
-
* 写动作统一走一段 `/apply`:一次 HTTP 带一组 id、逐条回结果;
|
|
31
|
-
* 单条就是长度为 1 的批量,仓里不留第二条执行路径。
|
|
32
|
-
* - `list`:对账并读清单(`session-trash/` 里的目录是准)。
|
|
33
|
-
* - `ping`:最便宜的在/不在(不碰清册、不碰盘、不进链),供客户端探测。
|
|
34
|
-
* - `detail`:单条详情(用 POST 表达一个读,判据在 `src/api/route-table.ts` 的 detail 行)。
|
|
35
|
-
* - `apply`:批量执行一个动作(`delete` / `restore` / `purge` / `count` / `orphan-clean`),逐条回 `ApplyOutcome`。
|
|
36
|
-
* - `empty`:清空回收站(聚合回执,不按条回)。
|
|
37
|
-
* - `orphans`:无主子会话的扫描报告(纯读)。清理是 `/apply` 的第五个动作,
|
|
38
|
-
* 这一段只负责"有多少、在哪、多大"。
|
|
39
|
-
* - `attachment`:附件原始字节(全仓唯一的二进制响应段;按查询串寻址,失败仍回 JSON 信封)。
|
|
40
|
-
* - `attachmentOrphans`:无引用图片对象的扫描报告(纯读;数量/字节 + 供预览的对象清单)。
|
|
41
|
-
* - `attachmentClean`:清掉报告那一刻无引用的图片对象(聚合回执 `AttachmentCleanupWire`)。
|
|
42
|
-
* - `config`:三只可调项的读/写共用一段——空体读当前值,带字段写回 profile 的 patch 层。 */
|
|
9
|
+
/** 请求体线上形状:`none` 无字段、`query` 查询串,其余是 JSON 字段组(字段清单见 {@link BODY_GROUPS})。
|
|
10
|
+
* Node 半按它决定是否预读 JSON;浏览器半只投影「有 JSON 字段即 POST」的配对事实。 */
|
|
11
|
+
export type RouteBody = 'none' | 'query' | 'config' | 'entry' | 'apply' | 'sessionId';
|
|
12
|
+
/** 段名表(相对前缀)。每项 `{ path, method, body }`:方法与请求体也是线上形状(ADR-0003),
|
|
13
|
+
* 路由记录与浏览器半都从这里派生,不写第二份字面量。写动作统一走一段 `/apply`;
|
|
14
|
+
* 单条是长度为 1 的批量,仓里不留第二条执行路径。各段语义见下。 */
|
|
43
15
|
export declare const ROUTES: {
|
|
44
16
|
readonly list: {
|
|
45
17
|
readonly path: "/list";
|
|
@@ -100,12 +72,42 @@ export declare const ROUTES: {
|
|
|
100
72
|
readonly method: "POST";
|
|
101
73
|
readonly body: "none";
|
|
102
74
|
};
|
|
75
|
+
/** 纯读:宿主 `session_projcache` 里找不到会话痕迹(语料/持久化、清册 raw 行与回收站目录都不认)的记录条数。 */
|
|
76
|
+
readonly projectionOrphans: {
|
|
77
|
+
readonly path: "/projection-orphans";
|
|
78
|
+
readonly method: "GET";
|
|
79
|
+
readonly body: "none";
|
|
80
|
+
};
|
|
81
|
+
/** 聚合清理:按 raw 行 + 目录名现扫(不对账、不改写清册),只删这一刻仍找不到会话痕迹的记录(不信任旧报告)。 */
|
|
82
|
+
readonly projectionClean: {
|
|
83
|
+
readonly path: "/projection-clean";
|
|
84
|
+
readonly method: "POST";
|
|
85
|
+
readonly body: "none";
|
|
86
|
+
};
|
|
87
|
+
/** 纯读:归档清单(registry 归档集 ∩ 语料,服务端一次算好行投影)。 */
|
|
88
|
+
readonly archiveList: {
|
|
89
|
+
readonly path: "/archive-list";
|
|
90
|
+
readonly method: "GET";
|
|
91
|
+
readonly body: "none";
|
|
92
|
+
};
|
|
93
|
+
/** 归档单条详情(POST 表达一个读,判据在 `src/api/route-table.ts` 的 archiveDetail 行):
|
|
94
|
+
* 目标自己仍在归档集,**或**目标是 `rootSessionId` 那条已归档会话的 subagent 闭包成员;
|
|
95
|
+
* 不是通用会话正文通道。 */
|
|
96
|
+
readonly archiveDetail: {
|
|
97
|
+
readonly path: "/archive-detail";
|
|
98
|
+
readonly method: "POST";
|
|
99
|
+
readonly body: "sessionId";
|
|
100
|
+
};
|
|
101
|
+
/** 纯读:在飞写入的进度快照(`idle` = 没写在飞);写在飞时轮询也要立刻回,不进到达序链。 */
|
|
102
|
+
readonly progress: {
|
|
103
|
+
readonly path: "/progress";
|
|
104
|
+
readonly method: "GET";
|
|
105
|
+
readonly body: "none";
|
|
106
|
+
};
|
|
103
107
|
};
|
|
104
|
-
/** 段名 →
|
|
105
|
-
* (`src/api/route-table.ts`)与运行期键集比对(`tests/route-table.test.ts`)都跟着这一格走。 */
|
|
108
|
+
/** 段名 → 那一段的路径;类型闸与运行期键集比对都跟着这张表走。 */
|
|
106
109
|
export type RouteName = (typeof ROUTES)[keyof typeof ROUTES]['path'];
|
|
107
|
-
/**
|
|
108
|
-
* 这一格固定线上字段名与接受范围({@link CONFIG_LIMITS}),默认值与归一在 `src/config.ts`。 */
|
|
110
|
+
/** 三只可调项的线上形状;`SessionDeleteConfig` 是它的别名,默认值与归一在 `src/config.ts`。 */
|
|
109
111
|
export interface SessionDeleteConfigWire {
|
|
110
112
|
/** 设置页「孤儿附件」预览清单最多列多少条(数量与字节仍按全量报告)。 */
|
|
111
113
|
orphanPreviewLimit: number;
|
|
@@ -114,8 +116,7 @@ export interface SessionDeleteConfigWire {
|
|
|
114
116
|
/** 附件引用扫描里单个 JSON 引用源的字节上限;超过就按「读不出」fail closed。 */
|
|
115
117
|
maxJsonRefBytes: number;
|
|
116
118
|
}
|
|
117
|
-
/**
|
|
118
|
-
* 两处各写一份范围就会「表单说能存、宿主激活时说越界」。 */
|
|
119
|
+
/** 三只可调项的接受范围;表单与归一共用这一格,各写一份就会「表单说能存、激活时说越界」。 */
|
|
119
120
|
export declare const CONFIG_LIMITS: {
|
|
120
121
|
readonly orphanPreviewLimit: {
|
|
121
122
|
readonly min: 1;
|
|
@@ -130,25 +131,16 @@ export declare const CONFIG_LIMITS: {
|
|
|
130
131
|
readonly max: number;
|
|
131
132
|
};
|
|
132
133
|
};
|
|
133
|
-
/** `/apply`
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
* `delete`/`restore` 是回收站那一行(`null` = 这一条已被**同批前一条**带走,幂等 no-op);
|
|
140
|
-
* `purge` 是这一组的聚合回执(同批已带走 ⇒ `{removed:0,freedBytes:0}`);
|
|
141
|
-
* `orphan-clean` 删的是**盘上目录**(不进回收站),所以清册那一行给不出 `null` 这种幂等 no-op——
|
|
142
|
-
* 组已经不在了就是 `not-found`,见 `verbs/batch.ts`。 */
|
|
134
|
+
/** `/apply` 的六个动作。id 的含义随动作走:`delete`/`count`/`orphan-clean`/`unarchive` 是宿主会话 id,
|
|
135
|
+
* `restore`/`purge` 是回收站条目 id;两域都是 string,错域由各动词在运行期处理。
|
|
136
|
+
* 静态事实收在 `src/shared/apply-actions.ts` 的 `APPLY_ACTION_INDEX`,成功值形状见 `APPLY_VALUE_SCHEMAS`。 */
|
|
137
|
+
export type ApplyAction = 'delete' | 'restore' | 'purge' | 'count' | 'orphan-clean' | 'unarchive';
|
|
138
|
+
/** 每个动作的成功值:`count`/`unarchive` 是数,`delete`/`restore` 是清册行或 `null`(同批前一条带走),
|
|
139
|
+
* `purge`/`orphan-clean` 是聚合回执。值形状只声明一次,见 `APPLY_VALUE_SCHEMAS`。 */
|
|
143
140
|
export type ApplyValueByAction = {
|
|
144
|
-
|
|
145
|
-
restore: TrashEntryWire | null;
|
|
146
|
-
purge: PurgeStatsWire;
|
|
147
|
-
count: number;
|
|
148
|
-
'orphan-clean': OrphanCleanStatsWire;
|
|
141
|
+
[A in ApplyAction]: Infer<(typeof APPLY_VALUE_SCHEMAS)[A]>;
|
|
149
142
|
};
|
|
150
|
-
/**
|
|
151
|
-
* 按 `action` + `ok` 双重可判别——浏览器半的便捷包装靠它把 `value` 收成各自动作的类型。 */
|
|
143
|
+
/** 一条动作的落地:原始 id 回带,成败各按信封;按 `action` + `ok` 双重可判别。 */
|
|
152
144
|
export type ApplyOutcome = {
|
|
153
145
|
id: string;
|
|
154
146
|
} & {
|
|
@@ -162,43 +154,40 @@ export type ApplyOutcome = {
|
|
|
162
154
|
error: RemoteFailure;
|
|
163
155
|
};
|
|
164
156
|
}[ApplyAction];
|
|
165
|
-
/**
|
|
166
|
-
*
|
|
167
|
-
export
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
157
|
+
/** 写入进度报的是哪些动作:写动作 + `/empty`(`count` 是纯读,不报进度)。
|
|
158
|
+
* 身份就按 `action` + `ids` 认领,请求形状不必为进度改。 */
|
|
159
|
+
export type WriteProgressAction = Exclude<ApplyAction, 'count'> | 'empty';
|
|
160
|
+
/** 写入进度的步骤码(渲染文案归浏览器半,码只住这一处)。**码只表达动作点**:步骤码→动作点的唯一映射
|
|
161
|
+
* 住 `src/verbs/write-progress.ts`,没有动作点的码不上册(`resuming` 就这样收窄掉——冷 resume 归宿主)。 */
|
|
162
|
+
export declare const WRITE_PROGRESS_STEPS: readonly ["checking", "measuring", "moving", "ledger", "deleting", "attachments", "finishing"];
|
|
163
|
+
export type WriteProgressStep = (typeof WRITE_PROGRESS_STEPS)[number];
|
|
164
|
+
/** `GET /progress` 的线上形状:没写在飞是 `idle`;在飞是那趟写的快照(身份、k/N、步骤、起始时刻)。
|
|
165
|
+
* 生命周期随进程:宿主重启天然回 `idle`,不留残留。 */
|
|
166
|
+
export type WriteProgressWire = {
|
|
167
|
+
readonly status: 'idle';
|
|
168
|
+
} | {
|
|
169
|
+
readonly status: 'running';
|
|
170
|
+
readonly action: WriteProgressAction;
|
|
171
|
+
readonly ids: readonly string[];
|
|
172
|
+
readonly done: number;
|
|
173
|
+
readonly total: number;
|
|
174
|
+
readonly step: WriteProgressStep;
|
|
175
|
+
readonly startedAt: number;
|
|
176
|
+
};
|
|
177
|
+
/** 清册那一行的线上形状:字段清单住 `TRASH_ENTRY_SCHEMA`(判形与类型同源)。 */
|
|
178
|
+
export type TrashEntryWire = Infer<typeof TRASH_ENTRY_SCHEMA>;
|
|
185
179
|
/**
|
|
186
|
-
* `GET /list`
|
|
180
|
+
* `GET /list` 真正发出去的那一行:清册行 + 现算现给的只读数(ADR-0003)。
|
|
187
181
|
*
|
|
188
|
-
*
|
|
189
|
-
* `releaseBytes` 之外全是可选字段,而且「缺席」与「是 0」是两件事——界面上不许拿 0 冒充「没有」,
|
|
190
|
-
* 也不许拿缺席冒充否。
|
|
182
|
+
* 只读数不落清册:它们随盘上状态随时变。「缺席」与「是 0」是两件事——界面不许拿 0 冒充「没有」。
|
|
191
183
|
*/
|
|
192
|
-
export
|
|
193
|
-
/**
|
|
194
|
-
*
|
|
195
|
-
* `planVisibleTrash`,Node 半算一次过线、投影原样搬运;界面上头部合计与单条确认框共用这一个数——
|
|
196
|
-
* 不许各算一遍(各算一遍就是两套口径,且客户端那套会重复计数)。 */
|
|
184
|
+
export type TrashRowWire = TrashEntryWire & {
|
|
185
|
+
/** 这一行「彻底删除」会释放的字节:盘上实测,与 purge 的 `freedBytes` 同一口径(算式住 `planVisibleTrash`)。
|
|
186
|
+
* 头部合计与单条确认框共用这一个数,不许各算一遍。 */
|
|
197
187
|
releaseBytes: number;
|
|
198
188
|
/** 跟着这条父会话**一起进了回收站**的孩子数(清册里 `parentEntryId` 指向它的行)。 */
|
|
199
189
|
subagentCount?: number;
|
|
200
|
-
/**
|
|
201
|
-
* 不念清册里记的 `sizeBytes`。它们已折进 `releaseBytes`——头部合计照念那个数,别再单独相加)。 */
|
|
190
|
+
/** 那些孩子回收站目录的实测字节合计(`planVisibleTrash` 现量);已折进 `releaseBytes`,别再单独相加。 */
|
|
202
191
|
subagentBytes?: number;
|
|
203
192
|
/** **还留在盘上、没被带走**的孩子数(宿主 `sessionQuery`)。与 `subagentCount` 各说各的。 */
|
|
204
193
|
strandedSubagents?: number;
|
|
@@ -206,9 +195,8 @@ export interface TrashRowWire extends TrashEntryWire {
|
|
|
206
195
|
strandedBytes?: number;
|
|
207
196
|
/** 删除时记下的工作区**已经不在账本里**(宿主的「删除工作区」只删注册、保留日志)。 */
|
|
208
197
|
workspaceMissing?: boolean;
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* `attachmentId` 是宿主附件库的 sha256 键,也是 `GET /attachment` 的唯一寻址依据。 */
|
|
198
|
+
};
|
|
199
|
+
/** 单条详情里的一条附件读数;`attachmentId` 是附件库 sha256 键,也是附件段的寻址依据。 */
|
|
212
200
|
export interface TrashDetailAttachmentWire {
|
|
213
201
|
attachmentId: string;
|
|
214
202
|
kind: 'image' | 'file';
|
|
@@ -218,14 +206,11 @@ export interface TrashDetailAttachmentWire {
|
|
|
218
206
|
width?: number;
|
|
219
207
|
height?: number;
|
|
220
208
|
}
|
|
221
|
-
/**
|
|
209
|
+
/** 单条详情里的一块正文(判据住 `src/trash/detail.ts`)。
|
|
222
210
|
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
|
|
226
|
-
* 分页游标(`olderCursor`)管的是"更早的块还没取",两者不是同一件事。
|
|
227
|
-
* 出线的每块**都有内容**(非空正文或至少一个附件;工具块的名字与状态就是内容):判据住
|
|
228
|
-
* `src/trash/detail.ts`,空块不建也不出线,渲染侧不用兜。 */
|
|
211
|
+
* `kind` 决定这块怎么画;`attachments` 每种块都必填(空数组 = 没有)。`truncated` 是单块载荷闸,
|
|
212
|
+
* 与分页游标 `olderCursor` 是两件事;空块不建也不出线。
|
|
213
|
+
*/
|
|
229
214
|
export interface TrashDetailTextBlockWire {
|
|
230
215
|
kind: 'user' | 'assistant' | 'reasoning' | 'system' | 'compaction';
|
|
231
216
|
/** 块在整条日志里的稳定序号(分页游标也用它);跨页不重复。 */
|
|
@@ -246,8 +231,7 @@ export interface TrashDetailInjectionBlockWire {
|
|
|
246
231
|
truncated: boolean;
|
|
247
232
|
attachments: TrashDetailAttachmentWire[];
|
|
248
233
|
}
|
|
249
|
-
/** 一次工具调用:`tool/call` 建块、`tool/result` 按 `callId`
|
|
250
|
-
* `unfinished` = 日志走完也没等到结果(会话可能在工具执行中被杀),不是失败。 */
|
|
234
|
+
/** 一次工具调用:`tool/call` 建块、`tool/result` 按 `callId` 回填;`unfinished` 不是失败。 */
|
|
251
235
|
export interface TrashDetailToolBlockWire {
|
|
252
236
|
kind: 'tool';
|
|
253
237
|
id: string;
|
|
@@ -262,34 +246,24 @@ export interface TrashDetailToolBlockWire {
|
|
|
262
246
|
attachments: TrashDetailAttachmentWire[];
|
|
263
247
|
}
|
|
264
248
|
export type TrashDetailBlockWire = TrashDetailTextBlockWire | TrashDetailInjectionBlockWire | TrashDetailToolBlockWire;
|
|
265
|
-
/**
|
|
249
|
+
/** 详情右缘「提问轨」的一行:整条会话里的一句用户提问,与当前分页窗口无关。
|
|
266
250
|
*
|
|
267
|
-
* `id`
|
|
268
|
-
* 按它直接找;没加载就照 `olderCursor` 一页页往回补到它进窗(`src/client/use-prompt-rail.ts`
|
|
269
|
-
* 的跳转循环),不另发一次定向读。`preview` 有界(空白折叠、超长带省略号):它是导航用的标签,
|
|
270
|
-
* 不是正文的第二份抄本。 */
|
|
251
|
+
* `id` 与 `blocks[].id` 同一套,跳转按 `olderCursor` 回补;`preview` 有界,不是正文抄本。 */
|
|
271
252
|
export interface TrashDetailPromptWire {
|
|
272
253
|
id: string;
|
|
273
254
|
at: number;
|
|
274
255
|
preview: string;
|
|
275
256
|
}
|
|
276
|
-
/**
|
|
277
|
-
|
|
278
|
-
* 正文按块分页:`blocks` 是当前这一页(从新往旧取),`olderCursor` 指向更早一页的边界;
|
|
279
|
-
* 计数是**整条日志**的,不受分页影响。 */
|
|
280
|
-
export interface TrashDetailWire {
|
|
281
|
-
entryId: string;
|
|
257
|
+
/** 会话详情公共基座(回收站与归档两档共用):块按页给,计数按整条日志。 */
|
|
258
|
+
export interface SessionDetailWire {
|
|
282
259
|
/** 日志 header 里的原串(**无损**,比从 `projectKey` 反推那一路强;组头怎么念项目名见 `src/client/trash-view.ts` 的 `projectLabel`,那是另一回事)。 */
|
|
283
260
|
cwd: string;
|
|
284
261
|
createdAt: number;
|
|
285
262
|
lastActivity: number;
|
|
286
|
-
/** 日志内 `session/title`
|
|
263
|
+
/** 日志内 `session/title` 那条记录;清单标题为空串时客户端拿它兜底。 */
|
|
287
264
|
logTitle: string;
|
|
288
|
-
/**
|
|
289
|
-
*
|
|
290
|
-
* `parentSession` 时取它自己日志的当前 `session/title`。它补的是没有父详情可兜的独立子会话
|
|
291
|
-
* ——那种条目的清册 `title` 是主会话那套起名法,`logTitle` 单看也是错的。
|
|
292
|
-
* 缺席 = 主会话、或没有 descriptor 也没有 `parentSession` 的会话,界面回落清册标题。 */
|
|
265
|
+
/** 这条会话自己的显示名,只在详情读时折出:子会话取 descriptor 的 `label`,fork 子会话取自身标题。
|
|
266
|
+
* 缺席 = 主会话或没有可用名字,界面回落清单标题。 */
|
|
293
267
|
label?: string;
|
|
294
268
|
models: string[];
|
|
295
269
|
turnCount: number;
|
|
@@ -300,52 +274,103 @@ export interface TrashDetailWire {
|
|
|
300
274
|
/** 宿主注入的上下文块数(空文本且无附件的注入不建块,也不计)。 */
|
|
301
275
|
injectedCount: number;
|
|
302
276
|
blocks: TrashDetailBlockWire[];
|
|
303
|
-
/** 更早一页的块序号;`null` =
|
|
277
|
+
/** 更早一页的块序号;`null` = 已经到顶。把它原样回传给详情段的 `before`。 */
|
|
304
278
|
olderCursor: number | null;
|
|
305
|
-
/**
|
|
306
|
-
* 跟着详情账本走,后续翻页不重复搬。没有用户提问时是空数组(缺席 = 这一读没带,不是"没有")。 */
|
|
279
|
+
/** 整条会话的提问索引;只在首次读(不带 `before`)时出线,翻页不重搬。 */
|
|
307
280
|
prompts?: TrashDetailPromptWire[];
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
*
|
|
281
|
+
}
|
|
282
|
+
/** 回收站单条详情的线上形状(`POST /detail`):基座 + 清册身份 + 子会话段。 */
|
|
283
|
+
export interface TrashDetailWire extends SessionDetailWire {
|
|
284
|
+
entryId: string;
|
|
285
|
+
/** 折进这一行的孩子(清册里 `parentEntryId` 指向它,判据复用 `visibleGroups`),按清册原序。
|
|
286
|
+
* 缺席 = 没有孩子;最多过线 `SUBAGENT_SUMMARY_LIMIT` 条,超出时 `subagentsTotal` 给总数。 */
|
|
314
287
|
subagents?: TrashEntryWire[];
|
|
315
288
|
/** 子会话总数;**只在 `subagents` 被条数闸截断时出线**(缺席 = 上面就是全部)。 */
|
|
316
289
|
subagentsTotal?: number;
|
|
317
|
-
/**
|
|
318
|
-
* 摘要条报「清册大小合计」用它——不要拿 `subagents` 已列行自己求和,那只是前 N 条。 */
|
|
290
|
+
/** 全部折进来孩子的清册 `sizeBytes` 合计;不要拿已列行求和,那只是前 N 条。 */
|
|
319
291
|
subagentsSizeBytes?: number;
|
|
320
292
|
}
|
|
321
|
-
/**
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
293
|
+
/** 归档清单的一行;大小与时间口径和回收站行不是一个数(ADR-0060 决定第 3 条)。 */
|
|
294
|
+
export interface ArchiveRowWire {
|
|
295
|
+
sessionId: string;
|
|
296
|
+
projectDir: string;
|
|
297
|
+
/** 日志标题(`session/title`;缺席 = 空串)。旧宿主没有批量读面时回退 `titleOf` 投影,属降级口径。 */
|
|
298
|
+
title: string;
|
|
299
|
+
/** 子会话的宿主 `subagent` 投影 label;空串/缺席 = 没有。显示名按 label 非空优先,否则 title。 */
|
|
300
|
+
label?: string;
|
|
301
|
+
/** 最后活动;缺席 = 宿主既没给提问时间、身份记录也没有创建时间(时间未知,不拿 0 冒充 1970)。 */
|
|
302
|
+
updatedAt?: number;
|
|
303
|
+
/** `updatedAt` 的口径;与 `updatedAt` 同进同退。 */
|
|
304
|
+
updatedAtSource?: 'prompt' | 'created';
|
|
305
|
+
/** 宿主持久化日志工件字节;缺席 = 这一行没有可信读数(不是 0)。 */
|
|
306
|
+
sizeBytes?: number;
|
|
307
|
+
/** `origin:'subagent'`;行上要带「子代理」标签。 */
|
|
308
|
+
subagent: boolean;
|
|
329
309
|
}
|
|
310
|
+
/** 归档清单:`sessionQuery` 缺席时显式 `{available:false}`(语料不可见),不是空列表也不是 `io`;
|
|
311
|
+
* `totalBytes` 只加已知大小,`missingSizeCount > 0` 时副标题要说 N 条大小缺席。 */
|
|
312
|
+
export type ArchiveListWire = {
|
|
313
|
+
available: true;
|
|
314
|
+
rows: ArchiveRowWire[];
|
|
315
|
+
totalBytes: number;
|
|
316
|
+
missingSizeCount: number;
|
|
317
|
+
} | {
|
|
318
|
+
available: false;
|
|
319
|
+
};
|
|
320
|
+
/** 归档详情里的一个子会话(宿主闭包 + 只读投影),不是清册行。 */
|
|
321
|
+
export interface ArchiveSubagentWire {
|
|
322
|
+
sessionId: string;
|
|
323
|
+
/** 这个孩子自己的归档态(宿主归档集精确判据);不拿「清单在不在场」冒充归档态。 */
|
|
324
|
+
archived: boolean;
|
|
325
|
+
projectDir: string;
|
|
326
|
+
title: string;
|
|
327
|
+
/** 宿主 `subagent` 投影 label;空串/缺席 = 没有,显示名回落 title。 */
|
|
328
|
+
label?: string;
|
|
329
|
+
/** 最后活动;缺席 = 宿主列表没给(不拿 0 冒充)。 */
|
|
330
|
+
updatedAt?: number;
|
|
331
|
+
/** `updatedAt` 的口径:真有提问时间才标 `prompt`。 */
|
|
332
|
+
updatedAtSource?: 'prompt' | 'created';
|
|
333
|
+
/** 宿主持久化日志工件字节;缺席 = 没有可信读数(不是 0)。 */
|
|
334
|
+
sizeBytes?: number;
|
|
335
|
+
}
|
|
336
|
+
/** 归档单条详情:基座 + 会话 id + 只读子会话段。目标自己已归档,或是 `rootSessionId` 的闭包成员
|
|
337
|
+
* ⇒ 可读;仅凭根放行(主体自己未归档)时不装配子会话段。 */
|
|
338
|
+
export interface ArchiveDetailWire extends SessionDetailWire {
|
|
339
|
+
sessionId: string;
|
|
340
|
+
/** 主体自己的归档态(这一读的权威判据);状态行认这一格,不认客户端快照。 */
|
|
341
|
+
archived: boolean;
|
|
342
|
+
/** 自己已归档且有孩子时出线;缺席 = 没有孩子或仅凭根放行的孩子读。 */
|
|
343
|
+
subagents?: ArchiveSubagentWire[];
|
|
344
|
+
/** 子会话总数;**只在 `subagents` 被条数闸截断时出线**。 */
|
|
345
|
+
subagentsTotal?: number;
|
|
346
|
+
/** **全部**孩子里已知 `sizeBytes` 的合计;没有任何已知读数时缺席(不拿 0 冒充)。 */
|
|
347
|
+
subagentsSizeBytes?: number;
|
|
348
|
+
}
|
|
349
|
+
/** 一次永久删除顺带或孤儿附件清理的附件读数(字段清单住 `ATTACHMENT_CLEANUP_SCHEMA`)。
|
|
350
|
+
* `skipped` 有值 = 部分或整体没清,`removed` 仍可能 > 0;`failed` 是逐文件真出错的那几件。 */
|
|
351
|
+
export type AttachmentCleanupWire = Infer<typeof ATTACHMENT_CLEANUP_SCHEMA>;
|
|
330
352
|
/** 孤儿附件报告里的一条:内容哈希 + 实测字节。没有原始文件名(附件库只存内容)。 */
|
|
331
353
|
export interface AttachmentOrphanItemWire {
|
|
332
354
|
attachmentId: string;
|
|
333
355
|
bytes: number;
|
|
334
356
|
}
|
|
335
|
-
/**
|
|
336
|
-
*
|
|
337
|
-
* (`src/config.ts` 的 `orphanPreviewLimit`,默认 200),数量与字节按全量算。
|
|
338
|
-
* 读不出任何一处引用源时**不返回这一形状**,而是 `io` 失败——不拿 0 冒充"没有孤儿"。 */
|
|
357
|
+
/** 孤儿附件报告:数量、总字节与对象清单(供设置页预览,条数由 `orphanPreviewLimit` 限)。
|
|
358
|
+
* 任何一处引用源读不出时不返回这一形状,而是 `io` 失败——不拿 0 冒充「没有孤儿」。 */
|
|
339
359
|
export interface AttachmentOrphanReportWire {
|
|
340
360
|
count: number;
|
|
341
361
|
totalBytes: number;
|
|
342
362
|
items: AttachmentOrphanItemWire[];
|
|
343
363
|
}
|
|
344
|
-
/**
|
|
345
|
-
export
|
|
364
|
+
/** 清空回收站的聚合回执(字段清单住 `PURGE_STATS_SCHEMA`);`attachments` 缺席 = 这一轮没有读数。 */
|
|
365
|
+
export type PurgeStatsWire = Infer<typeof PURGE_STATS_SCHEMA>;
|
|
366
|
+
/** 孤儿投影缓存报告:只念条数(ADR-0021);读面读不出时 `io` 失败,不拿 0 冒充。 */
|
|
367
|
+
export interface ProjectionCacheOrphanReportWire {
|
|
368
|
+
count: number;
|
|
369
|
+
}
|
|
370
|
+
/** 孤儿投影缓存清理回执:删掉与没删掉的条数;清完重查会再报真实剩余量。 */
|
|
371
|
+
export interface ProjectionCacheCleanupWire {
|
|
346
372
|
removed: number;
|
|
347
|
-
|
|
348
|
-
attachments?: AttachmentCleanupWire;
|
|
373
|
+
failed: number;
|
|
349
374
|
}
|
|
350
375
|
/** 无主子会话扫描里**一个项目目录**的汇总(界面上那条"哪一家还剩多少"的读数)。 */
|
|
351
376
|
export interface OrphanProjectGroupWire {
|
|
@@ -353,8 +378,7 @@ export interface OrphanProjectGroupWire {
|
|
|
353
378
|
sessions: number;
|
|
354
379
|
bytes: number;
|
|
355
380
|
}
|
|
356
|
-
/**
|
|
357
|
-
* `missingParents` 按**去前缀后的形状**去重——同一个失踪父在两种写法下只算一个。 */
|
|
381
|
+
/** 一次孤儿扫描的报告;`missingParents` 按去前缀后的形状去重,同一个失踪父只算一个。 */
|
|
358
382
|
export interface OrphanReportWire {
|
|
359
383
|
roots: readonly string[];
|
|
360
384
|
totalSessions: number;
|
|
@@ -362,17 +386,15 @@ export interface OrphanReportWire {
|
|
|
362
386
|
missingParents: number;
|
|
363
387
|
groups: readonly OrphanProjectGroupWire[];
|
|
364
388
|
}
|
|
365
|
-
/** 清理一组无主子会话的回执(与 {@link PurgeStatsWire}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
removed: number;
|
|
369
|
-
freedBytes: number;
|
|
370
|
-
attachments?: AttachmentCleanupWire;
|
|
371
|
-
}
|
|
372
|
-
/** 请求参数名:浏览器半发、Node 半读,同名同义(`empty` 没有入参)。
|
|
373
|
-
* 附件段是 **query 参数**(GET 二进制响应,没有请求体)。 */
|
|
389
|
+
/** 清理一组无主子会话的回执(与 {@link PurgeStatsWire} 同形,计的是删掉的会话目录)。 */
|
|
390
|
+
export type OrphanCleanStatsWire = PurgeStatsWire;
|
|
391
|
+
/** 请求参数名:浏览器半发、Node 半读,同名同义;附件段是 query 参数。 */
|
|
374
392
|
export declare const PARAMS: {
|
|
375
393
|
readonly entryId: "entryId";
|
|
394
|
+
/** `/archive-detail` 的寻址键(红线:路径字段不过线)。 */
|
|
395
|
+
readonly sessionId: "sessionId";
|
|
396
|
+
/** 归档详情的只读根:看未归档子会话时带上已归档父会话的 id;给了也只用于校验闭包归属。 */
|
|
397
|
+
readonly rootSessionId: "rootSessionId";
|
|
376
398
|
/** `/detail` 的分页游标:只取这个块序号之前的块。缺省 = 从尾部取。 */
|
|
377
399
|
readonly before: "before";
|
|
378
400
|
readonly action: "action";
|
|
@@ -382,20 +404,48 @@ export declare const PARAMS: {
|
|
|
382
404
|
readonly attachmentName: "name";
|
|
383
405
|
/** 图片引用的媒体类型 / 宽高:只给宿主 `attachments.readImage` 做引用校验,不参与路径拼接。 */
|
|
384
406
|
readonly attachmentMediaType: "mediaType";
|
|
385
|
-
/**
|
|
386
|
-
* (别为一张已知超限的图让宿主整份读出来)。 */
|
|
407
|
+
/** 字节数:图片支与文件支都带,先过 `maxAttachmentBytes` 闸再让宿主读。 */
|
|
387
408
|
readonly attachmentBytes: "bytes";
|
|
388
409
|
readonly attachmentWidth: "width";
|
|
389
410
|
readonly attachmentHeight: "height";
|
|
390
411
|
};
|
|
391
|
-
/**
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
412
|
+
/** 请求体字段的种类 → 解析后的类型:新增种类只改这张表的键,解析手与 {@link ParsedBody} 会一起编译错。 */
|
|
413
|
+
type ParsedByKind = {
|
|
414
|
+
requiredString: string;
|
|
415
|
+
optionalString: string | undefined;
|
|
416
|
+
optionalCursor: number | undefined;
|
|
417
|
+
action: ApplyAction;
|
|
418
|
+
idArray: string[];
|
|
419
|
+
};
|
|
420
|
+
/** 请求体字段的种类:每一种由通用解析手的一种读法兑现,拒绝原文也按种类只写一遍。 */
|
|
421
|
+
export type BodyFieldKind = keyof ParsedByKind;
|
|
422
|
+
/** 一个字段组:字段键 → 种类;键必须是 {@link PARAMS} 的成员(配对由 `tests/wire-shape.test.ts` 把守)。 */
|
|
423
|
+
export type BodyGroup = Readonly<Record<string, BodyFieldKind>>;
|
|
424
|
+
/** 段名表每格 `body` → 字段组;`config` 的三只旋钮由 `src/verbs/config.ts` 自己校验,路由层不重复拦。 */
|
|
425
|
+
export declare const BODY_GROUPS: {
|
|
426
|
+
readonly none: {};
|
|
427
|
+
readonly query: {};
|
|
428
|
+
readonly config: {};
|
|
429
|
+
readonly entry: {
|
|
430
|
+
readonly entryId: "requiredString";
|
|
431
|
+
readonly before: "optionalCursor";
|
|
432
|
+
};
|
|
433
|
+
readonly apply: {
|
|
434
|
+
readonly action: "action";
|
|
435
|
+
readonly ids: "idArray";
|
|
436
|
+
};
|
|
437
|
+
readonly sessionId: {
|
|
438
|
+
readonly sessionId: "requiredString";
|
|
439
|
+
readonly before: "optionalCursor";
|
|
440
|
+
readonly rootSessionId: "optionalString";
|
|
441
|
+
};
|
|
442
|
+
};
|
|
443
|
+
/** 描述 → 解析后的字段类型:描述与本型同源 ⇒ 解析手交回的字段,用法在类型层就对得上。 */
|
|
444
|
+
export type ParsedBody<G extends BodyGroup> = {
|
|
445
|
+
[K in keyof G]: ParsedByKind[G[K]];
|
|
446
|
+
};
|
|
447
|
+
/** 失败信封的线上形状:`code` 判别、`message` 上屏、`details` 可选结构化附带物(对齐官方 `rpcErrorSchema`)。
|
|
448
|
+
* 没有附带物时整件缺席,不写空表。 */
|
|
399
449
|
export interface RemoteFailure {
|
|
400
450
|
code: string;
|
|
401
451
|
message: string;
|
|
@@ -409,24 +459,11 @@ export type RemoteResult<T> = {
|
|
|
409
459
|
ok: false;
|
|
410
460
|
error: RemoteFailure;
|
|
411
461
|
};
|
|
412
|
-
/**
|
|
413
|
-
*
|
|
414
|
-
* 位名与判法取自宿主网关客户端面的原文:
|
|
415
|
-
* `if (typeof value === "object" && value !== null && value.isDSHRemoteError === true && typeof value.code === "string") return value`。
|
|
416
|
-
*
|
|
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`)。
|
|
422
|
-
*/
|
|
462
|
+
/** 进程内判别「这已经是一次失败」:按标记位认,不按 `instanceof`(跨 realm / 跨 bundle 不成立)。
|
|
463
|
+
* 标记位只由宿主服务抛出的 `RemoteError` 自带;线上 JSON 不跟着过线,生产侧不造它。 */
|
|
423
464
|
export declare function isDSHRemoteError(value: unknown): value is RemoteFailure;
|
|
424
|
-
/**
|
|
425
|
-
*
|
|
426
|
-
* 不是信封的 JSON;判形不过就该走「回的不是信封」诊断,而不是把垃圾喂给展开层炸出
|
|
427
|
-
* TypeError / "undefined" 上屏(issue #8 第 1 条)。判据就是两臂的形状:`ok` 必须是布尔,
|
|
428
|
-
* `ok:true` 须带 `value` 键(值可以是 null),`ok:false` 的 `error` 须是带 string `code`/`message` 的对象。
|
|
429
|
-
*/
|
|
465
|
+
/** 运行期判形「这段 JSON 是不是信封」:中间层会回非信封 JSON,判形不过就走「回的不是信封」诊断。
|
|
466
|
+
* `ok:true` 须带 `value` 键;`ok:false` 的 `error` 须是带 string `code`/`message` 的对象。 */
|
|
430
467
|
export declare function isRemoteResult(value: unknown): value is RemoteResult<unknown>;
|
|
431
468
|
/** 失败码的域。与宿主官方域(`workspace/*`、`session/*`…)不重名,见本文件。 */
|
|
432
469
|
export declare const SESSION_DELETE_ERROR_DOMAIN = "sessiondelete";
|
|
@@ -436,20 +473,29 @@ export type VerbCode = (typeof VERB_CODES)[number];
|
|
|
436
473
|
/** 三个**路由自检码**:请求本身不对,不是一次操作的结果(它们带 HTTP 状态,见 `api/dispatch.ts`)。 */
|
|
437
474
|
export declare const ROUTE_CODES: readonly ["bad-method", "not-found-route", "bad-request"];
|
|
438
475
|
export type RouteCode = (typeof ROUTE_CODES)[number];
|
|
439
|
-
/**
|
|
440
|
-
* 完整码(`sessiondelete/<后缀>`)。**`Record<…, …>` 是闸**:加一个后缀而忘了这里,
|
|
441
|
-
* 编译不过;写错一个字面量,也编译不过。
|
|
442
|
-
*/
|
|
476
|
+
/** 完整码(`sessiondelete/<后缀>`):`Record` 是闸,加后缀忘了这里或写错字面量都编译不过。 */
|
|
443
477
|
export type AllCodeSuffix = VerbCode | RouteCode;
|
|
444
478
|
export declare const SESSION_DELETE_CODES: Record<AllCodeSuffix, `sessiondelete/${AllCodeSuffix}`>;
|
|
445
|
-
/** `error.code`
|
|
446
|
-
* {@link verbCodeOf} 的问题。任何要「已经是本仓的码就原样对待」的调用点都问这一句,不在调用点
|
|
447
|
-
* 再写一份前缀字面量。 */
|
|
479
|
+
/** `error.code` 是不是本仓的失败形状:只认前缀,后缀在不在册是 {@link verbCodeOf} 的问题。 */
|
|
448
480
|
export declare function isSessionDeleteCodeError(error: unknown): boolean;
|
|
449
|
-
/** `error.code`
|
|
450
|
-
* 路由自检码、别域的码、非字符串 code 一律 `undefined`。 */
|
|
481
|
+
/** `error.code` 折回动词词:前缀与后缀两件都成立才交回;路由自检码与别域的码一律 `undefined`。 */
|
|
451
482
|
export declare function verbCodeOf(error: unknown): VerbCode | undefined;
|
|
452
483
|
/** 回收站目录名(相对宿主数据根)。Node 半拼路径,浏览器半在页脚念它——同一个字面量。 */
|
|
453
484
|
export declare const TRASH_DIR_NAME = "session-trash";
|
|
454
485
|
/** 页脚/文案里带尾斜杠的那一版(`splitOn` 按它切一刀再把目录名包成 code)。 */
|
|
455
486
|
export declare const TRASH_DIR_LABEL = "session-trash/";
|
|
487
|
+
export type WireValueGuard = (value: unknown) => boolean;
|
|
488
|
+
/** 走 JSON 信封的段名(段名表的键;二进制段以后若改走 JSON,这里与表一起改)。 */
|
|
489
|
+
type JsonRouteName = Exclude<keyof typeof ROUTES, 'attachment'>;
|
|
490
|
+
/** 构造面的按动作收窄(`ApplyOutcome` 的辅助判别):`Extract` 那格是条件类型,泛型装配的字面量
|
|
491
|
+
* TS 证不过它——收窄统一走这一枚谓词(装配即验),装配处不留窄化断言。信封判形复用
|
|
492
|
+
* `isApplyOutcomeValue`,形状不在这里抄第二份。 */
|
|
493
|
+
export declare function isApplyOutcomeOf<A extends ApplyAction>(value: unknown, action: A): value is Extract<ApplyOutcome, {
|
|
494
|
+
action: A;
|
|
495
|
+
}>;
|
|
496
|
+
/** 写入进度(`WriteProgressWire`)的判形:遥测快照不走 `/apply` 值那套 schema DSL,
|
|
497
|
+
* 与 `list`/`ping` 同法手写——只校判别键与渲染必读的那几格。 */
|
|
498
|
+
export declare function isWriteProgressWire(value: unknown): value is WriteProgressWire;
|
|
499
|
+
/** 段名表逐段的 JSON 值判形(`src/client/remote.ts` 的成功支只在这里问一次)。 */
|
|
500
|
+
export declare const WIRE_VALUE_GUARDS: Record<JsonRouteName, WireValueGuard>;
|
|
501
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 归档**单条详情**(`POST /archive-detail`):正文走 `sessionQuery.readSession` 的整本事件流 + 合成 `session` 头,喂 `DetailFold`
|
|
3
|
+
* (块/分页/计数与回收站详情同一份折叠,`src/trash/detail.ts`)。三条硬口径(ADR-0060 决定第 2–3 条、ADR-0061):
|
|
4
|
+
* ① **寻址只认 id**:客户端只传 `sessionId`(与可选 `rootSessionId`),路径字段不过线。目标自己已归档,或 `rootSessionId` 已归档且目标在该根的
|
|
5
|
+
* subagent 闭包里 ⇒ 可读;其余 ⇒ `not-found`——否则这就是一条可读任意会话的通用正文通道。路径形字符串只是「不满足闭包条件的 id」。
|
|
6
|
+
* ② **header 合成**:`readSession` 的 `events` **不含** raw JSONL 里那条 `{"type":"session", …}` 头记录——把 `snapshot.session` 的
|
|
7
|
+
* `cwd` / `createdAt` / `parentSession` 拼成同形的那一条先喂折叠,项目名、创建时间与 fork 子会话的 label 兜底才不丢。
|
|
8
|
+
* ③ **失败折码**:`SESSION_QUERY_SESSION_NOT_FOUND` ⇒ `sessiondelete/not-found`(不折就分不出「这条没了」与「读失败」);方法缺席 / 读失败 ⇒ `io`。
|
|
9
|
+
*
|
|
10
|
+
* 子会话段是**只读投影**(行读数走 `session-rows.ts` 那一份,只把大小读失败折成逐行缺);归档仍是**单会话粒度**,这里只展示孩子、不做随父归档/恢复。
|
|
11
|
+
* **仅凭根放行的读不装配这一段**:孩子视图单级、客户端对这种主体也不画它,不为此付第二次闭包 BFS 与逐孩子行读数(ADR-0061 边界)。
|
|
12
|
+
*/
|
|
13
|
+
import type { CoreDeps } from '../deps.js';
|
|
14
|
+
import type { ArchiveDetailWire } from '../shared/wire.js';
|
|
15
|
+
import { type DetailLimits } from './detail.js';
|
|
16
|
+
export declare function readArchiveDetail(deps: CoreDeps, limits?: DetailLimits): (sessionId: string, before?: number, rootSessionId?: string) => Promise<ArchiveDetailWire>;
|