node-karin 1.9.10 → 1.10.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # 更新日志
2
2
 
3
+ ## [1.10.0](https://github.com/KarinJS/Karin/compare/core-v1.9.11...core-v1.10.0) (2025-06-06)
4
+
5
+
6
+ ### ✨ Features
7
+
8
+ * **core:** 添加端口相关工具并优化 PID 获取逻辑 ([#457](https://github.com/KarinJS/Karin/issues/457)) ([dc4cda9](https://github.com/KarinJS/Karin/commit/dc4cda9889d52d4c2a4bd90992ce61c23ddf477d))
9
+
10
+
11
+ ### 🐛 Bug Fixes
12
+
13
+ * close [#460](https://github.com/KarinJS/Karin/issues/460) ([dd2bd1a](https://github.com/KarinJS/Karin/commit/dd2bd1aee7edd91dadf98617055426539b0881b8))
14
+ * 更新 HMR 日志输出,增加空插件列表提示 ([1d14be2](https://github.com/KarinJS/Karin/commit/1d14be295372096295af890bf45b53b8033e19be))
15
+
16
+
17
+ ### ⚡️ Performance
18
+
19
+ * **core:** 优化端口功能,添加结束指定PID或端口程序 ([#459](https://github.com/KarinJS/Karin/issues/459)) ([0d13395](https://github.com/KarinJS/Karin/commit/0d13395d610b36f306cf56231f732a2ff39c5582))
20
+
21
+ ## [1.9.11](https://github.com/KarinJS/Karin/compare/core-v1.9.10...core-v1.9.11) (2025-06-05)
22
+
23
+
24
+ ### 🐛 Bug Fixes
25
+
26
+ * 转换文件消息段错误 ([5048bd1](https://github.com/KarinJS/Karin/commit/5048bd1108a926086467563bc2f96a5605e68475))
27
+
3
28
  ## [1.9.10](https://github.com/KarinJS/Karin/compare/core-v1.9.9...core-v1.9.10) (2025-06-05)
4
29
 
5
30
 
package/dist/index.d.ts CHANGED
@@ -3207,9 +3207,11 @@ declare abstract class AdapterOneBot extends AdapterBase {
3207
3207
  eventHandlers(data: OB11AllEvent, str: string): void;
3208
3208
  /**
3209
3209
  * onebot11转karin
3210
+ * @param data onebot11格式消息
3211
+ * @param contact 联系人信息 如果需要转换napcat的文件消息则需要传入
3210
3212
  * @return karin格式消息
3211
3213
  */
3212
- AdapterConvertKarin(data: Array<OB11Segment>): Promise<Elements[]>;
3214
+ AdapterConvertKarin(data: Array<OB11Segment>, contact?: Contact): Promise<Elements[]>;
3213
3215
  /**
3214
3216
  * karin转onebot11
3215
3217
  * @param data karin格式消息
@@ -11237,7 +11239,7 @@ declare const isLocalRequest: (req: Request$1) => Promise<boolean>;
11237
11239
  * 传入端口号,返回对应的pid
11238
11240
  * @param port - 端口号
11239
11241
  */
11240
- declare const getPid: (port: number) => Promise<number>;
11242
+ declare const getPid: (port: number) => Promise<number | null>;
11241
11243
 
11242
11244
  /**
11243
11245
  * 执行 shell 命令
@@ -11303,6 +11305,28 @@ declare const stringifyError: (error?: Error | null) => {
11303
11305
  */
11304
11306
  declare const errorToString: (error?: Error | null) => string;
11305
11307
 
11308
+ /**
11309
+ * 检查端口是否可用
11310
+ * @param port - 端口号
11311
+ * @returns 端口可用返回true,否则返回false
11312
+ */
11313
+ declare const checkPort: (port: number) => Promise<boolean>;
11314
+ /**
11315
+ * 等待端口可用
11316
+ * @param port - 端口号
11317
+ * @param maxAttempts - 最大尝试次数
11318
+ * @param interval - 检查间隔(ms)
11319
+ * @returns 端口是否可用
11320
+ */
11321
+ declare const waitPort: (port: number, maxAttempts?: number, interval?: number) => Promise<boolean>;
11322
+ /**
11323
+ * 结束指定PID或端口的程序
11324
+ * @param identifier - PID号或端口号
11325
+ * @param isPort - 是否为端口号
11326
+ * @returns 是否成功结束程序
11327
+ */
11328
+ declare const killApp: (identifier: number, isPort?: boolean) => Promise<boolean>;
11329
+
11306
11330
  /**
11307
11331
  * @description ffmpeg命令
11308
11332
  * @param cmd 命令
@@ -11487,16 +11511,22 @@ declare const updateAllGitPlugin: (cmd?: string, time?: number) => Promise<strin
11487
11511
  * @param contact - 事件联系人信息 也就是从哪来的这条消息 传e.contact即可
11488
11512
  * @param messageId - 消息id 传e.message_id
11489
11513
  * @param isFront - 是否为前台重启 默认是 不支持的环境会强制为pm2重启
11514
+ * @param reloadDeps - 是否为重新加载依赖 默认是false
11490
11515
  */
11491
- declare const restart: (selfId: string, contact: Contact, messageId: string, isFront?: boolean) => Promise<{
11516
+ declare const restart: (selfId: string, contact: Contact, messageId: string, isFront?: boolean, reloadDeps?: boolean) => Promise<{
11492
11517
  status: "success" | "failed";
11493
11518
  data: string | Error;
11494
11519
  }>;
11495
11520
  /**
11496
11521
  * 直接重启
11497
- * @param isPm2 - 是否为pm2重启 默认false
11522
+ * @param options - 重启选项
11498
11523
  */
11499
- declare const restartDirect: (isPm2?: boolean) => Promise<void>;
11524
+ declare const restartDirect: (options: {
11525
+ /** 是否为pm2重启 */
11526
+ isPm2?: boolean;
11527
+ /** 是否为重新加载依赖 */
11528
+ reloadDeps?: boolean;
11529
+ }) => Promise<void>;
11500
11530
 
11501
11531
  /** fileToUrl Handler键 */
11502
11532
  declare const fileToUrlHandlerKey = "fileToUrl";
@@ -11507,39 +11537,40 @@ declare const fileToUrl: FileToUrlHandler;
11507
11537
 
11508
11538
  /**
11509
11539
  * 一个简单的版本范围检查函数
11510
- * @param range 版本范围
11540
+ * @param satisfies 版本范围
11511
11541
  * @param version 版本
11512
11542
  * @description 检查版本是否在范围内
11513
11543
  * @example
11514
11544
  * ```ts
11515
- * console.log(range('^1.0.0', '1.0.1')) // true
11516
- * console.log(range('^1.0.0', '2.0.0')) // false
11517
- * console.log(range('^1.0.0', '0.0.1')) // false
11518
- * console.log(range('>=1.0.0', '1.0.0')) // true
11519
- * console.log(range('>=1.0.0', '0.0.1')) // false
11520
- * console.log(range('<=1.0.0', '1.0.0')) // true
11521
- * console.log(range('<=1.0.0', '2.0.0')) // false
11522
- * console.log(range('>=1.0.0 <2.0.0', '1.0.0')) // true
11523
- * console.log(range('1.0.0-alpha', '1.0.0-beta')) // false
11524
- * console.log(range('1.0.0-beta', '1.0.0-alpha')) // false
11525
- * console.log(range('^1.0.0-beta', '1.0.0-alpha')) // false
11526
- * console.log(range('>=1.0.0-beta', '1.0.0-alpha')) // false
11527
- * console.log(range('^1.0.0-alpha', '1.0.0-beta')) // true
11528
- * console.log(range('^1.0.0-beta', '1.0.0-beta')) // true
11529
- * console.log(range('^1.0.0-alpha', '1.0.0-alpha')) // true
11545
+ * console.log(satisfies('^1.0.0', '1.0.1')) // true
11546
+ * console.log(satisfies('^1.0.0', '2.0.0')) // false
11547
+ * console.log(satisfies('^1.0.0', '0.0.1')) // false
11548
+ * console.log(satisfies('>=1.0.0', '1.0.0')) // true
11549
+ * console.log(satisfies('>=1.0.0', '0.0.1')) // false
11550
+ * console.log(satisfies('<=1.0.0', '1.0.0')) // true
11551
+ * console.log(satisfies('<=1.0.0', '2.0.0')) // false
11552
+ * console.log(satisfies('>=1.0.0 <2.0.0', '1.0.0')) // true
11553
+ * console.log(satisfies('1.0.0-alpha', '1.0.0-beta')) // false
11554
+ * console.log(satisfies('1.0.0-beta', '1.0.0-alpha')) // false
11555
+ * console.log(satisfies('^1.0.0-beta', '1.0.0-alpha')) // false
11556
+ * console.log(satisfies('>=1.0.0-beta', '1.0.0-alpha')) // false
11557
+ * console.log(satisfies('^1.0.0-alpha', '1.0.0-beta')) // true
11558
+ * console.log(satisfies('^1.0.0-beta', '1.0.0-beta')) // true
11559
+ * console.log(satisfies('^1.0.0-alpha', '1.0.0-alpha')) // true
11530
11560
  *
11531
11561
  * // 通配符示例
11532
- * console.log(range('1.0.x', '1.0.1')) // true
11533
- * console.log(range('1.0.x', '1.1.0')) // false
11534
- * console.log(range('1.x.x', '1.2.3')) // true
11535
- * console.log(range('1.x.0', '1.2.0')) // true
11536
- * console.log(range('1.x.0', '1.2.1')) // false
11562
+ * console.log(satisfies('1.0.x', '1.0.1')) // true
11563
+ * console.log(satisfies('1.0.x', '1.1.0')) // false
11564
+ * console.log(satisfies('1.x.x', '1.2.3')) // true
11565
+ * console.log(satisfies('1.x.0', '1.2.0')) // true
11566
+ * console.log(satisfies('1.x.0', '1.2.1')) // false
11537
11567
  * ```
11538
11568
  */
11539
- declare const satisfies: (range: string, version: string) => boolean;
11569
+ declare const satisfies: (satisfies: string, version: string) => boolean;
11540
11570
 
11541
11571
  declare const index$2_checkGitPluginUpdate: typeof checkGitPluginUpdate;
11542
11572
  declare const index$2_checkPkgUpdate: typeof checkPkgUpdate;
11573
+ declare const index$2_checkPort: typeof checkPort;
11543
11574
  declare const index$2_errorToString: typeof errorToString;
11544
11575
  declare const index$2_exec: typeof exec;
11545
11576
  declare const index$2_ffmpeg: typeof ffmpeg;
@@ -11565,6 +11596,10 @@ declare const index$2_isLoopback: typeof isLoopback;
11565
11596
  declare const index$2_isMac: typeof isMac;
11566
11597
  declare const index$2_isRoot: typeof isRoot;
11567
11598
  declare const index$2_isWin: typeof isWin;
11599
+ declare const index$2_killApp: typeof killApp;
11600
+ declare const index$2_lock: typeof lock;
11601
+ declare const index$2_lockMethod: typeof lockMethod;
11602
+ declare const index$2_lockProp: typeof lockProp;
11568
11603
  declare const index$2_restart: typeof restart;
11569
11604
  declare const index$2_restartDirect: typeof restartDirect;
11570
11605
  declare const index$2_satisfies: typeof satisfies;
@@ -11573,8 +11608,9 @@ declare const index$2_updateAllGitPlugin: typeof updateAllGitPlugin;
11573
11608
  declare const index$2_updateAllPkg: typeof updateAllPkg;
11574
11609
  declare const index$2_updateGitPlugin: typeof updateGitPlugin;
11575
11610
  declare const index$2_updatePkg: typeof updatePkg;
11611
+ declare const index$2_waitPort: typeof waitPort;
11576
11612
  declare namespace index$2 {
11577
- export { index$2_checkGitPluginUpdate as checkGitPluginUpdate, index$2_checkPkgUpdate as checkPkgUpdate, index$2_errorToString as errorToString, index$2_exec as exec, index$2_ffmpeg as ffmpeg, index$2_ffplay as ffplay, index$2_ffprobe as ffprobe, index$2_fileToUrl as fileToUrl, index$2_fileToUrlHandlerKey as fileToUrlHandlerKey, formatTime$1 as formatTime, index$2_getCommit as getCommit, index$2_getHash as getHash, index$2_getPid as getPid, index$2_getPkgVersion as getPkgVersion, index$2_getRemotePkgVersion as getRemotePkgVersion, index$2_getRequestIp as getRequestIp, index$2_getTime as getTime, index$2_importModule as importModule, index$2_isClass as isClass, index$2_isDocker as isDocker, index$2_isIPv4Loop as isIPv4Loop, index$2_isIPv6Loop as isIPv6Loop, index$2_isLinux as isLinux, index$2_isLocalRequest as isLocalRequest, index$2_isLoopback as isLoopback, index$2_isMac as isMac, index$2_isRoot as isRoot, index$2_isWin as isWin, index$2_restart as restart, index$2_restartDirect as restartDirect, index$2_satisfies as satisfies, index$2_stringifyError as stringifyError, index$2_updateAllGitPlugin as updateAllGitPlugin, index$2_updateAllPkg as updateAllPkg, index$2_updateGitPlugin as updateGitPlugin, index$2_updatePkg as updatePkg, uptime$1 as uptime };
11613
+ export { index$2_checkGitPluginUpdate as checkGitPluginUpdate, index$2_checkPkgUpdate as checkPkgUpdate, index$2_checkPort as checkPort, index$2_errorToString as errorToString, index$2_exec as exec, index$2_ffmpeg as ffmpeg, index$2_ffplay as ffplay, index$2_ffprobe as ffprobe, index$2_fileToUrl as fileToUrl, index$2_fileToUrlHandlerKey as fileToUrlHandlerKey, formatTime$1 as formatTime, index$2_getCommit as getCommit, index$2_getHash as getHash, index$2_getPid as getPid, index$2_getPkgVersion as getPkgVersion, index$2_getRemotePkgVersion as getRemotePkgVersion, index$2_getRequestIp as getRequestIp, index$2_getTime as getTime, index$2_importModule as importModule, index$2_isClass as isClass, index$2_isDocker as isDocker, index$2_isIPv4Loop as isIPv4Loop, index$2_isIPv6Loop as isIPv6Loop, index$2_isLinux as isLinux, index$2_isLocalRequest as isLocalRequest, index$2_isLoopback as isLoopback, index$2_isMac as isMac, index$2_isRoot as isRoot, index$2_isWin as isWin, index$2_killApp as killApp, index$2_lock as lock, index$2_lockMethod as lockMethod, index$2_lockProp as lockProp, index$2_restart as restart, index$2_restartDirect as restartDirect, index$2_satisfies as satisfies, index$2_stringifyError as stringifyError, index$2_updateAllGitPlugin as updateAllGitPlugin, index$2_updateAllPkg as updateAllPkg, index$2_updateGitPlugin as updateGitPlugin, index$2_updatePkg as updatePkg, uptime$1 as uptime, index$2_waitPort as waitPort };
11578
11614
  }
11579
11615
 
11580
11616
  /**
@@ -13683,4 +13719,4 @@ type Client = RedisClientType & {
13683
13719
  */
13684
13720
  declare const start: () => Promise<void>;
13685
13721
 
13686
- export { type Accept, type AccordionItemProps, type AccordionKV, type AccordionProProps, type AccordionProResult, type AccordionProps, type AccordionResult, type AccountInfo, type Adapter, AdapterBase, type AdapterCommunication, type AdapterInfo, AdapterOneBot, type AdapterOptions, type AdapterPlatform, type AdapterProtocol, type AdapterStandard, type AdapterType, type Adapters, type AddDependenciesParams, type AddTaskResult, type AfterForwardMessageCallback, type AfterMessageCallback, type AllPluginMethods, type AnonymousSegment, type Apps, type ArrayField, type AtElement, type AtSegment, type Author, BASE_ROUTER, BATCH_UPDATE_PLUGINS_ROUTER, type BaseContact, BaseEvent, type BaseEventOptions, type BaseEventType, type BaseForwardCallback, type BaseMessageCallback, type BasketballElement, Bot, type BoundingBox, type BubbleFaceElement, type Button, type ButtonElement, CHECK_PLUGIN_ROUTER, CLOSE_TERMINAL_ROUTER, CONSOLE_ROUTER, CREATE_TERMINAL_ROUTER, type Cache, type CacheEntry, type CheckboxField, type CheckboxGroupProps, type CheckboxProps, type CheckboxResult, type Children, type CmdFnc, type Command, type CommandClass, type ComponentConfig, type ComponentProps, type ComponentType, type Components, type ComponentsClass, type Config, type Contact, type ContactElement, type ContactSegment, type Count, type CreateGroupFolderResponse, type CreatePty, type CreateTask, type CreateTaskParams, type CreateTaskResult, type CronProps, type CustomMusicElement, type CustomMusicSegment, type CustomNodeElement, type CustomNodeSegments, type DbStreamStatus, type DbStreams, type DefineConfig, type DependenciesManage, type DependenciesManageBase, type Dependency, type DiceElement, type DiceSegment, type DirectContact, DirectMessage, type DirectMessageOptions, type DirectNodeElement, type DirectNodeSegment, type DirectSender, type DividerField, type DividerProps, type DownloadFileErrorResult, type DownloadFileOptions, type DownloadFileResponse, type DownloadFileResult, type DownloadFileSuccessResult, type DownloadFilesOptions, EVENT_COUNT, EXIT_ROUTER, type ElementTypes, type Elements, type Env, type Event, type EventCallCallback, type EventCallHookItem, type EventParent, type EventToSubEvent, type ExecOptions$1 as ExecOptions, type ExecReturn, type ExecType, type ExtendedAxiosRequestConfig, FILE_CHANGE, type FaceElement, type FaceSegment, type FieldType, type FileElement, type FileList, type FileListMap, type FileSegment, type FileToUrlHandler, type FileToUrlResult, type FormField, type ForwardMessageCallback, type ForwardOptions, type ForwardSegment, type FriendContact, type FriendData, FriendDecreaseNotice, type FriendDecreaseOptions, FriendIncreaseNotice, type FriendIncreaseOptions, FriendMessage, type FriendMessageOptions, type FriendNoticeEventMap, type FriendRequestEventMap, type FriendRequestOptions, type FriendSender, 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, type GeneralHookCallback, type GeneralHookItem, type GetAtAllCountResponse, type GetBot, type GetCommitHashOptions, type GetConfigRequest, type GetConfigResponse, type GetGroupFileListResponse, type GetGroupFileSystemInfoResponse, type GetGroupHighlightsResponse, type GetGroupInfo, type GetGroupMemberInfo, type GetGroupMuteListResponse, type GetMsg, type GetPluginLocalOptions, type GetPluginLocalReturn, type GetPluginReturn, type GetPluginType, type GiftElement, type GitLocalBranches, type GitPullOptions, type GitPullResult, type GitRemoteBranches, type GithubConfig, type GoToOptions, GroupAdminChangedNotice, type GroupAdminChangedOptions, GroupApplyRequest, type GroupApplyRequestOptions, GroupCardChangedNotice, type GroupCardChangedOptions, type GroupContact, type GroupData, GroupFileUploadedNotice, type GroupFileUploadedOptions, GroupHlightsChangedNotice, type GroupHlightsChangedOptions, GroupHonorChangedNotice, type GroupHonorChangedOptions, type GroupInfo, GroupInviteRequest, type GroupInviteRequestOptions, GroupLuckKingNotice, type GroupLuckKingOptions, GroupMemberBanNotice, type GroupMemberBanOptions, type GroupMemberData, GroupMemberDecreaseNotice, type GroupMemberDecreaseOptions, GroupMemberIncreaseNotice, type GroupMemberIncreaseOptions, type GroupMemberInfo, GroupMemberTitleUpdatedNotice, type GroupMemberUniqueTitleChangedOptions, GroupMessage, type GroupMessageOptions, GroupMessageReactionNotice, type GroupMessageReactionOptions, GroupNotice, type GroupNoticeEventMap, GroupPokeNotice, type GroupPokeOptions, GroupRecallNotice, type GroupRecallOptions, type GroupRequestEventMap, type GroupSender, GroupSignInNotice, type GroupSignInOptions, type GroupTempContact, GroupTempMessage, type GroupTempMessageOptions, type GroupTempSender, GroupWholeBanNotice, type GroupWholeBanOptions, type Groups, type GroupsObjectValue, type GuildContact, GuildMessage, type GuildMessageOptions, type GuildSender, HTTPStatusCode, type Handler, type HandlerType, type HonorInfoList, type HookCache, type HookCallback, type HookEmitForward, type HookEmitMessage, type HookNext, type HookOptions, type HooksType, INSTALL_PLUGIN_ROUTER, INSTALL_WEBUI_PLUGIN_ROUTER, IS_PLUGIN_CONFIG_EXIST_ROUTER, type Icon, type ImageElement, type ImageSegment, type ImportModuleResult, type InputGroupProps, type InputProps, type InputResult, type JsonElement, type JsonSegment, type JwtVerifyBase, type JwtVerifyError, type JwtVerifyExpired, type JwtVerifyResult, type JwtVerifySuccess, type JwtVerifyUnauthorized, type KarinButton, type KarinPluginAppsType, type KeyboardElement, LOGIN_ROUTER, type LoadPluginResult, type LoadedPluginCacheList, type LocalApiResponse, type LocationElement, type LocationSegment, type Log, LogMethodNames, Logger, LoggerLevel, type LongMsgElement, MANAGE_DEPENDENCIES_ROUTER, type MarkdownElement, type MarkdownTplElement, type MarketFaceElement, type Message$2 as Message, MessageBase, type MessageEventMap, type MessageEventSub, type MessageHookItem, type MessageOptions, type MessageResponse, type MetaEventBase, type MusicElement, type MusicPlatform, type MusicSegment, type NetworkStatus, type NodeElement, type NormalMessageCallback, type Notice, type NoticeAndRequest, NoticeBase, type NoticeEventMap, type NoticeEventSub, type NoticeOptions, type NpmBaseConfigResponse, type NpmrcFileResponse, type NumberField, type OB11AllEvent, OB11ApiAction, type OB11ApiParams, type OB11ApiRequest, OB11Event, type OB11EventBase, type OB11FriendSender, type OB11GroupMessage, type OB11GroupSender, type OB11GroupTempMessage, type OB11Message, OB11MessageSubType, OB11MessageType, type OB11Meta, type OB11NodeSegment, type OB11Notice, type OB11NoticeBaseType, OB11NoticeType, type OB11OtherFriendMessage, type OB11PrivateMessage, type OB11Request, type OB11RequestBaseType, OB11RequestType, type OB11Segment, type OB11SegmentBase, type OB11SegmentType, OB11Sex, type OB11serInfo, type ObjectArrayField, type ObjectField, type OneBot11FriendAdd, type OneBot11FriendOfflineFile, type OneBot11FriendRecall, type OneBot11FriendRequest, type OneBot11GroupAdmin, type OneBot11GroupBan, type OneBot11GroupCard, type OneBot11GroupDecrease, type OneBot11GroupEssence, type OneBot11GroupIncrease, type OneBot11GroupMessageReaction, type OneBot11GroupMessageReactionLagrange, type OneBot11GroupRecall, type OneBot11GroupRequest, type OneBot11GroupUpload, type OneBot11Heartbeat, type OneBot11Honor, type OneBot11Lifecycle, type OneBot11LuckyKing, type OneBot11Poke, type Option, type Options, PING_ROUTER, PLUGIN_ADMIN_ROUTER, type PM2, type Package, type Parser, type PasmsgElement, type Permission, type PingRequestResult, type PkgData, type PkgEnv, type PkgInfo, Plugin$1 as Plugin, type PluginAdminCustomInstall, type PluginAdminCustomInstallApp, type PluginAdminInstall, type PluginAdminListResponse, type PluginAdminMarketInstall, type PluginAdminMarketInstallApp, type PluginAdminParams, type PluginAdminResult, type PluginAdminUninstall, type PluginAdminUpdate, type PluginFile, type PluginFncTypes, type PluginLists, type PluginMarketAuthor, type PluginMarketLocalBase, type PluginMarketLocalOptions, type PluginMarketOptions, type PluginMarketRequest, type PluginMarketResponse, type PluginOptions, type PluginRule, type PluginUpdateInfo, type PnpmDependencies, type PnpmDependency, type Point, type PokeSegment, PrivateApplyRequest, type PrivateApplyRequestOptions, PrivateFileUploadedNotice, type PrivateFileUploadedOptions, PrivatePokeNotice, type PrivatePokeOptions, PrivateRecallNotice, type PrivateRecallOptions, type Privates, type PrivatesObjectValue, type PuppeteerLifeCycleEvent, type QQBotButton, type QQButtonTextType, type QQGroupFileInfo, type QQGroupFolderInfo, type QQGroupHonorInfo, RECV_MSG, REFRESH_ROUTER, RESTART_ROUTER, type RaceResult, type Radio, type RadioField, type RadioGroupProps, type RadioResult, type RawElement, type ReadyMusicElement, ReceiveLikeNotice, type ReceiveLikeOptions, type RecordElement, type RecordSegment, type Redis, type RemoveDependenciesParams, type Render, type RenderResult, Renderer, type Renders$1 as Renders, type Reply, type ReplyElement, type ReplySegment, type Request, RequestBase, type RequestEventMap, type RequestEventSub, type RequestOptions, type RequireFunction, type RequireFunctionSync, type RequireOptions, type Role, type RpsElement, type RpsSegment, 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, type SandBoxAccountInfo, type SandboxMsgRecord, type SandboxSendApi, type SandboxSendSendFriendMsg, type SandboxSendSendGroupMsg, type SandboxSendSendMsg, type SaveConfigResponse, type SaveResult, type Scene, type ScreenshotClip, type ScreenshotOptions, type SectionField, type Segment, type SelectField, type SendElement, type SendForwardMessageResponse, type SendMessage, type SendMsgHookItem, type SendMsgResults, type Sender, type SenderBase, type SenderGroup, type Sex, type ShakeSegment, type ShareElement, type ShareSegment, type Snapka, type SnapkaResult, type SrcReply, type StandardResult, type SwitchField, type SwitchProps, type SwitchResult, TASK_DELETE_ROUTER, TASK_LIST_ROUTER, TASK_LOGS_ROUTER, TASK_RUN_ROUTER, type Task, type TaskCallbacks, type TaskEntity, type TaskExecutor, type TaskFilter, type TaskStatus, type TaskType, type TerminalInstance, type TerminalShell, type TestNetworkRequestDetail, type TextElement, type TextField, type TextSegment, type TitleField, UNINSTALL_PLUGIN_ROUTER, UNINSTALL_WEBUI_PLUGIN_ROUTER, UPDATE_CORE_ROUTER, UPDATE_PLUGIN_ROUTER, UPDATE_TASK_STATUS_ROUTER, UPDATE_WEBUI_PLUGIN_VERSION_ROUTER, type UnionMessage, type UnregisterBot, type UpgradeDependenciesParams, type UserInfo, type ValidationRule, type ValueType, type VideoElement, type VideoSegment, 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, type WaitForOptions, Watch, Watcher, type WeatherElement, type XmlElement, type XmlSegment, type YamlComment, YamlEditor, type YamlValue, absPath, accordion, accordionItem, accordionPro, app, applyComments, authMiddleware, base64, buffer, buildGithub, buttonHandle, callRender, changelog, checkGitPluginUpdate, checkPkgUpdate, clearRequire, clearRequireFile, comment, index$1 as common, components, index as config, contact$1 as contact, contactDirect, contactFriend, contactGroup, contactGroupTemp, contactGuild, copyConfig, copyConfigSync, copyFiles, copyFilesSync, createAccessTokenExpiredResponse, createBadRequestResponse, 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, db, debug, karin as default, defineConfig, divider, downFile, downloadFile, errorToString, exec, executeTask, existToMkdir, existToMkdirSync, exists, existsSync, ffmpeg, ffplay, ffprobe, fs as file, fileToUrl, fileToUrlHandlerKey, filesByExt, formatPath, formatTime$1 as formatTime, index$3 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$1 as handler, hooks, importModule, ini, initOneBot, initTaskSystem, input, isClass, isDir, isDirSync, isDocker, isFile, isFileSync, isIPv4Loop, isIPv6Loop, isLinux, isLocalRequest, isLoopback, isMac, isPathEqual, isPlugin, isPublic, isRoot, isSubPath, isWin, json$1 as json, karin, karinToQQBot, key, lock, lockMethod, lockProp, log, logger, logs, makeForward, makeMessage, type messageType, mkdir, mkdirSync, parseChangelog, parseGithubUrl, pingRequest, pkgRoot, qqbotToKarin, raceRequest, randomStr, range, read, readFile, readJson, readJsonSync, redis, registerBot, registerRender, removeTaskCallback, render, renderHtml, renderMultiHtml, renderTpl, requireFile, requireFileSync, restart, restartDirect, rmSync, router, satisfies, save, type screenshot, segment, sendMsg$1 as sendMsg, sender, senderDirect, senderFriend, senderGroup, senderGroupTemp, senderGuild, sep, server, setTaskCallback, setTaskDatabase, splitPath, start, stream, stringifyError, switchComponent, index$2 as system, taskAdd, taskExists, taskGet, taskList, taskSystem, taskUpdateLogs, taskUpdateStatus, unregisterBot, unregisterRender, updateAllGitPlugin, updateAllPkg, updateGitPlugin, updatePkg, updateTaskLogs, updateTaskStatus, uptime$1 as uptime, urlToPath, watch, watchAndMerge, write, writeJson, writeJsonSync, yaml };
13722
+ export { type Accept, type AccordionItemProps, type AccordionKV, type AccordionProProps, type AccordionProResult, type AccordionProps, type AccordionResult, type AccountInfo, type Adapter, AdapterBase, type AdapterCommunication, type AdapterInfo, AdapterOneBot, type AdapterOptions, type AdapterPlatform, type AdapterProtocol, type AdapterStandard, type AdapterType, type Adapters, type AddDependenciesParams, type AddTaskResult, type AfterForwardMessageCallback, type AfterMessageCallback, type AllPluginMethods, type AnonymousSegment, type Apps, type ArrayField, type AtElement, type AtSegment, type Author, BASE_ROUTER, BATCH_UPDATE_PLUGINS_ROUTER, type BaseContact, BaseEvent, type BaseEventOptions, type BaseEventType, type BaseForwardCallback, type BaseMessageCallback, type BasketballElement, Bot, type BoundingBox, type BubbleFaceElement, type Button, type ButtonElement, CHECK_PLUGIN_ROUTER, CLOSE_TERMINAL_ROUTER, CONSOLE_ROUTER, CREATE_TERMINAL_ROUTER, type Cache, type CacheEntry, type CheckboxField, type CheckboxGroupProps, type CheckboxProps, type CheckboxResult, type Children, type CmdFnc, type Command, type CommandClass, type ComponentConfig, type ComponentProps, type ComponentType, type Components, type ComponentsClass, type Config, type Contact, type ContactElement, type ContactSegment, type Count, type CreateGroupFolderResponse, type CreatePty, type CreateTask, type CreateTaskParams, type CreateTaskResult, type CronProps, type CustomMusicElement, type CustomMusicSegment, type CustomNodeElement, type CustomNodeSegments, type DbStreamStatus, type DbStreams, type DefineConfig, type DependenciesManage, type DependenciesManageBase, type Dependency, type DiceElement, type DiceSegment, type DirectContact, DirectMessage, type DirectMessageOptions, type DirectNodeElement, type DirectNodeSegment, type DirectSender, type DividerField, type DividerProps, type DownloadFileErrorResult, type DownloadFileOptions, type DownloadFileResponse, type DownloadFileResult, type DownloadFileSuccessResult, type DownloadFilesOptions, EVENT_COUNT, EXIT_ROUTER, type ElementTypes, type Elements, type Env, type Event, type EventCallCallback, type EventCallHookItem, type EventParent, type EventToSubEvent, type ExecOptions$1 as ExecOptions, type ExecReturn, type ExecType, type ExtendedAxiosRequestConfig, FILE_CHANGE, type FaceElement, type FaceSegment, type FieldType, type FileElement, type FileList, type FileListMap, type FileSegment, type FileToUrlHandler, type FileToUrlResult, type FormField, type ForwardMessageCallback, type ForwardOptions, type ForwardSegment, type FriendContact, type FriendData, FriendDecreaseNotice, type FriendDecreaseOptions, FriendIncreaseNotice, type FriendIncreaseOptions, FriendMessage, type FriendMessageOptions, type FriendNoticeEventMap, type FriendRequestEventMap, type FriendRequestOptions, type FriendSender, 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, type GeneralHookCallback, type GeneralHookItem, type GetAtAllCountResponse, type GetBot, type GetCommitHashOptions, type GetConfigRequest, type GetConfigResponse, type GetGroupFileListResponse, type GetGroupFileSystemInfoResponse, type GetGroupHighlightsResponse, type GetGroupInfo, type GetGroupMemberInfo, type GetGroupMuteListResponse, type GetMsg, type GetPluginLocalOptions, type GetPluginLocalReturn, type GetPluginReturn, type GetPluginType, type GiftElement, type GitLocalBranches, type GitPullOptions, type GitPullResult, type GitRemoteBranches, type GithubConfig, type GoToOptions, GroupAdminChangedNotice, type GroupAdminChangedOptions, GroupApplyRequest, type GroupApplyRequestOptions, GroupCardChangedNotice, type GroupCardChangedOptions, type GroupContact, type GroupData, GroupFileUploadedNotice, type GroupFileUploadedOptions, GroupHlightsChangedNotice, type GroupHlightsChangedOptions, GroupHonorChangedNotice, type GroupHonorChangedOptions, type GroupInfo, GroupInviteRequest, type GroupInviteRequestOptions, GroupLuckKingNotice, type GroupLuckKingOptions, GroupMemberBanNotice, type GroupMemberBanOptions, type GroupMemberData, GroupMemberDecreaseNotice, type GroupMemberDecreaseOptions, GroupMemberIncreaseNotice, type GroupMemberIncreaseOptions, type GroupMemberInfo, GroupMemberTitleUpdatedNotice, type GroupMemberUniqueTitleChangedOptions, GroupMessage, type GroupMessageOptions, GroupMessageReactionNotice, type GroupMessageReactionOptions, GroupNotice, type GroupNoticeEventMap, GroupPokeNotice, type GroupPokeOptions, GroupRecallNotice, type GroupRecallOptions, type GroupRequestEventMap, type GroupSender, GroupSignInNotice, type GroupSignInOptions, type GroupTempContact, GroupTempMessage, type GroupTempMessageOptions, type GroupTempSender, GroupWholeBanNotice, type GroupWholeBanOptions, type Groups, type GroupsObjectValue, type GuildContact, GuildMessage, type GuildMessageOptions, type GuildSender, HTTPStatusCode, type Handler, type HandlerType, type HonorInfoList, type HookCache, type HookCallback, type HookEmitForward, type HookEmitMessage, type HookNext, type HookOptions, type HooksType, INSTALL_PLUGIN_ROUTER, INSTALL_WEBUI_PLUGIN_ROUTER, IS_PLUGIN_CONFIG_EXIST_ROUTER, type Icon, type ImageElement, type ImageSegment, type ImportModuleResult, type InputGroupProps, type InputProps, type InputResult, type JsonElement, type JsonSegment, type JwtVerifyBase, type JwtVerifyError, type JwtVerifyExpired, type JwtVerifyResult, type JwtVerifySuccess, type JwtVerifyUnauthorized, type KarinButton, type KarinPluginAppsType, type KeyboardElement, LOGIN_ROUTER, type LoadPluginResult, type LoadedPluginCacheList, type LocalApiResponse, type LocationElement, type LocationSegment, type Log, LogMethodNames, Logger, LoggerLevel, type LongMsgElement, MANAGE_DEPENDENCIES_ROUTER, type MarkdownElement, type MarkdownTplElement, type MarketFaceElement, type Message$2 as Message, MessageBase, type MessageEventMap, type MessageEventSub, type MessageHookItem, type MessageOptions, type MessageResponse, type MetaEventBase, type MusicElement, type MusicPlatform, type MusicSegment, type NetworkStatus, type NodeElement, type NormalMessageCallback, type Notice, type NoticeAndRequest, NoticeBase, type NoticeEventMap, type NoticeEventSub, type NoticeOptions, type NpmBaseConfigResponse, type NpmrcFileResponse, type NumberField, type OB11AllEvent, OB11ApiAction, type OB11ApiParams, type OB11ApiRequest, OB11Event, type OB11EventBase, type OB11FriendSender, type OB11GroupMessage, type OB11GroupSender, type OB11GroupTempMessage, type OB11Message, OB11MessageSubType, OB11MessageType, type OB11Meta, type OB11NodeSegment, type OB11Notice, type OB11NoticeBaseType, OB11NoticeType, type OB11OtherFriendMessage, type OB11PrivateMessage, type OB11Request, type OB11RequestBaseType, OB11RequestType, type OB11Segment, type OB11SegmentBase, type OB11SegmentType, OB11Sex, type OB11serInfo, type ObjectArrayField, type ObjectField, type OneBot11FriendAdd, type OneBot11FriendOfflineFile, type OneBot11FriendRecall, type OneBot11FriendRequest, type OneBot11GroupAdmin, type OneBot11GroupBan, type OneBot11GroupCard, type OneBot11GroupDecrease, type OneBot11GroupEssence, type OneBot11GroupIncrease, type OneBot11GroupMessageReaction, type OneBot11GroupMessageReactionLagrange, type OneBot11GroupRecall, type OneBot11GroupRequest, type OneBot11GroupUpload, type OneBot11Heartbeat, type OneBot11Honor, type OneBot11Lifecycle, type OneBot11LuckyKing, type OneBot11Poke, type Option, type Options, PING_ROUTER, PLUGIN_ADMIN_ROUTER, type PM2, type Package, type Parser, type PasmsgElement, type Permission, type PingRequestResult, type PkgData, type PkgEnv, type PkgInfo, Plugin$1 as Plugin, type PluginAdminCustomInstall, type PluginAdminCustomInstallApp, type PluginAdminInstall, type PluginAdminListResponse, type PluginAdminMarketInstall, type PluginAdminMarketInstallApp, type PluginAdminParams, type PluginAdminResult, type PluginAdminUninstall, type PluginAdminUpdate, type PluginFile, type PluginFncTypes, type PluginLists, type PluginMarketAuthor, type PluginMarketLocalBase, type PluginMarketLocalOptions, type PluginMarketOptions, type PluginMarketRequest, type PluginMarketResponse, type PluginOptions, type PluginRule, type PluginUpdateInfo, type PnpmDependencies, type PnpmDependency, type Point, type PokeSegment, PrivateApplyRequest, type PrivateApplyRequestOptions, PrivateFileUploadedNotice, type PrivateFileUploadedOptions, PrivatePokeNotice, type PrivatePokeOptions, PrivateRecallNotice, type PrivateRecallOptions, type Privates, type PrivatesObjectValue, type PuppeteerLifeCycleEvent, type QQBotButton, type QQButtonTextType, type QQGroupFileInfo, type QQGroupFolderInfo, type QQGroupHonorInfo, RECV_MSG, REFRESH_ROUTER, RESTART_ROUTER, type RaceResult, type Radio, type RadioField, type RadioGroupProps, type RadioResult, type RawElement, type ReadyMusicElement, ReceiveLikeNotice, type ReceiveLikeOptions, type RecordElement, type RecordSegment, type Redis, type RemoveDependenciesParams, type Render, type RenderResult, Renderer, type Renders$1 as Renders, type Reply, type ReplyElement, type ReplySegment, type Request, RequestBase, type RequestEventMap, type RequestEventSub, type RequestOptions, type RequireFunction, type RequireFunctionSync, type RequireOptions, type Role, type RpsElement, type RpsSegment, 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, type SandBoxAccountInfo, type SandboxMsgRecord, type SandboxSendApi, type SandboxSendSendFriendMsg, type SandboxSendSendGroupMsg, type SandboxSendSendMsg, type SaveConfigResponse, type SaveResult, type Scene, type ScreenshotClip, type ScreenshotOptions, type SectionField, type Segment, type SelectField, type SendElement, type SendForwardMessageResponse, type SendMessage, type SendMsgHookItem, type SendMsgResults, type Sender, type SenderBase, type SenderGroup, type Sex, type ShakeSegment, type ShareElement, type ShareSegment, type Snapka, type SnapkaResult, type SrcReply, type StandardResult, type SwitchField, type SwitchProps, type SwitchResult, TASK_DELETE_ROUTER, TASK_LIST_ROUTER, TASK_LOGS_ROUTER, TASK_RUN_ROUTER, type Task, type TaskCallbacks, type TaskEntity, type TaskExecutor, type TaskFilter, type TaskStatus, type TaskType, type TerminalInstance, type TerminalShell, type TestNetworkRequestDetail, type TextElement, type TextField, type TextSegment, type TitleField, UNINSTALL_PLUGIN_ROUTER, UNINSTALL_WEBUI_PLUGIN_ROUTER, UPDATE_CORE_ROUTER, UPDATE_PLUGIN_ROUTER, UPDATE_TASK_STATUS_ROUTER, UPDATE_WEBUI_PLUGIN_VERSION_ROUTER, type UnionMessage, type UnregisterBot, type UpgradeDependenciesParams, type UserInfo, type ValidationRule, type ValueType, type VideoElement, type VideoSegment, 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, type WaitForOptions, Watch, Watcher, type WeatherElement, type XmlElement, type XmlSegment, type YamlComment, YamlEditor, type YamlValue, absPath, accordion, accordionItem, accordionPro, app, applyComments, authMiddleware, base64, buffer, buildGithub, buttonHandle, callRender, changelog, checkGitPluginUpdate, checkPkgUpdate, checkPort, clearRequire, clearRequireFile, comment, index$1 as common, components, index as config, contact$1 as contact, contactDirect, contactFriend, contactGroup, contactGroupTemp, contactGuild, copyConfig, copyConfigSync, copyFiles, copyFilesSync, createAccessTokenExpiredResponse, createBadRequestResponse, 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, db, debug, karin as default, defineConfig, divider, downFile, downloadFile, errorToString, exec, executeTask, existToMkdir, existToMkdirSync, exists, existsSync, ffmpeg, ffplay, ffprobe, fs as file, fileToUrl, fileToUrlHandlerKey, filesByExt, formatPath, formatTime$1 as formatTime, index$3 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$1 as handler, hooks, importModule, ini, initOneBot, initTaskSystem, input, isClass, isDir, isDirSync, isDocker, isFile, isFileSync, isIPv4Loop, isIPv6Loop, isLinux, isLocalRequest, isLoopback, isMac, isPathEqual, isPlugin, isPublic, isRoot, isSubPath, isWin, json$1 as json, karin, karinToQQBot, key, killApp, lock, lockMethod, lockProp, log, logger, logs, makeForward, makeMessage, type messageType, mkdir, mkdirSync, parseChangelog, parseGithubUrl, pingRequest, pkgRoot, qqbotToKarin, raceRequest, randomStr, range, read, readFile, readJson, readJsonSync, redis, registerBot, registerRender, removeTaskCallback, render, renderHtml, renderMultiHtml, renderTpl, requireFile, requireFileSync, restart, restartDirect, rmSync, router, satisfies, save, type screenshot, segment, sendMsg$1 as sendMsg, sender, senderDirect, senderFriend, senderGroup, senderGroupTemp, senderGuild, sep, server, setTaskCallback, setTaskDatabase, splitPath, start, stream, stringifyError, switchComponent, index$2 as system, taskAdd, taskExists, taskGet, taskList, taskSystem, taskUpdateLogs, taskUpdateStatus, unregisterBot, unregisterRender, updateAllGitPlugin, updateAllPkg, updateGitPlugin, updatePkg, updateTaskLogs, updateTaskStatus, uptime$1 as uptime, urlToPath, waitPort, watch, watchAndMerge, write, writeJson, writeJsonSync, yaml };
package/dist/index.mjs CHANGED
@@ -22,6 +22,7 @@ import os, { homedir } from 'node:os';
22
22
  import chalk2 from 'chalk';
23
23
  import log4js from 'log4js';
24
24
  import { lookup } from 'dns/promises';
25
+ import { createServer as createServer$1 } from 'node:net';
25
26
  import sqlite3 from 'sqlite3';
26
27
  import WebSocket$1, { WebSocket, WebSocketServer } from 'ws';
27
28
  import require$$02 from 'buffer';
@@ -29,7 +30,6 @@ import require$$32 from 'stream';
29
30
  import require$$5 from 'util';
30
31
  import template from 'art-template';
31
32
  import schedule from 'node-schedule';
32
- import { createServer as createServer$1 } from 'node:net';
33
33
  import moment from 'moment';
34
34
  import { createClient } from 'redis';
35
35
  import express2, { Router } from 'express';
@@ -7624,7 +7624,7 @@ var init_message5 = __esm({
7624
7624
  messageId: event.message_id + "",
7625
7625
  messageSeq: event.message_id,
7626
7626
  eventId: `message:${event.message_id}`,
7627
- elements: await AdapterConvertKarin(event.message, bot),
7627
+ elements: await AdapterConvertKarin(event.message, bot, contact3),
7628
7628
  srcReply: (elements) => bot.sendMsg(contact3, elements)
7629
7629
  });
7630
7630
  return;
@@ -7637,7 +7637,7 @@ var init_message5 = __esm({
7637
7637
  createGroupTempMessage({
7638
7638
  bot,
7639
7639
  contact: contact3,
7640
- elements: await AdapterConvertKarin(event.message, bot),
7640
+ elements: await AdapterConvertKarin(event.message, bot, contact3),
7641
7641
  eventId: `message:${event.message_id}`,
7642
7642
  messageId: event.message_id + "",
7643
7643
  messageSeq: event.message_id,
@@ -7660,7 +7660,7 @@ var init_message5 = __esm({
7660
7660
  createGroupMessage({
7661
7661
  bot,
7662
7662
  contact: contact3,
7663
- elements: await AdapterConvertKarin(event.message, bot),
7663
+ elements: await AdapterConvertKarin(event.message, bot, contact3),
7664
7664
  eventId: `message:${event.message_id}`,
7665
7665
  messageId: event.message_id + "",
7666
7666
  messageSeq: event.message_id,
@@ -8184,10 +8184,12 @@ var init_base3 = __esm({
8184
8184
  }
8185
8185
  /**
8186
8186
  * onebot11转karin
8187
+ * @param data onebot11格式消息
8188
+ * @param contact 联系人信息 如果需要转换napcat的文件消息则需要传入
8187
8189
  * @return karin格式消息
8188
8190
  */
8189
- AdapterConvertKarin(data) {
8190
- return AdapterConvertKarin(data, this);
8191
+ AdapterConvertKarin(data, contact3) {
8192
+ return AdapterConvertKarin(data, this, contact3);
8191
8193
  }
8192
8194
  /**
8193
8195
  * karin转onebot11
@@ -8378,7 +8380,7 @@ var init_base3 = __esm({
8378
8380
  role: "unknown",
8379
8381
  name: result.sender.nickname
8380
8382
  },
8381
- elements: await this.AdapterConvertKarin(result.message)
8383
+ elements: await this.AdapterConvertKarin(result.message, contact3)
8382
8384
  };
8383
8385
  }
8384
8386
  /**
@@ -8452,7 +8454,7 @@ var init_base3 = __esm({
8452
8454
  role: v?.sender?.role || "unknown",
8453
8455
  card: contact3.scene === "group" ? v?.sender?.card || "" : ""
8454
8456
  },
8455
- elements: await this.AdapterConvertKarin(v.message)
8457
+ elements: await this.AdapterConvertKarin(v.message, contact3)
8456
8458
  };
8457
8459
  all.push(data);
8458
8460
  }
@@ -9994,11 +9996,12 @@ var init_pid = __esm({
9994
9996
  getPid = async (port2) => {
9995
9997
  const command2 = isWin2 ? `netstat -ano | findstr :${port2}` : `lsof -i:${port2} | grep LISTEN | awk '{print $2}'`;
9996
9998
  const { stdout } = await exec(command2);
9999
+ if (!stdout) return null;
9997
10000
  if (isWin2) {
9998
10001
  const pid = stdout.toString().split(/\s+/).filter(Boolean).pop();
9999
- return Number(pid);
10002
+ return isNaN(Number(pid)) ? null : Number(pid);
10000
10003
  }
10001
- return Number(stdout);
10004
+ return isNaN(Number(stdout)) ? null : Number(stdout);
10002
10005
  };
10003
10006
  }
10004
10007
  });
@@ -10046,6 +10049,56 @@ var init_class = __esm({
10046
10049
  }
10047
10050
  });
10048
10051
 
10052
+ // src/utils/common/sleep.ts
10053
+ var sleep;
10054
+ var init_sleep = __esm({
10055
+ "src/utils/common/sleep.ts"() {
10056
+ sleep = (ms2) => new Promise((resolve) => setTimeout(resolve, ms2));
10057
+ }
10058
+ });
10059
+ var checkPort, waitPort, killApp;
10060
+ var init_port = __esm({
10061
+ "src/utils/system/port.ts"() {
10062
+ init_sleep();
10063
+ init_exec();
10064
+ init_pid();
10065
+ init_system();
10066
+ checkPort = (port2) => {
10067
+ return new Promise((resolve) => {
10068
+ const server2 = createServer$1();
10069
+ server2.once("error", () => {
10070
+ server2.close();
10071
+ resolve(false);
10072
+ });
10073
+ server2.once("listening", () => {
10074
+ server2.close();
10075
+ resolve(true);
10076
+ });
10077
+ server2.listen(port2, "127.0.0.1");
10078
+ });
10079
+ };
10080
+ waitPort = async (port2, maxAttempts = 30, interval = 1e3) => {
10081
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
10082
+ const available = await checkPort(port2);
10083
+ if (available) {
10084
+ return true;
10085
+ }
10086
+ logger.debug(`\u7AEF\u53E3 ${port2} \u88AB\u5360\u7528\uFF0C\u7B49\u5F85\u91CA\u653E... (${attempt + 1}/${maxAttempts})`);
10087
+ await sleep(interval);
10088
+ }
10089
+ return false;
10090
+ };
10091
+ killApp = async (identifier, isPort = false) => {
10092
+ const pid = isPort ? await getPid(Number(identifier)) : Number(identifier);
10093
+ if (!pid) return false;
10094
+ const command2 = isWin2 ? `taskkill /F /PID ${pid}` : `kill -9 ${pid}`;
10095
+ const { stderr } = await exec(command2);
10096
+ if (stderr) return false;
10097
+ return true;
10098
+ };
10099
+ }
10100
+ });
10101
+
10049
10102
  // src/utils/system/import.ts
10050
10103
  var importModule;
10051
10104
  var init_import = __esm({
@@ -11202,7 +11255,7 @@ var restart, restartDirect;
11202
11255
  var init_restart = __esm({
11203
11256
  "src/utils/system/restart.ts"() {
11204
11257
  init_exec();
11205
- restart = async (selfId, contact3, messageId, isFront = true) => {
11258
+ restart = async (selfId, contact3, messageId, isFront = true, reloadDeps = false) => {
11206
11259
  const options = {
11207
11260
  selfId,
11208
11261
  contact: contact3,
@@ -11214,11 +11267,7 @@ var init_restart = __esm({
11214
11267
  const db2 = await createDB2();
11215
11268
  await db2.set(key, options);
11216
11269
  if (isFront && process.send) {
11217
- process.send(JSON.stringify({
11218
- type: "restart",
11219
- port: process.env.HTTP_PORT,
11220
- token: process.env.HTTP_AUTH_KEY
11221
- }));
11270
+ process.send(JSON.stringify({ type: "restart", reloadDeps }));
11222
11271
  return { status: "success", data: "\u5DF2\u53D1\u9001\u91CD\u542F\u4FE1\u53F7" };
11223
11272
  }
11224
11273
  if (process.env.PM2_RESTART !== "true") process.exit();
@@ -11231,16 +11280,13 @@ var init_restart = __esm({
11231
11280
  if (error) return { status: "failed", data: error };
11232
11281
  process.exit();
11233
11282
  };
11234
- restartDirect = async (isPm2 = false) => {
11283
+ restartDirect = async (options) => {
11284
+ const { isPm2 = false, reloadDeps = false } = options || {};
11235
11285
  logger.mark("\u6536\u5230\u91CD\u542F\u8BF7\u6C42\uFF0C\u6B63\u5728\u91CD\u542F...");
11236
11286
  if (!isPm2 && process?.send) {
11237
- process.send(JSON.stringify({
11238
- type: "restart",
11239
- port: process.env.HTTP_PORT,
11240
- token: process.env.HTTP_AUTH_KEY
11241
- }));
11242
- logger.mark("\u6B63\u5728\u901A\u77E5\u7236\u8FDB\u7A0B\u91CD\u542F...");
11243
- process.exit(0);
11287
+ process.send(JSON.stringify({ type: "restart", reloadDeps }));
11288
+ logger.debug("\u6B63\u5728\u901A\u77E5\u7236\u8FDB\u7A0B\u91CD\u542F...");
11289
+ return;
11244
11290
  }
11245
11291
  if (process.env.RUNTIME === "pm2") {
11246
11292
  if (process.env.PM2_RESTART !== "true") process.exit();
@@ -11442,8 +11488,8 @@ var init_range = __esm({
11442
11488
  return comparison === 0;
11443
11489
  }
11444
11490
  };
11445
- satisfies = (range3, version2) => {
11446
- const conditions = range3.split(" ");
11491
+ satisfies = (satisfies2, version2) => {
11492
+ const conditions = satisfies2.split(" ");
11447
11493
  return conditions.every((condition) => satisfiesCondition(version2, condition));
11448
11494
  };
11449
11495
  }
@@ -11454,6 +11500,7 @@ var system_exports = {};
11454
11500
  __export(system_exports, {
11455
11501
  checkGitPluginUpdate: () => checkGitPluginUpdate,
11456
11502
  checkPkgUpdate: () => checkPkgUpdate,
11503
+ checkPort: () => checkPort,
11457
11504
  errorToString: () => errorToString,
11458
11505
  exec: () => exec,
11459
11506
  ffmpeg: () => ffmpeg,
@@ -11480,6 +11527,10 @@ __export(system_exports, {
11480
11527
  isMac: () => isMac,
11481
11528
  isRoot: () => isRoot,
11482
11529
  isWin: () => isWin2,
11530
+ killApp: () => killApp,
11531
+ lock: () => lock,
11532
+ lockMethod: () => lockMethod,
11533
+ lockProp: () => lockProp,
11483
11534
  restart: () => restart,
11484
11535
  restartDirect: () => restartDirect,
11485
11536
  satisfies: () => satisfies,
@@ -11488,7 +11539,8 @@ __export(system_exports, {
11488
11539
  updateAllPkg: () => updateAllPkg,
11489
11540
  updateGitPlugin: () => updateGitPlugin,
11490
11541
  updatePkg: () => updatePkg,
11491
- uptime: () => uptime
11542
+ uptime: () => uptime,
11543
+ waitPort: () => waitPort
11492
11544
  });
11493
11545
  var init_system2 = __esm({
11494
11546
  "src/utils/system/index.ts"() {
@@ -11498,8 +11550,10 @@ var init_system2 = __esm({
11498
11550
  init_time();
11499
11551
  init_class();
11500
11552
  init_error();
11553
+ init_port();
11501
11554
  init_ffmpeg();
11502
11555
  init_import();
11556
+ init_lock();
11503
11557
  init_system();
11504
11558
  init_update();
11505
11559
  init_restart();
@@ -16335,14 +16389,6 @@ var init_string = __esm({
16335
16389
  }
16336
16390
  });
16337
16391
 
16338
- // src/utils/common/sleep.ts
16339
- var sleep;
16340
- var init_sleep = __esm({
16341
- "src/utils/common/sleep.ts"() {
16342
- sleep = (ms2) => new Promise((resolve) => setTimeout(resolve, ms2));
16343
- }
16344
- });
16345
-
16346
16392
  // src/utils/common/uptime.ts
16347
16393
  var uptime2;
16348
16394
  var init_uptime = __esm({
@@ -17787,37 +17833,6 @@ var init_file2 = __esm({
17787
17833
  };
17788
17834
  }
17789
17835
  });
17790
- var checkPort, waitPort;
17791
- var init_port = __esm({
17792
- "src/utils/system/port.ts"() {
17793
- init_sleep();
17794
- checkPort = (port2) => {
17795
- return new Promise((resolve) => {
17796
- const server2 = createServer$1();
17797
- server2.once("error", () => {
17798
- server2.close();
17799
- resolve(false);
17800
- });
17801
- server2.once("listening", () => {
17802
- server2.close();
17803
- resolve(true);
17804
- });
17805
- server2.listen(port2, "127.0.0.1");
17806
- });
17807
- };
17808
- waitPort = async (port2, maxAttempts = 30, interval = 1e3) => {
17809
- for (let attempt = 0; attempt < maxAttempts; attempt++) {
17810
- const available = await checkPort(port2);
17811
- if (available) {
17812
- return true;
17813
- }
17814
- logger.debug(`\u7AEF\u53E3 ${port2} \u88AB\u5360\u7528\uFF0C\u7B49\u5F85\u91CA\u653E... (${attempt + 1}/${maxAttempts})`);
17815
- await sleep(interval);
17816
- }
17817
- return false;
17818
- };
17819
- }
17820
- });
17821
17836
 
17822
17837
  // src/server/router/router.ts
17823
17838
  var BASE_ROUTER, LOGIN_ROUTER, REFRESH_ROUTER, GET_CONFIG_ROUTER, SAVE_CONFIG_ROUTER, GET_LOG_ROUTER, SET_LOG_LEVEL_ROUTER, GET_LOG_FILE_LIST_ROUTER, GET_LOG_FILE_ROUTER, EXIT_ROUTER, RESTART_ROUTER, GET_NETWORK_STATUS_ROUTER, UPDATE_CORE_ROUTER, GET_BOTS_ROUTER, CONSOLE_ROUTER, PING_ROUTER, SYSTEM_STATUS_ROUTER, SYSTEM_INFO_ROUTER, SYSTEM_STATUS_WS_ROUTER, SYSTEM_STATUS_KARIN_ROUTER, GET_ONLINE_PLUGIN_LIST_ROUTER, GET_PLUGIN_LIST_ROUTER, GET_PLUGIN_APPS_ROUTER, GET_PLUGIN_FILE_ROUTER, GET_UPDATABLE_PLUGINS_ROUTER, BATCH_UPDATE_PLUGINS_ROUTER, GET_PLUGIN_CONFIG_ROUTER, SAVE_PLUGIN_CONFIG_ROUTER, IS_PLUGIN_CONFIG_EXIST_ROUTER, UPDATE_PLUGIN_ROUTER, INSTALL_PLUGIN_ROUTER, UNINSTALL_PLUGIN_ROUTER, GET_TASK_STATUS_ROUTER, GET_TASK_LIST_ROUTER, UPDATE_TASK_STATUS_ROUTER, GET_LOCAL_PLUGIN_LIST_ROUTER, CREATE_TERMINAL_ROUTER, GET_TERMINAL_LIST_ROUTER, CLOSE_TERMINAL_ROUTER, CHECK_PLUGIN_ROUTER, INSTALL_WEBUI_PLUGIN_ROUTER, GET_WEBUI_PLUGIN_LIST_ROUTER, UNINSTALL_WEBUI_PLUGIN_ROUTER, GET_WEBUI_PLUGIN_VERSIONS_ROUTER, UPDATE_WEBUI_PLUGIN_VERSION_ROUTER, TASK_LIST_ROUTER, TASK_RUN_ROUTER, TASK_LOGS_ROUTER, TASK_DELETE_ROUTER, PLUGIN_ADMIN_ROUTER, GET_PLUGIN_LIST_PLUGIN_ADMIN_ROUTER, GET_DEPENDENCIES_LIST_ROUTER, MANAGE_DEPENDENCIES_ROUTER, GET_NPMRC_LIST_ROUTER, GET_NPM_CONFIG_ROUTER, GET_NPM_BASE_CONFIG_ROUTER, SAVE_NPMRC_ROUTER, GET_LOADED_COMMAND_PLUGIN_CACHE_LIST_ROUTER, GET_PLUGIN_MARKET_LIST_ROUTER;
@@ -20738,9 +20753,13 @@ var init_manage = __esm({
20738
20753
  init_restart();
20739
20754
  init_response();
20740
20755
  restartRouter = async (req, res) => {
20741
- const { isPm2 } = req.body;
20742
- createSuccessResponse(res, null, "\u91CD\u542F\u6307\u4EE4\u53D1\u9001\u6210\u529F");
20743
- restartDirect(isPm2 ?? false);
20756
+ try {
20757
+ const { isPm2 = false, reloadDeps = false } = req.body;
20758
+ restartDirect({ isPm2, reloadDeps });
20759
+ createSuccessResponse(res, null, "\u91CD\u542F\u6307\u4EE4\u53D1\u9001\u6210\u529F");
20760
+ } catch (error) {
20761
+ createServerErrorResponse(res, error.message);
20762
+ }
20744
20763
  };
20745
20764
  exitRouter = async (_req, res) => {
20746
20765
  logger.mark("\u6536\u5230\u9000\u51FA\u8BF7\u6C42\uFF0C\u6B63\u5728\u9000\u51FA...");
@@ -24000,17 +24019,11 @@ var init_input = __esm({
24000
24019
  }
24001
24020
  }
24002
24021
  if (text2 === "rs" || text2 === "restart") {
24003
- process.send(JSON.stringify({
24004
- type: "restart",
24005
- port: process.env.HTTP_PORT,
24006
- token: process.env.HTTP_AUTH_KEY
24007
- }));
24022
+ process.send(JSON.stringify({ type: "restart" }));
24008
24023
  return;
24009
24024
  }
24010
24025
  if (text2 === "stop") {
24011
- process.send(JSON.stringify({
24012
- type: "stop"
24013
- }));
24026
+ process.send(JSON.stringify({ type: "stop" }));
24014
24027
  return;
24015
24028
  }
24016
24029
  if (text2.startsWith("group")) {
@@ -24556,9 +24569,9 @@ var initPluginHmr = async () => {
24556
24569
  return path4.relative(process.cwd(), dir2).replace(/\\/g, "/");
24557
24570
  });
24558
24571
  watchDirs.clear();
24559
- logger.info(`
24572
+ relativePaths.length ? logger.info(`
24560
24573
  [hmr] ${logger.magenta("\u6B63\u5728\u76D1\u542C\u6587\u4EF6\u5939")}:
24561
- ${relativePaths.join("\n")}`);
24574
+ ${relativePaths.join("\n ")}`) : logger.info("[hmr] \u5F53\u524D\u76D1\u542C\u7684\u63D2\u4EF6\u5217\u8868\u4E3A\u7A7A");
24562
24575
  };
24563
24576
  var handleFileChange = async (file2, action) => {
24564
24577
  const ext = path4.extname(file2);
@@ -25815,4 +25828,4 @@ var start2 = async () => {
25815
25828
  (*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
25816
25829
  */
25817
25830
 
25818
- 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 };
25831
+ 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, checkPort, 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, killApp, 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, waitPort, watch, watchAndMerge, write, writeJson, writeJsonSync, yaml3 as yaml };
@@ -1,105 +1,258 @@
1
+ import os from 'node:os';
1
2
  import fs from 'node:fs';
2
- import net from 'node:net';
3
3
  import path from 'node:path';
4
4
  import { fileURLToPath } from 'node:url';
5
5
  import { fork } from 'node:child_process';
6
6
 
7
7
  // src/start/index.ts
8
- var isStart = false;
9
- var child;
10
- var _filename = fileURLToPath(import.meta.url);
11
- var _dirname = path.dirname(_filename);
12
- var getMainPath = () => {
13
- const isESM = import.meta.url.includes(".mjs");
14
- const filePath = path.join(_dirname, isESM ? "app.mjs" : "app.ts");
15
- if (fs.existsSync(filePath)) {
16
- return filePath;
17
- }
18
- return path.join(process.cwd(), "node_modules", "node-karin", "dist", "start", "app.mjs");
19
- };
20
- var start = () => {
21
- if (isStart) {
22
- console.log("\u5B50\u8FDB\u7A0B\u5DF2\u5728\u8FD0\u884C\u4E2D\uFF0CPID:", child.pid);
23
- return child;
24
- }
25
- isStart = true;
26
- child = fork(getMainPath());
27
- child.on("message", (message) => {
8
+ var ProcessManager = class {
9
+ /** 是否已经启动 */
10
+ isStarted = false;
11
+ /** 是否正在重启 */
12
+ isRestarting = false;
13
+ /** 子进程实例 */
14
+ childProcess = null;
15
+ /** 重启延迟时间 */
16
+ RESTART_DELAY_MS = 200;
17
+ /** 模块名称 */
18
+ MODULE_NAME = "ProcessManager";
19
+ /** 启动时间 */
20
+ startTime = Date.now();
21
+ /** 进程统计信息 */
22
+ processStats = {
23
+ /** 重启次数 */
24
+ restartCount: 0,
25
+ /** 最后重启时间 */
26
+ lastRestartTime: 0
27
+ };
28
+ // ANSI 颜色代码
29
+ COLORS = {
30
+ green: "\x1B[32m",
31
+ yellow: "\x1B[33m",
32
+ red: "\x1B[31m",
33
+ blue: "\x1B[34m",
34
+ magenta: "\x1B[35m",
35
+ cyan: "\x1B[36m",
36
+ gray: "\x1B[90m",
37
+ reset: "\x1B[0m"
38
+ };
39
+ constructor() {
40
+ process.on("exit", this.stop.bind(this));
41
+ this.logSystemInfo();
42
+ }
43
+ /**
44
+ * 启动子进程
45
+ */
46
+ start(options = {}) {
47
+ if (this.isAlreadyRunning()) {
48
+ this.log(`\u5B50\u8FDB\u7A0B\u5DF2\u5728\u8FD0\u884C | PID: ${this.childProcess.pid}`);
49
+ return this.childProcess;
50
+ }
51
+ this.isStarted = true;
52
+ const entryPath = this.resolveEntryPath();
53
+ const args = options.reloadDeps ? [`--reload-timestamp=${Date.now()}`] : [];
54
+ this.childProcess = fork(entryPath, args);
55
+ const pid = this.childProcess.pid;
56
+ this.setupEventListeners();
57
+ this.log(`\u542F\u52A8\u5B50\u8FDB\u7A0B | PID: ${pid} | \u5165\u53E3: ${path.basename(entryPath)} | \u53C2\u6570: ${args.join(" ") || "\u65E0"}`);
58
+ return this.childProcess;
59
+ }
60
+ /**
61
+ * 重启子进程
62
+ */
63
+ async restart(reloadDeps = false) {
64
+ if (!this.childProcess) {
65
+ this.logWarn("\u91CD\u542F\u5931\u8D25 | \u539F\u56E0: \u5B50\u8FDB\u7A0B\u4E0D\u5B58\u5728 | \u64CD\u4F5C: \u76F4\u63A5\u542F\u52A8\u65B0\u8FDB\u7A0B");
66
+ return this.start({ reloadDeps });
67
+ }
68
+ const oldPid = this.childProcess.pid;
69
+ this.isRestarting = true;
70
+ this.processStats.restartCount++;
71
+ this.processStats.lastRestartTime = Date.now();
72
+ this.log(`\u51C6\u5907\u91CD\u542F\u5B50\u8FDB\u7A0B | \u5F53\u524DPID: ${oldPid} | \u91CD\u8F7D\u4F9D\u8D56: ${reloadDeps ? "\u662F" : "\u5426"} | \u91CD\u542F\u6B21\u6570: ${this.processStats.restartCount}`);
28
73
  try {
29
- const { port, type, token } = JSON.parse(message) || {};
74
+ await this.terminateChildProcess();
75
+ this.isStarted = false;
76
+ const newChild = this.start({ reloadDeps });
77
+ const duration = Date.now() - this.processStats.lastRestartTime;
78
+ this.log(`\u91CD\u542F\u5B8C\u6210 | \u65E7PID: ${oldPid} | \u65B0PID: ${newChild.pid} | \u8017\u65F6: ${duration}ms`);
79
+ return newChild;
80
+ } catch (error) {
81
+ if (error.code === "ESRCH") {
82
+ this.logWarn(`\u91CD\u542F\u8FC7\u7A0B\u4E2D\u53D1\u73B0\u8FDB\u7A0B\u5DF2\u4E0D\u5B58\u5728 | \u9519\u8BEF\u7801: ${error.code} | \u64CD\u4F5C: \u542F\u52A8\u65B0\u8FDB\u7A0B`);
83
+ this.isStarted = false;
84
+ return this.start({ reloadDeps: true });
85
+ }
86
+ this.logError(`\u91CD\u542F\u5931\u8D25 | \u9519\u8BEF: ${error.message} | \u4EE3\u7801: ${error.code || "\u672A\u77E5"}`);
87
+ return null;
88
+ } finally {
89
+ this.isRestarting = false;
90
+ }
91
+ }
92
+ /**
93
+ * 停止子进程并退出父进程
94
+ */
95
+ stop() {
96
+ if (this.childProcess) {
97
+ const pid = this.childProcess.pid;
98
+ const uptime = this.getProcessUptime();
99
+ this.log(`\u6B63\u5728\u5173\u95ED\u5B50\u8FDB\u7A0B | PID: ${pid} | \u8FD0\u884C\u65F6\u95F4: ${uptime}`);
100
+ this.terminateChildProcess(false);
101
+ this.childProcess = null;
102
+ this.isStarted = false;
103
+ this.isRestarting = false;
104
+ }
105
+ const totalUptime = this.getTotalUptime();
106
+ this.log(`\u7236\u8FDB\u7A0B\u9000\u51FA | \u603B\u8FD0\u884C\u65F6\u95F4: ${totalUptime} | \u91CD\u542F\u6B21\u6570: ${this.processStats.restartCount}`);
107
+ process.exit(0);
108
+ }
109
+ /**
110
+ * 检查子进程是否已经在运行
111
+ */
112
+ isAlreadyRunning() {
113
+ return this.isStarted && this.childProcess !== null;
114
+ }
115
+ /**
116
+ * 设置子进程事件监听器
117
+ */
118
+ setupEventListeners() {
119
+ if (!this.childProcess) return;
120
+ this.childProcess.on("message", this.handleChildMessage.bind(this));
121
+ this.childProcess.once("exit", this.handleChildExit.bind(this));
122
+ }
123
+ /**
124
+ * 处理子进程发送的消息
125
+ */
126
+ async handleChildMessage(message) {
127
+ if (typeof message !== "string") return;
128
+ try {
129
+ const { type, reloadDeps } = JSON.parse(message);
30
130
  if (type === "restart") {
31
- restart(port, token);
131
+ this.log(`\u6536\u5230\u6D88\u606F | \u7C7B\u578B: restart | \u91CD\u8F7D\u4F9D\u8D56: ${reloadDeps ? "\u662F" : "\u5426"}`);
132
+ const child = await this.restart(reloadDeps);
133
+ if (!child) {
134
+ this.logWarn("\u91CD\u542F\u64CD\u4F5C\u5931\u8D25 | \u65E0\u6CD5\u83B7\u53D6\u65B0\u7684\u5B50\u8FDB\u7A0B");
135
+ } else {
136
+ this.childProcess = child;
137
+ }
138
+ return;
139
+ }
140
+ if (type === "stop") {
141
+ this.log("\u6536\u5230\u6D88\u606F | \u7C7B\u578B: stop | \u64CD\u4F5C: \u505C\u6B62\u8FDB\u7A0B");
142
+ this.stop();
32
143
  return;
33
144
  }
34
- if (type === "stop") exit();
145
+ this.logWarn(`\u6536\u5230\u672A\u77E5\u6D88\u606F | \u7C7B\u578B: ${type || "\u672A\u77E5"} | \u5185\u5BB9: ${JSON.stringify(message).substring(0, 100)}`);
35
146
  } catch (error) {
36
- console.error("\u5904\u7406\u5B50\u8FDB\u7A0B\u6D88\u606F\u65F6\u51FA\u9519:", error);
147
+ this.logError(`\u6D88\u606F\u5904\u7406\u9519\u8BEF | \u539F\u59CB\u6D88\u606F: ${String(message).substring(0, 50)}`, error);
37
148
  }
38
- });
39
- child.once("exit", exit);
40
- return child;
41
- };
42
- var restart = async (port, token, isFetch = true) => {
43
- if (isFetch) {
44
- await sendExit(port, token);
45
- }
46
- let portAvailable = false;
47
- const maxTries = 10;
48
- for (let i = 0; i < maxTries; i++) {
49
- portAvailable = await checkPort(port);
50
- if (portAvailable) {
51
- break;
52
- }
53
- await sleep(1e3);
54
149
  }
55
- if (!portAvailable) {
56
- console.warn(`\u8B66\u544A\uFF1A\u7AEF\u53E3 ${port} \u5728\u591A\u6B21\u5C1D\u8BD5\u540E\u4ECD\u88AB\u5360\u7528\uFF0C\u53EF\u80FD\u9700\u8981\u624B\u52A8\u5904\u7406`);
150
+ /**
151
+ * 处理子进程退出事件
152
+ */
153
+ handleChildExit(code, signal) {
154
+ const exitType = signal ? `\u4FE1\u53F7: ${signal}` : `\u9000\u51FA\u7801: ${code ?? "\u672A\u77E5"}`;
155
+ const uptime = this.getProcessUptime();
156
+ this.log(`\u5B50\u8FDB\u7A0B\u9000\u51FA | ${exitType} | \u8FD0\u884C\u65F6\u95F4: ${uptime}`);
157
+ if (!this.isRestarting) {
158
+ this.stop();
159
+ }
57
160
  }
58
- isStart = false;
59
- child = start();
60
- return child;
61
- };
62
- var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
63
- var checkPort = (port) => {
64
- const server = net.createServer();
65
- return new Promise((resolve) => {
66
- server.on("error", () => {
67
- resolve(false);
68
- });
69
- server.listen(port);
70
- server.once("listening", () => {
71
- server.close(() => {
72
- resolve(true);
73
- });
74
- });
75
- });
76
- };
77
- var sendExit = async (port, token) => {
78
- try {
79
- const result = await fetch(`http://127.0.0.1:${port}/api/v1/exit`, {
80
- method: "POST",
81
- headers: {
82
- authorization: `Bearer ${token}`
161
+ /**
162
+ * 终止子进程
163
+ */
164
+ async terminateChildProcess(waitForTermination = true) {
165
+ if (!this.childProcess) return;
166
+ try {
167
+ const pid = this.childProcess.pid;
168
+ this.log(`\u53D1\u9001\u7EC8\u6B62\u4FE1\u53F7 | PID: ${pid} | \u4FE1\u53F7: SIGTERM`);
169
+ this.childProcess.kill("SIGTERM");
170
+ if (waitForTermination) {
171
+ this.log(`\u7B49\u5F85\u8FDB\u7A0B\u7EC8\u6B62 | PID: ${pid} | \u8D85\u65F6: ${this.RESTART_DELAY_MS}ms`);
172
+ await new Promise((resolve) => setTimeout(resolve, this.RESTART_DELAY_MS));
173
+ }
174
+ try {
175
+ if (this.childProcess.pid) {
176
+ this.log(`\u786E\u4FDD\u8FDB\u7A0B\u7EC8\u6B62 | PID: ${pid} | \u53D1\u9001\u5F3A\u5236\u7EC8\u6B62\u4FE1\u53F7`);
177
+ process.kill(this.childProcess.pid);
178
+ }
179
+ } catch {
83
180
  }
84
- });
85
- if (result.status === 200) {
86
- console.log(await result.json());
87
- } else {
88
- console.log("\u53D1\u9001\u91CD\u542F\u8BF7\u6C42\u5931\u8D25:", result.status);
181
+ } catch {
89
182
  }
90
- await sleep(1e3);
91
- } catch {
92
183
  }
93
- };
94
- var exit = () => {
95
- try {
96
- child.kill("SIGTERM");
97
- process.kill(child.pid);
98
- } catch {
99
- child?.kill();
100
- } finally {
101
- process.exit(0);
184
+ /**
185
+ * 解析子进程入口文件路径
186
+ */
187
+ resolveEntryPath() {
188
+ const currentFilePath = fileURLToPath(import.meta.url);
189
+ const currentDirPath = path.dirname(currentFilePath);
190
+ const isESM = import.meta.url.includes(".mjs");
191
+ const localEntryPath = path.join(currentDirPath, isESM ? "app.mjs" : "app.ts");
192
+ return fs.existsSync(localEntryPath) ? localEntryPath : path.join(process.cwd(), "node_modules", "node-karin", "dist", "start", "app.mjs");
193
+ }
194
+ /**
195
+ * 获取当前时间戳,格式为 HH:MM:SS.mmm
196
+ */
197
+ getTimestamp() {
198
+ const now = /* @__PURE__ */ new Date();
199
+ const hours = now.getHours().toString().padStart(2, "0");
200
+ const minutes = now.getMinutes().toString().padStart(2, "0");
201
+ const seconds = now.getSeconds().toString().padStart(2, "0");
202
+ const milliseconds = now.getMilliseconds().toString().padStart(3, "0");
203
+ return `${hours}:${minutes}:${seconds}.${milliseconds}`;
204
+ }
205
+ /**
206
+ * 创建日志前缀
207
+ */
208
+ createLogPrefix(level) {
209
+ const timestamp = this.getTimestamp();
210
+ const prefix = `[Karin][${timestamp}][${level}]`;
211
+ return `${this.COLORS.green}${prefix}${this.COLORS.reset}`;
212
+ }
213
+ /**
214
+ * 获取进程运行时间的友好字符串
215
+ */
216
+ getProcessUptime() {
217
+ if (!this.childProcess?.pid) return "0s";
218
+ const uptime = (Date.now() - this.processStats.lastRestartTime) / 1e3;
219
+ if (uptime < 60) return `${uptime.toFixed(1)}s`;
220
+ if (uptime < 3600) return `${(uptime / 60).toFixed(1)}m`;
221
+ return `${(uptime / 3600).toFixed(1)}h`;
222
+ }
223
+ /**
224
+ * 获取总运行时间的友好字符串
225
+ */
226
+ getTotalUptime() {
227
+ const uptime = (Date.now() - this.startTime) / 1e3;
228
+ if (uptime < 60) return `${uptime.toFixed(1)}s`;
229
+ if (uptime < 3600) return `${(uptime / 60).toFixed(1)}m`;
230
+ return `${(uptime / 3600).toFixed(1)}h`;
231
+ }
232
+ /**
233
+ * 输出系统信息
234
+ */
235
+ logSystemInfo() {
236
+ const nodeVersion = process.version;
237
+ const platform = `${os.platform()} ${os.release()}`;
238
+ const cpus = os.cpus().length;
239
+ const memory = `${Math.round(os.totalmem() / 1024 / 1024 / 1024)}GB`;
240
+ this.log(`\u7CFB\u7EDF\u4FE1\u606F | Node: ${nodeVersion} | \u5E73\u53F0: ${platform} | CPU\u6838\u5FC3: ${cpus} | \u5185\u5B58: ${memory}`);
241
+ }
242
+ /**
243
+ * 日志输出方法
244
+ */
245
+ log(message) {
246
+ console.log(`${this.createLogPrefix("INFO" /* INFO */)} [${this.MODULE_NAME}] ${message}`);
247
+ }
248
+ logWarn(message) {
249
+ console.warn(`${this.createLogPrefix("WARN" /* WARN */)} [${this.MODULE_NAME}] ${message}`);
250
+ }
251
+ logError(message, error) {
252
+ console.error(`${this.createLogPrefix("ERROR" /* ERROR */)} [${this.MODULE_NAME}] ${message}`, error || "");
102
253
  }
254
+ // private logDebug(message: string): void {
255
+ // console.debug(`${this.createLogPrefix(LogLevel.DEBUG)} [${this.MODULE_NAME}] ${message}`)
256
+ // }
103
257
  };
104
- process.on("exit", exit);
105
- start();
258
+ new ProcessManager().start();
@@ -0,0 +1 @@
1
+ import{j as t}from"./vendor-react-Nm7PvEim.js";import{P as r}from"./components-DoLdoU3_.js";import"./vendor-others-DBQ8m94B.js";import"./vendor-editor-B8hjWfkw.js";import"./vendor-ui-utils-5rYIvRjL.js";import"./vendor-heroui-LBurlY8q.js";import"./page-dashboard-B89Pi8YU.js";import"./hooks-9NHYpXid.js";import"./utils-CiCAgsgm.js";import"./vendor-visual-CVzPJKGy.js";const x=()=>t.jsx("div",{className:"min-h-screen flex items-center justify-center",children:t.jsx(r,{})});export{x as default};
@@ -1,2 +1,2 @@
1
- import{V as p}from"./vendor-react-Nm7PvEim.js";import{a5 as g}from"./components-CPNNGkNi.js";const k=async(t,n,e,r)=>{const{setIsLogModalOpen:i,setTaskId:c,setTaskLogs:o,setTaskName:f}=n;f("更新插件");const a=["开始创建更新任务...",`options: ${JSON.stringify(t)}`];o(a);try{const s=await g(t);if(s.success&&s.taskId)c(s.taskId),o([...a,`
1
+ import{V as p}from"./vendor-react-Nm7PvEim.js";import{a6 as g}from"./components-DoLdoU3_.js";const k=async(t,n,e,r)=>{const{setIsLogModalOpen:i,setTaskId:c,setTaskLogs:o,setTaskName:f}=n;f("更新插件");const a=["开始创建更新任务...",`options: ${JSON.stringify(t)}`];o(a);try{const s=await g(t);if(s.success&&s.taskId)c(s.taskId),o([...a,`
2
2
  任务创建成功!`,`任务ID: ${s.taskId}`,"正在连接任务执行日志..."]),i(!0),typeof e=="function"&&e(),typeof r=="function"&&r();else throw new Error(s.message||"未知错误")}catch(s){console.error("更新失败:",s),p.error(`更新失败: ${s.message}`)}};export{k as c};
@@ -14,17 +14,17 @@
14
14
  content="viewport-fit=cover, width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
15
15
  name="viewport" />
16
16
  <link href="/web/assets/ico/favicon-BoqZd694.ico" rel="icon" />
17
- <script type="module" crossorigin src="/web/assets/js/entry-Baz5TCd6.js"></script>
17
+ <script type="module" crossorigin src="/web/assets/js/entry-Cv-Gqd__.js"></script>
18
18
  <link rel="modulepreload" crossorigin href="/web/assets/js/vendor-editor-B8hjWfkw.js">
19
19
  <link rel="modulepreload" crossorigin href="/web/assets/js/vendor-others-DBQ8m94B.js">
20
20
  <link rel="modulepreload" crossorigin href="/web/assets/js/vendor-ui-utils-5rYIvRjL.js">
21
21
  <link rel="modulepreload" crossorigin href="/web/assets/js/vendor-react-Nm7PvEim.js">
22
- <link rel="modulepreload" crossorigin href="/web/assets/js/vendor-heroui-4BnFpRmu.js">
23
- <link rel="modulepreload" crossorigin href="/web/assets/js/hooks-DBHKB0Wu.js">
22
+ <link rel="modulepreload" crossorigin href="/web/assets/js/vendor-heroui-LBurlY8q.js">
23
+ <link rel="modulepreload" crossorigin href="/web/assets/js/hooks-9NHYpXid.js">
24
24
  <link rel="modulepreload" crossorigin href="/web/assets/js/vendor-visual-CVzPJKGy.js">
25
- <link rel="modulepreload" crossorigin href="/web/assets/js/components-CPNNGkNi.js">
26
- <link rel="modulepreload" crossorigin href="/web/assets/js/utils-4g0tXjXS.js">
27
- <link rel="modulepreload" crossorigin href="/web/assets/js/page-dashboard-CPp-Yb1A.js">
25
+ <link rel="modulepreload" crossorigin href="/web/assets/js/components-DoLdoU3_.js">
26
+ <link rel="modulepreload" crossorigin href="/web/assets/js/utils-CiCAgsgm.js">
27
+ <link rel="modulepreload" crossorigin href="/web/assets/js/page-dashboard-B89Pi8YU.js">
28
28
  <link rel="stylesheet" crossorigin href="/web/assets/css/vendor-editor-CFbL2ovg.css">
29
29
  <link rel="stylesheet" crossorigin href="/web/assets/css/vendor-others-ZgkIHsf0.css">
30
30
  <link rel="stylesheet" crossorigin href="/web/assets/css/components-ep7vm38G.css">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-karin",
3
- "version": "1.9.10",
3
+ "version": "1.10.0",
4
4
  "description": "Lightweight, efficient, concise, and stable robot framework.",
5
5
  "keywords": [
6
6
  "node",
@@ -1 +0,0 @@
1
- import{j as t}from"./vendor-react-Nm7PvEim.js";import{P as r}from"./components-CPNNGkNi.js";import"./vendor-others-DBQ8m94B.js";import"./vendor-editor-B8hjWfkw.js";import"./vendor-ui-utils-5rYIvRjL.js";import"./vendor-heroui-4BnFpRmu.js";import"./page-dashboard-CPp-Yb1A.js";import"./hooks-DBHKB0Wu.js";import"./utils-4g0tXjXS.js";import"./vendor-visual-CVzPJKGy.js";const x=()=>t.jsx("div",{className:"min-h-screen flex items-center justify-center",children:t.jsx(r,{})});export{x as default};