@cortexkit/opencode-magic-context 0.41.2 → 0.41.3

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 (138) hide show
  1. package/README.md +9 -3
  2. package/dist/announcement-3c1vertn.js +14 -0
  3. package/dist/config/project-security.d.ts.map +1 -1
  4. package/dist/config/schema/magic-context.d.ts +756 -4
  5. package/dist/config/schema/magic-context.d.ts.map +1 -1
  6. package/dist/conflict-warning-hook-z5sd697e.js +16 -0
  7. package/dist/derive-budgets-901a0pk0.js +11 -0
  8. package/dist/features/magic-context/compartment-lease.d.ts +6 -0
  9. package/dist/features/magic-context/compartment-lease.d.ts.map +1 -1
  10. package/dist/features/magic-context/migrations.d.ts.map +1 -1
  11. package/dist/features/magic-context/storage-db.d.ts +18 -1
  12. package/dist/features/magic-context/storage-db.d.ts.map +1 -1
  13. package/dist/features/magic-context/storage-meta-persisted.d.ts +11 -12
  14. package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
  15. package/dist/features/magic-context/storage-meta.d.ts +1 -1
  16. package/dist/features/magic-context/storage-meta.d.ts.map +1 -1
  17. package/dist/features/magic-context/storage-subagent-invocations.d.ts +3 -2
  18. package/dist/features/magic-context/storage-subagent-invocations.d.ts.map +1 -1
  19. package/dist/features/magic-context/storage-tags.d.ts +6 -0
  20. package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
  21. package/dist/features/magic-context/storage.d.ts +2 -2
  22. package/dist/features/magic-context/storage.d.ts.map +1 -1
  23. package/dist/features/magic-context/subagent-token-capture.d.ts +2 -1
  24. package/dist/features/magic-context/subagent-token-capture.d.ts.map +1 -1
  25. package/dist/hooks/magic-context/compaction-marker-manager.d.ts +6 -1
  26. package/dist/hooks/magic-context/compaction-marker-manager.d.ts.map +1 -1
  27. package/dist/hooks/magic-context/compartment-runner.d.ts +2 -1
  28. package/dist/hooks/magic-context/compartment-runner.d.ts.map +1 -1
  29. package/dist/hooks/magic-context/hook.d.ts +4 -3
  30. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  31. package/dist/hooks/magic-context/inject-compartments.d.ts +6 -0
  32. package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
  33. package/dist/hooks/magic-context/module-state-sync.d.ts +2 -1
  34. package/dist/hooks/magic-context/module-state-sync.d.ts.map +1 -1
  35. package/dist/hooks/magic-context/module-transport.d.ts +11 -4
  36. package/dist/hooks/magic-context/module-transport.d.ts.map +1 -1
  37. package/dist/hooks/magic-context/module-wire.d.ts +6 -1
  38. package/dist/hooks/magic-context/module-wire.d.ts.map +1 -1
  39. package/dist/hooks/magic-context/read-session-db.d.ts +15 -0
  40. package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
  41. package/dist/hooks/magic-context/rust-mode-transform.d.ts +10 -0
  42. package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
  43. package/dist/hooks/magic-context/send-session-notification.d.ts +6 -0
  44. package/dist/hooks/magic-context/send-session-notification.d.ts.map +1 -1
  45. package/dist/hooks/magic-context/sentinel.d.ts +5 -16
  46. package/dist/hooks/magic-context/sentinel.d.ts.map +1 -1
  47. package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
  48. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +32 -0
  49. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  50. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  51. package/dist/{index-y1yr57fw.js → index-0bycg0np.js} +18 -18
  52. package/dist/{index-1yh8g550.js → index-22jkk6wg.js} +2 -15
  53. package/dist/{index-dmvy29z0.js → index-3wzdwt6p.js} +11 -15
  54. package/dist/{index-d1mxrd3p.js → index-7k55qm8a.js} +17 -12
  55. package/dist/{index-4x691bz5.js → index-dkv2dn46.js} +5 -2
  56. package/dist/{index-cvda5jb3.js → index-dn1rwpd8.js} +11 -11
  57. package/dist/{index-rgdqj8nj.js → index-e7vx3byk.js} +1 -1
  58. package/dist/{index-szf8w1p5.js → index-fmsr7v69.js} +2 -2
  59. package/dist/{index-d62ypazr.js → index-jdxxq8cz.js} +6 -11
  60. package/dist/{index-9j3tx8hy.js → index-may8skc8.js} +6 -25
  61. package/dist/{index-eq9wr75c.js → index-npx8vhmy.js} +57 -108
  62. package/dist/{index-zwjhba2r.js → index-q264erdp.js} +122 -41
  63. package/dist/{index-b9j85d29.js → index-raatkvw5.js} +49 -11
  64. package/dist/{index-9xexf8s7.js → index-rn7gafjr.js} +1 -9
  65. package/dist/index-v6t0tg85.js +13 -0
  66. package/dist/{index-j8r0ejb3.js → index-vmmjdpc0.js} +1694 -11167
  67. package/dist/index.d.ts.map +1 -1
  68. package/dist/index.js +2149 -1799
  69. package/dist/model-resolution-dxatzjde.js +12 -0
  70. package/dist/{index-dynqfgx1.js → module-asyncify-2EFITU5U-rkqjhjxd.js} +69 -8
  71. package/dist/plugin/boot-deadline.d.ts +47 -0
  72. package/dist/plugin/boot-deadline.d.ts.map +1 -0
  73. package/dist/plugin/conflict-warning-hook.d.ts +10 -0
  74. package/dist/plugin/conflict-warning-hook.d.ts.map +1 -1
  75. package/dist/plugin/hooks/create-session-hooks.d.ts +2 -0
  76. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  77. package/dist/plugin/messages-transform.d.ts.map +1 -1
  78. package/dist/prompt-context-5y5ms8f9.js +6 -0
  79. package/dist/recomp-orchestrator-f5m2wk74.js +19 -0
  80. package/dist/rpc-notifications-4amf6mf4.js +14 -0
  81. package/dist/{index-vnz6jvdc.js → safe-notification-target-q9z81zt3.js} +4 -3
  82. package/dist/send-session-notification-hdh02wy9.js +16 -0
  83. package/dist/shared/conflict-detector.d.ts +3 -1
  84. package/dist/shared/conflict-detector.d.ts.map +1 -1
  85. package/dist/shared/harness.d.ts +3 -3
  86. package/dist/shared/harness.d.ts.map +1 -1
  87. package/dist/shared/model-resolution.d.ts +3 -3
  88. package/dist/shared/model-resolution.d.ts.map +1 -1
  89. package/dist/shared/prompt-surface-runtime.d.ts +2 -2
  90. package/dist/shared/prompt-surface-runtime.d.ts.map +1 -1
  91. package/dist/shared/tag-transcript.d.ts.map +1 -1
  92. package/dist/shared/transcript.d.ts +2 -1
  93. package/dist/shared/transcript.d.ts.map +1 -1
  94. package/dist/storage-meta-session-3rxx9ekm.js +20 -0
  95. package/dist/task-config-hnv93r7p.js +9 -0
  96. package/dist/transformers-node-wasm.js +328 -328
  97. package/dist/transformers-web.js +72 -72
  98. package/dist/{transformers.node-b1wa0hgx.js → transformers.node-dpmf3wpx.js} +74 -74
  99. package/package.json +1 -1
  100. package/src/config/index.test.ts +28 -0
  101. package/src/config/project-security.hostile-matrix.test.ts +78 -9
  102. package/src/config/project-security.ts +4 -3
  103. package/src/config/schema/magic-context.test.ts +64 -0
  104. package/src/config/schema/magic-context.ts +100 -6
  105. package/src/shared/conflict-detector.test.ts +24 -0
  106. package/src/shared/conflict-detector.ts +25 -7
  107. package/src/shared/harness.ts +3 -3
  108. package/src/shared/model-resolution.test.ts +61 -0
  109. package/src/shared/model-resolution.ts +14 -5
  110. package/src/shared/prompt-surface-runtime.ts +3 -3
  111. package/src/shared/tag-transcript.ts +11 -0
  112. package/src/shared/transcript.ts +3 -1
  113. package/dist/announcement-3g9xg433.js +0 -18
  114. package/dist/conflict-warning-hook-rf17b6et.js +0 -17
  115. package/dist/derive-budgets-9q2d3r93.js +0 -14
  116. package/dist/emscripten-module-49k43zfy.js +0 -507
  117. package/dist/emscripten-module-ex4v0x4z.js +0 -606
  118. package/dist/emscripten-module-jfs3d1dq.js +0 -1536
  119. package/dist/emscripten-module-ss4g4spn.js +0 -4563
  120. package/dist/ffi-bbm9vkfa.js +0 -92
  121. package/dist/ffi-kb5r0x1j.js +0 -92
  122. package/dist/ffi-qnrt0y78.js +0 -80
  123. package/dist/ffi-yx2hpf4p.js +0 -80
  124. package/dist/index-8sseka65.js +0 -251
  125. package/dist/index-ss632za9.js +0 -77
  126. package/dist/model-resolution-6w6wzw18.js +0 -17
  127. package/dist/module-ES6BEMUI-1yjdz59c.js +0 -14
  128. package/dist/module-asyncify-2EFITU5U-fdkx4fhy.js +0 -9
  129. package/dist/prompt-context-29qkb28f.js +0 -7
  130. package/dist/recomp-orchestrator-m37p3fq6.js +0 -34
  131. package/dist/rpc-notifications-1ffm755w.js +0 -17
  132. package/dist/safe-notification-target-2a8py95v.js +0 -11
  133. package/dist/send-session-notification-bw7eex6w.js +0 -20
  134. package/dist/storage-meta-session-dse3qv6s.js +0 -23
  135. package/dist/task-config-gv6s04fp.js +0 -18
  136. /package/dist/{index-37yzyeca.js → index-3fe78beq.js} +0 -0
  137. /package/dist/{index-8mtsfhyg.js → index-jfpk81yt.js} +0 -0
  138. /package/dist/{index-2wchnyk6.js → index-kby1sng5.js} +0 -0
@@ -182,7 +182,7 @@ function mergeArrays(...arrs) {
182
182
  return Array.prototype.concat.apply([], arrs);
183
183
  }
184
184
  function product(...a) {
185
- return a.reduce((a2, b) => a2.flatMap((d) => b.map((e) => [d, e])));
185
+ return a.reduce((a, b) => a.flatMap((d) => b.map((e) => [d, e])));
186
186
  }
187
187
  function calculateReflectOffset(i, w) {
188
188
  return Math.abs((i + w) % (2 * w) - w);
@@ -195,12 +195,12 @@ function pick(o, props) {
195
195
  }));
196
196
  }
197
197
  function count(arr, value) {
198
- let count2 = 0;
198
+ let count = 0;
199
199
  for (const v of arr) {
200
200
  if (v === value)
201
- ++count2;
201
+ ++count;
202
202
  }
203
- return count2;
203
+ return count;
204
204
  }
205
205
 
206
206
  // ../../node_modules/.bun/@huggingface+transformers@4.2.0/node_modules/@huggingface/transformers/src/utils/logger.js
@@ -3060,10 +3060,10 @@ function strftime(date, format2) {
3060
3060
  function escapeRegExp(s) {
3061
3061
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3062
3062
  }
3063
- function replace(str, oldvalue, newvalue, count2) {
3064
- if (count2 === 0)
3063
+ function replace(str, oldvalue, newvalue, count) {
3064
+ if (count === 0)
3065
3065
  return str;
3066
- let remaining = count2 == null || count2 < 0 ? Infinity : count2;
3066
+ let remaining = count == null || count < 0 ? Infinity : count;
3067
3067
  const pattern = oldvalue.length === 0 ? new RegExp("(?=)", "gu") : new RegExp(escapeRegExp(oldvalue), "gu");
3068
3068
  return str.replaceAll(pattern, (match) => {
3069
3069
  if (remaining > 0) {
@@ -3241,20 +3241,20 @@ var StringValue = class extends RuntimeValue {
3241
3241
  if (!(oldValue instanceof StringValue && newValue instanceof StringValue)) {
3242
3242
  throw new Error("replace() arguments must be strings");
3243
3243
  }
3244
- let count2;
3244
+ let count;
3245
3245
  if (args.length > 2) {
3246
3246
  if (args[2].type === "KeywordArgumentsValue") {
3247
- count2 = args[2].value.get("count") ?? new NullValue;
3247
+ count = args[2].value.get("count") ?? new NullValue;
3248
3248
  } else {
3249
- count2 = args[2];
3249
+ count = args[2];
3250
3250
  }
3251
3251
  } else {
3252
- count2 = new NullValue;
3252
+ count = new NullValue;
3253
3253
  }
3254
- if (!(count2 instanceof IntegerValue || count2 instanceof NullValue)) {
3254
+ if (!(count instanceof IntegerValue || count instanceof NullValue)) {
3255
3255
  throw new Error("replace() count argument must be a number or null");
3256
3256
  }
3257
- return new StringValue(replace(this.value, oldValue.value, newValue.value, count2.value));
3257
+ return new StringValue(replace(this.value, oldValue.value, newValue.value, count.value));
3258
3258
  })
3259
3259
  ]
3260
3260
  ]);
@@ -3528,18 +3528,18 @@ __publicField(Environment, "TESTS", /* @__PURE__ */ new Map([
3528
3528
  ["equalto", (a, b) => a.value === b.value],
3529
3529
  ["eq", (a, b) => a.value === b.value]
3530
3530
  ]));
3531
- function setupGlobals(env2) {
3532
- env2.set("false", false);
3533
- env2.set("true", true);
3534
- env2.set("none", null);
3535
- env2.set("raise_exception", (args) => {
3531
+ function setupGlobals(env) {
3532
+ env.set("false", false);
3533
+ env.set("true", true);
3534
+ env.set("none", null);
3535
+ env.set("raise_exception", (args) => {
3536
3536
  throw new Error(args);
3537
3537
  });
3538
- env2.set("range", range);
3539
- env2.set("strftime_now", strftime_now);
3540
- env2.set("True", true);
3541
- env2.set("False", false);
3542
- env2.set("None", null);
3538
+ env.set("range", range);
3539
+ env.set("strftime_now", strftime_now);
3540
+ env.set("True", true);
3541
+ env.set("False", false);
3542
+ env.set("None", null);
3543
3543
  }
3544
3544
  function getAttributeValue(item, attributePath) {
3545
3545
  const parts = attributePath.split(".");
@@ -3604,8 +3604,8 @@ function compareRuntimeValues(a, b, caseSensitive = false) {
3604
3604
  }
3605
3605
  var Interpreter = class {
3606
3606
  global;
3607
- constructor(env2) {
3608
- this.global = env2 ?? new Environment;
3607
+ constructor(env) {
3608
+ this.global = env ?? new Environment;
3609
3609
  }
3610
3610
  run(program) {
3611
3611
  return this.evaluate(program, this.global);
@@ -4688,14 +4688,14 @@ var Template = class {
4688
4688
  this.parsed = parse(tokens);
4689
4689
  }
4690
4690
  render(items) {
4691
- const env2 = new Environment;
4692
- setupGlobals(env2);
4691
+ const env = new Environment;
4692
+ setupGlobals(env);
4693
4693
  if (items) {
4694
4694
  for (const [key, value] of Object.entries(items)) {
4695
- env2.set(key, value);
4695
+ env.set(key, value);
4696
4696
  }
4697
4697
  }
4698
- const interpreter = new Interpreter(env2);
4698
+ const interpreter = new Interpreter(env);
4699
4699
  const result = interpreter.run(this.parsed);
4700
4700
  return result.value;
4701
4701
  }
@@ -4831,8 +4831,8 @@ class Random {
4831
4831
  const mt = this._mt;
4832
4832
  if (this._idx >= 624) {
4833
4833
  for (let k = 0;k < 624; ++k) {
4834
- const y2 = mt[k] & 2147483648 | mt[(k + 1) % 624] & 2147483647;
4835
- mt[k] = (mt[(k + 397) % 624] ^ y2 >>> 1 ^ (y2 & 1 ? 2567483615 : 0)) >>> 0;
4834
+ const y = mt[k] & 2147483648 | mt[(k + 1) % 624] & 2147483647;
4835
+ mt[k] = (mt[(k + 397) % 624] ^ y >>> 1 ^ (y & 1 ? 2567483615 : 0)) >>> 0;
4836
4836
  }
4837
4837
  this._idx = 0;
4838
4838
  }
@@ -4898,8 +4898,8 @@ var _weightedIndex = (weights) => _weightedIndexWith(random.random, weights);
4898
4898
  var rng = new Random;
4899
4899
 
4900
4900
  class FileCache {
4901
- constructor(path3) {
4902
- this.path = path3;
4901
+ constructor(path) {
4902
+ this.path = path;
4903
4903
  }
4904
4904
  async match(request) {
4905
4905
  let filePath = path2.join(this.path, request);
@@ -4991,16 +4991,16 @@ function pathJoin(...parts) {
4991
4991
  return parts.join("/");
4992
4992
  }
4993
4993
  function isValidUrl(string, protocols = null, validHosts = null) {
4994
- let url2;
4994
+ let url;
4995
4995
  try {
4996
- url2 = new URL(string);
4996
+ url = new URL(string);
4997
4997
  } catch (_) {
4998
4998
  return false;
4999
4999
  }
5000
- if (protocols && !protocols.includes(url2.protocol)) {
5000
+ if (protocols && !protocols.includes(url.protocol)) {
5001
5001
  return false;
5002
5002
  }
5003
- if (validHosts && !validHosts.includes(url2.hostname)) {
5003
+ if (validHosts && !validHosts.includes(url.hostname)) {
5004
5004
  return false;
5005
5005
  }
5006
5006
  return true;
@@ -5050,19 +5050,19 @@ async function readResponse(response, progress_callback, expectedSize) {
5050
5050
  await read();
5051
5051
  return buffer;
5052
5052
  }
5053
- function isBlobURL(url2) {
5054
- return isValidUrl(url2, ["blob:"]);
5053
+ function isBlobURL(url) {
5054
+ return isValidUrl(url, ["blob:"]);
5055
5055
  }
5056
- function toAbsoluteURL(url2) {
5056
+ function toAbsoluteURL(url) {
5057
5057
  let baseURL;
5058
5058
  if (typeof location !== "undefined" && location.href) {
5059
5059
  baseURL = location.href;
5060
5060
  } else if (typeof import.meta !== "undefined" && import.meta.url) {
5061
5061
  baseURL = import.meta.url;
5062
5062
  } else {
5063
- return url2;
5063
+ return url;
5064
5064
  }
5065
- return new URL(url2, baseURL).href;
5065
+ return new URL(url, baseURL).href;
5066
5066
  }
5067
5067
 
5068
5068
  // ../../node_modules/.bun/@huggingface+transformers@4.2.0/node_modules/@huggingface/transformers/src/utils/cache/CrossOriginStorageCache.js
@@ -5134,16 +5134,16 @@ class CrossOriginStorage {
5134
5134
  return false;
5135
5135
  }
5136
5136
  };
5137
- _getFileHash = async (url2) => {
5137
+ _getFileHash = async (url) => {
5138
5138
  try {
5139
5139
  const hashCache = await this._getHashCache();
5140
- const cached = await hashCache.match(url2);
5140
+ const cached = await hashCache.match(url);
5141
5141
  if (cached) {
5142
5142
  return cached.text();
5143
5143
  }
5144
- const hash = await this._getLfsFileHash(url2);
5144
+ const hash = await this._getLfsFileHash(url);
5145
5145
  if (hash) {
5146
- await hashCache.put(url2, new Response(hash));
5146
+ await hashCache.put(url, new Response(hash));
5147
5147
  return hash;
5148
5148
  }
5149
5149
  return null;
@@ -5151,11 +5151,11 @@ class CrossOriginStorage {
5151
5151
  return null;
5152
5152
  }
5153
5153
  };
5154
- _getLfsFileHash = async (url2) => {
5155
- if (!url2.includes("/resolve/")) {
5154
+ _getLfsFileHash = async (url) => {
5155
+ if (!url.includes("/resolve/")) {
5156
5156
  return null;
5157
5157
  }
5158
- const rawUrl = url2.replace("/resolve/", "/raw/");
5158
+ const rawUrl = url.replace("/resolve/", "/raw/");
5159
5159
  try {
5160
5160
  const text = await fetch(rawUrl).then((r) => r.text());
5161
5161
  const match = text.match(/^oid sha256:([0-9a-f]+)$/m);
@@ -5287,9 +5287,9 @@ function get_file_metadata(path_or_repo_id, filename, options = {}) {
5287
5287
  return memoizePromise(key, () => _get_file_metadata(path_or_repo_id, filename, options));
5288
5288
  }
5289
5289
  async function _get_file_metadata(path_or_repo_id, filename, options) {
5290
- const cache2 = await getCache(options?.cache_dir);
5291
- const { localPath, remoteURL, proposedCacheKey, validModelId } = buildResourcePaths(path_or_repo_id, filename, options, cache2);
5292
- const cachedResponse = await checkCachedResource(cache2, localPath, proposedCacheKey);
5290
+ const cache = await getCache(options?.cache_dir);
5291
+ const { localPath, remoteURL, proposedCacheKey, validModelId } = buildResourcePaths(path_or_repo_id, filename, options, cache);
5292
+ const cachedResponse = await checkCachedResource(cache, localPath, proposedCacheKey);
5293
5293
  if (cachedResponse !== undefined && typeof cachedResponse !== "string") {
5294
5294
  const size = cachedResponse.headers.get("content-length");
5295
5295
  const contentType = cachedResponse.headers.get("content-type");
@@ -5382,13 +5382,13 @@ function getFetchHeaders(urlOrPath) {
5382
5382
  }
5383
5383
  return headers;
5384
5384
  }
5385
- function buildResourcePaths(path_or_repo_id, filename, options = {}, cache2 = null) {
5385
+ function buildResourcePaths(path_or_repo_id, filename, options = {}, cache = null) {
5386
5386
  const revision = options.revision ?? "main";
5387
5387
  const requestURL = pathJoin(path_or_repo_id, filename);
5388
5388
  const validModelId = isValidHfModelId(path_or_repo_id);
5389
5389
  const localPath = validModelId ? pathJoin(env.localModelPath, requestURL) : requestURL;
5390
5390
  const remoteURL = pathJoin(env.remoteHost, env.remotePathTemplate.replaceAll("{model}", path_or_repo_id).replaceAll("{revision}", encodeURIComponent(revision)), filename);
5391
- const proposedCacheKey = cache2 instanceof FileCache ? revision === "main" ? requestURL : pathJoin(path_or_repo_id, revision, filename) : remoteURL;
5391
+ const proposedCacheKey = cache instanceof FileCache ? revision === "main" ? requestURL : pathJoin(path_or_repo_id, revision, filename) : remoteURL;
5392
5392
  return {
5393
5393
  requestURL,
5394
5394
  localPath,
@@ -5397,14 +5397,14 @@ function buildResourcePaths(path_or_repo_id, filename, options = {}, cache2 = nu
5397
5397
  validModelId
5398
5398
  };
5399
5399
  }
5400
- async function checkCachedResource(cache2, localPath, proposedCacheKey) {
5401
- if (!cache2) {
5400
+ async function checkCachedResource(cache, localPath, proposedCacheKey) {
5401
+ if (!cache) {
5402
5402
  return;
5403
5403
  }
5404
- return await tryCache(cache2, localPath, proposedCacheKey);
5404
+ return await tryCache(cache, localPath, proposedCacheKey);
5405
5405
  }
5406
- async function storeCachedResource(path_or_repo_id, filename, cache2, cacheKey, response, result, options = {}) {
5407
- if (await cache2.match(cacheKey) !== undefined) {
5406
+ async function storeCachedResource(path_or_repo_id, filename, cache, cacheKey, response, result, options = {}) {
5407
+ if (await cache.match(cacheKey) !== undefined) {
5408
5408
  return;
5409
5409
  }
5410
5410
  if (!result) {
@@ -5414,23 +5414,23 @@ async function storeCachedResource(path_or_repo_id, filename, cache2, cacheKey,
5414
5414
  file: filename,
5415
5415
  ...data
5416
5416
  }) : undefined;
5417
- await cache2.put(cacheKey, response, wrapped_progress);
5417
+ await cache.put(cacheKey, response, wrapped_progress);
5418
5418
  } else if (typeof response !== "string") {
5419
5419
  const headers = new Headers(response.headers);
5420
5420
  headers.set("content-length", result.byteLength.toString());
5421
- await cache2.put(cacheKey, new Response(result, {
5421
+ await cache.put(cacheKey, new Response(result, {
5422
5422
  headers
5423
5423
  })).catch((err) => {
5424
5424
  logger.warn(`Unable to add response to browser cache: ${err}.`);
5425
5425
  });
5426
5426
  }
5427
5427
  }
5428
- async function loadResourceFile(path_or_repo_id, filename, fatal = true, options = {}, return_path = false, cache2 = null) {
5429
- const { requestURL, localPath, remoteURL, proposedCacheKey, validModelId } = buildResourcePaths(path_or_repo_id, filename, options, cache2);
5428
+ async function loadResourceFile(path_or_repo_id, filename, fatal = true, options = {}, return_path = false, cache = null) {
5429
+ const { requestURL, localPath, remoteURL, proposedCacheKey, validModelId } = buildResourcePaths(path_or_repo_id, filename, options, cache);
5430
5430
  let cacheKey;
5431
5431
  let toCacheResponse = false;
5432
5432
  let response;
5433
- response = await checkCachedResource(cache2, localPath, proposedCacheKey);
5433
+ response = await checkCachedResource(cache, localPath, proposedCacheKey);
5434
5434
  const cacheHit = response !== undefined;
5435
5435
  if (cacheHit) {
5436
5436
  cacheKey = proposedCacheKey;
@@ -5467,7 +5467,7 @@ async function loadResourceFile(path_or_repo_id, filename, fatal = true, options
5467
5467
  }
5468
5468
  cacheKey = proposedCacheKey;
5469
5469
  }
5470
- toCacheResponse = cache2 && typeof Response !== "undefined" && response instanceof Response && response.status === 200;
5470
+ toCacheResponse = cache && typeof Response !== "undefined" && response instanceof Response && response.status === 200;
5471
5471
  }
5472
5472
  dispatchCallback(options.progress_callback, {
5473
5473
  status: "download",
@@ -5516,7 +5516,7 @@ async function loadResourceFile(path_or_repo_id, filename, fatal = true, options
5516
5516
  result = buffer;
5517
5517
  }
5518
5518
  if (toCacheResponse && cacheKey && typeof response !== "string") {
5519
- await storeCachedResource(path_or_repo_id, filename, cache2, cacheKey, response, result, options);
5519
+ await storeCachedResource(path_or_repo_id, filename, cache, cacheKey, response, result, options);
5520
5520
  }
5521
5521
  if (apis.IS_NODE_ENV && return_path && options.progress_callback && typeof response !== "string") {
5522
5522
  const size = parseInt(response.headers.get("content-length"), 10) || 0;
@@ -5543,7 +5543,7 @@ async function loadResourceFile(path_or_repo_id, filename, fatal = true, options
5543
5543
  if (response instanceof FileResponse) {
5544
5544
  return response.filePath;
5545
5545
  }
5546
- const cachedResponse = await cache2?.match(cacheKey);
5546
+ const cachedResponse = await cache?.match(cacheKey);
5547
5547
  if (cachedResponse instanceof FileResponse) {
5548
5548
  return cachedResponse.filePath;
5549
5549
  } else if (cachedResponse instanceof Response) {
@@ -5570,8 +5570,8 @@ async function getModelFile(path_or_repo_id, filename, fatal = true, options = {
5570
5570
  const key = `${path_or_repo_id}::${filename}`;
5571
5571
  let pending = INFLIGHT_LOADS.get(key);
5572
5572
  if (!pending) {
5573
- const cache2 = await getCache(options?.cache_dir);
5574
- pending = loadResourceFile(path_or_repo_id, filename, fatal, options, return_path, cache2).then((result) => {
5573
+ const cache = await getCache(options?.cache_dir);
5574
+ pending = loadResourceFile(path_or_repo_id, filename, fatal, options, return_path, cache).then((result) => {
5575
5575
  INFLIGHT_LOADS.delete(key);
5576
5576
  return result;
5577
5577
  }, (err) => {
@@ -5693,28 +5693,28 @@ function magnitude(arr) {
5693
5693
  function min2(arr) {
5694
5694
  if (arr.length === 0)
5695
5695
  throw Error("Array must not be empty");
5696
- let min3 = arr[0];
5696
+ let min = arr[0];
5697
5697
  let indexOfMin = 0;
5698
5698
  for (let i = 1;i < arr.length; ++i) {
5699
- if (arr[i] < min3) {
5700
- min3 = arr[i];
5699
+ if (arr[i] < min) {
5700
+ min = arr[i];
5701
5701
  indexOfMin = i;
5702
5702
  }
5703
5703
  }
5704
- return [min3, indexOfMin];
5704
+ return [min, indexOfMin];
5705
5705
  }
5706
5706
  function max(arr) {
5707
5707
  if (arr.length === 0)
5708
5708
  throw Error("Array must not be empty");
5709
- let max2 = arr[0];
5709
+ let max = arr[0];
5710
5710
  let indexOfMax = 0;
5711
5711
  for (let i = 1;i < arr.length; ++i) {
5712
- if (arr[i] > max2) {
5713
- max2 = arr[i];
5712
+ if (arr[i] > max) {
5713
+ max = arr[i];
5714
5714
  indexOfMax = i;
5715
5715
  }
5716
5716
  }
5717
- return [max2, indexOfMax];
5717
+ return [max, indexOfMax];
5718
5718
  }
5719
5719
  function isPowerOfTwo(number) {
5720
5720
  return number > 0 && (number & number - 1) === 0;
@@ -5783,26 +5783,26 @@ class P2FFT {
5783
5783
  const size = this._csize;
5784
5784
  const width = this._width;
5785
5785
  let step = 1 << width;
5786
- let len2 = size / step << 1;
5786
+ let len = size / step << 1;
5787
5787
  let outOff;
5788
5788
  let t;
5789
5789
  const bitrev = this._bitrev;
5790
- if (len2 === 4) {
5791
- for (outOff = 0, t = 0;outOff < size; outOff += len2, ++t) {
5790
+ if (len === 4) {
5791
+ for (outOff = 0, t = 0;outOff < size; outOff += len, ++t) {
5792
5792
  const off = bitrev[t];
5793
5793
  this._singleTransform2(data, out, outOff, off, step);
5794
5794
  }
5795
5795
  } else {
5796
- for (outOff = 0, t = 0;outOff < size; outOff += len2, ++t) {
5796
+ for (outOff = 0, t = 0;outOff < size; outOff += len, ++t) {
5797
5797
  const off = bitrev[t];
5798
5798
  this._singleTransform4(data, out, outOff, off, step, inv);
5799
5799
  }
5800
5800
  }
5801
5801
  const table = this.table;
5802
5802
  for (step >>= 2;step >= 2; step >>= 2) {
5803
- len2 = size / step << 1;
5804
- const quarterLen = len2 >>> 2;
5805
- for (outOff = 0;outOff < size; outOff += len2) {
5803
+ len = size / step << 1;
5804
+ const quarterLen = len >>> 2;
5805
+ for (outOff = 0;outOff < size; outOff += len) {
5806
5806
  const limit = outOff + quarterLen - 1;
5807
5807
  for (let i = outOff, k = 0;i < limit; i += 2, k += step) {
5808
5808
  const A = i;
@@ -5891,28 +5891,28 @@ class P2FFT {
5891
5891
  const size = this._csize;
5892
5892
  const width = this._width;
5893
5893
  let step = 1 << width;
5894
- let len2 = size / step << 1;
5894
+ let len = size / step << 1;
5895
5895
  let outOff;
5896
5896
  let t;
5897
5897
  const bitrev = this._bitrev;
5898
- if (len2 === 4) {
5899
- for (outOff = 0, t = 0;outOff < size; outOff += len2, ++t) {
5898
+ if (len === 4) {
5899
+ for (outOff = 0, t = 0;outOff < size; outOff += len, ++t) {
5900
5900
  const off = bitrev[t];
5901
5901
  this._singleRealTransform2(data, out, outOff, off >>> 1, step >>> 1);
5902
5902
  }
5903
5903
  } else {
5904
- for (outOff = 0, t = 0;outOff < size; outOff += len2, ++t) {
5904
+ for (outOff = 0, t = 0;outOff < size; outOff += len, ++t) {
5905
5905
  const off = bitrev[t];
5906
5906
  this._singleRealTransform4(data, out, outOff, off >>> 1, step >>> 1, inv);
5907
5907
  }
5908
5908
  }
5909
5909
  const table = this.table;
5910
5910
  for (step >>= 2;step >= 2; step >>= 2) {
5911
- len2 = size / step << 1;
5912
- const halfLen = len2 >>> 1;
5911
+ len = size / step << 1;
5912
+ const halfLen = len >>> 1;
5913
5913
  const quarterLen = halfLen >>> 1;
5914
5914
  const hquarterLen = quarterLen >>> 1;
5915
- for (outOff = 0;outOff < size; outOff += len2) {
5915
+ for (outOff = 0;outOff < size; outOff += len) {
5916
5916
  for (let i = 0, k = 0;i <= hquarterLen; i += 2, k += step) {
5917
5917
  const A = outOff + i;
5918
5918
  const B = A + quarterLen;
@@ -6140,11 +6140,11 @@ function dynamic_time_warping(matrix) {
6140
6140
  const cost = Array.from({ length: outputShape[0] }, () => Array(outputShape[1]).fill(Infinity));
6141
6141
  cost[0][0] = 0;
6142
6142
  const trace = Array.from({ length: outputShape[0] }, () => Array(outputShape[1]).fill(-1));
6143
- for (let j2 = 1;j2 < outputShape[1]; ++j2) {
6144
- for (let i2 = 1;i2 < outputShape[0]; ++i2) {
6145
- const c0 = cost[i2 - 1][j2 - 1];
6146
- const c1 = cost[i2 - 1][j2];
6147
- const c2 = cost[i2][j2 - 1];
6143
+ for (let j = 1;j < outputShape[1]; ++j) {
6144
+ for (let i = 1;i < outputShape[0]; ++i) {
6145
+ const c0 = cost[i - 1][j - 1];
6146
+ const c1 = cost[i - 1][j];
6147
+ const c2 = cost[i][j - 1];
6148
6148
  let c, t;
6149
6149
  if (c0 < c1 && c0 < c2) {
6150
6150
  c = c0;
@@ -6156,15 +6156,15 @@ function dynamic_time_warping(matrix) {
6156
6156
  c = c2;
6157
6157
  t = 2;
6158
6158
  }
6159
- cost[i2][j2] = matrix[i2 - 1][j2 - 1] + c;
6160
- trace[i2][j2] = t;
6159
+ cost[i][j] = matrix[i - 1][j - 1] + c;
6160
+ trace[i][j] = t;
6161
6161
  }
6162
6162
  }
6163
- for (let i2 = 0;i2 < outputShape[1]; ++i2) {
6164
- trace[0][i2] = 2;
6163
+ for (let i = 0;i < outputShape[1]; ++i) {
6164
+ trace[0][i] = 2;
6165
6165
  }
6166
- for (let i2 = 0;i2 < outputShape[0]; ++i2) {
6167
- trace[i2][0] = 1;
6166
+ for (let i = 0;i < outputShape[0]; ++i) {
6167
+ trace[i][0] = 1;
6168
6168
  }
6169
6169
  let i = output_length;
6170
6170
  let j = input_length;
@@ -6248,13 +6248,13 @@ var onnxruntime_node_wasm_shim_default = ortWeb;
6248
6248
  import * as ONNX_WEB from "onnxruntime-web/webgpu";
6249
6249
 
6250
6250
  // ../../node_modules/.bun/@huggingface+transformers@4.2.0/node_modules/@huggingface/transformers/src/backends/utils/cacheWasm.js
6251
- async function loadAndCacheFile(url2) {
6252
- const fileName = url2.split("/").pop();
6253
- let cache2;
6251
+ async function loadAndCacheFile(url) {
6252
+ const fileName = url.split("/").pop();
6253
+ let cache;
6254
6254
  try {
6255
- cache2 = await getCache();
6256
- if (cache2) {
6257
- const result = await cache2.match(url2);
6255
+ cache = await getCache();
6256
+ if (cache) {
6257
+ const result = await cache.match(url);
6258
6258
  if (result) {
6259
6259
  return result;
6260
6260
  }
@@ -6262,13 +6262,13 @@ async function loadAndCacheFile(url2) {
6262
6262
  } catch (error) {
6263
6263
  logger.warn(`Failed to load ${fileName} from cache:`, error);
6264
6264
  }
6265
- const response = await env.fetch(url2);
6265
+ const response = await env.fetch(url);
6266
6266
  if (!response.ok) {
6267
6267
  throw new Error(`Failed to fetch ${fileName}: ${response.status} ${response.statusText}`);
6268
6268
  }
6269
- if (cache2) {
6269
+ if (cache) {
6270
6270
  try {
6271
- await cache2.put(url2, response.clone());
6271
+ await cache.put(url, response.clone());
6272
6272
  } catch (e) {
6273
6273
  logger.warn(`Failed to cache ${fileName}:`, e);
6274
6274
  }
@@ -7069,14 +7069,14 @@ var DEVICE_TO_EXECUTION_PROVIDER_MAPPING = Object.freeze({
7069
7069
  "webnn-gpu": { name: "webnn", deviceType: "gpu" },
7070
7070
  "webnn-cpu": { name: "webnn", deviceType: "cpu" }
7071
7071
  });
7072
- function getOnnxLogSeverityLevel(logLevel2) {
7073
- if (logLevel2 <= LogLevel.DEBUG) {
7072
+ function getOnnxLogSeverityLevel(logLevel) {
7073
+ if (logLevel <= LogLevel.DEBUG) {
7074
7074
  return 0;
7075
- } else if (logLevel2 <= LogLevel.INFO) {
7075
+ } else if (logLevel <= LogLevel.INFO) {
7076
7076
  return 2;
7077
- } else if (logLevel2 <= LogLevel.WARNING) {
7077
+ } else if (logLevel <= LogLevel.WARNING) {
7078
7078
  return 3;
7079
- } else if (logLevel2 <= LogLevel.ERROR) {
7079
+ } else if (logLevel <= LogLevel.ERROR) {
7080
7080
  return 3;
7081
7081
  } else {
7082
7082
  return 4;
@@ -7209,8 +7209,8 @@ function isONNXProxy() {
7209
7209
  return ONNX_ENV?.wasm?.proxy;
7210
7210
  }
7211
7211
  if (ONNX_ENV) {
7212
- let setLogLevel = function(logLevel2) {
7213
- const severityLevel = getOnnxLogSeverityLevel(logLevel2);
7212
+ let setLogLevel = function(logLevel) {
7213
+ const severityLevel = getOnnxLogSeverityLevel(logLevel);
7214
7214
  ONNX_ENV.logLevel = ONNX_LOG_LEVEL_NAMES[severityLevel];
7215
7215
  };
7216
7216
  if (ONNX_ENV.wasm) {
@@ -8536,25 +8536,25 @@ class Tensor3 {
8536
8536
  const newTensorDims = [];
8537
8537
  const newOffsets = [];
8538
8538
  for (let sliceIndex = 0;sliceIndex < this.dims.length; ++sliceIndex) {
8539
- let slice2 = slices[sliceIndex];
8540
- if (slice2 === null || slice2 === undefined) {
8539
+ let slice = slices[sliceIndex];
8540
+ if (slice === null || slice === undefined) {
8541
8541
  newOffsets.push([0, this.dims[sliceIndex]]);
8542
8542
  newTensorDims.push(this.dims[sliceIndex]);
8543
- } else if (typeof slice2 === "number") {
8544
- slice2 = safeIndex(slice2, this.dims[sliceIndex], sliceIndex);
8545
- newOffsets.push([slice2, slice2 + 1]);
8546
- } else if (Array.isArray(slice2) && slice2.length === 2) {
8547
- let [start, end] = slice2;
8543
+ } else if (typeof slice === "number") {
8544
+ slice = safeIndex(slice, this.dims[sliceIndex], sliceIndex);
8545
+ newOffsets.push([slice, slice + 1]);
8546
+ } else if (Array.isArray(slice) && slice.length === 2) {
8547
+ let [start, end] = slice;
8548
8548
  start = start === null ? 0 : safeIndex(start, this.dims[sliceIndex], sliceIndex, false);
8549
8549
  end = end === null ? this.dims[sliceIndex] : safeIndex(end, this.dims[sliceIndex], sliceIndex, false);
8550
8550
  if (start > end) {
8551
- throw new Error(`Invalid slice: ${slice2}`);
8551
+ throw new Error(`Invalid slice: ${slice}`);
8552
8552
  }
8553
8553
  const offsets = [Math.max(start, 0), Math.min(end, this.dims[sliceIndex])];
8554
8554
  newOffsets.push(offsets);
8555
8555
  newTensorDims.push(offsets[1] - offsets[0]);
8556
8556
  } else {
8557
- throw new Error(`Invalid slice: ${slice2}`);
8557
+ throw new Error(`Invalid slice: ${slice}`);
8558
8558
  }
8559
8559
  }
8560
8560
  const newDims = newOffsets.map(([start, end]) => end - start);
@@ -8701,8 +8701,8 @@ class Tensor3 {
8701
8701
  }
8702
8702
  const this_data = this.data;
8703
8703
  if (inferredIndex !== -1) {
8704
- const productOther = dims.reduce((product2, curr, index) => {
8705
- return index !== inferredIndex ? product2 * curr : product2;
8704
+ const productOther = dims.reduce((product, curr, index) => {
8705
+ return index !== inferredIndex ? product * curr : product;
8706
8706
  }, 1);
8707
8707
  dims[inferredIndex] = this_data.length / productOther;
8708
8708
  }
@@ -8734,15 +8734,15 @@ class Tensor3 {
8734
8734
  }
8735
8735
  return new Tensor3("bool", mask, this.dims);
8736
8736
  }
8737
- clamp_(min3, max2) {
8737
+ clamp_(min, max) {
8738
8738
  const this_data = this.data;
8739
8739
  for (let i = 0;i < this_data.length; ++i) {
8740
- this_data[i] = Math.min(Math.max(this_data[i], min3), max2);
8740
+ this_data[i] = Math.min(Math.max(this_data[i], min), max);
8741
8741
  }
8742
8742
  return this;
8743
8743
  }
8744
- clamp(min3, max2) {
8745
- return this.clone().clamp_(min3, max2);
8744
+ clamp(min, max) {
8745
+ return this.clone().clamp_(min, max);
8746
8746
  }
8747
8747
  round_() {
8748
8748
  const this_data = this.data;
@@ -8795,8 +8795,8 @@ class Tensor3 {
8795
8795
  if (repeats.length === this.dims.length) {
8796
8796
  return this.clone();
8797
8797
  }
8798
- const numPrependedDims2 = repeats.length - this.dims.length;
8799
- const newDims = Array(numPrependedDims2).fill(1).concat(this.dims);
8798
+ const numPrependedDims = repeats.length - this.dims.length;
8799
+ const newDims = Array(numPrependedDims).fill(1).concat(this.dims);
8800
8800
  return new Tensor3(this.type, this.data.slice(), newDims);
8801
8801
  }
8802
8802
  const numPrependedDims = repeats.length - this.dims.length;
@@ -8870,9 +8870,9 @@ function reshape(data, dimensions) {
8870
8870
  }
8871
8871
  return reshapedArray[0];
8872
8872
  }
8873
- function permute(tensor2, axes) {
8874
- const [permutedData, shape] = permute_data(tensor2.data, tensor2.dims, axes);
8875
- return new Tensor3(tensor2.type, permutedData, shape);
8873
+ function permute(tensor, axes) {
8874
+ const [permutedData, shape] = permute_data(tensor.data, tensor.dims, axes);
8875
+ return new Tensor3(tensor.type, permutedData, shape);
8876
8876
  }
8877
8877
  function interpolate(input, [out_height, out_width], mode = "bilinear", align_corners = false) {
8878
8878
  const in_channels = input.dims.at(-3) ?? 1;
@@ -8953,15 +8953,15 @@ function mean_pooling(last_hidden_state, attention_mask) {
8953
8953
  const offset = i * embedDim * seqLength;
8954
8954
  for (let k = 0;k < embedDim; ++k) {
8955
8955
  let sum = 0;
8956
- let count2 = 0;
8956
+ let count = 0;
8957
8957
  const attnMaskOffset = i * seqLength;
8958
8958
  const offset2 = offset + k;
8959
8959
  for (let j = 0;j < seqLength; ++j) {
8960
8960
  const attn = Number(attentionMaskData[attnMaskOffset + j]);
8961
- count2 += attn;
8961
+ count += attn;
8962
8962
  sum += lastHiddenStateData[offset2 + j * embedDim] * attn;
8963
8963
  }
8964
- const avg = sum / count2;
8964
+ const avg = sum / count;
8965
8965
  returnedData[outIndex++] = avg;
8966
8966
  }
8967
8967
  }
@@ -9032,8 +9032,8 @@ function cat(tensors, dim = 0) {
9032
9032
  const resultType = tensors[0].type;
9033
9033
  if (dim === 0) {
9034
9034
  let offset = 0;
9035
- for (const tensor2 of tensors) {
9036
- const tensorData = tensor2.data;
9035
+ for (const tensor of tensors) {
9036
+ const tensorData = tensor.data;
9037
9037
  result.set(tensorData, offset);
9038
9038
  offset += tensorData.length;
9039
9039
  }
@@ -9097,9 +9097,9 @@ function std_mean(input, dim = null, correction = 1, keepdim = false) {
9097
9097
  const sum = inputData.reduce((a, b) => a + b, 0);
9098
9098
  const mean = sum / inputData.length;
9099
9099
  const std = Math.sqrt(inputData.reduce((a, b) => a + (b - mean) ** 2, 0) / (inputData.length - correction));
9100
- const meanTensor2 = new Tensor3(input.type, [mean], []);
9101
- const stdTensor2 = new Tensor3(input.type, [std], []);
9102
- return [stdTensor2, meanTensor2];
9100
+ const meanTensor = new Tensor3(input.type, [mean], []);
9101
+ const stdTensor = new Tensor3(input.type, [std], []);
9102
+ return [stdTensor, meanTensor];
9103
9103
  }
9104
9104
  dim = safeIndex(dim, inputDims.length);
9105
9105
  const meanTensor = mean(input, dim, keepdim);
@@ -9156,20 +9156,20 @@ function full(size, fill_value) {
9156
9156
  }
9157
9157
  return fullHelper(size, fill_value, dtype, typedArrayCls);
9158
9158
  }
9159
- function full_like(tensor2, fill_value) {
9160
- return full(tensor2.dims, fill_value);
9159
+ function full_like(tensor, fill_value) {
9160
+ return full(tensor.dims, fill_value);
9161
9161
  }
9162
9162
  function ones(size) {
9163
9163
  return fullHelper(size, 1n, "int64", BigInt64Array);
9164
9164
  }
9165
- function ones_like(tensor2) {
9166
- return ones(tensor2.dims);
9165
+ function ones_like(tensor) {
9166
+ return ones(tensor.dims);
9167
9167
  }
9168
9168
  function zeros(size) {
9169
9169
  return fullHelper(size, 0n, "int64", BigInt64Array);
9170
9170
  }
9171
- function zeros_like(tensor2) {
9172
- return zeros(tensor2.dims);
9171
+ function zeros_like(tensor) {
9172
+ return zeros(tensor.dims);
9173
9173
  }
9174
9174
  function rand(size) {
9175
9175
  const length = size.reduce((a, b) => a * b, 1);
@@ -9179,11 +9179,11 @@ function randn(size) {
9179
9179
  const length = size.reduce((a, b) => a * b, 1);
9180
9180
  return new Tensor3("float32", Float32Array.from({ length }, () => random.gauss()), size);
9181
9181
  }
9182
- function quantize_embeddings(tensor2, precision) {
9183
- if (tensor2.dims.length !== 2) {
9182
+ function quantize_embeddings(tensor, precision) {
9183
+ if (tensor.dims.length !== 2) {
9184
9184
  throw new Error("The tensor must have 2 dimensions");
9185
9185
  }
9186
- if (tensor2.dims.at(-1) % 8 !== 0) {
9186
+ if (tensor.dims.at(-1) % 8 !== 0) {
9187
9187
  throw new Error("The last dimension of the tensor must be a multiple of 8");
9188
9188
  }
9189
9189
  if (!["binary", "ubinary"].includes(precision)) {
@@ -9192,7 +9192,7 @@ function quantize_embeddings(tensor2, precision) {
9192
9192
  const signed = precision === "binary";
9193
9193
  const dtype = signed ? "int8" : "uint8";
9194
9194
  const cls = signed ? Int8Array : Uint8Array;
9195
- const inputData = tensor2.data;
9195
+ const inputData = tensor.data;
9196
9196
  const outputData = new cls(inputData.length / 8);
9197
9197
  for (let i = 0;i < inputData.length; ++i) {
9198
9198
  const bit = inputData[i] > 0 ? 1 : 0;
@@ -9203,7 +9203,7 @@ function quantize_embeddings(tensor2, precision) {
9203
9203
  outputData[arrayIndex] -= 128;
9204
9204
  }
9205
9205
  }
9206
- return new Tensor3(dtype, outputData, [tensor2.dims[0], tensor2.dims[1] / 8]);
9206
+ return new Tensor3(dtype, outputData, [tensor.dims[0], tensor.dims[1] / 8]);
9207
9207
  }
9208
9208
 
9209
9209
  // ../../node_modules/.bun/@huggingface+transformers@4.2.0/node_modules/@huggingface/transformers/src/utils/model_registry/get_tokenizer_files.js
@@ -9223,16 +9223,16 @@ async function loadTokenizer(pretrained_model_name_or_path, options) {
9223
9223
  const tokenizerFiles = await get_tokenizer_files(pretrained_model_name_or_path);
9224
9224
  return await Promise.all(tokenizerFiles.map((file) => getModelJSON(pretrained_model_name_or_path, file, true, options)));
9225
9225
  }
9226
- function prepareTensorForDecode(tensor2) {
9227
- const dims = tensor2.dims;
9226
+ function prepareTensorForDecode(tensor) {
9227
+ const dims = tensor.dims;
9228
9228
  switch (dims.length) {
9229
9229
  case 1:
9230
- return tensor2.tolist();
9230
+ return tensor.tolist();
9231
9231
  case 2:
9232
9232
  if (dims[0] !== 1) {
9233
9233
  throw new Error("Unable to decode tensor with `batch size !== 1`. Use `tokenizer.batch_decode(...)` for batched inputs.");
9234
9234
  }
9235
- return tensor2.tolist()[0];
9235
+ return tensor.tolist()[0];
9236
9236
  default:
9237
9237
  throw new Error(`Expected tensor to have 1-2 dimensions, got ${dims.length}.`);
9238
9238
  }
@@ -9520,7 +9520,7 @@ class PreTrainedTokenizer extends Callable {
9520
9520
  documents = null,
9521
9521
  chat_template = null,
9522
9522
  add_generation_prompt = false,
9523
- tokenize: tokenize2 = true,
9523
+ tokenize = true,
9524
9524
  padding = false,
9525
9525
  truncation = false,
9526
9526
  max_length = null,
@@ -9553,7 +9553,7 @@ class PreTrainedTokenizer extends Callable {
9553
9553
  ...special_tokens_map,
9554
9554
  ...kwargs
9555
9555
  });
9556
- if (tokenize2) {
9556
+ if (tokenize) {
9557
9557
  const out = this._call(rendered, {
9558
9558
  add_special_tokens: false,
9559
9559
  padding,
@@ -9757,11 +9757,11 @@ class MarianTokenizer extends PreTrainedTokenizer {
9757
9757
  if (remainder.length === 0) {
9758
9758
  return super._encode_text(matchInfo);
9759
9759
  } else if (remainder.length === 2) {
9760
- const [language, text2] = remainder;
9760
+ const [language, text] = remainder;
9761
9761
  if (!this.supported_language_codes.includes(language)) {
9762
9762
  logger.warn(`Unsupported language code "${language}" detected, which may lead to unexpected behavior. Should be one of: ${JSON.stringify(this.supported_language_codes)}`);
9763
9763
  }
9764
- return mergeArrays([language], super._encode_text(text2));
9764
+ return mergeArrays([language], super._encode_text(text));
9765
9765
  }
9766
9766
  }
9767
9767
  }
@@ -10144,21 +10144,21 @@ class WhisperTokenizer extends PreTrainedTokenizer {
10144
10144
  chunks.push(chunk);
10145
10145
  }
10146
10146
  let optional = Object.create(null);
10147
- const full_text = chunks.map((chunk2) => chunk2.text).join("");
10147
+ const full_text = chunks.map((chunk) => chunk.text).join("");
10148
10148
  if (return_timestamps || return_language) {
10149
10149
  for (let i = 0;i < chunks.length; ++i) {
10150
- const chunk2 = chunks[i];
10150
+ const chunk = chunks[i];
10151
10151
  if (!return_timestamps) {
10152
- delete chunk2["timestamp"];
10152
+ delete chunk["timestamp"];
10153
10153
  }
10154
10154
  if (!return_language) {
10155
- delete chunk2["language"];
10155
+ delete chunk["language"];
10156
10156
  }
10157
10157
  }
10158
10158
  if (returnWordTimestamps) {
10159
10159
  const new_chunks = [];
10160
- for (const chunk2 of chunks) {
10161
- for (const word of chunk2.words) {
10160
+ for (const chunk of chunks) {
10161
+ for (const word of chunk.words) {
10162
10162
  new_chunks.push(word);
10163
10163
  }
10164
10164
  }
@@ -10178,36 +10178,36 @@ class WhisperTokenizer extends PreTrainedTokenizer {
10178
10178
  let left_token_timestamp_sequence = use_token_timestamp_sequences ? token_timestamp_sequences[0] : null;
10179
10179
  for (let i = 1;i < sequences.length; ++i) {
10180
10180
  const rightSequence = sequences[i];
10181
- let max2 = 0;
10181
+ let max = 0;
10182
10182
  let maxIndices = [leftLength, leftLength, 0, 0];
10183
10183
  const rightLength = rightSequence.length;
10184
10184
  for (let j = 1;j < leftLength + rightLength; ++j) {
10185
- const leftStart2 = Math.max(0, leftLength - j);
10186
- const leftStop2 = Math.min(leftLength, leftLength + rightLength - j);
10187
- const left = leftSequence.slice(leftStart2, leftStop2);
10188
- const rightStart2 = Math.max(0, j - leftLength);
10189
- const rightStop2 = Math.min(rightLength, j);
10190
- const right = rightSequence.slice(rightStart2, rightStop2);
10185
+ const leftStart = Math.max(0, leftLength - j);
10186
+ const leftStop = Math.min(leftLength, leftLength + rightLength - j);
10187
+ const left = leftSequence.slice(leftStart, leftStop);
10188
+ const rightStart = Math.max(0, j - leftLength);
10189
+ const rightStop = Math.min(rightLength, j);
10190
+ const right = rightSequence.slice(rightStart, rightStop);
10191
10191
  if (left.length !== right.length) {
10192
10192
  throw new Error("There is a bug within whisper `decode_asr` function, please report it. Dropping to prevent bad inference.");
10193
10193
  }
10194
10194
  let matches;
10195
10195
  if (use_token_timestamp_sequences) {
10196
- matches = left.filter((elem, idx) => elem === right[idx] && left_token_timestamp_sequence[leftStart2 + idx][0] - TIMESTAMP_MERGE_TOLERANCE <= token_timestamp_sequences[i][rightStart2 + idx][0]).length;
10196
+ matches = left.filter((elem, idx) => elem === right[idx] && left_token_timestamp_sequence[leftStart + idx][0] - TIMESTAMP_MERGE_TOLERANCE <= token_timestamp_sequences[i][rightStart + idx][0]).length;
10197
10197
  } else {
10198
10198
  matches = left.filter((elem, idx) => elem === right[idx]).length;
10199
10199
  }
10200
10200
  const eps = j / 1e4;
10201
10201
  const matching = matches / j + eps;
10202
- if (matches > 1 && matching > max2) {
10203
- max2 = matching;
10204
- maxIndices = [leftStart2, leftStop2, rightStart2, rightStop2];
10202
+ if (matches > 1 && matching > max) {
10203
+ max = matching;
10204
+ maxIndices = [leftStart, leftStop, rightStart, rightStop];
10205
10205
  }
10206
10206
  }
10207
10207
  const [leftStart, leftStop, rightStart, rightStop] = maxIndices;
10208
10208
  const leftMid = Math.floor((leftStop + leftStart) / 2);
10209
10209
  let rightMid = Math.floor((rightStop + rightStart) / 2);
10210
- if (use_token_timestamp_sequences && max2 === 0 && leftLength > 0) {
10210
+ if (use_token_timestamp_sequences && max === 0 && leftLength > 0) {
10211
10211
  const lastLeftTs = left_token_timestamp_sequence[leftLength - 1][0];
10212
10212
  const idx = token_timestamp_sequences[i].findIndex((ts) => ts[0] >= lastLeftTs);
10213
10213
  rightMid = idx === -1 ? rightSequence.length : idx;
@@ -10563,7 +10563,7 @@ __export(exports_feature_extractors, {
10563
10563
  import fs4 from "node:fs";
10564
10564
  import { Readable } from "node:stream";
10565
10565
  import { pipeline as pipe } from "node:stream/promises";
10566
- async function saveBlob(path3, blob) {
10566
+ async function saveBlob(path, blob) {
10567
10567
  if (apis.IS_BROWSER_ENV) {
10568
10568
  if (apis.IS_WEBWORKER_ENV) {
10569
10569
  throw new Error("Unable to save a file from a Web Worker.");
@@ -10571,14 +10571,14 @@ async function saveBlob(path3, blob) {
10571
10571
  const dataURL = URL.createObjectURL(blob);
10572
10572
  const downloadLink = document.createElement("a");
10573
10573
  downloadLink.href = dataURL;
10574
- downloadLink.download = path3;
10574
+ downloadLink.download = path;
10575
10575
  downloadLink.click();
10576
10576
  downloadLink.remove();
10577
10577
  URL.revokeObjectURL(dataURL);
10578
10578
  } else if (apis.IS_FS_AVAILABLE) {
10579
10579
  const webStream = blob.stream();
10580
10580
  const nodeStream = Readable.fromWeb(webStream);
10581
- const fileStream = fs4.createWriteStream(path3);
10581
+ const fileStream = fs4.createWriteStream(path);
10582
10582
  await pipe(nodeStream, fileStream);
10583
10583
  } else {
10584
10584
  throw new Error("Unable to save because filesystem is disabled in this environment.");
@@ -10586,11 +10586,11 @@ async function saveBlob(path3, blob) {
10586
10586
  }
10587
10587
 
10588
10588
  // ../../node_modules/.bun/@huggingface+transformers@4.2.0/node_modules/@huggingface/transformers/src/utils/audio.js
10589
- async function load_audio(url2, sampling_rate) {
10589
+ async function load_audio(url, sampling_rate) {
10590
10590
  if (typeof AudioContext === "undefined") {
10591
10591
  throw Error("Unable to load audio from path/URL since `AudioContext` is not available in your environment. " + "Instead, audio data should be passed directly to the pipeline/processor. " + "For more information and some example code, see https://huggingface.co/docs/transformers.js/guides/node-audio-processing.");
10592
10592
  }
10593
- const response = await (await getFile(url2)).arrayBuffer();
10593
+ const response = await (await getFile(url)).arrayBuffer();
10594
10594
  const audioCTX = new AudioContext({ sampleRate: sampling_rate });
10595
10595
  if (typeof sampling_rate === "undefined") {
10596
10596
  logger.warn(`No sampling rate provided, using default of ${audioCTX.sampleRate}Hz.`);
@@ -10859,9 +10859,9 @@ async function spectrogram(waveform, window2, frame_length, hop_length, {
10859
10859
  for (let j = 0;j < buffer_size; ++j) {
10860
10860
  sum += inputBuffer[j];
10861
10861
  }
10862
- const mean2 = sum / buffer_size;
10862
+ const mean = sum / buffer_size;
10863
10863
  for (let j = 0;j < buffer_size; ++j) {
10864
- inputBuffer[j] -= mean2;
10864
+ inputBuffer[j] -= mean;
10865
10865
  }
10866
10866
  }
10867
10867
  if (preemphasis !== null) {
@@ -11032,8 +11032,8 @@ class RawAudio {
11032
11032
  }
11033
11033
  return encodeWAV(audio, this.sampling_rate);
11034
11034
  }
11035
- async save(path3) {
11036
- return saveBlob(path3, this.toBlob());
11035
+ async save(path) {
11036
+ return saveBlob(path, this.toBlob());
11037
11037
  }
11038
11038
  }
11039
11039
 
@@ -11226,13 +11226,13 @@ class ParakeetFeatureExtractor extends FeatureExtractor {
11226
11226
  }
11227
11227
  const divisor = features_length > 1 ? features_length - 1 : 1;
11228
11228
  for (let j = 0;j < num_features; ++j) {
11229
- const mean2 = sum[j] / features_length;
11230
- const variance = (sum_sq[j] - features_length * mean2 * mean2) / divisor;
11229
+ const mean = sum[j] / features_length;
11230
+ const variance = (sum_sq[j] - features_length * mean * mean) / divisor;
11231
11231
  const std = Math.sqrt(variance) + EPSILON;
11232
11232
  const inv_std = 1 / std;
11233
11233
  for (let i = 0;i < features_length; ++i) {
11234
11234
  const index = i * num_features + j;
11235
- features_data[index] = (features_data[index] - mean2) * inv_std;
11235
+ features_data[index] = (features_data[index] - mean) * inv_std;
11236
11236
  }
11237
11237
  }
11238
11238
  const mask_data = new BigInt64Array(num_frames);
@@ -11250,9 +11250,9 @@ class CohereAsrFeatureExtractor extends ParakeetFeatureExtractor {
11250
11250
  const dither = this.config.dither ?? 0;
11251
11251
  if (dither <= 0)
11252
11252
  return waveform;
11253
- const rng2 = new Random(waveform.length);
11253
+ const rng = new Random(waveform.length);
11254
11254
  for (let i = 0;i < waveform.length; ++i) {
11255
- waveform[i] += dither * rng2.gauss();
11255
+ waveform[i] += dither * rng.gauss();
11256
11256
  }
11257
11257
  return waveform;
11258
11258
  }
@@ -11533,36 +11533,36 @@ class SeamlessM4TFeatureExtractor extends FeatureExtractor {
11533
11533
  for (let j = 0;j < num_features; ++j) {
11534
11534
  sum += data[j * feature_size + i];
11535
11535
  }
11536
- const mean2 = sum / num_features;
11536
+ const mean = sum / num_features;
11537
11537
  let variance = 0;
11538
11538
  for (let j = 0;j < num_features; ++j) {
11539
- variance += (data[j * feature_size + i] - mean2) ** 2;
11539
+ variance += (data[j * feature_size + i] - mean) ** 2;
11540
11540
  }
11541
11541
  variance /= num_features - 1;
11542
11542
  const std = Math.sqrt(variance + 0.0000001);
11543
11543
  for (let j = 0;j < num_features; ++j) {
11544
11544
  const index = j * feature_size + i;
11545
- data[index] = (data[index] - mean2) / std;
11545
+ data[index] = (data[index] - mean) / std;
11546
11546
  }
11547
11547
  }
11548
11548
  }
11549
11549
  let padded_attention_mask;
11550
11550
  if (padding) {
11551
- const [num_frames2, num_channels2] = features.dims;
11551
+ const [num_frames, num_channels] = features.dims;
11552
11552
  const data = features.data;
11553
- const pad_size = num_frames2 % pad_to_multiple_of;
11553
+ const pad_size = num_frames % pad_to_multiple_of;
11554
11554
  if (pad_size > 0) {
11555
- const padded_data = new Float32Array(num_channels2 * (num_frames2 + pad_size));
11555
+ const padded_data = new Float32Array(num_channels * (num_frames + pad_size));
11556
11556
  padded_data.set(data);
11557
11557
  padded_data.fill(this.config.padding_value, data.length);
11558
- const numPaddedFrames = num_frames2 + pad_size;
11559
- features = new Tensor3(features.type, padded_data, [numPaddedFrames, num_channels2]);
11558
+ const numPaddedFrames = num_frames + pad_size;
11559
+ features = new Tensor3(features.type, padded_data, [numPaddedFrames, num_channels]);
11560
11560
  if (return_attention_mask) {
11561
11561
  padded_attention_mask = new Tensor3("int64", new BigInt64Array(numPaddedFrames), [
11562
11562
  1,
11563
11563
  numPaddedFrames
11564
11564
  ]);
11565
- padded_attention_mask.data.fill(1n, 0, num_frames2);
11565
+ padded_attention_mask.data.fill(1n, 0, num_frames);
11566
11566
  }
11567
11567
  }
11568
11568
  }
@@ -11600,9 +11600,9 @@ class SpeechT5FeatureExtractor extends FeatureExtractor {
11600
11600
  class Wav2Vec2FeatureExtractor extends FeatureExtractor {
11601
11601
  _zero_mean_unit_var_norm(input_values) {
11602
11602
  const sum = input_values.reduce((a, b) => a + b, 0);
11603
- const mean2 = sum / input_values.length;
11604
- const variance = input_values.reduce((a, b) => a + (b - mean2) ** 2, 0) / input_values.length;
11605
- return input_values.map((x) => (x - mean2) / Math.sqrt(variance + 0.0000001));
11603
+ const mean = sum / input_values.length;
11604
+ const variance = input_values.reduce((a, b) => a + (b - mean) ** 2, 0) / input_values.length;
11605
+ return input_values.map((x) => (x - mean) / Math.sqrt(variance + 0.0000001));
11606
11606
  }
11607
11607
  async _call(audio) {
11608
11608
  validate_audio_inputs(audio, "Wav2Vec2FeatureExtractor");
@@ -11867,10 +11867,10 @@ class RawImage {
11867
11867
  const data = ctx.getImageData(0, 0, canvas.width, canvas.height).data;
11868
11868
  return new RawImage(data, canvas.width, canvas.height, 4);
11869
11869
  }
11870
- static async fromURL(url2) {
11871
- const response = await getFile(url2);
11870
+ static async fromURL(url) {
11871
+ const response = await getFile(url);
11872
11872
  if (response.status !== 200) {
11873
- throw new Error(`Unable to read image from "${url2}" (${response.status} ${response.statusText})`);
11873
+ throw new Error(`Unable to read image from "${url}" (${response.status} ${response.statusText})`);
11874
11874
  }
11875
11875
  const blob = await response.blob();
11876
11876
  return this.fromBlob(blob);
@@ -11886,26 +11886,26 @@ class RawImage {
11886
11886
  return await loadImageFunction(img);
11887
11887
  }
11888
11888
  }
11889
- static fromTensor(tensor2, channel_format = "CHW") {
11890
- if (tensor2.dims.length !== 3) {
11891
- throw new Error(`Tensor should have 3 dimensions, but has ${tensor2.dims.length} dimensions.`);
11889
+ static fromTensor(tensor, channel_format = "CHW") {
11890
+ if (tensor.dims.length !== 3) {
11891
+ throw new Error(`Tensor should have 3 dimensions, but has ${tensor.dims.length} dimensions.`);
11892
11892
  }
11893
11893
  if (channel_format === "CHW") {
11894
- tensor2 = tensor2.transpose(1, 2, 0);
11894
+ tensor = tensor.transpose(1, 2, 0);
11895
11895
  } else if (channel_format === "HWC") {} else {
11896
11896
  throw new Error(`Unsupported channel format: ${channel_format}`);
11897
11897
  }
11898
- if (!(tensor2.data instanceof Uint8ClampedArray || tensor2.data instanceof Uint8Array)) {
11899
- throw new Error(`Unsupported tensor type: ${tensor2.type}`);
11898
+ if (!(tensor.data instanceof Uint8ClampedArray || tensor.data instanceof Uint8Array)) {
11899
+ throw new Error(`Unsupported tensor type: ${tensor.type}`);
11900
11900
  }
11901
- switch (tensor2.dims[2]) {
11901
+ switch (tensor.dims[2]) {
11902
11902
  case 1:
11903
11903
  case 2:
11904
11904
  case 3:
11905
11905
  case 4:
11906
- return new RawImage(tensor2.data, tensor2.dims[1], tensor2.dims[0], tensor2.dims[2]);
11906
+ return new RawImage(tensor.data, tensor.dims[1], tensor.dims[0], tensor.dims[2]);
11907
11907
  default:
11908
- throw new Error(`Unsupported number of channels: ${tensor2.dims[2]}`);
11908
+ throw new Error(`Unsupported number of channels: ${tensor.dims[2]}`);
11909
11909
  }
11910
11910
  }
11911
11911
  grayscale() {
@@ -12192,13 +12192,13 @@ class RawImage {
12192
12192
  return await canvas.convertToBlob({ type, quality });
12193
12193
  }
12194
12194
  toTensor(channel_format = "CHW") {
12195
- let tensor2 = new Tensor3("uint8", new Uint8Array(this.data), [this.height, this.width, this.channels]);
12195
+ let tensor = new Tensor3("uint8", new Uint8Array(this.data), [this.height, this.width, this.channels]);
12196
12196
  if (channel_format === "HWC") {} else if (channel_format === "CHW") {
12197
- tensor2 = tensor2.permute(2, 0, 1);
12197
+ tensor = tensor.permute(2, 0, 1);
12198
12198
  } else {
12199
12199
  throw new Error(`Unsupported channel format: ${channel_format}`);
12200
12200
  }
12201
- return tensor2;
12201
+ return tensor;
12202
12202
  }
12203
12203
  toCanvas() {
12204
12204
  if (!apis.IS_WEB_ENV) {
@@ -12221,7 +12221,7 @@ class RawImage {
12221
12221
  split_data[j][i] = data[data_offset + j];
12222
12222
  }
12223
12223
  }
12224
- return split_data.map((data2) => new RawImage(data2, width, height, 1));
12224
+ return split_data.map((data) => new RawImage(data, width, height, 1));
12225
12225
  }
12226
12226
  _update(data, width, height, channels = null) {
12227
12227
  this.data = data;
@@ -12253,18 +12253,18 @@ class RawImage {
12253
12253
  }
12254
12254
  return this;
12255
12255
  }
12256
- async save(path3) {
12256
+ async save(path) {
12257
12257
  if (apis.IS_WEB_ENV) {
12258
12258
  if (apis.IS_WEBWORKER_ENV) {
12259
12259
  throw new Error("Unable to save an image from a Web Worker.");
12260
12260
  }
12261
- const extension = path3.split(".").pop().toLowerCase();
12261
+ const extension = path.split(".").pop().toLowerCase();
12262
12262
  const mime = CONTENT_TYPE_MAP2.get(extension) ?? "image/png";
12263
12263
  const blob = await this.toBlob(mime);
12264
- return saveBlob(path3, blob);
12264
+ return saveBlob(path, blob);
12265
12265
  } else if (apis.IS_FS_AVAILABLE) {
12266
12266
  const img = this.toSharp();
12267
- await img.toFile(path3);
12267
+ await img.toFile(path);
12268
12268
  } else {
12269
12269
  throw new Error("Unable to save the image because filesystem is disabled in this environment.");
12270
12270
  }
@@ -12345,7 +12345,7 @@ function post_process_object_detection(outputs, threshold = 0.5, target_sizes =
12345
12345
  let box = bbox[j].data;
12346
12346
  box = center_to_corners_format(box);
12347
12347
  if (target_size !== null) {
12348
- box = box.map((x, i2) => x * target_size[(i2 + 1) % 2]);
12348
+ box = box.map((x, i) => x * target_size[(i + 1) % 2]);
12349
12349
  }
12350
12350
  info.boxes.push(box);
12351
12351
  info.classes.push(index);
@@ -12519,9 +12519,9 @@ function post_process_panoptic_segmentation(outputs, threshold = 0.5, mask_thres
12519
12519
  let [mask_probs_item, pred_scores_item, pred_labels_item] = remove_low_and_no_objects(class_logits, mask_logits, threshold, num_labels);
12520
12520
  if (pred_labels_item.length === 0) {
12521
12521
  let [height, width] = target_size ?? mask_logits.dims.slice(-2);
12522
- let segmentation2 = new Tensor3("int32", new Int32Array(height * width).fill(-1), [height, width]);
12522
+ let segmentation = new Tensor3("int32", new Int32Array(height * width).fill(-1), [height, width]);
12523
12523
  toReturn.push({
12524
- segmentation: segmentation2,
12524
+ segmentation,
12525
12525
  segments_info: []
12526
12526
  });
12527
12527
  continue;
@@ -13388,8 +13388,8 @@ function get_target_ratios(min_tiles, max_tiles) {
13388
13388
  for (let n = min_tiles;n <= max_tiles; ++n) {
13389
13389
  for (let w = 1;w <= n; ++w) {
13390
13390
  for (let h = 1;h <= n; ++h) {
13391
- const product2 = w * h;
13392
- if (product2 >= min_tiles && product2 <= max_tiles) {
13391
+ const product = w * h;
13392
+ if (product >= min_tiles && product <= max_tiles) {
13393
13393
  const key = w << 16 | h;
13394
13394
  if (!seen.has(key)) {
13395
13395
  seen.add(key);
@@ -13429,11 +13429,11 @@ function convert_image_to_patches(images, patch_size) {
13429
13429
  return new Tensor3("float32", result, [B, ph * pw, patch_dim]);
13430
13430
  }
13431
13431
  function pad_along_first_dim(patches, target_length) {
13432
- const [, len2, dim] = patches.dims;
13432
+ const [, len, dim] = patches.dims;
13433
13433
  const mask_data = new BigInt64Array(target_length);
13434
- mask_data.fill(1n, 0, len2);
13434
+ mask_data.fill(1n, 0, len);
13435
13435
  let padded = patches;
13436
- if (len2 < target_length) {
13436
+ if (len < target_length) {
13437
13437
  const padded_data = new Float32Array(target_length * dim);
13438
13438
  padded_data.set(patches.data);
13439
13439
  padded = new Tensor3("float32", padded_data, [1, target_length, dim]);
@@ -13678,10 +13678,10 @@ class Phi3VImageProcessor extends ImageProcessor {
13678
13678
  const original_sizes = imageData.map((x) => x.original_size);
13679
13679
  const reshaped_input_sizes = imageData.map((x) => x.reshaped_input_size);
13680
13680
  const all_pixel_values = [];
13681
- for (const { pixel_values: pixel_values2 } of imageData) {
13682
- pixel_values2.unsqueeze_(0);
13683
- const [height, width] = pixel_values2.dims.slice(-2);
13684
- const batch_pixel_values = await interpolate_4d(pixel_values2, {
13681
+ for (const { pixel_values } of imageData) {
13682
+ pixel_values.unsqueeze_(0);
13683
+ const [height, width] = pixel_values.dims.slice(-2);
13684
+ const batch_pixel_values = await interpolate_4d(pixel_values, {
13685
13685
  size: [IMAGE_SIZE, IMAGE_SIZE],
13686
13686
  mode: "bicubic"
13687
13687
  });
@@ -13709,7 +13709,7 @@ class Phi3VImageProcessor extends ImageProcessor {
13709
13709
  }
13710
13710
  const starts = [start_y, start_x];
13711
13711
  const ends = [end_y, end_x];
13712
- const patch = await slice2(pixel_values2, starts, ends, SLICE_AXES);
13712
+ const patch = await slice2(pixel_values, starts, ends, SLICE_AXES);
13713
13713
  patches.push(patch);
13714
13714
  }
13715
13715
  }
@@ -13832,9 +13832,9 @@ class SamImageProcessor extends ImageProcessor {
13832
13832
  if (binarize) {
13833
13833
  const data = interpolated_mask.data;
13834
13834
  const binarizedMaskData = new Uint8Array(data.length);
13835
- for (let i2 = 0;i2 < data.length; ++i2) {
13836
- if (data[i2] > mask_threshold) {
13837
- binarizedMaskData[i2] = 1;
13835
+ for (let i = 0;i < data.length; ++i) {
13836
+ if (data[i] > mask_threshold) {
13837
+ binarizedMaskData[i] = 1;
13838
13838
  }
13839
13839
  }
13840
13840
  interpolated_mask = new Tensor3("bool", binarizedMaskData, interpolated_mask.dims);
@@ -14633,11 +14633,11 @@ class MgpstrProcessor extends Processor {
14633
14633
  get wp_tokenizer() {
14634
14634
  return this.components.wp_tokenizer;
14635
14635
  }
14636
- _decode_helper(pred_logits, format2) {
14637
- if (!DECODE_TYPE_MAPPING.hasOwnProperty(format2)) {
14638
- throw new Error(`Format ${format2} is not supported.`);
14636
+ _decode_helper(pred_logits, format) {
14637
+ if (!DECODE_TYPE_MAPPING.hasOwnProperty(format)) {
14638
+ throw new Error(`Format ${format} is not supported.`);
14639
14639
  }
14640
- const [decoder_name, eos_token] = DECODE_TYPE_MAPPING[format2];
14640
+ const [decoder_name, eos_token] = DECODE_TYPE_MAPPING[format];
14641
14641
  const decoder = this[decoder_name].bind(this);
14642
14642
  const [batch_size, batch_max_length] = pred_logits.dims;
14643
14643
  const conf_scores = [];
@@ -14817,8 +14817,8 @@ class PixtralProcessor extends Processor {
14817
14817
  const width_tokens = image_token.repeat(num_width_tokens);
14818
14818
  const row = width_tokens + image_break_token;
14819
14819
  const finalRow = width_tokens + image_end_token;
14820
- const full2 = row.repeat(num_height_tokens - 1) + finalRow;
14821
- text[i] = text[i].replace(image_token, full2);
14820
+ const full = row.repeat(num_height_tokens - 1) + finalRow;
14821
+ text[i] = text[i].replace(image_token, full);
14822
14822
  }
14823
14823
  }
14824
14824
  const text_inputs = text ? this.tokenizer(text, kwargs) : {};
@@ -15505,11 +15505,11 @@ async function getModelDataFiles(pretrained_model_name_or_path, fileName, suffix
15505
15505
  throw new Error(`The number of external data chunks (${num_chunks}) exceeds the maximum allowed value (${MAX_EXTERNAL_DATA_CHUNKS}).`);
15506
15506
  }
15507
15507
  const chunkNames = getExternalDataChunkNames(baseName, num_chunks);
15508
- for (const path3 of chunkNames) {
15509
- const fullPath = `${options.subfolder ?? ""}/${path3}`;
15508
+ for (const path of chunkNames) {
15509
+ const fullPath = `${options.subfolder ?? ""}/${path}`;
15510
15510
  externalDataPromises.push(new Promise(async (resolve, reject) => {
15511
15511
  const data = await getModelFile(pretrained_model_name_or_path, fullPath, true, options, return_path);
15512
- resolve(data instanceof Uint8Array ? { path: path3, data } : path3);
15512
+ resolve(data instanceof Uint8Array ? { path, data } : path);
15513
15513
  }));
15514
15514
  }
15515
15515
  } else if (session_options.externalData !== undefined) {
@@ -15604,25 +15604,25 @@ async function sessionRun(session, inputs) {
15604
15604
  const checkedInputs = validateInputs(session, inputs);
15605
15605
  try {
15606
15606
  const ortFeed = Object.fromEntries(Object.entries(checkedInputs).map(([k, v]) => {
15607
- const tensor2 = v.ort_tensor;
15607
+ const tensor = v.ort_tensor;
15608
15608
  if (apis.IS_NODE_ENV) {
15609
- if (typeof Float16Array !== "undefined" && tensor2.cpuData instanceof Float16Array) {
15610
- tensor2.cpuData = new Uint16Array(tensor2.cpuData.buffer);
15609
+ if (typeof Float16Array !== "undefined" && tensor.cpuData instanceof Float16Array) {
15610
+ tensor.cpuData = new Uint16Array(tensor.cpuData.buffer);
15611
15611
  }
15612
15612
  }
15613
- return [k, tensor2];
15613
+ return [k, tensor];
15614
15614
  }));
15615
15615
  const output = await runInferenceSession(session, ortFeed);
15616
15616
  return replaceTensors(output);
15617
15617
  } catch (e) {
15618
- const formatted = Object.fromEntries(Object.entries(checkedInputs).map(([k, tensor2]) => {
15618
+ const formatted = Object.fromEntries(Object.entries(checkedInputs).map(([k, tensor]) => {
15619
15619
  const unpacked = {
15620
- type: tensor2.type,
15621
- dims: tensor2.dims,
15622
- location: tensor2.location
15620
+ type: tensor.type,
15621
+ dims: tensor.dims,
15622
+ location: tensor.location
15623
15623
  };
15624
15624
  if (unpacked.location !== "gpu-buffer") {
15625
- unpacked.data = tensor2.data;
15625
+ unpacked.data = tensor.data;
15626
15626
  }
15627
15627
  return [k, unpacked];
15628
15628
  }));
@@ -15635,12 +15635,12 @@ function validateInputs(session, inputs) {
15635
15635
  const checkedInputs = Object.create(null);
15636
15636
  const missingInputs = [];
15637
15637
  for (const inputName of session.inputNames) {
15638
- const tensor2 = inputs[inputName];
15639
- if (!(tensor2 instanceof Tensor3)) {
15638
+ const tensor = inputs[inputName];
15639
+ if (!(tensor instanceof Tensor3)) {
15640
15640
  missingInputs.push(inputName);
15641
15641
  continue;
15642
15642
  }
15643
- checkedInputs[inputName] = isONNXProxy() ? tensor2.clone() : tensor2;
15643
+ checkedInputs[inputName] = isONNXProxy() ? tensor.clone() : tensor;
15644
15644
  }
15645
15645
  if (missingInputs.length > 0) {
15646
15646
  throw new Error(`An error occurred during model execution: "Missing the following inputs: ${missingInputs.join(", ")}.`);
@@ -15892,8 +15892,8 @@ class NoRepeatNGramLogitsProcessor extends LogitsProcessor {
15892
15892
  return bannedTokens;
15893
15893
  } else {
15894
15894
  const generatedNgrams = this.getNgrams(prevInputIds);
15895
- const bannedTokens2 = this.getGeneratedNgrams(generatedNgrams, prevInputIds);
15896
- return bannedTokens2;
15895
+ const bannedTokens = this.getGeneratedNgrams(generatedNgrams, prevInputIds);
15896
+ return bannedTokens;
15897
15897
  }
15898
15898
  }
15899
15899
  _call(input_ids, logits) {
@@ -17087,9 +17087,9 @@ class PreTrainedModel extends Callable {
17087
17087
  const sequences = new Tensor3("int64", all_input_ids.flat(), [all_input_ids.length, all_input_ids[0].length]);
17088
17088
  const past_key_values = getPastKeyValues(outputs, model_inputs.past_key_values);
17089
17089
  const cachedTensors = new Set(Object.values(past_key_values));
17090
- for (const tensor2 of Object.values(outputs)) {
17091
- if (tensor2.location === "gpu-buffer" && !cachedTensors.has(tensor2)) {
17092
- tensor2.dispose();
17090
+ for (const tensor of Object.values(outputs)) {
17091
+ if (tensor.location === "gpu-buffer" && !cachedTensors.has(tensor)) {
17092
+ tensor.dispose();
17093
17093
  }
17094
17094
  }
17095
17095
  const keepCacheAlive = "past_key_values" in kwargs || generation_config.return_dict_in_generate;
@@ -17393,9 +17393,9 @@ function decoder_prepare_inputs_for_generation(self2, input_ids, model_inputs, g
17393
17393
  model_inputs.attention_mask = ones([dims[0], past_length + dims[1]]);
17394
17394
  }
17395
17395
  if (model_inputs.past_key_values) {
17396
- const { input_ids: input_ids2, attention_mask } = model_inputs;
17397
- if (attention_mask && attention_mask.dims[1] > input_ids2.dims[1]) {} else if (past_length < input_ids2.dims[1]) {
17398
- model_inputs.input_ids = input_ids2.slice(null, [past_length, null]);
17396
+ const { input_ids, attention_mask } = model_inputs;
17397
+ if (attention_mask && attention_mask.dims[1] > input_ids.dims[1]) {} else if (past_length < input_ids.dims[1]) {
17398
+ model_inputs.input_ids = input_ids.slice(null, [past_length, null]);
17399
17399
  }
17400
17400
  }
17401
17401
  return model_inputs;
@@ -19367,13 +19367,13 @@ class Qwen2VLForConditionalGeneration extends Qwen2VLPreTrainedModel {
19367
19367
  }
19368
19368
  }
19369
19369
  }
19370
- let count2 = 0;
19370
+ let count = 0;
19371
19371
  for (let y = 0;y < attn_mask.length; ++y) {
19372
19372
  if (attn_mask[y] == 1) {
19373
19373
  for (let x = 0;x < 3; ++x) {
19374
- position_ids_list[x][batch_idx][y] = llm_positions[x * total_len / 3 + count2];
19374
+ position_ids_list[x][batch_idx][y] = llm_positions[x * total_len / 3 + count];
19375
19375
  }
19376
- ++count2;
19376
+ ++count;
19377
19377
  }
19378
19378
  }
19379
19379
  return llm_positions;
@@ -20342,8 +20342,8 @@ class MultiModalityCausalLM extends MultiModalityPreTrainedModel {
20342
20342
  });
20343
20343
  const clamped = decoded_image.add_(1).mul_(255 / 2).clamp_(0, 255).to("uint8");
20344
20344
  const images = [];
20345
- for (const tensor2 of clamped) {
20346
- const img = RawImage.fromTensor(tensor2);
20345
+ for (const tensor of clamped) {
20346
+ const img = RawImage.fromTensor(tensor);
20347
20347
  images.push(img);
20348
20348
  }
20349
20349
  return images;
@@ -21103,10 +21103,10 @@ class SpeechT5ForTextToSpeech extends SpeechT5PreTrainedModel {
21103
21103
  break;
21104
21104
  }
21105
21105
  }
21106
- const spectrogram2 = cat(spectrogramParts);
21107
- const { waveform } = await sessionRun(vocoder.sessions["model"], { spectrogram: spectrogram2 });
21106
+ const spectrogram = cat(spectrogramParts);
21107
+ const { waveform } = await sessionRun(vocoder.sessions["model"], { spectrogram });
21108
21108
  return {
21109
- spectrogram: spectrogram2,
21109
+ spectrogram,
21110
21110
  waveform
21111
21111
  };
21112
21112
  }
@@ -21395,10 +21395,10 @@ class VitPoseForPoseEstimation extends VitPosePreTrainedModel {
21395
21395
  }
21396
21396
  // ../../node_modules/.bun/@huggingface+transformers@4.2.0/node_modules/@huggingface/transformers/src/models/vits/modeling_vits.js
21397
21397
  class VitsModelOutput extends ModelOutput {
21398
- constructor({ waveform, spectrogram: spectrogram2 }) {
21398
+ constructor({ waveform, spectrogram }) {
21399
21399
  super();
21400
21400
  this.waveform = waveform;
21401
- this.spectrogram = spectrogram2;
21401
+ this.spectrogram = spectrogram;
21402
21402
  }
21403
21403
  }
21404
21404
 
@@ -22996,8 +22996,8 @@ class QuestionAnsweringPipeline extends Pipeline {
22996
22996
  const options = product(start_scores, end_scores).filter((x) => x[0][1] <= x[1][1]).map((x) => [x[0][1], x[1][1], x[0][0] * x[1][0]]).sort((a, b) => b[2] - a[2]);
22997
22997
  const sampleResults = [];
22998
22998
  for (let k = 0;k < Math.min(options.length, top_k); ++k) {
22999
- const [start2, end2, score] = options[k];
23000
- const answer_tokens = ids.slice(start2, end2 + 1);
22999
+ const [start, end, score] = options[k];
23000
+ const answer_tokens = ids.slice(start, end + 1);
23001
23001
  const answer = this.tokenizer.decode(answer_tokens, {
23002
23002
  skip_special_tokens: true
23003
23003
  });
@@ -23037,11 +23037,11 @@ class FillMaskPipeline extends Pipeline {
23037
23037
  const scores = await topk(new Tensor3("float32", softmax(itemLogits.data), itemLogits.dims), top_k);
23038
23038
  const values = scores[0].tolist();
23039
23039
  const indices = scores[1].tolist();
23040
- toReturn.push(indices.map((x, i2) => {
23040
+ toReturn.push(indices.map((x, i) => {
23041
23041
  const sequence = ids.slice();
23042
23042
  sequence[mask_token_index] = x;
23043
23043
  return {
23044
- score: values[i2],
23044
+ score: values[i],
23045
23045
  token: Number(x),
23046
23046
  token_str: this.tokenizer.decode([x]),
23047
23047
  sequence: this.tokenizer.decode(sequence, {
@@ -23107,7 +23107,7 @@ class TranslationPipeline extends Text2TextGenerationPipeline {
23107
23107
 
23108
23108
  // ../../node_modules/.bun/@huggingface+transformers@4.2.0/node_modules/@huggingface/transformers/src/pipelines/text-generation.js
23109
23109
  function isChat(x) {
23110
- return Array.isArray(x) && x.every((x2) => ("role" in x2) && ("content" in x2));
23110
+ return Array.isArray(x) && x.every((x) => ("role" in x) && ("content" in x));
23111
23111
  }
23112
23112
 
23113
23113
  class TextGenerationPipeline extends Pipeline {
@@ -23404,10 +23404,10 @@ class AutomaticSpeechRecognitionPipeline extends Pipeline {
23404
23404
  }
23405
23405
  ];
23406
23406
  }
23407
- for (const chunk2 of chunks) {
23408
- generation_config.num_frames = Math.floor(chunk2.stride[0] / hop_length);
23407
+ for (const chunk of chunks) {
23408
+ generation_config.num_frames = Math.floor(chunk.stride[0] / hop_length);
23409
23409
  const data = await this.model.generate({
23410
- inputs: chunk2.input_features,
23410
+ inputs: chunk.input_features,
23411
23411
  ...generation_config
23412
23412
  });
23413
23413
  if (return_timestamps === "word") {
@@ -23415,12 +23415,12 @@ class AutomaticSpeechRecognitionPipeline extends Pipeline {
23415
23415
  const token_ts = data.token_timestamps.tolist()[0];
23416
23416
  const timestamp_begin = this.tokenizer.timestamp_begin;
23417
23417
  const prefixLength = Math.max(sequences.findIndex((t) => Number(t) >= timestamp_begin), 0);
23418
- chunk2.tokens = sequences.slice(prefixLength);
23419
- chunk2.token_timestamps = token_ts.slice(prefixLength).map((x) => round(x, 2));
23418
+ chunk.tokens = sequences.slice(prefixLength);
23419
+ chunk.token_timestamps = token_ts.slice(prefixLength).map((x) => round(x, 2));
23420
23420
  } else {
23421
- chunk2.tokens = data[0].tolist();
23421
+ chunk.tokens = data[0].tolist();
23422
23422
  }
23423
- chunk2.stride = chunk2.stride.map((x) => x / sampling_rate);
23423
+ chunk.stride = chunk.stride.map((x) => x / sampling_rate);
23424
23424
  }
23425
23425
  const [full_text, optional] = this.tokenizer._decode_asr(chunks, {
23426
23426
  time_precision,
@@ -23458,8 +23458,8 @@ class AutomaticSpeechRecognitionPipeline extends Pipeline {
23458
23458
  for (const aud of preparedAudios) {
23459
23459
  const audioChunks = feature_extractor.split_audio(aud);
23460
23460
  const chunk_texts = [];
23461
- for (const chunk2 of audioChunks) {
23462
- const inputs = await this.processor(chunk2);
23461
+ for (const chunk of audioChunks) {
23462
+ const inputs = await this.processor(chunk);
23463
23463
  const outputs = await this.model.generate({
23464
23464
  ...inputs,
23465
23465
  decoder_input_ids,
@@ -23800,16 +23800,16 @@ class ZeroShotObjectDetectionPipeline extends Pipeline {
23800
23800
  text_threshold: threshold,
23801
23801
  target_sizes: imageSize
23802
23802
  })[0];
23803
- result = processed.boxes.map((box, i2) => ({
23804
- score: processed.scores[i2],
23805
- label: processed.labels[i2],
23803
+ result = processed.boxes.map((box, i) => ({
23804
+ score: processed.scores[i],
23805
+ label: processed.labels[i],
23806
23806
  box: get_bounding_box(box, !percentage)
23807
23807
  }));
23808
23808
  } else {
23809
23809
  const processed = this.processor.image_processor.post_process_object_detection(output, threshold, imageSize, true)[0];
23810
- result = processed.boxes.map((box, i2) => ({
23811
- score: processed.scores[i2],
23812
- label: candidate_labels[processed.classes[i2]],
23810
+ result = processed.boxes.map((box, i) => ({
23811
+ score: processed.scores[i],
23812
+ label: candidate_labels[processed.classes[i]],
23813
23813
  box: get_bounding_box(box, !percentage)
23814
23814
  }));
23815
23815
  }
@@ -24373,9 +24373,9 @@ class TextStreamer extends BaseStreamer {
24373
24373
  if (this.decode_kwargs.skip_special_tokens)
24374
24374
  return;
24375
24375
  if (this.token_cache.length > 0) {
24376
- const text2 = this.tokenizer.decode(this.token_cache, this.decode_kwargs);
24377
- const printable_text2 = text2.slice(this.print_len);
24378
- this.on_finalized_text(printable_text2, false);
24376
+ const text = this.tokenizer.decode(this.token_cache, this.decode_kwargs);
24377
+ const printable_text = text.slice(this.print_len);
24378
+ this.on_finalized_text(printable_text, false);
24379
24379
  this.token_cache = [];
24380
24380
  this.print_len = 0;
24381
24381
  }
@@ -24530,16 +24530,16 @@ async function load_video(src, { num_frames = null, fps = null } = {}) {
24530
24530
  await new Promise((resolve) => video.onloadedmetadata = resolve);
24531
24531
  }
24532
24532
  const duration = video.duration;
24533
- let count2, step;
24533
+ let count, step;
24534
24534
  if (num_frames != null) {
24535
- count2 = num_frames;
24535
+ count = num_frames;
24536
24536
  step = num_frames === 1 ? 0 : duration / (num_frames - 1);
24537
24537
  } else {
24538
24538
  step = 1 / fps;
24539
- count2 = Math.floor(duration / step);
24539
+ count = Math.floor(duration / step);
24540
24540
  }
24541
24541
  let sampleTimes = [];
24542
- for (let i = 0;i < count2; ++i) {
24542
+ for (let i = 0;i < count; ++i) {
24543
24543
  sampleTimes.push(num_frames === 1 ? duration / 2 : i * step);
24544
24544
  }
24545
24545
  const canvas = document.createElement("canvas");
@@ -24562,24 +24562,24 @@ async function load_video(src, { num_frames = null, fps = null } = {}) {
24562
24562
  }
24563
24563
  // ../../node_modules/.bun/@huggingface+transformers@4.2.0/node_modules/@huggingface/transformers/src/utils/model_registry/is_cached.js
24564
24564
  async function check_files_cache(modelId, files, options = {}) {
24565
- const cache2 = await getCache(options?.cache_dir);
24566
- if (!cache2) {
24567
- const fileStatuses2 = files.map((filename) => ({ file: filename, cached: false }));
24568
- return { allCached: false, files: fileStatuses2 };
24565
+ const cache = await getCache(options?.cache_dir);
24566
+ if (!cache) {
24567
+ const fileStatuses = files.map((filename) => ({ file: filename, cached: false }));
24568
+ return { allCached: false, files: fileStatuses };
24569
24569
  }
24570
24570
  const fileStatuses = await Promise.all(files.map(async (filename) => {
24571
- const { localPath, proposedCacheKey } = buildResourcePaths(modelId, filename, options, cache2);
24572
- const cached = await checkCachedResource(cache2, localPath, proposedCacheKey);
24571
+ const { localPath, proposedCacheKey } = buildResourcePaths(modelId, filename, options, cache);
24572
+ const cached = await checkCachedResource(cache, localPath, proposedCacheKey);
24573
24573
  return { file: filename, cached: !!cached };
24574
24574
  }));
24575
24575
  return { allCached: fileStatuses.every((f) => f.cached), files: fileStatuses };
24576
24576
  }
24577
24577
  async function is_file_cached(modelId, filename, options = {}) {
24578
- const cache2 = await getCache(options?.cache_dir);
24579
- if (!cache2)
24578
+ const cache = await getCache(options?.cache_dir);
24579
+ if (!cache)
24580
24580
  return false;
24581
- const { localPath, proposedCacheKey } = buildResourcePaths(modelId, filename, options, cache2);
24582
- return !!await checkCachedResource(cache2, localPath, proposedCacheKey);
24581
+ const { localPath, proposedCacheKey } = buildResourcePaths(modelId, filename, options, cache);
24582
+ return !!await checkCachedResource(cache, localPath, proposedCacheKey);
24583
24583
  }
24584
24584
  async function is_cached(modelId, options = {}) {
24585
24585
  if (!modelId) {
@@ -24626,25 +24626,25 @@ async function is_pipeline_cached_files(task, modelId, options = {}) {
24626
24626
 
24627
24627
  // ../../node_modules/.bun/@huggingface+transformers@4.2.0/node_modules/@huggingface/transformers/src/utils/model_registry/clear_cache.js
24628
24628
  async function clear_files_from_cache(modelId, files, options = {}) {
24629
- const cache2 = await getCache(options?.cache_dir);
24630
- if (!cache2) {
24629
+ const cache = await getCache(options?.cache_dir);
24630
+ if (!cache) {
24631
24631
  return {
24632
24632
  filesDeleted: 0,
24633
24633
  filesCached: 0,
24634
24634
  files: files.map((filename) => ({ file: filename, deleted: false, wasCached: false }))
24635
24635
  };
24636
24636
  }
24637
- if (!cache2.delete) {
24637
+ if (!cache.delete) {
24638
24638
  throw new Error("Cache does not support delete operation");
24639
24639
  }
24640
24640
  const results = await Promise.all(files.map(async (filename) => {
24641
- const { localPath, proposedCacheKey } = buildResourcePaths(modelId, filename, options, cache2);
24642
- const cached = await checkCachedResource(cache2, localPath, proposedCacheKey);
24641
+ const { localPath, proposedCacheKey } = buildResourcePaths(modelId, filename, options, cache);
24642
+ const cached = await checkCachedResource(cache, localPath, proposedCacheKey);
24643
24643
  const wasCached = !!cached;
24644
24644
  let deleted = false;
24645
24645
  if (wasCached) {
24646
- const deletedWithProposed = await cache2.delete(proposedCacheKey);
24647
- const deletedWithLocal = !deletedWithProposed && proposedCacheKey !== localPath ? await cache2.delete(localPath) : false;
24646
+ const deletedWithProposed = await cache.delete(proposedCacheKey);
24647
+ const deletedWithLocal = !deletedWithProposed && proposedCacheKey !== localPath ? await cache.delete(localPath) : false;
24648
24648
  deleted = deletedWithProposed || deletedWithLocal;
24649
24649
  }
24650
24650
  return { file: filename, deleted, wasCached };