@ynhcj/xiaoyi-channel 1.0.3 → 1.0.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.
Files changed (2) hide show
  1. package/dist/src/push.js +38 -39
  2. package/package.json +1 -1
package/dist/src/push.js CHANGED
@@ -1,7 +1,6 @@
1
1
  // Push message service for scheduled tasks
2
2
  import fetch from "node-fetch";
3
3
  import { randomUUID } from "crypto";
4
- import { logger } from "./utils/logger.js";
5
4
  import { configManager } from "./utils/config-manager.js";
6
5
  /**
7
6
  * Service for sending push messages to users.
@@ -29,22 +28,22 @@ export class XYPushService {
29
28
  // Get dynamic pushId for the session (falls back to config pushId)
30
29
  const dynamicPushId = configManager.getPushId(sessionId);
31
30
  const pushId = dynamicPushId || this.config.pushId;
32
- logger.log(`[PUSH] 📤 Preparing to send push message`);
33
- logger.log(`[PUSH] - Title: "${title}"`);
34
- logger.log(`[PUSH] - Content length: ${content.length} chars`);
35
- logger.log(`[PUSH] - Session ID: ${sessionId || 'none'}`);
36
- logger.log(`[PUSH] - Trace ID: ${traceId}`);
37
- logger.log(`[PUSH] - Push URL: ${pushUrl}`);
31
+ console.log(`[PUSH] 📤 Preparing to send push message`);
32
+ console.log(`[PUSH] - Title: "${title}"`);
33
+ console.log(`[PUSH] - Content length: ${content.length} chars`);
34
+ console.log(`[PUSH] - Session ID: ${sessionId || 'none'}`);
35
+ console.log(`[PUSH] - Trace ID: ${traceId}`);
36
+ console.log(`[PUSH] - Push URL: ${pushUrl}`);
38
37
  if (dynamicPushId) {
39
- logger.log(`[PUSH] - Using dynamic pushId (from session): ${pushId.substring(0, 20)}...`);
40
- logger.log(`[PUSH] - Full dynamic pushId: ${pushId}`);
38
+ console.log(`[PUSH] - Using dynamic pushId (from session): ${pushId.substring(0, 20)}...`);
39
+ console.log(`[PUSH] - Full dynamic pushId: ${pushId}`);
41
40
  }
42
41
  else {
43
- logger.log(`[PUSH] - Using config pushId (fallback): ${pushId.substring(0, 20)}...`);
44
- logger.log(`[PUSH] - Full config pushId: ${pushId}`);
42
+ console.log(`[PUSH] - Using config pushId (fallback): ${pushId.substring(0, 20)}...`);
43
+ console.log(`[PUSH] - Full config pushId: ${pushId}`);
45
44
  }
46
- logger.log(`[PUSH] - API ID: ${this.config.apiId}`);
47
- logger.log(`[PUSH] - UID: ${this.config.uid}`);
45
+ console.log(`[PUSH] - API ID: ${this.config.apiId}`);
46
+ console.log(`[PUSH] - UID: ${this.config.uid}`);
48
47
  try {
49
48
  const requestBody = {
50
49
  jsonrpc: "2.0",
@@ -68,7 +67,7 @@ export class XYPushService {
68
67
  ],
69
68
  },
70
69
  };
71
- logger.debug(`[PUSH] Full request body:`, JSON.stringify(requestBody, null, 2));
70
+ console.log(`[PUSH] Full request body:`, JSON.stringify(requestBody, null, 2));
72
71
  const response = await fetch(pushUrl, {
73
72
  method: "POST",
74
73
  headers: {
@@ -82,25 +81,25 @@ export class XYPushService {
82
81
  body: JSON.stringify(requestBody),
83
82
  });
84
83
  // Log response status and headers
85
- logger.log(`[PUSH] 📥 Response received`);
86
- logger.log(`[PUSH] - HTTP Status: ${response.status} ${response.statusText}`);
87
- logger.log(`[PUSH] - Content-Type: ${response.headers.get('content-type')}`);
88
- logger.log(`[PUSH] - Content-Length: ${response.headers.get('content-length')}`);
84
+ console.log(`[PUSH] 📥 Response received`);
85
+ console.log(`[PUSH] - HTTP Status: ${response.status} ${response.statusText}`);
86
+ console.log(`[PUSH] - Content-Type: ${response.headers.get('content-type')}`);
87
+ console.log(`[PUSH] - Content-Length: ${response.headers.get('content-length')}`);
89
88
  if (!response.ok) {
90
89
  const errorText = await response.text();
91
- logger.error(`[PUSH] ❌ Push request failed`);
92
- logger.error(`[PUSH] - HTTP Status: ${response.status}`);
93
- logger.error(`[PUSH] - Response body: ${errorText}`);
90
+ console.log(`[PUSH] ❌ Push request failed`);
91
+ console.log(`[PUSH] - HTTP Status: ${response.status}`);
92
+ console.log(`[PUSH] - Response body: ${errorText}`);
94
93
  throw new Error(`Push failed: HTTP ${response.status} - ${errorText}`);
95
94
  }
96
95
  // Try to parse JSON response with detailed error handling
97
96
  let result;
98
97
  try {
99
98
  const responseText = await response.text();
100
- logger.log(`[PUSH] 📄 Response body length: ${responseText.length} chars`);
101
- logger.log(`[PUSH] 📄 Response body preview: ${responseText.substring(0, 200)}`);
99
+ console.log(`[PUSH] 📄 Response body length: ${responseText.length} chars`);
100
+ console.log(`[PUSH] 📄 Response body preview: ${responseText.substring(0, 200)}`);
102
101
  if (!responseText || responseText.trim() === '') {
103
- logger.warn(`[PUSH] ⚠️ Received empty response body`);
102
+ console.log(`[PUSH] ⚠️ Received empty response body`);
104
103
  result = {};
105
104
  }
106
105
  else {
@@ -108,28 +107,28 @@ export class XYPushService {
108
107
  }
109
108
  }
110
109
  catch (parseError) {
111
- logger.error(`[PUSH] ❌ Failed to parse JSON response`);
112
- logger.error(`[PUSH] - Parse error: ${parseError instanceof Error ? parseError.message : String(parseError)}`);
110
+ console.log(`[PUSH] ❌ Failed to parse JSON response`);
111
+ console.log(`[PUSH] - Parse error: ${parseError instanceof Error ? parseError.message : String(parseError)}`);
113
112
  throw new Error(`Invalid JSON response from push service: ${parseError instanceof Error ? parseError.message : String(parseError)}`);
114
113
  }
115
- logger.log(`[PUSH] ✅ Push message sent successfully`);
116
- logger.log(`[PUSH] - Title: "${title}"`);
117
- logger.log(`[PUSH] - Trace ID: ${traceId}`);
118
- logger.log(`[PUSH] - Used pushId: ${pushId.substring(0, 20)}...`);
119
- logger.debug(`[PUSH] - Response:`, result);
114
+ console.log(`[PUSH] ✅ Push message sent successfully`);
115
+ console.log(`[PUSH] - Title: "${title}"`);
116
+ console.log(`[PUSH] - Trace ID: ${traceId}`);
117
+ console.log(`[PUSH] - Used pushId: ${pushId.substring(0, 20)}...`);
118
+ console.log(`[PUSH] - Response:`, result);
120
119
  }
121
120
  catch (error) {
122
- logger.error(`[PUSH] ❌ Failed to send push message`);
123
- logger.error(`[PUSH] - Trace ID: ${traceId}`);
124
- logger.error(`[PUSH] - Target URL: ${pushUrl}`);
125
- logger.error(`[PUSH] - Push ID: ${pushId.substring(0, 20)}...`);
121
+ console.log(`[PUSH] ❌ Failed to send push message`);
122
+ console.log(`[PUSH] - Trace ID: ${traceId}`);
123
+ console.log(`[PUSH] - Target URL: ${pushUrl}`);
124
+ console.log(`[PUSH] - Push ID: ${pushId.substring(0, 20)}...`);
126
125
  if (error instanceof Error) {
127
- logger.error(`[PUSH] - Error name: ${error.name}`);
128
- logger.error(`[PUSH] - Error message: ${error.message}`);
129
- logger.error(`[PUSH] - Error stack:`, error.stack);
126
+ console.log(`[PUSH] - Error name: ${error.name}`);
127
+ console.log(`[PUSH] - Error message: ${error.message}`);
128
+ console.log(`[PUSH] - Error stack:`, error.stack);
130
129
  }
131
130
  else {
132
- logger.error(`[PUSH] - Error:`, error);
131
+ console.log(`[PUSH] - Error:`, error);
133
132
  }
134
133
  throw error;
135
134
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ynhcj/xiaoyi-channel",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "OpenClaw Xiaoyi Channel plugin - Xiaoyi A2A protocol integration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",