feat: 发布 1.1.19,支持官方桌面 EXE

官方客户端可以应用并自己重启;修掉重启弹窗、残留 PowerShell,以及更新时要手动还原再应用的问题。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
叫我小杨同学andCursor committed 2026-09-25 02:47:29 +08:00
1 parent 00ccf4a1f1
commit fd8d47c00f
16 files changed
+973 -72

No files matched your search

+62 -1
View File
@@ -13,6 +13,7 @@ import {
revertHideConsoleFromBin,
} from "./hide-console.js";
import * as desktop from "./desktop.js";
import { asarArchiveIsFile, extractAsar, overlayAsarUnpacked, renameAsarAside } from "./extract-asar.js";
import { adapterFor, detectSurface } from "./surface.js";
import { openSlot } from "./table-read.js";
@@ -104,6 +105,7 @@ export function resetPathMemo() {
function isFile(fp) {
try {
if (desktop.isAsarSealedPath(fp)) return false;
return fs.existsSync(fp) && fs.statSync(fp).isFile();
} catch {
return false;
@@ -112,6 +114,7 @@ function isFile(fp) {
function isDir(fp) {
try {
if (desktop.isAsarSealedPath(fp)) return false;
return fs.existsSync(fp) && fs.statSync(fp).isDirectory();
} catch {
return false;
@@ -160,6 +163,8 @@ function aiBaseGuessesAround(dir) {
path.join(dir, "@deepseek-ai"),
path.join(dir, "node_modules", "@deepseek-ai"),
path.join(dir, "node_modules", nested),
path.join(dir, "dsh", "node_modules", "@deepseek-ai"),
path.join(dir, "dsh", "node_modules", nested),
path.join(dir, "..", "node_modules", "@deepseek-ai"),
path.join(dir, "..", "node_modules", nested),
path.join(dir, "..", "..", "node_modules", "@deepseek-ai"),
@@ -313,6 +318,7 @@ export function silenceCmdFlash(aiBase = findAiBase()) {
hide.entry === "already_injected" ||
hide.entry === "skipped_not_win32" ||
hide.entry === "missing_bin" ||
hide.entry === "sealed_asar" ||
(typeof hide.entry === "string" && hide.entry.startsWith("error:"));
return {
...hide,
@@ -1572,13 +1578,68 @@ export function missingAiBaseMessage() {
if (adapterFor(detectSurface()) === "desktop") {
const exe = desktop.findDesktopAppExecutable();
if (exe) {
const asar = path.join(path.dirname(exe), "resources", "app.asar");
if (asarArchiveIsFile(asar) && desktop.isOfficialHarnessExecutable(exe)) {
return `已找到 ${exe}。官方宿主在 app.asar 里,点「应用」会解开 resources\\app 并自动重启,不用另跑脚本。`;
}
return `已找到桌面应用 ${exe},但其 resources/app(或 app.asar.unpacked)下没有 @deepseek-ai`;
}
return "未定位到当前桌面应用的 @deepseek-ai。请在桌面端内打开设置再点「应用」(不要用官方 dsh)。安装目录可以是任意盘符;也可设置 DSH_DESKTOP_INSTALL 为安装目录,或 DSH_BASE 为该树下的 @deepseek-ai";
return "未定位到当前桌面应用的 @deepseek-ai。官方客户端点「应用」会解开 app.asar 并重启;第三方 DSH Desktop 直接点「应用」。安装目录任意盘符。";
}
return "插件根未找到 / set DSH_BASE";
}
function aiBaseUnderAppDir(appDir) {
const cands = [
path.join(appDir, "dsh", "node_modules", "@deepseek-ai"),
path.join(appDir, "node_modules", "@deepseek-ai"),
];
return cands.find((p) => isAiBase(p)) || null;
}
export function sealedAsarHandoff(input = {}) {
const surface = input.surface ?? detectSurface(input);
if (adapterFor(surface) !== "desktop") return null;
const hinted = input.execPath;
const exe = hinted && desktop.isDesktopExecutable(hinted)
? path.normalize(hinted)
: desktop.findDesktopAppExecutable(input);
if (!exe || !desktop.isOfficialHarnessExecutable(exe)) return null;
const asar = path.join(path.dirname(exe), "resources", "app.asar");
if (!asarArchiveIsFile(asar)) return null;
return { exe, asar, swapAsar: true };
}
/** 官方 app.asar 解开到 resources/app。点「应用」时调用,不要求用户先跑脚本。 */
export async function openSealedDesktopHost() {
const handoff = sealedAsarHandoff();
if (!handoff) return { aiBase: null, swapAsar: false };
const appDir = path.join(path.dirname(handoff.exe), "resources", "app");
let aiBase = aiBaseUnderAppDir(appDir);
if (!aiBase) {
await extractAsar(handoff.asar, appDir);
aiBase = aiBaseUnderAppDir(appDir);
}
overlayAsarUnpacked(handoff.asar, appDir);
if (!aiBase) {
throw new Error(`已解开 ${handoff.asar},但 resources\\app 下没有 @deepseek-ai`);
}
resetPathMemo();
return { aiBase, swapAsar: true, exe: handoff.exe, asar: handoff.asar };
}
export function scheduleSealedDesktopRestart(handoff) {
if (!handoff?.asar) return { renamed: false };
const moved = renameAsarAside(handoff.asar);
if (moved.renamed || !moved.busy) return moved;
const pending = desktop.scheduleAsarRenameWhenIdle({ exe: handoff.exe, asar: handoff.asar });
return { renamed: false, pending: true, ...pending };
}
export function officialHostMustStayUp() {
return process.env.ELECTRON_RUN_AS_NODE === "1" && desktop.isOfficialHarnessExecutable(process.execPath);
}
export function findAiBase() {
return remember("ai", () => {
if (adapterFor(detectSurface()) === "desktop") return findAiBaseDesktop();