node-karin 1.9.7 → 1.9.8

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/dist/index.mjs CHANGED
@@ -3,16 +3,15 @@ import path from 'path';
3
3
  import require$$2 from 'os';
4
4
  import require$$22 from 'crypto';
5
5
  import { fileURLToPath } from 'url';
6
- import lodash4 from 'lodash';
7
- import fs7, { promises, existsSync as existsSync$1, createWriteStream } from 'node:fs';
8
- import path5, { join } from 'node:path';
9
- import chalk2 from 'chalk';
10
- import util6, { promisify } from 'node:util';
6
+ import fs5, { promises, existsSync as existsSync$1, createWriteStream } from 'node:fs';
11
7
  import YAML, { isMap, isSeq, isPair } from 'yaml';
12
8
  import { spawn, execSync, exec as exec$2 } from 'node:child_process';
9
+ import path4, { join } from 'node:path';
13
10
  import chokidar from 'chokidar';
14
11
  import axios9, { AxiosError } from 'axios';
12
+ import util5, { promisify } from 'node:util';
15
13
  import { pipeline, Readable } from 'node:stream';
14
+ import lodash3 from 'lodash';
16
15
  import { URL as URL$1, pathToFileURL, fileURLToPath as fileURLToPath$1 } from 'node:url';
17
16
  import { createRequire } from 'module';
18
17
  import crypto, { createHmac, randomUUID } from 'node:crypto';
@@ -20,6 +19,8 @@ import { EventEmitter } from 'node:events';
20
19
  import { isPromise } from 'util/types';
21
20
  import { exec as exec$1, spawn as spawn$1 } from 'child_process';
22
21
  import os, { homedir } from 'node:os';
22
+ import chalk2 from 'chalk';
23
+ import log4js from 'log4js';
23
24
  import { lookup } from 'dns/promises';
24
25
  import sqlite3 from 'sqlite3';
25
26
  import WebSocket$1, { WebSocket, WebSocketServer } from 'ws';
@@ -76,7 +77,7 @@ function requireMain() {
76
77
  if (hasRequiredMain) return main$1.exports;
77
78
  hasRequiredMain = 1;
78
79
  const fs37 = fs15;
79
- const path37 = path;
80
+ const path36 = path;
80
81
  const os5 = require$$2;
81
82
  const crypto9 = require$$22;
82
83
  const packageJson = require$$4;
@@ -187,7 +188,7 @@ function requireMain() {
187
188
  possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
188
189
  }
189
190
  } else {
190
- possibleVaultPath = path37.resolve(process.cwd(), ".env.vault");
191
+ possibleVaultPath = path36.resolve(process.cwd(), ".env.vault");
191
192
  }
192
193
  if (fs37.existsSync(possibleVaultPath)) {
193
194
  return possibleVaultPath;
@@ -195,7 +196,7 @@ function requireMain() {
195
196
  return null;
196
197
  }
197
198
  function _resolveHome(envPath) {
198
- return envPath[0] === "~" ? path37.join(os5.homedir(), envPath.slice(1)) : envPath;
199
+ return envPath[0] === "~" ? path36.join(os5.homedir(), envPath.slice(1)) : envPath;
199
200
  }
200
201
  function _configVault2(options) {
201
202
  const debug3 = Boolean(options && options.debug);
@@ -211,7 +212,7 @@ function requireMain() {
211
212
  return { parsed };
212
213
  }
213
214
  function configDotenv2(options) {
214
- const dotenvPath = path37.resolve(process.cwd(), ".env");
215
+ const dotenvPath = path36.resolve(process.cwd(), ".env");
215
216
  let encoding = "utf8";
216
217
  const debug3 = Boolean(options && options.debug);
217
218
  if (options && options.encoding) {
@@ -287,1043 +288,197 @@ function requireMain() {
287
288
  throw err;
288
289
  } else if (decryptionFailed) {
289
290
  const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
290
- err.code = "DECRYPTION_FAILED";
291
- throw err;
292
- } else {
293
- throw error;
294
- }
295
- }
296
- }
297
- function populate2(processEnv, parsed, options = {}) {
298
- const debug3 = Boolean(options && options.debug);
299
- const override = Boolean(options && options.override);
300
- if (typeof parsed !== "object") {
301
- const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
302
- err.code = "OBJECT_REQUIRED";
303
- throw err;
304
- }
305
- for (const key of Object.keys(parsed)) {
306
- if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
307
- if (override === true) {
308
- processEnv[key] = parsed[key];
309
- }
310
- if (debug3) {
311
- if (override === true) {
312
- _debug(`"${key}" is already defined and WAS overwritten`);
313
- } else {
314
- _debug(`"${key}" is already defined and was NOT overwritten`);
315
- }
316
- }
317
- } else {
318
- processEnv[key] = parsed[key];
319
- }
320
- }
321
- }
322
- const DotenvModule = {
323
- configDotenv: configDotenv2,
324
- _configVault: _configVault2,
325
- _parseVault: _parseVault2,
326
- config: config3,
327
- decrypt: decrypt2,
328
- parse: parse2,
329
- populate: populate2
330
- };
331
- main$1.exports.configDotenv = DotenvModule.configDotenv;
332
- main$1.exports._configVault = DotenvModule._configVault;
333
- main$1.exports._parseVault = DotenvModule._parseVault;
334
- main$1.exports.config = DotenvModule.config;
335
- main$1.exports.decrypt = DotenvModule.decrypt;
336
- main$1.exports.parse = DotenvModule.parse;
337
- main$1.exports.populate = DotenvModule.populate;
338
- main$1.exports = DotenvModule;
339
- return main$1.exports;
340
- }
341
- var main$1, version, require$$4, hasRequiredMain, mainExports, main, dotenv;
342
- var init_main_D88Wwqn3 = __esm({
343
- "../../node_modules/.pnpm/@karinjs+dotenv@1.1.2/node_modules/@karinjs/dotenv/dist/main-D88Wwqn3.js"() {
344
- main$1 = { exports: {} };
345
- version = "16.5.0";
346
- require$$4 = {
347
- version
348
- };
349
- mainExports = requireMain();
350
- main = /* @__PURE__ */ getDefaultExportFromCjs(mainExports);
351
- dotenv = /* @__PURE__ */ _mergeNamespaces({
352
- __proto__: null,
353
- default: main
354
- }, [mainExports]);
355
- }
356
- });
357
-
358
- // ../../node_modules/.pnpm/@karinjs+dotenv@1.1.2/node_modules/@karinjs/dotenv/dist/index.js
359
- var _configVault, _parseVault;
360
- var init_dist = __esm({
361
- "../../node_modules/.pnpm/@karinjs+dotenv@1.1.2/node_modules/@karinjs/dotenv/dist/index.js"() {
362
- init_main_D88Wwqn3();
363
- ({
364
- _configVault: (
365
- // @ts-ignore
366
- _configVault
367
- ),
368
- _parseVault
369
- } = dotenv);
370
- mainExports.config;
371
- mainExports.configDotenv;
372
- mainExports.decrypt;
373
- mainExports.parse;
374
- mainExports.populate;
375
- }
376
- });
377
-
378
- // ../../node_modules/.pnpm/@karinjs+dotenv@1.1.2/node_modules/@karinjs/dotenv/index.js
379
- var app, dotenv_default;
380
- var init_dotenv = __esm({
381
- "../../node_modules/.pnpm/@karinjs+dotenv@1.1.2/node_modules/@karinjs/dotenv/index.js"() {
382
- init_dist();
383
- init_dist();
384
- app = dotenv.default;
385
- dotenv_default = app;
386
- }
387
- });
388
- var filename, karinPathRoot, karinPathMain, karinPathPlugins, isPackaged, karinPathDefaultConfig, karinPathDefaultView, karinPathComment, karinPathBase, karinPathConfig, karinPathData, karinPathTemp, karinPathResource, karinPathDb, karinPathTaskDb, karinPathRedisSqlite3, karinPathKv, karinPathLogs, karinPathHtml, karinPathPm2Config, karinPathConsole, karinPathSandboxData, karinPathSandboxTemp, karinDir, karinMain, pluginDir, isPkg, defaultConfigPath, defaultViewPath, commentPath, basePath, configPath, dataPath, tempPath, resourcePath, dbPath, redisSqlite3Path, kvPath, logsPath, htmlPath, pm2Path, consolePath, sandboxDataPath, sandboxTempPath, root_default;
389
- var init_root = __esm({
390
- "src/root.ts"() {
391
- filename = fileURLToPath(import.meta.url);
392
- karinPathRoot = Object.freeze(path.join(filename, "../..").replace(/\\/g, "/"));
393
- karinPathMain = Object.freeze(path.join(karinPathRoot, "dist", "index.js"));
394
- karinPathPlugins = Object.freeze(path.join(process.cwd(), "plugins"));
395
- isPackaged = Object.freeze(filename.includes("node_modules"));
396
- karinPathDefaultConfig = Object.freeze(path.join(karinPathRoot, "default", "config"));
397
- karinPathDefaultView = Object.freeze(path.join(karinPathRoot, "default", "view"));
398
- karinPathComment = Object.freeze(path.join(karinPathRoot, "default", "comment"));
399
- karinPathBase = Object.freeze(path.join(process.cwd(), "@karinjs"));
400
- karinPathConfig = Object.freeze(path.join(karinPathBase, "config"));
401
- karinPathData = Object.freeze(path.join(karinPathBase, "data"));
402
- karinPathTemp = Object.freeze(path.join(karinPathBase, "temp"));
403
- karinPathResource = Object.freeze(path.join(karinPathBase, "resource"));
404
- karinPathDb = Object.freeze(path.join(karinPathData, "db"));
405
- karinPathTaskDb = Object.freeze(path.join(karinPathDb, "task"));
406
- karinPathRedisSqlite3 = Object.freeze(path.join(karinPathDb, "redis-sqlite3"));
407
- karinPathKv = Object.freeze(path.join(karinPathDb, "kv"));
408
- karinPathLogs = Object.freeze(path.join(karinPathBase, "logs"));
409
- karinPathHtml = Object.freeze(path.join(karinPathTemp, "html"));
410
- karinPathPm2Config = Object.freeze(path.join(karinPathConfig, "pm2.yaml"));
411
- karinPathConsole = Object.freeze(path.join(karinPathTemp, "console"));
412
- karinPathSandboxData = Object.freeze(path.join(karinPathData, "sandbox"));
413
- karinPathSandboxTemp = Object.freeze(path.join(karinPathTemp, "sandbox"));
414
- karinDir = karinPathRoot;
415
- karinMain = karinPathMain;
416
- pluginDir = karinPathPlugins;
417
- isPkg = isPackaged;
418
- defaultConfigPath = karinPathDefaultConfig;
419
- defaultViewPath = karinPathDefaultView;
420
- commentPath = karinPathComment;
421
- basePath = karinPathBase;
422
- configPath = karinPathConfig;
423
- dataPath = karinPathData;
424
- tempPath = karinPathTemp;
425
- resourcePath = karinPathResource;
426
- dbPath = karinPathDb;
427
- redisSqlite3Path = karinPathRedisSqlite3;
428
- kvPath = karinPathKv;
429
- logsPath = karinPathLogs;
430
- htmlPath = karinPathHtml;
431
- pm2Path = karinPathPm2Config;
432
- consolePath = karinPathConsole;
433
- sandboxDataPath = karinPathSandboxData;
434
- sandboxTempPath = karinPathSandboxTemp;
435
- root_default = {
436
- // 新常量
437
- karinPathRoot,
438
- karinPathMain,
439
- karinPathPlugins,
440
- isPackaged,
441
- karinPathDefaultConfig,
442
- karinPathDefaultView,
443
- karinPathComment,
444
- karinPathBase,
445
- karinPathConfig,
446
- karinPathData,
447
- karinPathTemp,
448
- karinPathResource,
449
- karinPathDb,
450
- karinPathRedisSqlite3,
451
- karinPathKv,
452
- karinPathLogs,
453
- karinPathHtml,
454
- karinPathPm2Config,
455
- karinPathConsole,
456
- karinPathSandboxData,
457
- karinPathSandboxTemp,
458
- karinPathTaskDb,
459
- // 旧常量,保持兼容性
460
- karinDir,
461
- karinMain,
462
- pluginDir,
463
- isPkg,
464
- defaultConfigPath,
465
- defaultViewPath,
466
- commentPath,
467
- basePath,
468
- configPath,
469
- dataPath,
470
- tempPath,
471
- resourcePath,
472
- dbPath,
473
- redisSqlite3Path,
474
- kvPath,
475
- logsPath,
476
- htmlPath,
477
- pm2Path,
478
- consolePath,
479
- sandboxDataPath,
480
- sandboxTempPath
481
- };
482
- }
483
- });
484
-
485
- // src/service/logger/types.ts
486
- var DEFAULT_LOGGER_CONFIG, LoggerLevelPriority;
487
- var init_types = __esm({
488
- "src/service/logger/types.ts"() {
489
- DEFAULT_LOGGER_CONFIG = {
490
- prefix: "",
491
- level: "info",
492
- file: {
493
- enabled: false,
494
- dir: "logs",
495
- daysToKeep: 14,
496
- enableWholeMode: true,
497
- enableFragmentMode: false,
498
- maxFileSize: 10,
499
- separateErrorLog: true
500
- }
501
- };
502
- LoggerLevelPriority = {
503
- trace: 111,
504
- debug: 222,
505
- info: 333,
506
- warn: 444,
507
- error: 555,
508
- fatal: 666,
509
- mark: 777,
510
- off: 888
511
- };
512
- }
513
- });
514
-
515
- // src/service/logger/utils.ts
516
- var normalizeConfig;
517
- var init_utils = __esm({
518
- "src/service/logger/utils.ts"() {
519
- init_types();
520
- normalizeConfig = (config3) => {
521
- const result = {
522
- prefix: config3?.prefix ?? DEFAULT_LOGGER_CONFIG.prefix,
523
- color: config3?.color ?? DEFAULT_LOGGER_CONFIG.color,
524
- level: config3?.level ?? DEFAULT_LOGGER_CONFIG.level,
525
- file: {
526
- enabled: config3?.file?.enabled ?? DEFAULT_LOGGER_CONFIG.file.enabled,
527
- dir: config3?.file?.dir ?? DEFAULT_LOGGER_CONFIG.file.dir,
528
- level: config3?.file?.level ?? DEFAULT_LOGGER_CONFIG.file.level,
529
- daysToKeep: config3?.file?.daysToKeep ?? DEFAULT_LOGGER_CONFIG.file.daysToKeep,
530
- enableWholeMode: config3?.file?.enableWholeMode ?? DEFAULT_LOGGER_CONFIG.file.enableWholeMode,
531
- enableFragmentMode: config3?.file?.enableFragmentMode ?? DEFAULT_LOGGER_CONFIG.file.enableFragmentMode,
532
- maxFileSize: config3?.file?.maxFileSize ?? DEFAULT_LOGGER_CONFIG.file.maxFileSize,
533
- separateErrorLog: config3?.file?.separateErrorLog ?? DEFAULT_LOGGER_CONFIG.file.separateErrorLog
534
- }
535
- };
536
- return result;
537
- };
538
- }
539
- });
540
-
541
- // src/utils/message/segment.ts
542
- var segment_exports = {};
543
- __export(segment_exports, {
544
- at: () => at,
545
- basketball: () => basketball,
546
- bubbleFace: () => bubbleFace,
547
- button: () => button,
548
- contact: () => contact,
549
- customMusic: () => customMusic,
550
- dice: () => dice,
551
- face: () => face,
552
- gift: () => gift,
553
- image: () => image,
554
- json: () => json,
555
- keyboard: () => keyboard,
556
- location: () => location,
557
- longMsg: () => longMsg,
558
- markdown: () => markdown,
559
- markdownTpl: () => markdownTpl,
560
- marketFace: () => marketFace,
561
- music: () => music,
562
- node: () => node,
563
- nodeDirect: () => nodeDirect,
564
- pasmsg: () => pasmsg,
565
- raw: () => raw,
566
- record: () => record,
567
- reply: () => reply,
568
- rps: () => rps,
569
- share: () => share,
570
- text: () => text,
571
- video: () => video,
572
- weather: () => weather,
573
- xml: () => xml
574
- });
575
- var text, at, face, reply, image, video, record, json, xml, markdown, markdownTpl, pasmsg, keyboard, button, longMsg, raw, basketball, dice, rps, bubbleFace, weather, location, share, gift, marketFace, contact, music, customMusic, node, nodeDirect;
576
- var init_segment = __esm({
577
- "src/utils/message/segment.ts"() {
578
- text = (text2) => {
579
- return { type: "text", text: text2 };
580
- };
581
- at = (targetId, name) => {
582
- return { type: "at", targetId, name };
583
- };
584
- face = (id, isBig) => {
585
- return { type: "face", id: Number(id), isBig };
586
- };
587
- reply = (messageId) => {
588
- return { type: "reply", messageId: String(messageId) };
589
- };
590
- image = (file, options = {}) => {
591
- return {
592
- type: "image",
593
- file,
594
- fileType: options.fileType,
595
- height: options?.height,
596
- width: options?.width,
597
- md5: options?.md5,
598
- name: options?.name,
599
- subType: options?.subType
600
- };
601
- };
602
- video = (file, options) => {
603
- return {
604
- type: "video",
605
- file,
606
- height: options?.height,
607
- width: options?.width,
608
- md5: options?.md5,
609
- name: options?.name
610
- };
611
- };
612
- record = (file, magic = false, options) => {
613
- return {
614
- type: "record",
615
- file,
616
- magic,
617
- md5: options?.md5,
618
- name: options?.name
619
- };
620
- };
621
- json = (data) => {
622
- return { type: "json", data };
623
- };
624
- xml = (data) => {
625
- return { type: "xml", data };
626
- };
627
- markdown = (markdown2, config3) => {
628
- return { type: "markdown", markdown: markdown2, config: config3 };
629
- };
630
- markdownTpl = (templateId, params) => {
631
- return { type: "markdownTpl", templateId, params };
632
- };
633
- pasmsg = (id, source = "msg") => {
634
- return { type: "pasmsg", id, source };
635
- };
636
- keyboard = (data) => {
637
- const rows = [];
638
- if (!Array.isArray(data)) data = [data];
639
- for (const i of data) {
640
- if (Array.isArray(i)) {
641
- const button3 = [];
642
- for (const v of i) button3.push(v);
643
- rows.push(button3);
644
- } else {
645
- rows.push([i]);
646
- }
647
- }
648
- return { type: "keyboard", rows };
649
- };
650
- button = (data) => {
651
- return { type: "button", data: Array.isArray(data) ? data : [data] };
652
- };
653
- longMsg = (id) => {
654
- return { type: "longMsg", id };
655
- };
656
- raw = (data) => {
657
- return { type: "raw", data };
658
- };
659
- basketball = (id) => {
660
- return { type: "basketball", id: Number(id) };
661
- };
662
- dice = (id) => {
663
- return { type: "dice", id: Number(id) };
664
- };
665
- rps = (id) => {
666
- return { type: "rps", id: Number(id) };
667
- };
668
- bubbleFace = (id, count3) => {
669
- return { type: "bubbleFace", id: Number(id), count: Number(count3) };
670
- };
671
- weather = (city, code) => {
672
- return { type: "weather", city, code };
673
- };
674
- location = (lat, lon, title, address) => {
675
- return { type: "location", lat, lon, title, address };
676
- };
677
- share = (url, title, content, image2) => {
678
- return { type: "share", url, title, content, image: image2 };
679
- };
680
- gift = (qq, id) => {
681
- return { type: "gift", qq, id };
682
- };
683
- marketFace = (id) => {
684
- return { type: "marketFace", id };
685
- };
686
- contact = (scene, peer) => {
687
- return { type: "contact", scene, peer };
688
- };
689
- music = (platform, id) => {
690
- return { type: "music", platform, id };
691
- };
692
- customMusic = (url, audio, title, author, pic) => {
693
- return { type: "music", platform: "custom", url, audio, title, author, pic };
694
- };
695
- node = (userId, nickname, message2, options) => {
696
- return { type: "node", subType: "fake", userId, nickname, message: message2, options };
697
- };
698
- nodeDirect = (id) => {
699
- return { type: "node", subType: "messageID", messageId: id, message_id: id };
700
- };
701
- }
702
- });
703
- var createRawMessage, makeMessage, makeForward;
704
- var init_message = __esm({
705
- "src/utils/message/message.ts"() {
706
- init_segment();
707
- createRawMessage = (data) => {
708
- if (!Array.isArray(data)) data = [data];
709
- const msg = [];
710
- const rawStr = data.map((v) => {
711
- switch (v.type) {
712
- case "text": {
713
- msg.push(v.text);
714
- return v.text;
715
- }
716
- case "image":
717
- case "video":
718
- case "record": {
719
- if (Buffer.isBuffer(v.file)) return `[${v.type}:Buffer://...]`;
720
- if (/^http|^file/.test(v.file)) return `[${v.type}:${v.file}]`;
721
- return `[${v.type}:base64://...]`;
722
- }
723
- case "file": {
724
- if (Buffer.isBuffer(v.file)) return `[file:Buffer://..., fid:${v.fid}, md5:${v.md5}]`;
725
- if (/^http|^file/.test(v.file)) return `[file:${v.file}, fid:${v.fid}, md5:${v.md5}]`;
726
- return `[file:base64://..., fid:${v.fid}, md5:${v.md5}]`;
727
- }
728
- case "json":
729
- case "xml": {
730
- msg.push(v.data);
731
- return `[${v.type}:${v.data}]`;
732
- }
733
- case "at":
734
- return `[at:${v.targetId}]`;
735
- case "face":
736
- return `[face:${v.id}]`;
737
- case "reply":
738
- return `[reply:${v.messageId}]`;
739
- case "rps":
740
- return `[rps:${v.id}]`;
741
- case "dice":
742
- return `[dice:${v.id}]`;
743
- case "share":
744
- return `[share:${JSON.stringify(v)}]`;
745
- case "contact":
746
- return `[contact:${JSON.stringify(v)}]`;
747
- case "location":
748
- return `[location:${JSON.stringify(v)}]`;
749
- case "music":
750
- return `[music:${JSON.stringify(v)}]`;
751
- case "markdown":
752
- return `[markdown:${v.markdown}]`;
753
- case "button":
754
- return `[button:${JSON.stringify(v.data)}]`;
755
- case "keyboard":
756
- return `[rows:${JSON.stringify(v.rows)}]`;
757
- case "longMsg":
758
- return `[longmsg:${v.id}]`;
759
- case "pasmsg":
760
- return `[pasmsg:${v.id}]`;
761
- case "markdownTpl":
762
- return `[markdowntpl:${JSON.stringify({ templateId: v.templateId, ...v.params })}]`;
763
- default:
764
- return `[\u672A\u77E5:${lodash4.truncate(JSON.stringify(v), { length: 200 })}]`;
765
- }
766
- }).join("");
767
- return {
768
- /** 原始消息字符串: `[at:10001]这是一条测试的文本消息` */
769
- raw: rawStr,
770
- /**
771
- * - 经过处理的纯文本
772
- * - 可用于正则匹配
773
- * - tips: 此时还没有处理bot前缀
774
- */
775
- msg: msg.join("").trim()
776
- };
777
- };
778
- makeMessage = (elements) => {
779
- if (typeof elements === "string") return [text(elements)];
780
- if (!Array.isArray(elements)) return [elements];
781
- return elements.map((v) => typeof v === "string" ? text(v) : v);
782
- };
783
- makeForward = (elements, fakeId, fakeName) => {
784
- if (!Array.isArray(elements)) elements = [elements];
785
- return elements.map((v) => node(fakeId || "", fakeName || "", makeMessage(v)));
786
- };
787
- }
788
- });
789
-
790
- // src/utils/message/index.ts
791
- var init_message2 = __esm({
792
- "src/utils/message/index.ts"() {
793
- init_message();
794
- init_segment();
795
- }
796
- });
797
- function AdapterConvertKarin(data = []) {
798
- const elements = [];
799
- try {
800
- for (const i of data) {
801
- switch (i.type) {
802
- case "text":
803
- elements.push(segment_exports.text(i.data.text));
804
- break;
805
- case "face":
806
- elements.push(segment_exports.face(Number(i.data.id)));
807
- break;
808
- case "image":
809
- elements.push(segment_exports.image(i.data.url || i.data.file, { fileType: i.data.type }));
810
- break;
811
- case "record":
812
- elements.push(segment_exports.record(i.data.url || i.data.file, i.data.magic === 1));
813
- break;
814
- case "video":
815
- elements.push(segment_exports.video(i.data.url || i.data.file));
816
- break;
817
- case "at":
818
- elements.push(segment_exports.at(i.data.qq, i.data.name));
819
- break;
820
- case "contact":
821
- elements.push(segment_exports.contact(i.data.type === "qq" ? "friend" : "group", i.data.id));
822
- break;
823
- case "location":
824
- elements.push(segment_exports.location(
825
- Number(i.data.lat),
826
- Number(i.data.lon),
827
- i.data.title || "",
828
- i.data.content || ""
829
- ));
830
- break;
831
- case "reply":
832
- elements.push(segment_exports.reply(i.data.id));
833
- break;
834
- case "json":
835
- elements.push(segment_exports.json(i.data.data));
836
- break;
837
- case "xml":
838
- elements.push(segment_exports.xml(i.data.data));
839
- break;
840
- default: {
841
- elements.push(segment_exports.text(JSON.stringify(i)));
842
- }
843
- }
844
- }
845
- } catch (error) {
846
- logger.error("[AdapterConvertKarin] \u8F6C\u6362\u9519\u8BEF");
847
- logger.error(error);
848
- return elements;
849
- }
850
- return elements;
851
- }
852
- var formatLogString, buildError, fileToBase64, KarinConvertAdapter;
853
- var init_convert = __esm({
854
- "src/adapter/onebot/core/convert.ts"() {
855
- init_message2();
856
- formatLogString = (str) => {
857
- return str.replace(/(["']?(?:base64|base):\/\/)[^"',}\s]*["']?/g, "$1...");
858
- };
859
- buildError = (selfId, action, request2, error) => {
860
- if (error) {
861
- const err = JSON.stringify(error, null, 2).replace(/\\n/g, "\n");
862
- return new Error(`[${selfId}][sendApi] \u8BF7\u6C42\u9519\u8BEF:
863
- action: ${action}
864
- params: ${formatLogString(request2)}
865
- error: ${err}}`);
866
- }
867
- logger.error(`[${selfId}][sendApi][\u8BF7\u6C42\u9519\u8BEF]:
868
- action: ${action}
869
- params: ${formatLogString(request2)}`);
870
- };
871
- fileToBase64 = (file, url) => {
872
- if (!url || !file.startsWith("file://")) return file;
873
- const list2 = ["127.0.0.1", "localhost"];
874
- const link = new URL(url);
875
- return list2.includes(link.hostname) ? file : `base64://${fs7.readFileSync(file.replace("file://", "")).toString("base64")}`;
876
- };
877
- KarinConvertAdapter = (data, onebot) => {
878
- const elements = [];
879
- for (const i of data) {
880
- switch (i.type) {
881
- case "text":
882
- elements.push({ type: "text", data: { text: i.text } });
883
- break;
884
- case "face":
885
- elements.push({ type: "face", data: { id: i.id + "" } });
886
- break;
887
- case "at":
888
- elements.push({ type: "at", data: { qq: String(i.targetId), name: i.name } });
889
- break;
890
- case "reply":
891
- elements.push({ type: "reply", data: { id: i.messageId } });
892
- break;
893
- case "image": {
894
- elements.push({ type: "image", data: { file: fileToBase64(i.file, onebot.adapter.address) } });
895
- break;
896
- }
897
- case "video": {
898
- elements.push({ type: "video", data: { file: i.file } });
899
- break;
900
- }
901
- case "json":
902
- case "xml": {
903
- elements.push({ type: "json", data: { data: i.data } });
904
- break;
905
- }
906
- case "record": {
907
- elements.push({
908
- type: "record",
909
- data: {
910
- file: fileToBase64(i.file, onebot.adapter.address),
911
- magic: i.magic ?? false ? 1 : 0
912
- }
913
- });
914
- break;
915
- }
916
- case "music": {
917
- if (i.platform === "custom") {
918
- const { url, audio, title, author, pic } = i;
919
- elements.push({
920
- type: "music",
921
- data: {
922
- type: "custom",
923
- url,
924
- audio,
925
- title,
926
- content: author,
927
- image: pic
928
- }
929
- });
930
- } else {
931
- elements.push({
932
- type: "music",
933
- data: {
934
- type: i.platform,
935
- id: i.id
936
- }
937
- });
938
- }
939
- break;
940
- }
941
- // case OB11SegmentType.Contact: {
942
- // elements.push({ type, data: { type: i.scene, id: i.peer } })
943
- // break
944
- // }
945
- // case OB11SegmentType.Location: {
946
- // elements.push({ type, data: { lat: i.lat, lon: i.lon, title: i.title, content: i.address } })
947
- // break
948
- // }
949
- // case 'longMsg':
950
- // case 'basketball':
951
- // case 'marketFace': {
952
- // elements.push({ type: 'marketFace', data: { id: i.id + '' } })
953
- // break
954
- // }
955
- // case 'gift': {
956
- // elements.push({ type: 'gift', data: { qq: i.qq, id: i.id } })
957
- // break
958
- // }
959
- // case 'weather': {
960
- // elements.push({ type: 'weather', data: { city: i.city, type: i.type } })
961
- // break
962
- // }
963
- case "dice":
964
- case "rps": {
965
- elements.push({ type: i.type, data: {} });
966
- break;
967
- }
968
- case "share": {
969
- elements.push({ type: "share", data: { url: i.url, title: i.title, content: i.content, image: i.image } });
970
- break;
971
- }
972
- case "raw":
973
- elements.push(i.data);
974
- break;
975
- case "node": {
976
- if (i.subType === "messageID") {
977
- elements.push({ type: "forward", data: { id: i.messageId } });
978
- } else {
979
- elements.push({
980
- type: "node",
981
- data: {
982
- user_id: i.userId || onebot.selfId,
983
- nickname: i.nickname || onebot.selfName,
984
- content: KarinConvertAdapter(i.message, onebot),
985
- prompt: i?.options?.prompt,
986
- summary: i?.options?.summary,
987
- source: i?.options?.source
988
- }
989
- });
990
- }
991
- break;
992
- }
993
- case "button":
994
- case "markdown":
995
- case "keyboard":
996
- default: {
997
- elements.push(i);
998
- break;
999
- }
1000
- }
1001
- }
1002
- return elements;
1003
- };
1004
- }
1005
- });
1006
- var getCurrentDate, getMillisecondsUntilMidnight, ensureLogDir, cleanExpiredLogs, createFileWriter;
1007
- var init_file = __esm({
1008
- "src/service/logger/file.ts"() {
1009
- init_types();
1010
- init_convert();
1011
- getCurrentDate = () => {
1012
- const now = /* @__PURE__ */ new Date();
1013
- return now.toISOString().slice(0, 10);
1014
- };
1015
- getMillisecondsUntilMidnight = () => {
1016
- const now = /* @__PURE__ */ new Date();
1017
- const midnight = new Date(now);
1018
- midnight.setHours(24, 0, 0, 0);
1019
- return midnight.getTime() - now.getTime();
1020
- };
1021
- ensureLogDir = (dir2) => {
1022
- if (!fs7.existsSync(dir2)) {
1023
- try {
1024
- fs7.mkdirSync(dir2, { recursive: true });
1025
- } catch (err) {
1026
- console.error(`[Logger] \u521B\u5EFA\u65E5\u5FD7\u76EE\u5F55\u5931\u8D25: ${dir2}`, err);
1027
- }
291
+ err.code = "DECRYPTION_FAILED";
292
+ throw err;
293
+ } else {
294
+ throw error;
1028
295
  }
1029
- };
1030
- cleanExpiredLogs = async (dir2, daysToKeep) => {
1031
- if (!fs7.existsSync(dir2)) return;
1032
- const files = fs7.readdirSync(dir2);
1033
- const now = /* @__PURE__ */ new Date();
1034
- const logFileRegex = /^logger\.(?:error\.)?(\d{4}-\d{2}-\d{2})(?:-\d{2})?\.log$/;
1035
- await Promise.all(files.map(async (file) => {
1036
- const match = file.match(logFileRegex);
1037
- if (match) {
1038
- const dateStr = match[1];
1039
- const fileDate = new Date(dateStr);
1040
- const diffDays = Math.floor((now.getTime() - fileDate.getTime()) / (1e3 * 60 * 60 * 24));
1041
- if (diffDays > daysToKeep) {
1042
- try {
1043
- await fs7.promises.unlink(path5.join(dir2, file));
1044
- } catch {
1045
- }
1046
- }
1047
- }
1048
- }));
1049
- };
1050
- createFileWriter = (config3) => {
1051
- const normalHandle = { stream: null, date: "", fragment: 0, size: 0 };
1052
- const errorHandle = { stream: null, date: "", fragment: 0, size: 0 };
1053
- let midnightTimer = null;
1054
- let currentConfig = { ...config3 };
1055
- const getLogFilePath = (date, isError, fragment = 0) => {
1056
- const prefix = isError ? `logger.error.${date}` : `logger.${date}`;
1057
- const suffix = !isError && fragment > 0 ? `-${String(fragment).padStart(2, "0")}` : "";
1058
- return path5.join(currentConfig.dir, `${prefix}${suffix}.log`);
1059
- };
1060
- const safeGetFileSize = (filePath) => {
1061
- try {
1062
- return fs7.existsSync(filePath) ? fs7.statSync(filePath).size : 0;
1063
- } catch (err) {
1064
- return 0;
1065
- }
1066
- };
1067
- const createWriteStream2 = (filePath) => {
1068
- try {
1069
- const fileDir = path5.dirname(filePath);
1070
- if (!fs7.existsSync(fileDir)) {
1071
- fs7.mkdirSync(fileDir, { recursive: true });
1072
- }
1073
- return fs7.createWriteStream(filePath, {
1074
- flags: "a",
1075
- highWaterMark: 1024
1076
- // 降低缓冲阈值到1KB
1077
- });
1078
- } catch (err) {
1079
- const dummyStream = new fs7.WriteStream(null);
1080
- dummyStream.write = () => true;
1081
- return dummyStream;
1082
- }
1083
- };
1084
- const safeCloseStream = (stream3) => {
1085
- if (stream3) stream3.end();
1086
- };
1087
- const getStream = (isError) => {
1088
- const handle = isError ? errorHandle : normalHandle;
1089
- const currentDate = getCurrentDate();
1090
- const maxSize = currentConfig.maxFileSize * 1024 * 1024;
1091
- const filePath = getLogFilePath(currentDate, isError, handle.fragment);
1092
- if (handle.date !== currentDate || !handle.stream || !fs7.existsSync(filePath)) {
1093
- safeCloseStream(handle.stream);
1094
- if (handle.date !== currentDate) {
1095
- handle.fragment = 0;
1096
- }
1097
- handle.date = currentDate;
1098
- handle.size = safeGetFileSize(filePath);
1099
- handle.stream = createWriteStream2(filePath);
1100
- return handle.stream;
1101
- }
1102
- if (!isError && currentConfig.enableFragmentMode && handle.size >= maxSize) {
1103
- safeCloseStream(handle.stream);
1104
- handle.fragment++;
1105
- const newFilePath = getLogFilePath(currentDate, isError, handle.fragment);
1106
- handle.size = 0;
1107
- handle.stream = createWriteStream2(newFilePath);
1108
- }
1109
- return handle.stream;
1110
- };
1111
- const setupMidnightTimer = () => {
1112
- if (midnightTimer) {
1113
- clearTimeout(midnightTimer);
1114
- }
1115
- const msUntilMidnight = getMillisecondsUntilMidnight();
1116
- midnightTimer = setTimeout(() => {
1117
- closeStreams();
1118
- cleanExpiredLogs(currentConfig.dir, currentConfig.daysToKeep);
1119
- setupMidnightTimer();
1120
- }, msUntilMidnight);
1121
- };
1122
- const closeStreams = () => {
1123
- safeCloseStream(normalHandle.stream);
1124
- normalHandle.stream = null;
1125
- normalHandle.date = "";
1126
- safeCloseStream(errorHandle.stream);
1127
- errorHandle.stream = null;
1128
- errorHandle.date = "";
1129
- };
1130
- ensureLogDir(currentConfig.dir);
1131
- cleanExpiredLogs(currentConfig.dir, currentConfig.daysToKeep);
1132
- setupMidnightTimer();
1133
- const write2 = (level, content) => {
1134
- const contentSize = Buffer.from(content).length;
1135
- const logLevel = currentConfig.level || "info";
1136
- const formattedContent = formatLogString(content);
1137
- if ((currentConfig.enableWholeMode || currentConfig.enableFragmentMode) && LoggerLevelPriority[level] >= LoggerLevelPriority[logLevel]) {
1138
- const stream3 = getStream(false);
1139
- if (!stream3.write(formattedContent)) {
1140
- normalHandle.stream = null;
1141
- const newStream = getStream(false);
1142
- newStream.write(formattedContent);
1143
- }
1144
- normalHandle.size += contentSize;
1145
- }
1146
- if (currentConfig.separateErrorLog && (level === "error" || level === "fatal")) {
1147
- const stream3 = getStream(true);
1148
- stream3.write(formattedContent);
1149
- }
1150
- };
1151
- return {
1152
- write: write2,
1153
- /**
1154
- * @description 更新配置
1155
- * @param newConfig - 新的配置
1156
- */
1157
- updateConfig: (newConfig) => {
1158
- currentConfig = { ...currentConfig, ...newConfig };
1159
- },
1160
- /**
1161
- * @description 关闭日志写入器
1162
- */
1163
- close: closeStreams
1164
- };
1165
- };
296
+ }
1166
297
  }
1167
- });
1168
- var createLogger;
1169
- var init_logger = __esm({
1170
- "src/service/logger/logger.ts"() {
1171
- init_types();
1172
- init_utils();
1173
- init_file();
1174
- createLogger = (config3) => {
1175
- const normalizedConfig = normalizeConfig(config3);
1176
- const state = {
1177
- level: normalizedConfig.level,
1178
- config: normalizedConfig,
1179
- fileWriter: null
1180
- };
1181
- const setupWriters = () => {
1182
- if (state.fileWriter) {
1183
- state.fileWriter.close?.();
1184
- state.fileWriter = null;
1185
- }
1186
- if (state.config.file.enabled && (state.config.file.enableWholeMode || state.config.file.enableFragmentMode)) {
1187
- state.fileWriter = createFileWriter(state.config.file);
1188
- }
1189
- };
1190
- const configure = (newConfig) => {
1191
- const oldLevel = state.config.level;
1192
- const oldFileConfig = { ...state.config.file };
1193
- state.config = normalizeConfig({
1194
- ...state.config,
1195
- ...newConfig
1196
- });
1197
- if (state.config.level !== oldLevel) {
1198
- state.level = state.config.level;
1199
- }
1200
- const fileConfigChanged = JSON.stringify(oldFileConfig) !== JSON.stringify(state.config.file);
1201
- if (fileConfigChanged && (oldFileConfig.enabled !== state.config.file.enabled || oldFileConfig.enableWholeMode !== state.config.file.enableWholeMode || oldFileConfig.enableFragmentMode !== state.config.file.enableFragmentMode || oldFileConfig.dir !== state.config.file.dir)) {
1202
- setupWriters();
1203
- } else if (state.fileWriter && state.fileWriter.updateConfig) {
1204
- state.fileWriter.updateConfig(state.config.file);
298
+ function populate2(processEnv, parsed, options = {}) {
299
+ const debug3 = Boolean(options && options.debug);
300
+ const override = Boolean(options && options.override);
301
+ if (typeof parsed !== "object") {
302
+ const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
303
+ err.code = "OBJECT_REQUIRED";
304
+ throw err;
305
+ }
306
+ for (const key of Object.keys(parsed)) {
307
+ if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
308
+ if (override === true) {
309
+ processEnv[key] = parsed[key];
1205
310
  }
1206
- };
1207
- const createLogFunction = (level) => {
1208
- const levelText = level.toUpperCase().slice(0, 4);
1209
- const colorMap = {
1210
- trace: chalk2.cyan,
1211
- debug: chalk2.blue,
1212
- info: chalk2.green,
1213
- warn: chalk2.yellow,
1214
- error: chalk2.red,
1215
- fatal: chalk2.magenta,
1216
- mark: chalk2.gray
1217
- };
1218
- return (...args) => {
1219
- const now = /* @__PURE__ */ new Date();
1220
- const timestamp = now.toLocaleTimeString(void 0, { hour12: false }) + "." + now.getMilliseconds().toString().padStart(3, "0");
1221
- const prefixText = colorMap[level](`${state.config.prefix}[${timestamp}][${levelText}]`);
1222
- const message2 = util6.format(...args);
1223
- if (LoggerLevelPriority[level] >= LoggerLevelPriority[state.level]) {
1224
- process.stdout.write(`${prefixText} ${message2}
1225
- `);
1226
- }
1227
- if (state.fileWriter) {
1228
- try {
1229
- state.fileWriter.write(level, `[${timestamp}][${levelText}] ${message2}
1230
- `);
1231
- } catch (err) {
1232
- const errorMessage = err instanceof Error ? err.message : String(err);
1233
- process.stdout.write(`${chalk2.red(`${state.config.prefix}[${timestamp}][ERROR]`)} \u6587\u4EF6\u5199\u5165\u5931\u8D25: ${errorMessage}
1234
- `);
1235
- }
1236
- }
1237
- };
1238
- };
1239
- setupWriters();
1240
- const logger3 = {
1241
- chalk: chalk2,
1242
- red: chalk2.red,
1243
- green: chalk2.green,
1244
- yellow: chalk2.yellow,
1245
- blue: chalk2.blue,
1246
- magenta: chalk2.magenta,
1247
- cyan: chalk2.cyan,
1248
- white: chalk2.white,
1249
- gray: chalk2.gray,
1250
- violet: chalk2.hex("#868ECC"),
1251
- get fnc() {
1252
- return chalk2.hex(state.config.color || "#FFFF00");
1253
- },
1254
- get level() {
1255
- return state.level;
1256
- },
1257
- set level(value) {
1258
- state.level = value;
1259
- if (state.fileWriter && state.fileWriter.updateConfig) {
1260
- state.fileWriter.updateConfig({
1261
- level: value
1262
- });
311
+ if (debug3) {
312
+ if (override === true) {
313
+ _debug(`"${key}" is already defined and WAS overwritten`);
314
+ } else {
315
+ _debug(`"${key}" is already defined and was NOT overwritten`);
1263
316
  }
1264
- },
1265
- get config() {
1266
- return { ...state.config };
1267
- },
1268
- configure,
1269
- close: () => {
1270
- state.fileWriter?.close?.();
1271
- state.fileWriter = null;
1272
- },
1273
- off: () => {
1274
- state.level = "off";
1275
- },
1276
- trace: createLogFunction("trace"),
1277
- debug: createLogFunction("debug"),
1278
- info: createLogFunction("info"),
1279
- warn: createLogFunction("warn"),
1280
- error: createLogFunction("error"),
1281
- fatal: createLogFunction("fatal"),
1282
- mark: createLogFunction("mark"),
1283
- log: createLogFunction("info"),
1284
- bot: (level, id, ...args) => {
1285
- logger3[level](logger3.violet(`[Bot:${id}]`), ...args);
1286
- },
1287
- prefix: (prefixStr) => {
1288
- return (level, ...args) => {
1289
- logger3[level](prefixStr, ...args);
1290
- };
1291
317
  }
1292
- };
1293
- return logger3;
318
+ } else {
319
+ processEnv[key] = parsed[key];
320
+ }
321
+ }
322
+ }
323
+ const DotenvModule = {
324
+ configDotenv: configDotenv2,
325
+ _configVault: _configVault2,
326
+ _parseVault: _parseVault2,
327
+ config: config3,
328
+ decrypt: decrypt2,
329
+ parse: parse2,
330
+ populate: populate2
331
+ };
332
+ main$1.exports.configDotenv = DotenvModule.configDotenv;
333
+ main$1.exports._configVault = DotenvModule._configVault;
334
+ main$1.exports._parseVault = DotenvModule._parseVault;
335
+ main$1.exports.config = DotenvModule.config;
336
+ main$1.exports.decrypt = DotenvModule.decrypt;
337
+ main$1.exports.parse = DotenvModule.parse;
338
+ main$1.exports.populate = DotenvModule.populate;
339
+ main$1.exports = DotenvModule;
340
+ return main$1.exports;
341
+ }
342
+ var main$1, version, require$$4, hasRequiredMain, mainExports, main, dotenv;
343
+ var init_main_D88Wwqn3 = __esm({
344
+ "../../node_modules/.pnpm/@karinjs+dotenv@1.1.2/node_modules/@karinjs/dotenv/dist/main-D88Wwqn3.js"() {
345
+ main$1 = { exports: {} };
346
+ version = "16.5.0";
347
+ require$$4 = {
348
+ version
1294
349
  };
350
+ mainExports = requireMain();
351
+ main = /* @__PURE__ */ getDefaultExportFromCjs(mainExports);
352
+ dotenv = /* @__PURE__ */ _mergeNamespaces({
353
+ __proto__: null,
354
+ default: main
355
+ }, [mainExports]);
1295
356
  }
1296
357
  });
1297
358
 
1298
- // src/service/logger/index.ts
1299
- var init_logger2 = __esm({
1300
- "src/service/logger/index.ts"() {
1301
- init_logger();
359
+ // ../../node_modules/.pnpm/@karinjs+dotenv@1.1.2/node_modules/@karinjs/dotenv/dist/index.js
360
+ var _configVault, _parseVault;
361
+ var init_dist = __esm({
362
+ "../../node_modules/.pnpm/@karinjs+dotenv@1.1.2/node_modules/@karinjs/dotenv/dist/index.js"() {
363
+ init_main_D88Wwqn3();
364
+ ({
365
+ _configVault: (
366
+ // @ts-ignore
367
+ _configVault
368
+ ),
369
+ _parseVault
370
+ } = dotenv);
371
+ mainExports.config;
372
+ mainExports.configDotenv;
373
+ mainExports.decrypt;
374
+ mainExports.parse;
375
+ mainExports.populate;
1302
376
  }
1303
377
  });
1304
378
 
1305
- // src/utils/logger/logger.ts
1306
- var logger2, createInnerLogger;
1307
- var init_logger3 = __esm({
1308
- "src/utils/logger/logger.ts"() {
1309
- init_logger2();
1310
- logger2 = createLogger({ prefix: "[karin]", level: "info" });
1311
- createInnerLogger = (dir2) => {
1312
- global.logger = logger2;
1313
- logger2.level = process.env.LOG_LEVEL || "info";
1314
- const maxFileSize = Number(process.env.LOG_MAX_LOG_SIZE) || 0;
1315
- logger2.configure({
1316
- file: {
1317
- dir: dir2,
1318
- enabled: true,
1319
- enableWholeMode: true,
1320
- enableFragmentMode: maxFileSize > 0,
1321
- maxFileSize,
1322
- daysToKeep: Number(process.env.LOG_DAYS_TO_KEEP) || 1,
1323
- separateErrorLog: true
1324
- }
1325
- });
1326
- return logger2;
379
+ // ../../node_modules/.pnpm/@karinjs+dotenv@1.1.2/node_modules/@karinjs/dotenv/index.js
380
+ var app, dotenv_default;
381
+ var init_dotenv = __esm({
382
+ "../../node_modules/.pnpm/@karinjs+dotenv@1.1.2/node_modules/@karinjs/dotenv/index.js"() {
383
+ init_dist();
384
+ init_dist();
385
+ app = dotenv.default;
386
+ dotenv_default = app;
387
+ }
388
+ });
389
+ var filename, karinPathRoot, karinPathMain, karinPathPlugins, isPackaged, karinPathDefaultConfig, karinPathDefaultView, karinPathComment, karinPathBase, karinPathConfig, karinPathData, karinPathTemp, karinPathResource, karinPathDb, karinPathTaskDb, karinPathRedisSqlite3, karinPathKv, karinPathLogs, karinPathHtml, karinPathPm2Config, karinPathConsole, karinPathSandboxData, karinPathSandboxTemp, karinDir, karinMain, pluginDir, isPkg, defaultConfigPath, defaultViewPath, commentPath, basePath, configPath, dataPath, tempPath, resourcePath, dbPath, redisSqlite3Path, kvPath, logsPath, htmlPath, pm2Path, consolePath, sandboxDataPath, sandboxTempPath, root_default;
390
+ var init_root = __esm({
391
+ "src/root.ts"() {
392
+ filename = fileURLToPath(import.meta.url);
393
+ karinPathRoot = Object.freeze(path.join(filename, "../..").replace(/\\/g, "/"));
394
+ karinPathMain = Object.freeze(path.join(karinPathRoot, "dist", "index.js"));
395
+ karinPathPlugins = Object.freeze(path.join(process.cwd(), "plugins"));
396
+ isPackaged = Object.freeze(filename.includes("node_modules"));
397
+ karinPathDefaultConfig = Object.freeze(path.join(karinPathRoot, "default", "config"));
398
+ karinPathDefaultView = Object.freeze(path.join(karinPathRoot, "default", "view"));
399
+ karinPathComment = Object.freeze(path.join(karinPathRoot, "default", "comment"));
400
+ karinPathBase = Object.freeze(path.join(process.cwd(), "@karinjs"));
401
+ karinPathConfig = Object.freeze(path.join(karinPathBase, "config"));
402
+ karinPathData = Object.freeze(path.join(karinPathBase, "data"));
403
+ karinPathTemp = Object.freeze(path.join(karinPathBase, "temp"));
404
+ karinPathResource = Object.freeze(path.join(karinPathBase, "resource"));
405
+ karinPathDb = Object.freeze(path.join(karinPathData, "db"));
406
+ karinPathTaskDb = Object.freeze(path.join(karinPathDb, "task"));
407
+ karinPathRedisSqlite3 = Object.freeze(path.join(karinPathDb, "redis-sqlite3"));
408
+ karinPathKv = Object.freeze(path.join(karinPathDb, "kv"));
409
+ karinPathLogs = Object.freeze(path.join(karinPathBase, "logs"));
410
+ karinPathHtml = Object.freeze(path.join(karinPathTemp, "html"));
411
+ karinPathPm2Config = Object.freeze(path.join(karinPathConfig, "pm2.yaml"));
412
+ karinPathConsole = Object.freeze(path.join(karinPathTemp, "console"));
413
+ karinPathSandboxData = Object.freeze(path.join(karinPathData, "sandbox"));
414
+ karinPathSandboxTemp = Object.freeze(path.join(karinPathTemp, "sandbox"));
415
+ karinDir = karinPathRoot;
416
+ karinMain = karinPathMain;
417
+ pluginDir = karinPathPlugins;
418
+ isPkg = isPackaged;
419
+ defaultConfigPath = karinPathDefaultConfig;
420
+ defaultViewPath = karinPathDefaultView;
421
+ commentPath = karinPathComment;
422
+ basePath = karinPathBase;
423
+ configPath = karinPathConfig;
424
+ dataPath = karinPathData;
425
+ tempPath = karinPathTemp;
426
+ resourcePath = karinPathResource;
427
+ dbPath = karinPathDb;
428
+ redisSqlite3Path = karinPathRedisSqlite3;
429
+ kvPath = karinPathKv;
430
+ logsPath = karinPathLogs;
431
+ htmlPath = karinPathHtml;
432
+ pm2Path = karinPathPm2Config;
433
+ consolePath = karinPathConsole;
434
+ sandboxDataPath = karinPathSandboxData;
435
+ sandboxTempPath = karinPathSandboxTemp;
436
+ root_default = {
437
+ // 新常量
438
+ karinPathRoot,
439
+ karinPathMain,
440
+ karinPathPlugins,
441
+ isPackaged,
442
+ karinPathDefaultConfig,
443
+ karinPathDefaultView,
444
+ karinPathComment,
445
+ karinPathBase,
446
+ karinPathConfig,
447
+ karinPathData,
448
+ karinPathTemp,
449
+ karinPathResource,
450
+ karinPathDb,
451
+ karinPathRedisSqlite3,
452
+ karinPathKv,
453
+ karinPathLogs,
454
+ karinPathHtml,
455
+ karinPathPm2Config,
456
+ karinPathConsole,
457
+ karinPathSandboxData,
458
+ karinPathSandboxTemp,
459
+ karinPathTaskDb,
460
+ // 旧常量,保持兼容性
461
+ karinDir,
462
+ karinMain,
463
+ pluginDir,
464
+ isPkg,
465
+ defaultConfigPath,
466
+ defaultViewPath,
467
+ commentPath,
468
+ basePath,
469
+ configPath,
470
+ dataPath,
471
+ tempPath,
472
+ resourcePath,
473
+ dbPath,
474
+ redisSqlite3Path,
475
+ kvPath,
476
+ logsPath,
477
+ htmlPath,
478
+ pm2Path,
479
+ consolePath,
480
+ sandboxDataPath,
481
+ sandboxTempPath
1327
482
  };
1328
483
  }
1329
484
  });
@@ -1349,9 +504,9 @@ var init_env = __esm({
1349
504
  }
1350
505
  };
1351
506
  isWorkspace = () => {
1352
- const workspace = fs7.existsSync(`${process.cwd()}/pnpm-workspace.yaml`);
507
+ const workspace = fs5.existsSync(`${process.cwd()}/pnpm-workspace.yaml`);
1353
508
  if (!workspace) return false;
1354
- const data = YAML.parse(fs7.readFileSync(`${process.cwd()}/pnpm-workspace.yaml`, "utf-8"));
509
+ const data = YAML.parse(fs5.readFileSync(`${process.cwd()}/pnpm-workspace.yaml`, "utf-8"));
1355
510
  return Array.isArray(data.packages) && data.packages.length > 0;
1356
511
  };
1357
512
  setProcessEnv = (key, value) => {
@@ -1409,26 +564,26 @@ var init_require = __esm({
1409
564
  "src/utils/fs/require.ts"() {
1410
565
  cache = /* @__PURE__ */ new Map();
1411
566
  clearRequireFile = (filePath) => {
1412
- const absPath2 = path5.resolve(filePath).replace(/\\/g, "/");
567
+ const absPath2 = path4.resolve(filePath).replace(/\\/g, "/");
1413
568
  return cache.has(absPath2) && cache.delete(absPath2);
1414
569
  };
1415
570
  clearRequire = () => cache.clear();
1416
571
  requireFile = async (filePath, options = {}) => {
1417
572
  const now = Date.now();
1418
- const absPath2 = path5.resolve(filePath).replace(/\\/g, "/");
573
+ const absPath2 = path4.resolve(filePath).replace(/\\/g, "/");
1419
574
  const { encoding = "utf-8", force = false, ex = 300, size = 0, parser: parser2, type, readCache } = options;
1420
575
  const data = fileReady(absPath2, now, force, ex, readCache);
1421
576
  if (data !== false) return data;
1422
- const content = await fs7.promises.readFile(absPath2, encoding);
577
+ const content = await fs5.promises.readFile(absPath2, encoding);
1423
578
  return fileCache(content, absPath2, ex, now, size, encoding, parser2, type);
1424
579
  };
1425
580
  requireFileSync = (filePath, options = {}) => {
1426
581
  const now = Date.now();
1427
- const absPath2 = path5.resolve(filePath).replace(/\\/g, "/");
582
+ const absPath2 = path4.resolve(filePath).replace(/\\/g, "/");
1428
583
  const { encoding = "utf-8", force = false, ex = 300, size = 0, parser: parser2, type, readCache } = options;
1429
584
  const data = fileReady(absPath2, now, force, ex, readCache);
1430
585
  if (data !== false) return data;
1431
- const content = fs7.readFileSync(absPath2, encoding);
586
+ const content = fs5.readFileSync(absPath2, encoding);
1432
587
  return fileCache(content, absPath2, ex, now, size, encoding, parser2, type);
1433
588
  };
1434
589
  fileReady = (absPath2, now, force, ex, readCache) => {
@@ -1747,14 +902,14 @@ var init_watch = __esm({
1747
902
  const watcher2 = chokidar.watch(file);
1748
903
  cache2.set(file, watcher2);
1749
904
  watcher2.on("change", async () => {
1750
- logger.info(`[watch][change] ${path5.relative(process.cwd(), file).replace(/\\/g, "/")}`);
905
+ logger.info(`[watch][change] ${path4.relative(process.cwd(), file).replace(/\\/g, "/")}`);
1751
906
  const oldData = requireFileSync(file, { ...options, readCache: true });
1752
907
  clearRequireFile(file);
1753
908
  const newData = requireFileSync(file, { ...options, force: true });
1754
909
  typeof fnc2 === "function" && fnc2(oldData, newData);
1755
910
  });
1756
911
  watcher2.on("unlink", () => {
1757
- logger.info(`[watch][unlink] ${path5.relative(process.cwd(), file).replace(/\\/g, "/")}`);
912
+ logger.info(`[watch][unlink] ${path4.relative(process.cwd(), file).replace(/\\/g, "/")}`);
1758
913
  clearRequireFile(file);
1759
914
  });
1760
915
  watcher2.once("close", () => {
@@ -1830,7 +985,7 @@ var init_fsPromises = __esm({
1830
985
  "src/utils/fs/fsPromises.ts"() {
1831
986
  exists = async (file) => {
1832
987
  try {
1833
- await fs7.promises.access(file, fs7.constants.F_OK);
988
+ await fs5.promises.access(file, fs5.constants.F_OK);
1834
989
  return true;
1835
990
  } catch {
1836
991
  return false;
@@ -1838,7 +993,7 @@ var init_fsPromises = __esm({
1838
993
  };
1839
994
  isDir = async (file) => {
1840
995
  try {
1841
- const stat = await fs7.promises.stat(file);
996
+ const stat = await fs5.promises.stat(file);
1842
997
  return stat.isDirectory();
1843
998
  } catch {
1844
999
  return false;
@@ -1846,7 +1001,7 @@ var init_fsPromises = __esm({
1846
1001
  };
1847
1002
  isFile = async (file) => {
1848
1003
  try {
1849
- const stat = await fs7.promises.stat(file);
1004
+ const stat = await fs5.promises.stat(file);
1850
1005
  return stat.isFile();
1851
1006
  } catch {
1852
1007
  return false;
@@ -1854,7 +1009,7 @@ var init_fsPromises = __esm({
1854
1009
  };
1855
1010
  mkdir = async (dirname) => {
1856
1011
  try {
1857
- await fs7.promises.mkdir(dirname, { recursive: true });
1012
+ await fs5.promises.mkdir(dirname, { recursive: true });
1858
1013
  return true;
1859
1014
  } catch {
1860
1015
  return false;
@@ -1874,25 +1029,25 @@ var existsSync, isDirSync, isFileSync, mkdirSync, existToMkdirSync, rmSync;
1874
1029
  var init_fsSync = __esm({
1875
1030
  "src/utils/fs/fsSync.ts"() {
1876
1031
  existsSync = (file) => {
1877
- return fs7.existsSync(file);
1032
+ return fs5.existsSync(file);
1878
1033
  };
1879
1034
  isDirSync = (file) => {
1880
1035
  try {
1881
- return fs7.statSync(file).isDirectory();
1036
+ return fs5.statSync(file).isDirectory();
1882
1037
  } catch {
1883
1038
  return false;
1884
1039
  }
1885
1040
  };
1886
1041
  isFileSync = (file) => {
1887
1042
  try {
1888
- return fs7.statSync(file).isFile();
1043
+ return fs5.statSync(file).isFile();
1889
1044
  } catch {
1890
1045
  return false;
1891
1046
  }
1892
1047
  };
1893
1048
  mkdirSync = (dirname) => {
1894
1049
  try {
1895
- fs7.mkdirSync(dirname, { recursive: true });
1050
+ fs5.mkdirSync(dirname, { recursive: true });
1896
1051
  return true;
1897
1052
  } catch {
1898
1053
  return false;
@@ -1900,26 +1055,26 @@ var init_fsSync = __esm({
1900
1055
  };
1901
1056
  existToMkdirSync = (file) => {
1902
1057
  try {
1903
- if (!fs7.existsSync(file)) mkdirSync(file);
1058
+ if (!fs5.existsSync(file)) mkdirSync(file);
1904
1059
  return true;
1905
1060
  } catch {
1906
1061
  return false;
1907
1062
  }
1908
1063
  };
1909
- rmSync = fs7.rmSync;
1064
+ rmSync = fs5.rmSync;
1910
1065
  }
1911
1066
  });
1912
1067
  var streamPipeline, sep, downloadFile, downFile, absPath, createPluginDir, getFiles, copyFilesSync, copyFiles, copyConfigSync, copyConfig, getAllFilesSync, getAllFiles;
1913
- var init_file2 = __esm({
1068
+ var init_file = __esm({
1914
1069
  "src/utils/fs/file.ts"() {
1915
1070
  init_root();
1916
1071
  streamPipeline = promisify(pipeline);
1917
- sep = path5.sep === "/" ? /^file:\/\// : /^file:[/]{2,3}/;
1072
+ sep = path4.sep === "/" ? /^file:\/\// : /^file:[/]{2,3}/;
1918
1073
  downloadFile = async (fileUrl, savePath, options = {}) => {
1919
1074
  try {
1920
- await fs7.promises.mkdir(path5.dirname(savePath), { recursive: true });
1075
+ await fs5.promises.mkdir(path4.dirname(savePath), { recursive: true });
1921
1076
  const response = await axios9.get(fileUrl, { ...options, responseType: "stream" });
1922
- await streamPipeline(response.data, fs7.createWriteStream(savePath));
1077
+ await streamPipeline(response.data, fs5.createWriteStream(savePath));
1923
1078
  if (options.returnBoolean) {
1924
1079
  return true;
1925
1080
  }
@@ -1937,8 +1092,8 @@ var init_file2 = __esm({
1937
1092
  absPath = (file, absPath2 = true, prefix = false) => {
1938
1093
  file = file.replace(/\\/g, "/");
1939
1094
  if (file.startsWith("file://")) file = file.replace(sep, "");
1940
- file = path5.normalize(file);
1941
- if (absPath2) file = path5.resolve(file);
1095
+ file = path4.normalize(file);
1096
+ if (absPath2) file = path4.resolve(file);
1942
1097
  if (prefix) file = "file://" + file;
1943
1098
  return file.replace(/\\/g, "/");
1944
1099
  };
@@ -1946,26 +1101,26 @@ var init_file2 = __esm({
1946
1101
  if (!Array.isArray(files)) files = ["config", "data", "resources"];
1947
1102
  if (files.length === 0) return;
1948
1103
  const isOrgPkg = name.startsWith("@") && name.includes("/");
1949
- let pluginPath = isOrgPkg ? path5.join(karinPathBase, name.replace("/", "-")) : path5.join(karinPathBase, name);
1950
- if (isOrgPkg && !fs7.existsSync(pluginPath)) {
1104
+ let pluginPath = isOrgPkg ? path4.join(karinPathBase, name.replace("/", "-")) : path4.join(karinPathBase, name);
1105
+ if (isOrgPkg && !fs5.existsSync(pluginPath)) {
1951
1106
  const [orgName, pkgName] = name.split("/");
1952
- pluginPath = path5.join(karinPathBase, orgName, pkgName);
1107
+ pluginPath = path4.join(karinPathBase, orgName, pkgName);
1953
1108
  }
1954
1109
  await Promise.all(files.map((file) => {
1955
- const filePath = path5.join(pluginPath, file);
1956
- if (!fs7.existsSync(filePath)) return fs7.promises.mkdir(filePath, { recursive: true });
1110
+ const filePath = path4.join(pluginPath, file);
1111
+ if (!fs5.existsSync(filePath)) return fs5.promises.mkdir(filePath, { recursive: true });
1957
1112
  return Promise.resolve();
1958
1113
  }));
1959
1114
  };
1960
1115
  getFiles = (filePath, suffixs = []) => {
1961
- if (!fs7.existsSync(filePath)) {
1116
+ if (!fs5.existsSync(filePath)) {
1962
1117
  throw new Error(`\u8DEF\u5F84\u4E0D\u5B58\u5728: ${filePath}`);
1963
1118
  }
1964
- let files = fs7.readdirSync(filePath, { withFileTypes: true }).filter((file) => file.isFile()).map((file) => file.name);
1119
+ let files = fs5.readdirSync(filePath, { withFileTypes: true }).filter((file) => file.isFile()).map((file) => file.name);
1965
1120
  if (suffixs.length) {
1966
1121
  const normalizedSuffixs = suffixs.map((suffix) => suffix.startsWith(".") ? suffix : `.${suffix}`);
1967
1122
  files = files.filter((file) => {
1968
- const suffix = path5.extname(file);
1123
+ const suffix = path4.extname(file);
1969
1124
  return suffix && normalizedSuffixs.includes(suffix);
1970
1125
  });
1971
1126
  }
@@ -1973,27 +1128,27 @@ var init_file2 = __esm({
1973
1128
  };
1974
1129
  copyFilesSync = (files, defaulPath, userPath) => {
1975
1130
  files.forEach((file) => {
1976
- const defaulFile = path5.join(defaulPath, file);
1977
- const userFile = path5.join(userPath, file);
1978
- if (!fs7.existsSync(userFile)) {
1979
- fs7.copyFileSync(defaulFile, userFile);
1131
+ const defaulFile = path4.join(defaulPath, file);
1132
+ const userFile = path4.join(userPath, file);
1133
+ if (!fs5.existsSync(userFile)) {
1134
+ fs5.copyFileSync(defaulFile, userFile);
1980
1135
  }
1981
1136
  });
1982
1137
  };
1983
1138
  copyFiles = async (files, defaulPath, userPath) => {
1984
1139
  await Promise.all(files.map(async (file) => {
1985
- const defaulFile = path5.join(defaulPath, file);
1986
- const userFile = path5.join(userPath, file);
1987
- if (!fs7.existsSync(userFile)) {
1988
- await fs7.promises.copyFile(defaulFile, userFile);
1140
+ const defaulFile = path4.join(defaulPath, file);
1141
+ const userFile = path4.join(userPath, file);
1142
+ if (!fs5.existsSync(userFile)) {
1143
+ await fs5.promises.copyFile(defaulFile, userFile);
1989
1144
  }
1990
1145
  }));
1991
1146
  };
1992
1147
  copyConfigSync = (defaulPath, userPath, suffixs = [], isThrow = false) => {
1993
1148
  try {
1994
1149
  const files = getFiles(defaulPath, suffixs);
1995
- fs7.mkdirSync(userPath, { recursive: true });
1996
- fs7.mkdirSync(defaulPath, { recursive: true });
1150
+ fs5.mkdirSync(userPath, { recursive: true });
1151
+ fs5.mkdirSync(defaulPath, { recursive: true });
1997
1152
  copyFilesSync(files, defaulPath, userPath);
1998
1153
  return true;
1999
1154
  } catch (error) {
@@ -2005,8 +1160,8 @@ var init_file2 = __esm({
2005
1160
  try {
2006
1161
  const files = getFiles(defaulPath, suffixs);
2007
1162
  await Promise.all([
2008
- fs7.promises.mkdir(userPath, { recursive: true }),
2009
- fs7.promises.mkdir(defaulPath, { recursive: true })
1163
+ fs5.promises.mkdir(userPath, { recursive: true }),
1164
+ fs5.promises.mkdir(defaulPath, { recursive: true })
2010
1165
  ]);
2011
1166
  await copyFiles(files, defaulPath, userPath);
2012
1167
  return true;
@@ -2019,14 +1174,14 @@ var init_file2 = __esm({
2019
1174
  const { suffixs = [], exclude = [], returnType = "rel" } = options;
2020
1175
  const result = [];
2021
1176
  const readDirRecursive = (currentDir, prefix = "") => {
2022
- const files = fs7.readdirSync(currentDir, { withFileTypes: true });
1177
+ const files = fs5.readdirSync(currentDir, { withFileTypes: true });
2023
1178
  for (const file of files) {
2024
- const relativePath = path5.join(prefix, file.name);
2025
- const fullPath = path5.join(currentDir, file.name);
1179
+ const relativePath = path4.join(prefix, file.name);
1180
+ const fullPath = path4.join(currentDir, file.name);
2026
1181
  if (file.isDirectory()) {
2027
1182
  readDirRecursive(fullPath, relativePath);
2028
1183
  } else if (file.isFile()) {
2029
- const suffix = path5.extname(file.name);
1184
+ const suffix = path4.extname(file.name);
2030
1185
  if (suffixs.length > 0) {
2031
1186
  const normalizedSuffixs = suffixs.map((s) => s.startsWith(".") ? s : `.${s}`);
2032
1187
  if (normalizedSuffixs.includes(suffix)) {
@@ -2043,7 +1198,7 @@ var init_file2 = __esm({
2043
1198
  }
2044
1199
  }
2045
1200
  };
2046
- if (!fs7.existsSync(dir2)) {
1201
+ if (!fs5.existsSync(dir2)) {
2047
1202
  throw new Error(`\u8DEF\u5F84\u4E0D\u5B58\u5728: ${dir2}`);
2048
1203
  }
2049
1204
  readDirRecursive(dir2);
@@ -2053,14 +1208,14 @@ var init_file2 = __esm({
2053
1208
  const { suffixs = [], exclude = [], returnType = "rel" } = options;
2054
1209
  const result = [];
2055
1210
  const readDirRecursive = async (currentDir, prefix = "") => {
2056
- const files = await fs7.promises.readdir(currentDir, { withFileTypes: true });
1211
+ const files = await fs5.promises.readdir(currentDir, { withFileTypes: true });
2057
1212
  await Promise.all(files.map(async (file) => {
2058
- const relativePath = path5.join(prefix, file.name);
2059
- const fullPath = path5.join(currentDir, file.name);
1213
+ const relativePath = path4.join(prefix, file.name);
1214
+ const fullPath = path4.join(currentDir, file.name);
2060
1215
  if (file.isDirectory()) {
2061
1216
  await readDirRecursive(fullPath, relativePath);
2062
1217
  } else if (file.isFile()) {
2063
- const suffix = path5.extname(file.name);
1218
+ const suffix = path4.extname(file.name);
2064
1219
  if (suffixs.length > 0) {
2065
1220
  const normalizedSuffixs = suffixs.map((s) => s.startsWith(".") ? s : `.${s}`);
2066
1221
  if (normalizedSuffixs.includes(suffix)) {
@@ -2077,7 +1232,7 @@ var init_file2 = __esm({
2077
1232
  }
2078
1233
  }));
2079
1234
  };
2080
- if (!fs7.existsSync(dir2)) {
1235
+ if (!fs5.existsSync(dir2)) {
2081
1236
  throw new Error(`\u8DEF\u5F84\u4E0D\u5B58\u5728: ${dir2}`);
2082
1237
  }
2083
1238
  await readDirRecursive(dir2);
@@ -2088,7 +1243,7 @@ var init_file2 = __esm({
2088
1243
  var base64, buffer, stream, readFile, randomStr;
2089
1244
  var init_data = __esm({
2090
1245
  "src/utils/fs/data.ts"() {
2091
- init_file2();
1246
+ init_file();
2092
1247
  base64 = async (data, options = { http: false }) => {
2093
1248
  if (typeof data !== "string") {
2094
1249
  if (Buffer.isBuffer(data)) return data.toString("base64");
@@ -2104,7 +1259,7 @@ var init_data = __esm({
2104
1259
  return buffer2.toString("base64");
2105
1260
  }
2106
1261
  const files = data.replace(sep, "");
2107
- if (fs7.existsSync(files)) return (await fs7.promises.readFile(files)).toString("base64");
1262
+ if (fs5.existsSync(files)) return (await fs5.promises.readFile(files)).toString("base64");
2108
1263
  return Buffer.from(data, "base64").toString("base64");
2109
1264
  };
2110
1265
  buffer = async (data, options) => {
@@ -2123,7 +1278,7 @@ var init_data = __esm({
2123
1278
  return Buffer.from(response.data, "binary");
2124
1279
  }
2125
1280
  const files = data.replace(sep, "");
2126
- if (fs7.existsSync(files)) return fs7.readFileSync(files);
1281
+ if (fs5.existsSync(files)) return fs5.readFileSync(files);
2127
1282
  return Buffer.from(data);
2128
1283
  };
2129
1284
  stream = (stream3) => new Promise((resolve, reject) => {
@@ -2132,9 +1287,9 @@ var init_data = __esm({
2132
1287
  stream3.on("end", () => resolve(Buffer.concat(chunks)));
2133
1288
  stream3.on("error", (error) => reject(error));
2134
1289
  });
2135
- readFile = async (path37) => {
1290
+ readFile = async (path36) => {
2136
1291
  try {
2137
- const data = await fs7.promises.readFile(path37);
1292
+ const data = await fs5.promises.readFile(path36);
2138
1293
  return data;
2139
1294
  } catch (error) {
2140
1295
  logger.error(error);
@@ -2147,46 +1302,46 @@ var init_data = __esm({
2147
1302
  };
2148
1303
  }
2149
1304
  });
2150
- var readJsonSync, writeJsonSync, readJson, writeJson, json2;
1305
+ var readJsonSync, writeJsonSync, readJson, writeJson, json;
2151
1306
  var init_json = __esm({
2152
1307
  "src/utils/fs/json.ts"() {
2153
- readJsonSync = (path37, isThrow = false) => {
1308
+ readJsonSync = (path36, isThrow = false) => {
2154
1309
  try {
2155
- const data = fs7.readFileSync(path37, "utf8");
1310
+ const data = fs5.readFileSync(path36, "utf8");
2156
1311
  return JSON.parse(data);
2157
1312
  } catch (error) {
2158
1313
  if (isThrow) throw error;
2159
1314
  return null;
2160
1315
  }
2161
1316
  };
2162
- writeJsonSync = (path37, data, isThrow = false) => {
1317
+ writeJsonSync = (path36, data, isThrow = false) => {
2163
1318
  try {
2164
- fs7.writeFileSync(path37, JSON.stringify(data, null, 2));
1319
+ fs5.writeFileSync(path36, JSON.stringify(data, null, 2));
2165
1320
  return true;
2166
1321
  } catch (error) {
2167
1322
  if (isThrow) throw error;
2168
1323
  return false;
2169
1324
  }
2170
1325
  };
2171
- readJson = async (path37, isThrow = false) => {
1326
+ readJson = async (path36, isThrow = false) => {
2172
1327
  try {
2173
- const data = await fs7.promises.readFile(path37, "utf8");
1328
+ const data = await fs5.promises.readFile(path36, "utf8");
2174
1329
  return JSON.parse(data);
2175
1330
  } catch (error) {
2176
1331
  if (isThrow) throw error;
2177
1332
  return null;
2178
1333
  }
2179
1334
  };
2180
- writeJson = async (path37, data, isThrow = false) => {
1335
+ writeJson = async (path36, data, isThrow = false) => {
2181
1336
  try {
2182
- await fs7.promises.writeFile(path37, JSON.stringify(data, null, 2));
1337
+ await fs5.promises.writeFile(path36, JSON.stringify(data, null, 2));
2183
1338
  return true;
2184
1339
  } catch (error) {
2185
1340
  if (isThrow) throw error;
2186
1341
  return false;
2187
1342
  }
2188
1343
  };
2189
- json2 = {
1344
+ json = {
2190
1345
  /** 同步读取 */
2191
1346
  readSync: readJsonSync,
2192
1347
  /** 同步写入 */
@@ -2201,24 +1356,24 @@ var init_json = __esm({
2201
1356
  var filesByExt, splitPath, getRelPath, urlToPath, isSubPath, formatPath, isPathEqual;
2202
1357
  var init_path = __esm({
2203
1358
  "src/utils/fs/path.ts"() {
2204
- init_file2();
1359
+ init_file();
2205
1360
  filesByExt = (filePath, ext, returnType = "name") => {
2206
- if (!fs7.existsSync(filePath) || !fs7.statSync(filePath).isDirectory()) return [];
2207
- const files = fs7.readdirSync(filePath, { withFileTypes: true });
1361
+ if (!fs5.existsSync(filePath) || !fs5.statSync(filePath).isDirectory()) return [];
1362
+ const files = fs5.readdirSync(filePath, { withFileTypes: true });
2208
1363
  const list2 = [];
2209
1364
  if (!Array.isArray(ext)) ext = [ext];
2210
1365
  const allFiles = (dir2, entry) => {
2211
1366
  if (entry.isDirectory()) {
2212
- const subFiles = filesByExt(path5.join(dir2, entry.name), ext, returnType);
1367
+ const subFiles = filesByExt(path4.join(dir2, entry.name), ext, returnType);
2213
1368
  list2.push(...subFiles);
2214
- } else if (ext.includes(path5.extname(entry.name))) {
1369
+ } else if (ext.includes(path4.extname(entry.name))) {
2215
1370
  if (returnType === "name") {
2216
1371
  list2.push(entry.name);
2217
1372
  } else if (returnType === "rel") {
2218
- const file = path5.resolve(dir2, entry.name);
2219
- list2.push(path5.relative(process.cwd(), file));
1373
+ const file = path4.resolve(dir2, entry.name);
1374
+ list2.push(path4.relative(process.cwd(), file));
2220
1375
  } else if (returnType === "abs") {
2221
- list2.push(formatPath(path5.resolve(dir2, entry.name)));
1376
+ list2.push(formatPath(path4.resolve(dir2, entry.name)));
2222
1377
  }
2223
1378
  }
2224
1379
  };
@@ -2226,27 +1381,27 @@ var init_path = __esm({
2226
1381
  return list2;
2227
1382
  };
2228
1383
  splitPath = (filePath) => {
2229
- const dirname = path5.dirname(filePath).replace(sep, "");
2230
- const basename = path5.basename(filePath);
1384
+ const dirname = path4.dirname(filePath).replace(sep, "");
1385
+ const basename = path4.basename(filePath);
2231
1386
  return { dirname, basename };
2232
1387
  };
2233
1388
  getRelPath = (filePath) => filePath.replace(/\\+/g, "/").replace(/\.+\/+|\/+$/g, "");
2234
1389
  urlToPath = (url) => {
2235
1390
  const filePath = fileURLToPath$1(url);
2236
- const rel = path5.relative(path5.dirname(filePath), process.cwd());
2237
- const upLevelsCount = rel.split(path5.sep).length;
2238
- return lodash4.repeat("../", upLevelsCount);
1391
+ const rel = path4.relative(path4.dirname(filePath), process.cwd());
1392
+ const upLevelsCount = rel.split(path4.sep).length;
1393
+ return lodash3.repeat("../", upLevelsCount);
2239
1394
  };
2240
1395
  isSubPath = (root2, target, isAbs = true) => {
2241
1396
  if (isAbs) {
2242
- root2 = path5.resolve(root2);
2243
- target = path5.resolve(target);
1397
+ root2 = path4.resolve(root2);
1398
+ target = path4.resolve(target);
2244
1399
  }
2245
- const relative = path5.relative(root2, target);
2246
- return relative && !relative.startsWith("..") && !path5.isAbsolute(relative);
1400
+ const relative = path4.relative(root2, target);
1401
+ return relative && !relative.startsWith("..") && !path4.isAbsolute(relative);
2247
1402
  };
2248
1403
  formatPath = (filePath) => {
2249
- return path5.resolve(filePath).replace(/\\/g, "/");
1404
+ return path4.resolve(filePath).replace(/\\/g, "/");
2250
1405
  };
2251
1406
  isPathEqual = (path1, path210) => {
2252
1407
  if (path1 === path210) return true;
@@ -2303,15 +1458,15 @@ var init_pkg2 = __esm({
2303
1458
  dir2 = __require.resolve(name);
2304
1459
  }
2305
1460
  try {
2306
- if (existsSync$1(path5.join(dir2, "package.json"))) {
2307
- return path5.resolve(dir2);
1461
+ if (existsSync$1(path4.join(dir2, "package.json"))) {
1462
+ return path4.resolve(dir2);
2308
1463
  }
2309
1464
  while (true) {
2310
- dir2 = path5.dirname(dir2);
2311
- if (existsSync$1(path5.join(dir2, "package.json"))) {
2312
- return path5.resolve(dir2);
1465
+ dir2 = path4.dirname(dir2);
1466
+ if (existsSync$1(path4.join(dir2, "package.json"))) {
1467
+ return path4.resolve(dir2);
2313
1468
  }
2314
- if (dir2 === path5.dirname(dir2)) {
1469
+ if (dir2 === path4.dirname(dir2)) {
2315
1470
  throw new Error(`[common] \u672A\u627E\u5230\u5305${name}\u7684\u6839\u76EE\u5F55`);
2316
1471
  }
2317
1472
  }
@@ -2367,7 +1522,7 @@ var init_yaml = __esm({
2367
1522
  document;
2368
1523
  constructor(file) {
2369
1524
  this.filePath = file;
2370
- const data = YAML.parseDocument(fs7.existsSync(file) ? fs7.readFileSync(file, "utf8") : file);
1525
+ const data = YAML.parseDocument(fs5.existsSync(file) ? fs5.readFileSync(file, "utf8") : file);
2371
1526
  this.doc = data;
2372
1527
  this.document = data;
2373
1528
  }
@@ -2375,10 +1530,10 @@ var init_yaml = __esm({
2375
1530
  * 获取指定路径的值
2376
1531
  * @param path - 路径,多个路径使用`.`连接,例如:`a.b.c`
2377
1532
  */
2378
- get(path37) {
1533
+ get(path36) {
2379
1534
  try {
2380
- if (!path37) return this.document.toJSON();
2381
- return lodash4.get(this.document.toJSON(), path37);
1535
+ if (!path36) return this.document.toJSON();
1536
+ return lodash3.get(this.document.toJSON(), path36);
2382
1537
  } catch (error) {
2383
1538
  logger.error(`[YamlEditor] \u83B7\u53D6\u6570\u636E\u65F6\u51FA\u9519\uFF1A${error}`);
2384
1539
  return null;
@@ -2390,9 +1545,9 @@ var init_yaml = __esm({
2390
1545
  * @param value - 要设置的值 允许的类型:`string`, `boolean`, `number`, `object`, `array`
2391
1546
  * @param isSplit - 是否使用分割路径路径,默认为 `true`
2392
1547
  */
2393
- set(path37, value, isSplit = true) {
1548
+ set(path36, value, isSplit = true) {
2394
1549
  try {
2395
- const _path = typeof path37 === "string" ? isSplit ? path37.split(".") : [path37] : path37;
1550
+ const _path = typeof path36 === "string" ? isSplit ? path36.split(".") : [path36] : path36;
2396
1551
  this.document.setIn(_path, value);
2397
1552
  return true;
2398
1553
  } catch (error) {
@@ -2406,11 +1561,11 @@ var init_yaml = __esm({
2406
1561
  * @param value - 要添加的值
2407
1562
  * @param isSplit - 是否使用分割路径路径,默认为 `true`
2408
1563
  */
2409
- add(path37, value, isSplit = true) {
1564
+ add(path36, value, isSplit = true) {
2410
1565
  try {
2411
- const _path = typeof path37 === "string" ? isSplit ? path37.split(".") : [path37] : path37;
1566
+ const _path = typeof path36 === "string" ? isSplit ? path36.split(".") : [path36] : path36;
2412
1567
  this.document.addIn(_path, value);
2413
- logger.debug(`[YamlEditor] \u5DF2\u5728 ${path37} \u6DFB\u52A0\u65B0\u7684\u503C`);
1568
+ logger.debug(`[YamlEditor] \u5DF2\u5728 ${path36} \u6DFB\u52A0\u65B0\u7684\u503C`);
2414
1569
  return true;
2415
1570
  } catch (error) {
2416
1571
  logger.error(`[YamlEditor] \u6DFB\u52A0\u6570\u636E\u65F6\u51FA\u9519\uFF1A${error}`);
@@ -2423,9 +1578,9 @@ var init_yaml = __esm({
2423
1578
  * @param isSplit - 是否使用分割路径路径,默认为 `true`
2424
1579
  * @returns 是否删除成功
2425
1580
  */
2426
- del(path37, isSplit = true) {
1581
+ del(path36, isSplit = true) {
2427
1582
  try {
2428
- const _path = typeof path37 === "string" ? isSplit ? path37.split(".") : [path37] : path37;
1583
+ const _path = typeof path36 === "string" ? isSplit ? path36.split(".") : [path36] : path36;
2429
1584
  this.document.deleteIn(_path);
2430
1585
  return true;
2431
1586
  } catch (error) {
@@ -2440,9 +1595,9 @@ var init_yaml = __esm({
2440
1595
  * @param prepend - 如果为 true,则添加到数组的开头,否则添加到末尾
2441
1596
  * @param isSplit - 是否使用分割路径路径,默认为 `true`
2442
1597
  */
2443
- append(path37, value, prepend = false, isSplit = true) {
1598
+ append(path36, value, prepend = false, isSplit = true) {
2444
1599
  try {
2445
- const _path = typeof path37 === "string" ? isSplit ? path37.split(".") : [path37] : path37;
1600
+ const _path = typeof path36 === "string" ? isSplit ? path36.split(".") : [path36] : path36;
2446
1601
  let current = this.document.getIn(_path);
2447
1602
  if (!current) {
2448
1603
  current = new YAML.YAMLSeq();
@@ -2453,7 +1608,7 @@ var init_yaml = __esm({
2453
1608
  } else {
2454
1609
  prepend ? current.items.unshift(value) : current.add(value);
2455
1610
  }
2456
- logger.debug(`[YamlEditor] \u5DF2\u5411 ${path37} \u6570\u7EC4${prepend ? "\u5F00\u5934" : "\u672B\u5C3E"}\u6DFB\u52A0\u65B0\u5143\u7D20\uFF1A${value}`);
1611
+ logger.debug(`[YamlEditor] \u5DF2\u5411 ${path36} \u6570\u7EC4${prepend ? "\u5F00\u5934" : "\u672B\u5C3E"}\u6DFB\u52A0\u65B0\u5143\u7D20\uFF1A${value}`);
2457
1612
  return true;
2458
1613
  } catch (error) {
2459
1614
  logger.error(`[YamlEditor] \u5411\u6570\u7EC4\u6DFB\u52A0\u5143\u7D20\u65F6\u51FA\u9519\uFF1A${error}`);
@@ -2466,9 +1621,9 @@ var init_yaml = __esm({
2466
1621
  * @param value - 要删除的值
2467
1622
  * @param isSplit - 是否使用分割路径路径,默认为 `true`
2468
1623
  */
2469
- remove(path37, value, isSplit = true) {
1624
+ remove(path36, value, isSplit = true) {
2470
1625
  try {
2471
- const _path = typeof path37 === "string" ? isSplit ? path37.split(".") : [path37] : path37;
1626
+ const _path = typeof path36 === "string" ? isSplit ? path36.split(".") : [path36] : path36;
2472
1627
  const current = this.document.getIn(_path);
2473
1628
  if (!current) {
2474
1629
  logger.error("[YamlEditor] \u6307\u5B9A\u7684\u8DEF\u5F84\u4E0D\u5B58\u5728");
@@ -2478,13 +1633,13 @@ var init_yaml = __esm({
2478
1633
  logger.error("[YamlEditor] \u6307\u5B9A\u7684\u8DEF\u5F84\u4E0D\u662F\u6570\u7EC4");
2479
1634
  return false;
2480
1635
  }
2481
- const index6 = current.items.findIndex((item) => lodash4.isEqual(item.toJSON(), value));
1636
+ const index6 = current.items.findIndex((item) => lodash3.isEqual(item.toJSON(), value));
2482
1637
  if (index6 < 0) {
2483
1638
  logger.error("[YamlEditor] \u672A\u627E\u5230\u8981\u5220\u9664\u7684\u503C");
2484
1639
  return false;
2485
1640
  }
2486
1641
  current.items.splice(index6, 1);
2487
- logger.debug(`[YamlEditor] \u5DF2\u4ECE ${path37} \u6570\u7EC4\u5220\u9664\u5143\u7D20\uFF1A${value}`);
1642
+ logger.debug(`[YamlEditor] \u5DF2\u4ECE ${path36} \u6570\u7EC4\u5220\u9664\u5143\u7D20\uFF1A${value}`);
2488
1643
  return true;
2489
1644
  } catch (error) {
2490
1645
  logger.error(`[YamlEditor] \u4ECE\u6570\u7EC4\u5220\u9664\u5143\u7D20\u65F6\u51FA\u9519\uFF1A${error}`);
@@ -2496,9 +1651,9 @@ var init_yaml = __esm({
2496
1651
  * @param path - 路径,用点号分隔
2497
1652
  * @param isSplit - 是否使用分割路径路径,默认为 `true`
2498
1653
  */
2499
- has(path37, isSplit = true) {
1654
+ has(path36, isSplit = true) {
2500
1655
  try {
2501
- const _path = typeof path37 === "string" ? isSplit ? path37.split(".") : [path37] : path37;
1656
+ const _path = typeof path36 === "string" ? isSplit ? path36.split(".") : [path36] : path36;
2502
1657
  return this.document.hasIn(_path);
2503
1658
  } catch (error) {
2504
1659
  logger.error(`[YamlEditor] \u68C0\u67E5\u8DEF\u5F84\u662F\u5426\u5B58\u5728\u65F6\u51FA\u9519\uFF1A${error}`);
@@ -2511,20 +1666,20 @@ var init_yaml = __esm({
2511
1666
  * @param value - 要查询的值
2512
1667
  * @param isSplit - 是否使用分割路径路径,默认为 `true`
2513
1668
  */
2514
- hasval(path37, value, isSplit = true) {
1669
+ hasval(path36, value, isSplit = true) {
2515
1670
  try {
2516
- const _path = typeof path37 === "string" ? isSplit ? path37.split(".") : [path37] : path37;
1671
+ const _path = typeof path36 === "string" ? isSplit ? path36.split(".") : [path36] : path36;
2517
1672
  const current = this.document.getIn(_path);
2518
1673
  if (!current) return false;
2519
1674
  if (current instanceof YAML.YAMLSeq) {
2520
- return current.items.some((item) => lodash4.isEqual(item.toJSON(), value));
1675
+ return current.items.some((item) => lodash3.isEqual(item.toJSON(), value));
2521
1676
  } else if (current instanceof YAML.YAMLMap) {
2522
- return Array.from(current.values()).some((v) => lodash4.isEqual(v.toJSON(), value));
1677
+ return Array.from(current.values()).some((v) => lodash3.isEqual(v.toJSON(), value));
2523
1678
  } else {
2524
- return lodash4.isEqual(current, value);
1679
+ return lodash3.isEqual(current, value);
2525
1680
  }
2526
1681
  } catch (error) {
2527
- logger.error(`[YamlEditor] \u68C0\u67E5\u8DEF\u5F84 ${path37} \u662F\u5426\u5305\u542B\u503C\u65F6\u51FA\u9519\uFF1A${error}`);
1682
+ logger.error(`[YamlEditor] \u68C0\u67E5\u8DEF\u5F84 ${path36} \u662F\u5426\u5305\u542B\u503C\u65F6\u51FA\u9519\uFF1A${error}`);
2528
1683
  return false;
2529
1684
  }
2530
1685
  }
@@ -2534,8 +1689,8 @@ var init_yaml = __esm({
2534
1689
  * @param value - 要查询的值
2535
1690
  * @deprecated 请使用 `hasval` 代替
2536
1691
  */
2537
- hasVal(path37, value) {
2538
- return this.hasval(path37, value);
1692
+ hasVal(path36, value) {
1693
+ return this.hasval(path36, value);
2539
1694
  }
2540
1695
  /**
2541
1696
  * 向根节点新增元素,如果根节点不是数组,则将其转换为数组再新增元素
@@ -2580,9 +1735,9 @@ var init_yaml = __esm({
2580
1735
  * @param path - 路径,多个路径使用`.`连接,例如:`a.b.c`
2581
1736
  * @param isSplit - 是否使用分割路径路径,默认为 `true`
2582
1737
  */
2583
- getpair(path37, isSplit = true) {
2584
- if (!path37) throw new Error("path is required");
2585
- const keys = typeof path37 === "string" ? isSplit ? path37.split(".") : [path37] : path37;
1738
+ getpair(path36, isSplit = true) {
1739
+ if (!path36) throw new Error("path is required");
1740
+ const keys = typeof path36 === "string" ? isSplit ? path36.split(".") : [path36] : path36;
2586
1741
  let pair = this.document.contents;
2587
1742
  keys.forEach((key) => {
2588
1743
  if (isMap(pair)) {
@@ -2602,10 +1757,10 @@ var init_yaml = __esm({
2602
1757
  * @param prepend - 如果为 true,则添加注释到开头,否则添加到同一行的末尾
2603
1758
  * @param isSplit - 是否使用分割路径路径,默认为 `true`
2604
1759
  */
2605
- comment(path37, comment2, prepend = true, isSplit = true) {
2606
- if (!path37) throw new Error("[YamlEditor] path \u4E0D\u80FD\u4E3A\u7A7A");
2607
- const pair = this.getpair(path37, isSplit);
2608
- if (!pair) throw new Error(`[YamlEditor] \u672A\u627E\u5230\u8282\u70B9 ${path37}`);
1760
+ comment(path36, comment2, prepend = true, isSplit = true) {
1761
+ if (!path36) throw new Error("[YamlEditor] path \u4E0D\u80FD\u4E3A\u7A7A");
1762
+ const pair = this.getpair(path36, isSplit);
1763
+ if (!pair) throw new Error(`[YamlEditor] \u672A\u627E\u5230\u8282\u70B9 ${path36}`);
2609
1764
  comment2 = ` ${comment2}`;
2610
1765
  if (prepend) {
2611
1766
  pair.key.commentBefore = comment2;
@@ -2619,10 +1774,10 @@ var init_yaml = __esm({
2619
1774
  * @param type - 要删除的注释类型,`before` 为注释前,`after` 为注释后,`all` 为全部
2620
1775
  * @param isSplit - 是否使用分割路径路径,默认为 `true`
2621
1776
  */
2622
- uncomment(path37, type = "all", isSplit = true) {
2623
- if (!path37) throw new Error("[YamlEditor] path \u4E0D\u80FD\u4E3A\u7A7A");
2624
- const pair = this.getpair(path37, isSplit);
2625
- if (!pair) throw new Error(`[YamlEditor] \u672A\u627E\u5230\u8282\u70B9 ${path37}`);
1777
+ uncomment(path36, type = "all", isSplit = true) {
1778
+ if (!path36) throw new Error("[YamlEditor] path \u4E0D\u80FD\u4E3A\u7A7A");
1779
+ const pair = this.getpair(path36, isSplit);
1780
+ if (!pair) throw new Error(`[YamlEditor] \u672A\u627E\u5230\u8282\u70B9 ${path36}`);
2626
1781
  if (type === "all") {
2627
1782
  delete pair.key.comment;
2628
1783
  delete pair.key.commentBefore;
@@ -2638,10 +1793,10 @@ var init_yaml = __esm({
2638
1793
  * @param type - 要检查的注释类型,`before` 为注释前,`after` 为注释后
2639
1794
  * @param isSplit - 是否使用分割路径路径,默认为 `true`
2640
1795
  */
2641
- hascomment(path37, type, isSplit = true) {
2642
- if (!path37) throw new Error("[YamlEditor] path \u4E0D\u80FD\u4E3A\u7A7A");
2643
- const pair = this.getpair(path37, isSplit);
2644
- if (!pair) throw new Error(`[YamlEditor] \u672A\u627E\u5230\u8282\u70B9 ${path37}`);
1796
+ hascomment(path36, type, isSplit = true) {
1797
+ if (!path36) throw new Error("[YamlEditor] path \u4E0D\u80FD\u4E3A\u7A7A");
1798
+ const pair = this.getpair(path36, isSplit);
1799
+ if (!pair) throw new Error(`[YamlEditor] \u672A\u627E\u5230\u8282\u70B9 ${path36}`);
2645
1800
  if (type === "before") {
2646
1801
  return !!pair.key.commentBefore;
2647
1802
  } else if (type === "after") {
@@ -2654,10 +1809,10 @@ var init_yaml = __esm({
2654
1809
  * @param path - 路径,多个路径使用`.`连接,例如:`a.b.c`
2655
1810
  * @param isSplit - 是否使用分割路径路径,默认为 `true`
2656
1811
  */
2657
- getcomment(path37, isSplit = true) {
2658
- if (!path37) throw new Error("[YamlEditor] path \u4E0D\u80FD\u4E3A\u7A7A");
2659
- const pair = this.getpair(path37, isSplit);
2660
- if (!pair) throw new Error(`[YamlEditor] \u672A\u627E\u5230\u8282\u70B9 ${path37}`);
1812
+ getcomment(path36, isSplit = true) {
1813
+ if (!path36) throw new Error("[YamlEditor] path \u4E0D\u80FD\u4E3A\u7A7A");
1814
+ const pair = this.getpair(path36, isSplit);
1815
+ if (!pair) throw new Error(`[YamlEditor] \u672A\u627E\u5230\u8282\u70B9 ${path36}`);
2661
1816
  return pair.key.commentBefore || pair.key.comment;
2662
1817
  }
2663
1818
  /**
@@ -2665,15 +1820,15 @@ var init_yaml = __esm({
2665
1820
  * 保存失败会抛出异常
2666
1821
  */
2667
1822
  save() {
2668
- fs7.writeFileSync(this.filePath, this.document.toString());
1823
+ fs5.writeFileSync(this.filePath, this.document.toString());
2669
1824
  logger.debug("[YamlEditor] \u6587\u4EF6\u5DF2\u4FDD\u5B58");
2670
1825
  }
2671
1826
  };
2672
- read = (path37) => {
2673
- const data = YAML.parse(fs7.readFileSync(path37, "utf-8"));
1827
+ read = (path36) => {
1828
+ const data = YAML.parse(fs5.readFileSync(path36, "utf-8"));
2674
1829
  read.save = (options) => {
2675
1830
  try {
2676
- save(path37, data, typeof options === "string" ? JSON.parse(options) : options);
1831
+ save(path36, data, typeof options === "string" ? JSON.parse(options) : options);
2677
1832
  return true;
2678
1833
  } catch (error) {
2679
1834
  logger.error("[YamlEditor] \u4FDD\u5B58\u6587\u4EF6\u65F6\u51FA\u9519");
@@ -2683,27 +1838,27 @@ var init_yaml = __esm({
2683
1838
  };
2684
1839
  return data;
2685
1840
  };
2686
- write = (path37, value) => {
1841
+ write = (path36, value) => {
2687
1842
  try {
2688
- fs7.writeFileSync(path37, YAML.stringify(value));
1843
+ fs5.writeFileSync(path36, YAML.stringify(value));
2689
1844
  return true;
2690
1845
  } catch {
2691
1846
  return false;
2692
1847
  }
2693
1848
  };
2694
- save = (path37, value, options) => {
1849
+ save = (path36, value, options) => {
2695
1850
  if (!options) {
2696
- fs7.writeFileSync(path37, YAML.stringify(value));
1851
+ fs5.writeFileSync(path36, YAML.stringify(value));
2697
1852
  return;
2698
1853
  }
2699
1854
  const editor = new YamlEditor(YAML.stringify(value));
2700
- const comment2 = typeof options === "string" ? JSON.parse(fs7.readFileSync(options, "utf8")) : options;
1855
+ const comment2 = typeof options === "string" ? JSON.parse(fs5.readFileSync(options, "utf8")) : options;
2701
1856
  applyComments(editor, comment2);
2702
- fs7.writeFileSync(path37, editor.document.toString());
1857
+ fs5.writeFileSync(path36, editor.document.toString());
2703
1858
  };
2704
1859
  comment = (filePath, commentConfig) => {
2705
1860
  const editor = new YamlEditor(filePath);
2706
- const comment2 = typeof commentConfig === "string" ? JSON.parse(fs7.readFileSync(commentConfig, "utf8")) : commentConfig;
1861
+ const comment2 = typeof commentConfig === "string" ? JSON.parse(fs5.readFileSync(commentConfig, "utf8")) : commentConfig;
2707
1862
  applyComments(editor, comment2);
2708
1863
  editor.save();
2709
1864
  };
@@ -2923,7 +2078,7 @@ __export(fs_exports, {
2923
2078
  isPlugin: () => isPlugin,
2924
2079
  isPublic: () => isPublic,
2925
2080
  isSubPath: () => isSubPath,
2926
- json: () => json2,
2081
+ json: () => json,
2927
2082
  key: () => key_exports,
2928
2083
  lock: () => lock,
2929
2084
  lockMethod: () => lockMethod,
@@ -2960,7 +2115,7 @@ var init_fs = __esm({
2960
2115
  init_fsPromises();
2961
2116
  init_fsSync();
2962
2117
  init_data();
2963
- init_file2();
2118
+ init_file();
2964
2119
  init_json();
2965
2120
  init_path();
2966
2121
  init_pkg2();
@@ -3028,7 +2183,7 @@ __export(fs_exports2, {
3028
2183
  isPlugin: () => isPlugin,
3029
2184
  isPublic: () => isPublic,
3030
2185
  isSubPath: () => isSubPath,
3031
- json: () => json2,
2186
+ json: () => json,
3032
2187
  key: () => key_exports,
3033
2188
  lock: () => lock,
3034
2189
  lockMethod: () => lockMethod,
@@ -3073,15 +2228,15 @@ var diffArray, diffSimpleArray, clamp, random, formatNumber, percentage, formatU
3073
2228
  var init_number = __esm({
3074
2229
  "src/utils/common/number.ts"() {
3075
2230
  diffArray = (old, data) => {
3076
- const removed = lodash4.differenceWith(old, data, lodash4.isEqual);
3077
- const added = lodash4.differenceWith(data, old, lodash4.isEqual);
3078
- const common = lodash4.intersectionWith(old, data, lodash4.isEqual);
2231
+ const removed = lodash3.differenceWith(old, data, lodash3.isEqual);
2232
+ const added = lodash3.differenceWith(data, old, lodash3.isEqual);
2233
+ const common = lodash3.intersectionWith(old, data, lodash3.isEqual);
3079
2234
  return { removed, added, common };
3080
2235
  };
3081
2236
  diffSimpleArray = (old, data) => {
3082
- const removed = lodash4.difference(old, data);
3083
- const added = lodash4.difference(data, old);
3084
- const common = lodash4.intersection(old, data);
2237
+ const removed = lodash3.difference(old, data);
2238
+ const added = lodash3.difference(data, old);
2239
+ const common = lodash3.intersection(old, data);
3085
2240
  return { removed, added, common };
3086
2241
  };
3087
2242
  clamp = (value, min, max) => {
@@ -3256,7 +2411,264 @@ var init_listeners = __esm({
3256
2411
  return super.removeListener(event, listener);
3257
2412
  }
3258
2413
  };
3259
- listeners = new TypedListeners();
2414
+ listeners = new TypedListeners();
2415
+ }
2416
+ });
2417
+
2418
+ // src/utils/message/segment.ts
2419
+ var segment_exports = {};
2420
+ __export(segment_exports, {
2421
+ at: () => at,
2422
+ basketball: () => basketball,
2423
+ bubbleFace: () => bubbleFace,
2424
+ button: () => button,
2425
+ contact: () => contact,
2426
+ customMusic: () => customMusic,
2427
+ dice: () => dice,
2428
+ face: () => face,
2429
+ gift: () => gift,
2430
+ image: () => image,
2431
+ json: () => json2,
2432
+ keyboard: () => keyboard,
2433
+ location: () => location,
2434
+ longMsg: () => longMsg,
2435
+ markdown: () => markdown,
2436
+ markdownTpl: () => markdownTpl,
2437
+ marketFace: () => marketFace,
2438
+ music: () => music,
2439
+ node: () => node,
2440
+ nodeDirect: () => nodeDirect,
2441
+ pasmsg: () => pasmsg,
2442
+ raw: () => raw,
2443
+ record: () => record,
2444
+ reply: () => reply,
2445
+ rps: () => rps,
2446
+ share: () => share,
2447
+ text: () => text,
2448
+ video: () => video,
2449
+ weather: () => weather,
2450
+ xml: () => xml
2451
+ });
2452
+ var text, at, face, reply, image, video, record, json2, xml, markdown, markdownTpl, pasmsg, keyboard, button, longMsg, raw, basketball, dice, rps, bubbleFace, weather, location, share, gift, marketFace, contact, music, customMusic, node, nodeDirect;
2453
+ var init_segment = __esm({
2454
+ "src/utils/message/segment.ts"() {
2455
+ text = (text2) => {
2456
+ return { type: "text", text: text2 };
2457
+ };
2458
+ at = (targetId, name) => {
2459
+ return { type: "at", targetId, name };
2460
+ };
2461
+ face = (id, isBig) => {
2462
+ return { type: "face", id: Number(id), isBig };
2463
+ };
2464
+ reply = (messageId) => {
2465
+ return { type: "reply", messageId: String(messageId) };
2466
+ };
2467
+ image = (file, options = {}) => {
2468
+ return {
2469
+ type: "image",
2470
+ file,
2471
+ fileType: options.fileType,
2472
+ height: options?.height,
2473
+ width: options?.width,
2474
+ md5: options?.md5,
2475
+ name: options?.name,
2476
+ subType: options?.subType
2477
+ };
2478
+ };
2479
+ video = (file, options) => {
2480
+ return {
2481
+ type: "video",
2482
+ file,
2483
+ height: options?.height,
2484
+ width: options?.width,
2485
+ md5: options?.md5,
2486
+ name: options?.name
2487
+ };
2488
+ };
2489
+ record = (file, magic = false, options) => {
2490
+ return {
2491
+ type: "record",
2492
+ file,
2493
+ magic,
2494
+ md5: options?.md5,
2495
+ name: options?.name
2496
+ };
2497
+ };
2498
+ json2 = (data) => {
2499
+ return { type: "json", data };
2500
+ };
2501
+ xml = (data) => {
2502
+ return { type: "xml", data };
2503
+ };
2504
+ markdown = (markdown2, config3) => {
2505
+ return { type: "markdown", markdown: markdown2, config: config3 };
2506
+ };
2507
+ markdownTpl = (templateId, params) => {
2508
+ return { type: "markdownTpl", templateId, params };
2509
+ };
2510
+ pasmsg = (id, source = "msg") => {
2511
+ return { type: "pasmsg", id, source };
2512
+ };
2513
+ keyboard = (data) => {
2514
+ const rows = [];
2515
+ if (!Array.isArray(data)) data = [data];
2516
+ for (const i of data) {
2517
+ if (Array.isArray(i)) {
2518
+ const button3 = [];
2519
+ for (const v of i) button3.push(v);
2520
+ rows.push(button3);
2521
+ } else {
2522
+ rows.push([i]);
2523
+ }
2524
+ }
2525
+ return { type: "keyboard", rows };
2526
+ };
2527
+ button = (data) => {
2528
+ return { type: "button", data: Array.isArray(data) ? data : [data] };
2529
+ };
2530
+ longMsg = (id) => {
2531
+ return { type: "longMsg", id };
2532
+ };
2533
+ raw = (data) => {
2534
+ return { type: "raw", data };
2535
+ };
2536
+ basketball = (id) => {
2537
+ return { type: "basketball", id: Number(id) };
2538
+ };
2539
+ dice = (id) => {
2540
+ return { type: "dice", id: Number(id) };
2541
+ };
2542
+ rps = (id) => {
2543
+ return { type: "rps", id: Number(id) };
2544
+ };
2545
+ bubbleFace = (id, count3) => {
2546
+ return { type: "bubbleFace", id: Number(id), count: Number(count3) };
2547
+ };
2548
+ weather = (city, code) => {
2549
+ return { type: "weather", city, code };
2550
+ };
2551
+ location = (lat, lon, title, address) => {
2552
+ return { type: "location", lat, lon, title, address };
2553
+ };
2554
+ share = (url, title, content, image2) => {
2555
+ return { type: "share", url, title, content, image: image2 };
2556
+ };
2557
+ gift = (qq, id) => {
2558
+ return { type: "gift", qq, id };
2559
+ };
2560
+ marketFace = (id) => {
2561
+ return { type: "marketFace", id };
2562
+ };
2563
+ contact = (scene, peer) => {
2564
+ return { type: "contact", scene, peer };
2565
+ };
2566
+ music = (platform, id) => {
2567
+ return { type: "music", platform, id };
2568
+ };
2569
+ customMusic = (url, audio, title, author, pic) => {
2570
+ return { type: "music", platform: "custom", url, audio, title, author, pic };
2571
+ };
2572
+ node = (userId, nickname, message2, options) => {
2573
+ return { type: "node", subType: "fake", userId, nickname, message: message2, options };
2574
+ };
2575
+ nodeDirect = (id) => {
2576
+ return { type: "node", subType: "messageID", messageId: id, message_id: id };
2577
+ };
2578
+ }
2579
+ });
2580
+ var createRawMessage, makeMessage, makeForward;
2581
+ var init_message = __esm({
2582
+ "src/utils/message/message.ts"() {
2583
+ init_segment();
2584
+ createRawMessage = (data) => {
2585
+ if (!Array.isArray(data)) data = [data];
2586
+ const msg = [];
2587
+ const rawStr = data.map((v) => {
2588
+ switch (v.type) {
2589
+ case "text": {
2590
+ msg.push(v.text);
2591
+ return v.text;
2592
+ }
2593
+ case "image":
2594
+ case "video":
2595
+ case "record": {
2596
+ if (Buffer.isBuffer(v.file)) return `[${v.type}:Buffer://...]`;
2597
+ if (/^http|^file/.test(v.file)) return `[${v.type}:${v.file}]`;
2598
+ return `[${v.type}:base64://...]`;
2599
+ }
2600
+ case "file": {
2601
+ if (Buffer.isBuffer(v.file)) return `[file:Buffer://..., fid:${v.fid}, md5:${v.md5}]`;
2602
+ if (/^http|^file/.test(v.file)) return `[file:${v.file}, fid:${v.fid}, md5:${v.md5}]`;
2603
+ return `[file:base64://..., fid:${v.fid}, md5:${v.md5}]`;
2604
+ }
2605
+ case "json":
2606
+ case "xml": {
2607
+ msg.push(v.data);
2608
+ return `[${v.type}:${v.data}]`;
2609
+ }
2610
+ case "at":
2611
+ return `[at:${v.targetId}]`;
2612
+ case "face":
2613
+ return `[face:${v.id}]`;
2614
+ case "reply":
2615
+ return `[reply:${v.messageId}]`;
2616
+ case "rps":
2617
+ return `[rps:${v.id}]`;
2618
+ case "dice":
2619
+ return `[dice:${v.id}]`;
2620
+ case "share":
2621
+ return `[share:${JSON.stringify(v)}]`;
2622
+ case "contact":
2623
+ return `[contact:${JSON.stringify(v)}]`;
2624
+ case "location":
2625
+ return `[location:${JSON.stringify(v)}]`;
2626
+ case "music":
2627
+ return `[music:${JSON.stringify(v)}]`;
2628
+ case "markdown":
2629
+ return `[markdown:${v.markdown}]`;
2630
+ case "button":
2631
+ return `[button:${JSON.stringify(v.data)}]`;
2632
+ case "keyboard":
2633
+ return `[rows:${JSON.stringify(v.rows)}]`;
2634
+ case "longMsg":
2635
+ return `[longmsg:${v.id}]`;
2636
+ case "pasmsg":
2637
+ return `[pasmsg:${v.id}]`;
2638
+ case "markdownTpl":
2639
+ return `[markdowntpl:${JSON.stringify({ templateId: v.templateId, ...v.params })}]`;
2640
+ default:
2641
+ return `[\u672A\u77E5:${lodash3.truncate(JSON.stringify(v), { length: 200 })}]`;
2642
+ }
2643
+ }).join("");
2644
+ return {
2645
+ /** 原始消息字符串: `[at:10001]这是一条测试的文本消息` */
2646
+ raw: rawStr,
2647
+ /**
2648
+ * - 经过处理的纯文本
2649
+ * - 可用于正则匹配
2650
+ * - tips: 此时还没有处理bot前缀
2651
+ */
2652
+ msg: msg.join("").trim()
2653
+ };
2654
+ };
2655
+ makeMessage = (elements) => {
2656
+ if (typeof elements === "string") return [text(elements)];
2657
+ if (!Array.isArray(elements)) return [elements];
2658
+ return elements.map((v) => typeof v === "string" ? text(v) : v);
2659
+ };
2660
+ makeForward = (elements, fakeId, fakeName) => {
2661
+ if (!Array.isArray(elements)) elements = [elements];
2662
+ return elements.map((v) => node(fakeId || "", fakeName || "", makeMessage(v)));
2663
+ };
2664
+ }
2665
+ });
2666
+
2667
+ // src/utils/message/index.ts
2668
+ var init_message2 = __esm({
2669
+ "src/utils/message/index.ts"() {
2670
+ init_message();
2671
+ init_segment();
3260
2672
  }
3261
2673
  });
3262
2674
 
@@ -3310,7 +2722,7 @@ var init_sendMsg = __esm({
3310
2722
  priority: options.priority ?? 1e4,
3311
2723
  callback
3312
2724
  });
3313
- return { id, list: lodash4.orderBy(list2, ["priority"], ["asc"]) };
2725
+ return { id, list: lodash3.orderBy(list2, ["priority"], ["asc"]) };
3314
2726
  };
3315
2727
  sendMsg = {
3316
2728
  /**
@@ -4088,122 +3500,331 @@ var init_base = __esm({
4088
3500
  }
4089
3501
  });
4090
3502
 
4091
- // src/adapter/onebot/types/api.ts
4092
- var OB11ApiAction;
4093
- var init_api = __esm({
4094
- "src/adapter/onebot/types/api.ts"() {
4095
- OB11ApiAction = /* @__PURE__ */ ((OB11ApiAction2) => {
4096
- OB11ApiAction2["sendPrivateMsg"] = "send_private_msg";
4097
- OB11ApiAction2["sendGroupMsg"] = "send_group_msg";
4098
- OB11ApiAction2["sendMsg"] = "send_msg";
4099
- OB11ApiAction2["deleteMsg"] = "delete_msg";
4100
- OB11ApiAction2["getMsg"] = "get_msg";
4101
- OB11ApiAction2["getForwardMsg"] = "get_forward_msg";
4102
- OB11ApiAction2["sendLike"] = "send_like";
4103
- OB11ApiAction2["setGroupKick"] = "set_group_kick";
4104
- OB11ApiAction2["setGroupBan"] = "set_group_ban";
4105
- OB11ApiAction2["setGroupAnonymousBan"] = "set_group_anonymous_ban";
4106
- OB11ApiAction2["setGroupWholeBan"] = "set_group_whole_ban";
4107
- OB11ApiAction2["setGroupAdmin"] = "set_group_admin";
4108
- OB11ApiAction2["setGroupAnonymous"] = "set_group_anonymous";
4109
- OB11ApiAction2["setGroupCard"] = "set_group_card";
4110
- OB11ApiAction2["setGroupName"] = "set_group_name";
4111
- OB11ApiAction2["setGroupLeave"] = "set_group_leave";
4112
- OB11ApiAction2["setGroupSpecialTitle"] = "set_group_special_title";
4113
- OB11ApiAction2["setFriendAddRequest"] = "set_friend_add_request";
4114
- OB11ApiAction2["setGroupAddRequest"] = "set_group_add_request";
4115
- OB11ApiAction2["getLoginInfo"] = "get_login_info";
4116
- OB11ApiAction2["getStrangerInfo"] = "get_stranger_info";
4117
- OB11ApiAction2["getFriendList"] = "get_friend_list";
4118
- OB11ApiAction2["getGroupInfo"] = "get_group_info";
4119
- OB11ApiAction2["getGroupList"] = "get_group_list";
4120
- OB11ApiAction2["getGroupMemberInfo"] = "get_group_member_info";
4121
- OB11ApiAction2["getGroupMemberList"] = "get_group_member_list";
4122
- OB11ApiAction2["getGroupHonorInfo"] = "get_group_honor_info";
4123
- OB11ApiAction2["getCookies"] = "get_cookies";
4124
- OB11ApiAction2["getCsrfToken"] = "get_csrf_token";
4125
- OB11ApiAction2["getCredentials"] = "get_credentials";
4126
- OB11ApiAction2["getRecord"] = "get_record";
4127
- OB11ApiAction2["getImage"] = "get_image";
4128
- OB11ApiAction2["canSendImage"] = "can_send_image";
4129
- OB11ApiAction2["canSendRecord"] = "can_send_record";
4130
- OB11ApiAction2["getStatus"] = "get_status";
4131
- OB11ApiAction2["getVersionInfo"] = "get_version_info";
4132
- OB11ApiAction2["getVersion"] = "get_version";
4133
- OB11ApiAction2["setRestart"] = "set_restart";
4134
- OB11ApiAction2["cleanCache"] = "clean_cache";
4135
- OB11ApiAction2["sendForwardMsg"] = "send_forward_msg";
4136
- OB11ApiAction2["sendGroupForwardMsg"] = "send_group_forward_msg";
4137
- OB11ApiAction2["sendPrivateForwardMsg"] = "send_private_forward_msg";
4138
- OB11ApiAction2["getFriendMsgHistory"] = "get_friend_msg_history";
4139
- OB11ApiAction2["getGroupMsgHistory"] = "get_group_msg_history";
4140
- OB11ApiAction2["setMsgEmojiLike"] = "set_msg_emoji_like";
4141
- OB11ApiAction2["uploadGroupFile"] = "upload_group_file";
4142
- OB11ApiAction2["uploadPrivateFile"] = "upload_private_file";
4143
- OB11ApiAction2["getEssenceMsgList"] = "get_essence_msg_list";
4144
- OB11ApiAction2["setEssenceMsg"] = "set_essence_msg";
4145
- OB11ApiAction2["deleteEssenceMsg"] = "delete_essence_msg";
4146
- return OB11ApiAction2;
4147
- })(OB11ApiAction || {});
4148
- }
4149
- });
4150
-
4151
- // src/adapter/onebot/types/event.ts
4152
- var OB11Sex, OB11Event, OB11MessageType, OB11MessageSubType, OB11NoticeType, OB11RequestType;
4153
- var init_event2 = __esm({
4154
- "src/adapter/onebot/types/event.ts"() {
4155
- OB11Sex = /* @__PURE__ */ ((OB11Sex2) => {
4156
- OB11Sex2["Male"] = "male";
4157
- OB11Sex2["Female"] = "female";
4158
- OB11Sex2["Unknown"] = "unknown";
4159
- return OB11Sex2;
4160
- })(OB11Sex || {});
4161
- OB11Event = /* @__PURE__ */ ((OB11Event2) => {
4162
- OB11Event2["Message"] = "message";
4163
- OB11Event2["Notice"] = "notice";
4164
- OB11Event2["Request"] = "request";
4165
- OB11Event2["MetaEvent"] = "meta_event";
4166
- OB11Event2["MessageSent"] = "message_sent";
4167
- return OB11Event2;
4168
- })(OB11Event || {});
4169
- OB11MessageType = /* @__PURE__ */ ((OB11MessageType2) => {
4170
- OB11MessageType2["Private"] = "private";
4171
- OB11MessageType2["Group"] = "group";
4172
- return OB11MessageType2;
4173
- })(OB11MessageType || {});
4174
- OB11MessageSubType = /* @__PURE__ */ ((OB11MessageSubType2) => {
4175
- OB11MessageSubType2["Friend"] = "friend";
4176
- OB11MessageSubType2["Group"] = "group";
4177
- OB11MessageSubType2["Other"] = "other";
4178
- OB11MessageSubType2["Normal"] = "normal";
4179
- OB11MessageSubType2["Anonymous"] = "anonymous";
4180
- OB11MessageSubType2["Notice"] = "notice";
4181
- return OB11MessageSubType2;
4182
- })(OB11MessageSubType || {});
4183
- OB11NoticeType = /* @__PURE__ */ ((OB11NoticeType2) => {
4184
- OB11NoticeType2["GroupUpload"] = "group_upload";
4185
- OB11NoticeType2["GroupAdmin"] = "group_admin";
4186
- OB11NoticeType2["GroupDecrease"] = "group_decrease";
4187
- OB11NoticeType2["GroupIncrease"] = "group_increase";
4188
- OB11NoticeType2["GroupBan"] = "group_ban";
4189
- OB11NoticeType2["FriendAdd"] = "friend_add";
4190
- OB11NoticeType2["GroupRecall"] = "group_recall";
4191
- OB11NoticeType2["FriendRecall"] = "friend_recall";
4192
- OB11NoticeType2["Notify"] = "notify";
4193
- OB11NoticeType2["GroupMsgEmojiLike"] = "group_msg_emoji_like";
4194
- OB11NoticeType2["GroupMsgEmojiLikeLagrange"] = "reaction";
4195
- OB11NoticeType2["GroupEssence"] = "essence";
4196
- OB11NoticeType2["GroupCard"] = "group_card";
4197
- return OB11NoticeType2;
4198
- })(OB11NoticeType || {});
4199
- OB11RequestType = /* @__PURE__ */ ((OB11RequestType2) => {
4200
- OB11RequestType2["Friend"] = "friend";
4201
- OB11RequestType2["Group"] = "group";
4202
- return OB11RequestType2;
4203
- })(OB11RequestType || {});
4204
- }
4205
- });
4206
-
3503
+ // src/adapter/onebot/types/api.ts
3504
+ var OB11ApiAction;
3505
+ var init_api = __esm({
3506
+ "src/adapter/onebot/types/api.ts"() {
3507
+ OB11ApiAction = /* @__PURE__ */ ((OB11ApiAction2) => {
3508
+ OB11ApiAction2["sendPrivateMsg"] = "send_private_msg";
3509
+ OB11ApiAction2["sendGroupMsg"] = "send_group_msg";
3510
+ OB11ApiAction2["sendMsg"] = "send_msg";
3511
+ OB11ApiAction2["deleteMsg"] = "delete_msg";
3512
+ OB11ApiAction2["getMsg"] = "get_msg";
3513
+ OB11ApiAction2["getForwardMsg"] = "get_forward_msg";
3514
+ OB11ApiAction2["sendLike"] = "send_like";
3515
+ OB11ApiAction2["setGroupKick"] = "set_group_kick";
3516
+ OB11ApiAction2["setGroupBan"] = "set_group_ban";
3517
+ OB11ApiAction2["setGroupAnonymousBan"] = "set_group_anonymous_ban";
3518
+ OB11ApiAction2["setGroupWholeBan"] = "set_group_whole_ban";
3519
+ OB11ApiAction2["setGroupAdmin"] = "set_group_admin";
3520
+ OB11ApiAction2["setGroupAnonymous"] = "set_group_anonymous";
3521
+ OB11ApiAction2["setGroupCard"] = "set_group_card";
3522
+ OB11ApiAction2["setGroupName"] = "set_group_name";
3523
+ OB11ApiAction2["setGroupLeave"] = "set_group_leave";
3524
+ OB11ApiAction2["setGroupSpecialTitle"] = "set_group_special_title";
3525
+ OB11ApiAction2["setFriendAddRequest"] = "set_friend_add_request";
3526
+ OB11ApiAction2["setGroupAddRequest"] = "set_group_add_request";
3527
+ OB11ApiAction2["getLoginInfo"] = "get_login_info";
3528
+ OB11ApiAction2["getStrangerInfo"] = "get_stranger_info";
3529
+ OB11ApiAction2["getFriendList"] = "get_friend_list";
3530
+ OB11ApiAction2["getGroupInfo"] = "get_group_info";
3531
+ OB11ApiAction2["getGroupList"] = "get_group_list";
3532
+ OB11ApiAction2["getGroupMemberInfo"] = "get_group_member_info";
3533
+ OB11ApiAction2["getGroupMemberList"] = "get_group_member_list";
3534
+ OB11ApiAction2["getGroupHonorInfo"] = "get_group_honor_info";
3535
+ OB11ApiAction2["getCookies"] = "get_cookies";
3536
+ OB11ApiAction2["getCsrfToken"] = "get_csrf_token";
3537
+ OB11ApiAction2["getCredentials"] = "get_credentials";
3538
+ OB11ApiAction2["getRecord"] = "get_record";
3539
+ OB11ApiAction2["getImage"] = "get_image";
3540
+ OB11ApiAction2["canSendImage"] = "can_send_image";
3541
+ OB11ApiAction2["canSendRecord"] = "can_send_record";
3542
+ OB11ApiAction2["getStatus"] = "get_status";
3543
+ OB11ApiAction2["getVersionInfo"] = "get_version_info";
3544
+ OB11ApiAction2["getVersion"] = "get_version";
3545
+ OB11ApiAction2["setRestart"] = "set_restart";
3546
+ OB11ApiAction2["cleanCache"] = "clean_cache";
3547
+ OB11ApiAction2["sendForwardMsg"] = "send_forward_msg";
3548
+ OB11ApiAction2["sendGroupForwardMsg"] = "send_group_forward_msg";
3549
+ OB11ApiAction2["sendPrivateForwardMsg"] = "send_private_forward_msg";
3550
+ OB11ApiAction2["getFriendMsgHistory"] = "get_friend_msg_history";
3551
+ OB11ApiAction2["getGroupMsgHistory"] = "get_group_msg_history";
3552
+ OB11ApiAction2["setMsgEmojiLike"] = "set_msg_emoji_like";
3553
+ OB11ApiAction2["uploadGroupFile"] = "upload_group_file";
3554
+ OB11ApiAction2["uploadPrivateFile"] = "upload_private_file";
3555
+ OB11ApiAction2["getEssenceMsgList"] = "get_essence_msg_list";
3556
+ OB11ApiAction2["setEssenceMsg"] = "set_essence_msg";
3557
+ OB11ApiAction2["deleteEssenceMsg"] = "delete_essence_msg";
3558
+ return OB11ApiAction2;
3559
+ })(OB11ApiAction || {});
3560
+ }
3561
+ });
3562
+
3563
+ // src/adapter/onebot/types/event.ts
3564
+ var OB11Sex, OB11Event, OB11MessageType, OB11MessageSubType, OB11NoticeType, OB11RequestType;
3565
+ var init_event2 = __esm({
3566
+ "src/adapter/onebot/types/event.ts"() {
3567
+ OB11Sex = /* @__PURE__ */ ((OB11Sex2) => {
3568
+ OB11Sex2["Male"] = "male";
3569
+ OB11Sex2["Female"] = "female";
3570
+ OB11Sex2["Unknown"] = "unknown";
3571
+ return OB11Sex2;
3572
+ })(OB11Sex || {});
3573
+ OB11Event = /* @__PURE__ */ ((OB11Event2) => {
3574
+ OB11Event2["Message"] = "message";
3575
+ OB11Event2["Notice"] = "notice";
3576
+ OB11Event2["Request"] = "request";
3577
+ OB11Event2["MetaEvent"] = "meta_event";
3578
+ OB11Event2["MessageSent"] = "message_sent";
3579
+ return OB11Event2;
3580
+ })(OB11Event || {});
3581
+ OB11MessageType = /* @__PURE__ */ ((OB11MessageType2) => {
3582
+ OB11MessageType2["Private"] = "private";
3583
+ OB11MessageType2["Group"] = "group";
3584
+ return OB11MessageType2;
3585
+ })(OB11MessageType || {});
3586
+ OB11MessageSubType = /* @__PURE__ */ ((OB11MessageSubType2) => {
3587
+ OB11MessageSubType2["Friend"] = "friend";
3588
+ OB11MessageSubType2["Group"] = "group";
3589
+ OB11MessageSubType2["Other"] = "other";
3590
+ OB11MessageSubType2["Normal"] = "normal";
3591
+ OB11MessageSubType2["Anonymous"] = "anonymous";
3592
+ OB11MessageSubType2["Notice"] = "notice";
3593
+ return OB11MessageSubType2;
3594
+ })(OB11MessageSubType || {});
3595
+ OB11NoticeType = /* @__PURE__ */ ((OB11NoticeType2) => {
3596
+ OB11NoticeType2["GroupUpload"] = "group_upload";
3597
+ OB11NoticeType2["GroupAdmin"] = "group_admin";
3598
+ OB11NoticeType2["GroupDecrease"] = "group_decrease";
3599
+ OB11NoticeType2["GroupIncrease"] = "group_increase";
3600
+ OB11NoticeType2["GroupBan"] = "group_ban";
3601
+ OB11NoticeType2["FriendAdd"] = "friend_add";
3602
+ OB11NoticeType2["GroupRecall"] = "group_recall";
3603
+ OB11NoticeType2["FriendRecall"] = "friend_recall";
3604
+ OB11NoticeType2["Notify"] = "notify";
3605
+ OB11NoticeType2["GroupMsgEmojiLike"] = "group_msg_emoji_like";
3606
+ OB11NoticeType2["GroupMsgEmojiLikeLagrange"] = "reaction";
3607
+ OB11NoticeType2["GroupEssence"] = "essence";
3608
+ OB11NoticeType2["GroupCard"] = "group_card";
3609
+ return OB11NoticeType2;
3610
+ })(OB11NoticeType || {});
3611
+ OB11RequestType = /* @__PURE__ */ ((OB11RequestType2) => {
3612
+ OB11RequestType2["Friend"] = "friend";
3613
+ OB11RequestType2["Group"] = "group";
3614
+ return OB11RequestType2;
3615
+ })(OB11RequestType || {});
3616
+ }
3617
+ });
3618
+ function AdapterConvertKarin(data = []) {
3619
+ const elements = [];
3620
+ try {
3621
+ for (const i of data) {
3622
+ switch (i.type) {
3623
+ case "text":
3624
+ elements.push(segment_exports.text(i.data.text));
3625
+ break;
3626
+ case "face":
3627
+ elements.push(segment_exports.face(Number(i.data.id)));
3628
+ break;
3629
+ case "image":
3630
+ elements.push(segment_exports.image(i.data.url || i.data.file, { fileType: i.data.type }));
3631
+ break;
3632
+ case "record":
3633
+ elements.push(segment_exports.record(i.data.url || i.data.file, i.data.magic === 1));
3634
+ break;
3635
+ case "video":
3636
+ elements.push(segment_exports.video(i.data.url || i.data.file));
3637
+ break;
3638
+ case "at":
3639
+ elements.push(segment_exports.at(i.data.qq, i.data.name));
3640
+ break;
3641
+ case "contact":
3642
+ elements.push(segment_exports.contact(i.data.type === "qq" ? "friend" : "group", i.data.id));
3643
+ break;
3644
+ case "location":
3645
+ elements.push(segment_exports.location(
3646
+ Number(i.data.lat),
3647
+ Number(i.data.lon),
3648
+ i.data.title || "",
3649
+ i.data.content || ""
3650
+ ));
3651
+ break;
3652
+ case "reply":
3653
+ elements.push(segment_exports.reply(i.data.id));
3654
+ break;
3655
+ case "json":
3656
+ elements.push(segment_exports.json(i.data.data));
3657
+ break;
3658
+ case "xml":
3659
+ elements.push(segment_exports.xml(i.data.data));
3660
+ break;
3661
+ default: {
3662
+ elements.push(segment_exports.text(JSON.stringify(i)));
3663
+ }
3664
+ }
3665
+ }
3666
+ } catch (error) {
3667
+ logger.error("[AdapterConvertKarin] \u8F6C\u6362\u9519\u8BEF");
3668
+ logger.error(error);
3669
+ return elements;
3670
+ }
3671
+ return elements;
3672
+ }
3673
+ var formatLogString, buildError, fileToBase64, KarinConvertAdapter;
3674
+ var init_convert = __esm({
3675
+ "src/adapter/onebot/core/convert.ts"() {
3676
+ init_message2();
3677
+ formatLogString = (str) => {
3678
+ return str.replace(/(["']?(?:base64|base):\/\/)[^"',}\s]*["']?/g, "$1...");
3679
+ };
3680
+ buildError = (selfId, action, request2, error) => {
3681
+ if (error) {
3682
+ const err = JSON.stringify(error, null, 2).replace(/\\n/g, "\n");
3683
+ return new Error(`[${selfId}][sendApi] \u8BF7\u6C42\u9519\u8BEF:
3684
+ action: ${action}
3685
+ params: ${formatLogString(request2)}
3686
+ error: ${err}}`);
3687
+ }
3688
+ logger.error(`[${selfId}][sendApi][\u8BF7\u6C42\u9519\u8BEF]:
3689
+ action: ${action}
3690
+ params: ${formatLogString(request2)}`);
3691
+ };
3692
+ fileToBase64 = (file, url) => {
3693
+ if (!url || !file.startsWith("file://")) return file;
3694
+ const list2 = ["127.0.0.1", "localhost"];
3695
+ const link = new URL(url);
3696
+ return list2.includes(link.hostname) ? file : `base64://${fs5.readFileSync(file.replace("file://", "")).toString("base64")}`;
3697
+ };
3698
+ KarinConvertAdapter = (data, onebot) => {
3699
+ const elements = [];
3700
+ for (const i of data) {
3701
+ switch (i.type) {
3702
+ case "text":
3703
+ elements.push({ type: "text", data: { text: i.text } });
3704
+ break;
3705
+ case "face":
3706
+ elements.push({ type: "face", data: { id: i.id + "" } });
3707
+ break;
3708
+ case "at":
3709
+ elements.push({ type: "at", data: { qq: String(i.targetId), name: i.name } });
3710
+ break;
3711
+ case "reply":
3712
+ elements.push({ type: "reply", data: { id: i.messageId } });
3713
+ break;
3714
+ case "image": {
3715
+ elements.push({ type: "image", data: { file: fileToBase64(i.file, onebot.adapter.address) } });
3716
+ break;
3717
+ }
3718
+ case "video": {
3719
+ elements.push({ type: "video", data: { file: i.file } });
3720
+ break;
3721
+ }
3722
+ case "json":
3723
+ case "xml": {
3724
+ elements.push({ type: "json", data: { data: i.data } });
3725
+ break;
3726
+ }
3727
+ case "record": {
3728
+ elements.push({
3729
+ type: "record",
3730
+ data: {
3731
+ file: fileToBase64(i.file, onebot.adapter.address),
3732
+ magic: i.magic ?? false ? 1 : 0
3733
+ }
3734
+ });
3735
+ break;
3736
+ }
3737
+ case "music": {
3738
+ if (i.platform === "custom") {
3739
+ const { url, audio, title, author, pic } = i;
3740
+ elements.push({
3741
+ type: "music",
3742
+ data: {
3743
+ type: "custom",
3744
+ url,
3745
+ audio,
3746
+ title,
3747
+ content: author,
3748
+ image: pic
3749
+ }
3750
+ });
3751
+ } else {
3752
+ elements.push({
3753
+ type: "music",
3754
+ data: {
3755
+ type: i.platform,
3756
+ id: i.id
3757
+ }
3758
+ });
3759
+ }
3760
+ break;
3761
+ }
3762
+ // case OB11SegmentType.Contact: {
3763
+ // elements.push({ type, data: { type: i.scene, id: i.peer } })
3764
+ // break
3765
+ // }
3766
+ // case OB11SegmentType.Location: {
3767
+ // elements.push({ type, data: { lat: i.lat, lon: i.lon, title: i.title, content: i.address } })
3768
+ // break
3769
+ // }
3770
+ // case 'longMsg':
3771
+ // case 'basketball':
3772
+ // case 'marketFace': {
3773
+ // elements.push({ type: 'marketFace', data: { id: i.id + '' } })
3774
+ // break
3775
+ // }
3776
+ // case 'gift': {
3777
+ // elements.push({ type: 'gift', data: { qq: i.qq, id: i.id } })
3778
+ // break
3779
+ // }
3780
+ // case 'weather': {
3781
+ // elements.push({ type: 'weather', data: { city: i.city, type: i.type } })
3782
+ // break
3783
+ // }
3784
+ case "dice":
3785
+ case "rps": {
3786
+ elements.push({ type: i.type, data: {} });
3787
+ break;
3788
+ }
3789
+ case "share": {
3790
+ elements.push({ type: "share", data: { url: i.url, title: i.title, content: i.content, image: i.image } });
3791
+ break;
3792
+ }
3793
+ case "raw":
3794
+ elements.push(i.data);
3795
+ break;
3796
+ case "node": {
3797
+ if (i.subType === "messageID") {
3798
+ elements.push({ type: "forward", data: { id: i.messageId } });
3799
+ } else {
3800
+ elements.push({
3801
+ type: "node",
3802
+ data: {
3803
+ user_id: i.userId || onebot.selfId,
3804
+ nickname: i.nickname || onebot.selfName,
3805
+ content: KarinConvertAdapter(i.message, onebot),
3806
+ prompt: i?.options?.prompt,
3807
+ summary: i?.options?.summary,
3808
+ source: i?.options?.source
3809
+ }
3810
+ });
3811
+ }
3812
+ break;
3813
+ }
3814
+ case "button":
3815
+ case "markdown":
3816
+ case "keyboard":
3817
+ default: {
3818
+ elements.push(i);
3819
+ break;
3820
+ }
3821
+ }
3822
+ }
3823
+ return elements;
3824
+ };
3825
+ }
3826
+ });
3827
+
4207
3828
  // src/event/handler/other/cd.ts
4208
3829
  var userCD, groupCD, groupUserCD, privateCD, groupsCD, noticeRequestCD;
4209
3830
  var init_cd = __esm({
@@ -4272,7 +3893,7 @@ var init_error2 = __esm({
4272
3893
  if (missing.has(key)) return;
4273
3894
  missing.set(key, { name, file, depend: pkg2 });
4274
3895
  } else {
4275
- logger.error(`\u8F7D\u5165\u63D2\u4EF6\u9519\u8BEF\uFF1A${logger.red(`${name}/${path5.basename(file)}`)}`);
3896
+ logger.error(`\u8F7D\u5165\u63D2\u4EF6\u9519\u8BEF\uFF1A${logger.red(`${name}/${path4.basename(file)}`)}`);
4276
3897
  listeners.emit("error", error);
4277
3898
  }
4278
3899
  };
@@ -4285,7 +3906,7 @@ var init_error2 = __esm({
4285
3906
  if (!missing.size) return;
4286
3907
  const msg = ["\n-----\u4F9D\u8D56\u7F3A\u5931----"];
4287
3908
  for (const [, { name, file, depend }] of missing) {
4288
- msg.push(`[${name}][${path5.basename(file)}] \u7F3A\u5C11\u4F9D\u8D56\uFF1A${logger.red(depend)}`);
3909
+ msg.push(`[${name}][${path4.basename(file)}] \u7F3A\u5C11\u4F9D\u8D56\uFF1A${logger.red(depend)}`);
4289
3910
  }
4290
3911
  msg.push("-------------------");
4291
3912
  const one = missing.values().next().value;
@@ -4445,7 +4066,7 @@ var init_eventCall = __esm({
4445
4066
  priority: options.priority ?? 1e4,
4446
4067
  callback
4447
4068
  });
4448
- return { id, list: lodash4.orderBy(list2, ["priority"], ["asc"]) };
4069
+ return { id, list: lodash3.orderBy(list2, ["priority"], ["asc"]) };
4449
4070
  };
4450
4071
  eventCall = Object.assign(
4451
4072
  /**
@@ -4645,7 +4266,7 @@ var init_empty = __esm({
4645
4266
  priority: options.priority ?? 1e4,
4646
4267
  callback
4647
4268
  });
4648
- return { id, list: lodash4.orderBy(list2, ["priority"], ["asc"]) };
4269
+ return { id, list: lodash3.orderBy(list2, ["priority"], ["asc"]) };
4649
4270
  };
4650
4271
  addGeneralHook = (list2, callback, options = {}) => {
4651
4272
  const id = createHookId();
@@ -4654,7 +4275,7 @@ var init_empty = __esm({
4654
4275
  priority: options.priority ?? 1e4,
4655
4276
  callback
4656
4277
  });
4657
- return { id, list: lodash4.orderBy(list2, ["priority"], ["asc"]) };
4278
+ return { id, list: lodash3.orderBy(list2, ["priority"], ["asc"]) };
4658
4279
  };
4659
4280
  empty = Object.assign(
4660
4281
  /**
@@ -5429,7 +5050,7 @@ var init_messaeg = __esm({
5429
5050
  priority: options.priority ?? 1e4,
5430
5051
  callback
5431
5052
  });
5432
- return { id, list: lodash4.orderBy(list2, ["priority"], ["asc"]) };
5053
+ return { id, list: lodash3.orderBy(list2, ["priority"], ["asc"]) };
5433
5054
  };
5434
5055
  message = Object.assign(
5435
5056
  /**
@@ -5722,7 +5343,7 @@ var init_groups3 = __esm({
5722
5343
  if (!disableViaPluginBlacklist(plugin, config3)) return true;
5723
5344
  ctx3.logFnc = `[${plugin.pkg.name}][${plugin.file.name}]`;
5724
5345
  const logFnc = logger.fnc(ctx3.logFnc);
5725
- isPrint && plugin.log(ctx3.selfId, `${logFnc}${ctx3.logText} ${lodash4.truncate(ctx3.msg, { length: 100 })}`);
5346
+ isPrint && plugin.log(ctx3.selfId, `${logFnc}${ctx3.logText} ${lodash3.truncate(ctx3.msg, { length: 100 })}`);
5726
5347
  const start3 = Date.now();
5727
5348
  if (ctx3.isGroup) {
5728
5349
  const result = await eventCallEmit.group(ctx3, plugin);
@@ -5767,7 +5388,7 @@ var init_groups3 = __esm({
5767
5388
  return false;
5768
5389
  } finally {
5769
5390
  const time2 = logger.green(Date.now() - start3 + "ms");
5770
- const msg = lodash4.truncate(ctx3.msg, { length: 100 });
5391
+ const msg = lodash3.truncate(ctx3.msg, { length: 100 });
5771
5392
  isPrint && plugin.log(ctx3.selfId, `${logFnc} ${msg} \u5904\u7406\u5B8C\u6210 ${time2}`);
5772
5393
  }
5773
5394
  };
@@ -5869,7 +5490,7 @@ var init_private3 = __esm({
5869
5490
  if (!disableViaPluginBlacklist(plugin, config3)) return true;
5870
5491
  ctx3.logFnc = `[${plugin.pkg.name}][${plugin.file.name}]`;
5871
5492
  const logFnc = logger.fnc(ctx3.logFnc);
5872
- plugin.log(ctx3.selfId, `${logFnc}${ctx3.logText} ${lodash4.truncate(ctx3.msg, { length: 100 })}`);
5493
+ plugin.log(ctx3.selfId, `${logFnc}${ctx3.logText} ${lodash3.truncate(ctx3.msg, { length: 100 })}`);
5873
5494
  const start3 = Date.now();
5874
5495
  if (ctx3.isFriend) {
5875
5496
  const result = await eventCallEmit.friend(ctx3, plugin);
@@ -5912,7 +5533,7 @@ var init_private3 = __esm({
5912
5533
  return false;
5913
5534
  } finally {
5914
5535
  const time2 = logger.green(Date.now() - start3 + "ms");
5915
- const msg = lodash4.truncate(ctx3.msg, { length: 100 });
5536
+ const msg = lodash3.truncate(ctx3.msg, { length: 100 });
5916
5537
  plugin.log(ctx3.selfId, `${logFnc} ${msg} \u5904\u7406\u5B8C\u6210 ${time2}`);
5917
5538
  }
5918
5539
  };
@@ -6007,7 +5628,7 @@ var init_base2 = __esm({
6007
5628
  } else {
6008
5629
  this.selfId !== "console" && logger.bot("info", this.selfId, `${logger.green(`Send private ${this.contact.peer}: `)}${raw2.replace(/\n/g, "\\n")}`);
6009
5630
  }
6010
- result = util6.types.isPromise(request2) ? await request2 : request2;
5631
+ result = util5.types.isPromise(request2) ? await request2 : request2;
6011
5632
  result.message_id = result.messageId;
6012
5633
  if (recallMsg > 0 && result.messageId) {
6013
5634
  setTimeout(() => {
@@ -9642,7 +9263,7 @@ var init_segment2 = __esm({
9642
9263
  });
9643
9264
 
9644
9265
  // src/adapter/onebot/types/index.ts
9645
- var init_types2 = __esm({
9266
+ var init_types = __esm({
9646
9267
  "src/adapter/onebot/types/index.ts"() {
9647
9268
  init_api();
9648
9269
  init_segment2();
@@ -9656,7 +9277,7 @@ var init_ws = __esm({
9656
9277
  "src/adapter/onebot/connect/ws.ts"() {
9657
9278
  init_adapter();
9658
9279
  init_base3();
9659
- init_types2();
9280
+ init_types();
9660
9281
  init_event2();
9661
9282
  init_bot();
9662
9283
  init_convert();
@@ -10051,6 +9672,155 @@ var init_git = __esm({
10051
9672
  init_pull();
10052
9673
  }
10053
9674
  });
9675
+ var initLogger, addColor, createLogger, logger2;
9676
+ var init_logger = __esm({
9677
+ "src/service/logger/index.ts"() {
9678
+ init_root();
9679
+ initLogger = () => {
9680
+ const level = process.env.LOG_LEVEL || "info";
9681
+ const daysToKeep = Number(process.env.LOG_DAYS_TO_KEEP) || 30;
9682
+ const maxFileSize = Number(process.env.LOG_MAX_LOG_SIZE) || 0;
9683
+ const config3 = {
9684
+ appenders: {
9685
+ console: {
9686
+ type: "console",
9687
+ layout: {
9688
+ type: "pattern",
9689
+ pattern: `%[[Karin][%d{hh:mm:ss.SSS}][%4.4p]%] ${process.env.RUNTIME === "tsx" ? "[%f{3}:%l] " : ""}%m`
9690
+ }
9691
+ },
9692
+ overall: {
9693
+ /** 输出到文件 */
9694
+ type: "file",
9695
+ /** 日志文件名 */
9696
+ filename: "@karinjs/logs/logger",
9697
+ /** 日期后缀 */
9698
+ pattern: "yyyy-MM-dd.log",
9699
+ /** 日期后缀 */
9700
+ keepFileExt: true,
9701
+ /** 日志文件名中包含日期模式 */
9702
+ alwaysIncludePattern: true,
9703
+ /** 日志文件保留天数 */
9704
+ daysToKeep: daysToKeep,
9705
+ /** 日志输出格式 */
9706
+ layout: {
9707
+ type: "pattern",
9708
+ pattern: "[%d{hh:mm:ss.SSS}][%4.4p] %m"
9709
+ }
9710
+ },
9711
+ errorFile: {
9712
+ /** 输出到文件 */
9713
+ type: "file",
9714
+ /** 日志文件名 */
9715
+ filename: "@karinjs/logs/logger",
9716
+ /** 日期后缀 */
9717
+ pattern: "error.yyyy-MM-dd.log",
9718
+ /** 日期后缀 */
9719
+ keepFileExt: true,
9720
+ /** 日志文件名中包含日期模式 */
9721
+ alwaysIncludePattern: true,
9722
+ /** 日志文件保留天数 */
9723
+ daysToKeep: daysToKeep,
9724
+ /** 日志输出格式 */
9725
+ layout: {
9726
+ type: "pattern",
9727
+ pattern: "[%d{hh:mm:ss.SSS}][%4.4p] %m"
9728
+ }
9729
+ },
9730
+ errors: {
9731
+ /** 错误日志过滤器 */
9732
+ type: "logLevelFilter",
9733
+ /** 目标appender */
9734
+ appender: "errorFile",
9735
+ /** 只记录错误级别及以上的日志 */
9736
+ level: "error"
9737
+ }
9738
+ },
9739
+ categories: {
9740
+ default: {
9741
+ appenders: ["overall", "console", "errors"],
9742
+ level,
9743
+ enableCallStack: process.env.RUNTIME === "tsx"
9744
+ }
9745
+ },
9746
+ levels: {
9747
+ handler: { value: 15e3, colour: "cyan" }
9748
+ }
9749
+ };
9750
+ if (maxFileSize > 0) {
9751
+ config3.categories.default.appenders.unshift("fragments");
9752
+ config3.appenders.fragments = {
9753
+ type: "file",
9754
+ filename: "@karinjs/logs/app.log",
9755
+ pattern: "MM-dd.log",
9756
+ keepFileExt: true,
9757
+ alwaysIncludePattern: true,
9758
+ daysToKeep: daysToKeep,
9759
+ maxLogSize: (maxFileSize || 30) * 1024 * 1024,
9760
+ /** 最大文件数 */
9761
+ numBackups: 9999999,
9762
+ /** 日志输出格式 */
9763
+ layout: {
9764
+ type: "pattern",
9765
+ pattern: "[%d{hh:mm:ss.SSS}][%4.4p] %m"
9766
+ }
9767
+ };
9768
+ }
9769
+ return log4js.configure(config3);
9770
+ };
9771
+ addColor = (Logger, color) => {
9772
+ const logger3 = Logger;
9773
+ logger3.chalk = chalk2;
9774
+ logger3.red = chalk2.red;
9775
+ logger3.green = chalk2.green;
9776
+ logger3.yellow = chalk2.yellow;
9777
+ logger3.blue = chalk2.blue;
9778
+ logger3.magenta = chalk2.magenta;
9779
+ logger3.cyan = chalk2.cyan;
9780
+ logger3.white = chalk2.white;
9781
+ logger3.gray = chalk2.gray;
9782
+ logger3.violet = chalk2.hex("#868ECC");
9783
+ logger3.fnc = chalk2.hex(color || "#FFFF00");
9784
+ logger3.bot = (level, id, ...args) => {
9785
+ switch (level) {
9786
+ case "trace":
9787
+ return logger3.trace(logger3.violet(`[Bot:${id}]`), ...args);
9788
+ case "debug":
9789
+ return logger3.debug(logger3.violet(`[Bot:${id}]`), ...args);
9790
+ case "mark":
9791
+ return logger3.mark(logger3.violet(`[Bot:${id}]`), ...args);
9792
+ case "info":
9793
+ return logger3.info(logger3.violet(`[Bot:${id}]`), ...args);
9794
+ case "warn":
9795
+ return logger3.warn(logger3.violet(`[Bot:${id}]`), ...args);
9796
+ case "error":
9797
+ return logger3.error(logger3.violet(`[Bot:${id}]`), ...args);
9798
+ case "fatal":
9799
+ return logger3.fatal(logger3.violet(`[Bot:${id}]`), ...args);
9800
+ default:
9801
+ return logger3.info(logger3.violet(`[Bot:${id}]`), ...args);
9802
+ }
9803
+ };
9804
+ return logger3;
9805
+ };
9806
+ createLogger = () => {
9807
+ const dir2 = karinPathLogs;
9808
+ if (!fs5.existsSync(dir2)) fs5.mkdirSync(dir2, { recursive: true });
9809
+ initLogger();
9810
+ const logger3 = addColor(log4js.getLogger("default"));
9811
+ global.logger = logger3;
9812
+ return logger3;
9813
+ };
9814
+ logger2 = createLogger();
9815
+ }
9816
+ });
9817
+
9818
+ // src/utils/logger/logger.ts
9819
+ var init_logger2 = __esm({
9820
+ "src/utils/logger/logger.ts"() {
9821
+ init_logger();
9822
+ }
9823
+ });
10054
9824
  var isLoopback, isIPv4Loop, isIPv6Loop, getRequestIp, isLocalRequest;
10055
9825
  var init_ip = __esm({
10056
9826
  "src/utils/system/ip.ts"() {
@@ -10108,7 +9878,7 @@ var init_system = __esm({
10108
9878
  isWin2 = os.platform() === "win32";
10109
9879
  isLinux = os.platform() === "linux";
10110
9880
  isMac = os.platform() === "darwin";
10111
- isDocker = fs7.existsSync("/.dockerenv");
9881
+ isDocker = fs5.existsSync("/.dockerenv");
10112
9882
  isRoot = os.userInfo().uid === 0;
10113
9883
  }
10114
9884
  });
@@ -10261,11 +10031,11 @@ var init_list = __esm({
10261
10031
  };
10262
10032
  getCachedData = (type, isInfo) => {
10263
10033
  if (isInfo) {
10264
- if (cache5?.info?.[type] && !lodash4.isEqual(cache5.info[type], cache5.info[type])) {
10034
+ if (cache5?.info?.[type] && !lodash3.isEqual(cache5.info[type], cache5.info[type])) {
10265
10035
  return cache5.info[type];
10266
10036
  }
10267
10037
  } else {
10268
- if (cache5?.list?.[type] && !lodash4.isEqual(cache5.list[type], cache5.list[type])) {
10038
+ if (cache5?.list?.[type] && !lodash3.isEqual(cache5.list[type], cache5.list[type])) {
10269
10039
  return cache5.list[type];
10270
10040
  }
10271
10041
  }
@@ -10279,8 +10049,8 @@ var init_list = __esm({
10279
10049
  dir: dir2,
10280
10050
  id: -1,
10281
10051
  get pkgPath() {
10282
- const file = path5.join(this.dir, "package.json");
10283
- return fs7.existsSync(file) ? file : "";
10052
+ const file = path4.join(this.dir, "package.json");
10053
+ return fs5.existsSync(file) ? file : "";
10284
10054
  },
10285
10055
  get pkgData() {
10286
10056
  if (!this.pkgPath) return {};
@@ -10292,7 +10062,7 @@ var init_list = __esm({
10292
10062
  info.push(createPkg("app", name, dir2, apps, [dir2], isForce));
10293
10063
  };
10294
10064
  getGitInfo = async (info, dir2, name, ext, isForce, env3) => {
10295
- const pkg2 = await requireFile(path5.join(dir2, "package.json"));
10065
+ const pkg2 = await requireFile(path4.join(dir2, "package.json"));
10296
10066
  if (!pkg2 || !pkg2.karin) {
10297
10067
  info.push(createPkg("git", name, dir2, [], [], isForce));
10298
10068
  return;
@@ -10317,8 +10087,8 @@ var init_list = __esm({
10317
10087
  }
10318
10088
  await Promise.allSettled(
10319
10089
  files.map(async (app4) => {
10320
- const appPath = path5.join(dir2, app4);
10321
- if (!fs7.existsSync(appPath)) return;
10090
+ const appPath = path4.join(dir2, app4);
10091
+ if (!fs5.existsSync(appPath)) return;
10322
10092
  apps.push(...filesByExt(appPath, ext, "abs"));
10323
10093
  allApps.push(appPath);
10324
10094
  })
@@ -10329,7 +10099,7 @@ var init_list = __esm({
10329
10099
  const ext = ".js";
10330
10100
  let apps = [];
10331
10101
  let allApps = [];
10332
- const pkg2 = await requireFile(path5.join(dir2, "package.json"));
10102
+ const pkg2 = await requireFile(path4.join(dir2, "package.json"));
10333
10103
  if (!pkg2.karin?.apps?.length) {
10334
10104
  info.push(createPkg("npm", name, dir2, [], [], isForce));
10335
10105
  return;
@@ -10345,8 +10115,8 @@ var init_list = __esm({
10345
10115
  }
10346
10116
  await Promise.allSettled(
10347
10117
  files.map(async (app4) => {
10348
- const appPath = path5.join(dir2, app4);
10349
- if (!fs7.existsSync(appPath)) return;
10118
+ const appPath = path4.join(dir2, app4);
10119
+ if (!fs5.existsSync(appPath)) return;
10350
10120
  apps.push(...filesByExt(appPath, ext, "abs"));
10351
10121
  allApps.push(appPath);
10352
10122
  })
@@ -10363,17 +10133,17 @@ var init_list = __esm({
10363
10133
  list2.map(async (v) => {
10364
10134
  const [type, name] = v.split(":");
10365
10135
  if (type === "app") {
10366
- const file = path5.join(karinPathPlugins, name);
10136
+ const file = path4.join(karinPathPlugins, name);
10367
10137
  await getAppInfo(info, file, name, ext, isForce);
10368
10138
  return;
10369
10139
  }
10370
10140
  if (type === "git" || type === "root") {
10371
- const file = type === "root" ? process.cwd() : path5.join(karinPathPlugins, name);
10141
+ const file = type === "root" ? process.cwd() : path4.join(karinPathPlugins, name);
10372
10142
  await getGitInfo(info, file, name, ext, isForce, env3);
10373
10143
  return;
10374
10144
  }
10375
10145
  if (type === "npm") {
10376
- const file = path5.join(process.cwd(), "node_modules", name);
10146
+ const file = path4.join(process.cwd(), "node_modules", name);
10377
10147
  await getNpmInfo(info, file, name, isForce, env3);
10378
10148
  }
10379
10149
  })
@@ -10391,7 +10161,7 @@ var init_list = __esm({
10391
10161
  files.map(async (v) => {
10392
10162
  if (!v.isDirectory()) return;
10393
10163
  if (!v.name.startsWith("karin-plugin-")) return;
10394
- if (fs7.existsSync(`${karinPathPlugins}/${v.name}/package.json`)) return;
10164
+ if (fs5.existsSync(`${karinPathPlugins}/${v.name}/package.json`)) return;
10395
10165
  list2.push(`app:${v.name}`);
10396
10166
  })
10397
10167
  );
@@ -10401,8 +10171,8 @@ var init_list = __esm({
10401
10171
  files.map(async (v) => {
10402
10172
  if (!v.isDirectory()) return;
10403
10173
  if (!v.name.startsWith("karin-plugin-")) return;
10404
- if (!fs7.existsSync(path5.join(karinPathPlugins, v.name, "package.json"))) return;
10405
- const pkg2 = await requireFile(path5.join(karinPathPlugins, v.name, "package.json"));
10174
+ if (!fs5.existsSync(path4.join(karinPathPlugins, v.name, "package.json"))) return;
10175
+ const pkg2 = await requireFile(path4.join(karinPathPlugins, v.name, "package.json"));
10406
10176
  if (pkg2?.karin?.engines?.karin && !satisfies(pkg2.karin.engines.karin, process.env.KARIN_VERSION)) {
10407
10177
  const msg = `[getPlugins][git] ${v.name} \u8981\u6C42 node-karin \u7248\u672C\u4E3A ${pkg2.karin.engines.karin}\uFF0C\u5F53\u524D\u4E0D\u7B26\u5408\u8981\u6C42\uFF0C\u8DF3\u8FC7\u52A0\u8F7D\u63D2\u4EF6`;
10408
10178
  isInit && setTimeout(() => logger.error(msg), 1e3);
@@ -10448,7 +10218,7 @@ var init_list = __esm({
10448
10218
  ].filter((name) => !NPM_EXCLUDE_LIST.includes(name) && !name.startsWith("@types"));
10449
10219
  await Promise.allSettled(
10450
10220
  dependencies.map(async (name) => {
10451
- const file = path5.join(process.cwd(), "node_modules", name, "package.json");
10221
+ const file = path4.join(process.cwd(), "node_modules", name, "package.json");
10452
10222
  const pkg3 = await requireFile(file);
10453
10223
  if (!pkg3.karin) return;
10454
10224
  if (pkg3.karin?.engines?.karin) {
@@ -10481,7 +10251,7 @@ var init_list = __esm({
10481
10251
  initCache();
10482
10252
  if (!["npm", "all", "git", "app"].includes(type)) return [];
10483
10253
  const list2 = [];
10484
- const files = type === "npm" ? [] : fs7.existsSync(karinPathPlugins) ? await fs7.promises.readdir(karinPathPlugins, { withFileTypes: true }) : [];
10254
+ const files = type === "npm" ? [] : fs5.existsSync(karinPathPlugins) ? await fs5.promises.readdir(karinPathPlugins, { withFileTypes: true }) : [];
10485
10255
  switch (type) {
10486
10256
  case "app":
10487
10257
  await collectAppPlugins(files, list2);
@@ -10645,8 +10415,8 @@ var init_update = __esm({
10645
10415
  checkGitPluginUpdate = async (filePath, time2 = 120) => {
10646
10416
  const logger3 = global?.logger || console;
10647
10417
  try {
10648
- if (!fs7.existsSync(filePath)) return { status: "error", data: new Error("\u8DEF\u5F84\u4E0D\u5B58\u5728") };
10649
- if (!fs7.existsSync(`${filePath}/.git`)) return { status: "error", data: new Error("\u8BE5\u8DEF\u5F84\u4E0D\u662F\u4E00\u4E2Agit\u4ED3\u5E93") };
10418
+ if (!fs5.existsSync(filePath)) return { status: "error", data: new Error("\u8DEF\u5F84\u4E0D\u5B58\u5728") };
10419
+ if (!fs5.existsSync(`${filePath}/.git`)) return { status: "error", data: new Error("\u8BE5\u8DEF\u5F84\u4E0D\u662F\u4E00\u4E2Agit\u4ED3\u5E93") };
10650
10420
  const timer = setTimeout(() => {
10651
10421
  return { status: "failed", data: "\u6267\u884C\u8D85\u65F6" };
10652
10422
  }, time2 * 1e3);
@@ -10670,11 +10440,11 @@ var init_update = __esm({
10670
10440
  }
10671
10441
  };
10672
10442
  getCommit = async (options) => {
10673
- const { path: path37, count: count3 = 1, hash, branch } = options;
10443
+ const { path: path36, count: count3 = 1, hash, branch } = options;
10674
10444
  let cmd = `git log -${count3} --format="[%ad]%s %n" --date="format:%m-%d %H:%M"`;
10675
10445
  if (hash) cmd = `git log ${hash}..HEAD --format="[%ad] %s %n" --date="format:%m-%d %H:%M"`;
10676
10446
  if (branch) cmd = `git log -${count3} ${branch} --format="[%ad] %s %n" --date="format:%m-%d %H:%M"`;
10677
- const { stdout, error } = await exec(cmd, { cwd: path37 });
10447
+ const { stdout, error } = await exec(cmd, { cwd: path36 });
10678
10448
  if (error) {
10679
10449
  throw error;
10680
10450
  }
@@ -10697,8 +10467,8 @@ var init_update = __esm({
10697
10467
  updateGitPlugin = async (filePath, cmd = "git pull", time2 = 120) => {
10698
10468
  const logger3 = global?.logger || console;
10699
10469
  try {
10700
- if (!fs7.existsSync(filePath)) return { status: "failed", data: "\u8DEF\u5F84\u4E0D\u5B58\u5728" };
10701
- if (!fs7.existsSync(`${filePath}/.git`)) return { status: "failed", data: "\u8BE5\u8DEF\u5F84\u4E0D\u662F\u4E00\u4E2Agit\u4ED3\u5E93" };
10470
+ if (!fs5.existsSync(filePath)) return { status: "failed", data: "\u8DEF\u5F84\u4E0D\u5B58\u5728" };
10471
+ if (!fs5.existsSync(`${filePath}/.git`)) return { status: "failed", data: "\u8BE5\u8DEF\u5F84\u4E0D\u662F\u4E00\u4E2Agit\u4ED3\u5E93" };
10702
10472
  const timer = setTimeout(() => {
10703
10473
  return { status: "failed", data: "\u6267\u884C\u8D85\u65F6" };
10704
10474
  }, time2 * 1e3);
@@ -10787,7 +10557,7 @@ var init_sqlite = __esm({
10787
10557
  * 初始化数据库连接和表结构
10788
10558
  */
10789
10559
  async init() {
10790
- mkdirSync(path5.dirname(this.dbPath));
10560
+ mkdirSync(path4.dirname(this.dbPath));
10791
10561
  await new Promise((resolve, reject) => {
10792
10562
  this.db = new sqlite3.Database(
10793
10563
  this.dbPath,
@@ -11131,7 +10901,7 @@ var init_sqlite2 = __esm({
11131
10901
  this.dbPath = dbPath2;
11132
10902
  }
11133
10903
  async _init() {
11134
- mkdirSync(path5.dirname(this.dbPath));
10904
+ mkdirSync(path4.dirname(this.dbPath));
11135
10905
  await new Promise((resolve, reject) => {
11136
10906
  this._db = new sqlite3.Database(
11137
10907
  this.dbPath,
@@ -11310,7 +11080,7 @@ var init_kv = __esm({
11310
11080
  if (initializingPromise) {
11311
11081
  return initializingPromise;
11312
11082
  }
11313
- initializingPromise = init(path5.join(kvPath, "kv.db")).then((result) => {
11083
+ initializingPromise = init(path4.join(kvPath, "kv.db")).then((result) => {
11314
11084
  initialized = true;
11315
11085
  initializingPromise = null;
11316
11086
  return result;
@@ -11395,7 +11165,7 @@ var init_handler2 = __esm({
11395
11165
  done = false;
11396
11166
  };
11397
11167
  const res = info.fnc(args, next);
11398
- result = util6.types.isPromise(res) ? await res : res;
11168
+ result = util5.types.isPromise(res) ? await res : res;
11399
11169
  if (done) {
11400
11170
  logger.mark(`[Handler][Done]: [${info.pkg.name}][${info.file.method}][${key}]`);
11401
11171
  return result;
@@ -11770,8 +11540,8 @@ var init_github = __esm({
11770
11540
  const urlObj = new URL$1(url);
11771
11541
  const owner = urlObj.pathname.split("/")[1];
11772
11542
  const repo = urlObj.pathname.split("/")[2];
11773
- const path37 = urlObj.pathname.split("/").slice(3).join("/");
11774
- return { owner, repo, path: path37 };
11543
+ const path36 = urlObj.pathname.split("/").slice(3).join("/");
11544
+ return { owner, repo, path: path36 };
11775
11545
  };
11776
11546
  getFastGithub = async (type) => {
11777
11547
  const list2 = [
@@ -11791,8 +11561,8 @@ var init_github = __esm({
11791
11561
  isClone: false,
11792
11562
  isRaw: true,
11793
11563
  raw: function(url) {
11794
- const { owner, repo, path: path37 } = parseGithubUrl(url);
11795
- return `${this.proxy}/${owner}/${repo}/${path37}`;
11564
+ const { owner, repo, path: path36 } = parseGithubUrl(url);
11565
+ return `${this.proxy}/${owner}/${repo}/${path36}`;
11796
11566
  },
11797
11567
  clone: function(url) {
11798
11568
  const { owner, repo } = parseGithubUrl(url);
@@ -11804,8 +11574,8 @@ var init_github = __esm({
11804
11574
  isClone: false,
11805
11575
  isRaw: true,
11806
11576
  raw: function(url) {
11807
- const { owner, repo, path: path37 } = parseGithubUrl(url);
11808
- return `${this.proxy}/${owner}/${repo}/${path37}`;
11577
+ const { owner, repo, path: path36 } = parseGithubUrl(url);
11578
+ return `${this.proxy}/${owner}/${repo}/${path36}`;
11809
11579
  },
11810
11580
  clone: function(url) {
11811
11581
  const { owner, repo } = parseGithubUrl(url);
@@ -11923,12 +11693,12 @@ var init_ini = __esm({
11923
11693
  });
11924
11694
 
11925
11695
  // src/utils/index.ts
11926
- var init_utils2 = __esm({
11696
+ var init_utils = __esm({
11927
11697
  "src/utils/index.ts"() {
11928
11698
  init_button();
11929
11699
  init_fs2();
11930
11700
  init_git();
11931
- init_logger3();
11701
+ init_logger2();
11932
11702
  init_system2();
11933
11703
  init_message2();
11934
11704
  init_request4();
@@ -11943,12 +11713,12 @@ var init_utils2 = __esm({
11943
11713
  var HttpAdapterOneBot11;
11944
11714
  var init_http = __esm({
11945
11715
  "src/adapter/onebot/connect/http.ts"() {
11946
- init_utils2();
11716
+ init_utils();
11947
11717
  init_base3();
11948
11718
  init_listeners();
11949
11719
  init_bot();
11950
11720
  init_convert();
11951
- init_types2();
11721
+ init_types();
11952
11722
  init_register();
11953
11723
  HttpAdapterOneBot11 = class extends AdapterOneBot {
11954
11724
  timer;
@@ -12282,7 +12052,7 @@ function requireDataStream() {
12282
12052
  hasRequiredDataStream = 1;
12283
12053
  var Buffer2 = requireSafeBuffer().Buffer;
12284
12054
  var Stream = require$$32;
12285
- var util7 = require$$5;
12055
+ var util6 = require$$5;
12286
12056
  function DataStream(data) {
12287
12057
  this.buffer = null;
12288
12058
  this.writable = true;
@@ -12308,7 +12078,7 @@ function requireDataStream() {
12308
12078
  }
12309
12079
  throw new TypeError("Unexpected data type (" + typeof data + ")");
12310
12080
  }
12311
- util7.inherits(DataStream, Stream);
12081
+ util6.inherits(DataStream, Stream);
12312
12082
  DataStream.prototype.write = function write2(data) {
12313
12083
  this.buffer = Buffer2.concat([this.buffer, Buffer2.from(data)]);
12314
12084
  this.emit("data", data);
@@ -12517,7 +12287,7 @@ function requireJwa() {
12517
12287
  var Buffer2 = requireSafeBuffer().Buffer;
12518
12288
  var crypto9 = require$$22;
12519
12289
  var formatEcdsa = requireEcdsaSigFormatter();
12520
- var util7 = require$$5;
12290
+ var util6 = require$$5;
12521
12291
  var MSG_INVALID_ALGORITHM = '"%s" is not a valid algorithm.\n Supported algorithms are:\n "HS256", "HS384", "HS512", "RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512" and "none".';
12522
12292
  var MSG_INVALID_SECRET = "secret must be a string or buffer";
12523
12293
  var MSG_INVALID_VERIFIER_KEY = "key must be a string or a buffer";
@@ -12597,7 +12367,7 @@ function requireJwa() {
12597
12367
  }
12598
12368
  function typeError(template2) {
12599
12369
  var args = [].slice.call(arguments, 1);
12600
- var errMsg = util7.format.bind(util7, template2).apply(null, args);
12370
+ var errMsg = util6.format.bind(util6, template2).apply(null, args);
12601
12371
  return new TypeError(errMsg);
12602
12372
  }
12603
12373
  function bufferOrString(obj) {
@@ -12743,7 +12513,7 @@ function requireSignStream() {
12743
12513
  var jwa2 = requireJwa();
12744
12514
  var Stream = require$$32;
12745
12515
  var toString = requireTostring();
12746
- var util7 = require$$5;
12516
+ var util6 = require$$5;
12747
12517
  function base64url(string, encoding) {
12748
12518
  return Buffer2.from(string, encoding).toString("base64").replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
12749
12519
  }
@@ -12751,7 +12521,7 @@ function requireSignStream() {
12751
12521
  encoding = encoding || "utf8";
12752
12522
  var encodedHeader = base64url(toString(header), "binary");
12753
12523
  var encodedPayload = base64url(toString(payload), encoding);
12754
- return util7.format("%s.%s", encodedHeader, encodedPayload);
12524
+ return util6.format("%s.%s", encodedHeader, encodedPayload);
12755
12525
  }
12756
12526
  function jwsSign(opts) {
12757
12527
  var header = opts.header;
@@ -12761,7 +12531,7 @@ function requireSignStream() {
12761
12531
  var algo = jwa2(header.alg);
12762
12532
  var securedInput = jwsSecuredInput(header, payload, encoding);
12763
12533
  var signature = algo.sign(securedInput, secretOrKey);
12764
- return util7.format("%s.%s", securedInput, signature);
12534
+ return util6.format("%s.%s", securedInput, signature);
12765
12535
  }
12766
12536
  function SignStream(opts) {
12767
12537
  var secret = opts.secret || opts.privateKey || opts.key;
@@ -12780,7 +12550,7 @@ function requireSignStream() {
12780
12550
  this.sign();
12781
12551
  }.bind(this));
12782
12552
  }
12783
- util7.inherits(SignStream, Stream);
12553
+ util6.inherits(SignStream, Stream);
12784
12554
  SignStream.prototype.sign = function sign2() {
12785
12555
  try {
12786
12556
  var signature = jwsSign({
@@ -12812,7 +12582,7 @@ function requireVerifyStream() {
12812
12582
  var jwa2 = requireJwa();
12813
12583
  var Stream = require$$32;
12814
12584
  var toString = requireTostring();
12815
- var util7 = require$$5;
12585
+ var util6 = require$$5;
12816
12586
  var JWS_REGEX = /^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/;
12817
12587
  function isObject(thing) {
12818
12588
  return Object.prototype.toString.call(thing) === "[object Object]";
@@ -12891,7 +12661,7 @@ function requireVerifyStream() {
12891
12661
  this.verify();
12892
12662
  }.bind(this));
12893
12663
  }
12894
- util7.inherits(VerifyStream, Stream);
12664
+ util6.inherits(VerifyStream, Stream);
12895
12665
  VerifyStream.prototype.verify = function verify2() {
12896
12666
  try {
12897
12667
  var valid2 = jwsVerify(this.signature.buffer, this.algorithm, this.key.buffer);
@@ -16152,7 +15922,7 @@ var init_env4 = __esm({
16152
15922
  };
16153
15923
  setEnv = (data) => {
16154
15924
  try {
16155
- const targetPath = path5.join(process.cwd(), process.env.EBV_FILE);
15925
+ const targetPath = path4.join(process.cwd(), process.env.EBV_FILE);
16156
15926
  const envConfig = getEnv(targetPath);
16157
15927
  Object.entries(data).forEach(([key, value]) => {
16158
15928
  envConfig[key] = {
@@ -16162,7 +15932,7 @@ var init_env4 = __esm({
16162
15932
  });
16163
15933
  const newContent = Object.entries(envConfig).map(([key, value]) => `${value.comment}
16164
15934
  ${key}="${value.value}"`).join("\n");
16165
- fs7.writeFileSync(targetPath, newContent);
15935
+ fs5.writeFileSync(targetPath, newContent);
16166
15936
  dotenv_default.config({ path: targetPath, override: true });
16167
15937
  return true;
16168
15938
  } catch (error) {
@@ -16170,12 +15940,12 @@ ${key}="${value.value}"`).join("\n");
16170
15940
  return false;
16171
15941
  }
16172
15942
  };
16173
- getEnv = (filePath = path5.join(process.cwd(), process.env.EBV_FILE)) => {
15943
+ getEnv = (filePath = path4.join(process.cwd(), process.env.EBV_FILE)) => {
16174
15944
  const data = requireFileSync(filePath, { parser });
16175
15945
  return data;
16176
15946
  };
16177
15947
  env = () => {
16178
- const data = getEnv(path5.join(process.cwd(), process.env.EBV_FILE));
15948
+ const data = getEnv(path4.join(process.cwd(), process.env.EBV_FILE));
16179
15949
  const env3 = {};
16180
15950
  Object.entries(data).forEach(([key, value]) => {
16181
15951
  env3[key] = value.value;
@@ -16183,7 +15953,7 @@ ${key}="${value.value}"`).join("\n");
16183
15953
  return env3;
16184
15954
  };
16185
15955
  writeEnv = (data, cwd, isCover = false) => {
16186
- if (!cwd) cwd = path5.join(process.cwd(), process.env.EBV_FILE);
15956
+ if (!cwd) cwd = path4.join(process.cwd(), process.env.EBV_FILE);
16187
15957
  const env3 = getEnv(cwd);
16188
15958
  const result = { ...env3 };
16189
15959
  if (!Array.isArray(data)) data = [data];
@@ -16213,7 +15983,7 @@ ${key}=${val}`;
16213
15983
  }
16214
15984
  return `${key}=${val}`;
16215
15985
  }).join("\n");
16216
- fs7.writeFileSync(cwd, content);
15986
+ fs5.writeFileSync(cwd, content);
16217
15987
  dotenv_default.config({ path: cwd, override: true });
16218
15988
  };
16219
15989
  env_default = initEnv;
@@ -16237,7 +16007,7 @@ var init_admin = __esm({
16237
16007
  init_require();
16238
16008
  getYaml = (name, type, isRefresh) => {
16239
16009
  const file = `${type === "user" ? configPath : defaultConfigPath}/${name}.json`;
16240
- if (!fs7.existsSync(file)) {
16010
+ if (!fs5.existsSync(file)) {
16241
16011
  throw new TypeError(`${file} \u6587\u4EF6\u4E0D\u5B58\u5728`);
16242
16012
  }
16243
16013
  return requireFileSync(file, { force: isRefresh });
@@ -16245,17 +16015,17 @@ var init_admin = __esm({
16245
16015
  setYaml = (name, data) => {
16246
16016
  if (name === "env") return setEnv(data);
16247
16017
  const file = `${configPath}/${name}.json`;
16248
- if (!fs7.existsSync(file)) return false;
16249
- fs7.writeFileSync(file, JSON.stringify(data, null, 2));
16018
+ if (!fs5.existsSync(file)) return false;
16019
+ fs5.writeFileSync(file, JSON.stringify(data, null, 2));
16250
16020
  return true;
16251
16021
  };
16252
16022
  setConfig = (name, data) => {
16253
16023
  return setYaml(name, data);
16254
16024
  };
16255
16025
  clearFiles = (dir2) => {
16256
- const list2 = fs7.readdirSync(dir2);
16026
+ const list2 = fs5.readdirSync(dir2);
16257
16027
  list2.forEach((file) => {
16258
- fs7.promises.rm(file, { recursive: true, force: true });
16028
+ fs5.promises.rm(file, { recursive: true, force: true });
16259
16029
  });
16260
16030
  };
16261
16031
  updateLevel = (level) => {
@@ -16323,7 +16093,7 @@ var init_config = __esm({
16323
16093
  init_default();
16324
16094
  init_admin();
16325
16095
  init_pkg();
16326
- init_file3();
16096
+ init_file2();
16327
16097
  }
16328
16098
  });
16329
16099
 
@@ -16549,7 +16319,7 @@ var init_common = __esm({
16549
16319
  init_string();
16550
16320
  init_sleep();
16551
16321
  init_uptime();
16552
- init_file2();
16322
+ init_file();
16553
16323
  init_fsSync();
16554
16324
  init_data();
16555
16325
  init_path();
@@ -16598,13 +16368,13 @@ var init_common = __esm({
16598
16368
  getGitPlugins = async (isPack = false) => getPlugins("git", isPack);
16599
16369
  mergeImage = async (images, perRow = 3) => {
16600
16370
  if (images.length < 2) throw Error("\u56FE\u7247\u6570\u91CF\u5FC5\u987B\u5927\u4E8E1");
16601
- const root2 = path5.join(tempPath, "mergeImage");
16602
- const rootTemp = path5.join(root2, Date.now().toString());
16603
- fs7.mkdirSync(rootTemp, { recursive: true });
16371
+ const root2 = path4.join(tempPath, "mergeImage");
16372
+ const rootTemp = path4.join(root2, Date.now().toString());
16373
+ fs5.mkdirSync(rootTemp, { recursive: true });
16604
16374
  const files = getAbsPath(images, rootTemp);
16605
16375
  const filterComplex = await buildFilterComplex(files, perRow);
16606
16376
  const inputImages = files.map((file) => `-i "${file}"`).join(" ");
16607
- const output = path5.join(rootTemp, "output.png");
16377
+ const output = path4.join(rootTemp, "output.png");
16608
16378
  const ffmpegCmd = `${inputImages} -filter_complex "${filterComplex}" -map "[out]" ${output}`;
16609
16379
  const result = await ffmpeg(ffmpegCmd);
16610
16380
  if (!result.status) {
@@ -16612,8 +16382,8 @@ var init_common = __esm({
16612
16382
  throw result.error;
16613
16383
  }
16614
16384
  const { height, width } = await getImageSize(output);
16615
- const base642 = await fs7.promises.readFile(output, "base64");
16616
- setTimeout(() => fs7.promises.rm(rootTemp, { recursive: true, force: true }), 100);
16385
+ const base642 = await fs5.promises.readFile(output, "base64");
16386
+ setTimeout(() => fs5.promises.rm(rootTemp, { recursive: true, force: true }), 100);
16617
16387
  return { base64: base642, height, width };
16618
16388
  };
16619
16389
  getAbsPath = (images, root2) => {
@@ -16623,14 +16393,14 @@ var init_common = __esm({
16623
16393
  if (image2.startsWith("base64://")) {
16624
16394
  const base642 = image2.replace(/^base64:\/\//, "");
16625
16395
  const buffer2 = Buffer.from(base642, "base64");
16626
- const file2 = path5.join(root2, `${index6}.png`);
16627
- fs7.writeFileSync(file2, buffer2);
16396
+ const file2 = path4.join(root2, `${index6}.png`);
16397
+ fs5.writeFileSync(file2, buffer2);
16628
16398
  files.push(file2);
16629
16399
  return;
16630
16400
  }
16631
- if (!fs7.existsSync(image2)) throw Error(`\u56FE\u7247\u8DEF\u5F84\u4E0D\u5B58\u5728: ${image2}`);
16632
- const file = path5.join(root2, path5.basename(image2));
16633
- fs7.copyFileSync(image2, file);
16401
+ if (!fs5.existsSync(image2)) throw Error(`\u56FE\u7247\u8DEF\u5F84\u4E0D\u5B58\u5728: ${image2}`);
16402
+ const file = path4.join(root2, path4.basename(image2));
16403
+ fs5.copyFileSync(image2, file);
16634
16404
  files.push(file);
16635
16405
  });
16636
16406
  return files;
@@ -16967,7 +16737,7 @@ var init_groups4 = __esm({
16967
16737
  Object.entries(data).forEach(([key, value]) => {
16968
16738
  list2.push({ key, ...value });
16969
16739
  });
16970
- fs7.writeFileSync(file, JSON.stringify(list2, null, 2));
16740
+ fs5.writeFileSync(file, JSON.stringify(list2, null, 2));
16971
16741
  logger.mark("[migrate] \u8FC1\u79FB groups.json \u914D\u7F6E\u6587\u4EF6\u6210\u529F");
16972
16742
  return format2(list2);
16973
16743
  };
@@ -17088,7 +16858,7 @@ var init_privates = __esm({
17088
16858
  Object.entries(data).forEach(([key, value]) => {
17089
16859
  list2.push({ key, ...value });
17090
16860
  });
17091
- fs7.writeFileSync(file, JSON.stringify(list2, null, 2));
16861
+ fs5.writeFileSync(file, JSON.stringify(list2, null, 2));
17092
16862
  logger.mark("[migrate] \u8FC1\u79FB privates.json \u914D\u7F6E\u6587\u4EF6\u6210\u529F");
17093
16863
  return format3(list2);
17094
16864
  };
@@ -17263,29 +17033,29 @@ var init_template = __esm({
17263
17033
  "src/adapter/render/admin/template.ts"() {
17264
17034
  init_root();
17265
17035
  init_fsSync();
17266
- init_file2();
17036
+ init_file();
17267
17037
  renderTpl = (options) => {
17268
17038
  if (typeof options.file !== "string") {
17269
17039
  throw TypeError("\u6A21\u677F\u6587\u4EF6\u8DEF\u5F84\u5FC5\u987B\u4E3A\u5B57\u7B26\u4E32");
17270
17040
  }
17271
17041
  if (!options.name) {
17272
- options.name = path5.basename(options.file) || "render";
17042
+ options.name = path4.basename(options.file) || "render";
17273
17043
  }
17274
17044
  if (options.data) {
17275
17045
  if (options.file.startsWith("http")) {
17276
17046
  throw TypeError("\u4ED6\u55B5\u7684 \u4E0D\u4F1A\u771F\u7684\u6709\u7B28\u6BD4\u4F20\u4E2Ahttp\u6765\u5F53\u505A\u6A21\u677F\u5427...");
17277
17047
  }
17278
- const file = path5.resolve(options.file);
17279
- const tplData = fs7.readFileSync(file, "utf-8");
17048
+ const file = path4.resolve(options.file);
17049
+ const tplData = fs5.readFileSync(file, "utf-8");
17280
17050
  const renderData = template.render(tplData, options.data);
17281
17051
  const outputPath = getOutputPath(options.file, renderData, options.name);
17282
- fs7.writeFileSync(outputPath, renderData);
17052
+ fs5.writeFileSync(outputPath, renderData);
17283
17053
  delete options.data;
17284
17054
  options.file = `file://${outputPath}`;
17285
17055
  return options;
17286
17056
  }
17287
17057
  if (!options.file.startsWith("http") && !options.file.startsWith("file")) {
17288
- options.file = `file://${path5.resolve(options.file)}`;
17058
+ options.file = `file://${path4.resolve(options.file)}`;
17289
17059
  }
17290
17060
  delete options.data;
17291
17061
  return options;
@@ -17299,44 +17069,44 @@ var init_template = __esm({
17299
17069
  delete options.name;
17300
17070
  }
17301
17071
  if (!options.file_name) {
17302
- options.file_name = path5.basename(options.file) || "render";
17072
+ options.file_name = path4.basename(options.file) || "render";
17303
17073
  }
17304
17074
  if (options.data) {
17305
17075
  if (options.file.startsWith("http")) {
17306
17076
  throw TypeError("\u4ED6\u55B5\u7684 \u4E0D\u4F1A\u771F\u7684\u6709\u7B28\u6BD4\u4F20\u4E2Ahttp\u6765\u5F53\u505A\u6A21\u677F\u5427...");
17307
17077
  }
17308
- const file = path5.resolve(options.file);
17309
- const tplData = fs7.readFileSync(file, "utf-8");
17078
+ const file = path4.resolve(options.file);
17079
+ const tplData = fs5.readFileSync(file, "utf-8");
17310
17080
  const renderData = template.render(tplData, options.data);
17311
17081
  const outputPath = getOutputPath(options.file, renderData, options.file_name);
17312
- fs7.writeFileSync(outputPath, renderData);
17082
+ fs5.writeFileSync(outputPath, renderData);
17313
17083
  delete options.data;
17314
17084
  options.file = `file://${outputPath}`;
17315
17085
  return options;
17316
17086
  }
17317
17087
  if (!options.file.startsWith("http") && !options.file.startsWith("file")) {
17318
- options.file = `file://${path5.resolve(options.file)}`;
17088
+ options.file = `file://${path4.resolve(options.file)}`;
17319
17089
  }
17320
17090
  delete options.data;
17321
17091
  return options;
17322
17092
  };
17323
17093
  getOutputPath = (file, data, name) => {
17324
- const extname = path5.extname(file);
17325
- const basename = path5.basename(file, extname);
17326
- const fileDir = path5.join(htmlPath, name || "render");
17094
+ const extname = path4.extname(file);
17095
+ const basename = path4.basename(file, extname);
17096
+ const fileDir = path4.join(htmlPath, name || "render");
17327
17097
  mkdirSync(fileDir);
17328
17098
  const contentHash = crypto.createHash("md5").update(data).digest("hex").substring(0, 8);
17329
- const filePath = path5.join(fileDir, `${basename}-${contentHash}${extname}`);
17330
- if (fs7.existsSync(filePath)) {
17099
+ const filePath = path4.join(fileDir, `${basename}-${contentHash}${extname}`);
17100
+ if (fs5.existsSync(filePath)) {
17331
17101
  const now = /* @__PURE__ */ new Date();
17332
17102
  try {
17333
- fs7.utimesSync(filePath, now, now);
17103
+ fs5.utimesSync(filePath, now, now);
17334
17104
  } catch (err) {
17335
17105
  logger.error(`[\u6587\u4EF6\u66F4\u65B0] \u66F4\u65B0\u6587\u4EF6\u65F6\u51FA\u9519: ${filePath}, ${err}`);
17336
17106
  }
17337
17107
  return filePath;
17338
17108
  }
17339
- fs7.writeFileSync(filePath, data);
17109
+ fs5.writeFileSync(filePath, data);
17340
17110
  return filePath;
17341
17111
  };
17342
17112
  cleanExpiredFiles = async () => {
@@ -17347,10 +17117,10 @@ var init_template = __esm({
17347
17117
  const EXPIRE_TIME = 10 * 60 * 1e3;
17348
17118
  for (const file of files) {
17349
17119
  try {
17350
- const stats = await fs7.promises.stat(file);
17120
+ const stats = await fs5.promises.stat(file);
17351
17121
  const lastModified = stats.mtimeMs;
17352
17122
  if (now - lastModified > EXPIRE_TIME) {
17353
- await fs7.promises.unlink(file);
17123
+ await fs5.promises.unlink(file);
17354
17124
  count3++;
17355
17125
  }
17356
17126
  } catch (err) {
@@ -17563,7 +17333,7 @@ var init_client2 = __esm({
17563
17333
  onMessage = async (client, url, event, authorization) => {
17564
17334
  const raw2 = event.toString();
17565
17335
  const options = JSON.parse(raw2);
17566
- logger.debug(`${PREFIX}\u6536\u5230\u6D88\u606F: ${lodash4.truncate(raw2, { length: 300 })}`);
17336
+ logger.debug(`${PREFIX}\u6536\u5230\u6D88\u606F: ${lodash3.truncate(raw2, { length: 300 })}`);
17567
17337
  if (options.type === "response") {
17568
17338
  const key = createWsResponseKey(options.echo);
17569
17339
  return listeners.emit(key, options);
@@ -17593,7 +17363,7 @@ var init_client2 = __esm({
17593
17363
  target.toString(),
17594
17364
  {
17595
17365
  echo: options.echo,
17596
- file: `base64://${fs7.readFileSync(file, "base64")}`
17366
+ file: `base64://${fs5.readFileSync(file, "base64")}`
17597
17367
  },
17598
17368
  {
17599
17369
  headers: {
@@ -17707,7 +17477,7 @@ var init_http2 = __esm({
17707
17477
  createSnapkaHttp = async (options) => {
17708
17478
  if (!options.isSnapka || !options.enable) return;
17709
17479
  const authorization = `Bearer ${crypto.createHash("sha256").update(options.token).digest("hex")}`;
17710
- const url = path5.dirname(options.url) + `/ping?token=${authorization}`;
17480
+ const url = path4.dirname(options.url) + `/ping?token=${authorization}`;
17711
17481
  const test = async () => {
17712
17482
  try {
17713
17483
  const result = await axios9.get(url);
@@ -17887,7 +17657,7 @@ var init_redis2 = __esm({
17887
17657
 
17888
17658
  // src/utils/config/file/index.ts
17889
17659
  var initConfigCache;
17890
- var init_file3 = __esm({
17660
+ var init_file2 = __esm({
17891
17661
  "src/utils/config/file/index.ts"() {
17892
17662
  init_adapter();
17893
17663
  init_config2();
@@ -18024,35 +17794,35 @@ var init_check = __esm({
18024
17794
  headers: { Authorization: `Bearer ${process.env.HTTP_AUTH_KEY}` },
18025
17795
  validateStatus: () => true
18026
17796
  });
18027
- request = async (url, path37, method, timeout2, isPrint = true) => {
17797
+ request = async (url, path36, method, timeout2, isPrint = true) => {
18028
17798
  const client = createHttpClient(url, timeout2);
18029
17799
  try {
18030
- const result = await client[method](path37);
18031
- return handleResponse(result, method, path37, isPrint);
17800
+ const result = await client[method](path36);
17801
+ return handleResponse(result, method, path36, isPrint);
18032
17802
  } catch (error) {
18033
17803
  logger.debug(
18034
- tips(`${method.toUpperCase()} \u8BF7\u6C42\u5F02\u5E38:`, true) + ` ${path37} - ${error?.message || "\u672A\u77E5\u9519\u8BEF"}`
17804
+ tips(`${method.toUpperCase()} \u8BF7\u6C42\u5F02\u5E38:`, true) + ` ${path36} - ${error?.message || "\u672A\u77E5\u9519\u8BEF"}`
18035
17805
  );
18036
17806
  return { code: 500, success: false };
18037
17807
  }
18038
17808
  };
18039
- handleResponse = (result, method, path37, isPrint) => {
17809
+ handleResponse = (result, method, path36, isPrint) => {
18040
17810
  if (result.status === 200) {
18041
17811
  isPrint && logger.info(
18042
- tips(`${method.toUpperCase()} \u8BF7\u6C42\u6210\u529F:`, true) + ` ${path37} -> ${JSON.stringify(result.data)}`
17812
+ tips(`${method.toUpperCase()} \u8BF7\u6C42\u6210\u529F:`, true) + ` ${path36} -> ${JSON.stringify(result.data)}`
18043
17813
  );
18044
17814
  return { code: result.status, success: true, data: result.data };
18045
17815
  }
18046
17816
  if (result.status === 401) {
18047
17817
  logger.error(
18048
- tips(`${method.toUpperCase()} \u9274\u6743\u5931\u8D25:`, true) + ` ${path37} -> ${JSON.stringify(result.data)}`
17818
+ tips(`${method.toUpperCase()} \u9274\u6743\u5931\u8D25:`, true) + ` ${path36} -> ${JSON.stringify(result.data)}`
18049
17819
  );
18050
17820
  return { code: result.status, success: false };
18051
17821
  }
18052
- const logMethod = path37 === "/ping" ? logger.debug : logger.error;
17822
+ const logMethod = path36 === "/ping" ? logger.debug : logger.error;
18053
17823
  logMethod.call(
18054
17824
  logger,
18055
- tips(`${method.toUpperCase()} \u8BF7\u6C42\u5931\u8D25:`, true) + ` ${path37} -> ${JSON.stringify(result.data)}`
17825
+ tips(`${method.toUpperCase()} \u8BF7\u6C42\u5931\u8D25:`, true) + ` ${path36} -> ${JSON.stringify(result.data)}`
18056
17826
  );
18057
17827
  return { code: result.status, success: false };
18058
17828
  };
@@ -18358,7 +18128,7 @@ var init_mock = __esm({
18358
18128
  } else if (Buffer.isBuffer(value)) {
18359
18129
  value = value.toString();
18360
18130
  }
18361
- if (lodash4.isEmpty(options)) {
18131
+ if (lodash3.isEmpty(options)) {
18362
18132
  this.store[key] = { type: "str" /* STR */, expire };
18363
18133
  this.#str[key] = value;
18364
18134
  this.#sqlite.set(key, value, "str" /* STR */, expire);
@@ -18614,7 +18384,7 @@ var init_mock = __esm({
18614
18384
  async hGetAll(key) {
18615
18385
  if (!this.#hash[key]) return {};
18616
18386
  if (this.checkExpire(key)) return {};
18617
- return lodash4.mapValues(this.#hash[key], (value) => value.toString());
18387
+ return lodash3.mapValues(this.#hash[key], (value) => value.toString());
18618
18388
  }
18619
18389
  /**
18620
18390
  * 将一个或多个值插入到列表的头部
@@ -19450,7 +19220,7 @@ var init_redis3 = __esm({
19450
19220
  return "";
19451
19221
  };
19452
19222
  mock = async () => {
19453
- const sqlite = await new SQLiteWrapper(path5.join(redisSqlite3Path, "redis.db")).init();
19223
+ const sqlite = await new SQLiteWrapper(path4.join(redisSqlite3Path, "redis.db")).init();
19454
19224
  const redis3 = await new RedisClient(sqlite).init();
19455
19225
  Object.defineProperty(redis3, "id", { value: "mock" });
19456
19226
  return redis3;
@@ -19536,10 +19306,10 @@ var init_load = __esm({
19536
19306
  "src/plugin/admin/load.ts"() {
19537
19307
  init_env2();
19538
19308
  init_cache();
19539
- init_utils2();
19309
+ init_utils();
19540
19310
  init_tools2();
19541
19311
  init_class();
19542
- init_file2();
19312
+ init_file();
19543
19313
  init_import();
19544
19314
  init_internal();
19545
19315
  init_list();
@@ -19571,16 +19341,16 @@ var init_load = __esm({
19571
19341
  }
19572
19342
  if (pkg2.type !== "app" && pkg2?.pkgData?.karin?.static) {
19573
19343
  const list2 = Array.isArray(pkg2.pkgData.karin.static) ? pkg2.pkgData.karin.static : [pkg2.pkgData.karin.static];
19574
- cache3.static.push(...list2.map((file) => path5.resolve(pkg2.dir, file)));
19344
+ cache3.static.push(...list2.map((file) => path4.resolve(pkg2.dir, file)));
19575
19345
  } else {
19576
- cache3.static.push(path5.resolve(pkg2.dir, "resource"));
19577
- cache3.static.push(path5.resolve(pkg2.dir, "resources"));
19346
+ cache3.static.push(path4.resolve(pkg2.dir, "resource"));
19347
+ cache3.static.push(path4.resolve(pkg2.dir, "resources"));
19578
19348
  }
19579
19349
  };
19580
19350
  loadMainFile = async (entryPromises, pkg2, dir2) => {
19581
19351
  if (!dir2) return;
19582
- const file = path5.join(pkg2.dir, dir2);
19583
- if (fs7.existsSync(file)) {
19352
+ const file = path4.join(pkg2.dir, dir2);
19353
+ if (fs5.existsSync(file)) {
19584
19354
  entryPromises.push(pkgLoadModule(pkg2.name, file));
19585
19355
  }
19586
19356
  };
@@ -19629,7 +19399,7 @@ var init_load = __esm({
19629
19399
  try {
19630
19400
  val.log(`[\u5B9A\u65F6\u4EFB\u52A1][${val.name}][${val.cron}]: \u5F00\u59CB\u6267\u884C`);
19631
19401
  const result2 = val.fnc();
19632
- if (util6.types.isPromise(result2)) await result2;
19402
+ if (util5.types.isPromise(result2)) await result2;
19633
19403
  val.log(`[\u5B9A\u65F6\u4EFB\u52A1][${val.name}][${val.cron}]: \u6267\u884C\u5B8C\u6210`);
19634
19404
  } catch (error) {
19635
19405
  errorHandler.taskStart(val.name, val.name, error);
@@ -19656,10 +19426,10 @@ var init_load = __esm({
19656
19426
  return {
19657
19427
  absPath: app4,
19658
19428
  get dirname() {
19659
- return path5.dirname(this.absPath);
19429
+ return path4.dirname(this.absPath);
19660
19430
  },
19661
19431
  get basename() {
19662
- return path5.basename(this.absPath);
19432
+ return path4.basename(this.absPath);
19663
19433
  },
19664
19434
  type,
19665
19435
  method,
@@ -19703,16 +19473,16 @@ var init_load = __esm({
19703
19473
  * - 例如karin-plugin-example文件夹为空 则需要判断pkg是否为app类型
19704
19474
  * - 并且文件是否处于karin-plugin-example文件夹下
19705
19475
  */
19706
- pkg2.type === "app" && path5.normalize(file).startsWith(path5.normalize(pkg2.dir))
19476
+ pkg2.type === "app" && path4.normalize(file).startsWith(path4.normalize(pkg2.dir))
19707
19477
  ) || null;
19708
19478
  };
19709
19479
  pkgSort = () => {
19710
- cache3.accept = lodash4.sortBy(cache3.accept, ["rank"], ["asc"]);
19711
- cache3.command = lodash4.sortBy(cache3.command, ["rank"], ["asc"]);
19712
- cache3.task = lodash4.sortBy(cache3.task, ["rank"], ["asc"]);
19713
- cache3.button = lodash4.sortBy(cache3.button, ["rank"], ["asc"]);
19480
+ cache3.accept = lodash3.sortBy(cache3.accept, ["rank"], ["asc"]);
19481
+ cache3.command = lodash3.sortBy(cache3.command, ["rank"], ["asc"]);
19482
+ cache3.task = lodash3.sortBy(cache3.task, ["rank"], ["asc"]);
19483
+ cache3.button = lodash3.sortBy(cache3.button, ["rank"], ["asc"]);
19714
19484
  for (const key of Object.keys(cache3.handler)) {
19715
- cache3.handler[key] = lodash4.sortBy(cache3.handler[key], ["rank"], ["asc"]);
19485
+ cache3.handler[key] = lodash3.sortBy(cache3.handler[key], ["rank"], ["asc"]);
19716
19486
  }
19717
19487
  };
19718
19488
  pkgHotReload = async (type, name) => {
@@ -19863,7 +19633,7 @@ var init_ws2 = __esm({
19863
19633
  logger.warn(`[WebSocket] \u8BBF\u95EE\u7684\u8DEF\u5F84\u975E\u6CD5: echo: ${echo} data: ${JSON.stringify(data)}`);
19864
19634
  return this.socket.send(JSON.stringify({ echo, status: "error", data: "\u975E\u6CD5\u7684\u8BBF\u95EE\u8DEF\u5F84" }));
19865
19635
  }
19866
- const fileData = fs7.readFileSync(data.file);
19636
+ const fileData = fs5.readFileSync(data.file);
19867
19637
  return this.socket.send(JSON.stringify({ echo, status: "ok", data: fileData }));
19868
19638
  }
19869
19639
  render(data) {
@@ -20044,7 +19814,7 @@ var getMimeType, getMimeType_default;
20044
19814
  var init_getMimeType = __esm({
20045
19815
  "src/server/utils/getMimeType.ts"() {
20046
19816
  getMimeType = (filePath) => {
20047
- const ext = path5.extname(filePath).toLowerCase();
19817
+ const ext = path4.extname(filePath).toLowerCase();
20048
19818
  switch (ext) {
20049
19819
  case ".js":
20050
19820
  return "application/javascript";
@@ -20477,7 +20247,7 @@ var init_config4 = __esm({
20477
20247
  init_response();
20478
20248
  fileExists = (filepath) => {
20479
20249
  try {
20480
- return fs7.existsSync(filepath);
20250
+ return fs5.existsSync(filepath);
20481
20251
  } catch (error) {
20482
20252
  return false;
20483
20253
  }
@@ -20486,7 +20256,7 @@ var init_config4 = __esm({
20486
20256
  if (!pkg2.karin) return null;
20487
20257
  if (baseDir.includes("node_modules")) {
20488
20258
  if (pkg2.karin.web) {
20489
- const configPath3 = path5.join(baseDir, pkg2.karin.web);
20259
+ const configPath3 = path4.join(baseDir, pkg2.karin.web);
20490
20260
  return fileExists(configPath3) ? configPath3 : null;
20491
20261
  }
20492
20262
  return null;
@@ -20494,21 +20264,21 @@ var init_config4 = __esm({
20494
20264
  let configPath2 = null;
20495
20265
  if (isTs()) {
20496
20266
  if (pkg2.karin["ts-web"]) {
20497
- configPath2 = path5.join(baseDir, pkg2.karin["ts-web"]);
20267
+ configPath2 = path4.join(baseDir, pkg2.karin["ts-web"]);
20498
20268
  if (fileExists(configPath2)) return configPath2;
20499
20269
  }
20500
20270
  }
20501
20271
  if (pkg2.karin.web) {
20502
- configPath2 = path5.join(baseDir, pkg2.karin.web);
20272
+ configPath2 = path4.join(baseDir, pkg2.karin.web);
20503
20273
  if (fileExists(configPath2)) return configPath2;
20504
20274
  }
20505
20275
  return null;
20506
20276
  };
20507
20277
  getNpmPluginConfigPath = (name) => {
20508
- const dir2 = path5.join(process.cwd(), "node_modules", name);
20278
+ const dir2 = path4.join(process.cwd(), "node_modules", name);
20509
20279
  if (fileExists(dir2)) {
20510
20280
  try {
20511
- const pkgPath = path5.join(dir2, "package.json");
20281
+ const pkgPath = path4.join(dir2, "package.json");
20512
20282
  if (fileExists(pkgPath)) {
20513
20283
  const pkg2 = requireFileSync(pkgPath);
20514
20284
  const configPath2 = getWebConfigPathFromPkg(pkg2, dir2);
@@ -20520,7 +20290,7 @@ var init_config4 = __esm({
20520
20290
  }
20521
20291
  if (isDev()) {
20522
20292
  try {
20523
- const rootPkgPath = path5.join(process.cwd(), "package.json");
20293
+ const rootPkgPath = path4.join(process.cwd(), "package.json");
20524
20294
  if (fileExists(rootPkgPath)) {
20525
20295
  const pkg2 = requireFileSync(rootPkgPath);
20526
20296
  if (pkg2?.name === name) {
@@ -20534,10 +20304,10 @@ var init_config4 = __esm({
20534
20304
  return null;
20535
20305
  };
20536
20306
  getLocalPluginConfigPath = (name) => {
20537
- const pluginDir2 = path5.join(process.cwd(), "plugins", name);
20307
+ const pluginDir2 = path4.join(process.cwd(), "plugins", name);
20538
20308
  if (fileExists(pluginDir2)) {
20539
20309
  try {
20540
- const pkgPath = path5.join(pluginDir2, "package.json");
20310
+ const pkgPath = path4.join(pluginDir2, "package.json");
20541
20311
  if (fileExists(pkgPath)) {
20542
20312
  const pkg2 = requireFileSync(pkgPath);
20543
20313
  const configPath2 = getWebConfigPathFromPkg(pkg2, pluginDir2);
@@ -20548,7 +20318,7 @@ var init_config4 = __esm({
20548
20318
  }
20549
20319
  }
20550
20320
  try {
20551
- const pkgPath = path5.join(process.cwd(), "package.json");
20321
+ const pkgPath = path4.join(process.cwd(), "package.json");
20552
20322
  if (fileExists(pkgPath)) {
20553
20323
  const pkg2 = requireFileSync(pkgPath);
20554
20324
  return getWebConfigPathFromPkg(pkg2, process.cwd());
@@ -20589,7 +20359,7 @@ var init_config4 = __esm({
20589
20359
  if (!webConfig) {
20590
20360
  return null;
20591
20361
  }
20592
- const baseName = path5.basename(webConfig, path5.extname(webConfig));
20362
+ const baseName = path4.basename(webConfig, path4.extname(webConfig));
20593
20363
  if (baseName !== "web.config") {
20594
20364
  return null;
20595
20365
  }
@@ -20597,14 +20367,14 @@ var init_config4 = __esm({
20597
20367
  if (!result.info.version || !result.info.description) {
20598
20368
  let dir2 = "";
20599
20369
  if (type === "npm") {
20600
- dir2 = path5.join(process.cwd(), "node_modules", id);
20370
+ dir2 = path4.join(process.cwd(), "node_modules", id);
20601
20371
  } else {
20602
- dir2 = path5.join(process.cwd(), "plugins", id);
20603
- if (!fs7.existsSync(dir2)) {
20372
+ dir2 = path4.join(process.cwd(), "plugins", id);
20373
+ if (!fs5.existsSync(dir2)) {
20604
20374
  dir2 = process.cwd();
20605
20375
  }
20606
20376
  }
20607
- const pkg2 = requireFileSync(path5.join(dir2, "package.json"));
20377
+ const pkg2 = requireFileSync(path4.join(dir2, "package.json"));
20608
20378
  if (!pkg2 || pkg2.name !== id) {
20609
20379
  if (!result.info.version) result.info.version = "";
20610
20380
  if (!result.info.description) result.info.description = "";
@@ -20639,7 +20409,7 @@ var init_config4 = __esm({
20639
20409
  }
20640
20410
  const list2 = [];
20641
20411
  let result = config3.components();
20642
- result = util6.types.isPromise(result) ? await result : result;
20412
+ result = util5.types.isPromise(result) ? await result : result;
20643
20413
  result.forEach((item) => {
20644
20414
  if (typeof item?.toJSON === "function") {
20645
20415
  list2.push(item.toJSON());
@@ -20664,7 +20434,7 @@ var init_config4 = __esm({
20664
20434
  if (!configPath2) return createServerErrorResponse(res, "\u53C2\u6570\u9519\u8BEF");
20665
20435
  const { save: save2 } = await loadConfig(configPath2);
20666
20436
  const result = save2(options.config);
20667
- const response = util6.types.isPromise(result) ? await result : result;
20437
+ const response = util5.types.isPromise(result) ? await result : result;
20668
20438
  createSuccessResponse(res, response || { success: true, message: "\u6CA1\u6709\u8FD4\u56DE\u503C\u54E6 \u03C6(>\u03C9<*) " });
20669
20439
  };
20670
20440
  pluginIsConfigExist = async (req, res) => {
@@ -20759,7 +20529,7 @@ var init_console = __esm({
20759
20529
  if (url.includes("..") || url.includes("~") || !url.match(/^[a-zA-Z0-9-_.]+$/)) {
20760
20530
  return createForbiddenResponse(res, "\u975E\u6CD5\u8BF7\u6C42");
20761
20531
  }
20762
- const ext = path5.extname(url).toLowerCase();
20532
+ const ext = path4.extname(url).toLowerCase();
20763
20533
  if (!ALLOWED_TYPES[ext]) {
20764
20534
  return createBadRequestResponse(res, "\u4E0D\u652F\u6301\u7684\u6587\u4EF6\u7C7B\u578B");
20765
20535
  }
@@ -20777,7 +20547,7 @@ var init_console = __esm({
20777
20547
  return createForbiddenResponse(res, "\u65E0\u6548\u7684 token");
20778
20548
  }
20779
20549
  }
20780
- const file = path5.join(consolePath, url);
20550
+ const file = path4.join(consolePath, url);
20781
20551
  try {
20782
20552
  if (!file.startsWith(consolePath)) {
20783
20553
  return createForbiddenResponse(res, "\u975E\u6CD5\u8BF7\u6C42");
@@ -20988,7 +20758,7 @@ var init_getLog = __esm({
20988
20758
  if (!date.isValid()) {
20989
20759
  return createBadRequestResponse(res, "\u65E5\u671F\u683C\u5F0F\u9519\u8BEF");
20990
20760
  }
20991
- const file = path5.join(logsPath, `logger.${date.format("YYYY-MM-DD")}.log`);
20761
+ const file = path4.join(logsPath, `logger.${date.format("YYYY-MM-DD")}.log`);
20992
20762
  res.setHeader("Content-Type", "text/event-stream; charset=utf-8");
20993
20763
  res.setHeader("Cache-Control", "no-cache");
20994
20764
  res.setHeader("Connection", "keep-alive");
@@ -21001,7 +20771,7 @@ var init_getLog = __esm({
21001
20771
  }
21002
20772
  }, 3e4);
21003
20773
  const tailFile = () => {
21004
- fs7.stat(file, (err, stats) => {
20774
+ fs5.stat(file, (err, stats) => {
21005
20775
  if (err) {
21006
20776
  logger.error("\u8BFB\u53D6\u65E5\u5FD7\u6587\u4EF6\u72B6\u6001\u9519\u8BEF:", err);
21007
20777
  return;
@@ -21010,7 +20780,7 @@ var init_getLog = __esm({
21010
20780
  position = 0;
21011
20781
  }
21012
20782
  if (position < stats.size) {
21013
- const stream3 = fs7.createReadStream(file, { start: position, encoding: "utf-8" });
20783
+ const stream3 = fs5.createReadStream(file, { start: position, encoding: "utf-8" });
21014
20784
  stream3.on("data", (data) => {
21015
20785
  const lines = data.toString().split("\n");
21016
20786
  for (const line of lines) {
@@ -21042,7 +20812,7 @@ var init_getLog = __esm({
21042
20812
  });
21043
20813
  };
21044
20814
  getLogFileListRouter = async (_, res) => {
21045
- const files = fs7.readdirSync(logsPath);
20815
+ const files = fs5.readdirSync(logsPath);
21046
20816
  const logFiles = files.filter((file) => file.startsWith("logger.") && file.endsWith(".log")).map((file) => file.replace("logger.", "").replace(".log", ""));
21047
20817
  createSuccessResponse(res, logFiles, "\u6210\u529F");
21048
20818
  };
@@ -21051,11 +20821,11 @@ var init_getLog = __esm({
21051
20821
  if (!isStandardDate(file)) {
21052
20822
  return createBadRequestResponse(res, "\u65E5\u671F\u683C\u5F0F\u9519\u8BEF");
21053
20823
  }
21054
- const filePath = path5.join(logsPath, `logger.${file}.log`);
21055
- if (!fs7.existsSync(filePath)) {
20824
+ const filePath = path4.join(logsPath, `logger.${file}.log`);
20825
+ if (!fs5.existsSync(filePath)) {
21056
20826
  return createBadRequestResponse(res, "\u65E5\u5FD7\u6587\u4EF6\u4E0D\u5B58\u5728");
21057
20827
  }
21058
- const content = fs7.readFileSync(filePath, "utf-8");
20828
+ const content = fs5.readFileSync(filePath, "utf-8");
21059
20829
  createSuccessResponse(res, content, "\u6210\u529F");
21060
20830
  };
21061
20831
  }
@@ -21121,13 +20891,13 @@ var init_install = __esm({
21121
20891
  };
21122
20892
  installGitPlugin = async (task2, url) => {
21123
20893
  if (!url) throw new Error("Git \u63D2\u4EF6\u9700\u8981\u63D0\u4F9B\u4ED3\u5E93\u5730\u5740");
21124
- const pluginDir2 = path5.join(process.cwd(), "plugins", task2.name);
20894
+ const pluginDir2 = path4.join(process.cwd(), "plugins", task2.name);
21125
20895
  task2.logs.push(`\u5F00\u59CB\u514B\u9686\u4ED3\u5E93: ${url}`);
21126
20896
  task2.logs.push(`\u76EE\u6807\u76EE\u5F55: ${pluginDir2}`);
21127
- await fs7.promises.mkdir(pluginDir2, { recursive: true });
20897
+ await fs5.promises.mkdir(pluginDir2, { recursive: true });
21128
20898
  await spawnCommand("git", ["clone", "--depth=1", url, `./plugins/${task2.name}`], task2);
21129
- const pkgPath = path5.join(pluginDir2, "package.json");
21130
- if (fs7.existsSync(pkgPath)) {
20899
+ const pkgPath = path4.join(pluginDir2, "package.json");
20900
+ if (fs5.existsSync(pkgPath)) {
21131
20901
  task2.logs.push("\u68C0\u6D4B\u5230 package.json\uFF0C\u5F00\u59CB\u5B89\u88C5\u4F9D\u8D56...");
21132
20902
  await spawnCommand("pnpm", ["install"], task2);
21133
20903
  }
@@ -21137,10 +20907,10 @@ var init_install = __esm({
21137
20907
  if (!url.endsWith(".js") && !url.endsWith(".ts")) {
21138
20908
  throw new Error("\u975Ejs\u3001ts\u4E0D\u5141\u8BB8\u4E0B\u8F7D");
21139
20909
  }
21140
- const pluginDir2 = path5.join(process.cwd(), "plugins", "karin-plugin-example");
20910
+ const pluginDir2 = path4.join(process.cwd(), "plugins", "karin-plugin-example");
21141
20911
  task2.logs.push(`\u5F00\u59CB\u4E0B\u8F7D\u63D2\u4EF6: ${url}`);
21142
20912
  task2.logs.push(`\u76EE\u6807\u76EE\u5F55: ${pluginDir2}`);
21143
- await fs7.promises.mkdir(pluginDir2, { recursive: true });
20913
+ await fs5.promises.mkdir(pluginDir2, { recursive: true });
21144
20914
  await spawnCommand(
21145
20915
  "curl",
21146
20916
  [
@@ -21218,9 +20988,9 @@ var init_install = __esm({
21218
20988
  await spawnCommand("pnpm", ["rm", task2.name], task2);
21219
20989
  };
21220
20990
  uninstallGitPlugin = async (task2) => {
21221
- const pluginDir2 = path5.join(process.cwd(), "plugins", task2.name);
20991
+ const pluginDir2 = path4.join(process.cwd(), "plugins", task2.name);
21222
20992
  task2.logs.push(`\u5F00\u59CB\u5220\u9664\u63D2\u4EF6\u76EE\u5F55: ${pluginDir2}`);
21223
- await fs7.promises.rm(pluginDir2, { recursive: true, force: true });
20993
+ await fs5.promises.rm(pluginDir2, { recursive: true, force: true });
21224
20994
  task2.logs.push("\u63D2\u4EF6\u76EE\u5F55\u5DF2\u5220\u9664");
21225
20995
  task2.logs.push("\u6B63\u5728\u6E05\u7406\u4F9D\u8D56\u7F13\u5B58...");
21226
20996
  await spawnCommand("pnpm", ["install", "-P"], task2);
@@ -21342,7 +21112,7 @@ var init_terminalManager = __esm({
21342
21112
  "src/server/pty/terminalManager.ts"() {
21343
21113
  init_common2();
21344
21114
  init_internal();
21345
- init_utils2();
21115
+ init_utils();
21346
21116
  terminals = /* @__PURE__ */ new Map();
21347
21117
  pty = null;
21348
21118
  isPtyInstalled = async () => {
@@ -21618,14 +21388,14 @@ var init_webui = __esm({
21618
21388
  getWebuiPluginList = async (_, res) => {
21619
21389
  try {
21620
21390
  const updatedPlugins = await Promise.all(plugins.map(async (plugin) => {
21621
- const modulePath = path5.join(process.cwd(), "node_modules", plugin.name);
21622
- const isInstalled = fs7.existsSync(modulePath);
21391
+ const modulePath = path4.join(process.cwd(), "node_modules", plugin.name);
21392
+ const isInstalled = fs5.existsSync(modulePath);
21623
21393
  let version2;
21624
21394
  if (isInstalled) {
21625
21395
  try {
21626
- const pkgPath = path5.join(modulePath, "package.json");
21627
- if (fs7.existsSync(pkgPath)) {
21628
- const pkgContent = fs7.readFileSync(pkgPath, "utf-8");
21396
+ const pkgPath = path4.join(modulePath, "package.json");
21397
+ if (fs5.existsSync(pkgPath)) {
21398
+ const pkgContent = fs5.readFileSync(pkgPath, "utf-8");
21629
21399
  const pkg2 = JSON.parse(pkgContent);
21630
21400
  version2 = pkg2.version;
21631
21401
  }
@@ -21662,10 +21432,10 @@ var init_webui = __esm({
21662
21432
  return createSuccessResponse(res, cachedData.data);
21663
21433
  }
21664
21434
  let currentVersion = null;
21665
- const pkgPath = path5.join(process.cwd(), "node_modules", name, "package.json");
21666
- if (fs7.existsSync(pkgPath)) {
21435
+ const pkgPath = path4.join(process.cwd(), "node_modules", name, "package.json");
21436
+ if (fs5.existsSync(pkgPath)) {
21667
21437
  try {
21668
- const pkgContent = fs7.readFileSync(pkgPath, "utf-8");
21438
+ const pkgContent = fs5.readFileSync(pkgPath, "utf-8");
21669
21439
  const pkg2 = JSON.parse(pkgContent);
21670
21440
  currentVersion = pkg2.version;
21671
21441
  } catch (error) {
@@ -21829,10 +21599,10 @@ var init_database = __esm({
21829
21599
  };
21830
21600
  initDatabase = async (dbPath2) => {
21831
21601
  const filename2 = `${dbPath2}/task.db`;
21832
- if (fs7.existsSync(dbPath2) && fs7.statSync(dbPath2).isFile()) {
21833
- fs7.renameSync(dbPath2, `${dbPath2}.bak`);
21602
+ if (fs5.existsSync(dbPath2) && fs5.statSync(dbPath2).isFile()) {
21603
+ fs5.renameSync(dbPath2, `${dbPath2}.bak`);
21834
21604
  }
21835
- fs7.mkdirSync(dbPath2, { recursive: true });
21605
+ fs5.mkdirSync(dbPath2, { recursive: true });
21836
21606
  return new Promise((resolve, reject) => {
21837
21607
  const db2 = new sqlite3.Database(filename2, async (err) => {
21838
21608
  if (err) {
@@ -22347,7 +22117,7 @@ var init_update3 = __esm({
22347
22117
  }
22348
22118
  for (const item of git) {
22349
22119
  const { name, force } = item;
22350
- const cwd = path5.join(karinPathPlugins, name);
22120
+ const cwd = path4.join(karinPathPlugins, name);
22351
22121
  const result = await gitPull(cwd, { force, timeout: 60 * 1e3 });
22352
22122
  if (result.status) {
22353
22123
  log3(`\u66F4\u65B0 ${name}(git) \u63D2\u4EF6\u6210\u529F: ${result.hash.before} -> ${result.hash.after}`);
@@ -22399,7 +22169,7 @@ var init_update3 = __esm({
22399
22169
  await spawnProcess("pnpm", args, {}, log3);
22400
22170
  };
22401
22171
  const updateGitPlugin2 = async (pluginName) => {
22402
- const cwd = path5.join(karinPathPlugins, pluginName);
22172
+ const cwd = path4.join(karinPathPlugins, pluginName);
22403
22173
  const result = await gitPull(cwd, { force: options?.force, timeout: 60 * 1e3 });
22404
22174
  if (result.status) {
22405
22175
  return `\u66F4\u65B0 ${pluginName}(git) \u63D2\u4EF6\u6210\u529F: ${result.hash.before} -> ${result.hash.after}`;
@@ -22472,7 +22242,7 @@ var init_installMarket = __esm({
22472
22242
  init_root();
22473
22243
  init_request4();
22474
22244
  init_fsSync();
22475
- init_file2();
22245
+ init_file();
22476
22246
  init_task();
22477
22247
  init_system3();
22478
22248
  init_load();
@@ -22620,12 +22390,12 @@ var init_installMarket = __esm({
22620
22390
  },
22621
22391
  async (_, emitLog) => {
22622
22392
  const msg = ["\u5B89\u88C5\u4EFB\u52A1\u6267\u884C\u4E2D"];
22623
- const dir2 = path5.join(karinPathPlugins, "karin-plugin-example");
22393
+ const dir2 = path4.join(karinPathPlugins, "karin-plugin-example");
22624
22394
  mkdirSync(dir2);
22625
22395
  emitLog("\u5F00\u59CB\u4E0B\u8F7D\u63D2\u4EF6\u6587\u4EF6...");
22626
22396
  await Promise.all(urls.map(async (app4) => {
22627
- const filename2 = path5.basename(app4.url);
22628
- const fileUrl = path5.join(dir2, filename2);
22397
+ const filename2 = path4.basename(app4.url);
22398
+ const fileUrl = path4.join(dir2, filename2);
22629
22399
  emitLog(`\u6B63\u5728\u4E0B\u8F7D: ${filename2}`);
22630
22400
  const result = await downloadFile(app4.url, fileUrl);
22631
22401
  if (!result.success) {
@@ -22667,7 +22437,7 @@ var init_installCustom = __esm({
22667
22437
  init_tool();
22668
22438
  init_root();
22669
22439
  init_fsSync();
22670
- init_file2();
22440
+ init_file();
22671
22441
  init_task();
22672
22442
  init_load();
22673
22443
  installCustom = async (res, data, ip) => {
@@ -22717,7 +22487,7 @@ var init_installCustom = __esm({
22717
22487
  return handleReturn2(res, true, "\u5B89\u88C5\u4EFB\u52A1\u5DF2\u521B\u5EFA\uFF0C\u8BF7\u901A\u8FC7taskId\u6267\u884C\u4EFB\u52A1", id);
22718
22488
  };
22719
22489
  installGit2 = async (res, data, ip) => {
22720
- const pkgName = data.target || path5.basename(data.repo).replace(".git", "");
22490
+ const pkgName = data.target || path4.basename(data.repo).replace(".git", "");
22721
22491
  if (!pkgName.startsWith("karin-plugin-")) {
22722
22492
  return handleReturn2(res, false, "\u63D2\u4EF6\u540D\u79F0\u5FC5\u987B\u4EE5karin-plugin-\u5F00\u5934");
22723
22493
  }
@@ -22747,7 +22517,7 @@ var init_installCustom = __esm({
22747
22517
  if (!data.jsUrl) {
22748
22518
  return handleReturn2(res, false, "jsUrl\u4E0D\u80FD\u4E3A\u7A7A");
22749
22519
  }
22750
- let filename2 = data.target || path5.basename(data.jsUrl);
22520
+ let filename2 = data.target || path4.basename(data.jsUrl);
22751
22521
  if (!filename2.endsWith(".js")) {
22752
22522
  filename2 += ".js";
22753
22523
  }
@@ -22759,8 +22529,8 @@ var init_installCustom = __esm({
22759
22529
  operatorIp: ip
22760
22530
  },
22761
22531
  async (_, emitLog) => {
22762
- const dir2 = path5.join(karinPathPlugins, "karin-plugin-example");
22763
- const fileUrl = path5.join(dir2, filename2);
22532
+ const dir2 = path4.join(karinPathPlugins, "karin-plugin-example");
22533
+ const fileUrl = path4.join(dir2, filename2);
22764
22534
  mkdirSync(dir2);
22765
22535
  emitLog(`\u5F00\u59CB\u4E0B\u8F7D\u63D2\u4EF6\u6587\u4EF6: ${filename2}`);
22766
22536
  const result = await downloadFile(data.jsUrl, fileUrl);
@@ -22849,13 +22619,13 @@ var init_uninstall = __esm({
22849
22619
  emitLog(`\u5378\u8F7D ${v} \u5931\u8D25: \u6587\u4EF6\u540D\u79F0\u5B58\u5728\u8DEF\u5F84\u7A7F\u8D8A\u98CE\u9669`);
22850
22620
  continue;
22851
22621
  }
22852
- const dir2 = path5.join(karinPathPlugins, v);
22853
- if (!fs7.existsSync(path5.join(dir2, ".git"))) {
22622
+ const dir2 = path4.join(karinPathPlugins, v);
22623
+ if (!fs5.existsSync(path4.join(dir2, ".git"))) {
22854
22624
  emitLog(`\u5378\u8F7D ${v} \u5931\u8D25: \u975Egit\u4ED3\u5E93`);
22855
22625
  continue;
22856
22626
  }
22857
22627
  try {
22858
- await fs7.promises.rm(dir2, { recursive: true, force: true });
22628
+ await fs5.promises.rm(dir2, { recursive: true, force: true });
22859
22629
  emitLog(`\u5378\u8F7D ${v} \u6210\u529F`);
22860
22630
  } catch (error) {
22861
22631
  emitLog(`\u5378\u8F7D ${v} \u5931\u8D25: ${error.message}`);
@@ -22879,18 +22649,18 @@ var init_uninstall = __esm({
22879
22649
  emitLog(`\u5378\u8F7D ${v} \u5931\u8D25: \u63D2\u4EF6\u4E0D\u5B58\u5728`);
22880
22650
  continue;
22881
22651
  }
22882
- const dir2 = path5.join(karinPathPlugins, pkg2);
22883
- if (!fs7.existsSync(path5.join(dir2, file))) {
22652
+ const dir2 = path4.join(karinPathPlugins, pkg2);
22653
+ if (!fs5.existsSync(path4.join(dir2, file))) {
22884
22654
  emitLog(`\u5378\u8F7D ${v} \u5931\u8D25: \u6587\u4EF6\u4E0D\u5B58\u5728`);
22885
22655
  continue;
22886
22656
  }
22887
- const ext = path5.extname(file);
22657
+ const ext = path4.extname(file);
22888
22658
  if (![".js", ".mjs", ".cjs", ".ts", ".cts", ".mts"].includes(ext)) {
22889
22659
  emitLog(`\u5378\u8F7D ${v} \u5931\u8D25: \u9519\u8BEF\u7684\u6587\u4EF6\u7C7B\u578B`);
22890
22660
  continue;
22891
22661
  }
22892
22662
  try {
22893
- await fs7.promises.unlink(path5.join(dir2, file));
22663
+ await fs5.promises.unlink(path4.join(dir2, file));
22894
22664
  emitLog(`\u5378\u8F7D ${v} \u6210\u529F`);
22895
22665
  } catch (error) {
22896
22666
  emitLog(`\u5378\u8F7D ${v} \u5931\u8D25: ${error.message}`);
@@ -23003,7 +22773,7 @@ var init_list2 = __esm({
23003
22773
  unsavedDependencies: 5
23004
22774
  // 临时依赖
23005
22775
  };
23006
- list2 = lodash4.sortBy(list2, [
22776
+ list2 = lodash3.sortBy(list2, [
23007
22777
  // 1. 首先按照是否是node-karin插件排序(取反,使node-karin排在前面)
23008
22778
  (item) => !(item.name === "node-karin"),
23009
22779
  // 2. 然后按照是否是karin插件排序
@@ -23483,12 +23253,12 @@ var init_config5 = __esm({
23483
23253
  };
23484
23254
  getNpmrcContentRouter = async (req, res) => {
23485
23255
  try {
23486
- const { path: path37 } = req.body;
23256
+ const { path: path36 } = req.body;
23487
23257
  const list2 = await getNpmConfigList();
23488
- if (!list2.find((item) => item.path === path37)) {
23258
+ if (!list2.find((item) => item.path === path36)) {
23489
23259
  return createBadRequestResponse(res, "\u6587\u4EF6\u4E0D\u5B58\u5728");
23490
23260
  }
23491
- const content = ini.read(path37);
23261
+ const content = ini.read(path36);
23492
23262
  return createSuccessResponse(res, content);
23493
23263
  } catch (error) {
23494
23264
  logger.error("[getNpmrcContentRouter]", error);
@@ -23515,7 +23285,7 @@ var init_config5 = __esm({
23515
23285
  };
23516
23286
  saveNpmrcRouter = async (req, res) => {
23517
23287
  try {
23518
- const { path: path37, content, baseConfig } = req.body;
23288
+ const { path: path36, content, baseConfig } = req.body;
23519
23289
  const list2 = await getNpmConfigList();
23520
23290
  const promises = [];
23521
23291
  if (baseConfig.registry) {
@@ -23528,11 +23298,11 @@ var init_config5 = __esm({
23528
23298
  promises.push(setNpmConfig("https-proxy", baseConfig["https-proxy"]));
23529
23299
  }
23530
23300
  await Promise.all(promises);
23531
- if (path37 && content) {
23532
- if (!list2.find((item) => item.path === path37)) {
23301
+ if (path36 && content) {
23302
+ if (!list2.find((item) => item.path === path36)) {
23533
23303
  return createBadRequestResponse(res, "\u6587\u4EF6\u4E0D\u5B58\u5728");
23534
23304
  }
23535
- ini.write(content, path37);
23305
+ ini.write(content, path36);
23536
23306
  }
23537
23307
  return createSuccessResponse(res, "\u4FDD\u5B58\u6210\u529F");
23538
23308
  } catch (error) {
@@ -23581,7 +23351,7 @@ var init_list4 = __esm({
23581
23351
  list2.push({
23582
23352
  type: "app",
23583
23353
  id: plugin.name,
23584
- name: `${plugin.name}/${path5.basename(v)}`,
23354
+ name: `${plugin.name}/${path4.basename(v)}`,
23585
23355
  version: "",
23586
23356
  latestHash: ""
23587
23357
  });
@@ -23968,13 +23738,13 @@ var init_app = __esm({
23968
23738
  });
23969
23739
  };
23970
23740
  web = (dir2) => {
23971
- const webDir = path5.join(dir2.karinDir, "dist/web");
23741
+ const webDir = path4.join(dir2.karinDir, "dist/web");
23972
23742
  app3.use("/web", express2.static(webDir));
23973
23743
  app3.use("/sandbox/data", express2.static(dir2.sandboxDataPath));
23974
23744
  app3.use("/sandbox/file", express2.static(dir2.sandboxTempPath));
23975
23745
  app3.get("/web/{*splat}", (_, res) => {
23976
23746
  res.sendFile("index.html", {
23977
- root: path5.resolve(webDir)
23747
+ root: path4.resolve(webDir)
23978
23748
  });
23979
23749
  });
23980
23750
  listeners.once("online", () => {
@@ -23986,12 +23756,12 @@ var init_app = __esm({
23986
23756
  });
23987
23757
  };
23988
23758
  initExpress = async (dir2, port2, host2) => {
23989
- const webDir = path5.join(dir2.karinDir, "dist/web");
23759
+ const webDir = path4.join(dir2.karinDir, "dist/web");
23990
23760
  app3.use("/web", (req, res, next) => {
23991
- const filePath = path5.join(webDir, req.path);
23761
+ const filePath = path4.join(webDir, req.path);
23992
23762
  const brPath = `${filePath}.br`;
23993
23763
  const acceptEncoding = req.headers["accept-encoding"] || "";
23994
- if (fs7.existsSync(brPath)) {
23764
+ if (fs5.existsSync(brPath)) {
23995
23765
  if (acceptEncoding.includes("br")) {
23996
23766
  res.set({
23997
23767
  "Content-Encoding": "br",
@@ -24006,7 +23776,7 @@ var init_app = __esm({
24006
23776
  "Content-Type": getMimeType_default(req.path),
24007
23777
  "Cache-Control": "public, max-age=604800"
24008
23778
  });
24009
- const readStream = fs7.createReadStream(brPath);
23779
+ const readStream = fs5.createReadStream(brPath);
24010
23780
  const decompressStream = createBrotliDecompress();
24011
23781
  readStream.pipe(decompressStream).pipe(res);
24012
23782
  return;
@@ -24167,8 +23937,8 @@ var init_input = __esm({
24167
23937
  async getUrl(data, ext) {
24168
23938
  const cfg = adapter();
24169
23939
  const name = (++index5).toString();
24170
- const file = path5.join(consolePath, `${name}${ext}`);
24171
- await fs7.promises.writeFile(file, await buffer(data));
23940
+ const file = path4.join(consolePath, `${name}${ext}`);
23941
+ await fs5.promises.writeFile(file, await buffer(data));
24172
23942
  if (cfg.console.isLocal) {
24173
23943
  return `http://127.0.0.1:${process.env.HTTP_PORT}/api/v1/console/${name}${ext}`;
24174
23944
  }
@@ -24272,7 +24042,7 @@ var init_db = __esm({
24272
24042
  "src/service/sandbox/db.ts"() {
24273
24043
  init_root();
24274
24044
  DEFAULT_USER_AVATAR = "https://q1.qlogo.cn/g?b=qq&nk=1812868335&s=0";
24275
- root = path5.join(sandboxDataPath, "db");
24045
+ root = path4.join(sandboxDataPath, "db");
24276
24046
  selfInfo = {
24277
24047
  userId: "sandbox",
24278
24048
  nick: "\u6C99\u76D2\u5C0F\u52A9\u624B",
@@ -24283,25 +24053,25 @@ var init_db = __esm({
24283
24053
  };
24284
24054
  dir = {
24285
24055
  /** 登录号信息 */
24286
- account: path5.join(root, "account.db"),
24056
+ account: path4.join(root, "account.db"),
24287
24057
  /** 好友列表 */
24288
- frinendList: path5.join(root, "friend_list.db"),
24058
+ frinendList: path4.join(root, "friend_list.db"),
24289
24059
  /** 好友消息记录 */
24290
- friendHistory: path5.join(root, "friend_history.db"),
24060
+ friendHistory: path4.join(root, "friend_history.db"),
24291
24061
  /** 好友通知 */
24292
- friendNotice: path5.join(root, "friend_notice.db"),
24062
+ friendNotice: path4.join(root, "friend_notice.db"),
24293
24063
  /** 好友请求 */
24294
- friendRequest: path5.join(root, "friend_request.db"),
24064
+ friendRequest: path4.join(root, "friend_request.db"),
24295
24065
  /** 群列表 */
24296
- groupList: path5.join(root, "group_list.db"),
24066
+ groupList: path4.join(root, "group_list.db"),
24297
24067
  /** 群成员列表 */
24298
- groupMemberList: path5.join(root, "group_member_list.db"),
24068
+ groupMemberList: path4.join(root, "group_member_list.db"),
24299
24069
  /** 群消息记录 */
24300
- groupHistory: path5.join(root, "group_history.db"),
24070
+ groupHistory: path4.join(root, "group_history.db"),
24301
24071
  /** 群通知 */
24302
- groupNotice: path5.join(root, "group_notice.db"),
24072
+ groupNotice: path4.join(root, "group_notice.db"),
24303
24073
  /** 群请求 */
24304
- groupRequest: path5.join(root, "group_request.db")
24074
+ groupRequest: path4.join(root, "group_request.db")
24305
24075
  };
24306
24076
  stream2 = {
24307
24077
  frinendList: {
@@ -24393,7 +24163,7 @@ var init_db = __esm({
24393
24163
  try {
24394
24164
  await promises.access(dir.account);
24395
24165
  } catch {
24396
- await promises.mkdir(path5.dirname(dir.account), { recursive: true });
24166
+ await promises.mkdir(path4.dirname(dir.account), { recursive: true });
24397
24167
  await promises.writeFile(dir.account, JSON.stringify(selfInfo, null, 2));
24398
24168
  }
24399
24169
  return;
@@ -24402,7 +24172,7 @@ var init_db = __esm({
24402
24172
  await promises.access(file);
24403
24173
  if (file === dir.frinendList) writeAccountToFriendList();
24404
24174
  } catch {
24405
- await promises.mkdir(path5.dirname(file), { recursive: true });
24175
+ await promises.mkdir(path4.dirname(file), { recursive: true });
24406
24176
  await promises.writeFile(file, "");
24407
24177
  }
24408
24178
  });
@@ -24462,7 +24232,7 @@ var createDebug = (prefix) => {
24462
24232
  color = fnc2;
24463
24233
  };
24464
24234
  const debugFn = (...args) => {
24465
- process.stderr.write(`${color(prefix)} ${util6.format(...args)} ${color(`+${Date.now() - time}ms`)}
24235
+ process.stderr.write(`${color(prefix)} ${util5.format(...args)} ${color(`+${Date.now() - time}ms`)}
24466
24236
  `);
24467
24237
  };
24468
24238
  const noop = () => {
@@ -24486,14 +24256,11 @@ global.debug = debug2;
24486
24256
  init_dotenv();
24487
24257
  init_root();
24488
24258
 
24489
- // src/utils/logger/index.ts
24490
- init_logger3();
24491
-
24492
24259
  // src/utils/config/init.ts
24493
24260
  init_env2();
24494
24261
  init_pkg();
24495
24262
  init_default();
24496
- init_file3();
24263
+ init_file2();
24497
24264
  var env2 = () => {
24498
24265
  const list2 = [
24499
24266
  {
@@ -24503,7 +24270,7 @@ var env2 = () => {
24503
24270
  }
24504
24271
  ];
24505
24272
  const file = `${process.cwd()}/${process.env.EBV_FILE}`;
24506
- if (!fs7.existsSync(file)) {
24273
+ if (!fs5.existsSync(file)) {
24507
24274
  logger.error(logger.yellow("\u68C0\u67E5\u5230\u9879\u76EE\u914D\u7F6E\u6587\u4EF6\u7F3A\u5931\uFF0C\u6B63\u5728\u521D\u59CB\u5316..."));
24508
24275
  const cwd = fileURLToPath$1(new URL$1("./cli/index.mjs", import.meta.url));
24509
24276
  execSync(`node ${cwd} init`, {
@@ -24512,10 +24279,10 @@ var env2 = () => {
24512
24279
  });
24513
24280
  logger.info(logger.green("\u521D\u59CB\u5316\u6210\u529F~"));
24514
24281
  }
24515
- const content = fs7.readFileSync(file, "utf-8");
24282
+ const content = fs5.readFileSync(file, "utf-8");
24516
24283
  list2.forEach((v) => {
24517
24284
  if (!content.includes(v.key)) {
24518
- fs7.appendFileSync(file, `
24285
+ fs5.appendFileSync(file, `
24519
24286
  ${v.comment}
24520
24287
  ${v.key}=${v.value}`);
24521
24288
  process.env[v.key] = v.value;
@@ -24536,26 +24303,26 @@ var initConfig2 = async (dir2) => {
24536
24303
  `${dir2.sandboxDataPath}/avatar`
24537
24304
  ];
24538
24305
  await Promise.all(files.map((v) => {
24539
- if (!fs7.existsSync(v)) fs7.mkdirSync(v, { recursive: true });
24306
+ if (!fs5.existsSync(v)) fs5.mkdirSync(v, { recursive: true });
24540
24307
  return Promise.resolve();
24541
24308
  }));
24542
24309
  setVersion(pkg().version);
24543
24310
  env2();
24544
24311
  if (process.env.pm_id) setRuntime("pm2");
24545
- const list2 = await fs7.promises.readdir(dir2.consolePath);
24312
+ const list2 = await fs5.promises.readdir(dir2.consolePath);
24546
24313
  await Promise.all(list2.map((v) => {
24547
- if (fs7.statSync(`${dir2.consolePath}/${v}`).isDirectory()) {
24548
- fs7.rmdirSync(`${dir2.consolePath}/${v}`, { recursive: true });
24314
+ if (fs5.statSync(`${dir2.consolePath}/${v}`).isDirectory()) {
24315
+ fs5.rmdirSync(`${dir2.consolePath}/${v}`, { recursive: true });
24549
24316
  } else {
24550
- fs7.unlinkSync(`${dir2.consolePath}/${v}`);
24317
+ fs5.unlinkSync(`${dir2.consolePath}/${v}`);
24551
24318
  }
24552
24319
  return Promise.resolve();
24553
24320
  }));
24554
24321
  await Promise.all(Object.keys(defaultConfig).map(async (key) => {
24555
24322
  const file = `${dir2.configPath}/${key}.json`;
24556
- if (fs7.existsSync(file)) return;
24323
+ if (fs5.existsSync(file)) return;
24557
24324
  const data = JSON.stringify(defaultConfig[key], null, 2);
24558
- await fs7.promises.writeFile(file, data, "utf-8");
24325
+ await fs5.promises.writeFile(file, data, "utf-8");
24559
24326
  return true;
24560
24327
  }));
24561
24328
  initConfigCache(dir2.configPath);
@@ -24640,7 +24407,7 @@ var initPluginHmr = async () => {
24640
24407
  });
24641
24408
  watcher.on("add", (file) => handleFileChange(file, "add")).on("change", (file) => handleFileChange(file, "change")).on("unlink", (file) => handleFileChange(file, "unlink"));
24642
24409
  const relativePaths = Array.from(watchDirs).map((dir2) => {
24643
- return path5.relative(process.cwd(), dir2).replace(/\\/g, "/");
24410
+ return path4.relative(process.cwd(), dir2).replace(/\\/g, "/");
24644
24411
  });
24645
24412
  watchDirs.clear();
24646
24413
  logger.info(`
@@ -24648,17 +24415,17 @@ var initPluginHmr = async () => {
24648
24415
  ${relativePaths.join("\n")}`);
24649
24416
  };
24650
24417
  var handleFileChange = async (file, action) => {
24651
- const ext = path5.extname(file);
24418
+ const ext = path4.extname(file);
24652
24419
  const exts = getModuleType();
24653
24420
  if (!exts.includes(ext)) return;
24654
24421
  const absPath2 = formatPath(file);
24655
24422
  const pkg2 = findPkgByFile(absPath2);
24656
24423
  if (!pkg2) return;
24657
- const relativePath = path5.relative(process.cwd(), file).replace(/\\/g, "/");
24424
+ const relativePath = path4.relative(process.cwd(), file).replace(/\\/g, "/");
24658
24425
  logger.debug(`[hmr][${pkg2.name}] \u6587\u4EF6${action}: ${relativePath}`);
24659
24426
  if (action === "unlink") {
24660
24427
  pkgRemoveModule(absPath2);
24661
- logger.info(`[hmr][${pkg2.name}] \u5DF2\u5378\u8F7D: ${path5.basename(file)}`);
24428
+ logger.info(`[hmr][${pkg2.name}] \u5DF2\u5378\u8F7D: ${path4.basename(file)}`);
24662
24429
  return;
24663
24430
  }
24664
24431
  if (action === "change") {
@@ -24669,7 +24436,7 @@ var handleFileChange = async (file, action) => {
24669
24436
  pkgCache(result, pkg2, absPath2);
24670
24437
  pkgSort();
24671
24438
  const actionText = action === "add" ? "\u65B0\u589E\u63D2\u4EF6" : "\u91CD\u8F7D\u5B8C\u6210";
24672
- logger.info(`[hmr][${pkg2.name}] ${actionText}: ${path5.basename(file)}`);
24439
+ logger.info(`[hmr][${pkg2.name}] ${actionText}: ${path4.basename(file)}`);
24673
24440
  } catch (error) {
24674
24441
  logger.error(`[hmr][${pkg2.name}] \u52A0\u8F7D\u5931\u8D25:`);
24675
24442
  logger.error(error);
@@ -24757,7 +24524,7 @@ init_key2();
24757
24524
  init_adapter();
24758
24525
  init_connect();
24759
24526
  init_client();
24760
- init_types2();
24527
+ init_types();
24761
24528
  var createServer3 = async () => {
24762
24529
  listeners.on(WS_CONNECTION_ONEBOT, (socket, request2, call2) => {
24763
24530
  call2();
@@ -25137,7 +24904,7 @@ var karin = Object.assign(other, export_exports);
25137
24904
  var Bot = karin;
25138
24905
 
25139
24906
  // src/index.ts
25140
- init_utils2();
24907
+ init_utils();
25141
24908
 
25142
24909
  // src/server/index.ts
25143
24910
  init_router3();
@@ -25858,6 +25625,11 @@ var Plugin = class {
25858
25625
  // src/index.ts
25859
25626
  init_kv();
25860
25627
  init_redis3();
25628
+
25629
+ // src/utils/logger/index.ts
25630
+ init_logger2();
25631
+
25632
+ // src/index.ts
25861
25633
  var isStart = false;
25862
25634
  if (!process.env.EBV_FILE) process.env.EBV_FILE = ".env";
25863
25635
  var start2 = async () => {
@@ -25866,8 +25638,7 @@ var start2 = async () => {
25866
25638
  return;
25867
25639
  }
25868
25640
  isStart = true;
25869
- dotenv_default.config({ path: `${path5.resolve(process.cwd(), process.env.EBV_FILE)}` });
25870
- createInnerLogger(root_default.logsPath);
25641
+ dotenv_default.config({ path: `${path4.resolve(process.cwd(), process.env.EBV_FILE)}` });
25871
25642
  await initConfig2(root_default);
25872
25643
  printStartLog(process.env.KARIN_VERSION);
25873
25644
  await initProcess(+process.env.HTTP_PORT);
@@ -25900,4 +25671,4 @@ var start2 = async () => {
25900
25671
  (*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
25901
25672
  */
25902
25673
 
25903
- export { AdapterBase, BASE_ROUTER, BATCH_UPDATE_PLUGINS_ROUTER, BaseEvent, Bot, CHECK_PLUGIN_ROUTER, CLOSE_TERMINAL_ROUTER, CONSOLE_ROUTER, CREATE_TERMINAL_ROUTER, DirectMessage, EVENT_COUNT, EXIT_ROUTER, FILE_CHANGE, FriendDecreaseNotice, FriendIncreaseNotice, FriendMessage, GET_BOTS_ROUTER, GET_CONFIG_ROUTER, GET_DEPENDENCIES_LIST_ROUTER, GET_LOADED_COMMAND_PLUGIN_CACHE_LIST_ROUTER, GET_LOCAL_PLUGIN_LIST_ROUTER, GET_LOG_FILE_LIST_ROUTER, GET_LOG_FILE_ROUTER, GET_LOG_ROUTER, GET_NETWORK_STATUS_ROUTER, GET_NPMRC_LIST_ROUTER, GET_NPM_BASE_CONFIG_ROUTER, GET_NPM_CONFIG_ROUTER, GET_ONLINE_PLUGIN_LIST_ROUTER, GET_PLUGIN_APPS_ROUTER, GET_PLUGIN_CONFIG_ROUTER, GET_PLUGIN_FILE_ROUTER, GET_PLUGIN_LIST_PLUGIN_ADMIN_ROUTER, GET_PLUGIN_LIST_ROUTER, GET_PLUGIN_MARKET_LIST_ROUTER, GET_TASK_LIST_ROUTER, GET_TASK_STATUS_ROUTER, GET_TERMINAL_LIST_ROUTER, GET_UPDATABLE_PLUGINS_ROUTER, GET_WEBUI_PLUGIN_LIST_ROUTER, GET_WEBUI_PLUGIN_VERSIONS_ROUTER, GroupAdminChangedNotice, GroupApplyRequest, GroupCardChangedNotice, GroupFileUploadedNotice, GroupHlightsChangedNotice, GroupHonorChangedNotice, GroupInviteRequest, GroupLuckKingNotice, GroupMemberBanNotice, GroupMemberDecreaseNotice, GroupMemberIncreaseNotice, GroupMemberTitleUpdatedNotice, GroupMessage, GroupMessageReactionNotice, GroupNotice, GroupPokeNotice, GroupRecallNotice, GroupSignInNotice, GroupTempMessage, GroupWholeBanNotice, GuildMessage, HTTPStatusCode, INSTALL_PLUGIN_ROUTER, INSTALL_WEBUI_PLUGIN_ROUTER, IS_PLUGIN_CONFIG_EXIST_ROUTER, LOGIN_ROUTER, MANAGE_DEPENDENCIES_ROUTER, MessageBase, NoticeBase, OB11ApiAction, OB11Event, OB11MessageSubType, OB11MessageType, OB11NoticeType, OB11RequestType, OB11Sex, PING_ROUTER, PLUGIN_ADMIN_ROUTER, Plugin, PrivateApplyRequest, PrivateFileUploadedNotice, PrivatePokeNotice, PrivateRecallNotice, RECV_MSG, REFRESH_ROUTER, RESTART_ROUTER, ReceiveLikeNotice, Renderer, RequestBase, SAVE_CONFIG_ROUTER, SAVE_NPMRC_ROUTER, SAVE_PLUGIN_CONFIG_ROUTER, SEND_MSG, SET_LOG_LEVEL_ROUTER, SYSTEM_INFO_ROUTER, SYSTEM_STATUS_KARIN_ROUTER, SYSTEM_STATUS_ROUTER, SYSTEM_STATUS_WS_ROUTER, TASK_DELETE_ROUTER, TASK_LIST_ROUTER, TASK_LOGS_ROUTER, TASK_RUN_ROUTER, UNINSTALL_PLUGIN_ROUTER, UNINSTALL_WEBUI_PLUGIN_ROUTER, UPDATE_CORE_ROUTER, UPDATE_PLUGIN_ROUTER, UPDATE_TASK_STATUS_ROUTER, UPDATE_WEBUI_PLUGIN_VERSION_ROUTER, WS_CLOSE, WS_CLOSE_ONEBOT, WS_CLOSE_PUPPETEER, WS_CLOSE_SANDBOX, WS_CONNECTION, WS_CONNECTION_ONEBOT, WS_CONNECTION_PUPPETEER, WS_CONNECTION_SANDBOX, WS_CONNECTION_TERMINAL, WS_SNAPKA, Watch, Watcher, YamlEditor, absPath, accordion, accordionItem, accordionPro, app3 as app, applyComments, authMiddleware, base64, basePath, buffer, buildGithub, buttonHandle, callRender, changelog_exports as changelog, checkGitPluginUpdate, checkPkgUpdate, clearRequire, clearRequireFile, comment, commentPath, common_exports as common, components, config_exports as config, configPath, consolePath, contact2 as contact, contactDirect, contactFriend, contactGroup, contactGroupTemp, contactGuild, copyConfig, copyConfigSync, copyFiles, copyFilesSync, createAccessTokenExpiredResponse, createBadRequestResponse, createClient2 as createClient, createDirectMessage, createForbiddenResponse, createFriendDecreaseNotice, createFriendIncreaseNotice, createFriendMessage, createGroupAdminChangedNotice, createGroupApplyRequest, createGroupCardChangedNotice, createGroupFileUploadedNotice, createGroupHlightsChangedNotice, createGroupHonorChangedNotice, createGroupInviteRequest, createGroupLuckKingNotice, createGroupMemberAddNotice, createGroupMemberBanNotice, createGroupMemberDelNotice, createGroupMemberTitleUpdatedNotice, createGroupMessage, createGroupMessageReactionNotice, createGroupPokeNotice, createGroupRecallNotice, createGroupSignInNotice, createGroupTempMessage, createGroupWholeBanNotice, createGuildMessage, createHttp, createINIParser, createInnerLogger, createMethodNotAllowedResponse, createNotFoundResponse, createPayloadTooLargeResponse, createPluginDir, createPrivateApplyRequest, createPrivateFileUploadedNotice, createPrivatePokeNotice, createPrivateRecallNotice, createRawMessage, createReceiveLikeNotice, createRefreshTokenExpiredResponse, createResponse, createServerErrorResponse, createSuccessResponse, createTaskDatabase, createUnauthorizedResponse, cron, dataPath, db, dbPath, debug2 as debug, karin as default, defaultConfigPath, defaultViewPath, defineConfig, divider, downFile, downloadFile, errorToString, exec, executeTask, existToMkdir, existToMkdirSync, exists, existsSync, ffmpeg, ffplay, ffprobe, fs_exports as file, fileToUrl, fileToUrlHandlerKey, filesByExt, formatPath, formatTime, fs_exports2 as fs, getAllBot, getAllBotID, getAllBotList, getAllFiles, getAllFilesSync, getBot, getBotCount, getCommit, getDefaultBranch, getFastGithub, getFastRegistry, getFiles, getHash, getLocalBranches, getLocalCommitHash, getMimeType, getPackageJson, getPid, getPkgVersion, getPluginInfo, getPlugins, getRelPath, getRemoteBranches, getRemoteCommitHash, getRemotePkgVersion, getRender, getRenderCount, getRenderList, getRequestIp, getTaskCallback, getTaskDatabase, getTime, gitPull, handler, hooks, htmlPath, importModule, ini, initOneBot, initTaskSystem, input, isClass, isDir, isDirSync, isDocker, isFile, isFileSync, isIPv4Loop, isIPv6Loop, isLinux, isLocalRequest, isLoopback, isMac, isPackaged, isPathEqual, isPkg, isPlugin, isPublic, isRoot, isSubPath, isWin2 as isWin, json2 as json, karin, karinDir, karinMain, karinPathBase, karinPathComment, karinPathConfig, karinPathConsole, karinPathData, karinPathDb, karinPathDefaultConfig, karinPathDefaultView, karinPathHtml, karinPathKv, karinPathLogs, karinPathMain, karinPathPlugins, karinPathPm2Config, karinPathRedisSqlite3, karinPathResource, karinPathRoot, karinPathSandboxData, karinPathSandboxTemp, karinPathTaskDb, karinPathTemp, karinToQQBot, key_exports as key, kvPath, lock, lockMethod, lockProp, log, logger2 as logger, logs, logsPath, makeForward, makeMessage, mkdir, mkdirSync, parseChangelog, parseGithubUrl, pingRequest, pkgRoot, pluginDir, pm2Path, qqbotToKarin, raceRequest, randomStr, range, read, readFile, readJson, readJsonSync, redis2 as redis, redisSqlite3Path, registerBot, registerRender, removeTaskCallback, render, renderHtml, renderMultiHtml, renderTpl, requireFile, requireFileSync, resourcePath, restart, restartDirect, rmSync, router, sandboxDataPath, sandboxTempPath, satisfies, save, segment_exports as segment, sendMsg2 as sendMsg, sender, senderDirect, senderFriend, senderGroup, senderGroupTemp, senderGuild, sep, server, setTaskCallback, setTaskDatabase, splitPath, start2 as start, stream, stringifyError, switchComponent, system_exports as system, taskAdd, taskExists, taskGet, taskList, taskSystem, taskUpdateLogs, taskUpdateStatus, tempPath, unregisterBot, unregisterRender, updateAllGitPlugin, updateAllPkg, updateGitPlugin, updatePkg, updateTaskLogs, updateTaskStatus, uptime, urlToPath, watch, watchAndMerge, write, writeJson, writeJsonSync, yaml3 as yaml };
25674
+ export { AdapterBase, BASE_ROUTER, BATCH_UPDATE_PLUGINS_ROUTER, BaseEvent, Bot, CHECK_PLUGIN_ROUTER, CLOSE_TERMINAL_ROUTER, CONSOLE_ROUTER, CREATE_TERMINAL_ROUTER, DirectMessage, EVENT_COUNT, EXIT_ROUTER, FILE_CHANGE, FriendDecreaseNotice, FriendIncreaseNotice, FriendMessage, GET_BOTS_ROUTER, GET_CONFIG_ROUTER, GET_DEPENDENCIES_LIST_ROUTER, GET_LOADED_COMMAND_PLUGIN_CACHE_LIST_ROUTER, GET_LOCAL_PLUGIN_LIST_ROUTER, GET_LOG_FILE_LIST_ROUTER, GET_LOG_FILE_ROUTER, GET_LOG_ROUTER, GET_NETWORK_STATUS_ROUTER, GET_NPMRC_LIST_ROUTER, GET_NPM_BASE_CONFIG_ROUTER, GET_NPM_CONFIG_ROUTER, GET_ONLINE_PLUGIN_LIST_ROUTER, GET_PLUGIN_APPS_ROUTER, GET_PLUGIN_CONFIG_ROUTER, GET_PLUGIN_FILE_ROUTER, GET_PLUGIN_LIST_PLUGIN_ADMIN_ROUTER, GET_PLUGIN_LIST_ROUTER, GET_PLUGIN_MARKET_LIST_ROUTER, GET_TASK_LIST_ROUTER, GET_TASK_STATUS_ROUTER, GET_TERMINAL_LIST_ROUTER, GET_UPDATABLE_PLUGINS_ROUTER, GET_WEBUI_PLUGIN_LIST_ROUTER, GET_WEBUI_PLUGIN_VERSIONS_ROUTER, GroupAdminChangedNotice, GroupApplyRequest, GroupCardChangedNotice, GroupFileUploadedNotice, GroupHlightsChangedNotice, GroupHonorChangedNotice, GroupInviteRequest, GroupLuckKingNotice, GroupMemberBanNotice, GroupMemberDecreaseNotice, GroupMemberIncreaseNotice, GroupMemberTitleUpdatedNotice, GroupMessage, GroupMessageReactionNotice, GroupNotice, GroupPokeNotice, GroupRecallNotice, GroupSignInNotice, GroupTempMessage, GroupWholeBanNotice, GuildMessage, HTTPStatusCode, INSTALL_PLUGIN_ROUTER, INSTALL_WEBUI_PLUGIN_ROUTER, IS_PLUGIN_CONFIG_EXIST_ROUTER, LOGIN_ROUTER, MANAGE_DEPENDENCIES_ROUTER, MessageBase, NoticeBase, OB11ApiAction, OB11Event, OB11MessageSubType, OB11MessageType, OB11NoticeType, OB11RequestType, OB11Sex, PING_ROUTER, PLUGIN_ADMIN_ROUTER, Plugin, PrivateApplyRequest, PrivateFileUploadedNotice, PrivatePokeNotice, PrivateRecallNotice, RECV_MSG, REFRESH_ROUTER, RESTART_ROUTER, ReceiveLikeNotice, Renderer, RequestBase, SAVE_CONFIG_ROUTER, SAVE_NPMRC_ROUTER, SAVE_PLUGIN_CONFIG_ROUTER, SEND_MSG, SET_LOG_LEVEL_ROUTER, SYSTEM_INFO_ROUTER, SYSTEM_STATUS_KARIN_ROUTER, SYSTEM_STATUS_ROUTER, SYSTEM_STATUS_WS_ROUTER, TASK_DELETE_ROUTER, TASK_LIST_ROUTER, TASK_LOGS_ROUTER, TASK_RUN_ROUTER, UNINSTALL_PLUGIN_ROUTER, UNINSTALL_WEBUI_PLUGIN_ROUTER, UPDATE_CORE_ROUTER, UPDATE_PLUGIN_ROUTER, UPDATE_TASK_STATUS_ROUTER, UPDATE_WEBUI_PLUGIN_VERSION_ROUTER, WS_CLOSE, WS_CLOSE_ONEBOT, WS_CLOSE_PUPPETEER, WS_CLOSE_SANDBOX, WS_CONNECTION, WS_CONNECTION_ONEBOT, WS_CONNECTION_PUPPETEER, WS_CONNECTION_SANDBOX, WS_CONNECTION_TERMINAL, WS_SNAPKA, Watch, Watcher, YamlEditor, absPath, accordion, accordionItem, accordionPro, app3 as app, applyComments, authMiddleware, base64, basePath, buffer, buildGithub, buttonHandle, callRender, changelog_exports as changelog, checkGitPluginUpdate, checkPkgUpdate, clearRequire, clearRequireFile, comment, commentPath, common_exports as common, components, config_exports as config, configPath, consolePath, contact2 as contact, contactDirect, contactFriend, contactGroup, contactGroupTemp, contactGuild, copyConfig, copyConfigSync, copyFiles, copyFilesSync, createAccessTokenExpiredResponse, createBadRequestResponse, createClient2 as createClient, createDirectMessage, createForbiddenResponse, createFriendDecreaseNotice, createFriendIncreaseNotice, createFriendMessage, createGroupAdminChangedNotice, createGroupApplyRequest, createGroupCardChangedNotice, createGroupFileUploadedNotice, createGroupHlightsChangedNotice, createGroupHonorChangedNotice, createGroupInviteRequest, createGroupLuckKingNotice, createGroupMemberAddNotice, createGroupMemberBanNotice, createGroupMemberDelNotice, createGroupMemberTitleUpdatedNotice, createGroupMessage, createGroupMessageReactionNotice, createGroupPokeNotice, createGroupRecallNotice, createGroupSignInNotice, createGroupTempMessage, createGroupWholeBanNotice, createGuildMessage, createHttp, createINIParser, createMethodNotAllowedResponse, createNotFoundResponse, createPayloadTooLargeResponse, createPluginDir, createPrivateApplyRequest, createPrivateFileUploadedNotice, createPrivatePokeNotice, createPrivateRecallNotice, createRawMessage, createReceiveLikeNotice, createRefreshTokenExpiredResponse, createResponse, createServerErrorResponse, createSuccessResponse, createTaskDatabase, createUnauthorizedResponse, cron, dataPath, db, dbPath, debug2 as debug, karin as default, defaultConfigPath, defaultViewPath, defineConfig, divider, downFile, downloadFile, errorToString, exec, executeTask, existToMkdir, existToMkdirSync, exists, existsSync, ffmpeg, ffplay, ffprobe, fs_exports as file, fileToUrl, fileToUrlHandlerKey, filesByExt, formatPath, formatTime, fs_exports2 as fs, getAllBot, getAllBotID, getAllBotList, getAllFiles, getAllFilesSync, getBot, getBotCount, getCommit, getDefaultBranch, getFastGithub, getFastRegistry, getFiles, getHash, getLocalBranches, getLocalCommitHash, getMimeType, getPackageJson, getPid, getPkgVersion, getPluginInfo, getPlugins, getRelPath, getRemoteBranches, getRemoteCommitHash, getRemotePkgVersion, getRender, getRenderCount, getRenderList, getRequestIp, getTaskCallback, getTaskDatabase, getTime, gitPull, handler, hooks, htmlPath, importModule, ini, initOneBot, initTaskSystem, input, isClass, isDir, isDirSync, isDocker, isFile, isFileSync, isIPv4Loop, isIPv6Loop, isLinux, isLocalRequest, isLoopback, isMac, isPackaged, isPathEqual, isPkg, isPlugin, isPublic, isRoot, isSubPath, isWin2 as isWin, json, karin, karinDir, karinMain, karinPathBase, karinPathComment, karinPathConfig, karinPathConsole, karinPathData, karinPathDb, karinPathDefaultConfig, karinPathDefaultView, karinPathHtml, karinPathKv, karinPathLogs, karinPathMain, karinPathPlugins, karinPathPm2Config, karinPathRedisSqlite3, karinPathResource, karinPathRoot, karinPathSandboxData, karinPathSandboxTemp, karinPathTaskDb, karinPathTemp, karinToQQBot, key_exports as key, kvPath, lock, lockMethod, lockProp, log, logger2 as logger, logs, logsPath, makeForward, makeMessage, mkdir, mkdirSync, parseChangelog, parseGithubUrl, pingRequest, pkgRoot, pluginDir, pm2Path, qqbotToKarin, raceRequest, randomStr, range, read, readFile, readJson, readJsonSync, redis2 as redis, redisSqlite3Path, registerBot, registerRender, removeTaskCallback, render, renderHtml, renderMultiHtml, renderTpl, requireFile, requireFileSync, resourcePath, restart, restartDirect, rmSync, router, sandboxDataPath, sandboxTempPath, satisfies, save, segment_exports as segment, sendMsg2 as sendMsg, sender, senderDirect, senderFriend, senderGroup, senderGroupTemp, senderGuild, sep, server, setTaskCallback, setTaskDatabase, splitPath, start2 as start, stream, stringifyError, switchComponent, system_exports as system, taskAdd, taskExists, taskGet, taskList, taskSystem, taskUpdateLogs, taskUpdateStatus, tempPath, unregisterBot, unregisterRender, updateAllGitPlugin, updateAllPkg, updateGitPlugin, updatePkg, updateTaskLogs, updateTaskStatus, uptime, urlToPath, watch, watchAndMerge, write, writeJson, writeJsonSync, yaml3 as yaml };