@luckylillia-dev/luckylillia 9.0.2 → 9.0.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.
package/llbot-core.js CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as Hono, A as Registries, At as configPaths_exports, B as installHostLifecycle, Bt as isDevMode, C as scanPluginRoots, Ct as normalizePlatform, D as removeScannedPackage, Dt as mergeNewProperties, E as cleanupRemovedPackages, Et as deepMerge, F as parseSpec, G as GATEWAY_SECRET_HEADER, Ht as isPluginHmr, I as pickVersion, J as isManaged, Jt as __commonJSMin, Kt as TEMP_DIR, L as lockInstance, M as isExactVersion, Mt as currentInstance, N as isPackageName, Nt as instance_exports, O as scannedPackagePath, Ot as JsonFile, P as matches, Q as version_exports, Rt as environment_exports, S as resolveMain, St as normalizeScope, T as sdkRangeOf, Tt as platform_exports, Ut as DATA_DIR, Vt as isDockerEnvironment, W as GATEWAY_SECRET_ENV, Wt as LOG_DIR, X as protocol_exports, Xt as __require, Y as isManagerMessage, Yt as __exportAll, Z as version$10, Zt as __toESM, _ as manifest_exports, _t as upgradeConfig, at as migrateRenamedPackages, b as parsePluginDependencies, bt as normalizeUi, c as marketSettings, ct as RENAMED_PACKAGES, d as extractPackage, dt as withCurrentNames, et as HtmlEscapedCallbackPhase, f as readTarStream, ft as ADAPTER_ENTRIES, g as isInside, gt as templateSection, h as isImagePath, ht as templateConfig, it as migrateNTQQMessaging, j as RegistryError, jt as require_dist, k as require_semver, kt as configPaths, l as registriesOf, lt as currentPackageName, m as SDK_PACKAGE, mt as DEPRECATED_KEYS, nt as liftBuiltinSettings, ot as migrateToInstances, p as PLUGIN_CATEGORIES, pt as ADAPTER_KEYS, qt as globalVars_exports, r as coreUpdate_exports, rt as migrateExtractedPlugins, s as MarketSchema, st as renameNativeQQSettings, tt as resolveCallback, u as Catalog, ut as renamed_exports, v as matchesPluginVersion, vt as PluginStore, w as sdkIncompatibility, wt as normalizePlatformId, x as readPluginPackage, xt as acceptsScope, y as normalizeService, yt as newEntryId, zt as getPluginDirs } from "./chunks/coreUpdate-BQLZsgRG.js";
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-FeEAjxU_.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";
@@ -200,6 +200,8 @@ var FORBIDDEN_KEYS = /* @__PURE__ */ new Set([
200
200
  "constructor",
201
201
  "prototype"
202
202
  ]);
203
+ /** `name[key=value]`: the first item of the list `name` whose `key` is `value` (added when there is none) */
204
+ var SELECTOR = /^([^[\]=]+)\[([^[\]=]+)=([^[\]]*)\]$/;
203
205
  var ConfigPatchError = class extends Error {};
204
206
  function parseJsonLike(raw, context) {
205
207
  try {
@@ -447,7 +449,11 @@ function mergeObject(target, patch, node, at, label) {
447
449
  }
448
450
  function setAtPath(root, path, raw, rootNode, label) {
449
451
  if (!path.length) throw new ConfigPatchError("配置项路径不能为空");
450
- for (const segment of path) if (!segment || FORBIDDEN_KEYS.has(segment)) throw new ConfigPatchError(`配置项路径「${path.join(".")}」包含非法段「${segment}」`);
452
+ for (const segment of path) {
453
+ const selector = SELECTOR.exec(segment);
454
+ const keys = selector ? [selector[1], selector[2]] : [segment];
455
+ if (!segment || keys.some((key) => FORBIDDEN_KEYS.has(key))) throw new ConfigPatchError(`配置项路径「${path.join(".")}」包含非法段「${segment}」`);
456
+ }
451
457
  let container = root;
452
458
  let schema = rootNode;
453
459
  for (let i = 0; i < path.length; i++) {
@@ -481,6 +487,28 @@ function setAtPath(root, path, raw, rootNode, label) {
481
487
  continue;
482
488
  }
483
489
  if (!isPlainObject(container)) throw new ConfigPatchError(`配置项「${prefix}」的父级「${path.slice(0, i).join(".")}」不是对象`);
490
+ const selector = SELECTOR.exec(segment);
491
+ if (selector) {
492
+ if (isLast) throw new ConfigPatchError(`配置项「${prefix}」选中的是列表中的一项,要再写出它的字段`);
493
+ const [, key, field, wanted] = selector;
494
+ const dict = objectDictOf(schema, container);
495
+ if (dict && !Object.hasOwn(dict, key)) throw unknownFieldError(label, path.slice(0, i).concat(key).join("."), dict);
496
+ const listNode = unwrap(dict ? dict[key] : null);
497
+ if (listNode && listNode.type !== "array") throw new ConfigPatchError(`配置项「${prefix}」:「${key}」不是列表`);
498
+ if (container[key] === void 0) container[key] = [];
499
+ const list = container[key];
500
+ if (!Array.isArray(list)) throw new ConfigPatchError(`配置项「${prefix}」:「${key}」不是列表`);
501
+ const itemNode = listNode?.inner ?? null;
502
+ let item = list.find((candidate) => isPlainObject(candidate) && String(candidate[field]) === wanted);
503
+ if (!item) {
504
+ const fieldNode = objectDictOf(itemNode, { [field]: wanted })?.[field] ?? null;
505
+ item = { [field]: coerceValue(wanted, fieldNode, `${prefix}.${field}`) };
506
+ list.push(item);
507
+ }
508
+ container = item;
509
+ schema = itemNode;
510
+ continue;
511
+ }
484
512
  const dict = objectDictOf(schema, container);
485
513
  if (dict && !Object.hasOwn(dict, segment)) throw unknownFieldError(label, prefix, dict);
486
514
  const childNode = dict ? dict[segment] : resolved?.type === "dict" ? resolved.inner ?? null : null;
@@ -7343,8 +7371,19 @@ function splitConfigTarget(lhs) {
7343
7371
  * - Path assignment: `<plugin>:<path>=<value>` (e.g. `qq-official:appId=123456`, `onebot11:connect.0.url=ws://...`)
7344
7372
  * - JSON/JSON5 object merge: `<plugin>={...}` (e.g. `satori={"port":5500}`)
7345
7373
  */
7374
+ /** The `=` between target and value: one inside a list selector (`connect[type=ws]`) is part of the path. */
7375
+ function assignmentAt(raw) {
7376
+ let depth = 0;
7377
+ for (let index = 0; index < raw.length; index++) {
7378
+ const char = raw[index];
7379
+ if (char === "[") depth++;
7380
+ else if (char === "]") depth = Math.max(0, depth - 1);
7381
+ else if (char === "=" && !depth) return index;
7382
+ }
7383
+ return -1;
7384
+ }
7346
7385
  function parsePluginConfigSpec(raw) {
7347
- const eq = raw.indexOf("=");
7386
+ const eq = assignmentAt(raw);
7348
7387
  if (eq <= 0) throw new Error("--plugin-config 格式应为 <插件>:<字段>=<值> 或 <插件>={JSON},例如 --plugin-config qq-official:appId=123456");
7349
7388
  const lhs = raw.slice(0, eq).trim();
7350
7389
  const rhs = raw.slice(eq + 1);
@@ -7397,8 +7436,169 @@ function startupPluginConfigs(argv = process.argv) {
7397
7436
  }
7398
7437
  return configs;
7399
7438
  }
7439
+ /** LLBot's own flags, which no plugin may declare in `llbot.launch`; every `--plugin*` flag is LLBot's as well. */
7440
+ var HOST_FLAGS = /* @__PURE__ */ new Set([
7441
+ "--instance",
7442
+ "--webui-port",
7443
+ "--parent-pid",
7444
+ "--dev",
7445
+ "--debug",
7446
+ "--no-supervisor",
7447
+ "--no-manager"
7448
+ ]);
7449
+ var ARG_NAME = /^--[a-z0-9][a-z0-9-]*$/;
7450
+ /** Variables no plugin may declare: LLBot's own (`LLBOT_*`), Node's and npm's, and the system's. */
7451
+ var HOST_ENV_PREFIXES = [
7452
+ "LLBOT_",
7453
+ "NODE_",
7454
+ "NPM_",
7455
+ "npm_"
7456
+ ];
7457
+ var SYSTEM_ENV = /* @__PURE__ */ new Set([
7458
+ "PATH",
7459
+ "HOME",
7460
+ "USER",
7461
+ "USERNAME",
7462
+ "SHELL",
7463
+ "LANG",
7464
+ "TZ",
7465
+ "TMP",
7466
+ "TEMP",
7467
+ "TMPDIR",
7468
+ "PWD",
7469
+ "HOSTNAME"
7470
+ ]);
7471
+ var ENV_NAME = /^[A-Z][A-Z0-9_]*$/;
7472
+ var FLAGS = {
7473
+ key: "arg",
7474
+ noun: "参数",
7475
+ nameProblem: (flag) => !ARG_NAME.test(flag) ? "参数名只能是 --小写字母、数字和 -" : flag.startsWith("--plugin") || HOST_FLAGS.has(flag) ? "和 LLBot 自己的参数重名" : void 0
7476
+ };
7477
+ var VARIABLES = {
7478
+ key: "env",
7479
+ noun: "环境变量",
7480
+ nameProblem: (name) => !ENV_NAME.test(name) ? "变量名只能是大写字母、数字和 _" : HOST_ENV_PREFIXES.some((prefix) => name.startsWith(prefix)) || SYSTEM_ENV.has(name) ? "是 LLBot 或系统自己的变量" : void 0
7481
+ };
7482
+ /** What is wrong with a `llbot.launch` item, apart from its names. */
7483
+ function settingProblem(setting) {
7484
+ if (typeof setting.field !== "string" || !setting.field.trim()) return "要用 field 写出对应的配置字段";
7485
+ if (setting.arg === void 0 && setting.env === void 0) return "要写出 arg 或 env";
7486
+ const { aliases, set } = setting;
7487
+ if (aliases !== void 0 && (!isPlainObject(aliases) || Object.values(aliases).some((v) => typeof v !== "string"))) return "aliases 要是 { 给出的值: 配置里的值 }";
7488
+ if (set !== void 0 && (!isPlainObject(set) || Object.values(set).some((v) => ![
7489
+ "string",
7490
+ "number",
7491
+ "boolean"
7492
+ ].includes(typeof v)))) return "set 要是 { 字段: 值 }";
7493
+ }
7494
+ /**
7495
+ * The flags or the variables the plugins declare. An item that is invalid, or a name two plugins declare, is only a
7496
+ * warning until the name is used; a name a plugin may not have at all is dropped.
7497
+ */
7498
+ function declarations(sources, kind, warn) {
7499
+ const declared = /* @__PURE__ */ new Map();
7500
+ for (const { target, launch } of sources) {
7501
+ if (!Array.isArray(launch)) continue;
7502
+ for (const item of launch) {
7503
+ if (!isPlainObject(item)) continue;
7504
+ const name = item[kind.key];
7505
+ if (name === void 0) continue;
7506
+ if (typeof name !== "string") {
7507
+ warn(`${target} 的 llbot.launch 里 ${kind.key} 要是字符串,已忽略`);
7508
+ continue;
7509
+ }
7510
+ const badName = kind.nameProblem(name);
7511
+ if (badName) {
7512
+ warn(`${target} 声明的${kind.noun} ${name} 无效(${badName}),已忽略`);
7513
+ continue;
7514
+ }
7515
+ const problem = settingProblem(item);
7516
+ const other = declared.get(name);
7517
+ if (problem) {
7518
+ warn(`${target} 声明的${kind.noun} ${name} 无效(${problem}),已忽略`);
7519
+ if (!other) declared.set(name, { problem: `${target} 声明的${kind.noun} ${name} 无效:${problem}` });
7520
+ } else if (other && "target" in other && other.target !== target) {
7521
+ const message = `${kind.noun} ${name} 同时由 ${other.target} 和 ${target} 声明,无法确定交给谁`;
7522
+ warn(message);
7523
+ declared.set(name, { problem: message });
7524
+ } else if (!other || "target" in other) declared.set(name, {
7525
+ target,
7526
+ setting: item
7527
+ });
7528
+ }
7529
+ }
7530
+ return declared;
7531
+ }
7532
+ function pathPatch(target, fieldPath, raw, name) {
7533
+ const segments = fieldPath.trim().split(".");
7534
+ if (segments.some((segment) => !segment || FORBIDDEN_PATH_SEGMENTS.has(segment))) throw new Error(`${target} 的 ${name} 对应的字段「${fieldPath}」无效`);
7535
+ return {
7536
+ plugin: target,
7537
+ patch: {
7538
+ kind: "set",
7539
+ path: segments,
7540
+ raw
7541
+ }
7542
+ };
7543
+ }
7544
+ /** The settings one given value writes: its field, then what the item sets along with it. */
7545
+ function patchesOf({ target, setting }, raw, name) {
7546
+ return [pathPatch(target, setting.field, setting.aliases?.[raw] ?? raw, name), ...Object.entries(setting.set ?? {}).map(([field, value]) => pathPatch(target, field, String(value), name))];
7547
+ }
7548
+ /**
7549
+ * The settings that the launch flags and environment variables installed plugins declare (`llbot.launch`) write, as
7550
+ * `--plugin-config` would: the variables first, then the flags in command-line order, so a flag wins over a variable
7551
+ * for the same field. A flag or variable nobody declares is left alone: LLBot or a plugin may read it itself. An empty
7552
+ * variable counts as unset, as `NAME=` in a compose file whose value is not given.
7553
+ */
7554
+ function startupLaunchSettings(sources, argv = process.argv, warn = () => {}, env = process.env) {
7555
+ const configs = [];
7556
+ for (const sourceProblem of sources.filter((source) => source.launch !== void 0 && !Array.isArray(source.launch))) warn(`${sourceProblem.target} 的 llbot.launch 要是列表,已忽略`);
7557
+ for (const [name, found] of declarations(sources, VARIABLES, warn)) {
7558
+ const raw = env[name];
7559
+ if (raw === void 0 || !raw.trim()) continue;
7560
+ if ("problem" in found) throw new Error(found.problem);
7561
+ configs.push(...patchesOf(found, raw.trim(), name));
7562
+ }
7563
+ const flags = declarations(sources, FLAGS, warn);
7564
+ if (flags.size) for (let index = 0; index < argv.length; index++) {
7565
+ const arg = argv[index];
7566
+ if (arg === "--") break;
7567
+ const eq = arg.indexOf("=");
7568
+ const flag = eq < 0 ? arg : arg.slice(0, eq);
7569
+ const found = flags.get(flag);
7570
+ if (!found) continue;
7571
+ if ("problem" in found) throw new Error(found.problem);
7572
+ let raw;
7573
+ if (eq >= 0) raw = arg.slice(eq + 1);
7574
+ else if (index + 1 < argv.length && !argv[index + 1].startsWith("--")) raw = argv[++index];
7575
+ if (raw === void 0) throw new Error(`参数 ${flag} 需要一个值,例如 ${flag}=<值>`);
7576
+ configs.push(...patchesOf(found, raw, flag));
7577
+ }
7578
+ if (configs.length > 256) throw new Error("启动参数和环境变量最多写入 256 项配置");
7579
+ return configs;
7580
+ }
7581
+ /** The launch settings the plugins found declare, for startupLaunchSettings(). */
7582
+ function pluginLaunchSources(ctx) {
7583
+ const sources = /* @__PURE__ */ new Map();
7584
+ for (const pkg of ctx.plugins.packageList()) {
7585
+ const entry = pkg.manifest.builtin?.entry;
7586
+ if (typeof entry === "string" && entry.startsWith("builtin:")) continue;
7587
+ if (pkg.manifest.launch !== void 0) sources.set(pkg.name, {
7588
+ target: pkg.name,
7589
+ launch: pkg.manifest.launch
7590
+ });
7591
+ }
7592
+ for (const status of ctx.plugins.list()) if (status.builtin && status.manifest.launch !== void 0) sources.set(status.name, {
7593
+ target: status.name,
7594
+ launch: status.manifest.launch
7595
+ });
7596
+ return [...sources.values()];
7597
+ }
7598
+ /** Flag names that look like they carry a secret, whoever reads the flag: the startup log shows *** instead. */
7599
+ var SECRET_FLAG = /-(?:token|secret|password|key)$/;
7400
7600
  function redactConfigValue(raw) {
7401
- const eq = raw.indexOf("=");
7601
+ const eq = assignmentAt(raw);
7402
7602
  if (eq <= 0) return "***";
7403
7603
  const { plugin, fieldPath } = splitConfigTarget(raw.slice(0, eq).trim());
7404
7604
  return fieldPath !== void 0 ? `${plugin}:${fieldPath}=***` : `${plugin}={...}`;
@@ -7422,6 +7622,21 @@ function redactStartupArgv(argv) {
7422
7622
  redacted.push(`--plugin-config=${redactConfigValue(arg.slice(16))}`);
7423
7623
  continue;
7424
7624
  }
7625
+ if (!stop && arg.startsWith("--")) {
7626
+ const eq = arg.indexOf("=");
7627
+ const flag = eq < 0 ? arg : arg.slice(0, eq);
7628
+ if (SECRET_FLAG.test(flag)) {
7629
+ if (eq >= 0) redacted.push(`${flag}=***`);
7630
+ else {
7631
+ redacted.push(arg);
7632
+ if (index + 1 < argv.length && !argv[index + 1].startsWith("--")) {
7633
+ index++;
7634
+ redacted.push("***");
7635
+ }
7636
+ }
7637
+ continue;
7638
+ }
7639
+ }
7425
7640
  redacted.push(arg);
7426
7641
  }
7427
7642
  return redacted;
@@ -7485,7 +7700,7 @@ function installer(ctx) {
7485
7700
  return new Market(ctx, new Registries(registriesOf(config), (url, init) => ctx.http.fetch(url, init)), root);
7486
7701
  }
7487
7702
  /** CLI selection explicitly authorizes trust for requested packages and their required plugin dependencies. */
7488
- async function startRequestedPlugins(ctx, names, source, configs = []) {
7703
+ async function startRequestedPlugins(ctx, names, source, configs = [], installedLaunch) {
7489
7704
  if (!names.length && !configs.length) return;
7490
7705
  const logger = ctx.logger("startup-plugins");
7491
7706
  const listed = ctx.plugins.list();
@@ -7531,9 +7746,11 @@ async function startRequestedPlugins(ctx, names, source, configs = []) {
7531
7746
  const completed = /* @__PURE__ */ new Set();
7532
7747
  for (const requested of packageTargets) try {
7533
7748
  const plan = await market.ensureRequested(requested);
7749
+ const fromLaunch = /* @__PURE__ */ new Map();
7750
+ for (const item of installedLaunch?.(plan.names.filter((name) => !completed.has(name))) ?? []) if (!item.plugin.startsWith("builtin:")) fromLaunch.set(item.plugin, [...fromLaunch.get(item.plugin) ?? [], item.patch]);
7534
7751
  for (const name of plan.names) {
7535
7752
  if (completed.has(name)) continue;
7536
- const patches = packagePatches.get(name);
7753
+ const patches = [...fromLaunch.get(name) ?? [], ...packagePatches.get(name) ?? []];
7537
7754
  const entries = ctx.plugins.list().filter((entry) => entry.name === name || entry.packageName === name);
7538
7755
  if (!entries.length) {
7539
7756
  if (patches?.length) {
@@ -8151,14 +8368,19 @@ function botKey(sid) {
8151
8368
  }
8152
8369
  var PluginDataDirs = class {
8153
8370
  root;
8371
+ hostRoot;
8154
8372
  entries = /* @__PURE__ */ new WeakMap();
8155
8373
  storages = /* @__PURE__ */ new WeakMap();
8156
- constructor(root) {
8374
+ constructor(root, hostRoot) {
8157
8375
  this.root = root;
8376
+ this.hostRoot = hostRoot;
8158
8377
  }
8159
8378
  sharedDir(name) {
8160
8379
  return path.join(this.root, dataKey(name), "shared");
8161
8380
  }
8381
+ hostDir(name) {
8382
+ return path.join(this.hostRoot ?? this.root, dataKey(name));
8383
+ }
8162
8384
  /**
8163
8385
  * The entry's `ctx.baseUrl`: ecosystem plugins such as @cordisjs/plugin-database-sqlite resolve relative
8164
8386
  * paths with `new URL(path, ctx.baseUrl)`. The trailing separator matters, or the last segment is dropped.
@@ -8195,6 +8417,7 @@ var PluginDataDirs = class {
8195
8417
  async dir(name, scope = "global", bot) {
8196
8418
  let dir;
8197
8419
  if (scope === "global") dir = this.sharedDir(name);
8420
+ else if (scope === "host") dir = this.hostDir(name);
8198
8421
  else if (scope === "bot") {
8199
8422
  const sid = typeof bot === "string" ? bot : bot?.sid;
8200
8423
  if (typeof sid !== "string") throw new TypeError(`ctx.storage.dir('bot', bot): expected a bot or its sid`);
@@ -8209,7 +8432,7 @@ var PluginDataDirs = class {
8209
8432
  if (await this.directoryExists(legacy)) dir = legacy;
8210
8433
  }
8211
8434
  }
8212
- } else throw new TypeError(`ctx.storage.dir(): unknown scope ${JSON.stringify(scope)}, expected 'global' or 'bot'`);
8435
+ } else throw new TypeError(`ctx.storage.dir(): unknown scope ${JSON.stringify(scope)}, expected 'global', 'host' or 'bot'`);
8213
8436
  await mkdir(dir, { recursive: true });
8214
8437
  return dir;
8215
8438
  }
@@ -8590,7 +8813,7 @@ var PluginService = class extends Service {
8590
8813
  super(ctx, "plugins");
8591
8814
  this.config = config;
8592
8815
  this.home = ctx;
8593
- if (config.dataDir) this.dataDirs = new PluginDataDirs(config.dataDir);
8816
+ if (config.dataDir) this.dataDirs = new PluginDataDirs(config.dataDir, config.hostDataDir);
8594
8817
  this.store = new PluginStore(config.file);
8595
8818
  this.builtins = new Map((config.builtins ?? []).map((builtin) => [builtin.name, builtin]));
8596
8819
  this.builtinPackages = new BuiltinPackages(this.builtins.values(), config.roots[0]);
@@ -10218,7 +10441,7 @@ var WebUITokenUtil = class {
10218
10441
  tokenPath;
10219
10442
  token = "";
10220
10443
  mtimeMs = -1;
10221
- /** The path is looked up on use: it depends on the instance, which is only fixed after the startup migration. */
10444
+ /** Looked up on use so test suites that redirect DATA_DIR take effect. */
10222
10445
  constructor(tokenPath) {
10223
10446
  this.tokenPath = tokenPath;
10224
10447
  }
@@ -14023,7 +14246,24 @@ var builtin$6 = {
14023
14246
  description: {
14024
14247
  zh: "支持全部协议端的 Satori 适配器",
14025
14248
  en: "Supports all protocol backends through Satori"
14026
- }
14249
+ },
14250
+ launch: [
14251
+ {
14252
+ field: "host",
14253
+ arg: "--satori-host",
14254
+ env: "SATORI_HOST"
14255
+ },
14256
+ {
14257
+ field: "port",
14258
+ arg: "--satori-port",
14259
+ env: "SATORI_PORT"
14260
+ },
14261
+ {
14262
+ field: "token",
14263
+ arg: "--satori-token",
14264
+ env: "SATORI_TOKEN"
14265
+ }
14266
+ ]
14027
14267
  }
14028
14268
  };
14029
14269
  //#endregion
@@ -27526,6 +27766,23 @@ var packagesByEntry = new Map([
27526
27766
  "zh": "支持全部协议端的 Satori 适配器",
27527
27767
  "en": "Supports all protocol backends through Satori"
27528
27768
  },
27769
+ "launch": [
27770
+ {
27771
+ "field": "host",
27772
+ "arg": "--satori-host",
27773
+ "env": "SATORI_HOST"
27774
+ },
27775
+ {
27776
+ "field": "port",
27777
+ "arg": "--satori-port",
27778
+ "env": "SATORI_PORT"
27779
+ },
27780
+ {
27781
+ "field": "token",
27782
+ "arg": "--satori-token",
27783
+ "env": "SATORI_TOKEN"
27784
+ }
27785
+ ],
27529
27786
  "title": "Satori",
27530
27787
  "builtin": {
27531
27788
  "entry": "builtin:satori",
@@ -27820,6 +28077,7 @@ async function onLoad() {
27820
28077
  instance = currentInstance();
27821
28078
  await lockInstance(instance.name);
27822
28079
  migrateRenamedPackages(ctx.logger("config"));
28080
+ migrateWebuiToken(ctx.logger("config"), instance.name);
27823
28081
  liftBuiltinSettings(ctx.logger("config"));
27824
28082
  renameNativeQQSettings(ctx.logger("config"));
27825
28083
  migrateExtractedPlugins(ctx.logger("config"));
@@ -27836,6 +28094,7 @@ async function onLoad() {
27836
28094
  const plugins = ctx.plugin(PluginService, {
27837
28095
  file: configPaths.plugins(),
27838
28096
  dataDir: configPaths.pluginData(),
28097
+ hostDataDir: configPaths.sharedPluginData(),
27839
28098
  roots: [pluginDir, ...getPluginDirs().map((dir) => path.resolve(dir))],
27840
28099
  hmr: isPluginHmr(),
27841
28100
  builtins: builtinPlugins,
@@ -27857,9 +28116,14 @@ async function onLoad() {
27857
28116
  });
27858
28117
  ctx.parallel("llob/config-updated", config);
27859
28118
  });
27860
- if (requestedPlugins.length || requestedConfigs.length) try {
28119
+ try {
27861
28120
  await plugins;
27862
- await startRequestedPlugins(ctx, requestedPlugins, void 0, requestedConfigs);
28121
+ const warn = (message) => ctx.logger("startup-plugins").warn(message);
28122
+ const sources = pluginLaunchSources(ctx);
28123
+ const declared = startupLaunchSettings(sources, process.argv, warn);
28124
+ const known = new Set(sources.map((source) => source.target));
28125
+ const installedLaunch = (packages) => startupLaunchSettings(pluginLaunchSources(ctx).filter((source) => packages.includes(source.target) && !known.has(source.target)), process.argv, warn);
28126
+ await startRequestedPlugins(ctx, requestedPlugins, void 0, [...declared, ...requestedConfigs], installedLaunch);
27863
28127
  } catch (error) {
27864
28128
  return startupFailed(error);
27865
28129
  }