dsh-sweeper 1.5.3 → 1.5.5
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 +9 -1
- package/lib/deep-agent.js +2 -0
- package/lib/deep.js +3 -0
- package/lib/index.js +2 -1
- package/lib/trash.js +19 -2
- 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
|
+
- **动不了文件时说得清楚**:权限、占用、磁盘满这类系统错误会翻成一句话(`MOVE_ERRORS`),不再把 `EPERM` 直接丢到页面上;未列出的代码也会写成「系统拒绝了这次操作(CODE)」。
|
|
276
278
|
- **重新扫描不会打断正在跑的深度分析**:报告换了,但运行中的那一轮继续,页面继续轮询;结果里的每个路径在移动前都会对磁盘重新校验。
|
|
277
279
|
- **模型读报告期间如果你重扫了**,这一轮复核会被丢弃并返回 409,什么都不移动——判定针对的是你刚才看的那份报告。
|
|
278
280
|
- **读不出来的会话日志**只让那一段从计划里消失,不会让整份计划失败;页面会写「N 段日志读不出来」。
|
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,13 @@ window.__ModuleLoader__.load({
|
|
|
127
127
|
[/batch is busy/i, '这个批次正在被恢复或删除,稍等一下'],
|
|
128
128
|
[/bad batch id/i, '批次号不合法'],
|
|
129
129
|
[/already gone/i, '这一批已经被删掉了(可能是另一个标签页刚删的)'],
|
|
130
|
+
[/the model used its tool budget without answering/i, '模型把工具调用次数用完了,还没给出结论'],
|
|
131
|
+
[/the folder for that file is gone/i, '原来的文件夹已经不在了,文件还在回收站里'],
|
|
132
|
+
[/permission denied while moving the file/i, '系统不让动这个文件(可能被程序占用,或被安全软件拦住)'],
|
|
133
|
+
[/the file is still open by another program/i, '还有程序在用这个文件,关掉它再试'],
|
|
134
|
+
[/^the disk is full$/i, '磁盘空间不够了,没法把它写回去'],
|
|
135
|
+
[/something else is now at that path/i, '原来的位置现在被别的东西占着'],
|
|
136
|
+
[/the path is too long for this file system/i, '路径太长,这个磁盘不认'],
|
|
130
137
|
[/still open by another program/i, '批次里有文件正被别的程序占用,关掉占用它的程序再试'],
|
|
131
138
|
[/no files were moved/i, '这次没有移动任何文件'],
|
|
132
139
|
[/a file already exists there/i, '原位置已经有同名文件,没有覆盖'],
|
|
@@ -192,6 +199,7 @@ window.__ModuleLoader__.load({
|
|
|
192
199
|
if (hit) return head + (typeof hit[1] === 'function' ? hit[1](body.match(hit[0])) : hit[1])
|
|
193
200
|
if (/^HTTP \d+$/.test(body)) return head + '服务返回 ' + body.slice(5) + ',请重试'
|
|
194
201
|
if (/failed to fetch|networkerror|load failed/i.test(body)) return head + '连不上插件服务,DSH 可能刚重启'
|
|
202
|
+
if (/^[A-Z][A-Z0-9_]{2,}$/.test(body)) return head + '系统拒绝了这次操作(' + body + ')'
|
|
195
203
|
return raw
|
|
196
204
|
}
|
|
197
205
|
const humanError = (err) => humanReason((err && err.message) || err)
|
|
@@ -867,7 +875,7 @@ window.__ModuleLoader__.load({
|
|
|
867
875
|
+ (s.hidden ? '(另有 ' + fmtNum(s.hidden) + ' 个没发送给模型)' : '')),
|
|
868
876
|
),
|
|
869
877
|
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,
|
|
870
|
-
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,
|
|
878
|
+
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,
|
|
871
879
|
h(Chip, { tone: toneOf(s.status), dot: s.status === 'running' }, statusOf(s.status)),
|
|
872
880
|
))),
|
|
873
881
|
) : 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/trash.js
CHANGED
|
@@ -14,6 +14,23 @@ import { homedir } from 'node:os'
|
|
|
14
14
|
|
|
15
15
|
export const MAX_BATCH = 5000
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* The errno values a move realistically fails with, spelled out. A bare code
|
|
19
|
+
* used to reach the page as 恢复失败:EPERM; the client translates sentences.
|
|
20
|
+
*/
|
|
21
|
+
export const MOVE_ERRORS = {
|
|
22
|
+
ENOENT: 'the folder for that file is gone',
|
|
23
|
+
EACCES: 'permission denied while moving the file',
|
|
24
|
+
EPERM: 'permission denied while moving the file',
|
|
25
|
+
EBUSY: 'the file is still open by another program',
|
|
26
|
+
ENOSPC: 'the disk is full',
|
|
27
|
+
EISDIR: 'something else is now at that path',
|
|
28
|
+
ENOTDIR: 'something else is now at that path',
|
|
29
|
+
ENAMETOOLONG: 'the path is too long for this file system',
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const moveReason = (err) => (err && MOVE_ERRORS[err.code]) || (err && err.code) || String(err)
|
|
33
|
+
|
|
17
34
|
export function dshHome() {
|
|
18
35
|
const env = process.env.DSH_HOME
|
|
19
36
|
if (env && env.trim()) return resolve(env.trim())
|
|
@@ -185,7 +202,7 @@ export async function quarantine(items, meta = {}) {
|
|
|
185
202
|
try {
|
|
186
203
|
await moveFile(item.path, dest)
|
|
187
204
|
} catch (err) {
|
|
188
|
-
failed.push({ path: item.path, reason: (err
|
|
205
|
+
failed.push({ path: item.path, reason: moveReason(err) })
|
|
189
206
|
continue
|
|
190
207
|
}
|
|
191
208
|
|
|
@@ -278,7 +295,7 @@ export async function restore(id) {
|
|
|
278
295
|
await moveFile(src, entry.orig)
|
|
279
296
|
restored.push(entry.orig)
|
|
280
297
|
} catch (err) {
|
|
281
|
-
failed.push({ path: entry.orig, reason: (err
|
|
298
|
+
failed.push({ path: entry.orig, reason: moveReason(err) })
|
|
282
299
|
keep.push(entry)
|
|
283
300
|
}
|
|
284
301
|
}
|