stitchkit 0.114.1 → 0.115.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 (108) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/dist/agent-runtime/coding-tool-files.d.ts.map +1 -1
  3. package/dist/agent-runtime/coding-tool-listing.d.ts.map +1 -1
  4. package/dist/agent-runtime/coding-tool-paths.d.ts.map +1 -1
  5. package/dist/agent-runtime/coding-tool-refusals.d.ts +6 -0
  6. package/dist/agent-runtime/coding-tool-refusals.d.ts.map +1 -1
  7. package/dist/agent-runtime/coding-tool-search-patch.d.ts.map +1 -1
  8. package/dist/agent-runtime/contained-scan.d.ts +1 -1
  9. package/dist/agent-runtime/contained-scan.d.ts.map +1 -1
  10. package/dist/agent-runtime/sandbox-broker.d.ts.map +1 -1
  11. package/dist/agent-runtime/sandbox-bubblewrap-storage.d.ts.map +1 -1
  12. package/dist/application/directory-inbox-files.d.ts.map +1 -1
  13. package/dist/application/file-state-store.d.ts.map +1 -1
  14. package/dist/entrypoints/agent-runtime/coding-tools.js +6 -4
  15. package/dist/entrypoints/agent-runtime/harness.js +2 -1
  16. package/dist/entrypoints/agent-runtime/sandbox.js +13 -8
  17. package/dist/entrypoints/agent-runtime/sqlite/bun.js +8 -6
  18. package/dist/entrypoints/agent-runtime/sqlite/node.js +8 -6
  19. package/dist/entrypoints/agent-runtime/testing.js +8 -6
  20. package/dist/entrypoints/agent-runtime.js +8 -6
  21. package/dist/entrypoints/application/diagnostic-journal.js +2 -2
  22. package/dist/entrypoints/application/directory-inbox.js +10 -7
  23. package/dist/entrypoints/cli/publish.js +11 -8
  24. package/dist/entrypoints/cli.js +6 -3
  25. package/dist/entrypoints/files.js +10 -7
  26. package/dist/entrypoints/process/owner-loss.js +1 -1
  27. package/dist/entrypoints/process.js +3 -3
  28. package/dist/entrypoints/react/keyboard/testing.js +1 -1
  29. package/dist/entrypoints/react/keyboard.js +11 -11
  30. package/dist/entrypoints/server.js +4 -4
  31. package/dist/entrypoints/telegram.js +8 -5
  32. package/dist/entrypoints/tools.js +6 -3
  33. package/dist/files/chunk-spool.d.ts.map +1 -1
  34. package/dist/{index-2f9r0jgr.js → index-364k2zwa.js} +4 -4
  35. package/dist/{index-km2qw407.js → index-3qqdqwxe.js} +91 -36
  36. package/dist/{index-s47ac8zt.js → index-7yx8j6ay.js} +133 -156
  37. package/dist/{index-kdnfe0sr.js → index-90p34rts.js} +2 -2
  38. package/dist/{index-a3462dqf.js → index-944x38nv.js} +1 -1
  39. package/dist/{index-07dcf2yn.js → index-ac6vvm30.js} +5 -2
  40. package/dist/{index-qj1sy4ep.js → index-crmswbrt.js} +1 -1
  41. package/dist/{index-7r4knwf8.js → index-dr3t5n1v.js} +14 -4
  42. package/dist/{index-dc9ere5p.js → index-dx5cm9pc.js} +1 -1
  43. package/dist/{index-84bf5spd.js → index-f6m4c545.js} +5 -2
  44. package/dist/{index-hy802jnr.js → index-fdk4r4r6.js} +6 -3
  45. package/dist/index-j8kf56wx.js +100 -0
  46. package/dist/index-jj9228tt.js +6 -0
  47. package/dist/{index-t65erk4z.js → index-mgb7r8b8.js} +122 -62
  48. package/dist/{index-bh2ht9y5.js → index-n8z3rvzw.js} +4 -1
  49. package/dist/index-nregbbsc.js +107 -0
  50. package/dist/{index-j4zh647a.js → index-tt30h7mr.js} +4 -1
  51. package/dist/{index-zrtrjkbf.js → index-x0ddbj85.js} +148 -172
  52. package/dist/{index-p02zgk8x.js → index-y4rxnvgp.js} +6 -0
  53. package/dist/{index-5v5a9k2n.js → index-z3d6smer.js} +1 -1
  54. package/dist/{index-6b3pcq5z.js → index-zqkz4af9.js} +1 -1
  55. package/dist/internal/atomic-file.d.ts.map +1 -1
  56. package/dist/internal/atomic-staging.d.ts.map +1 -1
  57. package/dist/internal/contained-directory.d.ts +20 -0
  58. package/dist/internal/contained-directory.d.ts.map +1 -0
  59. package/dist/{agent-runtime → internal}/contained-files.d.ts +14 -13
  60. package/dist/internal/contained-files.d.ts.map +1 -0
  61. package/dist/internal/contained-handle.d.ts +30 -0
  62. package/dist/internal/contained-handle.d.ts.map +1 -0
  63. package/dist/internal/contained-write.d.ts +12 -0
  64. package/dist/internal/contained-write.d.ts.map +1 -0
  65. package/dist/internal/darwin-binding.d.ts +1 -1
  66. package/dist/internal/darwin-binding.d.ts.map +1 -1
  67. package/dist/internal/errno.d.ts +3 -0
  68. package/dist/internal/errno.d.ts.map +1 -0
  69. package/dist/internal/pinned-http.d.ts +27 -0
  70. package/dist/internal/pinned-http.d.ts.map +1 -0
  71. package/dist/internal/process-instance.d.ts.map +1 -1
  72. package/dist/internal/secure-fetch.d.ts +26 -6
  73. package/dist/internal/secure-fetch.d.ts.map +1 -1
  74. package/dist/internal/write-download.d.ts +5 -14
  75. package/dist/internal/write-download.d.ts.map +1 -1
  76. package/dist/process/group-diagnostics.d.ts +1 -0
  77. package/dist/process/group-diagnostics.d.ts.map +1 -1
  78. package/dist/process/group-settlement.d.ts +2 -0
  79. package/dist/process/group-settlement.d.ts.map +1 -1
  80. package/dist/process/group.d.ts.map +1 -1
  81. package/dist/process/owner-loss-control.d.ts.map +1 -1
  82. package/dist/react/keyboard/hooks.d.ts +2 -2
  83. package/dist/react/keyboard/hooks.d.ts.map +1 -1
  84. package/dist/react/keyboard/layers.d.ts +2 -0
  85. package/dist/react/keyboard/layers.d.ts.map +1 -1
  86. package/dist/telegram/broadcast-state.d.ts.map +1 -1
  87. package/dist/tools/cli/download.d.ts.map +1 -1
  88. package/dist/tools/cli/publication-storage.d.ts.map +1 -1
  89. package/dist/tools/cli/publication.d.ts.map +1 -1
  90. package/dist/tools/cli/view.d.ts.map +1 -1
  91. package/llms/agent-runtime.txt +16 -6
  92. package/llms/cli.txt +34 -2
  93. package/llms/process.txt +2 -2
  94. package/llms/react-keyboard.txt +18 -2
  95. package/llms/stitchkit.txt +3 -3
  96. package/llms/{upgrading-0.104.0-0.114.0.txt → upgrading-0.104.0-0.115.0.txt} +62 -3
  97. package/llms/upgrading.txt +1 -1
  98. package/llms-full.txt +132 -15
  99. package/llms.txt +5 -5
  100. package/native/darwin-arm64.node +0 -0
  101. package/native/darwin-x64.node +0 -0
  102. package/native-assets.json +4 -4
  103. package/package.json +1 -1
  104. package/dist/agent-runtime/contained-darwin.d.ts +0 -21
  105. package/dist/agent-runtime/contained-darwin.d.ts.map +0 -1
  106. package/dist/agent-runtime/contained-files.d.ts.map +0 -1
  107. package/dist/agent-runtime/contained-write.d.ts +0 -9
  108. package/dist/agent-runtime/contained-write.d.ts.map +0 -1
@@ -1,17 +1,22 @@
1
1
  import {
2
2
  loadDarwinBinding
3
3
  } from "./index-2kbysk9s.js";
4
+ import {
5
+ errnoOf
6
+ } from "./index-jj9228tt.js";
4
7
 
5
- // src/agent-runtime/contained-scan.ts
6
- import path2 from "node:path";
7
-
8
- // src/agent-runtime/contained-files.ts
8
+ // src/internal/contained-directory.ts
9
9
  import { constants } from "node:fs";
10
- import { lstat, mkdir, open, readdir, realpath } from "node:fs/promises";
10
+ import { mkdir, open, realpath } from "node:fs/promises";
11
11
  import path from "node:path";
12
12
 
13
- // src/agent-runtime/contained-darwin.ts
13
+ // src/internal/contained-handle.ts
14
14
  import { close as closeDescriptor, fstat, read as readDescriptor } from "node:fs";
15
+ function descriptorPath(handle) {
16
+ if (process.platform === "linux")
17
+ return `/proc/self/fd/${handle.fd}`;
18
+ throw new Error("Descriptor paths are available only in the Linux contained-files backend");
19
+ }
15
20
  var FILE_TYPE_MASK = 61440;
16
21
  var FILE_TYPE_DIRECTORY = 16384;
17
22
  var FILE_TYPE_REGULAR = 32768;
@@ -22,10 +27,14 @@ function modeIs(mode, type) {
22
27
 
23
28
  class NumericFileHandle {
24
29
  fd;
30
+ closed = false;
25
31
  constructor(fd) {
26
32
  this.fd = fd;
27
33
  }
28
34
  close() {
35
+ if (this.closed)
36
+ return Promise.resolve();
37
+ this.closed = true;
29
38
  return new Promise((resolve, reject) => {
30
39
  closeDescriptor(this.fd, (error) => error ? reject(error) : resolve());
31
40
  });
@@ -42,55 +51,111 @@ class NumericFileHandle {
42
51
  }
43
52
  }
44
53
 
45
- // src/agent-runtime/contained-files.ts
46
- function containedEntryKind(entry) {
47
- return entry.isDirectory() ? "directory" : entry.isSymbolicLink() ? "symlink" : entry.isFile() ? "file" : "other";
54
+ // src/internal/contained-directory.ts
55
+ var O_PATH_LINUX = 2097152;
56
+ var O_SEARCH_DARWIN = 1073741824;
57
+ function directoryFlags(searchOnly) {
58
+ const access = searchOnly ? process.platform === "linux" ? O_PATH_LINUX : O_SEARCH_DARWIN : constants.O_RDONLY;
59
+ return access | constants.O_DIRECTORY | constants.O_NOFOLLOW;
48
60
  }
49
- function descriptorPath(handle) {
50
- if (process.platform === "linux")
51
- return `/proc/self/fd/${handle.fd}`;
52
- throw new Error("Descriptor paths are available only in the Linux contained-files backend");
61
+ async function openDirectoryAt(directory, name, searchOnly = false) {
62
+ if (process.platform === "darwin") {
63
+ return new NumericFileHandle(loadDarwinBinding().openDirectoryAt(directory.fd, name, searchOnly));
64
+ }
65
+ return open(path.join(descriptorPath(directory), name), directoryFlags(searchOnly));
53
66
  }
54
- function sameIdentity(left, right) {
55
- return left.dev === right.dev && left.ino === right.ino;
67
+ async function descend(current, next) {
68
+ try {
69
+ await current.close();
70
+ } catch (error) {
71
+ await next.close();
72
+ throw error;
73
+ }
74
+ return next;
56
75
  }
57
- async function openPinnedDirectory(absolute) {
76
+ async function createDirectoryAt(directory, name) {
77
+ if (process.platform === "darwin") {
78
+ return loadDarwinBinding().createDirectoryAt(directory.fd, name, 511);
79
+ }
80
+ try {
81
+ await mkdir(path.join(descriptorPath(directory), name));
82
+ return true;
83
+ } catch (error) {
84
+ if (errnoOf(error) === "EEXIST")
85
+ return false;
86
+ throw error;
87
+ }
88
+ }
89
+ async function openPinnedDirectory(absolute, options = {}, io = { realpath }) {
58
90
  if (process.platform !== "linux" && process.platform !== "darwin") {
59
91
  throw new Error("Contained filesystem operations support Linux and macOS only");
60
92
  }
61
- const expected = await realpath(absolute);
62
- const handle = await open(expected, constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW);
93
+ let prefix = path.resolve(absolute);
94
+ const missing = [];
95
+ let canonical;
96
+ for (;; ) {
97
+ try {
98
+ canonical = await io.realpath(prefix);
99
+ break;
100
+ } catch (error) {
101
+ if (!options.create || errnoOf(error) !== "ENOENT")
102
+ throw error;
103
+ const parent = path.dirname(prefix);
104
+ if (parent === prefix)
105
+ throw error;
106
+ missing.unshift(path.basename(prefix));
107
+ prefix = parent;
108
+ }
109
+ }
110
+ const anchor = path.parse(canonical).root;
111
+ let current = await open(anchor, directoryFlags(true));
112
+ if (canonical === anchor && missing.length === 0 && options.readable !== false) {
113
+ await current.close();
114
+ return open(anchor, directoryFlags(false));
115
+ }
116
+ const existing = path.relative(anchor, canonical).split(path.sep).filter(Boolean);
63
117
  try {
64
- const [pathMetadata, handleMetadata] = await Promise.all([lstat(expected), handle.stat()]);
65
- if (!pathMetadata.isDirectory() || !sameIdentity(pathMetadata, handleMetadata)) {
66
- throw new Error("Contained directory identity changed while opening");
118
+ const segments = [...existing, ...missing];
119
+ for (const [index, segment] of segments.entries()) {
120
+ if (index >= existing.length)
121
+ await createDirectoryAt(current, segment);
122
+ const next = await openDirectoryAt(current, segment, index < segments.length - 1 || options.readable === false);
123
+ current = await descend(current, next);
67
124
  }
68
- return handle;
125
+ return current;
69
126
  } catch (error) {
70
- await handle.close();
127
+ await current.close();
71
128
  throw error;
72
129
  }
73
130
  }
131
+
132
+ // src/internal/contained-files.ts
133
+ import { constants as constants2 } from "node:fs";
134
+ import { lstat, open as open2, readdir } from "node:fs/promises";
135
+ import path2 from "node:path";
136
+ function containedEntryKind(entry) {
137
+ return entry.isDirectory() ? "directory" : entry.isSymbolicLink() ? "symlink" : entry.isFile() ? "file" : "other";
138
+ }
139
+ function sameIdentity(left, right) {
140
+ return left.dev === right.dev && left.ino === right.ino;
141
+ }
142
+ function isSafeEntryName(name) {
143
+ return name !== "" && name !== "." && name !== ".." && !name.includes("\x00");
144
+ }
74
145
  function safeSegments(relative) {
75
- if (path.isAbsolute(relative))
146
+ if (path2.isAbsolute(relative))
76
147
  throw new Error("Contained paths must be relative");
77
148
  const segments = relative.split(/[\\/]/u);
78
- if (segments.length === 0 || segments.some((segment) => segment === "" || segment === "." || segment === "..")) {
149
+ if (!segments.every(isSafeEntryName)) {
79
150
  throw new Error("Contained path has invalid segments");
80
151
  }
81
152
  return segments;
82
153
  }
83
- async function openDirectoryAt(directory, name) {
84
- if (process.platform === "darwin") {
85
- return new NumericFileHandle(loadDarwinBinding().openDirectoryAt(directory.fd, name));
86
- }
87
- return open(path.join(descriptorPath(directory), name), constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW);
88
- }
89
154
  async function openFileAt(directory, name) {
90
155
  if (process.platform === "darwin") {
91
156
  return new NumericFileHandle(loadDarwinBinding().openFileAt(directory.fd, name));
92
157
  }
93
- return open(path.join(descriptorPath(directory), name), constants.O_RDONLY | constants.O_NOFOLLOW);
158
+ return open2(path2.join(descriptorPath(directory), name), constants2.O_RDONLY | constants2.O_NOFOLLOW | constants2.O_NONBLOCK);
94
159
  }
95
160
  function entryMetadata(mode, size) {
96
161
  return {
@@ -106,8 +171,8 @@ async function statAt(directory, name) {
106
171
  const metadata = loadDarwinBinding().statAt(directory.fd, name);
107
172
  return metadata ? entryMetadata(metadata.mode, metadata.size) : null;
108
173
  }
109
- return lstat(path.join(descriptorPath(directory), name)).catch((error) => {
110
- if (error.code === "ENOENT")
174
+ return lstat(path2.join(descriptorPath(directory), name)).catch((error) => {
175
+ if (errnoOf(error) === "ENOENT")
111
176
  return null;
112
177
  throw error;
113
178
  });
@@ -123,14 +188,7 @@ async function listContainedDirectory(root, relative, maxEntries, authorizePath)
123
188
  try {
124
189
  if (relative !== ".") {
125
190
  for (const segment of safeSegments(relative)) {
126
- const next = await openDirectoryAt(current, segment);
127
- const metadata = await next.stat();
128
- if (!metadata.isDirectory()) {
129
- await next.close();
130
- throw new Error("Contained ancestor is not a directory");
131
- }
132
- await current.close();
133
- current = next;
191
+ current = await descend(current, await openDirectoryAt(current, segment));
134
192
  }
135
193
  }
136
194
  const raw = [...await listAt(current)];
@@ -138,7 +196,7 @@ async function listContainedDirectory(root, relative, maxEntries, authorizePath)
138
196
  const admitted = [];
139
197
  const denied = [];
140
198
  for (const entry of raw) {
141
- const entryPath = relative === "." ? entry.name : path.join(relative, entry.name);
199
+ const entryPath = relative === "." ? entry.name : path2.join(relative, entry.name);
142
200
  if (authorizePath && !await authorizePath(entryPath)) {
143
201
  denied.push({ name: entry.name, kind: containedEntryKind(entry) });
144
202
  continue;
@@ -174,19 +232,6 @@ async function listContainedDirectory(root, relative, maxEntries, authorizePath)
174
232
  await current.close();
175
233
  }
176
234
  }
177
- async function createDirectoryAt(directory, name) {
178
- if (process.platform === "darwin") {
179
- return loadDarwinBinding().createDirectoryAt(directory.fd, name, 511);
180
- }
181
- try {
182
- await mkdir(path.join(descriptorPath(directory), name));
183
- return true;
184
- } catch (error) {
185
- if (error.code === "EEXIST")
186
- return false;
187
- throw error;
188
- }
189
- }
190
235
  async function missingContainedDirectories(root, relative) {
191
236
  const segments = safeSegments(relative);
192
237
  segments.pop();
@@ -197,26 +242,34 @@ async function missingContainedDirectories(root, relative) {
197
242
  for (const segment of segments) {
198
243
  walked = [...walked, segment];
199
244
  if (missing.length > 0) {
200
- missing.push(walked.join(path.sep));
245
+ missing.push(walked.join(path2.sep));
201
246
  continue;
202
247
  }
203
248
  const next = await openDirectoryAt(current, segment).catch((error) => {
204
- if (error.code === "ENOENT")
249
+ if (errnoOf(error) === "ENOENT")
205
250
  return null;
206
251
  throw error;
207
252
  });
208
253
  if (!next) {
209
- missing.push(walked.join(path.sep));
254
+ missing.push(walked.join(path2.sep));
210
255
  continue;
211
256
  }
212
- await current.close();
213
- current = next;
257
+ current = await descend(current, next);
214
258
  }
215
259
  return missing;
216
260
  } finally {
217
261
  await current.close();
218
262
  }
219
263
  }
264
+
265
+ class UnapprovedContainedDirectoryError extends Error {
266
+ relative;
267
+ constructor(relative) {
268
+ super(`Contained directory creation was not authorized: ${relative}`);
269
+ this.relative = relative;
270
+ this.name = "UnapprovedContainedDirectoryError";
271
+ }
272
+ }
220
273
  async function openContainedParent(root, relative, options = {}) {
221
274
  const segments = safeSegments(relative);
222
275
  const basename = segments.pop();
@@ -224,17 +277,20 @@ async function openContainedParent(root, relative, options = {}) {
224
277
  throw new Error("Contained path is missing a basename");
225
278
  let current = await openPinnedDirectory(root);
226
279
  try {
280
+ const approved = new Set(options.createDirectories);
281
+ const walked = [];
227
282
  for (const segment of segments) {
228
- if (options.create)
283
+ walked.push(segment);
284
+ const next = await openDirectoryAt(current, segment).catch(async (error) => {
285
+ if (options.createDirectories === undefined || errnoOf(error) !== "ENOENT")
286
+ throw error;
287
+ const directory = walked.join(path2.sep);
288
+ if (!approved.has(directory))
289
+ throw new UnapprovedContainedDirectoryError(directory);
229
290
  await createDirectoryAt(current, segment);
230
- const next = await openDirectoryAt(current, segment);
231
- const metadata = await next.stat();
232
- if (!metadata.isDirectory()) {
233
- await next.close();
234
- throw new Error("Contained ancestor is not a directory");
235
- }
236
- await current.close();
237
- current = next;
291
+ return openDirectoryAt(current, segment);
292
+ });
293
+ current = await descend(current, next);
238
294
  }
239
295
  return { handle: current, basename };
240
296
  } catch (error) {
@@ -256,21 +312,38 @@ async function openContainedFile(root, relative) {
256
312
  await parent.handle.close();
257
313
  }
258
314
  }
315
+
316
+ class ContainedPathChangedError extends Error {
317
+ relative;
318
+ constructor(relative) {
319
+ super(`Contained path changed during authorization: ${relative}`);
320
+ this.relative = relative;
321
+ this.name = "ContainedPathChangedError";
322
+ }
323
+ }
324
+ async function reopen(relative, open) {
325
+ return open().catch((error) => {
326
+ if (["ENOENT", "ENOTDIR", "ELOOP"].includes(errnoOf(error) ?? "")) {
327
+ throw new ContainedPathChangedError(relative);
328
+ }
329
+ throw error;
330
+ });
331
+ }
259
332
  async function assertContainedFileCurrent(root, relative, expected) {
260
- const current = await openContainedFile(root, relative);
333
+ const current = await reopen(relative, () => openContainedFile(root, relative));
261
334
  try {
262
335
  if (!sameIdentity(await expected.stat(), await current.stat())) {
263
- throw new Error("Contained file identity changed during authorization");
336
+ throw new ContainedPathChangedError(relative);
264
337
  }
265
338
  } finally {
266
339
  await current.close();
267
340
  }
268
341
  }
269
342
  async function assertContainedParentCurrent(root, relative, expected) {
270
- const current = await openContainedParent(root, relative);
343
+ const current = await reopen(relative, () => openContainedParent(root, relative));
271
344
  try {
272
345
  if (!sameIdentity(await expected.stat(), await current.handle.stat())) {
273
- throw new Error("Contained parent identity changed during authorization");
346
+ throw new ContainedPathChangedError(relative);
274
347
  }
275
348
  } finally {
276
349
  await current.handle.close();
@@ -310,101 +383,4 @@ async function readContainedUtf8Handle(handle, maxBytes) {
310
383
  };
311
384
  }
312
385
 
313
- // src/agent-runtime/contained-scan.ts
314
- async function walkContainedFiles(input) {
315
- const scan = await scanContainedFiles({ ...input, symlinks: "refuse" });
316
- if (scan.truncated)
317
- throw new Error("Contained file traversal exceeded its bounds");
318
- return scan.files;
319
- }
320
- async function scanContainedFiles(input) {
321
- const files = [];
322
- let truncated = false;
323
- let skippedDirectories = 0;
324
- let skippedSymlinks = 0;
325
- const denied = [];
326
- let deniedTruncated = false;
327
- const root = await openPinnedDirectory(input.root);
328
- const visit = async (directory, relativeDirectory, depth) => {
329
- if (truncated)
330
- return;
331
- if (depth > input.maxDepth) {
332
- truncated = true;
333
- return;
334
- }
335
- const entries = [...await listAt(directory)];
336
- entries.sort((left, right) => left.name.localeCompare(right.name));
337
- for (const entry of entries) {
338
- const relative = relativeDirectory ? path2.join(relativeDirectory, entry.name) : entry.name;
339
- const kind = entry.isDirectory() ? "directory" : entry.isSymbolicLink() ? "symlink" : entry.isFile() ? "file" : "other";
340
- if (kind === "file" && input.includeFile && !input.includeFile(relative))
341
- continue;
342
- if (input.authorizePath && !await input.authorizePath(relative, kind)) {
343
- if (denied.length < input.maxFiles)
344
- denied.push({ relative, kind });
345
- else
346
- deniedTruncated = true;
347
- continue;
348
- }
349
- if (entry.isSymbolicLink()) {
350
- if (input.symlinks === "refuse") {
351
- throw new Error(`Contained file traversal refuses symlink: ${relative}`);
352
- }
353
- skippedSymlinks += 1;
354
- continue;
355
- }
356
- if (entry.isDirectory()) {
357
- if (input.excludeDirectory?.(relative)) {
358
- skippedDirectories += 1;
359
- continue;
360
- }
361
- let child;
362
- try {
363
- child = await openDirectoryAt(directory, entry.name);
364
- } catch (error) {
365
- if (input.symlinks === "skip") {
366
- skippedSymlinks += 1;
367
- continue;
368
- }
369
- throw error;
370
- }
371
- try {
372
- await visit(child, relative, depth + 1);
373
- } finally {
374
- await child.close();
375
- }
376
- continue;
377
- }
378
- if (!entry.isFile())
379
- continue;
380
- if (files.length >= input.maxFiles) {
381
- truncated = true;
382
- return;
383
- }
384
- let content;
385
- if (input.readMaxBytes !== undefined) {
386
- try {
387
- const handle = await openFileAt(directory, entry.name);
388
- try {
389
- content = await readContainedUtf8Handle(handle, input.readMaxBytes);
390
- } finally {
391
- await handle.close();
392
- }
393
- } catch (error) {
394
- if (input.skipUnreadable)
395
- continue;
396
- throw error;
397
- }
398
- }
399
- files.push({ absolute: relative, relative, ...content && { content } });
400
- }
401
- };
402
- try {
403
- await visit(root, "", 0);
404
- } finally {
405
- await root.close();
406
- }
407
- return { files, truncated, skippedDirectories, skippedSymlinks, denied, deniedTruncated };
408
- }
409
-
410
- export { NumericFileHandle, descriptorPath, listContainedDirectory, missingContainedDirectories, openContainedParent, openContainedFile, assertContainedFileCurrent, assertContainedParentCurrent, containedEntryMetadata, openContainedParentFile, readContainedUtf8Handle, walkContainedFiles, scanContainedFiles };
386
+ export { descriptorPath, NumericFileHandle, openDirectoryAt, openPinnedDirectory, isSafeEntryName, openFileAt, listAt, listContainedDirectory, missingContainedDirectories, UnapprovedContainedDirectoryError, openContainedParent, openContainedFile, ContainedPathChangedError, assertContainedFileCurrent, assertContainedParentCurrent, containedEntryMetadata, openContainedParentFile, readContainedUtf8Handle };
@@ -134,6 +134,12 @@ function createKeyLayerStack2(target) {
134
134
  if (!entries.delete(entry))
135
135
  return;
136
136
  sync();
137
+ },
138
+ restore() {
139
+ if (entries.has(entry))
140
+ return;
141
+ entries.add(entry);
142
+ sync();
137
143
  }
138
144
  };
139
145
  }
@@ -3,7 +3,7 @@ import {
3
3
  ProcessInstanceSchema2,
4
4
  readProcessInstance,
5
5
  probeProcessOwner2
6
- } from "./index-bh2ht9y5.js";
6
+ } from "./index-n8z3rvzw.js";
7
7
  import {
8
8
  BoundedFileReadError,
9
9
  readBoundedFile
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  attemptExclusiveLock
3
- } from "./index-5v5a9k2n.js";
3
+ } from "./index-z3d6smer.js";
4
4
  import {
5
5
  sleep
6
6
  } from "./index-eemvahkc.js";
@@ -1 +1 @@
1
- {"version":3,"file":"atomic-file.d.ts","sourceRoot":"","sources":["../../src/internal/atomic-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,OAAO,EACL,KAAK,oBAAoB,EAG1B,MAAM,sBAAsB,CAAC;AAI9B,0EAA0E;AAC1E,MAAM,WAAW,sBAAsB;IACrC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,WAAW,CAAC;CAC5C;AAQD,wEAAwE;AACxE,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC5F,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,IA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wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,UAAU,GAAG,MAAM,EACzB,OAAO,GAAE,sBAA2B,GACnC,IAAI,CAEN"}
@@ -1 +1 @@
1
- {"version":3,"file":"atomic-staging.d.ts","sourceRoot":"","sources":["../../src/internal/atomic-staging.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAaH,mGAAmG;AACnG,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,4FAA4F;AAC5F,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAElD;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED,6CAA6C;AAC7C,MAAM,WAAW,yBAAyB;IACxC,oEAAoE;IACpE,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,2EAA2E;IAC3E,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAQD;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,MAAM,EAAE,CAAC,CA6BnB"}
1
+ {"version":3,"file":"atomic-staging.d.ts","sourceRoot":"","sources":["../../src/internal/atomic-staging.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAcH,mGAAmG;AACnG,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,4FAA4F;AAC5F,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAElD;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED,6CAA6C;AAC7C,MAAM,WAAW,yBAAyB;IACxC,oEAAoE;IACpE,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,2EAA2E;IAC3E,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAMD;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,MAAM,EAAE,CAAC,CA6BnB"}
@@ -0,0 +1,20 @@
1
+ import { type ContainedFileHandle } from './contained-handle.js';
2
+ /** Open one child directory without following a symbolic link. */
3
+ export declare function openDirectoryAt(directory: ContainedFileHandle, name: string, searchOnly?: boolean): Promise<ContainedFileHandle>;
4
+ /** Move a walk to `next`; a failure to close the previous step does not leak the new one. */
5
+ export declare function descend(current: ContainedFileHandle, next: ContainedFileHandle): Promise<ContainedFileHandle>;
6
+ /** Create one directory through its pinned parent; false if an entry already exists. */
7
+ export declare function createDirectoryAt(directory: ContainedFileHandle, name: string): Promise<boolean>;
8
+ /**
9
+ * Select the configured root once, then walk its canonical components through directory
10
+ * descriptors. Initial root aliases are configuration; symlinks introduced after that
11
+ * selection cannot redirect the walk. Missing descendants are created through the same
12
+ * pinned parents. The returned capability remains the selected directory if it is renamed.
13
+ */
14
+ export declare function openPinnedDirectory(absolute: string, options?: {
15
+ create?: boolean;
16
+ readable?: boolean;
17
+ }, io?: {
18
+ realpath(path: string): Promise<string>;
19
+ }): Promise<ContainedFileHandle>;
20
+ //# sourceMappingURL=contained-directory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contained-directory.d.ts","sourceRoot":"","sources":["../../src/internal/contained-directory.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,mBAAmB,EAGzB,MAAM,oBAAoB,CAAC;AAkB5B,kEAAkE;AAClE,wBAAsB,eAAe,CACnC,SAAS,EAAE,mBAAmB,EAC9B,IAAI,EAAE,MAAM,EACZ,UAAU,UAAQ,GACjB,OAAO,CAAC,mBAAmB,CAAC,CAO9B;AAED,6FAA6F;AAC7F,wBAAsB,OAAO,CAC3B,OAAO,EAAE,mBAAmB,EAC5B,IAAI,EAAE,mBAAmB,GACxB,OAAO,CAAC,mBAAmB,CAAC,CAQ9B;AAED,wFAAwF;AACxF,wBAAsB,iBAAiB,CACrC,SAAS,EAAE,mBAAmB,EAC9B,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,OAAO,CAAC,CAWlB;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAO,EACtD,EAAE,GAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;CAAiB,GAC7D,OAAO,CAAC,mBAAmB,CAAC,CA0C9B"}
@@ -1,4 +1,4 @@
1
- import { type Stats } from 'node:fs';
1
+ import { type ContainedFileHandle } from './contained-handle.js';
2
2
  export interface ContainedFile {
3
3
  absolute: string;
4
4
  relative: string;
@@ -27,17 +27,8 @@ export interface ContainedFileScan {
27
27
  deniedTruncated: boolean;
28
28
  }
29
29
  export type ContainedEntryKind = 'file' | 'directory' | 'symlink' | 'other';
30
- export interface ContainedFileHandle {
31
- readonly fd: number;
32
- close(): Promise<void>;
33
- read(buffer: Buffer, offset: number, length: number, position: number): Promise<{
34
- bytesRead: number;
35
- }>;
36
- stat(): Promise<Stats>;
37
- }
38
- export declare function descriptorPath(handle: ContainedFileHandle): string;
39
- export declare function openPinnedDirectory(absolute: string): Promise<ContainedFileHandle>;
40
- export declare function openDirectoryAt(directory: ContainedFileHandle, name: string): Promise<ContainedFileHandle>;
30
+ /** One entry name a directory-relative call may receive: never a walk and never truncated by NUL. */
31
+ export declare function isSafeEntryName(name: string): boolean;
41
32
  export declare function openFileAt(directory: ContainedFileHandle, name: string): Promise<ContainedFileHandle>;
42
33
  interface ContainedEntryMetadata {
43
34
  mode: number;
@@ -80,11 +71,21 @@ export interface ContainedParent {
80
71
  * happens, and cannot do that without knowing what would be created.
81
72
  */
82
73
  export declare function missingContainedDirectories(root: string, relative: string): Promise<string[]>;
74
+ /** A directory vanished after the host approved a different creation plan. */
75
+ export declare class UnapprovedContainedDirectoryError extends Error {
76
+ readonly relative: string;
77
+ constructor(relative: string);
78
+ }
83
79
  export declare function openContainedParent(root: string, relative: string, options?: {
84
- create?: boolean;
80
+ createDirectories?: readonly string[];
85
81
  }): Promise<ContainedParent>;
86
82
  /** Open a final regular-file candidate through pinned ancestors without following symlinks. */
87
83
  export declare function openContainedFile(root: string, relative: string): Promise<ContainedFileHandle>;
84
+ /** What was checked is no longer what the path names; the caller can look again. */
85
+ export declare class ContainedPathChangedError extends Error {
86
+ readonly relative: string;
87
+ constructor(relative: string);
88
+ }
88
89
  export declare function assertContainedFileCurrent(root: string, relative: string, expected: ContainedFileHandle): Promise<void>;
89
90
  export declare function assertContainedParentCurrent(root: string, relative: string, expected: ContainedFileHandle): Promise<void>;
90
91
  export declare function containedEntryMetadata(parent: ContainedParent): Promise<ContainedEntryMetadata | null>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contained-files.d.ts","sourceRoot":"","sources":["../../src/internal/contained-files.ts"],"names":[],"mappings":"AASA,OAAO,EACL,KAAK,mBAAmB,EAOzB,MAAM,oBAAoB,CAAC;AAI5B,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CACzD;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,SAAS,aAAa,EAAE,CAAC;IAChC,SAAS,EAAE,OAAO,CAAC;IACnB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB;;;;;OAKG;IACH,MAAM,EAAE,SAAS;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,kBAAkB,CAAA;KAA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MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CAExC;AAED,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,mBAAmB,CAAC,CAO9B;AAED,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,mBAAmB,EAC3B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAsBxD;AAED,yFAAyF;AACzF,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAOxD"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * The shared contained-file capability and its platform descriptor adapters.
3
+ * Darwin native calls return numeric descriptors; Linux also exposes descriptor paths.
4
+ */
5
+ import { type Stats } from 'node:fs';
6
+ export interface ContainedFileHandle {
7
+ readonly fd: number;
8
+ close(): Promise<void>;
9
+ read(buffer: Buffer, offset: number, length: number, position: number): Promise<{
10
+ bytesRead: number;
11
+ }>;
12
+ stat(): Promise<Stats>;
13
+ }
14
+ export declare function descriptorPath(handle: ContainedFileHandle): string;
15
+ export declare const FILE_TYPE_DIRECTORY = 16384;
16
+ export declare const FILE_TYPE_REGULAR = 32768;
17
+ export declare const FILE_TYPE_SYMLINK = 40960;
18
+ export declare function modeIs(mode: number, type: number): boolean;
19
+ export declare class NumericFileHandle implements ContainedFileHandle {
20
+ readonly fd: number;
21
+ private closed;
22
+ constructor(fd: number);
23
+ /** Once only: the number may already name another file, and a walk's cleanup can repeat this. */
24
+ close(): Promise<void>;
25
+ read(buffer: Buffer, offset: number, length: number, position: number): Promise<{
26
+ bytesRead: number;
27
+ }>;
28
+ stat(): Promise<Stats>;
29
+ }
30
+ //# sourceMappingURL=contained-handle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contained-handle.d.ts","sourceRoot":"","sources":["../../src/internal/contained-handle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAA2D,KAAK,KAAK,EAAE,MAAM,SAAS,CAAC;AAE9F,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,IAAI,CACF,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClC,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC;CACxB;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM,CAGlE;AAGD,eAAO,MAAM,mBAAmB,QAAW,CAAC;AAC5C,eAAO,MAAM,iBAAiB,QAAW,CAAC;AAC1C,eAAO,MAAM,iBAAiB,QAAW,CAAC;AAE1C,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,qBAAa,iBAAkB,YAAW,mBAAmB;IAG/C,QAAQ,CAAC,EAAE,EAAE,MAAM;IAF/B,OAAO,CAAC,MAAM,CAAS;IAEvB,YAAqB,EAAE,EAAE,MAAM,EAAI;IAEnC,iGAAiG;IACjG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAMrB;IAED,IAAI,CACF,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAMhC;IAED,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,CAIrB;CACF"}
@@ -0,0 +1,12 @@
1
+ import type { ContainedParent } from './contained-files.js';
2
+ /**
3
+ * Create or atomically replace one direct child through the pinned parent descriptor.
4
+ * `mode` keeps permission bits only: new content must not inherit setuid, setgid or sticky.
5
+ */
6
+ export declare function writeContainedFile(input: {
7
+ parent: ContainedParent;
8
+ content: string | Uint8Array;
9
+ replace: boolean;
10
+ mode?: number;
11
+ }): Promise<void>;
12
+ //# sourceMappingURL=contained-write.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contained-write.d.ts","sourceRoot":"","sources":["../../src/internal/contained-write.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAoHzD;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,KAAK,EAAE;IAC9C,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,EAAE,MAAM,GAAG,UAAU,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,OAAO,CAAC,IAAI,CAAC,CAehB"}
@@ -5,7 +5,7 @@ export interface DarwinEntry {
5
5
  }
6
6
  export interface DarwinBinding {
7
7
  processIdentity(pid: number): unknown;
8
- openDirectoryAt(directory: number, name: string): number;
8
+ openDirectoryAt(directory: number, name: string, searchOnly: boolean): number;
9
9
  openFileAt(directory: number, name: string): number;
10
10
  createFileAt(directory: number, name: string, mode: number): number;
11
11
  createDirectoryAt(directory: number, name: string, mode: number): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"darwin-binding.d.ts","sourceRoot":"","sources":["../../src/internal/darwin-binding.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,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