@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 { handleXYMessage } from "./bot.js";
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
- const prefixMessage = "这是定时任务的执行结果,你检查一下是否依赖手机侧的工具执行,如果依赖则在本轮任务中完成手机侧任务执行,如果不依赖,则直接把完整的执行结果返回给用户";
49
- const fullMessage = `${prefixMessage}\n\n${pushDataItem.dataDetail}`;
50
- log(`[TRIGGER_HANDLER] 📝 Constructed message (length: ${fullMessage.length} chars)`);
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 a2aMessage = {
54
+ const response = {
56
55
  jsonrpc: "2.0",
57
- method: "sendMessage",
58
56
  id: messageId,
59
- params: {
60
- id: taskId, // 使用新的 taskId(点击推送时生成)
61
- sessionId: sessionId, // 使用原始会话 sessionId
62
- agentLoginSessionId: "",
63
- message: {
64
- role: "user",
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: fullMessage,
68
+ text: pushDataItem.dataDetail, // 直接返回原始内容
69
69
  },
70
70
  ],
71
71
  },
72
72
  },
73
+ error: { code: 0 },
73
74
  };
74
- log(`[TRIGGER_HANDLER] 🚀 Dispatching A2A message to bot handler`);
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} (NEW - will trigger steer mode if configured)`);
85
+ log(`[TRIGGER_HANDLER] - taskId: ${taskId}`);
77
86
  log(`[TRIGGER_HANDLER] - messageId: ${messageId}`);
78
- // 透传给 openclaw 处理
79
- // 如果配置了 steer 模式,且该 sessionId 有活跃任务,这个新的 taskId 会覆盖旧的
80
- await handleXYMessage({
81
- cfg,
82
- runtime,
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/snadbox/.openclaw/pushData.json";
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/snadbox/.openclaw/pushIdList.json";
5
+ const PUSHID_LIST_FILE = "/home/sandbox/.openclaw/pushIdList.json";
6
6
  /**
7
7
  * 确保目录存在
8
8
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ynhcj/xiaoyi-channel",
3
- "version": "0.0.40-beta",
3
+ "version": "0.0.42-beta",
4
4
  "description": "OpenClaw Xiaoyi Channel plugin - Xiaoyi A2A protocol integration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",