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.
Files changed (76) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.es.md +160 -117
  3. package/README.hi.md +162 -119
  4. package/README.md +133 -90
  5. package/README.pt.md +161 -118
  6. package/README.zh.md +162 -119
  7. package/docs/rule-test-vectors/README.md +28 -0
  8. package/docs/rule-test-vectors/corpus.json +109 -0
  9. package/lib/client.js +4693 -0
  10. package/lib/client.js.map +1 -0
  11. package/lib/index.js +1530 -179
  12. package/lib/typert.host.js +4305 -0
  13. package/lib/types/client/index.d.ts +28 -0
  14. package/lib/types/client/index.d.ts.map +1 -0
  15. package/lib/types/client/locales.d.ts +9 -0
  16. package/lib/types/client/locales.d.ts.map +1 -0
  17. package/lib/types/client/remote.d.ts +181 -0
  18. package/lib/types/client/remote.d.ts.map +1 -0
  19. package/lib/types/client/section.d.ts +35 -0
  20. package/lib/types/client/section.d.ts.map +1 -0
  21. package/lib/types/config.d.ts +54 -2
  22. package/lib/types/config.d.ts.map +1 -1
  23. package/lib/types/events.d.ts +45 -0
  24. package/lib/types/events.d.ts.map +1 -1
  25. package/lib/types/index.d.ts +8 -6
  26. package/lib/types/index.d.ts.map +1 -1
  27. package/lib/types/network.d.ts +90 -0
  28. package/lib/types/network.d.ts.map +1 -0
  29. package/lib/types/prose.d.ts +15 -0
  30. package/lib/types/prose.d.ts.map +1 -1
  31. package/lib/types/proxy.d.ts +128 -0
  32. package/lib/types/proxy.d.ts.map +1 -0
  33. package/lib/types/remote-service.d.ts +45 -0
  34. package/lib/types/remote-service.d.ts.map +1 -0
  35. package/lib/types/rules.d.ts +131 -0
  36. package/lib/types/rules.d.ts.map +1 -1
  37. package/lib/types/runtime.d.ts +153 -21
  38. package/lib/types/runtime.d.ts.map +1 -1
  39. package/lib/types/settings.d.ts +28 -0
  40. package/lib/types/settings.d.ts.map +1 -0
  41. package/lib/types/typert.host.d.ts +166 -0
  42. package/lib/types/typert.host.d.ts.map +1 -0
  43. package/lib/types/wire.d.ts +421 -0
  44. package/lib/types/wire.d.ts.map +1 -0
  45. package/package.json +182 -144
  46. package/scripts/repair-session-logs.mjs +7 -2
  47. package/src/client/index.ts +111 -0
  48. package/src/client/locales.ts +94 -0
  49. package/src/client/remote.ts +41 -0
  50. package/src/client/section.ts +201 -0
  51. package/src/config.ts +111 -0
  52. package/src/events.ts +46 -0
  53. package/src/index.ts +2 -0
  54. package/src/network.ts +177 -0
  55. package/src/prose.ts +85 -10
  56. package/src/proxy.ts +327 -0
  57. package/src/remote-service.ts +109 -0
  58. package/src/rules.ts +424 -5
  59. package/src/runtime.ts +464 -53
  60. package/src/settings.ts +74 -0
  61. package/src/typert.host.ts +25 -0
  62. package/src/wire.ts +239 -0
  63. package/lib/types/config.js +0 -99
  64. package/lib/types/config.js.map +0 -1
  65. package/lib/types/events.js +0 -44
  66. package/lib/types/events.js.map +0 -1
  67. package/lib/types/glob.js +0 -307
  68. package/lib/types/glob.js.map +0 -1
  69. package/lib/types/index.js +0 -27
  70. package/lib/types/index.js.map +0 -1
  71. package/lib/types/prose.js +0 -173
  72. package/lib/types/prose.js.map +0 -1
  73. package/lib/types/rules.js +0 -610
  74. package/lib/types/rules.js.map +0 -1
  75. package/lib/types/runtime.js +0 -818
  76. 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.2",
4
- "description": "Declarative Claude Code-style permission rules for DeepSeek Harness: ordered allow/deny/ask rules with tool-name, argument (glob/regex), and workspace-path matching on the tools/pre-execute waterfall, full session-log audit, and HMR rule reload.",
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
- "./package.json": "./package.json"
15
- },
16
- "files": [
17
- "lib",
18
- "src",
19
- "cordis.patch.yml",
20
- "docs",
21
- "scripts/repair-session-logs.mjs",
22
- "README.md",
23
- "README.zh.md",
24
- "README.es.md",
25
- "README.pt.md",
26
- "README.hi.md",
27
- "CHANGELOG.md",
28
- "LICENSE"
29
- ],
30
- "sideEffects": false,
31
- "dsh": {
32
- "bundle": {
33
- "patch": "./cordis.patch.yml"
34
- }
35
- },
36
- "dshWorkshop": {
37
- "schema": "omdsh-workshop-package/v1",
38
- "type": "plugin",
39
- "integration": {
40
- "protocol": "harness-profile",
41
- "artifact": "cordis.patch.yml"
42
- },
43
- "install": {
44
- "mode": "transactional",
45
- "adapter": "profile-bundle",
46
- "failurePolicy": "generation-rollback",
47
- "touchesCurrentBeforeActivation": false
48
- },
49
- "lifecycle": {
50
- "activation": "restart-profile",
51
- "dispose": "supported"
52
- },
53
- "permissions": [
54
- "files:read",
55
- "files:watch",
56
- "session:append",
57
- "network:none"
58
- ],
59
- "compatibility": {
60
- "dshVersions": [
61
- "0.1.0-rc.6"
62
- ]
63
- },
64
- "capability": {
65
- "id": "rules",
66
- "kind": "command",
67
- "invocation": "/rules",
68
- "expected": "lists the active permission rules with their source files"
69
- },
70
- "evidence": {
71
- "install": null,
72
- "failureIsolation": null,
73
- "hotReload": null,
74
- "remove": null
75
- }
76
- },
77
- "keywords": [
78
- "dsh",
79
- "dsh-plugin",
80
- "deepseek-harness",
81
- "permission",
82
- "policy",
83
- "allow-deny-ask",
84
- "approval",
85
- "safety"
86
- ],
87
- "author": "dsh-permission-rules contributors",
88
- "repository": {
89
- "type": "git",
90
- "url": "git+https://github.com/PerryLink/dsh-permission-rules.git"
91
- },
92
- "homepage": "https://github.com/PerryLink/dsh-permission-rules#readme",
93
- "bugs": {
94
- "url": "https://github.com/PerryLink/dsh-permission-rules/issues"
95
- },
96
- "engines": {
97
- "node": "^22.19.0 || >=24.0.0"
98
- },
99
- "peerDependencies": {
100
- "@deepseek-ai/cordis": "^4.0.1",
101
- "@deepseek-ai/dsh-agent": "0.1.0-rc.6",
102
- "@deepseek-ai/dsh-commands": "0.1.0-rc.6",
103
- "@deepseek-ai/dsh-llm": "0.1.0-rc.6",
104
- "@deepseek-ai/dsh-session": "0.1.0-rc.6",
105
- "@deepseek-ai/dsh-tools": "0.1.0-rc.6",
106
- "@deepseek-ai/schemastery": "^3.18.0"
107
- },
108
- "dependencies": {
109
- "chokidar": "^5.0.0",
110
- "tsdown": "^0.22.14",
111
- "typescript": "^5.9.0",
112
- "yaml": "^2.8.0"
113
- },
114
- "devDependencies": {
115
- "@deepseek-ai/cordis": "^4.0.1",
116
- "@deepseek-ai/dsh-agent": "0.1.0-rc.6",
117
- "@deepseek-ai/dsh-commands": "0.1.0-rc.6",
118
- "@deepseek-ai/dsh-llm": "0.1.0-rc.6",
119
- "@deepseek-ai/dsh-session": "0.1.0-rc.6",
120
- "@deepseek-ai/dsh-subagent": "0.1.0-rc.6",
121
- "@deepseek-ai/dsh-tools": "0.1.0-rc.6",
122
- "@deepseek-ai/dsh-user-approval": "0.1.0-rc.6",
123
- "@deepseek-ai/schemastery": "^3.18.0",
124
- "@eslint/js": "^10.0.1",
125
- "@types/node": "^22.19.0",
126
- "@vitest/coverage-v8": "^3.2.0",
127
- "dsh-auto-review": "file:vendor/dsh-auto-review-0.4.0.tgz",
128
- "eslint": "^10.8.1",
129
- "globals": "^17.11.0",
130
- "typescript-eslint": "^8.67.0",
131
- "vitest": "^3.2.0"
132
- },
133
- "scripts": {
134
- "build": "node scripts/prepare.mjs",
135
- "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json --noEmit",
136
- "lint": "eslint src test scripts",
137
- "test": "vitest run",
138
- "test:coverage": "vitest run --coverage",
139
- "pack:check": "node scripts/prepare.mjs && pnpm pack",
140
- "prepare": "node scripts/prepare.mjs"
141
- },
142
- "packageManager": "pnpm@11.7.0",
143
- "license": "Apache-2.0"
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; only types you understand
28
- * to be reconstruction-safe may be added via `--types`.
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)