@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,55 @@
1
+ import {
2
+ registerDefaultExecutors
3
+ } from "./chunk-E7OYNDGL.js";
4
+ import {
5
+ init_platform
6
+ } from "./chunk-B7TAL7S5.js";
7
+
8
+ // packages/safe-bash/src/commands/metadata/index.ts
9
+ init_platform();
10
+
11
+ // packages/safe-bash/src/commands/metadata/chmod.ts
12
+ init_platform();
13
+ import { createChmodCommand, evalSyncChmod, modeChange } from "../../safe-bash-command-chmod/command.js";
14
+
15
+ // packages/safe-bash/src/commands/metadata/stat.ts
16
+ init_platform();
17
+ import { createStatCommand, evalSyncStat } from "../../safe-bash-command-stat/command.js";
18
+
19
+ // packages/safe-bash/src/commands/metadata/mktemp.ts
20
+ init_platform();
21
+ import { createMktempCommand, evalSyncMktemp } from "../../safe-bash-command-mktemp/command.js";
22
+
23
+ // packages/safe-bash/src/commands/truncate.ts
24
+ init_platform();
25
+ import {} from "../../safe-bash-command-truncate/index.js";
26
+ import { createTruncateCommand, createTruncateCommands, truncateCommand, truncateCommands, evalSyncTruncate } from "../../safe-bash-command-truncate/index.js";
27
+
28
+ // packages/safe-bash/src/commands/metadata/internal.ts
29
+ init_platform();
30
+ import { MetadataBudget, metadataCommand, permissionString, settings } from "../../safe-bash-metadata-engine/index.js";
31
+
32
+ // packages/safe-bash/src/commands/metadata/index.ts
33
+ import { evalSyncTruncate as evalSyncTruncate2 } from "../../safe-bash-command-truncate/index.js";
34
+ function createMetadataCommands(options = {}) {
35
+ settings(options);
36
+ return registerDefaultExecutors([createChmodCommand(options), createStatCommand(options), createMktempCommand(options), truncateCommand(options)], options);
37
+ }
38
+ function metadataCommands(options = {}) {
39
+ const commands = createMetadataCommands(options);
40
+ return { name: "metadata-commands", setup(host) {
41
+ if (!options.replace) {
42
+ for (const command of commands) if (host.commands.has(command.name)) throw new Error(`Command already registered: ${command.name}`);
43
+ }
44
+ for (const command of commands) host.commands.register(command, { replace: options.replace ?? false });
45
+ } };
46
+ }
47
+
48
+ export {
49
+ modeChange,
50
+ evalSyncStat,
51
+ evalSyncMktemp,
52
+ createMetadataCommands,
53
+ metadataCommands,
54
+ evalSyncTruncate2 as evalSyncTruncate
55
+ };
@@ -6,12 +6,7 @@ import {
6
6
  init_platform();
7
7
  import { AvailableRecords, RegexExecutionError, RegexExecutor, RegexSession, withRegexSession } from "../../safe-bash-regex-engine/execution/portable.js";
8
8
 
9
- // packages/safe-bash/src/commands/regex-execution/bounded-provider.ts
10
- init_platform();
11
- import { createBoundedRegexProvider } from "../../safe-bash-regex-engine/execution/bounded-provider.js";
12
-
13
9
  export {
14
10
  RegexExecutor,
15
- RegexSession,
16
- createBoundedRegexProvider
11
+ RegexSession
17
12
  };
@@ -0,0 +1,14 @@
1
+ import {
2
+ init_platform
3
+ } from "./chunk-B7TAL7S5.js";
4
+
5
+ // packages/safe-bash/src/commands/apply-patch/index.ts
6
+ init_platform();
7
+ import { applyPatchCommands, createApplyPatchCommand, createApplyPatchCommands, evalSyncApplyPatch } from "../../safe-bash-command-apply-patch/index.js";
8
+
9
+ export {
10
+ applyPatchCommands,
11
+ createApplyPatchCommand,
12
+ createApplyPatchCommands,
13
+ evalSyncApplyPatch
14
+ };
@@ -0,0 +1,49 @@
1
+ import {
2
+ registerDefaultExecutors
3
+ } from "./chunk-E7OYNDGL.js";
4
+ import {
5
+ init_platform
6
+ } from "./chunk-B7TAL7S5.js";
7
+
8
+ // packages/safe-bash/src/commands/time-env/index.ts
9
+ init_platform();
10
+
11
+ // packages/safe-bash/src/commands/time-env/printenv.ts
12
+ init_platform();
13
+ import { createPrintenvWithSettings } from "../../safe-bash-command-printenv/printenv.js";
14
+ import { evalSyncPrintenv } from "../../safe-bash-command-printenv/printenv.js";
15
+
16
+ // packages/safe-bash/src/commands/time-env/date.ts
17
+ init_platform();
18
+ import { createDateWithSettings } from "../../safe-bash-command-date/date.js";
19
+ import { evalSyncDate } from "../../safe-bash-command-date/date.js";
20
+
21
+ // packages/safe-bash/src/commands/time-env/sleep.ts
22
+ init_platform();
23
+ import { createSleepWithSettings } from "../../safe-bash-command-sleep/sleep.js";
24
+
25
+ // packages/safe-bash/src/commands/time-env/shared.ts
26
+ init_platform();
27
+ import { CommandFailure, checkSize, command, defaultSleepScheduler, emit, ownEnvironment, settings, timeEnvExecutorSettings } from "../../safe-bash-calendar-engine/time-env/shared.js";
28
+
29
+ // packages/safe-bash/src/commands/time-env/index.ts
30
+ function createTimeEnvCommands(options = {}) {
31
+ const configuration = settings(options);
32
+ return registerDefaultExecutors([createDateWithSettings(configuration), createSleepWithSettings(configuration), createPrintenvWithSettings(configuration)], options);
33
+ }
34
+ function timeEnvCommands(options = {}) {
35
+ const commands = createTimeEnvCommands(options);
36
+ return { name: "time-env-commands", setup(host) {
37
+ if (!options.replace) for (const definition of commands) {
38
+ if (host.commands.has(definition.name)) throw new Error(`Command already registered: ${definition.name}`);
39
+ }
40
+ for (const definition of commands) host.commands.register(definition, { replace: options.replace ?? false });
41
+ } };
42
+ }
43
+
44
+ export {
45
+ evalSyncPrintenv,
46
+ evalSyncDate,
47
+ createTimeEnvCommands,
48
+ timeEnvCommands
49
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  SearchError
3
- } from "./chunk-VGG2DL5Q.js";
3
+ } from "./chunk-TRR4MYWF.js";
4
4
  import {
5
5
  init_buffer
6
6
  } from "./chunk-HX3SHTCE.js";
@@ -10,7 +10,7 @@ import {
10
10
 
11
11
  // packages/safe-bash-contracts/src/io.ts
12
12
  init_buffer();
13
- import { collectBytes, readBytes } from "@poe-platform/safe-fs/core";
13
+ import { collectBytes, readBytes, retainFileSystemCleanup } from "@poe-platform/safe-fs/core";
14
14
  import { collectBytes as collectBytes2, readBytes as readBytes2, toByteSource } from "@poe-platform/safe-fs/core";
15
15
 
16
16
  // packages/safe-bash-contracts/src/managed-abort.ts
@@ -305,6 +305,7 @@ Object.assign(PipeWriteEndpointImpl.prototype, {
305
305
  });
306
306
  var BytePipeImpl = class {
307
307
  constructor(options) {
308
+ this.admitWrite = options.admitWrite;
308
309
  const highWaterMark = options.highWaterMark ?? 64 * 1024;
309
310
  if (!Number.isSafeInteger(highWaterMark) || highWaterMark < 1) {
310
311
  throw new RangeError("highWaterMark must be a positive safe integer");
@@ -636,6 +637,7 @@ var BytePipeImpl = class {
636
637
  if (!this.readerReferences) throw brokenPipe();
637
638
  if (!(chunk instanceof Uint8Array)) throw new TypeError("Byte sinks require Uint8Array chunks");
638
639
  if (!chunk.byteLength) return resolvedVoid;
640
+ this.admitWrite?.(chunk.byteLength);
639
641
  const owned = new Uint8Array(chunk);
640
642
  if (!this.writes || this.writes.size === 0) {
641
643
  const reading = this.reads && this.reads.size > 0 ? this.reads.values().next().value : void 0;
@@ -858,16 +860,21 @@ var InputByteBudget = class _InputByteBudget {
858
860
  return value;
859
861
  }
860
862
  assertOpen() {
861
- if (this.#failure) throw this.#failure;
863
+ if (this.#failure) throw this.#failure.error;
862
864
  }
863
865
  charge(bytes) {
864
866
  this.assertOpen();
865
867
  if (!Number.isSafeInteger(bytes) || bytes < 0) throw new RangeError("Invalid input byte charge");
866
868
  if (bytes > this.maximum - this.#used) {
867
- this.#failure = new FsError("EFBIG", { message: "command input byte limit exceeded" });
868
- throw this.#failure;
869
+ this.#failure = { error: new FsError("EFBIG", { message: "command input byte limit exceeded" }) };
870
+ throw this.#failure.error;
871
+ }
872
+ try {
873
+ this.host?.check(this.#used + bytes);
874
+ } catch (error) {
875
+ this.#failure = { error };
876
+ throw error;
869
877
  }
870
- this.host?.check(this.#used + bytes);
871
878
  this.#used += bytes;
872
879
  }
873
880
  async run(context, execute) {
@@ -875,7 +882,7 @@ var InputByteBudget = class _InputByteBudget {
875
882
  const limited = {
876
883
  ...context,
877
884
  stdin: this.read(context.stdin, context.signal),
878
- fs: Object.create(fs, {
885
+ fs: new Proxy(Object.create(fs, {
879
886
  readFile: { configurable: true, value: async (...args) => {
880
887
  this.assertOpen();
881
888
  const bytes = await fs.readFile(...args);
@@ -902,6 +909,12 @@ var InputByteBudget = class _InputByteBudget {
902
909
  this.assertOpen();
903
910
  return this.read(fs.readStream(...args), context.signal);
904
911
  } } } : {}
912
+ }), {
913
+ get(target, key) {
914
+ if (Object.hasOwn(target, key)) return Reflect.get(target, key, target);
915
+ const value = Reflect.get(fs, key, fs);
916
+ return typeof value === "function" ? value.bind(fs) : value;
917
+ }
905
918
  }),
906
919
  inputBudget: {
907
920
  maxBytes: Math.min(this.maximum, context.inputBudget?.maxBytes ?? Infinity),
@@ -912,6 +925,13 @@ var InputByteBudget = class _InputByteBudget {
912
925
  }
913
926
  }
914
927
  };
928
+ const retain = (filesystem, callback, options) => {
929
+ if (filesystem !== limited.fs) throw new TypeError("Invalid input-budget cleanup filesystem");
930
+ return retainFileSystemCleanup(fs, callback, options);
931
+ };
932
+ Object.defineProperty(limited.fs, /* @__PURE__ */ Symbol.for("safe-fs.retainedCleanup"), {
933
+ value: Object.freeze({ filesystem: limited.fs, retain })
934
+ });
915
935
  try {
916
936
  return await execute(limited);
917
937
  } finally {
@@ -0,0 +1,200 @@
1
+ import {
2
+ init_buffer
3
+ } from "./chunk-HX3SHTCE.js";
4
+
5
+ // packages/safe-bash-command-chmod/src/command.ts
6
+ init_buffer();
7
+ import { modeChange } from "../../safe-bash-io-engine/commands/mode-change.js";
8
+ import { modeChange as modeChange2 } from "../../safe-bash-io-engine/commands/mode-change.js";
9
+ import { bindConditionalMutation } from "@poe-platform/safe-fs/core";
10
+ import { creationUmask } from "../../safe-bash-contracts/runtime-control.js";
11
+ import { FsError } from "../../safe-bash-contracts/index.js";
12
+ import { codeOf, diagnostic, options, pathOf, requireOperands, syncCommandEvaluators, UsageError, value } from "../../safe-bash-io-engine/internal.js";
13
+ import { gnuInformationSync } from "../../safe-bash-io-engine/gnu-information.js";
14
+ import { MetadataBudget, metadataCommand, permissionString, settings } from "../../safe-bash-metadata-engine/index.js";
15
+ function createChmodCommand(configuration = {}) {
16
+ const configured = settings(configuration);
17
+ const configuredUmask = configuration.umask === void 0 ? void 0 : configured.umask;
18
+ return metadataCommand("chmod", async (context) => {
19
+ const budget = new MetadataBudget(context, configured.limits);
20
+ const modeOptions = [];
21
+ let ended = false, referenceValue = false;
22
+ const args = context.args.flatMap((argument) => {
23
+ if (referenceValue) {
24
+ referenceValue = false;
25
+ return [argument];
26
+ }
27
+ if (argument === "--") ended = true;
28
+ if (ended) return [argument];
29
+ if (argument === "--reference") referenceValue = true;
30
+ if (argument.startsWith("-") && argument.length > 1 && "rwxXstugo01234567".includes(argument[1])) {
31
+ modeOptions.push(argument);
32
+ return [];
33
+ }
34
+ return [argument];
35
+ });
36
+ const parsed = options(args, "Rvcf", { recursive: "R", verbose: "v", changes: "c", silent: "f", quiet: "f", reference: "reference:" });
37
+ const reference = value(parsed, "reference");
38
+ if (reference !== void 0 && modeOptions.length) throw new UsageError("cannot combine mode and --reference options");
39
+ requireOperands(parsed.operands, reference === void 0 && !modeOptions.length ? 2 : 1);
40
+ const mode = modeOptions.length ? modeOptions.join(",") : reference === void 0 ? parsed.operands.shift() : void 0;
41
+ const mask = configuredUmask ?? Reflect.get(context.fs, creationUmask);
42
+ const activeUmask = typeof mask === "number" ? mask : configured.umask;
43
+ const change = mode === void 0 ? void 0 : modeChange(mode, activeUmask);
44
+ const paths = parsed.operands;
45
+ if (context.fs.capabilities.readOnly) throw new FsError("EROFS", { syscall: "chmod" });
46
+ if (!context.fs.chmod || context.fs.capabilities.permissions === false) throw new FsError("ENOTSUP", { syscall: "chmod" });
47
+ const referenceMode = reference === void 0 ? void 0 : (await context.fs.stat(pathOf(context, reference), { signal: context.signal })).mode & 4095;
48
+ let exitCode = 0;
49
+ const visit = async (path, display, depth, top) => {
50
+ await budget.step(depth);
51
+ const link = await context.fs.lstat(path, { signal: context.signal });
52
+ if (link.type === "symlink" && !top) return;
53
+ const target = link.type === "symlink" ? await context.fs.realpath(path, { signal: context.signal }) : path;
54
+ const stat = link.type === "symlink" ? await context.fs.stat(target, { signal: context.signal }) : link;
55
+ const mode2 = referenceMode ?? change(stat);
56
+ if (parsed.flags.has("R") && stat.type === "directory" && await context.fs.realpath(target, { signal: context.signal }) === "/") throw new FsError("EBUSY", { syscall: "chmod", path, message: "refusing recursive mode changes at virtual root" });
57
+ const canonicalTarget = await context.fs.realpath(target, { signal: context.signal });
58
+ const apply = async () => {
59
+ context.signal.throwIfAborted();
60
+ const currentCanonical = await context.fs.realpath(target, { signal: context.signal });
61
+ if (currentCanonical !== canonicalTarget) throw new FsError("EIO", { syscall: "chmod", path, message: "path changed during permission update" });
62
+ const fresh = await context.fs.lstat(canonicalTarget, { signal: context.signal });
63
+ if (fresh.type === "symlink" || fresh.type !== stat.type || stat.ino !== void 0 && fresh.ino !== stat.ino || stat.dev !== void 0 && fresh.dev !== stat.dev) throw new FsError("EIO", { syscall: "chmod", path, message: "path changed during permission update" });
64
+ const capabilities = await context.fs.capabilitiesFor?.(canonicalTarget, { signal: context.signal, conditionalChmod: true }) ?? context.fs.capabilities;
65
+ context.signal.throwIfAborted();
66
+ if (capabilities.conditionalChmod !== true) throw new FsError("ENOTSUP", { syscall: "chmod", path, message: "conditional permission updates are not supported" });
67
+ const parentPath = canonicalTarget.slice(0, canonicalTarget.lastIndexOf("/")) || "/";
68
+ const ancestorPaths = ["/"];
69
+ if (parentPath !== "/") {
70
+ let prefix = "";
71
+ for (const part of parentPath.split("/").filter(Boolean)) {
72
+ prefix += `/${part}`;
73
+ ancestorPaths.push(prefix);
74
+ }
75
+ }
76
+ const ancestors = await Promise.all(ancestorPaths.map(async (entryPath) => ({
77
+ path: entryPath,
78
+ stat: await context.fs.lstat(entryPath, { signal: context.signal })
79
+ })));
80
+ const parentStat = ancestors.at(-1).stat;
81
+ const mutation = { signal: context.signal, parent: parentStat, expected: fresh, ancestors };
82
+ await bindConditionalMutation(
83
+ fresh.identityScope,
84
+ { path: canonicalTarget, parent: parentStat, expected: fresh, ancestors },
85
+ () => context.fs.chmod(canonicalTarget, mode2, mutation)
86
+ );
87
+ if (parsed.flags.has("v") || parsed.flags.has("c") && mode2 !== (stat.mode & 4095)) {
88
+ await budget.output(`mode of '${display}' ${mode2 === (stat.mode & 4095) ? "retained as" : "changed from " + (stat.mode & 4095).toString(8).padStart(4, "0") + " (" + permissionString(stat.mode, stat.type).slice(1) + ") to"} ${mode2.toString(8).padStart(4, "0")} (${permissionString(mode2, stat.type).slice(1)})
89
+ `);
90
+ }
91
+ };
92
+ const deferred = stat.type === "directory" && parsed.flags.has("R") && (stat.mode & 511 & ~mode2) !== 0;
93
+ if (!deferred) await apply();
94
+ if (stat.type === "directory" && parsed.flags.has("R")) {
95
+ const entries = await context.fs.readdir(target, {
96
+ signal: context.signal,
97
+ ...Number.isFinite(budget.remainingEntries) ? { maxEntries: budget.remainingEntries } : {}
98
+ });
99
+ if (entries.length > budget.remainingEntries) throw new FsError("EFBIG", { message: "metadata traversal limit exceeded" });
100
+ for (const entry of entries) {
101
+ if (!entry.name || entry.name === "." || entry.name === ".." || entry.name.includes("/") || entry.name.includes("\0")) throw new FsError("EIO", { message: "invalid directory entry" });
102
+ try {
103
+ await visit(`${target.replace(/\/$/u, "")}/${entry.name}`, `${display.replace(/\/$/u, "")}/${entry.name}`, depth + 1, false);
104
+ } catch (error) {
105
+ context.signal.throwIfAborted();
106
+ if (codeOf(error) === "EFBIG") throw error;
107
+ exitCode = 1;
108
+ if (!parsed.flags.has("f")) await diagnostic(context, error);
109
+ }
110
+ }
111
+ }
112
+ if (deferred) await apply();
113
+ };
114
+ for (const operand of paths) {
115
+ try {
116
+ await visit(pathOf(context, operand), operand, 0, true);
117
+ } catch (error) {
118
+ context.signal.throwIfAborted();
119
+ if (codeOf(error) === "EFBIG") throw error;
120
+ exitCode = 1;
121
+ if (!parsed.flags.has("f")) await diagnostic(context, error);
122
+ }
123
+ }
124
+ return { exitCode };
125
+ });
126
+ }
127
+ function evalSyncChmod(opArgs, umask, chmodNodeSync) {
128
+ const gnuInfo = gnuInformationSync("chmod", opArgs);
129
+ if (gnuInfo !== void 0) return gnuInfo;
130
+ if (!chmodNodeSync) return void 0;
131
+ try {
132
+ const modeOptions = [];
133
+ let ended = false;
134
+ let referenceValue = false;
135
+ const args = [];
136
+ for (const argument of opArgs) {
137
+ if (referenceValue) {
138
+ referenceValue = false;
139
+ args.push(argument);
140
+ continue;
141
+ }
142
+ if (argument === "--") {
143
+ ended = true;
144
+ args.push(argument);
145
+ continue;
146
+ }
147
+ if (!ended && argument === "--reference") {
148
+ referenceValue = true;
149
+ args.push(argument);
150
+ continue;
151
+ }
152
+ if (!ended && argument.startsWith("-") && argument.length > 1 && "rwxXstugo01234567".includes(argument[1])) {
153
+ modeOptions.push(argument);
154
+ continue;
155
+ }
156
+ args.push(argument);
157
+ }
158
+ const parsed = options(args, "vcf", { verbose: "v", changes: "c", silent: "f", quiet: "f", reference: "reference:" });
159
+ const reference = value(parsed, "reference");
160
+ if (reference !== void 0 && modeOptions.length) return void 0;
161
+ const minOps = reference !== void 0 || modeOptions.length ? 1 : 2;
162
+ if (parsed.operands.length < minOps) return void 0;
163
+ let referenceMode;
164
+ if (reference !== void 0) {
165
+ if (!chmodNodeSync(reference, (stat) => {
166
+ referenceMode = stat.mode & 4095;
167
+ return stat.mode;
168
+ }) || referenceMode === void 0) {
169
+ return void 0;
170
+ }
171
+ }
172
+ const mode = modeOptions.length ? modeOptions.join(",") : reference === void 0 ? parsed.operands.shift() : void 0;
173
+ const change = mode === void 0 ? void 0 : modeChange(mode, umask);
174
+ let out = "";
175
+ for (const op of parsed.operands) {
176
+ let line = "";
177
+ const ok = chmodNodeSync(op, (stat) => {
178
+ const oldMode = stat.mode & 4095;
179
+ const nextMode = (referenceMode ?? change(stat)) & 4095;
180
+ if (parsed.flags.has("v") || parsed.flags.has("c") && nextMode !== oldMode) {
181
+ line = `mode of '${op}' ${nextMode === oldMode ? "retained as" : "changed from " + oldMode.toString(8).padStart(4, "0") + " (" + permissionString(oldMode, stat.type).slice(1) + ") to"} ${nextMode.toString(8).padStart(4, "0")} (${permissionString(nextMode, stat.type).slice(1)})
182
+ `;
183
+ }
184
+ return nextMode;
185
+ });
186
+ if (!ok) return void 0;
187
+ out += line;
188
+ }
189
+ return out;
190
+ } catch {
191
+ return void 0;
192
+ }
193
+ }
194
+ syncCommandEvaluators.evalSyncChmod = evalSyncChmod;
195
+
196
+ export {
197
+ createChmodCommand,
198
+ evalSyncChmod,
199
+ modeChange2 as modeChange
200
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  formats
3
- } from "./chunk-5E4WAO4O.js";
3
+ } from "./chunk-JD5QNRNO.js";
4
4
  import {
5
5
  CompressedDataError
6
6
  } from "./chunk-2UQSP2CE.js";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-Z6UEDK5T.js";
4
4
  import {
5
5
  boundedCodec
6
- } from "./chunk-W5DNF4JH.js";
6
+ } from "./chunk-LOICUCHG.js";
7
7
  import {
8
8
  init_buffer
9
9
  } from "./chunk-HX3SHTCE.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  SearchError
3
- } from "./chunk-VGG2DL5Q.js";
3
+ } from "./chunk-TRR4MYWF.js";
4
4
  import {
5
5
  init_buffer
6
6
  } from "./chunk-HX3SHTCE.js";
@@ -125,7 +125,7 @@ function syntheticStatFor(type) {
125
125
  function createFindDefinitions(execute, maxDirectoryEntries) {
126
126
  const readDirectory = createDirectoryReader(maxDirectoryEntries);
127
127
  const defs = [define("find", (context) => {
128
- if (!context.argumentValues && context.args.length === 3 && (context.args[1] === "-name" || context.args[1] === "-iname") && !sharedFindPrintBufInUse && !context.signal.aborted) {
128
+ if (context._hasInfiniteFsOpsLimit === true && !context.argumentValues && context.args.length === 3 && (context.args[1] === "-name" || context.args[1] === "-iname") && !sharedFindPrintBufInUse && !context.signal.aborted) {
129
129
  const rootDisplay = context.args[0];
130
130
  if (rootDisplay && !rootDisplay.startsWith("-") && rootDisplay !== "!" && rootDisplay !== "(") {
131
131
  const fastBacking = context._fastMemoryBackingFs;
@@ -658,7 +658,7 @@ ${explicitAction ? tree : `AND(${tree}, implicit -print)`}
658
658
  })();
659
659
  };
660
660
  const canSkipChildStat = !needsStat && !explicitAction && follow !== "-L";
661
- const backing = getRuntimeBackingFileSystem(context.fs);
661
+ const backing = context._hasInfiniteFsOpsLimit === true ? getRuntimeBackingFileSystem(context.fs) : void 0;
662
662
  const maxEntriesLimit = maxDirectoryEntries ?? Infinity;
663
663
  let uniformDirAdmitted = false;
664
664
  const scratchChildEntry = { path: "", display: "", name: "", stat: SYNTHETIC_FILE_STAT, symlink: false, depth: 0, root: "", relative: "", prune: false };