@luckylillia-dev/luckylillia 9.0.9 → 9.0.11

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 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-33NXrGUa.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-BUe8e_Ex.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";
@@ -754,8 +754,35 @@ function resolvePluginSpecifier(state, specifier, context, nextResolve, moduleTy
754
754
  url: pinned,
755
755
  shortCircuit: true
756
756
  };
757
- const result = nextResolve(specifier, context);
758
757
  const parent = context.parentURL;
758
+ const ownerRoot = parent?.startsWith("file:") ? packageRootOf(state.roots, parent) : void 0;
759
+ const owner = ownerRoot && [...state.plugins?.entries() ?? []].find(([, pkg]) => pkg.root === ownerRoot);
760
+ const name = specifier.startsWith("@") ? specifier.split("/").slice(0, 2).join("/") : specifier.split("/")[0];
761
+ const provider = owner && Object.hasOwn(owner[1].dependencies, name) && state.plugins?.get(name);
762
+ if (provider) {
763
+ const metadataUrl = new URL("package.json", provider.root);
764
+ const metadata = JSON.parse(readFileSync(metadataUrl, "utf8"));
765
+ const subpath = specifier.slice(name.length);
766
+ const result = nextResolve(metadata.exports !== void 0 ? metadata.name + subpath : new URL(subpath ? "." + subpath : metadata.main ?? "index.js", provider.root).href, {
767
+ ...context,
768
+ parentURL: metadataUrl.href
769
+ });
770
+ if (state.imports) {
771
+ const imports = state.imports.get(owner[0]) ?? /* @__PURE__ */ new Set();
772
+ imports.add(name);
773
+ state.imports.set(owner[0], imports);
774
+ }
775
+ if (result.url.startsWith(provider.root) && !isCommonJS(result.url, moduleType)) {
776
+ const url = new URL(result.url);
777
+ url.searchParams.set("v", String(state.epoch?.(name) ?? 1));
778
+ return {
779
+ ...result,
780
+ url: url.href
781
+ };
782
+ }
783
+ return result;
784
+ }
785
+ const result = nextResolve(specifier, context);
759
786
  if (!parent?.startsWith("file:") || !result.url.startsWith("file:")) return result;
760
787
  const epoch = new URL(parent).searchParams.get("v");
761
788
  if (!epoch) return result;
@@ -7064,6 +7091,13 @@ var Market = class {
7064
7091
  }
7065
7092
  async installCatalog(name, version, onProgress) {
7066
7093
  this.assertManageable(name);
7094
+ return this.installPlan(await this.catalogPlan(name, version), onProgress);
7095
+ }
7096
+ /**
7097
+ * What installing a plugin from the market writes: the version the catalog lists, and the plugins it needs at
7098
+ * the versions the catalog lists for them. The WebUI and startup requests both install this.
7099
+ */
7100
+ async catalogPlan(name, version) {
7067
7101
  const catalog = await this.catalog.load();
7068
7102
  const entry = this.assertListed(catalog, name);
7069
7103
  if (version !== void 0 && version !== entry.version) throw new MarketError(`${name}@${version} is not the catalog version ${entry.version}; refresh the plugin market`, 409);
@@ -7073,10 +7107,12 @@ var Market = class {
7073
7107
  if (builtin && !newer(chosen.version, builtin.version)) throw new MarketError(`${name}@${chosen.version} is not newer than installed version ${builtin.version}`, 409);
7074
7108
  const problem = this.incompatibility(chosen);
7075
7109
  if (problem) throw new MarketError(`${name}@${entry.version} cannot run on this bot: ${problem}`, 409);
7076
- const plan = await this.planPlugins(this.planned(source, name), catalog);
7077
- return this.installPlan(plan, onProgress);
7110
+ return this.planPlugins(this.planned(source, name), catalog);
7078
7111
  }
7079
- /** Explicit startup requests use npm directly. Existing packages are never updated by this operation. */
7112
+ /**
7113
+ * Explicit startup requests (`--plugin`) install what the market installs: the catalog version, never npm's
7114
+ * latest, so a package the catalog does not list is refused. Existing packages are never updated by this operation.
7115
+ */
7080
7116
  ensureRequested(name) {
7081
7117
  if (!isPackageName(name)) return Promise.reject(new MarketError("启动插件参数必须是 npm 包名"));
7082
7118
  if (!this.ctx.plugins.packageRootWritable(this.installer.root)) {
@@ -7096,17 +7132,16 @@ var Market = class {
7096
7132
  }
7097
7133
  return this.serial(async () => {
7098
7134
  const existing = this.installedPackages().find((pkg) => pkg.name === currentPackageName(name));
7099
- let main;
7100
- if (existing) main = {
7135
+ let plan;
7136
+ if (existing) plan = await this.planPlugins({
7101
7137
  name,
7102
7138
  version: existing.version,
7103
7139
  dependencies: parsePluginDependencies(existing.manifest.dependencies)
7104
- };
7140
+ });
7105
7141
  else {
7106
7142
  this.assertManageable(name);
7107
- main = this.planned({ manifest: await this.requestedVersion(name, []) }, name);
7143
+ plan = await this.catalogPlan(name);
7108
7144
  }
7109
- const plan = await this.planPlugins(main, void 0, void 0, (dependency, ranges) => this.requestedVersion(dependency, ranges));
7110
7145
  const installed = [];
7111
7146
  for (const item of plan) if (item.source) installed.push(await this.installPackage(item.source));
7112
7147
  return {
@@ -7115,14 +7150,6 @@ var Market = class {
7115
7150
  };
7116
7151
  });
7117
7152
  }
7118
- async requestedVersion(name, ranges) {
7119
- const accept = (candidate) => candidate.name === name && isExactVersion(candidate.version) && ranges.every((range) => matchesPluginVersion(candidate.version, range)) && !this.incompatibility(candidate);
7120
- const document = await this.registry.packument(name, true, (document) => !!pickVersion(document, ranges[0] ?? "latest", accept));
7121
- if (document.name !== name) throw new MarketError(`npm 返回的包与请求的 ${name} 不符`);
7122
- const version = pickVersion(document, ranges[0] ?? "latest", accept);
7123
- if (!version) throw new MarketError(`${name} 没有满足当前 Bot 和插件依赖要求的 npm 版本`, 409);
7124
- return version;
7125
- }
7126
7153
  /** Local uploads need no catalog approval; missing plugin dependencies still come from its pinned versions. */
7127
7154
  installLocal(archive, filename) {
7128
7155
  return this.trackTask(":local", async (report) => {
@@ -8982,13 +9009,16 @@ var PluginService = class extends Service {
8982
9009
  packages = /* @__PURE__ */ new Map();
8983
9010
  modules = /* @__PURE__ */ new Map();
8984
9011
  epochs = /* @__PURE__ */ new Map();
9012
+ moduleEpochs = /* @__PURE__ */ new Map();
8985
9013
  runtimes = /* @__PURE__ */ new Map();
8986
9014
  fiberIds = /* @__PURE__ */ new WeakMap();
8987
9015
  locks = /* @__PURE__ */ new Map();
8988
9016
  webuiVersions = /* @__PURE__ */ new Map();
8989
9017
  resolver = {
8990
9018
  shared: /* @__PURE__ */ new Map(),
8991
- roots: []
9019
+ roots: [],
9020
+ imports: /* @__PURE__ */ new Map(),
9021
+ epoch: (name) => this.moduleEpochs.get(name) ?? 1
8992
9022
  };
8993
9023
  resolverInstalled = false;
8994
9024
  sdkVersion;
@@ -9253,6 +9283,7 @@ var PluginService = class extends Service {
9253
9283
  entries: entries()
9254
9284
  };
9255
9285
  await this.lock(change.name, () => this.reloadPackage(change.name));
9286
+ await this.reloadImportConsumers(change.name);
9256
9287
  const failure = this.list().find((item) => item.name === change.name && !item.disabled && (item.error || item.state === "failed" || item.state === "incompatible"));
9257
9288
  if (failure) throw new Error(failure.error ?? "插件启动失败");
9258
9289
  await this.reconcilePackageDependencies();
@@ -9529,7 +9560,9 @@ var PluginService = class extends Service {
9529
9560
  reason: "module.registerHooks is unavailable (Node < 22.15), changed submodules would not be re-imported"
9530
9561
  };
9531
9562
  try {
9532
- return await this.lock(rt.entry.name, () => this.reloadPackage(rt.entry.name));
9563
+ const result = await this.lock(rt.entry.name, () => this.reloadPackage(rt.entry.name));
9564
+ await this.reloadImportConsumers(rt.entry.name);
9565
+ return result;
9533
9566
  } finally {
9534
9567
  await this.reconcilePackageDependencies();
9535
9568
  }
@@ -9771,6 +9804,10 @@ var PluginService = class extends Service {
9771
9804
  return old && shown(old) !== shown(pkg);
9772
9805
  });
9773
9806
  this.packages = next;
9807
+ this.resolver.plugins = new Map([...next.values()].map((pkg) => [pkg.name, {
9808
+ root: pathToFileURL(pkg.root + path.sep).href,
9809
+ dependencies: pkg.manifest.dependencies ?? {}
9810
+ }]));
9774
9811
  this.resolver.roots = [...next.values(), ...this.builtinPackages.list().flatMap((item) => {
9775
9812
  const pkg = this.builtinPackages.package(item.entryName);
9776
9813
  return pkg ? [pkg] : [];
@@ -9816,6 +9853,8 @@ var PluginService = class extends Service {
9816
9853
  if (cached && !fresh) return cached;
9817
9854
  const epoch = (this.epochs.get(pkg.name) ?? 0) + 1;
9818
9855
  this.epochs.set(pkg.name, epoch);
9856
+ const previousEpoch = this.moduleEpochs.get(pkg.name);
9857
+ this.moduleEpochs.set(pkg.name, epoch);
9819
9858
  const loaded = {};
9820
9859
  try {
9821
9860
  const plugin = unwrapPlugin(await __vitePreload(() => import(`${pathToFileURL(pkg.main).href}?v=${epoch}`), []));
@@ -9823,6 +9862,8 @@ var PluginService = class extends Service {
9823
9862
  if (bundlesOwnCordis(plugin)) throw new Error(`the plugin carries its own copy of cordis; build it with cordis and ${SDK_PACKAGE} marked external`);
9824
9863
  loaded.plugin = plugin;
9825
9864
  } catch (e) {
9865
+ if (previousEpoch === void 0) this.moduleEpochs.delete(pkg.name);
9866
+ else this.moduleEpochs.set(pkg.name, previousEpoch);
9826
9867
  loaded.error = errorText(e);
9827
9868
  }
9828
9869
  if (loaded.plugin || !cached) this.modules.set(pkg.name, loaded);
@@ -9950,6 +9991,10 @@ var PluginService = class extends Service {
9950
9991
  const pkg = await readPluginPackage(known.root) ?? known;
9951
9992
  pkg.location = known.location;
9952
9993
  this.packages.set(name, pkg);
9994
+ this.resolver.plugins?.set(name, {
9995
+ root: pathToFileURL(pkg.root + path.sep).href,
9996
+ dependencies: pkg.manifest.dependencies ?? {}
9997
+ });
9953
9998
  this.bumpWebui(name);
9954
9999
  const targets = this.entriesOf(name).filter((rt) => !this.isDisabled(rt));
9955
10000
  if (this.incompatibility(pkg) || targets.some((rt) => this.packageBlock(rt))) {
@@ -9978,6 +10023,26 @@ var PluginService = class extends Service {
9978
10023
  await Promise.all(targets.map((rt) => rt.fiber?.await().catch(() => {})));
9979
10024
  return { status: "reloaded" };
9980
10025
  }
10026
+ /** Imports capture ES module instances. Refresh consumers after a provider reload, outside its lock. */
10027
+ async reloadImportConsumers(provider) {
10028
+ const graph = this.resolver.imports ?? /* @__PURE__ */ new Map();
10029
+ const affected = /* @__PURE__ */ new Set([provider]);
10030
+ for (const name of affected) for (const [consumer, imports] of graph) if (imports.has(name)) affected.add(consumer);
10031
+ const visited = /* @__PURE__ */ new Set([provider]);
10032
+ const order = [];
10033
+ const visit = (name) => {
10034
+ if (visited.has(name)) return;
10035
+ visited.add(name);
10036
+ for (const dependency of graph.get(name) ?? []) if (affected.has(dependency)) visit(dependency);
10037
+ order.push(name);
10038
+ };
10039
+ for (const name of affected) visit(name);
10040
+ for (const consumer of order) {
10041
+ if (!this.packages.has(consumer)) continue;
10042
+ if (this.entriesOf(consumer).some((rt) => !this.isDisabled(rt))) await this.lock(consumer, () => this.reloadPackage(consumer));
10043
+ else this.modules.delete(consumer);
10044
+ }
10045
+ }
9981
10046
  onFiberStatus(fiber) {
9982
10047
  this.observeBuiltinFailure(fiber);
9983
10048
  const id = this.fiberIds.get(fiber);
@@ -10230,6 +10295,7 @@ var PluginService = class extends Service {
10230
10295
  this.ctx.logger.info(`${pkg.name} changed, reloading`);
10231
10296
  try {
10232
10297
  await this.lock(pkg.name, () => this.reloadPackage(pkg.name));
10298
+ await this.reloadImportConsumers(pkg.name);
10233
10299
  } finally {
10234
10300
  await this.reconcilePackageDependencies();
10235
10301
  }
@@ -14134,39 +14200,63 @@ var SatoriServer = class {
14134
14200
  wsServer;
14135
14201
  wsClients = [];
14136
14202
  routesRegistered = false;
14203
+ internalRoutes = /* @__PURE__ */ new Map();
14137
14204
  constructor(ctx, config, adapter) {
14138
14205
  this.ctx = ctx;
14139
14206
  this.config = config;
14140
14207
  this.adapter = adapter;
14141
14208
  this.app = new Hono();
14142
14209
  }
14143
- async callOneBot11API(action, params) {
14144
- const onebotAdapter = this.ctx.get("onebot") ?? this.ctx.get("ntOnebot");
14145
- if (!onebotAdapter) throw new Error(`OB11 service has not started`);
14146
- const handler = onebotAdapter.actionMap.get(action);
14147
- if (!handler) throw new Error(`Unsupported OB11 action: ${action}`);
14148
- return await handler.handle(params, {
14149
- messageFormat: "array",
14150
- debug: false
14151
- });
14210
+ /** Serves /v1/internal/<name>/... with handler until the returned function runs. */
14211
+ mountInternal(name, handler) {
14212
+ if (this.internalRoutes.has(name)) throw new Error(`Satori internal route ${name} is already mounted`);
14213
+ this.internalRoutes.set(name, handler);
14214
+ return () => {
14215
+ if (this.internalRoutes.get(name) === handler) this.internalRoutes.delete(name);
14216
+ };
14152
14217
  }
14153
- async handleOneBotRequest(c, next) {
14154
- const action = c.req.param("action");
14155
- const payload = c.req.method === "POST" ? await c.req.json() : c.req.query();
14156
- let result;
14218
+ /**
14219
+ * /v1/internal/<path>: Satori's passthrough to the platform's own API, whose request and response formats are the
14220
+ * platform's. A plugin's route serves the paths under its name; the rest is <group>/<method> of the account's
14221
+ * bot.internal, called with the JSON array in the body as its arguments. Only methods of a group are reachable:
14222
+ * functions directly on bot.internal (NTQQ's deprecated OneBot compatibility methods) are not.
14223
+ */
14224
+ async handleInternal(c) {
14225
+ const path = c.req.path.slice(13);
14226
+ const segments = path.split("/");
14227
+ const mounted = this.internalRoutes.get(segments[0]);
14228
+ if (mounted) return mounted.fetch(c.req.raw);
14229
+ if (c.req.method !== "POST") return c.text("Please use POST method to send requests.", 405);
14230
+ const bot = this.botOf(c);
14231
+ if (!bot) return c.text("login not found", 403);
14232
+ const [groupName, methodName, ...rest] = segments.length === 1 ? path.split(".") : segments;
14233
+ const internal = bot.internal ?? {};
14234
+ const found = groupName && Object.hasOwn(internal, groupName) ? internal[groupName] : void 0;
14235
+ const group = found && typeof found === "object" ? found : void 0;
14236
+ const method = !rest.length && methodName && group && Object.hasOwn(group, methodName) ? group[methodName] : void 0;
14237
+ if (typeof method !== "function") return c.text("method not found", 404);
14238
+ let args;
14157
14239
  try {
14158
- result = await this.callOneBot11API(action, payload);
14240
+ const text = await c.req.text();
14241
+ const body = text.trim() ? JSON.parse(text) : [];
14242
+ args = Array.isArray(body) ? body : [body];
14159
14243
  } catch (e) {
14160
- const message = e.message;
14161
- result = {
14162
- status: "failed",
14163
- retcode: 200,
14164
- data: null,
14165
- message,
14166
- wording: message
14167
- };
14244
+ return c.text(`invalid request body: ${e.message}`, 400);
14245
+ }
14246
+ try {
14247
+ const result = await method.apply(group, args);
14248
+ return c.json(result ?? null);
14249
+ } catch (e) {
14250
+ this.ctx.logger.error(e);
14251
+ return c.text(e.message, 500);
14168
14252
  }
14169
- return c.json(result);
14253
+ }
14254
+ /** The login the Satori-Platform and Satori-User-ID headers name */
14255
+ botOf(c) {
14256
+ const selfId = c.req.header("Satori-User-ID");
14257
+ const platform = c.req.header("Satori-Platform");
14258
+ const neutral = platform ? neutralPlatform(platform) : void 0;
14259
+ return selfId && neutral ? this.ctx.bots.get(`${neutral}:${selfId}`) : void 0;
14170
14260
  }
14171
14261
  start() {
14172
14262
  if (!this.routesRegistered) {
@@ -14220,15 +14310,12 @@ var SatoriServer = class {
14220
14310
  }));
14221
14311
  this.app.use("/v1/*", cors());
14222
14312
  this.app.use("/v1/*", this.checkAuth.bind(this));
14223
- this.app.use("/v1/internal/onebot11/:action", this.handleOneBotRequest.bind(this));
14313
+ this.app.all("/v1/internal/*", this.handleInternal.bind(this));
14224
14314
  this.app.get("/v1/*", async (c) => {
14225
14315
  return c.text("Please use POST method to send requests.", 405);
14226
14316
  });
14227
14317
  this.app.post("/v1/:name", async (c) => {
14228
- const selfId = c.req.header("Satori-User-ID");
14229
- const platform = c.req.header("Satori-Platform");
14230
- const neutral = platform ? neutralPlatform(platform) : void 0;
14231
- const bot = selfId && neutral ? this.ctx.bots.get(`${neutral}:${selfId}`) : void 0;
14318
+ const bot = this.botOf(c);
14232
14319
  if (!bot) return c.text("login not found", 403);
14233
14320
  const method = Universal.Methods[c.req.param("name")];
14234
14321
  if (!method || !implemented(bot, method.name)) return c.text("method not found", 404);
@@ -14298,7 +14385,8 @@ var SatoriServer = class {
14298
14385
  //#region src/plugin/internal/adapter/satori/adapter.ts
14299
14386
  /**
14300
14387
  * The bots of the neutral layer (ctx.bots), every one of them, as Satori logins: events from bot/session, API calls
14301
- * to the bot's own methods. Nothing here knows a platform beyond the names clients see (wire.ts).
14388
+ * to the bot's own methods. Nothing here knows a platform beyond the names clients see (wire.ts). ctx.satori is typed
14389
+ * by the plugin SDK, which plugins adding internal routes build against.
14302
14390
  */
14303
14391
  var SatoriAdapter = class extends Service {
14304
14392
  ctx;
@@ -14334,6 +14422,10 @@ var SatoriAdapter = class extends Service {
14334
14422
  });
14335
14423
  return () => this.server.stop();
14336
14424
  }
14425
+ internal(name, handler) {
14426
+ if (!/^[A-Za-z0-9][\w.-]*$/.test(name)) throw new Error(`invalid Satori internal route name ${name}`);
14427
+ return this.ctx.effect(() => this.server.mountInternal(name, handler), `satori.internal(${name})`);
14428
+ }
14337
14429
  loginSn(bot) {
14338
14430
  let sn = this.loginSns.get(bot.sid);
14339
14431
  if (sn === void 0) this.loginSns.set(bot.sid, sn = ++this.nextLoginSn);