@ynhcj/xiaoyi-channel 0.0.40-beta → 0.0.42-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.
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// Trigger 事件处理器
|
|
2
2
|
import { randomUUID } from "crypto";
|
|
3
3
|
import { getPushDataById } from "./utils/pushdata-manager.js";
|
|
4
|
-
import {
|
|
4
|
+
import { resolveXYConfig } from "./config.js";
|
|
5
|
+
import { getXYWebSocketManager } from "./client.js";
|
|
5
6
|
/**
|
|
6
7
|
* 处理 Trigger 事件
|
|
7
8
|
* 当用户在手机侧点击推送消息时触发
|
|
@@ -44,46 +45,50 @@ export async function handleTriggerEvent(context, cfg, runtime, accountId) {
|
|
|
44
45
|
log(`[TRIGGER_HANDLER] - pushDataId: ${pushDataItem.pushDataId}`);
|
|
45
46
|
log(`[TRIGGER_HANDLER] - time: ${pushDataItem.time}`);
|
|
46
47
|
log(`[TRIGGER_HANDLER] - dataDetail length: ${pushDataItem.dataDetail.length} chars`);
|
|
47
|
-
//
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
// 构造 A2A
|
|
52
|
-
// 使用从 WebSocket 传递过来的 sessionId 和 taskId(新的 taskId)
|
|
53
|
-
// 这样可以触发 steer 模式,覆盖之前正在执行的任务
|
|
48
|
+
// ==================== 新逻辑:直接返回结果 ====================
|
|
49
|
+
log(`[TRIGGER_HANDLER] 📤 Directly responding with pushData content`);
|
|
50
|
+
// 获取配置
|
|
51
|
+
const config = resolveXYConfig(cfg);
|
|
52
|
+
// 构造 A2A Response(final=true,直接结束)
|
|
54
53
|
const messageId = randomUUID();
|
|
55
|
-
const
|
|
54
|
+
const response = {
|
|
56
55
|
jsonrpc: "2.0",
|
|
57
|
-
method: "sendMessage",
|
|
58
56
|
id: messageId,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
57
|
+
result: {
|
|
58
|
+
taskId: taskId,
|
|
59
|
+
kind: "artifact-update",
|
|
60
|
+
append: false,
|
|
61
|
+
lastChunk: true,
|
|
62
|
+
final: true, // 直接结束
|
|
63
|
+
artifact: {
|
|
64
|
+
artifactId: randomUUID(),
|
|
65
65
|
parts: [
|
|
66
66
|
{
|
|
67
67
|
kind: "text",
|
|
68
|
-
text:
|
|
68
|
+
text: pushDataItem.dataDetail, // 直接返回原始内容
|
|
69
69
|
},
|
|
70
70
|
],
|
|
71
71
|
},
|
|
72
72
|
},
|
|
73
|
+
error: { code: 0 },
|
|
73
74
|
};
|
|
74
|
-
|
|
75
|
+
// 构造 WebSocket 消息
|
|
76
|
+
const outboundMessage = {
|
|
77
|
+
msgType: "agent_response",
|
|
78
|
+
agentId: config.agentId,
|
|
79
|
+
sessionId: sessionId,
|
|
80
|
+
taskId: taskId,
|
|
81
|
+
msgDetail: JSON.stringify(response),
|
|
82
|
+
};
|
|
83
|
+
log(`[TRIGGER_HANDLER] 📦 Sending direct response:`);
|
|
75
84
|
log(`[TRIGGER_HANDLER] - sessionId: ${sessionId}`);
|
|
76
|
-
log(`[TRIGGER_HANDLER] - taskId: ${taskId}
|
|
85
|
+
log(`[TRIGGER_HANDLER] - taskId: ${taskId}`);
|
|
77
86
|
log(`[TRIGGER_HANDLER] - messageId: ${messageId}`);
|
|
78
|
-
|
|
79
|
-
//
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
message: a2aMessage,
|
|
84
|
-
accountId,
|
|
85
|
-
});
|
|
86
|
-
log(`[TRIGGER_HANDLER] ✅ Trigger event handled successfully`);
|
|
87
|
+
log(`[TRIGGER_HANDLER] - content length: ${pushDataItem.dataDetail.length} chars`);
|
|
88
|
+
// 发送消息
|
|
89
|
+
const wsManager = getXYWebSocketManager(config);
|
|
90
|
+
await wsManager.sendMessage(sessionId, outboundMessage);
|
|
91
|
+
log(`[TRIGGER_HANDLER] ✅ Direct response sent successfully`);
|
|
87
92
|
}
|
|
88
93
|
catch (err) {
|
|
89
94
|
error(`[TRIGGER_HANDLER] ❌ Failed to handle Trigger event:`, err);
|
|
@@ -3,7 +3,7 @@ import { promises as fs } from "fs";
|
|
|
3
3
|
import * as path from "path";
|
|
4
4
|
import { randomUUID } from "crypto";
|
|
5
5
|
import { logger } from "./logger.js";
|
|
6
|
-
const PUSHDATA_FILE = "/home/
|
|
6
|
+
const PUSHDATA_FILE = "/home/sandbox/.openclaw/pushData.json";
|
|
7
7
|
const MAX_PUSHDATA_ITEMS = 1000; // 最多保留 1000 条记录
|
|
8
8
|
/**
|
|
9
9
|
* 格式化北京时间(UTC+8)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { promises as fs } from "fs";
|
|
3
3
|
import * as path from "path";
|
|
4
4
|
import { logger } from "./logger.js";
|
|
5
|
-
const PUSHID_LIST_FILE = "/home/
|
|
5
|
+
const PUSHID_LIST_FILE = "/home/sandbox/.openclaw/pushIdList.json";
|
|
6
6
|
/**
|
|
7
7
|
* 确保目录存在
|
|
8
8
|
*/
|