@luckylillia-dev/luckylillia 9.0.5 → 9.0.7

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.
package/llbot-core.js CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as Hono, A as Registries, At as require_dist, B as installHostLifecycle, Bt as getPluginDirs, C as scanPluginRoots, Ct as normalizeScope, D as removeScannedPackage, Dt as deepMerge, E as cleanupRemovedPackages, Et as platform_exports, F as parseSpec, G as GATEWAY_SECRET_HEADER, Gt as LOG_DIR, Ht as isDockerEnvironment, I as pickVersion, J as isManaged, Jt as globalVars_exports, L as lockInstance, M as isExactVersion, Mt as configPaths_exports, N as isPackageName, Nt as currentInstance, O as scannedPackagePath, Ot as mergeNewProperties, P as matches, Pt as instance_exports, Q as version_exports, Qt as __toESM, S as resolveMain, St as acceptsScope, T as sdkRangeOf, Tt as normalizePlatformId, Ut as isPluginHmr, Vt as isDevMode, W as GATEWAY_SECRET_ENV, Wt as DATA_DIR, X as protocol_exports, Xt as __exportAll, Y as isManagerMessage, Yt as __commonJSMin, Z as version$10, Zt as __require, _ as manifest_exports, _t as templateSection, at as migrateRenamedPackages, b as parsePluginDependencies, bt as newEntryId, c as marketSettings, ct as renameNativeQQSettings, d as extractPackage, dt as renamed_exports, et as HtmlEscapedCallbackPhase, f as readTarStream, ft as withCurrentNames, g as isInside, gt as templateConfig, h as isImagePath, ht as DEPRECATED_KEYS, it as migrateNTQQMessaging, j as RegistryError, jt as configPaths, k as require_semver, kt as JsonFile, l as registriesOf, lt as RENAMED_PACKAGES, m as SDK_PACKAGE, mt as ADAPTER_KEYS, nt as liftBuiltinSettings, ot as migrateToInstances, p as PLUGIN_CATEGORIES, pt as ADAPTER_ENTRIES, qt as TEMP_DIR, r as coreUpdate_exports, rt as migrateExtractedPlugins, s as MarketSchema, st as migrateWebuiToken, tt as resolveCallback, u as Catalog, ut as currentPackageName, v as matchesPluginVersion, vt as upgradeConfig, w as sdkIncompatibility, wt as normalizePlatform, x as readPluginPackage, xt as normalizeUi, y as normalizeService, yt as PluginStore, zt as environment_exports } from "./chunks/coreUpdate-DyKGU2VM.js";
1
+ import { $ as isManaged, $t as globalVars_exports, A as removeScannedPackage, At as normalizePlatformId, B as parseSpec, C as parsePluginDependencies, Ct as upgradeConfig, D as sdkIncompatibility, Dt as acceptsScope, E as scanPluginRoots, Et as normalizeUi, F as Registry, Ft as require_dist, G as installHostLifecycle, Gt as getPluginDirs, H as lockInstance, I as RegistryError, It as configPaths, Jt as isPluginHmr, Kt as isDevMode, L as isExactVersion, Lt as configPaths_exports, M as require_semver, Mt as deepMerge, N as IntegrityError, Nt as mergeNewProperties, O as sdkRangeOf, Ot as normalizeScope, P as Registries, Pt as JsonFile, Qt as TEMP_DIR, R as isPackageName, Rt as currentInstance, S as normalizeService, St as templateSection, T as resolveMain, Tt as newEntryId, V as pickVersion, Wt as environment_exports, X as GATEWAY_SECRET_HEADER, Xt as LOG_DIR, Y as GATEWAY_SECRET_ENV, Yt as DATA_DIR, _ as SDK_PACKAGE, _t as withCurrentNames, at as HtmlEscapedCallbackPhase, b as manifest_exports, bt as DEPRECATED_KEYS, c as marketSettings, ct as migrateExtractedPlugins, d as DEFAULT_GITHUB_MIRRORS, dt as migrateToInstances, en as __commonJSMin, et as isManagerMessage, f as githubAssetUrl, ft as migrateWebuiToken, g as PLUGIN_CATEGORIES, gt as renamed_exports, h as readTarStream, ht as currentPackageName, it as Hono, j as scannedPackagePath, jt as platform_exports, k as cleanupRemovedPackages, kt as normalizePlatform, l as registriesOf, lt as migrateNTQQMessaging, m as extractPackage, mt as RENAMED_PACKAGES, nn as __require, nt as version$10, ot as resolveCallback, p as isGitHubMirror, pt as renameNativeQQSettings, qt as isDockerEnvironment, r as coreUpdate_exports, rn as __toESM, rt as version_exports, s as MarketSchema, st as liftBuiltinSettings, tn as __exportAll, tt as protocol_exports, u as Catalog, ut as migrateRenamedPackages, v as isImagePath, vt as ADAPTER_ENTRIES, w as readPluginPackage, wt as PluginStore, x as matchesPluginVersion, xt as templateConfig, y as isInside, yt as ADAPTER_KEYS, z as matches, zt as instance_exports } from "./chunks/coreUpdate-Bhae6JrK.js";
2
2
  import { p as compareVersions } from "./chunks/restart-TVy8kurW.js";
3
3
  import { t as __vitePreload } from "./chunks/preload-helper-DxWiKyOd.js";
4
4
  import * as nodeModule from "node:module";
@@ -2000,7 +2000,7 @@ var ArchiveError = class extends Error {
2000
2000
  }
2001
2001
  };
2002
2002
  /** Stream into an isolated temporary directory; the caller removes it on failure or after installation. */
2003
- async function readLocalPackage(archive, filename, directory) {
2003
+ async function readLocalPackage(archive, filename, directory, limits) {
2004
2004
  if (!(await stat$1(archive)).size) throw new ArchiveError("插件压缩包不能为空");
2005
2005
  const zip = /\.zip$/i.test(filename);
2006
2006
  if (!zip && !/\.(tgz|tar\.gz)$/i.test(filename)) throw new ArchiveError("请选择 ZIP 或 npm 格式的 .tgz / .tar.gz 插件包");
@@ -2008,7 +2008,10 @@ async function readLocalPackage(archive, filename, directory) {
2008
2008
  await mkdir(directory, { recursive: true });
2009
2009
  const paths = /* @__PURE__ */ new Map();
2010
2010
  const entries = zip ? readZip(archive) : readNpmTar(archive);
2011
+ let expanded = 0;
2012
+ let count = 0;
2011
2013
  for await (const entry of entries) {
2014
+ if (limits && ++count > limits.maxEntries) throw new ArchiveError("插件压缩包文件数超过限制");
2012
2015
  const relative = packagePath(entry.path, entry.type, !zip);
2013
2016
  if (!relative) continue;
2014
2017
  const key = relative.toLowerCase();
@@ -2036,7 +2039,14 @@ async function readLocalPackage(archive, filename, directory) {
2036
2039
  if (entry.type === "directory") await mkdir(target, { recursive: true });
2037
2040
  else {
2038
2041
  await mkdir(path.dirname(target), { recursive: true });
2039
- await pipeline(entry.data, createWriteStream(target, { flags: "wx" }));
2042
+ async function* bounded() {
2043
+ for await (const chunk of entry.data) {
2044
+ expanded += chunk.length;
2045
+ if (limits && expanded > limits.maxBytes) throw new ArchiveError("插件解压大小超过限制");
2046
+ yield chunk;
2047
+ }
2048
+ }
2049
+ await pipeline(bounded(), createWriteStream(target, { flags: "wx" }));
2040
2050
  }
2041
2051
  }
2042
2052
  const json = paths.get("package.json");
@@ -2151,6 +2161,8 @@ function parseManifest(data) {
2151
2161
  if (value === void 0) continue;
2152
2162
  if (!object(value) || Object.entries(value).some(([name, spec]) => typeof spec !== "string" || field !== "scripts" && !isPackageName(name))) throw new ArchiveError(`package.json 的 ${field} 必须是名称到字符串的对象`);
2153
2163
  }
2164
+ const peers = manifest.peerDependenciesMeta;
2165
+ if (peers !== void 0 && (!object(peers) || Object.entries(peers).some(([name, meta]) => !isPackageName(name) || !object(meta) || meta.optional !== void 0 && typeof meta.optional !== "boolean"))) throw new ArchiveError("package.json 的 peerDependenciesMeta 必须是包名到元数据的对象,optional 必须是布尔值");
2154
2166
  for (const field of ["bundleDependencies", "bundledDependencies"]) {
2155
2167
  const value = manifest[field];
2156
2168
  if (value !== void 0 && typeof value !== "boolean" && (!Array.isArray(value) || !value.every(isPackageName))) throw new ArchiveError(`package.json 的 ${field} 必须是布尔值或包名数组`);
@@ -2881,7 +2893,7 @@ var Installer = class Installer {
2881
2893
  if (totalNodes > 1) emitDownload(`下载并解压依赖 ${completed}/${totalNodes}`);
2882
2894
  return;
2883
2895
  }
2884
- const tarball = await this.registry.tarball(node.source.manifest, void 0, (loaded, total) => {
2896
+ const tarball = node.source.tarball ?? await this.registry.tarball(node.source.manifest, void 0, (loaded, total) => {
2885
2897
  if (totalNodes === 1) {
2886
2898
  if (total && total > 0) {
2887
2899
  const ratio = Math.min(1, loaded / total);
@@ -2971,7 +2983,7 @@ var Installer = class Installer {
2971
2983
  const packument = (name) => {
2972
2984
  let document = documents.get(name);
2973
2985
  if (!document) {
2974
- document = this.registry.packument(name);
2986
+ document = this.registry.packument(name, false, void 0, "install");
2975
2987
  document.catch(() => {});
2976
2988
  documents.set(name, document);
2977
2989
  }
@@ -3003,7 +3015,7 @@ var Installer = class Installer {
3003
3015
  }
3004
3016
  const existing = lookup(node, dep.alias);
3005
3017
  if (existing && existing.source.manifest.name === spec.name && matches(existing.source.manifest.version, spec.range)) continue;
3006
- const version = await packument(spec.name).then((document) => pickVersion(document, spec.range) ?? this.registry.packument(spec.name, false, (document) => !!pickVersion(document, spec.range)).then((document) => pickVersion(document, spec.range))).catch((e) => {
3018
+ const version = await packument(spec.name).then((document) => pickVersion(document, spec.range) ?? this.registry.packument(spec.name, false, (document) => !!pickVersion(document, spec.range), "install").then((document) => pickVersion(document, spec.range))).catch((e) => {
3007
3019
  if (dep.optional) return void 0;
3008
3020
  throw e;
3009
3021
  });
@@ -3080,10 +3092,14 @@ function busy(error, name) {
3080
3092
  }
3081
3093
  function dependenciesOf(manifest) {
3082
3094
  const bundle = manifest.bundleDependencies ?? manifest.bundledDependencies;
3083
- if (bundle === true) return [];
3084
- const bundled = new Set(Array.isArray(bundle) ? bundle : []);
3095
+ const bundled = new Set(bundle === true ? [...Object.keys(manifest.dependencies ?? {}), ...Object.keys(manifest.optionalDependencies ?? {})] : Array.isArray(bundle) ? bundle : []);
3085
3096
  const deps = /* @__PURE__ */ new Map();
3086
3097
  const plugins = new Set(Object.keys(manifest.llbot?.dependencies ?? {}));
3098
+ for (const [alias, spec] of Object.entries(manifest.peerDependencies ?? {})) if (manifest.peerDependenciesMeta?.[alias]?.optional !== true) deps.set(alias, {
3099
+ alias,
3100
+ spec,
3101
+ optional: false
3102
+ });
3087
3103
  for (const [alias, spec] of Object.entries(manifest.dependencies ?? {})) deps.set(alias, {
3088
3104
  alias,
3089
3105
  spec,
@@ -3100,6 +3116,7 @@ function lookup(node, alias) {
3100
3116
  for (let current = node; current; current = current.parent) {
3101
3117
  const found = current.children.get(alias);
3102
3118
  if (found) return found;
3119
+ if (current.alias === alias) return current;
3103
3120
  }
3104
3121
  }
3105
3122
  function depthOf(node) {
@@ -6698,6 +6715,130 @@ async function withLocalUpload(request, root, install) {
6698
6715
  //#region src/plugin/internal/tool/market/origin.ts
6699
6716
  var matchesOrigin = (builtin, origin) => origin === "all" || (origin === "builtin" ? builtin : !builtin);
6700
6717
  //#endregion
6718
+ //#region src/plugin/internal/tool/market/github.ts
6719
+ var MAX_DOWNLOAD = 268435456;
6720
+ var canFallbackToGitHub = (error) => error instanceof RegistryError && !(error instanceof IntegrityError) && (error.status === void 0 || [
6721
+ 404,
6722
+ 408,
6723
+ 429
6724
+ ].includes(error.status) || error.status >= 500);
6725
+ /** Resolve the actual archive before dependency planning, even when npm metadata exists but its file is unavailable. */
6726
+ var GitHubPackages = class {
6727
+ pending = /* @__PURE__ */ new Map();
6728
+ manifests = /* @__PURE__ */ new Map();
6729
+ cache;
6730
+ downloader;
6731
+ mirrors;
6732
+ constructor(mirrors = DEFAULT_GITHUB_MIRRORS, fetch = (url, init) => globalThis.fetch(url, init)) {
6733
+ if (!mirrors.every(isGitHubMirror)) throw new Error("GitHub 镜像必须是无凭据、查询参数和片段的 HTTPS 前缀");
6734
+ this.mirrors = [...new Set(mirrors.map((url) => url.replace(/\/+$/, "") + "/"))];
6735
+ this.downloader = new Registry("https://github.com", async (url, init) => {
6736
+ const controller = new AbortController();
6737
+ const timer = setTimeout(() => controller.abort(/* @__PURE__ */ new Error("GitHub 下载连接超时")), 15e3);
6738
+ try {
6739
+ return await fetch(url, {
6740
+ ...init,
6741
+ credentials: "omit",
6742
+ headers: { Accept: "application/octet-stream" },
6743
+ signal: init?.signal ? AbortSignal.any([init.signal, controller.signal]) : controller.signal
6744
+ });
6745
+ } finally {
6746
+ clearTimeout(timer);
6747
+ }
6748
+ });
6749
+ }
6750
+ resolve(entry, registry, npm, metadataOnly = false) {
6751
+ const key = JSON.stringify([
6752
+ entry.name,
6753
+ entry.version,
6754
+ entry.repository,
6755
+ entry.github,
6756
+ npm?.dist
6757
+ ]);
6758
+ const manifest = this.manifests.get(key);
6759
+ if (metadataOnly && manifest) return Promise.resolve({ manifest });
6760
+ if (this.cache?.key === key && this.cache.expires > Date.now()) return Promise.resolve(this.cache.source);
6761
+ const pending = this.pending.get(key);
6762
+ if (pending) return pending;
6763
+ const result = this.read(entry, registry, npm).then((source) => {
6764
+ if (source.directory === void 0) {
6765
+ if (this.manifests.size >= 64) this.manifests.delete(this.manifests.keys().next().value);
6766
+ this.manifests.set(key, source.manifest);
6767
+ }
6768
+ if (source.directory === void 0 && source.tarball && source.tarball.length <= 33554432) this.cache = {
6769
+ key,
6770
+ expires: Date.now() + 6e4,
6771
+ source
6772
+ };
6773
+ return source;
6774
+ }).finally(() => this.pending.delete(key));
6775
+ this.pending.set(key, result);
6776
+ return result;
6777
+ }
6778
+ async read(entry, registry, npm) {
6779
+ const errors = [];
6780
+ if (npm) try {
6781
+ const data = await registry.tarball(npm, MAX_DOWNLOAD);
6782
+ return await this.inspect(entry, npm, data);
6783
+ } catch (error) {
6784
+ if (!canFallbackToGitHub(error)) throw error;
6785
+ errors.push(error.message);
6786
+ }
6787
+ if (!entry.github) throw new RegistryError("缺少 GitHub 安装来源");
6788
+ const official = githubAssetUrl(entry.repository, entry.github);
6789
+ const version = {
6790
+ name: entry.name,
6791
+ version: entry.version,
6792
+ dist: {
6793
+ tarball: official,
6794
+ integrity: entry.github.integrity
6795
+ }
6796
+ };
6797
+ for (const url of [...this.mirrors.map((prefix) => prefix + official), official]) {
6798
+ let data;
6799
+ try {
6800
+ data = await this.downloader.tarball({
6801
+ ...version,
6802
+ dist: {
6803
+ ...version.dist,
6804
+ tarball: url
6805
+ }
6806
+ }, MAX_DOWNLOAD);
6807
+ } catch (error) {
6808
+ if (!canFallbackToGitHub(error)) throw error;
6809
+ errors.push(error.message);
6810
+ continue;
6811
+ }
6812
+ return this.inspect(entry, version, data);
6813
+ }
6814
+ throw new RegistryError(`${entry.name}@${entry.version}: npm 和 GitHub 下载均不可用:${errors.join("; ")}`);
6815
+ }
6816
+ async inspect(entry, version, data) {
6817
+ const directory = await mkdtemp(path.join(tmpdir(), "luckylillia-github-"));
6818
+ try {
6819
+ const archive = path.join(directory, "plugin.tgz");
6820
+ await writeFile(archive, data);
6821
+ const source = await readLocalPackage(archive, "plugin.tgz", path.join(directory, "package"), {
6822
+ maxBytes: 1073741824,
6823
+ maxEntries: 1e5
6824
+ });
6825
+ if (source.manifest.name !== entry.name || source.manifest.version !== entry.version) throw new IntegrityError(`安装包内的包名或版本与市场目录不一致:${entry.name}@${entry.version}`);
6826
+ return {
6827
+ manifest: {
6828
+ ...source.manifest,
6829
+ dist: version.dist
6830
+ },
6831
+ tarball: data
6832
+ };
6833
+ } finally {
6834
+ await rm(directory, {
6835
+ recursive: true,
6836
+ force: true
6837
+ });
6838
+ }
6839
+ }
6840
+ };
6841
+ //#endregion
6701
6842
  //#region src/plugin/internal/tool/market/index.ts
6702
6843
  var market_exports = /* @__PURE__ */ __exportAll({
6703
6844
  Config: () => Config$4,
@@ -6726,6 +6867,7 @@ var Market = class {
6726
6867
  ctx;
6727
6868
  registry;
6728
6869
  catalog;
6870
+ github;
6729
6871
  installer;
6730
6872
  queue = Promise.resolve();
6731
6873
  serialPending = 0;
@@ -6734,10 +6876,11 @@ var Market = class {
6734
6876
  lastProgressEmit = 0;
6735
6877
  progressTimer;
6736
6878
  /** `root`: the plugin directory it installs into, as a real path */
6737
- constructor(ctx, registry, root, catalog = new Catalog(registry)) {
6879
+ constructor(ctx, registry, root, catalog = new Catalog(registry), github = new GitHubPackages()) {
6738
6880
  this.ctx = ctx;
6739
6881
  this.registry = registry;
6740
6882
  this.catalog = catalog;
6883
+ this.github = github;
6741
6884
  this.installer = new Installer(registry, root, new Set(SHARED_SPECIFIERS));
6742
6885
  }
6743
6886
  progress() {
@@ -6832,7 +6975,7 @@ var Market = class {
6832
6975
  const documents = /* @__PURE__ */ new Map();
6833
6976
  const packument = (name) => {
6834
6977
  let document = documents.get(name);
6835
- if (!document) documents.set(name, document = this.registry.packument(name, true));
6978
+ if (!document) documents.set(name, document = this.registry.packument(name, true, void 0, "install"));
6836
6979
  return document;
6837
6980
  };
6838
6981
  await Promise.all(installed.map(async (pkg) => {
@@ -6845,16 +6988,18 @@ var Market = class {
6845
6988
  return;
6846
6989
  }
6847
6990
  info.latest = entry.version;
6848
- const document = await packument(pkg.name);
6849
- const deprecated = document.versions[pkg.version]?.deprecated;
6991
+ if (entry.github && !newer(entry.version, pkg.version)) return;
6992
+ const document = packument(pkg.name);
6993
+ const source = await this.catalogSource(entry, document, true);
6994
+ const deprecated = await document.then((value) => value.versions[pkg.version]?.deprecated, () => void 0);
6850
6995
  if (deprecated) info.deprecated = deprecated;
6851
- const approved = await this.catalogVersion(entry, document);
6996
+ const approved = source.manifest;
6852
6997
  const problem = this.builtin(pkg.name) && !newer(entry.version, pkg.version) ? void 0 : this.incompatibility(approved);
6853
6998
  if (problem) info.blocked = problem;
6854
6999
  else {
6855
- const main = this.planned({ manifest: approved }, pkg.name);
7000
+ const main = this.planned(source, pkg.name);
6856
7001
  if (newer(entry.version, pkg.version)) {
6857
- await this.planPlugins(main, catalog, packument);
7002
+ await this.planPlugins(main, catalog, packument, void 0, true);
6858
7003
  info.update = entry.version;
6859
7004
  }
6860
7005
  }
@@ -6923,12 +7068,13 @@ var Market = class {
6923
7068
  const catalog = await this.catalog.load();
6924
7069
  const entry = this.assertListed(catalog, name);
6925
7070
  if (version !== void 0 && version !== entry.version) throw new MarketError(`${name}@${version} is not the catalog version ${entry.version}; refresh the plugin market`, 409);
6926
- const chosen = await this.catalogVersion(entry);
7071
+ const source = await this.catalogSource(entry);
7072
+ const chosen = source.manifest;
6927
7073
  const builtin = this.builtin(name);
6928
7074
  if (builtin && !newer(chosen.version, builtin.version)) throw new MarketError(`${name}@${chosen.version} is not newer than installed version ${builtin.version}`, 409);
6929
7075
  const problem = this.incompatibility(chosen);
6930
7076
  if (problem) throw new MarketError(`${name}@${entry.version} cannot run on this bot: ${problem}`, 409);
6931
- const plan = await this.planPlugins(this.planned({ manifest: chosen }, name), catalog);
7077
+ const plan = await this.planPlugins(this.planned(source, name), catalog);
6932
7078
  return this.installPlan(plan, onProgress);
6933
7079
  }
6934
7080
  /** Explicit startup requests use npm directly. Existing packages are never updated by this operation. */
@@ -7028,13 +7174,23 @@ var Market = class {
7028
7174
  if (!entry) throw new MarketError(`${name} is not found in the plugin market list; it cannot be installed`, 404);
7029
7175
  return entry;
7030
7176
  }
7031
- async catalogVersion(entry, document) {
7177
+ async catalogSource(entry, initial, metadataOnly = false) {
7032
7178
  const pinned = (document) => Object.hasOwn(document.versions ?? {}, entry.version);
7033
- if (!document || !pinned(document)) document = await this.registry.packument(entry.name, true, pinned);
7179
+ let document;
7180
+ try {
7181
+ document = await initial;
7182
+ if (!document || !pinned(document)) document = await this.registry.packument(entry.name, true, pinned, "install");
7183
+ } catch (error) {
7184
+ if (!entry.github || !canFallbackToGitHub(error)) throw error;
7185
+ return this.github.resolve(entry, this.registry, void 0, metadataOnly);
7186
+ }
7034
7187
  const version = pinned(document) ? document.versions[entry.version] : void 0;
7035
- if (!version) throw new MarketError(`${entry.name}: catalog version ${entry.version} is unavailable from the npm registry`, 404);
7188
+ if (!version) {
7189
+ if (entry.github) return this.github.resolve(entry, this.registry, void 0, metadataOnly);
7190
+ throw new MarketError(`${entry.name}: catalog version ${entry.version} is unavailable from the npm registry`, 404);
7191
+ }
7036
7192
  if (document.name !== entry.name || version.name !== entry.name || version.version !== entry.version) throw new MarketError(`the registry returned a different package or version for ${entry.name}@${entry.version}`);
7037
- return version;
7193
+ return entry.github ? this.github.resolve(entry, this.registry, version, metadataOnly) : { manifest: version };
7038
7194
  }
7039
7195
  planned(source, name) {
7040
7196
  const version = source.manifest;
@@ -7052,7 +7208,7 @@ var Market = class {
7052
7208
  }
7053
7209
  }
7054
7210
  /** Resolve the complete plugin graph before writing anything. npm library dependencies stay with Installer. */
7055
- async planPlugins(main, catalog, packument = (name) => this.registry.packument(name, true), requestedVersion) {
7211
+ async planPlugins(main, catalog, packument = (name) => this.registry.packument(name, true, void 0, "install"), requestedVersion, metadataOnly = false) {
7056
7212
  const installed = new Map(this.installedPackages().map((pkg) => [pkg.name, pkg]));
7057
7213
  const installedRequirements = /* @__PURE__ */ new Map();
7058
7214
  for (const pkg of installed.values()) {
@@ -7113,13 +7269,14 @@ var Market = class {
7113
7269
  conflict = `${parent} needs ${name}@${ranges.join(" and ")}, but the market catalog only lists ${entry.version}`;
7114
7270
  return;
7115
7271
  }
7116
- const candidate = await this.catalogVersion(entry, await packument(name));
7272
+ const source = await this.catalogSource(entry, packument(name), metadataOnly);
7273
+ const candidate = source.manifest;
7117
7274
  const problem = this.incompatibility(candidate);
7118
7275
  if (problem) {
7119
7276
  conflict = `${parent} needs ${name}, but its catalog version cannot run on this bot: ${problem}`;
7120
7277
  return;
7121
7278
  }
7122
- const item = this.planned({ manifest: candidate }, name);
7279
+ const item = this.planned(source, name);
7123
7280
  return resolve([...rest, ...requirementsOf(item)], new Map(selected).set(name, item));
7124
7281
  };
7125
7282
  const selected = await resolve(requirementsOf(main), /* @__PURE__ */ new Map([[main.name, main]]));
@@ -7264,7 +7421,7 @@ function apply$5(ctx, config) {
7264
7421
  root = realpathSync(root);
7265
7422
  } catch {}
7266
7423
  const registry = new Registries(registriesOf(config), (url, init) => ctx.http.fetch(url, init));
7267
- const market = new Market(ctx, registry, root, new Catalog(registry, config.catalog));
7424
+ const market = new Market(ctx, registry, root, new Catalog(registry, config.catalog), new GitHubPackages(config.githubMirrors, (url, init) => ctx.http.fetch(url, init)));
7268
7425
  market.cleanup().catch((e) => ctx.logger("market").warn(e));
7269
7426
  ctx.inject(["webuiServer"], (ctx) => {
7270
7427
  ctx.webuiServer.route("/api/market", new Hono().route("/api/market", createMarketRoutes(ctx, market)));