diff --git a/lib/core.js b/lib/core.js index 4dc0187..e8ef97a 100644 --- a/lib/core.js +++ b/lib/core.js @@ -2281,6 +2281,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' + @@ -2499,19 +2525,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", @@ -3313,6 +3352,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" + @@ -3549,8 +3630,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 ""; } @@ -3755,10 +3842,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"),