@ynhcj/xiaoyi 2.0.0 → 2.0.2
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 +21 -14
- package/dist/runtime.d.ts +5 -5
- package/dist/runtime.js +9 -8
- package/package.json +1 -1
package/dist/channel.js
CHANGED
|
@@ -197,8 +197,6 @@ exports.xiaoyiPlugin = {
|
|
|
197
197
|
console.log("XiaoYi: startAccount() called - START");
|
|
198
198
|
const runtime = (0, runtime_1.getXiaoYiRuntime)();
|
|
199
199
|
const resolvedAccount = ctx.account;
|
|
200
|
-
// Store the runtime environment for accessing handleInboundMessage
|
|
201
|
-
runtime.setRuntime(ctx.runtime);
|
|
202
200
|
// Start WebSocket connection (single account mode)
|
|
203
201
|
await runtime.start(resolvedAccount.config);
|
|
204
202
|
// Setup message handler IMMEDIATELY after connection is established
|
|
@@ -214,17 +212,26 @@ exports.xiaoyiPlugin = {
|
|
|
214
212
|
console.log(`XiaoYi: [Message Handler] Using runtime instance: ${runtime.getInstanceId()}`);
|
|
215
213
|
// Store sessionId -> taskId mapping in runtime
|
|
216
214
|
runtime.setTaskIdForSession(message.sessionId, message.id);
|
|
217
|
-
// Get
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
215
|
+
// Get PluginRuntime from our runtime wrapper
|
|
216
|
+
const pluginRuntime = runtime.getPluginRuntime();
|
|
217
|
+
console.log(`XiaoYi: PluginRuntime type: ${typeof pluginRuntime}`);
|
|
218
|
+
console.log(`XiaoYi: PluginRuntime.channel type: ${typeof pluginRuntime?.channel}`);
|
|
219
|
+
console.log(`XiaoYi: PluginRuntime.channel.reply type: ${typeof pluginRuntime?.channel?.reply}`);
|
|
220
|
+
console.log(`XiaoYi: PluginRuntime.channel.reply.handleInboundMessage type: ${typeof pluginRuntime?.channel?.reply?.handleInboundMessage}`);
|
|
221
|
+
if (!pluginRuntime || !pluginRuntime.channel?.reply?.handleInboundMessage) {
|
|
222
|
+
console.error("handleInboundMessage not available in PluginRuntime");
|
|
223
|
+
console.error(`PluginRuntime exists: ${!!pluginRuntime}`);
|
|
224
|
+
console.error(`PluginRuntime.channel exists: ${!!pluginRuntime?.channel}`);
|
|
225
|
+
console.error(`PluginRuntime.channel.reply exists: ${!!pluginRuntime?.channel?.reply}`);
|
|
226
|
+
console.error(`PluginRuntime.channel.reply.handleInboundMessage exists: ${!!pluginRuntime?.channel?.reply?.handleInboundMessage}`);
|
|
227
|
+
// Log the actual structure
|
|
228
|
+
if (pluginRuntime?.channel?.reply) {
|
|
229
|
+
console.error(`PluginRuntime.channel.reply keys: ${Object.keys(pluginRuntime.channel.reply).join(', ')}`);
|
|
230
|
+
}
|
|
224
231
|
return;
|
|
225
232
|
}
|
|
226
233
|
// Convert A2A message to OpenClaw inbound message format
|
|
227
|
-
await
|
|
234
|
+
await pluginRuntime.channel.reply.handleInboundMessage({
|
|
228
235
|
channel: "xiaoyi",
|
|
229
236
|
accountId: resolvedAccount.accountId,
|
|
230
237
|
from: message.sender.id,
|
|
@@ -247,10 +254,10 @@ exports.xiaoyiPlugin = {
|
|
|
247
254
|
// CRITICAL: Use dynamic require to get the latest runtime module after hot-reload
|
|
248
255
|
const { getXiaoYiRuntime } = require("./runtime");
|
|
249
256
|
const runtime = getXiaoYiRuntime();
|
|
250
|
-
//
|
|
251
|
-
const
|
|
252
|
-
if (
|
|
253
|
-
|
|
257
|
+
// Get PluginRuntime and emit cancel event
|
|
258
|
+
const pluginRuntime = runtime.getPluginRuntime();
|
|
259
|
+
if (pluginRuntime) {
|
|
260
|
+
pluginRuntime.emit("task:cancel", {
|
|
254
261
|
channel: "xiaoyi",
|
|
255
262
|
accountId: resolvedAccount.accountId,
|
|
256
263
|
taskId: data.taskId,
|
package/dist/runtime.d.ts
CHANGED
|
@@ -6,20 +6,20 @@ import { XiaoYiChannelConfig } from "./types";
|
|
|
6
6
|
*/
|
|
7
7
|
export declare class XiaoYiRuntime {
|
|
8
8
|
private connection;
|
|
9
|
-
private
|
|
9
|
+
private pluginRuntime;
|
|
10
10
|
private config;
|
|
11
11
|
private sessionToTaskIdMap;
|
|
12
12
|
private instanceId;
|
|
13
13
|
constructor();
|
|
14
14
|
getInstanceId(): string;
|
|
15
15
|
/**
|
|
16
|
-
* Set OpenClaw runtime
|
|
16
|
+
* Set OpenClaw PluginRuntime (from api.runtime in register())
|
|
17
17
|
*/
|
|
18
|
-
|
|
18
|
+
setPluginRuntime(runtime: any): void;
|
|
19
19
|
/**
|
|
20
|
-
* Get OpenClaw
|
|
20
|
+
* Get OpenClaw PluginRuntime
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
getPluginRuntime(): any;
|
|
23
23
|
/**
|
|
24
24
|
* Start connection (single account mode)
|
|
25
25
|
*/
|
package/dist/runtime.js
CHANGED
|
@@ -11,7 +11,7 @@ const websocket_1 = require("./websocket");
|
|
|
11
11
|
class XiaoYiRuntime {
|
|
12
12
|
constructor() {
|
|
13
13
|
this.connection = null;
|
|
14
|
-
this.
|
|
14
|
+
this.pluginRuntime = null; // Store PluginRuntime from OpenClaw
|
|
15
15
|
this.config = null;
|
|
16
16
|
this.sessionToTaskIdMap = new Map(); // Map sessionId to taskId
|
|
17
17
|
this.instanceId = `runtime_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
@@ -21,16 +21,17 @@ class XiaoYiRuntime {
|
|
|
21
21
|
return this.instanceId;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
* Set OpenClaw runtime
|
|
24
|
+
* Set OpenClaw PluginRuntime (from api.runtime in register())
|
|
25
25
|
*/
|
|
26
|
-
|
|
27
|
-
this.
|
|
26
|
+
setPluginRuntime(runtime) {
|
|
27
|
+
console.log(`XiaoYi: [${this.instanceId}] Setting PluginRuntime`);
|
|
28
|
+
this.pluginRuntime = runtime;
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
30
|
-
* Get OpenClaw
|
|
31
|
+
* Get OpenClaw PluginRuntime
|
|
31
32
|
*/
|
|
32
|
-
|
|
33
|
-
return this.
|
|
33
|
+
getPluginRuntime() {
|
|
34
|
+
return this.pluginRuntime;
|
|
34
35
|
}
|
|
35
36
|
/**
|
|
36
37
|
* Start connection (single account mode)
|
|
@@ -126,5 +127,5 @@ function getXiaoYiRuntime() {
|
|
|
126
127
|
return g[GLOBAL_KEY];
|
|
127
128
|
}
|
|
128
129
|
function setXiaoYiRuntime(runtime) {
|
|
129
|
-
getXiaoYiRuntime().
|
|
130
|
+
getXiaoYiRuntime().setPluginRuntime(runtime);
|
|
130
131
|
}
|