@poe-platform/safe-bash 0.1.801 → 0.1.802

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 (83) hide show
  1. package/dist/image-ast/index.browser.js +3 -1
  2. package/dist/image-ast/index.js +3 -1
  3. package/dist/safe-bash/chunks/chunk-3HQU4OJO.js +13 -0
  4. package/dist/safe-bash/chunks/{chunk-SZH7EJLD.js → chunk-44ALJ4QG.js} +5461 -6495
  5. package/dist/safe-bash/chunks/chunk-4BSJLKNM.js +14 -0
  6. package/dist/safe-bash/chunks/chunk-4D4N7IU2.js +47 -0
  7. package/dist/safe-bash/chunks/chunk-55YJASTN.js +14 -0
  8. package/dist/safe-bash/chunks/chunk-7ZBU7KYV.js +14 -0
  9. package/dist/safe-bash/chunks/chunk-DQP3VHSB.js +15 -0
  10. package/dist/safe-bash/chunks/chunk-FZE4HW6G.js +11 -0
  11. package/dist/safe-bash/chunks/chunk-GEG3BWGE.js +14 -0
  12. package/dist/safe-bash/chunks/{chunk-45PK3NWI.js → chunk-GETUOD5D.js} +1 -1
  13. package/dist/safe-bash/chunks/chunk-HBCN24ZA.js +50 -0
  14. package/dist/safe-bash/chunks/chunk-HZ7BWKQ3.js +13 -0
  15. package/dist/safe-bash/chunks/{chunk-ICFDYV64.js → chunk-HZAMGT5I.js} +2 -2
  16. package/dist/safe-bash/chunks/chunk-KDNSPLII.js +83 -0
  17. package/dist/safe-bash/chunks/{chunk-PQRAK7HU.js → chunk-NQCM3TYR.js} +238 -462
  18. package/dist/safe-bash/chunks/{chunk-IVRQ4BXL.js → chunk-PH63PLPZ.js} +7 -7
  19. package/dist/safe-bash/chunks/chunk-QGUV42T5.js +44 -0
  20. package/dist/safe-bash/chunks/chunk-R3NAKOED.js +51 -0
  21. package/dist/safe-bash/chunks/chunk-RRR7AQ24.js +38 -0
  22. package/dist/safe-bash/chunks/{chunk-FNDNHAGE.js → chunk-RSTHLAF3.js} +1 -1
  23. package/dist/safe-bash/chunks/{chunk-7VNF5BFF.js → chunk-SHEMU2Z7.js} +83 -416
  24. package/dist/safe-bash/chunks/{chunk-NR3EM4LS.js → chunk-VKNVHEX3.js} +1 -6
  25. package/dist/safe-bash/chunks/chunk-VSAJ4OTM.js +962 -0
  26. package/dist/safe-bash/chunks/{chunk-VQDD3G76.js → chunk-WDLGKIHD.js} +19 -19
  27. package/dist/safe-bash/chunks/chunk-XAQMU6OY.js +14 -0
  28. package/dist/safe-bash/chunks/chunk-ZVD5IS4V.js +49 -0
  29. package/dist/safe-bash/command-chunks/{chunk-PCEFOYA3.js → chunk-6GWJUQAV.js} +3 -3
  30. package/dist/safe-bash/command-chunks/{chunk-EFANWIHL.js → chunk-GY3BWK7K.js} +1 -0
  31. package/dist/safe-bash/command-chunks/{chunk-WBNZ4PRE.js → chunk-NGG2XL56.js} +7 -4
  32. package/dist/safe-bash/command-chunks/{chunk-GLOZX57Y.js → chunk-OQKC5ZU2.js} +23 -114
  33. package/dist/safe-bash/command-chunks/{chunk-CZ7EN3JG.js → chunk-VT6MJBEI.js} +1 -1
  34. package/dist/safe-bash/command-chunks/{chunk-F6OYH562.js → chunk-X54L3DBL.js} +4 -9
  35. package/dist/safe-bash/command-chunks/{chunk-TNOA7FCQ.js → chunk-YVNGTIJO.js} +1 -1
  36. package/dist/safe-bash/commands/apply-patch/index.browser.js +14 -0
  37. package/dist/safe-bash/commands/archive/index.browser.js +36 -0
  38. package/dist/safe-bash/commands/column/index.browser.js +12 -0
  39. package/dist/safe-bash/commands/du/index.browser.js +14 -0
  40. package/dist/safe-bash/commands/expr/index.browser.js +12 -0
  41. package/dist/safe-bash/commands/file/index.browser.js +14 -0
  42. package/dist/safe-bash/commands/filesystem.js +9 -2
  43. package/dist/safe-bash/commands/grep-aliases/index.browser.js +14 -0
  44. package/dist/safe-bash/commands/html-to-markdown/index.browser.js +16 -0
  45. package/dist/safe-bash/commands/metadata/index.browser.js +21 -0
  46. package/dist/safe-bash/commands/network/index.browser.js +1 -1
  47. package/dist/safe-bash/commands/node/index.browser.js +3 -3
  48. package/dist/safe-bash/commands/python/index.browser.js +8 -8
  49. package/dist/safe-bash/commands/regex-execution/public.browser.js +5 -3
  50. package/dist/safe-bash/commands/split/index.browser.js +14 -0
  51. package/dist/safe-bash/commands/stream-format/index.browser.js +11 -0
  52. package/dist/safe-bash/commands/stream-inspection/index.browser.js +11 -0
  53. package/dist/safe-bash/commands/streams.js +5 -5
  54. package/dist/safe-bash/commands/table-text/index.browser.js +11 -0
  55. package/dist/safe-bash/commands/text.js +2 -133
  56. package/dist/safe-bash/commands/time-env/index.browser.js +15 -0
  57. package/dist/safe-bash/commands/tree/index.browser.js +14 -0
  58. package/dist/safe-bash/full-core.browser.js +227 -218
  59. package/dist/safe-bash/jobs.browser.js +2 -2
  60. package/dist/safe-bash/optional-host.browser.js +8 -8
  61. package/dist/safe-bash/plugins/index.browser.js +23 -9
  62. package/dist/safe-bash/registry-entry.browser.js +23 -9
  63. package/dist/safe-bash/search.browser.js +48 -0
  64. package/dist/safe-bash/shell/runtime.d.ts +0 -9
  65. package/dist/safe-bash/shell/runtime.js +43 -308
  66. package/dist/safe-bash/shell/shell.js +0 -23
  67. package/dist/safe-bash/shell-entry.browser.js +19 -10
  68. package/dist/safe-bash-command-nl/index.js +1 -1
  69. package/dist/safe-bash-command-nl/nl.js +1 -1
  70. package/dist/safe-bash-command-rg/index.js +1 -1
  71. package/dist/safe-bash-command-rg/rg-command.d.ts +0 -1
  72. package/dist/safe-bash-command-rg/rg-command.js +3 -5
  73. package/dist/safe-bash-command-unexpand/index.js +1 -1
  74. package/dist/safe-bash-command-unexpand/unexpand.js +1 -1
  75. package/dist/safe-bash-mcp/index.js +3 -1
  76. package/dist/safe-bash-regex-engine/index.js +4 -4
  77. package/dist/safe-bash-regex-engine/text/budget.d.ts +0 -1
  78. package/dist/safe-bash-regex-engine/text/budget.js +1 -1
  79. package/dist/safe-bash-regex-engine/text/regex.js +4 -4
  80. package/dist/safe-bash-regex-engine/text/replacement-buffer.js +2 -2
  81. package/dist/safe-bash-regex-engine/text/rust-syntax.js +2 -2
  82. package/package.json +65 -10
  83. package/dist/safe-bash/chunks/{chunk-A7XEHALN.js → chunk-BJA5XNP6.js} +3 -3
@@ -8,14 +8,9 @@ import {
8
8
  isIdlePortableTrapInstance
9
9
  } from "./chunk-3NDIFSNM.js";
10
10
  import {
11
- abortManagedController,
12
- addAbortSignalWaiter,
13
11
  bindFileOutputBudget,
14
12
  clearRgFastRunnerPool,
15
- combineManagedSignals,
16
13
  createFmtEngine,
17
- createManagedControlController,
18
- creationUmask,
19
14
  defaultEchoExecutors,
20
15
  defaultMkdirExecutors,
21
16
  defaultPredicateExecutors,
@@ -24,49 +19,31 @@ import {
24
19
  evalSyncChecksum,
25
20
  evalSyncCmp,
26
21
  evalSyncCompression,
27
- evalSyncDate,
28
22
  evalSyncDf,
29
23
  evalSyncDiff,
30
- evalSyncDu,
31
24
  evalSyncEnv,
32
25
  evalSyncFd,
33
- evalSyncFile,
34
26
  evalSyncFind,
35
- evalSyncHtmlToMarkdown,
36
27
  evalSyncLess,
37
28
  evalSyncLs,
38
29
  evalSyncPathchk,
39
- evalSyncPrintenv,
40
30
  evalSyncReadlink,
41
31
  evalSyncRealpath,
42
- evalSyncStat,
43
- evalSyncTar,
44
- evalSyncTree,
45
- evalSyncUnzip,
46
32
  evalSyncWhich,
47
33
  evalSyncXargs,
48
- evalSyncZip,
49
34
  evaluateFilePredicate,
50
35
  executionCommands,
51
36
  extractFastPrintfSpecifiers,
52
37
  formatPrintf,
53
- getRuntimeBackingFileSystem,
54
- gnuInformationSync,
55
- interruptible,
56
- isManagedAbortSignal,
57
- isSyncResolved,
58
38
  openFileOutput,
59
39
  parseFmtArguments,
60
- preverifyMemoryRgTree,
61
40
  printfCommand,
62
- registerManagedAbortSignal,
63
- removeAbortSignalWaiter,
64
41
  tryFastEcho,
65
42
  tryFastPredicate,
66
43
  tryFastPrintf,
67
44
  variablePresence,
68
45
  wcDisplayWidth
69
- } from "./chunk-SZH7EJLD.js";
46
+ } from "./chunk-44ALJ4QG.js";
70
47
  import {
71
48
  evalSyncGetopt
72
49
  } from "./chunk-AUSNDQTJ.js";
@@ -87,13 +64,7 @@ import {
87
64
  PublicDiagnostic,
88
65
  publicDiagnosticMessage,
89
66
  writeDiagnostic
90
- } from "./chunk-IVRQ4BXL.js";
91
- import {
92
- bytesToHex,
93
- compareUtf8,
94
- latin1Bytes,
95
- latin1Text
96
- } from "./chunk-D3ANYGMC.js";
67
+ } from "./chunk-PH63PLPZ.js";
97
68
  import {
98
69
  evalSyncPr
99
70
  } from "./chunk-CHYGPFVM.js";
@@ -109,7 +80,7 @@ import {
109
80
  } from "./chunk-6O77NL2S.js";
110
81
  import {
111
82
  jobsExtension
112
- } from "./chunk-A7XEHALN.js";
83
+ } from "./chunk-BJA5XNP6.js";
113
84
  import {
114
85
  concatShellValues,
115
86
  shellValueByteLength,
@@ -121,6 +92,46 @@ import {
121
92
  import {
122
93
  openCommandFile
123
94
  } from "./chunk-I5HZ4FGE.js";
95
+ import {
96
+ CommandRegistry,
97
+ commandRuntimeIdentity,
98
+ createCommandArguments,
99
+ getCommandArguments,
100
+ validateExitCode
101
+ } from "./chunk-7R5BDCG7.js";
102
+ import {
103
+ evalSyncTree
104
+ } from "./chunk-55YJASTN.js";
105
+ import {
106
+ evalSyncFile
107
+ } from "./chunk-4BSJLKNM.js";
108
+ import {
109
+ evalSyncHtmlToMarkdown
110
+ } from "./chunk-DQP3VHSB.js";
111
+ import {
112
+ evalSyncDu
113
+ } from "./chunk-GEG3BWGE.js";
114
+ import {
115
+ abortManagedController,
116
+ addAbortSignalWaiter,
117
+ combineManagedSignals,
118
+ createManagedControlController,
119
+ creationUmask,
120
+ evalSyncStat,
121
+ getRuntimeBackingFileSystem,
122
+ gnuInformationSync,
123
+ interruptible,
124
+ isManagedAbortSignal,
125
+ isSyncResolved,
126
+ registerManagedAbortSignal,
127
+ removeAbortSignalWaiter
128
+ } from "./chunk-VSAJ4OTM.js";
129
+ import {
130
+ bytesToHex,
131
+ compareUtf8,
132
+ latin1Bytes,
133
+ latin1Text
134
+ } from "./chunk-D3ANYGMC.js";
124
135
  import {
125
136
  FsError,
126
137
  isFsError
@@ -149,12 +160,14 @@ import {
149
160
  writeText
150
161
  } from "./chunk-74GHTNJA.js";
151
162
  import {
152
- CommandRegistry,
153
- commandRuntimeIdentity,
154
- createCommandArguments,
155
- getCommandArguments,
156
- validateExitCode
157
- } from "./chunk-7R5BDCG7.js";
163
+ evalSyncTar,
164
+ evalSyncUnzip,
165
+ evalSyncZip
166
+ } from "./chunk-QGUV42T5.js";
167
+ import {
168
+ evalSyncDate,
169
+ evalSyncPrintenv
170
+ } from "./chunk-ZVD5IS4V.js";
158
171
  import {
159
172
  RESOLVED_EXIT_ONE,
160
173
  RESOLVED_EXIT_ZERO,
@@ -19991,260 +20004,6 @@ var Runtime = class _Runtime {
19991
20004
  }
19992
20005
  }
19993
20006
  }
19994
- tryRunFastConstEchoBatch(entryCachedUnit, sourceLength, state, io) {
19995
- if (state.noexec) return void 0;
19996
- let leadingMkdirUnit;
19997
- let leadingMkdirPaths;
19998
- let firstCachedUnit = entryCachedUnit;
19999
- let firstCc = firstCachedUnit.unit.script._fastConstEcho;
20000
- if (!firstCc) {
20001
- const nextU = entryCachedUnit.nextCached;
20002
- if (!nextU || entryCachedUnit.locale !== false || nextU.locale !== false || entryCachedUnit.unit.script.warnings && entryCachedUnit.unit.script.warnings.length > 0) return void 0;
20003
- firstCc = nextU.unit.script._fastConstEcho;
20004
- if (!firstCc) return void 0;
20005
- const mScript = entryCachedUnit.unit.script;
20006
- let mPaths = mScript._cachedMkdirPPaths;
20007
- if (mPaths === void 0) {
20008
- mPaths = null;
20009
- if (mScript.lists.length === 1 && !mScript.lists[0].terminator && mScript.lists[0].pipelines.length === 1 && !mScript.lists[0].pipelines[0].negate && mScript.lists[0].pipelines[0].commands.length === 1) {
20010
- const mCmd = mScript.lists[0].pipelines[0].commands[0];
20011
- if (mCmd.kind === "simple" && mCmd.redirects.length === 0 && mCmd.words.length >= 3 && mCmd.words[0].plain === "mkdir" && mCmd.words[1].plain === "-p") {
20012
- const arr = [];
20013
- let ok = true;
20014
- for (let wi = 2; wi < mCmd.words.length; wi++) {
20015
- const wp = mCmd.words[wi].plain;
20016
- if (!wp || !isCleanAbsolutePath(wp) || wp === "/" || wp === "/dev" || wp.startsWith("/dev/")) {
20017
- ok = false;
20018
- break;
20019
- }
20020
- arr.push(wp);
20021
- }
20022
- if (ok) mPaths = arr;
20023
- }
20024
- }
20025
- mScript._cachedMkdirPPaths = mPaths;
20026
- }
20027
- if (!mPaths) return void 0;
20028
- leadingMkdirUnit = entryCachedUnit;
20029
- leadingMkdirPaths = mPaths;
20030
- firstCachedUnit = nextU;
20031
- }
20032
- if (this.middleware.length > 0 || io.terminal !== void 0 || io.asyncDefaultInput !== void 0 || io.admittedHandles !== void 0 || this._fileWrites !== void 0 && this._fileWrites.size > 0 || !this._isMemoryBackingFs || !this.backingFs || !this.budget.canRedirect1 || !this.budget.hasInfiniteFsOps || io.descriptors && (io.descriptors.size > 3 || io.descriptors.get(0)?.closed || io.descriptors.get(1)?.closed || io.descriptors.get(2)?.closed)) {
20033
- return void 0;
20034
- }
20035
- const monitor = ensureStateMonitor(state, this.budget, io[invocationScope]);
20036
- const rawState = monitor.raw;
20037
- if (!this.tryStartExtensionsSync(state) || hasActiveExtensions(rawState) || rawState.externalInvocation || hasActiveVariableAttributes(rawState) || guestArrays(state) || rawState.noclobber || rawState.readonlyVariables?.has("PIPESTATUS") || hasShellFunction(rawState, "echo") || rawState.extensions?.builtins.has("echo")) {
20038
- return void 0;
20039
- }
20040
- const def = this.commands.get("echo");
20041
- if (!def || !defaultEchoExecutors.has(def.execute)) return void 0;
20042
- const store = monitor.store;
20043
- const existing = store?.get("PIPESTATUS");
20044
- const psTarget = existing ? "indexed" : pipelineStatusTarget(rawState);
20045
- if (psTarget !== "indexed" && psTarget !== "absent" || store?.watches.has("PIPESTATUS") || monitor.hasOverlay("PIPESTATUS")) return void 0;
20046
- if (existing && (existing.associative || existing.values.size !== 1 || existing.maximum !== 0)) return void 0;
20047
- const elem0 = existing?.values.get(0);
20048
- if (existing && (!elem0 || elem0.text.bytes !== 1 || existing.references !== 1 || elem0.text.references !== 1)) return void 0;
20049
- const byteLength0 = firstCc.encoded.byteLength;
20050
- if (this.budget.bytes + byteLength0 > this.budget.maxOutputBytesSmi && byteLength0 > this.budget.limits.maxOutputBytes - this.budget.bytes || !this.budget.canFileSystemOperation() || this.budget.commands + 1 > this.budget.maxCommandsSmi && this.budget.commands + 1 > this.budget.limits.maxCommands) {
20051
- return void 0;
20052
- }
20053
- const umask = rawState.umask ?? 18;
20054
- if (leadingMkdirUnit !== void 0 && leadingMkdirPaths !== void 0) {
20055
- if ((umask & 192) !== 0 || this._outputFiles !== void 0 && this._outputFiles.size > 0 || hasShellFunction(rawState, "mkdir") || rawState.extensions?.builtins.has("mkdir")) return void 0;
20056
- const mkdirDef = this.commands.get("mkdir");
20057
- if (!mkdirDef || !defaultMkdirExecutors.has(mkdirDef.execute)) return void 0;
20058
- const dirMode = 511 & ~umask;
20059
- try {
20060
- for (let mi = 0; mi < leadingMkdirPaths.length; mi++) {
20061
- const mp = leadingMkdirPaths[mi];
20062
- if (!tryMkdirMemorySync(this.backingFs, mp, true, dirMode, this.commandSignal, firstCc.dirPrefix.startsWith(mp) && firstCc.dirPrefix.length === mp.length + 1 ? firstCc.dirPrefix : void 0)) return void 0;
20063
- this.budget.fileSystemOperation();
20064
- }
20065
- } catch {
20066
- this.signal.throwIfAborted();
20067
- return void 0;
20068
- }
20069
- this.budget.commands++;
20070
- this.budget.parsing.admit(firstCachedUnit.unitsCharged);
20071
- }
20072
- const mode = 438 & ~umask;
20073
- try {
20074
- if (!tryWriteMemoryFileInDirSync(this.backingFs, firstCc.dirPrefix, firstCc.fileName, firstCc.encoded, firstCc.append, mode, this.commandSignal)) return void 0;
20075
- } catch {
20076
- this.signal.throwIfAborted();
20077
- return void 0;
20078
- }
20079
- this.budget.tick();
20080
- this.budget.fileSystemOperation();
20081
- this.budget.bytes += byteLength0;
20082
- let lastArg = firstCc.arg0;
20083
- let cur = firstCachedUnit;
20084
- const vars = rawState.variables;
20085
- const curLocale = vars.LC_ALL || vars.LC_CTYPE || vars.LANG ? byteLocale(vars) : false;
20086
- const mem = this.backingFs;
20087
- let deadRmTarget;
20088
- let deadRmTargetLen = 0;
20089
- const rmDef = this.commands.get("rm");
20090
- if (mem.symlinkCount === 0 && curLocale === false && rmDef && defaultRmExecutors.has(rmDef.execute) && !hasShellFunction(rawState, "rm") && !rawState.extensions?.builtins.has("rm")) {
20091
- const cachedCc = firstCc;
20092
- let target = cachedCc._cachedRmTarget;
20093
- let scanCount = cachedCc._cachedScanCount ?? 0;
20094
- if (target === void 0) {
20095
- let scan = firstCachedUnit;
20096
- scanCount = 1;
20097
- while (scan.nextCached !== void 0 && scan.nextCached.locale === false && (!scan.nextCached.unit.script.warnings || scan.nextCached.unit.script.warnings.length === 0) && scan.nextCached.unit.script._fastConstEcho !== void 0) {
20098
- scan = scan.nextCached;
20099
- scanCount++;
20100
- }
20101
- target = null;
20102
- const after = scan.nextCached;
20103
- if (after !== void 0 && after.locale === false && (!after.unit.script.warnings || after.unit.script.warnings.length === 0) && after.unit.script.lists.length === 1) {
20104
- const list0 = after.unit.script.lists[0];
20105
- if (!list0.terminator && list0.pipelines.length === 1 && !list0.pipelines[0].negate && list0.pipelines[0].commands.length === 1) {
20106
- const cmd0 = list0.pipelines[0].commands[0];
20107
- if (cmd0.kind === "simple" && cmd0.redirects.length === 0 && cmd0.words.length === 3 && cmd0.words[0].plain === "rm" && (cmd0.words[1].plain === "-rf" || cmd0.words[1].plain === "-fr")) {
20108
- const t = cmd0.words[2].plain;
20109
- if (t && t.length > 1 && t.charCodeAt(0) === 47 && t.charCodeAt(t.length - 1) !== 47 && !t.includes("/.")) target = t;
20110
- }
20111
- }
20112
- }
20113
- cachedCc._cachedRmTarget = target;
20114
- cachedCc._cachedScanCount = scanCount;
20115
- }
20116
- if (target !== null && this.budget.commands + scanCount + 1 <= this.budget.maxCommandsSmi && tryGetMemoryDirectoryEntryNamesSync(this.backingFs, target)?.size === 0) {
20117
- deadRmTarget = target;
20118
- deadRmTargetLen = target.length;
20119
- }
20120
- }
20121
- const cachedBatchPlan = deadRmTarget !== void 0 ? firstCc._cachedEchoBatch : void 0;
20122
- if (cachedBatchPlan !== void 0 && cachedBatchPlan !== null && mem.symlinkCount === 0 && !this.signal.aborted && this.budget.bytes + cachedBatchPlan.totalBytes <= this.budget.maxOutputBytesSmi && this.budget._fileSystemOperations + cachedBatchPlan.totalCount <= this.budget.maxFileSystemOperationsSmi && this.budget.commands + cachedBatchPlan.totalCount <= this.budget.maxCommandsSmi) {
20123
- this.budget.parsing.admit(cachedBatchPlan.totalUnitsCharged);
20124
- try {
20125
- mem.writeMemoryFilesInDirBatchFast(firstCc.fileName, firstCc.dirPrefix, cachedBatchPlan.fileNames, cachedBatchPlan.nameHashes, cachedBatchPlan.payloads, cachedBatchPlan.totalNameBytes, cachedBatchPlan.payloadBytesSum, mode);
20126
- this.budget.commands += cachedBatchPlan.totalCount;
20127
- this.budget._fileSystemOperations += cachedBatchPlan.totalCount;
20128
- this.budget.bytes += cachedBatchPlan.totalBytes;
20129
- lastArg = cachedBatchPlan.lastArg;
20130
- cur = cachedBatchPlan.endUnit;
20131
- } catch {
20132
- this.signal.throwIfAborted();
20133
- }
20134
- }
20135
- if (cur !== cachedBatchPlan?.endUnit && cur.unit.next < sourceLength && mem.symlinkCount === 0 && !this.signal.aborted) {
20136
- const buildBatchStart = cur === firstCachedUnit && deadRmTarget !== void 0 && cachedBatchPlan === void 0;
20137
- let bTotalCount = 0;
20138
- let bTotalBytes = 0;
20139
- let bTotalUnits = 0;
20140
- let bTotalNameBytes = 0;
20141
- let bPayloadBytesSum = 0;
20142
- let bCanCache = buildBatchStart && !firstCc.append;
20143
- const bFileNames = bCanCache ? [] : void 0;
20144
- const bHashes = bCanCache ? [] : void 0;
20145
- const bPayloads = bCanCache ? [] : void 0;
20146
- const bSeenNames = bCanCache ? /* @__PURE__ */ new Set([firstCc.fileName]) : void 0;
20147
- while (cur.unit.next < sourceLength && mem.symlinkCount === 0 && !this.signal.aborted) {
20148
- const next = cur.nextCached;
20149
- if (!next || next.locale !== curLocale || next.unit.script.warnings && next.unit.script.warnings.length > 0) break;
20150
- const nextCc = next.unit.script._fastConstEcho;
20151
- if (!nextCc) break;
20152
- const bLen = nextCc.encoded.byteLength;
20153
- if (this.budget.bytes + bLen > this.budget.maxOutputBytesSmi || this.budget._fileSystemOperations + 1 > this.budget.maxFileSystemOperationsSmi || this.budget.commands + 1 > this.budget.maxCommandsSmi) {
20154
- break;
20155
- }
20156
- this.budget.parsing.admit(next.unitsCharged);
20157
- if (!(deadRmTarget !== void 0 && nextCc.dirPrefix.length === deadRmTargetLen + 1 && nextCc.dirPrefix.charCodeAt(deadRmTargetLen) === 47 && nextCc.dirPrefix.startsWith(deadRmTarget))) {
20158
- let nameHash = nextCc._nameHash;
20159
- if (nameHash === void 0) {
20160
- const fn = nextCc.fileName;
20161
- let h = 5381;
20162
- for (let ci = 0; ci < fn.length; ci++) h = ((h & 2097151) * 33 ^ fn.charCodeAt(ci)) & 1073741823;
20163
- nextCc._nameHash = nameHash = h;
20164
- }
20165
- try {
20166
- mem.writeMemoryFileInDirFast(nextCc.dirPrefix, nextCc.fileName, nextCc.encoded, nextCc.append, mode, nameHash);
20167
- } catch {
20168
- this.signal.throwIfAborted();
20169
- break;
20170
- }
20171
- }
20172
- if (bCanCache) {
20173
- const isDeadRm = deadRmTarget !== void 0 && nextCc.dirPrefix.length === deadRmTargetLen + 1 && nextCc.dirPrefix.charCodeAt(deadRmTargetLen) === 47 && nextCc.dirPrefix.startsWith(deadRmTarget);
20174
- if (isDeadRm) {
20175
- bTotalCount++;
20176
- bTotalBytes += bLen;
20177
- bTotalUnits += next.unitsCharged;
20178
- } else if (!nextCc.append && nextCc.dirPrefix === firstCc.dirPrefix && nextCc.fileName.length <= 85 && !bSeenNames.has(nextCc.fileName)) {
20179
- bSeenNames.add(nextCc.fileName);
20180
- bFileNames.push(nextCc.fileName);
20181
- bHashes.push(nextCc._nameHash);
20182
- bPayloads.push(nextCc.encoded);
20183
- bTotalNameBytes += nextCc.fileName.length * 2;
20184
- bPayloadBytesSum += bLen;
20185
- bTotalCount++;
20186
- bTotalBytes += bLen;
20187
- bTotalUnits += next.unitsCharged;
20188
- } else bCanCache = false;
20189
- }
20190
- this.budget.commands++;
20191
- this.budget._fileSystemOperations++;
20192
- this.budget.bytes += bLen;
20193
- lastArg = nextCc.arg0;
20194
- cur = next;
20195
- }
20196
- if (buildBatchStart) {
20197
- firstCc._cachedEchoBatch = bCanCache && bTotalCount > 0 ? {
20198
- endUnit: cur,
20199
- totalCount: bTotalCount,
20200
- totalBytes: bTotalBytes,
20201
- totalUnitsCharged: bTotalUnits,
20202
- lastArg,
20203
- fileNames: bFileNames,
20204
- nameHashes: new Int32Array(bHashes),
20205
- payloads: bPayloads,
20206
- totalNameBytes: bTotalNameBytes,
20207
- payloadBytesSum: bPayloadBytesSum
20208
- } : null;
20209
- }
20210
- }
20211
- if (deadRmTarget !== void 0 && cur.nextCached !== void 0 && !this.signal.aborted && mem.symlinkCount === 0 && (this._outputFiles === void 0 || this._outputFiles.size === 0) && !hasShellFunction(rawState, "rm") && !rawState.extensions?.builtins.has("rm")) {
20212
- const rmDef2 = this.commands.get("rm");
20213
- const rmUnit = cur.nextCached;
20214
- const rmCmd0 = rmUnit.unit.script.lists[0]?.pipelines[0]?.commands[0];
20215
- if (rmDef2 && defaultRmExecutors.has(rmDef2.execute) && rmCmd0 && rmCmd0.kind === "simple" && rmCmd0.words[0]?.plain === "rm" && rmCmd0.words[2]?.plain === deadRmTarget) {
20216
- let rmOk = false;
20217
- try {
20218
- rmOk = tryRmRfMemorySync(this.backingFs, deadRmTarget, this.commandSignal);
20219
- } catch {
20220
- this.signal.throwIfAborted();
20221
- }
20222
- if (rmOk) {
20223
- this.budget.parsing.admit(rmUnit.unitsCharged);
20224
- this.budget.commands++;
20225
- this.budget._fileSystemOperations++;
20226
- lastArg = deadRmTarget;
20227
- cur = rmUnit;
20228
- }
20229
- }
20230
- }
20231
- const restEpoch = monitor.chargeInternal(syncRestorationCharge, syncRestorationTickets).epoch;
20232
- rawState.substitutionStatus = 0;
20233
- if (rawState.variables._ !== void 0) delete rawState.variables._;
20234
- rawState.lastArgument = lastArg;
20235
- if (io.assignmentDiagnosticContext) io.assignmentDiagnosticContext.name = void 0;
20236
- if (!existing) {
20237
- monitor.lazyPipeStatus = singleStatusZero;
20238
- monitor.chargeInternal(syncPipeStatusCharge, syncPipeStatusTickets);
20239
- } else {
20240
- elem0.text.shellValue = "0";
20241
- store.changed(monitor.chargeInternal(syncPipeStatusCharge, syncPipeStatusTickets), "PIPESTATUS");
20242
- }
20243
- rawState.status = 0;
20244
- monitor.epoch = restEpoch;
20245
- if (store) store.epoch = restEpoch;
20246
- return cur;
20247
- }
20248
20007
  tryRunCachedSyncForScript(script, monitor, io) {
20249
20008
  const rawScript = script;
20250
20009
  let plan = rawScript._cachedSyncForScriptPlan;
@@ -20329,10 +20088,12 @@ var Runtime = class _Runtime {
20329
20088
  rawScript._cachedSyncForScriptPlan = plan;
20330
20089
  }
20331
20090
  const forPlan = plan.forCmd._cachedForPlan;
20091
+ if (plan.echoVar !== void 0 && (!forPlan.touchedIntNamesList.includes(plan.echoVar) || forPlan.touchedIntNamesList.includes("IFS") || rawState.variables.IFS !== void 0 && rawState.variables.IFS !== " \n" || plan.initAssigns.some((assignment) => assignment.name === "IFS"))) return void 0;
20332
20092
  const fastSyncSink = plan.echoVar !== void 0 ? io.stdout instanceof BudgetedSyncSink && io.stdout.write === BudgetedSyncSink.prototype.write || io.stdout instanceof Capture && io.stdout.write === Capture.prototype.write ? io.stdout : void 0 : void 0;
20333
20093
  if (plan.echoVar !== void 0) {
20334
20094
  const def = this.commands.get("echo");
20335
20095
  if (!fastSyncSink || !def || !defaultEchoExecutors.has(def.execute) || hasShellFunction(rawState, "echo") || rawState.extensions?.builtins.has("echo") || io.descriptors && io.descriptors.get(1)?.output !== io.stdout) return void 0;
20096
+ if (this.budget.maxOutputBytesSmi - this.budget.bytes < 12) return void 0;
20336
20097
  }
20337
20098
  const store = monitor.store;
20338
20099
  const existing = store?.get("PIPESTATUS");
@@ -20353,28 +20114,32 @@ var Runtime = class _Runtime {
20353
20114
  const finalValues = /* @__PURE__ */ new Map();
20354
20115
  for (const assignment of plan.initAssigns) finalValues.set(assignment.name, assignment.strVal);
20355
20116
  const regNames = forPlan.regNames;
20356
- for (let r = 1; r < regNames.length; r++) {
20357
- const refName = regNames[r];
20358
- const parsed = fastSafeInt(finalValues.get(refName) ?? rawState.variables[refName], this.budget.parsing);
20359
- if (parsed === void 0) return void 0;
20360
- sharedLoopIntRegs[r] = parsed | 0;
20361
- }
20362
- const { ok } = runIntForLoop(forPlan.fastLoopWords, forPlan.bodyStepCount, forPlan.intSteps, this.budget.parsing);
20363
- if (!ok) return void 0;
20364
- for (let r = 0; r < regNames.length; r++) finalValues.set(regNames[r], intToStr(sharedLoopIntRegs[r]));
20117
+ const savedParseBudget = this.budget.parsing.snapshot();
20118
+ let admitted = false;
20365
20119
  let lastArg = "";
20366
- if (plan.echoVar !== void 0) {
20367
- const echoVal = finalValues.get(plan.echoVar) ?? rawState.variables[plan.echoVar] ?? "";
20368
- const ifs = finalValues.get("IFS") ?? rawState.variables.IFS;
20369
- if (ifs !== void 0 && ifs !== " \n") return void 0;
20370
- if (echoVal.startsWith("-") || echoVal.includes("\0")) return void 0;
20371
- const encoded = encodeRedirectTextWithNewlineToScratch(echoVal);
20372
- if (!encoded) return void 0;
20373
- const bLen = encoded.byteLength;
20374
- if (this.budget.bytes + bLen > this.budget.maxOutputBytesSmi) return void 0;
20375
- if (!fastSyncSink.writeSync(encoded)) return void 0;
20376
- this.budget.bytes += bLen;
20377
- lastArg = echoVal;
20120
+ try {
20121
+ for (let r = 1; r < regNames.length; r++) {
20122
+ const refName = regNames[r];
20123
+ const parsed = fastSafeInt(finalValues.get(refName) ?? rawState.variables[refName], this.budget.parsing);
20124
+ if (parsed === void 0) return void 0;
20125
+ sharedLoopIntRegs[r] = parsed | 0;
20126
+ }
20127
+ const { ok } = runIntForLoop(forPlan.fastLoopWords, forPlan.bodyStepCount, forPlan.intSteps, this.budget.parsing);
20128
+ if (!ok) return void 0;
20129
+ for (const name2 of forPlan.touchedIntNamesList) finalValues.set(name2, intToStr(sharedLoopIntRegs[regNames.indexOf(name2)]));
20130
+ if (plan.echoVar !== void 0) {
20131
+ const echoVal = finalValues.get(plan.echoVar);
20132
+ const encoded = encodeRedirectTextWithNewlineToScratch(echoVal);
20133
+ if (!encoded) return void 0;
20134
+ const bLen = encoded.byteLength;
20135
+ if (this.budget.bytes + bLen > this.budget.maxOutputBytesSmi) return void 0;
20136
+ if (!fastSyncSink.writeSync(encoded)) return void 0;
20137
+ this.budget.bytes += bLen;
20138
+ lastArg = echoVal;
20139
+ }
20140
+ admitted = true;
20141
+ } finally {
20142
+ if (!admitted) this.budget.parsing.restore(savedParseBudget);
20378
20143
  }
20379
20144
  for (const [name2, value] of finalValues) rawState.variables[name2] = value;
20380
20145
  for (const name2 of publishNames) {
@@ -26591,8 +26356,8 @@ var Runtime = class _Runtime {
26591
26356
  this.budget.tick();
26592
26357
  this.budget.iterations += wordCount;
26593
26358
  this.budget.commands += wordCount * forPlan.bodyStepCount;
26594
- for (let r = 0; r < regNames.length; r++) {
26595
- rawState.variables[regNames[r]] = intToStr(sharedLoopIntRegs[r]);
26359
+ for (const name2 of forPlan.touchedIntNamesList) {
26360
+ rawState.variables[name2] = intToStr(sharedLoopIntRegs[regNames.indexOf(name2)]);
26596
26361
  }
26597
26362
  const touchedList = forPlan.touchedIntNamesList;
26598
26363
  for (let t = 0; t < touchedList.length; t++) {
@@ -27752,8 +27517,8 @@ var Runtime = class _Runtime {
27752
27517
  rawState.status = 0;
27753
27518
  }
27754
27519
  runYieldCheckpoint(this.signal);
27755
- for (let r = 0; r < regNames.length; r++) {
27756
- rawState.variables[regNames[r]] = intToStr(sharedLoopIntRegs[r]);
27520
+ for (const name2 of forPlan.touchedIntNamesList) {
27521
+ rawState.variables[name2] = intToStr(sharedLoopIntRegs[regNames.indexOf(name2)]);
27757
27522
  }
27758
27523
  regNames.length = 0;
27759
27524
  }
@@ -47706,26 +47471,6 @@ var Shell = class _Shell {
47706
47471
  let unit = firstCached.unit;
47707
47472
  let exitCode = 0;
47708
47473
  while (true) {
47709
- if (currentCachedUnit !== void 0 && (unit.script._fastConstEcho !== void 0 || currentCachedUnit.nextCached !== void 0 && currentCachedUnit.nextCached.unit.script._fastConstEcho !== void 0)) {
47710
- const batchEnd = runtime.tryRunFastConstEchoBatch(currentCachedUnit, source.length, currentState, io);
47711
- if (batchEnd !== void 0) {
47712
- currentCachedUnit = batchEnd;
47713
- unit = batchEnd.unit;
47714
- exitCode = 0;
47715
- if (unit.next >= source.length) break;
47716
- budget.signal.throwIfAborted();
47717
- const vars2 = currentState.variables;
47718
- const nextLocale2 = vars2.LC_ALL || vars2.LC_CTYPE || vars2.LANG ? byteLocale(vars2) : false;
47719
- const nextCached2 = currentCachedUnit.locale === nextLocale2 ? currentCachedUnit.nextCached : void 0;
47720
- if (nextCached2 !== void 0 && (!nextCached2.unit.script.warnings || nextCached2.unit.script.warnings.length === 0)) {
47721
- currentCachedUnit = nextCached2;
47722
- budget.parsing.admit(nextCached2.unitsCharged);
47723
- unit = nextCached2.unit;
47724
- continue;
47725
- }
47726
- return this.#continueWarmAsync(source, options, warm, sourceCache, void 0, unit, currentCachedUnit, exitCode);
47727
- }
47728
- }
47729
47474
  if (unit.script.lists.length) {
47730
47475
  const unitResult = runtime.runUnit(unit.script, currentState, io);
47731
47476
  if (unitResult instanceof Promise) {
@@ -48223,7 +47968,6 @@ shell: -c: line ${line}: \`${source.split("\n")[line - 1] ?? ""}'
48223
47968
  stdout.enableScratchBuffer();
48224
47969
  stderr.enableScratchBuffer();
48225
47970
  void runtime.canFastMemoryRedirect;
48226
- preverifyMemoryRgTree(runtime.backingFs);
48227
47971
  this.#warmedInvocation = {
48228
47972
  budget,
48229
47973
  scope,
@@ -48328,82 +48072,6 @@ shell: -c: line ${line}: \`${source.split("\n")[line - 1] ?? ""}'
48328
48072
  }
48329
48073
  };
48330
48074
 
48331
- // packages/safe-bash/src/shell/worker-limits.ts
48332
- init_platform();
48333
- var cloudflareWorkerLimits = Object.freeze({
48334
- maxEnvSplitBytes: 131072,
48335
- maxEnvSplitArguments: 1e4,
48336
- maxEnvSplitExpansions: 32,
48337
- maxEnvSplitWork: 1048576,
48338
- maxDirectoryStackBytes: 4194304,
48339
- maxDirectoryDiagnosticBytes: 65792,
48340
- commandLimits: Object.freeze({ archive: Object.freeze({
48341
- maxArchiveBytes: 4 * 1024 * 1024,
48342
- maxInputMemoryBytes: 8 * 1024 * 1024,
48343
- maxEntryBytes: 4 * 1024 * 1024,
48344
- maxTotalBytes: 8 * 1024 * 1024,
48345
- maxMembers: 1e3,
48346
- maxPathBytes: 4 * 1024,
48347
- maxDepth: 64,
48348
- maxPaxBytes: 64 * 1024,
48349
- maxFilesFromBytes: 256 * 1024,
48350
- maxArgumentBytes: 256 * 1024,
48351
- maxTextBytes: 4 * 1024 * 1024,
48352
- maxDiagnosticBytes: 4 * 1024,
48353
- maxPatternSteps: 1e6,
48354
- maxBufferedFileBytes: 4 * 1024 * 1024,
48355
- chunkSize: 16 * 1024
48356
- }), htmlToMarkdown: Object.freeze({
48357
- maxInputBytes: 4 * 1024 * 1024,
48358
- maxOutputBytes: 4 * 1024 * 1024,
48359
- maxTokenBytes: 64 * 1024,
48360
- maxTokens: 3e4,
48361
- maxNodes: 1e4,
48362
- maxDepth: 64,
48363
- maxAttributes: 64,
48364
- maxTableCells: 1e4,
48365
- maxTableCellBytes: 64 * 1024,
48366
- maxFiles: 64,
48367
- maxArgumentBytes: 256 * 1024,
48368
- maxDiagnosticBytes: 4 * 1024,
48369
- maxWorkUnits: 32 * 1024 * 1024
48370
- }), split: Object.freeze({ maxSuffixLength: 255 }) }),
48371
- maxSyntaxDepth: 64,
48372
- maxAdmittedHandles: 64,
48373
- maxDescriptorOperations: 16,
48374
- maxDescriptorReadBytes: 65536,
48375
- maxCdWork: 8388608,
48376
- maxCdPathBytes: 65536,
48377
- maxCdProbes: 4097,
48378
- maxCdPathComponents: 4096,
48379
- maxDirectoryStackEntries: 4096,
48380
- maxDirectoryStackOutputBytes: 65536,
48381
- maxGlobstarStates: 1e5,
48382
- maxGlobstarDepth: 128,
48383
- maxGlobstarEntries: 1e5,
48384
- maxParseUnits: 65536,
48385
- maxInputBytes: 4 * 1024 * 1024,
48386
- maxOutputBytes: 4 * 1024 * 1024,
48387
- maxCommands: 1e3,
48388
- maxFileSystemOperations: 1e4,
48389
- maxPathComponents: 64,
48390
- maxPathnameComponents: 64,
48391
- maxRedirects: 64,
48392
- maxPipelineStages: 64,
48393
- maxLoopIterations: 1e3,
48394
- maxSubstitutionDepth: 16,
48395
- maxFunctionDepth: 16,
48396
- maxSourceBytes: 256 * 1024,
48397
- maxExpansionFields: 1e3,
48398
- maxExpansionBytes: 4 * 1024 * 1024,
48399
- maxWallClockMs: 1e4,
48400
- maxCpuMs: 1e4,
48401
- pipeHighWaterMark: 16 * 1024
48402
- });
48403
-
48404
- // packages/safe-bash/src/shell/index.ts
48405
- init_platform();
48406
-
48407
48075
  export {
48408
48076
  createMemoryFileSystem,
48409
48077
  defaultMemoryFileSystemLimits,
@@ -48429,6 +48097,5 @@ export {
48429
48097
  createSearchCommands,
48430
48098
  searchCommands,
48431
48099
  evalSyncRg,
48432
- Shell,
48433
- cloudflareWorkerLimits
48100
+ Shell
48434
48101
  };
@@ -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
  };