dsh-model-switch 0.4.72 → 0.4.73

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- import { a as bindAutoReviewSessionCorrelation, c as installToolCallSafetyNet, d as resolveSessionAutoReviewRoute, f as reviewLlm, i as autoReviewStatus, l as isReviewerInfrastructureFailure, n as autoReviewGate, o as defensivePermissionPresets, p as reviewScope, r as autoReviewRouteOf, s as inject, t as apply, u as name } from "./auto-review-B4L59yj4.js";
2
- export { apply, autoReviewGate, autoReviewRouteOf, autoReviewStatus, bindAutoReviewSessionCorrelation, defensivePermissionPresets, inject, installToolCallSafetyNet, isReviewerInfrastructureFailure, name, resolveSessionAutoReviewRoute, reviewLlm, reviewScope };
1
+ import { a as bindAutoReviewSessionCorrelation, c as installToolCallSafetyNet, d as ownGateEngaged, f as resolveSessionAutoReviewRoute, i as autoReviewStatus, l as isReviewerInfrastructureFailure, m as reviewScope, n as autoReviewGate, o as defensivePermissionPresets, p as reviewLlm, r as autoReviewRouteOf, s as inject, t as apply, u as name } from "./auto-review-0mh6NLlr.js";
2
+ export { apply, autoReviewGate, autoReviewRouteOf, autoReviewStatus, bindAutoReviewSessionCorrelation, defensivePermissionPresets, inject, installToolCallSafetyNet, isReviewerInfrastructureFailure, name, ownGateEngaged, resolveSessionAutoReviewRoute, reviewLlm, reviewScope };
package/lib/client.js CHANGED
@@ -721,6 +721,9 @@ window.__ModuleLoader__.load({
721
721
  held: status.held === true,
722
722
  allowedCalls: count(status.allowedCalls),
723
723
  skippedReadOnly: count(status.skippedReadOnly),
724
+ ownGate: status.ownGate === true,
725
+ purgeInstalled: status.purgeInstalled === true,
726
+ ...typeof status.officialGateNeutered === "boolean" ? { officialGateNeutered: status.officialGateNeutered } : {},
724
727
  automode,
725
728
  primeMemory: adapterRow(status.primeMemory),
726
729
  visionRouter: adapterRow(status.visionRouter)
@@ -2262,6 +2265,8 @@ window.__ModuleLoader__.load({
2262
2265
  const allowlistView = switchSettings.value === void 0 ? void 0 : deriveAutoReviewAllowlist(switchSettings.value);
2263
2266
  const allowlistTools = allowlistView?.tools ?? DEFAULT_READ_ONLY_TOOLS;
2264
2267
  const allowlistEnabled = allowlistView?.enabled === true;
2268
+ /** The own-gate switch value: default on; only meaningful on a purge-patched host. */
2269
+ const ownGateSettingOn = switchSettings.value === void 0 ? true : switchSettings.value.autoReviewOwnGate !== false;
2265
2270
  const allowlistWritable = switchSettings.status === "ready" && switchSettings.writable;
2266
2271
  const persistAllowlist = (next) => {
2267
2272
  if (busy !== void 0 || !allowlistWritable) return;
@@ -3350,6 +3355,33 @@ window.__ModuleLoader__.load({
3350
3355
  className: ModelSwitchSettings_module_css_default.hint,
3351
3356
  children: props.t("reviewAllowlistSkipped").replace("{count}", String(reviewStatus.skippedReadOnly))
3352
3357
  }),
3358
+ reviewStatus === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3359
+ className: ModelSwitchSettings_module_css_default.rowCard,
3360
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3361
+ className: ModelSwitchSettings_module_css_default.rowCopy,
3362
+ children: [
3363
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3364
+ className: ModelSwitchSettings_module_css_default.rowTitle,
3365
+ children: props.t("reviewOwnGate")
3366
+ }),
3367
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3368
+ className: ModelSwitchSettings_module_css_default.hint,
3369
+ children: props.t("reviewOwnGateHelp")
3370
+ }),
3371
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3372
+ className: ModelSwitchSettings_module_css_default.hint,
3373
+ children: reviewStatus.purgeInstalled === true ? props.t("reviewOwnGatePatched").replace("{neutered}", reviewStatus.officialGateNeutered === void 0 ? props.t("reviewOwnGateUnknown") : reviewStatus.officialGateNeutered ? props.t("reviewOwnGateNeuteredYes") : props.t("reviewOwnGateNeuteredNo")) : props.t("reviewOwnGateUnavailable")
3374
+ })
3375
+ ]
3376
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InstantSwitch, {
3377
+ checked: ownGateSettingOn,
3378
+ disabled: busy !== void 0 || !allowlistWritable || reviewStatus.purgeInstalled !== true,
3379
+ label: props.t("reviewOwnGate"),
3380
+ onChange: (next) => {
3381
+ run("allowlist", () => props.saveReviewOwnGate(next));
3382
+ }
3383
+ })]
3384
+ }),
3353
3385
  reviewStatus?.automode === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3354
3386
  className: ModelSwitchSettings_module_css_default.hint,
3355
3387
  children: props.t("reviewAutomodeLinked").replace("{route}", reviewStatus.automode.route ?? (reviewStatus.automode.routeSkipped === "user-set" ? props.t("reviewAutomodeRouteOwn") : props.t("reviewAutomodeRouteUnset"))).replace("{added}", String(reviewStatus.automode.added)).replace("{skipped}", String(reviewStatus.automode.skipped))
@@ -3935,6 +3967,13 @@ window.__ModuleLoader__.load({
3935
3967
  reviewAllowlistAvailable: "本机存在但未放行的工具:",
3936
3968
  reviewAllowlistRepo: "仓库",
3937
3969
  reviewAllowlistSkipped: "本 Host 进程已为纯读调用跳过 {count} 次审查。",
3970
+ reviewOwnGate: "破甲接管:自有审查门",
3971
+ reviewOwnGateHelp: "安装破甲(dsh-purge)后,官方审查门的宿主代码会被其补丁短路;开启后由本插件的自有审查门接管 auto 会话的逐调用审查,路由仍用上方配置的审查模型。",
3972
+ reviewOwnGateUnavailable: "未检测到破甲插件:官方审查门正常服务,此开关不适用。",
3973
+ reviewOwnGatePatched: "官方门补丁状态:{neutered}。",
3974
+ reviewOwnGateNeuteredYes: "已被宿主补丁短路",
3975
+ reviewOwnGateNeuteredNo: "未见补丁标记",
3976
+ reviewOwnGateUnknown: "未知",
3938
3977
  reviewAutomodeLinked: "Auto mode 已接入:审查路由 {route},直通 +{added} 个纯读工具({skipped} 条通配未同步)。",
3939
3978
  reviewAutomodeRouteOwn: "沿用其自身配置",
3940
3979
  reviewAutomodeRouteUnset: "未配置(沿用会话模型)",
@@ -4041,6 +4080,13 @@ window.__ModuleLoader__.load({
4041
4080
  reviewAllowlistAvailable: "Present on this machine but not allowed:",
4042
4081
  reviewAllowlistRepo: "repo",
4043
4082
  reviewAllowlistSkipped: "This Host process has skipped the reviewer {count} times.",
4083
+ reviewOwnGate: "Purge takeover: owned review gate",
4084
+ reviewOwnGateHelp: "Once dsh-purge patches the host, the official review gate’s host code is short-circuited; when on, this plugin’s own gate reviews every call in Auto sessions using the reviewer model configured above.",
4085
+ reviewOwnGateUnavailable: "No purge plugin detected: the official gate serves and this switch does not apply.",
4086
+ reviewOwnGatePatched: "Official gate patch state: {neutered}.",
4087
+ reviewOwnGateNeuteredYes: "short-circuited by a host patch",
4088
+ reviewOwnGateNeuteredNo: "no patch marker seen",
4089
+ reviewOwnGateUnknown: "unknown",
4044
4090
  reviewAutomodeLinked: "Auto mode linked: reviewer route {route}, passes +{added} read-only tools ({skipped} pattern entries not synced).",
4045
4091
  reviewAutomodeRouteOwn: "its own settings",
4046
4092
  reviewAutomodeRouteUnset: "unset (follows the session model)",
@@ -6799,6 +6845,13 @@ window.__ModuleLoader__.load({
6799
6845
  value: [...tools]
6800
6846
  }])) throw new Error("settings-rejected");
6801
6847
  },
6848
+ saveReviewOwnGate: async (ownGate) => {
6849
+ if (!await owned.mutate([{
6850
+ op: "set",
6851
+ path: ["autoReviewOwnGate"],
6852
+ value: ownGate
6853
+ }])) throw new Error("settings-rejected");
6854
+ },
6802
6855
  ...connectionRpc === void 0 ? {} : { scanTools: async () => {
6803
6856
  const response = await callPluginRpc(connectionRpc, "plugin-rpc/model-switch", "tools", {});
6804
6857
  if (!response.ok || response.value === void 0) throw new Error(t("reviewAllowlistScanFailed"));
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { l as normalizeProviderGroups } from "./session-route-CRfpxarI.js";
2
2
  import { r as resolveToolSource, t as DEFAULT_READ_ONLY_TOOLS } from "./tool-allowlist-Ddb8jfNx.js";
3
- import { i as autoReviewStatus } from "./auto-review-B4L59yj4.js";
3
+ import { d as ownGateEngaged, i as autoReviewStatus } from "./auto-review-0mh6NLlr.js";
4
4
  import { ModelSwitchAdapterRegistry } from "./adapter-registry.js";
5
5
  import { automodeCompatView } from "./automode-compat.js";
6
6
  import { s as subagentDiscoveryHintStatus } from "./subagent-runtime-eNKrdb2H.js";
@@ -35,6 +35,7 @@ const Config = z.object({
35
35
  autoReviewProvider: z.string().volatile(),
36
36
  autoReviewModel: z.string().volatile(),
37
37
  autoReviewSkipReadOnly: z.boolean().default(false).volatile(),
38
+ autoReviewOwnGate: z.boolean().default(true).volatile(),
38
39
  autoReviewAllowlist: z.array(z.string()).default([...DEFAULT_READ_ONLY_TOOLS]).volatile(),
39
40
  /** Reviewer stream idle timeout in ms; 0 = cancel (upstream ceiling); absent = provider default. */
40
41
  autoReviewTimeoutMs: z.number().step(1).min(0).max(2147483647).volatile(),
@@ -76,6 +77,7 @@ function readConfig(config) {
76
77
  const autoReviewProvider = config.autoReviewProvider.get();
77
78
  const autoReviewModel = config.autoReviewModel.get();
78
79
  const autoReviewSkipReadOnly = config.autoReviewSkipReadOnly.get();
80
+ const autoReviewOwnGate = config.autoReviewOwnGate.get();
79
81
  const autoReviewAllowlist = config.autoReviewAllowlist.get();
80
82
  const autoReviewTimeoutMs = config.autoReviewTimeoutMs.get();
81
83
  const compactProvider = config.compactProvider.get();
@@ -100,6 +102,7 @@ function readConfig(config) {
100
102
  ...autoReviewProvider === void 0 || autoReviewProvider === "" ? {} : { autoReviewProvider },
101
103
  ...autoReviewModel === void 0 || autoReviewModel === "" ? {} : { autoReviewModel },
102
104
  ...autoReviewSkipReadOnly ? { autoReviewSkipReadOnly } : {},
105
+ ...autoReviewOwnGate === void 0 ? {} : { autoReviewOwnGate },
103
106
  ...Array.isArray(autoReviewAllowlist) ? { autoReviewAllowlist: [...autoReviewAllowlist] } : {},
104
107
  ...autoReviewTimeoutMs === void 0 ? {} : { autoReviewTimeoutMs },
105
108
  ...compactProvider === void 0 || compactProvider === "" ? {} : { compactProvider },
@@ -463,7 +466,9 @@ function capabilitiesRpc(registry, snapshot, lifetime, catalog = () => ({
463
466
  }), status = () => ({
464
467
  held: false,
465
468
  allowedCalls: 0,
466
- skippedReadOnly: 0
469
+ skippedReadOnly: 0,
470
+ ownGate: false,
471
+ purgeInstalled: false
467
472
  })) {
468
473
  let revision = 0;
469
474
  let previous;
@@ -557,6 +562,9 @@ function installCapabilitiesRpc(ctx, registry, snapshot) {
557
562
  held: autoReviewStatus.held,
558
563
  allowedCalls: autoReviewStatus.allowedCalls,
559
564
  skippedReadOnly: autoReviewStatus.skippedReadOnly,
565
+ ownGate: ownGateEngaged(),
566
+ purgeInstalled: autoReviewStatus.purgeInstalled,
567
+ ...autoReviewStatus.officialGateNeutered === void 0 ? {} : { officialGateNeutered: autoReviewStatus.officialGateNeutered },
560
568
  automode: automodeCompatView(),
561
569
  primeMemory: {
562
570
  installed: primeMemoryCompatStatus.installed,
@@ -0,0 +1,186 @@
1
+ /**
2
+ * Model Switch's owned Auto-review gate (the "purge takeover").
3
+ *
4
+ * The official `@deepseek-ai/dsh-experimental-auto-review` row this plugin
5
+ * mounts is host-plane code: a third-party host patch (dsh-purge-community
6
+ * 1.7.20, applied 2026-11-23) inserted `return next()` as the first line of
7
+ * its `tools/pre-execute` listener, which silently disabled review for every
8
+ * call regardless of the permission preset. This module forks that review
9
+ * pipeline — snapshot assembly, reviewer request, decision protocol, denial
10
+ * surfaces — verbatim from the official 0.2.2-rc.5 implementation, so the
11
+ * review path lives in this plugin's own source and survives host-package
12
+ * patches. The official package keeps only the registration choreography
13
+ * (`registerAuto`, teardown, dependency gating) it still mounts.
14
+ *
15
+ * Calibration source: `@deepseek-ai/dsh-experimental-auto-review` 0.2.2-rc.5
16
+ * `lib/index.js` (behavior ported line-for-line; the snapshot logic and the
17
+ * REVIEW_POLICY text must track that file — compat-watch diffs it per line).
18
+ *
19
+ * The gate is armed only when the profile started the dsh-purge-community
20
+ * bundle and the `autoReviewOwnGate` setting is not explicitly off; the
21
+ * official gate stays mounted either way, and the two never double-review:
22
+ * whichever listener engages first marks the ambient call context, and the
23
+ * `permissionPresets` shadow in `./auto-review.ts` answers `custom` for the
24
+ * other (see the coordination notes on {@link OwnGateCallContext}).
25
+ *
26
+ * @module dsh-model-switch/auto-review-gate
27
+ */
28
+ import type { GenerateOptions } from '@deepseek-ai/dsh-llm';
29
+ import type { Session } from '@deepseek-ai/dsh-session';
30
+ import type { PreToolDecision } from '@deepseek-ai/dsh-tools';
31
+ import type { Context } from '@deepseek-ai/cordis';
32
+ /** The decision surface the pre-execute waterfall expects (dsh-tools' own shape). */
33
+ type GateDecision = PreToolDecision;
34
+ /**
35
+ * Minimal structural faces of the session log the snapshot reads.
36
+ *
37
+ * These mirror the official gate's reads; the shapes are part of the released
38
+ * session format and are covered by compat-watch.
39
+ */
40
+ export interface ReviewEvent {
41
+ readonly type: string;
42
+ readonly seq: number;
43
+ readonly data: any;
44
+ }
45
+ /** The pending execution's face (subset of dsh-tools' ToolExecution). */
46
+ export interface OwnGateExecution {
47
+ readonly name: string;
48
+ readonly arguments: unknown;
49
+ readonly rootCallId: string;
50
+ readonly callId: string;
51
+ readonly parent: unknown | undefined;
52
+ readonly signal: AbortSignal;
53
+ readonly agent: {
54
+ readonly session: Session;
55
+ } | undefined;
56
+ readonly schema: {
57
+ readonly name: string;
58
+ readonly description: string;
59
+ readonly parameters: unknown;
60
+ } | undefined;
61
+ }
62
+ /** What one own-gate review carries in the ambient call context. */
63
+ export interface OwnGateCallContext {
64
+ /** Marks a call whose review decision another listener already made. */
65
+ handled: boolean;
66
+ /** Marks a call the official gate's listener is engaging with. */
67
+ officialEngaged: boolean;
68
+ }
69
+ /** One frozen reviewer snapshot. */
70
+ export interface AutoReviewSnapshot {
71
+ readonly provider: string;
72
+ readonly model: string;
73
+ readonly cwd: string;
74
+ readonly history: readonly unknown[];
75
+ readonly pending: {
76
+ readonly key: string;
77
+ readonly schema: {
78
+ name: string;
79
+ description: string;
80
+ parameters: unknown;
81
+ };
82
+ };
83
+ }
84
+ /**
85
+ * Freeze the reviewer input from one session and pending execution (official parity).
86
+ * @param session - the session whose durable surface and request header authorize the call.
87
+ * @param exec - immutable pending execution.
88
+ * @param cwd - the session's current working directory.
89
+ * @param shown - schemas earlier reviews of this session showed.
90
+ * @returns the exact route, environment, and history ending with the pending call.
91
+ */
92
+ export declare function snapshotAutoReview(session: Session, exec: OwnGateExecution, cwd: string, shown: ReadonlyMap<string, {
93
+ name: string;
94
+ description: string;
95
+ parameters: unknown;
96
+ }>): AutoReviewSnapshot;
97
+ /** Render the environment and one message per retained item (official parity). */
98
+ export declare function reviewMessages(snapshot: AutoReviewSnapshot): Array<{
99
+ role: 'user';
100
+ content: Array<{
101
+ type: 'text';
102
+ text: string;
103
+ }>;
104
+ }>;
105
+ /** Count members in the raw top-level JSON object. */
106
+ export declare function topLevelMemberCount(text: string): number;
107
+ /** One parsed reviewer decision. */
108
+ export interface ReviewDecision {
109
+ readonly risk: 'low' | 'medium' | 'high';
110
+ readonly decision: 'allow' | 'deny';
111
+ readonly reason?: string;
112
+ }
113
+ /** Parse the closed risk/decision protocol and its fixed safety combinations. */
114
+ export declare function parseDecision(text: string): ReviewDecision;
115
+ /** Consume zero or more reasoning blocks, one JSON text block, and one terminal stop. */
116
+ export declare function readDecision(stream: AsyncIterable<unknown>): Promise<ReviewDecision>;
117
+ /** Minimal llm face the gate uses (it calls exactly `stream`). */
118
+ export interface GateLlm {
119
+ stream(options: GenerateOptions): AsyncIterable<unknown>;
120
+ }
121
+ /** Structural face of the workingDirectory service the gate reads. */
122
+ export interface GateWorkingDirectory {
123
+ ensure(agent: {
124
+ readonly session: Session;
125
+ }, signal: AbortSignal): Promise<string>;
126
+ }
127
+ /** Structural face of the approval service the gate reads. */
128
+ export interface GateApproval {
129
+ overrideOf(session: Session): string;
130
+ }
131
+ /** Review one frozen pending action with the fixed policy and the scoped llm route. */
132
+ export declare function classifyRisk(deps: {
133
+ readonly llm: GateLlm;
134
+ readonly workingDirectory: GateWorkingDirectory;
135
+ }, session: Session, exec: OwnGateExecution, signal: AbortSignal, shown: Map<string, {
136
+ name: string;
137
+ description: string;
138
+ parameters: unknown;
139
+ }>): Promise<ReviewDecision>;
140
+ /** Materialize the fixed model-facing final Auto denial plus optional UI detail. */
141
+ export declare function denied(exec: OwnGateExecution, reason: string | undefined): GateDecision;
142
+ /** Ask the user to decide one call the reviewer denied. */
143
+ export declare function askUser(exec: OwnGateExecution, reason: string | undefined): GateDecision;
144
+ /** Materialize a reviewer failure as its own error rather than a denial. */
145
+ export declare function failed(exec: OwnGateExecution, error: unknown): GateDecision;
146
+ /** The ambient call context shape the own gate coordinates through. */
147
+ export interface OwnGateAmbient {
148
+ readonly session: Session | undefined;
149
+ readonly tool: string;
150
+ /** Marks a call whose review decision another listener already made. */
151
+ handled?: boolean;
152
+ /** Marks a call the official gate's listener is engaging with. */
153
+ officialEngaged?: boolean;
154
+ }
155
+ /** Wiring the own gate needs from the mounting row. */
156
+ export interface OwnGateOptions {
157
+ /** The ambient store shared with the correlation wrapper and the preset shadow. */
158
+ readonly activeSession: {
159
+ getStore(): OwnGateAmbient | undefined;
160
+ };
161
+ /** Whether the own gate should engage (purge bundle present and the setting on). */
162
+ readonly isActive: () => boolean;
163
+ /** The raw preset read (the real service — never the defensive shadow). */
164
+ readonly currentPreset: (session: Session) => string;
165
+ /** Whether the tool is allowlisted (the live settings read). */
166
+ readonly skipReadOnly: (tool: string) => boolean;
167
+ /** Count one read-only skip on the shared status counter. */
168
+ readonly countReadOnlySkip: () => void;
169
+ }
170
+ /**
171
+ * Register this row's own review listener on the gate context.
172
+ *
173
+ * The listener is registered with `{ prepend: true }` after the official gate's
174
+ * apply, so it sits ahead of the official listener in the waterfall; the
175
+ * correlation wrapper (bound later, also prepended) stays outermost. Whichever
176
+ * listener engages first marks the ambient context (`handled` for ours, the
177
+ * shadow's `custom` answer for the official probe), so a call is never reviewed
178
+ * twice regardless of mount ordering.
179
+ *
180
+ * @param gateCtx - the context the official gate mounted under (services resolve
181
+ * through the review scope: the llm proxy routes the reviewer, the shadowed
182
+ * permissionPresets is bypassed via {@link OwnGateOptions.currentPreset}).
183
+ * @param options - the wiring from the mounting row.
184
+ */
185
+ export declare function installOwnReviewGate(gateCtx: Context, options: OwnGateOptions): void;
186
+ export {};
@@ -66,7 +66,24 @@ export declare const autoReviewStatus: {
66
66
  held: boolean;
67
67
  allowedCalls: number;
68
68
  skippedReadOnly: number;
69
+ /** Whether the profile started the dsh-purge-community bundle (mount-time read). */
70
+ purgeInstalled: boolean;
71
+ /**
72
+ * Whether the official gate's host code carries a third-party patch marker.
73
+ *
74
+ * Best-effort diagnostic only: the own gate does not depend on it. `undefined`
75
+ * means the official package could not be read.
76
+ */
77
+ officialGateNeutered: boolean | undefined;
69
78
  };
79
+ /**
80
+ * Whether the own review gate engages for the current call.
81
+ *
82
+ * The purge bundle must have started (mount-time) and the setting must not be
83
+ * explicitly off (per-call read); on a purge-free host the own gate never
84
+ * engages and the official gate stays the only reviewer.
85
+ */
86
+ export declare function ownGateEngaged(): boolean;
70
87
  /**
71
88
  * What one `tools/pre-execute` call carries into the reviewer's async context.
72
89
  *
@@ -79,6 +96,16 @@ export interface AutoCallContext {
79
96
  readonly session: Session | undefined;
80
97
  /** `exec.name` — the tool under review. */
81
98
  readonly tool: string;
99
+ /**
100
+ * Marks a call whose review decision another listener already made.
101
+ *
102
+ * Set by the own gate when it reviews (or read-only-skips) a call, and by the
103
+ * preset shadow when it takes the official gate's probe off the reviewer —
104
+ * whichever listener engages first wins, so a call is never reviewed twice.
105
+ */
106
+ handled?: boolean;
107
+ /** Marks a call the official gate's listener is engaging with. */
108
+ officialEngaged?: boolean;
82
109
  }
83
110
  /** The read-only skip: which tools, and whether the switch is on. */
84
111
  export interface ReadOnlyBypass {
@@ -264,14 +291,16 @@ export interface MountedAutoReviewGate {
264
291
  * `inject`. Mounting it instead lets cordis resolve the official list, which is
265
292
  * what keeps a released Host's new dependency (0.2.1's `workingDirectory`) from
266
293
  * breaking every tool call. The hooks let the caller observe whether the gate
267
- * actually ran before it binds the session-correlation listener.
294
+ * actually ran before it binds the session-correlation listener; `onApplied`
295
+ * receives the gate's own context so per-mount listeners (the own gate) can
296
+ * register on it and share its lifetime.
268
297
  *
269
298
  * @param gate - the official module (or an equivalent structural gate).
270
299
  * @param hooks - applied/failure observers; the failure is rethrown.
271
300
  * @returns A cordis plugin mounting the official gate unchanged.
272
301
  */
273
302
  export declare function autoReviewGate(gate: OfficialAutoReviewGate, hooks?: {
274
- readonly onApplied?: () => void;
303
+ readonly onApplied?: (gateCtx: Context) => void;
275
304
  readonly onFailure?: (error: unknown) => void;
276
305
  }): MountedAutoReviewGate;
277
306
  /**
@@ -8,6 +8,12 @@ export interface ReviewStatus {
8
8
  readonly held: boolean;
9
9
  readonly allowedCalls: number;
10
10
  readonly skippedReadOnly: number;
11
+ /** Whether this plugin's own review gate engages (purge bundle + setting). */
12
+ readonly ownGate: boolean;
13
+ /** Whether the profile started the dsh-purge-community bundle. */
14
+ readonly purgeInstalled: boolean;
15
+ /** Whether the official gate's host code carries a third-party patch marker; undefined when unreadable. */
16
+ readonly officialGateNeutered?: boolean | undefined;
11
17
  /** Third-party `@log.li/dsh-automode` row, when this Host mounts one. */
12
18
  readonly automode?: {
13
19
  readonly installed: boolean;
@@ -35,6 +35,8 @@ export interface ModelSwitchSettingsFace {
35
35
  enabled: boolean;
36
36
  tools: readonly string[];
37
37
  }) => Promise<void>;
38
+ /** Persist the purge-takeover switch (the own review gate). */
39
+ saveReviewOwnGate: (ownGate: boolean) => Promise<void>;
38
40
  /** The Host's live tool catalog; absent on a Host without the `tools` RPC endpoint. */
39
41
  scanTools?: () => Promise<{
40
42
  rows: readonly ToolCatalogRow[];
@@ -94,6 +94,13 @@ export declare const zh: {
94
94
  readonly reviewAllowlistAvailable: "本机存在但未放行的工具:";
95
95
  readonly reviewAllowlistRepo: "仓库";
96
96
  readonly reviewAllowlistSkipped: "本 Host 进程已为纯读调用跳过 {count} 次审查。";
97
+ readonly reviewOwnGate: "破甲接管:自有审查门";
98
+ readonly reviewOwnGateHelp: "安装破甲(dsh-purge)后,官方审查门的宿主代码会被其补丁短路;开启后由本插件的自有审查门接管 auto 会话的逐调用审查,路由仍用上方配置的审查模型。";
99
+ readonly reviewOwnGateUnavailable: "未检测到破甲插件:官方审查门正常服务,此开关不适用。";
100
+ readonly reviewOwnGatePatched: "官方门补丁状态:{neutered}。";
101
+ readonly reviewOwnGateNeuteredYes: "已被宿主补丁短路";
102
+ readonly reviewOwnGateNeuteredNo: "未见补丁标记";
103
+ readonly reviewOwnGateUnknown: "未知";
97
104
  readonly reviewAutomodeLinked: "Auto mode 已接入:审查路由 {route},直通 +{added} 个纯读工具({skipped} 条通配未同步)。";
98
105
  readonly reviewAutomodeRouteOwn: "沿用其自身配置";
99
106
  readonly reviewAutomodeRouteUnset: "未配置(沿用会话模型)";
@@ -14,6 +14,8 @@ export interface ModelSwitchSettingsView {
14
14
  autoReviewModel?: string;
15
15
  /** Opt-in read-only skip for the Auto reviewer; absent/false keeps every call reviewed. */
16
16
  autoReviewSkipReadOnly?: boolean;
17
+ /** Purge takeover: run the own review gate on a dsh-purge host (default on; grayed out without that bundle). */
18
+ autoReviewOwnGate?: boolean;
17
19
  /** Exact tool names, or trailing-`*` patterns, that skip the reviewer when enabled. */
18
20
  autoReviewAllowlist?: readonly string[];
19
21
  compactProvider?: string;
@@ -123,6 +125,12 @@ export interface ReviewStatusView {
123
125
  readonly held: boolean;
124
126
  readonly allowedCalls: number;
125
127
  readonly skippedReadOnly: number;
128
+ /** Whether this plugin's own review gate engages (purge bundle started and the setting not off). */
129
+ readonly ownGate: boolean;
130
+ /** Whether the profile started the dsh-purge-community bundle. */
131
+ readonly purgeInstalled: boolean;
132
+ /** Whether the official gate's host code carries a third-party patch marker; undefined when unreadable. */
133
+ readonly officialGateNeutered?: boolean | undefined;
126
134
  /** Third-party `@log.li/dsh-automode` row this Host adapted, when present. */
127
135
  readonly automode?: {
128
136
  readonly route?: string | undefined;
@@ -21,6 +21,15 @@ export interface ModelSwitchSettings {
21
21
  * reviewer. Absent/false keeps every call reviewed (the shipped default).
22
22
  */
23
23
  autoReviewSkipReadOnly?: boolean;
24
+ /**
25
+ * Whether this plugin's own review gate takes over the Auto review on a
26
+ * dsh-purge-patched host (default true). The official gate's host code can be
27
+ * short-circuited by that patch; the own gate runs the same review pipeline
28
+ * from this plugin's source. Only meaningful when the dsh-purge-community
29
+ * bundle started — on a clean host the switch is ignored (the official gate
30
+ * serves) and the settings card grays it out.
31
+ */
32
+ autoReviewOwnGate?: boolean;
24
33
  /**
25
34
  * Tool names that skip the reviewer when {@link autoReviewSkipReadOnly} is on.
26
35
  *
@@ -77,6 +86,8 @@ export interface Config {
77
86
  autoReviewModel: Volatile<string | undefined>;
78
87
  /** Opt-in: skip the Auto reviewer for allowlisted pure-read tools (default off). */
79
88
  autoReviewSkipReadOnly: Volatile<boolean>;
89
+ /** Purge takeover: run the own review gate on a dsh-purge host (default on). */
90
+ autoReviewOwnGate: Volatile<boolean>;
80
91
  /** Tool names (exact, or a trailing `*` pattern) that skip the Auto reviewer. */
81
92
  autoReviewAllowlist: Volatile<readonly string[]>;
82
93
  /** Reviewer stream idle timeout in ms; 0 = cancel (upstream ceiling); absent = provider default. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-model-switch",
3
- "version": "0.4.72",
3
+ "version": "0.4.73",
4
4
  "description": "Explicit model routing plus composer/Plan picker for DeepSeek Harness",
5
5
  "repository": {
6
6
  "type": "git",