@ynhcj/xiaoyi-channel 1.0.2 → 1.0.3

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 +35 -3
  2. package/package.json +1 -1
package/dist/src/push.js CHANGED
@@ -81,14 +81,37 @@ export class XYPushService {
81
81
  },
82
82
  body: JSON.stringify(requestBody),
83
83
  });
84
+ // 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
89
  if (!response.ok) {
85
90
  const errorText = await response.text();
86
91
  logger.error(`[PUSH] ❌ Push request failed`);
87
92
  logger.error(`[PUSH] - HTTP Status: ${response.status}`);
88
- logger.error(`[PUSH] - Error: ${errorText}`);
93
+ logger.error(`[PUSH] - Response body: ${errorText}`);
89
94
  throw new Error(`Push failed: HTTP ${response.status} - ${errorText}`);
90
95
  }
91
- const result = await response.json();
96
+ // Try to parse JSON response with detailed error handling
97
+ let result;
98
+ try {
99
+ 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)}`);
102
+ if (!responseText || responseText.trim() === '') {
103
+ logger.warn(`[PUSH] ⚠️ Received empty response body`);
104
+ result = {};
105
+ }
106
+ else {
107
+ result = JSON.parse(responseText);
108
+ }
109
+ }
110
+ catch (parseError) {
111
+ logger.error(`[PUSH] ❌ Failed to parse JSON response`);
112
+ logger.error(`[PUSH] - Parse error: ${parseError instanceof Error ? parseError.message : String(parseError)}`);
113
+ throw new Error(`Invalid JSON response from push service: ${parseError instanceof Error ? parseError.message : String(parseError)}`);
114
+ }
92
115
  logger.log(`[PUSH] ✅ Push message sent successfully`);
93
116
  logger.log(`[PUSH] - Title: "${title}"`);
94
117
  logger.log(`[PUSH] - Trace ID: ${traceId}`);
@@ -98,7 +121,16 @@ export class XYPushService {
98
121
  catch (error) {
99
122
  logger.error(`[PUSH] ❌ Failed to send push message`);
100
123
  logger.error(`[PUSH] - Trace ID: ${traceId}`);
101
- logger.error(`[PUSH] - Error:`, error);
124
+ logger.error(`[PUSH] - Target URL: ${pushUrl}`);
125
+ logger.error(`[PUSH] - Push ID: ${pushId.substring(0, 20)}...`);
126
+ 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);
130
+ }
131
+ else {
132
+ logger.error(`[PUSH] - Error:`, error);
133
+ }
102
134
  throw error;
103
135
  }
104
136
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ynhcj/xiaoyi-channel",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "OpenClaw Xiaoyi Channel plugin - Xiaoyi A2A protocol integration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",