@luckylillia-dev/luckylillia 9.0.10 → 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/chunks/{coreUpdate-DjtWFA8I.js → coreUpdate-BUe8e_Ex.js} +3 -3
- package/chunks/{coreUpdate-DjtWFA8I.js.map → coreUpdate-BUe8e_Ex.js.map} +1 -1
- package/llbot-core.js +72 -46
- package/llbot-core.js.map +1 -1
- package/llbot-manager.js +1 -1
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/index.d.ts +1 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/satori.d.ts +19 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/satori.js +1 -0
- package/package.json +1 -1
- package/webui/assets/{index-BrIxD8Tq.js → index-C2Vti2Pp.js} +1 -1
- package/webui/index.html +1 -1
- package//346/233/264/346/226/260/346/227/245/345/277/227.txt +9 -0
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-
|
|
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";
|
|
@@ -7091,6 +7091,13 @@ var Market = class {
|
|
|
7091
7091
|
}
|
|
7092
7092
|
async installCatalog(name, version, onProgress) {
|
|
7093
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) {
|
|
7094
7101
|
const catalog = await this.catalog.load();
|
|
7095
7102
|
const entry = this.assertListed(catalog, name);
|
|
7096
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);
|
|
@@ -7100,10 +7107,12 @@ var Market = class {
|
|
|
7100
7107
|
if (builtin && !newer(chosen.version, builtin.version)) throw new MarketError(`${name}@${chosen.version} is not newer than installed version ${builtin.version}`, 409);
|
|
7101
7108
|
const problem = this.incompatibility(chosen);
|
|
7102
7109
|
if (problem) throw new MarketError(`${name}@${entry.version} cannot run on this bot: ${problem}`, 409);
|
|
7103
|
-
|
|
7104
|
-
return this.installPlan(plan, onProgress);
|
|
7110
|
+
return this.planPlugins(this.planned(source, name), catalog);
|
|
7105
7111
|
}
|
|
7106
|
-
/**
|
|
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
|
+
*/
|
|
7107
7116
|
ensureRequested(name) {
|
|
7108
7117
|
if (!isPackageName(name)) return Promise.reject(new MarketError("启动插件参数必须是 npm 包名"));
|
|
7109
7118
|
if (!this.ctx.plugins.packageRootWritable(this.installer.root)) {
|
|
@@ -7123,17 +7132,16 @@ var Market = class {
|
|
|
7123
7132
|
}
|
|
7124
7133
|
return this.serial(async () => {
|
|
7125
7134
|
const existing = this.installedPackages().find((pkg) => pkg.name === currentPackageName(name));
|
|
7126
|
-
let
|
|
7127
|
-
if (existing)
|
|
7135
|
+
let plan;
|
|
7136
|
+
if (existing) plan = await this.planPlugins({
|
|
7128
7137
|
name,
|
|
7129
7138
|
version: existing.version,
|
|
7130
7139
|
dependencies: parsePluginDependencies(existing.manifest.dependencies)
|
|
7131
|
-
};
|
|
7140
|
+
});
|
|
7132
7141
|
else {
|
|
7133
7142
|
this.assertManageable(name);
|
|
7134
|
-
|
|
7143
|
+
plan = await this.catalogPlan(name);
|
|
7135
7144
|
}
|
|
7136
|
-
const plan = await this.planPlugins(main, void 0, void 0, (dependency, ranges) => this.requestedVersion(dependency, ranges));
|
|
7137
7145
|
const installed = [];
|
|
7138
7146
|
for (const item of plan) if (item.source) installed.push(await this.installPackage(item.source));
|
|
7139
7147
|
return {
|
|
@@ -7142,14 +7150,6 @@ var Market = class {
|
|
|
7142
7150
|
};
|
|
7143
7151
|
});
|
|
7144
7152
|
}
|
|
7145
|
-
async requestedVersion(name, ranges) {
|
|
7146
|
-
const accept = (candidate) => candidate.name === name && isExactVersion(candidate.version) && ranges.every((range) => matchesPluginVersion(candidate.version, range)) && !this.incompatibility(candidate);
|
|
7147
|
-
const document = await this.registry.packument(name, true, (document) => !!pickVersion(document, ranges[0] ?? "latest", accept));
|
|
7148
|
-
if (document.name !== name) throw new MarketError(`npm 返回的包与请求的 ${name} 不符`);
|
|
7149
|
-
const version = pickVersion(document, ranges[0] ?? "latest", accept);
|
|
7150
|
-
if (!version) throw new MarketError(`${name} 没有满足当前 Bot 和插件依赖要求的 npm 版本`, 409);
|
|
7151
|
-
return version;
|
|
7152
|
-
}
|
|
7153
7153
|
/** Local uploads need no catalog approval; missing plugin dependencies still come from its pinned versions. */
|
|
7154
7154
|
installLocal(archive, filename) {
|
|
7155
7155
|
return this.trackTask(":local", async (report) => {
|
|
@@ -14200,39 +14200,63 @@ var SatoriServer = class {
|
|
|
14200
14200
|
wsServer;
|
|
14201
14201
|
wsClients = [];
|
|
14202
14202
|
routesRegistered = false;
|
|
14203
|
+
internalRoutes = /* @__PURE__ */ new Map();
|
|
14203
14204
|
constructor(ctx, config, adapter) {
|
|
14204
14205
|
this.ctx = ctx;
|
|
14205
14206
|
this.config = config;
|
|
14206
14207
|
this.adapter = adapter;
|
|
14207
14208
|
this.app = new Hono();
|
|
14208
14209
|
}
|
|
14209
|
-
|
|
14210
|
-
|
|
14211
|
-
if (
|
|
14212
|
-
|
|
14213
|
-
|
|
14214
|
-
|
|
14215
|
-
|
|
14216
|
-
debug: false
|
|
14217
|
-
});
|
|
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
|
+
};
|
|
14218
14217
|
}
|
|
14219
|
-
|
|
14220
|
-
|
|
14221
|
-
|
|
14222
|
-
|
|
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;
|
|
14223
14239
|
try {
|
|
14224
|
-
|
|
14240
|
+
const text = await c.req.text();
|
|
14241
|
+
const body = text.trim() ? JSON.parse(text) : [];
|
|
14242
|
+
args = Array.isArray(body) ? body : [body];
|
|
14225
14243
|
} catch (e) {
|
|
14226
|
-
|
|
14227
|
-
|
|
14228
|
-
|
|
14229
|
-
|
|
14230
|
-
|
|
14231
|
-
|
|
14232
|
-
|
|
14233
|
-
|
|
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);
|
|
14234
14252
|
}
|
|
14235
|
-
|
|
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;
|
|
14236
14260
|
}
|
|
14237
14261
|
start() {
|
|
14238
14262
|
if (!this.routesRegistered) {
|
|
@@ -14286,15 +14310,12 @@ var SatoriServer = class {
|
|
|
14286
14310
|
}));
|
|
14287
14311
|
this.app.use("/v1/*", cors());
|
|
14288
14312
|
this.app.use("/v1/*", this.checkAuth.bind(this));
|
|
14289
|
-
this.app.
|
|
14313
|
+
this.app.all("/v1/internal/*", this.handleInternal.bind(this));
|
|
14290
14314
|
this.app.get("/v1/*", async (c) => {
|
|
14291
14315
|
return c.text("Please use POST method to send requests.", 405);
|
|
14292
14316
|
});
|
|
14293
14317
|
this.app.post("/v1/:name", async (c) => {
|
|
14294
|
-
const
|
|
14295
|
-
const platform = c.req.header("Satori-Platform");
|
|
14296
|
-
const neutral = platform ? neutralPlatform(platform) : void 0;
|
|
14297
|
-
const bot = selfId && neutral ? this.ctx.bots.get(`${neutral}:${selfId}`) : void 0;
|
|
14318
|
+
const bot = this.botOf(c);
|
|
14298
14319
|
if (!bot) return c.text("login not found", 403);
|
|
14299
14320
|
const method = Universal.Methods[c.req.param("name")];
|
|
14300
14321
|
if (!method || !implemented(bot, method.name)) return c.text("method not found", 404);
|
|
@@ -14364,7 +14385,8 @@ var SatoriServer = class {
|
|
|
14364
14385
|
//#region src/plugin/internal/adapter/satori/adapter.ts
|
|
14365
14386
|
/**
|
|
14366
14387
|
* The bots of the neutral layer (ctx.bots), every one of them, as Satori logins: events from bot/session, API calls
|
|
14367
|
-
* 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.
|
|
14368
14390
|
*/
|
|
14369
14391
|
var SatoriAdapter = class extends Service {
|
|
14370
14392
|
ctx;
|
|
@@ -14400,6 +14422,10 @@ var SatoriAdapter = class extends Service {
|
|
|
14400
14422
|
});
|
|
14401
14423
|
return () => this.server.stop();
|
|
14402
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
|
+
}
|
|
14403
14429
|
loginSn(bot) {
|
|
14404
14430
|
let sn = this.loginSns.get(bot.sid);
|
|
14405
14431
|
if (sn === void 0) this.loginSns.set(bot.sid, sn = ++this.nextLoginSn);
|