@poe-platform/safe-bash 0.1.802 → 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 (150) hide show
  1. package/README.md +4 -2
  2. package/dist/image-ast/index.browser.js +13 -4
  3. package/dist/image-ast/index.js +13 -4
  4. package/dist/safe-bash/chunks/{chunk-KDNSPLII.js → chunk-2LSAMQER.js} +1 -0
  5. package/dist/safe-bash/chunks/{chunk-NZQXYWA3.js → chunk-5OHX7C2V.js} +0 -1
  6. package/dist/safe-bash/chunks/{chunk-SHEMU2Z7.js → chunk-B7PIL77G.js} +82 -63
  7. package/dist/safe-bash/chunks/{chunk-WDLGKIHD.js → chunk-EEEWOYEG.js} +4 -4
  8. package/dist/safe-bash/chunks/{chunk-GETUOD5D.js → chunk-GDYNCWRV.js} +1 -1
  9. package/dist/safe-bash/chunks/{chunk-RSTHLAF3.js → chunk-JMMEIDPF.js} +1 -1
  10. package/dist/safe-bash/chunks/{chunk-44ALJ4QG.js → chunk-PNBBUWSM.js} +71 -55
  11. package/dist/safe-bash/chunks/{chunk-NQCM3TYR.js → chunk-RYFQ3LZG.js} +73 -44
  12. package/dist/safe-bash/chunks/chunk-VBTDHOWC.js +55 -0
  13. package/dist/safe-bash/command-chunks/{chunk-ORYGZYKW.js → chunk-4FEVBOL5.js} +1 -1
  14. package/dist/safe-bash/command-chunks/{chunk-VXSLJH7G.js → chunk-6JSIFWYT.js} +26 -6
  15. package/dist/safe-bash/command-chunks/chunk-A7MU7762.js +200 -0
  16. package/dist/safe-bash/command-chunks/{chunk-KJIMDLBB.js → chunk-BXCXRYVU.js} +1 -1
  17. package/dist/safe-bash/command-chunks/{chunk-F4TEEZTL.js → chunk-CQHP3I66.js} +1 -1
  18. package/dist/safe-bash/command-chunks/{chunk-PEF7K3UQ.js → chunk-EARHPPPJ.js} +1 -1
  19. package/dist/safe-bash/command-chunks/{chunk-QKFSRZGQ.js → chunk-GFC2NTDG.js} +2 -2
  20. package/dist/safe-bash/command-chunks/chunk-GIRNFXP3.js +466 -0
  21. package/dist/safe-bash/command-chunks/{chunk-FPVUD6TH.js → chunk-HDCNKOIX.js} +9 -7
  22. package/dist/safe-bash/command-chunks/{chunk-MQFIPHIQ.js → chunk-ILX2NOLF.js} +18 -15
  23. package/dist/safe-bash/command-chunks/{chunk-5E4WAO4O.js → chunk-JD5QNRNO.js} +3 -3
  24. package/dist/safe-bash/command-chunks/{chunk-I237SNW5.js → chunk-LFJJQQND.js} +1 -1
  25. package/dist/safe-bash/command-chunks/{chunk-W5DNF4JH.js → chunk-LOICUCHG.js} +1 -1
  26. package/dist/safe-bash/command-chunks/{chunk-7U7EXOXX.js → chunk-NASVPT6F.js} +2 -1
  27. package/dist/safe-bash/command-chunks/{chunk-OQKC5ZU2.js → chunk-NKIELG7Y.js} +22 -1
  28. package/dist/safe-bash/command-chunks/{chunk-WPYIOKE3.js → chunk-PICVQ6B5.js} +2 -2
  29. package/dist/safe-bash/command-chunks/{chunk-YOFC45RK.js → chunk-QVOS4YXL.js} +1 -1
  30. package/dist/safe-bash/command-chunks/{chunk-VGG2DL5Q.js → chunk-TRR4MYWF.js} +4 -0
  31. package/dist/safe-bash/command-chunks/{chunk-2JRBIDAD.js → chunk-V4K2JDYU.js} +2 -2
  32. package/dist/safe-bash/command-chunks/{chunk-6GWJUQAV.js → chunk-WWIBP2ET.js} +38 -111
  33. package/dist/safe-bash/command-chunks/chunk-ZDN7MJE6.js +168 -0
  34. package/dist/safe-bash/commands/bytes/compression/index.js +54 -51
  35. package/dist/safe-bash/commands/chmod/index.browser.js +14 -0
  36. package/dist/safe-bash/commands/chmod/index.d.ts +2 -0
  37. package/dist/safe-bash/commands/chmod/index.js +2 -0
  38. package/dist/safe-bash/commands/metadata/chmod.d.ts +1 -7
  39. package/dist/safe-bash/commands/metadata/chmod.js +1 -204
  40. package/dist/safe-bash/commands/metadata/index.browser.js +1 -5
  41. package/dist/safe-bash/commands/metadata/internal.d.ts +1 -30
  42. package/dist/safe-bash/commands/metadata/internal.js +1 -76
  43. package/dist/safe-bash/commands/metadata/mktemp.d.ts +1 -3
  44. package/dist/safe-bash/commands/metadata/mktemp.js +1 -202
  45. package/dist/safe-bash/commands/metadata/stat.d.ts +1 -7
  46. package/dist/safe-bash/commands/metadata/stat.js +1 -530
  47. package/dist/safe-bash/commands/mktemp/index.browser.js +13 -0
  48. package/dist/safe-bash/commands/mktemp/index.d.ts +2 -0
  49. package/dist/safe-bash/commands/mktemp/index.js +2 -0
  50. package/dist/safe-bash/commands/node/index.browser.js +2 -2
  51. package/dist/safe-bash/commands/portable-random.d.ts +1 -1
  52. package/dist/safe-bash/commands/portable-random.js +1 -12
  53. package/dist/safe-bash/commands/python/index.browser.js +3 -3
  54. package/dist/safe-bash/commands/stat/index.browser.js +13 -0
  55. package/dist/safe-bash/commands/stat/index.d.ts +2 -0
  56. package/dist/safe-bash/commands/stat/index.js +2 -0
  57. package/dist/safe-bash/commands/text.js +46 -10
  58. package/dist/safe-bash/full-core.browser.js +86 -86
  59. package/dist/safe-bash/jobs.browser.js +2 -2
  60. package/dist/safe-bash/opt-in/commands/yq/native-work.js +1 -0
  61. package/dist/safe-bash/optional-host.browser.js +10 -10
  62. package/dist/safe-bash/plugins/index.browser.js +13 -13
  63. package/dist/safe-bash/registry-entry.browser.js +16 -16
  64. package/dist/safe-bash/search.browser.js +14 -14
  65. package/dist/safe-bash/shell/runtime.d.ts +3 -0
  66. package/dist/safe-bash/shell/runtime.js +20 -3
  67. package/dist/safe-bash/shell/types.d.ts +2 -0
  68. package/dist/safe-bash/shell/worker-limits.js +1 -0
  69. package/dist/safe-bash/shell-entry.browser.js +12 -12
  70. package/dist/safe-bash/worker/host.js +1 -1
  71. package/dist/safe-bash-command-bc/index.js +12 -5
  72. package/dist/safe-bash-command-bzip2/index.js +4 -3
  73. package/dist/safe-bash-command-chmod/LICENSE +21 -0
  74. package/dist/safe-bash-command-chmod/command.d.ts +7 -0
  75. package/dist/safe-bash-command-chmod/command.js +11 -0
  76. package/dist/safe-bash-command-chmod/index.d.ts +6 -0
  77. package/dist/safe-bash-command-chmod/index.js +27 -0
  78. package/dist/safe-bash-command-exiftool/index.js +5 -5
  79. package/dist/safe-bash-command-find/find.js +1 -1
  80. package/dist/safe-bash-command-find/index.js +1 -1
  81. package/dist/safe-bash-command-fmt/index.js +9 -2
  82. package/dist/safe-bash-command-gzip/index.js +45 -42
  83. package/dist/safe-bash-command-imagemagick/index.js +3 -1
  84. package/dist/safe-bash-command-jq/index.js +1 -1
  85. package/dist/safe-bash-command-jq/jq.js +1 -1
  86. package/dist/safe-bash-command-less/index.js +12 -3
  87. package/dist/safe-bash-command-mktemp/LICENSE +21 -0
  88. package/dist/safe-bash-command-mktemp/command.d.ts +3 -0
  89. package/dist/safe-bash-command-mktemp/command.js +9 -0
  90. package/dist/safe-bash-command-mktemp/index.d.ts +6 -0
  91. package/dist/safe-bash-command-mktemp/index.js +25 -0
  92. package/dist/safe-bash-command-od/index.js +6 -2
  93. package/dist/safe-bash-command-op/index.js +25 -6
  94. package/dist/safe-bash-command-rg/index.js +1 -1
  95. package/dist/safe-bash-command-rg/rg-command.js +1 -1
  96. package/dist/safe-bash-command-sed/index.js +1 -1
  97. package/dist/safe-bash-command-sed/sed.js +1 -1
  98. package/dist/safe-bash-command-sips/index.js +13 -5
  99. package/dist/safe-bash-command-sponge/index.js +10 -3
  100. package/dist/safe-bash-command-stat/LICENSE +21 -0
  101. package/dist/safe-bash-command-stat/command.d.ts +7 -0
  102. package/dist/safe-bash-command-stat/command.js +9 -0
  103. package/dist/safe-bash-command-stat/index.d.ts +6 -0
  104. package/dist/safe-bash-command-stat/index.js +25 -0
  105. package/dist/safe-bash-command-unrtf/index.js +11 -1
  106. package/dist/safe-bash-command-xxd/index.js +6 -2
  107. package/dist/safe-bash-command-xz/command.d.ts +1 -1
  108. package/dist/safe-bash-command-xz/index.js +3 -2
  109. package/dist/safe-bash-command-yq/index.js +1 -0
  110. package/dist/safe-bash-command-yq/native-work.js +1 -0
  111. package/dist/safe-bash-command-yq/query.js +3 -0
  112. package/dist/safe-bash-compression-engine/bounded-codec.js +3 -3
  113. package/dist/safe-bash-compression-engine/codec-loader.js +2 -2
  114. package/dist/safe-bash-compression-engine/files.js +6 -6
  115. package/dist/safe-bash-compression-engine/index.js +5 -5
  116. package/dist/safe-bash-compression-engine/operand.js +6 -6
  117. package/dist/safe-bash-compression-engine/options.js +1 -1
  118. package/dist/safe-bash-compression-engine/stream.js +5 -5
  119. package/dist/safe-bash-compression-engine/zstd-decode.js +4 -4
  120. package/dist/safe-bash-contracts/escaping.js +2 -2
  121. package/dist/safe-bash-contracts/filesystem-output.js +2 -2
  122. package/dist/safe-bash-contracts/index.js +2 -2
  123. package/dist/safe-bash-contracts/io.d.ts +2 -0
  124. package/dist/safe-bash-contracts/io.js +1 -1
  125. package/dist/safe-bash-contracts/output.js +2 -2
  126. package/dist/safe-bash-io-engine/commands/search/requirements.js +1 -1
  127. package/dist/safe-bash-io-engine/commands/text-programs/shared.js +1 -1
  128. package/dist/safe-bash-mcp/index.browser.js +11 -1
  129. package/dist/safe-bash-mcp/index.js +35 -16
  130. package/dist/safe-bash-metadata-engine/LICENSE +21 -0
  131. package/dist/safe-bash-metadata-engine/index.d.ts +30 -0
  132. package/dist/safe-bash-metadata-engine/index.js +82 -0
  133. package/dist/safe-bash-metadata-engine/random.d.ts +1 -0
  134. package/dist/safe-bash-metadata-engine/random.js +21 -0
  135. package/dist/safe-bash-regex-engine/index.js +1 -1
  136. package/dist/safe-bash-regex-engine/text/regex.js +1 -1
  137. package/dist/safe-bash-search-engine/ergonomic-regex.js +2 -2
  138. package/dist/safe-bash-search-engine/glob.js +2 -2
  139. package/dist/safe-bash-search-engine/grep.js +2 -2
  140. package/dist/safe-bash-search-engine/matcher.js +2 -2
  141. package/dist/safe-bash-search-engine/options.d.ts +2 -0
  142. package/dist/safe-bash-search-engine/options.js +1 -1
  143. package/dist/safe-bash-search-engine/output.js +1 -1
  144. package/dist/safe-bash-search-engine/shared.js +2 -2
  145. package/dist/safe-bash-search-engine/walk.js +3 -3
  146. package/dist/safe-playwright-cloudflare/browser-snapshot-json.js +2 -2
  147. package/dist/safe-playwright-cloudflare/browser-snapshot-references.js +1 -1
  148. package/package.json +31 -5
  149. package/dist/safe-bash/chunks/chunk-VSAJ4OTM.js +0 -962
  150. package/dist/safe-bash/chunks/{chunk-BJA5XNP6.js → chunk-A7XEHALN.js} +3 -3
@@ -15,23 +15,15 @@ import {
15
15
  quoteShellOperand,
16
16
  writeDiagnostic
17
17
  } from "./chunk-PH63PLPZ.js";
18
- import {
19
- shellValueByteLength,
20
- shellValueBytes
21
- } from "./chunk-J42RIHHJ.js";
22
- import {
23
- getCommandArguments
24
- } from "./chunk-7R5BDCG7.js";
25
- import {
26
- creationUmask,
27
- getRuntimeBackingFileSystem,
28
- modeChange
29
- } from "./chunk-VSAJ4OTM.js";
30
18
  import {
31
19
  byteLength,
32
20
  compareUtf8,
33
21
  equalBytes
34
22
  } from "./chunk-D3ANYGMC.js";
23
+ import {
24
+ shellValueByteLength,
25
+ shellValueBytes
26
+ } from "./chunk-J42RIHHJ.js";
35
27
  import {
36
28
  FsError
37
29
  } from "./chunk-VTH3MLDU.js";
@@ -44,12 +36,18 @@ import {
44
36
  relativePath,
45
37
  resolvePath,
46
38
  yieldTurn
47
- } from "./chunk-NZQXYWA3.js";
39
+ } from "./chunk-5OHX7C2V.js";
48
40
  import {
49
41
  collectBytes,
50
42
  readBytes,
51
43
  writeBytes
52
44
  } from "./chunk-74GHTNJA.js";
45
+ import {
46
+ getCommandArguments
47
+ } from "./chunk-7R5BDCG7.js";
48
+ import {
49
+ modeChange
50
+ } from "./chunk-VBTDHOWC.js";
53
51
  import {
54
52
  RESOLVED_EXIT_ZERO,
55
53
  UsageError,
@@ -361,6 +359,10 @@ import { clearRgFastRunnerPool, createRgCommand } from "../../safe-bash-command-
361
359
  init_platform();
362
360
  import { assertCommandRequirements, evaluateCommandSupport } from "../../safe-bash-contracts/command-requirements.js";
363
361
 
362
+ // packages/safe-bash/src/fs/creation-mask.ts
363
+ init_platform();
364
+ import { abortManagedController, addAbortSignalWaiter, builtInDirectContextExecutors as builtInDirectContextExecutors2, chargeRuntimeFileSystemOperation, combineManagedSignals, createManagedControlController, creationUmask, getRuntimeBackingFileSystem, interruptible, isManagedAbortSignal, isManagedControlSignal, isSyncResolved, notifyAbortSignalWaiters, registerManagedAbortSignal, registerRuntimeBackingFileSystem, removeAbortSignalWaiter, syncCommandEvaluators as syncCommandEvaluators2, toNativeAbortSignal } from "../../safe-bash-contracts/runtime-control.js";
365
+
364
366
  // packages/safe-bash/src/commands/bytes/checksums/index.ts
365
367
  init_platform();
366
368
  import { command } from "../../safe-bash-checksum-engine/index.js";
@@ -417,10 +419,11 @@ function createCompressionCommands(config = {}) {
417
419
  if (maxDecodedBytes !== void 0 && maxDecodedBytes !== Infinity && (!Number.isSafeInteger(maxDecodedBytes) || maxDecodedBytes < 0)) {
418
420
  throw new RangeError("maxDecodedBytes must be a nonnegative safe integer or Infinity");
419
421
  }
420
- const commands = profiles.flatMap((profile) => profile.format === "gzip" ? createGzipCommands(config) : profile.format === "bzip2" ? createBzip2Commands(config) : profile.names.map((name) => define(name, withInputByteBudget(async (context) => {
421
- const options2 = parseOptions(name, context.args);
422
- if (options2.help) {
423
- await output(context, `Usage: ${name} [OPTION]... [FILE]...
422
+ const commands = profiles.flatMap((profile) => profile.format === "gzip" ? createGzipCommands(config) : profile.format === "bzip2" ? createBzip2Commands(config) : profile.names.map((name) => {
423
+ const command2 = define(name, async (context) => {
424
+ const options2 = parseOptions(name, context.args);
425
+ if (options2.help) {
426
+ await output(context, `Usage: ${name} [OPTION]... [FILE]...
424
427
  -c, --stdout, --to-stdout
425
428
  -d, --decompress, --uncompress
426
429
  -k, --keep
@@ -430,48 +433,50 @@ ${options2.format === "zstd" ? "-1..-9, --best\nHigher levels and --fast[=NUM] a
430
433
  `}-h, --help
431
434
  No FILE or FILE '-' uses stdin; file output uses private VFS staging.
432
435
  `);
433
- return { exitCode: 0 };
434
- }
435
- let plans;
436
- let planningFailed = false;
437
- try {
438
- if (options2.operands.length > 1) {
439
- plans = [];
440
- for (const name2 of options2.operands) {
441
- try {
442
- plans.push(...await planOperands(context, { ...options2, operands: [name2] }));
443
- } catch (error) {
444
- context.signal.throwIfAborted();
445
- if (codeOf(error) === "EROFS") throw error;
446
- planningFailed = true;
447
- if (options2.quiet < 2) await diagnostic(context, error);
448
- }
449
- }
450
- if (plans.length > 1) await verifyOperandDestinations(context, plans);
451
- } else plans = await planOperands(context, options2);
452
- } catch (error) {
453
- context.signal.throwIfAborted();
454
- if (options2.quiet < 2) throw error;
455
- return { exitCode: 1 };
456
- }
457
- const decodedBudget = new DecodedBudget(maxDecodedBytes);
458
- let exitCode = planningFailed ? 1 : 0;
459
- for (const plan of plans) {
436
+ return { exitCode: 0 };
437
+ }
438
+ let plans;
439
+ let planningFailed = false;
460
440
  try {
461
- const warned = await runOperand(context, plan, options2, decodedBudget);
462
- if (warned) {
463
- if (!options2.quiet) await diagnostic(context, new PublicDiagnostic(`${plan.source}: decompression OK, trailing garbage ignored`));
464
- if (exitCode === 0) exitCode = 2;
465
- }
441
+ if (options2.operands.length > 1) {
442
+ plans = [];
443
+ for (const name2 of options2.operands) {
444
+ try {
445
+ plans.push(...await planOperands(context, { ...options2, operands: [name2] }));
446
+ } catch (error) {
447
+ context.signal.throwIfAborted();
448
+ if (codeOf(error) === "EROFS") throw error;
449
+ planningFailed = true;
450
+ if (options2.quiet < 2) await diagnostic(context, error);
451
+ }
452
+ }
453
+ if (plans.length > 1) await verifyOperandDestinations(context, plans);
454
+ } else plans = await planOperands(context, options2);
466
455
  } catch (error) {
467
456
  context.signal.throwIfAborted();
468
- if (options2.quiet < 2) await diagnostic(context, error);
469
- exitCode = 1;
470
- if (decodedBudget.exceeded) break;
457
+ if (options2.quiet < 2) throw error;
458
+ return { exitCode: 1 };
471
459
  }
472
- }
473
- return { exitCode };
474
- }))));
460
+ const decodedBudget = new DecodedBudget(maxDecodedBytes);
461
+ let exitCode = planningFailed ? 1 : 0;
462
+ for (const plan of plans) {
463
+ try {
464
+ const warned = await runOperand(context, plan, options2, decodedBudget);
465
+ if (warned) {
466
+ if (!options2.quiet) await diagnostic(context, new PublicDiagnostic(`${plan.source}: decompression OK, trailing garbage ignored`));
467
+ if (exitCode === 0) exitCode = 2;
468
+ }
469
+ } catch (error) {
470
+ context.signal.throwIfAborted();
471
+ if (options2.quiet < 2) await diagnostic(context, error);
472
+ exitCode = 1;
473
+ if (decodedBudget.exceeded) break;
474
+ }
475
+ }
476
+ return { exitCode };
477
+ });
478
+ return { ...command2, execute: withInputByteBudget(async (context) => command2.execute(context)) };
479
+ }));
475
480
  const xzCmds = createXzCommands(config);
476
481
  if (maxDecodedBytes === void 0 || maxDecodedBytes === Infinity) {
477
482
  for (const c of [...commands, ...xzCmds]) builtInDirectContextExecutors.add(c.execute);
@@ -8109,6 +8114,17 @@ export {
8109
8114
  createRgCommand,
8110
8115
  assertCommandRequirements,
8111
8116
  evaluateFilePredicate,
8117
+ abortManagedController,
8118
+ addAbortSignalWaiter,
8119
+ combineManagedSignals,
8120
+ createManagedControlController,
8121
+ creationUmask,
8122
+ getRuntimeBackingFileSystem,
8123
+ interruptible,
8124
+ isManagedAbortSignal,
8125
+ isSyncResolved,
8126
+ registerManagedAbortSignal,
8127
+ removeAbortSignalWaiter,
8112
8128
  wcDisplayWidth,
8113
8129
  bindFileOutputBudget,
8114
8130
  openFileOutput,
@@ -1,18 +1,18 @@
1
+ import {
2
+ createTsortCommands
3
+ } from "./chunk-6PAVEFT3.js";
1
4
  import {
2
5
  createFactorCommands
3
6
  } from "./chunk-AM5ESLPH.js";
4
7
  import {
5
8
  createHexdumpCommands
6
9
  } from "./chunk-CS4MNM6I.js";
7
- import {
8
- createTimeoutCommands
9
- } from "./chunk-FBUCWVTE.js";
10
- import {
11
- createTsortCommands
12
- } from "./chunk-6PAVEFT3.js";
13
10
  import {
14
11
  RegexExecutor
15
12
  } from "./chunk-VKNVHEX3.js";
13
+ import {
14
+ createTimeoutCommands
15
+ } from "./chunk-FBUCWVTE.js";
16
16
  import {
17
17
  Chi,
18
18
  HashMD,
@@ -39,6 +39,9 @@ import {
39
39
  import {
40
40
  createApplyPatchCommands
41
41
  } from "./chunk-XAQMU6OY.js";
42
+ import {
43
+ createBoundedRegexProvider
44
+ } from "./chunk-FZE4HW6G.js";
42
45
  import {
43
46
  assertCommandRequirements,
44
47
  basicCommands,
@@ -61,7 +64,13 @@ import {
61
64
  openFileOutput,
62
65
  predicateCommands,
63
66
  wcDisplayWidth
64
- } from "./chunk-44ALJ4QG.js";
67
+ } from "./chunk-PNBBUWSM.js";
68
+ import {
69
+ createMdqCommand
70
+ } from "./chunk-OV6IHKO6.js";
71
+ import {
72
+ createPrCommands
73
+ } from "./chunk-CHYGPFVM.js";
65
74
  import {
66
75
  createGetoptCommands
67
76
  } from "./chunk-AUSNDQTJ.js";
@@ -71,9 +80,6 @@ import {
71
80
  import {
72
81
  createDos2unixCommands2 as createDos2unixCommands
73
82
  } from "./chunk-3R3AANOR.js";
74
- import {
75
- createMdqCommand
76
- } from "./chunk-OV6IHKO6.js";
77
83
  import {
78
84
  compareCopyIdentity,
79
85
  compareObservedEntries,
@@ -88,11 +94,24 @@ import {
88
94
  PublicDiagnostic
89
95
  } from "./chunk-PH63PLPZ.js";
90
96
  import {
91
- createPrCommands
92
- } from "./chunk-CHYGPFVM.js";
97
+ compareByteArrays,
98
+ decodeBytes,
99
+ encodeBytes,
100
+ indexOfBytes
101
+ } from "./chunk-D3ANYGMC.js";
93
102
  import {
94
- createBoundedRegexProvider
95
- } from "./chunk-FZE4HW6G.js";
103
+ FsError
104
+ } from "./chunk-VTH3MLDU.js";
105
+ import {
106
+ hasYieldCheckpoint,
107
+ monotonicNow,
108
+ yieldTurn
109
+ } from "./chunk-5OHX7C2V.js";
110
+ import {
111
+ collectBytes,
112
+ createBufferedOutput,
113
+ outputFailure
114
+ } from "./chunk-74GHTNJA.js";
96
115
  import {
97
116
  CommandRegistry
98
117
  } from "./chunk-7R5BDCG7.js";
@@ -110,26 +129,7 @@ import {
110
129
  } from "./chunk-GEG3BWGE.js";
111
130
  import {
112
131
  createMetadataCommands
113
- } from "./chunk-VSAJ4OTM.js";
114
- import {
115
- compareByteArrays,
116
- decodeBytes,
117
- encodeBytes,
118
- indexOfBytes
119
- } from "./chunk-D3ANYGMC.js";
120
- import {
121
- FsError
122
- } from "./chunk-VTH3MLDU.js";
123
- import {
124
- hasYieldCheckpoint,
125
- monotonicNow,
126
- yieldTurn
127
- } from "./chunk-NZQXYWA3.js";
128
- import {
129
- collectBytes,
130
- createBufferedOutput,
131
- outputFailure
132
- } from "./chunk-74GHTNJA.js";
132
+ } from "./chunk-VBTDHOWC.js";
133
133
  import {
134
134
  createArchiveCommands
135
135
  } from "./chunk-QGUV42T5.js";
@@ -4371,6 +4371,17 @@ var SortRecordBudget = class {
4371
4371
  };
4372
4372
 
4373
4373
  // packages/safe-bash/src/commands/text.ts
4374
+ function sortCollator(env) {
4375
+ const locale = env.LC_ALL || env.LC_COLLATE || env.LANG || "C";
4376
+ if (["C", "POSIX", "C.UTF-8", "C.utf8"].includes(locale)) return void 0;
4377
+ const language = locale.split(".")[0].split("_").join("-");
4378
+ try {
4379
+ if (!Intl.Collator.supportedLocalesOf([language]).length || locale.includes("@")) throw new RangeError();
4380
+ return new Intl.Collator(language, { usage: "sort", sensitivity: "variant", caseFirst: "lower" });
4381
+ } catch {
4382
+ throw new UsageError(`unsupported collation locale '${locale}'`);
4383
+ }
4384
+ }
4374
4385
  var SortWork = class {
4375
4386
  constructor(signal) {
4376
4387
  this.signal = signal;
@@ -5323,7 +5334,7 @@ async function collectSortRecords(source, delimiter, budget, signal, accept) {
5323
5334
  pending.clear();
5324
5335
  }
5325
5336
  }
5326
- async function executeSortGeneral(context, preReadChunks) {
5337
+ async function executeSortGeneral(context, preReadChunks, collator = sortCollator(context.env)) {
5327
5338
  let ended = false;
5328
5339
  let hasCheckLong = false;
5329
5340
  for (let i = 0; i < context.args.length; i++) {
@@ -5374,6 +5385,22 @@ async function executeSortGeneral(context, preReadChunks) {
5374
5385
  const simple = !keys.length && !["b", "f", "h", "n", "g", "M", "V", "d", "i"].some((flag) => parsed.flags.has(flag));
5375
5386
  const direction = parsed.flags.has("r") ? -1 : 1;
5376
5387
  const work = new SortWork(context.signal);
5388
+ const decoder2 = collator ? new TextDecoder("utf-8", { fatal: true }) : void 0;
5389
+ const compareText = collator ? async (left, right, work2) => {
5390
+ await work2.charge(left.length + right.length);
5391
+ let first, second;
5392
+ try {
5393
+ first = decoder2.decode(left);
5394
+ } catch {
5395
+ }
5396
+ try {
5397
+ second = decoder2.decode(right);
5398
+ } catch {
5399
+ }
5400
+ if (first === void 0) return second === void 0 ? compareSortBytes(left, right, work2) : 1;
5401
+ if (second === void 0) return -1;
5402
+ return collator.compare(first, second);
5403
+ } : compareSortBytes;
5377
5404
  const numericKey = keys.length === 1 ? keys[0] : void 0;
5378
5405
  const numericKeyFlags = numericKey?.flags.size ? numericKey.flags : parsed.flags;
5379
5406
  const skipTieFallback = simple || parsed.flags.has("s") || parsed.flags.has("u");
@@ -5381,7 +5408,7 @@ async function executeSortGeneral(context, preReadChunks) {
5381
5408
  const exitCode = 0;
5382
5409
  const delimiter = parsed.flags.has("z") ? 0 : 10;
5383
5410
  const outPath = value(parsed, "o");
5384
- const canFastIndexSort = !preReadChunks && !checking && !hasYieldCheckpoint(context.signal) && !parsed.flags.has("m") && !parsed.flags.has("u") && outPath === void 0 && parsed.operands.length <= 1 && SortRecordBudget.prototype.admit === defaultSortAdmit && Uint8Array === defaultUint8Array && (simple || keys.length === 1 && numericKey !== void 0 && numericKeyFlags.has("n") && !numericKeyFlags.has("h") && !["b", "f", "d", "i", "M", "V", "g"].some((flag) => numericKeyFlags.has(flag)) && !["b", "f", "d", "i", "h", "M", "V", "g"].some((flag) => parsed.flags.has(flag)) && numericKey.startCharacter === 1 && (numericKey.endCharacter === void 0 || numericKey.endCharacter === 0));
5411
+ const canFastIndexSort = collator === void 0 && !preReadChunks && !checking && !hasYieldCheckpoint(context.signal) && !parsed.flags.has("m") && !parsed.flags.has("u") && outPath === void 0 && parsed.operands.length <= 1 && SortRecordBudget.prototype.admit === defaultSortAdmit && Uint8Array === defaultUint8Array && (simple || keys.length === 1 && numericKey !== void 0 && numericKeyFlags.has("n") && !numericKeyFlags.has("h") && !["b", "f", "d", "i", "M", "V", "g"].some((flag) => numericKeyFlags.has(flag)) && !["b", "f", "d", "i", "h", "M", "V", "g"].some((flag) => parsed.flags.has(flag)) && numericKey.startCharacter === 1 && (numericKey.endCharacter === void 0 || numericKey.endCharacter === 0));
5385
5412
  if (canFastIndexSort) {
5386
5413
  let firstChunk;
5387
5414
  try {
@@ -5580,7 +5607,7 @@ async function executeSortGeneral(context, preReadChunks) {
5580
5607
  result = a.rank - b.rank || (a.value < b.value ? -1 : a.value > b.value ? 1 : 0);
5581
5608
  } else if (flags.has("M")) result = await monthValue(first, work) - await monthValue(second, work);
5582
5609
  else if (flags.has("V")) result = await compareVersions(first, second, work);
5583
- else result = flags.has("n") || flags.has("h") ? await compareNumeric(first, second, flags.has("h")) : await compareSortBytes(first, second, work);
5610
+ else result = flags.has("n") || flags.has("h") ? await compareNumeric(first, second, flags.has("h")) : await compareText(first, second, work);
5584
5611
  if (flags.has("r")) result = -result;
5585
5612
  if (result) return result;
5586
5613
  }
@@ -5588,7 +5615,7 @@ async function executeSortGeneral(context, preReadChunks) {
5588
5615
  };
5589
5616
  const keyCompareSimpleAsync = async (left, right, checkpoint) => {
5590
5617
  await checkpoint;
5591
- return await compareSortBytes(left, right, work) * direction;
5618
+ return await compareText(left, right, work) * direction;
5592
5619
  };
5593
5620
  const compareUnkeyedNumericAsync = async (left, right, rightPending) => {
5594
5621
  const leftValue = await left;
@@ -5599,7 +5626,7 @@ async function executeSortGeneral(context, preReadChunks) {
5599
5626
  const checkpoint = work.charge();
5600
5627
  if (simple) {
5601
5628
  if (checkpoint) return keyCompareSimpleAsync(left, right, checkpoint);
5602
- const cmp = compareSortBytes(left, right, work);
5629
+ const cmp = compareText(left, right, work);
5603
5630
  return typeof cmp === "number" ? cmp * direction : resolveScaledAfterPromise(cmp, direction);
5604
5631
  }
5605
5632
  if (isUnkeyedNumericFast && checkpoint === void 0) {
@@ -5637,7 +5664,7 @@ async function executeSortGeneral(context, preReadChunks) {
5637
5664
  if (checkpoint) await checkpoint;
5638
5665
  const first = await (firstPending ?? getKeyedLexSlice(left));
5639
5666
  const second = await (secondPending ?? getKeyedLexSlice(right));
5640
- return await compareSortBytes(first, second, work) * lexRev;
5667
+ return await compareText(first, second, work) * lexRev;
5641
5668
  };
5642
5669
  keyCompare = (left, right) => {
5643
5670
  const checkpoint = work.charge();
@@ -5648,7 +5675,7 @@ async function executeSortGeneral(context, preReadChunks) {
5648
5675
  if (!(first instanceof Promise)) {
5649
5676
  second = getKeyedLexSlice(right);
5650
5677
  if (!(second instanceof Promise)) {
5651
- const cmp = compareSortBytes(first, second, work);
5678
+ const cmp = compareText(first, second, work);
5652
5679
  if (typeof cmp === "number") return cmp * lexRev;
5653
5680
  return resolveScaledAfterPromise(cmp, lexRev);
5654
5681
  }
@@ -5801,7 +5828,7 @@ async function executeSortGeneral(context, preReadChunks) {
5801
5828
  if (ls === void 0) return keyCompareGeneralAsync(left, right, void 0);
5802
5829
  const rs = ev.evalLexSync(right);
5803
5830
  if (rs === void 0) return keyCompareGeneralAsync(left, right, void 0);
5804
- const cmp = compareSortBytes(ls, rs, work);
5831
+ const cmp = compareText(ls, rs, work);
5805
5832
  if (typeof cmp !== "number") return keyCompareGeneralAsync(left, right, void 0);
5806
5833
  if (cmp !== 0) return cmp * ev.revScale;
5807
5834
  }
@@ -5812,13 +5839,13 @@ async function executeSortGeneral(context, preReadChunks) {
5812
5839
  const compareSlowAsync = async (resultPromise, left, right) => {
5813
5840
  const resolved = await resultPromise;
5814
5841
  if (resolved !== 0 || skipTieFallback) return resolved;
5815
- return await compareSortBytes(left, right, work) * direction;
5842
+ return await compareText(left, right, work) * direction;
5816
5843
  };
5817
5844
  const compare = (left, right) => {
5818
5845
  const result = keyCompare(left, right);
5819
5846
  if (typeof result === "number") {
5820
5847
  if (result !== 0 || skipTieFallback) return result;
5821
- const fallback = compareSortBytes(left, right, work);
5848
+ const fallback = compareText(left, right, work);
5822
5849
  return typeof fallback === "number" ? fallback * direction : resolveScaledAfterPromise(fallback, direction);
5823
5850
  }
5824
5851
  return compareSlowAsync(result, left, right);
@@ -6391,6 +6418,8 @@ async function executeUniqGeneral(context, preReadSource) {
6391
6418
  function textCommands() {
6392
6419
  return [
6393
6420
  define("sort", (context) => {
6421
+ const collator = sortCollator(context.env);
6422
+ if (collator) return executeSortGeneral(context, void 0, collator);
6394
6423
  if ((context.args.length === 0 || context.args.length === 1 && context.args[0] === "-r") && !hasYieldCheckpoint(context.signal) && SortRecordBudget.prototype.admit === defaultSortAdmit && Uint8Array === defaultUint8Array) {
6395
6424
  const direction = context.args.length === 1 ? -1 : 1;
6396
6425
  const req = assertInputRequirements(context, EMPTY_OPERANDS);
@@ -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
+ };
@@ -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 {