dsh-permission-rules 0.6.0 → 0.6.3
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 +42 -0
- package/README.es.md +35 -17
- package/README.hi.md +35 -17
- package/README.md +35 -17
- package/README.pt.md +35 -17
- package/README.zh.md +35 -17
- package/lib/index.js +38 -24
- package/lib/types/call-id.d.ts +10 -0
- package/lib/types/call-id.d.ts.map +1 -0
- package/lib/types/events.d.ts +1 -1
- package/lib/types/events.d.ts.map +1 -1
- package/lib/types/proxy.d.ts +1 -1
- package/lib/types/proxy.d.ts.map +1 -1
- package/lib/types/runtime.d.ts +28 -15
- package/lib/types/runtime.d.ts.map +1 -1
- package/package.json +29 -5
- package/scripts/repair-session-logs.mjs +38 -19
- package/src/call-id.ts +11 -0
- package/src/events.ts +1 -1
- package/src/prose.ts +5 -5
- package/src/proxy.ts +1 -1
- package/src/runtime.ts +34 -20
package/lib/index.js
CHANGED
|
@@ -1747,7 +1747,7 @@ const EN = {
|
|
|
1747
1747
|
usage: "Usage: /rules [list | reload | network | decisions [n] | test <tool> <json-args>]",
|
|
1748
1748
|
decisionsHeader: (shown, total) => `Last ${shown} of ${total} permission decision(s) for this session:`,
|
|
1749
1749
|
noDecisions: "No permission decisions recorded in this session yet.",
|
|
1750
|
-
auditDisabledNotice: "Session-log audit is disabled on this host:
|
|
1750
|
+
auditDisabledNotice: "Session-log audit is disabled on this host: it cannot safely persist ignorable-marked audit events, which would make sessions unresumable elsewhere (set allowUnmarkedAudit: true to opt back in).",
|
|
1751
1751
|
invalidDecisionsCount: (arg) => `Invalid decisions count "${arg}": give a positive integer (default 10).`,
|
|
1752
1752
|
decisionLine: (seq, action, toolName, ruleIndex, reason, dryRun, outcome) => {
|
|
1753
1753
|
return `- #${seq} ${action} ${toolName}${ruleIndex === void 0 ? "" : ` (rule ${ruleIndex + 1})`}${dryRun ? outcome === void 0 ? " (dry-run)" : ` (dry-run → ${outcome})` : ""}${reason === void 0 ? "" : `: ${short(reason)}`}`;
|
|
@@ -1781,7 +1781,7 @@ const ZH = {
|
|
|
1781
1781
|
usage: "用法:/rules [list | reload | network | decisions [n] | test <工具名> <json-参数>]",
|
|
1782
1782
|
decisionsHeader: (shown, total) => `本会话最近 ${shown}/${total} 条权限裁决:`,
|
|
1783
1783
|
noDecisions: "本会话还没有记录任何权限裁决。",
|
|
1784
|
-
auditDisabledNotice: "
|
|
1784
|
+
auditDisabledNotice: "本宿主上会话日志审计已停用:其无法安全持久化 ignorable 标记的审计事件,会令会话在其他宿主上无法恢复(设 allowUnmarkedAudit: true 可重新开启)。",
|
|
1785
1785
|
invalidDecisionsCount: (arg) => `无效的裁决条数 "${arg}":请给正整数(默认 10)。`,
|
|
1786
1786
|
decisionLine: (seq, action, toolName, ruleIndex, reason, dryRun, outcome) => {
|
|
1787
1787
|
return `- #${seq} ${action} ${toolName}${ruleIndex === void 0 ? "" : `(规则 ${ruleIndex + 1})`}${dryRun ? outcome === void 0 ? "(干跑)" : `(干跑 → ${outcome})` : ""}${reason === void 0 ? "" : `:${short(reason)}`}`;
|
|
@@ -1815,7 +1815,7 @@ const ES = {
|
|
|
1815
1815
|
usage: "Uso: /rules [list | reload | network | decisions [n] | test <herramienta> <json-args>]",
|
|
1816
1816
|
decisionsHeader: (shown, total) => `Últimas ${shown} de ${total} decisión(es) de permiso de esta sesión:`,
|
|
1817
1817
|
noDecisions: "Esta sesión aún no registra decisiones de permiso.",
|
|
1818
|
-
auditDisabledNotice: "La auditoría del registro de sesión está desactivada en este host:
|
|
1818
|
+
auditDisabledNotice: "La auditoría del registro de sesión está desactivada en este host: no puede persistir de forma segura eventos de auditoría marcados como ignorable, lo que haría las sesiones irrecuperables en otros hosts (establece allowUnmarkedAudit: true para reactivarla).",
|
|
1819
1819
|
invalidDecisionsCount: (arg) => `Cantidad de decisiones inválida "${arg}": indique un entero positivo (por defecto 10).`,
|
|
1820
1820
|
decisionLine: (seq, action, toolName, ruleIndex, reason, dryRun, outcome) => {
|
|
1821
1821
|
return `- #${seq} ${action} ${toolName}${ruleIndex === void 0 ? "" : ` (regla ${ruleIndex + 1})`}${dryRun ? outcome === void 0 ? " (simulación)" : ` (simulación → ${outcome})` : ""}${reason === void 0 ? "" : `: ${short(reason)}`}`;
|
|
@@ -1849,7 +1849,7 @@ const PT = {
|
|
|
1849
1849
|
usage: "Uso: /rules [list | reload | network | decisions [n] | test <ferramenta> <json-args>]",
|
|
1850
1850
|
decisionsHeader: (shown, total) => `Últimas ${shown} de ${total} decisão(ões) de permissão desta sessão:`,
|
|
1851
1851
|
noDecisions: "Esta sessão ainda não registrou decisões de permissão.",
|
|
1852
|
-
auditDisabledNotice: "A auditoria do registro da sessão está desativada neste host:
|
|
1852
|
+
auditDisabledNotice: "A auditoria do registro da sessão está desativada neste host: ele não consegue persistir com segurança eventos de auditoria marcados como ignorable, o que tornaria as sessões irrecuperáveis em outros hosts (defina allowUnmarkedAudit: true para reativar).",
|
|
1853
1853
|
invalidDecisionsCount: (arg) => `Quantidade de decisões inválida "${arg}": informe um inteiro positivo (padrão 10).`,
|
|
1854
1854
|
decisionLine: (seq, action, toolName, ruleIndex, reason, dryRun, outcome) => {
|
|
1855
1855
|
return `- #${seq} ${action} ${toolName}${ruleIndex === void 0 ? "" : ` (regra ${ruleIndex + 1})`}${dryRun ? outcome === void 0 ? " (simulação)" : ` (simulação → ${outcome})` : ""}${reason === void 0 ? "" : `: ${short(reason)}`}`;
|
|
@@ -1883,7 +1883,7 @@ const HI = {
|
|
|
1883
1883
|
usage: "उपयोग: /rules [list | reload | network | decisions [n] | test <टूल> <json-args>]",
|
|
1884
1884
|
decisionsHeader: (shown, total) => `इस सत्र के अंतिम ${shown}/${total} अनुमति निर्णय:`,
|
|
1885
1885
|
noDecisions: "इस सत्र में अभी कोई अनुमति निर्णय दर्ज नहीं है।",
|
|
1886
|
-
auditDisabledNotice: "इस होस्ट पर सत्र-लॉग ऑडिट अक्षम है:
|
|
1886
|
+
auditDisabledNotice: "इस होस्ट पर सत्र-लॉग ऑडिट अक्षम है: यह ignorable-चिह्नित ऑडिट इवेंट को सुरक्षित रूप से सहेज नहीं सकता, जिससे सत्र अन्य होस्ट पर अप्राप्य हो जाते (पुनः चालू करने के लिए allowUnmarkedAudit: true सेट करें)।",
|
|
1887
1887
|
invalidDecisionsCount: (arg) => `अमान्य निर्णय-संख्या "${arg}": एक धनात्मक पूर्णांक दें (डिफ़ॉल्ट 10)।`,
|
|
1888
1888
|
decisionLine: (seq, action, toolName, ruleIndex, reason, dryRun, outcome) => {
|
|
1889
1889
|
return `- #${seq} ${action} ${toolName}${ruleIndex === void 0 ? "" : ` (नियम ${ruleIndex + 1})`}${dryRun ? outcome === void 0 ? " (ड्राई-रन)" : ` (ड्राई-रन → ${outcome})` : ""}${reason === void 0 ? "" : `: ${short(reason)}`}`;
|
|
@@ -2789,8 +2789,11 @@ var PermissionRulesRuntime = class {
|
|
|
2789
2789
|
* runtime therefore detects such hosts BEFORE the first append (peer
|
|
2790
2790
|
* version) and re-checks after the first append (returned envelope), then
|
|
2791
2791
|
* degrades: session-log audit is disabled with a one-time warning unless
|
|
2792
|
-
* `allowUnmarkedAudit: true` opts back in. `
|
|
2793
|
-
*
|
|
2792
|
+
* `allowUnmarkedAudit: true` opts back in. The `0.1.2-alpha` line refuses
|
|
2793
|
+
* plugin event types on read even when marked, so its version gate
|
|
2794
|
+
* disables audit the same way (see `isUnmarkedHostVersion`). `source`
|
|
2795
|
+
* names the matched rule's file, or the nearest effective file on a
|
|
2796
|
+
* passthrough; `cwd`
|
|
2794
2797
|
* names the workspace the rules were resolved for; `dryRun` marks
|
|
2795
2798
|
* would-be deny/ask hits under `enforce: false`; `modeDefault` records a
|
|
2796
2799
|
* network mode-default decision on a web tool (no rule fired).
|
|
@@ -3161,7 +3164,7 @@ var PermissionRulesRuntime = class {
|
|
|
3161
3164
|
}
|
|
3162
3165
|
/** One-time warning that session-log audit was disabled to keep session logs loadable. */
|
|
3163
3166
|
warnUnmarkedAuditHost() {
|
|
3164
|
-
this.ctx.logger.warn("permission-rules: this host
|
|
3167
|
+
this.ctx.logger.warn("permission-rules: this host cannot safely persist ignorable-marked audit events (its Session.append predates the marker, or its read path refuses plugin events), which would make sessions unresumable on stricter harness builds — session-log audit is disabled; set allowUnmarkedAudit: true to opt back in, and repair existing logs with scripts/repair-session-logs.mjs (see https://github.com/PerryLink/dsh-permission-rules/issues/2)");
|
|
3165
3168
|
}
|
|
3166
3169
|
/**
|
|
3167
3170
|
* Execute the `/rules` command: bare `/rules` lists the active rules and
|
|
@@ -3654,25 +3657,36 @@ async function apply(ctx, config) {
|
|
|
3654
3657
|
});
|
|
3655
3658
|
}
|
|
3656
3659
|
/**
|
|
3657
|
-
* Whether a `@deepseek-ai/dsh-session` version line
|
|
3658
|
-
*
|
|
3659
|
-
*
|
|
3660
|
-
*
|
|
3661
|
-
*
|
|
3662
|
-
*
|
|
3663
|
-
*
|
|
3664
|
-
*
|
|
3665
|
-
*
|
|
3666
|
-
*
|
|
3667
|
-
*
|
|
3668
|
-
*
|
|
3660
|
+
* Whether a `@deepseek-ai/dsh-session` version line cannot safely persist
|
|
3661
|
+
* plugin audit events, either because it predates the `ignorable`
|
|
3662
|
+
* envelope-marker surface or because its read path refuses out-of-vocabulary
|
|
3663
|
+
* event types even when marked:
|
|
3664
|
+
* - The released `0.1.0-rc.1`–`0.1.0-rc.7` lines silently drop the marker
|
|
3665
|
+
* from `Session.append` options, so audit events written by those builds
|
|
3666
|
+
* land unmarked and break resume on stricter hosts. `0.1.0-rc.8` and
|
|
3667
|
+
* later stamp the marker. The `0.1.1-rc` line regressed the same way
|
|
3668
|
+
* (verified on `0.1.1-rc.2` — the stamping fix exists only on harness
|
|
3669
|
+
* master), so `0.1.1-rc.1`–`0.1.1-rc.7` are treated as unmarked too.
|
|
3670
|
+
* - The `0.1.2-alpha` line refuses to interpret logs containing plugin
|
|
3671
|
+
* event types even when the envelope carries `ignorable: true` (verified
|
|
3672
|
+
* on `0.1.2-alpha-1`, reported by @rgw87 in issue #15), so audit events
|
|
3673
|
+
* written there make the session unresumable on that host itself. The
|
|
3674
|
+
* whole alpha line is treated as unsafe; over-refusal is harmless because
|
|
3675
|
+
* `allowUnmarkedAudit: true` opts back in, and
|
|
3676
|
+
* `scripts/repair-session-logs.mjs strip` removes already-written audit
|
|
3677
|
+
* rows for hosts where the marker cannot help. Extend the bound if a
|
|
3678
|
+
* future alpha/rc line regresses. Non-matching (later rc, stable, or
|
|
3679
|
+
* unresolvable) versions are treated as possibly-marker-aware and
|
|
3680
|
+
* verified by the append probe.
|
|
3669
3681
|
* @param version - the installed peer version string.
|
|
3670
|
-
* @returns true for the known-
|
|
3682
|
+
* @returns true for the known-unsafe rc.1–rc.7 lines of `0.1.0` and
|
|
3683
|
+
* `0.1.1`, and the `0.1.2-alpha` line.
|
|
3671
3684
|
*/
|
|
3672
3685
|
function isUnmarkedHostVersion(version) {
|
|
3673
|
-
const
|
|
3674
|
-
|
|
3675
|
-
return Number(
|
|
3686
|
+
const v = version.trim();
|
|
3687
|
+
const rc = /^0\.1\.[01]-rc\.(\d+)$/.exec(v);
|
|
3688
|
+
if (rc !== null) return Number(rc[1]) <= 7;
|
|
3689
|
+
return /^0\.1\.2-alpha[.-]\d+$/.test(v);
|
|
3676
3690
|
}
|
|
3677
3691
|
/**
|
|
3678
3692
|
* Identity candidates for the `agents` match dimension, derived from the
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dual-ruler call-id brand: host master renamed the dsh-llm `CallId`
|
|
3
|
+
* brand to `ToolCallId`, while the published 0.1.1-rc.2 line still
|
|
4
|
+
* exports `CallId`. Derive the brand from the dsh-tools execution
|
|
5
|
+
* contract so both rulers typecheck without naming either brand name.
|
|
6
|
+
* @module dsh-permission-rules/call-id
|
|
7
|
+
*/
|
|
8
|
+
import type { ToolExecution } from '@deepseek-ai/dsh-tools';
|
|
9
|
+
export type CallId = ToolExecution['callId'];
|
|
10
|
+
//# sourceMappingURL=call-id.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call-id.d.ts","sourceRoot":"","sources":["../../src/call-id.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAE3D,MAAM,MAAM,MAAM,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAA"}
|
package/lib/types/events.d.ts
CHANGED
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
* and `scripts/repair-session-logs.mjs` repairs already-polluted logs.
|
|
30
30
|
* @module dsh-permission-rules/events
|
|
31
31
|
*/
|
|
32
|
-
import type { CallId } from '@deepseek-ai/dsh-llm';
|
|
33
32
|
import type { PreToolDecision } from '@deepseek-ai/dsh-tools';
|
|
33
|
+
import type { CallId } from './call-id.js';
|
|
34
34
|
declare module '@deepseek-ai/dsh-session/types' {
|
|
35
35
|
interface SessionEventMap {
|
|
36
36
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1C,OAAO,QAAQ,gCAAgC,CAAC;IAC9C,UAAU,eAAe;QACvB;;;;;;;;;;WAUG;QACH,0BAA0B,EAAE;YAC1B,QAAQ,EAAE,MAAM,CAAA;YAChB,MAAM,CAAC,EAAE,MAAM,CAAA;YACf,MAAM,EAAE,MAAM,CAAA;YACd,MAAM,EAA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,yDAAyD;IACzD,GAAG,EAAE,MAAM,CAAA;IACX,iFAAiF;IACjF,MAAM,CAAC,EAAE,IAAI,CAAA;CACd;AAED,iEAAiE;AACjE,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,OAAO,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,OAAO,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACzB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,GAAG,KAAK,CAAA;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,WAAW,GAAG,CACxB,IAAI,EAAE,0BAA0B,EAChC,IAAI,EAAE,aAAa,EACnB,OAAO,CAAC,EAAE;IAAE,SAAS,CAAC,EAAE,IAAI,CAAA;CAAE,KAC3B,OAAO,CAAA;AAEZ;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAE3D"}
|
package/lib/types/proxy.d.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* (web tools get the real approval seam at `tools/pre-execute`).
|
|
15
15
|
* @module dsh-permission-rules/proxy
|
|
16
16
|
*/
|
|
17
|
-
import type { CallId } from '
|
|
17
|
+
import type { CallId } from './call-id.js';
|
|
18
18
|
import type { NetworkDecision, NetworkMode } from './network.js';
|
|
19
19
|
import type { NetworkTarget, SchemeName } from './rules.js';
|
|
20
20
|
/** Proxy environment variable names the injector sets/restores (uppercase + lowercase for mixed-ecosystem CLIs). */
|
package/lib/types/proxy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AASH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AASH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAGhE,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE3D,oHAAoH;AACpH,eAAO,MAAM,eAAe,EAAE,SAAS,MAAM,EAAyF,CAAA;AAEtI,6DAA6D;AAC7D,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAA6B,CAAA;AAE7E,oFAAoF;AACpF,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAA;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,CAAA;IAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,CAAA;IAC/B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAA;IAC1B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAA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AO,CAAC,QAAQ,CAAC,OAAO;IANpC,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoB;IAC5C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2B;IAClD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA6C;IACnE,OAAO,CAAC,UAAU,CAAI;gBAEO,OAAO,EAAE,mBAAmB;IAEzD,2DAA2D;IAC3D,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,+EAA+E;IAC/E,YAAY,IAAI,SAAS,kBAAkB,EAAE;IAI7C,iCAAiC;IACjC,UAAU,IAAI,YAAY;IAI1B,kDAAkD;IAClD,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;IA4BxB,kFAAkF;IAClF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAWtB,oHAAoH;YACtG,aAAa;IA0B3B,uGAAuG;YACzF,aAAa;IAgC3B,sGAAsG;YACxF,cAAc;IAY5B,yFAAyF;YAC3E,oBAAoB;IAalC,4FAA4F;IAC5F,OAAO,CAAC,WAAW;CA4BpB;AAYD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,UAAU,GAAG,MAAM,IAAI,CAyBtF"}
|
package/lib/types/runtime.d.ts
CHANGED
|
@@ -174,8 +174,11 @@ export declare class PermissionRulesRuntime {
|
|
|
174
174
|
* runtime therefore detects such hosts BEFORE the first append (peer
|
|
175
175
|
* version) and re-checks after the first append (returned envelope), then
|
|
176
176
|
* degrades: session-log audit is disabled with a one-time warning unless
|
|
177
|
-
* `allowUnmarkedAudit: true` opts back in. `
|
|
178
|
-
*
|
|
177
|
+
* `allowUnmarkedAudit: true` opts back in. The `0.1.2-alpha` line refuses
|
|
178
|
+
* plugin event types on read even when marked, so its version gate
|
|
179
|
+
* disables audit the same way (see `isUnmarkedHostVersion`). `source`
|
|
180
|
+
* names the matched rule's file, or the nearest effective file on a
|
|
181
|
+
* passthrough; `cwd`
|
|
179
182
|
* names the workspace the rules were resolved for; `dryRun` marks
|
|
180
183
|
* would-be deny/ask hits under `enforce: false`; `modeDefault` records a
|
|
181
184
|
* network mode-default decision on a web tool (no rule fired).
|
|
@@ -405,20 +408,30 @@ export declare class PermissionRulesRuntime {
|
|
|
405
408
|
*/
|
|
406
409
|
export declare function apply(ctx: Context, config: Config): Promise<void>;
|
|
407
410
|
/**
|
|
408
|
-
* Whether a `@deepseek-ai/dsh-session` version line
|
|
409
|
-
*
|
|
410
|
-
*
|
|
411
|
-
*
|
|
412
|
-
*
|
|
413
|
-
*
|
|
414
|
-
*
|
|
415
|
-
*
|
|
416
|
-
*
|
|
417
|
-
*
|
|
418
|
-
*
|
|
419
|
-
*
|
|
411
|
+
* Whether a `@deepseek-ai/dsh-session` version line cannot safely persist
|
|
412
|
+
* plugin audit events, either because it predates the `ignorable`
|
|
413
|
+
* envelope-marker surface or because its read path refuses out-of-vocabulary
|
|
414
|
+
* event types even when marked:
|
|
415
|
+
* - The released `0.1.0-rc.1`–`0.1.0-rc.7` lines silently drop the marker
|
|
416
|
+
* from `Session.append` options, so audit events written by those builds
|
|
417
|
+
* land unmarked and break resume on stricter hosts. `0.1.0-rc.8` and
|
|
418
|
+
* later stamp the marker. The `0.1.1-rc` line regressed the same way
|
|
419
|
+
* (verified on `0.1.1-rc.2` — the stamping fix exists only on harness
|
|
420
|
+
* master), so `0.1.1-rc.1`–`0.1.1-rc.7` are treated as unmarked too.
|
|
421
|
+
* - The `0.1.2-alpha` line refuses to interpret logs containing plugin
|
|
422
|
+
* event types even when the envelope carries `ignorable: true` (verified
|
|
423
|
+
* on `0.1.2-alpha-1`, reported by @rgw87 in issue #15), so audit events
|
|
424
|
+
* written there make the session unresumable on that host itself. The
|
|
425
|
+
* whole alpha line is treated as unsafe; over-refusal is harmless because
|
|
426
|
+
* `allowUnmarkedAudit: true` opts back in, and
|
|
427
|
+
* `scripts/repair-session-logs.mjs strip` removes already-written audit
|
|
428
|
+
* rows for hosts where the marker cannot help. Extend the bound if a
|
|
429
|
+
* future alpha/rc line regresses. Non-matching (later rc, stable, or
|
|
430
|
+
* unresolvable) versions are treated as possibly-marker-aware and
|
|
431
|
+
* verified by the append probe.
|
|
420
432
|
* @param version - the installed peer version string.
|
|
421
|
-
* @returns true for the known-
|
|
433
|
+
* @returns true for the known-unsafe rc.1–rc.7 lines of `0.1.0` and
|
|
434
|
+
* `0.1.1`, and the `0.1.2-alpha` line.
|
|
422
435
|
*/
|
|
423
436
|
export declare function isUnmarkedHostVersion(version: string): boolean;
|
|
424
437
|
export {};
|
|
@@ -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;
|
|
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;AAE5E,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;AAE9E,OAAO,KAAK,EAAE,kBAAkB,EAAoB,MAAM,YAAY,CAAA;AAItE,OAAO,KAAK,EAAiD,eAAe,EAA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EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA4BvE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;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.3",
|
|
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",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"platform": "web",
|
|
46
46
|
"inject": [
|
|
47
47
|
"@deepseek-ai/dsh-client-connection",
|
|
48
|
-
"@deepseek-ai/dsh-client-
|
|
48
|
+
"@deepseek-ai/dsh-client-web",
|
|
49
49
|
"@deepseek-ai/dsh-client-locale",
|
|
50
50
|
"@deepseek-ai/dsh-client-ui-settings"
|
|
51
51
|
]
|
|
@@ -127,7 +127,25 @@
|
|
|
127
127
|
"@deepseek-ai/dsh-tools": ">=0.1.0-rc.8 <0.2.0",
|
|
128
128
|
"@deepseek-ai/dsh-typert-protocol": ">=0.1.0-rc.8 <0.2.0",
|
|
129
129
|
"@deepseek-ai/schemastery": "^3.18.0",
|
|
130
|
-
"react": "^18.2.0"
|
|
130
|
+
"react": "^18.2.0",
|
|
131
|
+
"@deepseek-ai/dsh-client-connection": ">=0.1.1-rc.2 <0.2.0",
|
|
132
|
+
"@deepseek-ai/dsh-client-locale": ">=0.1.1-rc.2 <0.2.0",
|
|
133
|
+
"@deepseek-ai/dsh-client-ui-settings": ">=0.1.1-rc.2 <0.2.0",
|
|
134
|
+
"@deepseek-ai/dsh-client-web": ">=0.1.1-rc.2 <0.2.0"
|
|
135
|
+
},
|
|
136
|
+
"peerDependenciesMeta": {
|
|
137
|
+
"@deepseek-ai/dsh-client-connection": {
|
|
138
|
+
"optional": true
|
|
139
|
+
},
|
|
140
|
+
"@deepseek-ai/dsh-client-locale": {
|
|
141
|
+
"optional": true
|
|
142
|
+
},
|
|
143
|
+
"@deepseek-ai/dsh-client-ui-settings": {
|
|
144
|
+
"optional": true
|
|
145
|
+
},
|
|
146
|
+
"@deepseek-ai/dsh-client-web": {
|
|
147
|
+
"optional": true
|
|
148
|
+
}
|
|
131
149
|
},
|
|
132
150
|
"dependencies": {
|
|
133
151
|
"@types/react": "18.3.31",
|
|
@@ -145,9 +163,9 @@
|
|
|
145
163
|
"@deepseek-ai/dsh-brand": "0.1.1-rc.2",
|
|
146
164
|
"@deepseek-ai/dsh-client-connection": "0.1.1-rc.2",
|
|
147
165
|
"@deepseek-ai/dsh-client-locale": "0.1.1-rc.2",
|
|
148
|
-
"@deepseek-ai/dsh-client-runtime": "0.1.1-rc.2",
|
|
149
166
|
"@deepseek-ai/dsh-client-ui-settings": "0.1.1-rc.2",
|
|
150
167
|
"@deepseek-ai/dsh-client-ui-slots": "0.1.1-rc.2",
|
|
168
|
+
"@deepseek-ai/dsh-client-web": "0.1.1-rc.2",
|
|
151
169
|
"@deepseek-ai/dsh-commands": "0.1.1-rc.2",
|
|
152
170
|
"@deepseek-ai/dsh-invariants": "0.1.1-rc.2",
|
|
153
171
|
"@deepseek-ai/dsh-llm": "0.1.1-rc.2",
|
|
@@ -181,5 +199,11 @@
|
|
|
181
199
|
"prepare": "node scripts/prepare.mjs"
|
|
182
200
|
},
|
|
183
201
|
"packageManager": "pnpm@11.7.0",
|
|
184
|
-
"license": "Apache-2.0"
|
|
202
|
+
"license": "Apache-2.0",
|
|
203
|
+
"funding": {
|
|
204
|
+
"type": "individual",
|
|
205
|
+
"url": "https://github.com/sponsors/PerryLink"
|
|
206
|
+
}
|
|
185
207
|
}
|
|
208
|
+
|
|
209
|
+
|
|
@@ -6,10 +6,18 @@
|
|
|
6
6
|
* `SessionFormatUnsupportedError` ("unknown to this harness and not marked
|
|
7
7
|
* ignorable").
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* `repair` rewrites ONLY the targeted log-only audit rows, adding
|
|
10
10
|
* `ignorable: true` to their envelopes; every other byte is preserved. Each
|
|
11
11
|
* modified artifact is backed up to `<file>.bak-<epoch>` before replacement.
|
|
12
12
|
*
|
|
13
|
+
* `strip` removes the targeted rows entirely. It exists for harness lines
|
|
14
|
+
* whose read path refuses out-of-vocabulary event types even when the
|
|
15
|
+
* envelope is marked (the `0.1.2-alpha` line, verified on `0.1.2-alpha-1` —
|
|
16
|
+
* issue #15): there the marker cannot help, and dropping the log-only audit
|
|
17
|
+
* rows is the only repair. The target vocabulary is reconstruction-safe by
|
|
18
|
+
* construction (never injected into the model context), so removal does not
|
|
19
|
+
* change how the session replays.
|
|
20
|
+
*
|
|
13
21
|
* It understands both physical encodings of the JSONL backend:
|
|
14
22
|
* - `session.jsonl.zstd` — a concatenation of checksummed Zstandard frames
|
|
15
23
|
* (frame 1 = header line, later frames = durable append batches); each
|
|
@@ -20,6 +28,7 @@
|
|
|
20
28
|
* Usage:
|
|
21
29
|
* node scripts/repair-session-logs.mjs scan [--home DIR] # report foreign rows, change nothing
|
|
22
30
|
* node scripts/repair-session-logs.mjs repair [--home DIR] [--dry-run]
|
|
31
|
+
* node scripts/repair-session-logs.mjs strip [--home DIR] [--dry-run]
|
|
23
32
|
* node scripts/repair-session-logs.mjs repair --types a/b,c/d
|
|
24
33
|
*
|
|
25
34
|
* `--home` defaults to `$env:DSH_HOME/sessions` or `~/.dsh/sessions`.
|
|
@@ -171,37 +180,44 @@ function splitLines(text) {
|
|
|
171
180
|
}
|
|
172
181
|
|
|
173
182
|
/**
|
|
174
|
-
* Apply the ignorable marker to targeted audit rows in one JSONL frame
|
|
183
|
+
* Apply the ignorable marker to targeted audit rows in one JSONL frame, or
|
|
184
|
+
* drop them outright in strip mode (for harness lines that refuse marked
|
|
185
|
+
* plugin events, e.g. the 0.1.2-alpha line).
|
|
175
186
|
* @param {string} text - the frame plaintext.
|
|
176
187
|
* @param {Set<string>} targetTypes - event types to mark.
|
|
177
188
|
* @param {Map<string, number>} foreignSeen - scan accumulator: type -> row count.
|
|
189
|
+
* @param {boolean} strip - remove targeted rows instead of marking them.
|
|
178
190
|
* @returns {{ text: string, changed: number }}
|
|
179
191
|
*/
|
|
180
|
-
function filterFrame(text, targetTypes, foreignSeen) {
|
|
192
|
+
function filterFrame(text, targetTypes, foreignSeen, strip) {
|
|
181
193
|
const lines = splitLines(text)
|
|
182
194
|
let changed = 0
|
|
183
|
-
const out = lines.
|
|
184
|
-
if (line.length === 0) return line
|
|
195
|
+
const out = lines.flatMap(line => {
|
|
196
|
+
if (line.length === 0) return [line]
|
|
185
197
|
let row
|
|
186
198
|
try {
|
|
187
199
|
row = JSON.parse(line)
|
|
188
200
|
} catch {
|
|
189
|
-
return line // preserve unparsable bytes exactly; the reader owns the refusal
|
|
201
|
+
return [line] // preserve unparsable bytes exactly; the reader owns the refusal
|
|
190
202
|
}
|
|
191
|
-
if (typeof row !== 'object' || row === null) return line
|
|
203
|
+
if (typeof row !== 'object' || row === null) return [line]
|
|
192
204
|
const type = row.type
|
|
193
|
-
if (typeof type !== 'string' || STORAGE_ROW_TYPES.has(type)) return line
|
|
194
|
-
if (type === 'session') return line // header row: never an event
|
|
205
|
+
if (typeof type !== 'string' || STORAGE_ROW_TYPES.has(type)) return [line]
|
|
206
|
+
if (type === 'session') return [line] // header row: never an event
|
|
195
207
|
if (!KNOWN_SESSION_EVENT_TYPES.has(type)) {
|
|
196
208
|
foreignSeen.set(type, (foreignSeen.get(type) ?? 0) + 1)
|
|
197
209
|
}
|
|
198
210
|
if (targetTypes.has(type)) {
|
|
199
|
-
if (
|
|
211
|
+
if (strip) {
|
|
212
|
+
changed += 1
|
|
213
|
+
return []
|
|
214
|
+
}
|
|
215
|
+
if (row.ignorable === true) return [line]
|
|
200
216
|
row.ignorable = true
|
|
201
217
|
changed += 1
|
|
202
|
-
return JSON.stringify(row)
|
|
218
|
+
return [JSON.stringify(row)]
|
|
203
219
|
}
|
|
204
|
-
return line
|
|
220
|
+
return [line]
|
|
205
221
|
})
|
|
206
222
|
return { text: out.join('\n') + '\n', changed }
|
|
207
223
|
}
|
|
@@ -249,7 +265,7 @@ function parseArgs(argv) {
|
|
|
249
265
|
const args = { mode: undefined, home: undefined, dryRun: false, types: DEFAULT_TARGET_TYPES }
|
|
250
266
|
for (let i = 0; i < argv.length; i++) {
|
|
251
267
|
const arg = argv[i]
|
|
252
|
-
if (arg === 'scan' || arg === 'repair') args.mode = arg
|
|
268
|
+
if (arg === 'scan' || arg === 'repair' || arg === 'strip') args.mode = arg
|
|
253
269
|
else if (arg === '--home') args.home = argv[++i]
|
|
254
270
|
else if (arg === '--dry-run') args.dryRun = true
|
|
255
271
|
else if (arg === '--types') args.types = argv[++i].split(',')
|
|
@@ -258,7 +274,7 @@ function parseArgs(argv) {
|
|
|
258
274
|
}
|
|
259
275
|
|
|
260
276
|
function usage() {
|
|
261
|
-
console.error('usage: node repair-session-logs.mjs scan|repair [--home DIR] [--dry-run] [--types a/b,c/d]')
|
|
277
|
+
console.error('usage: node repair-session-logs.mjs scan|repair|strip [--home DIR] [--dry-run] [--types a/b,c/d]')
|
|
262
278
|
process.exit(2)
|
|
263
279
|
}
|
|
264
280
|
|
|
@@ -297,8 +313,9 @@ for (const path of logs) {
|
|
|
297
313
|
}
|
|
298
314
|
let fileChanged = 0
|
|
299
315
|
const newFrames = []
|
|
316
|
+
const strip = args.mode === 'strip'
|
|
300
317
|
for (const frame of log.frames) {
|
|
301
|
-
const { text, changed } = filterFrame(frame.text, targetTypes, foreignSeen)
|
|
318
|
+
const { text, changed } = filterFrame(frame.text, targetTypes, foreignSeen, strip)
|
|
302
319
|
newFrames.push({ ...frame, text })
|
|
303
320
|
fileChanged += changed
|
|
304
321
|
}
|
|
@@ -306,16 +323,16 @@ for (const path of logs) {
|
|
|
306
323
|
if (fileChanged > 0) {
|
|
307
324
|
affectedFiles += 1
|
|
308
325
|
marked += fileChanged
|
|
309
|
-
if (args.mode
|
|
326
|
+
if (args.mode !== 'scan' && !args.dryRun) {
|
|
310
327
|
const backup = `${path}.bak-${Date.now()}`
|
|
311
328
|
renameSync(path, backup)
|
|
312
329
|
const content = log.compressed
|
|
313
330
|
? Buffer.concat(newFrames.map(frame => zstdCompressSync(frame.text, CHECKSUM_OPTIONS)))
|
|
314
331
|
: Buffer.from(newFrames[0].text, 'utf8')
|
|
315
332
|
writeFileSync(path, content)
|
|
316
|
-
console.log(
|
|
333
|
+
console.log(`${strip ? 'stripped' : 'repaired'} ${path} (${fileChanged} row(s) ${strip ? 'removed' : 'marked ignorable'}; backup: ${backup})`)
|
|
317
334
|
} else {
|
|
318
|
-
console.log(
|
|
335
|
+
console.log(`[${args.dryRun ? 'dry-run' : 'scan'}] would ${strip ? 'strip' : 'repair'} ${path}: ${fileChanged} row(s)`)
|
|
319
336
|
}
|
|
320
337
|
}
|
|
321
338
|
}
|
|
@@ -328,5 +345,7 @@ if (foreignSeen.size > 0) {
|
|
|
328
345
|
}
|
|
329
346
|
}
|
|
330
347
|
for (const failure of failures) console.error(`error: ${failure}`)
|
|
331
|
-
|
|
348
|
+
const verb = args.mode === 'strip' ? 'stripped' : 'marked'
|
|
349
|
+
const past = args.mode !== 'scan' && !args.dryRun ? ` (${verb})` : ''
|
|
350
|
+
console.log(`\n${scanned} log(s) scanned, ${affectedFiles} affected, ${marked} row(s) would be ${verb}${past}`)
|
|
332
351
|
process.exit(failures.length > 0 ? 1 : 0)
|
package/src/call-id.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dual-ruler call-id brand: host master renamed the dsh-llm `CallId`
|
|
3
|
+
* brand to `ToolCallId`, while the published 0.1.1-rc.2 line still
|
|
4
|
+
* exports `CallId`. Derive the brand from the dsh-tools execution
|
|
5
|
+
* contract so both rulers typecheck without naming either brand name.
|
|
6
|
+
* @module dsh-permission-rules/call-id
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { ToolExecution } from '@deepseek-ai/dsh-tools'
|
|
10
|
+
|
|
11
|
+
export type CallId = ToolExecution['callId']
|
package/src/events.ts
CHANGED
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
* @module dsh-permission-rules/events
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
|
-
import type { CallId } from '@deepseek-ai/dsh-llm'
|
|
34
33
|
import type { PreToolDecision } from '@deepseek-ai/dsh-tools'
|
|
34
|
+
import type { CallId } from './call-id.ts'
|
|
35
35
|
|
|
36
36
|
declare module '@deepseek-ai/dsh-session/types' {
|
|
37
37
|
interface SessionEventMap {
|
package/src/prose.ts
CHANGED
|
@@ -109,7 +109,7 @@ const EN: UiProse = {
|
|
|
109
109
|
usage: 'Usage: /rules [list | reload | network | decisions [n] | test <tool> <json-args>]',
|
|
110
110
|
decisionsHeader: (shown, total) => `Last ${shown} of ${total} permission decision(s) for this session:`,
|
|
111
111
|
noDecisions: 'No permission decisions recorded in this session yet.',
|
|
112
|
-
auditDisabledNotice: 'Session-log audit is disabled on this host:
|
|
112
|
+
auditDisabledNotice: 'Session-log audit is disabled on this host: it cannot safely persist ignorable-marked audit events, which would make sessions unresumable elsewhere (set allowUnmarkedAudit: true to opt back in).',
|
|
113
113
|
invalidDecisionsCount: arg => `Invalid decisions count "${arg}": give a positive integer (default 10).`,
|
|
114
114
|
decisionLine: (seq, action, toolName, ruleIndex, reason, dryRun, outcome) => {
|
|
115
115
|
const rule = ruleIndex === undefined ? '' : ` (rule ${ruleIndex + 1})`
|
|
@@ -152,7 +152,7 @@ const ZH: UiProse = {
|
|
|
152
152
|
usage: '用法:/rules [list | reload | network | decisions [n] | test <工具名> <json-参数>]',
|
|
153
153
|
decisionsHeader: (shown, total) => `本会话最近 ${shown}/${total} 条权限裁决:`,
|
|
154
154
|
noDecisions: '本会话还没有记录任何权限裁决。',
|
|
155
|
-
auditDisabledNotice: '
|
|
155
|
+
auditDisabledNotice: '本宿主上会话日志审计已停用:其无法安全持久化 ignorable 标记的审计事件,会令会话在其他宿主上无法恢复(设 allowUnmarkedAudit: true 可重新开启)。',
|
|
156
156
|
invalidDecisionsCount: arg => `无效的裁决条数 "${arg}":请给正整数(默认 10)。`,
|
|
157
157
|
decisionLine: (seq, action, toolName, ruleIndex, reason, dryRun, outcome) => {
|
|
158
158
|
const rule = ruleIndex === undefined ? '' : `(规则 ${ruleIndex + 1})`
|
|
@@ -195,7 +195,7 @@ const ES: UiProse = {
|
|
|
195
195
|
usage: 'Uso: /rules [list | reload | network | decisions [n] | test <herramienta> <json-args>]',
|
|
196
196
|
decisionsHeader: (shown, total) => `Últimas ${shown} de ${total} decisión(es) de permiso de esta sesión:`,
|
|
197
197
|
noDecisions: 'Esta sesión aún no registra decisiones de permiso.',
|
|
198
|
-
auditDisabledNotice: 'La auditoría del registro de sesión está desactivada en este host:
|
|
198
|
+
auditDisabledNotice: 'La auditoría del registro de sesión está desactivada en este host: no puede persistir de forma segura eventos de auditoría marcados como ignorable, lo que haría las sesiones irrecuperables en otros hosts (establece allowUnmarkedAudit: true para reactivarla).',
|
|
199
199
|
invalidDecisionsCount: arg => `Cantidad de decisiones inválida "${arg}": indique un entero positivo (por defecto 10).`,
|
|
200
200
|
decisionLine: (seq, action, toolName, ruleIndex, reason, dryRun, outcome) => {
|
|
201
201
|
const rule = ruleIndex === undefined ? '' : ` (regla ${ruleIndex + 1})`
|
|
@@ -238,7 +238,7 @@ const PT: UiProse = {
|
|
|
238
238
|
usage: 'Uso: /rules [list | reload | network | decisions [n] | test <ferramenta> <json-args>]',
|
|
239
239
|
decisionsHeader: (shown, total) => `Últimas ${shown} de ${total} decisão(ões) de permissão desta sessão:`,
|
|
240
240
|
noDecisions: 'Esta sessão ainda não registrou decisões de permissão.',
|
|
241
|
-
auditDisabledNotice: 'A auditoria do registro da sessão está desativada neste host:
|
|
241
|
+
auditDisabledNotice: 'A auditoria do registro da sessão está desativada neste host: ele não consegue persistir com segurança eventos de auditoria marcados como ignorable, o que tornaria as sessões irrecuperáveis em outros hosts (defina allowUnmarkedAudit: true para reativar).',
|
|
242
242
|
invalidDecisionsCount: arg => `Quantidade de decisões inválida "${arg}": informe um inteiro positivo (padrão 10).`,
|
|
243
243
|
decisionLine: (seq, action, toolName, ruleIndex, reason, dryRun, outcome) => {
|
|
244
244
|
const rule = ruleIndex === undefined ? '' : ` (regra ${ruleIndex + 1})`
|
|
@@ -281,7 +281,7 @@ const HI: UiProse = {
|
|
|
281
281
|
usage: 'उपयोग: /rules [list | reload | network | decisions [n] | test <टूल> <json-args>]',
|
|
282
282
|
decisionsHeader: (shown, total) => `इस सत्र के अंतिम ${shown}/${total} अनुमति निर्णय:`,
|
|
283
283
|
noDecisions: 'इस सत्र में अभी कोई अनुमति निर्णय दर्ज नहीं है।',
|
|
284
|
-
auditDisabledNotice: 'इस होस्ट पर सत्र-लॉग ऑडिट अक्षम है:
|
|
284
|
+
auditDisabledNotice: 'इस होस्ट पर सत्र-लॉग ऑडिट अक्षम है: यह ignorable-चिह्नित ऑडिट इवेंट को सुरक्षित रूप से सहेज नहीं सकता, जिससे सत्र अन्य होस्ट पर अप्राप्य हो जाते (पुनः चालू करने के लिए allowUnmarkedAudit: true सेट करें)।',
|
|
285
285
|
invalidDecisionsCount: arg => `अमान्य निर्णय-संख्या "${arg}": एक धनात्मक पूर्णांक दें (डिफ़ॉल्ट 10)।`,
|
|
286
286
|
decisionLine: (seq, action, toolName, ruleIndex, reason, dryRun, outcome) => {
|
|
287
287
|
const rule = ruleIndex === undefined ? '' : ` (नियम ${ruleIndex + 1})`
|
package/src/proxy.ts
CHANGED
|
@@ -22,7 +22,7 @@ import { lookup } from 'node:dns/promises'
|
|
|
22
22
|
import type { AddressInfo } from 'node:net'
|
|
23
23
|
import type { Duplex } from 'node:stream'
|
|
24
24
|
import type { Server, IncomingMessage, ServerResponse } from 'node:http'
|
|
25
|
-
import type { CallId } from '
|
|
25
|
+
import type { CallId } from './call-id.ts'
|
|
26
26
|
import type { NetworkDecision, NetworkMode } from './network.ts'
|
|
27
27
|
import { blockMessage } from './network.ts'
|
|
28
28
|
import { isIpLiteral, parseUrlTarget } from './rules.ts'
|