diff --git a/README.en.md b/README.en.md index 1cda16b..e218c29 100644 --- a/README.en.md +++ b/README.en.md @@ -94,10 +94,10 @@ The toggle state is saved in the profile's `cordis.patch.yml` and takes effect o ```sh # Install on DSH Web -dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.11 +dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.12 # Install on DSH Desktop -dsh plugin --profile desktop add github:yexi-by/dsh-unrestricted#v0.2.11 +dsh plugin --profile desktop add github:yexi-by/dsh-unrestricted#v0.2.12 ``` Restart `dsh web` or DSH Desktop after installing, then follow [Usage](#usage) to enable it. @@ -108,7 +108,7 @@ Use the update controls in DSH’s built-in plugin manager, or the CLI commands ```sh dsh plugin --profile web remove dsh-unrestricted -dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.11 +dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.12 ``` Restart `dsh web` or DSH Desktop. @@ -138,6 +138,7 @@ Make sure both switches are turned on after installation: The settings card also provides: +- **Strip Host Brand Identity**: An independent option that removes `DeepSeek Harness` / `DSH` identity sections and Web GUI checkout context from assembled prompts to reduce upstream proxy client-fingerprinting blocks. - **Mode Coverage & Prompt Preview**: Shows active status for Standard, PTC, Cordis, and Minimal modes, with expandable full-prompt preview and one-click copy. --- diff --git a/README.ja.md b/README.ja.md index 69d0527..3788967 100644 --- a/README.ja.md +++ b/README.ja.md @@ -94,10 +94,10 @@ DSH のセクション名(`deployment:persona-prefix`、`plan:policy`、`tools ```sh # DSH Web へのインストール -dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.11 +dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.12 # DSH Desktop へのインストール -dsh plugin --profile desktop add github:yexi-by/dsh-unrestricted#v0.2.11 +dsh plugin --profile desktop add github:yexi-by/dsh-unrestricted#v0.2.12 ``` インストール後に `dsh web` または DSH Desktop を再起動し、下記の[使い方](#使い方)に従って有効化します。 @@ -108,7 +108,7 @@ dsh plugin --profile desktop add github:yexi-by/dsh-unrestricted#v0.2.11 ```sh dsh plugin --profile web remove dsh-unrestricted -dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.11 +dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.12 ``` 更新後に `dsh web` または DSH Desktop を再起動します。 @@ -138,6 +138,7 @@ dsh plugin --profile web add file:D:/work/dsh/plugin/unrestricted 設定カードでは以下の項目も確認できます: +- **ホストブランド識別子の非表示**:破限スイッチとは独立して動作し、システムプロンプトおよび実行時コンテキストから `DeepSeek Harness` / `DSH` の識別セクションや Web GUI 開発パスを除去して、上流プロキシによるクライアント指紋判定を抑制します。 - **モード状態とプロンプトプレビュー**:Standard、PTC、Cordis、Minimal の 4 モードの状態表示、完全なシステムプロンプトの展開プレビューおよびワンクリックコピー。 --- diff --git a/README.md b/README.md index 029dd8a..50ba031 100644 --- a/README.md +++ b/README.md @@ -94,10 +94,10 @@ DSH 发起请求时会先组装全局系统提示词(System Prompt)。在普 ```sh # Web 端安装指定版本 -dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.11 +dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.12 # 桌面端安装指定版本(使用桌面端内置 CLI) -& "$env:LOCALAPPDATA\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd" plugin --profile desktop add github:yexi-by/dsh-unrestricted#v0.2.11 +& "$env:LOCALAPPDATA\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd" plugin --profile desktop add github:yexi-by/dsh-unrestricted#v0.2.12 ``` 安装后重启 `dsh web` 或 DSH 桌面端,按下方[使用说明](#使用说明)启用。 @@ -108,7 +108,7 @@ dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.11 ```sh dsh plugin --profile web remove dsh-unrestricted -dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.11 +dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.12 ``` 更新后重启 `dsh web` 或 DSH 桌面端。 @@ -138,6 +138,7 @@ dsh plugin --profile web add file:D:/work/dsh/plugin/unrestricted 设置卡片中同时提供: +- **隐藏宿主品牌标识**:独立于破限主开关的去指纹选项,开启后自动移除系统提示词与运行时上下文中的 `DeepSeek Harness` / `DSH` 身份段落及开发界面路径,减少上游反代触发客户端特征检测。 - **模式覆盖与提示词预览**:显示 Standard、PTC、Cordis、Minimal 四种模式的生效状态,支持展开查看或一键复制各模式最终生成的完整系统提示词。 --- diff --git a/docs/prompt-fusion.en.md b/docs/prompt-fusion.en.md index 7e0c6be..6f64463 100644 --- a/docs/prompt-fusion.en.md +++ b/docs/prompt-fusion.en.md @@ -69,10 +69,13 @@ Each DSH preset structures its prompt sections differently: ## 4. Structural Fusion & Prompt Preview ### Structural Section Fusion -During assembly, the plugin locates and fuses prompt sections by DSH's canonical section names (`deployment:persona-prefix`, `plan:policy`, `tools:ptc-only`, `tool:structured_output`) with idempotency guards, supporting both DSH Web and DSH Desktop without brittle exact-string or hash checks. If a custom preset omits the persona section, it safely falls back to the stock prompt. +During assembly, the plugin locates and fuses prompt sections by DSH's canonical section names (`deployment:persona-prefix`, `plan:policy`, `tools:ptc-only`, `tool:structured_output`) with idempotency guards, supporting both DSH Web and DSH Desktop without brittle exact-string or hash checks. Additional preset ids can be opted in via `extraPresets`; if a preset omits the persona section, it safely falls back to the stock prompt. + +### Host Brand Identity Stripping (Optional) +When **Strip host brand identity** (`stripHostIdentity`) is enabled, the pipeline drops `harness:identity`, `harness:source`, and `app:web-surface` sections plus matching runtime contexts, and neutralizes residual `DeepSeek Harness` / `DSH` brand strings in retained sections (works independently of the main toggle). ### Prompt preview -The settings UI queries an RPC endpoint to preview the full assembled system prompt, line count, and byte size for each mode. Version checks and installation use DSH’s built-in plugin manager. +The settings UI queries an RPC endpoint to assemble live baseline previews of the full system prompt, line count, and byte size for each mode (reflecting the strip-identity toggle). Version checks and installation use DSH’s built-in plugin manager. --- diff --git a/docs/prompt-fusion.ja.md b/docs/prompt-fusion.ja.md index 7ca66af..d8fe61e 100644 --- a/docs/prompt-fusion.ja.md +++ b/docs/prompt-fusion.ja.md @@ -69,10 +69,13 @@ DSH の各実行モードに応じてプロンプトセクションを処理し ## 4. 構造化融合とプロンプトプレビュー ### 構造化セクション融合 -組み立て時には DSH の標準セクション名(`deployment:persona-prefix`、`plan:policy`、`tools:ptc-only`、`tool:structured_output`)に基づいて冪等に融合を行うため、文面のハッシュ照合に依存せず DSH Web と DSH Desktop の双方で安定して動作します。カスタムプリセットにペルソナセクションがない場合は自動的に標準プロンプトへフォールバックします。 +組み立て時には DSH の標準セクション名(`deployment:persona-prefix`、`plan:policy`、`tools:ptc-only`、`tool:structured_output`)に基づいて冪等に融合を行うため、文面のハッシュ照合に依存せず DSH Web と DSH Desktop の双方で安定して動作します。`extraPresets` 設定で追加のプリセット名にも対応し、ペルソナセクションがない場合は自動的に標準プロンプトへフォールバックします。 + +### ホストブランド識別子の除去(オプション) +**ホストブランド識別子の非表示**(`stripHostIdentity`)を有効にすると、`harness:identity`・`harness:source`・`app:web-surface` セクションおよび対応する実行時コンテキストを除去し、残存セクション内の `DeepSeek Harness` / `DSH` 表記を中立的な表現へ置換します(メインスイッチとは独立して動作します)。 ### プロンプトプレビュー -設定画面から RPC エンドポイントを通じて各モードのシステムプロンプト全文、総行数、サイズをプレビューできます。バージョン確認とインストールには DSH 標準のプラグイン管理画面を使用します。 +設定画面から RPC エンドポイントを通じて各モードのシステムプロンプト全文、総行数、サイズを基準スコープから都度プレビューできます(識別子除去スイッチも反映されます)。バージョン確認とインストールには DSH 標準のプラグイン管理画面を使用します。 --- diff --git a/docs/prompt-fusion.md b/docs/prompt-fusion.md index e13a421..3d12e7e 100644 --- a/docs/prompt-fusion.md +++ b/docs/prompt-fusion.md @@ -69,10 +69,13 @@ DSH 不同运行模式下的提示词分块结构不同,插件分别处理如 ## 4. 结构化融合与状态预览 ### 结构化段落融合 -每次组装时,插件按 DSH 官方系统提示词的结构化段落名称(`deployment:persona-prefix`、`plan:policy`、`tools:ptc-only`、`tool:structured_output`)进行定位与幂等融合,不依赖脆弱的逐字文本比对或哈希校验,同时兼容 DSH Web 与 DSH 桌面端。若自定义模式不包含角色设定段落,则自动保留官方原版提示词并在设置界面提示。 +每次组装时,插件按 DSH 官方系统提示词的结构化段落名称(`deployment:persona-prefix`、`plan:policy`、`tools:ptc-only`、`tool:structured_output`)进行定位与幂等融合,不依赖脆弱的逐字文本比对或哈希校验,同时兼容 DSH Web 与 DSH 桌面端。可通过 `extraPresets` 配置扩展预设名称支持动态按结构融合;若目标预设不包含角色设定段落,则自动保留官方原版提示词并在设置界面提示。 + +### 宿主品牌标识剥离(可选) +启用「隐藏宿主品牌标识(`stripHostIdentity`)」后,流水线会移除 `harness:identity`、`harness:source`、`app:web-surface` 分块以及对应运行时上下文,并将残留分块中的 `DeepSeek Harness`、`DSH` 等宿主品牌字眼替换为中性表述(可独立于破限主开关生效)。 ### 提示词预览 -前端设置卡片通过 RPC 接口预览各运行模式组装后的完整系统提示词、总行数与体积。版本检查和安装统一使用 DSH 原生插件管理页。 +前端设置卡片通过 RPC 接口实时按基准作用域生成各运行模式组装后的完整系统提示词、总行数与体积预览(并同步反映去标识开关状态)。版本检查和安装统一使用 DSH 原生插件管理页。 --- diff --git a/lib/client.js b/lib/client.js index 69b9b0b..d0040c9 100644 --- a/lib/client.js +++ b/lib/client.js @@ -25,6 +25,7 @@ window.__ModuleLoader__.load({ const settings = ctx.configForms.get(SETTINGS_NS); let snapshot = { enabled: false, + stripHostIdentity: false, writable: false, settingsStatus: "loading", status: null, @@ -45,9 +46,11 @@ window.__ModuleLoader__.load({ function publish() { const settingsSnapshot = settings.getSnapshot(); const enabled = settingsSnapshot.value?.enabled === true; - if (enabled !== snapshot.enabled) invalidatePreviews(); + const stripHostIdentity = settingsSnapshot.value?.stripHostIdentity === true; + if (enabled !== snapshot.enabled || stripHostIdentity !== snapshot.stripHostIdentity) invalidatePreviews(); snapshot = { enabled, + stripHostIdentity, writable: settingsSnapshot.writable, settingsStatus: settingsSnapshot.status, status: snapshot.status, @@ -103,10 +106,10 @@ window.__ModuleLoader__.load({ function refresh(clearPreviews = false) { return readStatus("status", clearPreviews); } - function setEnabled(enabled) { + function updateSetting(field, value) { return whileBusy(async () => { try { - await settings.set("enabled", enabled); + await settings.set(field, value); await refresh(true); } catch (error) { snapshot = { @@ -116,6 +119,12 @@ window.__ModuleLoader__.load({ } }); } + function setEnabled(enabled) { + return updateSetting("enabled", enabled); + } + function setStripHostIdentity(strip) { + return updateSetting("stripHostIdentity", strip); + } function recheck() { return readStatus("recheck", true); } @@ -172,6 +181,7 @@ window.__ModuleLoader__.load({ return { face: () => ({ hooks: { view }, setEnabled, + setStripHostIdentity, recheck, refresh: () => refresh(true), loadPreview @@ -190,6 +200,9 @@ window.__ModuleLoader__.load({ summaryValidationFailed: "部分模式未生效", description: "开启后,各运行模式与委派子代理的系统提示词将自动融合无限制本地执行契约;关闭即恢复 DSH 原版提示词。切换从下一次请求生效,不改动正在执行的请求、工具定义、权限配置与会话历史。", toggle: "启用破限模式", + stripHostBadge: "已隐去宿主标识", + stripHostTitle: "隐藏宿主品牌标识", + stripHostDesc: "移除系统提示词与运行时上下文中的 DeepSeek Harness / DSH 身份段落及开发界面路径,降低上游反代客户端指纹拦截概率(可独立于破限开关生效)。", scopeNote: "仅作用于由 DSH 组装的系统提示词;模型平台或外部网关的远端策略不在本插件覆盖范围内。", statusTitle: "模式覆盖与提示词预览", statusSubtitle: "覆盖全部 4 种预设及委派子代理,可随时展开核对或复制融合后的完整提示词。", @@ -238,6 +251,9 @@ window.__ModuleLoader__.load({ summaryValidationFailed: "Partial mode coverage", description: "When enabled, system prompts across all modes and delegated subagents are fused with the unrestricted local execution contract; disabling restores the stock DSH prompt immediately. Takes effect from the next request without altering in-flight turns, tool schemas, permissions, or session history.", toggle: "Enable unrestricted mode", + stripHostBadge: "Host identity stripped", + stripHostTitle: "Strip host brand identity", + stripHostDesc: "Remove DeepSeek Harness / DSH identity sections and Web GUI checkout context from assembled prompts to reduce upstream proxy client-fingerprinting blocks (works independently of the main toggle).", scopeNote: "Applies only to system prompts assembled by DSH; upstream model provider policies outside the prompt are out of scope.", statusTitle: "Mode Coverage & Prompt Preview", statusSubtitle: "Covers all 4 built-in presets and delegated subagents. Expand any mode to inspect or copy the full fused prompt.", @@ -368,6 +384,23 @@ window.__ModuleLoader__.load({ color: var(--dsw-alias-label-tertiary); } +.dsh-unrestricted-optionRow { + display: flex; + align-items: center; + justify-content: space-between; + gap: 12px 16px; + padding-top: 12px; + border-top: 1px solid var(--dsw-alias-border-l3, var(--dsw-alias-border-l2)); +} + +.dsh-unrestricted-optionCopy { + display: flex; + flex: 1; + min-width: 0; + flex-direction: column; + gap: 3px; +} + .dsh-unrestricted-banner { margin: 0; border: 1px solid var(--dsw-alias-border-l2); @@ -672,14 +705,21 @@ window.__ModuleLoader__.load({ className: "dsh-unrestricted-header", children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { className: "dsh-unrestricted-headerTitle", - children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { - id: "dsh-unrestricted-main-title", - className: "dsh-unrestricted-title", - children: t("title") - }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, { - tone: summaryTone, - children: t(summaryKey) - })] + children: [ + /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { + id: "dsh-unrestricted-main-title", + className: "dsh-unrestricted-title", + children: t("title") + }), + /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, { + tone: summaryTone, + children: t(summaryKey) + }), + view.settingsStatus === "ready" && view.stripHostIdentity && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, { + tone: "outline", + children: t("stripHostBadge") + }) + ] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { className: "dsh-unrestricted-headerControls", children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { @@ -703,6 +743,26 @@ window.__ModuleLoader__.load({ className: "dsh-unrestricted-note", children: t("scopeNote") }), + /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { + className: "dsh-unrestricted-optionRow", + children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { + className: "dsh-unrestricted-optionCopy", + children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { + className: "dsh-unrestricted-modeName", + children: t("stripHostTitle") + }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { + className: "dsh-unrestricted-note", + children: t("stripHostDesc") + })] + }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Switch, { + checked: view.stripHostIdentity, + disabled: !view.writable || view.settingsStatus !== "ready" || view.busy, + label: t("stripHostTitle"), + onChange: (checked) => { + props.setStripHostIdentity(checked); + } + })] + }), view.settingsStatus === "loading" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { className: "dsh-unrestricted-note", role: "status", diff --git a/lib/client.js.map b/lib/client.js.map index a5e3912..a99d211 100644 --- a/lib/client.js.map +++ b/lib/client.js.map @@ -1 +1 @@ -{"version":3,"file":"client.js","names":["useState","writeClipboard","Tag","Switch","Button","StateDot","fileSizeText"],"sources":["../src/client/controller.ts","../src/client/locales.ts","../src/client/styles.ts","../src/client/UnrestrictedCard.tsx","../src/client/index.tsx"],"sourcesContent":["/**\n * Browser-half controller for the unrestricted card: binds the `unrestricted`\n * settings namespace (the toggle) and reads per-preset state and previews.\n */\nimport type { Context } from '@deepseek-ai/cordis'\nimport type { ConnectionHandle } from '@deepseek-ai/dsh-client-connection/client'\n// Type-only: the ctx.remote Context merge and the forwarded-event key face.\nimport type {} from '@deepseek-ai/dsh-api-remotes/client'\n// Type-only: the ctx.configForms Context merge.\nimport type {} from '@deepseek-ai/dsh-client-ui-settings/client'\n\n/** The toggle section stored in the `unrestricted` settings namespace. */\nexport interface UnrestrictedSettings {\n enabled?: boolean\n}\n\n/** Per-preset fusion state reported by the host half. */\nexport interface UnrestrictedModeState {\n state: 'off' | 'active' | 'failed'\n issues: string[]\n}\n\n/** Host status endpoint payload. */\nexport interface UnrestrictedStatus {\n enabled: boolean\n /** Current plugin version reported by the host half. */\n version?: string\n modes: Record\n}\n\n/** Deploy preview for one preset: what switching on would actually assemble. */\nexport interface UnrestrictedPreview {\n presetId: string\n available: boolean\n /** `live` = bytes a live agent received; `standing` = preset scope, no agent bound. */\n source?: 'live' | 'standing'\n /** Fused prompt text; present when available. */\n text?: string\n bytes?: number\n lines?: number\n /** Structured error code when unavailable. */\n errorCode?: string\n /** Diagnostic reason when unavailable. */\n reason?: string\n}\n\n/** One fetched preview, keyed by preset, plus its in-flight/error state. */\nexport interface UnrestrictedPreviewEntry {\n status: 'loading' | 'ready' | 'failed'\n preview?: UnrestrictedPreview\n errorCode?: string\n message?: string\n}\n\n/** Full view snapshot the card subscribes to. */\nexport interface UnrestrictedViewSnapshot {\n /** Persisted toggle; false until the settings scope first syncs. */\n enabled: boolean\n /** Whether the Host document accepts writes. */\n writable: boolean\n /** Settings scope sync state. */\n settingsStatus: 'loading' | 'ready' | 'unavailable'\n /** Live host status; null until the first RPC answer. */\n status: UnrestrictedStatus | null\n /** presetId -> fetched deploy preview. */\n previews: Record\n /** Whether a settings write or status refresh is in flight. */\n busy: boolean\n /** Last transport/business failure, if any. */\n message?: string\n}\n\n/** Minimal RPC wire shape (structural copy of the host RpcResult). */\ntype RpcResult = { ok: true; value: T } | { ok: false; error: { code: string; message: string } }\n\n/** Minimal observable contract consumed by the slot renderer's hook binding. */\nexport interface UnrestrictedViewSource {\n getSnapshot(): UnrestrictedViewSnapshot\n subscribe(listener: () => void): () => void\n}\n\n/** Inject face handed to the card at registration. */\nexport interface UnrestrictedCardInjected {\n hooks: {\n /** Reactive card view. */\n view: UnrestrictedViewSource\n }\n /** Persist the toggle. */\n setEnabled: (enabled: boolean) => Promise\n /** Re-validate runtime state and refresh. */\n recheck: () => Promise\n /** Re-read host status and invalidate cached previews. */\n refresh: () => Promise\n /** Fetch the exact fused prompt this preset would deploy. */\n loadPreview: (presetId: string) => Promise\n}\n\nconst RPC_CHANNEL = '/api'\nconst RPC_NAMESPACE = 'dsh-unrestricted'\nconst SETTINGS_NS = 'unrestricted'\n\n/** Human-readable error text for the banner. */\nfunction messageOf(error: unknown): string {\n return error instanceof Error ? error.message : String(error)\n}\n\n/**\n * Create the card controller bound to the calling plugin's context.\n * @param ctx - the browser plugin context (connection + remote + configForms injected).\n * @returns the controller whose face() feeds the slot inject share.\n */\nexport function createUnrestrictedController(ctx: Context) {\n const connection = ctx.get('connection') as ConnectionHandle\n const settings = ctx.configForms.get(SETTINGS_NS)\n\n let snapshot: UnrestrictedViewSnapshot = {\n enabled: false,\n writable: false,\n settingsStatus: 'loading',\n status: null,\n previews: {},\n busy: false,\n }\n const listeners = new Set<() => void>()\n const previewRequests = new Map()\n let statusGeneration = 0\n let pendingOperations = 0\n\n const view: UnrestrictedViewSource = {\n getSnapshot: () => snapshot,\n subscribe: (listener) => {\n listeners.add(listener)\n return () => listeners.delete(listener)\n },\n }\n\n function publish(): void {\n const settingsSnapshot = settings.getSnapshot()\n const enabled = settingsSnapshot.value?.enabled === true\n if (enabled !== snapshot.enabled) invalidatePreviews()\n snapshot = {\n enabled,\n writable: settingsSnapshot.writable,\n settingsStatus: settingsSnapshot.status,\n status: snapshot.status,\n previews: snapshot.previews,\n busy: pendingOperations > 0,\n message: snapshot.message,\n }\n for (const listener of listeners) listener()\n }\n\n function invalidatePreviews(): void {\n previewRequests.clear()\n snapshot = { ...snapshot, previews: {} }\n }\n\n async function call(endpoint: string, payload: unknown): Promise {\n const result = await connection.rpc.call(\n RPC_CHANNEL,\n `${RPC_NAMESPACE}/${endpoint}`,\n payload,\n ) as RpcResult\n if (!result.ok) throw new Error(result.error.message)\n return result.value\n }\n\n async function whileBusy(action: () => Promise): Promise {\n pendingOperations++\n publish()\n try {\n await action()\n } finally {\n pendingOperations--\n publish()\n }\n }\n\n function readStatus(endpoint: 'status' | 'recheck', clearPreviews: boolean): Promise {\n const generation = ++statusGeneration\n return whileBusy(async () => {\n try {\n const status = await call(endpoint, {})\n if (generation !== statusGeneration) return\n if (clearPreviews) invalidatePreviews()\n snapshot = {\n ...snapshot,\n status,\n message: undefined,\n }\n } catch (error) {\n if (generation !== statusGeneration) return\n snapshot = { ...snapshot, message: messageOf(error) }\n }\n })\n }\n\n function refresh(clearPreviews = false): Promise {\n return readStatus('status', clearPreviews)\n }\n\n function setEnabled(enabled: boolean): Promise {\n return whileBusy(async () => {\n try {\n await settings.set('enabled', enabled)\n await refresh(true)\n } catch (error) {\n snapshot = { ...snapshot, message: messageOf(error) }\n }\n })\n }\n\n function recheck(): Promise {\n return readStatus('recheck', true)\n }\n\n /**\n * Fetch one preset's deploy preview.\n * @param presetId - preset id from the card's row.\n */\n async function loadPreview(presetId: string): Promise {\n const request = Symbol(presetId)\n previewRequests.set(presetId, request)\n snapshot = {\n ...snapshot,\n previews: { ...snapshot.previews, [presetId]: { status: 'loading' } },\n }\n publish()\n try {\n const preview = await call('preview', { presetId })\n if (previewRequests.get(presetId) !== request) return\n snapshot = {\n ...snapshot,\n previews: { ...snapshot.previews, [presetId]: { status: 'ready', preview } },\n }\n } catch (error) {\n if (previewRequests.get(presetId) !== request) return\n snapshot = {\n ...snapshot,\n previews: {\n ...snapshot.previews,\n [presetId]: {\n status: 'failed',\n errorCode: 'preview-failed',\n message: messageOf(error),\n },\n },\n }\n }\n publish()\n }\n\n ctx.effect(\n () => settings.subscribe(publish),\n 'dsh-unrestricted: settings mirror',\n )\n ctx.effect(\n () => ctx.remote.$on('settings/document-updated', (namespace?: string) => {\n if (namespace === undefined || namespace === SETTINGS_NS) void refresh(true)\n }),\n 'dsh-unrestricted: settings invalidations',\n )\n\n publish()\n void refresh()\n return {\n face: (): UnrestrictedCardInjected => ({\n hooks: { view },\n setEnabled,\n recheck,\n refresh: () => refresh(true),\n loadPreview,\n }),\n }\n}\n","/** Copy dictionaries for the unrestricted settings card and detail badge. */\n\n/** Simplified Chinese dictionary and key source of truth. */\nexport const zh = {\n title: '破限模式',\n summaryEnabled: '已开启',\n summaryDisabled: '已关闭',\n summaryLoading: '读取中',\n summaryUnavailable: '只读模式',\n summaryValidationFailed: '部分模式未生效',\n description: '开启后,各运行模式与委派子代理的系统提示词将自动融合无限制本地执行契约;关闭即恢复 DSH 原版提示词。切换从下一次请求生效,不改动正在执行的请求、工具定义、权限配置与会话历史。',\n toggle: '启用破限模式',\n scopeNote: '仅作用于由 DSH 组装的系统提示词;模型平台或外部网关的远端策略不在本插件覆盖范围内。',\n statusTitle: '模式覆盖与提示词预览',\n statusSubtitle: '覆盖全部 4 种预设及委派子代理,可随时展开核对或复制融合后的完整提示词。',\n modeStandard: 'Standard 标准模式',\n modeStandardDesc: '日常编码、逆向分析、脚本编写与综合问答',\n modePtc: 'PTC 编程模式',\n modePtcDesc: '基于 run_code 工具链的程序化任务执行',\n modeCordis: 'Cordis 创造模式',\n modeCordisDesc: 'DSH 与 Cordis 插件生态开发调试',\n modeMinimal: 'Minimal 极简模式',\n modeMinimalDesc: '零内置先验的纯净系统提示词与子代理基座',\n subagentNote: '子代理(含结构化输出子代理)随所属会话模式一并生效。',\n stateActive: '已生效',\n stateOff: '待命',\n stateValidationFailed: '已跳过(缺少角色段落)',\n refresh: '刷新状态',\n presetStandard: 'standard',\n presetPtc: 'ptc',\n presetCordis: 'cordis',\n presetMinimal: 'minimal',\n showPreview: '查看提示词',\n hidePreview: '收起预览',\n copyPreview: '复制全文',\n copiedPreview: '已复制',\n previewLoading: '正在生成当前模式的提示词预览…',\n previewUnavailable: '暂无法生成预览:',\n previewSize: '行',\n previewSourceLive: '当前会话实时组装',\n previewSourceStanding: '预设基准组装',\n settingsUnavailable: '当前连接处于只读模式,无法修改设置。',\n settingsLoading: '正在读取配置…',\n operationFailed: '操作失败:',\n issuePersona: '未检测到预设角色前缀段落,已自动保留原版提示词',\n errorRpcDisconnected: '无法连接宿主服务,请确认 DSH 正在运行后刷新重试。',\n errorUnsupportedPreset: '不支持该预设模式的提示词预览。',\n errorMissingPersona: '当前预设未包含角色前缀段落,已自动保留原版提示词。',\n errorPreviewFailed: '生成提示词预览失败,请稍后刷新重试。',\n} satisfies Record\n\n/** Unrestricted card locale key union. */\nexport type UnrestrictedLocaleKey = keyof typeof zh\n\n/** English dictionary checked against the Chinese key set. */\nexport const en = {\n title: 'Unrestricted Mode',\n summaryEnabled: 'Enabled',\n summaryDisabled: 'Disabled',\n summaryLoading: 'Loading',\n summaryUnavailable: 'Read-only',\n summaryValidationFailed: 'Partial mode coverage',\n description: 'When enabled, system prompts across all modes and delegated subagents are fused with the unrestricted local execution contract; disabling restores the stock DSH prompt immediately. Takes effect from the next request without altering in-flight turns, tool schemas, permissions, or session history.',\n toggle: 'Enable unrestricted mode',\n scopeNote: 'Applies only to system prompts assembled by DSH; upstream model provider policies outside the prompt are out of scope.',\n statusTitle: 'Mode Coverage & Prompt Preview',\n statusSubtitle: 'Covers all 4 built-in presets and delegated subagents. Expand any mode to inspect or copy the full fused prompt.',\n modeStandard: 'Standard',\n modeStandardDesc: 'General coding, reverse engineering, scripting, and technical Q&A',\n modePtc: 'PTC Mode',\n modePtcDesc: 'Programmatic tool calling via the run_code execution environment',\n modeCordis: 'Cordis Mode',\n modeCordisDesc: 'DSH and Cordis plugin development and framework debugging',\n modeMinimal: 'Minimal Mode',\n modeMinimalDesc: 'Zero-prior minimal system prompt and subagent foundation',\n subagentNote: 'Subagents (including structured-output subagents) automatically follow their parent mode.',\n stateActive: 'Active',\n stateOff: 'Standby',\n stateValidationFailed: 'Skipped (missing persona section)',\n refresh: 'Refresh',\n presetStandard: 'standard',\n presetPtc: 'ptc',\n presetCordis: 'cordis',\n presetMinimal: 'minimal',\n showPreview: 'Preview prompt',\n hidePreview: 'Hide preview',\n copyPreview: 'Copy prompt',\n copiedPreview: 'Copied',\n previewLoading: 'Assembling prompt preview…',\n previewUnavailable: 'Preview unavailable: ',\n previewSize: 'lines',\n previewSourceLive: 'Live session assembly',\n previewSourceStanding: 'Preset baseline assembly',\n settingsUnavailable: 'This connection is read-only and cannot modify settings.',\n settingsLoading: 'Loading configuration…',\n operationFailed: 'Operation failed: ',\n issuePersona: 'Preset persona section not found — stock prompt kept',\n errorRpcDisconnected: 'Cannot reach the host service. Please verify DSH is running and refresh.',\n errorUnsupportedPreset: 'Prompt preview is not supported for this preset.',\n errorMissingPersona: 'The preset is missing a persona prefix section; the stock prompt is kept.',\n errorPreviewFailed: 'Could not assemble the prompt preview. Please try refreshing.',\n} satisfies Record\n\n/** Dictionary namespace owned by this plugin. */\nexport const NS = 'settings.unrestricted'\n","/**\n * Stylesheet for the unrestricted settings card. Injected once as a single\n *