dsh-efm-integration 0.4.8 → 0.5.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 +36 -11
- package/README.zh.md +29 -8
- package/client.js +118 -29
- package/cordis.patch.yml +5 -0
- package/lib/archive-cleaner/core.d.ts +86 -15
- package/lib/archive-cleaner/core.d.ts.map +1 -1
- package/lib/archive-cleaner/core.js +262 -62
- package/lib/archive-cleaner/core.js.map +1 -1
- package/lib/archive-cleaner/index.d.ts +14 -1
- package/lib/archive-cleaner/index.d.ts.map +1 -1
- package/lib/archive-cleaner/index.js +341 -40
- package/lib/archive-cleaner/index.js.map +1 -1
- package/lib/archive-cleaner/paths.d.ts +26 -0
- package/lib/archive-cleaner/paths.d.ts.map +1 -0
- package/lib/archive-cleaner/paths.js +67 -0
- package/lib/archive-cleaner/paths.js.map +1 -0
- package/lib/archive-cleaner/pending.d.ts +23 -0
- package/lib/archive-cleaner/pending.d.ts.map +1 -0
- package/lib/archive-cleaner/pending.js +88 -0
- package/lib/archive-cleaner/pending.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ upstream DeepSeek Harness checkout.
|
|
|
16
16
|
| `skill-guard` | Denies configured tools until their required skills have been loaded. |
|
|
17
17
|
| `command-guard` | Refuses long foreground sleeps and filesystem-root scans before execution. |
|
|
18
18
|
| `bundled-skill` | Ships the `powershell-usage` skill and exposes it without a user-directory copy. |
|
|
19
|
-
| `archive-cleaner` | Adds a sidebar page
|
|
19
|
+
| `archive-cleaner` | Adds a sidebar page for safe or forced deletion of archived roots and their subagent descendants; live Sessions finish after a restart. |
|
|
20
20
|
| `lsp-servers` | Owns the DSH LSP stack and adds a sidebar page to enable or disable language servers without restarting. |
|
|
21
21
|
|
|
22
22
|
All host plugins are mounted by `cordis.patch.yml`. `client.js` provides the web
|
|
@@ -235,22 +235,47 @@ explicit `timeoutMs`, or a narrower path.
|
|
|
235
235
|
|
|
236
236
|
## Clear archived Sessions
|
|
237
237
|
|
|
238
|
-
The web sidebar includes **清空全部存档会话**. It
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
238
|
+
The web sidebar includes **清空全部存档会话**. It shows each archived root as a
|
|
239
|
+
group with its subagent descendants. Ordinary forks are independent Sessions and
|
|
240
|
+
are never included in a root's deletion group.
|
|
241
|
+
|
|
242
|
+
Two actions are available:
|
|
243
|
+
|
|
244
|
+
- **永久删除可删除的会话** uses
|
|
245
|
+
`x-dsh-efm-integration-confirm: DELETE_ALL_ARCHIVED`. It deletes only groups
|
|
246
|
+
with no live Agent and no running turn, subagent, job, or schedule. One busy
|
|
247
|
+
group does not block the other groups.
|
|
248
|
+
- **强制删除全部存档会话** uses
|
|
249
|
+
`x-dsh-efm-integration-confirm: FORCE_DELETE_ARCHIVED`. It first requests a stop
|
|
250
|
+
for every non-blocked group. Groups that become quiescent are deleted
|
|
251
|
+
immediately. Groups that still have a live Agent are queued in
|
|
252
|
+
`$DSH_HOME/plugins/dsh-efm-integration/pending-deletions.json` and finalized
|
|
253
|
+
when DSH next starts, after the Agent and its write handle are released.
|
|
242
254
|
|
|
243
255
|
Deletion removes:
|
|
244
256
|
|
|
245
|
-
- JSONL Session log directories for archived roots and their
|
|
257
|
+
- JSONL Session log directories for archived roots and their subagent
|
|
258
|
+
descendants;
|
|
246
259
|
- the Sessions' Workspace accounting;
|
|
247
260
|
- their entries in the global archive set.
|
|
248
261
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
per-Session `session-*` directory
|
|
252
|
-
|
|
253
|
-
the
|
|
262
|
+
Both actions require DSH authentication and a same-origin POST; force does not
|
|
263
|
+
require the owner principal. Both still refuse non-JSONL persistence, an unknown
|
|
264
|
+
sessions root, or a path outside the per-Session `session-*` directory
|
|
265
|
+
convention; force does not bypass those checks. Workspace source files and shared attachments are preserved.
|
|
266
|
+
After a safe deletion the page reloads; a forced deletion that queued live groups
|
|
267
|
+
shows the restart requirement instead.
|
|
268
|
+
|
|
269
|
+
The route defaults to `dshHomePath('sessions')` and accepts plugin config when
|
|
270
|
+
the JSONL backend uses another root:
|
|
271
|
+
|
|
272
|
+
```yaml
|
|
273
|
+
- id: dsh-efm-integration-archive-cleaner
|
|
274
|
+
name: 'dsh-efm-integration/archive-cleaner'
|
|
275
|
+
config:
|
|
276
|
+
sessionsRoot: 'D:/dsh-home/sessions'
|
|
277
|
+
forceStopTimeoutMs: 5000
|
|
278
|
+
```
|
|
254
279
|
|
|
255
280
|
## Language servers (LSP)
|
|
256
281
|
|
package/README.zh.md
CHANGED
|
@@ -15,7 +15,7 @@ DeepSeek Harness 代码。
|
|
|
15
15
|
| `skill-guard` | 在所需技能加载完成之前拒绝被配置的工具。 |
|
|
16
16
|
| `command-guard` | 在执行前拒绝长时间前台 sleep 与文件系统根目录扫描。 |
|
|
17
17
|
| `bundled-skill` | 随包提供 `powershell-usage` 技能,无需复制到用户目录。 |
|
|
18
|
-
| `archive-cleaner` |
|
|
18
|
+
| `archive-cleaner` | 增加侧栏页面,可安全或强制删除归档根及其 subagent 子会话;live 会话在重启后完成删除。 |
|
|
19
19
|
| `lsp-servers` | 接管 DSH 的 LSP 栈,并提供无需重启即可启停语言服务器的侧栏页面。 |
|
|
20
20
|
|
|
21
21
|
所有宿主插件都由 `cordis.patch.yml` 挂载,`client.js` 提供 Web 侧栏页面。包内的
|
|
@@ -203,19 +203,40 @@ node scripts/repair-reasoning-replay.mjs "$env:USERPROFILE\.dsh\sessions"
|
|
|
203
203
|
|
|
204
204
|
## 清空归档会话
|
|
205
205
|
|
|
206
|
-
Web 侧栏包含
|
|
207
|
-
|
|
208
|
-
|
|
206
|
+
Web 侧栏包含 **清空全部存档会话**。它按归档根分组显示会话及其 subagent 子会话。普通 fork
|
|
207
|
+
是独立会话,不会被算进某个根的删除组。
|
|
208
|
+
|
|
209
|
+
页面提供两个操作:
|
|
210
|
+
|
|
211
|
+
- **永久删除可删除的会话**:请求头为
|
|
212
|
+
`x-dsh-efm-integration-confirm: DELETE_ALL_ARCHIVED`。只删除没有 live Agent、也没有
|
|
213
|
+
运行中的 turn、subagent、后台任务或计划的组。一个忙碌组不会阻塞其他组。
|
|
214
|
+
- **强制删除全部存档会话**:请求头为
|
|
215
|
+
`x-dsh-efm-integration-confirm: FORCE_DELETE_ARCHIVED`。先对所有未阻止的组请求停止;
|
|
216
|
+
静默下来的组立即删除。仍有 live Agent 的组会排入
|
|
217
|
+
`$DSH_HOME/plugins/dsh-efm-integration/pending-deletions.json`,在下次启动 DSH、Agent
|
|
218
|
+
及其写句柄释放后完成删除。
|
|
209
219
|
|
|
210
220
|
删除内容包括:
|
|
211
221
|
|
|
212
|
-
-
|
|
222
|
+
- 归档根及其 subagent 子会话的 JSONL 会话日志目录;
|
|
213
223
|
- 这些会话的 Workspace 记账;
|
|
214
224
|
- 它们在全局归档集合中的条目。
|
|
215
225
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
226
|
+
两种操作都需要 DSH 认证和同源 POST;强制删除不要求 owner principal。两种操作都会拒绝非
|
|
227
|
+
JSONL 持久化、未知会话根,或不符合每会话 `session-*` 目录约定的路径;强制删除不会绕过这些
|
|
228
|
+
检查。Workspace 源码文件与共享附件会被保留。安全删除成功后页面会重新
|
|
229
|
+
加载;如果强制删除有排队中的 live 会话,页面会显示需要重启 DSH。
|
|
230
|
+
|
|
231
|
+
路由默认使用 `dshHomePath('sessions')`;JSONL 后端使用其他根目录时可通过插件配置覆盖:
|
|
232
|
+
|
|
233
|
+
```yaml
|
|
234
|
+
- id: dsh-efm-integration-archive-cleaner
|
|
235
|
+
name: 'dsh-efm-integration/archive-cleaner'
|
|
236
|
+
config:
|
|
237
|
+
sessionsRoot: 'D:/dsh-home/sessions'
|
|
238
|
+
forceStopTimeoutMs: 5000
|
|
239
|
+
```
|
|
219
240
|
|
|
220
241
|
## 语言服务器(LSP)
|
|
221
242
|
|
package/client.js
CHANGED
|
@@ -59,51 +59,96 @@ window.__ModuleLoader__.load({
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
function ArchiveCleanerPage() {
|
|
62
|
-
const
|
|
62
|
+
const empty = {
|
|
63
|
+
loading: true, count: 0, archivedCount: 0, blocked: [], groups: [], queuedRoots: [],
|
|
64
|
+
restartRequired: false, sessionsRoot: '', pendingError: '', error: '', notice: '',
|
|
65
|
+
}
|
|
66
|
+
const [state, setState] = useState(empty)
|
|
63
67
|
const [busy, setBusy] = useState(false)
|
|
64
68
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
fetch(ARCHIVE_ENDPOINT, { signal: controller.signal, headers: { accept: 'application/json' } })
|
|
69
|
+
const load = (signal) => {
|
|
70
|
+
fetch(ARCHIVE_ENDPOINT, { signal, headers: { accept: 'application/json' } })
|
|
68
71
|
.then(async response => {
|
|
69
72
|
const body = await response.json()
|
|
70
73
|
if (!response.ok) throw new Error(body.error || '无法读取存档会话')
|
|
71
|
-
setState({
|
|
74
|
+
setState({
|
|
75
|
+
loading: false,
|
|
76
|
+
count: body.count || 0,
|
|
77
|
+
archivedCount: body.archivedCount || 0,
|
|
78
|
+
blocked: body.blocked || [],
|
|
79
|
+
groups: body.groups || [],
|
|
80
|
+
queuedRoots: body.queuedRoots || [],
|
|
81
|
+
restartRequired: body.restartRequired === true,
|
|
82
|
+
sessionsRoot: body.sessionsRoot || '',
|
|
83
|
+
pendingError: body.pendingError || '',
|
|
84
|
+
error: '',
|
|
85
|
+
notice: '',
|
|
86
|
+
})
|
|
72
87
|
})
|
|
73
88
|
.catch(error => {
|
|
74
|
-
if (
|
|
89
|
+
if (signal?.aborted) return
|
|
75
90
|
setState(current => ({ ...current, loading: false, error: String(error.message || error) }))
|
|
76
91
|
})
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
const controller = new AbortController()
|
|
96
|
+
load(controller.signal)
|
|
77
97
|
return () => controller.abort()
|
|
78
98
|
}, [])
|
|
79
99
|
|
|
80
|
-
const
|
|
81
|
-
if (state.count === 0) return
|
|
82
|
-
const confirmed = window.confirm(
|
|
83
|
-
|
|
84
|
-
|
|
100
|
+
const submit = async (mode) => {
|
|
101
|
+
if (state.count === 0 && state.archivedCount === 0) return
|
|
102
|
+
const confirmed = window.confirm(mode === 'force'
|
|
103
|
+
? `将强制停止所有相关会话的 turn、子 Agent、后台任务和计划,并删除 ${state.archivedCount} 个归档根及其子会话。\n\n仍有 live Agent 的会话会在下次启动 DSH 时完成删除;共享附件和工作区文件会保留。确定继续吗?`
|
|
104
|
+
: `将永久删除可删除的 ${state.archivedCount} 个归档根及其子会话,删除后无法恢复。\n\n共享附件和工作区文件会保留。确定继续吗?`)
|
|
85
105
|
if (!confirmed) return
|
|
106
|
+
if (mode === 'force') {
|
|
107
|
+
const typed = window.prompt('输入“强制删除”以确认强制删除:')
|
|
108
|
+
if (typed !== '强制删除') return
|
|
109
|
+
}
|
|
86
110
|
setBusy(true)
|
|
87
|
-
setState(current => ({ ...current, error: '' }))
|
|
111
|
+
setState(current => ({ ...current, error: '', notice: '' }))
|
|
88
112
|
try {
|
|
89
113
|
const response = await fetch(ARCHIVE_ENDPOINT, {
|
|
90
114
|
method: 'POST',
|
|
91
115
|
headers: {
|
|
92
116
|
accept: 'application/json',
|
|
93
117
|
'content-type': 'application/json',
|
|
94
|
-
'x-dsh-efm-integration-confirm': 'DELETE_ALL_ARCHIVED',
|
|
118
|
+
'x-dsh-efm-integration-confirm': mode === 'force' ? 'FORCE_DELETE_ARCHIVED' : 'DELETE_ALL_ARCHIVED',
|
|
95
119
|
},
|
|
96
120
|
body: '{}',
|
|
97
121
|
})
|
|
98
122
|
const body = await response.json()
|
|
99
|
-
if (!response.ok
|
|
123
|
+
if (!response.ok) {
|
|
100
124
|
throw new Error(
|
|
101
125
|
body.error
|
|
102
|
-
|| body.blocked?.
|
|
126
|
+
|| body.blocked?.join('\n')
|
|
103
127
|
|| body.failures?.map(failure => `${failure.sessionId}: ${failure.message}`).join('\n')
|
|
104
128
|
|| '删除失败',
|
|
105
129
|
)
|
|
106
130
|
}
|
|
131
|
+
if (body.restartRequired) {
|
|
132
|
+
setBusy(false)
|
|
133
|
+
setState(current => ({
|
|
134
|
+
...current,
|
|
135
|
+
notice: `已停止相关会话;重启 DSH 后将删除排队中的 ${body.queuedRoots?.length || body.queuedSessionIds?.length || 0} 个归档根。`,
|
|
136
|
+
blocked: body.blocked || [],
|
|
137
|
+
restartRequired: true,
|
|
138
|
+
}))
|
|
139
|
+
return
|
|
140
|
+
}
|
|
141
|
+
if ((body.failures && body.failures.length > 0) || (body.blocked && body.blocked.length > 0)) {
|
|
142
|
+
setBusy(false)
|
|
143
|
+
setState(current => ({
|
|
144
|
+
...current,
|
|
145
|
+
error: [
|
|
146
|
+
...(body.blocked || []),
|
|
147
|
+
...(body.failures || []).map(failure => `${failure.sessionId}: ${failure.message}`),
|
|
148
|
+
].join('\n'),
|
|
149
|
+
}))
|
|
150
|
+
return
|
|
151
|
+
}
|
|
107
152
|
window.location.reload()
|
|
108
153
|
} catch (error) {
|
|
109
154
|
setBusy(false)
|
|
@@ -111,29 +156,73 @@ window.__ModuleLoader__.load({
|
|
|
111
156
|
}
|
|
112
157
|
}
|
|
113
158
|
|
|
159
|
+
const ready = state.groups.filter(group => group.status === 'ready').length
|
|
160
|
+
const queued = state.groups.filter(group => group.status === 'queued').length
|
|
161
|
+
const statusLabel = status => status === 'ready' ? '可删除'
|
|
162
|
+
: status === 'busy' ? '运行中'
|
|
163
|
+
: status === 'queued' ? '等待重启'
|
|
164
|
+
: '已阻止'
|
|
165
|
+
|
|
114
166
|
return React.createElement('main', { style: pageStyle }, React.createElement('section', {
|
|
115
|
-
style: { ...cardStyle, maxWidth: '
|
|
167
|
+
style: { ...cardStyle, maxWidth: '760px' },
|
|
116
168
|
},
|
|
117
169
|
React.createElement('h1', { style: { margin: '0 0 12px', fontSize: '24px' } }, '清空全部存档会话'),
|
|
118
170
|
React.createElement('p', { style: { color: '#aaa', lineHeight: 1.7 } },
|
|
119
|
-
'
|
|
171
|
+
'永久删除归档根会话及其子 Agent 日志。安全删除只处理空闲会话;强制删除会先停止 turn、子 Agent、后台任务和计划,仍有 live Agent 的会话会在下次启动 DSH 时完成删除。共享附件和工作区文件不会被删除。'),
|
|
120
172
|
React.createElement('p', { style: { fontSize: '18px', fontWeight: 600 } },
|
|
121
|
-
state.loading ? '正在统计…' : `当前共有 ${state.count} 个会话(${state.archivedCount}
|
|
173
|
+
state.loading ? '正在统计…' : `当前共有 ${state.count} 个会话(${state.archivedCount} 个归档根)`),
|
|
174
|
+
React.createElement('p', { style: { color: '#999', fontSize: '13px' } },
|
|
175
|
+
`可删除 ${ready} 组 · 等待重启 ${queued} 组 · 会话根目录:${state.sessionsRoot || '未配置'}`),
|
|
176
|
+
state.restartRequired && React.createElement('div', { style: noticeStyle },
|
|
177
|
+
'有会话已排队等待删除。请重启 DSH,启动时会自动完成删除并清理归档条目。'),
|
|
178
|
+
state.notice && React.createElement('div', { style: noticeStyle }, state.notice),
|
|
179
|
+
state.pendingError && React.createElement('div', { style: noticeStyle }, `待删除清单无法读取:${state.pendingError}`),
|
|
122
180
|
state.blocked.length > 0 && React.createElement('div', { style: noticeStyle },
|
|
123
|
-
'
|
|
181
|
+
'部分组暂不能删除:', React.createElement('ul', null, state.blocked.map((item, index) => React.createElement('li', { key: index }, item)))),
|
|
124
182
|
state.error && React.createElement('pre', {
|
|
125
183
|
style: { color: '#ff8989', whiteSpace: 'pre-wrap', background: '#f003', padding: '12px', borderRadius: '10px' },
|
|
126
184
|
}, state.error),
|
|
127
|
-
React.createElement('
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
185
|
+
React.createElement('h2', { style: { fontSize: '18px', margin: '20px 0 8px' } }, '归档组'),
|
|
186
|
+
state.groups.length === 0
|
|
187
|
+
? React.createElement('p', { style: { color: '#888' } }, state.loading ? '正在读取…' : '没有归档会话。')
|
|
188
|
+
: React.createElement('ul', { style: { listStyle: 'none', padding: 0, margin: 0 } },
|
|
189
|
+
state.groups.map(group => React.createElement('li', {
|
|
190
|
+
key: group.rootSessionId,
|
|
191
|
+
style: { borderBottom: '1px solid #5553', padding: '10px 0' },
|
|
192
|
+
},
|
|
193
|
+
React.createElement('div', { style: { display: 'flex', gap: '10px', alignItems: 'baseline' } },
|
|
194
|
+
React.createElement('strong', null, group.rootSessionId),
|
|
195
|
+
React.createElement('span', {
|
|
196
|
+
style: {
|
|
197
|
+
color: group.status === 'ready' ? '#7fd08a' : group.status === 'blocked' ? '#ff8989' : '#e0a06b',
|
|
198
|
+
fontSize: '13px',
|
|
199
|
+
},
|
|
200
|
+
}, `${statusLabel(group.status)} · ${group.members.length} 个会话`)),
|
|
201
|
+
group.reasons.length > 0 && React.createElement('div', { style: { color: '#e0a06b', fontSize: '13px' } },
|
|
202
|
+
group.reasons.join('; ')))),
|
|
203
|
+
),
|
|
204
|
+
React.createElement('div', { style: { display: 'flex', flexWrap: 'wrap', gap: '10px', marginTop: '14px' } },
|
|
205
|
+
React.createElement('button', {
|
|
206
|
+
type: 'button',
|
|
207
|
+
disabled: busy || state.loading || ready === 0,
|
|
208
|
+
onClick: () => submit('safe'),
|
|
209
|
+
style: {
|
|
210
|
+
appearance: 'none', border: 0, borderRadius: '10px', background: '#1f6f43', color: 'white',
|
|
211
|
+
cursor: 'pointer', fontSize: '15px', fontWeight: 600,
|
|
212
|
+
opacity: busy || ready === 0 ? 0.45 : 1, padding: '12px 18px',
|
|
213
|
+
},
|
|
214
|
+
}, busy ? '正在处理…' : '永久删除可删除的会话'),
|
|
215
|
+
React.createElement('button', {
|
|
216
|
+
type: 'button',
|
|
217
|
+
disabled: busy || state.loading || (state.count === 0 && state.archivedCount === 0),
|
|
218
|
+
onClick: () => submit('force'),
|
|
219
|
+
style: {
|
|
220
|
+
appearance: 'none', border: 0, borderRadius: '10px', background: '#d94747', color: 'white',
|
|
221
|
+
cursor: 'pointer', fontSize: '15px', fontWeight: 600,
|
|
222
|
+
opacity: busy || (state.count === 0 && state.archivedCount === 0) ? 0.45 : 1, padding: '12px 18px',
|
|
223
|
+
},
|
|
224
|
+
}, busy ? '正在处理…' : '强制删除全部存档会话'),
|
|
225
|
+
),
|
|
137
226
|
))
|
|
138
227
|
}
|
|
139
228
|
|
package/cordis.patch.yml
CHANGED
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
- id: dsh-efm-integration-archive-cleaner
|
|
6
6
|
name: 'dsh-efm-integration/archive-cleaner'
|
|
7
|
+
config:
|
|
8
|
+
# Defaults to dshHomePath('sessions'); set an absolute path when the
|
|
9
|
+
# JSONL session backend uses a custom root.
|
|
10
|
+
# sessionsRoot: 'D:/dsh-home/sessions'
|
|
11
|
+
forceStopTimeoutMs: 5000
|
|
7
12
|
|
|
8
13
|
- id: dsh-efm-integration-prompt
|
|
9
14
|
name: 'dsh-efm-integration/prompt'
|
|
@@ -1,37 +1,108 @@
|
|
|
1
|
-
|
|
1
|
+
import type { LocationValidation, SessionLocation } from './paths.js';
|
|
2
|
+
export type { LocationValidation, SessionLocation } from './paths.js';
|
|
3
|
+
/** Whether a deletion request may stop running work or must refuse it. */
|
|
4
|
+
export type DeletionMode = 'safe' | 'force';
|
|
5
|
+
/** How one archived root group currently behaves. */
|
|
6
|
+
export type ArchiveGroupStatus = 'ready' | 'busy' | 'queued' | 'blocked';
|
|
7
|
+
/** One live or stored Session known to the roster. */
|
|
8
|
+
export interface RosterSession {
|
|
2
9
|
readonly sessionId: string;
|
|
3
10
|
readonly parentSessionId?: string;
|
|
11
|
+
readonly origin?: 'subagent';
|
|
12
|
+
readonly isSeeded?: boolean;
|
|
4
13
|
readonly running: boolean;
|
|
14
|
+
readonly live: boolean;
|
|
5
15
|
readonly agentAvailable: boolean;
|
|
16
|
+
readonly location?: SessionLocation;
|
|
6
17
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
readonly
|
|
18
|
+
/** One member of an archive root's deletion group. */
|
|
19
|
+
export interface ArchiveMemberInspection {
|
|
20
|
+
readonly sessionId: string;
|
|
21
|
+
readonly parentSessionId?: string;
|
|
22
|
+
readonly origin?: 'subagent';
|
|
23
|
+
readonly running: boolean;
|
|
24
|
+
readonly live: boolean;
|
|
25
|
+
readonly agentAvailable: boolean;
|
|
26
|
+
readonly activity: readonly string[];
|
|
27
|
+
readonly directory?: string;
|
|
28
|
+
readonly missing: boolean;
|
|
29
|
+
readonly reasons: readonly string[];
|
|
30
|
+
}
|
|
31
|
+
/** One archived root and every subagent descendant that must go with it. */
|
|
32
|
+
export interface ArchiveGroupInspection {
|
|
33
|
+
readonly rootSessionId: string;
|
|
34
|
+
readonly members: readonly ArchiveMemberInspection[];
|
|
35
|
+
readonly status: ArchiveGroupStatus;
|
|
36
|
+
readonly reasons: readonly string[];
|
|
10
37
|
}
|
|
38
|
+
/** Dependencies needed to inspect archived roots without mutating anything. */
|
|
11
39
|
export interface ArchiveCleanerDependencies {
|
|
12
40
|
readonly archivedSessionIds: readonly string[];
|
|
13
|
-
readonly
|
|
14
|
-
readonly
|
|
15
|
-
|
|
16
|
-
|
|
41
|
+
readonly roster: readonly RosterSession[];
|
|
42
|
+
readonly queuedRoots: readonly string[];
|
|
43
|
+
readonly activityOf: (sessionId: string) => Promise<readonly string[]>;
|
|
44
|
+
readonly validateLocation: (location: SessionLocation | undefined) => Promise<LocationValidation>;
|
|
45
|
+
readonly removeDirectory: (directory: string) => Promise<void>;
|
|
17
46
|
readonly detachSession: (sessionId: string) => Promise<void>;
|
|
18
47
|
readonly unarchiveSession: (sessionId: string) => Promise<void>;
|
|
19
48
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
readonly
|
|
23
|
-
readonly
|
|
24
|
-
|
|
49
|
+
/** Dependencies needed to execute a forced deletion. */
|
|
50
|
+
export interface ArchiveDeletionDependencies extends ArchiveCleanerDependencies {
|
|
51
|
+
readonly stopActivity: (sessionId: string) => Promise<void>;
|
|
52
|
+
readonly waitQuiescent: (sessionIds: readonly string[], timeoutMs: number) => Promise<boolean>;
|
|
53
|
+
/** Final synchronous liveness check immediately before removing files. */
|
|
54
|
+
readonly isLive: (sessionId: string) => boolean;
|
|
25
55
|
}
|
|
56
|
+
/** Outcome for one archived root group. */
|
|
57
|
+
export interface GroupDeletionResult {
|
|
58
|
+
readonly rootSessionId: string;
|
|
59
|
+
readonly status: 'deleted' | 'queued' | 'blocked' | 'failed';
|
|
60
|
+
readonly deletedSessionIds: readonly string[];
|
|
61
|
+
readonly queuedSessionIds: readonly string[];
|
|
62
|
+
readonly reasons: readonly string[];
|
|
63
|
+
}
|
|
64
|
+
/** One group-level failure, retained for the existing API shape. */
|
|
26
65
|
export interface ArchiveDeletionFailure {
|
|
27
66
|
readonly sessionId: string;
|
|
28
67
|
readonly message: string;
|
|
29
68
|
}
|
|
69
|
+
/** Complete result of one safe or force deletion request. */
|
|
30
70
|
export interface ArchiveDeletionResult {
|
|
71
|
+
readonly mode: DeletionMode;
|
|
72
|
+
readonly groups: readonly GroupDeletionResult[];
|
|
31
73
|
readonly deletedSessionIds: readonly string[];
|
|
74
|
+
readonly queuedSessionIds: readonly string[];
|
|
32
75
|
readonly blocked: readonly string[];
|
|
33
76
|
readonly failures: readonly ArchiveDeletionFailure[];
|
|
77
|
+
readonly restartRequired: boolean;
|
|
78
|
+
}
|
|
79
|
+
/** Options for executing a deletion plan. */
|
|
80
|
+
export interface ArchiveDeletionOptions {
|
|
81
|
+
readonly mode: DeletionMode;
|
|
82
|
+
readonly forceStopTimeoutMs?: number;
|
|
34
83
|
}
|
|
35
|
-
|
|
36
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Build the archived-root groups and classify each one. The closure follows
|
|
86
|
+
* only `origin === 'subagent'` children: ordinary forks keep their own log and
|
|
87
|
+
* must never be deleted with the source conversation.
|
|
88
|
+
* @param deps - roster, activity, and path-validation seams.
|
|
89
|
+
* @returns one group per archived root id, in archive order.
|
|
90
|
+
*/
|
|
91
|
+
export declare function inspectArchiveGroups(deps: ArchiveCleanerDependencies): Promise<ArchiveGroupInspection[]>;
|
|
92
|
+
/**
|
|
93
|
+
* Execute safe or forced deletion over inspected groups. Safe refuses any
|
|
94
|
+
* group with live work; force stops every non-blocked group first, deletes the
|
|
95
|
+
* quiescent groups, and queues groups that still have a live Session.
|
|
96
|
+
* @param deps - inspection plus stop/wait seams.
|
|
97
|
+
* @param groups - inspected groups from {@link inspectArchiveGroups}.
|
|
98
|
+
* @param options - safe/force mode and the force stop deadline.
|
|
99
|
+
* @returns per-group results and flattened compatibility fields.
|
|
100
|
+
*/
|
|
101
|
+
export declare function deleteArchiveGroups(deps: ArchiveDeletionDependencies, groups: readonly ArchiveGroupInspection[], options: ArchiveDeletionOptions): Promise<ArchiveDeletionResult>;
|
|
102
|
+
/**
|
|
103
|
+
* Remove one per-Session directory. `ENOENT` means an earlier attempt already
|
|
104
|
+
* finished; Windows sharing violations are retried by Node's `rm` options.
|
|
105
|
+
* @param directory - validated real Session directory.
|
|
106
|
+
*/
|
|
107
|
+
export declare function removeSessionDirectory(directory: string): Promise<void>;
|
|
37
108
|
//# sourceMappingURL=core.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/archive-cleaner/core.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/archive-cleaner/core.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAErE,YAAY,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAErE,0EAA0E;AAC1E,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,CAAA;AAE3C,qDAAqD;AACrD,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAA;AAExE,sDAAsD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