@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 +1 -1
- package/dist/runtime.d.ts +3 -0
- package/dist/runtime.js +13 -7
- package/package.json +1 -1
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(
|
|
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
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(
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
129
|
-
|
|
133
|
+
const g = global;
|
|
134
|
+
if (!g[GLOBAL_KEY]) {
|
|
135
|
+
g[GLOBAL_KEY] = new XiaoYiRuntime();
|
|
130
136
|
}
|
|
131
|
-
return
|
|
137
|
+
return g[GLOBAL_KEY];
|
|
132
138
|
}
|
|
133
139
|
function setXiaoYiRuntime(runtime) {
|
|
134
140
|
getXiaoYiRuntime().setRuntime(runtime);
|