@ynhcj/xiaoyi 1.9.8 → 2.0.0

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/dist/channel.js CHANGED
@@ -208,14 +208,19 @@ exports.xiaoyiPlugin = {
208
208
  }
209
209
  // Setup message handler
210
210
  connection.on("message", async (message) => {
211
- // Get runtime dynamically to handle module reloads
212
- const runtime = (0, runtime_1.getXiaoYiRuntime)();
211
+ // CRITICAL: Use dynamic require to get the latest runtime module after hot-reload
212
+ const { getXiaoYiRuntime } = require("./runtime");
213
+ const runtime = getXiaoYiRuntime();
214
+ console.log(`XiaoYi: [Message Handler] Using runtime instance: ${runtime.getInstanceId()}`);
213
215
  // Store sessionId -> taskId mapping in runtime
214
216
  runtime.setTaskIdForSession(message.sessionId, message.id);
215
217
  // Get handleInboundMessage from runtime environment
216
218
  const runtimeEnv = runtime.getRuntime();
217
219
  if (!runtimeEnv || !runtimeEnv.channel?.reply?.handleInboundMessage) {
218
220
  console.error("handleInboundMessage not available in runtime");
221
+ console.error(`Runtime env exists: ${!!runtimeEnv}`);
222
+ console.error(`Runtime env.channel exists: ${!!runtimeEnv?.channel}`);
223
+ console.error(`Runtime env.channel.reply exists: ${!!runtimeEnv?.channel?.reply}`);
219
224
  return;
220
225
  }
221
226
  // Convert A2A message to OpenClaw inbound message format
@@ -239,6 +244,9 @@ exports.xiaoyiPlugin = {
239
244
  // Setup cancel handler
240
245
  connection.on("cancel", async (data) => {
241
246
  console.log(`Handling cancel request for task: ${data.taskId}`);
247
+ // CRITICAL: Use dynamic require to get the latest runtime module after hot-reload
248
+ const { getXiaoYiRuntime } = require("./runtime");
249
+ const runtime = getXiaoYiRuntime();
242
250
  // Emit cancel event to OpenClaw runtime
243
251
  const runtimeEnv = runtime.getRuntime();
244
252
  if (runtimeEnv) {
@@ -250,7 +258,10 @@ exports.xiaoyiPlugin = {
250
258
  });
251
259
  }
252
260
  // Send success response
253
- await connection.sendCancelSuccessResponse(data.sessionId, data.taskId, data.id);
261
+ const connection = runtime.getConnection();
262
+ if (connection) {
263
+ await connection.sendCancelSuccessResponse(data.sessionId, data.taskId, data.id);
264
+ }
254
265
  });
255
266
  console.log("XiaoYi: Event handlers registered");
256
267
  console.log("XiaoYi: startAccount() completed - END");
package/dist/runtime.js CHANGED
@@ -112,7 +112,8 @@ class XiaoYiRuntime {
112
112
  }
113
113
  exports.XiaoYiRuntime = XiaoYiRuntime;
114
114
  // Global runtime instance - use global object to survive module reloads
115
- const GLOBAL_KEY = Symbol.for('__xiaoyi_runtime_instance__');
115
+ // CRITICAL: Use string key instead of Symbol to ensure consistency across module reloads
116
+ const GLOBAL_KEY = '__xiaoyi_runtime_instance__';
116
117
  function getXiaoYiRuntime() {
117
118
  const g = global;
118
119
  if (!g[GLOBAL_KEY]) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ynhcj/xiaoyi",
3
- "version": "1.9.8",
3
+ "version": "2.0.0",
4
4
  "description": "XiaoYi channel plugin for OpenClaw",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",