claw-subagent-service 0.0.84 → 0.0.86

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claw-subagent-service",
3
- "version": "0.0.84",
3
+ "version": "0.0.86",
4
4
  "description": "虾说智能助手",
5
5
  "main": "cli.js",
6
6
  "bin": {
@@ -13,6 +13,8 @@ const { executeCommand } = require('./openclaw-control');
13
13
  const { createOpencodeSession, deleteOpencodeSession, forwardChatMessage } = require('./opencode-service');
14
14
  const { ServiceManager } = require('./service-manager');
15
15
  const { collectDashboardData } = require('./dashboard-collector');
16
+ const { getOpenClawStatus } = require('./port-checker');
17
+ const { getMacAddress } = require('./mac-address');
16
18
  const fs = require('fs');
17
19
  const path = require('path');
18
20
  const os = require('os');
@@ -306,11 +308,22 @@ class RongyunMessageHandler {
306
308
  const requestId = data.request_id;
307
309
  const targetId = data.source_im_id;
308
310
 
309
- this.logInfo(`[RongyunMessageHandler] 收到设备状态请求, from=${targetId}`);
311
+ this.logInfo(`[RongyunMessageHandler] 收到设备状态请求, from=${targetId}, requestId=${requestId}`);
310
312
 
311
313
  try {
312
- const dashboard = await collectDashboardData();
313
- await this.sendDeviceStatusReport(targetId, requestId, dashboard);
314
+ // 获取 OpenClaw 运行状态(检查端口 18789)
315
+ const openClawStatus = await getOpenClawStatus();
316
+
317
+ // 构建精简状态数据(避免超过融云 128KB 限制)
318
+ const statusData = {
319
+ open_claw_status: openClawStatus, // 1=运行中, 0=未运行
320
+ mac_address: getMacAddress(),
321
+ version: '0.0.20',
322
+ timestamp: Date.now(),
323
+ };
324
+
325
+ this.logInfo(`[RongyunMessageHandler] 设备状态: openClawStatus=${openClawStatus}`);
326
+ await this.sendDeviceStatusReport(targetId, requestId, statusData);
314
327
  } catch (e) {
315
328
  const msg = e instanceof Error ? e.message : String(e);
316
329
  this.logError(`设备状态查询异常: ${msg}`);
@@ -92,8 +92,8 @@ class ScriptExecutor {
92
92
  const fullOutput = stdout + stderr;
93
93
 
94
94
  // 调试日志:记录脚本实际输出
95
- console.log(`[ScriptExecutor-DEBUG] ${scriptName} 原始输出:\n${fullOutput}`);
96
- console.log(`[ScriptExecutor-DEBUG] ${scriptName} 输出长度: ${fullOutput.length}`);
95
+ console.log(`[ScriptExecutor] 执行脚本: ${scriptPath}`);
96
+ console.log(`[ScriptExecutor] ${scriptName} 输出:\n${fullOutput}`);
97
97
 
98
98
  return this.parseStatus(command, fullOutput);
99
99
  } catch (e) {
@@ -39,16 +39,16 @@ class RongCloudClient {
39
39
  this.log?.info('[RongCloudClient] 初始化 SDK...');
40
40
  RongIMLib.init({ appkey: this.config.appKey });
41
41
 
42
- // 注册 system_service 自定义消息类型(与前端对齐)
42
+ // 注册 command 自定义消息类型(与前端对齐)
43
43
  try {
44
44
  if (typeof RongIMLib.registerMessageType === 'function') {
45
- this.SystemServiceMessage = RongIMLib.registerMessageType('system_service', true, false);
46
- this.log?.info('[RongCloudClient] system_service 自定义消息类型已注册');
45
+ this.SystemServiceMessage = RongIMLib.registerMessageType('command', true, false);
46
+ this.log?.info('[RongCloudClient] command 自定义消息类型已注册');
47
47
  } else {
48
48
  this.log?.warn('[RongCloudClient] SDK 不支持 registerMessageType');
49
49
  }
50
50
  } catch (err) {
51
- this.log?.warn(`[RongCloudClient] 注册 system_service 消息类型失败: ${err.message}`);
51
+ this.log?.warn(`[RongCloudClient] 注册 command 消息类型失败: ${err.message}`);
52
52
  }
53
53
 
54
54
  this.log?.info(`[RongCloudClient] SDK Events: ${JSON.stringify(Object.keys(RongIMLib.Events || {}))}`);
@@ -169,8 +169,8 @@ class RongCloudClient {
169
169
  // 自定义消息 content 可能是对象,提取文本内容并保留 mentionedInfo
170
170
  if (rawContent && typeof rawContent === 'object') {
171
171
  mentionedInfo = mentionedInfo || rawContent.mentionedInfo || null;
172
- // system_service 等结构化消息保留完整 JSON(上层需要 msg_type 等字段)
173
- if (message.messageType === 'system_service' || rawContent.msg_type) {
172
+ // command 等结构化消息保留完整 JSON(上层需要 msg_type 等字段)
173
+ if (message.messageType === 'command' || rawContent.msg_type) {
174
174
  rawContent = JSON.stringify(rawContent);
175
175
  } else {
176
176
  rawContent = rawContent.content || rawContent.text || JSON.stringify(rawContent);
@@ -274,14 +274,14 @@ class RongCloudClient {
274
274
  }
275
275
  }
276
276
 
277
- async sendCustomMessage(targetId, content, conversationType, customType = 'system_service') {
277
+ async sendCustomMessage(targetId, content, conversationType, customType = 'command') {
278
278
  if (!this.isConnected) {
279
279
  this.log?.error('[RongCloudClient] 未连接,无法发送自定义消息');
280
280
  return false;
281
281
  }
282
282
 
283
283
  if (!this.SystemServiceMessage) {
284
- this.log?.error('[RongCloudClient] system_service 消息类型未注册');
284
+ this.log?.error('[RongCloudClient] command 消息类型未注册');
285
285
  return false;
286
286
  }
287
287