dsh-sweeper 1.5.4 → 1.5.6
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 +2 -0
- package/lib/agent.js +5 -1
- package/lib/client.js +5 -1
- package/lib/deep-agent.js +2 -0
- package/lib/deep.js +3 -0
- package/lib/index.js +2 -1
- package/lib/scan.js +25 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -273,6 +273,8 @@ node test/browser/check.mjs # 需要本机有 Chrome/Edge,或 CHROME=<p
|
|
|
273
273
|
|
|
274
274
|
## 边界与自保
|
|
275
275
|
|
|
276
|
+
- **读不到运行中的对话就不出报告**:列不出「哪些对话正在跑」时扫描直接失败并说明原因,宁可这次不扫,也不把还在用的文件列成候选。
|
|
277
|
+
- **模型被预算截断会说出来**:工具调用跑到上限、又没给出任何判定时,会退回单提示词再问一次;有判定但行被截断的行标「· 到工具上限,结论可能不全」,不会伪装成「看过了,很干净」。
|
|
276
278
|
- **动不了文件时说得清楚**:权限、占用、磁盘满这类系统错误会翻成一句话(`MOVE_ERRORS`),不再把 `EPERM` 直接丢到页面上;未列出的代码也会写成「系统拒绝了这次操作(CODE)」。
|
|
277
279
|
- **重新扫描不会打断正在跑的深度分析**:报告换了,但运行中的那一轮继续,页面继续轮询;结果里的每个路径在移动前都会对磁盘重新校验。
|
|
278
280
|
- **模型读报告期间如果你重扫了**,这一轮复核会被丢弃并返回 409,什么都不移动——判定针对的是你刚才看的那份报告。
|
package/lib/agent.js
CHANGED
|
@@ -83,7 +83,7 @@ export async function runAgentLoop(ctx, opts) {
|
|
|
83
83
|
}]
|
|
84
84
|
|
|
85
85
|
const trace = []
|
|
86
|
-
const summary = { turns: 0, calls: 0, text: '', finished: false }
|
|
86
|
+
const summary = { turns: 0, calls: 0, text: '', finished: false, exhausted: null }
|
|
87
87
|
try {
|
|
88
88
|
for (let turn = 0; turn < maxTurns; turn += 1) {
|
|
89
89
|
// One prepared call per turn: the host marks a prepared call dispatched
|
|
@@ -124,6 +124,7 @@ export async function runAgentLoop(ctx, opts) {
|
|
|
124
124
|
})
|
|
125
125
|
for (const block of calls) {
|
|
126
126
|
if (summary.calls >= maxCalls) {
|
|
127
|
+
summary.exhausted = summary.exhausted || 'calls'
|
|
127
128
|
messages.push(toolMessage(block.id, 'tool call budget for this conversation is used up; answer with what you have', true))
|
|
128
129
|
continue
|
|
129
130
|
}
|
|
@@ -166,6 +167,9 @@ export async function runAgentLoop(ctx, opts) {
|
|
|
166
167
|
clearTimeout(timer)
|
|
167
168
|
if (external && typeof external.removeEventListener === 'function') external.removeEventListener('abort', onAbort)
|
|
168
169
|
}
|
|
170
|
+
// A loop that ran out of turns never got a chance to answer; the caller has
|
|
171
|
+
// to say so, or a budget cut looks exactly like "found nothing".
|
|
172
|
+
if (!summary.finished) summary.exhausted = summary.exhausted || 'turns'
|
|
169
173
|
return { ...summary, trace }
|
|
170
174
|
}
|
|
171
175
|
|
package/lib/client.js
CHANGED
|
@@ -127,6 +127,10 @@ window.__ModuleLoader__.load({
|
|
|
127
127
|
[/batch is busy/i, '这个批次正在被恢复或删除,稍等一下'],
|
|
128
128
|
[/bad batch id/i, '批次号不合法'],
|
|
129
129
|
[/already gone/i, '这一批已经被删掉了(可能是另一个标签页刚删的)'],
|
|
130
|
+
[/^route not found:/i, '服务不认识这个地址,可能是插件版本不匹配,刷新页面再试'],
|
|
131
|
+
[/the session service is not available, so whether a conversation is still running cannot be told/i, '读不到正在运行的对话列表,分不清哪些文件还在用,这次先不扫'],
|
|
132
|
+
[/the session service failed while listing running conversations/i, '列正在运行的对话时出错了,这次先不扫'],
|
|
133
|
+
[/the model used its tool budget without answering/i, '模型把工具调用次数用完了,还没给出结论'],
|
|
130
134
|
[/the folder for that file is gone/i, '原来的文件夹已经不在了,文件还在回收站里'],
|
|
131
135
|
[/permission denied while moving the file/i, '系统不让动这个文件(可能被程序占用,或被安全软件拦住)'],
|
|
132
136
|
[/the file is still open by another program/i, '还有程序在用这个文件,关掉它再试'],
|
|
@@ -874,7 +878,7 @@ window.__ModuleLoader__.load({
|
|
|
874
878
|
+ (s.hidden ? '(另有 ' + fmtNum(s.hidden) + ' 个没发送给模型)' : '')),
|
|
875
879
|
),
|
|
876
880
|
s.error ? h('div', { title: s.error, style: { fontSize: 10.5, color: T.danger, maxWidth: 220, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' } }, s.error) : null,
|
|
877
|
-
s.status === 'done' ? h('span', { className: 'sw-num', style: { fontSize: 11, color: T.faint } }, (s.ms ? (s.ms / 1000).toFixed(1) + 's' : '') + (s.calls ? ' · 工具 ' + s.calls + ' 次' : '') + (s.found ? ' · ' + s.found + ' 项' : '')) : null,
|
|
881
|
+
s.status === 'done' ? h('span', { className: 'sw-num', style: { fontSize: 11, color: T.faint } }, (s.ms ? (s.ms / 1000).toFixed(1) + 's' : '') + (s.calls ? ' · 工具 ' + s.calls + ' 次' : '') + (s.found ? ' · ' + s.found + ' 项' : '') + (s.cutShort ? ' · 到工具上限,结论可能不全' : '')) : null,
|
|
878
882
|
h(Chip, { tone: toneOf(s.status), dot: s.status === 'running' }, statusOf(s.status)),
|
|
879
883
|
))),
|
|
880
884
|
) : null,
|
package/lib/deep-agent.js
CHANGED
|
@@ -83,6 +83,8 @@ export async function auditWithTools(ctx, info, digest, opts = {}) {
|
|
|
83
83
|
verdict: parseVerdict(result.text),
|
|
84
84
|
turns: result.turns,
|
|
85
85
|
calls: result.calls,
|
|
86
|
+
finished: result.finished === true,
|
|
87
|
+
exhausted: result.exhausted || null,
|
|
86
88
|
ms: Date.now() - started,
|
|
87
89
|
trace: result.trace,
|
|
88
90
|
text: result.text,
|
package/lib/deep.js
CHANGED
|
@@ -573,10 +573,13 @@ export async function runDeep(ctx, sessions, opts = {}) {
|
|
|
573
573
|
deny: [dshHome(), trashRoot()],
|
|
574
574
|
})
|
|
575
575
|
const verdict = audited.verdict
|
|
576
|
+
const decided = (verdict.sweep || []).length + (verdict.optional || []).length + (verdict.keep || []).length
|
|
577
|
+
if (!audited.finished && decided === 0) throw new Error('the model used its tool budget without answering')
|
|
576
578
|
return {
|
|
577
579
|
ok: true,
|
|
578
580
|
parsed: verdict,
|
|
579
581
|
agent: true,
|
|
582
|
+
cutShort: !audited.finished,
|
|
580
583
|
turns: audited.turns,
|
|
581
584
|
calls: audited.calls,
|
|
582
585
|
ms: audited.ms,
|
package/lib/index.js
CHANGED
|
@@ -230,7 +230,7 @@ export function apply(ctx, config = {}) {
|
|
|
230
230
|
id, title: s.title, cwd: s.cwd, ageDays: s.ageDays, toolCalls: s.toolCalls,
|
|
231
231
|
candidates: s.candidates, hidden: s.hidden || 0, truncated: !!s.truncated,
|
|
232
232
|
estTokens: s.estTokens, status: s.status,
|
|
233
|
-
agent: s.agent === true, turns: s.turns || 0, calls: s.calls || 0,
|
|
233
|
+
agent: s.agent === true, turns: s.turns || 0, calls: s.calls || 0, cutShort: s.cutShort === true,
|
|
234
234
|
ms: s.ms, error: s.error, found: s.items.length,
|
|
235
235
|
debug: job.debug ? s.debug : undefined,
|
|
236
236
|
}
|
|
@@ -695,6 +695,7 @@ export function apply(ctx, config = {}) {
|
|
|
695
695
|
row.agent = payload.agent === true
|
|
696
696
|
row.turns = payload.turns || 0
|
|
697
697
|
row.calls = payload.calls || 0
|
|
698
|
+
row.cutShort = payload.cutShort === true
|
|
698
699
|
row.ms = payload.ms || 0
|
|
699
700
|
row.estTokens = payload.estTokens || row.estTokens
|
|
700
701
|
job.done += 1
|
package/lib/scan.js
CHANGED
|
@@ -33,6 +33,7 @@ function normKey(p) {
|
|
|
33
33
|
|
|
34
34
|
function idOf(entry) {
|
|
35
35
|
if (!entry) return null
|
|
36
|
+
if (typeof entry === 'string') return entry
|
|
36
37
|
if (entry.id) return entry.id
|
|
37
38
|
if (entry.sessionId) return entry.sessionId
|
|
38
39
|
const h = entry.header
|
|
@@ -46,6 +47,27 @@ function spilledBy(sessionId, spillPath) {
|
|
|
46
47
|
return String(spillPath).toLowerCase().includes('session-' + uuid.slice(0, 12).toLowerCase())
|
|
47
48
|
}
|
|
48
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Which conversations are running right now. If the session service cannot answer,
|
|
52
|
+
* the scan must not guess: an empty set would let a file that a live conversation
|
|
53
|
+
* is still using through as a delete candidate.
|
|
54
|
+
*/
|
|
55
|
+
export async function liveSessionIds(ctx) {
|
|
56
|
+
const sessions = (ctx.get ? ctx.get('sessions') : ctx.sessions)
|
|
57
|
+
if (!sessions || typeof sessions.list !== 'function') {
|
|
58
|
+
throw Object.assign(new Error('the session service is not available, so whether a conversation is still running cannot be told'), { status: 503 })
|
|
59
|
+
}
|
|
60
|
+
let rows
|
|
61
|
+
try { rows = sessions.list() } catch (err) {
|
|
62
|
+
throw Object.assign(new Error('the session service failed while listing running conversations, so this scan would not know what is still in use'), { status: 503, cause: err })
|
|
63
|
+
}
|
|
64
|
+
if (rows && typeof rows.then === 'function') rows = await rows
|
|
65
|
+
const out = new Set()
|
|
66
|
+
const list = Array.isArray(rows) ? rows : (rows && typeof rows[Symbol.iterator] === 'function' ? [...rows] : [])
|
|
67
|
+
for (const s of list) { const lid = idOf(s); if (lid) out.add(String(lid)) }
|
|
68
|
+
return out
|
|
69
|
+
}
|
|
70
|
+
|
|
49
71
|
function last2(key) {
|
|
50
72
|
const parts = key.split(WIN ? '\\' : '/').filter(Boolean)
|
|
51
73
|
return parts.slice(-2).join(WIN ? '\\' : '/')
|
|
@@ -234,12 +256,7 @@ export async function scan(ctx, opts = {}) {
|
|
|
234
256
|
|
|
235
257
|
const persistence = ctx.get ? ctx.get('sessionPersistence') : ctx.sessionPersistence
|
|
236
258
|
if (!persistence) throw new Error('sessionPersistence service is not available')
|
|
237
|
-
const liveIds =
|
|
238
|
-
try {
|
|
239
|
-
const sessions = (ctx.get ? ctx.get('sessions') : ctx.sessions)
|
|
240
|
-
const arr = sessions && typeof sessions.list === 'function' ? sessions.list() : []
|
|
241
|
-
for (const s of arr || []) { const lid = idOf(s); if (lid) liveIds.add(String(lid)) }
|
|
242
|
-
} catch { /* live detection is best effort */ }
|
|
259
|
+
const liveIds = await liveSessionIds(ctx)
|
|
243
260
|
|
|
244
261
|
const snapshots = await persistence.list()
|
|
245
262
|
const list = Array.isArray(snapshots) ? snapshots : [...(snapshots || [])]
|
|
@@ -532,4 +549,5 @@ function safeHome() {
|
|
|
532
549
|
try { return homedir() } catch { return '' }
|
|
533
550
|
}
|
|
534
551
|
|
|
535
|
-
export const _internal = {
|
|
552
|
+
export const _internal = {
|
|
553
|
+
liveSessionIds, normKey, toks, last2, relKey, SCRATCH, DEEP_TEMP, SPILL, scratchRootOf, collectHints, gitTracked }
|