@peninsula-med/beisen-ehr-plugin 1.0.4 → 1.0.6

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/README.md CHANGED
@@ -15,33 +15,22 @@
15
15
  openclaw plugins install @peninsula-med/beisen-ehr-plugin
16
16
  ```
17
17
 
18
- ### 2️⃣ 配置凭证(3 种方式)
18
+ ### 2️⃣ 配置凭证(推荐 ⭐)
19
19
 
20
- **方式 A:使用配置向导(推荐 ⭐)**
20
+ 使用独立的配置工具,无需查找路径:
21
21
 
22
- **Mac/Linux:**
23
22
  ```bash
24
- node ~/.openclaw/extensions/beisen-ehr-plugin/scripts/configure.js
23
+ npx @peninsula-med/beisen-ehr-configure
25
24
  ```
26
25
 
27
- **Windows:**
28
- ```bash
29
- node %USERPROFILE%\.openclaw\extensions\beisen-ehr-plugin\scripts\configure.js
30
- ```
26
+ 或(安装到全局后):
31
27
 
32
- 或使用完整路径:
33
28
  ```bash
34
- node C:\Users\Administrator\.openclaw\extensions\beisen-ehr-plugin\scripts\configure.js
29
+ npx beisen-ehr-configure
35
30
  ```
36
31
 
37
32
  按提示输入北森凭证即可,自动完成配置!
38
33
 
39
- **方式 B:运行配置脚本**
40
-
41
- ```bash
42
- node node_modules/@peninsula-med/beisen-ehr-plugin/scripts/configure.js
43
- ```
44
-
45
34
  **方式 C:手动编辑配置文件**
46
35
 
47
36
  编辑 `~/.openclaw/config.json`:
package/dist/index.cjs.js CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var fs = require('fs');
6
+ var path = require('path');
7
+ var os = require('os');
8
+
5
9
  /**
6
10
  * 北森 EHR OpenClaw Plugin
7
11
  * 🐉 龙二 开发
@@ -17,6 +21,31 @@ const pluginVersion = '1.0.0';
17
21
  const defaultConfig = {
18
22
  apiUrl: 'https://openapi.italent.cn',
19
23
  };
24
+ /**
25
+ * 从配置文件读取配置
26
+ */
27
+ function loadConfig() {
28
+ try {
29
+ const homeDir = os.homedir();
30
+ const configPath = path.join(homeDir, '.openclaw', 'config.json');
31
+ if (!fs.existsSync(configPath)) {
32
+ return null;
33
+ }
34
+ const content = fs.readFileSync(configPath, 'utf-8');
35
+ const config = JSON.parse(content);
36
+ // 尝试读取插件配置(支持两种格式)
37
+ const pluginConfig = config.plugins?.['beisen-ehr-plugin'] ||
38
+ config.plugins?.['@peninsula-med/beisen-ehr-plugin'];
39
+ if (!pluginConfig || !pluginConfig.config) {
40
+ return null;
41
+ }
42
+ return pluginConfig.config;
43
+ }
44
+ catch (error) {
45
+ console.error('❌ 读取配置文件失败:', error.message);
46
+ return null;
47
+ }
48
+ }
20
49
  /**
21
50
  * 插件激活函数
22
51
  *
@@ -24,14 +53,26 @@ const defaultConfig = {
24
53
  */
25
54
  async function activate(runtime, config) {
26
55
  console.error(`🏢 北森 EHR 插件已激活 v${pluginVersion}`);
56
+ // 如果 OpenClaw 没有传入配置,尝试从配置文件读取
57
+ if (!config) {
58
+ config = loadConfig();
59
+ }
27
60
  // 处理空配置情况
28
61
  if (!config) {
29
62
  console.error('⚠️ 插件已安装,但未配置凭证');
63
+ console.error('');
30
64
  console.error('📝 请运行配置向导完成配置:');
31
- console.error(' node ~/.openclaw/extensions/beisen-ehr-plugin/scripts/configure.js');
32
65
  console.error('');
33
- console.error('Windows 用户:');
34
- console.error(' node %USERPROFILE%\\.openclaw\\extensions\\beisen-ehr-plugin\\scripts\\configure.js');
66
+ console.error(' npx @peninsula-med/beisen-ehr-configure');
67
+ console.error('');
68
+ console.error('按提示输入北森凭证即可!');
69
+ console.error('');
70
+ console.error('需要凭证?联系北森管理员获取:');
71
+ console.error(' • App Key');
72
+ console.error(' • App Secret');
73
+ console.error(' • Tenant ID');
74
+ console.error(' • Staff ID');
75
+ console.error(' • 企业邮箱');
35
76
  return;
36
77
  }
37
78
  // 验证必要配置
@@ -39,8 +80,12 @@ async function activate(runtime, config) {
39
80
  const missingFields = requiredFields.filter(field => !config[field]);
40
81
  if (missingFields.length > 0) {
41
82
  console.error(`❌ 缺少必要配置:${missingFields.join(', ')}`);
83
+ console.error('');
42
84
  console.error('📝 请运行配置向导完成配置:');
43
- console.error(' node ~/.openclaw/extensions/beisen-ehr-plugin/scripts/configure.js');
85
+ console.error('');
86
+ console.error(' npx @peninsula-med/beisen-ehr-configure');
87
+ console.error('');
88
+ console.error('按提示输入北森凭证即可!');
44
89
  return;
45
90
  }
46
91
  // MCP 服务器配置会自动从 openclaw.plugin.json 加载
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/index.ts"],"sourcesContent":["/**\n * 北森 EHR OpenClaw Plugin\n * 🐉 龙二 开发\n * \n * 功能:加班申请、考勤查询、假期余额、审批状态查询\n */\n\nimport type { OpenClawPlugin } from 'openclaw/plugin-sdk';\n\n// 插件元数据\nexport const pluginId = 'beisen-ehr-plugin';\nexport const pluginVersion = '1.0.0';\n\n/**\n * 北森 EHR 插件配置接口\n */\nexport interface BeisenEHRConfig {\n /** 北森 API 地址 */\n apiUrl?: string;\n /** App Key */\n appKey: string;\n /** App Secret */\n appSecret: string;\n /** 员工 ID */\n staffId: string;\n /** 企业租户 ID */\n tenantId: string;\n /** 企业邮箱 */\n email: string;\n}\n\n/**\n * 默认配置\n */\nexport const defaultConfig: Partial<BeisenEHRConfig> = {\n apiUrl: 'https://openapi.italent.cn',\n};\n\n/**\n * 插件激活函数\n * \n * 当插件被激活时,自动配置 MCP 服务器\n */\nexport async function activate(runtime: any, config?: BeisenEHRConfig) {\n console.error(`🏢 北森 EHR 插件已激活 v${pluginVersion}`);\n \n // 处理空配置情况\n if (!config) {\n console.error('⚠️ 插件已安装,但未配置凭证');\n console.error('📝 请运行配置向导完成配置:');\n console.error(' node ~/.openclaw/extensions/beisen-ehr-plugin/scripts/configure.js');\n console.error('');\n console.error('Windows 用户:');\n console.error(' node %USERPROFILE%\\\\.openclaw\\\\extensions\\\\beisen-ehr-plugin\\\\scripts\\\\configure.js');\n return;\n }\n \n // 验证必要配置\n const requiredFields: (keyof BeisenEHRConfig)[] = ['appKey', 'appSecret', 'staffId', 'tenantId', 'email'];\n const missingFields = requiredFields.filter(field => !config[field]);\n \n if (missingFields.length > 0) {\n console.error(`❌ 缺少必要配置:${missingFields.join(', ')}`);\n console.error('📝 请运行配置向导完成配置:');\n console.error(' node ~/.openclaw/extensions/beisen-ehr-plugin/scripts/configure.js');\n return;\n }\n \n // MCP 服务器配置会自动从 openclaw.plugin.json 加载\n // 这里只需要验证配置即可\n console.error('✅ 北森 EHR 配置验证通过');\n console.error(`📡 API: ${config.apiUrl || defaultConfig.apiUrl}`);\n console.error(`👤 员工:${config.staffId}`);\n console.error(`🏢 企业:${config.tenantId}`);\n}\n\n/**\n * 插件停用函数\n */\nexport async function deactivate() {\n console.error('🏢 北森 EHR 插件已停用');\n}\n\n/**\n * 配置变更回调\n */\nexport async function onConfigChange(config: BeisenEHRConfig) {\n console.error('🔄 北森 EHR 配置已更新');\n await activate(undefined as any, config);\n}\n\n// 导出插件入口\nconst plugin: OpenClawPlugin = {\n id: pluginId,\n version: pluginVersion,\n activate,\n deactivate,\n onConfigChange,\n};\n\nexport default plugin;\n"],"names":[],"mappings":";;;;AAAA;;;;;AAKG;AAIH;AACO,MAAM,QAAQ,GAAG;AACjB,MAAM,aAAa,GAAG;AAoB7B;;AAEG;AACI,MAAM,aAAa,GAA6B;AACrD,IAAA,MAAM,EAAE,4BAA4B;;AAGtC;;;;AAIG;AACI,eAAe,QAAQ,CAAC,OAAY,EAAE,MAAwB,EAAA;AACnE,IAAA,OAAO,CAAC,KAAK,CAAC,oBAAoB,aAAa,CAAA,CAAE,CAAC;;IAGlD,IAAI,CAAC,MAAM,EAAE;AACX,QAAA,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC;AACjC,QAAA,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC;AAChC,QAAA,OAAO,CAAC,KAAK,CAAC,uEAAuE,CAAC;AACtF,QA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AAEA;AACA,MAAM,MAAM,GAAmB;AAC7B,IAAA,EAAE,EAAE,QAAQ;AACZ,IAAA,OAAO,EAAE,aAAa;IACtB,QAAQ;IACR,UAAU;IACV,cAAc;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/index.ts"],"sourcesContent":["/**\n * 北森 EHR OpenClaw Plugin\n * 🐉 龙二 开发\n * \n * 功能:加班申请、考勤查询、假期余额、审批状态查询\n */\n\nimport type { OpenClawPlugin } from 'openclaw/plugin-sdk';\n\n// 插件元数据\nexport const pluginId = 'beisen-ehr-plugin';\nexport const pluginVersion = '1.0.0';\n\n/**\n * 北森 EHR 插件配置接口\n */\nexport interface BeisenEHRConfig {\n /** 北森 API 地址 */\n apiUrl?: string;\n /** App Key */\n appKey: string;\n /** App Secret */\n appSecret: string;\n /** 员工 ID */\n staffId: string;\n /** 企业租户 ID */\n tenantId: string;\n /** 企业邮箱 */\n email: string;\n}\n\n/**\n * 默认配置\n */\nexport const defaultConfig: Partial<BeisenEHRConfig> = {\n apiUrl: 'https://openapi.italent.cn',\n};\n\nimport fs from 'fs';\nimport path from 'path';\nimport os from 'os';\n\n/**\n * 从配置文件读取配置\n */\nfunction loadConfig(): BeisenEHRConfig | null {\n try {\n const homeDir = os.homedir();\n const configPath = path.join(homeDir, '.openclaw', 'config.json');\n \n if (!fs.existsSync(configPath)) {\n return null;\n }\n \n const content = fs.readFileSync(configPath, 'utf-8');\n const config = JSON.parse(content);\n \n // 尝试读取插件配置(支持两种格式)\n const pluginConfig = config.plugins?.['beisen-ehr-plugin'] || \n config.plugins?.['@peninsula-med/beisen-ehr-plugin'];\n \n if (!pluginConfig || !pluginConfig.config) {\n return null;\n }\n \n return pluginConfig.config as BeisenEHRConfig;\n } catch (error) {\n console.error('❌ 读取配置文件失败:', (error as Error).message);\n return null;\n }\n}\n\n/**\n * 插件激活函数\n * \n * 当插件被激活时,自动配置 MCP 服务器\n */\nexport async function activate(runtime: any, config?: BeisenEHRConfig) {\n console.error(`🏢 北森 EHR 插件已激活 v${pluginVersion}`);\n \n // 如果 OpenClaw 没有传入配置,尝试从配置文件读取\n if (!config) {\n config = loadConfig() as BeisenEHRConfig | null;\n }\n \n // 处理空配置情况\n if (!config) {\n console.error('⚠️ 插件已安装,但未配置凭证');\n console.error('');\n console.error('📝 请运行配置向导完成配置:');\n console.error('');\n console.error(' npx @peninsula-med/beisen-ehr-configure');\n console.error('');\n console.error('按提示输入北森凭证即可!');\n console.error('');\n console.error('需要凭证?联系北森管理员获取:');\n console.error(' • App Key');\n console.error(' App Secret');\n console.error(' • Tenant ID');\n console.error(' • Staff ID');\n console.error(' • 企业邮箱');\n return;\n }\n \n // 验证必要配置\n const requiredFields: (keyof BeisenEHRConfig)[] = ['appKey', 'appSecret', 'staffId', 'tenantId', 'email'];\n const missingFields = requiredFields.filter(field => !config[field]);\n \n if (missingFields.length > 0) {\n console.error(`❌ 缺少必要配置:${missingFields.join(', ')}`);\n console.error('');\n console.error('📝 请运行配置向导完成配置:');\n console.error('');\n console.error(' npx @peninsula-med/beisen-ehr-configure');\n console.error('');\n console.error('按提示输入北森凭证即可!');\n return;\n }\n \n // MCP 服务器配置会自动从 openclaw.plugin.json 加载\n // 这里只需要验证配置即可\n console.error('✅ 北森 EHR 配置验证通过');\n console.error(`📡 API: ${config.apiUrl || defaultConfig.apiUrl}`);\n console.error(`👤 员工:${config.staffId}`);\n console.error(`🏢 企业:${config.tenantId}`);\n}\n\n/**\n * 插件停用函数\n */\nexport async function deactivate() {\n console.error('🏢 北森 EHR 插件已停用');\n}\n\n/**\n * 配置变更回调\n */\nexport async function onConfigChange(config: BeisenEHRConfig) {\n console.error('🔄 北森 EHR 配置已更新');\n await activate(undefined as any, config);\n}\n\n// 导出插件入口\nconst plugin: OpenClawPlugin = {\n id: pluginId,\n version: pluginVersion,\n activate,\n deactivate,\n onConfigChange,\n};\n\nexport default plugin;\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;;AAKG;AAIH;AACO,MAA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,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC;QAC7B;IACF;;;AAIA,IAAA,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC;AAChC,IAAA,OAAO,CAAC,KAAK,CAAC,CAAA,QAAA,EAAW,MAAM,CAAC,MAAM,IAAI,aAAa,CAAC,MAAM,CAAA,CAAE,CAAC;IACjE,OAAO,CAAC,KAAK,CAAC,CAAA,MAAA,EAAS,MAAM,CAAC,OAAO,CAAA,CAAE,CAAC;IACxC,OAAO,CAAC,KAAK,CAAC,CAAA,MAAA,EAAS,MAAM,CAAC,QAAQ,CAAA,CAAE,CAAC;AAC3C;AAEA;;AAEG;AACI,eAAe,UAAU,GAAA;AAC9B,IAAA,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC;AAClC;AAEA;;AAEG;AACI,eAAe,cAAc,CAAC,MAAuB,EAAA;AAC1D,IAAA,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC;AAChC,IAAA,MAAM,QAAQ,CAAC,SAAgB,EAAE,MAAM,CAAC;AAC1C;AAEA;AACA,MAAM,MAAM,GAAmB;AAC7B,IAAA,EAAE,EAAE,QAAQ;AACZ,IAAA,OAAO,EAAE,aAAa;IACtB,QAAQ;IACR,UAAU;IACV,cAAc;;;;;;;;;;;"}
package/dist/index.esm.js CHANGED
@@ -1,3 +1,7 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import os from 'os';
4
+
1
5
  /**
2
6
  * 北森 EHR OpenClaw Plugin
3
7
  * 🐉 龙二 开发
@@ -13,6 +17,31 @@ const pluginVersion = '1.0.0';
13
17
  const defaultConfig = {
14
18
  apiUrl: 'https://openapi.italent.cn',
15
19
  };
20
+ /**
21
+ * 从配置文件读取配置
22
+ */
23
+ function loadConfig() {
24
+ try {
25
+ const homeDir = os.homedir();
26
+ const configPath = path.join(homeDir, '.openclaw', 'config.json');
27
+ if (!fs.existsSync(configPath)) {
28
+ return null;
29
+ }
30
+ const content = fs.readFileSync(configPath, 'utf-8');
31
+ const config = JSON.parse(content);
32
+ // 尝试读取插件配置(支持两种格式)
33
+ const pluginConfig = config.plugins?.['beisen-ehr-plugin'] ||
34
+ config.plugins?.['@peninsula-med/beisen-ehr-plugin'];
35
+ if (!pluginConfig || !pluginConfig.config) {
36
+ return null;
37
+ }
38
+ return pluginConfig.config;
39
+ }
40
+ catch (error) {
41
+ console.error('❌ 读取配置文件失败:', error.message);
42
+ return null;
43
+ }
44
+ }
16
45
  /**
17
46
  * 插件激活函数
18
47
  *
@@ -20,14 +49,26 @@ const defaultConfig = {
20
49
  */
21
50
  async function activate(runtime, config) {
22
51
  console.error(`🏢 北森 EHR 插件已激活 v${pluginVersion}`);
52
+ // 如果 OpenClaw 没有传入配置,尝试从配置文件读取
53
+ if (!config) {
54
+ config = loadConfig();
55
+ }
23
56
  // 处理空配置情况
24
57
  if (!config) {
25
58
  console.error('⚠️ 插件已安装,但未配置凭证');
59
+ console.error('');
26
60
  console.error('📝 请运行配置向导完成配置:');
27
- console.error(' node ~/.openclaw/extensions/beisen-ehr-plugin/scripts/configure.js');
28
61
  console.error('');
29
- console.error('Windows 用户:');
30
- console.error(' node %USERPROFILE%\\.openclaw\\extensions\\beisen-ehr-plugin\\scripts\\configure.js');
62
+ console.error(' npx @peninsula-med/beisen-ehr-configure');
63
+ console.error('');
64
+ console.error('按提示输入北森凭证即可!');
65
+ console.error('');
66
+ console.error('需要凭证?联系北森管理员获取:');
67
+ console.error(' • App Key');
68
+ console.error(' • App Secret');
69
+ console.error(' • Tenant ID');
70
+ console.error(' • Staff ID');
71
+ console.error(' • 企业邮箱');
31
72
  return;
32
73
  }
33
74
  // 验证必要配置
@@ -35,8 +76,12 @@ async function activate(runtime, config) {
35
76
  const missingFields = requiredFields.filter(field => !config[field]);
36
77
  if (missingFields.length > 0) {
37
78
  console.error(`❌ 缺少必要配置:${missingFields.join(', ')}`);
79
+ console.error('');
38
80
  console.error('📝 请运行配置向导完成配置:');
39
- console.error(' node ~/.openclaw/extensions/beisen-ehr-plugin/scripts/configure.js');
81
+ console.error('');
82
+ console.error(' npx @peninsula-med/beisen-ehr-configure');
83
+ console.error('');
84
+ console.error('按提示输入北森凭证即可!');
40
85
  return;
41
86
  }
42
87
  // MCP 服务器配置会自动从 openclaw.plugin.json 加载
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/index.ts"],"sourcesContent":["/**\n * 北森 EHR OpenClaw Plugin\n * 🐉 龙二 开发\n * \n * 功能:加班申请、考勤查询、假期余额、审批状态查询\n */\n\nimport type { OpenClawPlugin } from 'openclaw/plugin-sdk';\n\n// 插件元数据\nexport const pluginId = 'beisen-ehr-plugin';\nexport const pluginVersion = '1.0.0';\n\n/**\n * 北森 EHR 插件配置接口\n */\nexport interface BeisenEHRConfig {\n /** 北森 API 地址 */\n apiUrl?: string;\n /** App Key */\n appKey: string;\n /** App Secret */\n appSecret: string;\n /** 员工 ID */\n staffId: string;\n /** 企业租户 ID */\n tenantId: string;\n /** 企业邮箱 */\n email: string;\n}\n\n/**\n * 默认配置\n */\nexport const defaultConfig: Partial<BeisenEHRConfig> = {\n apiUrl: 'https://openapi.italent.cn',\n};\n\n/**\n * 插件激活函数\n * \n * 当插件被激活时,自动配置 MCP 服务器\n */\nexport async function activate(runtime: any, config?: BeisenEHRConfig) {\n console.error(`🏢 北森 EHR 插件已激活 v${pluginVersion}`);\n \n // 处理空配置情况\n if (!config) {\n console.error('⚠️ 插件已安装,但未配置凭证');\n console.error('📝 请运行配置向导完成配置:');\n console.error(' node ~/.openclaw/extensions/beisen-ehr-plugin/scripts/configure.js');\n console.error('');\n console.error('Windows 用户:');\n console.error(' node %USERPROFILE%\\\\.openclaw\\\\extensions\\\\beisen-ehr-plugin\\\\scripts\\\\configure.js');\n return;\n }\n \n // 验证必要配置\n const requiredFields: (keyof BeisenEHRConfig)[] = ['appKey', 'appSecret', 'staffId', 'tenantId', 'email'];\n const missingFields = requiredFields.filter(field => !config[field]);\n \n if (missingFields.length > 0) {\n console.error(`❌ 缺少必要配置:${missingFields.join(', ')}`);\n console.error('📝 请运行配置向导完成配置:');\n console.error(' node ~/.openclaw/extensions/beisen-ehr-plugin/scripts/configure.js');\n return;\n }\n \n // MCP 服务器配置会自动从 openclaw.plugin.json 加载\n // 这里只需要验证配置即可\n console.error('✅ 北森 EHR 配置验证通过');\n console.error(`📡 API: ${config.apiUrl || defaultConfig.apiUrl}`);\n console.error(`👤 员工:${config.staffId}`);\n console.error(`🏢 企业:${config.tenantId}`);\n}\n\n/**\n * 插件停用函数\n */\nexport async function deactivate() {\n console.error('🏢 北森 EHR 插件已停用');\n}\n\n/**\n * 配置变更回调\n */\nexport async function onConfigChange(config: BeisenEHRConfig) {\n console.error('🔄 北森 EHR 配置已更新');\n await activate(undefined as any, config);\n}\n\n// 导出插件入口\nconst plugin: OpenClawPlugin = {\n id: pluginId,\n version: pluginVersion,\n activate,\n deactivate,\n onConfigChange,\n};\n\nexport default plugin;\n"],"names":[],"mappings":"AAAA;;;;;AAKG;AAIH;AACO,MAAM,QAAQ,GAAG;AACjB,MAAM,aAAa,GAAG;AAoB7B;;AAEG;AACI,MAAM,aAAa,GAA6B;AACrD,IAAA,MAAM,EAAE,4BAA4B;;AAGtC;;;;AAIG;AACI,eAAe,QAAQ,CAAC,OAAY,EAAE,MAAwB,EAAA;AACnE,IAAA,OAAO,CAAC,KAAK,CAAC,oBAAoB,aAAa,CAAA,CAAE,CAAC;;IAGlD,IAAI,CAAC,MAAM,EAAE;AACX,QAAA,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC;AACjC,QAAA,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC;AAChC,QAAA,OAAO,CAAC,KAAK,CAAC,uEAAuE,CAAC;AACtF,QAAA,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;AACjB,QAAA,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC;AAC5B,QAAA,OAAO,CAAC,KAAK,CAAC,wFAAwF,CAAC;QACvG;IACF;;AAGA,IA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","sources":["../src/index.ts"],"sourcesContent":["/**\n * 北森 EHR OpenClaw Plugin\n * 🐉 龙二 开发\n * \n * 功能:加班申请、考勤查询、假期余额、审批状态查询\n */\n\nimport type { OpenClawPlugin } from 'openclaw/plugin-sdk';\n\n// 插件元数据\nexport const pluginId = 'beisen-ehr-plugin';\nexport const pluginVersion = '1.0.0';\n\n/**\n * 北森 EHR 插件配置接口\n */\nexport interface BeisenEHRConfig {\n /** 北森 API 地址 */\n apiUrl?: string;\n /** App Key */\n appKey: string;\n /** App Secret */\n appSecret: string;\n /** 员工 ID */\n staffId: string;\n /** 企业租户 ID */\n tenantId: string;\n /** 企业邮箱 */\n email: string;\n}\n\n/**\n * 默认配置\n */\nexport const defaultConfig: Partial<BeisenEHRConfig> = {\n apiUrl: 'https://openapi.italent.cn',\n};\n\nimport fs from 'fs';\nimport path from 'path';\nimport os from 'os';\n\n/**\n * 从配置文件读取配置\n */\nfunction loadConfig(): BeisenEHRConfig | null {\n try {\n const homeDir = os.homedir();\n const configPath = path.join(homeDir, '.openclaw', 'config.json');\n \n if (!fs.existsSync(configPath)) {\n return null;\n }\n \n const content = fs.readFileSync(configPath, 'utf-8');\n const config = JSON.parse(content);\n \n // 尝试读取插件配置(支持两种格式)\n const pluginConfig = config.plugins?.['beisen-ehr-plugin'] || \n config.plugins?.['@peninsula-med/beisen-ehr-plugin'];\n \n if (!pluginConfig || !pluginConfig.config) {\n return null;\n }\n \n return pluginConfig.config as BeisenEHRConfig;\n } catch (error) {\n console.error('❌ 读取配置文件失败:', (error as Error).message);\n return null;\n }\n}\n\n/**\n * 插件激活函数\n * \n * 当插件被激活时,自动配置 MCP 服务器\n */\nexport async function activate(runtime: any, config?: BeisenEHRConfig) {\n console.error(`🏢 北森 EHR 插件已激活 v${pluginVersion}`);\n \n // 如果 OpenClaw 没有传入配置,尝试从配置文件读取\n if (!config) {\n config = loadConfig() as BeisenEHRConfig | null;\n }\n \n // 处理空配置情况\n if (!config) {\n console.error('⚠️ 插件已安装,但未配置凭证');\n console.error('');\n console.error('📝 请运行配置向导完成配置:');\n console.error('');\n console.error(' npx @peninsula-med/beisen-ehr-configure');\n console.error('');\n console.error('按提示输入北森凭证即可!');\n console.error('');\n console.error('需要凭证?联系北森管理员获取:');\n console.error(' • App Key');\n console.error(' App Secret');\n console.error(' • Tenant ID');\n console.error(' • Staff ID');\n console.error(' • 企业邮箱');\n return;\n }\n \n // 验证必要配置\n const requiredFields: (keyof BeisenEHRConfig)[] = ['appKey', 'appSecret', 'staffId', 'tenantId', 'email'];\n const missingFields = requiredFields.filter(field => !config[field]);\n \n if (missingFields.length > 0) {\n console.error(`❌ 缺少必要配置:${missingFields.join(', ')}`);\n console.error('');\n console.error('📝 请运行配置向导完成配置:');\n console.error('');\n console.error(' npx @peninsula-med/beisen-ehr-configure');\n console.error('');\n console.error('按提示输入北森凭证即可!');\n return;\n }\n \n // MCP 服务器配置会自动从 openclaw.plugin.json 加载\n // 这里只需要验证配置即可\n console.error('✅ 北森 EHR 配置验证通过');\n console.error(`📡 API: ${config.apiUrl || defaultConfig.apiUrl}`);\n console.error(`👤 员工:${config.staffId}`);\n console.error(`🏢 企业:${config.tenantId}`);\n}\n\n/**\n * 插件停用函数\n */\nexport async function deactivate() {\n console.error('🏢 北森 EHR 插件已停用');\n}\n\n/**\n * 配置变更回调\n */\nexport async function onConfigChange(config: BeisenEHRConfig) {\n console.error('🔄 北森 EHR 配置已更新');\n await activate(undefined as any, config);\n}\n\n// 导出插件入口\nconst plugin: OpenClawPlugin = {\n id: pluginId,\n version: pluginVersion,\n activate,\n deactivate,\n onConfigChange,\n};\n\nexport default plugin;\n"],"names":[],"mappings":";;;;AAAA;;;;;AAKG;AAIH;AACO,MAAM,QAAQ,GAAG;AACjB,MAAM,aAAa,GAAG;AAoB7B;;AAEG;AACI,MAAM,aAAa,GAA6B;AACrD,IAAA,MAAM,EAAE,4BAA4B;;AAOtC;;AAEG;AACH,SAAS,UAAU,GAAA;AACjB,IAAA,IAAI;AACF,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,IAAI,aAAa,CAAC,MAAM,CAAA,CAAE,CAAC;IACjE,OAAO,CAAC,KAAK,CAAC,CAAA,MAAA,EAAS,MAAM,CAAC,OAAO,CAAA,CAAE,CAAC;IACxC,OAAO,CAAC,KAAK,CAAC,CAAA,MAAA,EAAS,MAAM,CAAC,QAAQ,CAAA,CAAE,CAAC;AAC3C;AAEA;;AAEG;AACI,eAAe,UAAU,GAAA;AAC9B,IAAA,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC;AAClC;AAEA;;AAEG;AACI,eAAe,cAAc,CAAC,MAAuB,EAAA;AAC1D,IAAA,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC;AAChC,IAAA,MAAM,QAAQ,CAAC,SAAgB,EAAE,MAAM,CAAC;AAC1C;AAEA;AACA,MAAM,MAAM,GAAmB;AAC7B,IAAA,EAAE,EAAE,QAAQ;AACZ,IAAA,OAAO,EAAE,aAAa;IACtB,QAAQ;IACR,UAAU;IACV,cAAc;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peninsula-med/beisen-ehr-plugin",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",