mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 11:40:22 +08:00
release: 1.1.84,尾部锚点与子代理审批接管,红队模式中文化,#194/#188
- 接线 lib/anchor.js:锚点物理追加到 system prompt sections 末尾, identity.js 支持 anchorText(对象/字符串两种入参),已有同名段先滤再追加; 锚点改为跟随操作者语言,删除写死的英文开头句(红队回答变英文的根因) - 接线 lib/subagent-control.js:子会话 approval/policy=never 改回 ask, 并在 approval/request 瀑布放行;anchorMode/subagentControl 提供回滚开关 - index.js:真实 anchorApplied / injectTail 判定、审批策略探针、iso 分支 注册锚点、applyHostHooks 注册锚点与子代理接管并统一释放 - office 技能自愈:core/desktop 增加 healOfficeSkillsRuntimeOnDisk,桌面端触发 - 红队模式中文化:preset 文案、角色名、五阶段、25 项计分规则与 POC 分类、 技能修复说明、环境适配提示、面板报错、成果报告与复现报告 - #194:hung-operator 改按内容变更缓存,加风暴/慢调用熔断;WeakMap 去重 同次 assemble 的重复改写;新增 #91 记录宿主信号退出的持久化日志 - #188(rc.4 专属部分):新增 #89 沙箱策略去品牌、#90 skill-badge 中文描述, 扩展 #32/#53 的 rc.3 变体与 marker,均 optional - 新增锚点接线与红队文案测试,81/81 通过
This commit is contained in:
1 parent
ec4c8b889f
commit
5d0ebdae81
19 files changed
+1521
-847
No files matched your search
+20
-20
@@ -80,9 +80,9 @@ function resolvePluginSkillsDir() {
|
||||
const PLUGIN_SKILLS_DIR = resolvePluginSkillsDir()
|
||||
|
||||
function readOfficialSkill(name) {
|
||||
if (typeof name !== 'string' || name.length === 0) return { ok: false, error: 'name required' }
|
||||
if (typeof name !== 'string' || name.length === 0) return { ok: false, error: '缺少 name 参数' }
|
||||
const found = officialSkillSummaries().find((skill) => skill.name === name)
|
||||
if (!found) return { ok: false, error: 'skill not found: ' + name }
|
||||
if (!found) return { ok: false, error: '技能不存在: ' + name }
|
||||
return {
|
||||
ok: true,
|
||||
name: found.name,
|
||||
@@ -323,8 +323,8 @@ async function updatePreflight(ctx) {
|
||||
/* ① 开发态(源码软链):profile 里没有这个包名 → 不能用包管理器更新 */
|
||||
const devLinked = declared === null && !existsSync(join(installedDir, 'package.json'))
|
||||
if (devLinked) {
|
||||
blockers.push("This is a **development install** (the profile dependencies do not list " + pkg.name + " and it is source-symlinked or mounted manually), so package-manager updates do not apply.")
|
||||
notes.push("For a development install, upgrade in this repository: `git pull && npm run build:client`, then restart DeepSeek Harness.")
|
||||
blockers.push("这是**开发态安装**(profile 依赖里没有 " + pkg.name + ",且是源码软链或手动挂载),包管理器更新不适用。")
|
||||
notes.push("开发态安装请在仓库内升级:`git pull && npm run build:client`,然后重启 DeepSeek Harness。")
|
||||
}
|
||||
|
||||
/* ② 有智能体在跑:重启会打断它们 */
|
||||
@@ -348,7 +348,7 @@ async function updatePreflight(ctx) {
|
||||
}
|
||||
} catch { /* 注册表不可用就不挡(只是少了一层保护) */ }
|
||||
if (running.length > 0) {
|
||||
blockers.push("There are " + running.length + " agent(s) running (" + running.map((r) => r.label).join(', ') + "): updating restarts the current host and will interrupt them. Wait for them to finish.")
|
||||
blockers.push("当前有 " + running.length + " 个智能体在跑(" + running.map((r) => r.label).join(', ') + "):更新会重启当前宿主并打断它们,等它们跑完再更新。")
|
||||
}
|
||||
return { dir, declared, packageManager: packageManagerOf(dir), devLinked, running, blockers, notes }
|
||||
}
|
||||
@@ -383,14 +383,14 @@ function fetchJsonFromGithub(url) {
|
||||
res.on('data', (chunk) => {
|
||||
if (body.length + chunk.length > BODY_CAP) {
|
||||
try { res.destroy(new Error('body too large')) } catch { /* 忽略 */ }
|
||||
resolveP({ ok: false, error: 'response body too large' })
|
||||
resolveP({ ok: false, error: '响应体过大' })
|
||||
return
|
||||
}
|
||||
body += chunk
|
||||
})
|
||||
res.on('end', () => {
|
||||
try { resolveP({ ok: true, data: JSON.parse(body) }) }
|
||||
catch { resolveP({ ok: false, error: 'JSON parse error' }) }
|
||||
catch { resolveP({ ok: false, error: 'JSON 解析失败' }) }
|
||||
})
|
||||
})
|
||||
// req.setTimeout 要 socket 分配后才生效,DNS 查询阶段卡死不触发。外加 setTimeout 兜底。
|
||||
@@ -417,7 +417,7 @@ function isPrereleaseName(name) {
|
||||
async function checkLatestFromGithub(homepage) {
|
||||
const repo = githubRepoOf(homepage)
|
||||
const r = await fetchJsonFromGithub(`https://api.github.com/repos/${repo}/tags?per_page=50`)
|
||||
if (!r.ok || !Array.isArray(r.data)) return { ok: false, error: r.error || "GitHub tags unavailable" }
|
||||
if (!r.ok || !Array.isArray(r.data)) return { ok: false, error: r.error || "GitHub 标签获取失败" }
|
||||
let latest = null
|
||||
for (const row of r.data) {
|
||||
const name = String(row && row.name || '').trim()
|
||||
@@ -429,7 +429,7 @@ async function checkLatestFromGithub(homepage) {
|
||||
if (isPrereleaseName(ver)) continue
|
||||
if (!latest || versionLess(latest, ver)) latest = ver
|
||||
}
|
||||
if (!latest) return { ok: false, error: "No recognizable stable release tag on GitHub" }
|
||||
if (!latest) return { ok: false, error: "GitHub 上没有可用的稳定版标签" }
|
||||
return { ok: true, latest, registry: 'github' }
|
||||
}
|
||||
|
||||
@@ -761,17 +761,17 @@ async function handleSkillOp(ctx, request) {
|
||||
cached: availability.cached,
|
||||
broken: Array.from(availability.byName.values()).filter((x) => x.status === 'broken')
|
||||
.map((x) => ({ name: x.name, problems: x.problems, needs_user: x.needs_user })),
|
||||
note: "Availability = the skill file exists and its body can be loaded. Missing tools, keys, and VPS placeholders are recorded as gaps and do not mark the whole skill unavailable.",
|
||||
note: '可用 = 技能文件存在且正文能读取。缺工具、缺 key、VPS 占位符未填只记为待补项,不会把整条技能判为不可用。',
|
||||
},
|
||||
bySource: Array.from(bySource, ([k, n]) => ({ key: k, n })).sort((a, b) => b.n - a.n),
|
||||
byDir: Array.from(byDir, ([k, n]) => ({ key: k, n })).sort((a, b) => b.n - a.n),
|
||||
note: "Red team skills and official skills are separate. Tool-path checks apply only to red team skills; official skills live in $DSH_HOME/skills and are invoked by the host per task.",
|
||||
note: '红队技能与官方技能是两个库:工具路径检查只作用于红队技能;官方技能在 $DSH_HOME/skills,由宿主按任务调用。',
|
||||
items,
|
||||
})
|
||||
}
|
||||
if (request.library === 'official') return readOfficialSkill(request.name)
|
||||
if (typeof request.name !== 'string' || request.name.length === 0) {
|
||||
return { ok: false, error: 'name required' }
|
||||
return { ok: false, error: '缺少 name 参数' }
|
||||
}
|
||||
try {
|
||||
const skill = await skillsSvc.get(request.name, { scope })
|
||||
@@ -795,7 +795,7 @@ async function handleSkillOp(ctx, request) {
|
||||
function handleSkillOpFromPluginDir(request) {
|
||||
const dir = resolvePluginSkillsDir() || PLUGIN_SKILLS_DIR
|
||||
if (!dir || !existsSync(dir)) {
|
||||
return { ok: false, error: "The bundled skills/redteam directory does not exist, and the host skills service is unavailable" }
|
||||
return { ok: false, error: "随包 skills/redteam 目录不存在,宿主 skills 服务也不可用" }
|
||||
}
|
||||
const files = readdirSync(dir).filter((f) => f.endsWith('.md'))
|
||||
const parseMeta = (text) => {
|
||||
@@ -864,20 +864,20 @@ function handleSkillOpFromPluginDir(request) {
|
||||
cached: false,
|
||||
broken: Array.from(byName.values()).filter((x) => x.status === 'broken')
|
||||
.map((x) => ({ name: x.name, problems: x.problems, needs_user: x.needs_user })),
|
||||
note: "Self-check against this package's skill files (including the Env adapt config.json). Tool paths, keys, and VPS placeholders are recorded only as gaps and do not mark the whole skill unavailable.",
|
||||
note: "按本包的技能文件自检(含环境适配 config.json)。工具路径、key、VPS 占位符只记为待补项,不会把整条技能判为不可用。",
|
||||
},
|
||||
bySource: [{ key: 'plugin', n: items.length }],
|
||||
byDir: [{ key: dir, n: items.length }],
|
||||
note: "The bundled skills/redteam has " + items.length + " skill(s); availability was checked against their bodies and this machine's config.",
|
||||
note: "随包 skills/redteam 共 " + items.length + " 条技能;可用性按技能正文与本机配置实测。",
|
||||
items,
|
||||
})
|
||||
}
|
||||
if (request.library === 'official') return readOfficialSkill(request.name)
|
||||
if (typeof request.name !== 'string' || request.name.length === 0) {
|
||||
return { ok: false, error: 'name required' }
|
||||
return { ok: false, error: '缺少 name 参数' }
|
||||
}
|
||||
const file = join(dir, request.name.endsWith('.md') ? request.name : (request.name + '.md'))
|
||||
if (!existsSync(file)) return { ok: false, error: 'skill not found: ' + request.name }
|
||||
if (!existsSync(file)) return { ok: false, error: '技能不存在: ' + request.name }
|
||||
let content = ''
|
||||
try { content = readFileSync(file, 'utf8') } catch (error) {
|
||||
return { ok: false, error: error && error.message ? error.message : String(error) }
|
||||
@@ -998,7 +998,7 @@ async function handleUpdateOp(ctx, request) {
|
||||
}
|
||||
/* updateApply */
|
||||
if (pre.blockers.length > 0) {
|
||||
return { ok: false, error: "Cannot update now: " + pre.blockers.join(' '), blockers: pre.blockers, notes: pre.notes }
|
||||
return { ok: false, error: "现在无法更新: " + pre.blockers.join(' '), blockers: pre.blockers, notes: pre.notes }
|
||||
}
|
||||
/* target 会被原样拼进 `npm install <target>`:不校验就等于把"装任意包并重启进程"
|
||||
暴露给浏览器侧输入。只接受纯 semver(可带 v 前缀),其余一律拒绝并说清原因。 */
|
||||
@@ -1043,7 +1043,7 @@ export function apply(ctx) {
|
||||
return {
|
||||
kind: 'reject',
|
||||
reason: status.message
|
||||
|| "Environment not adapted: open dsh-purge → Env adapt to configure the tools, or confirm Skip for now before sending.",
|
||||
|| "环境未适配:打开 dsh-purge → Env adapt 配置工具,或先确认「暂时跳过」再发送。",
|
||||
messages: [],
|
||||
}
|
||||
}
|
||||
@@ -1140,7 +1140,7 @@ export function apply(ctx) {
|
||||
if (!skillResult || skillResult.ok === false) {
|
||||
skillResult = {
|
||||
ok: false,
|
||||
error: "Skill read failed: " + (skillErr && skillErr.message ? skillErr.message : String(skillErr)),
|
||||
error: "技能读取失败: " + (skillErr && skillErr.message ? skillErr.message : String(skillErr)),
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user