@ynhcj/xiaoyi-channel 0.0.23-next → 0.0.24-next

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.
@@ -48,9 +48,27 @@ export async function callCsplApi(questionText, cfg) {
48
48
  textSource: config.textSource,
49
49
  action: config.action,
50
50
  };
51
+ // 打印请求信息
52
+ console.log(`[CSPL API] ==================== 发起请求 ====================`);
53
+ console.log(`[CSPL API] URL: ${config.api.url}`);
54
+ console.log(`[CSPL API] Method: POST`);
55
+ console.log(`[CSPL API] Headers:`);
56
+ console.log(`[CSPL API] - x-hag-trace-id: ${headers["x-hag-trace-id"]}`);
57
+ console.log(`[CSPL API] - x-uid: ${headers["x-uid"]}`);
58
+ console.log(`[CSPL API] - x-api-key: ${headers["x-api-key"] ? "***" + headers["x-api-key"].slice(-8) : "undefined"}`);
59
+ console.log(`[CSPL API] - x-request-from: ${headers["x-request-from"]}`);
60
+ console.log(`[CSPL API] - x-skill-id: ${headers["x-skill-id"]}`);
61
+ console.log(`[CSPL API] - content-type: ${headers["content-type"]}`);
62
+ console.log(`[CSPL API] Body:`);
63
+ console.log(`[CSPL API] - questionText: ${questionText.substring(0, 100)}${questionText.length > 100 ? "..." : ""}`);
64
+ console.log(`[CSPL API] - textSource: ${payload.textSource}`);
65
+ console.log(`[CSPL API] - action: ${payload.action}`);
66
+ console.log(`[CSPL API] =================================================`);
51
67
  return new Promise((resolve, reject) => {
52
68
  const options = buildRequestOptions(config.api.url, headers, config.api.timeout);
53
69
  const req = https.request(options, (res) => {
70
+ console.log(`[CSPL API] Response Status: ${res.statusCode}`);
71
+ console.log(`[CSPL API] Response Headers: ${JSON.stringify(res.headers)}`);
54
72
  if (res.statusCode && res.statusCode >= HTTP_STATUS_BAD_REQUEST) {
55
73
  reject(new Error(`[CSPL] HTTP error: ${res.statusCode}`));
56
74
  return;
@@ -61,15 +79,25 @@ export async function callCsplApi(questionText, cfg) {
61
79
  });
62
80
  res.on("end", () => {
63
81
  try {
64
- resolve(parseResponse(data));
82
+ const result = parseResponse(data);
83
+ console.log(`[CSPL API] ✅ 请求成功`);
84
+ console.log(`[CSPL API] Response Body: ${data.substring(0, 200)}${data.length > 200 ? "..." : ""}`);
85
+ console.log(`[CSPL API] =================================================`);
86
+ resolve(result);
65
87
  }
66
88
  catch (e) {
89
+ console.error(`[CSPL API] ❌ 请求失败: ${e instanceof Error ? e.message : String(e)}`);
90
+ console.error(`[CSPL API] Response Body: ${data}`);
67
91
  reject(e);
68
92
  }
69
93
  });
70
94
  });
71
- req.on("error", reject);
95
+ req.on("error", (error) => {
96
+ console.error(`[CSPL API] ❌ 请求错误: ${error instanceof Error ? error.message : String(error)}`);
97
+ reject(error);
98
+ });
72
99
  req.on("timeout", () => {
100
+ console.error(`[CSPL API] ⏰ 请求超时 (${config.api.timeout}ms)`);
73
101
  req.destroy();
74
102
  reject(new Error("[CSPL] Request timeout"));
75
103
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ynhcj/xiaoyi-channel",
3
- "version": "0.0.23-next",
3
+ "version": "0.0.24-next",
4
4
  "description": "OpenClaw Xiaoyi Channel plugin - Xiaoyi A2A protocol integration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",