@procedures/fs 0.7.0 → 0.8.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.
@@ -0,0 +1,64 @@
1
+ /**
2
+ * The root of the files for all the procedures of a registry (roadmap R33).
3
+ *
4
+ * `confineFsProcedures()` gives the `fs.*` procedures the handlers of the root. The other
5
+ * procedures reach files too: they read with `node:fs`, or they start a program. This file
6
+ * applies the rules that each procedure declares in `metadata.fsRoot` (`FsRootRules` of the core):
7
+ *
8
+ * - **confined**: the procedure names its path inputs. The host examines each of them before the
9
+ * handler starts. A working folder that the call does not give is the root. A path of `paths`
10
+ * starts at the root, and the handler gets it absolute. A path of `names` starts at the working
11
+ * folder, and the handler gets it as the caller gave it (a program resolves it the same way).
12
+ * - **program**: the procedure starts the program of its input (`shell.run`). The host refuses a
13
+ * call of a client. It accepts the nested call of a confined procedure that names the program
14
+ * procedure in `metadata.calls`: that caller chose the program and its arguments.
15
+ * - **refused**: the rules give the reason that the root cannot confine the procedure.
16
+ *
17
+ * A procedure without rules gets a decision from its effects. The decision fails closed: the host
18
+ * refuses the procedure when its effects are not known, when it reads or writes `fs`, or when it
19
+ * writes `process`. A data-driven procedure stays as it is: it reaches files only through its
20
+ * nested calls, and each nested call gets the rules of its own procedure.
21
+ *
22
+ * Each refusal is the error of a path outside the root: `FORBIDDEN` with the reason `outside-root`.
23
+ */
24
+ import { type AnyProcedure, type FsRootRules, type ProcedureRegistry } from "@procedures/client";
25
+ /** What a root does to a procedure. */
26
+ export type RootKind = "fs" | "confined" | "program" | "refused" | "unchanged";
27
+ /** The decision of a root for one procedure. */
28
+ export interface RootDecision {
29
+ readonly kind: RootKind;
30
+ /** For the kind `refused`: the reason. */
31
+ readonly reason?: string;
32
+ }
33
+ /**
34
+ * This function gives the rules of a procedure, or undefined when it has none. It throws for
35
+ * rules that are not correct, because the root cannot apply them.
36
+ */
37
+ export declare function rootRulesOf(procedure: Pick<AnyProcedure, "path" | "metadata">): FsRootRules | undefined;
38
+ /**
39
+ * This function tells what a root does to a procedure, without a root. It throws for rules that
40
+ * are not correct. `confineToRoot()` uses the same decision.
41
+ */
42
+ export declare function rootDecisionOf(procedure: Pick<AnyProcedure, "path" | "metadata" | "handler">): RootDecision;
43
+ /** What `confineToRoot()` did. Each list holds the keys of the procedures. */
44
+ export interface ConfinedRegistry {
45
+ /** The absolute path of the root. */
46
+ root: string;
47
+ /** The `fs.*` procedures: they have the handlers of `createFsModule({ root })`. */
48
+ fs: string[];
49
+ /** The procedures whose path inputs the root examines. */
50
+ confined: string[];
51
+ /** The procedures that start the program of their input: only as a nested call of a confined procedure. */
52
+ programs: string[];
53
+ /** The procedures that the root refuses. */
54
+ refused: string[];
55
+ /** The procedures that reach no file: the root does not change them. */
56
+ unchanged: string[];
57
+ }
58
+ /**
59
+ * This function applies the decision of each procedure of the registry, except `fs.*`, to a root
60
+ * that exists. It replaces the handler of each confined, program and refused procedure, and it
61
+ * adds no procedure. `confineToRoot()` of the module starts it after the `fs.*` procedures.
62
+ */
63
+ export declare function confineOtherProcedures(registry: ProcedureRegistry, folder: string): Omit<ConfinedRegistry, "root" | "fs">;
64
+ //# sourceMappingURL=confine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confine.d.ts","sourceRoot":"","sources":["../src/confine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAQL,KAAK,YAAY,EACjB,KAAK,WAAW,EAGhB,KAAK,iBAAiB,EACvB,MAAM,oBAAoB,CAAC;AAG5B,uCAAuC;AACvC,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,CAAC;AAE/E,gDAAgD;AAChD,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,0CAA0C;IAC1C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAkBD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,UAAU,CAAC,GAAG,WAAW,GAAG,SAAS,CAwBvG;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC,GAAG,YAAY,CAoB3G;AAED,8EAA8E;AAC9E,MAAM,WAAW,gBAAgB;IAC/B,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,mFAAmF;IACnF,EAAE,EAAE,MAAM,EAAE,CAAC;IACb,0DAA0D;IAC1D,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,2GAA2G;IAC3G,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,4CAA4C;IAC5C,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,wEAAwE;IACxE,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAwDD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC,CAgDzH"}
@@ -0,0 +1,213 @@
1
+ /**
2
+ * The root of the files for all the procedures of a registry (roadmap R33).
3
+ *
4
+ * `confineFsProcedures()` gives the `fs.*` procedures the handlers of the root. The other
5
+ * procedures reach files too: they read with `node:fs`, or they start a program. This file
6
+ * applies the rules that each procedure declares in `metadata.fsRoot` (`FsRootRules` of the core):
7
+ *
8
+ * - **confined**: the procedure names its path inputs. The host examines each of them before the
9
+ * handler starts. A working folder that the call does not give is the root. A path of `paths`
10
+ * starts at the root, and the handler gets it absolute. A path of `names` starts at the working
11
+ * folder, and the handler gets it as the caller gave it (a program resolves it the same way).
12
+ * - **program**: the procedure starts the program of its input (`shell.run`). The host refuses a
13
+ * call of a client. It accepts the nested call of a confined procedure that names the program
14
+ * procedure in `metadata.calls`: that caller chose the program and its arguments.
15
+ * - **refused**: the rules give the reason that the root cannot confine the procedure.
16
+ *
17
+ * A procedure without rules gets a decision from its effects. The decision fails closed: the host
18
+ * refuses the procedure when its effects are not known, when it reads or writes `fs`, or when it
19
+ * writes `process`. A data-driven procedure stays as it is: it reaches files only through its
20
+ * nested calls, and each nested call gets the rules of its own procedure.
21
+ *
22
+ * Each refusal is the error of a path outside the root: `FORBIDDEN` with the reason `outside-root`.
23
+ */
24
+ import { callMatches, declaredCalls, effectsOf, isDataDriven, pathToKey, scopeOf, withScope, } from "@procedures/client";
25
+ import { inRoot, outsideRoot, resolveRoot } from "./root.js";
26
+ /** The resource name of the files of the host (CAPABILITIES-2026-10). */
27
+ const FILES = "fs";
28
+ /** The resource name of a procedure that starts any program. */
29
+ const PROGRAMS = "process";
30
+ /** The keys of the rules that `FsRootRules` has. */
31
+ const RULE_KEYS = new Set(["cwd", "paths", "names", "required", "values", "refuse", "program"]);
32
+ /** The procedure key of a path, for the messages. */
33
+ const keyOf = (procedure) => pathToKey(procedure.path);
34
+ /** True for a list of names that are not empty. */
35
+ function isNameList(value) {
36
+ return Array.isArray(value) && value.every((name) => typeof name === "string" && name.length > 0);
37
+ }
38
+ /**
39
+ * This function gives the rules of a procedure, or undefined when it has none. It throws for
40
+ * rules that are not correct, because the root cannot apply them.
41
+ */
42
+ export function rootRulesOf(procedure) {
43
+ const rules = procedure.metadata?.fsRoot;
44
+ if (rules === undefined)
45
+ return undefined;
46
+ const invalid = (problem) => new Error(`The metadata.fsRoot of ${keyOf(procedure)} is not correct: ${problem}`);
47
+ if (rules === null || typeof rules !== "object" || Array.isArray(rules))
48
+ throw invalid("it must be an object");
49
+ const record = rules;
50
+ for (const key of Object.keys(record)) {
51
+ if (!RULE_KEYS.has(key))
52
+ throw invalid(`it has the unknown key ${key}`);
53
+ }
54
+ if (record["cwd"] !== undefined && (typeof record["cwd"] !== "string" || record["cwd"] === ""))
55
+ throw invalid("cwd must be the name of an input");
56
+ for (const key of ["paths", "names", "required", "values"]) {
57
+ if (record[key] !== undefined && !isNameList(record[key]))
58
+ throw invalid(`${key} must be a list of texts`);
59
+ }
60
+ if (record["refuse"] !== undefined && (typeof record["refuse"] !== "string" || record["refuse"] === ""))
61
+ throw invalid("refuse must be the reason, as text");
62
+ if (record["program"] !== undefined && typeof record["program"] !== "boolean")
63
+ throw invalid("program must be true or false");
64
+ const typed = rules;
65
+ if (typed.refuse !== undefined && Object.keys(record).length > 1)
66
+ throw invalid("refuse cannot go with other rules");
67
+ const paths = new Set(typed.paths ?? []);
68
+ for (const name of typed.required ?? []) {
69
+ if (!paths.has(name))
70
+ throw invalid(`the required input ${name} is not in paths`);
71
+ }
72
+ const inputs = [...(typed.cwd !== undefined ? [typed.cwd] : []), ...(typed.paths ?? []), ...(typed.names ?? [])];
73
+ if (new Set(inputs).size !== inputs.length)
74
+ throw invalid("an input is in more than one of cwd, paths and names");
75
+ return typed;
76
+ }
77
+ /**
78
+ * This function tells what a root does to a procedure, without a root. It throws for rules that
79
+ * are not correct. `confineToRoot()` uses the same decision.
80
+ */
81
+ export function rootDecisionOf(procedure) {
82
+ if (procedure.path[0] === FILES)
83
+ return { kind: "fs" };
84
+ const rules = rootRulesOf(procedure);
85
+ if (rules !== undefined) {
86
+ if (rules.refuse !== undefined)
87
+ return { kind: "refused", reason: rules.refuse };
88
+ return { kind: rules.program === true ? "program" : "confined" };
89
+ }
90
+ // A data-driven procedure runs the refs of its caller: each nested call gets its own decision
91
+ if (isDataDriven(procedure))
92
+ return { kind: "unchanged" };
93
+ const effects = effectsOf(procedure);
94
+ if (effects?.reads === undefined || effects.writes === undefined) {
95
+ return { kind: "refused", reason: "it declares no effects and no metadata.fsRoot, so its files are not known" };
96
+ }
97
+ if (effects.reads.includes(FILES) || effects.writes.includes(FILES)) {
98
+ return { kind: "refused", reason: "it reads or writes files, and it declares no metadata.fsRoot" };
99
+ }
100
+ if (effects.writes.includes(PROGRAMS)) {
101
+ return { kind: "refused", reason: "it starts a program, and it declares no metadata.fsRoot" };
102
+ }
103
+ return { kind: "unchanged" };
104
+ }
105
+ /** The values of a path input: a text, or a list of texts. Another value cannot be examined. */
106
+ function pathValues(value, name, at) {
107
+ if (typeof value === "string")
108
+ return [value];
109
+ if (Array.isArray(value) && value.every((item) => typeof item === "string"))
110
+ return value;
111
+ throw outsideRoot(at, `the input ${name} is not a path or a list of paths, so the root cannot examine it`);
112
+ }
113
+ /**
114
+ * This function gives the input with each path in the root. The working folder that the call does
115
+ * not give is the root. Each path of `paths` starts at the root and becomes absolute. A path of
116
+ * `names` starts at the working folder, and it stays as it is.
117
+ */
118
+ async function confinedInput(input, rules, root, at) {
119
+ const examines = rules.cwd !== undefined || (rules.paths?.length ?? 0) > 0 || (rules.names?.length ?? 0) > 0;
120
+ if (!examines)
121
+ return input;
122
+ if (input === null || typeof input !== "object" || Array.isArray(input)) {
123
+ throw outsideRoot(at, "the input is not an object, so the root cannot examine its paths");
124
+ }
125
+ const given = input;
126
+ const next = { ...given };
127
+ const kept = new Set(rules.values ?? []);
128
+ let base = root.folder;
129
+ if (rules.cwd !== undefined) {
130
+ const value = given[rules.cwd];
131
+ if (value !== undefined && value !== null && typeof value !== "string") {
132
+ throw outsideRoot(at, `the input ${rules.cwd} is not a folder, so the root cannot examine it`);
133
+ }
134
+ base = await inRoot(root, typeof value === "string" ? value : ".", at);
135
+ next[rules.cwd] = base;
136
+ }
137
+ for (const name of rules.paths ?? []) {
138
+ const value = given[name];
139
+ if (value === undefined || value === null) {
140
+ if (rules.required?.includes(name)) {
141
+ throw outsideRoot(at, `the input ${name} has no value, and its default is outside the root ${root.folder}: give a path in the root`);
142
+ }
143
+ continue;
144
+ }
145
+ const absolute = [];
146
+ for (const path of pathValues(value, name, at))
147
+ absolute.push(kept.has(path) ? path : await inRoot(root, path, at));
148
+ next[name] = typeof value === "string" ? absolute[0] : absolute;
149
+ }
150
+ for (const name of rules.names ?? []) {
151
+ const value = given[name];
152
+ if (value === undefined || value === null)
153
+ continue;
154
+ for (const path of pathValues(value, name, at))
155
+ if (!kept.has(path))
156
+ await inRoot(root, path, at, base);
157
+ }
158
+ // A runner reads the scope of its raw input: the copy keeps it (DOC-10)
159
+ return withScope(next, scopeOf(input));
160
+ }
161
+ /**
162
+ * This function applies the decision of each procedure of the registry, except `fs.*`, to a root
163
+ * that exists. It replaces the handler of each confined, program and refused procedure, and it
164
+ * adds no procedure. `confineToRoot()` of the module starts it after the `fs.*` procedures.
165
+ */
166
+ export function confineOtherProcedures(registry, folder) {
167
+ const result = { confined: [], programs: [], refused: [], unchanged: [] };
168
+ // All decisions first: a rule that is not correct throws before the registry changes
169
+ const decisions = registry
170
+ .getAll()
171
+ .filter((procedure) => procedure.path[0] !== FILES)
172
+ .map((procedure) => ({ procedure, decision: rootDecisionOf(procedure) }));
173
+ const confinedProcedures = new WeakSet();
174
+ const root = () => resolveRoot(folder);
175
+ for (const { procedure, decision } of decisions) {
176
+ const key = keyOf(procedure);
177
+ const original = procedure.handler;
178
+ if (decision.kind === "unchanged" || original === undefined) {
179
+ result.unchanged.push(key);
180
+ continue;
181
+ }
182
+ const rules = rootRulesOf(procedure) ?? {};
183
+ let handler;
184
+ if (decision.kind === "refused") {
185
+ const message = `the root ${folder} cannot confine this procedure: ${decision.reason ?? "no reason"}`;
186
+ handler = (async () => {
187
+ throw outsideRoot(procedure.path, message);
188
+ });
189
+ result.refused.push(key);
190
+ }
191
+ else if (decision.kind === "program") {
192
+ handler = (async (input, ctx) => {
193
+ const caller = ctx?.caller;
194
+ const named = caller !== undefined && (declaredCalls(caller) ?? []).some((entry) => callMatches(entry, key));
195
+ if (caller === undefined || !confinedProcedures.has(caller) || !named) {
196
+ const from = caller === undefined ? "a client" : keyOf(caller);
197
+ throw outsideRoot(procedure.path, `this procedure starts the program of its input. Under the root ${folder}, it runs only as the nested call of a confined procedure that names it in metadata.calls, not for ${from}`);
198
+ }
199
+ return original(await confinedInput(input, rules, await root(), procedure.path), ctx);
200
+ });
201
+ result.programs.push(key);
202
+ }
203
+ else {
204
+ handler = (async (input, ctx) => original(await confinedInput(input, rules, await root(), procedure.path), ctx));
205
+ result.confined.push(key);
206
+ }
207
+ registry.register({ ...procedure, handler }, { override: true });
208
+ if (decision.kind === "confined")
209
+ confinedProcedures.add(registry.get(procedure.path));
210
+ }
211
+ return result;
212
+ }
213
+ //# sourceMappingURL=confine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confine.js","sourceRoot":"","sources":["../src/confine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EACL,WAAW,EACX,aAAa,EACb,SAAS,EACT,YAAY,EACZ,SAAS,EACT,OAAO,EACP,SAAS,GAMV,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAqB,MAAM,WAAW,CAAC;AAYhF,yEAAyE;AACzE,MAAM,KAAK,GAAG,IAAI,CAAC;AACnB,gEAAgE;AAChE,MAAM,QAAQ,GAAG,SAAS,CAAC;AAE3B,oDAAoD;AACpD,MAAM,SAAS,GAAwB,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;AAErH,qDAAqD;AACrD,MAAM,KAAK,GAAG,CAAC,SAA2C,EAAU,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAEjG,mDAAmD;AACnD,SAAS,UAAU,CAAC,KAAc;IAChC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACpG,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,SAAkD;IAC5E,MAAM,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AAC,KAAK,CAAC,MAAM,CAAC,CAAC;oBAC/D,MAAM,WAAW,CACf,SAAS,CAAC,IAAI,EACd,kEAAkE,MAAM,sGAAsG,IAAI,EAAE,CACrL,CAAC;gBACJ,CAAC;gBACD,OAAO,QAAQ,CAAC,MAAM,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,IAAI,EAAE,EAAE,SAAS,CAAC,IAAI,CAAC,EAAE,GAAuB,CAAC,CAAC;YAC5G,CAAC,CAAY,CAAC;YACd,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC5B,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,CAAC,KAAK,EAAE,KAAc,EAAE,GAAqB,EAAE,EAAE,CACzD,QAAQ,CAAC,MAAM,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,IAAI,EAAE,EAAE,SAAS,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAY,CAAC;YAC7F,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC5B,CAAC;QACD,QAAQ,CAAC,QAAQ,CAAC,EAAE,GAAG,SAAS,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACjE,IAAI,QAAQ,CAAC,IAAI,KAAK,UAAU;YAAE,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAE,CAAC,CAAC;IAC1F,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/dist/module.d.ts CHANGED
@@ -7,9 +7,12 @@
7
7
  * This file is referenced by package.json's client.procedures field.
8
8
  *
9
9
  * `fsModule` operates on each path. `createFsModule({ root })` gives the same procedures, and
10
- * each path of their input must be in the root (roadmap R33, `root.ts`).
10
+ * each path of their input must be in the root (roadmap R33, `root.ts`). `confineToRoot()` gives
11
+ * a root to all the procedures of a registry (`confine.ts`).
11
12
  */
12
13
  import { type ProcedureModule, type ProcedureRegistry } from "@procedures/client";
14
+ import { type ConfinedRegistry } from "./confine.js";
15
+ export { rootDecisionOf, rootRulesOf, type ConfinedRegistry, type RootDecision, type RootKind } from "./confine.js";
13
16
  /**
14
17
  * The module of this package, for `createRegistry()`: its procedures as data. Importing this
15
18
  * file registers nothing. (`register.ts` registers the same procedures in the global registry.)
@@ -48,8 +51,26 @@ export interface ConfinedFs {
48
51
  * A nested call of another procedure (`lib.scan` calls `fs.readdir`) finds the procedure in the
49
52
  * registry, so the root confines that call too. The root must be a folder that exists. An `fs.*`
50
53
  * procedure that this package does not have is an error, because the root cannot confine it.
54
+ *
55
+ * This function changes only the `fs.*` procedures. A host uses `confineToRoot()`: it also keeps
56
+ * the paths of the other procedures in the root, or it refuses them.
51
57
  */
52
58
  export declare function confineFsProcedures(registry: ProcedureRegistry, root: string): ConfinedFs;
59
+ /**
60
+ * This function confines each procedure of a registry to a root (roadmap R33). A host starts it
61
+ * after the last registration: `mark --fs-root`, `procedure-server --fs-root` and `MCP_FS_ROOT`.
62
+ *
63
+ * - Each `fs.*` procedure gets the handler of `createFsModule({ root })`, as with
64
+ * `confineFsProcedures()`.
65
+ * - Each other procedure gets the decision of `rootDecisionOf()`: the host examines its path
66
+ * inputs (`metadata.fsRoot`), or it refuses the procedure. A procedure that reaches no file
67
+ * stays as it is.
68
+ *
69
+ * The function adds no procedure, and the names of the tools do not change. It changes nothing
70
+ * when it throws: for a root that does not exist, an unknown `fs.*` procedure, or rules that are
71
+ * not correct.
72
+ */
73
+ export declare function confineToRoot(registry: ProcedureRegistry, root: string): ConfinedRegistry;
53
74
  /**
54
75
  * This function registers the procedures of @procedures/fs, and of the modules that it requires, in
55
76
  * a registry. The default is the global registry. Importing this file registers nothing: the
@@ -1 +1 @@
1
- {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAA8E,KAAK,eAAe,EA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AgB,cAAc,CAAC,OAAO,GAAE,eAAoB,GAAG,eAAe,CAW7E;AAED,4CAA4C;AAC5C,MAAM,WAAW,UAAU;IACzB,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,0FAA0F;IAC1F,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,CAKzF;AA2BD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,GAAG,gBAAgB,CAQzF;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,GAAE,iBAAsC,EAAE,OAAO,GAAE,eAAoB,GAAG,IAAI,CAE1H"}
package/dist/module.js CHANGED
@@ -7,12 +7,14 @@
7
7
  * This file is referenced by package.json's client.procedures field.
8
8
  *
9
9
  * `fsModule` operates on each path. `createFsModule({ root })` gives the same procedures, and
10
- * each path of their input must be in the root (roadmap R33, `root.ts`).
10
+ * each path of their input must be in the root (roadmap R33, `root.ts`). `confineToRoot()` gives
11
+ * a root to all the procedures of a registry (`confine.ts`).
11
12
  */
12
13
  import { createProcedure, zodAdapter, defineModule, PROCEDURE_REGISTRY, registerModules } from "@procedures/client";
13
14
  import { statSync } from "node:fs";
14
15
  import { resolve } from "node:path";
15
16
  import { HANDLER_NAMES, rootedHandlers } from "./handlers.js";
17
+ import { confineOtherProcedures, rootDecisionOf } from "./confine.js";
16
18
  import { read } from "./procedures/fs/read.js";
17
19
  import { write } from "./procedures/fs/write.js";
18
20
  import { exists } from "./procedures/fs/exists.js";
@@ -242,6 +244,8 @@ const fsWatchProcedure = createProcedure()
242
244
  // =============================================================================
243
245
  // Registration
244
246
  // =============================================================================
247
+ // The root for all the procedures of a registry (roadmap R33)
248
+ export { rootDecisionOf, rootRulesOf } from "./confine.js";
245
249
  /**
246
250
  * The module of this package, for `createRegistry()`: its procedures as data. Importing this
247
251
  * file registers nothing. (`register.ts` registers the same procedures in the global registry.)
@@ -292,8 +296,19 @@ export function createFsModule(options = {}) {
292
296
  * A nested call of another procedure (`lib.scan` calls `fs.readdir`) finds the procedure in the
293
297
  * registry, so the root confines that call too. The root must be a folder that exists. An `fs.*`
294
298
  * procedure that this package does not have is an error, because the root cannot confine it.
299
+ *
300
+ * This function changes only the `fs.*` procedures. A host uses `confineToRoot()`: it also keeps
301
+ * the paths of the other procedures in the root, or it refuses them.
295
302
  */
296
303
  export function confineFsProcedures(registry, root) {
304
+ const folder = rootFolder(root);
305
+ const rooted = rootedFsProcedures(registry, folder);
306
+ for (const procedure of rooted)
307
+ registry.register(procedure, { override: true });
308
+ return { root: folder, procedures: rooted.map((procedure) => procedure.path.join(".")) };
309
+ }
310
+ /** The absolute path of a root. It throws when the root does not exist or is not a folder. */
311
+ function rootFolder(root) {
297
312
  const folder = resolve(root);
298
313
  let isFolder;
299
314
  try {
@@ -304,20 +319,44 @@ export function confineFsProcedures(registry, root) {
304
319
  }
305
320
  if (!isFolder)
306
321
  throw new Error(`The root of the file procedures is not a folder: ${folder}`);
322
+ return folder;
323
+ }
324
+ /** The procedures with a root for the `fs.*` procedures of a registry. An unknown `fs.*` procedure is an error. */
325
+ function rootedFsProcedures(registry, folder) {
307
326
  const rooted = new Map(createFsModule({ root: folder }).procedures.map((procedure) => [procedure.path.join("."), procedure]));
308
327
  const present = registry.getAll().filter((procedure) => procedure.path[0] === "fs");
309
- for (const procedure of present) {
328
+ return present.map((procedure) => {
310
329
  const key = procedure.path.join(".");
311
- if (!rooted.has(key))
330
+ const replacement = rooted.get(key);
331
+ if (!replacement)
312
332
  throw new Error(`The root of the file procedures cannot confine ${key}: @procedures/fs has no such procedure`);
313
- }
314
- const procedures = [];
315
- for (const procedure of present) {
316
- const key = procedure.path.join(".");
317
- registry.register(rooted.get(key), { override: true });
318
- procedures.push(key);
319
- }
320
- return { root: folder, procedures };
333
+ return replacement;
334
+ });
335
+ }
336
+ /**
337
+ * This function confines each procedure of a registry to a root (roadmap R33). A host starts it
338
+ * after the last registration: `mark --fs-root`, `procedure-server --fs-root` and `MCP_FS_ROOT`.
339
+ *
340
+ * - Each `fs.*` procedure gets the handler of `createFsModule({ root })`, as with
341
+ * `confineFsProcedures()`.
342
+ * - Each other procedure gets the decision of `rootDecisionOf()`: the host examines its path
343
+ * inputs (`metadata.fsRoot`), or it refuses the procedure. A procedure that reaches no file
344
+ * stays as it is.
345
+ *
346
+ * The function adds no procedure, and the names of the tools do not change. It changes nothing
347
+ * when it throws: for a root that does not exist, an unknown `fs.*` procedure, or rules that are
348
+ * not correct.
349
+ */
350
+ export function confineToRoot(registry, root) {
351
+ const folder = rootFolder(root);
352
+ const rooted = rootedFsProcedures(registry, folder);
353
+ // Each decision before a change: rules that are not correct throw here
354
+ for (const procedure of registry.getAll())
355
+ rootDecisionOf(procedure);
356
+ for (const procedure of rooted)
357
+ registry.register(procedure, { override: true });
358
+ const others = confineOtherProcedures(registry, folder);
359
+ return { root: folder, fs: rooted.map((procedure) => procedure.path.join(".")), ...others };
321
360
  }
322
361
  /**
323
362
  * This function registers the procedures of @procedures/fs, and of the modules that it requires, in
@@ -1 +1 @@
1
- {"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,EAAyD,kBAAkB,EAAE,eAAe,EAA0B,MAAM,oBAAoB,CAAC;AACnM,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CA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AAC,EAAE,GAAG,MAAM,EAAE,CAAC;AAC9F,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAQ,GAAsB,kBAAkB,EAAE,OAAO,GAAoB,EAAE;IAClH,eAAe,CAAC,QAAQ,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACvD,CAAC"}
package/dist/root.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  /**
2
2
  * The root of the file procedures: one folder that confines each path (roadmap R33).
3
3
  *
4
+ * This file is the `./root` entry of the package: the rules without the procedures. Another
5
+ * package that confines its own paths imports them, for example `@procedures/archive`.
6
+ *
4
7
  * `createFsModule({ root })` sends each path of an input through `inRoot()`:
5
8
  * - A relative path starts at the root, not at the working folder of the process.
6
9
  * - A path outside the root gives `FORBIDDEN` with the reason `outside-root`. This includes a
@@ -32,8 +35,11 @@ export interface ResolvedRoot {
32
35
  folder: string;
33
36
  real: string;
34
37
  }
35
- /** This function gives the absolute path and the real path of a root. The root must exist. */
36
- export declare function resolveRoot(root: string): Promise<ResolvedRoot>;
38
+ /**
39
+ * This function gives the absolute path and the real path of a root. The root must exist. The
40
+ * error of a missing root names `owner`, for example "the archive procedures".
41
+ */
42
+ export declare function resolveRoot(root: string, owner?: string): Promise<ResolvedRoot>;
37
43
  /** The `FORBIDDEN` error for a path outside the root. */
38
44
  export declare function outsideRoot(procedure: ProcedurePath, message: string): InvocationError;
39
45
  /** True for the `FORBIDDEN` error of a path outside the root. */
@@ -44,9 +50,9 @@ export declare function isOutsideRoot(error: unknown): boolean;
44
50
  */
45
51
  export declare function realPathIsInside(root: ResolvedRoot, absolute: string): Promise<boolean>;
46
52
  /**
47
- * This function gives the absolute path of `path` in the root. A relative path starts at the
48
- * root. The real path decides: a path whose real path is outside the real path of the root gives
49
- * `FORBIDDEN` with the reason `outside-root`.
53
+ * This function gives the absolute path of `path` in the root. A relative path starts at `base`,
54
+ * and the default `base` is the root. The real path decides: a path whose real path is outside the
55
+ * real path of the root gives `FORBIDDEN` with the reason `outside-root`.
50
56
  */
51
- export declare function inRoot(root: ResolvedRoot, path: string, procedure: ProcedurePath): Promise<string>;
57
+ export declare function inRoot(root: ResolvedRoot, path: string, procedure: ProcedurePath, base?: string): Promise<string>;
52
58
  //# sourceMappingURL=root.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../src/root.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAAE,eAAe,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEzE,uEAAuE;AACvE,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAK3C;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAG9D;AAoBD;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAwBzE;AAED,uEAAuE;AACvE,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,8FAA8F;AAC9F,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAUrE;AAED,yDAAyD;AACzD,wBAAgB,WAAW,CAAC,SAAS,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,GAAG,eAAe,CAEtF;AAED,iEAAiE;AACjE,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAErD;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAE7F;AAED;;;;GAIG;AACH,wBAAsB,MAAM,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,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**
2
2
  * The root of the file procedures: one folder that confines each path (roadmap R33).
3
3
  *
4
+ * This file is the `./root` entry of the package: the rules without the procedures. Another
5
+ * package that confines its own paths imports them, for example `@procedures/archive`.
6
+ *
4
7
  * `createFsModule({ root })` sends each path of an input through `inRoot()`:
5
8
  * - A relative path starts at the root, not at the working folder of the process.
6
9
  * - A path outside the root gives `FORBIDDEN` with the reason `outside-root`. This includes a
@@ -79,8 +82,11 @@ export async function realPathOf(path, links = 0) {
79
82
  current = parent;
80
83
  }
81
84
  }
82
- /** This function gives the absolute path and the real path of a root. The root must exist. */
83
- export async function resolveRoot(root) {
85
+ /**
86
+ * This function gives the absolute path and the real path of a root. The root must exist. The
87
+ * error of a missing root names `owner`, for example "the archive procedures".
88
+ */
89
+ export async function resolveRoot(root, owner = "the file procedures") {
84
90
  const folder = resolve(root);
85
91
  try {
86
92
  return { folder, real: await realpath(folder) };
@@ -88,7 +94,7 @@ export async function resolveRoot(root) {
88
94
  catch (error) {
89
95
  if (!isMissing(error))
90
96
  throw error;
91
- const missing = new Error(`The root of the file procedures does not exist: ${folder}`);
97
+ const missing = new Error(`The root of ${owner} does not exist: ${folder}`);
92
98
  missing.code = "ENOENT";
93
99
  throw missing;
94
100
  }
@@ -109,12 +115,12 @@ export async function realPathIsInside(root, absolute) {
109
115
  return isInside(root.real, await realPathOf(absolute));
110
116
  }
111
117
  /**
112
- * This function gives the absolute path of `path` in the root. A relative path starts at the
113
- * root. The real path decides: a path whose real path is outside the real path of the root gives
114
- * `FORBIDDEN` with the reason `outside-root`.
118
+ * This function gives the absolute path of `path` in the root. A relative path starts at `base`,
119
+ * and the default `base` is the root. The real path decides: a path whose real path is outside the
120
+ * real path of the root gives `FORBIDDEN` with the reason `outside-root`.
115
121
  */
116
- export async function inRoot(root, path, procedure) {
117
- const absolute = resolve(root.folder, path);
122
+ export async function inRoot(root, path, procedure, base = root.folder) {
123
+ const absolute = resolve(base, path);
118
124
  const real = await realPathOf(absolute);
119
125
  // A path counts as inside by its given form or by its real form. On Windows, the two forms of a
120
126
  // folder can differ by more than the links: a short 8.3 name (RUNNER~1) has a long real name.
package/dist/root.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"root.js","sourceRoot":"","sources":["../src/root.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACxF,OAAO,EAAE,eAAe,EAAsB,MAAM,oBAAoB,CAAC;AAEzE,uEAAuE;AACvE,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC;AAE3C,qGAAqG;AACrG,MAAM,SAAS,GAAG,EAAE,CAAC;AAErB;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAc,EAAE,IAAY;IACnD,MAAM,GAAG,GAAG,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACnC,OAAO,GAAG,KAAK,EAAE,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,GAAG,KAAK,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC;AACzF,CAAC;AAED,wDAAwD;AACxD,SAAS,SAAS,CAAC,KAAc;IAC/B,MAAM,IAAI,GAAI,KAA2C,EAAE,IAAI,CAAC;IAChE,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,SAAS,CAAC;AACjD,CAAC;AAED,8FAA8F;AAC9F,KAAK,UAAU,UAAU,CAAC,IAAY;IACpC,IAAI,CAAC;QACH,OAAO,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,oCAAoC;QACpC,MAAM,IAAI,GAAI,KAA+B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