node-karin 1.10.14 → 1.10.15

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,16 @@
1
1
  # 更新日志
2
2
 
3
+ ## [1.10.15](https://github.com/KarinJS/Karin/compare/core-v1.10.14...core-v1.10.15) (2025-06-30)
4
+
5
+
6
+ ### 🐛 Bug Fixes
7
+
8
+ * `raw`原始文本 ([21cd207](https://github.com/KarinJS/Karin/commit/21cd2074ba7da1650c2ccad6d62f117a8907321f))
9
+ * close [#474](https://github.com/KarinJS/Karin/issues/474) ([a985f0a](https://github.com/KarinJS/Karin/commit/a985f0a214ecc8fb7edefe4a00f9afe24e443e4a))
10
+ * webui卸载插件 ([2b08c90](https://github.com/KarinJS/Karin/commit/2b08c900c9b199439e418d4f1ec76e3303704408))
11
+ * 孤儿进程 ([f459e14](https://github.com/KarinJS/Karin/commit/f459e145480dcb8ebeddf694ca947998350183e9))
12
+ * 更新`hooks.sendMsg.message`描述 ([9efe1d4](https://github.com/KarinJS/Karin/commit/9efe1d4378cf5df00ab6c621ead976447f906eba))
13
+
3
14
  ## [1.10.14](https://github.com/KarinJS/Karin/compare/core-v1.10.13...core-v1.10.14) (2025-06-30)
4
15
 
5
16
 
package/README.md ADDED
@@ -0,0 +1,95 @@
1
+ ![karin](https://socialify.git.ci/karinjs/karin/image?description=1&font=Bitter&forks=1&issues=1&language=1&logo=https%3A%2F%2Favatars.githubusercontent.com%2Fu%2F162426977%3Fs%3D200%26v%3D4&name=1&owner=1&pulls=1&stargazers=1&theme=Auto)
2
+
3
+ ## 项目介绍
4
+
5
+ `karin`(卡琳)是一款灵活、现代、极易扩展的 Node.js 插件化应用框架,专为开发者打造,助你轻松构建属于自己的高效工具链和自动化服务。
6
+
7
+ ✨ **主要特性**:
8
+ - ~~插件化架构,支持热插拔,生态丰富~~
9
+ - 一行命令即可初始化项目,快速上手
10
+ - 丰富的 Web UI(基于 React + HeroUI),颜值与功能并存
11
+ - 支持多种自动化场景、任务调度、依赖管理
12
+ - 轻松集成第三方服务,打造属于你的"数字助理"
13
+ - 社区活跃,持续更新,文档完善
14
+
15
+ > 🦄 让开发变得像魔法一样有趣!
16
+
17
+ ## 🚀 稳定长期维护
18
+
19
+ 自 `1.8.0` 版本起,Karin 已进入**稳定长期维护阶段**。我们承诺持续修复 bug、优化体验,并欢迎社区力量共同完善生态。
20
+
21
+ ## 快速开始
22
+
23
+ [📚 查看最新文档](https://karin.fun/)
24
+
25
+ 一键初始化:`pnpm create karin`
26
+
27
+ > 当前文档可能存在滞后性,欢迎加入交流群(967068507)一起玩耍、提建议!
28
+
29
+ ## 温馨提示
30
+
31
+ > Karin 现已稳定,放心食用!遇到问题欢迎提 Issue 或加群讨论,我们会持续优化。
32
+
33
+ ## 文档站说明
34
+
35
+ 我们提供多个文档站点供您访问,解决可能出现的访问困难:
36
+
37
+ - **主文档站**: [https://karin.fun](https://karin.fun) (基于 GitHub Pages)
38
+ - **镜像站点**:
39
+ - 憨憨镜像: [https://karin.hanhanz.top](https://karin.hanhanz.top) (**推荐访问**)
40
+ - Vercel 镜像: [https://docs.karin.fun](https://docs.karin.fun) (**推荐访问**)
41
+ - Deno 镜像: [https://karin.deno.dev](https://karin.deno.dev) (**推荐访问**)
42
+
43
+ > 💡 主文档站托管在 GitHub 上,如访问不畅,推荐使用 Deno 镜像站
44
+
45
+ ## 鸣谢
46
+
47
+ - webui: [bietiaop](https://github.com/bietiaop)
48
+ - docs: [ikenxuan](https://github.com/ikenxuan)
49
+ - name: [fuqiuluo](https://github.com/fuqiuluo)
50
+
51
+ > 🧙‍♂️ 感谢三位大佬的魔法加持!
52
+
53
+ ### 贡献者
54
+
55
+ > 🌟 星光闪烁,你们的智慧如同璀璨的夜空。感谢所有为 **Karin** 做出贡献的人!
56
+
57
+ [![贡献者](https://contributors-img.web.app/image?repo=KarinJS/Karin)](https://github.com/KarinJS/Karin/graphs/contributors)
58
+
59
+ ![Alt](https://repobeats.axiom.co/api/embed/aaaa2759c8885691443a4d80e5753f975d4f250e.svg "Repobeats analytics image")
60
+
61
+ ---
62
+
63
+ 🎉 **加入我们,让 Karin 成为你开发路上的贴心伙伴!**
64
+
65
+ ## 常见问题
66
+
67
+ - 文档没看懂?[点我提问](https://github.com/KarinJS/Karin/issues) 或加群 967068507
68
+ - 插件不会写?欢迎参考[插件开发文档](https://karin.fun/plugins/)
69
+ - 遇到 bug?大胆提 Issue,我们超快响应!
70
+
71
+ ## 如何参与贡献(PR)
72
+
73
+ 1. Fork 本仓库,创建你的分支
74
+ 2. 提交你的更改,附上简要说明
75
+ 3. 发起 Pull Request,耐心等待 Review
76
+ 4. 你的名字将出现在贡献者列表,收获一份开源荣誉!
77
+
78
+ > 💡 欢迎任何形式的贡献,无论是代码、文档、建议还是灵感!
79
+
80
+ ## Issue 指南
81
+
82
+ - 提交前请先搜索是否有类似问题
83
+ - 尽量提供详细的复现步骤、环境信息和截图
84
+ - 标题简明扼要,正文描述清晰
85
+ - 遇到安全相关问题请私信维护者
86
+
87
+ ## 开源协议
88
+
89
+ 本项目基于 [MIT License](./LICENSE) 开源,欢迎自由使用、修改和分发。
90
+
91
+ > 📢 记得给个 Star 支持我们,你的支持是我们最大的动力!
92
+
93
+ ## 更新日志
94
+
95
+ 我们定期发布更新,查看 [CHANGELOG](https://github.com/KarinJS/Karin/releases) 了解最新变化。
package/dist/index.d.ts CHANGED
@@ -17284,28 +17284,28 @@ declare const message: ((callback: HookCallback<Message$2>, options?: HookOption
17284
17284
  /** 发送消息钩子 */
17285
17285
  declare const sendMsg: {
17286
17286
  /**
17287
- * 添加普通消息钩子
17287
+ * 添加普通消息钩子 `也就是调用 bot.sendMsg 时触发 此时会先进入这个 hook 才会到 bot.sendMsg`
17288
17288
  * @param callback 消息处理回调函数
17289
17289
  * @param options 钩子配置项
17290
17290
  * @returns 钩子ID
17291
17291
  */
17292
17292
  message: (callback: NormalMessageCallback, options?: HookOptions) => number;
17293
17293
  /**
17294
- * 添加转发消息钩子
17294
+ * 添加转发消息钩子 `也就是调用 bot.sendForwardMsg 时触发 此时会先进入这个 hook 才会到 bot.sendForwardMsg`
17295
17295
  * @param callback 消息处理回调函数
17296
17296
  * @param options 钩子配置项
17297
17297
  * @returns 钩子ID
17298
17298
  */
17299
17299
  forward: (callback: ForwardMessageCallback, options?: HookOptions) => number;
17300
17300
  /**
17301
- * 添加普通消息发送后钩子
17301
+ * 添加普通消息发送后钩子 `也就是调用 bot.sendMsg 处理完成返回结果前触发 此时会先进入这个 hook 才会正常返回结果`
17302
17302
  * @param callback 消息处理回调函数
17303
17303
  * @param options 钩子配置项
17304
17304
  * @returns 钩子ID
17305
17305
  */
17306
17306
  afterMessage: (callback: AfterMessageCallback, options?: HookOptions) => number;
17307
17307
  /**
17308
- * 添加转发消息发送后钩子
17308
+ * 添加转发消息发送后钩子 `也就是调用 bot.sendForwardMsg 处理完成返回结果前触发 此时会先进入这个 hook 才会正常返回结果`
17309
17309
  * @param callback 消息处理回调函数
17310
17310
  * @param options 钩子配置项
17311
17311
  * @returns 钩子ID
package/dist/index.mjs CHANGED
@@ -3184,6 +3184,8 @@ var init_message = __esm({
3184
3184
  return `[pasmsg:${v.id}]`;
3185
3185
  case "markdownTpl":
3186
3186
  return `[markdowntpl:${JSON.stringify({ templateId: v.templateId, ...v.params })}]`;
3187
+ case "raw":
3188
+ return `[raw:${JSON.stringify(v.data)}]`;
3187
3189
  default:
3188
3190
  return `[\u672A\u77E5:${lodash3.truncate(JSON.stringify(v), { length: 200 })}]`;
3189
3191
  }
@@ -16897,7 +16899,7 @@ var init_sendMsg = __esm({
16897
16899
  };
16898
16900
  sendMsg = {
16899
16901
  /**
16900
- * 添加普通消息钩子
16902
+ * 添加普通消息钩子 `也就是调用 bot.sendMsg 时触发 此时会先进入这个 hook 才会到 bot.sendMsg`
16901
16903
  * @param callback 消息处理回调函数
16902
16904
  * @param options 钩子配置项
16903
16905
  * @returns 钩子ID
@@ -16909,7 +16911,7 @@ var init_sendMsg = __esm({
16909
16911
  return id;
16910
16912
  },
16911
16913
  /**
16912
- * 添加转发消息钩子
16914
+ * 添加转发消息钩子 `也就是调用 bot.sendForwardMsg 时触发 此时会先进入这个 hook 才会到 bot.sendForwardMsg`
16913
16915
  * @param callback 消息处理回调函数
16914
16916
  * @param options 钩子配置项
16915
16917
  * @returns 钩子ID
@@ -16921,7 +16923,7 @@ var init_sendMsg = __esm({
16921
16923
  return id;
16922
16924
  },
16923
16925
  /**
16924
- * 添加普通消息发送后钩子
16926
+ * 添加普通消息发送后钩子 `也就是调用 bot.sendMsg 处理完成返回结果前触发 此时会先进入这个 hook 才会正常返回结果`
16925
16927
  * @param callback 消息处理回调函数
16926
16928
  * @param options 钩子配置项
16927
16929
  * @returns 钩子ID
@@ -16933,7 +16935,7 @@ var init_sendMsg = __esm({
16933
16935
  return id;
16934
16936
  },
16935
16937
  /**
16936
- * 添加转发消息发送后钩子
16938
+ * 添加转发消息发送后钩子 `也就是调用 bot.sendForwardMsg 处理完成返回结果前触发 此时会先进入这个 hook 才会正常返回结果`
16937
16939
  * @param callback 消息处理回调函数
16938
16940
  * @param options 钩子配置项
16939
16941
  * @returns 钩子ID
@@ -24300,28 +24302,16 @@ var init_webui = __esm({
24300
24302
  };
24301
24303
  getWebuiPluginList = async (_, res) => {
24302
24304
  try {
24303
- const updatedPlugins = await Promise.all(plugins.map(async (plugin) => {
24304
- const modulePath = path4.join(process.cwd(), "node_modules", plugin.name);
24305
- const isInstalled = fs5.existsSync(modulePath);
24306
- let version2;
24307
- if (isInstalled) {
24308
- try {
24309
- const pkgPath = path4.join(modulePath, "package.json");
24310
- if (fs5.existsSync(pkgPath)) {
24311
- const pkgContent = fs5.readFileSync(pkgPath, "utf-8");
24312
- const pkg2 = JSON.parse(pkgContent);
24313
- version2 = pkg2.version;
24314
- }
24315
- } catch (error) {
24316
- logger.error(`[webui] \u8BFB\u53D6\u63D2\u4EF6\u7248\u672C\u5931\u8D25: ${plugin.name}`);
24317
- }
24318
- }
24305
+ const pkg2 = JSON.parse(fs5.readFileSync(path4.join(process.cwd(), "package.json"), "utf-8"));
24306
+ const updatedPlugins = plugins.map((plugin) => {
24307
+ const isInstalled = pkg2.dependencies?.[plugin.name] || pkg2.devDependencies?.[plugin.name] || pkg2.peerDependencies?.[plugin.name];
24308
+ const version2 = isInstalled || null;
24319
24309
  return {
24320
24310
  ...plugin,
24321
- installed: isInstalled,
24311
+ installed: typeof version2 === "string",
24322
24312
  version: version2
24323
24313
  };
24324
- }));
24314
+ });
24325
24315
  return createSuccessResponse(res, updatedPlugins);
24326
24316
  } catch (error) {
24327
24317
  logger.error("[webui] \u83B7\u53D6\u63D2\u4EF6\u5217\u8868\u5931\u8D25");
@@ -25012,7 +25002,23 @@ var init_uninstall = __esm({
25012
25002
  }
25013
25003
  notExist.push(v.name);
25014
25004
  });
25015
- await spawnProcess("pnpm", ["remove", ...npm2, "--save"], { timeout: 60 * 1e3 }, emitLog);
25005
+ await spawnProcess("pnpm", ["remove", ...npm2], { timeout: 60 * 1e3 }, emitLog);
25006
+ const pkg2 = path4.join(process.cwd(), "package.json");
25007
+ if (fs5.existsSync(pkg2)) {
25008
+ const content = fs5.readFileSync(pkg2, "utf-8");
25009
+ const data = JSON.parse(content);
25010
+ const delDep = (obj) => {
25011
+ Object.keys(obj).forEach((key) => {
25012
+ if (npm2.includes(key)) {
25013
+ delete obj[key];
25014
+ }
25015
+ });
25016
+ };
25017
+ delDep(data.dependencies);
25018
+ delDep(data.devDependencies);
25019
+ delDep(data.peerDependencies);
25020
+ fs5.writeFileSync(pkg2, JSON.stringify(data, null, 2), "utf-8");
25021
+ }
25016
25022
  for (const v of git2) {
25017
25023
  emitLog("-----------------------");
25018
25024
  emitLog(`\u5F00\u59CB\u5378\u8F7D git \u63D2\u4EF6: ${v}`);
@@ -25041,16 +25047,16 @@ var init_uninstall = __esm({
25041
25047
  continue;
25042
25048
  }
25043
25049
  const arr = v.split("/");
25044
- const [pkg2, file2] = arr;
25045
- if (arr.length !== 2 || !pkg2 || !file2) {
25050
+ const [pkg3, file2] = arr;
25051
+ if (arr.length !== 2 || !pkg3 || !file2) {
25046
25052
  emitLog(`\u5378\u8F7D ${v} \u5931\u8D25: \u683C\u5F0F\u9519\u8BEF`);
25047
25053
  continue;
25048
25054
  }
25049
- if (!list2.includes(`app:${pkg2}`)) {
25055
+ if (!list2.includes(`app:${pkg3}`)) {
25050
25056
  emitLog(`\u5378\u8F7D ${v} \u5931\u8D25: \u63D2\u4EF6\u4E0D\u5B58\u5728`);
25051
25057
  continue;
25052
25058
  }
25053
- const dir = path4.join(karinPathPlugins, pkg2);
25059
+ const dir = path4.join(karinPathPlugins, pkg3);
25054
25060
  if (!fs5.existsSync(path4.join(dir, file2))) {
25055
25061
  emitLog(`\u5378\u8F7D ${v} \u5931\u8D25: \u6587\u4EF6\u4E0D\u5B58\u5728`);
25056
25062
  continue;
@@ -26834,6 +26840,12 @@ var processHandler = () => {
26834
26840
  logger.error(...args);
26835
26841
  });
26836
26842
  if (process.env.pm_id) process.env.RUNTIME = "pm2";
26843
+ if (typeof process.send === "function") {
26844
+ process.on("disconnect", () => {
26845
+ logger.fatal("IPC\u901A\u9053\u5DF2\u65AD\u5F00\uFF0C\u7236\u8FDB\u7A0B\u53EF\u80FD\u5DF2\u9000\u51FA\uFF0CKarin\u5C06\u7ED3\u675F\u8FD0\u884C");
26846
+ process.exit(1);
26847
+ });
26848
+ }
26837
26849
  };
26838
26850
 
26839
26851
  // src/service/process/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-karin",
3
- "version": "1.10.14",
3
+ "version": "1.10.15",
4
4
  "description": "Lightweight, efficient, concise, and stable robot framework.",
5
5
  "keywords": [
6
6
  "node",