@kangyishuai/dsh-session-delete 0.3.0 → 0.4.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 +9 -8
- package/README.zh-CN.md +11 -8
- package/lib/capability.js +10 -4
- package/lib/client.js +196 -1
- package/lib/operations.js +68 -0
- package/lib/service.js +27 -0
- package/locale/en.json +10 -1
- package/locale/zh.json +10 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
Unofficial plugin for [DeepSeek Harness (DSH)](https://github.com/deepseek-ai). Not affiliated with DeepSeek.
|
|
8
8
|
|
|
9
|
-
> **Status: v0.
|
|
9
|
+
> **Status: v0.4, early.** Verified on DSH 0.2.1-rc.5 with `pnpm smoke:session-delete` (24 end-to-end assertions) plus a manual pass in the desktop GUI. Treat it as young software and keep backups of anything you cannot lose.
|
|
10
10
|
|
|
11
11
|
## What it does
|
|
12
12
|
|
|
@@ -89,15 +89,17 @@ Archive is a bookmark, not a deletion: DSH adds the session id to the workspace'
|
|
|
89
89
|
|
|
90
90
|
v0.1 declares no `engines.dsh` range. Instead there are three layers of defense:
|
|
91
91
|
|
|
92
|
-
| Layer
|
|
93
|
-
|
|
|
94
|
-
| L1 version gate
|
|
95
|
-
| L2 startup self-check
|
|
96
|
-
|
|
92
|
+
| Layer | When it runs | What it does | What you see |
|
|
93
|
+
| --------------------- | -------------------- | ------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
94
|
+
| L1 version gate | install / activation | `engines.dsh` version range. **Not declared in v0.1**, so this layer is currently inactive. | nothing |
|
|
95
|
+
| L2 startup self-check | plugin activation | Probes every host capability it depends on and grades them api / internal / unknown. | **Degraded mode**: a host without `workspaceRegistry` (for example the headless composition) still allows deletion — the archive gate and workspace bookkeeping steps are skipped and reported in the receipt. Only a missing persistence seam puts the plugin in read-only mode. |
|
|
96
|
+
|
|
97
|
+
**Read-only mode**: plan, audit and trash listing keep working; delete, restore and purge are disabled. |
|
|
98
|
+
| L3 per-operation refusal | every operation | Each operation re-checks its own prerequisites; unknown always refuses. | A structured error code plus a human-readable reason, and no half-deleted state. |
|
|
97
99
|
|
|
98
100
|
| Plugin | Verified on DSH | Notes |
|
|
99
101
|
| ------ | ------------------------ | ------------------------------------------------------------------------------------------- |
|
|
100
|
-
| 0.
|
|
102
|
+
| 0.4.0 | **0.2.1-rc.5** (desktop) | `pnpm smoke:session-delete`: 24 assertions green; manual GUI pass on the same host version. |
|
|
101
103
|
|
|
102
104
|
After a DSH upgrade: restart, then open the plugin status (settings → plugins). If it reports read-only mode, the host API changed — upgrade the plugin or report the version pair; don't force it.
|
|
103
105
|
|
|
@@ -117,7 +119,6 @@ After a DSH upgrade: restart, then open the plugin status (settings → plugins)
|
|
|
117
119
|
The following are planned and not implemented yet:
|
|
118
120
|
|
|
119
121
|
- batch deletion (multi-select);
|
|
120
|
-
- an undo toast after a delete.
|
|
121
122
|
|
|
122
123
|
## License
|
|
123
124
|
|
package/README.zh-CN.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
非官方 [DeepSeek Harness (DSH)](https://github.com/deepseek-ai) 插件,与 DeepSeek 无关。
|
|
8
8
|
|
|
9
|
-
> **状态:v0.
|
|
9
|
+
> **状态:v0.4,早期可用。** 已在 DSH 0.2.1-rc.5 上用 `pnpm smoke:session-delete`(24 项端到端断言)加一轮桌面版人工验收。仍是年轻软件,重要数据请自行备份。
|
|
10
10
|
|
|
11
11
|
## 做什么
|
|
12
12
|
|
|
@@ -89,15 +89,19 @@ dsh plugin --profile desktop add /tmp/kangyishuai-dsh-session-delete-*.tgz
|
|
|
89
89
|
|
|
90
90
|
v0.1 没有声明 `engines.dsh` 版本范围,改用三层防线:
|
|
91
91
|
|
|
92
|
-
| 层
|
|
93
|
-
|
|
|
94
|
-
| L1 版本闸门
|
|
95
|
-
| L2 启动自检
|
|
96
|
-
|
|
92
|
+
| 层 | 触发时机 | 做什么 | 你会看到什么 |
|
|
93
|
+
| ----------- | ----------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
94
|
+
| L1 版本闸门 | 安装 / 激活 | `engines.dsh` 版本范围。**v0.1 尚未声明**,这一层目前不生效。 | 无 |
|
|
95
|
+
| L2 启动自检 | 插件激活时 | 探测所有依赖的宿主能力,分成 api / internal / unknown 三档。 | 进入**降级模式**:宿主没有 `workspaceRegistry`(例如 headless 组合)时仍然允许删除——归档闸门与工作区记账步骤会被跳过并写进回执。只有持久化本体缺失时才进入只读模式。 |
|
|
96
|
+
|
|
97
|
+
**只读模式**:plan、审计、回收站列表还能用;删除、恢复、彻底删除被禁用。 |
|
|
98
|
+
| L3 执行期拒绝 | 每次操作 | 每个操作自己再校验前置能力,unknown 一律拒绝。 | 结构化错误码 + 人类可读原因,磁盘上不会出现删了一半的状态。 |
|
|
97
99
|
|
|
98
100
|
| 插件版本 | 已验证的 DSH 版本 | 说明 |
|
|
99
101
|
| -------- | ------------------------ | -------------------------------------------------------------------------------- |
|
|
100
|
-
| 0.
|
|
102
|
+
| 0.4.0 | **0.2.1-rc.5**(桌面版) | `pnpm smoke:session-delete` 24 项断言全绿,并在同一版本桌面版做过人工 GUI 验收。 |
|
|
103
|
+
|
|
104
|
+
目前只在 **macOS** 上验证过。Windows 相关路径(`session.lock` 的 EBUSY/EPERM 重试、宿主在那儿用的命名信号量)代码里有,但**还没实测**。
|
|
101
105
|
|
|
102
106
|
DSH 升级之后:重启,然后看插件的状态条(设置 → 插件)。如果显示只读模式,说明宿主 API 变了——升级插件,或者把两个版本号一起报上来,别硬用。
|
|
103
107
|
|
|
@@ -117,7 +121,6 @@ DSH 升级之后:重启,然后看插件的状态条(设置 → 插件)
|
|
|
117
121
|
下面这些是计划,尚未实现:
|
|
118
122
|
|
|
119
123
|
- 批量删除(多选);
|
|
120
|
-
- 删除后的撤销 toast。
|
|
121
124
|
|
|
122
125
|
## License
|
|
123
126
|
|
package/lib/capability.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// 宿主能力探测。整个插件对宿主内部契约的依赖只在这里出现一次,
|
|
3
3
|
// 这样 DSH 升级后需要改的地方永远只有一个文件(见 docs/adr/0005)。
|
|
4
4
|
|
|
5
|
-
/** @typedef {"api" | "internal" | "unknown"} CapabilityTier */
|
|
5
|
+
/** @typedef {"api" | "internal" | "minimal" | "unknown"} CapabilityTier */
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @typedef {object} Capabilities
|
|
@@ -33,10 +33,12 @@ function callable(target, key) {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* 探测本插件依赖的全部宿主能力,并按四档给出结论:
|
|
37
37
|
* - api:官方文档里有的一等公民能力齐全;
|
|
38
38
|
* - internal:核心可用,但有依赖社区契约的部件(会降级执行并告警);
|
|
39
|
-
* -
|
|
39
|
+
* - minimal:缺少 workspaceRegistry(如 headless 组合),删除仍可做,
|
|
40
|
+
* 归档闸门/工作区记账等步骤跳过并在回执里标记;
|
|
41
|
+
* - unknown:持久化本体缺失,破坏性操作必须拒绝。
|
|
40
42
|
*
|
|
41
43
|
* @param {any} ctx host 上下文。
|
|
42
44
|
* @returns {Capabilities}
|
|
@@ -75,7 +77,10 @@ export function probeCapabilities(ctx) {
|
|
|
75
77
|
|
|
76
78
|
/** @type {CapabilityTier} */
|
|
77
79
|
let tier = "api";
|
|
78
|
-
|
|
80
|
+
// 删除本身只需要持久化读取 + 文件系统;工作区/归档只是闸门与记账,
|
|
81
|
+
// 缺失时降级为 minimal(跳过对应步骤并报告),不应整体禁用。
|
|
82
|
+
const essential = ["persistence.stat"];
|
|
83
|
+
const workspaceGate = ["workspace.archive", "workspace.unarchive"];
|
|
79
84
|
const convenient = [
|
|
80
85
|
"persistence.list",
|
|
81
86
|
"persistence.locate",
|
|
@@ -86,6 +91,7 @@ export function probeCapabilities(ctx) {
|
|
|
86
91
|
"event.session-activity",
|
|
87
92
|
];
|
|
88
93
|
if (essential.some((k) => !table[k])) tier = "unknown";
|
|
94
|
+
else if (workspaceGate.some((k) => !table[k])) tier = "minimal";
|
|
89
95
|
else if (convenient.some((k) => !table[k])) tier = "internal";
|
|
90
96
|
|
|
91
97
|
return {
|
package/lib/client.js
CHANGED
|
@@ -70,6 +70,15 @@ window.__ModuleLoader__.load({
|
|
|
70
70
|
"panel.tabAudit": "审计",
|
|
71
71
|
"panel.tabHealth": "体检",
|
|
72
72
|
"panel.tabReceipts": "回执",
|
|
73
|
+
"panel.tabBatch": "批量",
|
|
74
|
+
"batch.empty": "没有可删除的会话。",
|
|
75
|
+
"batch.selectAll": "全选",
|
|
76
|
+
"batch.clear": "清空",
|
|
77
|
+
"batch.delete": "批量删除({n})",
|
|
78
|
+
"batch.confirm": "确认删除 {n} 个?各自进回收站",
|
|
79
|
+
"batch.running": "正在删除…",
|
|
80
|
+
"batch.done": "完成:{ok}/{total} 成功",
|
|
81
|
+
"batch.live": "运行中",
|
|
73
82
|
"receipts.empty": "还没有操作回执。",
|
|
74
83
|
"receipts.restored": "已移回原位置",
|
|
75
84
|
"health.loading": "正在检查…",
|
|
@@ -124,6 +133,15 @@ window.__ModuleLoader__.load({
|
|
|
124
133
|
"panel.tabAudit": "Audit",
|
|
125
134
|
"panel.tabHealth": "Health",
|
|
126
135
|
"panel.tabReceipts": "Receipts",
|
|
136
|
+
"panel.tabBatch": "Batch",
|
|
137
|
+
"batch.empty": "No sessions to delete.",
|
|
138
|
+
"batch.selectAll": "Select all",
|
|
139
|
+
"batch.clear": "Clear",
|
|
140
|
+
"batch.delete": "Delete {n} selected",
|
|
141
|
+
"batch.confirm": "Delete {n} session(s)? Each goes to trash",
|
|
142
|
+
"batch.running": "Deleting…",
|
|
143
|
+
"batch.done": "Done: {ok}/{total} succeeded",
|
|
144
|
+
"batch.live": "live",
|
|
127
145
|
"receipts.empty": "No operation receipts yet.",
|
|
128
146
|
"receipts.restored": "restored",
|
|
129
147
|
"health.loading": "Checking…",
|
|
@@ -658,6 +676,30 @@ window.__ModuleLoader__.load({
|
|
|
658
676
|
var receiptsState = React.useState(null);
|
|
659
677
|
var receipts = receiptsState[0];
|
|
660
678
|
var setReceipts = receiptsState[1];
|
|
679
|
+
var batchListState = React.useState(null);
|
|
680
|
+
var batchList = batchListState[0];
|
|
681
|
+
var setBatchList = batchListState[1];
|
|
682
|
+
var batchSelectedState = React.useState({});
|
|
683
|
+
var batchSelected = batchSelectedState[0];
|
|
684
|
+
var setBatchSelected = batchSelectedState[1];
|
|
685
|
+
var batchBusyState = React.useState(false);
|
|
686
|
+
var batchBusy = batchBusyState[0];
|
|
687
|
+
var setBatchBusy = batchBusyState[1];
|
|
688
|
+
var batchMsgState = React.useState("");
|
|
689
|
+
var batchMsg = batchMsgState[0];
|
|
690
|
+
var setBatchMsg = batchMsgState[1];
|
|
691
|
+
|
|
692
|
+
const loadBatch = React.useCallback(() => {
|
|
693
|
+
props
|
|
694
|
+
.call("listSessions")
|
|
695
|
+
.then((/** @type {any} */ value) => {
|
|
696
|
+
setBatchList(value && value.sessions ? value.sessions : []);
|
|
697
|
+
})
|
|
698
|
+
.catch((/** @type {any} */ reason) => {
|
|
699
|
+
setBatchList([]);
|
|
700
|
+
setBatchMsg(errorText(reason));
|
|
701
|
+
});
|
|
702
|
+
}, []);
|
|
661
703
|
|
|
662
704
|
const loadReceipts = React.useCallback(() => {
|
|
663
705
|
props
|
|
@@ -843,10 +885,163 @@ window.__ModuleLoader__.load({
|
|
|
843
885
|
},
|
|
844
886
|
props.t("panel.tabReceipts"),
|
|
845
887
|
),
|
|
888
|
+
h(
|
|
889
|
+
Btn,
|
|
890
|
+
{
|
|
891
|
+
onClick: () => {
|
|
892
|
+
setTab("batch");
|
|
893
|
+
loadBatch();
|
|
894
|
+
},
|
|
895
|
+
},
|
|
896
|
+
props.t("panel.tabBatch"),
|
|
897
|
+
),
|
|
846
898
|
),
|
|
847
899
|
);
|
|
848
900
|
|
|
849
|
-
if (tab === "
|
|
901
|
+
if (tab === "batch") {
|
|
902
|
+
if (!batchList) {
|
|
903
|
+
content.push(
|
|
904
|
+
h(
|
|
905
|
+
"div",
|
|
906
|
+
{ key: "batch-loading", style: { color: T.dim, padding: "8px 0" } },
|
|
907
|
+
props.t("health.loading"),
|
|
908
|
+
),
|
|
909
|
+
);
|
|
910
|
+
} else if (batchList.length === 0) {
|
|
911
|
+
content.push(
|
|
912
|
+
h(
|
|
913
|
+
"div",
|
|
914
|
+
{ key: "batch-empty", style: { color: T.dim, padding: "8px 0" } },
|
|
915
|
+
props.t("batch.empty"),
|
|
916
|
+
),
|
|
917
|
+
);
|
|
918
|
+
} else {
|
|
919
|
+
const selectedIds = Object.keys(batchSelected).filter(
|
|
920
|
+
(id) => /** @type {any} */ (batchSelected)[id],
|
|
921
|
+
);
|
|
922
|
+
content.push(
|
|
923
|
+
h(
|
|
924
|
+
"div",
|
|
925
|
+
{
|
|
926
|
+
key: "batch-actions",
|
|
927
|
+
style: { display: "flex", gap: "8px", alignItems: "center", marginBottom: "8px" },
|
|
928
|
+
},
|
|
929
|
+
h(
|
|
930
|
+
Btn,
|
|
931
|
+
{
|
|
932
|
+
onClick: () => {
|
|
933
|
+
/** @type {Record<string, boolean>} */
|
|
934
|
+
const all = {};
|
|
935
|
+
for (const item of /** @type {any[]} */ (batchList)) all[item.id] = true;
|
|
936
|
+
setBatchSelected(all);
|
|
937
|
+
},
|
|
938
|
+
},
|
|
939
|
+
props.t("batch.selectAll"),
|
|
940
|
+
),
|
|
941
|
+
h(Btn, { onClick: () => setBatchSelected({}) }, props.t("batch.clear")),
|
|
942
|
+
confirmPurge === "__batch__"
|
|
943
|
+
? h(
|
|
944
|
+
Btn,
|
|
945
|
+
{
|
|
946
|
+
danger: true,
|
|
947
|
+
disabled: batchBusy || selectedIds.length === 0,
|
|
948
|
+
onClick: () => {
|
|
949
|
+
setBatchBusy(true);
|
|
950
|
+
setBatchMsg("");
|
|
951
|
+
props
|
|
952
|
+
.call("trashMany", { sessionIds: selectedIds })
|
|
953
|
+
.then((/** @type {any} */ result) => {
|
|
954
|
+
setBatchBusy(false);
|
|
955
|
+
setConfirmPurge(null);
|
|
956
|
+
setBatchMsg(
|
|
957
|
+
props.t("batch.done", { ok: result.succeeded, total: result.total }),
|
|
958
|
+
);
|
|
959
|
+
for (const item of result.results) {
|
|
960
|
+
if (item.ok) props.onPurged?.(item.id);
|
|
961
|
+
}
|
|
962
|
+
setBatchSelected({});
|
|
963
|
+
loadBatch();
|
|
964
|
+
refresh();
|
|
965
|
+
props.bump?.();
|
|
966
|
+
})
|
|
967
|
+
.catch((/** @type {any} */ reason) => {
|
|
968
|
+
setBatchBusy(false);
|
|
969
|
+
setBatchMsg(errorText(reason));
|
|
970
|
+
});
|
|
971
|
+
},
|
|
972
|
+
},
|
|
973
|
+
props.t("batch.confirm", { n: selectedIds.length }),
|
|
974
|
+
)
|
|
975
|
+
: h(
|
|
976
|
+
Btn,
|
|
977
|
+
{
|
|
978
|
+
danger: true,
|
|
979
|
+
disabled: batchBusy || selectedIds.length === 0,
|
|
980
|
+
onClick: () => setConfirmPurge("__batch__"),
|
|
981
|
+
},
|
|
982
|
+
batchBusy
|
|
983
|
+
? props.t("batch.running")
|
|
984
|
+
: props.t("batch.delete", { n: selectedIds.length }),
|
|
985
|
+
),
|
|
986
|
+
),
|
|
987
|
+
);
|
|
988
|
+
batchList.forEach((/** @type {any} */ item, /** @type {any} */ index) => {
|
|
989
|
+
const checked = Boolean(/** @type {any} */ (batchSelected)[item.id]);
|
|
990
|
+
content.push(
|
|
991
|
+
h(
|
|
992
|
+
"label",
|
|
993
|
+
{
|
|
994
|
+
key: "batch-" + index,
|
|
995
|
+
style: {
|
|
996
|
+
display: "flex",
|
|
997
|
+
alignItems: "baseline",
|
|
998
|
+
gap: "8px",
|
|
999
|
+
borderTop: "1px solid " + T.border,
|
|
1000
|
+
padding: "6px 0",
|
|
1001
|
+
fontSize: "12px",
|
|
1002
|
+
cursor: "pointer",
|
|
1003
|
+
},
|
|
1004
|
+
},
|
|
1005
|
+
h("input", {
|
|
1006
|
+
type: "checkbox",
|
|
1007
|
+
checked: checked,
|
|
1008
|
+
disabled: batchBusy,
|
|
1009
|
+
onChange: () =>
|
|
1010
|
+
setBatchSelected((/** @type {any} */ current) => ({
|
|
1011
|
+
...current,
|
|
1012
|
+
[item.id]: !checked,
|
|
1013
|
+
})),
|
|
1014
|
+
style: { marginTop: "2px" },
|
|
1015
|
+
}),
|
|
1016
|
+
h(
|
|
1017
|
+
"span",
|
|
1018
|
+
{
|
|
1019
|
+
title: item.id,
|
|
1020
|
+
style: {
|
|
1021
|
+
flex: 1,
|
|
1022
|
+
minWidth: 0,
|
|
1023
|
+
overflow: "hidden",
|
|
1024
|
+
textOverflow: "ellipsis",
|
|
1025
|
+
whiteSpace: "nowrap",
|
|
1026
|
+
},
|
|
1027
|
+
},
|
|
1028
|
+
item.title || item.id,
|
|
1029
|
+
),
|
|
1030
|
+
item.live ? h("span", { style: { color: T.danger } }, props.t("batch.live")) : null,
|
|
1031
|
+
),
|
|
1032
|
+
);
|
|
1033
|
+
});
|
|
1034
|
+
}
|
|
1035
|
+
if (batchMsg) {
|
|
1036
|
+
content.push(
|
|
1037
|
+
h(
|
|
1038
|
+
"div",
|
|
1039
|
+
{ key: "batch-msg", style: { color: T.dim, marginTop: "8px", fontSize: "12px" } },
|
|
1040
|
+
batchMsg,
|
|
1041
|
+
),
|
|
1042
|
+
);
|
|
1043
|
+
}
|
|
1044
|
+
} else if (tab === "receipts") {
|
|
850
1045
|
if (!receipts || receipts.length === 0) {
|
|
851
1046
|
content.push(
|
|
852
1047
|
h(
|
package/lib/operations.js
CHANGED
|
@@ -880,6 +880,72 @@ export function createOperations({ ctx, dataRoot, logger }) {
|
|
|
880
880
|
};
|
|
881
881
|
}
|
|
882
882
|
|
|
883
|
+
/** 列出会话(批量删除用):只读,字段刻意保持最小。 */
|
|
884
|
+
async function listSessions() {
|
|
885
|
+
if (!caps.checks["persistence.list"]) {
|
|
886
|
+
throw failure("session-delete/unsupported-host", "当前宿主没有 sessionPersistence.list");
|
|
887
|
+
}
|
|
888
|
+
const list = (await caps.services.persistence.list()) ?? [];
|
|
889
|
+
const out = list.map((/** @type {any} */ entry) => {
|
|
890
|
+
const id = String(entry?.id ?? entry?.header?.id ?? "");
|
|
891
|
+
return {
|
|
892
|
+
id,
|
|
893
|
+
title: typeof entry?.header?.title === "string" ? entry.header.title : null,
|
|
894
|
+
cwd: typeof entry?.header?.cwd === "string" ? entry.header.cwd : null,
|
|
895
|
+
live: caps.services.sessions?.get?.(id) !== undefined,
|
|
896
|
+
};
|
|
897
|
+
});
|
|
898
|
+
out.sort((/** @type {any} */ a, /** @type {any} */ b) =>
|
|
899
|
+
String(b.title ?? b.id).localeCompare(String(a.title ?? a.id)),
|
|
900
|
+
);
|
|
901
|
+
return { sessions: out.filter((/** @type {any} */ item) => item.id.length > 0) };
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
/**
|
|
905
|
+
* 批量删除(顺序执行,逐条返回结果;单条失败不影响其它)。
|
|
906
|
+
* @param {{ sessionIds?: string[], cascade?: boolean, operator?: string }} request
|
|
907
|
+
*/
|
|
908
|
+
async function trashMany(request = {}) {
|
|
909
|
+
const ids = Array.isArray(request.sessionIds) ? request.sessionIds : [];
|
|
910
|
+
if (ids.length === 0) throw failure("session-delete/invalid-request", "没有选择任何会话");
|
|
911
|
+
if (ids.length > 50) throw failure("session-delete/invalid-request", "一次最多 50 个会话");
|
|
912
|
+
/** @type {{ id: string, ok: boolean, entryId?: string, receiptId?: string, code?: string, error?: string }[]} */
|
|
913
|
+
const results = [];
|
|
914
|
+
for (const id of ids) {
|
|
915
|
+
try {
|
|
916
|
+
const result = await trash(id, {
|
|
917
|
+
cascade: request.cascade === true,
|
|
918
|
+
operator: request.operator ?? "ui",
|
|
919
|
+
});
|
|
920
|
+
results.push({ id, ok: true, entryId: result.entryId, receiptId: result.receiptId });
|
|
921
|
+
} catch (error) {
|
|
922
|
+
const raw = /** @type {any} */ (error);
|
|
923
|
+
results.push({
|
|
924
|
+
id,
|
|
925
|
+
ok: false,
|
|
926
|
+
code: typeof raw?.code === "string" ? raw.code : "error",
|
|
927
|
+
error: messageOf(error),
|
|
928
|
+
});
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
const okCount = results.filter((item) => item.ok).length;
|
|
932
|
+
const receiptId = await writeReceipt(dataRoot, {
|
|
933
|
+
action: "trash-many",
|
|
934
|
+
at: new Date().toISOString(),
|
|
935
|
+
requested: ids.length,
|
|
936
|
+
succeeded: okCount,
|
|
937
|
+
failed: results.length - okCount,
|
|
938
|
+
results,
|
|
939
|
+
});
|
|
940
|
+
return {
|
|
941
|
+
ok: okCount === results.length,
|
|
942
|
+
total: results.length,
|
|
943
|
+
succeeded: okCount,
|
|
944
|
+
results,
|
|
945
|
+
receiptId,
|
|
946
|
+
};
|
|
947
|
+
}
|
|
948
|
+
|
|
883
949
|
/** @param {number} [limit] */
|
|
884
950
|
async function receipts(limit = 50) {
|
|
885
951
|
return { entries: await listReceipts(dataRoot, limit) };
|
|
@@ -888,6 +954,8 @@ export function createOperations({ ctx, dataRoot, logger }) {
|
|
|
888
954
|
return {
|
|
889
955
|
caps,
|
|
890
956
|
health,
|
|
957
|
+
listSessions,
|
|
958
|
+
trashMany,
|
|
891
959
|
receipts,
|
|
892
960
|
scanHealth,
|
|
893
961
|
cleanHealth,
|
package/lib/service.js
CHANGED
|
@@ -255,6 +255,31 @@ export class SessionDeleteService extends TypertRemoteService {
|
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
+
/** 批量删除的候选列表(只读)。 */
|
|
259
|
+
async listSessions() {
|
|
260
|
+
try {
|
|
261
|
+
return await this.ops.listSessions();
|
|
262
|
+
} catch (error) {
|
|
263
|
+
rethrow(error);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* 批量删除。
|
|
269
|
+
* @param {{ sessionIds?: string[], cascade?: boolean }} request
|
|
270
|
+
*/
|
|
271
|
+
async trashMany(request) {
|
|
272
|
+
try {
|
|
273
|
+
return await this.ops.trashMany({
|
|
274
|
+
sessionIds: request?.sessionIds,
|
|
275
|
+
cascade: request?.cascade === true,
|
|
276
|
+
operator: "ui",
|
|
277
|
+
});
|
|
278
|
+
} catch (error) {
|
|
279
|
+
rethrow(error);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
258
283
|
/**
|
|
259
284
|
* 最近的操作回执。
|
|
260
285
|
* @param {{ limit?: number }} [request]
|
|
@@ -308,6 +333,8 @@ declareRemote(SessionDeleteService, "list");
|
|
|
308
333
|
declareRemote(SessionDeleteService, "restore");
|
|
309
334
|
declareRemote(SessionDeleteService, "purge");
|
|
310
335
|
declareRemote(SessionDeleteService, "audit");
|
|
336
|
+
declareRemote(SessionDeleteService, "listSessions");
|
|
337
|
+
declareRemote(SessionDeleteService, "trashMany");
|
|
311
338
|
declareRemote(SessionDeleteService, "receipts");
|
|
312
339
|
declareRemote(SessionDeleteService, "healthScan");
|
|
313
340
|
declareRemote(SessionDeleteService, "cleanHealth");
|
package/locale/en.json
CHANGED
|
@@ -48,6 +48,15 @@
|
|
|
48
48
|
"confirm.cascade": "Also delete these {n} child session(s) (each goes to trash separately)",
|
|
49
49
|
"health.agentTool": "Agent tool session_delete: {state}",
|
|
50
50
|
"health.agentToolOn": "registered",
|
|
51
|
-
"health.agentToolOff": "not registered (host has no tools runtime)"
|
|
51
|
+
"health.agentToolOff": "not registered (host has no tools runtime)",
|
|
52
|
+
"panel.tabBatch": "Batch",
|
|
53
|
+
"batch.empty": "No sessions to delete.",
|
|
54
|
+
"batch.selectAll": "Select all",
|
|
55
|
+
"batch.clear": "Clear",
|
|
56
|
+
"batch.delete": "Delete {n} selected",
|
|
57
|
+
"batch.confirm": "Delete {n} session(s)? Each goes to trash",
|
|
58
|
+
"batch.running": "Deleting…",
|
|
59
|
+
"batch.done": "Done: {ok}/{total} succeeded",
|
|
60
|
+
"batch.live": "live"
|
|
52
61
|
}
|
|
53
62
|
}
|
package/locale/zh.json
CHANGED
|
@@ -48,6 +48,15 @@
|
|
|
48
48
|
"confirm.cascade": "同时删除这 {n} 个子会话(各自进入回收站,需分别恢复)",
|
|
49
49
|
"health.agentTool": "模型工具 session_delete:{state}",
|
|
50
50
|
"health.agentToolOn": "已注册",
|
|
51
|
-
"health.agentToolOff": "未注册(宿主未提供 tools 运行时)"
|
|
51
|
+
"health.agentToolOff": "未注册(宿主未提供 tools 运行时)",
|
|
52
|
+
"panel.tabBatch": "批量",
|
|
53
|
+
"batch.empty": "没有可删除的会话。",
|
|
54
|
+
"batch.selectAll": "全选",
|
|
55
|
+
"batch.clear": "清空",
|
|
56
|
+
"batch.delete": "批量删除({n})",
|
|
57
|
+
"batch.confirm": "确认删除 {n} 个?各自进回收站",
|
|
58
|
+
"batch.running": "正在删除…",
|
|
59
|
+
"batch.done": "完成:{ok}/{total} 成功",
|
|
60
|
+
"batch.live": "运行中"
|
|
52
61
|
}
|
|
53
62
|
}
|