@xrn1997/dsh-session-delete 0.12.0 → 0.14.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 +4 -3
- package/THIRD_PARTY_NOTICES.md +2 -2
- package/lib/client.js +7856 -5511
- package/lib/index.js +1147 -174
- package/lib/types/api/project-ranks.d.ts +3 -0
- package/lib/types/api/search.d.ts +7 -0
- package/lib/types/api/trash-rows.d.ts +1 -1
- package/lib/types/client/{batch-bar.d.ts → batch/batch-bar.d.ts} +2 -2
- package/lib/types/client/{batch-menu-item.d.ts → batch/batch-menu-item.d.ts} +1 -1
- package/lib/types/client/{batch-pick.d.ts → batch/batch-pick.d.ts} +1 -1
- package/lib/types/client/{batch-select.d.ts → batch/batch-select.d.ts} +2 -2
- package/lib/types/client/{delete-menu-item.d.ts → batch/delete-menu-item.d.ts} +1 -1
- package/lib/types/client/batch/index.d.ts +10 -0
- package/lib/types/client/{copy.d.ts → core/copy.d.ts} +41 -2
- package/lib/types/client/{receipt.d.ts → core/receipt.d.ts} +1 -1
- package/lib/types/client/{remote.d.ts → core/remote.d.ts} +23 -2
- package/lib/types/client/detail/block-render.d.ts +22 -0
- package/lib/types/client/{detail-blocks.d.ts → detail/detail-blocks.d.ts} +1 -1
- package/lib/types/client/detail/detail-style.d.ts +62 -0
- package/lib/types/client/detail/detail-text.d.ts +18 -0
- package/lib/types/client/detail/index.d.ts +17 -0
- package/lib/types/client/{markdown.d.ts → detail/markdown.d.ts} +2 -2
- package/lib/types/client/{prompt-rail.d.ts → detail/prompt-rail.d.ts} +2 -2
- package/lib/types/client/{session-detail.d.ts → detail/session-detail.d.ts} +20 -13
- package/lib/types/client/{subagent-section.d.ts → detail/subagent-section.d.ts} +2 -2
- package/lib/types/client/{use-archive-detail-reader.d.ts → detail/use-archive-detail-reader.d.ts} +2 -2
- package/lib/types/client/{use-detail-pager.d.ts → detail/use-detail-pager.d.ts} +1 -1
- package/lib/types/client/{use-detail-rail.d.ts → detail/use-detail-rail.d.ts} +3 -1
- package/lib/types/client/{use-detail-reader.d.ts → detail/use-detail-reader.d.ts} +3 -3
- package/lib/types/client/{use-prompt-rail.d.ts → detail/use-prompt-rail.d.ts} +1 -1
- package/lib/types/client/{use-trash-detail-reader.d.ts → detail/use-trash-detail-reader.d.ts} +2 -2
- package/lib/types/client/{context-menu-actions.d.ts → host/context-menu-actions.d.ts} +2 -2
- package/lib/types/client/host/guard.d.ts +16 -0
- package/lib/types/client/{host-archive-watch.d.ts → host/host-archive-watch.d.ts} +1 -1
- package/lib/types/client/host/index.d.ts +11 -0
- package/lib/types/client/panel/archive-detail.d.ts +22 -0
- package/lib/types/client/{archive-pane.d.ts → panel/archive-pane.d.ts} +28 -9
- package/lib/types/client/{detail-pane.d.ts → panel/detail-pane.d.ts} +3 -3
- package/lib/types/client/panel/index.d.ts +9 -0
- package/lib/types/client/panel/panel-tab.d.ts +61 -0
- package/lib/types/client/{session-list.d.ts → panel/session-list.d.ts} +4 -4
- package/lib/types/client/{trash-confirm.d.ts → panel/trash-confirm.d.ts} +2 -12
- package/lib/types/client/{trash-detail.d.ts → panel/trash-detail.d.ts} +10 -7
- package/lib/types/client/{trash-drop.d.ts → panel/trash-drop.d.ts} +1 -1
- package/lib/types/client/{trash-entry.d.ts → panel/trash-entry.d.ts} +2 -2
- package/lib/types/client/{trash-panel.d.ts → panel/trash-panel.d.ts} +1 -1
- package/lib/types/client/panel/trash-tab.d.ts +42 -0
- package/lib/types/client/{use-archive-panel-controller.d.ts → panel/use-archive-panel-controller.d.ts} +7 -5
- package/lib/types/client/{use-archive-query.d.ts → panel/use-archive-query.d.ts} +2 -2
- package/lib/types/client/{use-list-selection.d.ts → panel/use-list-selection.d.ts} +1 -1
- package/lib/types/client/{use-panel-child-view.d.ts → panel/use-panel-child-view.d.ts} +1 -1
- package/lib/types/client/{use-panel-tab.d.ts → panel/use-panel-tab.d.ts} +9 -12
- package/lib/types/client/{use-trash-panel-controller.d.ts → panel/use-trash-panel-controller.d.ts} +10 -4
- package/lib/types/client/{use-trash-query.d.ts → panel/use-trash-query.d.ts} +4 -4
- package/lib/types/client/panel/view-switches.d.ts +29 -0
- package/lib/types/client/scene.d.ts +8 -8
- package/lib/types/client/search/index.d.ts +12 -0
- package/lib/types/client/search/search-box.d.ts +24 -0
- package/lib/types/client/search/search-preview.d.ts +46 -0
- package/lib/types/client/search/search-results.d.ts +62 -0
- package/lib/types/client/search/search-text.d.ts +13 -0
- package/lib/types/client/search/use-search-view.d.ts +59 -0
- package/lib/types/client/search/use-search.d.ts +62 -0
- package/lib/types/client/{config-settings.d.ts → settings/config-settings.d.ts} +2 -2
- package/lib/types/client/settings/index.d.ts +8 -0
- package/lib/types/client/{maintenance-parts.d.ts → settings/maintenance-parts.d.ts} +1 -1
- package/lib/types/client/{maintenance-settings.d.ts → settings/maintenance-settings.d.ts} +1 -1
- package/lib/types/client/settings/orphan-confirm.d.ts +12 -0
- package/lib/types/client/{orphan-maintenance.d.ts → settings/orphan-maintenance.d.ts} +3 -3
- package/lib/types/client/{settings-cards.d.ts → settings/settings-cards.d.ts} +2 -2
- package/lib/types/client/{use-maintenance-section.d.ts → settings/use-maintenance-section.d.ts} +1 -1
- package/lib/types/client/{use-maintenance.d.ts → settings/use-maintenance.d.ts} +4 -4
- package/lib/types/client/{batch-selection-store.d.ts → state/batch-selection-store.d.ts} +11 -4
- package/lib/types/client/state/delete-action.d.ts +16 -0
- package/lib/types/client/{main-view.d.ts → state/main-view.d.ts} +1 -1
- package/lib/types/client/{trash-snapshot.d.ts → state/trash-snapshot.d.ts} +1 -1
- package/lib/types/client/{undo-notices.d.ts → state/undo-notices.d.ts} +9 -22
- package/lib/types/client/ui/Button.d.ts +2 -1
- package/lib/types/client/ui/ErrorBoundary.d.ts +4 -8
- package/lib/types/client/ui/Modal.d.ts +4 -3
- package/lib/types/client/ui/Toast.d.ts +13 -3
- package/lib/types/client/ui/Tooltip.d.ts +3 -2
- package/lib/types/client/ui/anchor-fit.d.ts +42 -0
- package/lib/types/client/ui/icons.d.ts +13 -2
- package/lib/types/client/ui/inert.d.ts +15 -0
- package/lib/types/client/{attachment-view.d.ts → widgets/attachment-view.d.ts} +3 -3
- package/lib/types/client/{confirm-dialog.d.ts → widgets/confirm-dialog.d.ts} +4 -0
- package/lib/types/client/{trash-view.d.ts → widgets/trash-view.d.ts} +8 -5
- package/lib/types/client/write/delete-action-host.d.ts +4 -0
- package/lib/types/client/write/index.d.ts +13 -0
- package/lib/types/client/{undo-toast.d.ts → write/undo-toast.d.ts} +2 -2
- package/lib/types/client/{use-write-progress.d.ts → write/use-write-progress.d.ts} +2 -2
- package/lib/types/client/{write-progress.d.ts → write/write-progress.d.ts} +1 -1
- package/lib/types/client/{write-seats.d.ts → write/write-seats.d.ts} +7 -15
- package/lib/types/ports/agent-handles.d.ts +2 -1
- package/lib/types/ports/host-port.d.ts +6 -1
- package/lib/types/shared/wire.d.ts +135 -3
- package/lib/types/trash/content-text.d.ts +10 -0
- package/lib/types/trash/groups.d.ts +18 -6
- package/lib/types/trash/search-corpus.d.ts +40 -0
- package/lib/types/trash/search-text.d.ts +43 -0
- package/lib/types/trash/shrinking-view.d.ts +6 -4
- package/lib/types/verbs/permanent-removal.d.ts +22 -6
- package/lib/types/verbs/search.d.ts +53 -0
- package/lib/types/verbs/trash-scope.d.ts +5 -1
- package/package.json +7 -7
- package/lib/types/client/archive-detail.d.ts +0 -19
- package/lib/types/client/delete-action.d.ts +0 -23
- package/lib/types/client/panel-tab.d.ts +0 -39
- package/lib/types/client/trash-tab.d.ts +0 -22
- package/lib/types/client/ui/Tag.d.ts +0 -16
- /package/lib/types/client/{api-base.d.ts → core/api-base.d.ts} +0 -0
- /package/lib/types/client/{context.d.ts → core/context.d.ts} +0 -0
- /package/lib/types/client/{detail-ledger.d.ts → core/detail-ledger.d.ts} +0 -0
- /package/lib/types/client/{plugin.d.ts → core/plugin.d.ts} +0 -0
- /package/lib/types/client/{use-gated-refresh.d.ts → core/use-gated-refresh.d.ts} +0 -0
- /package/lib/types/client/{use-prefetch.d.ts → core/use-prefetch.d.ts} +0 -0
- /package/lib/types/client/{store.d.ts → core/value-store.d.ts} +0 -0
- /package/lib/types/client/{use-detail-frame.d.ts → detail/use-detail-frame.d.ts} +0 -0
- /package/lib/types/client/{session-live.d.ts → host/session-live.d.ts} +0 -0
- /package/lib/types/client/{drop-machine.d.ts → panel/drop-machine.d.ts} +0 -0
- /package/lib/types/client/{trash-nav.d.ts → panel/trash-nav.d.ts} +0 -0
- /package/lib/types/client/{use-column-resize.d.ts → panel/use-column-resize.d.ts} +0 -0
- /package/lib/types/client/{use-panel-list-read.d.ts → panel/use-panel-list-read.d.ts} +0 -0
- /package/lib/types/client/{use-panel-selection.d.ts → panel/use-panel-selection.d.ts} +0 -0
- /package/lib/types/client/{use-panel-width.d.ts → panel/use-panel-width.d.ts} +0 -0
- /package/lib/types/client/{settings-view.d.ts → settings/settings-view.d.ts} +0 -0
- /package/lib/types/client/{archive-store.d.ts → state/archive-store.d.ts} +0 -0
- /package/lib/types/client/{host-rows.d.ts → state/host-rows.d.ts} +0 -0
- /package/lib/types/client/{pending-open.d.ts → state/pending-open.d.ts} +0 -0
- /package/lib/types/client/{trash-store.d.ts → state/trash-store.d.ts} +0 -0
- /package/lib/types/client/{notice.d.ts → widgets/notice.d.ts} +0 -0
- /package/lib/types/client/{busy-gate.d.ts → write/busy-gate.d.ts} +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { type TrashDetailAttachmentWire } from '
|
|
2
|
-
import type { Translate } from '
|
|
1
|
+
import { type TrashDetailAttachmentWire } from '../../shared/wire.js';
|
|
2
|
+
import type { Translate } from '../core/copy.js';
|
|
3
3
|
/** 取数地址只从校验过的 id 与 kind 派生:不接受路径与任意查询串,故不存在「读任意文件」的入口。 */
|
|
4
4
|
export declare function attachmentUrl(a: TrashDetailAttachmentWire): string;
|
|
5
5
|
/**
|
|
6
6
|
* 一条消息的全部附件,顺序照日志(用户先发图后发文件)。`align` 是这一行的对齐:用户行靠右、助手行靠左。
|
|
7
|
-
* `failed` 按 `attachmentId`
|
|
7
|
+
* `failed` 按 `attachmentId` 记:同一内容哈希可能被引用多次,裂一次就不再画破图。
|
|
8
8
|
*/
|
|
9
9
|
export declare function AttachmentStrip({ attachments, t, align, }: {
|
|
10
10
|
attachments: readonly TrashDetailAttachmentWire[];
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 回收站与维护卡各确认框共用的**一个壳**:`Modal` + 标题 + 关闭钮 + 「取消(描边) / 确认(主按钮)」页脚。
|
|
3
3
|
* 共用的只有页脚与关框规则(在飞时取消与关闭都按住),业务面各框自持;裁决见 ADR-0052。
|
|
4
|
+
*
|
|
5
|
+
* **初始焦点在取消上**(`data-modal-autofocus`):这些框全是危险动作(彻底删除 / 清空回收站 /
|
|
6
|
+
* 孤儿清理),指南 `dialog` 要求破坏性确认把自动焦点给安全动作;不给标记的话 `Modal` 会落到
|
|
7
|
+
* 首个可聚焦元素——header 那颗关闭钮,而忙碌档里它正是 `aria-disabled` 的死键。
|
|
4
8
|
*/
|
|
5
9
|
import { type ReactNode } from 'react';
|
|
6
10
|
export interface ConfirmDialogProps {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* **配色与圆角一律走 token,字号是字面量 px**:卡片用宿主设置面的底层 token,清单行不铺底不描边。
|
|
4
4
|
*/
|
|
5
5
|
import type { CSSProperties } from 'react';
|
|
6
|
-
import type { Translate } from '
|
|
6
|
+
import type { Translate } from '../core/copy.js';
|
|
7
7
|
/** 卡片配方:宿主设置面的 fill/stroke 底层 token + 官方 `lg` 圆角。 */
|
|
8
8
|
export declare const CARD: CSSProperties;
|
|
9
9
|
/** 清单条目行:与 `CARD` 同族但不铺底、不描边——`CARD` 借给读数失败块与附件回执块(要打断视线),
|
|
@@ -29,8 +29,6 @@ export interface ProjectGroup<R> {
|
|
|
29
29
|
title: string;
|
|
30
30
|
/** 「未分组」组:只有回收站档有(工作区已不在账本里的条目);归档档不传 `ungroupedOf` ⇒ 恒 false。 */
|
|
31
31
|
ungrouped: boolean;
|
|
32
|
-
/** 组内最新一条的时间键——组间排序的键。 */
|
|
33
|
-
latest: number;
|
|
34
32
|
rows: readonly R[];
|
|
35
33
|
}
|
|
36
34
|
/** 「未分组」组的键:工作区已删(`workspaceMissing`)的条目归这里;哨兵不与真实 `projectDir` 同形
|
|
@@ -38,13 +36,16 @@ export interface ProjectGroup<R> {
|
|
|
38
36
|
export declare const UNGROUPED_PROJECT_DIR = "__dsh-session-delete__ungrouped";
|
|
39
37
|
/** 分组键:回收站传移入回收站时间 + workspaceMissing⇒未分组;归档传 `updatedAt`、不传 `ungroupedOf`。 */
|
|
40
38
|
export interface GroupKeys<R> {
|
|
41
|
-
/**
|
|
39
|
+
/** 组**内**的排序时间键(trash: `deletedAt`;archive: `updatedAt`),按它倒序。 */
|
|
42
40
|
timeOf: (row: R) => number;
|
|
43
41
|
projectDirOf: (row: R) => string;
|
|
42
|
+
/** 组**间**第一判据:宿主工作区显示顺序里的位置(0 起);缺席 = 项目当前不在账本里。 */
|
|
43
|
+
rankOf?: (row: R) => number | undefined;
|
|
44
44
|
/** 只有回收站档传:命中 ⇒ 归「未分组」组(永远沉底)。 */
|
|
45
45
|
ungroupedOf?: (row: R) => boolean;
|
|
46
46
|
}
|
|
47
|
-
/**
|
|
47
|
+
/** 按项目分组:组内按时间键倒序;组间按宿主工作区顺序(无位组排在其后、按 `projectDir` 码点兜底),
|
|
48
|
+
* 「未分组」组(若有)永远沉底。组与组之间不因条目被删除 / 恢复而换位。 */
|
|
48
49
|
export declare function groupByProject<R>(rows: readonly R[], t: Translate, keys: GroupKeys<R>): ProjectGroup<R>[];
|
|
49
50
|
/** 显示名次序前两格(ADR-0058):`label` 非空优先,否则 `title`;兜底那句归调用方。次序只有这一份。 */
|
|
50
51
|
export declare function preferredNameOf(row: {
|
|
@@ -66,3 +67,5 @@ export declare function detailNameOf(row: {
|
|
|
66
67
|
readonly label?: string;
|
|
67
68
|
readonly logTitle: string;
|
|
68
69
|
} | undefined, fallback: string): string;
|
|
70
|
+
/** 确认框里那份可滚的逐条清单(两张确认框共用一份):长清单在框内滚,标题与动作行留在框里。 */
|
|
71
|
+
export declare const CARD_LIST: CSSProperties;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 写链模块的入口:六个写入座位共用的一条 `apply → 解信封 → 回执摘要 → settlement → refresh` 生命周期
|
|
3
|
+
* (ADR-0013 / ADR-0017 / ADR-0069),外加删除动作宿主与撤销横幅。
|
|
4
|
+
*
|
|
5
|
+
* 外部只 import 本文件;座位怎么排、busy 闸怎么开、进度怎么认领、撤销怎么起落是这一层的实现细节。
|
|
6
|
+
* 边界由 `tests/dependency-direction.test.ts` 钉住。
|
|
7
|
+
*/
|
|
8
|
+
export { useBusyGate, type BusyGate, type GateRun } from './busy-gate.js';
|
|
9
|
+
export { DeleteActionHost } from './delete-action-host.js';
|
|
10
|
+
export { UndoToast } from './undo-toast.js';
|
|
11
|
+
export { useWriteProgress } from './use-write-progress.js';
|
|
12
|
+
export { WriteProgressLine } from './write-progress.js';
|
|
13
|
+
export { deleteSessionsFromBatch, deleteSessionFromMenu, unarchiveFromArchiveTab, purgeFromPanel, restoreFromPanel, type WriteOutcome, } from './write-seats.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type Translate } from '
|
|
2
|
-
import type { OneShotDeps } from '
|
|
1
|
+
import { type Translate } from '../core/copy.js';
|
|
2
|
+
import type { OneShotDeps } from '../core/remote.js';
|
|
3
3
|
/**
|
|
4
4
|
* 常驻的撤销提示宿主,挂 `shell.overlay`。两种来源共用:**当前横幅**优先;不在时顶上一条待显示的
|
|
5
5
|
* 撤销失败(在飞期间横幅被覆盖/熄灭,失败原文不能跟着消失)。
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { WriteProgressAction, WriteProgressStep } from '
|
|
2
|
-
import type { ProgressDeps } from '
|
|
1
|
+
import type { WriteProgressAction, WriteProgressStep } from '../../shared/wire.js';
|
|
2
|
+
import type { ProgressDeps } from '../core/remote.js';
|
|
3
3
|
/** 轮询周期 300ms:够密到 k/N 的推进看得见,够疏到不跟自己那趟写抢盘(口径裁定,不随配置走)。 */
|
|
4
4
|
export declare const PROGRESS_POLL_MS = 300;
|
|
5
5
|
/** 认领结果的界面脸:`own` 才带 k/N 与步骤(原样来自快照,不折算百分比——假进度是反目标);
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* 整句一个键会让任一段变化都重写整句模板,也让「已用秒数」没法单独活着。语序与「 · 」分隔在两种语言下同形。
|
|
7
7
|
*/
|
|
8
8
|
import { type ReactElement } from 'react';
|
|
9
|
-
import type { Translate } from '
|
|
9
|
+
import type { Translate } from '../core/copy.js';
|
|
10
10
|
import type { WriteProgressFace } from './use-write-progress.js';
|
|
11
11
|
/** 进度行本体:`role="status"` 就是 `docs/ui-spec.md` §2 那条 `aria-live`(遥测小读的翻转不该抢焦点)。
|
|
12
12
|
* `announce=false` 用于已经处在另一个 live region(撤销横幅的 `role=alert`)里的场景:整行只做视觉,
|
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
* 的收尾住 `use-trash-query.ts`。闸包住整趟:给了 `gate` 就把 apply → settle → refresh 一起包进去——
|
|
5
5
|
* refresh 落在闸外时旧清单还在屏上,同一个动作能被再点一次;被挡回的那趟什么都不落地,交回 blocked。
|
|
6
6
|
*/
|
|
7
|
-
import type { Translate } from '
|
|
7
|
+
import type { Translate } from '../core/copy.js';
|
|
8
8
|
import type { BusyGate, GateRun } from './busy-gate.js';
|
|
9
|
-
import type { OneShotDeps, TrashEntryLike } from '
|
|
10
|
-
import {
|
|
11
|
-
import { type
|
|
12
|
-
import
|
|
9
|
+
import type { OneShotDeps, TrashEntryLike } from '../core/remote.js';
|
|
10
|
+
import type { PickItem } from '../state/batch-selection-store.js';
|
|
11
|
+
import { type ReceiptSummary } from '../core/receipt.js';
|
|
12
|
+
import { type UndoNotice } from '../state/undo-notices.js';
|
|
13
|
+
import type { ApplyAction, RemoteFailure } from '../../shared/wire.js';
|
|
13
14
|
/** 有座位的动作:写入链只服务这四支;新增动作默认落进这里,穷尽闸会编译错直到补上它的收尾。 */
|
|
14
15
|
export type SeatedAction = Exclude<ApplyAction, 'count' | 'orphan-clean'>;
|
|
15
16
|
/** 一次写入结局的成功支:渲染无关的事实(`SettledFacts`)加 `ok` 判别。 */
|
|
@@ -34,18 +35,9 @@ export interface FailureSink {
|
|
|
34
35
|
/** 这一趟的逐条失败表(信封成功或顶层失败都交;没有失败时是空 Map)。被挡回时不调用。 */
|
|
35
36
|
set(failures: ReadonlyMap<string, string>): void;
|
|
36
37
|
}
|
|
37
|
-
/** 一条待移入回收站的会话:宿主投影的会话 id + 移入回收站那一刻的显示名。请求现场、单条座位、批量选中集
|
|
38
|
-
* (`batch-selection-store.ts` 的 `PickItem`)与撤销横幅共用这组同行字段;`title` 只用于已选清单与
|
|
39
|
-
* 撤销/失败原文,不参与请求。 */
|
|
40
|
-
export interface TrashMoveTarget {
|
|
41
|
-
/** 宿主槽位投影的会话 id,原样透给 `/apply`(浏览器半不自己拼 id)。 */
|
|
42
|
-
readonly sessionId: string;
|
|
43
|
-
/** 移入回收站那一刻的显示名(投影的 `displayTitle`)。 */
|
|
44
|
-
readonly title: string;
|
|
45
|
-
}
|
|
46
38
|
/** 会话行菜单的单条移入座位:一条会话、`single` 读法、成功发单条撤销横幅。`value` 是这条的失败原文,
|
|
47
39
|
* `null` = 跑了且无失败;调用方据此发布裸失败提示。 */
|
|
48
|
-
export declare function deleteSessionFromMenu(deps: OneShotDeps, input:
|
|
40
|
+
export declare function deleteSessionFromMenu(deps: OneShotDeps, input: PickItem & {
|
|
49
41
|
failureSink?: FailureSink;
|
|
50
42
|
refresh?: () => void | Promise<void>;
|
|
51
43
|
}, gate: Pick<BusyGate, 'around'>): Promise<GateRun<string | null>>;
|
|
@@ -7,7 +7,8 @@ export interface AgentCtxLike {
|
|
|
7
7
|
}) => void): void;
|
|
8
8
|
effect?(execute: () => () => unknown, label?: string): unknown;
|
|
9
9
|
}
|
|
10
|
-
/** 一次捕获交回的句柄表:按会话 id `dispose`。没捕到 / 已经 dispose 过都是 no-op;dispose
|
|
10
|
+
/** 一次捕获交回的句柄表:按会话 id `dispose`。没捕到 / 已经 dispose 过都是 no-op;dispose 本身的失败**原样抛出**,
|
|
11
|
+
* 由 `evictLive` 记一条诊断;**会话是否已离场只看 live store**,不拿 agent 收尾的成败去改写在场三态。 */
|
|
11
12
|
export interface AgentHandleStore {
|
|
12
13
|
dispose(sessionId: string): Promise<void>;
|
|
13
14
|
}
|
|
@@ -10,6 +10,9 @@ export interface HostIdentityPort {
|
|
|
10
10
|
/** 会话落盘的**项目目录名**(`<sessions>/<projectKey(cwd)>`);账本里没有这个会话 ⇒ `undefined`。header 走公开 live/持久化读面;
|
|
11
11
|
* 与 `workspaceOf` 同一口径:**未命中是正常的 no-op,不是故障**(存储真故障照抛)。 */
|
|
12
12
|
projectDirOf(sessionId: string): Promise<string | undefined>;
|
|
13
|
+
/** 宿主工作区**显示顺序**:`registry.list()` 的项目目录名序列(宿主持久的手动顺序;新工作区前插、重排只经显式动作)。
|
|
14
|
+
* 清单行上的 `projectRank` 由它派生。`list()` 抛错照抛——顺序读不出来不静默换一种排法。 */
|
|
15
|
+
projectOrder(): Promise<readonly string[]>;
|
|
13
16
|
/** 移入回收站时**尽力**取的会话显示名,**与宿主工作中同名**:子会话(`subagent` 投影有 label)取 label,其余取 `title` 投影;取不到返回空串,
|
|
14
17
|
* 绝不因此让删除失败。子会话不按 `title` 起名:同批子会话会撞成同名分不清(ADR-0058)。名字只存在于宿主自己的账本/缓存里 ⇒ 取数面归宿主端口。 */
|
|
15
18
|
titleOf(sessionId: string): Promise<string>;
|
|
@@ -21,7 +24,9 @@ export interface HostIdentityPort {
|
|
|
21
24
|
archivedSessionIds(): Promise<readonly string[]>;
|
|
22
25
|
unarchive(sessionId: string): Promise<void>;
|
|
23
26
|
detach(sessionId: string, workspaceId: string): Promise<void>;
|
|
24
|
-
|
|
27
|
+
/** 挂账本。`when: 'if-unassigned'` 只给失败回滚用:会话已经被用户重新归到别的工作区、或原工作区
|
|
28
|
+
* 已经不在了,就**安静跳过**——回滚不许把用户的重新归属覆盖掉,也不许在 registry 里造幽灵归属。 */
|
|
29
|
+
attach(sessionId: string, workspaceId: string, when?: 'if-unassigned'): Promise<void>;
|
|
25
30
|
/** 归档是 registry **全局**的,与工作区账目无关 ⇒ 只收 `sessionId`(未分组的会话同样只有这一条归档路)。 */
|
|
26
31
|
archive(sessionId: string): Promise<void>;
|
|
27
32
|
}
|
|
@@ -8,7 +8,7 @@ export declare const SESSION_DELETE_API_PREFIX = "/dsh-session-delete-api";
|
|
|
8
8
|
export declare const OFFICIAL_SESSION_DELETE_API_PREFIX = "/api/dsh-session-delete-api";
|
|
9
9
|
/** 请求体线上形状:`none` 无字段、`query` 查询串,其余是 JSON 字段组(字段清单见 {@link BODY_GROUPS})。
|
|
10
10
|
* Node 半按它决定是否预读 JSON;浏览器半只投影「有 JSON 字段即 POST」的配对事实。 */
|
|
11
|
-
export type RouteBody = 'none' | 'query' | 'config' | 'entry' | 'apply' | 'sessionId';
|
|
11
|
+
export type RouteBody = 'none' | 'query' | 'config' | 'entry' | 'apply' | 'sessionId' | 'search' | 'searchPreview';
|
|
12
12
|
/** 段名表(相对前缀)。每项 `{ path, method, body }`:方法与请求体也是线上形状(ADR-0003),
|
|
13
13
|
* 路由记录与浏览器半都从这里派生,不写第二份字面量。写动作统一走一段 `/apply`;
|
|
14
14
|
* 单条是长度为 1 的批量,仓里不留第二条执行路径。各段语义见下。 */
|
|
@@ -104,6 +104,30 @@ export declare const ROUTES: {
|
|
|
104
104
|
readonly method: "GET";
|
|
105
105
|
readonly body: "none";
|
|
106
106
|
};
|
|
107
|
+
/** 纯读:**回收站档**按查询串扫一页(标题命中首页给全 + 正文命中一页 + 续扫游标)。不建索引、不缓存、零写入。 */
|
|
108
|
+
readonly search: {
|
|
109
|
+
readonly path: "/search";
|
|
110
|
+
readonly method: "POST";
|
|
111
|
+
readonly body: "search";
|
|
112
|
+
};
|
|
113
|
+
/** 纯读:**归档档**按查询串扫一页;语料是「归档集 ∩ 会话」,读面是宿主 `readSession`,**不碰回收站清册**。 */
|
|
114
|
+
readonly archiveSearch: {
|
|
115
|
+
readonly path: "/archive-search";
|
|
116
|
+
readonly method: "POST";
|
|
117
|
+
readonly body: "search";
|
|
118
|
+
};
|
|
119
|
+
/** 纯读:回收站档一条正文命中的窗口(前邻 / 命中 / 后邻)与本会话命中序号 / 相邻命中下标。 */
|
|
120
|
+
readonly searchPreview: {
|
|
121
|
+
readonly path: "/search-preview";
|
|
122
|
+
readonly method: "POST";
|
|
123
|
+
readonly body: "searchPreview";
|
|
124
|
+
};
|
|
125
|
+
/** 纯读:归档档一条正文命中的窗口;每次重校验归档集成员(ADR-0061 寻址边界)。 */
|
|
126
|
+
readonly archiveSearchPreview: {
|
|
127
|
+
readonly path: "/archive-search-preview";
|
|
128
|
+
readonly method: "POST";
|
|
129
|
+
readonly body: "searchPreview";
|
|
130
|
+
};
|
|
107
131
|
};
|
|
108
132
|
/** 段名 → 那一段的路径;类型闸与运行期键集比对都跟着这张表走。 */
|
|
109
133
|
export type RouteName = (typeof ROUTES)[keyof typeof ROUTES]['path'];
|
|
@@ -195,6 +219,8 @@ export type TrashRowWire = TrashEntryWire & {
|
|
|
195
219
|
strandedBytes?: number;
|
|
196
220
|
/** 移入回收站时记下的工作区**已经不在账本里**(宿主的「删除工作区」只删注册、保留日志)。 */
|
|
197
221
|
workspaceMissing?: boolean;
|
|
222
|
+
/** 该行项目在**宿主工作区显示顺序**里的位置(0 起);缺席 = 这个项目当前不在账本里(不拿 0 冒充)。 */
|
|
223
|
+
projectRank?: number;
|
|
198
224
|
};
|
|
199
225
|
/** 单条详情里的一条附件读数;`attachmentId` 是附件库 sha256 键,也是附件段的寻址依据。 */
|
|
200
226
|
export interface TrashDetailAttachmentWire {
|
|
@@ -256,7 +282,7 @@ export interface TrashDetailPromptWire {
|
|
|
256
282
|
}
|
|
257
283
|
/** 会话详情公共基座(回收站与归档两档共用):块按页给,计数按整条日志。 */
|
|
258
284
|
export interface SessionDetailWire {
|
|
259
|
-
/** 日志 header 里的原串(**无损**,比从 `projectKey` 反推那一路强;组头怎么念项目名见 `src/client/trash-view.ts` 的 `projectLabel`,那是另一回事)。 */
|
|
285
|
+
/** 日志 header 里的原串(**无损**,比从 `projectKey` 反推那一路强;组头怎么念项目名见 `src/client/widgets/trash-view.ts` 的 `projectLabel`,那是另一回事)。 */
|
|
260
286
|
cwd: string;
|
|
261
287
|
createdAt: number;
|
|
262
288
|
lastActivity: number;
|
|
@@ -306,6 +332,8 @@ export interface ArchiveRowWire {
|
|
|
306
332
|
sizeBytes?: number;
|
|
307
333
|
/** `origin:'subagent'`;行上要带「子代理」标签。 */
|
|
308
334
|
subagent: boolean;
|
|
335
|
+
/** 该行项目在**宿主工作区显示顺序**里的位置(0 起);缺席 = 这个项目当前不在账本里(不拿 0 冒充)。 */
|
|
336
|
+
projectRank?: number;
|
|
309
337
|
}
|
|
310
338
|
/** 归档清单:`sessionQuery` 缺席时显式 `{available:false}`(语料不可见),不是空列表也不是 `io`;
|
|
311
339
|
* `totalBytes` 只加已知大小,`missingSizeCount > 0` 时副标题要说 N 条大小缺席。 */
|
|
@@ -346,6 +374,87 @@ export interface ArchiveDetailWire extends SessionDetailWire {
|
|
|
346
374
|
/** **全部**孩子里已知 `sizeBytes` 的合计;没有任何已知读数时缺席(不拿 0 冒充)。 */
|
|
347
375
|
subagentsSizeBytes?: number;
|
|
348
376
|
}
|
|
377
|
+
/** 检索范围名单:**唯一一处**(游标编码 / 解码与客户端选段都投影它,不各写一份字面量)。 */
|
|
378
|
+
export declare const SEARCH_SCOPES: readonly ["trash", "archive"];
|
|
379
|
+
/** 检索词上限(按**码点**):请求面与检索框共用这一格,粘贴长文在输入框就收住,不把服务端 400 当提示。 */
|
|
380
|
+
export declare const SEARCH_QUERY_MAX = 100;
|
|
381
|
+
/** 检索范围:两档的语料与读面各不相同(回收站读清册目录日志、归档读宿主 `readSession`)。 */
|
|
382
|
+
export type SearchScopeWire = (typeof SEARCH_SCOPES)[number];
|
|
383
|
+
/** 一处命中 = 一条**命中消息**(同一消息里出现多次算一处)。标题命中**没有消息位置**,不产生预览。 */
|
|
384
|
+
interface SearchHitBaseWire {
|
|
385
|
+
/** 实际命中的行:回收站条目 id / 归档 sessionId。 */
|
|
386
|
+
readonly rowId: string;
|
|
387
|
+
/** 结果行归属:回收站 = 组根条目 id(子会话命中并到父行);归档 = sessionId。 */
|
|
388
|
+
readonly groupId: string;
|
|
389
|
+
/** 已含省略号的摘录,长度有界。 */
|
|
390
|
+
readonly snippet: string;
|
|
391
|
+
/** 摘录内的高亮区间,坐标是 **`snippet` 的 UTF-16 码元下标**(客户端可直接 slice)。 */
|
|
392
|
+
readonly ranges: readonly (readonly [number, number])[];
|
|
393
|
+
/** 命中来自组根的孩子(回收站档才有意义)。 */
|
|
394
|
+
readonly isChild: boolean;
|
|
395
|
+
}
|
|
396
|
+
/** 判别式联合:标题命中没有 `role/time/messageIndex`(用哨兵值冒充会误导读取方——类型层就不给)。 */
|
|
397
|
+
export type SearchHitWire = SearchHitBaseWire & ({
|
|
398
|
+
readonly kind: 'title';
|
|
399
|
+
} | {
|
|
400
|
+
readonly kind: 'body';
|
|
401
|
+
readonly role: 'user' | 'assistant';
|
|
402
|
+
readonly time: number;
|
|
403
|
+
readonly messageIndex: number;
|
|
404
|
+
});
|
|
405
|
+
/** 命中的两个分支名字(消费者用这两个别名收窄,不在调用点各写一遍 `Extract<...>`)。 */
|
|
406
|
+
export type SearchTitleHitWire = Extract<SearchHitWire, {
|
|
407
|
+
readonly kind: 'title';
|
|
408
|
+
}>;
|
|
409
|
+
export type SearchBodyHitWire = Extract<SearchHitWire, {
|
|
410
|
+
readonly kind: 'body';
|
|
411
|
+
}>;
|
|
412
|
+
/** 被跳过的会话:单位是**会话**(与 `scanned/total` 同单位),读不出或超上限——不算命中、也不算失败。 */
|
|
413
|
+
export interface SearchSkippedWire {
|
|
414
|
+
/** 实际没参与检索的那条会话(回收站 = 条目 id,含孩子自己的条目 id;归档 = sessionId)。 */
|
|
415
|
+
readonly rowId: string;
|
|
416
|
+
/** 结果行归属(回收站 = 组根条目 id;归档 = sessionId):界面按它说「哪个结果行没被搜全」。 */
|
|
417
|
+
readonly groupId: string;
|
|
418
|
+
readonly reason: 'unreadable' | 'too-large';
|
|
419
|
+
}
|
|
420
|
+
/** 检索的一页:标题命中只出首页;正文命中按游标续扫——游标为空即扫完。
|
|
421
|
+
* 两个区各自带**判别式收窄后的数组类型**:标题区不可能出现正文命中,消费者不必在调用点再筛一遍。 */
|
|
422
|
+
export interface SearchPageWire {
|
|
423
|
+
readonly titleHits: readonly SearchTitleHitWire[];
|
|
424
|
+
readonly bodyHits: readonly SearchBodyHitWire[];
|
|
425
|
+
readonly cursor: string | null;
|
|
426
|
+
readonly scanned: number;
|
|
427
|
+
readonly total: number;
|
|
428
|
+
readonly skipped: readonly SearchSkippedWire[];
|
|
429
|
+
/** 游标锚点行在分页期间消失(被恢复 / 删除):只证明这一场扫描被迫收尾,不是「搜完了」。
|
|
430
|
+
* 客户端保留已得结果并给出重新检索入口,不把尾部会话静默当作没有(ADR-0074 决定 4)。 */
|
|
431
|
+
readonly incomplete?: true;
|
|
432
|
+
}
|
|
433
|
+
/** 预览里的一条消息:命中消息是开窗文本,邻句是截断文本。 */
|
|
434
|
+
export interface SearchPreviewMessageWire {
|
|
435
|
+
readonly messageIndex: number;
|
|
436
|
+
readonly role: 'user' | 'assistant';
|
|
437
|
+
readonly time: number;
|
|
438
|
+
readonly text: string;
|
|
439
|
+
readonly truncated: boolean;
|
|
440
|
+
readonly isHit: boolean;
|
|
441
|
+
/** 只有命中消息非空,坐标是 `text` 的 UTF-16 码元下标。 */
|
|
442
|
+
readonly ranges: readonly (readonly [number, number])[];
|
|
443
|
+
}
|
|
444
|
+
/** 命中预览的值:至多三条(前邻 / 命中 / 后邻),命中为首尾时少一格。
|
|
445
|
+
*
|
|
446
|
+
* `hitIndex/hitCount` 是**整条会话**内的命中序(不是搜索结果页已加载的那几条);相邻命中用
|
|
447
|
+
* `previous/nextHitMessageIndex` 指路——导航是会话域事实,客户端不必把「搜索结果页加载了几条」掺进来。
|
|
448
|
+
* 没有上一处 / 下一处时该格是 `null`(不是缺席:缺席与没有是两件事)。 */
|
|
449
|
+
export interface SearchPreviewWire {
|
|
450
|
+
readonly groupId: string;
|
|
451
|
+
readonly rowId: string;
|
|
452
|
+
readonly hitIndex: number;
|
|
453
|
+
readonly hitCount: number;
|
|
454
|
+
readonly previousHitMessageIndex: number | null;
|
|
455
|
+
readonly nextHitMessageIndex: number | null;
|
|
456
|
+
readonly messages: readonly SearchPreviewMessageWire[];
|
|
457
|
+
}
|
|
349
458
|
/** 一次永久删除顺带或孤儿附件清理的附件读数(字段清单住 `ATTACHMENT_CLEANUP_SCHEMA`)。
|
|
350
459
|
* `skipped` 有值 = 部分或整体没清,`removed` 仍可能 > 0;`failed` 是逐文件真出错的那几件。 */
|
|
351
460
|
export type AttachmentCleanupWire = Infer<typeof ATTACHMENT_CLEANUP_SCHEMA>;
|
|
@@ -408,12 +517,21 @@ export declare const PARAMS: {
|
|
|
408
517
|
readonly attachmentBytes: "bytes";
|
|
409
518
|
readonly attachmentWidth: "width";
|
|
410
519
|
readonly attachmentHeight: "height";
|
|
520
|
+
/** 检索的查询串(浏览器半去抖后原样发来;Node 半归一后匹配)。 */
|
|
521
|
+
readonly query: "query";
|
|
522
|
+
/** 正文命中续扫游标:上一页回的 `cursor` 原样带回;缺省 = 首页。 */
|
|
523
|
+
readonly cursor: "cursor";
|
|
524
|
+
/** 命中预览的寻址键:命中所在行(回收站条目 id / 归档 sessionId)。 */
|
|
525
|
+
readonly rowId: "rowId";
|
|
526
|
+
/** 命中预览要取的那条消息在会话抽取序里的下标。 */
|
|
527
|
+
readonly messageIndex: "messageIndex";
|
|
411
528
|
};
|
|
412
529
|
/** 请求体字段的种类 → 解析后的类型:新增种类只改这张表的键,解析手与 {@link ParsedBody} 会一起编译错。 */
|
|
413
530
|
type ParsedByKind = {
|
|
414
531
|
requiredString: string;
|
|
415
532
|
optionalString: string | undefined;
|
|
416
533
|
optionalCursor: number | undefined;
|
|
534
|
+
requiredNumber: number;
|
|
417
535
|
action: ApplyAction;
|
|
418
536
|
idArray: string[];
|
|
419
537
|
};
|
|
@@ -439,11 +557,25 @@ export declare const BODY_GROUPS: {
|
|
|
439
557
|
readonly before: "optionalCursor";
|
|
440
558
|
readonly rootSessionId: "optionalString";
|
|
441
559
|
};
|
|
560
|
+
/** 检索一页:查询串必填、游标缺省 = 首页;语料由**段名**(`/search` vs `/archive-search`)决定,不在请求体里再带一次范围。 */
|
|
561
|
+
readonly search: {
|
|
562
|
+
readonly query: "requiredString";
|
|
563
|
+
readonly cursor: "optionalString";
|
|
564
|
+
};
|
|
565
|
+
/** 命中预览:寻址键 + 消息下标;语料同样由段名决定。 */
|
|
566
|
+
readonly searchPreview: {
|
|
567
|
+
readonly query: "requiredString";
|
|
568
|
+
readonly rowId: "requiredString";
|
|
569
|
+
readonly messageIndex: "requiredNumber";
|
|
570
|
+
};
|
|
442
571
|
};
|
|
443
572
|
/** 描述 → 解析后的字段类型:描述与本型同源 ⇒ 解析手交回的字段,用法在类型层就对得上。 */
|
|
444
573
|
export type ParsedBody<G extends BodyGroup> = {
|
|
445
574
|
[K in keyof G]: ParsedByKind[G[K]];
|
|
446
575
|
};
|
|
576
|
+
/** 检索两段的请求字段(通用解析手交回的类型面):语义校验住 `src/api/search.ts`,字段形状只住这里。 */
|
|
577
|
+
export type SearchBodyFields = ParsedBody<typeof BODY_GROUPS.search>;
|
|
578
|
+
export type SearchPreviewBodyFields = ParsedBody<typeof BODY_GROUPS.searchPreview>;
|
|
447
579
|
/** 失败信封的线上形状:`code` 判别、`message` 上屏、`details` 可选结构化附带物(对齐官方 `rpcErrorSchema`)。
|
|
448
580
|
* 没有附带物时整件缺席,不写空表。 */
|
|
449
581
|
export interface RemoteFailure {
|
|
@@ -503,6 +635,6 @@ export declare function isApplyOutcomeOf<A extends ApplyAction>(value: unknown,
|
|
|
503
635
|
/** 写入进度(`WriteProgressWire`)的判形:遥测快照不走 `/apply` 值那套 schema DSL,
|
|
504
636
|
* 与 `list`/`ping` 同法手写——只校判别键与渲染必读的那几格。 */
|
|
505
637
|
export declare function isWriteProgressWire(value: unknown): value is WriteProgressWire;
|
|
506
|
-
/** 段名表逐段的 JSON 值判形(`src/client/remote.ts` 的成功支只在这里问一次)。 */
|
|
638
|
+
/** 段名表逐段的 JSON 值判形(`src/client/core/remote.ts` 的成功支只在这里问一次)。 */
|
|
507
639
|
export declare const WIRE_VALUE_GUARDS: Record<JsonRouteName, WireValueGuard>;
|
|
508
640
|
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 一条记录 `content[]` 里「正文文字」的**唯一抽取**:详情块与检索语料共用这一份,判据写两遍就是两份会漂移的抄本。
|
|
3
|
+
*
|
|
4
|
+
* 只认文本段:图片、文件、工具调用段都不是正文文字(附件另有自己的读数面)。过线 JSON 的数组元素可能是 `null`
|
|
5
|
+
* (镜像说 `ContentPart`,运行时未必),所以取到的东西仍要判类型与 `text` 成员才用。
|
|
6
|
+
*
|
|
7
|
+
* 多段之间用换行连接再 `trim()`:宿主一条消息里的连续文本段本来就是一段话被切开,用换行连能保住段落边界,
|
|
8
|
+
* 又不会像拼接那样把两句话粘成一个词。
|
|
9
|
+
*/
|
|
10
|
+
export declare function contentText(content: unknown): string;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 组语义的唯一家(ADR-0001):回收站里「这一组有谁」以及「哪些行在清单里露面」。接得住孩子的只有组根——自己不记 `parentEntryId` 的那一行。
|
|
3
3
|
* 父行不在、或父行自己也是孩子时,孩子必须自己占一行,否则它的字节会被头部合计数两遍,而它自己既看不见也清不掉。
|
|
4
|
-
*
|
|
4
|
+
* 这些函数都是纯函数:`indexGroups` / `visibleGroups` / `rootIdOf` 吃一份快照,`groupOf` / `claimOf` 吃索引;
|
|
5
|
+
* 收缩视图的持有机制住 `src/trash/shrinking-view.ts` 的 `createShrinkingView`。
|
|
5
6
|
*/
|
|
6
7
|
import type { TrashEntry } from './entry.js';
|
|
7
8
|
/** 一条露面的组根,连同它接住的孩子(顺序与清册一致)。 */
|
|
@@ -10,6 +11,14 @@ export interface TrashGroupView {
|
|
|
10
11
|
/** 跟着这条根进来的孩子(`parentEntryId` 指向根的 id)。根自己不在里面。 */
|
|
11
12
|
readonly kids: readonly TrashEntry[];
|
|
12
13
|
}
|
|
14
|
+
/** 一份快照的索引:按 id 认行、按父 id 认孩子。批量面一次建好、多次判组,不再逐次 `filter` 整份快照。 */
|
|
15
|
+
export interface GroupIndex {
|
|
16
|
+
readonly byId: ReadonlyMap<string, TrashEntry>;
|
|
17
|
+
readonly kidsByParent: ReadonlyMap<string, readonly TrashEntry[]>;
|
|
18
|
+
}
|
|
19
|
+
/** 把一份快照索引一次:`byId` 第一行胜(清册是存储域主键 KV,id 应唯一;首行胜与前实现的后者胜只在这类
|
|
20
|
+
* 不可达输入上不同,`visibleGroups` / `rootIdOf` 共用这一份)。 */
|
|
21
|
+
export declare function indexGroups(rows: readonly TrashEntry[]): GroupIndex;
|
|
13
22
|
/**
|
|
14
23
|
* 清单露面的一行 = 组根,按清册原序。孩子折进根那一行(宿主的客户端本来就把 `origin:"subagent"` 的行整排藏了 ⇒ 单列会冒出一堆点不到的行)。
|
|
15
24
|
* 折不进去的那两种孩子(父行不在 / 父行自己也是孩子)**自己站出来占一行**——`visibleGroups` 与 `groupOf` 共用这条判据。
|
|
@@ -19,13 +28,16 @@ export declare function visibleGroups(rows: readonly TrashEntry[]): TrashGroupVi
|
|
|
19
28
|
* 一条 id 所属的整组。三种形状,三个答案:**组根** ⇒ 它自己 + 它接住的孩子(UI 点的是父那一行,删除/恢复/彻底删除都按整组走);
|
|
20
29
|
* **孩子** ⇒ **只回它自己**(清单不单独列它,只有手工/降级路径会点到这里);**清册里没有这一条 id,但还有孩子指向它** ⇒ 那一批孩子;
|
|
21
30
|
* 都没有 ⇒ 空数组,调用方据此报 `trash-empty` / 判"已被同批前一条带走"。
|
|
31
|
+
*
|
|
32
|
+
* `present` 只用于收缩视图:当前视图里已经不在的行不算进组(默认全在)。
|
|
22
33
|
*/
|
|
23
|
-
export declare function groupOf(
|
|
34
|
+
export declare function groupOf(index: GroupIndex, id: string, present?: (id: string) => boolean): TrashEntry[];
|
|
24
35
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
36
|
+
* 一条 id 的**可见组根**:与 {@link visibleGroups} 的折叠判据同一份——能折进根的孩子归它,折不进去的
|
|
37
|
+
* (父不在 / 父自己也是孩子)自己就是根。检索把子会话的命中并到组根、预览报归属都用这一份,
|
|
38
|
+
* 不复刻一遍「沿 parentEntryId 一直上溯」的第二种判据。id 不在快照里回它自己。
|
|
27
39
|
*/
|
|
28
|
-
export declare function
|
|
40
|
+
export declare function rootIdOf(rows: readonly TrashEntry[], id: string): string;
|
|
29
41
|
/** 一条 id 在「原始快照 vs 当前视图」里的三态。判别联合:**只有 `fresh` 带当前这一组**——carried / absent 没有可交的组,调用方无从误用。 */
|
|
30
42
|
export type GroupClaim = {
|
|
31
43
|
readonly verdict: 'fresh';
|
|
@@ -43,4 +55,4 @@ export type IdGroupClaim = {
|
|
|
43
55
|
* 「这条是被**同批前一条**带走的,还是整批开始前就没有,还是仍在?」幂等语义只属于 `carried`:后来者本来就不在清册里(用户点了条幽灵 id、
|
|
44
56
|
* 或对账刚摘掉它)必须照样响亮报 `trash-empty`。**所以判据是快照的原始形状,不是当前形状**:原始快照里认得出而当前视图已空 ⇒ 同批带走的。
|
|
45
57
|
*/
|
|
46
|
-
export declare function claimOf(
|
|
58
|
+
export declare function claimOf(index: GroupIndex, id: string, present: (id: string) => boolean): GroupClaim;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** 日志记录的最小面:回收站的 `SessionRecord` 与归档的 `CorpusEvent` 都是这个形状。 */
|
|
2
|
+
export interface SessionRecordLike {
|
|
3
|
+
readonly type?: string;
|
|
4
|
+
readonly time?: number;
|
|
5
|
+
readonly data?: unknown;
|
|
6
|
+
}
|
|
7
|
+
/** 一条参与检索的消息。`index` 是「第几条可检索消息」,从 0 起;预览按它寻址。 */
|
|
8
|
+
export interface CorpusMessage {
|
|
9
|
+
readonly index: number;
|
|
10
|
+
readonly role: 'user' | 'assistant';
|
|
11
|
+
readonly time: number;
|
|
12
|
+
readonly text: string;
|
|
13
|
+
}
|
|
14
|
+
/** 单条会话的抽取预算:正文总字符数上限,防「压缩包小、解出来巨大」。 */
|
|
15
|
+
export interface ExtractBudget {
|
|
16
|
+
readonly maxChars: number;
|
|
17
|
+
}
|
|
18
|
+
/** 抽取结果:要么正常结束并报条数与字符数,要么超预算整条作废。 */
|
|
19
|
+
export type ExtractResult = {
|
|
20
|
+
readonly ok: true;
|
|
21
|
+
readonly count: number;
|
|
22
|
+
readonly chars: number;
|
|
23
|
+
} | {
|
|
24
|
+
readonly ok: false;
|
|
25
|
+
readonly kind: 'too-large';
|
|
26
|
+
};
|
|
27
|
+
export interface MessageExtractor {
|
|
28
|
+
/** 喂一条日志记录。回调停机后不再产生消息,但**继续计字符**:预算是整条会话的属性,不是一页的属性。 */
|
|
29
|
+
feed(record: SessionRecordLike): void;
|
|
30
|
+
/** 已经确定超出预算(调用方可据此提前停止解码后续记录,省掉白读)。 */
|
|
31
|
+
isExhausted(): boolean;
|
|
32
|
+
/** 收尾:可重复调用,回同一个结果。 */
|
|
33
|
+
finish(): ExtractResult;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 造一个抽取器。`onMessage` 返回 `false` 表示调用方「够了、不再收命中」(例如本页命中数已满)——
|
|
37
|
+
* 它只停**收集**,不停**计账**:后续消息继续计字符,`finish()` 仍按整条会话报 `ok / too-large`。
|
|
38
|
+
* 这样预算闸属于会话、分页属于传输,任何页都不会出现「先给了命中、后来又说没搜完」的半截结论。
|
|
39
|
+
*/
|
|
40
|
+
export declare function createMessageExtractor(onMessage: (message: CorpusMessage) => void | false, budget: ExtractBudget): MessageExtractor;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 检索的**纯函数层**:查询归一、区间查找、开窗/摘要、游标编解码。零 I/O、不碰 deps——编排在 `src/verbs/search.ts`。
|
|
3
|
+
*
|
|
4
|
+
* 三条口径都不是口味:
|
|
5
|
+
* ① **字面子串,不解析正则**:用户输入 `.*` 就该找那两个字面字符,不能变成模式(也不用正则去实现,省得转义漏一处就成漏洞)。
|
|
6
|
+
* ② **不重叠**:`aaaa` 里找 `aa` 是两处,不是三处——重叠区段会让高亮切出互相吞并的片段,且「N 处」失去基数。
|
|
7
|
+
* ③ **开窗按码点、高亮区间按 UTF-16 码元**:切窗不能切坏代理对(emoji),而 `ranges` 的坐标要在**切好的那一串**上重算,
|
|
8
|
+
* 两套坐标混用就是高亮错位——所以这里从不搬运下标,只重算。
|
|
9
|
+
*/
|
|
10
|
+
/** 检索范围唯一名单住 `shared/wire.ts`;纯函数层只投影,不另写一份字面量。 */
|
|
11
|
+
import { type SearchScopeWire } from '../shared/wire.js';
|
|
12
|
+
/** 一处命中:`[start, end)`,UTF-16 码元下标(JS 字符串下标,客户端可直接 `slice`)。 */
|
|
13
|
+
export type SearchRange = readonly [start: number, end: number];
|
|
14
|
+
/** 一段被切过的文本:内容、在**这段内容上**重算的高亮区间、以及「有没有被切」。 */
|
|
15
|
+
export interface SlicedText {
|
|
16
|
+
readonly text: string;
|
|
17
|
+
readonly ranges: readonly SearchRange[];
|
|
18
|
+
readonly truncated: boolean;
|
|
19
|
+
}
|
|
20
|
+
/** 归一查询串:`trim` 后小写。空串(含全空白)回 `undefined`——那不是一次检索。 */
|
|
21
|
+
export declare function normalizeQuery(raw: string): string | undefined;
|
|
22
|
+
/** 在 `text` 里找 `query` 的全部出现(大小写不敏感、字面、不重叠),按出现序。 */
|
|
23
|
+
export declare function findRanges(text: string, query: string): SearchRange[];
|
|
24
|
+
/** 以命为中心开窗,两端**不补省略号**(命中消息用:省略号会被误读成正文本身有截断标记)。 */
|
|
25
|
+
export declare function windowOf(text: string, query: string, before: number, after: number): SlicedText;
|
|
26
|
+
/** 摘要:与 {@link windowOf} 同一刀,但两端被切时补 `…`;区间先在正文核心上算出再按前缀长度平移,不误高亮合成省略号。 */
|
|
27
|
+
export declare function snippetOf(text: string, query: string, before: number, after: number): SlicedText;
|
|
28
|
+
/** 检索游标:记「扫到哪条会话的第几条消息」,不记语料下标(语料增删不会让整页错位)。 */
|
|
29
|
+
export interface SearchCursor {
|
|
30
|
+
readonly v: 1;
|
|
31
|
+
readonly scope: SearchScopeWire;
|
|
32
|
+
readonly queryHash: string;
|
|
33
|
+
/** 实际命中的行 id(回收站条目 id / 归档 sessionId)——不是组根 id。 */
|
|
34
|
+
readonly rowId: string;
|
|
35
|
+
/** 该行内已经扫到的消息下标;下一页从它的下一条继续。-1 = 从这条会话的第一条消息开始。 */
|
|
36
|
+
readonly messageIndex: number;
|
|
37
|
+
}
|
|
38
|
+
/** 查询串的稳定短哈希(FNV-1a 32 位):游标只认同一次查询,防跨查询串页。 */
|
|
39
|
+
export declare function hashQuery(query: string): string;
|
|
40
|
+
/** 游标 → 不透明串(base64url 的 JSON)。 */
|
|
41
|
+
export declare function encodeCursor(cursor: SearchCursor): string;
|
|
42
|
+
/** 不透明串 → 游标;畸形、版本不符、字段不合法一律 `undefined`,绝不抛(请求面据此回 400)。 */
|
|
43
|
+
export declare function decodeCursor(raw: string): SearchCursor | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 收缩视图的持有机制的唯一家:entry 适配(restore 的同批已带走集)与清册作用域(purge)都接这一份。判据不搬:三态读 `groups.ts` 的
|
|
3
|
-
* `claimOf
|
|
3
|
+
* `claimOf`、按组取行读 `groupOf`——这里只有本批的索引与存活状态,无 I/O。
|
|
4
4
|
*/
|
|
5
5
|
import type { TrashEntry } from './entry.js';
|
|
6
6
|
import { type GroupClaim, type IdGroupClaim } from './groups.js';
|
|
@@ -12,9 +12,11 @@ export interface ShrinkingView {
|
|
|
12
12
|
* **执行视图不动**:`take` / `takeRows` 只在动作成功后调,失败/挂起的组下一轮(第二波)重新认领得到。
|
|
13
13
|
* 每条连自己的 id 交回(`IdGroupClaim`),调用方不靠名单下标配对。 */
|
|
14
14
|
claimAll(ids: readonly string[]): readonly IdGroupClaim[];
|
|
15
|
-
/**
|
|
15
|
+
/** 整批开始时的这一组(不看执行期的收缩):挂起条目的附件扫描要吃“未来会删的整组”,不是预测或执行后剩下的行。 */
|
|
16
|
+
originalGroup(id: string): readonly TrashEntry[];
|
|
17
|
+
/** 收掉一条 id 当前所属的整组。 */
|
|
16
18
|
take(id: string): void;
|
|
17
|
-
/**
|
|
19
|
+
/** 只摘掉这次实际执行成功的条目行(不二次按当前组扩大收缩范围,免得把未删子一并抹掉)。 */
|
|
18
20
|
takeRows(rowIds: readonly string[]): void;
|
|
19
21
|
/** 把当前视图收缩到空。 */
|
|
20
22
|
takeAll(): void;
|
|
@@ -24,6 +26,6 @@ export interface ShrinkingView {
|
|
|
24
26
|
/**
|
|
25
27
|
* 开工时把整批的原始快照捕下来(三态判据的「整批开始前的样子」),当前视图从它出发、按组收缩。
|
|
26
28
|
* 调用纪律:`take` / `takeAll` 都在动作**成功之后**才调——清完才收缩,失败时视图不动、下一次重试还能看见这一组。
|
|
27
|
-
*
|
|
29
|
+
* 什么时候收缩、把实例放在哪里仍归调用方:本函数只记录哪些行仍在,不改清册。
|
|
28
30
|
*/
|
|
29
31
|
export declare function createShrinkingView(rows: readonly TrashEntry[]): ShrinkingView;
|