dsh-model-guard 0.0.0-stage → 1.0.1

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 lawrsp
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,82 @@
1
- # Temporary Holding Version
1
+ # Directory model guard
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ English | [中文](README.zh.md)
4
+
5
+ Chinese: **模型守卫** (`dsh-model-guard`)
6
+
7
+ Sets a model whitelist for each workspace folder. When the model selected in a
8
+ Session is not allowed in that Session's current folder, the composer locks and
9
+ the model selector turns red. While the Session is idle, the send button is red
10
+ too. The message cannot be sent until another model is chosen or the rule is
11
+ changed.
12
+
13
+ ## Install
14
+
15
+ ```sh
16
+ dsh plugin --profile web add dsh-model-guard
17
+ ```
18
+
19
+ Or install the GitHub source directly:
20
+
21
+ ```sh
22
+ dsh plugin --profile web add github:lawrsp/dsh-model-guard
23
+ ```
24
+
25
+ In the Web UI, the same package can be installed from **Plugins → Add plugin**.
26
+
27
+ ## Use
28
+
29
+ 1. Open **Settings** and choose **Model guard**.
30
+ 2. Choose **Add directory rule**.
31
+ 3. Enter an absolute folder path, or choose **Use current workspace**.
32
+ 4. Select the models that may be used there, then choose **Save rule**.
33
+ 5. Return to a Session in that folder. The model selector stays usable while
34
+ the composer is locked, because changing the model is how you clear the
35
+ block.
36
+
37
+ For a faster path, open a Workspace's **...** menu (or right-click the
38
+ Workspace header) and choose **Set model whitelist**. When that directory
39
+ already has an exact rule, the entry reads **Edit model whitelist** and opens an
40
+ editor with the current selection. The dialog is fixed to that Workspace's
41
+ path. When an exact rule exists, it also offers **Delete rule**. If the folder
42
+ has no exact rule but inherits a parent rule, the dialog starts from the
43
+ inherited models and says that saving creates an override for this folder.
44
+
45
+ Paths are normalized to forward slashes. A rule applies to its directory and
46
+ all descendants; the deepest matching rule wins. A directory with no matching
47
+ rule, whether its own or inherited from an ancestor, is unrestricted. A rule with no
48
+ selected models blocks every model in that folder once a model is selected.
49
+
50
+ ## Model keys
51
+
52
+ The Settings page lists the Host's model catalog. A manually entered key may be:
53
+
54
+ - `provider/model` — one exact model route;
55
+ - `model` — that model id under any provider;
56
+ - `provider/*` — every model from one provider;
57
+ - `*` — every model.
58
+
59
+ ## Screenshots
60
+
61
+ ![The composer locked with a red model selector, a red send button, and a Model restricted badge](assets/composer-blocked.png)
62
+
63
+ ![The Model guard settings page with directory rules and their allowed models](assets/settings.png)
64
+
65
+ ![The quick rule editor showing the model catalog and selected models](assets/rule-dialog.png)
66
+
67
+ ## Storage and limitations
68
+
69
+ Rules are the plugin entry's volatile `rules` configuration. The config editor
70
+ persists them in the active DSH profile, so every browser connected to that
71
+ profile reads and edits the same whitelist, and the rules survive reloads and
72
+ restarts. A different profile keeps its own rules.
73
+
74
+ The composer guard is the user-facing rejection. The Host also installs an
75
+ `agent/pre-step` safety net: when a step's active model is not allowed in the
76
+ Session's directory, the step is rejected before any model request. Because DSH
77
+ acknowledges `session/prompt` before pre-step, a direct Session API prompt can
78
+ be acknowledged and then end as a blocked turn instead of receiving an
79
+ immediate RPC error; it produces no model response. The model selector is tinted
80
+ whenever a rule blocks the active model. While the Session is idle the send
81
+ button is red too; while a turn is running, the primary button remains Stop and
82
+ keeps its normal color.
package/README.zh.md ADDED
@@ -0,0 +1,56 @@
1
+ # 模型守卫
2
+
3
+ [English](README.md) | 中文
4
+
5
+ 中文名:**模型守卫**(插件名 `dsh-model-guard`)
6
+
7
+ 按工作区目录设定可用模型白名单。当会话当前目录不允许所选模型时,输入框会锁定,模型选择器变红;会话空闲时发送按钮也会变红,直到切换到允许的模型或修改规则后才能发送。
8
+
9
+ ## 安装
10
+
11
+ ```sh
12
+ dsh plugin --profile web add dsh-model-guard
13
+ ```
14
+
15
+ 也可以直接从 GitHub 安装:
16
+
17
+ ```sh
18
+ dsh plugin --profile web add github:lawrsp/dsh-model-guard
19
+ ```
20
+
21
+ 在 Web UI 中,也可以通过 **插件 → 添加插件** 安装。
22
+
23
+ ## 使用
24
+
25
+ 1. 打开 **设置**,选择 **模型守卫**。
26
+ 2. 点击 **添加目录规则**。
27
+ 3. 输入绝对路径,或点击 **使用当前工作区**。
28
+ 4. 勾选该目录允许使用的模型,然后点击 **保存规则**。
29
+ 5. 回到该目录下的会话。输入框锁定时,模型选择器仍然可用,因为切换模型就是解除锁定的方式。
30
+
31
+ 更快捷的方式:打开工作区标题的 **“...”** 菜单(或右键工作区标题),选择 **设置模型白名单**。如果该目录已有精确规则,菜单项会显示 **编辑模型白名单**,并打开编辑器,带入当前选择。弹窗中的目录固定为该工作区路径;存在精确规则时还会提供 **删除规则**。如果该目录没有精确规则但继承了父目录规则,弹窗会从继承的模型开始,并提示保存后会在本目录创建一条覆盖规则。
32
+
33
+ 路径会统一规范为正斜杠。规则作用于其目录及所有子目录,最深的匹配规则优先。没有任何匹配规则(自身或祖先目录)的目录不受限制。规则中不选择任何模型时,该目录会在会话选中模型后拦截所有模型。
34
+
35
+ ## 模型键
36
+
37
+ 设置页会列出 Host 的模型目录。也可以手动输入以下形式的键:
38
+
39
+ - `provider/model` — 一个精确的模型路由;
40
+ - `model` — 任意 provider 下该模型 ID;
41
+ - `provider/*` — 某个 provider 的全部模型;
42
+ - `*` — 全部模型。
43
+
44
+ ## 截图
45
+
46
+ ![输入框被锁定,模型选择器和发送按钮变红,并显示“模型受限”徽标](assets/composer-blocked.png)
47
+
48
+ ![模型守卫设置页中的目录规则及允许模型](assets/settings.png)
49
+
50
+ ![快捷规则编辑器中的模型目录和已选模型](assets/rule-dialog.png)
51
+
52
+ ## 存储与限制
53
+
54
+ 规则保存在插件条目的 volatile `rules` 配置中。配置编辑器会将其持久化到当前 DSH profile,因此连接到该 profile 的所有浏览器读写同一份白名单,刷新和重启后仍然保留。不同 profile 各自独立。
55
+
56
+ 输入框守卫是用户可见的拦截。Host 还会安装 `agent/pre-step` 安全网:如果步骤使用的模型不在当前 Session 目录的允许列表中,会在发出模型请求前拒绝该步骤。由于 DSH 在 pre-step 之前已经确认 `session/prompt`,直接调用 Session API 时可能先被接受,然后以 blocked 回合结束,而不是立即收到 RPC 错误;它不会产生模型响应。只要规则拦截当前模型,模型选择器就会显示红色;会话空闲时发送按钮也会变红,回合运行中主按钮仍为“停止”并保持原色。
Binary file
Binary file
Binary file
Binary file