dsh-extra-paths 0.2.1 → 0.3.0

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 (52) hide show
  1. package/README.md +189 -28
  2. package/README.zh.md +163 -21
  3. package/lib/argv.js +96 -24
  4. package/lib/argv.js.map +1 -1
  5. package/lib/client.js +1169 -467
  6. package/lib/config.js +140 -44
  7. package/lib/config.js.map +1 -1
  8. package/lib/context.js +48 -12
  9. package/lib/context.js.map +1 -1
  10. package/lib/denial.js +132 -0
  11. package/lib/denial.js.map +1 -0
  12. package/lib/index.js +40 -5
  13. package/lib/index.js.map +1 -1
  14. package/lib/name-rule.js +217 -0
  15. package/lib/name-rule.js.map +1 -0
  16. package/lib/paths.js +155 -27
  17. package/lib/paths.js.map +1 -1
  18. package/lib/pattern.js +128 -62
  19. package/lib/pattern.js.map +1 -1
  20. package/lib/platform.js +325 -0
  21. package/lib/platform.js.map +1 -0
  22. package/lib/preview.js +47 -20
  23. package/lib/preview.js.map +1 -1
  24. package/lib/resolve.js +345 -64
  25. package/lib/resolve.js.map +1 -1
  26. package/lib/schema.js +19 -6
  27. package/lib/schema.js.map +1 -1
  28. package/lib/shell-dialect.js +92 -0
  29. package/lib/shell-dialect.js.map +1 -0
  30. package/lib/tool-guard.js +214 -0
  31. package/lib/tool-guard.js.map +1 -0
  32. package/lib/types/argv.d.ts +50 -12
  33. package/lib/types/config.d.ts +29 -13
  34. package/lib/types/context.d.ts +6 -1
  35. package/lib/types/denial.d.ts +88 -0
  36. package/lib/types/index.d.ts +8 -4
  37. package/lib/types/name-rule.d.ts +112 -0
  38. package/lib/types/paths.d.ts +55 -10
  39. package/lib/types/pattern.d.ts +43 -5
  40. package/lib/types/platform.d.ts +148 -0
  41. package/lib/types/preview.d.ts +39 -3
  42. package/lib/types/resolve.d.ts +129 -23
  43. package/lib/types/schema.d.ts +24 -8
  44. package/lib/types/shell-dialect.d.ts +60 -0
  45. package/lib/types/tool-guard.d.ts +103 -0
  46. package/lib/types/wrap-fs.d.ts +86 -4
  47. package/lib/types/wrap-sandbox.d.ts +26 -6
  48. package/lib/wrap-fs.js +323 -47
  49. package/lib/wrap-fs.js.map +1 -1
  50. package/lib/wrap-sandbox.js +149 -12
  51. package/lib/wrap-sandbox.js.map +1 -1
  52. package/package.json +1 -1
package/lib/wrap-fs.js CHANGED
@@ -1,6 +1,22 @@
1
1
  /**
2
2
  * The filesystem half of the plugin: a transparent Proxy over `ctx.fs` that
3
- * re-stamps ONE call's policy when its target lies under a configured root.
3
+ *
4
+ * 1. RE-FENCES every mutation whose target lies under a configured writable root
5
+ * (re-stamps ONE call's policy), and
6
+ * 2. ENFORCES the hard rules — a `deny` rule refuses content reads, listings,
7
+ * watching AND writes; a `read` rule refuses writes (a downgrade) even when the
8
+ * target is inside the writable workspace. Hard rules are user-written, so
9
+ * they hold under `danger-full-access` too.
10
+ *
11
+ * BARE NAMES (`.git`, `.env`, `node_modules`) are NAME RULES: they apply to that
12
+ * component at any depth under the session workspace plus every configured
13
+ * writable root. The fs surface matches them LEXICALLY on every call
14
+ * ({@link matchNameRule} over the target's components), never by walking the
15
+ * filesystem: a write may run once per tool call, so the enforcement layer must
16
+ * not pay for a directory tree and must also catch a directory created a moment
17
+ * ago. The shell surface is the only caller of the expensive bounded walk
18
+ * (`resolve.ts` with `expandNameRules`), because a sandbox profile can only name
19
+ * concrete paths.
4
20
  *
5
21
  * The host generation decides how many mutations this surface has. 0.2.0/0.2.1
6
22
  * fence `writeText`/`editText`; 0.2.2 additionally fences `patchText`,
@@ -9,6 +25,13 @@
9
25
  * actually exposes, and never invents one: on a 0.2.1 service the three newer
10
26
  * methods stay absent, exactly as the base class declared them.
11
27
  *
28
+ * Reads are guarded on the six content/listing/watch entry points
29
+ * (`readText`, `streamText`, `readBytes`, `readByteRange`, `listDir`, `watch`).
30
+ * The documented metadata boundary is deliberate: `stat`, `lstat`, `resolve`,
31
+ * `contains`, `processPath` and `fileUrl` expose existence/size/identity without
32
+ * reading content, and the host itself relies on them to probe paths — denying
33
+ * them would break the tool layer without protecting any content.
34
+ *
12
35
  * Transparency rules (verified against cordis 4.0.2 by
13
36
  * spike/cordis-get-wrap-baseline.mjs): forward every property with the inner
14
37
  * value as the receiver, bind methods to the inner instance — except
@@ -18,10 +41,84 @@
18
41
  */
19
42
  import { realpathSync, statSync } from 'node:fs';
20
43
  import { resolve as resolvePath } from 'node:path';
44
+ import { matchDenied, matchReadOnly, readDenied, writeDenied, writeReadOnly } from './denial.js';
21
45
  import { grantFor } from './grant.js';
22
- import { isUnder } from './paths.js';
46
+ import { findNameComponent } from './name-rule.js';
47
+ import { discoverPlatformFacts, isUnder } from './paths.js';
23
48
  import { syntheticPolicy } from './policy.js';
24
- import { resolveRoots } from './resolve.js';
49
+ import { nameScopeRoots, resolveRoots, } from './resolve.js';
50
+ /** The list of read methods, so one loop covers all six identically. */
51
+ const READ_METHODS = ['readText', 'streamText', 'readBytes', 'readByteRange', 'listDir', 'watch'];
52
+ /**
53
+ * The first name rule in `rules` that covers `targetKey` on `surface`.
54
+ *
55
+ * This is the ONE lexical name-rule test both enforcement surfaces share (the
56
+ * fs wrapper per call and the tool-layer guard per tool execution): a second
57
+ * implementation could let one surface's scope drift from the other. Callers pass
58
+ * the rule list prefiltered by access level (deny, read, or the grant set), so
59
+ * one rule list maps to one decision.
60
+ * @param rules - name rules to test, already filtered by access and intent.
61
+ * @param surface - the enforcement surface asking.
62
+ * @param targetKey - the fresh canonical target path (may name a missing suffix).
63
+ * @param scopeRoots - {@link nameScopeRoots} output for the same report.
64
+ * @param facts - host facts.
65
+ * @returns the matched rule and component path, or undefined (no opinion).
66
+ */
67
+ export function matchNameRule(rules, surface, targetKey, scopeRoots, facts) {
68
+ for (const rule of rules) {
69
+ if (!rule.surfaces.includes(surface))
70
+ continue;
71
+ const root = findNameComponent(targetKey, rule.name, scopeRoots, facts);
72
+ if (root !== undefined)
73
+ return { rule, root };
74
+ }
75
+ return undefined;
76
+ }
77
+ /**
78
+ * A rule-shaped view of a name-rule hit, so `denial.ts`'s message helpers apply
79
+ * to name rules unchanged. Callers pass only deny/read rule lists (a grant is
80
+ * never a refusal, and `write` maps to the `read` message level).
81
+ * @param hit - the matched name rule and component path.
82
+ * @returns the `ResolvedRule`-like value the message builders take.
83
+ */
84
+ export function nameRuleHitAsResolvedRule(hit) {
85
+ return {
86
+ raw: hit.rule.raw,
87
+ root: hit.root,
88
+ access: hit.rule.access === 'deny' ? 'deny' : 'read',
89
+ surfaces: [...hit.rule.surfaces],
90
+ };
91
+ }
92
+ /** Keep only the fs-surface rules of one resolved report, splitting literal from name rules. */
93
+ function fsHardRulesOf(report) {
94
+ return {
95
+ denied: report.denied.filter(rule => rule.surfaces.includes('fs')),
96
+ readOnly: report.readOnly.filter(rule => rule.surfaces.includes('fs')),
97
+ nameDenied: report.nameRules.filter(rule => rule.access === 'deny' && rule.surfaces.includes('fs')),
98
+ nameReadOnly: report.nameRules.filter(rule => rule.access === 'read' && rule.surfaces.includes('fs')),
99
+ };
100
+ }
101
+ /** Whether any hard rule — literal or name — could refuse a write. */
102
+ function hasHardRules(hard) {
103
+ return hard.denied.length > 0
104
+ || hard.readOnly.length > 0
105
+ || hard.nameDenied.length > 0
106
+ || hard.nameReadOnly.length > 0;
107
+ }
108
+ /**
109
+ * The name rules that GRANT a write on one surface under `mode`, mirroring
110
+ * `grantFor`'s mode gate exactly: `write` rides `workspace-write`, `always-write`
111
+ * survives `read-only` (the caller never reaches this under
112
+ * `danger-full-access`: there is no fence to widen).
113
+ * @param report - the resolved report.
114
+ * @param surface - the enforcement surface asking.
115
+ * @param mode - the resolved per-call mode.
116
+ * @returns the granting name rules, in configured order.
117
+ */
118
+ function grantingNameRules(report, surface, mode) {
119
+ return report.nameRules.filter(rule => rule.surfaces.includes(surface)
120
+ && (rule.access === 'always-write' || (rule.access === 'write' && mode === 'workspace-write')));
121
+ }
25
122
  /**
26
123
  * Whether a service is the sandboxed filesystem: mutating methods plus the
27
124
  * capability fact (`sandboxMode`) that only a confining backend exposes.
@@ -52,78 +149,257 @@ function isPhysicalDirectory(path) {
52
149
  return false;
53
150
  }
54
151
  }
152
+ /**
153
+ * Whether the configuration COULD produce a document-wide hard rule (a
154
+ * `deny`/`read` entry on the fs surface — a BARE NAME rule included: it is an
155
+ * entry like any other, it just matches at many depths). This is the cheap
156
+ * pre-check that keeps a legacy write-only document from paying a resolution on
157
+ * every read.
158
+ * @param config - the live configuration.
159
+ * @returns true when at least one restriction entry exists for `fs`.
160
+ */
161
+ function hasFsRestrictionEntries(config) {
162
+ return config.paths.some(entry => (entry.access === 'deny' || entry.access === 'read') && entry.surfaces.includes('fs'));
163
+ }
164
+ /** The same pre-check for deny rules alone (what a READ can be refused by). */
165
+ function hasFsDenyEntries(config) {
166
+ return config.paths.some(entry => entry.access === 'deny' && entry.surfaces.includes('fs'));
167
+ }
168
+ /**
169
+ * The lazily resolved view of ONE call: the report and the name-rule scope roots
170
+ * derived from it.
171
+ *
172
+ * Why lazy: a write under `danger-full-access` (or a caller-less call) must not
173
+ * pay for a report nothing will consult — that is the "no resolve, no re-stamp"
174
+ * pin. Why shared per call: the hard-rule check and the grant translation used
175
+ * to resolve TWICE, so a concurrent change could make one see a rule the other
176
+ * did not. One report, one scope, one decision.
177
+ * @param config - the live configuration snapshot of this call.
178
+ * @param baseRoot - the workspace the report and the name scope resolve against.
179
+ * @param facts - host facts.
180
+ * @returns accessors that build each value at most once.
181
+ */
182
+ function callResolution(config, baseRoot, facts) {
183
+ let report;
184
+ let scopeRoots;
185
+ return {
186
+ report: () => (report ??= resolveRoots(config, baseRoot, facts)),
187
+ scopeRoots: () => {
188
+ const resolved = (report ??= resolveRoots(config, baseRoot, facts));
189
+ return (scopeRoots ??= nameScopeRoots(resolved, baseRoot, facts));
190
+ },
191
+ };
192
+ }
55
193
  /**
56
194
  * Wrap one filesystem service.
57
195
  * @param inner - the service instance read from the context.
58
196
  * @param deps - configuration and policy sources.
59
- * @returns a transparent proxy that grants configured roots on mutation.
197
+ * @returns a transparent proxy that refuses hard-rule violations and grants
198
+ * configured writable roots on mutation.
60
199
  */
61
200
  export function wrapFs(inner, deps) {
62
201
  const bound = new Map();
63
- /** Roots this call grants, or an empty list when the target set is not covered. */
64
- const grantedFor = (policy) => grantFor(policy.mode, resolveRoots(deps.readConfig(), policy.workspaceRoot).roots, 'fs');
65
- const translate = async (target, policy, delegate) => {
66
- if (policy === undefined || policy.mode === 'danger-full-access')
67
- return delegate(policy);
68
- const granted = grantedFor(policy);
69
- if (granted.length === 0)
70
- return delegate(policy);
71
- // Re-canonicalise NOW, exactly like the base fence does, so the identity we
72
- // matched is the identity the base will check.
73
- const fresh = await inner.resolve(target.displayPath);
74
- const match = granted.find(root => isUnder(String(fresh.targetKey), root.root));
75
- if (match === undefined)
76
- return delegate(policy);
77
- return delegate(syntheticPolicy(policy, match.root));
202
+ /**
203
+ * Refuse a content read when a `deny` rule (literal or name) covers the
204
+ * caller-resolved target.
205
+ *
206
+ * Reads carry no per-call policy, so the resolution base is the deployment
207
+ * fallback's workspace (relative deny rules are best effort here; the tool
208
+ * layer's guard resolves them against the SESSION cwd instead). The same base
209
+ * is the workspace scope root of a name rule, which is exactly what the shell
210
+ * expansion and the preview used — one scope definition, no surface drift.
211
+ * @param target - the resolved target the read is about.
212
+ * @throws {AccessDeniedError} when a deny rule covers the target.
213
+ */
214
+ const assertReadAllowed = (target) => {
215
+ const config = deps.readConfig();
216
+ if (!hasFsDenyEntries(config))
217
+ return;
218
+ const baseRoot = deps.fallbackPolicy()?.workspaceRoot ?? process.cwd();
219
+ const facts = discoverPlatformFacts();
220
+ const report = resolveRoots(config, baseRoot, facts);
221
+ const hard = fsHardRulesOf(report);
222
+ if (hard.denied.length === 0 && hard.nameDenied.length === 0)
223
+ return;
224
+ const targetKey = String(target.targetKey);
225
+ const rule = matchDenied(hard.denied, 'fs', targetKey, facts);
226
+ if (rule !== undefined)
227
+ throw readDenied(target.displayPath, rule);
228
+ const nameHit = matchNameRule(hard.nameDenied, 'fs', targetKey, nameScopeRoots(report, baseRoot, facts), facts);
229
+ if (nameHit !== undefined)
230
+ throw readDenied(target.displayPath, nameRuleHitAsResolvedRule(nameHit));
231
+ };
232
+ /**
233
+ * Refuse a write when a `deny` (first) or `read` rule covers the target, on
234
+ * either the literal or the name-rule side.
235
+ *
236
+ * Deny wins over read-only across BOTH kinds (`deny` on a name rule must not
237
+ * lose to a literal read rule), and every check runs BEFORE any grant elevation
238
+ * or backend delegation: a hard rule is never overridden by a broader writable
239
+ * ancestor. They are also checked under `danger-full-access` — the host does not
240
+ * confine then, so this is the only layer left.
241
+ * @param hard - the fs-surface hard rules of the resolved report.
242
+ * @param displayPath - the target as the caller spelled it (for the message).
243
+ * @param targetKey - the freshly re-canonicalised target identity.
244
+ * @param scopeRoots - name-rule scope roots for this report.
245
+ * @param facts - host facts.
246
+ * @throws {AccessDeniedError} when a hard rule covers the target.
247
+ */
248
+ const assertWritable = (hard, displayPath, targetKey, scopeRoots, facts) => {
249
+ const denied = matchDenied(hard.denied, 'fs', targetKey, facts);
250
+ if (denied !== undefined)
251
+ throw writeDenied(displayPath, denied);
252
+ const nameDenied = matchNameRule(hard.nameDenied, 'fs', targetKey, scopeRoots, facts);
253
+ if (nameDenied !== undefined)
254
+ throw writeDenied(displayPath, nameRuleHitAsResolvedRule(nameDenied));
255
+ const readOnly = matchReadOnly(hard.readOnly, 'fs', targetKey, facts);
256
+ if (readOnly !== undefined)
257
+ throw writeReadOnly(displayPath, readOnly);
258
+ const nameReadOnly = matchNameRule(hard.nameReadOnly, 'fs', targetKey, scopeRoots, facts);
259
+ if (nameReadOnly !== undefined)
260
+ throw writeReadOnly(displayPath, nameRuleHitAsResolvedRule(nameReadOnly));
261
+ };
262
+ const translate = async (target, callerPolicy, delegate) => {
263
+ const config = deps.readConfig();
264
+ const effective = callerPolicy ?? deps.fallbackPolicy();
265
+ const facts = discoverPlatformFacts();
266
+ // Every relative restriction (and the name-rule workspace scope) resolves
267
+ // against the policy workspace when one exists, exactly like the base fence.
268
+ const baseRoot = effective?.workspaceRoot ?? process.cwd();
269
+ const resolution = callResolution(config, baseRoot, facts);
270
+ // Re-canonicalise ONCE, exactly like the base fence does: the identity a hard
271
+ // rule judges and the identity a grant matches must be the same fresh one.
272
+ let fresh;
273
+ const freshOf = async () => {
274
+ if (fresh === undefined)
275
+ fresh = await inner.resolve(target.displayPath);
276
+ return fresh;
277
+ };
278
+ const targetKeyOf = async () => String((await freshOf()).targetKey);
279
+ // Hard rules first, in EVERY mode: a deny/read rule is an explicit user rule,
280
+ // not a consequence of the session mode. Name rules match the same fresh
281
+ // canonical identity, lexically, at any depth under the scope roots.
282
+ if (hasFsRestrictionEntries(config)) {
283
+ const hard = fsHardRulesOf(resolution.report());
284
+ if (hasHardRules(hard))
285
+ assertWritable(hard, target.displayPath, await targetKeyOf(), resolution.scopeRoots(), facts);
286
+ }
287
+ if (effective === undefined || effective.mode === 'danger-full-access')
288
+ return delegate(effective);
289
+ const granted = grantFor(effective.mode, resolution.report().roots, 'fs');
290
+ const nameGrants = grantingNameRules(resolution.report(), 'fs', effective.mode);
291
+ if (granted.length === 0 && nameGrants.length === 0)
292
+ return delegate(effective);
293
+ const targetKey = await targetKeyOf();
294
+ // Literal grants win over name rules: the name rule is the fallback spelling
295
+ // for "this structure anywhere", and the literal entry is the more specific
296
+ // statement of the same intent (the same reason a nested literal root is not
297
+ // narrowed by its child in the report).
298
+ const match = granted.find(root => isUnder(targetKey, root.root, facts));
299
+ if (match !== undefined)
300
+ return delegate(syntheticPolicy(effective, match.root));
301
+ const nameGrant = matchNameRule(nameGrants, 'fs', targetKey, resolution.scopeRoots(), facts);
302
+ if (nameGrant !== undefined)
303
+ return delegate(syntheticPolicy(effective, nameGrant.root));
304
+ return delegate(effective);
78
305
  };
79
306
  /**
80
- * A move is one call with TWO fenced targets. Both ends must land in the
81
- * configured set; one policy then carries the union. When the ends share one
82
- * configured root the workspace-root re-stamp is enough on every host; two
83
- * different roots are expressed through `additionalWritableRoots` (0.2.2+,
84
- * the only host generation that has `moveFile` at all).
307
+ * A move is one call with TWO fenced targets. Both ends must pass the hard
308
+ * rules (literal and name), and both must land in the configured set: one
309
+ * policy then carries the union. When the ends share one configured root (or
310
+ * one matched name component) the workspace-root re-stamp is enough on every
311
+ * host; two different roots are expressed through `additionalWritableRoots`
312
+ * (0.2.2+, the only host generation that has `moveFile` at all).
85
313
  */
86
- const translateMove = async (source, destination, policy, delegate) => {
87
- if (policy === undefined || policy.mode === 'danger-full-access')
88
- return delegate(policy);
89
- const granted = grantedFor(policy);
90
- if (granted.length === 0)
91
- return delegate(policy);
92
- const [freshSource, freshDestination] = await Promise.all([
93
- inner.resolve(source.displayPath),
94
- inner.resolve(destination.displayPath),
95
- ]);
96
- const sourceRoot = granted.find(root => isUnder(String(freshSource.targetKey), root.root));
97
- const destinationRoot = granted.find(root => isUnder(String(freshDestination.targetKey), root.root));
314
+ const translateMove = async (source, destination, callerPolicy, delegate) => {
315
+ const config = deps.readConfig();
316
+ const effective = callerPolicy ?? deps.fallbackPolicy();
317
+ const facts = discoverPlatformFacts();
318
+ const baseRoot = effective?.workspaceRoot ?? process.cwd();
319
+ const resolution = callResolution(config, baseRoot, facts);
320
+ // Both ends are re-canonicalised ONCE and shared by the hard rules and the
321
+ // grant translation, so a single call cannot judge two different identities.
322
+ let freshSource;
323
+ let freshDestination;
324
+ const resolveBoth = async () => {
325
+ if (freshSource === undefined || freshDestination === undefined) {
326
+ const [resolvedSource, resolvedDestination] = await Promise.all([
327
+ inner.resolve(source.displayPath),
328
+ inner.resolve(destination.displayPath),
329
+ ]);
330
+ freshSource = resolvedSource;
331
+ freshDestination = resolvedDestination;
332
+ }
333
+ return [freshSource, freshDestination];
334
+ };
335
+ if (hasFsRestrictionEntries(config)) {
336
+ const hard = fsHardRulesOf(resolution.report());
337
+ if (hasHardRules(hard)) {
338
+ const [resolvedSource, resolvedDestination] = await resolveBoth();
339
+ const scopeRoots = resolution.scopeRoots();
340
+ assertWritable(hard, source.displayPath, String(resolvedSource.targetKey), scopeRoots, facts);
341
+ assertWritable(hard, destination.displayPath, String(resolvedDestination.targetKey), scopeRoots, facts);
342
+ }
343
+ }
344
+ if (effective === undefined || effective.mode === 'danger-full-access')
345
+ return delegate(effective);
346
+ const granted = grantFor(effective.mode, resolution.report().roots, 'fs');
347
+ const nameGrants = grantingNameRules(resolution.report(), 'fs', effective.mode);
348
+ if (granted.length === 0 && nameGrants.length === 0)
349
+ return delegate(effective);
350
+ const [resolvedSource, resolvedDestination] = await resolveBoth();
351
+ // The effective root of one end: the literal grant first, then the matched
352
+ // name component (the same precedence `translate` uses).
353
+ const grantRootOf = (targetKey) => {
354
+ const literal = granted.find(root => isUnder(targetKey, root.root, facts));
355
+ if (literal !== undefined)
356
+ return literal.root;
357
+ return matchNameRule(nameGrants, 'fs', targetKey, resolution.scopeRoots(), facts)?.root;
358
+ };
359
+ const sourceRoot = grantRootOf(String(resolvedSource.targetKey));
360
+ const destinationRoot = grantRootOf(String(resolvedDestination.targetKey));
98
361
  if (sourceRoot === undefined || destinationRoot === undefined)
99
- return delegate(policy);
362
+ return delegate(effective);
100
363
  if (sourceRoot === destinationRoot)
101
- return delegate(syntheticPolicy(policy, sourceRoot.root));
102
- const roots = [sourceRoot.root, destinationRoot.root];
364
+ return delegate(syntheticPolicy(effective, sourceRoot));
365
+ const roots = [sourceRoot, destinationRoot];
103
366
  if (!roots.every(isPhysicalDirectory))
104
- return delegate(policy);
105
- return delegate(syntheticPolicy(policy, sourceRoot.root, [destinationRoot.root]));
367
+ return delegate(effective);
368
+ return delegate(syntheticPolicy(effective, sourceRoot, [destinationRoot]));
106
369
  };
107
370
  // Built ONCE per wrapper: reading a method twice must hand back the same
108
371
  // function (and a fresh closure per read is pure allocation). Nothing here
109
372
  // captures read-time state — the policy is resolved inside each call.
110
- const writeText = (t, content, expected, signal, policy) => translate(t, policy ?? deps.fallbackPolicy(), effective => inner.writeText(t, content, expected, signal, effective));
111
- const editText = (t, edit, expected, signal, policy) => translate(t, policy ?? deps.fallbackPolicy(), effective => inner.editText(t, edit, expected, signal, effective));
112
- const patchText = (t, hunks, expected, signal, policy) => translate(t, policy ?? deps.fallbackPolicy(), effective => inner.patchText(t, hunks, expected, signal, effective));
113
- const deleteFile = (t, expected, signal, policy) => translate(t, policy ?? deps.fallbackPolicy(), effective => inner.deleteFile(t, expected, signal, effective));
114
- const moveFile = (source, destination, options, signal, policy) => translateMove(source, destination, policy ?? deps.fallbackPolicy(), effective => inner.moveFile(source, destination, options, signal, effective));
373
+ const writeText = (t, content, expected, signal, policy) => translate(t, policy, effective => inner.writeText(t, content, expected, signal, effective));
374
+ const editText = (t, edit, expected, signal, policy) => translate(t, policy, effective => inner.editText(t, edit, expected, signal, effective));
375
+ const patchText = (t, hunks, expected, signal, policy) => translate(t, policy, effective => inner.patchText(t, hunks, expected, signal, effective));
376
+ const deleteFile = (t, expected, signal, policy) => translate(t, policy, effective => inner.deleteFile(t, expected, signal, effective));
377
+ const moveFile = (source, destination, options, signal, policy) => translateMove(source, destination, policy, effective => inner.moveFile(source, destination, options, signal, effective));
115
378
  const overrides = new Map([
116
379
  ['writeText', writeText],
117
380
  ['editText', editText],
118
381
  ]);
119
382
  // Only override what the running host declares: a 0.2.1 service must keep
120
- // answering `undefined` for the 0.2.2-only mutations.
383
+ // answering `undefined` for the 0.2.2-only mutations, and a stub without reads
384
+ // must keep answering `undefined` for them too.
121
385
  if (typeof inner.patchText === 'function')
122
386
  overrides.set('patchText', patchText);
123
387
  if (typeof inner.deleteFile === 'function')
124
388
  overrides.set('deleteFile', deleteFile);
125
389
  if (typeof inner.moveFile === 'function')
126
390
  overrides.set('moveFile', moveFile);
391
+ // Reads are guarded only when the inner declares them: the deny check is the
392
+ // FIRST thing that runs, before the backend can touch the file. The delegate
393
+ // result is returned as-is (no `async` wrapper), keeping sync backends sync.
394
+ for (const method of READ_METHODS) {
395
+ const impl = inner[method];
396
+ if (typeof impl !== 'function')
397
+ continue;
398
+ overrides.set(method, (target, ...rest) => {
399
+ assertReadAllowed(target);
400
+ return impl.call(inner, target, ...rest);
401
+ });
402
+ }
127
403
  return new Proxy(inner, {
128
404
  get(target, prop) {
129
405
  const override = overrides.get(prop);
@@ -1 +1 @@
1
- {"version":3,"file":"wrap-fs.js","sourceRoot":"","sources":["../src/wrap-fs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAChD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAA;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAAE,eAAe,EAAmB,MAAM,aAAa,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAqB,MAAM,cAAc,CAAA;AA8B9D;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,MAAM,EAAE,GAAG,KAAgC,CAAA;IAC3C,OAAO,OAAO,EAAE,EAAE,SAAS,KAAK,UAAU;WACrC,OAAO,EAAE,CAAC,QAAQ,KAAK,UAAU;WACjC,OAAO,EAAE,CAAC,OAAO,KAAK,UAAU;WAChC,OAAO,EAAE,CAAC,WAAW,KAAK,QAAQ,CAAA;AACzC,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,mBAAmB,CAAC,IAAY;IACvC,IAAI,CAAC;QACH,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,IAAI,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,WAAW,CAAC,IAAI,CAAC,CAAA;IACxF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,KAAkB,EAAE,IAAgB;IACzD,MAAM,KAAK,GAAG,IA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