@ynhcj/xiaoyi 1.9.4 → 1.9.6

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/index.js CHANGED
@@ -34,7 +34,7 @@ const plugin = {
34
34
  console.log("XiaoYi: setXiaoYiRuntime() completed");
35
35
  // Clean up any existing connections from previous plugin loads
36
36
  const runtime = require("./runtime").getXiaoYiRuntime();
37
- console.log("XiaoYi: Got runtime instance, isConnected:", runtime.isConnected());
37
+ console.log(`XiaoYi: Got runtime instance: ${runtime.getInstanceId()}, isConnected: ${runtime.isConnected()}`);
38
38
  if (runtime.isConnected()) {
39
39
  console.log("XiaoYi: Cleaning up existing connection from previous load");
40
40
  runtime.stop();
package/dist/runtime.d.ts CHANGED
@@ -10,6 +10,9 @@ export declare class XiaoYiRuntime {
10
10
  private config;
11
11
  private sessionToTaskIdMap;
12
12
  private handleInboundMessage;
13
+ private instanceId;
14
+ constructor();
15
+ getInstanceId(): string;
13
16
  /**
14
17
  * Set OpenClaw runtime
15
18
  */
package/dist/runtime.js CHANGED
@@ -15,6 +15,11 @@ class XiaoYiRuntime {
15
15
  this.config = null;
16
16
  this.sessionToTaskIdMap = new Map(); // Map sessionId to taskId
17
17
  this.handleInboundMessage = null; // Store handleInboundMessage callback
18
+ this.instanceId = `runtime_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
19
+ console.log(`XiaoYi: Created new runtime instance: ${this.instanceId}`);
20
+ }
21
+ getInstanceId() {
22
+ return this.instanceId;
18
23
  }
19
24
  /**
20
25
  * Set OpenClaw runtime
@@ -32,14 +37,14 @@ class XiaoYiRuntime {
32
37
  * Set handleInboundMessage callback
33
38
  */
34
39
  setHandleInboundMessage(handler) {
35
- console.log("XiaoYi: Setting handleInboundMessage callback");
40
+ console.log(`XiaoYi: [${this.instanceId}] Setting handleInboundMessage callback`);
36
41
  this.handleInboundMessage = handler;
37
42
  }
38
43
  /**
39
44
  * Get handleInboundMessage callback
40
45
  */
41
46
  getHandleInboundMessage() {
42
- console.log("XiaoYi: Getting handleInboundMessage callback, available:", !!this.handleInboundMessage);
47
+ console.log(`XiaoYi: [${this.instanceId}] Getting handleInboundMessage callback, available:`, !!this.handleInboundMessage);
43
48
  return this.handleInboundMessage;
44
49
  }
45
50
  /**
@@ -122,13 +127,14 @@ class XiaoYiRuntime {
122
127
  }
123
128
  }
124
129
  exports.XiaoYiRuntime = XiaoYiRuntime;
125
- // Global runtime instance
126
- let globalRuntime = null;
130
+ // Global runtime instance - use global object to survive module reloads
131
+ const GLOBAL_KEY = Symbol.for('__xiaoyi_runtime_instance__');
127
132
  function getXiaoYiRuntime() {
128
- if (!globalRuntime) {
129
- globalRuntime = new XiaoYiRuntime();
133
+ const g = global;
134
+ if (!g[GLOBAL_KEY]) {
135
+ g[GLOBAL_KEY] = new XiaoYiRuntime();
130
136
  }
131
- return globalRuntime;
137
+ return g[GLOBAL_KEY];
132
138
  }
133
139
  function setXiaoYiRuntime(runtime) {
134
140
  getXiaoYiRuntime().setRuntime(runtime);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ynhcj/xiaoyi",
3
- "version": "1.9.4",
3
+ "version": "1.9.6",
4
4
  "description": "XiaoYi channel plugin for OpenClaw",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",