@ynhcj/xiaoyi 2.0.0 → 2.0.1
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 +12 -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,17 @@ 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
|
-
if (!
|
|
220
|
-
console.error("handleInboundMessage not available in
|
|
221
|
-
console.error(`
|
|
222
|
-
console.error(`
|
|
223
|
-
console.error(`
|
|
215
|
+
// Get PluginRuntime from our runtime wrapper
|
|
216
|
+
const pluginRuntime = runtime.getPluginRuntime();
|
|
217
|
+
if (!pluginRuntime || !pluginRuntime.channel?.reply?.handleInboundMessage) {
|
|
218
|
+
console.error("handleInboundMessage not available in PluginRuntime");
|
|
219
|
+
console.error(`PluginRuntime exists: ${!!pluginRuntime}`);
|
|
220
|
+
console.error(`PluginRuntime.channel exists: ${!!pluginRuntime?.channel}`);
|
|
221
|
+
console.error(`PluginRuntime.channel.reply exists: ${!!pluginRuntime?.channel?.reply}`);
|
|
224
222
|
return;
|
|
225
223
|
}
|
|
226
224
|
// Convert A2A message to OpenClaw inbound message format
|
|
227
|
-
await
|
|
225
|
+
await pluginRuntime.channel.reply.handleInboundMessage({
|
|
228
226
|
channel: "xiaoyi",
|
|
229
227
|
accountId: resolvedAccount.accountId,
|
|
230
228
|
from: message.sender.id,
|
|
@@ -247,10 +245,10 @@ exports.xiaoyiPlugin = {
|
|
|
247
245
|
// CRITICAL: Use dynamic require to get the latest runtime module after hot-reload
|
|
248
246
|
const { getXiaoYiRuntime } = require("./runtime");
|
|
249
247
|
const runtime = getXiaoYiRuntime();
|
|
250
|
-
//
|
|
251
|
-
const
|
|
252
|
-
if (
|
|
253
|
-
|
|
248
|
+
// Get PluginRuntime and emit cancel event
|
|
249
|
+
const pluginRuntime = runtime.getPluginRuntime();
|
|
250
|
+
if (pluginRuntime) {
|
|
251
|
+
pluginRuntime.emit("task:cancel", {
|
|
254
252
|
channel: "xiaoyi",
|
|
255
253
|
accountId: resolvedAccount.accountId,
|
|
256
254
|
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
|
}
|