Files
dsh-purge/lib/settle-policy.js
叫我小杨同学andCursor f51c1d6ddc fix: 发布 1.1.61,多宿主 Apply 与 #73/#74、极简 preset
- Apply/reapply 同时写 npm-global 与桌面宿主;#73 地区闸门误拦;#74 提示词落盘与 resolveInjectText

- 极简 #80 官方 shell;agent-preset/selected 优先;adaptInjectForMinimalPreset;refusal-recover 扩展

- identity 注入去重与组装;默认提示词重加密 asset-table.js

Closes #73. Closes #74.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-07 18:13:19 +08:00

62 lines
2.0 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/** 官方桌面启动时 Fiber._reload 还在挂 desktop-office,settle 不得解包/杀进程。 */
export const DESKTOP_SETTLE_DELAY_MS = 4000;
export function isInactiveContextError(error) {
if (!error) return false;
if (error.code === "INACTIVE_EFFECT") return true;
return /inactive context/i.test(String(error.message || error));
}
export function watchContextLife(ctx) {
const life = { alive: true };
if (!ctx || typeof ctx.effect !== "function") return life;
try {
ctx.effect(() => () => {
life.alive = false;
});
} catch (error) {
if (isInactiveContextError(error)) {
life.alive = false;
return life;
}
throw error;
}
return life;
}
export function settleDelayMs(surface) {
return surface === "desktop" ? DESKTOP_SETTLE_DELAY_MS : 0;
}
/** 桌面启动自愈不得 requestRestart / taskkill,否则 Cordis 会 INACTIVE_EFFECT。 */
export function settleMayRestart({ surface, sealed = false } = {}) {
if (surface === "desktop") return false;
if (sealed) return false;
return true;
}
/** 密封 asar 上就地 extract/swap 会和官方 Host 的 Fiber._reload 抢锁。 */
export function settleMayReapply({ surface, sealed = false } = {}) {
if (surface === "desktop" && sealed) return false;
return true;
}
/**
* 点「应用」后是否重启。网页和桌面用同一条:
* 提示词已经写入,或这次写了补丁,就重启。对不上当前版本的代码补丁不取消重启。
* 密封包多出来的只是换包,不另做一套判断。
* 冷却不放在这里——否则第一次重启没换掉 asar,第二次应用会被当成取消。
*/
export function applyShouldRestart({
complete = false,
sealed = false,
appliedCount = 0,
promptReady = false,
} = {}) {
// 密封桌面:点「应用」后必须完全退出才能换 asar / 加载 resources/app,与补丁是否标 applied 无关。
if (sealed) return true;
if (complete || promptReady) return true;
return Number(appliedCount) > 0;
}