poe-code 15.0.14 → 15.0.16

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 (124) hide show
  1. package/dist/metafile.json +1 -1
  2. package/package.json +13 -1
  3. package/packages/safe-bash/dist/chunks/{chunk-GZKLXMBM.js → chunk-5VBLSPNM.js} +6 -1
  4. package/packages/safe-bash/dist/chunks/{chunk-GZKLXMBM.js.map → chunk-5VBLSPNM.js.map} +2 -2
  5. package/packages/safe-bash/dist/chunks/{chunk-DJHZJAB7.js → chunk-66VSWIUC.js} +3 -3
  6. package/packages/safe-bash/dist/chunks/{chunk-PPPN3OME.js → chunk-6PSMEBVP.js} +2 -2
  7. package/packages/safe-bash/dist/chunks/chunk-A4UXQKWZ.js +2609 -0
  8. package/packages/safe-bash/dist/chunks/chunk-A4UXQKWZ.js.map +7 -0
  9. package/packages/safe-bash/dist/chunks/{chunk-32GGX4AS.js → chunk-AZNI263O.js} +3 -3
  10. package/packages/safe-bash/dist/chunks/{chunk-LRVRQIG5.js → chunk-EZLQA6ON.js} +3 -3
  11. package/packages/safe-bash/dist/chunks/{chunk-ZQEL7DYC.js → chunk-HFEU5SBQ.js} +4 -4
  12. package/packages/safe-bash/dist/chunks/{chunk-EYJTLUBJ.js → chunk-PZMJ4EC3.js} +2 -2
  13. package/packages/safe-bash/dist/chunks/chunk-R3QJL5HH.js +698 -0
  14. package/packages/safe-bash/dist/chunks/chunk-R3QJL5HH.js.map +7 -0
  15. package/packages/safe-bash/dist/chunks/{chunk-J4CKSMJV.js → chunk-T5BV7HPD.js} +2 -2
  16. package/packages/safe-bash/dist/chunks/{chunk-IIWXPQB3.js → chunk-TPD45VUZ.js} +5 -5
  17. package/packages/safe-bash/dist/chunks/{chunk-UGMO7OO5.js → chunk-VNDFKT6F.js} +3 -3
  18. package/packages/safe-bash/dist/chunks/{chunk-LZUOZVGJ.js → chunk-WF4P7XKI.js} +3 -3
  19. package/packages/safe-bash/dist/chunks/{chunk-Z75O7XWR.js → chunk-WODV2DVM.js} +3 -3
  20. package/packages/safe-bash/dist/chunks/{chunk-QKQNBJOU.js → chunk-YEJBZLE5.js} +5 -5
  21. package/packages/safe-bash/dist/commands/bytes/compression/file-operation.d.ts +16 -0
  22. package/packages/safe-bash/dist/commands/bytes/compression/file-operation.d.ts.map +1 -0
  23. package/packages/safe-bash/dist/commands/bytes/compression/file-operation.js +134 -0
  24. package/packages/safe-bash/dist/commands/bytes/compression/file-operation.js.map +1 -0
  25. package/packages/safe-bash/dist/commands/bytes/compression/files.d.ts.map +1 -1
  26. package/packages/safe-bash/dist/commands/bytes/compression/files.js +126 -67
  27. package/packages/safe-bash/dist/commands/bytes/compression/files.js.map +1 -1
  28. package/packages/safe-bash/dist/commands/bytes/compression/stream.d.ts.map +1 -1
  29. package/packages/safe-bash/dist/commands/bytes/compression/stream.js +2 -1
  30. package/packages/safe-bash/dist/commands/bytes/compression/stream.js.map +1 -1
  31. package/packages/safe-bash/dist/commands/csplit/index.browser.js +4 -4
  32. package/packages/safe-bash/dist/commands/factor/index.browser.js +3 -3
  33. package/packages/safe-bash/dist/commands/getopt/index.browser.js +3 -3
  34. package/packages/safe-bash/dist/commands/hexdump/command.d.ts +5 -0
  35. package/packages/safe-bash/dist/commands/hexdump/command.d.ts.map +1 -0
  36. package/packages/safe-bash/dist/commands/hexdump/command.js +174 -0
  37. package/packages/safe-bash/dist/commands/hexdump/command.js.map +1 -0
  38. package/packages/safe-bash/dist/commands/hexdump/format.d.ts +2 -0
  39. package/packages/safe-bash/dist/commands/hexdump/format.d.ts.map +1 -0
  40. package/packages/safe-bash/dist/commands/hexdump/format.js +25 -0
  41. package/packages/safe-bash/dist/commands/hexdump/format.js.map +1 -0
  42. package/packages/safe-bash/dist/commands/hexdump/index.browser.js +17 -0
  43. package/packages/safe-bash/dist/commands/hexdump/index.browser.js.map +7 -0
  44. package/packages/safe-bash/dist/commands/hexdump/index.d.ts +7 -0
  45. package/packages/safe-bash/dist/commands/hexdump/index.d.ts.map +1 -0
  46. package/packages/safe-bash/dist/commands/hexdump/index.js +17 -0
  47. package/packages/safe-bash/dist/commands/hexdump/index.js.map +1 -0
  48. package/packages/safe-bash/dist/commands/hexdump/internal.d.ts +52 -0
  49. package/packages/safe-bash/dist/commands/hexdump/internal.d.ts.map +1 -0
  50. package/packages/safe-bash/dist/commands/hexdump/internal.js +150 -0
  51. package/packages/safe-bash/dist/commands/hexdump/internal.js.map +1 -0
  52. package/packages/safe-bash/dist/commands/hexdump/io.d.ts +41 -0
  53. package/packages/safe-bash/dist/commands/hexdump/io.d.ts.map +1 -0
  54. package/packages/safe-bash/dist/commands/hexdump/io.js +288 -0
  55. package/packages/safe-bash/dist/commands/hexdump/io.js.map +1 -0
  56. package/packages/safe-bash/dist/commands/hexdump/options.d.ts +10 -0
  57. package/packages/safe-bash/dist/commands/hexdump/options.d.ts.map +1 -0
  58. package/packages/safe-bash/dist/commands/hexdump/options.js +80 -0
  59. package/packages/safe-bash/dist/commands/hexdump/options.js.map +1 -0
  60. package/packages/safe-bash/dist/commands/iconv/codec.d.ts +10 -0
  61. package/packages/safe-bash/dist/commands/iconv/codec.d.ts.map +1 -0
  62. package/packages/safe-bash/dist/commands/iconv/codec.js +200 -0
  63. package/packages/safe-bash/dist/commands/iconv/codec.js.map +1 -0
  64. package/packages/safe-bash/dist/commands/iconv/command.d.ts +4 -0
  65. package/packages/safe-bash/dist/commands/iconv/command.d.ts.map +1 -0
  66. package/packages/safe-bash/dist/commands/iconv/command.js +116 -0
  67. package/packages/safe-bash/dist/commands/iconv/command.js.map +1 -0
  68. package/packages/safe-bash/dist/commands/iconv/index.browser.js +15 -0
  69. package/packages/safe-bash/dist/commands/iconv/index.browser.js.map +7 -0
  70. package/packages/safe-bash/dist/commands/iconv/index.d.ts +7 -0
  71. package/packages/safe-bash/dist/commands/iconv/index.d.ts.map +1 -0
  72. package/packages/safe-bash/dist/commands/iconv/index.js +11 -0
  73. package/packages/safe-bash/dist/commands/iconv/index.js.map +1 -0
  74. package/packages/safe-bash/dist/commands/iconv/internal.d.ts +54 -0
  75. package/packages/safe-bash/dist/commands/iconv/internal.d.ts.map +1 -0
  76. package/packages/safe-bash/dist/commands/iconv/internal.js +154 -0
  77. package/packages/safe-bash/dist/commands/iconv/internal.js.map +1 -0
  78. package/packages/safe-bash/dist/commands/iconv/lifecycle.d.ts +24 -0
  79. package/packages/safe-bash/dist/commands/iconv/lifecycle.d.ts.map +1 -0
  80. package/packages/safe-bash/dist/commands/iconv/lifecycle.js +111 -0
  81. package/packages/safe-bash/dist/commands/iconv/lifecycle.js.map +1 -0
  82. package/packages/safe-bash/dist/commands/iconv/options.d.ts +11 -0
  83. package/packages/safe-bash/dist/commands/iconv/options.d.ts.map +1 -0
  84. package/packages/safe-bash/dist/commands/iconv/options.js +82 -0
  85. package/packages/safe-bash/dist/commands/iconv/options.js.map +1 -0
  86. package/packages/safe-bash/dist/commands/iconv/reader.d.ts +21 -0
  87. package/packages/safe-bash/dist/commands/iconv/reader.d.ts.map +1 -0
  88. package/packages/safe-bash/dist/commands/iconv/reader.js +192 -0
  89. package/packages/safe-bash/dist/commands/iconv/reader.js.map +1 -0
  90. package/packages/safe-bash/dist/commands/iconv/transliterations.d.ts +2 -0
  91. package/packages/safe-bash/dist/commands/iconv/transliterations.d.ts.map +1 -0
  92. package/packages/safe-bash/dist/commands/iconv/transliterations.js +1785 -0
  93. package/packages/safe-bash/dist/commands/iconv/transliterations.js.map +1 -0
  94. package/packages/safe-bash/dist/commands/network/index.browser.js +5 -5
  95. package/packages/safe-bash/dist/commands/pr/index.browser.js +3 -3
  96. package/packages/safe-bash/dist/commands/tsort/index.browser.js +3 -3
  97. package/packages/safe-bash/dist/commands/xml/index.browser.js +4 -4
  98. package/packages/safe-bash/dist/commands/yq/index.browser.js +5 -5
  99. package/packages/safe-bash/dist/contracts/yield.d.ts +1 -0
  100. package/packages/safe-bash/dist/contracts/yield.d.ts.map +1 -1
  101. package/packages/safe-bash/dist/contracts/yield.js +5 -0
  102. package/packages/safe-bash/dist/contracts/yield.js.map +1 -1
  103. package/packages/safe-bash/dist/core.browser.js +297 -79
  104. package/packages/safe-bash/dist/core.browser.js.map +4 -4
  105. package/packages/safe-bash/dist/core.d.ts +2 -0
  106. package/packages/safe-bash/dist/core.d.ts.map +1 -1
  107. package/packages/safe-bash/dist/core.js +2 -0
  108. package/packages/safe-bash/dist/core.js.map +1 -1
  109. package/packages/safe-bash/dist/plugins/composition.d.ts +4 -0
  110. package/packages/safe-bash/dist/plugins/composition.d.ts.map +1 -1
  111. package/packages/safe-bash/dist/plugins/composition.js +5 -1
  112. package/packages/safe-bash/dist/plugins/composition.js.map +1 -1
  113. /package/packages/safe-bash/dist/chunks/{chunk-DJHZJAB7.js.map → chunk-66VSWIUC.js.map} +0 -0
  114. /package/packages/safe-bash/dist/chunks/{chunk-PPPN3OME.js.map → chunk-6PSMEBVP.js.map} +0 -0
  115. /package/packages/safe-bash/dist/chunks/{chunk-32GGX4AS.js.map → chunk-AZNI263O.js.map} +0 -0
  116. /package/packages/safe-bash/dist/chunks/{chunk-LRVRQIG5.js.map → chunk-EZLQA6ON.js.map} +0 -0
  117. /package/packages/safe-bash/dist/chunks/{chunk-ZQEL7DYC.js.map → chunk-HFEU5SBQ.js.map} +0 -0
  118. /package/packages/safe-bash/dist/chunks/{chunk-EYJTLUBJ.js.map → chunk-PZMJ4EC3.js.map} +0 -0
  119. /package/packages/safe-bash/dist/chunks/{chunk-J4CKSMJV.js.map → chunk-T5BV7HPD.js.map} +0 -0
  120. /package/packages/safe-bash/dist/chunks/{chunk-IIWXPQB3.js.map → chunk-TPD45VUZ.js.map} +0 -0
  121. /package/packages/safe-bash/dist/chunks/{chunk-UGMO7OO5.js.map → chunk-VNDFKT6F.js.map} +0 -0
  122. /package/packages/safe-bash/dist/chunks/{chunk-LZUOZVGJ.js.map → chunk-WF4P7XKI.js.map} +0 -0
  123. /package/packages/safe-bash/dist/chunks/{chunk-Z75O7XWR.js.map → chunk-WODV2DVM.js.map} +0 -0
  124. /package/packages/safe-bash/dist/chunks/{chunk-QKQNBJOU.js.map → chunk-YEJBZLE5.js.map} +0 -0
@@ -2,12 +2,23 @@ import {
2
2
  createGetoptCommand,
3
3
  createGetoptCommands,
4
4
  getoptCommands
5
- } from "./chunks/chunk-LRVRQIG5.js";
5
+ } from "./chunks/chunk-EZLQA6ON.js";
6
+ import {
7
+ createHdCommand,
8
+ createHexdumpCommand,
9
+ createHexdumpCommands,
10
+ hexdumpCommands
11
+ } from "./chunks/chunk-R3QJL5HH.js";
12
+ import {
13
+ createIconvCommand,
14
+ createIconvCommands,
15
+ iconvCommands
16
+ } from "./chunks/chunk-A4UXQKWZ.js";
6
17
  import {
7
18
  createXmlCommands,
8
19
  defaultXmlQueryLimits,
9
20
  xmlCommands
10
- } from "./chunks/chunk-ZQEL7DYC.js";
21
+ } from "./chunks/chunk-HFEU5SBQ.js";
11
22
  import {
12
23
  Interpreter,
13
24
  createYqCommand,
@@ -18,7 +29,7 @@ import {
18
29
  rawValues,
19
30
  stringify,
20
31
  yqCommands
21
- } from "./chunks/chunk-QKQNBJOU.js";
32
+ } from "./chunks/chunk-YEJBZLE5.js";
22
33
  import {
23
34
  Budget,
24
35
  JqError,
@@ -31,7 +42,7 @@ import {
31
42
  resolveJqLimits,
32
43
  truth,
33
44
  wellFormed
34
- } from "./chunks/chunk-PPPN3OME.js";
45
+ } from "./chunks/chunk-6PSMEBVP.js";
35
46
  import {
36
47
  CurlError,
37
48
  cloudflareWorkerNetworkLimits,
@@ -44,7 +55,7 @@ import {
44
55
  curlCommands,
45
56
  defaultNetworkLimits,
46
57
  networkCommands
47
- } from "./chunks/chunk-IIWXPQB3.js";
58
+ } from "./chunks/chunk-TPD45VUZ.js";
48
59
  import {
49
60
  RecordBuffer,
50
61
  UsageError,
@@ -76,7 +87,7 @@ import {
76
87
  textOutputRequirements,
77
88
  value,
78
89
  writeDiagnostic
79
- } from "./chunks/chunk-J4CKSMJV.js";
90
+ } from "./chunks/chunk-T5BV7HPD.js";
80
91
  import {
81
92
  AvailableRecords,
82
93
  EreLedger,
@@ -96,22 +107,22 @@ import {
96
107
  exprMatchCeilings,
97
108
  matchEre,
98
109
  withRegexSession
99
- } from "./chunks/chunk-Z75O7XWR.js";
110
+ } from "./chunks/chunk-WODV2DVM.js";
100
111
  import {
101
112
  bindFileOutputBudget,
102
113
  openFileOutput,
103
114
  writeFileOutput
104
- } from "./chunks/chunk-32GGX4AS.js";
115
+ } from "./chunks/chunk-AZNI263O.js";
105
116
  import {
106
117
  createPrCommand,
107
118
  createPrCommands,
108
119
  prCommands
109
- } from "./chunks/chunk-UGMO7OO5.js";
120
+ } from "./chunks/chunk-VNDFKT6F.js";
110
121
  import {
111
122
  createTsortCommand,
112
123
  createTsortCommands,
113
124
  tsortCommands
114
- } from "./chunks/chunk-LZUOZVGJ.js";
125
+ } from "./chunks/chunk-WF4P7XKI.js";
115
126
  import {
116
127
  basename,
117
128
  dirname,
@@ -126,10 +137,10 @@ import {
126
137
  createFactorCommand,
127
138
  createFactorCommands,
128
139
  factorCommands
129
- } from "./chunks/chunk-DJHZJAB7.js";
140
+ } from "./chunks/chunk-66VSWIUC.js";
130
141
  import {
131
142
  createOutputOperation
132
- } from "./chunks/chunk-EYJTLUBJ.js";
143
+ } from "./chunks/chunk-PZMJ4EC3.js";
133
144
  import {
134
145
  CommandArgumentIdentityError,
135
146
  CommandRegistry,
@@ -142,6 +153,7 @@ import {
142
153
  createBytePipe,
143
154
  createCommandArguments,
144
155
  getCommandArguments,
156
+ inheritYieldCheckpoint,
145
157
  isErrnoCode,
146
158
  isFsError,
147
159
  monotonicNow,
@@ -162,7 +174,7 @@ import {
162
174
  writeBytes,
163
175
  writeText,
164
176
  yieldTurn
165
- } from "./chunks/chunk-GZKLXMBM.js";
177
+ } from "./chunks/chunk-5VBLSPNM.js";
166
178
  import {
167
179
  import_buffer,
168
180
  init_platform
@@ -17254,6 +17266,7 @@ init_platform();
17254
17266
 
17255
17267
  // packages/safe-bash/src/commands/bytes/compression/files.ts
17256
17268
  init_platform();
17269
+ import { retainFileSystemCleanup } from "poe-code/safe-fs/core";
17257
17270
 
17258
17271
  // packages/safe-bash/src/commands/bytes/compression/options.ts
17259
17272
  init_platform();
@@ -20871,6 +20884,7 @@ async function* split2(source2, signal, fail4) {
20871
20884
  async function transform(source2, consume, options2, parentSignal, maxOutput = Infinity) {
20872
20885
  const controller = new AbortController();
20873
20886
  const signal = AbortSignal.any([parentSignal, controller.signal]);
20887
+ inheritYieldCheckpoint(parentSignal, signal);
20874
20888
  let failure;
20875
20889
  let hasFailure = false;
20876
20890
  const fail4 = (error) => {
@@ -20926,15 +20940,153 @@ async function transform(source2, consume, options2, parentSignal, maxOutput = I
20926
20940
  return warned2;
20927
20941
  }
20928
20942
 
20943
+ // packages/safe-bash/src/commands/bytes/compression/file-operation.ts
20944
+ init_platform();
20945
+ var FileOperation = class {
20946
+ signal;
20947
+ fs;
20948
+ controller = new AbortController();
20949
+ pending = /* @__PURE__ */ new Set();
20950
+ sources = [];
20951
+ closing;
20952
+ caller;
20953
+ constructor(context2, cleanup) {
20954
+ this.caller = context2.signal;
20955
+ this.signal = this.controller.signal;
20956
+ this.caller.throwIfAborted();
20957
+ inheritYieldCheckpoint(this.caller, this.signal);
20958
+ const filesystem = context2.fs;
20959
+ this.caller.throwIfAborted();
20960
+ this.fs = new Proxy(filesystem, {
20961
+ get: (target, key) => {
20962
+ this.check();
20963
+ const value2 = Reflect.get(target, key, target);
20964
+ this.check();
20965
+ return typeof value2 === "function" ? (...args) => {
20966
+ this.check();
20967
+ const result2 = Reflect.apply(value2, target, args);
20968
+ return key === "readStream" ? this.ownSource(result2) : result2;
20969
+ } : value2;
20970
+ }
20971
+ });
20972
+ let outcomeClaimed = false;
20973
+ let registeredClosing;
20974
+ const abort = () => {
20975
+ void retire().catch(() => {
20976
+ });
20977
+ };
20978
+ const retire = () => {
20979
+ if (!this.closing) {
20980
+ this.closing = Promise.resolve().then(async () => {
20981
+ try {
20982
+ const sources2 = Promise.allSettled(this.sources.map((close) => close()));
20983
+ await Promise.allSettled([...this.pending]);
20984
+ const outcomes = await sources2;
20985
+ await cleanup?.();
20986
+ const failures = outcomes.filter((outcome) => outcome.status === "rejected").map((outcome) => outcome.reason);
20987
+ if (failures.length === 1) throw failures[0];
20988
+ if (failures.length) throw new AggregateError(failures, "Compression source cleanup failed");
20989
+ } finally {
20990
+ this.caller.removeEventListener("abort", abort);
20991
+ }
20992
+ });
20993
+ void this.closing.catch(() => {
20994
+ });
20995
+ this.controller.abort(this.caller.aborted ? this.caller.reason : new Error("Compression file operation is closed"));
20996
+ }
20997
+ return this.closing;
20998
+ };
20999
+ this.close = () => {
21000
+ outcomeClaimed = true;
21001
+ return retire();
21002
+ };
21003
+ const register = context2.registerCleanup;
21004
+ this.check();
21005
+ if (register) Reflect.apply(register, context2, [() => {
21006
+ registeredClosing ??= retire().catch((error) => {
21007
+ if (!outcomeClaimed) throw error;
21008
+ });
21009
+ void registeredClosing.catch(() => {
21010
+ });
21011
+ return registeredClosing;
21012
+ }]);
21013
+ this.check();
21014
+ this.caller.addEventListener("abort", abort, { once: true });
21015
+ if (this.caller.aborted) abort();
21016
+ }
21017
+ close;
21018
+ check() {
21019
+ this.caller.throwIfAborted();
21020
+ this.signal.throwIfAborted();
21021
+ }
21022
+ async run(start) {
21023
+ this.check();
21024
+ const pending = Promise.resolve().then(() => {
21025
+ this.check();
21026
+ return start();
21027
+ });
21028
+ this.pending.add(pending);
21029
+ try {
21030
+ return await pending;
21031
+ } finally {
21032
+ this.pending.delete(pending);
21033
+ }
21034
+ }
21035
+ ownSource(source2) {
21036
+ let iterator = void 0;
21037
+ let closing;
21038
+ const close = () => {
21039
+ closing ??= Promise.resolve().then(async () => {
21040
+ const method = iterator?.return;
21041
+ return method ? await Reflect.apply(method, iterator, []) : { done: true, value: void 0 };
21042
+ });
21043
+ void closing.catch(() => {
21044
+ });
21045
+ return closing;
21046
+ };
21047
+ this.sources.push(close);
21048
+ const factory = source2[Symbol.asyncIterator];
21049
+ iterator = Reflect.apply(factory, source2, []);
21050
+ this.check();
21051
+ let claimed = false;
21052
+ return {
21053
+ [Symbol.asyncIterator]: () => {
21054
+ this.check();
21055
+ if (claimed) throw new Error("Compression input was already acquired");
21056
+ claimed = true;
21057
+ return {
21058
+ next: async () => {
21059
+ this.check();
21060
+ if (closing) throw new Error("Compression input is closed");
21061
+ const method = iterator.next;
21062
+ this.check();
21063
+ const result2 = await Reflect.apply(method, iterator, []);
21064
+ this.check();
21065
+ const done = result2.done;
21066
+ this.check();
21067
+ const value2 = result2.value;
21068
+ this.check();
21069
+ return done ? { done: true, value: value2 } : { done: false, value: value2 };
21070
+ },
21071
+ return: close
21072
+ };
21073
+ }
21074
+ };
21075
+ }
21076
+ };
21077
+
20929
21078
  // packages/safe-bash/src/commands/bytes/compression/files.ts
21079
+ function identified(stat) {
21080
+ return stat.identityScope !== void 0 && Number.isSafeInteger(stat.ino) && Number.isSafeInteger(stat.dev);
21081
+ }
20930
21082
  function sameIdentity(first, second) {
20931
- return first.ino !== void 0 && second.ino !== void 0 && first.ino === second.ino && first.dev === second.dev;
21083
+ return identified(first) && identified(second) && first.identityScope === second.identityScope && first.ino === second.ino && first.dev === second.dev;
20932
21084
  }
20933
21085
  function sameSnapshot(first, second) {
20934
- return first.type === second.type && first.size === second.size && first.mode === second.mode && first.mtimeMs === second.mtimeMs && first.ctimeMs === second.ctimeMs && first.ino === second.ino && first.dev === second.dev && first.nlink === second.nlink && first.birthtimeMs === second.birthtimeMs && first.uid === second.uid && first.gid === second.gid;
21086
+ return first.type === second.type && first.size === second.size && first.mode === second.mode && first.mtimeMs === second.mtimeMs && first.ctimeMs === second.ctimeMs && first.ino === second.ino && first.dev === second.dev && first.nlink === second.nlink && first.birthtimeMs === second.birthtimeMs && first.uid === second.uid && first.gid === second.gid && first.identityScope === second.identityScope;
20935
21087
  }
20936
21088
  function sameEntry(first, second) {
20937
- return first.type === second.type && first.ino === second.ino && first.dev === second.dev && first.birthtimeMs === second.birthtimeMs;
21089
+ return sameIdentity(first, second) && first.type === second.type && first.birthtimeMs === second.birthtimeMs;
20938
21090
  }
20939
21091
  async function existing(context2, path) {
20940
21092
  try {
@@ -20970,6 +21122,15 @@ function outputPath(source2, options2) {
20970
21122
  return source2 + ".gz";
20971
21123
  }
20972
21124
  async function planOperands(context2, options2) {
21125
+ const operation2 = new FileOperation(context2);
21126
+ try {
21127
+ return await operation2.run(() => collectOperands({ ...context2, fs: operation2.fs, signal: operation2.signal }, options2));
21128
+ } finally {
21129
+ await operation2.close();
21130
+ context2.signal.throwIfAborted();
21131
+ }
21132
+ }
21133
+ async function collectOperands(context2, options2) {
20973
21134
  const plans = [];
20974
21135
  for (const name2 of options2.operands) {
20975
21136
  context2.signal.throwIfAborted();
@@ -21003,6 +21164,13 @@ async function planOperands(context2, options2) {
21003
21164
  throw new FsError("ENOTSUP", { message: "file output requires VFS streaming writes (use -c for stdout)" });
21004
21165
  }
21005
21166
  const destinationStat = await existing(context2, destination2);
21167
+ if (!identified(sourceStat) || destinationStat && !identified(destinationStat)) {
21168
+ throw new FsError("ENOTSUP", { path: source2, message: "file output requires stable scoped entry identities" });
21169
+ }
21170
+ if (!context2.fs.rmdir || capabilities.exclusiveCreate !== true || (destinationStat ? capabilities.atomicRename : capabilities.atomicRenameNoReplace) !== true) {
21171
+ throw new FsError("ENOTSUP", { path: destination2, message: "file output requires exclusive staging, safe rmdir and atomic publication (use -c for stdout)" });
21172
+ }
21173
+ context2.signal.throwIfAborted();
21006
21174
  if (destinationStat) {
21007
21175
  if (destinationStat.type !== "file" || sameIdentity(sourceStat, destinationStat) || realSource === await context2.fs.realpath(destination2, { signal: context2.signal })) {
21008
21176
  throw new FsError("EINVAL", { path: destination2, message: "destination is not a distinct regular file" });
@@ -21033,23 +21201,10 @@ async function unchangedSource(context2, plan) {
21033
21201
  throw new FsError("EBUSY", { path: plan.source, message: "input identity or metadata changed; input retained" });
21034
21202
  }
21035
21203
  }
21036
- async function temporaryDirectory(context2, destination2) {
21037
- for (let attempt = 0; attempt < 16; attempt++) {
21038
- const path = joinPath(dirname(destination2), `.virtual-bash-gzip-${globalThis.crypto.randomUUID()}`);
21039
- try {
21040
- await context2.fs.mkdir(path, { mode: 448, signal: context2.signal });
21041
- return path;
21042
- } catch (error) {
21043
- if (codeOf(error) !== "EEXIST") throw error;
21044
- }
21045
- }
21046
- throw new FsError("EEXIST", { message: "unable to allocate a private gzip staging directory" });
21047
- }
21048
21204
  async function writeFileOperand(context2, plan, options2) {
21049
21205
  const destination2 = plan.destination;
21050
- await unchangedSource(context2, plan);
21051
- const directory2 = await temporaryDirectory(context2, destination2);
21052
- const staged = joinPath(directory2, "data");
21206
+ let directory2;
21207
+ let staged;
21053
21208
  let directoryStat;
21054
21209
  let stageStat;
21055
21210
  let stageOwned = false;
@@ -21057,69 +21212,121 @@ async function writeFileOperand(context2, plan, options2) {
21057
21212
  let failure;
21058
21213
  let failed = false;
21059
21214
  let warned2 = false;
21215
+ let cleanupFailed = false;
21216
+ let retainedCleanup;
21217
+ const operation2 = new FileOperation(context2, async () => {
21218
+ await retainedCleanup?.();
21219
+ });
21220
+ const active = { ...context2, fs: operation2.fs, signal: operation2.signal };
21221
+ const { fs, signal } = active;
21222
+ const snapshot = (stat) => {
21223
+ const result2 = {};
21224
+ for (const key of ["type", "size", "mode", "mtimeMs", "atimeMs", "ctimeMs", "birthtimeMs", "identityScope", "ino", "dev", "nlink", "uid", "gid"]) {
21225
+ result2[key] = stat[key];
21226
+ operation2.check();
21227
+ }
21228
+ return Object.freeze(result2);
21229
+ };
21060
21230
  try {
21061
- directoryStat = await context2.fs.lstat(directory2, { signal: context2.signal });
21062
- if (directoryStat.type !== "directory") throw new FsError("EBUSY", { path: directory2 });
21063
- await context2.fs.writeFile(staged, new Uint8Array(), { flag: "wx", mode: 384, signal: context2.signal });
21064
- stageOwned = true;
21065
- stageStat = await context2.fs.lstat(staged, { signal: context2.signal });
21066
- if (stageStat.type !== "file" || stageStat.size !== 0) throw new FsError("EBUSY", { path: staged });
21067
- warned2 = await transform((signal) => context2.fs.readStream(plan.source, { signal, chunkSize: chunkBytes }), async (output2, signal) => {
21068
- await context2.fs.writeStream(staged, output2, { flag: "w", mode: 384, signal });
21069
- }, { ...options2, force: false }, context2.signal, stagingLimit);
21070
- await unchangedSource(context2, plan);
21071
- const target = await existing(context2, destination2);
21231
+ retainedCleanup = retainFileSystemCleanup(context2.fs, async (cleanup) => {
21232
+ if (directory2 === void 0) return;
21233
+ const cleanupSignal = AbortSignal.timeout(5e3);
21234
+ const currentDirectory = await cleanup.lstat(directory2, { signal: cleanupSignal });
21235
+ if (!directoryStat || !sameEntry(directoryStat, currentDirectory)) {
21236
+ throw new FsError("EBUSY", { path: directory2, message: "staging directory identity is unknown or changed; refusing cleanup" });
21237
+ }
21238
+ if (stageOwned && !moved && staged !== void 0) {
21239
+ let currentStage;
21240
+ try {
21241
+ currentStage = await cleanup.lstat(staged, { signal: cleanupSignal });
21242
+ } catch (error) {
21243
+ if (codeOf(error) !== "ENOENT") throw error;
21244
+ }
21245
+ if (currentStage) {
21246
+ if (!stageStat || !sameEntry(stageStat, currentStage)) throw new FsError("EBUSY", { path: staged, message: "staging file identity changed; refusing cleanup" });
21247
+ await cleanup.rm(staged, { signal: cleanupSignal });
21248
+ }
21249
+ }
21250
+ if (!cleanup.rmdir) throw new FsError("ENOTSUP", { path: directory2, message: "safe directory removal unavailable" });
21251
+ try {
21252
+ await cleanup.rmdir(directory2, { signal: cleanupSignal });
21253
+ } catch (error) {
21254
+ if (codeOf(error) === "ENOTEMPTY") throw new FsError("ENOTEMPTY", { path: directory2, message: "unexpected staging entries; refusing cleanup" });
21255
+ throw error;
21256
+ }
21257
+ }, { maxOperations: 8 });
21258
+ operation2.check();
21259
+ await operation2.run(() => unchangedSource(active, plan));
21260
+ for (let attempt = 0; directory2 === void 0 && attempt < 16; attempt++) {
21261
+ const path = joinPath(dirname(destination2), `.virtual-bash-gzip-${globalThis.crypto.randomUUID()}`);
21262
+ const capabilities = await operation2.run(async () => await fs.capabilitiesFor?.(path, { signal, create: true, allowDirectory: true }) ?? fs.capabilities);
21263
+ operation2.check();
21264
+ const snapshotRmdir = capabilities.snapshotRmdir;
21265
+ operation2.check();
21266
+ if (snapshotRmdir === true) throw new FsError("ENOTSUP", { path, message: "strong staging directory cleanup unavailable; snapshot-only rmdir is unsupported" });
21267
+ try {
21268
+ await operation2.run(async () => {
21269
+ await fs.mkdir(path, { mode: 448, signal });
21270
+ directory2 = path;
21271
+ });
21272
+ } catch (error) {
21273
+ operation2.check();
21274
+ if (codeOf(error) !== "EEXIST") throw error;
21275
+ }
21276
+ }
21277
+ if (directory2 === void 0) throw new FsError("EEXIST", { message: "unable to allocate a private gzip staging directory" });
21278
+ staged = joinPath(directory2, "data");
21279
+ directoryStat = snapshot(await operation2.run(() => fs.lstat(directory2, { signal })));
21280
+ if (directoryStat.type !== "directory" || !identified(directoryStat)) throw new FsError("EBUSY", { path: directory2 });
21281
+ await operation2.run(async () => {
21282
+ await fs.writeFile(staged, new Uint8Array(), { flag: "wx", mode: 384, signal });
21283
+ stageOwned = true;
21284
+ });
21285
+ stageStat = snapshot(await operation2.run(() => fs.lstat(staged, { signal })));
21286
+ if (stageStat.type !== "file" || stageStat.size !== 0 || !identified(stageStat)) throw new FsError("EBUSY", { path: staged });
21287
+ warned2 = await operation2.run(() => transform((signal2) => fs.readStream(plan.source, { signal: signal2, chunkSize: chunkBytes }), async (output2, signal2) => {
21288
+ await fs.writeStream(staged, output2, { flag: "w", mode: 384, signal: signal2 });
21289
+ }, { ...options2, force: false }, signal, stagingLimit));
21290
+ await operation2.run(() => unchangedSource(active, plan));
21291
+ const target = await operation2.run(() => existing(active, destination2));
21072
21292
  if (plan.destinationStat ? !target || !sameSnapshot(plan.destinationStat, target) : target !== void 0) {
21073
21293
  throw new FsError("EBUSY", { path: destination2, message: "destination changed during compression" });
21074
21294
  }
21075
- if (!sameEntry(stageStat, await context2.fs.lstat(staged, { signal: context2.signal }))) {
21295
+ if (!sameEntry(stageStat, snapshot(await operation2.run(() => fs.lstat(staged, { signal }))))) {
21076
21296
  throw new FsError("EBUSY", { path: staged, message: "staging identity changed" });
21077
21297
  }
21078
- if (plan.destinationStat) {
21079
- await context2.fs.rename(staged, destination2, { signal: context2.signal });
21298
+ await operation2.run(async () => {
21299
+ await fs.rename(staged, destination2, { signal, noReplace: !plan.destinationStat });
21080
21300
  moved = true;
21081
- } else await context2.fs.copyFile(staged, destination2, { exclusive: true, signal: context2.signal });
21082
- context2.signal.throwIfAborted();
21301
+ });
21302
+ operation2.check();
21303
+ try {
21304
+ await retainedCleanup();
21305
+ } catch (error) {
21306
+ cleanupFailed = true;
21307
+ throw error;
21308
+ }
21309
+ operation2.check();
21310
+ if (!options2.keep) {
21311
+ await operation2.run(() => unchangedSource(active, plan));
21312
+ await operation2.run(() => fs.rm(plan.source, { signal }));
21313
+ }
21083
21314
  } catch (error) {
21084
21315
  failed = true;
21085
21316
  failure = error;
21086
21317
  }
21087
21318
  try {
21088
- const signal = AbortSignal.timeout(5e3);
21089
- const currentDirectory = await context2.fs.lstat(directory2, { signal });
21090
- if (directoryStat && !sameEntry(directoryStat, currentDirectory)) {
21091
- throw new FsError("EBUSY", { path: directory2, message: "staging directory identity changed; refusing cleanup" });
21092
- }
21093
- if (stageOwned && !moved) {
21094
- let currentStage;
21095
- try {
21096
- currentStage = await context2.fs.lstat(staged, { signal });
21097
- } catch (error) {
21098
- if (codeOf(error) !== "ENOENT") throw error;
21099
- }
21100
- if (currentStage) {
21101
- if (!stageStat || !sameEntry(stageStat, currentStage)) {
21102
- throw new FsError("EBUSY", { path: staged, message: "staging file identity changed; refusing cleanup" });
21103
- }
21104
- await context2.fs.rm(staged, { signal });
21105
- }
21106
- }
21107
- if ((await context2.fs.readdir(directory2, { signal })).length) {
21108
- throw new FsError("ENOTEMPTY", { path: directory2, message: "unexpected staging entries; refusing recursive cleanup" });
21109
- }
21110
- await context2.fs.rm(directory2, { recursive: true, signal });
21319
+ await operation2.close();
21111
21320
  } catch (error) {
21321
+ if (cleanupFailed && error === failure) throw error;
21112
21322
  if (failed) {
21113
21323
  const aggregate = new AggregateError([failure, error], "compression failed and staging cleanup failed; input retained");
21114
21324
  throw new PublicDiagnostic(aggregate.message, { cause: aggregate });
21115
21325
  }
21116
21326
  throw error;
21117
21327
  }
21328
+ context2.signal.throwIfAborted();
21118
21329
  if (failed) throw failure;
21119
- if (!options2.keep) {
21120
- await unchangedSource(context2, plan);
21121
- await context2.fs.rm(plan.source, { signal: context2.signal });
21122
- }
21123
21330
  return warned2;
21124
21331
  }
21125
21332
 
@@ -26822,7 +27029,7 @@ async function writeZipArchive(archive, limits, signal) {
26822
27029
 
26823
27030
  // packages/safe-bash/src/commands/archive/zip/safety.ts
26824
27031
  init_platform();
26825
- import { retainFileSystemCleanup } from "poe-code/safe-fs/core";
27032
+ import { retainFileSystemCleanup as retainFileSystemCleanup2 } from "poe-code/safe-fs/core";
26826
27033
  var ZipScope = class {
26827
27034
  constructor(original, limits) {
26828
27035
  this.original = original;
@@ -26930,7 +27137,7 @@ async function publishZip(scope, prepared) {
26930
27137
  const owner = directory2 && await scope.stat(directory2.path);
26931
27138
  if (parent !== prepared.parent || !owner || owner.type !== "directory" || !sameIdentity2(owner, directory2.stat)) fail("ZIP temporary ownership changed before mutation");
26932
27139
  };
26933
- const close = retainFileSystemCleanup(fs, async (cleanup) => {
27140
+ const close = retainFileSystemCleanup2(fs, async (cleanup) => {
26934
27141
  if (!directory2 || !hasIdentity(directory2.stat)) return;
26935
27142
  const parent = await cleanup.realpath(prepared.parentName);
26936
27143
  const owner = await cleanup.lstat(directory2.path);
@@ -27435,7 +27642,7 @@ var Answers = class {
27435
27642
 
27436
27643
  // packages/safe-bash/src/commands/archive/unzip/safety.ts
27437
27644
  init_platform();
27438
- import { retainFileSystemCleanup as retainFileSystemCleanup2 } from "poe-code/safe-fs/core";
27645
+ import { retainFileSystemCleanup as retainFileSystemCleanup3 } from "poe-code/safe-fs/core";
27439
27646
  var Extraction = class {
27440
27647
  constructor(context2, limits) {
27441
27648
  this.context = context2;
@@ -27622,7 +27829,7 @@ var Extraction = class {
27622
27829
  let identity2;
27623
27830
  let created = false;
27624
27831
  let failure;
27625
- const cleanup = retainFileSystemCleanup2(fs, async (view) => {
27832
+ const cleanup = retainFileSystemCleanup3(fs, async (view) => {
27626
27833
  if (!created || !identity2) return;
27627
27834
  try {
27628
27835
  let parent = "/";
@@ -36599,6 +36806,8 @@ function composeAgentCommands(options2, executors) {
36599
36806
  const tsortLimits = options2.tsort?.limits;
36600
36807
  const factorLimits = options2.factor?.limits;
36601
36808
  const getoptLimits = options2.getopt?.limits;
36809
+ const hexdumpLimits = options2.hexdump?.limits;
36810
+ const iconvLimits = options2.iconv?.limits;
36602
36811
  const whichLimits = options2.which?.limits;
36603
36812
  const timeoutOptions = options2.timeout;
36604
36813
  const applyPatchLimits = options2.applyPatch?.limits;
@@ -36636,7 +36845,9 @@ function composeAgentCommands(options2, executors) {
36636
36845
  ...createPrCommands({ ...prLimits === void 0 ? {} : { limits: prLimits }, ...prClock === void 0 ? {} : { clock: prClock } }),
36637
36846
  ...createTsortCommands(tsortLimits === void 0 ? {} : { limits: tsortLimits }),
36638
36847
  ...createFactorCommands(factorLimits === void 0 ? {} : { limits: factorLimits }),
36639
- ...createGetoptCommands(getoptLimits === void 0 ? {} : { limits: getoptLimits })
36848
+ ...createGetoptCommands(getoptLimits === void 0 ? {} : { limits: getoptLimits }),
36849
+ ...createHexdumpCommands(hexdumpLimits === void 0 ? {} : { limits: hexdumpLimits }),
36850
+ ...createIconvCommands(iconvLimits === void 0 ? {} : { limits: iconvLimits })
36640
36851
  );
36641
36852
  return new CommandRegistry(commands).list();
36642
36853
  }
@@ -53020,8 +53231,13 @@ export {
53020
53231
  createGetoptCommand,
53021
53232
  createGetoptCommands,
53022
53233
  createGrepAliasCommands,
53234
+ createHdCommand,
53235
+ createHexdumpCommand,
53236
+ createHexdumpCommands,
53023
53237
  createHtmlToMarkdownCommand,
53024
53238
  createHtmlToMarkdownCommands,
53239
+ createIconvCommand,
53240
+ createIconvCommands,
53025
53241
  createMemoryFileSystem2 as createMemoryFileSystem,
53026
53242
  createMetadataCommands,
53027
53243
  createMountFileSystem2 as createMountFileSystem,
@@ -53077,7 +53293,9 @@ export {
53077
53293
  getCommandArguments,
53078
53294
  getoptCommands,
53079
53295
  grepAliasCommands,
53296
+ hexdumpCommands,
53080
53297
  htmlToMarkdownCommands,
53298
+ iconvCommands,
53081
53299
  isAbsolutePath3 as isAbsolutePath,
53082
53300
  isErrnoCode,
53083
53301
  isFsError,