@pipelex/sdk 0.47.0 → 0.48.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.
Files changed (70) hide show
  1. package/README.md +9 -7
  2. package/dist/artifacts.d.ts +4 -3
  3. package/dist/artifacts.js +20 -14
  4. package/dist/artifacts.js.map +1 -1
  5. package/dist/cli/script.d.ts +1 -1
  6. package/dist/cli/source.d.ts +8 -7
  7. package/dist/cli/source.js +11 -5
  8. package/dist/cli/source.js.map +1 -1
  9. package/dist/client.d.ts +326 -213
  10. package/dist/client.js +829 -517
  11. package/dist/client.js.map +1 -1
  12. package/dist/codegen-check.d.ts +2 -3
  13. package/dist/codegen-check.js +2 -3
  14. package/dist/codegen-check.js.map +1 -1
  15. package/dist/errors.d.ts +5 -2
  16. package/dist/errors.js +5 -2
  17. package/dist/errors.js.map +1 -1
  18. package/dist/hooks/bundle-gather.d.ts +47 -40
  19. package/dist/hooks/bundle-gather.js +121 -219
  20. package/dist/hooks/bundle-gather.js.map +1 -1
  21. package/dist/hooks/check-core.d.ts +70 -6
  22. package/dist/hooks/check-core.js +188 -29
  23. package/dist/hooks/check-core.js.map +1 -1
  24. package/dist/hooks/claude-mthds-check.d.ts +19 -5
  25. package/dist/hooks/claude-mthds-check.js +20 -53
  26. package/dist/hooks/claude-mthds-check.js.map +1 -1
  27. package/dist/hooks/secret-guard.d.ts +38 -0
  28. package/dist/hooks/secret-guard.js +134 -0
  29. package/dist/hooks/secret-guard.js.map +1 -0
  30. package/dist/hooks/validate-stage.d.ts +29 -0
  31. package/dist/hooks/validate-stage.js +66 -0
  32. package/dist/hooks/validate-stage.js.map +1 -0
  33. package/dist/index.d.ts +3 -4
  34. package/dist/index.js +4 -3
  35. package/dist/index.js.map +1 -1
  36. package/dist/method-trees.d.ts +220 -74
  37. package/dist/method-trees.js +250 -37
  38. package/dist/method-trees.js.map +1 -1
  39. package/dist/models.d.ts +162 -59
  40. package/dist/node-host/node.d.ts +33 -0
  41. package/dist/node-host/node.js +27 -0
  42. package/dist/node-host/node.js.map +1 -0
  43. package/dist/node-host/unavailable.d.ts +8 -0
  44. package/dist/node-host/unavailable.js +8 -0
  45. package/dist/node-host/unavailable.js.map +1 -0
  46. package/dist/node-host.d.ts +53 -0
  47. package/dist/node-host.js +72 -0
  48. package/dist/node-host.js.map +1 -0
  49. package/dist/prepare-inputs.d.ts +46 -27
  50. package/dist/prepare-inputs.js +123 -42
  51. package/dist/prepare-inputs.js.map +1 -1
  52. package/dist/product-models.d.ts +14 -16
  53. package/dist/upload.d.ts +4 -9
  54. package/dist/upload.js +13 -16
  55. package/dist/upload.js.map +1 -1
  56. package/dist/version.d.ts +1 -1
  57. package/dist/version.js +1 -1
  58. package/docs/architecture.md +44 -21
  59. package/docs/cli.md +1 -1
  60. package/docs/crate-routes.md +43 -21
  61. package/docs/errors.md +5 -5
  62. package/docs/hook-bundle.md +27 -1
  63. package/docs/input-preparation.md +13 -13
  64. package/docs/method-trees.md +120 -22
  65. package/docs/run-results.md +5 -2
  66. package/package.json +8 -2
  67. package/dist/bundle-resources.d.ts +0 -62
  68. package/dist/bundle-resources.js +0 -165
  69. package/dist/bundle-resources.js.map +0 -1
  70. package/docs/bundle-resources.md +0 -107
@@ -1,58 +1,65 @@
1
1
  /**
2
- * Bundle gathering for the validate stage: the multi-file set sent to
3
- * `POST /v1/validate` around an edited `.mthds` file.
2
+ * The method tree the validate stage sends to `POST /v1/validate` around an edited `.mthds` file.
4
3
  *
5
- * Mirrors what the plxt-era hook's `-L "$PARENT_DIR/"` did through the Python
6
- * runtime (`pipelex/libraries/library_utils.py`): a recursive `.mthds` scan of
7
- * the edited file's parent directory, skipping the runtime's excluded dirs.
8
- * Capped, because an under-supplied bundle can produce a FALSE invalid verdict
9
- * (missing cross-file refs) — on overflow the caller must treat validate as
10
- * unavailable rather than risk a wrong block.
4
+ * It is the tree a run of the method would send: the edited file's directory listed by the `mthds`
5
+ * package's lister, under the MTHDS standard's membership rule and Manifest Discovery, so it is
6
+ * rooted at the nearest `METHODS.toml` at or above that directory, else at the directory itself,
7
+ * and holds every file the rule keeps — every bundle of the method, and every file a step reads,
8
+ * such as a `PipeDocGen` step's `template_file`, under its tree path. The client sends it inline
9
+ * when small and by hash otherwise, uploading the files the API lacks.
11
10
  *
12
- * It also gathers the files the bundle's steps read, a `PipeDocGen` step's
13
- * `template_file`, read beside the `.mthds` file whose step names it and sent as
14
- * the request's `resources` under the path the step names, as the runtime reads
15
- * a bundle loaded from disk: without them the server could only answer that the
16
- * template file was not supplied, which would block every edit of such a bundle.
11
+ * Screened, because the listing reads no `.gitignore` above the tree's root, so a repository's
12
+ * own ignore lines protect nothing in it: every file is read once, before any request, and one
13
+ * that looks like a secret by the workshop's rule, as `secret-guard.ts` refines it, stays home.
14
+ * The tree sent is the rest, over the bytes screened, never read again. A bundle or the manifest
15
+ * is read by every validation, so a tree without one is not the method: one that looks like a
16
+ * secret refuses the whole tree, and nothing is sent. Any other file is left out and the method
17
+ * validated without it, which only a step reading that file can notice, as a missing file the
18
+ * caller is told about.
19
+ *
20
+ * Capped, because the hook should not send a large tree on every edit, and because a tree it
21
+ * cannot list whole would risk a wrong verdict: on any of the caps, on a tree the standard refuses
22
+ * (a symbolic link or a special file in it, an unreadable directory), on a file that changed since
23
+ * it was listed, and on an edited file the tree does not hold (one the membership rule keeps out),
24
+ * the caller treats validate as unavailable rather than risk a wrong block.
17
25
  */
18
- import type { MthdsFile } from "../client.js";
26
+ import type { MethodTreeSource } from "mthds/protocol";
27
+ import type { WithheldFile } from "./check-core.js";
28
+ /** The hook's own bounds on the tree it sends, whatever the deployment would take. */
19
29
  export interface GatherCaps {
30
+ /** How many files the tree may hold. */
20
31
  maxFiles: number;
32
+ /** How large one file of it may be, in bytes. */
33
+ maxFileBytes: number;
34
+ /** How large all its files together may be, in bytes. */
21
35
  maxTotalBytes: number;
22
- /** How many template files the gather sends at most; the server's default limit when omitted. */
23
- maxResourceFiles?: number;
24
- /** How large one template file may be; the server's default limit when omitted. */
25
- maxResourceFileBytes?: number;
26
- /** How many bytes of template files the gather sends at most; the server's default when omitted. */
27
- maxResourceBytes?: number;
28
36
  }
29
37
  export declare const DEFAULT_GATHER_CAPS: GatherCaps;
30
38
  /**
31
- * The gathered bundle, or why there is none to send. `resources` maps the path a
32
- * step names to the template file's bytes. `conflict` is one path naming two
33
- * different files beside two `.mthds` files of the bundle, or a file beside one
34
- * and nothing beside the other: the request keys a file by its path alone, so it
35
- * cannot say what loading each file from disk would find, and validate is
36
- * unavailable rather than a wrong verdict.
39
+ * The gathered tree and the files it leaves home, or why there is none to send: `secret` for a
40
+ * bundle or the manifest that looks like a secret, with the tree's root and every file of the
41
+ * tree that does, `overflow` for a tree past one of the caps, `unreadable` for a directory the
42
+ * standard's lister refuses to list or a file that changed since it was listed, and `outside` for
43
+ * an edited file the tree does not hold. A withheld file's path, and the root, are spelled as the
44
+ * caller spelled the edited file's directory whenever that spelling reaches the same root.
37
45
  */
38
46
  export type GatherResult = {
39
47
  ok: true;
40
- files: MthdsFile[];
41
- resources: Record<string, Uint8Array>;
48
+ tree: MethodTreeSource;
49
+ withheld: WithheldFile[];
50
+ } | {
51
+ ok: false;
52
+ reason: "secret";
53
+ root: string;
54
+ withheld: WithheldFile[];
42
55
  } | {
43
56
  ok: false;
44
- reason: "overflow" | "unreadable" | "conflict";
57
+ reason: "overflow" | "unreadable" | "outside";
45
58
  };
46
59
  /**
47
- * Gather the `.mthds` files under the edited file's parent directory, the
48
- * edited file first (absent any `main_pipe`, the server's primary blueprint is
49
- * the first content — make that the file being edited). Contents are read
50
- * fresh from disk, so a format write-back is already reflected.
51
- */
52
- export declare function gatherBundle(editedFilePath: string, caps?: GatherCaps): GatherResult;
53
- /**
54
- * The paths of the template files the steps of one `.mthds` file name: each
55
- * `PipeDocGen` pipe's `template_file`. A file that does not parse names none, the
56
- * server giving its verdict on it.
60
+ * List the method tree around the edited file, its directory under the standard's membership
61
+ * rule and the hook's caps, then read and screen every file of it. The files are read here, after
62
+ * the format write-back the hook made before this call, and the tree returned serves the bytes
63
+ * read, so what was screened is what is sent.
57
64
  */
58
- export declare function templateFilesNamedBy(mthdsContent: string): string[];
65
+ export declare function gatherMethodTree(editedFilePath: string, caps?: GatherCaps): Promise<GatherResult>;
@@ -1,252 +1,154 @@
1
1
  /**
2
- * Bundle gathering for the validate stage: the multi-file set sent to
3
- * `POST /v1/validate` around an edited `.mthds` file.
2
+ * The method tree the validate stage sends to `POST /v1/validate` around an edited `.mthds` file.
4
3
  *
5
- * Mirrors what the plxt-era hook's `-L "$PARENT_DIR/"` did through the Python
6
- * runtime (`pipelex/libraries/library_utils.py`): a recursive `.mthds` scan of
7
- * the edited file's parent directory, skipping the runtime's excluded dirs.
8
- * Capped, because an under-supplied bundle can produce a FALSE invalid verdict
9
- * (missing cross-file refs) — on overflow the caller must treat validate as
10
- * unavailable rather than risk a wrong block.
4
+ * It is the tree a run of the method would send: the edited file's directory listed by the `mthds`
5
+ * package's lister, under the MTHDS standard's membership rule and Manifest Discovery, so it is
6
+ * rooted at the nearest `METHODS.toml` at or above that directory, else at the directory itself,
7
+ * and holds every file the rule keeps — every bundle of the method, and every file a step reads,
8
+ * such as a `PipeDocGen` step's `template_file`, under its tree path. The client sends it inline
9
+ * when small and by hash otherwise, uploading the files the API lacks.
11
10
  *
12
- * It also gathers the files the bundle's steps read, a `PipeDocGen` step's
13
- * `template_file`, read beside the `.mthds` file whose step names it and sent as
14
- * the request's `resources` under the path the step names, as the runtime reads
15
- * a bundle loaded from disk: without them the server could only answer that the
16
- * template file was not supplied, which would block every edit of such a bundle.
11
+ * Screened, because the listing reads no `.gitignore` above the tree's root, so a repository's
12
+ * own ignore lines protect nothing in it: every file is read once, before any request, and one
13
+ * that looks like a secret by the workshop's rule, as `secret-guard.ts` refines it, stays home.
14
+ * The tree sent is the rest, over the bytes screened, never read again. A bundle or the manifest
15
+ * is read by every validation, so a tree without one is not the method: one that looks like a
16
+ * secret refuses the whole tree, and nothing is sent. Any other file is left out and the method
17
+ * validated without it, which only a step reading that file can notice, as a missing file the
18
+ * caller is told about.
19
+ *
20
+ * Capped, because the hook should not send a large tree on every edit, and because a tree it
21
+ * cannot list whole would risk a wrong verdict: on any of the caps, on a tree the standard refuses
22
+ * (a symbolic link or a special file in it, an unreadable directory), on a file that changed since
23
+ * it was listed, and on an edited file the tree does not hold (one the membership rule keeps out),
24
+ * the caller treats validate as unavailable rather than risk a wrong block.
17
25
  */
18
- import { readdirSync, readFileSync, realpathSync, statSync } from "node:fs";
19
- import { dirname, join, relative, resolve, sep } from "node:path";
20
- import { parse as parseToml } from "smol-toml";
21
- import { bundleResourcePathRefusal, canonicalBundleResourcePath } from "../bundle-resources.js";
22
- /** Mirror of pipelex's `scan_config.excluded_dirs` (dot-dirs are skipped wholesale). */
23
- const EXCLUDED_DIRS = new Set([
24
- "venv",
25
- "env",
26
- "virtualenv",
27
- "__pycache__",
28
- "node_modules",
29
- "results",
30
- ]);
31
- /** The server's default bounds on the files a request sends with its bundle. */
32
- const DEFAULT_MAX_RESOURCE_FILES = 32;
33
- const DEFAULT_MAX_RESOURCE_FILE_BYTES = 5 * 1024 * 1024;
34
- const DEFAULT_MAX_RESOURCE_BYTES = 10 * 1024 * 1024;
26
+ import { realpathSync } from "node:fs";
27
+ import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
28
+ import { listDirectoryTree, treeDigestOf } from "../method-trees.js";
29
+ import { secretFindings } from "./secret-guard.js";
35
30
  export const DEFAULT_GATHER_CAPS = {
36
- maxFiles: 50,
37
- maxTotalBytes: 2 * 1024 * 1024,
38
- maxResourceFiles: DEFAULT_MAX_RESOURCE_FILES,
39
- maxResourceFileBytes: DEFAULT_MAX_RESOURCE_FILE_BYTES,
40
- maxResourceBytes: DEFAULT_MAX_RESOURCE_BYTES,
31
+ maxFiles: 100,
32
+ maxFileBytes: 5 * 1024 * 1024,
33
+ maxTotalBytes: 12 * 1024 * 1024,
41
34
  };
42
35
  /**
43
- * Recursively collect `.mthds` paths under `dir`. Throws if any directory in
44
- * the tree can't be read: a silently-skipped subtree would drop cross-file
45
- * refs and risk a FALSE invalid verdict, so the caller must treat an
46
- * unreadable scan as `unreadable` (validate unavailable), not as a smaller
47
- * bundle. The caps guard the opposite failure (over-supply), never this one.
48
- */
49
- function walkMthdsFiles(dir, collected) {
50
- const entries = readdirSync(dir, { withFileTypes: true });
51
- for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
52
- if (entry.name.startsWith(".") || EXCLUDED_DIRS.has(entry.name)) {
53
- continue;
54
- }
55
- const full = join(dir, entry.name);
56
- if (entry.isDirectory()) {
57
- walkMthdsFiles(full, collected);
58
- }
59
- else if (entry.isFile() && entry.name.endsWith(".mthds")) {
60
- collected.push(full);
61
- }
62
- }
63
- }
64
- /**
65
- * Gather the `.mthds` files under the edited file's parent directory, the
66
- * edited file first (absent any `main_pipe`, the server's primary blueprint is
67
- * the first content — make that the file being edited). Contents are read
68
- * fresh from disk, so a format write-back is already reflected.
36
+ * List the method tree around the edited file, its directory under the standard's membership
37
+ * rule and the hook's caps, then read and screen every file of it. The files are read here, after
38
+ * the format write-back the hook made before this call, and the tree returned serves the bytes
39
+ * read, so what was screened is what is sent.
69
40
  */
70
- export function gatherBundle(editedFilePath, caps = DEFAULT_GATHER_CAPS) {
41
+ export async function gatherMethodTree(editedFilePath, caps = DEFAULT_GATHER_CAPS) {
71
42
  const editedAbs = resolve(editedFilePath);
72
- const parentDir = dirname(editedAbs);
73
- const paths = [];
43
+ let tree;
74
44
  try {
75
- walkMthdsFiles(parentDir, paths);
45
+ tree = await listDirectoryTree(dirname(editedAbs), {
46
+ maxFileCount: caps.maxFiles,
47
+ maxFileSize: caps.maxFileBytes,
48
+ maxTotalSize: caps.maxTotalBytes,
49
+ }, "validate");
50
+ }
51
+ catch (err) {
52
+ return { ok: false, reason: isLimitExceeded(err) ? "overflow" : "unreadable" };
53
+ }
54
+ const root = tree.root;
55
+ const treePath = root === null ? undefined : treePathOf(editedAbs, root);
56
+ if (root === null || treePath === undefined || !tree.files.some((f) => f.path === treePath)) {
57
+ return { ok: false, reason: "outside" };
58
+ }
59
+ // The tree's reader checks each file against the hash it was listed with.
60
+ const bytesByPath = new Map();
61
+ try {
62
+ for (const file of tree.files) {
63
+ bytesByPath.set(file.path, await tree.readFile(file.path));
64
+ }
76
65
  }
77
66
  catch {
78
67
  return { ok: false, reason: "unreadable" };
79
68
  }
80
- const ordered = [editedAbs, ...paths.filter((path) => resolve(path) !== editedAbs)];
81
- if (ordered.length > caps.maxFiles) {
82
- return { ok: false, reason: "overflow" };
83
- }
84
- let totalBytes = 0;
85
- for (const path of ordered) {
86
- try {
87
- totalBytes += statSync(path).size;
88
- }
89
- catch {
90
- return { ok: false, reason: "unreadable" };
91
- }
92
- }
93
- if (totalBytes > caps.maxTotalBytes) {
94
- return { ok: false, reason: "overflow" };
95
- }
96
- const files = [];
97
- for (const path of ordered) {
98
- try {
99
- files.push({ content: readFileSync(path, "utf-8"), uri: relative(parentDir, path) });
100
- }
101
- catch {
102
- return { ok: false, reason: "unreadable" };
103
- }
104
- }
105
- const gathered = gatherTemplateFiles(parentDir, ordered, files, caps);
106
- if (!gathered.ok)
107
- return gathered;
108
- return { ok: true, files, resources: gathered.resources };
69
+ const findings = secretFindings(tree.files.map((file) => ({ path: file.path, bytes: bytesByPath.get(file.path) })));
70
+ const shownRoot = shownRootOf(editedAbs, root);
71
+ const withheld = findings.map((finding) => ({
72
+ path: join(shownRoot, ...finding.path.split("/")),
73
+ reason: finding.reason,
74
+ }));
75
+ if (findings.some((finding) => isReadByEveryValidation(finding.path))) {
76
+ // The files to fix first lead, so a note naming only the first few still names them.
77
+ const firsts = findings.map((finding) => isReadByEveryValidation(finding.path));
78
+ const ordered = [
79
+ ...withheld.filter((_, index) => firsts[index]),
80
+ ...withheld.filter((_, index) => !firsts[index]),
81
+ ];
82
+ return { ok: false, reason: "secret", root: shownRoot, withheld: ordered };
83
+ }
84
+ // A withheld file's bytes leave the map, so the tree sent cannot serve them.
85
+ for (const finding of findings)
86
+ bytesByPath.delete(finding.path);
87
+ const files = tree.files.filter((file) => bytesByPath.has(file.path));
88
+ return { ok: true, tree: await treeOver(files, bytesByPath), withheld };
109
89
  }
110
90
  /**
111
- * The paths of the template files the steps of one `.mthds` file name: each
112
- * `PipeDocGen` pipe's `template_file`. A file that does not parse names none, the
113
- * server giving its verdict on it.
91
+ * The tree's root as the caller spells it, the way the hook's output names the files of the
92
+ * tree: the root reached from the edited file's directory as the caller wrote it, by the same
93
+ * steps that lead from that directory's real path to the root, when it is the same directory,
94
+ * and the root's real path, the lister's, otherwise. A directory reached through a link above
95
+ * the root is so named through the link, while a link pointing into the tree, whose steps up
96
+ * leave the tree, falls back to the real path.
114
97
  */
115
- export function templateFilesNamedBy(mthdsContent) {
116
- let document;
98
+ function shownRootOf(editedAbs, root) {
99
+ const editedDir = dirname(editedAbs);
117
100
  try {
118
- document = parseToml(mthdsContent);
101
+ const candidate = resolve(editedDir, relative(realpathSync(editedDir), root));
102
+ return realpathSync(candidate) === root ? candidate : root;
119
103
  }
120
104
  catch {
121
- return [];
122
- }
123
- const pipes = isRecord(document) ? document["pipe"] : undefined;
124
- if (!isRecord(pipes))
125
- return [];
126
- const named = [];
127
- for (const pipe of Object.values(pipes)) {
128
- if (isRecord(pipe) &&
129
- pipe["type"] === "PipeDocGen" &&
130
- typeof pipe["template_file"] === "string") {
131
- named.push(pipe["template_file"]);
132
- }
105
+ return root;
133
106
  }
134
- return named;
107
+ }
108
+ /** Whether every validation reads the file whole: a bundle, or the manifest at the root. */
109
+ function isReadByEveryValidation(treePath) {
110
+ return treePath.endsWith(".mthds") || treePath === "METHODS.toml";
135
111
  }
136
112
  /**
137
- * Read the template files the gathered `.mthds` files name, each beside the file
138
- * whose step names it, keyed by the path the step names, as the runtime reads a
139
- * bundle loaded from disk. A path the server would refuse is left out, and so is a
140
- * file that is not there beside any `.mthds` file naming it, for the server to say
141
- * the step's file was not supplied.
142
- *
143
- * Validate is unavailable rather than a wrong verdict when the request cannot carry
144
- * what loading the bundle from disk would find: a file that leads out of the
145
- * bundle's directory through a link is never read (`unreadable`), and one path that
146
- * names different files beside different `.mthds` files, or a file beside one and
147
- * nothing beside another, is a `conflict`. Every size is checked against the caps
148
- * before any file is read, the bytes compared to tell two files apart included, so
149
- * the hook never holds more than the caps allow (`overflow`).
113
+ * The tree of `files`, the listing's own entries, serving the bytes already read, which hold
114
+ * those files' bytes alone, with the digest of that listing: the listed tree's digest when
115
+ * nothing was left out.
150
116
  */
151
- function gatherTemplateFiles(parentDir, paths, files, caps) {
152
- const maxFiles = caps.maxResourceFiles ?? DEFAULT_MAX_RESOURCE_FILES;
153
- const maxFileBytes = caps.maxResourceFileBytes ?? DEFAULT_MAX_RESOURCE_FILE_BYTES;
154
- const maxBytes = caps.maxResourceBytes ?? DEFAULT_MAX_RESOURCE_BYTES;
155
- let root;
156
- try {
157
- root = realpathSync(parentDir);
158
- }
159
- catch {
160
- return { ok: false, reason: "unreadable" };
161
- }
162
- // Each path a step names, once, with the file it names beside the first `.mthds` file
163
- // naming it, or `null` when there is none there.
164
- const located = new Map();
165
- let fileCount = 0;
166
- let totalBytes = 0;
167
- for (const [index, mthdsPath] of paths.entries()) {
168
- for (const named of templateFilesNamedBy(files[index].content)) {
169
- if (bundleResourcePathRefusal(named) !== undefined)
170
- continue;
171
- const key = canonicalBundleResourcePath(named);
172
- const found = locateRegularFile(join(dirname(mthdsPath), key));
173
- if (found !== null) {
174
- if (!found.real.startsWith(root + sep))
175
- return { ok: false, reason: "unreadable" };
176
- if (found.size > maxFileBytes)
177
- return { ok: false, reason: "overflow" };
178
- }
179
- if (!located.has(key)) {
180
- located.set(key, found);
181
- if (found === null)
182
- continue;
183
- fileCount += 1;
184
- if (fileCount > maxFiles)
185
- return { ok: false, reason: "overflow" };
186
- totalBytes += found.size;
187
- if (totalBytes > maxBytes)
188
- return { ok: false, reason: "overflow" };
189
- continue;
190
- }
191
- const known = located.get(key);
192
- if (known === null || found === null) {
193
- if (known !== found)
194
- return { ok: false, reason: "conflict" };
195
- continue;
196
- }
197
- if (!sameFileContent(known, found))
198
- return { ok: false, reason: "conflict" };
199
- }
200
- }
201
- const resources = Object.create(null);
202
- let readBytes = 0;
203
- for (const [key, found] of located) {
204
- if (found === null)
205
- continue;
206
- try {
207
- const bytes = readFileSync(found.real);
208
- // A file that grew since it was measured is held to the caps as read.
209
- readBytes += bytes.length;
210
- if (bytes.length > maxFileBytes || readBytes > maxBytes) {
211
- return { ok: false, reason: "overflow" };
212
- }
213
- resources[key] = bytes;
214
- }
215
- catch {
216
- return { ok: false, reason: "unreadable" };
217
- }
218
- }
219
- return { ok: true, resources };
117
+ async function treeOver(files, bytesByPath) {
118
+ return {
119
+ files,
120
+ digest: await treeDigestOf(files),
121
+ readFile: async (treePath) => {
122
+ const bytes = bytesByPath.get(treePath);
123
+ if (bytes === undefined)
124
+ throw new Error(`The tree holds no file '${treePath}'.`);
125
+ return bytes;
126
+ },
127
+ };
220
128
  }
221
- /** The regular file at `path`, link resolved, or `null` when there is none there. */
222
- function locateRegularFile(path) {
129
+ /** The edited file's tree path under `root`, or `undefined` when it lies outside it. */
130
+ function treePathOf(editedAbs, root) {
131
+ let real;
223
132
  try {
224
- const real = realpathSync(path);
225
- const stats = statSync(real);
226
- return stats.isFile() ? { real, size: stats.size } : null;
133
+ real = realpathSync(editedAbs);
227
134
  }
228
135
  catch {
229
- return null;
136
+ return undefined;
230
137
  }
231
- }
232
- /**
233
- * Whether two files hold the same bytes. Their sizes were measured and held to the
234
- * per-file cap before this reads either, so a comparison reads at most two files of
235
- * that size; files of different sizes differ unread, and an unreadable one holds none.
236
- */
237
- function sameFileContent(left, right) {
238
- if (left.real === right.real)
239
- return true;
240
- if (left.size !== right.size)
241
- return false;
242
- try {
243
- return Buffer.compare(readFileSync(left.real), readFileSync(right.real)) === 0;
244
- }
245
- catch {
246
- return false;
138
+ const relativePath = relative(root, real);
139
+ if (relativePath === "" ||
140
+ relativePath === ".." ||
141
+ relativePath.startsWith(`..${sep}`) ||
142
+ isAbsolute(relativePath)) {
143
+ return undefined;
247
144
  }
145
+ return relativePath.split(sep).join("/").normalize("NFC");
248
146
  }
249
- function isRecord(value) {
250
- return typeof value === "object" && value !== null && !Array.isArray(value);
147
+ /** Whether a listing failed on one of the caps: the lister's `limit_exceeded`. */
148
+ function isLimitExceeded(err) {
149
+ const cause = err instanceof Error ? err.cause : undefined;
150
+ return (typeof cause === "object" &&
151
+ cause !== null &&
152
+ cause.code === "limit_exceeded");
251
153
  }
252
154
  //# sourceMappingURL=bundle-gather.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"bundle-gather.js","sourceRoot":"","sources":["../../src/hooks/bundle-gather.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAClE,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,yBAAyB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAGhG,wFAAwF;AACxF,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;IAC5B,MAAM;IACN,KAAK;IACL,YAAY;IACZ,aAAa;IACb,cAAc;IACd,SAAS;CACV,CAAC,CAAC;AAaH,gFAAgF;AAChF,MAAM,0BAA0B,GAAG,EAAE,CAAC;AACtC,MAAM,+BAA+B,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AACxD,MAAM,0BAA0B,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAEpD,MAAM,CAAC,MAAM,mBAAmB,GAAe;IAC7C,QAAQ,EAAE,EAAE;IACZ,aAAa,EAAE,CAAC,GAAG,IAAI,G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