diff --git a/README.en.md b/README.en.md index 6074e88..ba62ee1 100644 --- a/README.en.md +++ b/README.en.md @@ -82,7 +82,7 @@ The plugin handles each DSH execution preset according to its prompt structure: ### Structural Fusion & Fallback -The plugin fuses sections structurally by DSH's canonical section names (`deployment:persona-prefix`, `plan:policy`, `tools:ptc-only`, `tool:structured_output`) with idempotency guards, supporting both the latest DSH Web (`0.2.2-alpha.2`) and DSH Desktop (`0.2.1-rc.5`) without brittle exact-string hash checks. If a custom preset omits the persona section, it safely falls back to the stock prompt. +The plugin fuses sections structurally by DSH's canonical section names (`deployment:persona-prefix`, `plan:policy`, `tools:ptc-only`, `tool:structured_output`) with idempotency guards, supporting both the latest DSH Web (`0.2.2-alpha.3`) and DSH Desktop (`0.2.1-rc.5`) without brittle exact-string hash checks. If a custom preset omits the persona section, it safely falls back to the stock prompt. ### Instant Toggle @@ -94,21 +94,21 @@ 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.6 +dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.7 # Install on DSH Desktop -dsh plugin --profile desktop add github:yexi-by/dsh-unrestricted#v0.2.6 +dsh plugin --profile desktop add github:yexi-by/dsh-unrestricted#v0.2.7 ``` Restart `dsh web` or DSH Desktop after installing, then follow [Usage](#usage) to enable it. #### Update -You can check and install updates directly from the **Version & Updates** card inside **Plugins → dsh-unrestricted**, or update via CLI: +Use the update controls in DSH’s built-in plugin manager, or the CLI commands below. The plugin no longer queries GitHub or runs its own pnpm installer. ```sh dsh plugin --profile web remove dsh-unrestricted -dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.6 +dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.7 ``` Restart `dsh web` or DSH Desktop. @@ -139,7 +139,6 @@ Make sure both switches are turned on after installation: The settings card also provides: - **Mode Coverage & Prompt Preview**: Shows active status for Standard, PTC, Cordis, and Minimal modes, with expandable full-prompt preview and one-click copy. -- **Version & Updates**: Automatically checks GitHub Releases for new versions, displays an update badge in the plugin detail header, and supports one-click self-update. --- diff --git a/README.ja.md b/README.ja.md index 106d4b5..083c3ba 100644 --- a/README.ja.md +++ b/README.ja.md @@ -82,7 +82,7 @@ DSH の各実行モードに合わせてプロンプトセクションを処理 ### 構造化融合とフォールバック -DSH のセクション名(`deployment:persona-prefix`、`plan:policy`、`tools:ptc-only`、`tool:structured_output`)に基づいて構造的かつ冪等に融合を行うため、最新の DSH Web(`0.2.2-alpha.2`)および DSH Desktop(`0.2.1-rc.5`)の双方で安定して動作します。ペルソナセクションが存在しない場合は自動的に標準プロンプトへフォールバックします。 +DSH のセクション名(`deployment:persona-prefix`、`plan:policy`、`tools:ptc-only`、`tool:structured_output`)に基づいて構造的かつ冪等に融合を行うため、最新の DSH Web(`0.2.2-alpha.3`)および DSH Desktop(`0.2.1-rc.5`)の双方で安定して動作します。ペルソナセクションが存在しない場合は自動的に標準プロンプトへフォールバックします。 ### 即時切り替え @@ -94,21 +94,21 @@ DSH のセクション名(`deployment:persona-prefix`、`plan:policy`、`tools ```sh # DSH Web へのインストール -dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.6 +dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.7 # DSH Desktop へのインストール -dsh plugin --profile desktop add github:yexi-by/dsh-unrestricted#v0.2.6 +dsh plugin --profile desktop add github:yexi-by/dsh-unrestricted#v0.2.7 ``` インストール後に `dsh web` または DSH Desktop を再起動し、下記の[使い方](#使い方)に従って有効化します。 #### 更新 -DSH の **「プラグイン → dsh-unrestricted」** 詳細画面にある **「バージョンと更新」** カードからワンクリックで更新を確認・適用できるほか、CLI からも更新できます: +更新には DSH 標準のプラグイン管理画面、または以下の CLI コマンドを使用します。プラグイン独自の GitHub 更新チェックと pnpm インストーラーは廃止しました。 ```sh dsh plugin --profile web remove dsh-unrestricted -dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.6 +dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.7 ``` 更新後に `dsh web` または DSH Desktop を再起動します。 @@ -139,7 +139,6 @@ dsh plugin --profile web add file:D:/work/dsh/plugin/unrestricted 設定カードでは以下の項目も確認できます: - **モード状態とプロンプトプレビュー**:Standard、PTC、Cordis、Minimal の 4 モードの状態表示、完全なシステムプロンプトの展開プレビューおよびワンクリックコピー。 -- **バージョンと更新**:GitHub Releases の新バージョン自動チェック、更新通知バッジ表示、および画面内からの手動アップデート。 --- diff --git a/README.md b/README.md index 27337e4..2619803 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ DSH 发起请求时会先组装全局系统提示词(System Prompt)。在普 ### 结构化融合与安全回退 -插件按 DSH 官方提示词的结构化段落名称(`deployment:persona-prefix`、`plan:policy`、`tools:ptc-only`、`tool:structured_output`)进行幂等融合,不依赖脆弱的逐字文案哈希校验,兼容最新 DSH Web(`0.2.2-alpha.2`)与 DSH Desktop(`0.2.1-rc.5`)。如果自定义模式缺少角色设定段落,对应模式会自动保留原版提示词并在设置页友好提示。 +插件按 DSH 官方提示词的结构化段落名称(`deployment:persona-prefix`、`plan:policy`、`tools:ptc-only`、`tool:structured_output`)进行幂等融合,不依赖脆弱的逐字文案哈希校验,兼容最新 DSH Web(`0.2.2-alpha.3`)与 DSH Desktop(`0.2.1-rc.5`)。如果自定义模式缺少角色设定段落,对应模式会自动保留原版提示词并在设置页友好提示。 ### 即时开关 @@ -94,21 +94,21 @@ DSH 发起请求时会先组装全局系统提示词(System Prompt)。在普 ```sh # Web 端安装指定版本 -dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.6 +dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.7 # 桌面端安装指定版本(使用桌面端内置 CLI) -"& '$env:LOCALAPPDATA\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd' plugin --profile desktop add github:yexi-by/dsh-unrestricted#v0.2.6" +"& '$env:LOCALAPPDATA\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd' plugin --profile desktop add github:yexi-by/dsh-unrestricted#v0.2.7" ``` 安装后重启 `dsh web` 或 DSH 桌面端,按下方[使用说明](#使用说明)启用。 #### 更新 -可在 DSH **「插件 → dsh-unrestricted」** 详情页底部的 **「版本与更新」** 卡片中点击 **「检查更新」** 与 **「立即更新」** 一键完成更新,或通过命令行手动更新: +更新统一使用 DSH 原生插件管理页的更新功能,或通过以下命令更新。插件不再自行查询 GitHub 或执行 pnpm 安装。 ```sh dsh plugin --profile web remove dsh-unrestricted -dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.6 +dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.7 ``` 更新后重启 `dsh web` 或 DSH 桌面端。 @@ -139,7 +139,6 @@ dsh plugin --profile web add file:D:/work/dsh/plugin/unrestricted 设置卡片中同时提供: - **模式覆盖与提示词预览**:显示 Standard、PTC、Cordis、Minimal 四种模式的生效状态,支持展开查看或一键复制各模式最终生成的完整系统提示词。 -- **版本与更新**:打开插件详情页时自动检测 GitHub 最新版本并在标题栏显示「可更新」提醒徽标,支持在页面内一键更新。 --- diff --git a/docs/prompt-fusion.en.md b/docs/prompt-fusion.en.md index 3ef2206..7e0c6be 100644 --- a/docs/prompt-fusion.en.md +++ b/docs/prompt-fusion.en.md @@ -71,8 +71,8 @@ Each DSH preset structures its prompt sections differently: ### 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. -### Prompt Preview & Updates -The settings UI queries an RPC endpoint to preview the full assembled system prompt, line count, and byte size for each mode, and checks GitHub Releases for one-click updates. +### 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. --- diff --git a/docs/prompt-fusion.ja.md b/docs/prompt-fusion.ja.md index dbfaaff..7ca66af 100644 --- a/docs/prompt-fusion.ja.md +++ b/docs/prompt-fusion.ja.md @@ -71,8 +71,8 @@ DSH の各実行モードに応じてプロンプトセクションを処理し ### 構造化セクション融合 組み立て時には DSH の標準セクション名(`deployment:persona-prefix`、`plan:policy`、`tools:ptc-only`、`tool:structured_output`)に基づいて冪等に融合を行うため、文面のハッシュ照合に依存せず DSH Web と DSH Desktop の双方で安定して動作します。カスタムプリセットにペルソナセクションがない場合は自動的に標準プロンプトへフォールバックします。 -### プロンプトプレビューと更新確認 -設定画面から RPC エンドポイントを通じて各モードのシステムプロンプト全文、総行数、サイズをプレビューでき、GitHub Releases の新バージョン確認とワンクリック更新にも対応しています。 +### プロンプトプレビュー +設定画面から RPC エンドポイントを通じて各モードのシステムプロンプト全文、総行数、サイズをプレビューできます。バージョン確認とインストールには DSH 標準のプラグイン管理画面を使用します。 --- diff --git a/docs/prompt-fusion.md b/docs/prompt-fusion.md index d07be03..e13a421 100644 --- a/docs/prompt-fusion.md +++ b/docs/prompt-fusion.md @@ -71,8 +71,8 @@ DSH 不同运行模式下的提示词分块结构不同,插件分别处理如 ### 结构化段落融合 每次组装时,插件按 DSH 官方系统提示词的结构化段落名称(`deployment:persona-prefix`、`plan:policy`、`tools:ptc-only`、`tool:structured_output`)进行定位与幂等融合,不依赖脆弱的逐字文本比对或哈希校验,同时兼容 DSH Web 与 DSH 桌面端。若自定义模式不包含角色设定段落,则自动保留官方原版提示词并在设置界面提示。 -### 提示词预览与版本更新 -前端设置卡片可通过 RPC 接口实时预览各运行模式组装后的完整系统提示词、总行数与体积,并支持检测 GitHub Releases 新版本与一键更新。 +### 提示词预览 +前端设置卡片通过 RPC 接口预览各运行模式组装后的完整系统提示词、总行数与体积。版本检查和安装统一使用 DSH 原生插件管理页。 --- diff --git a/lib/client.js b/lib/client.js index ee94d95..2dad577 100644 --- a/lib/client.js +++ b/lib/client.js @@ -10,7 +10,6 @@ window.__ModuleLoader__.load({ //#region src/client/controller.ts const RPC_CHANNEL = "/dsh-unrestricted"; const SETTINGS_NS = "unrestricted"; - const DEFAULT_VERSION = "0.2.6"; /** Human-readable error text for the banner. */ function messageOf(error) { return error instanceof Error ? error.message : String(error); @@ -28,11 +27,6 @@ window.__ModuleLoader__.load({ writable: false, settingsStatus: "loading", status: null, - update: { - state: "idle", - currentVersion: DEFAULT_VERSION, - restartRequired: false - }, previews: {}, busy: false }; @@ -56,7 +50,6 @@ window.__ModuleLoader__.load({ writable: settingsSnapshot.writable, settingsStatus: settingsSnapshot.status, status: snapshot.status, - update: snapshot.update, previews: snapshot.previews, busy: pendingOperations > 0, message: snapshot.message @@ -92,14 +85,9 @@ window.__ModuleLoader__.load({ const status = await call(endpoint, {}); if (generation !== statusGeneration) return; if (clearPreviews) invalidatePreviews(); - const nextUpdate = status.update !== void 0 && (snapshot.update.state === "idle" || status.update.state !== "idle") ? status.update : { - ...snapshot.update, - currentVersion: status.version ?? snapshot.update.currentVersion - }; snapshot = { ...snapshot, status, - update: nextUpdate, message: void 0 }; } catch (error) { @@ -174,75 +162,6 @@ window.__ModuleLoader__.load({ } publish(); } - /** - * Check whether a newer version is available from GitHub or the local source directory. - * @param force - bypass in-flight reuse and force a fresh check. - */ - async function checkUpdate(force = false) { - if (snapshot.update.state === "checking" || snapshot.update.state === "updating") return; - snapshot = { - ...snapshot, - update: { - ...snapshot.update, - state: "checking", - errorCode: void 0, - errorDetail: void 0 - } - }; - publish(); - try { - const update = await call("check-update", { force }); - snapshot = { - ...snapshot, - update - }; - } catch (error) { - snapshot = { - ...snapshot, - update: { - ...snapshot.update, - state: "failed", - errorCode: "update-check-failed", - errorDetail: messageOf(error) - } - }; - } - publish(); - } - /** - * Download and install the latest version into the active profile. - */ - async function performUpdate() { - if (snapshot.update.state === "updating") return; - snapshot = { - ...snapshot, - update: { - ...snapshot.update, - state: "updating", - errorCode: void 0, - errorDetail: void 0 - } - }; - publish(); - try { - const update = await call("perform-update", { targetTag: snapshot.update.latestTag }); - snapshot = { - ...snapshot, - update - }; - } catch (error) { - snapshot = { - ...snapshot, - update: { - ...snapshot.update, - state: "failed", - errorCode: "update-install-failed", - errorDetail: messageOf(error) - } - }; - } - publish(); - } ctx.effect(() => settings.subscribe(publish), "dsh-unrestricted: settings mirror"); ctx.effect(() => ctx.remote.$on("settings/document-updated", (namespace) => { if (namespace === void 0 || namespace === SETTINGS_NS) refresh(true); @@ -254,9 +173,7 @@ window.__ModuleLoader__.load({ setEnabled, recheck, refresh: () => refresh(true), - loadPreview, - checkUpdate, - performUpdate + loadPreview }) }; } //#endregion @@ -305,33 +222,10 @@ window.__ModuleLoader__.load({ settingsLoading: "正在读取配置…", operationFailed: "操作失败:", issuePersona: "未检测到预设角色前缀段落,已自动保留原版提示词", - updateTitle: "版本与更新", - currentVersion: "当前版本", - latestVersion: "最新版本", - installSource: "安装方式", - sourceGithub: "GitHub 仓库", - sourceFile: "本地目录 (file:)", - sourceRegistry: "软件包镜像", - sourceUnknown: "当前 Profile", - updateIdle: "尚未检查更新", - updateChecking: "正在检查更新…", - updateUpToDate: "已是最新版本", - updateAvailable: "发现新版本", - updateInstalling: "正在下载并安装更新,请稍候…", - updateInstalled: "已安装新版本,重启 DSH Web 或桌面端后生效", - updateBadge: "可更新", - updateRestartBadge: "待重启生效", - checkUpdate: "检查更新", - installUpdate: "立即更新", - viewRelease: "发布说明", errorRpcDisconnected: "无法连接宿主服务,请确认 DSH 正在运行后刷新重试。", errorUnsupportedPreset: "不支持该预设模式的提示词预览。", errorMissingPersona: "当前预设未包含角色前缀段落,已自动保留原版提示词。", - errorPreviewFailed: "生成提示词预览失败,请稍后刷新重试。", - errorUpdateCheckFailed: "检查更新失败,请确认网络连接正常后重试。", - errorUpdateNoProfile: "当前运行环境未绑定可管理的 Profile 目录,无法执行自动更新。", - errorUpdateFileOutdated: "当前通过本地目录 (file:) 安装,且本地目录版本低于远端最新版本,请先更新本地源码目录后再点更新。", - errorUpdateInstallFailed: "安装更新失败:" + errorPreviewFailed: "生成提示词预览失败,请稍后刷新重试。" }; /** English dictionary checked against the Chinese key set. */ const en = { @@ -376,33 +270,10 @@ window.__ModuleLoader__.load({ settingsLoading: "Loading configuration…", operationFailed: "Operation failed: ", issuePersona: "Preset persona section not found — stock prompt kept", - updateTitle: "Version & Updates", - currentVersion: "Current version", - latestVersion: "Latest version", - installSource: "Install source", - sourceGithub: "GitHub repository", - sourceFile: "Local directory (file:)", - sourceRegistry: "Package registry", - sourceUnknown: "Active profile", - updateIdle: "Not checked yet", - updateChecking: "Checking for updates…", - updateUpToDate: "Up to date", - updateAvailable: "Update available", - updateInstalling: "Downloading and installing update…", - updateInstalled: "Update installed — restart DSH Web or Desktop to apply", - updateBadge: "Update available", - updateRestartBadge: "Restart to apply", - checkUpdate: "Check for updates", - installUpdate: "Update now", - viewRelease: "Release notes", errorRpcDisconnected: "Cannot reach the host service. Please verify DSH is running and refresh.", errorUnsupportedPreset: "Prompt preview is not supported for this preset.", errorMissingPersona: "The preset is missing a persona prefix section; the stock prompt is kept.", - errorPreviewFailed: "Could not assemble the prompt preview. Please try refreshing.", - errorUpdateCheckFailed: "Could not check for updates. Please verify your network connection and try again.", - errorUpdateNoProfile: "This runtime does not expose a managed profile directory for self-update.", - errorUpdateFileOutdated: "Installed from a local file: directory whose version is older than the latest release. Update the local directory first.", - errorUpdateInstallFailed: "Failed to install update: " + errorPreviewFailed: "Could not assemble the prompt preview. Please try refreshing." }; /** Dictionary namespace owned by this plugin. */ const NS = "settings.unrestricted"; @@ -638,50 +509,6 @@ window.__ModuleLoader__.load({ overflow-wrap: anywhere; } -.dsh-unrestricted-metaGrid { - display: grid; - grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); - gap: 10px 14px; - margin: 0; - border: 1px solid var(--dsw-alias-border-l2); - border-radius: var(--dsw-radius-lg, 10px); - padding: 11px 14px; - background: var(--dsw-alias-bg-layer-2); -} - -.dsh-unrestricted-metaItem { - display: flex; - min-width: 0; - flex-direction: column; - gap: 2px; -} - -.dsh-unrestricted-metaItem dt { - font-size: 11px; - line-height: 16px; - color: var(--dsw-alias-label-tertiary); -} - -.dsh-unrestricted-metaItem dd { - margin: 0; - font-size: 13px; - line-height: 19px; - font-weight: 500; - color: var(--dsw-alias-label-primary); - overflow-wrap: anywhere; -} - -.dsh-unrestricted-link { - color: var(--dsw-alias-state-business-primary); - font-size: 12px; - line-height: 18px; - text-decoration: none; -} - -.dsh-unrestricted-link:hover { - text-decoration: underline; -} - @media (max-width: 640px) { .dsh-unrestricted-card { padding: 14px; @@ -705,10 +532,9 @@ window.__ModuleLoader__.load({ //#endregion //#region src/client/UnrestrictedCard.tsx /** - * The unrestricted settings view and plugin-detail badge: + * The unrestricted settings view: * - Master toggle card with native Switch, status Tag, and scope boundary notes * - Per-preset coverage list with StateDot, Tag, preview drawer, and one-click copy - * - Version & Updates card with automatic release check and one-click self-update */ /** Mode rows in display order, with their locale label and description keys. */ const MODE_ROWS = [ @@ -781,68 +607,16 @@ window.__ModuleLoader__.load({ const detail = entry.preview?.reason ?? entry.message; return detail !== void 0 && detail.trim() !== "" ? `${t("previewUnavailable")}${detail}` : t("errorPreviewFailed"); } - /** Friendly localized text for update errors. */ - function localizeUpdateError(update, t) { - switch (update.errorCode) { - case "update-check-failed": return t("errorUpdateCheckFailed"); - case "update-no-profile": return t("errorUpdateNoProfile"); - case "update-file-source-outdated": return t("errorUpdateFileOutdated"); - case "update-install-failed": return `${t("errorUpdateInstallFailed")}${update.errorDetail ?? ""}`; - default: return update.errorDetail !== void 0 && update.errorDetail !== "" ? `${t("operationFailed")}${update.errorDetail}` : t("errorUpdateCheckFailed"); - } - } - /** Friendly label for the installation source. */ - function installSourceLabel(source, t) { - switch (source) { - case "github": return t("sourceGithub"); - case "file": return t("sourceFile"); - case "registry": return t("sourceRegistry"); - default: return t("sourceUnknown"); - } - } - /** - * Badge shown in the Plugin Manager detail header when an update is available - * or waiting for a restart. - */ - function UnrestrictedDetailBadge(props) { - const { subject, t, checkUpdate } = props; - const update = props.useView((snapshot) => snapshot.update); - const isTargetBundle = subject.kind === "bundle" && subject.pkg.name === "dsh-unrestricted"; - (0, react.useEffect)(() => { - if (isTargetBundle && update.state === "idle") checkUpdate(false); - }, [ - isTargetBundle, - update.state, - checkUpdate - ]); - if (!isTargetBundle) return null; - if (update.state === "available") { - const versionSuffix = update.latestVersion !== void 0 ? ` v${update.latestVersion}` : ""; - return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, { - tone: "info", - children: `${t("updateBadge")}${versionSuffix}` - }); - } - if (update.state === "updated" || update.restartRequired === true) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, { - tone: "success", - children: t("updateRestartBadge") - }); - return null; - } /** * Render the unrestricted configuration cards. */ function UnrestrictedCard(props) { - const { t, loadPreview, checkUpdate } = props; + const { t, loadPreview } = props; const view = props.useView((snapshot) => snapshot); const status = view.status; - const update = view.update; const [openPreview, setOpenPreview] = (0, react.useState)(null); const [copiedPreset, setCopiedPreset] = (0, react.useState)(null); const openEntry = openPreview === null ? void 0 : view.previews[openPreview]; - (0, react.useEffect)(() => { - if (update.state === "idle") checkUpdate(false); - }, [update.state, checkUpdate]); (0, react.useEffect)(() => { if (openPreview !== null && openEntry === void 0) loadPreview(openPreview); }, [ @@ -879,294 +653,195 @@ window.__ModuleLoader__.load({ return key !== void 0 ? t(key) : issue; }).join(";"); } - const updateBusy = update.state === "checking" || update.state === "updating"; - const updateTagTone = update.state === "available" ? "info" : update.state === "updated" ? "success" : update.state === "failed" ? "danger" : "neutral"; - const updateTagKey = update.state === "checking" ? "updateChecking" : update.state === "updating" ? "updateInstalling" : update.state === "available" ? "updateAvailable" : update.state === "updated" ? "updateRestartBadge" : update.state === "up-to-date" ? "updateUpToDate" : "updateIdle"; return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { className: "dsh-unrestricted-root", - "aria-busy": view.busy || updateBusy, - children: [ - /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", { - className: "dsh-unrestricted-card", - "aria-labelledby": "dsh-unrestricted-main-title", - children: [ - /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { - 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) - })] - }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { - className: "dsh-unrestricted-headerControls", - children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { - className: "dsh-unrestricted-switchLabel", - children: t("toggle") - }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Switch, { - checked: view.enabled, - disabled: !view.writable || view.settingsStatus !== "ready" || view.busy, - label: t("toggle"), - onChange: (checked) => { - props.setEnabled(checked); - } - })] + "aria-busy": view.busy, + children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", { + className: "dsh-unrestricted-card", + "aria-labelledby": "dsh-unrestricted-main-title", + children: [ + /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { + 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) })] - }), - /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { - className: "dsh-unrestricted-description", - children: t("description") - }), - /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { - className: "dsh-unrestricted-note", - children: t("scopeNote") - }), - view.settingsStatus === "loading" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { - className: "dsh-unrestricted-note", - role: "status", - children: t("settingsLoading") - }), - view.settingsStatus === "unavailable" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { - className: "dsh-unrestricted-banner", - "data-tone": "info", - role: "status", - children: t("settingsUnavailable") - }), - view.message !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { - className: "dsh-unrestricted-banner", - "data-tone": "error", - role: "alert", - children: localizeBannerError(view.message, t) - }) - ] - }), - /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", { - className: "dsh-unrestricted-card", - "aria-labelledby": "dsh-unrestricted-modes-title", - children: [ - /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { - className: "dsh-unrestricted-header", - children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { - className: "dsh-unrestricted-headerTitle", - children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h4", { - id: "dsh-unrestricted-modes-title", - className: "dsh-unrestricted-subtitle", - children: t("statusTitle") - }) - }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { - className: "dsh-unrestricted-headerControls", - children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, { - variant: "outline", - size: "sm", - disabled: view.busy, - onClick: () => { - props.refresh(); - }, - children: t("refresh") - }) + }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { + className: "dsh-unrestricted-headerControls", + children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { + className: "dsh-unrestricted-switchLabel", + children: t("toggle") + }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Switch, { + checked: view.enabled, + disabled: !view.writable || view.settingsStatus !== "ready" || view.busy, + label: t("toggle"), + onChange: (checked) => { + props.setEnabled(checked); + } })] - }), - /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { - className: "dsh-unrestricted-note", - children: t("statusSubtitle") - }), - /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", { - className: "dsh-unrestricted-modes", - children: MODE_ROWS.map((row) => { - const mode = status?.modes[row.id]; - const entry = view.previews[row.id]; - const isOpen = openPreview === row.id; - const previewText = entry?.preview?.text; - return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", { - className: "dsh-unrestricted-mode", - children: [ - /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { - className: "dsh-unrestricted-modeMain", - children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { - className: "dsh-unrestricted-modeInfo", - children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { - className: "dsh-unrestricted-modeHeading", - children: [ - /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, { state: dotStateOf(mode) }), - /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { - className: "dsh-unrestricted-modeName", - children: t(row.labelKey) - }), - /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, { - tone: "outline", - children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { - className: "dsh-unrestricted-mono", - children: t(row.presetKey) - }) - }), - /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, { - tone: modeTagTone(mode), - children: t(stateKey(mode)) - }) - ] - }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { - className: "dsh-unrestricted-modeDesc", - children: t(row.descKey) - })] - }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { - className: "dsh-unrestricted-headerControls", - children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, { - variant: isOpen ? "toolbar" : "outline", - size: "sm", - onClick: () => { - togglePreview(row.id); - }, - children: t(isOpen ? "hidePreview" : "showPreview") - }) - })] - }), - mode !== void 0 && mode.issues.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { - className: "dsh-unrestricted-issues", - children: formatIssues(mode.issues) - }), - isOpen && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { - className: "dsh-unrestricted-preview", - children: entry === void 0 || entry.status === "loading" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { - className: "dsh-unrestricted-note", - role: "status", - children: t("previewLoading") - }) : entry.status === "failed" || entry.preview?.available === false ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { - className: "dsh-unrestricted-banner", - "data-tone": "error", - role: "alert", - children: localizePreviewError(entry, t) - }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { - className: "dsh-unrestricted-previewHeader", - children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", { - className: "dsh-unrestricted-previewMeta", - children: [ - entry.preview?.lines, - " ", - t("previewSize"), - entry.preview?.bytes !== void 0 && ` · ${(0, _deepseek_ai_dsh_client_ui_primitives.fileSizeText)(entry.preview.bytes)}`, - entry.preview?.source !== void 0 && ` · ${t(entry.preview.source === "live" ? "previewSourceLive" : "previewSourceStanding")}` - ] - }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, { - variant: "ghost", - size: "sm", - onClick: () => { - handleCopyPreview(row.id, previewText); - }, - children: t(copiedPreset === row.id ? "copiedPreview" : "copyPreview") - })] - }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", { - className: "dsh-unrestricted-previewText", - children: previewText - })] }) - }) - ] - }, row.id); + })] + }), + /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { + className: "dsh-unrestricted-description", + children: t("description") + }), + /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { + className: "dsh-unrestricted-note", + children: t("scopeNote") + }), + view.settingsStatus === "loading" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { + className: "dsh-unrestricted-note", + role: "status", + children: t("settingsLoading") + }), + view.settingsStatus === "unavailable" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { + className: "dsh-unrestricted-banner", + "data-tone": "info", + role: "status", + children: t("settingsUnavailable") + }), + view.message !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { + className: "dsh-unrestricted-banner", + "data-tone": "error", + role: "alert", + children: localizeBannerError(view.message, t) + }) + ] + }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", { + className: "dsh-unrestricted-card", + "aria-labelledby": "dsh-unrestricted-modes-title", + children: [ + /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { + className: "dsh-unrestricted-header", + children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { + className: "dsh-unrestricted-headerTitle", + children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h4", { + id: "dsh-unrestricted-modes-title", + className: "dsh-unrestricted-subtitle", + children: t("statusTitle") }) - }), - /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { - className: "dsh-unrestricted-note", - children: t("subagentNote") - }) - ] - }), - /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", { - className: "dsh-unrestricted-card", - "aria-labelledby": "dsh-unrestricted-update-title", - children: [ - /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { - className: "dsh-unrestricted-header", - children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { - className: "dsh-unrestricted-headerTitle", - children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h4", { - id: "dsh-unrestricted-update-title", - className: "dsh-unrestricted-subtitle", - children: t("updateTitle") - }), update.state !== "failed" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, { - tone: updateTagTone, - children: update.state === "available" && update.latestVersion !== void 0 ? `${t("updateAvailable")} v${update.latestVersion}` : t(updateTagKey) - })] - }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { - className: "dsh-unrestricted-headerControls", + }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { + className: "dsh-unrestricted-headerControls", + children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, { + variant: "outline", + size: "sm", + disabled: view.busy, + onClick: () => { + props.refresh(); + }, + children: t("refresh") + }) + })] + }), + /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { + className: "dsh-unrestricted-note", + children: t("statusSubtitle") + }), + /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", { + className: "dsh-unrestricted-modes", + children: MODE_ROWS.map((row) => { + const mode = status?.modes[row.id]; + const entry = view.previews[row.id]; + const isOpen = openPreview === row.id; + const previewText = entry?.preview?.text; + return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", { + className: "dsh-unrestricted-mode", children: [ - update.releaseUrl !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", { - className: "dsh-unrestricted-link", - href: update.releaseUrl, - target: "_blank", - rel: "noreferrer", - children: t("viewRelease") + /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { + className: "dsh-unrestricted-modeMain", + children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { + className: "dsh-unrestricted-modeInfo", + children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { + className: "dsh-unrestricted-modeHeading", + children: [ + /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, { state: dotStateOf(mode) }), + /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { + className: "dsh-unrestricted-modeName", + children: t(row.labelKey) + }), + /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, { + tone: "outline", + children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { + className: "dsh-unrestricted-mono", + children: t(row.presetKey) + }) + }), + /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, { + tone: modeTagTone(mode), + children: t(stateKey(mode)) + }) + ] + }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { + className: "dsh-unrestricted-modeDesc", + children: t(row.descKey) + })] + }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { + className: "dsh-unrestricted-headerControls", + children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, { + variant: isOpen ? "toolbar" : "outline", + size: "sm", + onClick: () => { + togglePreview(row.id); + }, + children: t(isOpen ? "hidePreview" : "showPreview") + }) + })] }), - update.state === "available" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, { - variant: "primary", - size: "sm", - disabled: updateBusy, - onClick: () => { - props.performUpdate(); - }, - children: update.latestVersion !== void 0 ? `${t("installUpdate")} (v${update.latestVersion})` : t("installUpdate") + mode !== void 0 && mode.issues.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { + className: "dsh-unrestricted-issues", + children: formatIssues(mode.issues) }), - /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, { - variant: "outline", - size: "sm", - disabled: updateBusy, - onClick: () => { - props.checkUpdate(true); - }, - children: t("checkUpdate") + isOpen && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { + className: "dsh-unrestricted-preview", + children: entry === void 0 || entry.status === "loading" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { + className: "dsh-unrestricted-note", + role: "status", + children: t("previewLoading") + }) : entry.status === "failed" || entry.preview?.available === false ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { + className: "dsh-unrestricted-banner", + "data-tone": "error", + role: "alert", + children: localizePreviewError(entry, t) + }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { + className: "dsh-unrestricted-previewHeader", + children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", { + className: "dsh-unrestricted-previewMeta", + children: [ + entry.preview?.lines, + " ", + t("previewSize"), + entry.preview?.bytes !== void 0 && ` · ${(0, _deepseek_ai_dsh_client_ui_primitives.fileSizeText)(entry.preview.bytes)}`, + entry.preview?.source !== void 0 && ` · ${t(entry.preview.source === "live" ? "previewSourceLive" : "previewSourceStanding")}` + ] + }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, { + variant: "ghost", + size: "sm", + onClick: () => { + handleCopyPreview(row.id, previewText); + }, + children: t(copiedPreset === row.id ? "copiedPreview" : "copyPreview") + })] + }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", { + className: "dsh-unrestricted-previewText", + children: previewText + })] }) }) ] - })] - }), - /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("dl", { - className: "dsh-unrestricted-metaGrid", - children: [ - /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { - className: "dsh-unrestricted-metaItem", - children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dt", { children: t("currentVersion") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dd", { - className: "dsh-unrestricted-mono", - children: `v${update.currentVersion}` - })] - }), - /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { - className: "dsh-unrestricted-metaItem", - children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dt", { children: t("latestVersion") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dd", { - className: "dsh-unrestricted-mono", - children: update.latestVersion !== void 0 ? `v${update.latestVersion}` : "—" - })] - }), - /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { - className: "dsh-unrestricted-metaItem", - children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dt", { children: t("installSource") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dd", { - title: update.dependencySpec, - children: installSourceLabel(update.installSource, t) - })] - }) - ] - }), - update.state === "updating" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { - className: "dsh-unrestricted-banner", - "data-tone": "info", - role: "status", - children: t("updateInstalling") - }), - (update.state === "updated" || update.restartRequired === true) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { - className: "dsh-unrestricted-banner", - "data-tone": "success", - role: "status", - children: t("updateInstalled") - }), - update.state === "failed" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { - className: "dsh-unrestricted-banner", - "data-tone": "error", - role: "alert", - children: localizeUpdateError(update, t) + }, row.id); }) - ] - }) - ] + }), + /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { + className: "dsh-unrestricted-note", + children: t("subagentNote") + }) + ] + })] }); } //#endregion @@ -1179,7 +854,7 @@ window.__ModuleLoader__.load({ "remote", "configForms" ]; - /** 注册本插件的配置卡片与详情页更新徽标。 */ + /** 注册本插件的配置卡片。 */ function apply(ctx) { ensureStyles(); ctx.effect(() => ctx.locale.register(NS, { @@ -1193,12 +868,6 @@ window.__ModuleLoader__.load({ locale: NS, inject: () => controller.face() }, UnrestrictedCard)); - ctx.slots.inject("plugins.detail.badge", () => ctx.slots.register({ - name: "plugins.detail.badge", - id: "dsh-unrestricted:update-badge", - locale: NS, - inject: () => controller.face() - }, UnrestrictedDetailBadge)); } //#endregion exports.apply = apply; diff --git a/lib/client.js.map b/lib/client.js.map index 1ee423f..d6943d3 100644 --- a/lib/client.js.map +++ b/lib/client.js.map @@ -1 +1 @@ -{"version":3,"file":"client.js","names":["Tag","useState","writeClipboard","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), reads per-preset fusion state and previews,\n * and manages version checks and self-updates via the host half's private RPC.\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/** Version and update status reported by the host half. */\nexport interface UnrestrictedUpdateInfo {\n state: 'idle' | 'checking' | 'up-to-date' | 'available' | 'updating' | 'updated' | 'failed'\n currentVersion: string\n latestVersion?: string\n latestTag?: string\n updatedVersion?: string\n releaseUrl?: string\n publishedAt?: string\n checkedAt?: string\n installSource?: 'github' | 'file' | 'registry' | 'unknown'\n dependencySpec?: string\n restartRequired?: boolean\n errorCode?: string\n errorDetail?: 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 update?: UnrestrictedUpdateInfo\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 /** Version and update check state. */\n update: UnrestrictedUpdateInfo\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 and detail badge 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 /** Check whether a newer plugin version is available. */\n checkUpdate: (force?: boolean) => Promise\n /** Download and install the latest version into the active profile. */\n performUpdate: () => Promise\n}\n\nconst RPC_CHANNEL = '/dsh-unrestricted'\nconst SETTINGS_NS = 'unrestricted'\nconst DEFAULT_VERSION = '0.2.6'\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 update: {\n state: 'idle',\n currentVersion: DEFAULT_VERSION,\n restartRequired: false,\n },\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 update: snapshot.update,\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(RPC_CHANNEL, endpoint, payload) 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 const nextUpdate = status.update !== undefined\n && (snapshot.update.state === 'idle' || status.update.state !== 'idle')\n ? status.update\n : {\n ...snapshot.update,\n currentVersion: status.version ?? snapshot.update.currentVersion,\n }\n snapshot = {\n ...snapshot,\n status,\n update: nextUpdate,\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 /**\n * Check whether a newer version is available from GitHub or the local source directory.\n * @param force - bypass in-flight reuse and force a fresh check.\n */\n async function checkUpdate(force = false): Promise {\n if (snapshot.update.state === 'checking' || snapshot.update.state === 'updating') return\n snapshot = {\n ...snapshot,\n update: { ...snapshot.update, state: 'checking', errorCode: undefined, errorDetail: undefined },\n }\n publish()\n try {\n const update = await call('check-update', { force })\n snapshot = { ...snapshot, update }\n } catch (error) {\n snapshot = {\n ...snapshot,\n update: {\n ...snapshot.update,\n state: 'failed',\n errorCode: 'update-check-failed',\n errorDetail: messageOf(error),\n },\n }\n }\n publish()\n }\n\n /**\n * Download and install the latest version into the active profile.\n */\n async function performUpdate(): Promise {\n if (snapshot.update.state === 'updating') return\n snapshot = {\n ...snapshot,\n update: { ...snapshot.update, state: 'updating', errorCode: undefined, errorDetail: undefined },\n }\n publish()\n try {\n const update = await call('perform-update', {\n targetTag: snapshot.update.latestTag,\n })\n snapshot = { ...snapshot, update }\n } catch (error) {\n snapshot = {\n ...snapshot,\n update: {\n ...snapshot.update,\n state: 'failed',\n errorCode: 'update-install-failed',\n errorDetail: messageOf(error),\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 checkUpdate,\n performUpdate,\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 updateTitle: '版本与更新',\n currentVersion: '当前版本',\n latestVersion: '最新版本',\n installSource: '安装方式',\n sourceGithub: 'GitHub 仓库',\n sourceFile: '本地目录 (file:)',\n sourceRegistry: '软件包镜像',\n sourceUnknown: '当前 Profile',\n updateIdle: '尚未检查更新',\n updateChecking: '正在检查更新…',\n updateUpToDate: '已是最新版本',\n updateAvailable: '发现新版本',\n updateInstalling: '正在下载并安装更新,请稍候…',\n updateInstalled: '已安装新版本,重启 DSH Web 或桌面端后生效',\n updateBadge: '可更新',\n updateRestartBadge: '待重启生效',\n checkUpdate: '检查更新',\n installUpdate: '立即更新',\n viewRelease: '发布说明',\n errorRpcDisconnected: '无法连接宿主服务,请确认 DSH 正在运行后刷新重试。',\n errorUnsupportedPreset: '不支持该预设模式的提示词预览。',\n errorMissingPersona: '当前预设未包含角色前缀段落,已自动保留原版提示词。',\n errorPreviewFailed: '生成提示词预览失败,请稍后刷新重试。',\n errorUpdateCheckFailed: '检查更新失败,请确认网络连接正常后重试。',\n errorUpdateNoProfile: '当前运行环境未绑定可管理的 Profile 目录,无法执行自动更新。',\n errorUpdateFileOutdated: '当前通过本地目录 (file:) 安装,且本地目录版本低于远端最新版本,请先更新本地源码目录后再点更新。',\n errorUpdateInstallFailed: '安装更新失败:',\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 updateTitle: 'Version & Updates',\n currentVersion: 'Current version',\n latestVersion: 'Latest version',\n installSource: 'Install source',\n sourceGithub: 'GitHub repository',\n sourceFile: 'Local directory (file:)',\n sourceRegistry: 'Package registry',\n sourceUnknown: 'Active profile',\n updateIdle: 'Not checked yet',\n updateChecking: 'Checking for updates…',\n updateUpToDate: 'Up to date',\n updateAvailable: 'Update available',\n updateInstalling: 'Downloading and installing update…',\n updateInstalled: 'Update installed — restart DSH Web or Desktop to apply',\n updateBadge: 'Update available',\n updateRestartBadge: 'Restart to apply',\n checkUpdate: 'Check for updates',\n installUpdate: 'Update now',\n viewRelease: 'Release notes',\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 errorUpdateCheckFailed: 'Could not check for updates. Please verify your network connection and try again.',\n errorUpdateNoProfile: 'This runtime does not expose a managed profile directory for self-update.',\n errorUpdateFileOutdated: 'Installed from a local file: directory whose version is older than the latest release. Update the local directory first.',\n errorUpdateInstallFailed: 'Failed to install update: ',\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 *