window.__ModuleLoader__.load({ id: "dsh-unrestricted", factory: (require) => { var module = { exports: {} }; var exports = module.exports; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); let react = require("react"); let react_jsx_runtime = require("react/jsx-runtime"); //#region src/client/controller.ts const RPC_CHANNEL = "/dsh-unrestricted"; const SETTINGS_NS = "unrestricted"; /** Human-readable error text for the banner. */ function messageOf(error) { return error instanceof Error ? error.message : String(error); } /** * Create the card controller bound to the calling plugin's context. * @param ctx - the browser plugin context (connection + remote + settingsScope injected). * @returns the controller whose face() feeds the slot inject share. */ function createUnrestrictedController(ctx) { const connection = ctx.get("connection"); const settings = ctx.settingsScope.bind({ namespace: SETTINGS_NS }); let snapshot = { enabled: false, writable: false, settingsStatus: "loading", status: null, previews: {} }; const listeners = /* @__PURE__ */ new Set(); const view = { getSnapshot: () => snapshot, subscribe: (listener) => { listeners.add(listener); return () => listeners.delete(listener); } }; function publish() { const settingsSnapshot = settings.getSnapshot(); snapshot = { enabled: settingsSnapshot.value?.enabled === true, writable: settingsSnapshot.writable, settingsStatus: settingsSnapshot.status, status: snapshot.status, previews: snapshot.previews, message: snapshot.message }; for (const listener of listeners) listener(); } async function call(endpoint, payload) { const result = await connection.rpc.call(RPC_CHANNEL, endpoint, payload); if (!result.ok) throw new Error(result.error.message); return result.value; } async function refresh() { try { const status = await call("status", {}); snapshot = { ...snapshot, status, message: void 0 }; publish(); } catch (error) { snapshot = { ...snapshot, message: messageOf(error) }; publish(); } } async function setEnabled(enabled) { await settings.set("enabled", enabled); publish(); setTimeout(() => void refresh(), 300); } async function recheck() { try { const status = await call("recheck", {}); snapshot = { ...snapshot, status, previews: {}, message: void 0 }; publish(); } catch (error) { snapshot = { ...snapshot, message: messageOf(error) }; publish(); } } /** * Fetch one preset's deploy preview. The card renders the raw fused prompt, * so the user reads the exact bytes before switching the mode on. * @param presetId - preset id from the card's row. */ async function loadPreview(presetId) { snapshot = { ...snapshot, previews: { ...snapshot.previews, [presetId]: { status: "loading" } } }; publish(); try { const preview = await call("preview", { presetId }); snapshot = { ...snapshot, previews: { ...snapshot.previews, [presetId]: { status: "ready", preview } } }; } catch (error) { snapshot = { ...snapshot, previews: { ...snapshot.previews, [presetId]: { status: "failed", message: 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(); }), "dsh-unrestricted: settings invalidations"); publish(); refresh(); return { face: () => ({ hooks: { view }, setEnabled, recheck, refresh, loadPreview }) }; } //#endregion //#region src/client/locales.ts /** Copy dictionaries for the unrestricted settings card. */ /** Simplified Chinese dictionary and key source of truth. */ const zh = { title: "破限模式", summaryEnabled: "已开启", summaryDisabled: "已关闭", summaryLoading: "读取中", summaryUnavailable: "设置不可用", summaryValidationFailed: "部分模式校验未通过", description: "开启后,各模式的系统提示词整体替换为以当前原版为底稿、融合破限规则的完整版本;关闭即恢复 DSH 原版提示词。从下一次请求和新建子代理开始生效,不改动正在执行的请求、工具定义、权限配置与会话历史。", toggle: "启用破限", scopeNote: "提示词仅由 DSH 生成时才受本插件控制;模型平台或宿主环境中更高优先级的规则不在覆盖范围内。", statusTitle: "各模式状态", modeStandard: "Standard 标准模式", modePtc: "PTC 模式", modeCordis: "Cordis 创造模式", modeMinimal: "Minimal 极简模式", subagentNote: "子代理随所属模式一并生效。", stateActive: "已生效", stateOff: "已关闭", stateChecking: "校验中", stateValidationFailed: "校验未通过,已保持原版", recheck: "重新校验", refresh: "刷新", preflightTitle: "本次即将写入的内容", fingerprint: "契约指纹", fingerprintNote: "与当前提示词一一对应。各模式实际部署的就是下面这段文本。", preset: "预设", presetStandard: "standard", presetPtc: "ptc", presetCordis: "cordis", presetMinimal: "minimal", showPreview: "查看预览", hidePreview: "收起预览", previewLoading: "正在组装当前提示词…", previewUnavailable: "暂不可预览:", previewSize: "行", settingsUnavailable: "当前连接不可写设置(远程浏览器只读)。", settingsLoading: "正在读取设置…", operationFailed: "操作失败:" }; /** English dictionary checked against the Chinese key set. */ const en = { title: "Unrestricted mode", summaryEnabled: "Enabled", summaryDisabled: "Disabled", summaryLoading: "Loading", summaryUnavailable: "Settings unavailable", summaryValidationFailed: "Some mode checks failed", description: "When enabled, each mode's system prompt is replaced wholesale by a fused prompt built on its current original; disabling restores the stock DSH prompt. Applies from the next request and new subagents; in-flight requests, tool definitions, permissions, and session history are never touched.", toggle: "Enable unrestricted mode", scopeNote: "This plugin can only rewrite prompts DSH generates itself; higher-priority rules from the model platform or host environment are out of scope.", statusTitle: "Per-mode status", modeStandard: "Standard", modePtc: "PTC", modeCordis: "Cordis", modeMinimal: "Minimal", subagentNote: "Subagents follow their parent's mode.", stateActive: "Active", stateOff: "Off", stateChecking: "Checking", stateValidationFailed: "Check failed — stock prompt kept", recheck: "Re-check", refresh: "Refresh", preflightTitle: "What this deployment would write", fingerprint: "Contract fingerprint", fingerprintNote: "One-to-one with the current prompt: the text below is exactly what each mode deploys.", preset: "Preset", presetStandard: "standard", presetPtc: "ptc", presetCordis: "cordis", presetMinimal: "minimal", showPreview: "Show preview", hidePreview: "Hide preview", previewLoading: "Assembling the current prompt…", previewUnavailable: "No preview available: ", previewSize: "lines", settingsUnavailable: "This connection cannot write settings (remote browser is read-only).", settingsLoading: "Reading settings…", operationFailed: "Operation failed: " }; /** Dictionary namespace owned by this plugin. */ const NS = "settings.unrestricted"; //#endregion //#region src/client/styles.ts /** * Stylesheet for the unrestricted settings card. One hand-written stylesheet * injected as a single