dsh-permission-rules 0.6.20 → 0.6.21
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 +6 -0
- package/lib/index.js +26 -2
- package/lib/types/runtime.d.ts +20 -2
- package/lib/types/runtime.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/runtime.ts +29 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## v0.6.21 - 2026-09-10
|
|
2
|
+
|
|
3
|
+
### Fixed
|
|
4
|
+
|
|
5
|
+
- The session-less host chain no longer survives an explicit reload, so a corrected rule takes effect without restarting the process. `hostLoaded` was cached for the lifetime of the mount, and that chain is deliberately neither a `byCwd` member nor watched, so neither `reloadAll()` nor `saveRuleFile()` ever reached it — and the settings page (which drives `reloadAll()`) is the one surface usable while no session has run a tool call, i.e. exactly the window in which this chain is what judges traffic. `invalidateHostChain()` now drops the cache and re-arms the one-shot warning, and is called from `reloadAll()`, `saveRuleFile()` and `onNetworkConfigChanged()` (the last because `rulesFile` and `fallbackPath` are inputs to the chain, so a config change must not reuse a chain built from the previous one). The new test asserts both the stale read and the refreshed one, and removing the invalidation makes it fail.
|
|
6
|
+
|
|
1
7
|
## v0.6.20 - 2026-09-10
|
|
2
8
|
|
|
3
9
|
### Fixed
|
package/lib/index.js
CHANGED
|
@@ -3114,7 +3114,10 @@ var PermissionRulesRuntime = class {
|
|
|
3114
3114
|
* connection is then judged exactly as before, against the loaded workspace
|
|
3115
3115
|
* chains). It is not watched either: the session-less window is the boot
|
|
3116
3116
|
* window, and the first tool call of any session takes over with the normal
|
|
3117
|
-
* per-workspace chain, which is watched.
|
|
3117
|
+
* per-workspace chain, which is watched. An EXPLICIT reload still drops this
|
|
3118
|
+
* cache ({@link invalidateHostChain}) — `/rules reload`, the settings-page
|
|
3119
|
+
* reload and a settings save all reach it — because during the boot window a
|
|
3120
|
+
* corrected rule otherwise had no effect short of restarting the process.
|
|
3118
3121
|
* @returns the configured chain, or undefined when it cannot be loaded (the mode default then applies).
|
|
3119
3122
|
*/
|
|
3120
3123
|
hostChain() {
|
|
@@ -3132,6 +3135,18 @@ var PermissionRulesRuntime = class {
|
|
|
3132
3135
|
sources: this.hostLoaded.sources
|
|
3133
3136
|
};
|
|
3134
3137
|
}
|
|
3138
|
+
/**
|
|
3139
|
+
* Drop the cached session-less chain so the next proxy decision re-reads it,
|
|
3140
|
+
* and re-arm the one-shot warning so a file that has since become loadable
|
|
3141
|
+
* can report a failure again. Without this the cache was permanent: the
|
|
3142
|
+
* session-less chain is deliberately not a `byCwd` member and is not watched,
|
|
3143
|
+
* so neither `reloadAll()` nor a settings save ever reached it and a
|
|
3144
|
+
* corrected rule needed a process restart (issue #18 follow-up).
|
|
3145
|
+
*/
|
|
3146
|
+
invalidateHostChain() {
|
|
3147
|
+
this.hostLoaded = void 0;
|
|
3148
|
+
this.hostChainWarned = false;
|
|
3149
|
+
}
|
|
3135
3150
|
/** Mark one delegated shell execution as in-flight (newest attribution wins). */
|
|
3136
3151
|
markShell(exec) {
|
|
3137
3152
|
this.inFlight.set(String(exec.callId), {
|
|
@@ -3252,6 +3267,7 @@ var PermissionRulesRuntime = class {
|
|
|
3252
3267
|
*/
|
|
3253
3268
|
async onNetworkConfigChanged() {
|
|
3254
3269
|
if (!this.config.network.enabled) return;
|
|
3270
|
+
this.invalidateHostChain();
|
|
3255
3271
|
await this.networkProxy?.close();
|
|
3256
3272
|
this.envRestore?.();
|
|
3257
3273
|
this.envRestore = void 0;
|
|
@@ -3333,8 +3349,15 @@ var PermissionRulesRuntime = class {
|
|
|
3333
3349
|
sourceOwner(path) {
|
|
3334
3350
|
for (const loaded of this.byCwd.values()) if (loaded.sources.includes(path) || !isAbsolute(this.config.rulesFile) && join(loaded.cwd, this.config.rulesFile) === path) return loaded.cwd;
|
|
3335
3351
|
}
|
|
3336
|
-
/**
|
|
3352
|
+
/**
|
|
3353
|
+
* Re-read every cached workspace chain and drop the session-less host chain
|
|
3354
|
+
* (the settings-page reload action). The host chain matters here because the
|
|
3355
|
+
* settings page is a web-client surface: it can be used while no session has
|
|
3356
|
+
* run a tool call, which is exactly the window in which the host chain is
|
|
3357
|
+
* what judges traffic.
|
|
3358
|
+
*/
|
|
3337
3359
|
reloadAll() {
|
|
3360
|
+
this.invalidateHostChain();
|
|
3338
3361
|
for (const cwd of [...this.byCwd.keys()]) this.reload(cwd);
|
|
3339
3362
|
}
|
|
3340
3363
|
/**
|
|
@@ -3371,6 +3394,7 @@ var PermissionRulesRuntime = class {
|
|
|
3371
3394
|
};
|
|
3372
3395
|
}
|
|
3373
3396
|
let reloaded = 0;
|
|
3397
|
+
this.invalidateHostChain();
|
|
3374
3398
|
for (const cwd of [...this.byCwd.keys()]) {
|
|
3375
3399
|
this.reload(cwd);
|
|
3376
3400
|
reloaded += 1;
|
package/lib/types/runtime.d.ts
CHANGED
|
@@ -260,10 +260,22 @@ export declare class PermissionRulesRuntime {
|
|
|
260
260
|
* connection is then judged exactly as before, against the loaded workspace
|
|
261
261
|
* chains). It is not watched either: the session-less window is the boot
|
|
262
262
|
* window, and the first tool call of any session takes over with the normal
|
|
263
|
-
* per-workspace chain, which is watched.
|
|
263
|
+
* per-workspace chain, which is watched. An EXPLICIT reload still drops this
|
|
264
|
+
* cache ({@link invalidateHostChain}) — `/rules reload`, the settings-page
|
|
265
|
+
* reload and a settings save all reach it — because during the boot window a
|
|
266
|
+
* corrected rule otherwise had no effect short of restarting the process.
|
|
264
267
|
* @returns the configured chain, or undefined when it cannot be loaded (the mode default then applies).
|
|
265
268
|
*/
|
|
266
269
|
private hostChain;
|
|
270
|
+
/**
|
|
271
|
+
* Drop the cached session-less chain so the next proxy decision re-reads it,
|
|
272
|
+
* and re-arm the one-shot warning so a file that has since become loadable
|
|
273
|
+
* can report a failure again. Without this the cache was permanent: the
|
|
274
|
+
* session-less chain is deliberately not a `byCwd` member and is not watched,
|
|
275
|
+
* so neither `reloadAll()` nor a settings save ever reached it and a
|
|
276
|
+
* corrected rule needed a process restart (issue #18 follow-up).
|
|
277
|
+
*/
|
|
278
|
+
private invalidateHostChain;
|
|
267
279
|
/** Mark one delegated shell execution as in-flight (newest attribution wins). */
|
|
268
280
|
private markShell;
|
|
269
281
|
/** Drop one shell execution when it settles. */
|
|
@@ -324,7 +336,13 @@ export declare class PermissionRulesRuntime {
|
|
|
324
336
|
};
|
|
325
337
|
/** The workspace a rule source belongs to (for the editor's file list), or undefined for the fallback. */
|
|
326
338
|
sourceOwner(path: string): string | undefined;
|
|
327
|
-
/**
|
|
339
|
+
/**
|
|
340
|
+
* Re-read every cached workspace chain and drop the session-less host chain
|
|
341
|
+
* (the settings-page reload action). The host chain matters here because the
|
|
342
|
+
* settings page is a web-client surface: it can be used while no session has
|
|
343
|
+
* run a tool call, which is exactly the window in which the host chain is
|
|
344
|
+
* what judges traffic.
|
|
345
|
+
*/
|
|
328
346
|
reloadAll(): void;
|
|
329
347
|
/**
|
|
330
348
|
* Validate and write one known rule file. The document must parse and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAOH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACjF,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAG5E,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAGzD,OAAO,KAAK,EAAgC,eAAe,EAA+B,OAAO,EAAE,MAAM,YAAY,CAAA;AAIrH,OAAO,KAAK,EAAiC,WAAW,EAAE,MAAM,cAAc,CAAA;AAQ9E,OAAO,KAAK,EAAE,kBAAkB,EAAoB,MAAM,YAAY,CAAA;AAItE,OAAO,KAAK,EA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EAAsE;IACtE,kBAAkB,IAAI,MAAM;IAI5B;;;;;OAKG;IACH,OAAO,CAAC,cAAc;CAevB;AAED;;;;;GAKG;AACH,wBAAsB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA4BvE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAK9D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-permission-rules",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.21",
|
|
4
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
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
package/src/runtime.ts
CHANGED
|
@@ -604,7 +604,10 @@ export class PermissionRulesRuntime {
|
|
|
604
604
|
* connection is then judged exactly as before, against the loaded workspace
|
|
605
605
|
* chains). It is not watched either: the session-less window is the boot
|
|
606
606
|
* window, and the first tool call of any session takes over with the normal
|
|
607
|
-
* per-workspace chain, which is watched.
|
|
607
|
+
* per-workspace chain, which is watched. An EXPLICIT reload still drops this
|
|
608
|
+
* cache ({@link invalidateHostChain}) — `/rules reload`, the settings-page
|
|
609
|
+
* reload and a settings save all reach it — because during the boot window a
|
|
610
|
+
* corrected rule otherwise had no effect short of restarting the process.
|
|
608
611
|
* @returns the configured chain, or undefined when it cannot be loaded (the mode default then applies).
|
|
609
612
|
*/
|
|
610
613
|
private hostChain(): NetworkChain | undefined {
|
|
@@ -624,6 +627,19 @@ export class PermissionRulesRuntime {
|
|
|
624
627
|
return { ruleset: this.hostLoaded.compiled, sources: this.hostLoaded.sources }
|
|
625
628
|
}
|
|
626
629
|
|
|
630
|
+
/**
|
|
631
|
+
* Drop the cached session-less chain so the next proxy decision re-reads it,
|
|
632
|
+
* and re-arm the one-shot warning so a file that has since become loadable
|
|
633
|
+
* can report a failure again. Without this the cache was permanent: the
|
|
634
|
+
* session-less chain is deliberately not a `byCwd` member and is not watched,
|
|
635
|
+
* so neither `reloadAll()` nor a settings save ever reached it and a
|
|
636
|
+
* corrected rule needed a process restart (issue #18 follow-up).
|
|
637
|
+
*/
|
|
638
|
+
private invalidateHostChain(): void {
|
|
639
|
+
this.hostLoaded = undefined
|
|
640
|
+
this.hostChainWarned = false
|
|
641
|
+
}
|
|
642
|
+
|
|
627
643
|
/** Mark one delegated shell execution as in-flight (newest attribution wins). */
|
|
628
644
|
private markShell(exec: ToolExecution): void {
|
|
629
645
|
this.inFlight.set(String(exec.callId), { tool: exec.name, callId: exec.callId, startedAt: Date.now(), agent: exec.agent })
|
|
@@ -744,6 +760,9 @@ export class PermissionRulesRuntime {
|
|
|
744
760
|
*/
|
|
745
761
|
async onNetworkConfigChanged(): Promise<void> {
|
|
746
762
|
if (!this.config.network.enabled) return
|
|
763
|
+
// The chain inputs (rulesFile, fallbackPath, …) may have changed with the
|
|
764
|
+
// config, so the session-less chain must be re-read rather than reused.
|
|
765
|
+
this.invalidateHostChain()
|
|
747
766
|
await this.networkProxy?.close()
|
|
748
767
|
this.envRestore?.()
|
|
749
768
|
this.envRestore = undefined
|
|
@@ -824,8 +843,15 @@ export class PermissionRulesRuntime {
|
|
|
824
843
|
return undefined
|
|
825
844
|
}
|
|
826
845
|
|
|
827
|
-
/**
|
|
846
|
+
/**
|
|
847
|
+
* Re-read every cached workspace chain and drop the session-less host chain
|
|
848
|
+
* (the settings-page reload action). The host chain matters here because the
|
|
849
|
+
* settings page is a web-client surface: it can be used while no session has
|
|
850
|
+
* run a tool call, which is exactly the window in which the host chain is
|
|
851
|
+
* what judges traffic.
|
|
852
|
+
*/
|
|
828
853
|
reloadAll(): void {
|
|
854
|
+
this.invalidateHostChain()
|
|
829
855
|
for (const cwd of [...this.byCwd.keys()]) this.reload(cwd)
|
|
830
856
|
}
|
|
831
857
|
|
|
@@ -860,6 +886,7 @@ export class PermissionRulesRuntime {
|
|
|
860
886
|
return { ok: false, error: error instanceof Error ? error.message : String(error) }
|
|
861
887
|
}
|
|
862
888
|
let reloaded = 0
|
|
889
|
+
this.invalidateHostChain()
|
|
863
890
|
for (const cwd of [...this.byCwd.keys()]) {
|
|
864
891
|
this.reload(cwd)
|
|
865
892
|
reloaded += 1
|