@ynhcj/xiaoyi-channel 0.0.108-beta → 0.0.109-beta
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/src/monitor.js
CHANGED
|
@@ -164,7 +164,7 @@ export async function monitorXYProvider(opts = {}) {
|
|
|
164
164
|
};
|
|
165
165
|
const selfEvolutionStateGetHandler = (context) => {
|
|
166
166
|
log(`[MONITOR] Received self-evolution-state-get-event, dispatching to handler...`);
|
|
167
|
-
handleSelfEvolutionStateGetEvent(context, cfg, runtime).catch((err) => {
|
|
167
|
+
handleSelfEvolutionStateGetEvent(context, cfg, runtime, wsManager).catch((err) => {
|
|
168
168
|
error(`[MONITOR] Failed to handle self-evolution-state-get-event:`, err);
|
|
169
169
|
});
|
|
170
170
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type { XYWebSocketManager } from "./websocket.js";
|
|
1
2
|
export declare function handleSelfEvolutionEvent(context: any, runtime: any): void;
|
|
2
3
|
/**
|
|
3
|
-
* 读取 .xiaoyiruntime 中的 selfEvolutionState
|
|
4
|
+
* 读取 .xiaoyiruntime 中的 selfEvolutionState 并直接通过 wsManager 下发指令回复设备
|
|
5
|
+
* 参考trigger实现:直接使用当前已连接的 wsManager 发送消息,避免 getXYWebSocketManager 返回未连接实例
|
|
4
6
|
*/
|
|
5
|
-
export declare function handleSelfEvolutionStateGetEvent(context: any, cfg: any, runtime: any): Promise<void>;
|
|
7
|
+
export declare function handleSelfEvolutionStateGetEvent(context: any, cfg: any, runtime: any, wsManager: XYWebSocketManager): Promise<void>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { readFileSync, writeFileSync } from "fs";
|
|
2
2
|
import { v4 as uuidv4 } from "uuid";
|
|
3
|
-
import { sendCommand } from "./formatter.js";
|
|
4
3
|
const XIAOYIRUNTIME_PATH = "/home/sandbox/.openclaw/.xiaoyiruntime";
|
|
5
4
|
export function handleSelfEvolutionEvent(context, runtime) {
|
|
6
5
|
const log = runtime?.log ?? console.log;
|
|
@@ -48,9 +47,10 @@ export function handleSelfEvolutionEvent(context, runtime) {
|
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
49
|
/**
|
|
51
|
-
* 读取 .xiaoyiruntime 中的 selfEvolutionState
|
|
50
|
+
* 读取 .xiaoyiruntime 中的 selfEvolutionState 并直接通过 wsManager 下发指令回复设备
|
|
51
|
+
* 参考trigger实现:直接使用当前已连接的 wsManager 发送消息,避免 getXYWebSocketManager 返回未连接实例
|
|
52
52
|
*/
|
|
53
|
-
export async function handleSelfEvolutionStateGetEvent(context, cfg, runtime) {
|
|
53
|
+
export async function handleSelfEvolutionStateGetEvent(context, cfg, runtime, wsManager) {
|
|
54
54
|
const log = runtime?.log ?? console.log;
|
|
55
55
|
const error = runtime?.error ?? console.error;
|
|
56
56
|
try {
|
|
@@ -103,13 +103,36 @@ export async function handleSelfEvolutionStateGetEvent(context, cfg, runtime) {
|
|
|
103
103
|
pageControlRelated: false,
|
|
104
104
|
},
|
|
105
105
|
};
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
// 构造 artifact update 消息,直接通过当前 wsManager 发送
|
|
107
|
+
const jsonRpcResponse = {
|
|
108
|
+
jsonrpc: "2.0",
|
|
109
|
+
id: messageId,
|
|
110
|
+
result: {
|
|
111
|
+
taskId,
|
|
112
|
+
kind: "artifact-update",
|
|
113
|
+
append: false,
|
|
114
|
+
lastChunk: true,
|
|
115
|
+
final: false,
|
|
116
|
+
artifact: {
|
|
117
|
+
artifactId: uuidv4(),
|
|
118
|
+
parts: [{
|
|
119
|
+
kind: "data",
|
|
120
|
+
data: {
|
|
121
|
+
commands: [command],
|
|
122
|
+
},
|
|
123
|
+
}],
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
const outboundMessage = {
|
|
128
|
+
msgType: "agent_response",
|
|
129
|
+
agentId: cfg.agentId,
|
|
108
130
|
sessionId,
|
|
109
131
|
taskId,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
});
|
|
132
|
+
msgDetail: JSON.stringify(jsonRpcResponse),
|
|
133
|
+
};
|
|
134
|
+
log(`[A2A_COMMAND] 📤 Sending A2A command: taskId: ${taskId}`);
|
|
135
|
+
await wsManager.sendMessage(sessionId, outboundMessage);
|
|
113
136
|
log(`[SELF_EVOLUTION_GET] command sent successfully`);
|
|
114
137
|
}
|
|
115
138
|
catch (err) {
|