@vercel/sandbox 2.0.0-beta.2 → 2.0.0-beta.20

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 (208) hide show
  1. package/README.md +48 -1
  2. package/dist/_virtual/rolldown_runtime.cjs +29 -0
  3. package/dist/api-client/api-client.cjs +445 -0
  4. package/dist/api-client/api-client.cjs.map +1 -0
  5. package/dist/api-client/api-client.d.cts +6235 -0
  6. package/dist/api-client/api-client.d.ts +6229 -706
  7. package/dist/api-client/api-client.js +436 -472
  8. package/dist/api-client/api-client.js.map +1 -1
  9. package/dist/api-client/api-error.cjs +32 -0
  10. package/dist/api-client/api-error.cjs.map +1 -0
  11. package/dist/api-client/api-error.d.cts +29 -0
  12. package/dist/api-client/api-error.d.ts +21 -16
  13. package/dist/api-client/api-error.js +28 -32
  14. package/dist/api-client/api-error.js.map +1 -1
  15. package/dist/api-client/base-client.cjs +126 -0
  16. package/dist/api-client/base-client.cjs.map +1 -0
  17. package/dist/api-client/base-client.d.cts +38 -0
  18. package/dist/api-client/base-client.d.ts +31 -36
  19. package/dist/api-client/base-client.js +114 -118
  20. package/dist/api-client/base-client.js.map +1 -1
  21. package/dist/api-client/file-writer.cjs +62 -0
  22. package/dist/api-client/file-writer.cjs.map +1 -0
  23. package/dist/api-client/file-writer.d.cts +66 -0
  24. package/dist/api-client/file-writer.d.ts +56 -42
  25. package/dist/api-client/file-writer.js +57 -61
  26. package/dist/api-client/file-writer.js.map +1 -1
  27. package/dist/api-client/index.cjs +2 -0
  28. package/dist/api-client/index.d.ts +2 -2
  29. package/dist/api-client/index.js +4 -21
  30. package/dist/api-client/validators.cjs +229 -0
  31. package/dist/api-client/validators.cjs.map +1 -0
  32. package/dist/api-client/validators.d.cts +26885 -0
  33. package/dist/api-client/validators.d.ts +26732 -3706
  34. package/dist/api-client/validators.js +198 -191
  35. package/dist/api-client/validators.js.map +1 -1
  36. package/dist/api-client/with-retry.cjs +89 -0
  37. package/dist/api-client/with-retry.cjs.map +1 -0
  38. package/dist/api-client/with-retry.d.cts +10 -0
  39. package/dist/api-client/with-retry.d.ts +9 -13
  40. package/dist/api-client/with-retry.js +81 -102
  41. package/dist/api-client/with-retry.js.map +1 -1
  42. package/dist/auth/api.cjs +29 -0
  43. package/dist/auth/api.cjs.map +1 -0
  44. package/dist/auth/api.js +26 -25
  45. package/dist/auth/api.js.map +1 -1
  46. package/dist/auth/error.cjs +13 -0
  47. package/dist/auth/error.cjs.map +1 -0
  48. package/dist/auth/error.js +11 -11
  49. package/dist/auth/error.js.map +1 -1
  50. package/dist/auth/file.cjs +64 -0
  51. package/dist/auth/file.cjs.map +1 -0
  52. package/dist/auth/file.d.cts +26 -0
  53. package/dist/auth/file.d.ts +19 -15
  54. package/dist/auth/file.js +49 -64
  55. package/dist/auth/file.js.map +1 -1
  56. package/dist/auth/index.cjs +11 -0
  57. package/dist/auth/index.d.cts +5 -0
  58. package/dist/auth/index.d.ts +5 -6
  59. package/dist/auth/index.js +6 -27
  60. package/dist/auth/linked-project.cjs +38 -0
  61. package/dist/auth/linked-project.cjs.map +1 -0
  62. package/dist/auth/linked-project.js +30 -64
  63. package/dist/auth/linked-project.js.map +1 -1
  64. package/dist/auth/oauth.cjs +205 -0
  65. package/dist/auth/oauth.cjs.map +1 -0
  66. package/dist/auth/oauth.d.cts +135 -0
  67. package/dist/auth/oauth.d.ts +113 -109
  68. package/dist/auth/oauth.js +185 -252
  69. package/dist/auth/oauth.js.map +1 -1
  70. package/dist/auth/poll-for-token.cjs +82 -0
  71. package/dist/auth/poll-for-token.cjs.map +1 -0
  72. package/dist/auth/poll-for-token.d.cts +28 -0
  73. package/dist/auth/poll-for-token.d.ts +23 -15
  74. package/dist/auth/poll-for-token.js +79 -64
  75. package/dist/auth/poll-for-token.js.map +1 -1
  76. package/dist/auth/project.cjs +178 -0
  77. package/dist/auth/project.cjs.map +1 -0
  78. package/dist/auth/project.d.cts +40 -0
  79. package/dist/auth/project.d.ts +19 -19
  80. package/dist/auth/project.js +169 -72
  81. package/dist/auth/project.js.map +1 -1
  82. package/dist/auth/zod.cjs +22 -0
  83. package/dist/auth/zod.cjs.map +1 -0
  84. package/dist/auth/zod.js +18 -17
  85. package/dist/auth/zod.js.map +1 -1
  86. package/dist/command.cjs +328 -0
  87. package/dist/command.cjs.map +1 -0
  88. package/dist/command.d.cts +289 -0
  89. package/dist/command.d.ts +265 -171
  90. package/dist/command.js +323 -226
  91. package/dist/command.js.map +1 -1
  92. package/dist/constants.d.cts +5 -0
  93. package/dist/constants.d.ts +5 -1
  94. package/dist/filesystem.cjs +499 -0
  95. package/dist/filesystem.cjs.map +1 -0
  96. package/dist/filesystem.d.cts +258 -0
  97. package/dist/filesystem.d.ts +258 -0
  98. package/dist/filesystem.js +497 -0
  99. package/dist/filesystem.js.map +1 -0
  100. package/dist/index.cjs +15 -0
  101. package/dist/index.d.cts +8 -0
  102. package/dist/index.d.ts +8 -6
  103. package/dist/index.js +8 -17
  104. package/dist/network-policy.d.cts +156 -0
  105. package/dist/network-policy.d.ts +88 -28
  106. package/dist/sandbox.cjs +816 -0
  107. package/dist/sandbox.cjs.map +1 -0
  108. package/dist/sandbox.d.cts +2847 -0
  109. package/dist/sandbox.d.ts +2834 -628
  110. package/dist/sandbox.js +808 -557
  111. package/dist/sandbox.js.map +1 -1
  112. package/dist/session.cjs +527 -0
  113. package/dist/session.cjs.map +1 -0
  114. package/dist/session.d.cts +410 -0
  115. package/dist/session.d.ts +403 -368
  116. package/dist/session.js +524 -489
  117. package/dist/session.js.map +1 -1
  118. package/dist/snapshot.cjs +204 -0
  119. package/dist/snapshot.cjs.map +1 -0
  120. package/dist/snapshot.d.cts +161 -0
  121. package/dist/snapshot.d.ts +152 -92
  122. package/dist/snapshot.js +201 -114
  123. package/dist/snapshot.js.map +1 -1
  124. package/dist/utils/array.cjs +17 -0
  125. package/dist/utils/array.cjs.map +1 -0
  126. package/dist/utils/array.js +12 -15
  127. package/dist/utils/array.js.map +1 -1
  128. package/dist/utils/consume-readable.cjs +18 -0
  129. package/dist/utils/consume-readable.cjs.map +1 -0
  130. package/dist/utils/consume-readable.js +13 -12
  131. package/dist/utils/consume-readable.js.map +1 -1
  132. package/dist/utils/decode-base64-url.cjs +15 -0
  133. package/dist/utils/decode-base64-url.cjs.map +1 -0
  134. package/dist/utils/decode-base64-url.js +10 -9
  135. package/dist/utils/decode-base64-url.js.map +1 -1
  136. package/dist/utils/dev-credentials.cjs +142 -0
  137. package/dist/utils/dev-credentials.cjs.map +1 -0
  138. package/dist/utils/dev-credentials.js +126 -184
  139. package/dist/utils/dev-credentials.js.map +1 -1
  140. package/dist/utils/get-credentials.cjs +123 -0
  141. package/dist/utils/get-credentials.cjs.map +1 -0
  142. package/dist/utils/get-credentials.d.cts +21 -0
  143. package/dist/utils/get-credentials.d.ts +19 -61
  144. package/dist/utils/get-credentials.js +106 -140
  145. package/dist/utils/get-credentials.js.map +1 -1
  146. package/dist/utils/log.cjs +25 -0
  147. package/dist/utils/log.cjs.map +1 -0
  148. package/dist/utils/log.js +15 -17
  149. package/dist/utils/log.js.map +1 -1
  150. package/dist/utils/network-policy.cjs +49 -0
  151. package/dist/utils/network-policy.cjs.map +1 -0
  152. package/dist/utils/network-policy.js +42 -77
  153. package/dist/utils/network-policy.js.map +1 -1
  154. package/dist/utils/normalizePath.cjs +27 -0
  155. package/dist/utils/normalizePath.cjs.map +1 -0
  156. package/dist/utils/normalizePath.js +21 -28
  157. package/dist/utils/normalizePath.js.map +1 -1
  158. package/dist/utils/paginator.cjs +41 -0
  159. package/dist/utils/paginator.cjs.map +1 -0
  160. package/dist/utils/paginator.d.cts +16 -0
  161. package/dist/utils/paginator.d.ts +16 -0
  162. package/dist/utils/paginator.js +40 -0
  163. package/dist/utils/paginator.js.map +1 -0
  164. package/dist/utils/resolveSignal.cjs +20 -0
  165. package/dist/utils/resolveSignal.cjs.map +1 -0
  166. package/dist/utils/resolveSignal.d.cts +15 -0
  167. package/dist/utils/resolveSignal.d.ts +12 -10
  168. package/dist/utils/resolveSignal.js +14 -17
  169. package/dist/utils/resolveSignal.js.map +1 -1
  170. package/dist/utils/sandbox-snapshot.cjs +14 -0
  171. package/dist/utils/sandbox-snapshot.cjs.map +1 -0
  172. package/dist/utils/sandbox-snapshot.d.cts +10 -0
  173. package/dist/utils/sandbox-snapshot.d.ts +11 -0
  174. package/dist/utils/sandbox-snapshot.js +14 -0
  175. package/dist/utils/sandbox-snapshot.js.map +1 -0
  176. package/dist/utils/types.cjs +13 -0
  177. package/dist/utils/types.cjs.map +1 -0
  178. package/dist/utils/types.d.cts +11 -0
  179. package/dist/utils/types.d.ts +5 -7
  180. package/dist/utils/types.js +8 -8
  181. package/dist/utils/types.js.map +1 -1
  182. package/dist/version.cjs +7 -0
  183. package/dist/version.cjs.map +1 -0
  184. package/dist/version.js +5 -5
  185. package/dist/version.js.map +1 -1
  186. package/package.json +23 -3
  187. package/dist/api-client/index.js.map +0 -1
  188. package/dist/auth/api.d.ts +0 -6
  189. package/dist/auth/error.d.ts +0 -11
  190. package/dist/auth/index.js.map +0 -1
  191. package/dist/auth/linked-project.d.ts +0 -10
  192. package/dist/auth/zod.d.ts +0 -5
  193. package/dist/constants.js +0 -3
  194. package/dist/constants.js.map +0 -1
  195. package/dist/index.js.map +0 -1
  196. package/dist/network-policy.js +0 -3
  197. package/dist/network-policy.js.map +0 -1
  198. package/dist/utils/array.d.ts +0 -9
  199. package/dist/utils/consume-readable.d.ts +0 -5
  200. package/dist/utils/convert-sandbox.d.ts +0 -6
  201. package/dist/utils/convert-sandbox.js +0 -14
  202. package/dist/utils/convert-sandbox.js.map +0 -1
  203. package/dist/utils/decode-base64-url.d.ts +0 -7
  204. package/dist/utils/dev-credentials.d.ts +0 -37
  205. package/dist/utils/log.d.ts +0 -2
  206. package/dist/utils/network-policy.d.ts +0 -7
  207. package/dist/utils/normalizePath.d.ts +0 -17
  208. package/dist/version.d.ts +0 -1
@@ -0,0 +1,497 @@
1
+ import * as constants from "node:constants";
2
+
3
+ //#region src/filesystem.ts
4
+ const { S_IFMT, S_IFREG, S_IFDIR, S_IFLNK, S_IFBLK, S_IFCHR, S_IFIFO, S_IFSOCK } = constants;
5
+ const UV_DIRENT_FILE = 1;
6
+ const UV_DIRENT_DIR = 2;
7
+ const UV_DIRENT_LINK = 3;
8
+ const UV_DIRENT_FIFO = 4;
9
+ const UV_DIRENT_SOCKET = 5;
10
+ const UV_DIRENT_CHAR = 6;
11
+ const UV_DIRENT_BLOCK = 7;
12
+ function fsError(code, message, syscall, path) {
13
+ const err = /* @__PURE__ */ new Error(`${code}: ${message}, ${syscall} '${path}'`);
14
+ err.code = code;
15
+ err.syscall = syscall;
16
+ err.path = path;
17
+ return err;
18
+ }
19
+ function parseEncoding(options) {
20
+ if (options === null || options === void 0) return { encoding: null };
21
+ if (typeof options === "string") return { encoding: options };
22
+ return {
23
+ encoding: options.encoding ?? null,
24
+ signal: options.signal
25
+ };
26
+ }
27
+ var SandboxStats = class {
28
+ constructor(dev, _mode, nlink, uid, gid, rdev, blksize, ino, size, blocks, atimeMs, mtimeMs, ctimeMs, birthtimeMs) {
29
+ this.dev = dev;
30
+ this._mode = _mode;
31
+ this.nlink = nlink;
32
+ this.uid = uid;
33
+ this.gid = gid;
34
+ this.rdev = rdev;
35
+ this.blksize = blksize;
36
+ this.ino = ino;
37
+ this.size = size;
38
+ this.blocks = blocks;
39
+ this.atimeMs = atimeMs;
40
+ this.mtimeMs = mtimeMs;
41
+ this.ctimeMs = ctimeMs;
42
+ this.birthtimeMs = birthtimeMs;
43
+ this.atime = new Date(atimeMs);
44
+ this.mtime = new Date(mtimeMs);
45
+ this.ctime = new Date(ctimeMs);
46
+ this.birthtime = new Date(birthtimeMs);
47
+ }
48
+ get mode() {
49
+ return this._mode;
50
+ }
51
+ isFile() {
52
+ return (this.mode & S_IFMT) === S_IFREG;
53
+ }
54
+ isDirectory() {
55
+ return (this.mode & S_IFMT) === S_IFDIR;
56
+ }
57
+ isBlockDevice() {
58
+ return (this.mode & S_IFMT) === S_IFBLK;
59
+ }
60
+ isCharacterDevice() {
61
+ return (this.mode & S_IFMT) === S_IFCHR;
62
+ }
63
+ isSymbolicLink() {
64
+ return (this.mode & S_IFMT) === S_IFLNK;
65
+ }
66
+ isFIFO() {
67
+ return (this.mode & S_IFMT) === S_IFIFO;
68
+ }
69
+ isSocket() {
70
+ return (this.mode & S_IFMT) === S_IFSOCK;
71
+ }
72
+ };
73
+ var SandboxDirent = class {
74
+ constructor(name, type, parentPath) {
75
+ this.name = name;
76
+ this.type = type;
77
+ this.parentPath = parentPath;
78
+ this.path = `${this.parentPath}/${this.name}`;
79
+ }
80
+ isFile() {
81
+ return this.type === UV_DIRENT_FILE;
82
+ }
83
+ isDirectory() {
84
+ return this.type === UV_DIRENT_DIR;
85
+ }
86
+ isBlockDevice() {
87
+ return this.type === UV_DIRENT_BLOCK;
88
+ }
89
+ isCharacterDevice() {
90
+ return this.type === UV_DIRENT_CHAR;
91
+ }
92
+ isSymbolicLink() {
93
+ return this.type === UV_DIRENT_LINK;
94
+ }
95
+ isFIFO() {
96
+ return this.type === UV_DIRENT_FIFO;
97
+ }
98
+ isSocket() {
99
+ return this.type === UV_DIRENT_SOCKET;
100
+ }
101
+ };
102
+ function parseStat(stdout) {
103
+ const parts = stdout.trim().split("|");
104
+ return new SandboxStats(parseInt(parts[10], 10), parseInt(parts[1], 16), parseInt(parts[8], 10), parseInt(parts[2], 10), parseInt(parts[3], 10), 0, parseInt(parts[11], 10), parseInt(parts[9], 10), parseInt(parts[0], 10), parseInt(parts[12], 10), parseFloat(parts[4]) * 1e3, parseFloat(parts[5]) * 1e3, parseFloat(parts[6]) * 1e3, parseFloat(parts[7]) * 1e3);
105
+ }
106
+ function parseDirent(stdout, path) {
107
+ const parts = stdout.trim().split("|");
108
+ const name = parts[0];
109
+ const type = parts[1];
110
+ if (!name) throw fsError("ENOENT", "no such file or directory", "readdir", path);
111
+ if (!type) throw new Error(`Invalid dirent type: ${type}`);
112
+ return new SandboxDirent(name, FIND_TYPE_TO_DIRENT[type] ?? UV_DIRENT_FILE, path);
113
+ }
114
+ const STAT_FORMAT = "%s|%f|%u|%g|%X|%Y|%Z|%W|%h|%i|%d|%B|%b";
115
+ const FIND_TYPE_TO_DIRENT = {
116
+ f: UV_DIRENT_FILE,
117
+ d: UV_DIRENT_DIR,
118
+ l: UV_DIRENT_LINK,
119
+ b: UV_DIRENT_BLOCK,
120
+ c: UV_DIRENT_CHAR,
121
+ p: UV_DIRENT_FIFO,
122
+ s: UV_DIRENT_SOCKET
123
+ };
124
+ var FileSystem = class {
125
+ /** @internal */
126
+ constructor(sandbox) {
127
+ this.sandbox = sandbox;
128
+ }
129
+ async readFile(path, options) {
130
+ "use step";
131
+ const { encoding, signal } = parseEncoding(options);
132
+ const buffer = await this.sandbox.readFileToBuffer({ path }, { signal });
133
+ if (buffer === null) throw fsError("ENOENT", "no such file or directory", "open", path);
134
+ return encoding ? buffer.toString(encoding) : buffer;
135
+ }
136
+ /**
137
+ * Write data to a file, replacing the file if it already exists.
138
+ *
139
+ * @param path - Path to the file
140
+ * @param data - The data to write
141
+ * @param options - Write options
142
+ */
143
+ async writeFile(path, data, options) {
144
+ "use step";
145
+ const { encoding, signal } = typeof options === "string" ? {
146
+ encoding: options,
147
+ signal: void 0
148
+ } : {
149
+ encoding: options?.encoding,
150
+ signal: options?.signal
151
+ };
152
+ let content;
153
+ if (typeof data === "string") content = Buffer.from(data, encoding ?? "utf8");
154
+ else if (Buffer.isBuffer(data)) content = data;
155
+ else content = Buffer.from(data);
156
+ await this.sandbox.writeFiles([{
157
+ path,
158
+ content
159
+ }], { signal });
160
+ }
161
+ /**
162
+ * Append data to a file, creating the file if it does not yet exist.
163
+ *
164
+ * @param path - Path to the file
165
+ * @param data - The data to append
166
+ * @param options - Write options
167
+ */
168
+ async appendFile(path, data, options) {
169
+ "use step";
170
+ const { encoding, signal } = typeof options === "string" ? {
171
+ encoding: options,
172
+ signal: void 0
173
+ } : {
174
+ encoding: options?.encoding,
175
+ signal: options?.signal
176
+ };
177
+ let appendContent;
178
+ if (typeof data === "string") appendContent = Buffer.from(data, encoding ?? "utf8");
179
+ else if (Buffer.isBuffer(data)) appendContent = data;
180
+ else appendContent = Buffer.from(data);
181
+ const existing = await this.sandbox.readFileToBuffer({ path }, { signal });
182
+ const content = existing !== null ? Buffer.concat([existing, appendContent]) : appendContent;
183
+ await this.sandbox.writeFiles([{
184
+ path,
185
+ content
186
+ }], { signal });
187
+ }
188
+ /**
189
+ * Create a directory.
190
+ *
191
+ * @param path - Path of the directory to create
192
+ * @param options - Options for directory creation
193
+ */
194
+ async mkdir(path, options) {
195
+ "use step";
196
+ const opts = typeof options === "number" ? { recursive: false } : options ?? {};
197
+ if (opts.recursive) {
198
+ const result = await this.sandbox.runCommand("mkdir", ["-p", path], { signal: opts.signal });
199
+ if (result.exitCode !== 0) throw fsError("EACCES", (await result.stderr()).trim() || "permission denied", "mkdir", path);
200
+ return;
201
+ }
202
+ await this.sandbox.mkDir(path, { signal: opts.signal });
203
+ }
204
+ async readdir(path, options) {
205
+ "use step";
206
+ if (options?.withFileTypes) {
207
+ const result$1 = await this.sandbox.runCommand("find", [
208
+ path,
209
+ "-maxdepth",
210
+ "1",
211
+ "-mindepth",
212
+ "1",
213
+ "-printf",
214
+ "%f|%y\\n"
215
+ ], { signal: options?.signal });
216
+ if (result$1.exitCode !== 0) {
217
+ const stderr = await result$1.stderr();
218
+ if (stderr.includes("No such file or directory")) throw fsError("ENOENT", "no such file or directory", "scandir", path);
219
+ throw fsError("EACCES", stderr.trim(), "scandir", path);
220
+ }
221
+ return (await result$1.stdout()).trim().split("\n").filter(Boolean).map((line) => parseDirent(line, path));
222
+ }
223
+ const result = await this.sandbox.runCommand("ls", ["-1", path], { signal: options?.signal });
224
+ if (result.exitCode !== 0) {
225
+ const stderr = await result.stderr();
226
+ if (stderr.includes("No such file or directory")) throw fsError("ENOENT", "no such file or directory", "scandir", path);
227
+ throw fsError("EACCES", stderr.trim(), "scandir", path);
228
+ }
229
+ return (await result.stdout()).trim().split("\n").filter(Boolean);
230
+ }
231
+ /**
232
+ * Get file status. Follows symbolic links.
233
+ *
234
+ * @param path - Path to the file
235
+ * @param options - Options
236
+ */
237
+ async stat(path, options) {
238
+ "use step";
239
+ const result = await this.sandbox.runCommand("stat", [
240
+ "-L",
241
+ "-c",
242
+ STAT_FORMAT,
243
+ path
244
+ ], { signal: options?.signal });
245
+ if (result.exitCode !== 0) {
246
+ const stderr = await result.stderr();
247
+ if (stderr.includes("No such file or directory")) throw fsError("ENOENT", "no such file or directory", "stat", path);
248
+ throw fsError("EACCES", stderr.trim(), "stat", path);
249
+ }
250
+ return parseStat(await result.stdout());
251
+ }
252
+ /**
253
+ * Get file status. Does not follow symbolic links.
254
+ *
255
+ * @param path - Path to the file
256
+ * @param options - Options
257
+ */
258
+ async lstat(path, options) {
259
+ "use step";
260
+ const result = await this.sandbox.runCommand("stat", [
261
+ "-c",
262
+ STAT_FORMAT,
263
+ path
264
+ ], { signal: options?.signal });
265
+ if (result.exitCode !== 0) {
266
+ const stderr = await result.stderr();
267
+ if (stderr.includes("No such file or directory")) throw fsError("ENOENT", "no such file or directory", "lstat", path);
268
+ throw fsError("EACCES", stderr.trim(), "lstat", path);
269
+ }
270
+ return parseStat(await result.stdout());
271
+ }
272
+ /**
273
+ * Remove a file or symbolic link.
274
+ *
275
+ * @param path - Path to the file
276
+ * @param options - Options
277
+ */
278
+ async unlink(path, options) {
279
+ "use step";
280
+ const result = await this.sandbox.runCommand("rm", [path], { signal: options?.signal });
281
+ if (result.exitCode !== 0) {
282
+ const stderr = await result.stderr();
283
+ if (stderr.includes("No such file or directory")) throw fsError("ENOENT", "no such file or directory", "unlink", path);
284
+ throw fsError("EACCES", stderr.trim(), "unlink", path);
285
+ }
286
+ }
287
+ /**
288
+ * Remove files and directories.
289
+ *
290
+ * @param path - Path to remove
291
+ * @param options - Options
292
+ */
293
+ async rm(path, options) {
294
+ "use step";
295
+ const args = [];
296
+ if (options?.recursive) args.push("-r");
297
+ if (options?.force) args.push("-f");
298
+ args.push(path);
299
+ const result = await this.sandbox.runCommand("rm", args, { signal: options?.signal });
300
+ if (result.exitCode !== 0) {
301
+ const stderr = await result.stderr();
302
+ if (stderr.includes("No such file or directory")) throw fsError("ENOENT", "no such file or directory", "rm", path);
303
+ throw fsError("EACCES", stderr.trim(), "rm", path);
304
+ }
305
+ }
306
+ /**
307
+ * Remove a directory.
308
+ *
309
+ * @param path - Path to the directory
310
+ * @param options - Options
311
+ */
312
+ async rmdir(path, options) {
313
+ "use step";
314
+ const result = await this.sandbox.runCommand("rmdir", [path], { signal: options?.signal });
315
+ if (result.exitCode !== 0) {
316
+ const stderr = await result.stderr();
317
+ if (stderr.includes("No such file or directory")) throw fsError("ENOENT", "no such file or directory", "rmdir", path);
318
+ if (stderr.includes("not empty")) throw fsError("ENOTEMPTY", "directory not empty", "rmdir", path);
319
+ throw fsError("EACCES", stderr.trim(), "rmdir", path);
320
+ }
321
+ }
322
+ /**
323
+ * Rename a file or directory.
324
+ *
325
+ * @param oldPath - Current path
326
+ * @param newPath - New path
327
+ * @param options - Options
328
+ */
329
+ async rename(oldPath, newPath, options) {
330
+ "use step";
331
+ const result = await this.sandbox.runCommand("mv", [oldPath, newPath], { signal: options?.signal });
332
+ if (result.exitCode !== 0) {
333
+ const stderr = await result.stderr();
334
+ if (stderr.includes("No such file or directory")) throw fsError("ENOENT", "no such file or directory", "rename", oldPath);
335
+ throw fsError("EACCES", stderr.trim(), "rename", oldPath);
336
+ }
337
+ }
338
+ /**
339
+ * Copy a file.
340
+ *
341
+ * @param src - Source path
342
+ * @param dest - Destination path
343
+ * @param options - Options
344
+ */
345
+ async copyFile(src, dest, options) {
346
+ "use step";
347
+ const result = await this.sandbox.runCommand("cp", [src, dest], { signal: options?.signal });
348
+ if (result.exitCode !== 0) {
349
+ const stderr = await result.stderr();
350
+ if (stderr.includes("No such file or directory")) throw fsError("ENOENT", "no such file or directory", "copyfile", src);
351
+ throw fsError("EACCES", stderr.trim(), "copyfile", src);
352
+ }
353
+ }
354
+ /**
355
+ * Test whether a file exists and the user has the specified permissions.
356
+ *
357
+ * @param path - Path to the file
358
+ * @param options - Options
359
+ */
360
+ async access(path, options) {
361
+ "use step";
362
+ if ((await this.sandbox.runCommand("test", ["-e", path], { signal: options?.signal })).exitCode !== 0) throw fsError("ENOENT", "no such file or directory", "access", path);
363
+ }
364
+ /**
365
+ * Check if a path exists.
366
+ *
367
+ * This is a convenience method not in `node:fs/promises` but commonly needed.
368
+ *
369
+ * @param path - Path to check
370
+ * @param options - Options
371
+ */
372
+ async exists(path, options) {
373
+ return (await this.sandbox.runCommand("test", ["-e", path], { signal: options?.signal })).exitCode === 0;
374
+ }
375
+ /**
376
+ * Change file mode (permissions).
377
+ *
378
+ * @param path - Path to the file
379
+ * @param mode - File mode (e.g., 0o755 or "755")
380
+ * @param options - Options
381
+ */
382
+ async chmod(path, mode, options) {
383
+ "use step";
384
+ const modeStr = typeof mode === "number" ? mode.toString(8) : mode;
385
+ const result = await this.sandbox.runCommand("chmod", [modeStr, path], { signal: options?.signal });
386
+ if (result.exitCode !== 0) {
387
+ const stderr = await result.stderr();
388
+ if (stderr.includes("No such file or directory")) throw fsError("ENOENT", "no such file or directory", "chmod", path);
389
+ throw fsError("EACCES", stderr.trim(), "chmod", path);
390
+ }
391
+ }
392
+ /**
393
+ * Change file owner and group.
394
+ *
395
+ * @param path - Path to the file
396
+ * @param uid - User ID
397
+ * @param gid - Group ID
398
+ * @param options - Options
399
+ */
400
+ async chown(path, uid, gid, options) {
401
+ "use step";
402
+ const result = await this.sandbox.runCommand("chown", [`${uid}:${gid}`, path], { signal: options?.signal });
403
+ if (result.exitCode !== 0) {
404
+ const stderr = await result.stderr();
405
+ if (stderr.includes("No such file or directory")) throw fsError("ENOENT", "no such file or directory", "chown", path);
406
+ throw fsError("EACCES", stderr.trim(), "chown", path);
407
+ }
408
+ }
409
+ /**
410
+ * Create a symbolic link.
411
+ *
412
+ * @param target - The target of the symbolic link
413
+ * @param path - The path of the symbolic link to create
414
+ * @param options - Options
415
+ */
416
+ async symlink(target, path, options) {
417
+ "use step";
418
+ const result = await this.sandbox.runCommand("ln", [
419
+ "-s",
420
+ target,
421
+ path
422
+ ], { signal: options?.signal });
423
+ if (result.exitCode !== 0) {
424
+ const stderr = await result.stderr();
425
+ if (stderr.includes("File exists")) throw fsError("EEXIST", "file already exists", "symlink", path);
426
+ throw fsError("EACCES", stderr.trim(), "symlink", path);
427
+ }
428
+ }
429
+ /**
430
+ * Read the value of a symbolic link.
431
+ *
432
+ * @param path - Path to the symbolic link
433
+ * @param options - Options
434
+ */
435
+ async readlink(path, options) {
436
+ "use step";
437
+ const result = await this.sandbox.runCommand("readlink", [path], { signal: options?.signal });
438
+ if (result.exitCode !== 0) {
439
+ if ((await result.stderr()).includes("No such file or directory")) throw fsError("ENOENT", "no such file or directory", "readlink", path);
440
+ throw fsError("EINVAL", "invalid argument", "readlink", path);
441
+ }
442
+ return (await result.stdout()).trim();
443
+ }
444
+ /**
445
+ * Resolve the real path of a file (resolving symlinks).
446
+ *
447
+ * @param path - Path to resolve
448
+ * @param options - Options
449
+ */
450
+ async realpath(path, options) {
451
+ "use step";
452
+ const result = await this.sandbox.runCommand("realpath", [path], { signal: options?.signal });
453
+ if (result.exitCode !== 0) {
454
+ const stderr = await result.stderr();
455
+ if (stderr.includes("No such file or directory")) throw fsError("ENOENT", "no such file or directory", "realpath", path);
456
+ throw fsError("EACCES", stderr.trim(), "realpath", path);
457
+ }
458
+ return (await result.stdout()).trim();
459
+ }
460
+ /**
461
+ * Truncate a file to a specified length.
462
+ *
463
+ * @param path - Path to the file
464
+ * @param len - Length to truncate to (default: 0)
465
+ * @param options - Options
466
+ */
467
+ async truncate(path, len, options) {
468
+ "use step";
469
+ const result = await this.sandbox.runCommand("truncate", [
470
+ "-s",
471
+ String(len ?? 0),
472
+ path
473
+ ], { signal: options?.signal });
474
+ if (result.exitCode !== 0) {
475
+ const stderr = await result.stderr();
476
+ if (stderr.includes("No such file or directory")) throw fsError("ENOENT", "no such file or directory", "truncate", path);
477
+ throw fsError("EACCES", stderr.trim(), "truncate", path);
478
+ }
479
+ }
480
+ /**
481
+ * Create a unique temporary directory.
482
+ *
483
+ * @param prefix - The prefix for the temporary directory name
484
+ * @param options - Options
485
+ * @returns The path of the created temporary directory
486
+ */
487
+ async mkdtemp(prefix, options) {
488
+ "use step";
489
+ const result = await this.sandbox.runCommand("mktemp", ["-d", `${prefix}XXXXXX`], { signal: options?.signal });
490
+ if (result.exitCode !== 0) throw fsError("EACCES", (await result.stderr()).trim(), "mkdtemp", prefix);
491
+ return (await result.stdout()).trim();
492
+ }
493
+ };
494
+
495
+ //#endregion
496
+ export { FileSystem };
497
+ //# sourceMappingURL=filesystem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filesystem.js","names":["dev: number","_mode: number","nlink: number","uid: number","gid: number","rdev: number","blksize: number","ino: number","size: number","blocks: number","atimeMs: number","mtimeMs: number","ctimeMs: number","birthtimeMs: number","name: string","type: number","parentPath: string","FIND_TYPE_TO_DIRENT: Record<string, number>","content: Buffer","appendContent: Buffer","result","args: string[]"],"sources":["../src/filesystem.ts"],"sourcesContent":["import type { Stats, Dirent } from \"fs\";\nimport * as constants from \"node:constants\";\n\nconst {\n S_IFMT,\n S_IFREG,\n S_IFDIR,\n S_IFLNK,\n S_IFBLK,\n S_IFCHR,\n S_IFIFO,\n S_IFSOCK,\n} = constants;\n\n// https://github.com/nodejs/node/blob/main/deps/uv/include/uv.h#L1267-L1276\n// exposed through node:constants but not in @types/node\nconst UV_DIRENT_FILE = 1;\nconst UV_DIRENT_DIR = 2;\nconst UV_DIRENT_LINK = 3;\nconst UV_DIRENT_FIFO = 4;\nconst UV_DIRENT_SOCKET = 5;\nconst UV_DIRENT_CHAR = 6;\nconst UV_DIRENT_BLOCK = 7;\n\ntype EncodingOption =\n | { encoding?: BufferEncoding | null; signal?: AbortSignal }\n | BufferEncoding\n | null;\n\ntype WriteFileData = string | Buffer | Uint8Array;\n\ninterface MkdirOptions {\n recursive?: boolean;\n signal?: AbortSignal;\n}\n\ninterface RmOptions {\n recursive?: boolean;\n force?: boolean;\n signal?: AbortSignal;\n}\n\nfunction fsError(\n code: string,\n message: string,\n syscall: string,\n path: string,\n): Error & { code: string; syscall: string; path: string } {\n const err = new Error(\n `${code}: ${message}, ${syscall} '${path}'`,\n ) as Error & {\n code: string;\n syscall: string;\n path: string;\n };\n err.code = code;\n err.syscall = syscall;\n err.path = path;\n return err;\n}\n\ninterface SandboxHandle {\n readFileToBuffer(\n file: { path: string },\n opts?: { signal?: AbortSignal },\n ): Promise<Buffer | null>;\n writeFiles(\n files: { path: string; content: Buffer }[],\n opts?: { signal?: AbortSignal },\n ): Promise<void>;\n mkDir(path: string, opts?: { signal?: AbortSignal }): Promise<void>;\n runCommand(\n cmd: string,\n args?: string[],\n opts?: { signal?: AbortSignal },\n ): Promise<{\n exitCode: number;\n stdout(opts?: { signal?: AbortSignal }): Promise<string>;\n stderr(opts?: { signal?: AbortSignal }): Promise<string>;\n }>;\n}\n\nfunction parseEncoding(options?: EncodingOption): {\n encoding: BufferEncoding | null;\n signal?: AbortSignal;\n} {\n if (options === null || options === undefined) {\n return { encoding: null };\n }\n if (typeof options === \"string\") {\n return { encoding: options };\n }\n return { encoding: options.encoding ?? null, signal: options.signal };\n}\n\nclass SandboxStats {\n readonly atime: Date;\n readonly mtime: Date;\n readonly ctime: Date;\n readonly birthtime: Date;\n\n constructor(\n readonly dev: number,\n private readonly _mode: number,\n readonly nlink: number,\n readonly uid: number,\n readonly gid: number,\n readonly rdev: number,\n readonly blksize: number,\n readonly ino: number,\n readonly size: number,\n readonly blocks: number,\n readonly atimeMs: number,\n readonly mtimeMs: number,\n readonly ctimeMs: number,\n readonly birthtimeMs: number,\n ) {\n this.atime = new Date(atimeMs);\n this.mtime = new Date(mtimeMs);\n this.ctime = new Date(ctimeMs);\n this.birthtime = new Date(birthtimeMs);\n }\n\n get mode(): number {\n return this._mode;\n }\n\n isFile(): boolean {\n return (this.mode & S_IFMT) === S_IFREG;\n }\n isDirectory(): boolean {\n return (this.mode & S_IFMT) === S_IFDIR;\n }\n isBlockDevice(): boolean {\n return (this.mode & S_IFMT) === S_IFBLK;\n }\n isCharacterDevice(): boolean {\n return (this.mode & S_IFMT) === S_IFCHR;\n }\n isSymbolicLink(): boolean {\n return (this.mode & S_IFMT) === S_IFLNK;\n }\n isFIFO(): boolean {\n return (this.mode & S_IFMT) === S_IFIFO;\n }\n isSocket(): boolean {\n return (this.mode & S_IFMT) === S_IFSOCK;\n }\n}\n\nclass SandboxDirent {\n readonly path: string;\n\n constructor(\n public name: string,\n private type: number,\n public parentPath: string,\n ) {\n this.path = `${this.parentPath}/${this.name}`;\n }\n\n isFile(): boolean {\n return this.type === UV_DIRENT_FILE;\n }\n isDirectory(): boolean {\n return this.type === UV_DIRENT_DIR;\n }\n isBlockDevice(): boolean {\n return this.type === UV_DIRENT_BLOCK;\n }\n isCharacterDevice(): boolean {\n return this.type === UV_DIRENT_CHAR;\n }\n isSymbolicLink(): boolean {\n return this.type === UV_DIRENT_LINK;\n }\n isFIFO(): boolean {\n return this.type === UV_DIRENT_FIFO;\n }\n isSocket(): boolean {\n return this.type === UV_DIRENT_SOCKET;\n }\n}\n\nfunction parseStat(stdout: string) {\n // Format: size|rawModeHex|uid|gid|atimeMs|mtimeMs|ctimeMs|birthtimeMs|nlink|ino|dev|blksize|blocks\n const parts = stdout.trim().split(\"|\");\n\n return new SandboxStats(\n parseInt(parts[10]!, 10), // dev\n parseInt(parts[1]!, 16), // mode (raw mode from %f, hex)\n parseInt(parts[8]!, 10), // nlink\n parseInt(parts[2]!, 10), // uid\n parseInt(parts[3]!, 10), // gid\n 0, // rdev\n parseInt(parts[11]!, 10), // blksize\n parseInt(parts[9]!, 10), // ino\n parseInt(parts[0]!, 10), // size\n parseInt(parts[12]!, 10), // blocks\n parseFloat(parts[4]!) * 1000, // atimeMs\n parseFloat(parts[5]!) * 1000, // mtimeMs\n parseFloat(parts[6]!) * 1000, // ctimeMs\n parseFloat(parts[7]!) * 1000, // birthtimeMs\n ) satisfies Stats;\n}\n\nfunction parseDirent(stdout: string, path: string) {\n const parts = stdout.trim().split(\"|\");\n const name = parts[0];\n const type = parts[1];\n\n if (!name) {\n throw fsError(\"ENOENT\", \"no such file or directory\", \"readdir\", path);\n }\n\n if (!type) {\n throw new Error(`Invalid dirent type: ${type}`);\n }\n\n const direntType = FIND_TYPE_TO_DIRENT[type] ?? UV_DIRENT_FILE;\n return new SandboxDirent(name, direntType, path) satisfies Dirent;\n}\n\n// %f = raw mode in hex, includes file type bits so Stats.isFile()/isDirectory()/etc. work\nconst STAT_FORMAT = \"%s|%f|%u|%g|%X|%Y|%Z|%W|%h|%i|%d|%B|%b\";\n\nconst FIND_TYPE_TO_DIRENT: Record<string, number> = {\n f: UV_DIRENT_FILE,\n d: UV_DIRENT_DIR,\n l: UV_DIRENT_LINK,\n b: UV_DIRENT_BLOCK,\n c: UV_DIRENT_CHAR,\n p: UV_DIRENT_FIFO,\n s: UV_DIRENT_SOCKET,\n};\n\nexport class FileSystem {\n /** @internal */\n private sandbox: SandboxHandle;\n\n /** @internal */\n constructor(sandbox: SandboxHandle) {\n this.sandbox = sandbox;\n }\n\n /**\n * Read the entire contents of a file.\n *\n * @param path - Path to the file\n * @param options - Encoding or options object. If encoding is specified, returns a string; otherwise returns a Buffer.\n */\n async readFile(\n path: string,\n options?: { encoding?: null; signal?: AbortSignal } | null,\n ): Promise<Buffer>;\n async readFile(\n path: string,\n options:\n | { encoding: BufferEncoding; signal?: AbortSignal }\n | BufferEncoding,\n ): Promise<string>;\n async readFile(\n path: string,\n options?: EncodingOption,\n ): Promise<Buffer | string> {\n \"use step\";\n const { encoding, signal } = parseEncoding(options);\n const buffer = await this.sandbox.readFileToBuffer({ path }, { signal });\n if (buffer === null) {\n throw fsError(\"ENOENT\", \"no such file or directory\", \"open\", path);\n }\n return encoding ? buffer.toString(encoding) : buffer;\n }\n\n /**\n * Write data to a file, replacing the file if it already exists.\n *\n * @param path - Path to the file\n * @param data - The data to write\n * @param options - Write options\n */\n async writeFile(\n path: string,\n data: WriteFileData,\n options?:\n | { encoding?: BufferEncoding; signal?: AbortSignal }\n | BufferEncoding,\n ): Promise<void> {\n \"use step\";\n const { encoding, signal } =\n typeof options === \"string\"\n ? { encoding: options, signal: undefined }\n : { encoding: options?.encoding, signal: options?.signal };\n let content: Buffer;\n if (typeof data === \"string\") {\n content = Buffer.from(data, encoding ?? \"utf8\");\n } else if (Buffer.isBuffer(data)) {\n content = data;\n } else {\n content = Buffer.from(data);\n }\n await this.sandbox.writeFiles([{ path, content }], { signal });\n }\n\n /**\n * Append data to a file, creating the file if it does not yet exist.\n *\n * @param path - Path to the file\n * @param data - The data to append\n * @param options - Write options\n */\n async appendFile(\n path: string,\n data: WriteFileData,\n options?:\n | { encoding?: BufferEncoding; signal?: AbortSignal }\n | BufferEncoding,\n ): Promise<void> {\n \"use step\";\n const { encoding, signal } =\n typeof options === \"string\"\n ? { encoding: options, signal: undefined }\n : { encoding: options?.encoding, signal: options?.signal };\n let appendContent: Buffer;\n if (typeof data === \"string\") {\n appendContent = Buffer.from(data, encoding ?? \"utf8\");\n } else if (Buffer.isBuffer(data)) {\n appendContent = data;\n } else {\n appendContent = Buffer.from(data);\n }\n\n const existing = await this.sandbox.readFileToBuffer({ path }, { signal });\n const content =\n existing !== null\n ? Buffer.concat([existing, appendContent])\n : appendContent;\n await this.sandbox.writeFiles([{ path, content }], { signal });\n }\n\n /**\n * Create a directory.\n *\n * @param path - Path of the directory to create\n * @param options - Options for directory creation\n */\n async mkdir(\n path: string,\n options?: MkdirOptions | number,\n ): Promise<string | undefined> {\n \"use step\";\n const opts =\n typeof options === \"number\" ? { recursive: false } : (options ?? {});\n if (opts.recursive) {\n const result = await this.sandbox.runCommand(\"mkdir\", [\"-p\", path], {\n signal: opts.signal,\n });\n if (result.exitCode !== 0) {\n const stderr = await result.stderr();\n throw fsError(\n \"EACCES\",\n stderr.trim() || \"permission denied\",\n \"mkdir\",\n path,\n );\n }\n return undefined;\n }\n await this.sandbox.mkDir(path, { signal: opts.signal });\n return undefined;\n }\n\n /**\n * Read the contents of a directory.\n *\n * @param path - Path to the directory\n * @param options - Options. When `withFileTypes` is true, returns `Dirent` objects.\n */\n async readdir(\n path: string,\n options?: { signal?: AbortSignal; withFileTypes?: false },\n ): Promise<string[]>;\n async readdir(\n path: string,\n options: { signal?: AbortSignal; withFileTypes: true },\n ): Promise<Dirent[]>;\n async readdir(\n path: string,\n options?: { signal?: AbortSignal; withFileTypes?: boolean },\n ): Promise<string[] | Dirent[]> {\n \"use step\";\n if (options?.withFileTypes) {\n // Use find to get name and type in one pass\n const result = await this.sandbox.runCommand(\n \"find\",\n [path, \"-maxdepth\", \"1\", \"-mindepth\", \"1\", \"-printf\", \"%f|%y\\\\n\"],\n { signal: options?.signal },\n );\n if (result.exitCode !== 0) {\n const stderr = await result.stderr();\n if (stderr.includes(\"No such file or directory\")) {\n throw fsError(\"ENOENT\", \"no such file or directory\", \"scandir\", path);\n }\n throw fsError(\"EACCES\", stderr.trim(), \"scandir\", path);\n }\n const stdout = await result.stdout();\n const lines = stdout.trim().split(\"\\n\").filter(Boolean);\n\n return lines.map((line) => parseDirent(line, path));\n }\n\n const result = await this.sandbox.runCommand(\"ls\", [\"-1\", path], {\n signal: options?.signal,\n });\n if (result.exitCode !== 0) {\n const stderr = await result.stderr();\n if (stderr.includes(\"No such file or directory\")) {\n throw fsError(\"ENOENT\", \"no such file or directory\", \"scandir\", path);\n }\n throw fsError(\"EACCES\", stderr.trim(), \"scandir\", path);\n }\n const stdout = await result.stdout();\n return stdout.trim().split(\"\\n\").filter(Boolean);\n }\n\n /**\n * Get file status. Follows symbolic links.\n *\n * @param path - Path to the file\n * @param options - Options\n */\n async stat(path: string, options?: { signal?: AbortSignal }): Promise<Stats> {\n \"use step\";\n const result = await this.sandbox.runCommand(\n \"stat\",\n [\"-L\", \"-c\", STAT_FORMAT, path],\n { signal: options?.signal },\n );\n if (result.exitCode !== 0) {\n const stderr = await result.stderr();\n if (stderr.includes(\"No such file or directory\")) {\n throw fsError(\"ENOENT\", \"no such file or directory\", \"stat\", path);\n }\n throw fsError(\"EACCES\", stderr.trim(), \"stat\", path);\n }\n return parseStat(await result.stdout());\n }\n\n /**\n * Get file status. Does not follow symbolic links.\n *\n * @param path - Path to the file\n * @param options - Options\n */\n async lstat(\n path: string,\n options?: { signal?: AbortSignal },\n ): Promise<Stats> {\n \"use step\";\n const result = await this.sandbox.runCommand(\n \"stat\",\n [\"-c\", STAT_FORMAT, path],\n { signal: options?.signal },\n );\n if (result.exitCode !== 0) {\n const stderr = await result.stderr();\n if (stderr.includes(\"No such file or directory\")) {\n throw fsError(\"ENOENT\", \"no such file or directory\", \"lstat\", path);\n }\n throw fsError(\"EACCES\", stderr.trim(), \"lstat\", path);\n }\n return parseStat(await result.stdout());\n }\n\n /**\n * Remove a file or symbolic link.\n *\n * @param path - Path to the file\n * @param options - Options\n */\n async unlink(\n path: string,\n options?: { signal?: AbortSignal },\n ): Promise<void> {\n \"use step\";\n const result = await this.sandbox.runCommand(\"rm\", [path], {\n signal: options?.signal,\n });\n if (result.exitCode !== 0) {\n const stderr = await result.stderr();\n if (stderr.includes(\"No such file or directory\")) {\n throw fsError(\"ENOENT\", \"no such file or directory\", \"unlink\", path);\n }\n throw fsError(\"EACCES\", stderr.trim(), \"unlink\", path);\n }\n }\n\n /**\n * Remove files and directories.\n *\n * @param path - Path to remove\n * @param options - Options\n */\n async rm(path: string, options?: RmOptions): Promise<void> {\n \"use step\";\n const args: string[] = [];\n if (options?.recursive) args.push(\"-r\");\n if (options?.force) args.push(\"-f\");\n args.push(path);\n\n const result = await this.sandbox.runCommand(\"rm\", args, {\n signal: options?.signal,\n });\n if (result.exitCode !== 0) {\n const stderr = await result.stderr();\n if (stderr.includes(\"No such file or directory\")) {\n throw fsError(\"ENOENT\", \"no such file or directory\", \"rm\", path);\n }\n throw fsError(\"EACCES\", stderr.trim(), \"rm\", path);\n }\n }\n\n /**\n * Remove a directory.\n *\n * @param path - Path to the directory\n * @param options - Options\n */\n async rmdir(path: string, options?: { signal?: AbortSignal }): Promise<void> {\n \"use step\";\n const result = await this.sandbox.runCommand(\"rmdir\", [path], {\n signal: options?.signal,\n });\n if (result.exitCode !== 0) {\n const stderr = await result.stderr();\n if (stderr.includes(\"No such file or directory\")) {\n throw fsError(\"ENOENT\", \"no such file or directory\", \"rmdir\", path);\n }\n if (stderr.includes(\"not empty\")) {\n throw fsError(\"ENOTEMPTY\", \"directory not empty\", \"rmdir\", path);\n }\n throw fsError(\"EACCES\", stderr.trim(), \"rmdir\", path);\n }\n }\n\n /**\n * Rename a file or directory.\n *\n * @param oldPath - Current path\n * @param newPath - New path\n * @param options - Options\n */\n async rename(\n oldPath: string,\n newPath: string,\n options?: { signal?: AbortSignal },\n ): Promise<void> {\n \"use step\";\n const result = await this.sandbox.runCommand(\"mv\", [oldPath, newPath], {\n signal: options?.signal,\n });\n if (result.exitCode !== 0) {\n const stderr = await result.stderr();\n if (stderr.includes(\"No such file or directory\")) {\n throw fsError(\"ENOENT\", \"no such file or directory\", \"rename\", oldPath);\n }\n throw fsError(\"EACCES\", stderr.trim(), \"rename\", oldPath);\n }\n }\n\n /**\n * Copy a file.\n *\n * @param src - Source path\n * @param dest - Destination path\n * @param options - Options\n */\n async copyFile(\n src: string,\n dest: string,\n options?: { signal?: AbortSignal },\n ): Promise<void> {\n \"use step\";\n const result = await this.sandbox.runCommand(\"cp\", [src, dest], {\n signal: options?.signal,\n });\n if (result.exitCode !== 0) {\n const stderr = await result.stderr();\n if (stderr.includes(\"No such file or directory\")) {\n throw fsError(\"ENOENT\", \"no such file or directory\", \"copyfile\", src);\n }\n throw fsError(\"EACCES\", stderr.trim(), \"copyfile\", src);\n }\n }\n\n /**\n * Test whether a file exists and the user has the specified permissions.\n *\n * @param path - Path to the file\n * @param options - Options\n */\n async access(\n path: string,\n options?: { signal?: AbortSignal },\n ): Promise<void> {\n \"use step\";\n const result = await this.sandbox.runCommand(\"test\", [\"-e\", path], {\n signal: options?.signal,\n });\n if (result.exitCode !== 0) {\n throw fsError(\"ENOENT\", \"no such file or directory\", \"access\", path);\n }\n }\n\n /**\n * Check if a path exists.\n *\n * This is a convenience method not in `node:fs/promises` but commonly needed.\n *\n * @param path - Path to check\n * @param options - Options\n */\n async exists(\n path: string,\n options?: { signal?: AbortSignal },\n ): Promise<boolean> {\n const result = await this.sandbox.runCommand(\"test\", [\"-e\", path], {\n signal: options?.signal,\n });\n return result.exitCode === 0;\n }\n\n /**\n * Change file mode (permissions).\n *\n * @param path - Path to the file\n * @param mode - File mode (e.g., 0o755 or \"755\")\n * @param options - Options\n */\n async chmod(\n path: string,\n mode: number | string,\n options?: { signal?: AbortSignal },\n ): Promise<void> {\n \"use step\";\n const modeStr = typeof mode === \"number\" ? mode.toString(8) : mode;\n const result = await this.sandbox.runCommand(\"chmod\", [modeStr, path], {\n signal: options?.signal,\n });\n if (result.exitCode !== 0) {\n const stderr = await result.stderr();\n if (stderr.includes(\"No such file or directory\")) {\n throw fsError(\"ENOENT\", \"no such file or directory\", \"chmod\", path);\n }\n throw fsError(\"EACCES\", stderr.trim(), \"chmod\", path);\n }\n }\n\n /**\n * Change file owner and group.\n *\n * @param path - Path to the file\n * @param uid - User ID\n * @param gid - Group ID\n * @param options - Options\n */\n async chown(\n path: string,\n uid: number,\n gid: number,\n options?: { signal?: AbortSignal },\n ): Promise<void> {\n \"use step\";\n const result = await this.sandbox.runCommand(\n \"chown\",\n [`${uid}:${gid}`, path],\n { signal: options?.signal },\n );\n if (result.exitCode !== 0) {\n const stderr = await result.stderr();\n if (stderr.includes(\"No such file or directory\")) {\n throw fsError(\"ENOENT\", \"no such file or directory\", \"chown\", path);\n }\n throw fsError(\"EACCES\", stderr.trim(), \"chown\", path);\n }\n }\n\n /**\n * Create a symbolic link.\n *\n * @param target - The target of the symbolic link\n * @param path - The path of the symbolic link to create\n * @param options - Options\n */\n async symlink(\n target: string,\n path: string,\n options?: { signal?: AbortSignal },\n ): Promise<void> {\n \"use step\";\n const result = await this.sandbox.runCommand(\"ln\", [\"-s\", target, path], {\n signal: options?.signal,\n });\n if (result.exitCode !== 0) {\n const stderr = await result.stderr();\n if (stderr.includes(\"File exists\")) {\n throw fsError(\"EEXIST\", \"file already exists\", \"symlink\", path);\n }\n throw fsError(\"EACCES\", stderr.trim(), \"symlink\", path);\n }\n }\n\n /**\n * Read the value of a symbolic link.\n *\n * @param path - Path to the symbolic link\n * @param options - Options\n */\n async readlink(\n path: string,\n options?: { signal?: AbortSignal },\n ): Promise<string> {\n \"use step\";\n const result = await this.sandbox.runCommand(\"readlink\", [path], {\n signal: options?.signal,\n });\n if (result.exitCode !== 0) {\n const stderr = await result.stderr();\n if (stderr.includes(\"No such file or directory\")) {\n throw fsError(\"ENOENT\", \"no such file or directory\", \"readlink\", path);\n }\n throw fsError(\"EINVAL\", \"invalid argument\", \"readlink\", path);\n }\n return (await result.stdout()).trim();\n }\n\n /**\n * Resolve the real path of a file (resolving symlinks).\n *\n * @param path - Path to resolve\n * @param options - Options\n */\n async realpath(\n path: string,\n options?: { signal?: AbortSignal },\n ): Promise<string> {\n \"use step\";\n const result = await this.sandbox.runCommand(\"realpath\", [path], {\n signal: options?.signal,\n });\n if (result.exitCode !== 0) {\n const stderr = await result.stderr();\n if (stderr.includes(\"No such file or directory\")) {\n throw fsError(\"ENOENT\", \"no such file or directory\", \"realpath\", path);\n }\n throw fsError(\"EACCES\", stderr.trim(), \"realpath\", path);\n }\n return (await result.stdout()).trim();\n }\n\n /**\n * Truncate a file to a specified length.\n *\n * @param path - Path to the file\n * @param len - Length to truncate to (default: 0)\n * @param options - Options\n */\n async truncate(\n path: string,\n len?: number,\n options?: { signal?: AbortSignal },\n ): Promise<void> {\n \"use step\";\n const result = await this.sandbox.runCommand(\n \"truncate\",\n [\"-s\", String(len ?? 0), path],\n { signal: options?.signal },\n );\n if (result.exitCode !== 0) {\n const stderr = await result.stderr();\n if (stderr.includes(\"No such file or directory\")) {\n throw fsError(\"ENOENT\", \"no such file or directory\", \"truncate\", path);\n }\n throw fsError(\"EACCES\", stderr.trim(), \"truncate\", path);\n }\n }\n\n /**\n * Create a unique temporary directory.\n *\n * @param prefix - The prefix for the temporary directory name\n * @param options - Options\n * @returns The path of the created temporary directory\n */\n async mkdtemp(\n prefix: string,\n options?: { signal?: AbortSignal },\n ): Promise<string> {\n \"use step\";\n const result = await this.sandbox.runCommand(\n \"mktemp\",\n [\"-d\", `${prefix}XXXXXX`],\n { signal: options?.signal },\n );\n if (result.exitCode !== 0) {\n const stderr = await result.stderr();\n throw fsError(\"EACCES\", stderr.trim(), \"mkdtemp\", prefix);\n }\n return (await result.stdout()).trim();\n }\n}\n"],"mappings":";;;AAGA,MAAM,EACJ,QACA,SACA,SACA,SACA,SACA,SACA,SACA,aACE;AAIJ,MAAM,iBAAiB;AACvB,MAAM,gBAAgB;AACtB,MAAM,iBAAiB;AACvB,MAAM,iBAAiB;AACvB,MAAM,mBAAmB;AACzB,MAAM,iBAAiB;AACvB,MAAM,kBAAkB;AAoBxB,SAAS,QACP,MACA,SACA,SACA,MACyD;CACzD,MAAM,sBAAM,IAAI,MACd,GAAG,KAAK,IAAI,QAAQ,IAAI,QAAQ,IAAI,KAAK,GAC1C;AAKD,KAAI,OAAO;AACX,KAAI,UAAU;AACd,KAAI,OAAO;AACX,QAAO;;AAwBT,SAAS,cAAc,SAGrB;AACA,KAAI,YAAY,QAAQ,YAAY,OAClC,QAAO,EAAE,UAAU,MAAM;AAE3B,KAAI,OAAO,YAAY,SACrB,QAAO,EAAE,UAAU,SAAS;AAE9B,QAAO;EAAE,UAAU,QAAQ,YAAY;EAAM,QAAQ,QAAQ;EAAQ;;AAGvE,IAAM,eAAN,MAAmB;CAMjB,YACE,AAASA,KACT,AAAiBC,OACjB,AAASC,OACT,AAASC,KACT,AAASC,KACT,AAASC,MACT,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GAAE;GAAK,EAC9B,EAAE,QAAQ,SAAS,QAAQ,CAC5B;AACD,MAAI,OAAO,aAAa,GAAG;GACzB,MAAM,SAAS,MAAM,OAAO,QAAQ;AACpC,OAAI,OAAO,SAAS,4BAA4B,CAC9C,OAAM,QAAQ,UAAU,6BAA6B,YAAY,KAAK;AAExE,SAAM,QAAQ,UAAU,OAAO,MAAM,EAAE,YAAY,KAAK;;;;;;;;;;CAW5D,MAAM,QACJ,QACA,SACiB;AACjB;EACA,MAAM,SAAS,MAAM,KAAK,QAAQ,WAChC,UACA,CAAC,MAAM,GAAG,OAAO,QAAQ,EACzB,EAAE,QAAQ,SAAS,QAAQ,CAC5B;AACD,MAAI,OAAO,aAAa,EAEtB,OAAM,QAAQ,WADC,MAAM,OAAO,QAAQ,EACL,MAAM,EAAE,WAAW,OAAO;AAE3D,UAAQ,MAAM,OAAO,QAAQ,EAAE,MAAM"}
package/dist/index.cjs ADDED
@@ -0,0 +1,15 @@
1
+ const require_api_error = require('./api-client/api-error.cjs');
2
+ const require_command = require('./command.cjs');
3
+ const require_snapshot = require('./snapshot.cjs');
4
+ const require_session = require('./session.cjs');
5
+ const require_filesystem = require('./filesystem.cjs');
6
+ const require_sandbox = require('./sandbox.cjs');
7
+
8
+ exports.APIError = require_api_error.APIError;
9
+ exports.Command = require_command.Command;
10
+ exports.CommandFinished = require_command.CommandFinished;
11
+ exports.FileSystem = require_filesystem.FileSystem;
12
+ exports.Sandbox = require_sandbox.Sandbox;
13
+ exports.Session = require_session.Session;
14
+ exports.Snapshot = require_snapshot.Snapshot;
15
+ exports.StreamError = require_api_error.StreamError;
@@ -0,0 +1,8 @@
1
+ import { APIError, StreamError } from "./api-client/api-error.cjs";
2
+ import { NetworkPolicy, NetworkPolicyKeyValueMatcher, NetworkPolicyMatch, NetworkPolicyMatcher, NetworkPolicyRule, NetworkTransformer } from "./network-policy.cjs";
3
+ import { Command, CommandFinished, CommandOutput, SerializedCommand, SerializedCommandFinished } from "./command.cjs";
4
+ import { SerializedSnapshot, Snapshot } from "./snapshot.cjs";
5
+ import { Session } from "./session.cjs";
6
+ import { FileSystem } from "./filesystem.cjs";
7
+ import { Sandbox, SerializedSandbox } from "./sandbox.cjs";
8
+ export { APIError, Command, CommandFinished, type CommandOutput, FileSystem, type NetworkPolicy, type NetworkPolicyKeyValueMatcher, type NetworkPolicyMatch, type NetworkPolicyMatcher, type NetworkPolicyRule, type NetworkTransformer, Sandbox, type SerializedCommand, type SerializedCommandFinished, type SerializedSandbox, type SerializedSnapshot, Session, Snapshot, StreamError };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
- export { type NetworkPolicy, Sandbox, } from "./sandbox";
2
- export { Session, type NetworkPolicyRule, type NetworkTransformer, } from "./session";
3
- export { Snapshot } from "./snapshot";
4
- export { Command, CommandFinished } from "./command";
5
- export { StreamError } from "./api-client/api-error";
6
- export { APIError } from "./api-client/api-error";
1
+ import { APIError, StreamError } from "./api-client/api-error.js";
2
+ import { NetworkPolicy, NetworkPolicyKeyValueMatcher, NetworkPolicyMatch, NetworkPolicyMatcher, NetworkPolicyRule, NetworkTransformer } from "./network-policy.js";
3
+ import { Command, CommandFinished, CommandOutput, SerializedCommand, SerializedCommandFinished } from "./command.js";
4
+ import { SerializedSnapshot, Snapshot } from "./snapshot.js";
5
+ import { Session } from "./session.js";
6
+ import { FileSystem } from "./filesystem.js";
7
+ import { Sandbox, SerializedSandbox } from "./sandbox.js";
8
+ export { APIError, Command, CommandFinished, type CommandOutput, FileSystem, type NetworkPolicy, type NetworkPolicyKeyValueMatcher, type NetworkPolicyMatch, type NetworkPolicyMatcher, type NetworkPolicyRule, type NetworkTransformer, Sandbox, type SerializedCommand, type SerializedCommandFinished, type SerializedSandbox, type SerializedSnapshot, Session, Snapshot, StreamError };
package/dist/index.js CHANGED
@@ -1,17 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.APIError = exports.StreamError = exports.CommandFinished = exports.Command = exports.Snapshot = exports.Session = exports.Sandbox = void 0;
4
- var sandbox_1 = require("./sandbox");
5
- Object.defineProperty(exports, "Sandbox", { enumerable: true, get: function () { return sandbox_1.Sandbox; } });
6
- var session_1 = require("./session");
7
- Object.defineProperty(exports, "Session", { enumerable: true, get: function () { return session_1.Session; } });
8
- var snapshot_1 = require("./snapshot");
9
- Object.defineProperty(exports, "Snapshot", { enumerable: true, get: function () { return snapshot_1.Snapshot; } });
10
- var command_1 = require("./command");
11
- Object.defineProperty(exports, "Command", { enumerable: true, get: function () { return command_1.Command; } });
12
- Object.defineProperty(exports, "CommandFinished", { enumerable: true, get: function () { return command_1.CommandFinished; } });
13
- var api_error_1 = require("./api-client/api-error");
14
- Object.defineProperty(exports, "StreamError", { enumerable: true, get: function () { return api_error_1.StreamError; } });
15
- var api_error_2 = require("./api-client/api-error");
16
- Object.defineProperty(exports, "APIError", { enumerable: true, get: function () { return api_error_2.APIError; } });
17
- //# sourceMappingURL=index.js.map
1
+ import { APIError, StreamError } from "./api-client/api-error.js";
2
+ import { Command, CommandFinished } from "./command.js";
3
+ import { Snapshot } from "./snapshot.js";
4
+ import { Session } from "./session.js";
5
+ import { FileSystem } from "./filesystem.js";
6
+ import { Sandbox } from "./sandbox.js";
7
+
8
+ export { APIError, Command, CommandFinished, FileSystem, Sandbox, Session, Snapshot, StreamError };