@poe-platform/safe-bash 0.1.821 → 0.1.823

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 (93) hide show
  1. package/dist/safe-bash/chunks/{chunk-HNT2MR4W.js → chunk-363QOIDR.js} +2 -1
  2. package/dist/safe-bash/chunks/chunk-AGHV53VF.js +42 -0
  3. package/dist/safe-bash/chunks/{chunk-VF3Q2V3E.js → chunk-RAFD5ZAH.js} +1 -1
  4. package/dist/safe-bash/chunks/{chunk-67QE3JLU.js → chunk-TZRVK3NU.js} +1 -1
  5. package/dist/safe-bash/chunks/{chunk-IRJS54AA.js → chunk-VWLQDZFF.js} +20 -12
  6. package/dist/safe-bash/chunks/{chunk-NAETSXBW.js → chunk-ZJAXMB5M.js} +1 -1
  7. package/dist/safe-bash/command-chunks/{chunk-QX3WKBLI.js → chunk-36FV6BAG.js} +5 -3
  8. package/dist/safe-bash/command-chunks/{chunk-ZSHXZ3XG.js → chunk-3EAZRKI4.js} +7 -7
  9. package/dist/safe-bash/command-chunks/chunk-64HIOP7Q.js +993 -0
  10. package/dist/safe-bash/command-chunks/{chunk-WOT2YXBT.js → chunk-7ZQVMPSB.js} +213 -42
  11. package/dist/safe-bash/command-chunks/{chunk-GRFJKJFN.js → chunk-AVSINNZ6.js} +233 -3
  12. package/dist/safe-bash/command-chunks/{chunk-BZLLQWRK.js → chunk-E5CDHXFA.js} +2 -2
  13. package/dist/safe-bash/command-chunks/{chunk-RHXV2KG5.js → chunk-EO3RYGUZ.js} +1010 -58
  14. package/dist/safe-bash/command-chunks/{chunk-MCUDSE4H.js → chunk-EWECMOQ5.js} +1 -1
  15. package/dist/safe-bash/command-chunks/{chunk-RTUDDAAY.js → chunk-O3KFOFJM.js} +1 -1
  16. package/dist/safe-bash/command-chunks/{chunk-SLD5A7IL.js → chunk-OU5UEUZN.js} +1 -1
  17. package/dist/safe-bash/command-chunks/{chunk-RKAL5VFP.js → chunk-PLVFJ6FF.js} +255 -616
  18. package/dist/safe-bash/command-chunks/{chunk-CJIFJ45R.js → chunk-QBCEAYQT.js} +1 -1
  19. package/dist/safe-bash/command-chunks/{chunk-4Q3HP33O.js → chunk-RGKHTSUY.js} +146 -123
  20. package/dist/safe-bash/command-chunks/{chunk-I7MEH76L.js → chunk-UYNJF5QN.js} +1 -1
  21. package/dist/safe-bash/command-chunks/{chunk-IAHYG67O.js → chunk-V5ZBRM5R.js} +3 -3
  22. package/dist/safe-bash/command-chunks/{chunk-R4NPYXQX.js → chunk-WDTWJFPK.js} +320 -67
  23. package/dist/safe-bash/command-chunks/{chunk-GQV5RWMN.js → chunk-ZFXHSFTU.js} +1 -1
  24. package/dist/safe-bash/command-chunks/{prompt-tool-debug-ERJKK3XZ.js → prompt-tool-debug-3POFNRYP.js} +5 -5
  25. package/dist/safe-bash/commands/bc/index.browser.js +1 -1
  26. package/dist/safe-bash/commands/llm/index.browser.js +3 -1
  27. package/dist/safe-bash/commands/llm/index.js +1 -1
  28. package/dist/safe-bash/commands/python/executor.browser.js +12 -1
  29. package/dist/safe-bash/commands/python/executor.js +1 -1
  30. package/dist/safe-bash/commands/python/index.browser.js +23 -1
  31. package/dist/safe-bash/commands/python/index.js +1 -1
  32. package/dist/safe-bash/core.browser.js +2 -2
  33. package/dist/safe-bash/full-core.browser.js +30 -6
  34. package/dist/safe-bash/plugins/index.browser.js +3 -3
  35. package/dist/safe-bash/registry-entry.browser.js +2 -2
  36. package/dist/safe-bash/search.browser.js +1 -1
  37. package/dist/safe-bash/shell/runtime.d.ts +2 -2
  38. package/dist/safe-bash/shell/runtime.js +11 -2
  39. package/dist/safe-bash/shell/sync-extra-evaluators.js +12 -12
  40. package/dist/safe-bash/shell-entry.browser.js +2 -2
  41. package/dist/safe-bash-command-llm/collections.js +24 -65
  42. package/dist/safe-bash-command-llm/command.js +6 -6
  43. package/dist/safe-bash-command-llm/fragment-loaders.d.ts +3 -2
  44. package/dist/safe-bash-command-llm/index.d.ts +3 -2
  45. package/dist/safe-bash-command-llm/index.js +10 -8
  46. package/dist/safe-bash-command-llm/loader-provider.d.ts +25 -0
  47. package/dist/safe-bash-command-llm/openai-sse.js +2 -2
  48. package/dist/safe-bash-command-llm/openai.js +4 -4
  49. package/dist/safe-bash-command-llm/providers/index.js +4 -4
  50. package/dist/safe-bash-command-llm/providers/openai.js +4 -4
  51. package/dist/safe-bash-command-llm/python-unicode.d.ts +2 -0
  52. package/dist/safe-bash-command-llm/templates.d.ts +7 -2
  53. package/dist/safe-bash-command-llm/types.d.ts +7 -1
  54. package/dist/safe-bash-command-mcp/index.browser.js +3 -0
  55. package/dist/safe-bash-command-mcp/index.js +3 -0
  56. package/dist/safe-bash-command-patch/index.js +2 -2
  57. package/dist/safe-bash-command-patch/patch-publication.js +1 -1
  58. package/dist/safe-bash-command-patch/patch.js +2 -2
  59. package/dist/safe-bash-command-python/build-backend.d.ts +51 -0
  60. package/dist/safe-bash-command-python/build-dependencies.d.ts +12 -0
  61. package/dist/safe-bash-command-python/build-environment.d.ts +3 -0
  62. package/dist/safe-bash-command-python/build-wheel.d.ts +8 -0
  63. package/dist/safe-bash-command-python/executor.d.ts +12 -2
  64. package/dist/safe-bash-command-python/executor.js +26 -4
  65. package/dist/safe-bash-command-python/index.js +26 -4
  66. package/dist/safe-bash-command-python/jspi.js +2 -2
  67. package/dist/safe-bash-command-python/llm-assets-node.js +1 -1
  68. package/dist/safe-bash-command-python/llm-fragment-loader.d.ts +6 -0
  69. package/dist/safe-bash-command-python/llm-functions-loader.d.ts +5 -1
  70. package/dist/safe-bash-command-python/llm-loader-discovery.d.ts +13 -0
  71. package/dist/safe-bash-command-python/llm-package-manager.d.ts +7 -0
  72. package/dist/safe-bash-command-python/llm-template-loader.d.ts +6 -0
  73. package/dist/safe-bash-command-python/manifest.d.ts +13 -0
  74. package/dist/safe-bash-command-python/provisioning.d.ts +33 -5
  75. package/dist/safe-bash-command-python/provisioning.js +1 -1
  76. package/dist/safe-bash-command-python/source-environment.d.ts +9 -0
  77. package/dist/safe-bash-command-python/source-snapshot.d.ts +8 -0
  78. package/dist/safe-bash-command-python/worker.js +3 -185
  79. package/dist/safe-bash-csv-engine/index.js +1 -1
  80. package/dist/safe-bash-csv-engine/python-iso2022.d.ts +21 -0
  81. package/dist/safe-bash-csv-engine/python-utf7.d.ts +18 -0
  82. package/dist/safe-bash-csv-engine/text-decoder.d.ts +2 -0
  83. package/dist/safe-bash-csv-engine/text-decoder.js +7 -3
  84. package/dist/safe-bash-zip-engine/index.js +1 -1
  85. package/dist/safe-bash-zip-engine/zip/repair.js +1 -1
  86. package/dist/safe-bash-zip-engine/zip/sfx.js +1 -1
  87. package/dist/safe-bash-zip-engine/zip-format.d.ts +3 -1
  88. package/dist/safe-bash-zip-engine/zip-format.js +1 -1
  89. package/dist/safe-playwright-cloudflare/shell-browser-resource.d.ts +1 -1
  90. package/dist/safe-playwright-cloudflare/shell-browser-resource.js +35 -20
  91. package/package.json +3 -3
  92. package/dist/safe-bash/chunks/chunk-PSD2RSOS.js +0 -31
  93. package/dist/safe-bash/command-chunks/chunk-5EFNQ6FY.js +0 -458
@@ -1,8 +1,9 @@
1
1
  // packages/safe-bash/src/commands/llm/index.ts
2
- import { LlmCancelToolCall, createElevenLabsProvider, createLlmCommand, createLlmCommands, createLlmConfiguration, createLlmFragmentLoaders, createLlmFragmentSource, createLlmInputBudget, createLlmService, createLlmSpool, createLlmTemplateStore, createLlmToolRegistry, createLlmUrlFragmentSource, createLlmUrlSource, createOpenAiProvider, encodeLlmBase64, evaluateLlmTemplate, executeLlmToolCalls, findExtractedRange, getLlmAttachmentUrlId, getLlmFragmentPrefix, getLlmModelAliases, llmCommands, llmReferenceVersion, llmTemplateUsesInput, loadLlmPluginFragments, openAiChatOptions, parseLlmSchemaDsl, resolveLlmSchemaInput, resolveLlmUrlAttachment, selectLlmModelByQuery, selectLlmTools, serializeLlmJsonString, serializeLlmJsonValue, serializeLlmTokenUsage, serializeOpenAiChatRequest, streamLlmToolChain, templateYaml, validateLlmTemplateParameters, validateModelOptions } from "../../safe-bash-command-llm/index.js";
2
+ import { LlmCancelToolCall, LlmLoaderLookupError, createElevenLabsProvider, createLlmCommand, createLlmCommands, createLlmConfiguration, createLlmFragmentLoaders, createLlmFragmentSource, createLlmInputBudget, createLlmService, createLlmSpool, createLlmTemplateStore, createLlmToolRegistry, createLlmUrlFragmentSource, createLlmUrlSource, createOpenAiProvider, encodeLlmBase64, evaluateLlmTemplate, executeLlmToolCalls, findExtractedRange, getLlmAttachmentUrlId, getLlmFragmentPrefix, getLlmModelAliases, llmCommands, llmReferenceVersion, llmTemplateUsesInput, loadLlmPluginFragments, openAiChatOptions, parseLlmSchemaDsl, resolveLlmSchemaInput, resolveLlmUrlAttachment, selectLlmModelByQuery, selectLlmTools, serializeLlmJsonString, serializeLlmJsonValue, serializeLlmTokenUsage, serializeOpenAiChatRequest, streamLlmToolChain, templateYaml, validateLlmTemplateParameters, validateModelOptions } from "../../safe-bash-command-llm/index.js";
3
3
 
4
4
  export {
5
5
  LlmCancelToolCall,
6
+ LlmLoaderLookupError,
6
7
  createElevenLabsProvider,
7
8
  createLlmCommand,
8
9
  createLlmCommands,
@@ -0,0 +1,42 @@
1
+ // packages/safe-bash/src/commands/python/index.ts
2
+ import { PythonFailure, PythonPackageConflictError, createPythonBuildBackend, createPythonBuildDependencies, createPythonBuildEnvironment, createPythonCommands, createPythonExecutorCommands, createPythonExecutorPool, createPythonHostBridge, createPythonJspiAssets, createPythonJspiExecutor, createPythonJspiNativeCall, createPythonJspiStatResult, createPythonJspiTrampoline, createPythonLlmCapability, createPythonLlmFragmentLoader, createPythonLlmLoaderDiscovery, createPythonLlmLoaderProvider, createPythonLlmPackageManager, createPythonLlmTemplateLoader, createPythonLlmToolLoader, createPythonPackageCache, createPythonPackageEnvironment, createPythonPackageManifestStore, createPythonShellCapability, createPythonSourcePackageEnvironment, createPythonSourceSnapshot, inspectPythonCapabilities, installPythonLlmDependencies, installPythonLlmPackages, publishPythonBuildWheel, pythonCommands, pythonDocumentPackages, pythonExecutorCommands, pythonHostFailureCode, pythonLlmDependencies, pythonLlmPackages } from "../../safe-bash-command-python/index.js";
3
+
4
+ export {
5
+ PythonFailure,
6
+ PythonPackageConflictError,
7
+ createPythonBuildBackend,
8
+ createPythonBuildDependencies,
9
+ createPythonBuildEnvironment,
10
+ createPythonCommands,
11
+ createPythonExecutorCommands,
12
+ createPythonExecutorPool,
13
+ createPythonHostBridge,
14
+ createPythonJspiAssets,
15
+ createPythonJspiExecutor,
16
+ createPythonJspiNativeCall,
17
+ createPythonJspiStatResult,
18
+ createPythonJspiTrampoline,
19
+ createPythonLlmCapability,
20
+ createPythonLlmFragmentLoader,
21
+ createPythonLlmLoaderDiscovery,
22
+ createPythonLlmLoaderProvider,
23
+ createPythonLlmPackageManager,
24
+ createPythonLlmTemplateLoader,
25
+ createPythonLlmToolLoader,
26
+ createPythonPackageCache,
27
+ createPythonPackageEnvironment,
28
+ createPythonPackageManifestStore,
29
+ createPythonShellCapability,
30
+ createPythonSourcePackageEnvironment,
31
+ createPythonSourceSnapshot,
32
+ inspectPythonCapabilities,
33
+ installPythonLlmDependencies,
34
+ installPythonLlmPackages,
35
+ publishPythonBuildWheel,
36
+ pythonCommands,
37
+ pythonDocumentPackages,
38
+ pythonExecutorCommands,
39
+ pythonHostFailureCode,
40
+ pythonLlmDependencies,
41
+ pythonLlmPackages
42
+ };
@@ -80,7 +80,7 @@ import {
80
80
  wcDisplayWidth,
81
81
  writeFileOutput,
82
82
  yieldTurn
83
- } from "./chunk-IRJS54AA.js";
83
+ } from "./chunk-VWLQDZFF.js";
84
84
  import {
85
85
  compareByteArrays,
86
86
  compareCopyIdentity,
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-GI7OALXO.js";
4
4
  import {
5
5
  yieldTurn
6
- } from "./chunk-IRJS54AA.js";
6
+ } from "./chunk-VWLQDZFF.js";
7
7
  import {
8
8
  latin1Text
9
9
  } from "./chunk-N4CQ5E3G.js";
@@ -14405,10 +14405,16 @@ var BudgetedPipeStageSink = class {
14405
14405
  }
14406
14406
  }
14407
14407
  writeSync(chunk) {
14408
- this.budget.assertPipelineInput(chunk.byteLength);
14409
- this.budget.bytes += chunk.byteLength;
14408
+ if (!this.canWriteSync(chunk.byteLength)) return false;
14409
+ this.signal.throwIfAborted();
14410
+ if (!(chunk instanceof Uint8Array)) throw new TypeError("Shell output must be Uint8Array");
14411
+ const budget = this.budget;
14412
+ if (chunk.byteLength > budget.limits.maxOutputBytes - budget.bytes) budget.fail("maxOutputBytes");
14413
+ budget.assertPipelineInput(chunk.byteLength);
14414
+ budget.bytes += chunk.byteLength;
14410
14415
  this.writable.write(chunk);
14411
14416
  if (chunk.byteLength && this.written) this.written.add(this.index);
14417
+ return true;
14412
14418
  }
14413
14419
  write(chunk) {
14414
14420
  try {
@@ -29331,6 +29337,9 @@ function exportedVariablesView(rawState) {
29331
29337
  }
29332
29338
  var evalSyncFd = (...args) => syncCommandEvaluators.evalSyncFd?.(...args);
29333
29339
  var evalSyncRg = (...args) => syncCommandEvaluators.evalSyncRg?.(...args);
29340
+ function canWriteBuiltinOutput(budget, pipe, byteLength3) {
29341
+ return (!pipe || pipe.canWriteSync(byteLength3)) && (budget.bytes + byteLength3 <= budget.maxOutputBytesSmi || byteLength3 <= budget.limits.maxOutputBytes - budget.bytes);
29342
+ }
29334
29343
  var createFmtEngine = (...args) => syncCommandEvaluators.createFmtEngine(...args);
29335
29344
  var parseFmtArguments = (...args) => syncCommandEvaluators.parseFmtArguments(...args);
29336
29345
  var evalSyncCal = (...args) => syncCommandEvaluators.evalSyncCal?.(...args);
@@ -29484,11 +29493,13 @@ function initializeSyncPrototypes() {
29484
29493
  }
29485
29494
  });
29486
29495
  Object.assign(BudgetedPipeStageSink.prototype, {
29487
- canWriteSync() {
29496
+ canWriteSync(byteLength3 = 0) {
29488
29497
  if (this.signal.aborted) return false;
29489
29498
  const w = this.writable;
29490
29499
  const pipe = w._pipe;
29491
- return Boolean(w.open && pipe && !pipe.failed && !pipe.signal?.aborted && pipe.readerReferences && (!pipe.writes || pipe.writes.size === 0) && (pipe.availableBytes ?? 0) < (pipe.highWaterMark ?? 0));
29500
+ const avail = pipe?.availableBytes ?? 0;
29501
+ const hwm = pipe?.highWaterMark ?? 0;
29502
+ return Boolean(w.open && pipe && !pipe.failed && !pipe.signal?.aborted && pipe.readerReferences && (!pipe.writes || pipe.writes.size === 0) && (byteLength3 > 0 ? avail + byteLength3 <= hwm : avail < hwm));
29492
29503
  }
29493
29504
  });
29494
29505
  }
@@ -39051,7 +39062,7 @@ var syncExtraRuntimeMethods = {
39051
39062
  const encoded = disc.status === 0 ? encodeRedirectTextWithNewlineToScratch(disc.text) ?? fastSharedTextEncoder2.encode(`${disc.text}
39052
39063
  `) : void 0;
39053
39064
  const byteLength3 = encoded ? encoded.byteLength : 0;
39054
- if (byteLength3 === 0 || this.budget.bytes + byteLength3 <= this.budget.maxOutputBytesSmi || byteLength3 <= this.budget.limits.maxOutputBytes - this.budget.bytes) {
39065
+ if (byteLength3 === 0 || canWriteBuiltinOutput(this.budget, fastPipeSink, byteLength3)) {
39055
39066
  if (rawState.extensions && !rawState.extensions.eventDepth) publishCommandSpelling(rawState, commandSpelling(command));
39056
39067
  const restEpoch = monitor.chargeInternal(syncRestorationCharge, syncRestorationTickets).epoch;
39057
39068
  this.budget.tick();
@@ -39085,7 +39096,7 @@ var syncExtraRuntimeMethods = {
39085
39096
  const encoded = encodeRedirectTextWithNewlineToScratch(rawState.cwd) ?? fastSharedTextEncoder2.encode(`${rawState.cwd}
39086
39097
  `);
39087
39098
  const byteLength3 = encoded.byteLength;
39088
- if (this.budget.bytes + byteLength3 <= this.budget.maxOutputBytesSmi || byteLength3 <= this.budget.limits.maxOutputBytes - this.budget.bytes) {
39099
+ if (canWriteBuiltinOutput(this.budget, fastPipeSink, byteLength3)) {
39089
39100
  if (rawState.extensions && !rawState.extensions.eventDepth) publishCommandSpelling(rawState, commandSpelling(command));
39090
39101
  const restEpoch = monitor.chargeInternal(syncRestorationCharge, syncRestorationTickets).epoch;
39091
39102
  this.budget.tick();
@@ -39154,7 +39165,7 @@ var syncExtraRuntimeMethods = {
39154
39165
  const encoded = encodeRedirectTextWithNewlineToScratch(outText) ?? fastSharedTextEncoder2.encode(`${outText}
39155
39166
  `);
39156
39167
  const byteLength3 = encoded.byteLength;
39157
- if (this.budget.bytes + byteLength3 <= this.budget.maxOutputBytesSmi || byteLength3 <= this.budget.limits.maxOutputBytes - this.budget.bytes) {
39168
+ if (canWriteBuiltinOutput(this.budget, fastPipeSink, byteLength3)) {
39158
39169
  if (rawState.extensions && !rawState.extensions.eventDepth) publishCommandSpelling(rawState, commandSpelling(command));
39159
39170
  const restEpoch = monitor.chargeInternal(syncRestorationCharge, syncRestorationTickets).epoch;
39160
39171
  this.budget.tick();
@@ -39252,7 +39263,7 @@ var syncExtraRuntimeMethods = {
39252
39263
  if (preEncoded !== void 0 || formatted2 !== void 0) {
39253
39264
  const encoded = preEncoded ?? encodeRedirectTextToScratch(formatted2);
39254
39265
  const byteLength3 = encoded.byteLength;
39255
- if (this.budget.bytes + byteLength3 <= this.budget.maxOutputBytesSmi || byteLength3 <= this.budget.limits.maxOutputBytes - this.budget.bytes) {
39266
+ if (canWriteBuiltinOutput(this.budget, fastPipeSink, byteLength3)) {
39256
39267
  const restEpoch = monitor.chargeInternal(syncRestorationCharge, syncRestorationTickets).epoch;
39257
39268
  this.budget.tick();
39258
39269
  if (fastSyncSink) {
@@ -44747,15 +44758,12 @@ ${s1}
44747
44758
  }
44748
44759
  const chunk = fastSharedTextEncoder2.encode(this._syncStdoutBatch);
44749
44760
  this._syncStdoutBatch = "";
44750
- if (io.stdout instanceof BudgetedSyncSink && io.stdout.write === BudgetedSyncSink.prototype.write || io.stdout instanceof Capture && io.stdout.write === Capture.prototype.write) {
44761
+ if (io.stdout instanceof BudgetedSyncSink && io.stdout.write === BudgetedSyncSink.prototype.write || io.stdout instanceof Capture && io.stdout.write === Capture.prototype.write || io.stdout instanceof BudgetedPipeStageSink && io.stdout.write === BudgetedPipeStageSink.prototype.write && io.stdout.canWriteSync(chunk.byteLength)) {
44751
44762
  if (io.stdout.budget !== this.budget) {
44752
44763
  if (chunk.byteLength > this.budget.limits.maxOutputBytes - this.budget.bytes) this.budget.fail("maxOutputBytes");
44753
44764
  this.budget.bytes += chunk.byteLength;
44754
44765
  }
44755
44766
  io.stdout.writeSync(chunk);
44756
- } else if (io.stdout instanceof BudgetedPipeStageSink && io.stdout.canWriteSync()) {
44757
- if (chunk.byteLength > this.budget.limits.maxOutputBytes - this.budget.bytes) this.budget.fail("maxOutputBytes");
44758
- io.stdout.writeSync(chunk);
44759
44767
  } else {
44760
44768
  if (budgetedSinks.get(io.stdout)?.budget !== this.budget) {
44761
44769
  if (chunk.byteLength > this.budget.limits.maxOutputBytes - this.budget.bytes) this.budget.fail("maxOutputBytes");
@@ -5,7 +5,7 @@ import {
5
5
  composeAgentCommands,
6
6
  createAgentCommandPlugin,
7
7
  createRegexExecutors
8
- } from "./chunk-VF3Q2V3E.js";
8
+ } from "./chunk-RAFD5ZAH.js";
9
9
  import {
10
10
  createOpCommands
11
11
  } from "./chunk-UKMP6ZT5.js";
@@ -1,5 +1,5 @@
1
1
  // packages/safe-bash-command-llm/src/request-source.ts
2
- function waitForSource(start, signal) {
2
+ function waitForSource(start, signal, late) {
3
3
  signal.throwIfAborted();
4
4
  return new Promise((resolve, reject) => {
5
5
  const abort = () => {
@@ -13,8 +13,10 @@ function waitForSource(start, signal) {
13
13
  }).then(
14
14
  (value) => {
15
15
  signal.removeEventListener("abort", abort);
16
- if (signal.aborted) reject(signal.reason);
17
- else resolve(value);
16
+ if (signal.aborted) {
17
+ if (late) void Promise.resolve().then(() => late(value)).catch(() => void 0);
18
+ reject(signal.reason);
19
+ } else resolve(value);
18
20
  },
19
21
  (error) => {
20
22
  signal.removeEventListener("abort", abort);
@@ -66,10 +66,10 @@ async function exact(source, offset, length, signal) {
66
66
  async function readZipSpan(source, index, signal) {
67
67
  return decode(await exact(source, index * recordBytes, recordBytes, signal), 0);
68
68
  }
69
- async function validateZipSpans(index, count, factory, signal, chunkSize, initial, centralStart) {
69
+ async function validateZipSpans(index, count, factory, signal, chunkSize, initial, centralStart, allowUnreferencedData = false) {
70
70
  if (!count) {
71
71
  const start = initial ?? centralStart;
72
- if (start !== centralStart) fail("ZIP unreferenced local data is unsupported");
72
+ if (!allowUnreferencedData && start !== centralStart) fail("ZIP unreferenced local data is unsupported");
73
73
  return start;
74
74
  }
75
75
  const windowRecords = Math.max(1, Math.floor(Math.min(chunkSize, 65536) / recordBytes));
@@ -136,11 +136,11 @@ async function validateZipSpans(index, count, factory, signal, chunkSize, initia
136
136
  let covered = prefix;
137
137
  while (record) {
138
138
  signal.throwIfAborted();
139
- if (record.start !== covered) fail("ZIP overlapping spans, gaps or self-extracting prefix are unsupported");
139
+ if (record.start < covered || !allowUnreferencedData && record.start !== covered) fail("ZIP overlapping spans, gaps or self-extracting prefix are unsupported");
140
140
  covered = record.end;
141
141
  record = await sorted.next();
142
142
  }
143
- if (covered !== centralStart) fail("ZIP unreferenced local data is unsupported");
143
+ if (!allowUnreferencedData && covered !== centralStart) fail("ZIP unreferenced local data is unsupported");
144
144
  return prefix;
145
145
  } finally {
146
146
  try {
@@ -489,10 +489,10 @@ async function readZipArchive(input, limits, signal, profile = {}) {
489
489
  const prefix = profile.disks ? 4 : profile.prefix ? spans[0]?.start ?? reader.centralStart : 0;
490
490
  let covered = prefix;
491
491
  for (const span of spans) {
492
- if (span.start !== covered) fail2("ZIP overlapping spans, gaps or self-extracting prefix are unsupported");
492
+ if (span.start < covered || !profile.allowUnreferencedData && span.start !== covered) fail2("ZIP overlapping spans, gaps or self-extracting prefix are unsupported");
493
493
  covered = span.end;
494
494
  }
495
- if (covered !== reader.centralStart) fail2("ZIP unreferenced local data is unsupported");
495
+ if (!profile.allowUnreferencedData && covered !== reader.centralStart) fail2("ZIP unreferenced local data is unsupported");
496
496
  if (profile.grow) for (const entry of entries) {
497
497
  const start = entry.growStart, length = entry.growLength;
498
498
  zipGrowRecords.set(entry, input instanceof Uint8Array ? await reader.bytes.subarray(start, start + length) : { length, version: entry.growVersion, source: () => reader.bytes.stream(start, length) });
@@ -507,7 +507,7 @@ async function readZipIndexedArchive(input, limits, signal, createSpool, profile
507
507
  try {
508
508
  for await (const record of scanZipDirectory(reader, limits, signal, profile)) await spool.append(encodeZipSpan(record));
509
509
  const index = await spool.finish();
510
- const prefix = await validateZipSpans(index, reader.members, createSpool, signal, reader.chunkSize, profile.disks ? 4 : profile.prefix ? void 0 : 0, reader.centralStart);
510
+ const prefix = await validateZipSpans(index, reader.members, createSpool, signal, reader.chunkSize, profile.disks ? 4 : profile.prefix ? void 0 : 0, reader.centralStart, profile.allowUnreferencedData);
511
511
  const entries = {
512
512
  length: reader.members,
513
513
  async get(position) {