@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
@@ -1,531 +1,2 @@
1
- const syncStatEncoder = new TextEncoder();
2
- function concatBytes(chunks) {
3
- if (chunks.length === 0)
4
- return new Uint8Array(0);
5
- if (chunks.length === 1)
6
- return chunks[0];
7
- let total = 0;
8
- for (let i = 0; i < chunks.length; i++)
9
- total += chunks[i].byteLength;
10
- const out = new Uint8Array(total);
11
- let offset = 0;
12
- for (let i = 0; i < chunks.length; i++) {
13
- const c = chunks[i];
14
- out.set(c, offset);
15
- offset += c.byteLength;
16
- }
17
- return out;
18
- }
19
- function allocSpaces(length) {
20
- const out = new Uint8Array(length);
21
- out.fill(32);
22
- return out;
23
- }
24
- import { FsError } from "../../contracts/index.js";
25
- import { codeOf, diagnostic, pathOf, requireOperands, UsageError } from "../internal.js";
26
- import { MetadataBudget, metadataCommand, permissionString, settings } from "./internal.js";
27
- function parse(args) {
28
- let follow = false;
29
- let filesystem = false;
30
- let terse = false;
31
- let format;
32
- let printf = false;
33
- let literal = false;
34
- const paths = [];
35
- for (let index = 0; index < args.length; index++) {
36
- const argument = args[index];
37
- if (literal || argument === "-" || !argument.startsWith("-"))
38
- paths.push(argument);
39
- else if (argument === "--")
40
- literal = true;
41
- else if (argument === "--dereference")
42
- follow = true;
43
- else if (argument === "--cached=default" || argument === "--cached=never" || argument === "--cached=always")
44
- continue;
45
- else if (argument === "--file-system")
46
- filesystem = true;
47
- else if (argument === "--terse")
48
- terse = true;
49
- else if (argument === "--format" || argument.startsWith("--format=") || argument === "--printf" || argument.startsWith("--printf=")) {
50
- printf = argument.startsWith("--printf");
51
- format = argument.includes("=") ? argument.slice(argument.indexOf("=") + 1) : args[++index];
52
- if (format === undefined)
53
- throw new UsageError(`missing format for '${argument}'`);
54
- }
55
- else if (!argument.startsWith("--")) {
56
- for (let offset = 1; offset < argument.length; offset++) {
57
- if (argument[offset] === "L")
58
- follow = true;
59
- else if (argument[offset] === "f")
60
- filesystem = true;
61
- else if (argument[offset] === "t")
62
- terse = true;
63
- else if (argument[offset] === "c") {
64
- format = argument.slice(offset + 1) || args[++index];
65
- if (format === undefined)
66
- throw new UsageError("missing format for '-c'");
67
- printf = false;
68
- break;
69
- }
70
- else
71
- throw new UsageError(`unrecognized option '${argument}'`);
72
- }
73
- }
74
- else
75
- throw new UsageError(`unrecognized option '${argument}'`);
76
- }
77
- requireOperands(paths);
78
- return { follow, filesystem, terse, format, printf, paths };
79
- }
80
- function quoted(text, style) {
81
- if (style === "literal")
82
- return text;
83
- if (style && !["shell-escape-always", "shell-always"].includes(style))
84
- throw new FsError("ENOTSUP", { message: `unsupported QUOTING_STYLE: ${style}` });
85
- if (style !== "shell-always" && /[\x00-\x1f\x7f]/u.test(text)) {
86
- return "$'" + text.replace(/[\\'\x00-\x1f\x7f]/gu, character => {
87
- if (character === "\\" || character === "'")
88
- return `\\${character}`;
89
- if (character === "\n")
90
- return "\\n";
91
- if (character === "\r")
92
- return "\\r";
93
- if (character === "\t")
94
- return "\\t";
95
- return `\\${character.charCodeAt(0).toString(8).padStart(3, "0")}`;
96
- }) + "'";
97
- }
98
- return `'${text.replace(/'/gu, "'\\''")}'`;
99
- }
100
- function available(value, field) {
101
- if (value === undefined)
102
- throw new FsError("ENOTSUP", { syscall: "stat", message: `filesystem does not expose ${field}` });
103
- if (!Number.isFinite(value))
104
- throw new FsError("EIO", { syscall: "stat", message: `invalid ${field}` });
105
- return value;
106
- }
107
- function timestamp(milliseconds) {
108
- const value = available(milliseconds, "timestamp");
109
- if (Math.abs(value) > 8_640_000_000_000_000)
110
- throw new FsError("EIO", { message: "invalid filesystem timestamp" });
111
- const [coefficient = "0", exponent = "0"] = Math.abs(value).toString().split("e");
112
- const [integer = "0", fraction = ""] = coefficient.split(".");
113
- const digits = BigInt(integer + fraction);
114
- const power = Number(exponent) - fraction.length + 6;
115
- const divisor = power < 0 ? 10n ** BigInt(-power) : 1n;
116
- const magnitude = power < 0 ? (digits + divisor / 2n) / divisor : digits * 10n ** BigInt(power);
117
- const nanoseconds = value < 0 ? -magnitude : magnitude;
118
- const remainder = ((nanoseconds % 1000000000n) + 1000000000n) % 1000000000n;
119
- const seconds = (nanoseconds - remainder) / 1000000000n;
120
- const date = new Date(Number(seconds * 1000n));
121
- if (Number.isNaN(date.getTime()))
122
- throw new FsError("EIO", { message: "invalid filesystem timestamp" });
123
- return `${date.toISOString().replace("T", " ").replace(/\.\d{3}Z$/u, `.${remainder.toString().padStart(9, "0")}`)} +0000`;
124
- }
125
- function epoch(milliseconds, precision) {
126
- const value = available(milliseconds, "timestamp");
127
- const [coefficient = "0", exponent = "0"] = Math.abs(value).toString().split("e");
128
- const [integer = "0", decimal = ""] = coefficient.split(".");
129
- const digits = BigInt(integer + decimal);
130
- const places = Math.min(precision, 9);
131
- const scale = 10n ** BigInt(places);
132
- const power = Number(exponent) - decimal.length - 3 + places;
133
- const absolute = power < 0 ? digits / (10n ** BigInt(-power)) : digits * 10n ** BigInt(power);
134
- const fraction = absolute % scale;
135
- const seconds = value < 0 && fraction === 0n ? -Math.floor(value / 1000) : absolute / scale;
136
- const suffix = precision ? "." + fraction.toString().padStart(places, "0") + "0".repeat(precision - places) : "";
137
- return `${value < 0 ? "-" : ""}${seconds}${suffix}`;
138
- }
139
- function directive(format, start) {
140
- let index = start + 1;
141
- const flagsStart = index;
142
- while (index < format.length && "-+ #0".includes(format[index]))
143
- index++;
144
- const flags = format.slice(flagsStart, index);
145
- const widthStart = index;
146
- while (index < format.length && format[index] >= "0" && format[index] <= "9")
147
- index++;
148
- const width = format.slice(widthStart, index);
149
- let precision;
150
- if (format[index] === ".") {
151
- const precisionStart = ++index;
152
- while (index < format.length && format[index] >= "0" && format[index] <= "9")
153
- index++;
154
- precision = format.slice(precisionStart, index);
155
- }
156
- const code = format[index];
157
- if (code === undefined)
158
- throw new UsageError("invalid stat format directive");
159
- const codePoint = code.charCodeAt(0);
160
- if (code !== "%" && !(codePoint >= 65 && codePoint <= 90) && !(codePoint >= 97 && codePoint <= 122)) {
161
- throw new UsageError("invalid stat format directive");
162
- }
163
- return { code, flags, length: index + 1 - start, precision, width };
164
- }
165
- function formatField(text, code, flags, width, precision, numeric, epoch) {
166
- if (numeric) {
167
- const nonzero = !/^0+$/u.test(text);
168
- if (!epoch && precision !== undefined)
169
- text = precision === 0 && !nonzero ? "" : text.padStart(precision, "0");
170
- if (flags.includes("#"))
171
- text = code === "a" ? (text.startsWith("0") ? text : `0${text}`) : (code === "f" || code === "D") && nonzero ? `0x${text}` : text;
172
- if (epoch && !text.startsWith("-") && (flags.includes("+") || flags.includes(" ")))
173
- text = `${flags.includes("+") ? "+" : " "}${text}`;
174
- }
175
- if (epoch && precision) {
176
- const decimal = text.indexOf(".");
177
- const integerWidth = width > precision + 2 && !flags.includes("-") ? width - precision - 1 : 0;
178
- const integer = formatField(text.slice(0, decimal), code, flags, integerWidth, undefined, true, false);
179
- const trailingWidth = integer.length < width && 1 < width - integer.length
180
- ? Math.abs(width - integer.length - 1 - precision) : 0;
181
- return concatBytes([integer, syncStatEncoder.encode(text.slice(decimal)), allocSpaces(trailingWidth)]);
182
- }
183
- const encoded = syncStatEncoder.encode(text);
184
- const bytes = !numeric && precision !== undefined ? encoded.subarray(0, precision) : encoded;
185
- const padding = Math.max(0, width - bytes.length);
186
- if (flags.includes("-"))
187
- return concatBytes([bytes, allocSpaces(padding)]);
188
- if (numeric && flags.includes("0") && (epoch || precision === undefined) && padding) {
189
- const prefix = /^[+ -]|^0x/u.exec(text)?.[0] ?? "";
190
- return syncStatEncoder.encode(prefix + "0".repeat(padding) + text.slice(prefix.length));
191
- }
192
- return concatBytes([allocSpaces(padding), bytes]);
193
- }
194
- async function render(context, path, name, stat, format, escapes, limit, filesystem, terse) {
195
- const chunks = [];
196
- let bytes = 0;
197
- const append = (text) => {
198
- const chunk = typeof text === "string" ? new TextEncoder().encode(text) : text;
199
- bytes += chunk.byteLength;
200
- if (bytes > limit)
201
- throw new FsError("EFBIG", { message: "stat format output limit exceeded" });
202
- chunks.push(chunk);
203
- };
204
- for (let index = 0; index < format.length;) {
205
- context.signal.throwIfAborted();
206
- if (escapes && format[index] === "\\") {
207
- const named = { a: "\x07", b: "\b", e: "\x1b", f: "\f", n: "\n", r: "\r", t: "\t", v: "\v", "\\": "\\", "\"": "\"" };
208
- const code = format[index + 1] ?? "";
209
- if (Object.hasOwn(named, code)) {
210
- append(named[code]);
211
- index += 2;
212
- continue;
213
- }
214
- const radix = code === "x" ? 16 : 8;
215
- const start = index + (radix === 16 ? 2 : 1);
216
- const end = Math.min(format.length, start + (radix === 16 ? 2 : 3));
217
- let offset = start;
218
- let value = 0;
219
- while (offset < end) {
220
- const digit = "0123456789abcdef".indexOf(format[offset].toLowerCase());
221
- if (digit < 0 || digit >= radix)
222
- break;
223
- value = value * radix + digit;
224
- offset++;
225
- }
226
- if (offset === start) {
227
- append(format[index++]);
228
- continue;
229
- }
230
- append(Uint8Array.of(value));
231
- index = offset;
232
- continue;
233
- }
234
- if (format[index] !== "%") {
235
- const point = String.fromCodePoint(format.codePointAt(index));
236
- append(point);
237
- index += point.length;
238
- continue;
239
- }
240
- const parsed = directive(format, index);
241
- index += parsed.length;
242
- const { code, flags } = parsed;
243
- const width = Number(parsed.width || 0);
244
- if (!Number.isSafeInteger(width) || width > limit)
245
- throw new FsError("EFBIG", { message: "stat format width limit exceeded" });
246
- const epochCode = !filesystem && ["X", "Y", "Z", "W"].includes(code);
247
- const precision = parsed.precision === undefined ? undefined : Number(parsed.precision || (epochCode ? 9 : 0));
248
- if (precision !== undefined && (!Number.isSafeInteger(precision) || precision > limit))
249
- throw new FsError("EFBIG", { message: "stat format precision limit exceeded" });
250
- if (code === "%" && parsed.length !== 2)
251
- throw new UsageError("invalid stat format directive");
252
- if (filesystem) {
253
- let text;
254
- if (code === "n")
255
- text = name;
256
- else if (code === "%")
257
- text = "%";
258
- else if (code === "T") {
259
- if (stat.filesystemType === undefined)
260
- throw new FsError("ENOTSUP", { syscall: "stat", message: "filesystem does not expose its type" });
261
- if (typeof stat.filesystemType !== "string" || stat.filesystemType.length === 0)
262
- throw new FsError("EIO", { syscall: "stat", message: "invalid filesystem type" });
263
- text = stat.filesystemType;
264
- }
265
- else
266
- throw new FsError("ENOTSUP", { message: `unsupported filesystem stat format: %${code}` });
267
- append(formatField(text, code, flags, width, precision, false, false));
268
- continue;
269
- }
270
- let text;
271
- let linkText;
272
- let numeric = false;
273
- if (["a", "A", "f"].includes(code))
274
- available(stat.mode, "mode");
275
- const times = { X: stat.atimeMs, Y: stat.mtimeMs, Z: stat.ctimeMs, W: stat.birthtimeMs };
276
- if (Object.hasOwn(times, code)) {
277
- text = terse && times[code] === undefined ? "?" : epoch(available(times[code], code), precision ?? 0);
278
- numeric = text !== "?";
279
- }
280
- else if (code === "n")
281
- text = name;
282
- else if (code === "N") {
283
- text = quoted(name, context.env.QUOTING_STYLE);
284
- if (stat.type === "symlink") {
285
- if (!context.fs.readlink)
286
- throw new FsError("ENOTSUP", { syscall: "readlink", path });
287
- linkText = quoted(await context.fs.readlink(path, { signal: context.signal }), context.env.QUOTING_STYLE);
288
- }
289
- }
290
- else if (code === "%")
291
- text = "%";
292
- else if (code === "A")
293
- text = permissionString(stat.mode, stat.type);
294
- else if (code === "U")
295
- text = available(stat.uid, "u") === 0 ? "root" : String(stat.uid);
296
- else if (code === "G")
297
- text = available(stat.gid, "g") === 0 ? "root" : String(stat.gid);
298
- else if (code === "m")
299
- text = "/";
300
- else if (code === "F")
301
- text = stat.type === "directory" ? "directory" : stat.type === "symlink" ? "symbolic link" : stat.type === "character" ? "character special file" : stat.size === 0 ? "regular empty file" : "regular file";
302
- else if (["x", "y", "z", "w"].includes(code)) {
303
- const value = times[code.toUpperCase()];
304
- text = code === "w" && value === undefined ? "-" : timestamp(available(value, code));
305
- }
306
- else {
307
- const fields = { s: stat.size, a: stat.mode & 0o7777, f: stat.mode, i: stat.ino, h: stat.nlink, u: stat.uid, g: stat.gid, d: stat.dev, D: stat.dev,
308
- B: 512, b: stat.allocatedBytes === undefined ? undefined : Math.ceil(stat.allocatedBytes / 512),
309
- o: stat.ioBlockSize, t: stat.rdevMajor, T: stat.rdevMinor };
310
- if (!Object.hasOwn(fields, code))
311
- throw new FsError("ENOTSUP", { message: `unsupported stat format: %${code}` });
312
- const value = fields[code];
313
- text = terse && value === undefined ? "?" : available(value, code).toString(code === "a" ? 8 : ["f", "D", "t", "T"].includes(code) ? 16 : 10);
314
- numeric = text !== "?";
315
- }
316
- append(formatField(text, code, flags, width, precision, numeric, epochCode));
317
- if (linkText !== undefined) {
318
- append(" -> ");
319
- append(formatField(linkText, code, flags, width, precision, false, false));
320
- }
321
- }
322
- return concatBytes(chunks);
323
- }
324
- export function createStatCommand(configuration = {}) {
325
- const configured = settings(configuration);
326
- return metadataCommand("stat", async (context) => {
327
- const budget = new MetadataBudget(context, configured.limits);
328
- const parsed = parse(context.args);
329
- let exitCode = 0;
330
- for (const name of parsed.paths) {
331
- await budget.step();
332
- try {
333
- const path = pathOf(context, name);
334
- const stat = await context.fs[parsed.follow || parsed.filesystem ? "stat" : "lstat"](path, { signal: context.signal });
335
- const terse = parsed.terse && parsed.format === undefined;
336
- if (terse && parsed.filesystem)
337
- throw new FsError("ENOTSUP", { message: "filesystem terse stat is unsupported" });
338
- const format = parsed.format ?? (parsed.filesystem ? " File: %n\n Type: %T" : terse
339
- ? "%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %W %o"
340
- : " File: %N\n Size: %s\tType: %F\n Mode: %a (%A)\nAccess: %x\nModify: %y\nChange: %z\n Birth: %w");
341
- const text = await render(context, path, name, stat, format, parsed.printf, configured.limits.maxOutputBytes, parsed.filesystem, terse);
342
- await budget.output(parsed.printf ? text : concatBytes([text, Uint8Array.of(10)]));
343
- }
344
- catch (error) {
345
- context.signal.throwIfAborted();
346
- if (codeOf(error) === "EFBIG")
347
- throw error;
348
- await diagnostic(context, error);
349
- exitCode = 1;
350
- }
351
- }
352
- return { exitCode };
353
- });
354
- }
355
- const syncStatDecoder = new TextDecoder("utf-8", { fatal: false });
356
- function renderSync(path, name, stat, format, escapes, limit, filesystem, terse, quotingStyle) {
357
- const chunks = [];
358
- let bytes = 0;
359
- const append = (text) => {
360
- const chunk = typeof text === "string" ? new TextEncoder().encode(text) : text;
361
- bytes += chunk.byteLength;
362
- if (bytes > limit)
363
- throw new FsError("EFBIG", { message: "stat format output limit exceeded" });
364
- chunks.push(chunk);
365
- };
366
- for (let index = 0; index < format.length;) {
367
- if (escapes && format[index] === "\\") {
368
- const named = { a: "\x07", b: "\b", e: "\x1b", f: "\f", n: "\n", r: "\r", t: "\t", v: "\v", "\\": "\\", "\"": "\"" };
369
- const code = format[index + 1] ?? "";
370
- if (Object.hasOwn(named, code)) {
371
- append(named[code]);
372
- index += 2;
373
- continue;
374
- }
375
- const radix = code === "x" ? 16 : 8;
376
- const start = index + (radix === 16 ? 2 : 1);
377
- const end = Math.min(format.length, start + (radix === 16 ? 2 : 3));
378
- let offset = start;
379
- let value = 0;
380
- while (offset < end) {
381
- const digit = "0123456789abcdef".indexOf(format[offset].toLowerCase());
382
- if (digit < 0 || digit >= radix)
383
- break;
384
- value = value * radix + digit;
385
- offset++;
386
- }
387
- if (offset === start) {
388
- append(format[index++]);
389
- continue;
390
- }
391
- append(Uint8Array.of(value));
392
- index = offset;
393
- continue;
394
- }
395
- if (format[index] !== "%") {
396
- const point = String.fromCodePoint(format.codePointAt(index));
397
- append(point);
398
- index += point.length;
399
- continue;
400
- }
401
- const parsed = directive(format, index);
402
- index += parsed.length;
403
- const { code, flags } = parsed;
404
- const width = Number(parsed.width || 0);
405
- if (!Number.isSafeInteger(width) || width > limit)
406
- throw new FsError("EFBIG", { message: "stat format width limit exceeded" });
407
- const epochCode = !filesystem && ["X", "Y", "Z", "W"].includes(code);
408
- const precision = parsed.precision === undefined ? undefined : Number(parsed.precision || (epochCode ? 9 : 0));
409
- if (precision !== undefined && (!Number.isSafeInteger(precision) || precision > limit))
410
- throw new FsError("EFBIG", { message: "stat format precision limit exceeded" });
411
- if (code === "%" && parsed.length !== 2)
412
- throw new UsageError("invalid stat format directive");
413
- if (filesystem) {
414
- let text;
415
- if (code === "n")
416
- text = name;
417
- else if (code === "%")
418
- text = "%";
419
- else if (code === "T") {
420
- if (stat.filesystemType === undefined)
421
- throw new FsError("ENOTSUP", { syscall: "stat", message: "filesystem does not expose its type" });
422
- if (typeof stat.filesystemType !== "string" || stat.filesystemType.length === 0)
423
- throw new FsError("EIO", { syscall: "stat", message: "invalid filesystem type" });
424
- text = stat.filesystemType;
425
- }
426
- else
427
- throw new FsError("ENOTSUP", { message: `unsupported filesystem stat format: %${code}` });
428
- append(formatField(text, code, flags, width, precision, false, false));
429
- continue;
430
- }
431
- let text;
432
- let linkText;
433
- let numeric = false;
434
- if (["a", "A", "f"].includes(code))
435
- available(stat.mode, "mode");
436
- const times = { X: stat.atimeMs, Y: stat.mtimeMs, Z: stat.ctimeMs, W: stat.birthtimeMs };
437
- if (Object.hasOwn(times, code)) {
438
- text = terse && times[code] === undefined ? "?" : epoch(available(times[code], code), precision ?? 0);
439
- numeric = text !== "?";
440
- }
441
- else if (code === "n")
442
- text = name;
443
- else if (code === "N") {
444
- text = quoted(name, quotingStyle);
445
- if (stat.type === "symlink") {
446
- if (stat.target === undefined)
447
- throw new FsError("ENOTSUP", { syscall: "readlink", path });
448
- linkText = quoted(stat.target, quotingStyle);
449
- }
450
- }
451
- else if (code === "%")
452
- text = "%";
453
- else if (code === "A")
454
- text = permissionString(stat.mode, stat.type);
455
- else if (code === "U")
456
- text = available(stat.uid, "u") === 0 ? "root" : String(stat.uid);
457
- else if (code === "G")
458
- text = available(stat.gid, "g") === 0 ? "root" : String(stat.gid);
459
- else if (code === "m")
460
- text = "/";
461
- else if (code === "F")
462
- text = stat.type === "directory" ? "directory" : stat.type === "symlink" ? "symbolic link" : stat.type === "character" ? "character special file" : stat.size === 0 ? "regular empty file" : "regular file";
463
- else if (["x", "y", "z", "w"].includes(code)) {
464
- const value = times[code.toUpperCase()];
465
- text = code === "w" && value === undefined ? "-" : timestamp(available(value, code));
466
- }
467
- else {
468
- const fields = { s: stat.size, a: stat.mode & 0o7777, f: stat.mode, i: stat.ino, h: stat.nlink, u: stat.uid, g: stat.gid, d: stat.dev, D: stat.dev,
469
- B: 512, b: stat.allocatedBytes === undefined ? undefined : Math.ceil(stat.allocatedBytes / 512),
470
- o: stat.ioBlockSize, t: stat.rdevMajor, T: stat.rdevMinor };
471
- if (!Object.hasOwn(fields, code))
472
- throw new FsError("ENOTSUP", { message: `unsupported stat format: %${code}` });
473
- const value = fields[code];
474
- text = terse && value === undefined ? "?" : available(value, code).toString(code === "a" ? 8 : ["f", "D", "t", "T"].includes(code) ? 16 : 10);
475
- numeric = text !== "?";
476
- }
477
- append(formatField(text, code, flags, width, precision, numeric, epochCode));
478
- if (linkText !== undefined) {
479
- append(" -> ");
480
- append(formatField(linkText, code, flags, width, precision, false, false));
481
- }
482
- }
483
- return concatBytes(chunks);
484
- }
485
- function resolveSyncStatPath(cwd, target) {
486
- const raw = target.startsWith("/") ? target : (cwd.endsWith("/") ? cwd + target : `${cwd}/${target}`);
487
- const parts = raw.split("/");
488
- const stack = [];
489
- for (const part of parts) {
490
- if (!part || part === ".")
491
- continue;
492
- if (part === "..")
493
- stack.pop();
494
- else
495
- stack.push(part);
496
- }
497
- return "/" + stack.join("/");
498
- }
499
- export function evalSyncStat(args, cwd, quotingStyle, inspectStat) {
500
- let parsed;
501
- try {
502
- parsed = parse(args);
503
- }
504
- catch {
505
- return undefined;
506
- }
507
- const outChunks = [];
508
- for (const name of parsed.paths) {
509
- if (!name)
510
- return undefined;
511
- const abs = resolveSyncStatPath(cwd, name);
512
- const stat = inspectStat(abs, parsed.follow || parsed.filesystem);
513
- if (!stat)
514
- return undefined;
515
- const terse = parsed.terse && parsed.format === undefined;
516
- if (terse && parsed.filesystem)
517
- return undefined;
518
- const format = parsed.format ?? (parsed.filesystem ? " File: %n\n Type: %T" : terse
519
- ? "%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %W %o"
520
- : " File: %N\n Size: %s\tType: %F\n Mode: %a (%A)\nAccess: %x\nModify: %y\nChange: %z\n Birth: %w");
521
- try {
522
- const rendered = renderSync(abs, name, stat, format, parsed.printf, 262144, parsed.filesystem, terse, quotingStyle);
523
- outChunks.push(parsed.printf ? rendered : concatBytes([rendered, Uint8Array.of(10)]));
524
- }
525
- catch {
526
- return undefined;
527
- }
528
- }
529
- return syncStatDecoder.decode(concatBytes(outChunks));
530
- }
1
+ export * from "../../../safe-bash-command-stat/command.js";
531
2
  //# sourceMappingURL=stat.js.map
@@ -0,0 +1,13 @@
1
+ import {
2
+ init_platform
3
+ } from "../../chunks/chunk-B7TAL7S5.js";
4
+
5
+ // packages/safe-bash/src/commands/mktemp/index.ts
6
+ init_platform();
7
+ import { createMktempCommand, createMktempCommands, evalSyncMktemp, mktempCommands } from "../../../safe-bash-command-mktemp/index.js";
8
+ export {
9
+ createMktempCommand,
10
+ createMktempCommands,
11
+ evalSyncMktemp,
12
+ mktempCommands
13
+ };
@@ -0,0 +1,2 @@
1
+ export * from "../../../safe-bash-command-mktemp/index.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,2 @@
1
+ export * from "../../../safe-bash-command-mktemp/index.js";
2
+ //# sourceMappingURL=index.js.map
@@ -13,8 +13,8 @@ import {
13
13
  evalSyncWget,
14
14
  networkCommands
15
15
  } from "../../chunks/chunk-K6VCD7IY.js";
16
- import "../../chunks/chunk-IWDICZVK.js";
17
16
  import "../../chunks/chunk-E7OYNDGL.js";
17
+ import "../../chunks/chunk-IWDICZVK.js";
18
18
  import "../../chunks/chunk-B7TAL7S5.js";
19
19
  export {
20
20
  CurlError,
@@ -2,13 +2,13 @@ import {
2
2
  createSafeJsNodeCommand,
3
3
  createSafeJsNodeCommands,
4
4
  safeJsNodeCommands
5
- } from "../../chunks/chunk-FNDNHAGE.js";
6
- import "../../chunks/chunk-IVRQ4BXL.js";
5
+ } from "../../chunks/chunk-JMMEIDPF.js";
6
+ import "../../chunks/chunk-PH63PLPZ.js";
7
7
  import "../../chunks/chunk-D3ANYGMC.js";
8
- import "../../chunks/chunk-NZQXYWA3.js";
8
+ import "../../chunks/chunk-5OHX7C2V.js";
9
9
  import "../../chunks/chunk-74GHTNJA.js";
10
- import "../../chunks/chunk-IWDICZVK.js";
11
10
  import "../../chunks/chunk-E7OYNDGL.js";
11
+ import "../../chunks/chunk-IWDICZVK.js";
12
12
  import "../../chunks/chunk-B7TAL7S5.js";
13
13
  export {
14
14
  createSafeJsNodeCommand as createNodeCommand,
@@ -1,2 +1,2 @@
1
- export declare function randomInteger(maximum: number): number;
1
+ export * from "../../safe-bash-metadata-engine/random.js";
2
2
  //# sourceMappingURL=portable-random.d.ts.map
@@ -1,13 +1,2 @@
1
- export function randomInteger(maximum) {
2
- const range = 0x1_0000_0000;
3
- if (!Number.isSafeInteger(maximum) || maximum < 1 || maximum > range) {
4
- throw new RangeError("Random integer maximum must be an integer from 1 to 2^32");
5
- }
6
- const limit = Math.floor(range / maximum) * maximum;
7
- const sample = new Uint32Array(1);
8
- do {
9
- globalThis.crypto.getRandomValues(sample);
10
- } while (sample[0] >= limit);
11
- return sample[0] % maximum;
12
- }
1
+ export * from "../../safe-bash-metadata-engine/random.js";
13
2
  //# sourceMappingURL=portable-random.js.map
@@ -16,19 +16,19 @@ import {
16
16
  pythonCommands,
17
17
  pythonDocumentPackages,
18
18
  pythonHostFailureCode
19
- } from "../../chunks/chunk-VQDD3G76.js";
20
- import "../../chunks/chunk-I5HZ4FGE.js";
21
- import "../../chunks/chunk-ICFDYV64.js";
22
- import "../../chunks/chunk-VTH3MLDU.js";
23
- import "../../chunks/chunk-NZQXYWA3.js";
24
- import "../../chunks/chunk-74GHTNJA.js";
25
- import "../../chunks/chunk-7R5BDCG7.js";
19
+ } from "../../chunks/chunk-EEEWOYEG.js";
20
+ import "../../chunks/chunk-HZAMGT5I.js";
26
21
  import {
27
22
  PythonFailure,
28
23
  inspectPythonCapabilities
29
24
  } from "../../chunks/chunk-LVOBFF4D.js";
30
- import "../../chunks/chunk-IWDICZVK.js";
25
+ import "../../chunks/chunk-I5HZ4FGE.js";
26
+ import "../../chunks/chunk-VTH3MLDU.js";
27
+ import "../../chunks/chunk-5OHX7C2V.js";
28
+ import "../../chunks/chunk-74GHTNJA.js";
29
+ import "../../chunks/chunk-7R5BDCG7.js";
31
30
  import "../../chunks/chunk-E7OYNDGL.js";
31
+ import "../../chunks/chunk-IWDICZVK.js";
32
32
  import "../../chunks/chunk-B7TAL7S5.js";
33
33
  export {
34
34
  PythonFailure,
@@ -1,6 +1,10 @@
1
1
  import {
2
2
  RegexExecutionError
3
3
  } from "../../chunks/chunk-46Z5E5EV.js";
4
+ import {
5
+ RegexExecutor,
6
+ RegexSession
7
+ } from "../../chunks/chunk-VKNVHEX3.js";
4
8
  import {
5
9
  EreLedger,
6
10
  EreProfileLimitError,
@@ -11,10 +15,8 @@ import {
11
15
  matchEre
12
16
  } from "../../chunks/chunk-6O77NL2S.js";
13
17
  import {
14
- RegexExecutor,
15
- RegexSession,
16
18
  createBoundedRegexProvider
17
- } from "../../chunks/chunk-NR3EM4LS.js";
19
+ } from "../../chunks/chunk-FZE4HW6G.js";
18
20
  import "../../chunks/chunk-B7TAL7S5.js";
19
21
  export {
20
22
  EreLedger,