@peninsula-med/beisen-ehr-plugin 3.1.3 → 3.1.4

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
@@ -1,28 +1,14 @@
1
- # 北森 EHR 加班申请插件 v3.1.3 🐉
1
+ # 北森 EHR 加班申请插件 v3.1.0 🐉
2
2
 
3
3
  专注功能:**加班申请**
4
4
 
5
- ## 🚀 v3.1.3 优化 (2026-03-13)
6
-
7
- **性能优化:**
8
- - ⚡ **Token 缓存增强** - 减少重复获取(500-1000ms/次)
9
- - 🔇 **日志精简** - DEBUG 模式控制,减少 I/O 开销
10
- - ✅ **参数验证前置** - 日期格式错误提前拦截
11
-
12
- **错误处理修复:**
13
- - 🚨 **API 响应严格检查** - 支持 `code`/`status` 多种格式
14
- - 📝 **原始响应日志** - DEBUG 模式下记录完整 API 响应
15
- - 🔍 **详细错误信息** - 尝试 `message`/`msg`/`error` 多种字段
16
-
17
- **文档优化:**
18
- - 📖 **SKILL.md 快速开始** - 30 秒内找到正确调用方式
19
- - 🛠️ **故障排查指南** - 响应慢/调用失败检查清单
5
+ **新增**:SKILL.md 技能文档,AI 自动识别何时调用工具!
20
6
 
21
7
  ## 一键安装
22
8
 
23
9
  ```bash
24
10
  # 1. 安装插件
25
- openclaw plugins install @peninsula-med/beisen-ehr-plugin@3.1.3
11
+ openclaw plugins install @peninsula-med/beisen-ehr-plugin@latest
26
12
 
27
13
  # 2. 配置凭证
28
14
  npx @peninsula-med/beisen-ehr-configure
@@ -47,24 +33,7 @@ openclaw gateway restart
47
33
  - Tenant ID
48
34
  - 企业邮箱
49
35
 
50
- ## 调试模式
51
-
52
- ```bash
53
- # 开启详细日志
54
- export DEBUG=true
55
- openclaw gateway restart
56
-
57
- # 查看日志
58
- openclaw gateway logs
59
- ```
60
-
61
- ## 故障排查
62
-
63
- 见 `SKILL.md` 或访问:
64
- - `/home/node/.openclaw/workspace/beisen-ehr-plugin/skills/beisen-ehr/SKILL.md`
65
-
66
36
  ---
67
37
 
68
- **版本**: 3.1.3
69
- **作者**: 龙二 🐉
70
- **更新**: 2026-03-13
38
+ **版本**: 3.0.0
39
+ **作者**: 龙二 🐉
package/dist/index.cjs.js CHANGED
@@ -3454,30 +3454,25 @@ var TypeBuilder = /*#__PURE__*/Object.freeze({
3454
3454
  const Type = TypeBuilder;
3455
3455
 
3456
3456
  /**
3457
- * 北森 EHR OpenClaw Plugin v3.1.0 (性能优化版)
3457
+ * 北森 EHR OpenClaw Plugin v3.0.0
3458
3458
  * 🐉 龙二 开发
3459
3459
  *
3460
3460
  * 专注功能:加班申请
3461
- * 优化:Token 缓存增强、日志精简、错误处理修复
3462
3461
  */
3463
3462
  const pluginId = 'beisen-ehr-plugin';
3464
- const pluginVersion = '3.1.0';
3463
+ const pluginVersion = '3.0.0';
3465
3464
  const defaultConfig = {
3466
3465
  apiUrl: 'https://openapi.italent.cn',
3467
3466
  };
3468
- // ============ Token 管理(增强缓存) ============
3467
+ // ============ Token 管理 ============
3469
3468
  let cachedToken = null;
3470
3469
  let tokenExpiry = 0;
3471
- // 调试模式控制
3472
- const DEBUG = process.env.DEBUG === 'true' || process.env.BEISEN_DEBUG === 'true';
3473
- const log = (...args) => DEBUG ? console.error(...args) : null;
3474
3470
  async function getAccessToken(config) {
3475
3471
  if (cachedToken && Date.now() < tokenExpiry) {
3476
- log(`[BEISEN] ⚡ 使用缓存 Token`);
3477
3472
  return cachedToken;
3478
3473
  }
3479
3474
  const tokenUrl = `${config.apiUrl || defaultConfig.apiUrl}/token`;
3480
- log(`[BEISEN] 🔑 正在获取 Token: ${tokenUrl}`);
3475
+ console.error(`[BEISEN] 🔑 正在获取 Token: ${tokenUrl}`);
3481
3476
  const response = await fetch(tokenUrl, {
3482
3477
  method: "POST",
3483
3478
  headers: { "Content-Type": "application/json" },
@@ -3494,7 +3489,7 @@ async function getAccessToken(config) {
3494
3489
  const data = await response.json();
3495
3490
  cachedToken = data.accessToken || data.access_token;
3496
3491
  tokenExpiry = Date.now() + (data.expiresIn || data.expires_in || 7200) * 1000 - 5 * 60 * 1000;
3497
- log(`[BEISEN] ✅ Token 获取成功,有效期至:${new Date(tokenExpiry).toISOString()}`);
3492
+ console.error(`[BEISEN] ✅ Token 获取成功,有效期至:${new Date(tokenExpiry).toISOString()}`);
3498
3493
  return cachedToken;
3499
3494
  }
3500
3495
  // ============ API 客户端 ============
@@ -3512,8 +3507,12 @@ class BeisenClient {
3512
3507
  ...(options.headers || {}),
3513
3508
  };
3514
3509
  const requestBody = options.body ? JSON.stringify(options.body) : undefined;
3515
- log(`[BEISEN] 📡 ${options.method || 'GET'} ${url}`);
3516
- log(`[BEISEN] 🔑 Token: ${token.substring(0, 20)}...`);
3510
+ console.error(`[BEISEN] 📡 ${options.method || 'GET'} ${url}`);
3511
+ console.error(`[BEISEN] 🔑 Token: ${token.substring(0, 20)}...`);
3512
+ console.error(`[BEISEN] 🏢 TenantId: ${this.config.tenantId}`);
3513
+ if (requestBody) {
3514
+ console.error(`[BEISEN] 📦 Body: ${requestBody.substring(0, 200)}`);
3515
+ }
3517
3516
  const controller = new AbortController();
3518
3517
  const timeoutId = setTimeout(() => controller.abort(), 30000);
3519
3518
  try {
@@ -3529,7 +3528,7 @@ class BeisenClient {
3529
3528
  throw new Error(`API 错误:${response.status} - ${errorText}`);
3530
3529
  }
3531
3530
  const result = await response.json();
3532
- log(`[BEISEN] 📥 API 原始响应:${JSON.stringify(result)}`);
3531
+ console.error(`[BEISEN] 响应:`, JSON.stringify(result).substring(0, 200));
3533
3532
  return result;
3534
3533
  }
3535
3534
  catch (error) {
@@ -3537,7 +3536,7 @@ class BeisenClient {
3537
3536
  if (error.name === 'AbortError') {
3538
3537
  throw new Error('请求超时(30 秒)');
3539
3538
  }
3540
- log(`[BEISEN] ❌ 错误:${error.message}`);
3539
+ console.error(`[BEISEN] ❌ 错误:`, error.message);
3541
3540
  throw error;
3542
3541
  }
3543
3542
  }
@@ -3578,7 +3577,7 @@ async function register(api) {
3578
3577
  console.error('[BEISEN] 🔧 正在注册工具...');
3579
3578
  api.registerTool({
3580
3579
  name: 'beisen_submit_overtime',
3581
- description: '提交加班申请',
3580
+ description: '提交加班申请到北森 EHR(推送数据并发起审批)',
3582
3581
  parameters: Type.Object({
3583
3582
  startDate: Type.String({ description: '开始时间 (YYYY-MM-DD HH:mm:ss)' }),
3584
3583
  stopDate: Type.String({ description: '结束时间 (YYYY-MM-DD HH:mm:ss)' }),
@@ -3586,16 +3585,8 @@ async function register(api) {
3586
3585
  properties: Type.Optional(Type.String({ description: '自定义字段 JSON' })),
3587
3586
  }),
3588
3587
  async execute(_id, params) {
3589
- log(`[BEISEN] 🔨 工具调用:beisen_submit_overtime`, JSON.stringify(params));
3588
+ console.error(`[BEISEN] 🔨 工具调用:beisen_submit_overtime`, JSON.stringify(params));
3590
3589
  try {
3591
- // 参数验证
3592
- const dateTimeRegex = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/;
3593
- if (!dateTimeRegex.test(params.startDate)) {
3594
- throw new Error("startDate 格式错误,应为 YYYY-MM-DD HH:mm:ss");
3595
- }
3596
- if (!dateTimeRegex.test(params.stopDate)) {
3597
- throw new Error("stopDate 格式错误,应为 YYYY-MM-DD HH:mm:ss");
3598
- }
3599
3590
  const result = await client.submitOvertime({
3600
3591
  staffId: config.staffId,
3601
3592
  email: config.email,
@@ -3604,32 +3595,17 @@ async function register(api) {
3604
3595
  compensationType: params.compensationType,
3605
3596
  properties: params.properties,
3606
3597
  });
3607
- // 严格检查响应状态
3608
- const isSuccess = (result.code === "200" ||
3609
- result.code === 200 ||
3610
- result.status === "200" ||
3611
- result.status === 200 ||
3612
- result.status === "success");
3613
- if (isSuccess) {
3614
- const compTypeText = params.compensationType === 1 ? "加班费" : "调休假";
3615
- const applicationId = result.data || result.id || result.applicationId || "待返回";
3616
- log(`[BEISEN] ✅ 加班申请提交成功:${applicationId}`);
3617
- return {
3618
- content: [{
3619
- type: "text",
3620
- text: `✅ 加班申请已提交!\n\n- 员工:${config.staffId}\n- 邮箱:${config.email}\n- 时间:${params.startDate} ~ ${params.stopDate}\n- 类型:${compTypeText}\n- 申请 ID: ${applicationId}`,
3621
- }],
3622
- };
3623
- }
3624
- else {
3625
- // 详细错误信息
3626
- const errorMsg = result.message || result.msg || result.error || `API 返回错误:${JSON.stringify(result)}`;
3627
- log(`[BEISEN] ❌ API 错误:${errorMsg}`);
3628
- throw new Error(errorMsg);
3629
- }
3598
+ const compTypeText = params.compensationType === 1 ? "加班费" : "调休假";
3599
+ console.error(`[BEISEN] 加班申请提交成功:`, result);
3600
+ return {
3601
+ content: [{
3602
+ type: "text",
3603
+ text: `✅ 加班申请已提交!\n\n- 员工:${config.staffId}\n- 邮箱:${config.email}\n- 时间:${params.startDate} ~ ${params.stopDate}\n- 类型:${compTypeText}`,
3604
+ }],
3605
+ };
3630
3606
  }
3631
3607
  catch (error) {
3632
- log(`[BEISEN] ❌ 提交失败:${error.message}`);
3608
+ console.error(`[BEISEN] ❌ 提交失败:`, error.message);
3633
3609
  return {
3634
3610
  content: [{ type: "text", text: `❌ 提交失败:${error.message}` }],
3635
3611
  isError: true,