@poe-platform/safe-bash 0.1.801 → 0.1.803

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 (198) hide show
  1. package/README.md +4 -2
  2. package/dist/image-ast/index.browser.js +16 -5
  3. package/dist/image-ast/index.js +16 -5
  4. package/dist/safe-bash/chunks/chunk-2LSAMQER.js +84 -0
  5. package/dist/safe-bash/chunks/chunk-3HQU4OJO.js +13 -0
  6. package/dist/safe-bash/chunks/chunk-4BSJLKNM.js +14 -0
  7. package/dist/safe-bash/chunks/chunk-4D4N7IU2.js +47 -0
  8. package/dist/safe-bash/chunks/chunk-55YJASTN.js +14 -0
  9. package/dist/safe-bash/chunks/{chunk-NZQXYWA3.js → chunk-5OHX7C2V.js} +0 -1
  10. package/dist/safe-bash/chunks/chunk-7ZBU7KYV.js +14 -0
  11. package/dist/safe-bash/chunks/{chunk-7VNF5BFF.js → chunk-B7PIL77G.js} +101 -415
  12. package/dist/safe-bash/chunks/chunk-DQP3VHSB.js +15 -0
  13. package/dist/safe-bash/chunks/{chunk-VQDD3G76.js → chunk-EEEWOYEG.js} +18 -18
  14. package/dist/safe-bash/chunks/chunk-FZE4HW6G.js +11 -0
  15. package/dist/safe-bash/chunks/{chunk-45PK3NWI.js → chunk-GDYNCWRV.js} +1 -1
  16. package/dist/safe-bash/chunks/chunk-GEG3BWGE.js +14 -0
  17. package/dist/safe-bash/chunks/chunk-HBCN24ZA.js +50 -0
  18. package/dist/safe-bash/chunks/chunk-HZ7BWKQ3.js +13 -0
  19. package/dist/safe-bash/chunks/{chunk-ICFDYV64.js → chunk-HZAMGT5I.js} +2 -2
  20. package/dist/safe-bash/chunks/{chunk-FNDNHAGE.js → chunk-JMMEIDPF.js} +2 -2
  21. package/dist/safe-bash/chunks/{chunk-IVRQ4BXL.js → chunk-PH63PLPZ.js} +7 -7
  22. package/dist/safe-bash/chunks/{chunk-SZH7EJLD.js → chunk-PNBBUWSM.js} +5529 -6547
  23. package/dist/safe-bash/chunks/chunk-QGUV42T5.js +44 -0
  24. package/dist/safe-bash/chunks/chunk-R3NAKOED.js +51 -0
  25. package/dist/safe-bash/chunks/chunk-RRR7AQ24.js +38 -0
  26. package/dist/safe-bash/chunks/{chunk-PQRAK7HU.js → chunk-RYFQ3LZG.js} +281 -476
  27. package/dist/safe-bash/chunks/chunk-VBTDHOWC.js +55 -0
  28. package/dist/safe-bash/chunks/{chunk-NR3EM4LS.js → chunk-VKNVHEX3.js} +1 -6
  29. package/dist/safe-bash/chunks/chunk-XAQMU6OY.js +14 -0
  30. package/dist/safe-bash/chunks/chunk-ZVD5IS4V.js +49 -0
  31. package/dist/safe-bash/command-chunks/{chunk-ORYGZYKW.js → chunk-4FEVBOL5.js} +1 -1
  32. package/dist/safe-bash/command-chunks/{chunk-VXSLJH7G.js → chunk-6JSIFWYT.js} +26 -6
  33. package/dist/safe-bash/command-chunks/chunk-A7MU7762.js +200 -0
  34. package/dist/safe-bash/command-chunks/{chunk-KJIMDLBB.js → chunk-BXCXRYVU.js} +1 -1
  35. package/dist/safe-bash/command-chunks/{chunk-F4TEEZTL.js → chunk-CQHP3I66.js} +1 -1
  36. package/dist/safe-bash/command-chunks/{chunk-PEF7K3UQ.js → chunk-EARHPPPJ.js} +1 -1
  37. package/dist/safe-bash/command-chunks/{chunk-QKFSRZGQ.js → chunk-GFC2NTDG.js} +2 -2
  38. package/dist/safe-bash/command-chunks/chunk-GIRNFXP3.js +466 -0
  39. package/dist/safe-bash/command-chunks/{chunk-EFANWIHL.js → chunk-GY3BWK7K.js} +1 -0
  40. package/dist/safe-bash/command-chunks/{chunk-FPVUD6TH.js → chunk-HDCNKOIX.js} +9 -7
  41. package/dist/safe-bash/command-chunks/{chunk-MQFIPHIQ.js → chunk-ILX2NOLF.js} +18 -15
  42. package/dist/safe-bash/command-chunks/{chunk-5E4WAO4O.js → chunk-JD5QNRNO.js} +3 -3
  43. package/dist/safe-bash/command-chunks/{chunk-I237SNW5.js → chunk-LFJJQQND.js} +1 -1
  44. package/dist/safe-bash/command-chunks/{chunk-W5DNF4JH.js → chunk-LOICUCHG.js} +1 -1
  45. package/dist/safe-bash/command-chunks/{chunk-7U7EXOXX.js → chunk-NASVPT6F.js} +2 -1
  46. package/dist/safe-bash/command-chunks/{chunk-WBNZ4PRE.js → chunk-NGG2XL56.js} +7 -4
  47. package/dist/safe-bash/command-chunks/{chunk-GLOZX57Y.js → chunk-NKIELG7Y.js} +45 -115
  48. package/dist/safe-bash/command-chunks/{chunk-WPYIOKE3.js → chunk-PICVQ6B5.js} +2 -2
  49. package/dist/safe-bash/command-chunks/{chunk-YOFC45RK.js → chunk-QVOS4YXL.js} +1 -1
  50. package/dist/safe-bash/command-chunks/{chunk-VGG2DL5Q.js → chunk-TRR4MYWF.js} +4 -0
  51. package/dist/safe-bash/command-chunks/{chunk-2JRBIDAD.js → chunk-V4K2JDYU.js} +2 -2
  52. package/dist/safe-bash/command-chunks/{chunk-CZ7EN3JG.js → chunk-VT6MJBEI.js} +1 -1
  53. package/dist/safe-bash/command-chunks/{chunk-PCEFOYA3.js → chunk-WWIBP2ET.js} +41 -114
  54. package/dist/safe-bash/command-chunks/{chunk-F6OYH562.js → chunk-X54L3DBL.js} +4 -9
  55. package/dist/safe-bash/command-chunks/{chunk-TNOA7FCQ.js → chunk-YVNGTIJO.js} +1 -1
  56. package/dist/safe-bash/command-chunks/chunk-ZDN7MJE6.js +168 -0
  57. package/dist/safe-bash/commands/apply-patch/index.browser.js +14 -0
  58. package/dist/safe-bash/commands/archive/index.browser.js +36 -0
  59. package/dist/safe-bash/commands/bytes/compression/index.js +54 -51
  60. package/dist/safe-bash/commands/chmod/index.browser.js +14 -0
  61. package/dist/safe-bash/commands/chmod/index.d.ts +2 -0
  62. package/dist/safe-bash/commands/chmod/index.js +2 -0
  63. package/dist/safe-bash/commands/column/index.browser.js +12 -0
  64. package/dist/safe-bash/commands/du/index.browser.js +14 -0
  65. package/dist/safe-bash/commands/expr/index.browser.js +12 -0
  66. package/dist/safe-bash/commands/file/index.browser.js +14 -0
  67. package/dist/safe-bash/commands/filesystem.js +9 -2
  68. package/dist/safe-bash/commands/grep-aliases/index.browser.js +14 -0
  69. package/dist/safe-bash/commands/html-to-markdown/index.browser.js +16 -0
  70. package/dist/safe-bash/commands/metadata/chmod.d.ts +1 -7
  71. package/dist/safe-bash/commands/metadata/chmod.js +1 -204
  72. package/dist/safe-bash/commands/metadata/index.browser.js +17 -0
  73. package/dist/safe-bash/commands/metadata/internal.d.ts +1 -30
  74. package/dist/safe-bash/commands/metadata/internal.js +1 -76
  75. package/dist/safe-bash/commands/metadata/mktemp.d.ts +1 -3
  76. package/dist/safe-bash/commands/metadata/mktemp.js +1 -202
  77. package/dist/safe-bash/commands/metadata/stat.d.ts +1 -7
  78. package/dist/safe-bash/commands/metadata/stat.js +1 -530
  79. package/dist/safe-bash/commands/mktemp/index.browser.js +13 -0
  80. package/dist/safe-bash/commands/mktemp/index.d.ts +2 -0
  81. package/dist/safe-bash/commands/mktemp/index.js +2 -0
  82. package/dist/safe-bash/commands/network/index.browser.js +1 -1
  83. package/dist/safe-bash/commands/node/index.browser.js +4 -4
  84. package/dist/safe-bash/commands/portable-random.d.ts +1 -1
  85. package/dist/safe-bash/commands/portable-random.js +1 -12
  86. package/dist/safe-bash/commands/python/index.browser.js +8 -8
  87. package/dist/safe-bash/commands/regex-execution/public.browser.js +5 -3
  88. package/dist/safe-bash/commands/split/index.browser.js +14 -0
  89. package/dist/safe-bash/commands/stat/index.browser.js +13 -0
  90. package/dist/safe-bash/commands/stat/index.d.ts +2 -0
  91. package/dist/safe-bash/commands/stat/index.js +2 -0
  92. package/dist/safe-bash/commands/stream-format/index.browser.js +11 -0
  93. package/dist/safe-bash/commands/stream-inspection/index.browser.js +11 -0
  94. package/dist/safe-bash/commands/streams.js +5 -5
  95. package/dist/safe-bash/commands/table-text/index.browser.js +11 -0
  96. package/dist/safe-bash/commands/text.js +48 -143
  97. package/dist/safe-bash/commands/time-env/index.browser.js +15 -0
  98. package/dist/safe-bash/commands/tree/index.browser.js +14 -0
  99. package/dist/safe-bash/full-core.browser.js +256 -247
  100. package/dist/safe-bash/opt-in/commands/yq/native-work.js +1 -0
  101. package/dist/safe-bash/optional-host.browser.js +12 -12
  102. package/dist/safe-bash/plugins/index.browser.js +25 -11
  103. package/dist/safe-bash/registry-entry.browser.js +28 -14
  104. package/dist/safe-bash/search.browser.js +48 -0
  105. package/dist/safe-bash/shell/runtime.d.ts +3 -9
  106. package/dist/safe-bash/shell/runtime.js +63 -311
  107. package/dist/safe-bash/shell/shell.js +0 -23
  108. package/dist/safe-bash/shell/types.d.ts +2 -0
  109. package/dist/safe-bash/shell/worker-limits.js +1 -0
  110. package/dist/safe-bash/shell-entry.browser.js +19 -10
  111. package/dist/safe-bash/worker/host.js +1 -1
  112. package/dist/safe-bash-command-bc/index.js +12 -5
  113. package/dist/safe-bash-command-bzip2/index.js +4 -3
  114. package/dist/safe-bash-command-chmod/LICENSE +21 -0
  115. package/dist/safe-bash-command-chmod/command.d.ts +7 -0
  116. package/dist/safe-bash-command-chmod/command.js +11 -0
  117. package/dist/safe-bash-command-chmod/index.d.ts +6 -0
  118. package/dist/safe-bash-command-chmod/index.js +27 -0
  119. package/dist/safe-bash-command-exiftool/index.js +5 -5
  120. package/dist/safe-bash-command-find/find.js +1 -1
  121. package/dist/safe-bash-command-find/index.js +1 -1
  122. package/dist/safe-bash-command-fmt/index.js +9 -2
  123. package/dist/safe-bash-command-gzip/index.js +45 -42
  124. package/dist/safe-bash-command-imagemagick/index.js +3 -1
  125. package/dist/safe-bash-command-jq/index.js +1 -1
  126. package/dist/safe-bash-command-jq/jq.js +1 -1
  127. package/dist/safe-bash-command-less/index.js +12 -3
  128. package/dist/safe-bash-command-mktemp/LICENSE +21 -0
  129. package/dist/safe-bash-command-mktemp/command.d.ts +3 -0
  130. package/dist/safe-bash-command-mktemp/command.js +9 -0
  131. package/dist/safe-bash-command-mktemp/index.d.ts +6 -0
  132. package/dist/safe-bash-command-mktemp/index.js +25 -0
  133. package/dist/safe-bash-command-nl/index.js +1 -1
  134. package/dist/safe-bash-command-nl/nl.js +1 -1
  135. package/dist/safe-bash-command-od/index.js +6 -2
  136. package/dist/safe-bash-command-op/index.js +25 -6
  137. package/dist/safe-bash-command-rg/index.js +1 -1
  138. package/dist/safe-bash-command-rg/rg-command.d.ts +0 -1
  139. package/dist/safe-bash-command-rg/rg-command.js +3 -5
  140. package/dist/safe-bash-command-sed/index.js +1 -1
  141. package/dist/safe-bash-command-sed/sed.js +1 -1
  142. package/dist/safe-bash-command-sips/index.js +13 -5
  143. package/dist/safe-bash-command-sponge/index.js +10 -3
  144. package/dist/safe-bash-command-stat/LICENSE +21 -0
  145. package/dist/safe-bash-command-stat/command.d.ts +7 -0
  146. package/dist/safe-bash-command-stat/command.js +9 -0
  147. package/dist/safe-bash-command-stat/index.d.ts +6 -0
  148. package/dist/safe-bash-command-stat/index.js +25 -0
  149. package/dist/safe-bash-command-unexpand/index.js +1 -1
  150. package/dist/safe-bash-command-unexpand/unexpand.js +1 -1
  151. package/dist/safe-bash-command-unrtf/index.js +11 -1
  152. package/dist/safe-bash-command-xxd/index.js +6 -2
  153. package/dist/safe-bash-command-xz/command.d.ts +1 -1
  154. package/dist/safe-bash-command-xz/index.js +3 -2
  155. package/dist/safe-bash-command-yq/index.js +1 -0
  156. package/dist/safe-bash-command-yq/native-work.js +1 -0
  157. package/dist/safe-bash-command-yq/query.js +3 -0
  158. package/dist/safe-bash-compression-engine/bounded-codec.js +3 -3
  159. package/dist/safe-bash-compression-engine/codec-loader.js +2 -2
  160. package/dist/safe-bash-compression-engine/files.js +6 -6
  161. package/dist/safe-bash-compression-engine/index.js +5 -5
  162. package/dist/safe-bash-compression-engine/operand.js +6 -6
  163. package/dist/safe-bash-compression-engine/options.js +1 -1
  164. package/dist/safe-bash-compression-engine/stream.js +5 -5
  165. package/dist/safe-bash-compression-engine/zstd-decode.js +4 -4
  166. package/dist/safe-bash-contracts/escaping.js +2 -2
  167. package/dist/safe-bash-contracts/filesystem-output.js +2 -2
  168. package/dist/safe-bash-contracts/index.js +2 -2
  169. package/dist/safe-bash-contracts/io.d.ts +2 -0
  170. package/dist/safe-bash-contracts/io.js +1 -1
  171. package/dist/safe-bash-contracts/output.js +2 -2
  172. package/dist/safe-bash-io-engine/commands/search/requirements.js +1 -1
  173. package/dist/safe-bash-io-engine/commands/text-programs/shared.js +1 -1
  174. package/dist/safe-bash-mcp/index.browser.js +11 -1
  175. package/dist/safe-bash-mcp/index.js +38 -17
  176. package/dist/safe-bash-metadata-engine/LICENSE +21 -0
  177. package/dist/safe-bash-metadata-engine/index.d.ts +30 -0
  178. package/dist/safe-bash-metadata-engine/index.js +82 -0
  179. package/dist/safe-bash-metadata-engine/random.d.ts +1 -0
  180. package/dist/safe-bash-metadata-engine/random.js +21 -0
  181. package/dist/safe-bash-regex-engine/index.js +4 -4
  182. package/dist/safe-bash-regex-engine/text/budget.d.ts +0 -1
  183. package/dist/safe-bash-regex-engine/text/budget.js +1 -1
  184. package/dist/safe-bash-regex-engine/text/regex.js +4 -4
  185. package/dist/safe-bash-regex-engine/text/replacement-buffer.js +2 -2
  186. package/dist/safe-bash-regex-engine/text/rust-syntax.js +2 -2
  187. package/dist/safe-bash-search-engine/ergonomic-regex.js +2 -2
  188. package/dist/safe-bash-search-engine/glob.js +2 -2
  189. package/dist/safe-bash-search-engine/grep.js +2 -2
  190. package/dist/safe-bash-search-engine/matcher.js +2 -2
  191. package/dist/safe-bash-search-engine/options.d.ts +2 -0
  192. package/dist/safe-bash-search-engine/options.js +1 -1
  193. package/dist/safe-bash-search-engine/output.js +1 -1
  194. package/dist/safe-bash-search-engine/shared.js +2 -2
  195. package/dist/safe-bash-search-engine/walk.js +3 -3
  196. package/dist/safe-playwright-cloudflare/browser-snapshot-json.js +2 -2
  197. package/dist/safe-playwright-cloudflare/browser-snapshot-references.js +1 -1
  198. package/package.json +91 -10
@@ -0,0 +1,168 @@
1
+ import {
2
+ init_buffer
3
+ } from "./chunk-HX3SHTCE.js";
4
+
5
+ // packages/safe-bash-command-mktemp/src/command.ts
6
+ init_buffer();
7
+ import { creationUmask } from "../../safe-bash-contracts/runtime-control.js";
8
+ import { randomInteger } from "../../safe-bash-metadata-engine/random.js";
9
+ import { FsError, validatePath } from "../../safe-bash-contracts/index.js";
10
+ import { codeOf, diagnostic, pathOf, syncCommandEvaluators, UsageError } from "../../safe-bash-io-engine/internal.js";
11
+ import { gnuInformationSync } from "../../safe-bash-io-engine/gnu-information.js";
12
+ import { MetadataBudget, metadataCommand, settings } from "../../safe-bash-metadata-engine/index.js";
13
+ var mktempEncoder = new TextEncoder();
14
+ function parse(args) {
15
+ let directory = false;
16
+ let dryRun = false;
17
+ let quiet = false;
18
+ let useTmpdir = false;
19
+ let deprecatedTmpdir = false;
20
+ let tmpdir;
21
+ let suffix;
22
+ let literal = false;
23
+ const operands = [];
24
+ for (let index = 0; index < args.length; index++) {
25
+ const argument = args[index];
26
+ if (literal || argument === "-" || !argument.startsWith("-")) operands.push(argument);
27
+ else if (argument === "--") literal = true;
28
+ else if (argument === "--directory") directory = true;
29
+ else if (argument === "--dry-run") dryRun = true;
30
+ else if (argument === "--quiet") quiet = true;
31
+ else if (argument === "--tmpdir" || argument.startsWith("--tmpdir=")) {
32
+ useTmpdir = true;
33
+ tmpdir = argument.includes("=") ? argument.slice(argument.indexOf("=") + 1) : "";
34
+ } else if (argument === "--suffix" || argument.startsWith("--suffix=")) {
35
+ suffix = argument.includes("=") ? argument.slice(argument.indexOf("=") + 1) : args[++index];
36
+ if (suffix === void 0) throw new UsageError("--suffix requires an argument");
37
+ } else if (!argument.startsWith("--")) {
38
+ for (let offset = 1; offset < argument.length; offset++) {
39
+ const option = argument[offset];
40
+ if (option === "d") directory = true;
41
+ else if (option === "u") dryRun = true;
42
+ else if (option === "q") quiet = true;
43
+ else if (option === "t") {
44
+ useTmpdir = true;
45
+ deprecatedTmpdir = true;
46
+ } else if (option === "p") {
47
+ tmpdir = argument.slice(offset + 1) || args[++index];
48
+ if (tmpdir === void 0) throw new UsageError("-p requires an argument");
49
+ useTmpdir = true;
50
+ break;
51
+ } else throw new UsageError(`unrecognized option '${argument}'`);
52
+ }
53
+ } else throw new UsageError(`unrecognized option '${argument}'`);
54
+ }
55
+ if (operands.length > 1) throw new UsageError("too many templates");
56
+ const template = operands[0] ?? "tmp.XXXXXXXXXX";
57
+ if (operands.length === 0) useTmpdir = true;
58
+ validatePath(template);
59
+ if (deprecatedTmpdir && template.includes("/")) throw new UsageError("template contains directory separator");
60
+ validatePath(suffix ?? "");
61
+ if (suffix?.includes("/") || suffix !== void 0 && !template.endsWith("X")) throw new UsageError("suffix requires a template ending in X and cannot contain '/'");
62
+ const name = template.slice(template.lastIndexOf("/") + 1);
63
+ if (name.length + (suffix?.length ?? 0) > 255 || mktempEncoder.encode(name).byteLength + mktempEncoder.encode(suffix ?? "").byteLength > 255) throw new FsError("ENAMETOOLONG", { path: template });
64
+ const end = name.lastIndexOf("X") + 1;
65
+ let start = end;
66
+ while (start > 0 && name[start - 1] === "X") start--;
67
+ if (end - start < 3) throw new UsageError("template must contain at least three consecutive X characters in its last component");
68
+ if (useTmpdir && template.startsWith("/")) throw new UsageError("template must be relative with --tmpdir/-p");
69
+ const tail = suffix ?? name.slice(end);
70
+ return { directory, dryRun, quiet, useTmpdir, deprecatedTmpdir, tmpdir, template, prefix: template.slice(0, template.length - name.length + start), count: end - start, tail };
71
+ }
72
+ var alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
73
+ function sampleTemplateChars(count) {
74
+ let out = "";
75
+ for (let index = 0; index < count; index++) out += alphabet[randomInteger(alphabet.length)];
76
+ return out;
77
+ }
78
+ function evalSyncMktemp(opArgs, env, statTypeSync, writeFileSync, mkdirSync) {
79
+ const gnuInfo = gnuInformationSync("mktemp", opArgs);
80
+ if (gnuInfo !== void 0) return gnuInfo;
81
+ try {
82
+ const parsed = parse(opArgs);
83
+ const parent = parsed.deprecatedTmpdir && env.TMPDIR || parsed.tmpdir || env.TMPDIR || "/tmp";
84
+ validatePath(parent);
85
+ if (!statTypeSync) return void 0;
86
+ if (parsed.useTmpdir && !parsed.dryRun && statTypeSync(parent || ".") !== "directory") return void 0;
87
+ for (let attempt = 0; attempt < 32; attempt++) {
88
+ const random = sampleTemplateChars(parsed.count);
89
+ const generated = `${parsed.prefix}${random}${parsed.tail}`;
90
+ const display = parsed.useTmpdir ? `${parent.replace(/\/+$/u, "")}/${generated}` : generated;
91
+ const st = statTypeSync(display);
92
+ if (st !== "missing") continue;
93
+ if (!parsed.dryRun) {
94
+ if (parsed.directory) {
95
+ if (!mkdirSync || !mkdirSync(display)) return void 0;
96
+ } else {
97
+ if (!writeFileSync || !writeFileSync(display, new Uint8Array(0))) return void 0;
98
+ }
99
+ }
100
+ return `${display}
101
+ `;
102
+ }
103
+ return void 0;
104
+ } catch {
105
+ return void 0;
106
+ }
107
+ }
108
+ syncCommandEvaluators.evalSyncMktemp = evalSyncMktemp;
109
+ function createMktempCommand(configuration = {}) {
110
+ const configured = settings(configuration);
111
+ const configuredUmask = configuration.umask === void 0 ? void 0 : configured.umask;
112
+ return metadataCommand("mktemp", async (context) => {
113
+ const budget = new MetadataBudget(context, configured.limits);
114
+ const parsed = parse(context.args);
115
+ const parent = parsed.deprecatedTmpdir && context.env.TMPDIR || parsed.tmpdir || context.env.TMPDIR || "/tmp";
116
+ validatePath(parent);
117
+ try {
118
+ if (!parsed.dryRun) {
119
+ if (context.fs.capabilities.readOnly) throw new FsError("EROFS", { syscall: "mktemp" });
120
+ }
121
+ for (let attempt = 0; attempt < configured.limits.maxAttempts; attempt++) {
122
+ await budget.step();
123
+ const random = sampleTemplateChars(parsed.count);
124
+ const generated = `${parsed.prefix}${random}${parsed.tail}`;
125
+ const display = parsed.useTmpdir ? `${parent.replace(/\/+$/u, "")}/${generated}` : generated;
126
+ const path = pathOf(context, display);
127
+ if (mktempEncoder.encode(display).byteLength + 1 > configured.limits.maxOutputBytes) throw new FsError("EFBIG", { message: "temporary pathname output exceeds limit" });
128
+ if (parsed.dryRun) {
129
+ try {
130
+ await context.fs.lstat(path, { signal: context.signal });
131
+ continue;
132
+ } catch (error) {
133
+ context.signal.throwIfAborted();
134
+ if (codeOf(error) !== "ENOENT") throw error;
135
+ }
136
+ } else {
137
+ const capabilities = await context.fs.capabilitiesFor?.(path, { signal: context.signal }) ?? context.fs.capabilities;
138
+ if (capabilities.readOnly === true) throw new FsError("EROFS", { syscall: "mktemp" });
139
+ if (capabilities.permissions !== true) throw new FsError("ENOTSUP", { syscall: "mktemp", message: "private temporary creation requires declared permission support" });
140
+ try {
141
+ const mask = configuredUmask ?? Reflect.get(context.fs, creationUmask);
142
+ const activeUmask = typeof mask === "number" ? mask : configured.umask;
143
+ const mode = (parsed.directory ? 448 : 384) & ~activeUmask;
144
+ if (parsed.directory) await context.fs.mkdir(path, { mode, recursive: false, signal: context.signal });
145
+ else await context.fs.writeFile(path, new Uint8Array(), { mode, flag: "wx", signal: context.signal });
146
+ } catch (error) {
147
+ context.signal.throwIfAborted();
148
+ if (codeOf(error) !== "EEXIST") throw error;
149
+ continue;
150
+ }
151
+ }
152
+ await budget.output(`${display}
153
+ `);
154
+ return { exitCode: 0 };
155
+ }
156
+ throw new FsError("EEXIST", { syscall: "mktemp", message: "temporary name collision limit exceeded" });
157
+ } catch (error) {
158
+ context.signal.throwIfAborted();
159
+ if (!parsed.quiet) await diagnostic(context, error);
160
+ return { exitCode: 1 };
161
+ }
162
+ });
163
+ }
164
+
165
+ export {
166
+ evalSyncMktemp,
167
+ createMktempCommand
168
+ };
@@ -0,0 +1,14 @@
1
+ import {
2
+ applyPatchCommands,
3
+ createApplyPatchCommand,
4
+ createApplyPatchCommands,
5
+ evalSyncApplyPatch
6
+ } from "../../chunks/chunk-XAQMU6OY.js";
7
+ import "../../chunks/chunk-IWDICZVK.js";
8
+ import "../../chunks/chunk-B7TAL7S5.js";
9
+ export {
10
+ applyPatchCommands,
11
+ createApplyPatchCommand,
12
+ createApplyPatchCommands,
13
+ evalSyncApplyPatch
14
+ };
@@ -0,0 +1,36 @@
1
+ import {
2
+ DEFAULT_ARCHIVE_LIMITS,
3
+ archiveCommands,
4
+ createArchiveCommands,
5
+ createTarCommand,
6
+ createTarCommands,
7
+ createUnzipCommand,
8
+ createUnzipCommands,
9
+ createZipCommand,
10
+ createZipCommands,
11
+ evalSyncTar,
12
+ evalSyncUnzip,
13
+ evalSyncZip,
14
+ tarCommands,
15
+ unzipCommands,
16
+ zipCommands
17
+ } from "../../chunks/chunk-QGUV42T5.js";
18
+ import "../../chunks/chunk-IWDICZVK.js";
19
+ import "../../chunks/chunk-B7TAL7S5.js";
20
+ export {
21
+ DEFAULT_ARCHIVE_LIMITS,
22
+ archiveCommands,
23
+ createArchiveCommands,
24
+ createTarCommand,
25
+ createTarCommands,
26
+ createUnzipCommand,
27
+ createUnzipCommands,
28
+ createZipCommand,
29
+ createZipCommands,
30
+ evalSyncTar,
31
+ evalSyncUnzip,
32
+ evalSyncZip,
33
+ tarCommands,
34
+ unzipCommands,
35
+ zipCommands
36
+ };
@@ -23,65 +23,68 @@ export function createCompressionCommands(config = {}) {
23
23
  if (maxDecodedBytes !== undefined && maxDecodedBytes !== Infinity && (!Number.isSafeInteger(maxDecodedBytes) || maxDecodedBytes < 0)) {
24
24
  throw new RangeError("maxDecodedBytes must be a nonnegative safe integer or Infinity");
25
25
  }
26
- const commands = profiles.flatMap(profile => profile.format === "gzip" ? createGzipCommands(config) : profile.format === "bzip2" ? createBzip2Commands(config) : profile.names.map((name) => define(name, withInputByteBudget(async (context) => {
27
- const options = parseOptions(name, context.args);
28
- if (options.help) {
29
- await output(context, `Usage: ${name} [OPTION]... [FILE]...\n-c, --stdout, --to-stdout\n-d, --decompress, --uncompress\n-k, --keep\n-f, --force\n-t, --test\n${options.format === "zstd" ? "-1..-9, --best\nHigher levels and --fast[=NUM] are unsupported by the bounded codec.\n" : "-1..-9, --fast, --best\n"}${options.format === "zstd" ? "-q, --quiet (repeat to suppress errors)\n" : ""}${options.format === "gzip" ? "-q, --quiet (suppress warnings)\n-r, --recursive (traverse directories without following symlinks)\n-n, --no-name (always enabled)\n" : `Default compression level: ${options.level}.\n`}-h, --help\nNo FILE or FILE '-' uses stdin; file output uses private VFS staging.\n`);
30
- return { exitCode: 0 };
31
- }
32
- let plans;
33
- let planningFailed = false;
34
- try {
35
- if (options.operands.length > 1) {
36
- plans = [];
37
- for (const name of options.operands) {
38
- try {
39
- plans.push(...await planOperands(context, { ...options, operands: [name] }));
40
- }
41
- catch (error) {
42
- context.signal.throwIfAborted();
43
- if (codeOf(error) === "EROFS")
44
- throw error;
45
- planningFailed = true;
46
- if (options.quiet < 2)
47
- await diagnostic(context, error);
48
- }
49
- }
50
- if (plans.length > 1)
51
- await verifyOperandDestinations(context, plans);
26
+ const commands = profiles.flatMap(profile => profile.format === "gzip" ? createGzipCommands(config) : profile.format === "bzip2" ? createBzip2Commands(config) : profile.names.map((name) => {
27
+ const command = define(name, async (context) => {
28
+ const options = parseOptions(name, context.args);
29
+ if (options.help) {
30
+ await output(context, `Usage: ${name} [OPTION]... [FILE]...\n-c, --stdout, --to-stdout\n-d, --decompress, --uncompress\n-k, --keep\n-f, --force\n-t, --test\n${options.format === "zstd" ? "-1..-9, --best\nHigher levels and --fast[=NUM] are unsupported by the bounded codec.\n" : "-1..-9, --fast, --best\n"}${options.format === "zstd" ? "-q, --quiet (repeat to suppress errors)\n" : ""}${options.format === "gzip" ? "-q, --quiet (suppress warnings)\n-r, --recursive (traverse directories without following symlinks)\n-n, --no-name (always enabled)\n" : `Default compression level: ${options.level}.\n`}-h, --help\nNo FILE or FILE '-' uses stdin; file output uses private VFS staging.\n`);
31
+ return { exitCode: 0 };
52
32
  }
53
- else
54
- plans = await planOperands(context, options);
55
- }
56
- catch (error) {
57
- context.signal.throwIfAborted();
58
- if (options.quiet < 2)
59
- throw error;
60
- return { exitCode: 1 };
61
- }
62
- const decodedBudget = new DecodedBudget(maxDecodedBytes);
63
- let exitCode = planningFailed ? 1 : 0;
64
- for (const plan of plans) {
33
+ let plans;
34
+ let planningFailed = false;
65
35
  try {
66
- const warned = await runOperand(context, plan, options, decodedBudget);
67
- if (warned) {
68
- if (!options.quiet)
69
- await diagnostic(context, new PublicDiagnostic(`${plan.source}: decompression OK, trailing garbage ignored`));
70
- if (exitCode === 0)
71
- exitCode = 2;
36
+ if (options.operands.length > 1) {
37
+ plans = [];
38
+ for (const name of options.operands) {
39
+ try {
40
+ plans.push(...await planOperands(context, { ...options, operands: [name] }));
41
+ }
42
+ catch (error) {
43
+ context.signal.throwIfAborted();
44
+ if (codeOf(error) === "EROFS")
45
+ throw error;
46
+ planningFailed = true;
47
+ if (options.quiet < 2)
48
+ await diagnostic(context, error);
49
+ }
50
+ }
51
+ if (plans.length > 1)
52
+ await verifyOperandDestinations(context, plans);
72
53
  }
54
+ else
55
+ plans = await planOperands(context, options);
73
56
  }
74
57
  catch (error) {
75
58
  context.signal.throwIfAborted();
76
59
  if (options.quiet < 2)
77
- await diagnostic(context, error);
78
- exitCode = 1;
79
- if (decodedBudget.exceeded)
80
- break;
60
+ throw error;
61
+ return { exitCode: 1 };
81
62
  }
82
- }
83
- return { exitCode };
84
- }))));
63
+ const decodedBudget = new DecodedBudget(maxDecodedBytes);
64
+ let exitCode = planningFailed ? 1 : 0;
65
+ for (const plan of plans) {
66
+ try {
67
+ const warned = await runOperand(context, plan, options, decodedBudget);
68
+ if (warned) {
69
+ if (!options.quiet)
70
+ await diagnostic(context, new PublicDiagnostic(`${plan.source}: decompression OK, trailing garbage ignored`));
71
+ if (exitCode === 0)
72
+ exitCode = 2;
73
+ }
74
+ }
75
+ catch (error) {
76
+ context.signal.throwIfAborted();
77
+ if (options.quiet < 2)
78
+ await diagnostic(context, error);
79
+ exitCode = 1;
80
+ if (decodedBudget.exceeded)
81
+ break;
82
+ }
83
+ }
84
+ return { exitCode };
85
+ });
86
+ return { ...command, execute: withInputByteBudget(async (context) => command.execute(context)) };
87
+ }));
85
88
  const xzCmds = createXzCommands(config);
86
89
  if (maxDecodedBytes === undefined || maxDecodedBytes === Infinity) {
87
90
  for (const c of [...commands, ...xzCmds])
@@ -0,0 +1,14 @@
1
+ import {
2
+ init_platform
3
+ } from "../../chunks/chunk-B7TAL7S5.js";
4
+
5
+ // packages/safe-bash/src/commands/chmod/index.ts
6
+ init_platform();
7
+ import { chmodCommands, createChmodCommand, createChmodCommands, evalSyncChmod, modeChange } from "../../../safe-bash-command-chmod/index.js";
8
+ export {
9
+ chmodCommands,
10
+ createChmodCommand,
11
+ createChmodCommands,
12
+ evalSyncChmod,
13
+ modeChange
14
+ };
@@ -0,0 +1,2 @@
1
+ export * from "../../../safe-bash-command-chmod/index.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,2 @@
1
+ export * from "../../../safe-bash-command-chmod/index.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,12 @@
1
+ import {
2
+ columnCommands,
3
+ createColumnCommand,
4
+ createColumnCommands
5
+ } from "../../chunks/chunk-3HQU4OJO.js";
6
+ import "../../chunks/chunk-IWDICZVK.js";
7
+ import "../../chunks/chunk-B7TAL7S5.js";
8
+ export {
9
+ columnCommands,
10
+ createColumnCommand,
11
+ createColumnCommands
12
+ };
@@ -0,0 +1,14 @@
1
+ import {
2
+ createDuCommand,
3
+ createDuCommands,
4
+ duCommands,
5
+ evalSyncDu
6
+ } from "../../chunks/chunk-GEG3BWGE.js";
7
+ import "../../chunks/chunk-IWDICZVK.js";
8
+ import "../../chunks/chunk-B7TAL7S5.js";
9
+ export {
10
+ createDuCommand,
11
+ createDuCommands,
12
+ duCommands,
13
+ evalSyncDu
14
+ };
@@ -0,0 +1,12 @@
1
+ import {
2
+ createExprCommand,
3
+ createExprCommands,
4
+ exprCommands
5
+ } from "../../chunks/chunk-HZ7BWKQ3.js";
6
+ import "../../chunks/chunk-IWDICZVK.js";
7
+ import "../../chunks/chunk-B7TAL7S5.js";
8
+ export {
9
+ createExprCommand,
10
+ createExprCommands,
11
+ exprCommands
12
+ };
@@ -0,0 +1,14 @@
1
+ import {
2
+ createFileCommand,
3
+ createFileCommands,
4
+ evalSyncFile,
5
+ fileCommands
6
+ } from "../../chunks/chunk-4BSJLKNM.js";
7
+ import "../../chunks/chunk-IWDICZVK.js";
8
+ import "../../chunks/chunk-B7TAL7S5.js";
9
+ export {
10
+ createFileCommand,
11
+ createFileCommands,
12
+ evalSyncFile,
13
+ fileCommands
14
+ };
@@ -577,10 +577,17 @@ export function filesystemCommands(maxDirectoryEntries, maxRecursiveDirectoryDep
577
577
  if (admitted) {
578
578
  const effectiveMode = backingMem.capabilities.permissions !== false ? 0o777 & ~umask : undefined;
579
579
  let allCreated = true;
580
+ ended = false;
580
581
  for (let i = 0; i < rawArgs.length; i++) {
581
582
  const a = rawArgs[i];
582
- if (a === "--" || a === "-p" || a === "--parents")
583
- continue;
583
+ if (!ended) {
584
+ if (a === "--") {
585
+ ended = true;
586
+ continue;
587
+ }
588
+ if (a === "-p" || a === "--parents")
589
+ continue;
590
+ }
584
591
  if (!backingMem.tryMkdirFastSync(pathOf(context, a), recursive, effectiveMode)) {
585
592
  allCreated = false;
586
593
  break;
@@ -0,0 +1,14 @@
1
+ import {
2
+ createEgrepCommand,
3
+ createFgrepCommand,
4
+ createGrepAliasCommands,
5
+ grepAliasCommands
6
+ } from "../../chunks/chunk-RRR7AQ24.js";
7
+ import "../../chunks/chunk-E7OYNDGL.js";
8
+ import "../../chunks/chunk-B7TAL7S5.js";
9
+ export {
10
+ createGrepAliasCommands,
11
+ createEgrepCommand as egrepCommand,
12
+ createFgrepCommand as fgrepCommand,
13
+ grepAliasCommands
14
+ };
@@ -0,0 +1,16 @@
1
+ import {
2
+ createHtmlToMarkdownCommand,
3
+ createHtmlToMarkdownCommands,
4
+ evalSyncHtmlToMarkdown,
5
+ evalSyncShuf,
6
+ htmlToMarkdownCommands
7
+ } from "../../chunks/chunk-DQP3VHSB.js";
8
+ import "../../chunks/chunk-IWDICZVK.js";
9
+ import "../../chunks/chunk-B7TAL7S5.js";
10
+ export {
11
+ createHtmlToMarkdownCommand,
12
+ createHtmlToMarkdownCommands,
13
+ evalSyncHtmlToMarkdown,
14
+ evalSyncShuf,
15
+ htmlToMarkdownCommands
16
+ };
@@ -1,8 +1,2 @@
1
- export { modeChange } from "../../../safe-bash-io-engine/commands/mode-change.js";
2
- import { type MetadataCommandsOptions } from "./internal.js";
3
- export declare function createChmodCommand(configuration?: MetadataCommandsOptions): import("../../../safe-bash-contracts/command.js").CommandDefinition;
4
- export declare function evalSyncChmod(opArgs: readonly string[], umask: number, chmodNodeSync?: (filePath: string, change: (stat: {
5
- type: "file" | "directory" | "symlink";
6
- mode: number;
7
- }) => number) => boolean): string | undefined;
1
+ export * from "../../../safe-bash-command-chmod/command.js";
8
2
  //# sourceMappingURL=chmod.d.ts.map