dsh-mask 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,70 @@
1
+ # Architecture
2
+
3
+ ## Overview
4
+
5
+ `dsh-mask` anonymizes PII at the model boundary: it rewrites the messages that enter a step so that phones, emails, ID cards, bank cards, keys, and IPs become `<TYPE_N>` placeholders, and it keeps a `placeholder → original` restore table so those placeholders can be mapped back at the display layer. The hard invariant is that **the plaintext never enters the session log** — the masked form is what gets logged and sent to the model, so model-visible content reconstructs from the log in placeholder form.
6
+
7
+ ## Roles
8
+
9
+ - **Consumes public services only**: `commands`, `storageDomain` (hard `inject`); `tools` (registered via `ctx.inject(['tools'], …)` when present). The masking seam is the `agent/pre-step` waterfall.
10
+ - **`lib/` is zero-DSH-dependency**: services are wired only at the boundary in `index.mjs`; `lib/` depends only on `node:` built-ins (the single sanctioned exception is `lib/domain.mjs`, which imports `zod` and `@deepseek-ai/dsh-storage-domain` because the domain record schema is a persistence-boundary validator).
11
+
12
+ ## Module map
13
+
14
+ | Module | Responsibility |
15
+ |---|---|
16
+ | `index.mjs` | The single host face: `Config` schema + `resolveConfig`, `probeIgnorableAppend`, the `agent/pre-step` masking listener, the `/mask` command handler, the `mask_test` tool factory, `apply()` |
17
+ | `lib/constants.mjs` | Vocabulary + protocol constants (entity names/labels, modes, scopes, error codes, defaults, bounds) — zero dependency |
18
+ | `lib/errors.mjs` | Structured domain errors (`MaskError` with stable `code` + `details`) |
19
+ | `lib/strip.mjs` | The regex PII detector and `Stripper` (strip/stripInto/restore/mapping/stats/loadMapping) — zero dependency |
20
+ | `lib/mask.mjs` | Message masking: rewrite `UserMessage` text blocks through a `Stripper` — zero dependency |
21
+ | `lib/sanitize.mjs` | Pure display/log redaction (PII entities, secrets, URL credentials, mapping summarization) |
22
+ | `lib/gate.mjs` | Session-event adaptive gate (append only when the host records the type or supports `ignorable`) |
23
+ | `lib/store.mjs` | The restore table: per-session `Stripper` in memory + optional persistence to `storageDomain` |
24
+ | `lib/domain.mjs` | The `dsh-mask` storage-domain spec (`restore` table, zod-validated) |
25
+
26
+ ## Data flow
27
+
28
+ ```text
29
+ inbox ──agent/pre-step──▶ maskMessages ──▶ user/message (placeholders) ──▶ model
30
+ │
31
+ └──▶ RestoreStore (memory + dsh_mask/restore)
32
+ response (placeholders) ──restore()──▶ display (originals)
33
+ ```
34
+
35
+ 1. **Mask** — the `agent/pre-step` listener calls `next()` first (waterfall discipline), then rewrites the returned decision's messages through the session's `Stripper`. The masked messages are what the loop appends as `user/message`, so the log and the model both see placeholders.
36
+ 2. **Record** — the `Stripper` accumulates the mapping and counts in memory; `store.persist(sessionId)` writes the mapping to `dsh_mask/restore` (best-effort, when `persistRestoreTable: true`).
37
+ 3. **Restore** — `/mask restore` (and a future client half) call `store.restore(sessionId, text)`, which unmaps placeholders using the in-memory mapping or reloads it from the domain.
38
+
39
+ ## Why `agent/pre-step` and not `agent/request`
40
+
41
+ The official contract states that `agent/request` is the model-configuration waterfall and **cannot mutate messages**. The extension point that can replace the messages entering a step is `agent/pre-step` (`PreStepDecision = { kind: 'reject' } | { kind: 'enter'; messages }`). Masking there — after `next()`, before the loop appends `user/message` — is exactly the model boundary this plugin needs.
42
+
43
+ ## Detection and overlap resolution
44
+
45
+ Ported from Pii-Stripper-Middleware's `core.py`:
46
+
47
+ - Regex patterns for phone, ID card, email, bank card, and IP (plus a `key` detector this repo adds for the spec's "密钥").
48
+ - Overlap resolution sorts by start ascending, then score descending, and keeps only non-overlapping spans (first-come, higher score wins at the same position) — an 18-digit ID card beats a 16–19-digit bank-card match.
49
+ - Same original value reuses the same placeholder; the counter is monotonic per session so placeholders never collide across turns.
50
+
51
+ ## Session events (adaptive gate)
52
+
53
+ `mask/applied` is declared through `SessionEventMap` declaration merging in `types.d.ts`. At runtime the plugin appends it only when either (a) the host's `KNOWN_SESSION_EVENT_TYPES` already includes the type, or (b) the host `Session.append` supports the `ignorable` envelope (`probeIgnorableAppend`). On `0.1.0-rc.6` neither is true, so the gate stays closed and appends are skipped — sessions keep loading. The audit payload is counts + type distribution only, never plaintext or the mapping.
54
+
55
+ ## Storage domain
56
+
57
+ The `dsh_mask` domain has one `restore` table keyed by session id. Its record holds `entries: { placeholder: original }` plus `updatedAt`. This is the only place plaintext PII is stored, and only when `persistRestoreTable: true`; the `Stripper` keeps a bounded in-memory copy (`maxRestoreEntriesPerSession`, `maxSessions` with LRU eviction).
58
+
59
+ ## Safety boundaries
60
+
61
+ - **Plaintext never enters the session log.** The masked form is logged; originals stay in the restore table.
62
+ - **Sanitize before display/log.** `lib/sanitize.mjs` redacts PII, secrets, and URL credentials before any text reaches the model or log; `mask_test` and `/mask status` never echo originals.
63
+ - **Fail closed.** Unimplemented `mode` (`regex+ner`), `scope` (`tools`), NER-only entities, and out-of-bounds numbers fail loudly at load.
64
+ - **Registrations are effects.** The listener, command, tool, and domain close are all Cordis effects, so stop/hot-reload is reversible.
65
+
66
+ ## Reserved seams
67
+
68
+ - `mode: regex+ner` — external name/address recognition; fails loudly until a recognizer is wired in.
69
+ - `scope: tools` — masking tool arguments (`tools/pre-execute`); reserved.
70
+ - A browser half would consume the restore table to transparently un-mask assistant bubbles; this pure-host form ships the host-side seam only.
package/CHANGELOG.md ADDED
@@ -0,0 +1,23 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.1] - 2026-08-17
9
+
10
+ ### Fixed
11
+
12
+ - The bundle patch now composes the storage stack (`@deepseek-ai/dsh-storage` + `dsh-storage-json` + `dsh-storage-domain`) and declares all three packages, so a bare profile gets the `storageDomain` service the plugin injects instead of hanging with `pending (waiting for service: storageDomain)`.
13
+
14
+ ## [0.1.0] - 2026-08-17
15
+
16
+ ### Added
17
+
18
+ - PII masking middleware for DeepSeek Harness: request-time anonymization at the `agent/pre-step` boundary (phones, emails, ID cards, bank cards, keys, and opt-in IPs become `<TYPE_N>` placeholders), a `placeholder → original` restore table kept only in memory and the controlled `dsh_mask` storage domain, and a `mask/applied` audit session event that records counts + type distribution only.
19
+ - The `/mask` command (`status`/`on`/`off`/`restore <text>`/`help`) and the `mask_test` model tool (mask a snippet, never reveal the original).
20
+ - The regex PII detector ported from Pii-Stripper-Middleware (`lib/strip.mjs`), plus a `key` detector for the spec's secret-type PII.
21
+ - Pure display/log sanitizers (`lib/sanitize.mjs`) with extreme-case coverage: PII plaintext and the mapping table never leak into logs or results.
22
+ - Schemastery configuration with fail-loud bounds; every tunable documented in `cordis.patch.yml` and the five-language READMEs.
23
+ - Session-event adaptive gate (`mask/applied` appends only when the host records the type or supports the `ignorable` envelope).
package/LICENSE ADDED
@@ -0,0 +1,195 @@
1
+ Copyright 2026 PerryLink
2
+
3
+ Apache License
4
+ Version 2.0, January 2004
5
+ http://www.apache.org/licenses/
6
+
7
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
+
9
+ 1. Definitions.
10
+
11
+ "License" shall mean the terms and conditions for use, reproduction,
12
+ and distribution as defined by Sections 1 through 9 of this document.
13
+
14
+ "Licensor" shall mean the copyright owner or entity authorized by
15
+ the copyright owner that is granting the License.
16
+
17
+ "Legal Entity" shall mean the union of the acting entity and all
18
+ other entities that control, are controlled by, or are under common
19
+ control with that entity. For the purposes of this definition,
20
+ "control" means (i) the power, direct or indirect, to cause the
21
+ direction or management of such entity, whether by contract or
22
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
23
+ outstanding shares, or (iii) beneficial ownership of such entity.
24
+
25
+ "You" (or "Your") shall mean an individual or Legal Entity
26
+ exercising permissions granted by this License.
27
+
28
+ "Source" form shall mean the preferred form for making modifications,
29
+ including but not limited to software source code, documentation
30
+ source, and configuration files.
31
+
32
+ "Object" form shall mean any form resulting from mechanical
33
+ transformation or translation of a Source form, including but
34
+ not limited to compiled object code, generated documentation,
35
+ and conversions to other media types.
36
+
37
+ "Work" shall mean the work of authorship made available under
38
+ the License, as indicated by a copyright notice that is included in
39
+ or attached to the work (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
50
+ in the Work by the copyright owner or by an individual or Legal Entity
51
+ authorized to submit on behalf of the copyright owner. For the purposes
52
+ of this definition, "submitted" means any form of electronic, verbal,
53
+ or written communication sent to the Licensor or its representatives,
54
+ including but not limited to communication on electronic mailing lists,
55
+ source code control systems, and issue tracking systems that are managed
56
+ by, or on behalf of, the Licensor for the purpose of discussing and
57
+ improving the Work, but excluding communication that is conspicuously
58
+ marked or otherwise designated in writing by the copyright owner as
59
+ "Not a Contribution."
60
+
61
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
62
+ whom a Contribution has been received by the Licensor and subsequently
63
+ incorporated within the Work.
64
+
65
+ 2. Grant of Copyright License. Subject to the terms and conditions of
66
+ this License, each Contributor hereby grants to You a perpetual,
67
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
68
+ copyright license to reproduce, prepare Derivative Works of,
69
+ publicly display, publicly perform, sublicense, and distribute the
70
+ Work and such Derivative Works in Source or Object form.
71
+
72
+ 3. Grant of Patent License. Subject to the terms and conditions of
73
+ this License, each Contributor hereby grants to You a perpetual,
74
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
75
+ (except as stated in this section) patent license to make, have made,
76
+ use, offer to sell, sell, import, and otherwise transfer the Work,
77
+ where such license applies only to those patent claims licensable
78
+ by such Contributor that are necessarily infringed by their
79
+ Contribution(s) alone or by combination of their Contribution(s)
80
+ with the Work to which such Contribution(s) was submitted. If You
81
+ institute patent litigation against any entity (including a cross-claim
82
+ or counterclaim in a lawsuit) alleging that the Work or a Contribution
83
+ incorporated within the Work constitutes direct or contributory patent
84
+ infringement, then any patent licenses granted to You under this License
85
+ for that Work shall terminate as of the date such litigation is filed.
86
+
87
+ 4. Redistribution. You may reproduce and distribute copies of the
88
+ Work or Derivative Works thereof in any medium, with or without
89
+ modifications, and in Source or Object form, provided that You
90
+ meet the following conditions:
91
+
92
+ (a) You must give any other recipients of the Work or Derivative Works
93
+ a copy of this License; and
94
+
95
+ (b) You must cause any modified files to carry prominent notices
96
+ stating that You changed the files; and
97
+
98
+ (c) You must retain, in the Source form of any Derivative Works
99
+ that You distribute, all copyright, patent, trademark, and
100
+ attribution notices from the Source form of the Work, excluding
101
+ those notices that do not pertain to any part of the Derivative
102
+ Works; and
103
+
104
+ (d) If the Work includes a "NOTICE" text file as part of its
105
+ distribution, You must include a readable copy of the attribution
106
+ notices contained within such NOTICE file, in at least one of the
107
+ following places: within a NOTICE text file distributed as part of
108
+ the Derivative Works; within the Source form or documentation, if
109
+ provided along with the Derivative Works; or, within a display
110
+ generated by the Derivative Works, if and wherever such third-party
111
+ notices normally appear. The contents of the NOTICE file are for
112
+ informational purposes only and do not modify the License. You may
113
+ add Your own attribution notices within Derivative Works that You
114
+ distribute, alongside or as an addendum to the NOTICE text from the
115
+ Work, provided that such additional attribution notices cannot be
116
+ construed as modifying the License.
117
+
118
+ You may add Your own license statement for Your modifications and
119
+ may provide additional grant of rights to use, copy, modify, merge,
120
+ publish, distribute, sublicense, and/or sell copies of the Work under
121
+ terms of Your choice, or to simply not grant those additional rights.
122
+
123
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
124
+ any Contribution intentionally submitted for inclusion in the Work
125
+ by You to the Licensor shall be under the terms and conditions of
126
+ this License, without any additional terms or conditions.
127
+ Notwithstanding the above, nothing herein shall supersede or modify
128
+ the terms of any separate license agreement you may have executed
129
+ with Licensor regarding such Contributions.
130
+
131
+ 6. Trademarks. This License does not grant permission to use the trade
132
+ names, trademarks, service marks, or product names of the Licensor,
133
+ except as required for reasonable and customary use in describing the
134
+ origin of the Work and reproducing the content of the NOTICE file.
135
+
136
+ 7. Disclaimer of Warranty. Unless required by applicable law or
137
+ agreed to in writing, Licensor provides the Work (and each
138
+ Contributor provides its Contributions) on an "AS IS" BASIS,
139
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
140
+ implied, including, without limitation, any warranties or conditions
141
+ of TITLE, MERCHANTABILITY, SATISFACTORY QUALITY, NON-INFRINGEMENT,
142
+ FITNESS FOR A PARTICULAR PURPOSE, or any other warranties or
143
+ conditions. You are solely responsible for determining the
144
+ appropriateness of using or redistributing the Work and assume any
145
+ risks associated with Your exercise of permissions under this License.
146
+
147
+ 8. Limitation of Liability. In no event and under no legal theory,
148
+ whether in tort (including negligence), contract, or otherwise,
149
+ unless required by applicable law (such as deliberate and grossly
150
+ negligent acts) or agreed to in writing, shall any Contributor be
151
+ liable to You for damages, including any direct, indirect, special,
152
+ incidental, or exemplary damages of any character arising as a result
153
+ of this License or out of the use or inability to use the Work
154
+ (including but not limited to damages for loss of goodwill, work
155
+ stoppage, computer failure or malfunction, or all other commercial
156
+ damages or losses), even if such Contributor has been advised of the
157
+ possibility of such damages.
158
+
159
+ 9. Accepting Warranty or Additional Liability. While redistributing
160
+ the Work or Derivative Works thereof, You may choose to offer, and
161
+ charge a fee for, acceptance of support, warranty, indemnity, or
162
+ other liability obligations and/or rights consistent with this License.
163
+ However, in accepting such obligations, You may offer such obligations
164
+ only on Your own behalf and on Your sole responsibility, not on behalf
165
+ of any other Contributor, and only if You agree to indemnify, defend,
166
+ and hold each Contributor harmless for any liability incurred by, or
167
+ claims asserted against, such Contributor by reason of your accepting
168
+ any such warranty or additional liability.
169
+
170
+ END OF TERMS AND CONDITIONS
171
+
172
+ APPENDIX: How to apply the Apache License to your work.
173
+
174
+ To apply the Apache License to your work, attach the following
175
+ boilerplate notice, with the fields enclosed by brackets "[]"
176
+ replaced with your own identifying information. (Don't include
177
+ the brackets!) The text should be enclosed in the appropriate
178
+ comment syntax for the file format. We also recommend that a
179
+ file or class name and description of purpose be included on the
180
+ same "printed page" as the copyright notice for easier
181
+ identification within third-party archives.
182
+
183
+ Copyright 2026 PerryLink
184
+
185
+ Licensed under the Apache License, Version 2.0 (the "License");
186
+ you may not use this file except in compliance with the License.
187
+ You may obtain a copy of the License at
188
+
189
+ http://www.apache.org/licenses/LICENSE-2.0
190
+
191
+ Unless required by applicable law or agreed to in writing, software
192
+ distributed under the License is distributed on an "AS IS" BASIS,
193
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
194
+ See the License for the specific language governing permissions and
195
+ limitations under the License.
package/README.es.md ADDED
@@ -0,0 +1,170 @@
1
+ <div align="center">
2
+
3
+ # dsh-mask
4
+
5
+ **Middleware de enmascaramiento de PII para DeepSeek Harness: anonimiza los datos personales antes de que lleguen al modelo y los restaura en la capa de visualización.**
6
+
7
+ *Teléfonos, correos, documentos, tarjetas, claves y más se convierten en marcadores de posición en el límite del modelo; el texto plano nunca entra en tu registro de sesión.*
8
+
9
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
10
+ [![DSH plugin](https://img.shields.io/badge/dsh-plugin-✅-green)](https://github.com/topics/dsh-plugin)
11
+ [![Node](https://img.shields.io/badge/node-%5E22.19%20%7C%7C%20%3E%3D24-brightgreen.svg)](#)
12
+ [![CI](https://img.shields.io/github/actions/workflow/status/PerryLink/dsh-mask/ci.yml?branch=main&label=CI)](https://github.com/PerryLink/dsh-mask/actions)
13
+ [![Version](https://img.shields.io/github/v/tag/PerryLink/dsh-mask?label=version)](https://github.com/PerryLink/dsh-mask/releases)
14
+ [![npm version](https://img.shields.io/npm/v/dsh-mask)](https://www.npmjs.com/package/dsh-mask)
15
+ [![npm downloads](https://img.shields.io/npm/dm/dsh-mask)](https://www.npmjs.com/package/dsh-mask)
16
+
17
+ [English](README.md) · [简体中文](README.zh.md) · [Español](README.es.md) · [Português](README.pt.md) · [हिन्दी](README.hi.md)
18
+
19
+ </div>
20
+
21
+ ---
22
+
23
+ ## Compatibility
24
+
25
+ | Superficie | Estado |
26
+ |---|---|
27
+ | Harness | DeepSeek Harness `0.1.0-rc.6` |
28
+ | Node | `^22.19.0 \|\| >=24.0.0` |
29
+ | Plataformas | Donde corra DSH (host puro, regex sin dependencias; sin mitad de navegador) |
30
+ | Modelo | Modelos de texto totalmente soportados |
31
+
32
+ ## What you get
33
+
34
+ `dsh-mask` anonimiza datos personales **en el límite del modelo** y mantiene una tabla de restauración para volver de los marcadores a los originales:
35
+
36
+ - **Enmascarado antes de la petición** — reescribe los mensajes de `agent/pre-step` para que teléfonos, correos, documentos, tarjetas, claves e IP (opt-in) se vuelvan marcadores como `<PHONE_1>`. El texto enmascarado es lo que se registra y se envía al modelo.
37
+ - **Tabla de restauración** — el mapa `marcador → original` vive solo en memoria y en un dominio de almacenamiento controlado (`dsh_mask`); el texto plano nunca entra en el registro de sesión.
38
+ - **Auditoría sin texto plano** — el evento `mask/applied` solo registra «N valores reemplazados + distribución por tipo».
39
+ - **Comando `/mask`** — `status`, `on`/`off`, `restore <text>`, `help`.
40
+ - **Herramienta `mask_test`** — prueba un fragmento y ve el resultado con marcadores; nunca revela los valores originales.
41
+
42
+ ```text
43
+ mensaje de usuario ──agent/pre-step──▶ marcadores ──modelo──▶ marcadores ──restore──▶ pantalla
44
+ ▲ │
45
+ └──── tabla de restauración (memoria + dsh_mask) ─┘
46
+ ```
47
+
48
+ ## Quick start
49
+
50
+ ```sh
51
+ dsh plugin --profile web add "github:PerryLink/dsh-mask#main"
52
+ # o desde npm
53
+ dsh plugin --profile web add dsh-mask
54
+ dsh --profile web --dump-config | grep -A2 'id: mask'
55
+ ```
56
+
57
+ ```yaml
58
+ - insert:
59
+ - id: mask
60
+ name: dsh-mask
61
+ config:
62
+ entities: [phone, email, id-card, bank-card, key]
63
+ ```
64
+
65
+ ```
66
+ > /mask status
67
+ > /mask restore <PHONE_1>
68
+ ```
69
+
70
+ ## Install & uninstall
71
+
72
+ - **Canal git**: `dsh plugin --profile web add "github:PerryLink/dsh-mask#main"` (equivale a `git+https://github.com/PerryLink/dsh-mask.git`). Sin paso de build.
73
+ - **Canal npm**: `dsh plugin --profile web add dsh-mask`.
74
+ - **Canal tarball**: `pnpm pack` y luego `dsh plugin --profile web add ./dsh-mask-<version>.tgz`.
75
+ - **Desinstalar**: `dsh plugin --profile web remove dsh-mask`.
76
+
77
+ ## Configuration
78
+
79
+ Todas las opciones son campos Schemastery `Config` (modificables desde cordis.yml). `cordis.patch.yml` documenta cada clave.
80
+
81
+ | Clave | Predeterminado | Significado |
82
+ |---|---|---|
83
+ | `enabled` | `true` | Interruptor maestro |
84
+ | `mode` | `regex` | Solo `regex` implementado (`regex+ner` reservado) |
85
+ | `entities` | `[phone, email, id-card, bank-card, key]` | Tipos de PII a enmascarar; `ip` opt-in, `person`/`address` requieren NER |
86
+ | `scope` | `messages` | Solo `messages` implementado |
87
+ | `registerCommand` | `true` | Registra el comando `/mask` |
88
+ | `registerTools` | `true` | Registra la herramienta `mask_test` |
89
+ | `persistRestoreTable` | `true` | Persiste la tabla en el dominio `dsh_mask` |
90
+ | `maxRestoreEntriesPerSession` | `500` | Tope de entradas por sesión |
91
+ | `maxSessions` | `1000` | Tope de sesiones en memoria |
92
+
93
+ ## Tools & surfaces
94
+
95
+ | Superficie | Revela texto plano | Notas |
96
+ |---|---|---|
97
+ | Enmascarado `agent/pre-step` | nunca | Reescribe mensajes a marcadores |
98
+ | `/mask status` | nunca | Estado, total reemplazado, distribución |
99
+ | `/mask on` / `/mask off` | nunca | Alternancia en tiempo de ejecución |
100
+ | `/mask restore <text>` | sí (explícito) | Desmapea marcadores a los valores de esta sesión |
101
+ | `mask_test` | nunca | Enmascara un fragmento y reporta el resultado |
102
+
103
+ ## Permissions & data
104
+
105
+ - **Permisos**: sin red, sin credenciales (`network:none`, `credentials:none`).
106
+ - **Datos**: la tabla `marcador → original` vive en memoria y, con `persistRestoreTable: true`, en el dominio `dsh_mask`; nunca en el registro de sesión.
107
+ - **Registro de sesión**: `mask/applied` se declara en `types.d.ts` y se añade solo cuando el host registra el tipo.
108
+
109
+ ## Security boundaries
110
+
111
+ - **El texto plano nunca entra en el registro de sesión.** Lo registrado y enviado es la forma enmascarada; los originales quedan en la tabla de restauración.
112
+ - **Sanitizar antes de mostrar/registrar.** `lib/sanitize.mjs` redacta PII, secretos y credenciales de URL.
113
+ - **Restauración controlada.** `/mask restore` es la única superficie de revelado explícita.
114
+ - **Fallo cerrado.** `mode`/`scope`/entidades no implementados y números fuera de rango fallan al cargar.
115
+ - **Registros como efectos.** Listener, comando, herramienta y cierre de dominio son efectos Cordis.
116
+
117
+ ## Known limitations
118
+
119
+ - **Solo regex.** `person` y `address` requieren un reconocedor NER externo; fallan al cargar. Cubierto de serie: teléfono, correo, documento, tarjeta, clave e IP (opt-in).
120
+ - **La restauración visual necesita una mitad de cliente.** Enmascarar es host-side; desenmascarar burbujas en la UI es una función de navegador que esta forma host puro no incluye. La tabla y `restore()` son el seam host-side completo.
121
+ - **Eventos en `0.1.0-rc.6`.** El host aún no registra `mask/*`, así que los appends de auditoría se omiten (las sesiones siguen cargando).
122
+
123
+ ## Development
124
+
125
+ ```sh
126
+ pnpm install
127
+ pnpm run typecheck && pnpm run typecheck:ci
128
+ pnpm test
129
+ pnpm run verify:self-contained
130
+ pnpm run verify:artifacts
131
+ pnpm run check:readmes
132
+ pnpm pack
133
+ ```
134
+
135
+ Sin paso de build: ESM puro, `index.mjs` y `lib/` son los artefactos enviados.
136
+
137
+ ## Topics
138
+
139
+ `dsh`, `dsh-plugin`, `deepseek-harness`, `deepseek`, `cordis`, `pii`, `mask`, `privacy`, `anonymization`, `security`
140
+
141
+ ## Contributors
142
+
143
+ - [@PerryLink](https://github.com/PerryLink) — creador y mantenedor.
144
+
145
+ ## PerryLink DSH Plugin Family
146
+
147
+ Este proyecto es uno de los [plugins de DeepSeek Harness](https://github.com/PerryLink) mantenidos por [PerryLink](https://github.com/PerryLink). Si este te ayuda, los demás probablemente también:
148
+
149
+ | Plugin | En una línea |
150
+ |---|---|
151
+ | **[dsh-mask](https://github.com/PerryLink/dsh-mask)** | Middleware de enmascaramiento de PII: anonimiza en el límite del modelo, restaura en la capa de visualización |
152
+ | [dsh-mcp-panel](https://github.com/PerryLink/dsh-mcp-panel) | Panel MCP de solo lectura: comando /mcp + pestaña de ajustes con estado, herramientas y errores |
153
+ | [dsh-doublecheck](https://github.com/PerryLink/dsh-doublecheck) | Guardia de disciplina de ingeniería: interrogatorio de requisitos, puertas de pruebas, revisión adversaria |
154
+ | [dsh-background-agents](https://github.com/PerryLink/dsh-background-agents) | Agentes hijos en segundo plano con barra lateral web, mensajería e interrupción |
155
+ | [dsh-lsp-actions](https://github.com/PerryLink/dsh-lsp-actions) | Diagnóstico, formato, autocompletado, acciones de código y renombrado LSP |
156
+ | [dsh-output-styles](https://github.com/PerryLink/dsh-output-styles) | Cambio de estilo en tiempo de ejecución equivalente a outputStyles de Claude Code |
157
+ | [dsh-checkpoint-rewind](https://github.com/PerryLink/dsh-checkpoint-rewind) | Equivalente a /rewind de Claude Code: snapshots, forks de sesión, restauración de un clic |
158
+ | [dsh-permission-rules](https://github.com/PerryLink/dsh-permission-rules) | Reglas de permisos declarativas allow/deny/ask estilo Claude Code, con auditoría |
159
+ | [dsh-auto-review](https://github.com/PerryLink/dsh-auto-review) | Autorrevisión de segundo modelo en la cadena de aprobación, fail-closed por defecto |
160
+ | [dsh-memento](https://github.com/PerryLink/dsh-memento) | Memoria entre sesiones con aprobación: seam ctx.memory + SQLite + herramienta memory |
161
+ | [dsh-skill-pack-security](https://github.com/PerryLink/dsh-skill-pack-security) | Paquete de skills de auditoría de seguridad: escaneo de secretos, revisión de dependencias y cadena de suministro |
162
+ | [dsh-session-pin](https://github.com/PerryLink/dsh-session-pin) | Fija sesiones en la barra lateral web con orden duradero |
163
+ | [dsh-composer-history](https://github.com/PerryLink/dsh-composer-history) | Historial de entrada estilo terminal para el compositor web: flechas, búsqueda Ctrl+R |
164
+ | [dsh-github](https://github.com/PerryLink/dsh-github) | Integración de PR/issues de GitHub para DSH, toda escritura con aprobación |
165
+ | [dsh-plugin-guide](https://github.com/PerryLink/dsh-plugin-guide) | Base de conocimiento de desarrollo de plugins como skill de agente bajo demanda |
166
+ | [dsh-claude-move](https://github.com/PerryLink/dsh-claude-move) | Migra sesiones, memoria, skills y CLAUDE.md de Claude Code a DSH |
167
+
168
+ ## License
169
+
170
+ [LICENSE](LICENSE) (Apache License 2.0) © 2026 dsh-mask contributors
package/README.hi.md ADDED
@@ -0,0 +1,170 @@
1
+ <div align="center">
2
+
3
+ # dsh-mask
4
+
5
+ **DeepSeek Harness के लिए PII मास्किंग मिडलवेयर — मॉडल तक पहुँचने से पहले व्यक्तिगत डेटा को अनाम करें, डिस्प्ले लेयर पर उसे वापस लाएँ।**
6
+
7
+ *फ़ोन, ईमेल, आईडी कार्ड, बैंक कार्ड, कुंजियाँ आदि मॉडल सीमा पर प्लेसहोल्डर बन जाते हैं; मूल पाठ आपके सत्र लॉग में कभी नहीं जाता।*
8
+
9
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
10
+ [![DSH plugin](https://img.shields.io/badge/dsh-plugin-✅-green)](https://github.com/topics/dsh-plugin)
11
+ [![Node](https://img.shields.io/badge/node-%5E22.19%20%7C%7C%20%3E%3D24-brightgreen.svg)](#)
12
+ [![CI](https://img.shields.io/github/actions/workflow/status/PerryLink/dsh-mask/ci.yml?branch=main&label=CI)](https://github.com/PerryLink/dsh-mask/actions)
13
+ [![Version](https://img.shields.io/github/v/tag/PerryLink/dsh-mask?label=version)](https://github.com/PerryLink/dsh-mask/releases)
14
+ [![npm version](https://img.shields.io/npm/v/dsh-mask)](https://www.npmjs.com/package/dsh-mask)
15
+ [![npm downloads](https://img.shields.io/npm/dm/dsh-mask)](https://www.npmjs.com/package/dsh-mask)
16
+
17
+ [English](README.md) · [简体中文](README.zh.md) · [Español](README.es.md) · [Português](README.pt.md) · [हिन्दी](README.hi.md)
18
+
19
+ </div>
20
+
21
+ ---
22
+
23
+ ## Compatibility
24
+
25
+ | सतह | स्थिति |
26
+ |---|---|
27
+ | Harness | DeepSeek Harness `0.1.0-rc.6` |
28
+ | Node | `^22.19.0 \|\| >=24.0.0` |
29
+ | प्लेटफ़ॉर्म | जहाँ DSH चले (शुद्ध host, शून्य-निर्भरता regex; कोई ब्राउज़र आधा नहीं) |
30
+ | मॉडल | टेक्स्ट मॉडल पूर्ण रूप से समर्थित |
31
+
32
+ ## What you get
33
+
34
+ `dsh-mask` व्यक्तिगत डेटा को **मॉडल सीमा पर** अनाम करता है और पुनर्स्थापना तालिका रखता है:
35
+
36
+ - **अनुरोध से पहले मास्किंग** — `agent/pre-step` संदेशों को फिर से लिखता है ताकि फ़ोन, ईमेल, आईडी कार्ड, बैंक कार्ड, कुंजियाँ और IP (opt-in) `<PHONE_1>` जैसे प्लेसहोल्डर बन जाएँ। मास्क किया हुआ पाठ ही लॉग होता है और मॉडल को जाता है।
37
+ - **पुनर्स्थापना तालिका** — `प्लेसहोल्डर → मूल` नक्शा केवल मेमोरी और नियंत्रित स्टोरेज डोमेन (`dsh_mask`) में रहता है; मूल पाठ सत्र लॉग में कभी नहीं जाता।
38
+ - **बिना मूल पाठ की ऑडिट** — `mask/applied` इवेंट केवल «N मान बदले + प्रकार-वितरण» दर्ज करता है।
39
+ - **`/mask` कमांड** — `status`, `on`/`off`, `restore <text>`, `help`।
40
+ - **`mask_test` टूल** — एक अंश चलाकर प्लेसहोल्डर परिणाम देखें; मूल मान कभी नहीं दिखाता।
41
+
42
+ ```text
43
+ उपयोगकर्ता संदेश ──agent/pre-step──▶ प्लेसहोल्डर ──मॉडल──▶ प्लेसहोल्डर ──restore──▶ डिस्प्ले
44
+ ▲ │
45
+ └──── पुनर्स्थापना तालिका (मेमोरी + dsh_mask) ─┘
46
+ ```
47
+
48
+ ## Quick start
49
+
50
+ ```sh
51
+ dsh plugin --profile web add "github:PerryLink/dsh-mask#main"
52
+ # या npm से
53
+ dsh plugin --profile web add dsh-mask
54
+ dsh --profile web --dump-config | grep -A2 'id: mask'
55
+ ```
56
+
57
+ ```yaml
58
+ - insert:
59
+ - id: mask
60
+ name: dsh-mask
61
+ config:
62
+ entities: [phone, email, id-card, bank-card, key]
63
+ ```
64
+
65
+ ```
66
+ > /mask status
67
+ > /mask restore <PHONE_1>
68
+ ```
69
+
70
+ ## Install & uninstall
71
+
72
+ - **git चैनल**: `dsh plugin --profile web add "github:PerryLink/dsh-mask#main"` (`git+https://github.com/PerryLink/dsh-mask.git` के बराबर)। कोई build चरण नहीं।
73
+ - **npm चैनल**: `dsh plugin --profile web add dsh-mask`।
74
+ - **tarball चैनल**: `pnpm pack` फिर `dsh plugin --profile web add ./dsh-mask-<version>.tgz`।
75
+ - **अनइंस्टॉल**: `dsh plugin --profile web remove dsh-mask`।
76
+
77
+ ## Configuration
78
+
79
+ सभी विकल्प Schemastery `Config` फ़ील्ड हैं (cordis.yml से बदले जा सकते हैं)। `cordis.patch.yml` हर कुंजी का दस्तावेज़ देता है।
80
+
81
+ | कुंजी | डिफ़ॉल्ट | अर्थ |
82
+ |---|---|---|
83
+ | `enabled` | `true` | मुख्य स्विच |
84
+ | `mode` | `regex` | केवल `regex` लागू (`regex+ner` आरक्षित) |
85
+ | `entities` | `[phone, email, id-card, bank-card, key]` | PII प्रकार; `ip` opt-in, `person`/`address` को NER चाहिए |
86
+ | `scope` | `messages` | केवल `messages` लागू |
87
+ | `registerCommand` | `true` | `/mask` कमांड पंजीकृत करें |
88
+ | `registerTools` | `true` | `mask_test` टूल पंजीकृत करें |
89
+ | `persistRestoreTable` | `true` | तालिका को `dsh_mask` डोमेन में सहेजें |
90
+ | `maxRestoreEntriesPerSession` | `500` | प्रति सत्र प्रविष्टि सीमा |
91
+ | `maxSessions` | `1000` | मेमोरी में सत्र सीमा |
92
+
93
+ ## Tools & surfaces
94
+
95
+ | सतह | मूल पाठ दिखाता है | नोट्स |
96
+ |---|---|---|
97
+ | `agent/pre-step` मास्किंग | कभी नहीं | संदेशों को प्लेसहोल्डर में बदलता है |
98
+ | `/mask status` | कभी नहीं | स्थिति, कुल बदले, वितरण |
99
+ | `/mask on` / `/mask off` | कभी नहीं | रनटाइम टॉगल |
100
+ | `/mask restore <text>` | हाँ (स्पष्ट) | प्लेसहोल्डर को इस सत्र के मानों में बदलता है |
101
+ | `mask_test` | कभी नहीं | अंश को मास्क कर परिणाम देता है |
102
+
103
+ ## Permissions & data
104
+
105
+ - **अनुमतियाँ**: कोई नेटवर्क नहीं, कोई क्रेडेंशियल नहीं (`network:none`, `credentials:none`)।
106
+ - **डेटा**: `प्लेसहोल्डर → मूल` तालिका मेमोरी में और, `persistRestoreTable: true` होने पर, `dsh_mask` डोमेन में रहती है; सत्र लॉग में कभी नहीं।
107
+ - **सत्र लॉग**: `mask/applied` `types.d.ts` में घोषित है और केवल तब जोड़ा जाता है जब host प्रकार दर्ज करे।
108
+
109
+ ## Security boundaries
110
+
111
+ - **मूल पाठ सत्र लॉग में कभी नहीं जाता।** लॉग और मॉडल को मास्क रूप ही जाता है; मूल तालिका में रहते हैं।
112
+ - **दिखाने/लॉग से पहले सैनिटाइज़।** `lib/sanitize.mjs` PII, रहस्य और URL क्रेडेंशियल हटाता है।
113
+ - **नियंत्रित पुनर्स्थापना।** `/mask restore` एकमात्र स्पष्ट प्रकटीकरण सतह है।
114
+ - **फेल क्लोज़्ड।** अलागू `mode`/`scope`/इकाइयाँ और सीमा से बाहर संख्याएँ लोड पर विफल होती हैं।
115
+ - **पंजीकरण प्रभाव हैं।** listener, कमांड, टूल और डोमेन-बंद सभी Cordis effects हैं।
116
+
117
+ ## Known limitations
118
+
119
+ - **केवल regex।** `person` और `address` को बाहरी NER पहचानकर्ता चाहिए; लोड पर विफल। बॉक्स में: फ़ोन, ईमेल, आईडी कार्ड, बैंक कार्ड, कुंजी और IP (opt-in)।
120
+ - **डिस्प्ले-लेयर पुनर्स्थापना को क्लाइंट आधा चाहिए।** मास्किंग host-side है; UI बुलबुलों को खोलना एक ब्राउज़र-आधा सुविधा है जो यह शुद्ध-host रूप नहीं देता। तालिका और `restore()` पूर्ण host-side seam हैं।
121
+ - **`0.1.0-rc.6` इवेंट।** host अभी `mask/*` दर्ज नहीं करता, इसलिए ऑडिट appends छोड़े जाते हैं (सत्र लोड होते रहते हैं)।
122
+
123
+ ## Development
124
+
125
+ ```sh
126
+ pnpm install
127
+ pnpm run typecheck && pnpm run typecheck:ci
128
+ pnpm test
129
+ pnpm run verify:self-contained
130
+ pnpm run verify:artifacts
131
+ pnpm run check:readmes
132
+ pnpm pack
133
+ ```
134
+
135
+ कोई build चरण नहीं: शुद्ध ESM, `index.mjs` और `lib/` ही भेजे गए आर्टिफ़ैक्ट हैं।
136
+
137
+ ## Topics
138
+
139
+ `dsh`, `dsh-plugin`, `deepseek-harness`, `deepseek`, `cordis`, `pii`, `mask`, `privacy`, `anonymization`, `security`
140
+
141
+ ## Contributors
142
+
143
+ - [@PerryLink](https://github.com/PerryLink) — निर्माता और अनुरक्षक।
144
+
145
+ ## PerryLink DSH Plugin Family
146
+
147
+ यह परियोजना [PerryLink](https://github.com/PerryLink) द्वारा अनुरक्षित [DeepSeek Harness प्लगइनों](https://github.com/PerryLink) में से एक है। अगर यह आपकी मदद करता है, तो बाकी भी संभवतः करेंगे:
148
+
149
+ | प्लगइन | एक पंक्ति में |
150
+ |---|---|
151
+ | **[dsh-mask](https://github.com/PerryLink/dsh-mask)** | PII मास्किंग मिडलवेयर: मॉडल सीमा पर अनाम करें, डिस्प्ले लेयर पर पुनर्स्थापित करें |
152
+ | [dsh-mcp-panel](https://github.com/PerryLink/dsh-mcp-panel) | रीड-ओनली MCP रनटाइम पैनल: /mcp कमांड + सेटिंग्स टैब, स्थिति/टूल/त्रुटियाँ |
153
+ | [dsh-doublecheck](https://github.com/PerryLink/dsh-doublecheck) | इंजीनियरिंग-अनुशासन गार्ड: आवश्यकता पूछताछ, टेस्ट गेट, विरोधी समीक्षा |
154
+ | [dsh-background-agents](https://github.com/PerryLink/dsh-background-agents) | टिकाऊ पृष्ठभूमि चाइल्ड एजेंट: वेब साइडबार, संदेश और व्यवधान |
155
+ | [dsh-lsp-actions](https://github.com/PerryLink/dsh-lsp-actions) | LSP निदान, फ़ॉर्मेटिंग, पूर्णता, कोड क्रियाएँ और नाम बदलना |
156
+ | [dsh-output-styles](https://github.com/PerryLink/dsh-output-styles) | Claude Code outputStyles-समकक्ष रनटाइम शैली बदलाव |
157
+ | [dsh-checkpoint-rewind](https://github.com/PerryLink/dsh-checkpoint-rewind) | Claude Code /rewind-समकक्ष: स्नैपशॉट, सत्र fork, एक-क्लिक पुनर्स्थापना |
158
+ | [dsh-permission-rules](https://github.com/PerryLink/dsh-permission-rules) | Claude Code-शैली घोषणात्मक allow/deny/ask अनुमति नियम, ऑडिट सहित |
159
+ | [dsh-auto-review](https://github.com/PerryLink/dsh-auto-review) | अनुमोदन श्रृंखला पर दूसरे मॉडल की स्वतः समीक्षा, डिफ़ॉल्ट fail-closed |
160
+ | [dsh-memento](https://github.com/PerryLink/dsh-memento) | अनुमोदित क्रॉस-सत्र मेमोरी: ctx.memory seam + SQLite + memory टूल |
161
+ | [dsh-skill-pack-security](https://github.com/PerryLink/dsh-skill-pack-security) | सुरक्षा-ऑडिट स्किल पैक: सीक्रेट स्कैन, डिपेंडेंसी और सप्लाई-चेन समीक्षा |
162
+ | [dsh-session-pin](https://github.com/PerryLink/dsh-session-pin) | वेब साइडबार में सत्र पिन करें, टिकाऊ क्रम |
163
+ | [dsh-composer-history](https://github.com/PerryLink/dsh-composer-history) | वेब कम्पोज़र के लिए टर्मिनल-शैली इनपुट इतिहास: तीर, Ctrl+R खोज |
164
+ | [dsh-github](https://github.com/PerryLink/dsh-github) | DSH के लिए GitHub PR/issue एकीकरण, हर लेखन अनुमोदित |
165
+ | [dsh-plugin-guide](https://github.com/PerryLink/dsh-plugin-guide) | प्लगइन-विकास ज्ञान आधार, माँग पर एजेंट स्किल के रूप में |
166
+ | [dsh-claude-move](https://github.com/PerryLink/dsh-claude-move) | Claude Code के सत्र, मेमोरी, स्किल और CLAUDE.md को DSH में स्थानांतरित करें |
167
+
168
+ ## License
169
+
170
+ [LICENSE](LICENSE) (Apache License 2.0) © 2026 dsh-mask contributors