@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
@@ -1,11 +1,16 @@
1
1
  import {
2
2
  baseAgentCommands
3
- } from "./chunks/chunk-PQRAK7HU.js";
3
+ } from "./chunks/chunk-NQCM3TYR.js";
4
4
  import "./chunks/chunk-AM5ESLPH.js";
5
5
  import "./chunks/chunk-CS4MNM6I.js";
6
6
  import "./chunks/chunk-FBUCWVTE.js";
7
7
  import "./chunks/chunk-6PAVEFT3.js";
8
- import "./chunks/chunk-SZH7EJLD.js";
8
+ import "./chunks/chunk-46Z5E5EV.js";
9
+ import "./chunks/chunk-VKNVHEX3.js";
10
+ import "./chunks/chunk-HZAMGT5I.js";
11
+ import "./chunks/chunk-3HQU4OJO.js";
12
+ import "./chunks/chunk-XAQMU6OY.js";
13
+ import "./chunks/chunk-44ALJ4QG.js";
9
14
  import "./chunks/chunk-MHMMRCYC.js";
10
15
  import "./chunks/chunk-AUSNDQTJ.js";
11
16
  import "./chunks/chunk-CTVWDACF.js";
@@ -13,22 +18,31 @@ import "./chunks/chunk-3R3AANOR.js";
13
18
  import "./chunks/chunk-OV6IHKO6.js";
14
19
  import "./chunks/chunk-XVOSKJE2.js";
15
20
  import "./chunks/chunk-C5OWC2TL.js";
16
- import "./chunks/chunk-IVRQ4BXL.js";
17
- import "./chunks/chunk-D3ANYGMC.js";
21
+ import "./chunks/chunk-PH63PLPZ.js";
18
22
  import "./chunks/chunk-CHYGPFVM.js";
19
- import "./chunks/chunk-46Z5E5EV.js";
20
23
  import "./chunks/chunk-6O77NL2S.js";
21
24
  import {
22
25
  createBoundedRegexProvider
23
- } from "./chunks/chunk-NR3EM4LS.js";
26
+ } from "./chunks/chunk-FZE4HW6G.js";
24
27
  import "./chunks/chunk-J42RIHHJ.js";
25
- import "./chunks/chunk-ICFDYV64.js";
28
+ import "./chunks/chunk-7R5BDCG7.js";
29
+ import "./chunks/chunk-55YJASTN.js";
30
+ import "./chunks/chunk-4BSJLKNM.js";
31
+ import "./chunks/chunk-DQP3VHSB.js";
32
+ import "./chunks/chunk-GEG3BWGE.js";
33
+ import "./chunks/chunk-VSAJ4OTM.js";
34
+ import "./chunks/chunk-D3ANYGMC.js";
26
35
  import "./chunks/chunk-VTH3MLDU.js";
27
36
  import "./chunks/chunk-NZQXYWA3.js";
28
37
  import "./chunks/chunk-74GHTNJA.js";
29
- import "./chunks/chunk-7R5BDCG7.js";
30
- import "./chunks/chunk-IWDICZVK.js";
38
+ import "./chunks/chunk-QGUV42T5.js";
39
+ import "./chunks/chunk-4D4N7IU2.js";
40
+ import "./chunks/chunk-HBCN24ZA.js";
41
+ import "./chunks/chunk-R3NAKOED.js";
42
+ import "./chunks/chunk-7ZBU7KYV.js";
43
+ import "./chunks/chunk-ZVD5IS4V.js";
31
44
  import "./chunks/chunk-E7OYNDGL.js";
45
+ import "./chunks/chunk-IWDICZVK.js";
32
46
  import {
33
47
  init_platform
34
48
  } from "./chunks/chunk-B7TAL7S5.js";
@@ -0,0 +1,48 @@
1
+ import {
2
+ Shell,
3
+ createSearchCommands
4
+ } from "./chunks/chunk-SHEMU2Z7.js";
5
+ import "./chunks/chunk-TFIBK2GI.js";
6
+ import "./chunks/chunk-3NDIFSNM.js";
7
+ import "./chunks/chunk-44ALJ4QG.js";
8
+ import "./chunks/chunk-MHMMRCYC.js";
9
+ import "./chunks/chunk-AUSNDQTJ.js";
10
+ import "./chunks/chunk-CTVWDACF.js";
11
+ import "./chunks/chunk-3R3AANOR.js";
12
+ import "./chunks/chunk-OV6IHKO6.js";
13
+ import "./chunks/chunk-XVOSKJE2.js";
14
+ import "./chunks/chunk-C5OWC2TL.js";
15
+ import "./chunks/chunk-PH63PLPZ.js";
16
+ import "./chunks/chunk-CHYGPFVM.js";
17
+ import "./chunks/chunk-6O77NL2S.js";
18
+ import {
19
+ createBoundedRegexProvider
20
+ } from "./chunks/chunk-FZE4HW6G.js";
21
+ import "./chunks/chunk-BJA5XNP6.js";
22
+ import "./chunks/chunk-J42RIHHJ.js";
23
+ import "./chunks/chunk-I5HZ4FGE.js";
24
+ import "./chunks/chunk-7R5BDCG7.js";
25
+ import "./chunks/chunk-55YJASTN.js";
26
+ import "./chunks/chunk-4BSJLKNM.js";
27
+ import "./chunks/chunk-DQP3VHSB.js";
28
+ import "./chunks/chunk-GEG3BWGE.js";
29
+ import "./chunks/chunk-VSAJ4OTM.js";
30
+ import "./chunks/chunk-D3ANYGMC.js";
31
+ import "./chunks/chunk-VTH3MLDU.js";
32
+ import "./chunks/chunk-NZQXYWA3.js";
33
+ import "./chunks/chunk-74GHTNJA.js";
34
+ import "./chunks/chunk-QGUV42T5.js";
35
+ import "./chunks/chunk-ZVD5IS4V.js";
36
+ import "./chunks/chunk-E7OYNDGL.js";
37
+ import "./chunks/chunk-IWDICZVK.js";
38
+ import {
39
+ init_platform
40
+ } from "./chunks/chunk-B7TAL7S5.js";
41
+
42
+ // packages/safe-bash/src/search.ts
43
+ init_platform();
44
+ export {
45
+ Shell,
46
+ createBoundedRegexProvider,
47
+ createSearchCommands
48
+ };
@@ -471,15 +471,6 @@ export declare class Runtime {
471
471
  finishShell(state: State, io: IO, status: number): Promise<number>;
472
472
  private releaseExtensions;
473
473
  private finishReturn;
474
- tryRunFastConstEchoBatch<T extends {
475
- unit: {
476
- script: Script;
477
- next: number;
478
- };
479
- nextCached?: T | undefined;
480
- locale: boolean;
481
- unitsCharged: number;
482
- }>(entryCachedUnit: T, sourceLength: number, state: State, io: IO): T | undefined;
483
474
  private tryRunCachedSyncForScript;
484
475
  runUnit(script: Script, state: State, io: IO): {
485
476
  exitCode: number;
@@ -7446,282 +7446,6 @@ export class Runtime {
7446
7446
  }
7447
7447
  }
7448
7448
  }
7449
- tryRunFastConstEchoBatch(entryCachedUnit, sourceLength, state, io) {
7450
- if (state.noexec)
7451
- return undefined;
7452
- let leadingMkdirUnit;
7453
- let leadingMkdirPaths;
7454
- let firstCachedUnit = entryCachedUnit;
7455
- let firstCc = firstCachedUnit.unit.script._fastConstEcho;
7456
- if (!firstCc) {
7457
- const nextU = entryCachedUnit.nextCached;
7458
- if (!nextU || entryCachedUnit.locale !== false || nextU.locale !== false || (entryCachedUnit.unit.script.warnings && entryCachedUnit.unit.script.warnings.length > 0))
7459
- return undefined;
7460
- firstCc = nextU.unit.script._fastConstEcho;
7461
- if (!firstCc)
7462
- return undefined;
7463
- const mScript = entryCachedUnit.unit.script;
7464
- let mPaths = mScript._cachedMkdirPPaths;
7465
- if (mPaths === undefined) {
7466
- mPaths = null;
7467
- 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) {
7468
- const mCmd = mScript.lists[0].pipelines[0].commands[0];
7469
- if (mCmd.kind === "simple" && mCmd.redirects.length === 0 && mCmd.words.length >= 3 && mCmd.words[0].plain === "mkdir" && mCmd.words[1].plain === "-p") {
7470
- const arr = [];
7471
- let ok = true;
7472
- for (let wi = 2; wi < mCmd.words.length; wi++) {
7473
- const wp = mCmd.words[wi].plain;
7474
- if (!wp || !isCleanAbsolutePath(wp) || wp === "/" || wp === "/dev" || wp.startsWith("/dev/")) {
7475
- ok = false;
7476
- break;
7477
- }
7478
- arr.push(wp);
7479
- }
7480
- if (ok)
7481
- mPaths = arr;
7482
- }
7483
- }
7484
- mScript._cachedMkdirPPaths = mPaths;
7485
- }
7486
- if (!mPaths)
7487
- return undefined;
7488
- leadingMkdirUnit = entryCachedUnit;
7489
- leadingMkdirPaths = mPaths;
7490
- firstCachedUnit = nextU;
7491
- }
7492
- if (this.middleware.length > 0 || io.terminal !== undefined || io.asyncDefaultInput !== undefined || io.admittedHandles !== undefined || (this._fileWrites !== undefined && 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))) {
7493
- return undefined;
7494
- }
7495
- const monitor = ensureStateMonitor(state, this.budget, io[invocationScope]);
7496
- const rawState = monitor.raw;
7497
- 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")) {
7498
- return undefined;
7499
- }
7500
- const def = this.commands.get("echo");
7501
- if (!def || !defaultEchoExecutors.has(def.execute))
7502
- return undefined;
7503
- const store = monitor.store;
7504
- const existing = store?.get("PIPESTATUS");
7505
- const psTarget = existing ? "indexed" : pipelineStatusTarget(rawState);
7506
- if ((psTarget !== "indexed" && psTarget !== "absent") || store?.watches.has("PIPESTATUS") || monitor.hasOverlay("PIPESTATUS"))
7507
- return undefined;
7508
- if (existing && (existing.associative || existing.values.size !== 1 || existing.maximum !== 0))
7509
- return undefined;
7510
- const elem0 = existing?.values.get(0);
7511
- if (existing && (!elem0 || elem0.text.bytes !== 1 || existing.references !== 1 || elem0.text.references !== 1))
7512
- return undefined;
7513
- const byteLength0 = firstCc.encoded.byteLength;
7514
- 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)) {
7515
- return undefined;
7516
- }
7517
- const umask = rawState.umask ?? 0o022;
7518
- if (leadingMkdirUnit !== undefined && leadingMkdirPaths !== undefined) {
7519
- if ((umask & 0o300) !== 0 || (this._outputFiles !== undefined && this._outputFiles.size > 0) || hasShellFunction(rawState, "mkdir") || rawState.extensions?.builtins.has("mkdir"))
7520
- return undefined;
7521
- const mkdirDef = this.commands.get("mkdir");
7522
- if (!mkdirDef || !defaultMkdirExecutors.has(mkdirDef.execute))
7523
- return undefined;
7524
- const dirMode = 0o777 & ~umask;
7525
- try {
7526
- for (let mi = 0; mi < leadingMkdirPaths.length; mi++) {
7527
- const mp = leadingMkdirPaths[mi];
7528
- if (!tryMkdirMemorySync(this.backingFs, mp, true, dirMode, this.commandSignal, firstCc.dirPrefix.startsWith(mp) && firstCc.dirPrefix.length === mp.length + 1 ? firstCc.dirPrefix : undefined))
7529
- return undefined;
7530
- this.budget.fileSystemOperation();
7531
- }
7532
- }
7533
- catch {
7534
- this.signal.throwIfAborted();
7535
- return undefined;
7536
- }
7537
- this.budget.commands++;
7538
- this.budget.parsing.admit(firstCachedUnit.unitsCharged);
7539
- }
7540
- const mode = 0o666 & ~umask;
7541
- try {
7542
- if (!tryWriteMemoryFileInDirSync(this.backingFs, firstCc.dirPrefix, firstCc.fileName, firstCc.encoded, firstCc.append, mode, this.commandSignal))
7543
- return undefined;
7544
- }
7545
- catch {
7546
- this.signal.throwIfAborted();
7547
- return undefined;
7548
- }
7549
- this.budget.tick();
7550
- this.budget.fileSystemOperation();
7551
- this.budget.bytes += byteLength0;
7552
- let lastArg = firstCc.arg0;
7553
- let cur = firstCachedUnit;
7554
- const vars = rawState.variables;
7555
- const curLocale = (vars.LC_ALL || vars.LC_CTYPE || vars.LANG) ? byteLocale(vars) : false;
7556
- const mem = this.backingFs;
7557
- let deadRmTarget;
7558
- let deadRmTargetLen = 0;
7559
- const rmDef = this.commands.get("rm");
7560
- if (mem.symlinkCount === 0 && curLocale === false && rmDef && defaultRmExecutors.has(rmDef.execute) && !hasShellFunction(rawState, "rm") && !rawState.extensions?.builtins.has("rm")) {
7561
- const cachedCc = firstCc;
7562
- let target = cachedCc._cachedRmTarget;
7563
- let scanCount = cachedCc._cachedScanCount ?? 0;
7564
- if (target === undefined) {
7565
- let scan = firstCachedUnit;
7566
- scanCount = 1;
7567
- while (scan.nextCached !== undefined && scan.nextCached.locale === false && (!scan.nextCached.unit.script.warnings || scan.nextCached.unit.script.warnings.length === 0) && scan.nextCached.unit.script._fastConstEcho !== undefined) {
7568
- scan = scan.nextCached;
7569
- scanCount++;
7570
- }
7571
- target = null;
7572
- const after = scan.nextCached;
7573
- if (after !== undefined && after.locale === false && (!after.unit.script.warnings || after.unit.script.warnings.length === 0) && after.unit.script.lists.length === 1) {
7574
- const list0 = after.unit.script.lists[0];
7575
- if (!list0.terminator && list0.pipelines.length === 1 && !list0.pipelines[0].negate && list0.pipelines[0].commands.length === 1) {
7576
- const cmd0 = list0.pipelines[0].commands[0];
7577
- 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")) {
7578
- const t = cmd0.words[2].plain;
7579
- if (t && t.length > 1 && t.charCodeAt(0) === 47 && t.charCodeAt(t.length - 1) !== 47 && !t.includes("/."))
7580
- target = t;
7581
- }
7582
- }
7583
- }
7584
- cachedCc._cachedRmTarget = target;
7585
- cachedCc._cachedScanCount = scanCount;
7586
- }
7587
- if (target !== null && this.budget.commands + scanCount + 1 <= this.budget.maxCommandsSmi && tryGetMemoryDirectoryEntryNamesSync(this.backingFs, target)?.size === 0) {
7588
- deadRmTarget = target;
7589
- deadRmTargetLen = target.length;
7590
- }
7591
- }
7592
- const cachedBatchPlan = deadRmTarget !== undefined ? firstCc._cachedEchoBatch : undefined;
7593
- if (cachedBatchPlan !== undefined && 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) {
7594
- this.budget.parsing.admit(cachedBatchPlan.totalUnitsCharged);
7595
- try {
7596
- mem.writeMemoryFilesInDirBatchFast(firstCc.fileName, firstCc.dirPrefix, cachedBatchPlan.fileNames, cachedBatchPlan.nameHashes, cachedBatchPlan.payloads, cachedBatchPlan.totalNameBytes, cachedBatchPlan.payloadBytesSum, mode);
7597
- this.budget.commands += cachedBatchPlan.totalCount;
7598
- this.budget._fileSystemOperations += cachedBatchPlan.totalCount;
7599
- this.budget.bytes += cachedBatchPlan.totalBytes;
7600
- lastArg = cachedBatchPlan.lastArg;
7601
- cur = cachedBatchPlan.endUnit;
7602
- }
7603
- catch {
7604
- this.signal.throwIfAborted();
7605
- }
7606
- }
7607
- if (cur !== cachedBatchPlan?.endUnit && cur.unit.next < sourceLength && mem.symlinkCount === 0 && !this.signal.aborted) {
7608
- const buildBatchStart = cur === firstCachedUnit && deadRmTarget !== undefined && cachedBatchPlan === undefined;
7609
- let bTotalCount = 0;
7610
- let bTotalBytes = 0;
7611
- let bTotalUnits = 0;
7612
- let bTotalNameBytes = 0;
7613
- let bPayloadBytesSum = 0;
7614
- let bCanCache = buildBatchStart && !firstCc.append;
7615
- const bFileNames = bCanCache ? [] : undefined;
7616
- const bHashes = bCanCache ? [] : undefined;
7617
- const bPayloads = bCanCache ? [] : undefined;
7618
- const bSeenNames = bCanCache ? new Set([firstCc.fileName]) : undefined;
7619
- while (cur.unit.next < sourceLength && mem.symlinkCount === 0 && !this.signal.aborted) {
7620
- const next = cur.nextCached;
7621
- if (!next || next.locale !== curLocale || (next.unit.script.warnings && next.unit.script.warnings.length > 0))
7622
- break;
7623
- const nextCc = next.unit.script._fastConstEcho;
7624
- if (!nextCc)
7625
- break;
7626
- const bLen = nextCc.encoded.byteLength;
7627
- if (this.budget.bytes + bLen > this.budget.maxOutputBytesSmi || this.budget._fileSystemOperations + 1 > this.budget.maxFileSystemOperationsSmi || this.budget.commands + 1 > this.budget.maxCommandsSmi) {
7628
- break;
7629
- }
7630
- this.budget.parsing.admit(next.unitsCharged);
7631
- if (!(deadRmTarget !== undefined && nextCc.dirPrefix.length === deadRmTargetLen + 1 && nextCc.dirPrefix.charCodeAt(deadRmTargetLen) === 47 && nextCc.dirPrefix.startsWith(deadRmTarget))) {
7632
- let nameHash = nextCc._nameHash;
7633
- if (nameHash === undefined) {
7634
- const fn = nextCc.fileName;
7635
- let h = 5381;
7636
- for (let ci = 0; ci < fn.length; ci++)
7637
- h = (((h & 0x1fffff) * 33) ^ fn.charCodeAt(ci)) & 0x3fffffff;
7638
- nextCc._nameHash = nameHash = h;
7639
- }
7640
- try {
7641
- mem.writeMemoryFileInDirFast(nextCc.dirPrefix, nextCc.fileName, nextCc.encoded, nextCc.append, mode, nameHash);
7642
- }
7643
- catch {
7644
- this.signal.throwIfAborted();
7645
- break;
7646
- }
7647
- }
7648
- if (bCanCache) {
7649
- const isDeadRm = deadRmTarget !== undefined && nextCc.dirPrefix.length === deadRmTargetLen + 1 && nextCc.dirPrefix.charCodeAt(deadRmTargetLen) === 47 && nextCc.dirPrefix.startsWith(deadRmTarget);
7650
- if (isDeadRm) {
7651
- bTotalCount++;
7652
- bTotalBytes += bLen;
7653
- bTotalUnits += next.unitsCharged;
7654
- }
7655
- else if (!nextCc.append && nextCc.dirPrefix === firstCc.dirPrefix && nextCc.fileName.length <= 85 && !bSeenNames.has(nextCc.fileName)) {
7656
- bSeenNames.add(nextCc.fileName);
7657
- bFileNames.push(nextCc.fileName);
7658
- bHashes.push(nextCc._nameHash);
7659
- bPayloads.push(nextCc.encoded);
7660
- bTotalNameBytes += nextCc.fileName.length * 2;
7661
- bPayloadBytesSum += bLen;
7662
- bTotalCount++;
7663
- bTotalBytes += bLen;
7664
- bTotalUnits += next.unitsCharged;
7665
- }
7666
- else
7667
- bCanCache = false;
7668
- }
7669
- this.budget.commands++;
7670
- this.budget._fileSystemOperations++;
7671
- this.budget.bytes += bLen;
7672
- lastArg = nextCc.arg0;
7673
- cur = next;
7674
- }
7675
- if (buildBatchStart) {
7676
- firstCc._cachedEchoBatch = bCanCache && bTotalCount > 0
7677
- ? {
7678
- endUnit: cur, totalCount: bTotalCount, totalBytes: bTotalBytes, totalUnitsCharged: bTotalUnits, lastArg, fileNames: bFileNames, nameHashes: new Int32Array(bHashes), payloads: bPayloads, totalNameBytes: bTotalNameBytes, payloadBytesSum: bPayloadBytesSum,
7679
- }
7680
- : null;
7681
- }
7682
- }
7683
- if (deadRmTarget !== undefined && cur.nextCached !== undefined && !this.signal.aborted && mem.symlinkCount === 0 && (this._outputFiles === undefined || this._outputFiles.size === 0) && !hasShellFunction(rawState, "rm") && !rawState.extensions?.builtins.has("rm")) {
7684
- const rmDef = this.commands.get("rm");
7685
- const rmUnit = cur.nextCached;
7686
- const rmCmd0 = rmUnit.unit.script.lists[0]?.pipelines[0]?.commands[0];
7687
- if (rmDef && defaultRmExecutors.has(rmDef.execute) && rmCmd0 && rmCmd0.kind === "simple" && rmCmd0.words[0]?.plain === "rm" && rmCmd0.words[2]?.plain === deadRmTarget) {
7688
- let rmOk = false;
7689
- try {
7690
- rmOk = tryRmRfMemorySync(this.backingFs, deadRmTarget, this.commandSignal);
7691
- }
7692
- catch {
7693
- this.signal.throwIfAborted();
7694
- }
7695
- if (rmOk) {
7696
- this.budget.parsing.admit(rmUnit.unitsCharged);
7697
- this.budget.commands++;
7698
- this.budget._fileSystemOperations++;
7699
- lastArg = deadRmTarget;
7700
- cur = rmUnit;
7701
- }
7702
- }
7703
- }
7704
- const restEpoch = monitor.chargeInternal(syncRestorationCharge, syncRestorationTickets).epoch;
7705
- rawState.substitutionStatus = 0;
7706
- if (rawState.variables._ !== undefined)
7707
- delete rawState.variables._;
7708
- rawState.lastArgument = lastArg;
7709
- if (io.assignmentDiagnosticContext)
7710
- io.assignmentDiagnosticContext.name = undefined;
7711
- if (!existing) {
7712
- monitor.lazyPipeStatus = singleStatusZero;
7713
- monitor.chargeInternal(syncPipeStatusCharge, syncPipeStatusTickets);
7714
- }
7715
- else {
7716
- elem0.text.shellValue = "0";
7717
- store.changed(monitor.chargeInternal(syncPipeStatusCharge, syncPipeStatusTickets), "PIPESTATUS");
7718
- }
7719
- rawState.status = 0;
7720
- monitor.epoch = restEpoch;
7721
- if (store)
7722
- store.epoch = restEpoch;
7723
- return cur;
7724
- }
7725
7449
  tryRunCachedSyncForScript(script, monitor, io) {
7726
7450
  const rawScript = script;
7727
7451
  let plan = rawScript._cachedSyncForScriptPlan;
@@ -7808,6 +7532,9 @@ export class Runtime {
7808
7532
  rawScript._cachedSyncForScriptPlan = plan;
7809
7533
  }
7810
7534
  const forPlan = plan.forCmd._cachedForPlan;
7535
+ // Only integer registers can skip unquoted field splitting and globbing.
7536
+ if (plan.echoVar !== undefined && (!forPlan.touchedIntNamesList.includes(plan.echoVar) || forPlan.touchedIntNamesList.includes("IFS") || (rawState.variables.IFS !== undefined && rawState.variables.IFS !== " \t\n") || plan.initAssigns.some(assignment => assignment.name === "IFS")))
7537
+ return undefined;
7811
7538
  const fastSyncSink = plan.echoVar !== undefined
7812
7539
  ? ((io.stdout instanceof BudgetedSyncSink && io.stdout.write === BudgetedSyncSink.prototype.write) || (io.stdout instanceof Capture && io.stdout.write === Capture.prototype.write) ? io.stdout : undefined)
7813
7540
  : undefined;
@@ -7815,6 +7542,10 @@ export class Runtime {
7815
7542
  const def = this.commands.get("echo");
7816
7543
  if (!fastSyncSink || !def || !defaultEchoExecutors.has(def.execute) || hasShellFunction(rawState, "echo") || rawState.extensions?.builtins.has("echo") || (io.descriptors && io.descriptors.get(1)?.output !== io.stdout))
7817
7544
  return undefined;
7545
+ // Every signed SMI plus a newline fits in 12 bytes. Admit the bound before
7546
+ // speculative arithmetic; smaller allowances use ordinary execution.
7547
+ if (this.budget.maxOutputBytesSmi - this.budget.bytes < 12)
7548
+ return undefined;
7818
7549
  }
7819
7550
  const store = monitor.store;
7820
7551
  const existing = store?.get("PIPESTATUS");
@@ -7841,36 +7572,40 @@ export class Runtime {
7841
7572
  for (const assignment of plan.initAssigns)
7842
7573
  finalValues.set(assignment.name, assignment.strVal);
7843
7574
  const regNames = forPlan.regNames;
7844
- for (let r = 1; r < regNames.length; r++) {
7845
- const refName = regNames[r];
7846
- const parsed = fastSafeInt(finalValues.get(refName) ?? rawState.variables[refName], this.budget.parsing);
7847
- if (parsed === undefined)
7848
- return undefined;
7849
- sharedLoopIntRegs[r] = parsed | 0;
7850
- }
7851
- const { ok } = runIntForLoop(forPlan.fastLoopWords, forPlan.bodyStepCount, forPlan.intSteps, this.budget.parsing);
7852
- if (!ok)
7853
- return undefined;
7854
- for (let r = 0; r < regNames.length; r++)
7855
- finalValues.set(regNames[r], intToStr(sharedLoopIntRegs[r]));
7575
+ const savedParseBudget = this.budget.parsing.snapshot();
7576
+ let admitted = false;
7856
7577
  let lastArg = "";
7857
- if (plan.echoVar !== undefined) {
7858
- const echoVal = finalValues.get(plan.echoVar) ?? rawState.variables[plan.echoVar] ?? "";
7859
- const ifs = finalValues.get("IFS") ?? rawState.variables.IFS;
7860
- if (ifs !== undefined && ifs !== " \t\n")
7861
- return undefined;
7862
- if (echoVal.startsWith("-") || echoVal.includes("\0"))
7863
- return undefined;
7864
- const encoded = encodeRedirectTextWithNewlineToScratch(echoVal);
7865
- if (!encoded)
7866
- return undefined;
7867
- const bLen = encoded.byteLength;
7868
- if (this.budget.bytes + bLen > this.budget.maxOutputBytesSmi)
7869
- return undefined;
7870
- if (!fastSyncSink.writeSync(encoded))
7578
+ try {
7579
+ for (let r = 1; r < regNames.length; r++) {
7580
+ const refName = regNames[r];
7581
+ const parsed = fastSafeInt(finalValues.get(refName) ?? rawState.variables[refName], this.budget.parsing);
7582
+ if (parsed === undefined)
7583
+ return undefined;
7584
+ sharedLoopIntRegs[r] = parsed | 0;
7585
+ }
7586
+ const { ok } = runIntForLoop(forPlan.fastLoopWords, forPlan.bodyStepCount, forPlan.intSteps, this.budget.parsing);
7587
+ if (!ok)
7871
7588
  return undefined;
7872
- this.budget.bytes += bLen;
7873
- lastArg = echoVal;
7589
+ for (const name of forPlan.touchedIntNamesList)
7590
+ finalValues.set(name, intToStr(sharedLoopIntRegs[regNames.indexOf(name)]));
7591
+ if (plan.echoVar !== undefined) {
7592
+ const echoVal = finalValues.get(plan.echoVar);
7593
+ const encoded = encodeRedirectTextWithNewlineToScratch(echoVal);
7594
+ if (!encoded)
7595
+ return undefined;
7596
+ const bLen = encoded.byteLength;
7597
+ if (this.budget.bytes + bLen > this.budget.maxOutputBytesSmi)
7598
+ return undefined;
7599
+ if (!fastSyncSink.writeSync(encoded))
7600
+ return undefined;
7601
+ this.budget.bytes += bLen;
7602
+ lastArg = echoVal;
7603
+ }
7604
+ admitted = true;
7605
+ }
7606
+ finally {
7607
+ if (!admitted)
7608
+ this.budget.parsing.restore(savedParseBudget);
7874
7609
  }
7875
7610
  for (const [name, value] of finalValues)
7876
7611
  rawState.variables[name] = value;
@@ -15697,8 +15432,8 @@ export class Runtime {
15697
15432
  this.budget.tick();
15698
15433
  this.budget.iterations += wordCount;
15699
15434
  this.budget.commands += wordCount * forPlan.bodyStepCount;
15700
- for (let r = 0; r < regNames.length; r++) {
15701
- rawState.variables[regNames[r]] = intToStr(sharedLoopIntRegs[r]);
15435
+ for (const name of forPlan.touchedIntNamesList) {
15436
+ rawState.variables[name] = intToStr(sharedLoopIntRegs[regNames.indexOf(name)]);
15702
15437
  }
15703
15438
  const touchedList = forPlan.touchedIntNamesList;
15704
15439
  for (let t = 0; t < touchedList.length; t++) {
@@ -17082,8 +16817,8 @@ export class Runtime {
17082
16817
  rawState.status = 0;
17083
16818
  }
17084
16819
  runYieldCheckpoint(this.signal);
17085
- for (let r = 0; r < regNames.length; r++) {
17086
- rawState.variables[regNames[r]] = intToStr(sharedLoopIntRegs[r]);
16820
+ for (const name of forPlan.touchedIntNamesList) {
16821
+ rawState.variables[name] = intToStr(sharedLoopIntRegs[regNames.indexOf(name)]);
17087
16822
  }
17088
16823
  regNames.length = 0;
17089
16824
  }
@@ -1,5 +1,4 @@
1
1
  var _a;
2
- import { preverifyMemoryRgTree } from "../commands/search/rg-command.js";
3
2
  import { MemoryFileSystem } from "../fs/memory/index.js";
4
3
  function utf8ByteLength(str) {
5
4
  if (typeof globalThis.Buffer === "function")
@@ -598,27 +597,6 @@ export class Shell {
598
597
  let unit = firstCached.unit;
599
598
  let exitCode = 0;
600
599
  while (true) {
601
- if (currentCachedUnit !== undefined && (unit.script._fastConstEcho !== undefined || (currentCachedUnit.nextCached !== undefined && currentCachedUnit.nextCached.unit.script._fastConstEcho !== undefined))) {
602
- const batchEnd = runtime.tryRunFastConstEchoBatch(currentCachedUnit, source.length, currentState, io);
603
- if (batchEnd !== undefined) {
604
- currentCachedUnit = batchEnd;
605
- unit = batchEnd.unit;
606
- exitCode = 0;
607
- if (unit.next >= source.length)
608
- break;
609
- budget.signal.throwIfAborted();
610
- const vars = currentState.variables;
611
- const nextLocale = (vars.LC_ALL || vars.LC_CTYPE || vars.LANG) ? byteLocale(vars) : false;
612
- const nextCached = currentCachedUnit.locale === nextLocale ? currentCachedUnit.nextCached : undefined;
613
- if (nextCached !== undefined && (!nextCached.unit.script.warnings || nextCached.unit.script.warnings.length === 0)) {
614
- currentCachedUnit = nextCached;
615
- budget.parsing.admit(nextCached.unitsCharged);
616
- unit = nextCached.unit;
617
- continue;
618
- }
619
- return this.#continueWarmAsync(source, options, warm, sourceCache, undefined, unit, currentCachedUnit, exitCode);
620
- }
621
- }
622
600
  if (unit.script.lists.length) {
623
601
  const unitResult = runtime.runUnit(unit.script, currentState, io);
624
602
  if (unitResult instanceof Promise) {
@@ -1181,7 +1159,6 @@ export class Shell {
1181
1159
  stdout.enableScratchBuffer();
1182
1160
  stderr.enableScratchBuffer();
1183
1161
  void runtime.canFastMemoryRedirect;
1184
- preverifyMemoryRgTree(runtime.backingFs);
1185
1162
  this.#warmedInvocation = {
1186
1163
  budget,
1187
1164
  scope,
@@ -1,13 +1,15 @@
1
+ import {
2
+ cloudflareWorkerLimits
3
+ } from "./chunks/chunk-KDNSPLII.js";
1
4
  import {
2
5
  Shell,
3
6
  ShellLimitError,
4
7
  ShellSyntaxError,
5
- cloudflareWorkerLimits,
6
8
  parseShell
7
- } from "./chunks/chunk-7VNF5BFF.js";
9
+ } from "./chunks/chunk-SHEMU2Z7.js";
8
10
  import "./chunks/chunk-TFIBK2GI.js";
9
11
  import "./chunks/chunk-3NDIFSNM.js";
10
- import "./chunks/chunk-SZH7EJLD.js";
12
+ import "./chunks/chunk-44ALJ4QG.js";
11
13
  import "./chunks/chunk-MHMMRCYC.js";
12
14
  import "./chunks/chunk-AUSNDQTJ.js";
13
15
  import "./chunks/chunk-CTVWDACF.js";
@@ -15,24 +17,31 @@ import "./chunks/chunk-3R3AANOR.js";
15
17
  import "./chunks/chunk-OV6IHKO6.js";
16
18
  import "./chunks/chunk-XVOSKJE2.js";
17
19
  import "./chunks/chunk-C5OWC2TL.js";
18
- import "./chunks/chunk-IVRQ4BXL.js";
19
- import "./chunks/chunk-D3ANYGMC.js";
20
+ import "./chunks/chunk-PH63PLPZ.js";
20
21
  import "./chunks/chunk-CHYGPFVM.js";
21
22
  import "./chunks/chunk-6O77NL2S.js";
22
- import "./chunks/chunk-A7XEHALN.js";
23
+ import "./chunks/chunk-BJA5XNP6.js";
23
24
  import "./chunks/chunk-J42RIHHJ.js";
24
25
  import "./chunks/chunk-I5HZ4FGE.js";
25
- import "./chunks/chunk-VTH3MLDU.js";
26
- import "./chunks/chunk-NZQXYWA3.js";
27
- import "./chunks/chunk-74GHTNJA.js";
28
26
  import {
29
27
  CommandRegistry,
30
28
  commandRuntimeIdentity,
31
29
  createCommandArguments,
32
30
  getCommandArguments
33
31
  } from "./chunks/chunk-7R5BDCG7.js";
34
- import "./chunks/chunk-IWDICZVK.js";
32
+ import "./chunks/chunk-55YJASTN.js";
33
+ import "./chunks/chunk-4BSJLKNM.js";
34
+ import "./chunks/chunk-DQP3VHSB.js";
35
+ import "./chunks/chunk-GEG3BWGE.js";
36
+ import "./chunks/chunk-VSAJ4OTM.js";
37
+ import "./chunks/chunk-D3ANYGMC.js";
38
+ import "./chunks/chunk-VTH3MLDU.js";
39
+ import "./chunks/chunk-NZQXYWA3.js";
40
+ import "./chunks/chunk-74GHTNJA.js";
41
+ import "./chunks/chunk-QGUV42T5.js";
42
+ import "./chunks/chunk-ZVD5IS4V.js";
35
43
  import "./chunks/chunk-E7OYNDGL.js";
44
+ import "./chunks/chunk-IWDICZVK.js";
36
45
  import {
37
46
  init_platform
38
47
  } from "./chunks/chunk-B7TAL7S5.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createNlWithSettings
3
- } from "../safe-bash/command-chunks/chunk-EFANWIHL.js";
3
+ } from "../safe-bash/command-chunks/chunk-GY3BWK7K.js";
4
4
  import {
5
5
  init_buffer
6
6
  } from "../safe-bash/command-chunks/chunk-HX3SHTCE.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createNlWithSettings
3
- } from "../safe-bash/command-chunks/chunk-EFANWIHL.js";
3
+ } from "../safe-bash/command-chunks/chunk-GY3BWK7K.js";
4
4
  import "../safe-bash/command-chunks/chunk-HX3SHTCE.js";
5
5
  export {
6
6
  createNlWithSettings
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createRgCommand
3
- } from "../safe-bash/command-chunks/chunk-GLOZX57Y.js";
3
+ } from "../safe-bash/command-chunks/chunk-OQKC5ZU2.js";
4
4
  import {
5
5
  init_buffer
6
6
  } from "../safe-bash/command-chunks/chunk-HX3SHTCE.js";
@@ -1,6 +1,5 @@
1
1
  import { type CommandDefinition } from "../safe-bash-contracts/index.js";
2
2
  import { type SearchOptions } from "../safe-bash-search-engine/options.js";
3
3
  import { RegexExecutor } from "../safe-bash-regex-engine/execution/portable.js";
4
- export declare function preverifyMemoryRgTree(fastMem: unknown): void;
5
4
  export declare function clearRgFastRunnerPool(): void;
6
5
  export declare function createRgCommand(executor: RegexExecutor, options?: SearchOptions): CommandDefinition;