diff --git a/.gitignore b/.gitignore
index d3e1c50..6078671 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,11 @@ npm-debug.log*
.DS_Store
Thumbs.db
+# 本地草稿,不进仓库
+scripts/tmp-*.mjs
+scripts/test-*.mjs
+dsh-redteam-mode-main/
+
# 外部参考,不是本插件
choirboy-prompt/
/choirboy-prompt/
diff --git a/README.md b/README.md
index 9af6d38..0563bb1 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
⚔️ DeepSeek Harness cybersecurity red-team tool (dsh-purge)
-Version 1.1.54
+Version 1.1.55
Local official DeepSeek Harness cybersecurity red-team plugin. Clean host policy, and ship a built-in drill console. Swap prompts per model. Default prompt for Chinese models — 小码酱. Please star ⭐
@@ -118,7 +118,7 @@ This release supports **DeepSeek Harness 0.2** only (official desktop **0.2.0-rc
| Official Harness 0.1.x | Not supported |
| Any other version | Unmatched patches stay pending or skipped; do not expect them to work |
-The plugin version is **1.1.54**. 1.1.45 is skipped; it has bugs.
+The plugin version is **1.1.55**. 1.1.45 is skipped; it has bugs.
---
@@ -220,13 +220,13 @@ dsh plugin --profile default add https://github.com/YuJunZhiXue/dsh-purge/archiv
🌐 Open Hub page
·
- 🚀 Install in desktop client
+ 🚀 Install in desktop client
🔗 **Raw protocol URL:**
```
-dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.54&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz
+dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.55&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz
```
@@ -242,7 +242,7 @@ export function installDshPurgeToDesktop() {
const params = new URLSearchParams({
id: 'dsh-purge',
name: 'dsh-purge',
- version: '1.1.54',
+ version: '1.1.55',
repo: 'YuJunZhiXue/dsh-purge',
permissions: '系统提示词注入, 本机补丁, 设置页',
downloadUrl: 'https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz',
@@ -261,7 +261,7 @@ export function installDshPurgeToDesktop() {
**HTML link:**
```html
-
+
🚀 Install in desktop client
```
@@ -272,7 +272,7 @@ export function installDshPurgeToDesktop() {
|---|---|---|
| id | `dsh-purge` | Plugin id |
| name | `dsh-purge` | Display name |
-| version | `1.1.54` | Semver |
+| version | `1.1.55` | Semver |
| repo | `YuJunZhiXue/dsh-purge` | GitHub repo |
| permissions | `系统提示词注入, 本机补丁, 设置页` | Requested permissions |
| downloadUrl | `https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz` | GitHub source archive |
diff --git a/README.zh-CN.md b/README.zh-CN.md
index 0b6034f..8962e88 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -4,7 +4,7 @@
⚔️ DeepSeek Harness 网络安全红队工具(dsh-purge)
-Version 1.1.54
+Version 1.1.55
本机官方 DeepSeek Harness 网络安全红队评测插件。清洗宿主策略,并带内嵌演练台。不同模型可换不同提示词。默认提示词面向国模「小码酱」。求 Star 收藏 ⭐
@@ -118,7 +118,7 @@ Harness 不只是把问题交给模型。它还会在运行时改提示词、审
| 官方 Harness 0.1.x | 不支持 |
| 其它未列出版本 | 对不上的补丁会显示待应用或跳过,不要指望能用 |
-插件版本是 **1.1.54**。1.1.45 有问题,略过。
+插件版本是 **1.1.55**。1.1.45 有问题,略过。
---
@@ -220,13 +220,13 @@ dsh plugin --profile default add https://github.com/YuJunZhiXue/dsh-purge/archiv
🌐 打开插件市场页
·
- 🚀 唤起客户端一键安装
+ 🚀 唤起客户端一键安装
🔗 **原生协议链接:**
```
-dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.54&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz
+dsh://plugin/install?id=dsh-purge&name=dsh-purge&version=1.1.55&repo=YuJunZhiXue%2Fdsh-purge&permissions=%E7%B3%BB%E7%BB%9F%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%B3%A8%E5%85%A5%2C%E6%9C%AC%E6%9C%BA%E8%A1%A5%E4%B8%81%2C%E8%AE%BE%E7%BD%AE%E9%A1%B5&downloadUrl=https%3A%2F%2Fgithub.com%2FYuJunZhiXue%2Fdsh-purge%2Farchive%2Frefs%2Fheads%2Fmaster.tar.gz
```
@@ -242,7 +242,7 @@ export function installDshPurgeToDesktop() {
const params = new URLSearchParams({
id: 'dsh-purge',
name: 'dsh-purge',
- version: '1.1.54',
+ version: '1.1.55',
repo: 'YuJunZhiXue/dsh-purge',
permissions: '系统提示词注入, 本机补丁, 设置页',
downloadUrl: 'https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz',
@@ -261,7 +261,7 @@ export function installDshPurgeToDesktop() {
**HTML 静态链接方式:**
```html
-
+
🚀 唤起客户端一键安装
```
@@ -272,7 +272,7 @@ export function installDshPurgeToDesktop() {
|---|---|---|
| id | `dsh-purge` | 插件唯一标识符 |
| name | `dsh-purge` | 插件展示名称 |
-| version | `1.1.54` | 语义化版本号 |
+| version | `1.1.55` | 语义化版本号 |
| repo | `YuJunZhiXue/dsh-purge` | GitHub 仓库 |
| permissions | `系统提示词注入, 本机补丁, 设置页` | 申请权限 |
| downloadUrl | `https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz` | GitHub 源码包地址 |
diff --git a/client.js b/client.js
index 3df0e88..6d5a54b 100644
--- a/client.js
+++ b/client.js
@@ -1429,9 +1429,7 @@ body .dshp-dock[data-theme="white"] .dshp-dock-body .rt-card,body .dshp-dock[dat
.then((r) => r.json())
.then((d) => {
if (ticket !== actionTicket.current) return;
- const posted = action === "apply" ? applyContent : override;
- const applyEmptyBlocked = action === "apply" && promptBoxEmpty(posted) && (!d || d.injectSource !== "rule");
- if (responseNeedsPrompt(d) || applyEmptyBlocked) {
+ if (responseNeedsPrompt(d)) {
rejectNeedPrompt(tr);
return;
}
@@ -1480,7 +1478,7 @@ body .dshp-dock[data-theme="white"] .dshp-dock-body .rt-card,body .dshp-dock[dat
loadAll();
return;
}
- if (action === "apply" && (d.restart_after_apply || d.restarting || d.unpacked_asar || d.needs_full_quit)) {
+ if (action === "apply" && (d.restart_after_apply || d.restarting)) {
setNotice({
kind: "ok",
text: d.asar_still_sealed ? tr("restart.asarSwap") : tr("update.restarting"),
@@ -1490,6 +1488,14 @@ body .dshp-dock[data-theme="white"] .dshp-dock-body .rt-card,body .dshp-dock[dat
restartDsh(setNotice, setPatchBusy, tr, surf);
return;
}
+ if (action === "apply" && (d.needs_full_quit || d.unpacked_asar)) {
+ setNotice({
+ kind: "ok",
+ text: d.asar_still_sealed ? tr("restart.asarSwap") : tr("ok.done"),
+ });
+ loadAll();
+ return;
+ }
setNotice({ kind: "ok", text: tr("ok.done") });
loadAll();
})
@@ -1501,18 +1507,7 @@ body .dshp-dock[data-theme="white"] .dshp-dock-body .rt-card,body .dshp-dock[dat
if (ticket === actionTicket.current) setPatchBusy(false);
});
};
- if (action !== "apply") {
- run();
- return;
- }
- bothInjectEmpty(overrideRef.current, defaultOverrideRef.current).then((empty) => {
- if (ticket !== actionTicket.current) return;
- if (empty) {
- rejectNeedPrompt(tr);
- return;
- }
- run();
- });
+ run();
}, [loadAll, rejectNeedPrompt]);
const saveOverride = useCallback(() => {
diff --git a/lib/index.js b/lib/index.js
index e36a64b..f9cd1ef 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -20,6 +20,7 @@ import * as uninstaller from "./uninstall.js";
import { installRegionGate, readAllowText, writeAllowText } from "./net-scope.js";
import * as refusalRecover from "./refusal-recover.js";
import {
+ applyShouldRestart,
isInactiveContextError,
settleDelayMs,
settleMayReapply,
@@ -203,9 +204,17 @@ function rejectIfNeedPrompt(dshHome, boxText) {
}
async function ensureRestartReady() {
- const inject = rules.resolveInjectText(core.findDshHome());
+ const home = core.findDshHome();
+ try { core.seedOverrideSync(home); } catch { /* 仍可读内置默认 */ }
+ const inject = rules.resolveInjectText(home);
if (!inject.text) return { ok: false, error: "没有可注入的提示词,已取消重启" };
- return core.ensureHostClean();
+ const clean = await core.ensureHostClean();
+ if (clean.ok) return clean;
+ // 密封 asar 读的是旧包,清洗写在解包目录;允许换包重启,注入靠 assemble 包装。
+ try {
+ if (core.desktopAsarStillSealed()) return { ok: true, pending: clean.pending || [] };
+ } catch { /* 非桌面 */ }
+ return clean;
}
export function registerPromptSections(ctx, config, _injectFile) {
@@ -215,7 +224,7 @@ export function registerPromptSections(ctx, config, _injectFile) {
interpolate: false,
text: (context) => {
if (!injectAllowedNow(config)) return "";
- return rules.resolveModeInject(core.findDshHome(), isRedteamSession(context));
+ return readInjectFallback(context);
},
});
@@ -249,7 +258,9 @@ export function registerPromptSections(ctx, config, _injectFile) {
}
function readInjectFallback(context) {
- return rules.resolveModeInject(core.findDshHome(), isRedteamSession(context));
+ const home = core.findDshHome();
+ try { core.seedOverrideSync(home); } catch { /* 落盘失败仍试读默认 */ }
+ return rules.resolveModeInject(home, isRedteamSession(context));
}
function installMnemonMessageStrip(ctx, config = {}) {
@@ -360,33 +371,46 @@ function installRewindDeriveFilter(ctx) {
function installIdentityOverride(ctx, config = {}) {
if (typeof ctx.on !== "function") return;
installSubagentRoleCapture(ctx);
- if (ctx.__dshPurgeAssembleHook) return;
- ctx.__dshPurgeAssembleHook = true;
- const hook = async (_assembly, context, next) => {
- const assembled = typeof next === "function" ? await next() : _assembly;
- return rewriteLiveAssembly(config, assembled, context);
- };
- // 只挂一次。不改 contexts,不改 pre-step 白名单,梁神 phase-1 和其它插件的消息原样保留。
- ctx.on("system-prompt/assemble", hook, { global: true, prepend: true });
- // 0.1.5 起 complete:true 在 waterfall 之后用调用前的快照盖掉 sections。
- // 换宿主版本时文件补丁还没写上,或换插件版本时旧钩子把 dsh-purge 段删掉,注入都会丢。
- // 包住 assemble 的返回值,按 prompt-inject.md 再补回。
const wrapAssemble = () => {
- const prompt = ctx.systemPrompt;
- if (!prompt || typeof prompt.assemble !== "function" || prompt.__dshPurgeAssembleWrapped) return false;
- const orig = prompt.assemble;
- prompt.assemble = async function (...args) {
- const assembled = await orig.apply(this, args);
- return rewriteLiveAssembly(config, assembled, args[0]);
- };
- prompt.__dshPurgeAssembleWrapped = true;
- return true;
+ try {
+ const prompt = ctx.systemPrompt;
+ if (!prompt || typeof prompt.assemble !== "function") return false;
+ if (prompt.assemble._dshPurgeWrapped) return true;
+ const orig = prompt.assemble.bind(prompt);
+ const wrapped = async function assembleWithPurge(...args) {
+ const assembled = await orig(...args);
+ return rewriteLiveAssembly(config, assembled, args[0]);
+ };
+ wrapped._dshPurgeWrapped = true;
+ prompt.assemble = wrapped;
+ return true;
+ } catch {
+ return false;
+ }
};
- if (!wrapAssemble()) {
- queueMicrotask(wrapAssemble);
- setTimeout(wrapAssemble, 500);
- setTimeout(wrapAssemble, 2000);
+ if (!ctx.__dshPurgeAssembleHook) {
+ ctx.__dshPurgeAssembleHook = true;
+ ctx.on("system-prompt/assemble", async (_assembly, context, next) => {
+ const assembled = typeof next === "function" ? await next() : _assembly;
+ return rewriteLiveAssembly(config, assembled, context);
+ }, { global: true, prepend: true });
}
+ // complete:true 会在 waterfall 之后盖掉 sections;包住 assemble 返回值,每轮都补回注入。
+ wrapAssemble();
+ const started = Date.now();
+ const timer = setInterval(() => {
+ wrapAssemble();
+ if (Date.now() - started > 20000) clearInterval(timer);
+ }, 400);
+ if (typeof timer.unref === "function") timer.unref();
+ try { ctx.effect(() => () => clearInterval(timer)); } catch { /* 无 effect 时靠 unref */ }
+ try { ctx.on("session/created", wrapAssemble); } catch { /* ignore */ }
+ try {
+ ctx.on("agent/pre-step", (payload, next) => {
+ wrapAssemble();
+ return typeof next === "function" ? next() : payload;
+ }, { global: true, prepend: true });
+ } catch { /* ignore */ }
}
function shimNeedsPatch(state) {
@@ -1503,7 +1527,13 @@ function installWebServer(ctx, cfg) {
const leaveTray = renamed || pendingQuit;
if (complete) reapply.markPatchesApplied();
if (leaveTray) bootFullQuit = true;
- const shouldRestart = complete;
+ const sealedNow = core.desktopAsarStillSealed();
+ const shouldRestart = applyShouldRestart({
+ complete,
+ sealed: sealedNow,
+ appliedCount: summary.applied,
+ });
+ if (shouldRestart) reapply.markSettleRestart();
sendJson(response, 200, {
ok: true,
complete,
@@ -1511,8 +1541,8 @@ function installWebServer(ctx, cfg) {
restart_after_apply: shouldRestart,
unpacked_asar: leaveTray,
needs_full_quit: leaveTray,
- asar_still_sealed: core.desktopAsarStillSealed(),
- asar_swap_started: Boolean(shouldRestart && handoff && core.desktopAsarStillSealed()),
+ asar_still_sealed: sealedNow,
+ asar_swap_started: Boolean(shouldRestart && handoff && sealedNow),
applied: summary.applied,
already: summary.already,
failed: summary.failed.length,
@@ -1532,7 +1562,7 @@ function installWebServer(ctx, cfg) {
cli_repair: cliRepair,
cmd_flash: flash,
});
- if (shouldRestart && handoff && core.desktopAsarStillSealed()) {
+ if (shouldRestart && handoff && sealedNow) {
setImmediate(() => {
try {
core.restartSealedDesktopIfNeeded();
@@ -1606,6 +1636,7 @@ function installWebServer(ctx, cfg) {
if (request.method === "GET") {
try {
const home = core.findDshHome();
+ try { core.seedOverrideSync(home); } catch { /* 仍可读内置默认 */ }
const ui = await core.readOverrideForUi(home);
sendJson(response, 200, { ok: true, ...ui, ...injectSnapshot(home) });
} catch (e) {
diff --git a/lib/settle-policy.js b/lib/settle-policy.js
index 7a09f82..79ce22a 100644
--- a/lib/settle-policy.js
+++ b/lib/settle-policy.js
@@ -41,3 +41,17 @@ export function settleMayReapply({ surface, sealed = false } = {}) {
if (surface === "desktop" && sealed) return false;
return true;
}
+
+/**
+ * 点「应用」后是否重启:密封 asar 还要换包就重启;否则只在这次真的写了宿主补丁时重启。
+ * 冷却不放在这里——否则第一次重启没换掉 asar,第二次应用会被当成取消。
+ */
+export function applyShouldRestart({
+ complete = false,
+ sealed = false,
+ appliedCount = 0,
+} = {}) {
+ if (!complete) return false;
+ if (sealed) return true;
+ return Number(appliedCount) > 0;
+}
diff --git a/package.json b/package.json
index 5975e0b..7255251 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "dsh-purge",
- "version": "1.1.54",
+ "version": "1.1.55",
"description": "DeepSeek Harness 网络安全红队工具:本机官方 Harness 受控评测与清洗,内嵌演练台;不同模型可换不同提示词;默认提示词面向国模「小码酱」。求 Star ⭐",
"type": "module",
"main": "lib/index.js",
diff --git a/release-notes.md b/release-notes.md
index 94d9abc..fd30f59 100644
--- a/release-notes.md
+++ b/release-notes.md
@@ -1,3 +1,19 @@
+# 1.1.55
+
+## 中文
+
+- 版本升级到 1.1.55。
+- 点「应用」并重启后,每一轮 assemble 都会把提示词补回最前;宿主换成新 assemble 也会再包一次,不会第二轮丢掉。
+- 空框不再在前端误取消应用;重启前先落下默认提示词。密封 asar 不会因为当前进程还是旧包而取消重启。
+- 第二次应用不会因为冷却把重启/注入当成取消;密封包在换掉之前每次应用都会重启一次,补丁写完后不再空转。
+
+## English
+
+- Version 1.1.55.
+- After Apply + restart, every assemble turn puts the operator prompt back at the front. If the host replaces assemble, it is wrapped again so turn 2 does not drop the inject.
+- An empty settings box no longer cancels Apply on the client; Restart seeds the default prompt first. A sealed asar no longer cancels restart just because the running process still has the old archive.
+- A second Apply is not treated as a cancel because of settle cooldown. A sealed archive still restarts on each Apply until swapped; after patches are in, it does not loop.
+
# 1.1.54
## 中文
diff --git a/scripts/test-reapply-stamp.mjs b/scripts/test-reapply-stamp.mjs
deleted file mode 100644
index 4cffd04..0000000
--- a/scripts/test-reapply-stamp.mjs
+++ /dev/null
@@ -1,65 +0,0 @@
-import assert from "node:assert/strict";
-import fs from "node:fs";
-import os from "node:os";
-import path from "node:path";
-
-const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "dsh-purge-stamp-"));
-process.env.DSH_HOME = tmp;
-
-const {
- stampMatches,
- resolveApplySha,
- markPatchesApplied,
- readAppliedStamp,
- healEmptyAppliedStamp,
- ensureInstalledRevSeed,
- shouldSkipSettleRestart,
- markSettleRestart,
- canHealEmptyStamp,
-} = await import("../lib/reapply.js");
-
-assert.equal(stampMatches({ version: "1.1.52", sha: "" }, "1.1.52", "abc"), false);
-assert.equal(stampMatches({ version: "1.1.52", sha: "abc" }, "1.1.52", "abc"), true);
-assert.equal(stampMatches({ version: "1.1.52", sha: "abc" }, "1.1.52", ""), true);
-assert.equal(stampMatches({ version: "1.1.52", sha: "apply:1.1.52" }, "1.1.52", "deadbeef"), true);
-assert.equal(stampMatches({ version: "1.1.52", sha: "abc" }, "1.1.52", "def"), false);
-assert.equal(stampMatches({ version: "1.1.51", sha: "abc" }, "1.1.52", "abc"), false);
-
-// #56:空 sha 仍不能当对齐;#57:密封/缺标记不能就地补戳。
-assert.equal(canHealEmptyStamp({ sealed: true, hasAiBase: true, markersPresent: true }), false);
-assert.equal(canHealEmptyStamp({ sealed: false, hasAiBase: true, markersPresent: false }), false);
-assert.equal(canHealEmptyStamp({ sealed: false, hasAiBase: true, markersPresent: true }), true);
-assert.equal(canHealEmptyStamp({ sealed: false, hasAiBase: false, markersPresent: false }), true);
-
-assert.equal(resolveApplySha("deadbeef"), "deadbeef");
-assert.match(resolveApplySha(""), /^(apply:|applied)/);
-
-const sha = markPatchesApplied();
-assert.ok(sha);
-assert.ok(sha.length > 0);
-const stamp = readAppliedStamp();
-assert.equal(stamp.sha, sha);
-assert.ok(stamp.sha);
-const revFile = path.join(tmp, "dsh-purge", "installed-rev");
-assert.equal(fs.readFileSync(revFile, "utf8").trim(), sha);
-assert.equal(stampMatches(stamp, stamp.version, sha), true);
-
-fs.writeFileSync(path.join(tmp, "dsh-purge", "applied.json"), `${JSON.stringify({
- version: stamp.version,
- sha: "",
- at: new Date().toISOString(),
-}, null, 2)}\n`);
-assert.equal(healEmptyAppliedStamp(), true);
-assert.ok(readAppliedStamp().sha);
-
-// #60:缺 installed-rev 时种子
-fs.rmSync(path.join(tmp, "dsh-purge", "installed-rev"), { force: true });
-const seeded = ensureInstalledRevSeed();
-assert.ok(seeded);
-assert.equal(fs.readFileSync(path.join(tmp, "dsh-purge", "installed-rev"), "utf8").trim(), seeded);
-
-assert.equal(shouldSkipSettleRestart(), false);
-markSettleRestart();
-assert.equal(shouldSkipSettleRestart(), true);
-
-console.log("ok: reapply stamp / infinite-restart guards");
diff --git a/scripts/test-settle-policy.mjs b/scripts/test-settle-policy.mjs
deleted file mode 100644
index 7df8a05..0000000
--- a/scripts/test-settle-policy.mjs
+++ /dev/null
@@ -1,50 +0,0 @@
-import assert from "node:assert/strict";
-import {
- DESKTOP_SETTLE_DELAY_MS,
- isInactiveContextError,
- settleDelayMs,
- settleMayReapply,
- settleMayRestart,
- watchContextLife,
-} from "../lib/settle-policy.js";
-
-assert.equal(settleMayRestart({ surface: "desktop", sealed: false }), false);
-assert.equal(settleMayRestart({ surface: "desktop", sealed: true }), false);
-assert.equal(settleMayRestart({ surface: "web", sealed: true }), false);
-assert.equal(settleMayRestart({ surface: "web", sealed: false }), true);
-
-assert.equal(settleMayReapply({ surface: "desktop", sealed: true }), false);
-assert.equal(settleMayReapply({ surface: "desktop", sealed: false }), true);
-assert.equal(settleMayReapply({ surface: "web", sealed: false }), true);
-
-assert.equal(settleDelayMs("desktop"), DESKTOP_SETTLE_DELAY_MS);
-assert.equal(settleDelayMs("web"), 0);
-assert.ok(DESKTOP_SETTLE_DELAY_MS >= 3000);
-
-assert.equal(isInactiveContextError({ code: "INACTIVE_EFFECT" }), true);
-assert.equal(isInactiveContextError(new Error("cannot create effect on inactive context")), true);
-assert.equal(isInactiveContextError(new Error("ENOENT")), false);
-
-const missing = watchContextLife(null);
-assert.equal(missing.alive, true);
-
-let disposed = null;
-const active = watchContextLife({
- effect(factory) {
- disposed = factory();
- },
-});
-assert.equal(active.alive, true);
-disposed();
-assert.equal(active.alive, false);
-
-const inactive = watchContextLife({
- effect() {
- const err = new Error("cannot create effect on inactive context");
- err.code = "INACTIVE_EFFECT";
- throw err;
- },
-});
-assert.equal(inactive.alive, false);
-
-console.log("ok: settle policy / inactive-context guards");