dsh-permission-rules 0.4.2 → 0.5.2
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/CHANGELOG.md +34 -0
- package/README.es.md +160 -117
- package/README.hi.md +162 -119
- package/README.md +133 -90
- package/README.pt.md +161 -118
- package/README.zh.md +162 -119
- package/docs/rule-test-vectors/README.md +28 -0
- package/docs/rule-test-vectors/corpus.json +109 -0
- package/lib/client.js +4693 -0
- package/lib/client.js.map +1 -0
- package/lib/index.js +1530 -179
- package/lib/typert.host.js +4305 -0
- package/lib/types/client/index.d.ts +28 -0
- package/lib/types/client/index.d.ts.map +1 -0
- package/lib/types/client/locales.d.ts +9 -0
- package/lib/types/client/locales.d.ts.map +1 -0
- package/lib/types/client/remote.d.ts +181 -0
- package/lib/types/client/remote.d.ts.map +1 -0
- package/lib/types/client/section.d.ts +35 -0
- package/lib/types/client/section.d.ts.map +1 -0
- package/lib/types/config.d.ts +54 -2
- package/lib/types/config.d.ts.map +1 -1
- package/lib/types/events.d.ts +45 -0
- package/lib/types/events.d.ts.map +1 -1
- package/lib/types/index.d.ts +8 -6
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/network.d.ts +90 -0
- package/lib/types/network.d.ts.map +1 -0
- package/lib/types/prose.d.ts +15 -0
- package/lib/types/prose.d.ts.map +1 -1
- package/lib/types/proxy.d.ts +128 -0
- package/lib/types/proxy.d.ts.map +1 -0
- package/lib/types/remote-service.d.ts +45 -0
- package/lib/types/remote-service.d.ts.map +1 -0
- package/lib/types/rules.d.ts +131 -0
- package/lib/types/rules.d.ts.map +1 -1
- package/lib/types/runtime.d.ts +153 -21
- package/lib/types/runtime.d.ts.map +1 -1
- package/lib/types/settings.d.ts +28 -0
- package/lib/types/settings.d.ts.map +1 -0
- package/lib/types/typert.host.d.ts +166 -0
- package/lib/types/typert.host.d.ts.map +1 -0
- package/lib/types/wire.d.ts +421 -0
- package/lib/types/wire.d.ts.map +1 -0
- package/package.json +182 -144
- package/scripts/repair-session-logs.mjs +7 -2
- package/src/client/index.ts +111 -0
- package/src/client/locales.ts +94 -0
- package/src/client/remote.ts +41 -0
- package/src/client/section.ts +201 -0
- package/src/config.ts +111 -0
- package/src/events.ts +46 -0
- package/src/index.ts +2 -0
- package/src/network.ts +177 -0
- package/src/prose.ts +85 -10
- package/src/proxy.ts +327 -0
- package/src/remote-service.ts +109 -0
- package/src/rules.ts +424 -5
- package/src/runtime.ts +464 -53
- package/src/settings.ts +74 -0
- package/src/typert.host.ts +25 -0
- package/src/wire.ts +239 -0
- package/lib/types/config.js +0 -99
- package/lib/types/config.js.map +0 -1
- package/lib/types/events.js +0 -44
- package/lib/types/events.js.map +0 -1
- package/lib/types/glob.js +0 -307
- package/lib/types/glob.js.map +0 -1
- package/lib/types/index.js +0 -27
- package/lib/types/index.js.map +0 -1
- package/lib/types/prose.js +0 -173
- package/lib/types/prose.js.map +0 -1
- package/lib/types/rules.js +0 -610
- package/lib/types/rules.js.map +0 -1
- package/lib/types/runtime.js +0 -818
- package/lib/types/runtime.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,144 +1,182 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "dsh-permission-rules",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Declarative Claude Code-style permission rules for DeepSeek Harness: ordered allow/deny/ask rules with tool-name, argument (glob/regex),
|
|
5
|
-
"private": false,
|
|
6
|
-
"type": "module",
|
|
7
|
-
"main": "./lib/index.js",
|
|
8
|
-
"types": "./lib/types/index.d.ts",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"types": "./lib/types/index.d.ts",
|
|
12
|
-
"default": "./lib/index.js"
|
|
13
|
-
},
|
|
14
|
-
"./
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
},
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
"
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
},
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
"
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
"
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
"
|
|
101
|
-
"
|
|
102
|
-
"
|
|
103
|
-
"
|
|
104
|
-
"
|
|
105
|
-
"
|
|
106
|
-
"
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
"
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
"
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
"
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
"@deepseek-ai/
|
|
124
|
-
"@
|
|
125
|
-
"@
|
|
126
|
-
"@
|
|
127
|
-
"dsh-
|
|
128
|
-
"
|
|
129
|
-
"
|
|
130
|
-
"
|
|
131
|
-
"
|
|
132
|
-
},
|
|
133
|
-
"
|
|
134
|
-
"
|
|
135
|
-
"
|
|
136
|
-
"
|
|
137
|
-
"
|
|
138
|
-
"
|
|
139
|
-
"
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "dsh-permission-rules",
|
|
3
|
+
"version": "0.5.2",
|
|
4
|
+
"description": "Declarative Claude Code-style permission rules plus a Codex-style process-level network policy for DeepSeek Harness: ordered allow/deny/ask rules with tool-name, argument (glob/regex), workspace-path, and network-target (domain/ip/port/scheme) matching on the tools/pre-execute waterfall, a built-in local HTTP/CONNECT proxy governing shell subprocess traffic, three network modes mapped onto the official sandbox presets, full session-log audit, HMR rule reload, and a settings page with a rule editor, block counters, and recent interception lists.",
|
|
5
|
+
"private": false,
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./lib/index.js",
|
|
8
|
+
"types": "./lib/types/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./lib/types/index.d.ts",
|
|
12
|
+
"default": "./lib/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./typert": {
|
|
15
|
+
"types": "./lib/types/typert.host.d.ts",
|
|
16
|
+
"default": "./lib/typert.host.js"
|
|
17
|
+
},
|
|
18
|
+
"./client": {
|
|
19
|
+
"types": "./lib/types/client/index.d.ts",
|
|
20
|
+
"default": "./lib/client.js"
|
|
21
|
+
},
|
|
22
|
+
"./package.json": "./package.json"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"lib",
|
|
26
|
+
"src",
|
|
27
|
+
"cordis.patch.yml",
|
|
28
|
+
"docs",
|
|
29
|
+
"scripts/repair-session-logs.mjs",
|
|
30
|
+
"README.md",
|
|
31
|
+
"README.zh.md",
|
|
32
|
+
"README.es.md",
|
|
33
|
+
"README.pt.md",
|
|
34
|
+
"README.hi.md",
|
|
35
|
+
"CHANGELOG.md",
|
|
36
|
+
"LICENSE"
|
|
37
|
+
],
|
|
38
|
+
"sideEffects": false,
|
|
39
|
+
"dsh": {
|
|
40
|
+
"bundle": {
|
|
41
|
+
"patch": "./cordis.patch.yml"
|
|
42
|
+
},
|
|
43
|
+
"client": {
|
|
44
|
+
"platform": "web",
|
|
45
|
+
"inject": [
|
|
46
|
+
"@deepseek-ai/dsh-client-connection",
|
|
47
|
+
"@deepseek-ai/dsh-client-runtime",
|
|
48
|
+
"@deepseek-ai/dsh-client-locale",
|
|
49
|
+
"@deepseek-ai/dsh-client-ui-settings"
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"dshWorkshop": {
|
|
54
|
+
"schema": "omdsh-workshop-package/v1",
|
|
55
|
+
"type": "plugin",
|
|
56
|
+
"integration": {
|
|
57
|
+
"protocol": "harness-profile",
|
|
58
|
+
"artifact": "cordis.patch.yml"
|
|
59
|
+
},
|
|
60
|
+
"install": {
|
|
61
|
+
"mode": "transactional",
|
|
62
|
+
"adapter": "profile-bundle",
|
|
63
|
+
"failurePolicy": "generation-rollback",
|
|
64
|
+
"touchesCurrentBeforeActivation": false
|
|
65
|
+
},
|
|
66
|
+
"lifecycle": {
|
|
67
|
+
"activation": "restart-profile",
|
|
68
|
+
"dispose": "supported"
|
|
69
|
+
},
|
|
70
|
+
"permissions": [
|
|
71
|
+
"files:read",
|
|
72
|
+
"files:watch",
|
|
73
|
+
"files:write",
|
|
74
|
+
"session:append",
|
|
75
|
+
"network:outbound"
|
|
76
|
+
],
|
|
77
|
+
"compatibility": {
|
|
78
|
+
"dshVersions": [
|
|
79
|
+
"0.1.0-rc.5",
|
|
80
|
+
"0.1.0-rc.7",
|
|
81
|
+
"0.1.0-rc.7"
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
"capability": {
|
|
85
|
+
"id": "rules",
|
|
86
|
+
"kind": "command",
|
|
87
|
+
"invocation": "/rules",
|
|
88
|
+
"expected": "lists the active permission rules with their source files"
|
|
89
|
+
},
|
|
90
|
+
"evidence": {
|
|
91
|
+
"install": null,
|
|
92
|
+
"failureIsolation": null,
|
|
93
|
+
"hotReload": null,
|
|
94
|
+
"remove": null
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"keywords": [
|
|
98
|
+
"dsh",
|
|
99
|
+
"dsh-plugin",
|
|
100
|
+
"deepseek-harness",
|
|
101
|
+
"permission",
|
|
102
|
+
"policy",
|
|
103
|
+
"allow-deny-ask",
|
|
104
|
+
"approval",
|
|
105
|
+
"safety",
|
|
106
|
+
"network",
|
|
107
|
+
"network-policy",
|
|
108
|
+
"proxy"
|
|
109
|
+
],
|
|
110
|
+
"author": "dsh-permission-rules contributors",
|
|
111
|
+
"repository": {
|
|
112
|
+
"type": "git",
|
|
113
|
+
"url": "git+https://github.com/PerryLink/dsh-permission-rules.git"
|
|
114
|
+
},
|
|
115
|
+
"homepage": "https://github.com/PerryLink/dsh-permission-rules#readme",
|
|
116
|
+
"bugs": {
|
|
117
|
+
"url": "https://github.com/PerryLink/dsh-permission-rules/issues"
|
|
118
|
+
},
|
|
119
|
+
"engines": {
|
|
120
|
+
"node": "^22.19.0 || >=24.0.0"
|
|
121
|
+
},
|
|
122
|
+
"peerDependencies": {
|
|
123
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
124
|
+
"@deepseek-ai/dsh-agent": "0.1.0-rc.7",
|
|
125
|
+
"@deepseek-ai/dsh-commands": "0.1.0-rc.7",
|
|
126
|
+
"@deepseek-ai/dsh-llm": "0.1.0-rc.7",
|
|
127
|
+
"@deepseek-ai/dsh-session": "0.1.0-rc.7",
|
|
128
|
+
"@deepseek-ai/dsh-tools": "0.1.0-rc.7",
|
|
129
|
+
"@deepseek-ai/dsh-typert-protocol": "0.1.0-rc.7",
|
|
130
|
+
"@deepseek-ai/schemastery": "^3.18.0",
|
|
131
|
+
"react": "^18.2.0"
|
|
132
|
+
},
|
|
133
|
+
"dependencies": {
|
|
134
|
+
"@types/react": "18.3.31",
|
|
135
|
+
"chokidar": "^5.0.0",
|
|
136
|
+
"tsdown": "^0.22.14",
|
|
137
|
+
"typescript": "^5.9.0",
|
|
138
|
+
"yaml": "^2.8.0",
|
|
139
|
+
"zod": "^4.4.3"
|
|
140
|
+
},
|
|
141
|
+
"devDependencies": {
|
|
142
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
143
|
+
"@deepseek-ai/cordis-plugin-loader": "1.0.2",
|
|
144
|
+
"@deepseek-ai/dsh-agent": "0.1.0-rc.7",
|
|
145
|
+
"@deepseek-ai/dsh-client-connection": "0.1.0-rc.7",
|
|
146
|
+
"@deepseek-ai/dsh-client-locale": "0.1.0-rc.7",
|
|
147
|
+
"@deepseek-ai/dsh-client-runtime": "0.1.0-rc.7",
|
|
148
|
+
"@deepseek-ai/dsh-client-ui-settings": "0.1.0-rc.7",
|
|
149
|
+
"@deepseek-ai/dsh-client-ui-slots": "0.1.0-rc.7",
|
|
150
|
+
"@deepseek-ai/dsh-commands": "0.1.0-rc.7",
|
|
151
|
+
"@deepseek-ai/dsh-llm": "0.1.0-rc.7",
|
|
152
|
+
"@deepseek-ai/dsh-session": "0.1.0-rc.7",
|
|
153
|
+
"@deepseek-ai/dsh-subagent": "0.1.0-rc.7",
|
|
154
|
+
"@deepseek-ai/dsh-tools": "0.1.0-rc.7",
|
|
155
|
+
"@deepseek-ai/dsh-typert-protocol": "0.1.0-rc.7",
|
|
156
|
+
"@deepseek-ai/dsh-user-approval": "0.1.0-rc.7",
|
|
157
|
+
"@deepseek-ai/schemastery": "^3.18.0",
|
|
158
|
+
"@eslint/js": "^10.0.1",
|
|
159
|
+
"@types/node": "^22.19.0",
|
|
160
|
+
"@vitest/coverage-v8": "^3.2.0",
|
|
161
|
+
"dsh-auto-review": "file:vendor/dsh-auto-review-0.5.1.tgz",
|
|
162
|
+
"eslint": "^10.8.1",
|
|
163
|
+
"globals": "^17.11.0",
|
|
164
|
+
"react": "18.3.1",
|
|
165
|
+
"react-dom": "18.3.1",
|
|
166
|
+
"typescript-eslint": "^8.67.0",
|
|
167
|
+
"vitest": "^3.2.0"
|
|
168
|
+
},
|
|
169
|
+
"scripts": {
|
|
170
|
+
"build": "node scripts/prepare.mjs",
|
|
171
|
+
"typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json --noEmit",
|
|
172
|
+
"lint": "eslint src test scripts",
|
|
173
|
+
"test": "vitest run",
|
|
174
|
+
"test:coverage": "vitest run --coverage",
|
|
175
|
+
"check:readmes": "node scripts/check-readme-sync.mjs",
|
|
176
|
+
"verify:self-contained": "node scripts/verify-self-contained.mjs",
|
|
177
|
+
"pack:check": "node scripts/prepare.mjs && pnpm pack",
|
|
178
|
+
"prepare": "node scripts/prepare.mjs"
|
|
179
|
+
},
|
|
180
|
+
"packageManager": "pnpm@11.7.0",
|
|
181
|
+
"license": "Apache-2.0"
|
|
182
|
+
}
|
|
@@ -24,8 +24,10 @@
|
|
|
24
24
|
*
|
|
25
25
|
* `--home` defaults to `$env:DSH_HOME/sessions` or `~/.dsh/sessions`.
|
|
26
26
|
* The default target set is the log-only audit vocabulary owned by the
|
|
27
|
-
* dsh-permission-rules / dsh-auto-review plugins
|
|
28
|
-
*
|
|
27
|
+
* dsh-permission-rules / dsh-auto-review plugins (all five `autoReview/*`
|
|
28
|
+
* event types — `state`, `verdict`, `circuit`, `override`, `rejection`);
|
|
29
|
+
* only types you understand to be reconstruction-safe may be added via
|
|
30
|
+
* `--types`.
|
|
29
31
|
*/
|
|
30
32
|
|
|
31
33
|
import { constants, zstdCompressSync, zstdDecompressSync } from 'node:zlib'
|
|
@@ -40,6 +42,9 @@ const DEFAULT_TARGET_TYPES = [
|
|
|
40
42
|
'permissionRules/decision',
|
|
41
43
|
'autoReview/verdict',
|
|
42
44
|
'autoReview/state',
|
|
45
|
+
'autoReview/circuit',
|
|
46
|
+
'autoReview/override',
|
|
47
|
+
'autoReview/rejection',
|
|
43
48
|
]
|
|
44
49
|
|
|
45
50
|
/** Row types that are storage records, never session events (leave untouched). */
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `dsh-permission-rules`, browser half: mounts the `permissionRules`
|
|
3
|
+
* Remote contribution, then registers the "Permission Rules" settings
|
|
4
|
+
* page (`settings.section`, id `permission-rules`) with the network-policy
|
|
5
|
+
* summary, block counters, the recent interception list, and the rule
|
|
6
|
+
* editor. All data arrives through the `remote.permissionRules`
|
|
7
|
+
* namespace — the page issues no other RPC.
|
|
8
|
+
*
|
|
9
|
+
* The slot and remote services are accessed structurally (through
|
|
10
|
+
* `ctx.get`/`ctx.inject`) so this bundle compiles against the published
|
|
11
|
+
* rc.6 client peers without hard value imports beyond the platform
|
|
12
|
+
* modules.
|
|
13
|
+
* @module dsh-permission-rules/client
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type { Context } from '@deepseek-ai/cordis'
|
|
17
|
+
import type { RemoteResult } from '@deepseek-ai/dsh-typert-protocol'
|
|
18
|
+
import { PERMISSION_RULES_REMOTE } from './remote.ts'
|
|
19
|
+
import { PermissionRulesSection } from './section.ts'
|
|
20
|
+
import type { PermissionRulesSectionInjected } from './section.ts'
|
|
21
|
+
import { en, zh, type PermissionRulesLocaleKey } from './locales.ts'
|
|
22
|
+
import type { PermissionRulesSnapshot, RulesReadResult, RulesReloadResult, RulesSaveResult } from '../wire.ts'
|
|
23
|
+
|
|
24
|
+
/** Dictionary namespace owned by this plugin. */
|
|
25
|
+
export const NS = 'settings.permissionRules'
|
|
26
|
+
|
|
27
|
+
/** Plugin name: matches the package name, the graph row id, and the bundle id. */
|
|
28
|
+
export const name = 'dsh-permission-rules'
|
|
29
|
+
|
|
30
|
+
/** Services the page reads; `remote.permissionRules` appears once this plugin mounts its contribution. */
|
|
31
|
+
export const inject = ['slots', 'locale', 'remote']
|
|
32
|
+
|
|
33
|
+
/** The locale registry face (structural; the real `ctx.locale` satisfies it). */
|
|
34
|
+
interface LocaleLike {
|
|
35
|
+
register(namespace: string, dictionaries: { en: Record<string, string>; zh: Record<string, string> }): () => void
|
|
36
|
+
bind(namespace: string): (key: PermissionRulesLocaleKey, vars?: Record<string, string | number>) => string
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** The remote-contribution host face (structural; the real `ctx.remote` satisfies it). */
|
|
40
|
+
interface RemoteLike {
|
|
41
|
+
$mount(contribution: unknown): Promise<void>
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** The slots registry face (structural; the real `ctx.slots` satisfies it). */
|
|
45
|
+
interface SlotsLike {
|
|
46
|
+
inject(slot: string, register: () => unknown): void
|
|
47
|
+
register(options: object, component: unknown): unknown
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Browser plugin body: dictionaries, the Remote contribution mount, and
|
|
52
|
+
* the settings-section registration.
|
|
53
|
+
* @param ctx - client root context.
|
|
54
|
+
*/
|
|
55
|
+
export async function apply(ctx: Context): Promise<void> {
|
|
56
|
+
const locale = ctx.get('locale') as LocaleLike | undefined
|
|
57
|
+
const remote = ctx.get('remote') as RemoteLike | undefined
|
|
58
|
+
const slots = ctx.get('slots') as SlotsLike | undefined
|
|
59
|
+
if (locale === undefined || remote === undefined || slots === undefined) return
|
|
60
|
+
|
|
61
|
+
// locale.register returns the only unregister disposer and throws on a
|
|
62
|
+
// duplicate namespace: ride this fiber's effect so unload/reload cycles
|
|
63
|
+
// can re-register the dictionaries.
|
|
64
|
+
ctx.effect(() => locale.register(NS, { zh, en }), 'dsh-permission-rules: dictionaries')
|
|
65
|
+
|
|
66
|
+
// $mount registers the 'remote.permissionRules' namespace service and owns
|
|
67
|
+
// its removal for this fiber's lifetime.
|
|
68
|
+
await remote.$mount(PERMISSION_RULES_REMOTE)
|
|
69
|
+
|
|
70
|
+
ctx.inject(['remote.permissionRules'], (scope) => {
|
|
71
|
+
const t = locale.bind(NS)
|
|
72
|
+
const bridge = scope.get('remote.permissionRules') as {
|
|
73
|
+
networkStatus: () => Promise<RemoteResult<PermissionRulesSnapshot>>
|
|
74
|
+
rulesRead: (path: string) => Promise<RemoteResult<RulesReadResult>>
|
|
75
|
+
rulesSave: (path: string, text: string) => Promise<RemoteResult<RulesSaveResult>>
|
|
76
|
+
reload: () => Promise<RemoteResult<RulesReloadResult>>
|
|
77
|
+
} | undefined
|
|
78
|
+
if (bridge === undefined) return
|
|
79
|
+
const injected = (): PermissionRulesSectionInjected => ({
|
|
80
|
+
status: async () => {
|
|
81
|
+
const result = await bridge.networkStatus()
|
|
82
|
+
if (!result.ok) throw new Error(`networkStatus failed: ${result.error.code}: ${result.error.message}`)
|
|
83
|
+
return result.value
|
|
84
|
+
},
|
|
85
|
+
rulesRead: async (path) => {
|
|
86
|
+
const result = await bridge.rulesRead(path)
|
|
87
|
+
if (!result.ok) throw new Error(`rulesRead failed: ${result.error.code}: ${result.error.message}`)
|
|
88
|
+
return result.value
|
|
89
|
+
},
|
|
90
|
+
rulesSave: async (path, text) => {
|
|
91
|
+
const result = await bridge.rulesSave(path, text)
|
|
92
|
+
if (!result.ok) throw new Error(`rulesSave failed: ${result.error.code}: ${result.error.message}`)
|
|
93
|
+
return result.value
|
|
94
|
+
},
|
|
95
|
+
reload: async () => {
|
|
96
|
+
const result = await bridge.reload()
|
|
97
|
+
if (!result.ok) throw new Error(`reload failed: ${result.error.code}: ${result.error.message}`)
|
|
98
|
+
return result.value
|
|
99
|
+
},
|
|
100
|
+
t,
|
|
101
|
+
})
|
|
102
|
+
slots.inject('settings.section', () => slots.register({
|
|
103
|
+
name: 'settings.section',
|
|
104
|
+
id: 'permission-rules',
|
|
105
|
+
order: 20,
|
|
106
|
+
label: () => t('nav'),
|
|
107
|
+
locale: NS,
|
|
108
|
+
inject: injected,
|
|
109
|
+
}, PermissionRulesSection))
|
|
110
|
+
})
|
|
111
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Settings-page copy for `dsh-permission-rules`, `en`/`zh` (the two UI
|
|
3
|
+
* language codes the harness locale registry accepts today).
|
|
4
|
+
* @module dsh-permission-rules/client/locales
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export type PermissionRulesLocaleKey =
|
|
8
|
+
| 'nav'
|
|
9
|
+
| 'policyTitle'
|
|
10
|
+
| 'mode'
|
|
11
|
+
| 'preset'
|
|
12
|
+
| 'configured'
|
|
13
|
+
| 'proxy'
|
|
14
|
+
| 'proxyActive'
|
|
15
|
+
| 'proxyInactive'
|
|
16
|
+
| 'proxyDisabled'
|
|
17
|
+
| 'counters'
|
|
18
|
+
| 'denied'
|
|
19
|
+
| 'askBlocked'
|
|
20
|
+
| 'recentTitle'
|
|
21
|
+
| 'noBlocks'
|
|
22
|
+
| 'blockBy'
|
|
23
|
+
| 'blockDefault'
|
|
24
|
+
| 'blockUnattributed'
|
|
25
|
+
| 'editorTitle'
|
|
26
|
+
| 'editorPath'
|
|
27
|
+
| 'editorLoad'
|
|
28
|
+
| 'editorSave'
|
|
29
|
+
| 'editorReload'
|
|
30
|
+
| 'editorEmpty'
|
|
31
|
+
| 'editorSaved'
|
|
32
|
+
| 'editorFailed'
|
|
33
|
+
| 'editorUntitled'
|
|
34
|
+
| 'unknown'
|
|
35
|
+
|
|
36
|
+
export const en: Record<PermissionRulesLocaleKey, string> = {
|
|
37
|
+
nav: 'Permission Rules',
|
|
38
|
+
policyTitle: 'Network policy',
|
|
39
|
+
mode: 'Mode',
|
|
40
|
+
preset: 'Sandbox preset',
|
|
41
|
+
configured: 'Configured',
|
|
42
|
+
proxy: 'Proxy',
|
|
43
|
+
proxyActive: 'active on 127.0.0.1:{port}',
|
|
44
|
+
proxyInactive: 'INACTIVE (bind failed — shell network policy is not enforced)',
|
|
45
|
+
proxyDisabled: 'network policy disabled',
|
|
46
|
+
counters: 'Blocks',
|
|
47
|
+
denied: 'denied',
|
|
48
|
+
askBlocked: 'ask-blocked',
|
|
49
|
+
recentTitle: 'Recent blocks',
|
|
50
|
+
noBlocks: 'No network blocks recorded yet.',
|
|
51
|
+
blockBy: 'rule {index}',
|
|
52
|
+
blockDefault: 'mode default',
|
|
53
|
+
blockUnattributed: 'unattributed',
|
|
54
|
+
editorTitle: 'Rule editor',
|
|
55
|
+
editorPath: 'Rule file',
|
|
56
|
+
editorLoad: 'Load',
|
|
57
|
+
editorSave: 'Save',
|
|
58
|
+
editorReload: 'Reload rules',
|
|
59
|
+
editorEmpty: 'Choose a rule file to edit. The editor only touches rule files the plugin already loads.',
|
|
60
|
+
editorSaved: 'Saved and reloaded ({reloaded} workspace(s)).',
|
|
61
|
+
editorFailed: 'Save rejected: {error}',
|
|
62
|
+
editorUntitled: '(new file)',
|
|
63
|
+
unknown: 'Unknown error',
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const zh: Record<PermissionRulesLocaleKey, string> = {
|
|
67
|
+
nav: '权限规则',
|
|
68
|
+
policyTitle: '网络策略',
|
|
69
|
+
mode: '模式',
|
|
70
|
+
preset: '沙箱预设',
|
|
71
|
+
configured: '显式配置',
|
|
72
|
+
proxy: '代理',
|
|
73
|
+
proxyActive: '运行于 127.0.0.1:{port}',
|
|
74
|
+
proxyInactive: '未激活(绑定失败——shell 网络策略未生效)',
|
|
75
|
+
proxyDisabled: '网络策略已停用',
|
|
76
|
+
counters: '拦截',
|
|
77
|
+
denied: '拒绝',
|
|
78
|
+
askBlocked: '待审批阻断',
|
|
79
|
+
recentTitle: '近期拦截',
|
|
80
|
+
noBlocks: '尚未记录任何网络拦截。',
|
|
81
|
+
blockBy: '规则 {index}',
|
|
82
|
+
blockDefault: '模式默认',
|
|
83
|
+
blockUnattributed: '未归属',
|
|
84
|
+
editorTitle: '规则编辑器',
|
|
85
|
+
editorPath: '规则文件',
|
|
86
|
+
editorLoad: '载入',
|
|
87
|
+
editorSave: '保存',
|
|
88
|
+
editorReload: '重载规则',
|
|
89
|
+
editorEmpty: '选择要编辑的规则文件。编辑器只能读写插件已加载的规则文件。',
|
|
90
|
+
editorSaved: '已保存并重载({reloaded} 个工作区)。',
|
|
91
|
+
editorFailed: '保存被拒绝:{error}',
|
|
92
|
+
editorUntitled: '(新文件)',
|
|
93
|
+
unknown: '未知错误',
|
|
94
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The client-side Remote face of the `permissionRules` namespace: the
|
|
3
|
+
* hand-written `TypertRemoteContribution` mounted through
|
|
4
|
+
* `ctx.remote.$mount`, plus the declaration merging that types
|
|
5
|
+
* `ctx.remote.permissionRules`. The descriptor list is shared with the
|
|
6
|
+
* host `./typert` manifest (`../wire.ts`), so the two faces can never
|
|
7
|
+
* drift.
|
|
8
|
+
* @module dsh-permission-rules/client/remote
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { RemoteResult, TypertRemoteContribution } from '@deepseek-ai/dsh-typert-protocol'
|
|
12
|
+
import { PERMISSION_RULES_INVOCATIONS } from '../wire.ts'
|
|
13
|
+
import type { PermissionRulesSnapshot, RulesReadResult, RulesReloadResult, RulesSaveResult } from '../wire.ts'
|
|
14
|
+
|
|
15
|
+
declare module '@deepseek-ai/dsh-typert-protocol' {
|
|
16
|
+
interface TypertRemoteNamespace$permissionRules {
|
|
17
|
+
/** Read the network-policy snapshot (mode, counters, recent blocks, editable rule sources). */
|
|
18
|
+
networkStatus: () => Promise<RemoteResult<PermissionRulesSnapshot>>
|
|
19
|
+
/** Read one known rule file for the editor. */
|
|
20
|
+
rulesRead: (path: string) => Promise<RemoteResult<RulesReadResult>>
|
|
21
|
+
/** Validate and write one known rule file. */
|
|
22
|
+
rulesSave: (path: string, text: string) => Promise<RemoteResult<RulesSaveResult>>
|
|
23
|
+
/** Re-read every cached workspace chain. */
|
|
24
|
+
reload: () => Promise<RemoteResult<RulesReloadResult>>
|
|
25
|
+
}
|
|
26
|
+
interface TypertRemoteMap {
|
|
27
|
+
'permissionRules/networkStatus': () => Promise<RemoteResult<PermissionRulesSnapshot>>
|
|
28
|
+
'permissionRules/rulesRead': (path: string) => Promise<RemoteResult<RulesReadResult>>
|
|
29
|
+
'permissionRules/rulesSave': (path: string, text: string) => Promise<RemoteResult<RulesSaveResult>>
|
|
30
|
+
'permissionRules/reload': () => Promise<RemoteResult<RulesReloadResult>>
|
|
31
|
+
}
|
|
32
|
+
interface TypertRemoteNamespaceMap {
|
|
33
|
+
permissionRules: TypertRemoteNamespace$permissionRules
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The client Remote contribution for the `permissionRules` namespace. */
|
|
38
|
+
export const PERMISSION_RULES_REMOTE = Object.freeze({
|
|
39
|
+
package: 'dsh-permission-rules',
|
|
40
|
+
descriptors: PERMISSION_RULES_INVOCATIONS,
|
|
41
|
+
} satisfies TypertRemoteContribution)
|