mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 00:40:22 +08:00
fix: 修正 escalation 目标解析、desktop-shell 入口探测,并重新对齐 0.1.x 锚点
1) targetFiles 的 "escalation" 用 firstExisting,只认 lib/types/escalation.js(编译残留), 而运行时加载的是包入口 lib/index.js —— escalation 实现被 bundle 内联进了它。 结果 #13/#14/#34/#35 的替换全部落在不被执行的文件上:设置页显示「已应用」, 运行行为零变化(可对照 lib/index.js 里仍留着原版 `[sandbox: escalation available ...]` 与 `[sandbox: file access denied ...]`)。 改为 allExisting 并让 lib/index.js 排前,两个文件都覆盖。 2) officialShellMain() 只找 <app>/lib/main.js;官方桌面壳 0.1.3 起入口直接在 <app>/main.js,于是 desktop-shell 永远未定位、#45/#46 被误报成「文件缺失」。 两种布局都探测。 3) #15 补 dsh-sandbox-local 新版 confine(argv, policy) 锚点(去掉 async/signal 与 policy 规范化),旧签名保留。 4) #23 file 补 tool-subagent(0.1.7 起深度默认在工具参数上),新增 z.union([...z.const("provider-managed")]).default(3) 锚点,旧锚点保留。 5) #47 补 pi-ai 新版 context.systemPrompt 锚点,旧 initialSystemText 锚点保留。 所有旧锚点全部保留,向后兼容 0.1.5 / 0.1.6 / 0.1.7 / 0.2.0 环境。 实测环境:DSH Desktop 0.1.3.0 + harness 包 0.1.2-rc.1(安装形态 resources/app.asar.unpacked/dsh/node_modules/@deepseek-ai,与 resources/runtime 是 junction 同一份文件)。 修复前 30/45 已清洗、9 条 skipped/missing;修复后 36/45、0 待清洗, 涉及改写的文件全部 node --check 通过。
This commit is contained in:
1 parent
925f7d3f0f
commit
ce279104d6
1 file changed
+100
-9
+100
-9
@@ -2168,6 +2168,32 @@ const ENGINE_PATCHES = [
|
||||
file: "sandbox-local",
|
||||
rel: ["lib", "index.js"],
|
||||
patterns: [
|
||||
// 新版 dsh-sandbox-local:confine(argv, policy) 去掉了 async/signal 与 policy 规范化。
|
||||
'confine(argv, policy) {\n' +
|
||||
'\t\tif (this.runnerCommand !== void 0) return {\n' +
|
||||
'\t\t\targv: [\n' +
|
||||
'\t\t\t\t...this.runnerCommand,\n' +
|
||||
'\t\t\t\t...bwrapProfileArgs(policy),\n' +
|
||||
'\t\t\t\t"--",\n' +
|
||||
'\t\t\t\t...argv\n' +
|
||||
'\t\t\t],\n' +
|
||||
'\t\t\tenforcement: "full",\n' +
|
||||
'\t\t\tdenialSignatures: DENIAL_SIGNATURES.runnerCommand,\n' +
|
||||
'\t\t\trunnerFailureRules: [{ fatalSignatures: this.configuredRunnerFailureSignatures }]\n' +
|
||||
'\t\t};\n' +
|
||||
'\t\tconst selected = this.selectRunner(policy.mode);\n' +
|
||||
'\t\treturn {\n' +
|
||||
'\t\t\targv: [\n' +
|
||||
'\t\t\t\t...this.runnerArgv(selected.runner, policy),\n' +
|
||||
'\t\t\t\t"--",\n' +
|
||||
'\t\t\t\t...argv\n' +
|
||||
'\t\t\t],\n' +
|
||||
'\t\t\tenforcement: selected.enforcement,\n' +
|
||||
'\t\t\tdenialSignatures: DENIAL_SIGNATURES[selected.runner],\n' +
|
||||
'\t\t\trunnerFailureRules: RUNNER_FAILURE_RULES[selected.runner]\n' +
|
||||
'\t\t};\n' +
|
||||
'\t}',
|
||||
// 旧签名(带 signal 与 policy 规范化),保留以兼容旧版回放。
|
||||
'async confine(argv, policy, signal) {\n' +
|
||||
'\t\tsignal?.throwIfAborted();\n' +
|
||||
'\t\tpolicy = {\n' +
|
||||
@@ -2386,19 +2412,32 @@ const NEW_TOOL_PATCHES = [
|
||||
},
|
||||
{
|
||||
id: 23, name: "SUBAGENT_MAXDEPTH_RAISED", layer: "代码", layer_en: "Code",
|
||||
desc: "子代理深度默认 1 → 10 / subagent maxDepth raised",
|
||||
file: "subagent",
|
||||
desc: "子代理深度默认 3 → 10 / subagent maxDepth raised",
|
||||
// 0.1.7 起深度默认在工具参数上(dsh-tool-subagent);旧版在 dsh-subagent 服务配置上。
|
||||
// 两个 key 都列,命中哪个都能抬高递归预算。
|
||||
file: ["subagent", "tool-subagent"],
|
||||
rel: ["lib", "index.js"],
|
||||
replacements: [
|
||||
{
|
||||
// 0.1.7 起深度默认在 dsh-subagent 的服务配置上,工具参数不再带 .default(3)。
|
||||
// 新版工具参数:union + provider-managed,默认 3。
|
||||
pattern:
|
||||
'maxDepth: z.union([z.natural().max(Number.MAX_SAFE_INTEGER), z.const("provider-managed")]).default(3)',
|
||||
replace:
|
||||
'maxDepth: z.union([z.natural().max(Number.MAX_SAFE_INTEGER), z.const("provider-managed")]).default(10) // [dsh-purge] subagent depth raised',
|
||||
},
|
||||
{
|
||||
// 0.1.5/0.1.6 时代:数值 schema,默认 1。
|
||||
pattern:
|
||||
"maxDepth: z.number().step(1).min(0).max(Number.MAX_SAFE_INTEGER).default(1).volatile()",
|
||||
replace:
|
||||
"maxDepth: z.number().step(1).min(0).max(Number.MAX_SAFE_INTEGER).default(10).volatile()",
|
||||
},
|
||||
],
|
||||
markers: ["maxDepth: z.number().step(1).min(0).max(Number.MAX_SAFE_INTEGER).default(10).volatile()"],
|
||||
markersAny: true,
|
||||
markers: [
|
||||
"[dsh-purge] subagent depth raised",
|
||||
"maxDepth: z.number().step(1).min(0).max(Number.MAX_SAFE_INTEGER).default(10).volatile()",
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 24, name: "PRESET_FETCH_ENABLED", layer: "代码", layer_en: "Code",
|
||||
@@ -3190,6 +3229,48 @@ const NEW_TOOL_PATCHES = [
|
||||
optional: true,
|
||||
skipIfMarked: true,
|
||||
replacements: [
|
||||
{
|
||||
// pi-ai 新版:变量名从 initialSystemText 改成 context.systemPrompt。
|
||||
pattern:
|
||||
" // For OAuth tokens, we MUST include Claude Code identity\n" +
|
||||
" if (isOAuthToken) {\n" +
|
||||
" params.system = [\n" +
|
||||
" {\n" +
|
||||
' type: "text",\n' +
|
||||
' text: "You are Claude Code, Anthropic\'s official CLI for Claude.",\n' +
|
||||
" ...(cacheControl ? { cache_control: cacheControl } : {}),\n" +
|
||||
" },\n" +
|
||||
" ];\n" +
|
||||
" if (context.systemPrompt) {\n" +
|
||||
" params.system.push({\n" +
|
||||
' type: "text",\n' +
|
||||
" text: sanitizeSurrogates(context.systemPrompt),\n" +
|
||||
" ...(cacheControl ? { cache_control: cacheControl } : {}),\n" +
|
||||
" });\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" else if (context.systemPrompt) {\n" +
|
||||
" // Add cache control to system prompt for non-OAuth tokens\n" +
|
||||
" params.system = [\n" +
|
||||
" {\n" +
|
||||
' type: "text",\n' +
|
||||
" text: sanitizeSurrogates(context.systemPrompt),\n" +
|
||||
" ...(cacheControl ? { cache_control: cacheControl } : {}),\n" +
|
||||
" },\n" +
|
||||
" ];\n" +
|
||||
" }",
|
||||
replace:
|
||||
" // [dsh-purge] OAuth no longer prepends Claude Code identity\n" +
|
||||
" if (context.systemPrompt) {\n" +
|
||||
" params.system = [\n" +
|
||||
" {\n" +
|
||||
' type: "text",\n' +
|
||||
" text: sanitizeSurrogates(context.systemPrompt),\n" +
|
||||
" ...(cacheControl ? { cache_control: cacheControl } : {}),\n" +
|
||||
" },\n" +
|
||||
" ];\n" +
|
||||
" }",
|
||||
},
|
||||
{
|
||||
pattern:
|
||||
" // For OAuth tokens, we MUST include Claude Code identity\n" +
|
||||
@@ -3276,8 +3357,14 @@ function officialShellMain() {
|
||||
try {
|
||||
const exe = desktop.findDesktopAppExecutable();
|
||||
if (!exe || !desktop.isOfficialHarnessExecutable(exe)) return "";
|
||||
const main = path.join(desktop.appDirForExecutable(exe), "lib", "main.js");
|
||||
return fs.existsSync(main) ? main : "";
|
||||
const appDir = desktop.appDirForExecutable(exe);
|
||||
// 官方桌面壳入口布局换过:早期是 lib/main.js,0.1.3 起直接是 main.js。
|
||||
// 只认 lib/ 会让 desktop-shell 永远未定位,#45/#46 被误报成"文件缺失"。
|
||||
for (const rel of [["lib", "main.js"], ["main.js"]]) {
|
||||
const main = path.join(appDir, ...rel);
|
||||
if (fs.existsSync(main)) return main;
|
||||
}
|
||||
return "";
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
@@ -3482,10 +3569,14 @@ export function targetFiles(aiBase, dshHome = findDshHome()) {
|
||||
...nestedPkg(aiBase, "dsh-user-approval", "lib", "invariant.js"),
|
||||
...(root ? [path.join(root, "packages", "interaction", "user-approval", "lib", "invariant.js")] : []),
|
||||
]),
|
||||
"escalation": firstExisting([
|
||||
...nestedPkg(aiBase, "dsh-sandbox", "lib", "types", "escalation.js"),
|
||||
...(root ? [path.join(root, "packages", "sandbox", "sandbox", "lib", "types", "escalation.js")] : []),
|
||||
// 运行时加载的是包入口 lib/index.js(escalation 实现已被 bundle 内联进它);
|
||||
// lib/types/escalation.js 只是编译残留,补丁打在那里对运行行为零影响。
|
||||
// 两者都覆盖,且入口排前,保证 markers 命中真正被执行的文件。
|
||||
"escalation": allExisting([
|
||||
...nestedPkg(aiBase, "dsh-sandbox", "lib", "index.js"),
|
||||
...nestedPkg(aiBase, "dsh-sandbox", "lib", "types", "escalation.js"),
|
||||
...(root ? [path.join(root, "packages", "sandbox", "sandbox", "lib", "index.js")] : []),
|
||||
...(root ? [path.join(root, "packages", "sandbox", "sandbox", "lib", "types", "escalation.js")] : []),
|
||||
]),
|
||||
"fs-sandbox": firstExisting([
|
||||
path.join(aiBase, "dsh-fs-sandbox", "lib", "index.js"),
|
||||
|
||||
Reference in new issue
Block a user