mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 05:10:22 +08:00
fix: 发布 1.1.40,适配 DSH 0.2.0 并应用后自动重启
Anthropic OAuth 去掉 Claude Code 首段;移除 0.2 无效的 patch 41;应用成功后自动重启宿主。
This commit is contained in:
1 parent
be2189d290
commit
3bc63beca4
7 files changed
+97
-67
No files matched your search
+55
-43
@@ -2889,49 +2889,6 @@ const NEW_TOOL_PATCHES = [
|
||||
forbid: ["dsh-purge:committed"],
|
||||
markers: ["dshPurgeInject"],
|
||||
},
|
||||
{
|
||||
// 自定义 OpenAI 兼容接口不认 developer;推理模型默认会把 system 收成这个角色,直接 400。
|
||||
id: 41, name: "DEVELOPER_ROLE_TO_SYSTEM", layer: "0.1.5 兼容", layer_en: "0.1.5",
|
||||
desc: "developer 角色改回 system,兼容接口不再 400 / remap developer role to system",
|
||||
file: ["pi-ai-completions", "pi-ai-responses-shared"],
|
||||
optional: true,
|
||||
skipIfMarked: true,
|
||||
replacements: [
|
||||
{
|
||||
pattern:
|
||||
" const useDeveloperRole = model.reasoning && compat.supportsDeveloperRole;\n" +
|
||||
" const role = useDeveloperRole ? \"developer\" : \"system\";",
|
||||
replace:
|
||||
" const useDeveloperRole = false; // [dsh-purge] compatible APIs reject developer\n" +
|
||||
" const role = useDeveloperRole ? \"developer\" : \"system\";",
|
||||
},
|
||||
{
|
||||
pattern:
|
||||
" lastRole = msg.role;\n" +
|
||||
" }\n" +
|
||||
" return params;\n" +
|
||||
"}\n" +
|
||||
"function convertTools(",
|
||||
replace:
|
||||
" lastRole = msg.role;\n" +
|
||||
" }\n" +
|
||||
" for (const message of params) {\n" +
|
||||
" if (message && message.role === \"developer\") message.role = \"system\";\n" +
|
||||
" } // [dsh-purge] compatible APIs reject developer\n" +
|
||||
" return params;\n" +
|
||||
"}\n" +
|
||||
"function convertTools(",
|
||||
},
|
||||
{
|
||||
pattern:
|
||||
" const role = model.reasoning && compat?.supportsDeveloperRole !== false ? \"developer\" : \"system\";",
|
||||
replace:
|
||||
" const role = \"system\"; // [dsh-purge] compatible APIs reject developer",
|
||||
},
|
||||
],
|
||||
markersAny: true,
|
||||
markers: ["[dsh-purge] compatible APIs reject developer"],
|
||||
},
|
||||
{
|
||||
id: 42, name: "SETTINGS_LEGACY_API", layer: "代码", layer_en: "Code",
|
||||
desc: "设置服务补回 register/get,旧插件可继续用 / legacy settings API",
|
||||
@@ -3223,6 +3180,60 @@ const NEW_TOOL_PATCHES = [
|
||||
],
|
||||
markers: ["function dshPurgeWshLiteral"],
|
||||
},
|
||||
{
|
||||
id: 47,
|
||||
name: "ANTHROPIC_OAUTH_NO_CLAUDE_IDENTITY",
|
||||
layer: "0.2.0 兼容",
|
||||
layer_en: "0.2.0",
|
||||
desc: "Anthropic OAuth 不再强插 Claude Code 首段系统提示 / drop Claude Code OAuth system prefix",
|
||||
file: ["pi-ai-anthropic-messages"],
|
||||
optional: true,
|
||||
skipIfMarked: true,
|
||||
replacements: [
|
||||
{
|
||||
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 (initialSystemText) {\n" +
|
||||
" params.system.push({\n" +
|
||||
" type: \"text\",\n" +
|
||||
" text: sanitizeSurrogates(initialSystemText),\n" +
|
||||
" ...(cacheControl ? { cache_control: cacheControl } : {}),\n" +
|
||||
" });\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" else if (initialSystemText) {\n" +
|
||||
" // Add cache control to system prompt for non-OAuth tokens\n" +
|
||||
" params.system = [\n" +
|
||||
" {\n" +
|
||||
" type: \"text\",\n" +
|
||||
" text: sanitizeSurrogates(initialSystemText),\n" +
|
||||
" ...(cacheControl ? { cache_control: cacheControl } : {}),\n" +
|
||||
" },\n" +
|
||||
" ];\n" +
|
||||
" }",
|
||||
replace:
|
||||
" // [dsh-purge] OAuth no longer prepends Claude Code identity\n" +
|
||||
" if (initialSystemText) {\n" +
|
||||
" params.system = [\n" +
|
||||
" {\n" +
|
||||
" type: \"text\",\n" +
|
||||
" text: sanitizeSurrogates(initialSystemText),\n" +
|
||||
" ...(cacheControl ? { cache_control: cacheControl } : {}),\n" +
|
||||
" },\n" +
|
||||
" ];\n" +
|
||||
" }",
|
||||
},
|
||||
],
|
||||
markers: ["[dsh-purge] OAuth no longer prepends Claude Code identity"],
|
||||
},
|
||||
];
|
||||
|
||||
export const ALL_PATCHES = [...PATCHES, ...CODE_PATCHES, ...ENGINE_PATCHES, ...NEW_TOOL_PATCHES];
|
||||
@@ -3598,6 +3609,7 @@ export function targetFiles(aiBase, dshHome = findDshHome()) {
|
||||
]),
|
||||
"pi-ai-completions": allExisting(listPiAiApiFiles(dshHome, aiBase, "openai-completions.js")),
|
||||
"pi-ai-responses-shared": allExisting(listPiAiApiFiles(dshHome, aiBase, "openai-responses-shared.js")),
|
||||
"pi-ai-anthropic-messages": allExisting(listPiAiApiFiles(dshHome, aiBase, "anthropic-messages.js")),
|
||||
};
|
||||
return filterTargetFiles(files);
|
||||
}
|
||||
|
||||
+3
-1
@@ -1248,10 +1248,12 @@ function installWebServer(ctx, cfg) {
|
||||
const leaveTray = renamed || pendingQuit;
|
||||
if (complete) reapply.markPatchesApplied();
|
||||
if (leaveTray) bootFullQuit = true;
|
||||
const shouldRestart = complete;
|
||||
sendJson(response, 200, {
|
||||
ok: true,
|
||||
complete,
|
||||
restarting: false,
|
||||
restarting: shouldRestart,
|
||||
restart_after_apply: shouldRestart,
|
||||
unpacked_asar: leaveTray,
|
||||
needs_full_quit: leaveTray,
|
||||
applied: summary.applied,
|
||||
|
||||
Reference in new issue
Block a user