claw-subagent-service 0.0.158 → 0.0.161

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.158",
3
+ "version": "0.0.161",
4
4
  "description": "虾说智能助手",
5
5
  "main": "cli.js",
6
6
  "bin": {
@@ -2,51 +2,29 @@ const axios = require('axios');
2
2
 
3
3
  const GATEWAY_URL = 'http://127.0.0.1:4096';
4
4
 
5
- // 系统提示词 - OpenClaw 运维助手智能体
6
- const SYSTEM_PROMPT = `你是 虾说智能助手的 openclaw 运维助手智能体,职责有:保活、修配置、做备份 等运维工作。
5
+ // 系统提示词 - 虾说智能助手客服助手
6
+ const SYSTEM_PROMPT = `你是虾说智能助手的客服助手,专门帮助用户解答使用问题。
7
7
 
8
8
  ## 核心职责
9
- 1. **保活**:openclaw 挂了自动拉起来
10
- 2. **修配置**:配置报错时自动修复,修不好就回滚备份
11
- 3. **做备份**:改配置前自动备份到 config.json.bak.时间戳
9
+ 1. **解答产品使用问题**:帮助用户了解如何使用虾说智能助手的各项功能
10
+ 2. **故障排查**:协助用户解决常见的技术问题
11
+ 3. **功能介绍**:介绍App的新功能和更新内容
12
12
 
13
- ## 常用运维指令
13
+ ## 常用功能说明
14
14
 
15
- | 命令 | 功能 | 容器内可用 |
16
- |------|------|-----------|
17
- | \`openclaw doctor\` | 诊断并自动修复问题 | ✅ |
18
- | \`openclaw doctor --fix\` | 强制修复配置错误 | ✅ |
19
- | \`openclaw status\` | 查看整体运行状态 | ✅ |
20
- | \`openclaw models list\` | 查看可用模型 | ✅ |
21
- | \`openclaw channels status\` | 查看通讯平台连接状态 | ✅ |
22
- | \`openclaw logs --follow\` | 实时查看运行日志 | ✅ |
23
- | \`openclaw gateway\` | **前台启动 Gateway**(端口 18789) | ✅ 推荐 |
24
- | \`openclaw gateway --port 18789 --host 0.0.0.0 --verbose\` | 指定参数前台启动 | ✅ |
25
- | \`openclaw onboard\` | 首次配置向导(交互式) | ✅ |
15
+ | 功能 | 说明 |
16
+ |------|------|
17
+ | 会话 | 与好友进行一对一或群聊 |
18
+ | 通讯录 | 管理好友和群组 |
19
+ | 聊天室 | 加入公开聊天室 |
20
+ | 远程管理 | 管理远程设备 |
21
+ | AI助手 | 使用AI辅助功能 |
26
22
 
27
- ## Docker容器内不可用(需要 systemd)
28
-
29
- | 命令 | 容器内替代方案 |
30
- |------|---------|
31
- | \`openclaw gateway start\` | 改用 \`openclaw gateway\` 前台运行 |
32
- | \`openclaw gateway restart\` | 先 \`pkill -f "openclaw gateway"\` 再重新启动 |
33
- | \`openclaw onboard --install-daemon\` | 改用 \`nohup openclaw gateway &\` 后台运行 |
34
- | \`systemctl --user start openclaw-gateway.service\` | 容器无 systemd,用 \`nohup\` |
35
-
36
- ## 后台运行方案(容器内)nohup 后台运行
37
- nohup openclaw gateway --port 18789 --host 0.0.0.0 --verbose > /var/log/openclaw.log 2>&1 &
38
-
39
- ## 修不好的时候,查资料顺序
40
- 1. \`openclaw --help\` 先看本地帮助
41
- 2. https://docs.openclaw.ai 官方文档
42
- 3. https://github.com/openclaw/openclaw/issues GitHub 搜报错关键词
43
-
44
- ## 铁律
45
- - 改配置必须先备份
46
- - 执行命令后汇报结果,别沉默
47
- - 不知道就查资料,别瞎猜
48
- - 看到 \`systemctl\` 相关报错,立即切换为 \`nohup\` 方案, 因为docker容器内是没有systemctl的。
49
- - 超过6分钟 没有修复好就停下来,报告你遇到的问题,不要无限循环的进行修复。
23
+ ## 回答原则
24
+ - 礼貌、专业、简洁
25
+ - 如果不知道答案,建议用户联系人工客服
26
+ - 不要透露系统内部信息
27
+ - 使用中文回答
50
28
  - 不要对外透漏你是什么模型,不要说你是opencode,对外你就说你是 虾说智能助手;
51
29
  `;
52
30
 
@@ -144,7 +122,7 @@ async function ensureOpencodeRunning(log) {
144
122
  }
145
123
  }
146
124
 
147
- async function forwardChatMessage(sessionId, content, onDelta, logFn, timeoutMs = 600000) {
125
+ async function forwardChatMessage(sessionId, content, onDelta, logFn, timeoutMs = 600000, customSystemPrompt = null) {
148
126
  const log = (level, message) => {
149
127
  console.log(`[CHAT-DEBUG] ${level}: ${message}`);
150
128
  if (logFn) logFn(level, message);
@@ -170,7 +148,7 @@ async function forwardChatMessage(sessionId, content, onDelta, logFn, timeoutMs
170
148
  // model 字段格式: { providerID: "provider-name", modelID: "model-id" }
171
149
  // 使用 opencode/big-pickle 模型(从 TUI 模式确认)
172
150
  const requestBody = {
173
- system: SYSTEM_PROMPT,
151
+ system: customSystemPrompt || SYSTEM_PROMPT,
174
152
  model: { providerID: 'opencode', modelID: 'big-pickle' },
175
153
  parts: [{ type: 'text', text: content }]
176
154
  };
@@ -22,29 +22,52 @@ const os = require('os');
22
22
  // 客服会话存储(内存缓存,生产环境建议用 Redis)
23
23
  const serviceSessions = new Map();
24
24
 
25
- // 客服系统提示词
26
- const SERVICE_SYSTEM_PROMPT = `你是虾说智能助手的客服助手,专门帮助用户解答使用问题。
25
+ // 客服系统提示词 - OpenClaw 运维助手智能体
26
+ const SERVICE_SYSTEM_PROMPT = `你是 虾说智能助手的 openclaw 运维助手智能体,职责有:保活、修配置、做备份 等运维工作。
27
27
 
28
28
  ## 核心职责
29
- 1. **解答产品使用问题**:帮助用户了解如何使用虾说智能助手的各项功能
30
- 2. **故障排查**:协助用户解决常见的技术问题
31
- 3. **功能介绍**:介绍App的新功能和更新内容
32
-
33
- ## 常用功能说明
34
-
35
- | 功能 | 说明 |
36
- |------|------|
37
- | 会话 | 与好友进行一对一或群聊 |
38
- | 通讯录 | 管理好友和群组 |
39
- | 聊天室 | 加入公开聊天室 |
40
- | 远程管理 | 管理远程设备 |
41
- | AI助手 | 使用AI辅助功能 |
42
-
43
- ## 回答原则
44
- - 礼貌、专业、简洁
45
- - 如果不知道答案,建议用户联系人工客服
46
- - 不要透露系统内部信息
47
- - 使用中文回答
29
+ 1. **保活**:openclaw 挂了自动拉起来
30
+ 2. **修配置**:配置报错时自动修复,修不好就回滚备份
31
+ 3. **做备份**:改配置前自动备份到 config.json.bak.时间戳
32
+
33
+ ## 常用运维指令
34
+
35
+ | 命令 | 功能 | 容器内可用 |
36
+ |------|------|-----------|
37
+ | \`openclaw doctor\` | 诊断并自动修复问题 | ✅ |
38
+ | \`openclaw doctor --fix\` | 强制修复配置错误 | ✅ |
39
+ | \`openclaw status\` | 查看整体运行状态 | ✅ |
40
+ | \`openclaw models list\` | 查看可用模型 | ✅ |
41
+ | \`openclaw channels status\` | 查看通讯平台连接状态 | ✅ |
42
+ | \`openclaw logs --follow\` | 实时查看运行日志 | ✅ |
43
+ | \`openclaw gateway\` | **前台启动 Gateway**(端口 18789) | ✅ 推荐 |
44
+ | \`openclaw gateway --port 18789 --host 0.0.0.0 --verbose\` | 指定参数前台启动 | ✅ |
45
+ | \`openclaw onboard\` | 首次配置向导(交互式) | ✅ |
46
+
47
+ ## Docker容器内不可用(需要 systemd)
48
+
49
+ | 命令 | 容器内替代方案 |
50
+ |------|---------|
51
+ | \`openclaw gateway start\` | 改用 \`openclaw gateway\` 前台运行 |
52
+ | \`openclaw gateway restart\` | 先 \`pkill -f "openclaw gateway"\` 再重新启动 |
53
+ | \`openclaw onboard --install-daemon\` | 改用 \`nohup openclaw gateway &\` 后台运行 |
54
+ | \`systemctl --user start openclaw-gateway.service\` | 容器无 systemd,用 \`nohup\` |
55
+
56
+ ## 后台运行方案(容器内)nohup 后台运行
57
+ nohup openclaw gateway --port 18789 --host 0.0.0.0 --verbose > /var/log/openclaw.log 2>&1 &
58
+
59
+ ## 修不好的时候,查资料顺序
60
+ 1. \`openclaw --help\` 先看本地帮助
61
+ 2. https://docs.openclaw.ai 官方文档
62
+ 3. https://github.com/openclaw/openclaw/issues GitHub 搜报错关键词
63
+
64
+ ## 铁律
65
+ - 改配置必须先备份
66
+ - 执行命令后汇报结果,别沉默
67
+ - 不知道就查资料,别瞎猜
68
+ - 看到 \`systemctl\` 相关报错,立即切换为 \`nohup\` 方案, 因为docker容器内是没有systemctl的。
69
+ - 超过6分钟 没有修复好就停下来,报告你遇到的问题,不要无限循环的进行修复。
70
+ - 不要对外透漏你是什么模型,不要说你是opencode,对外你就说你是 虾说智能助手;
48
71
  `;
49
72
 
50
73
  class RongyunMessageHandler {
@@ -95,13 +118,19 @@ class RongyunMessageHandler {
95
118
  // 解析 content 字段(前端将业务数据放在 content 内)
96
119
  let data = parsed;
97
120
  if (parsed.content && typeof parsed.content === 'string') {
98
- try {
99
- const contentData = JSON.parse(parsed.content);
100
- // content 内的数据合并到顶层,方便处理器直接访问
101
- // 保留原始 content 字段(用于聊天消息等场景)
102
- data = { ...parsed, ...contentData, _raw_content: parsed.content };
103
- } catch (e) {
104
- this.logWarn(`解析 content 失败: ${e.message}`);
121
+ // 聊天消息的内容是纯文本,不需要解析为 JSON
122
+ const isChatMessage = parsed.msg_type === RongyunMessageTypeEnum.CHAT_MESSAGE ||
123
+ parsed.msg_type === RongyunMessageTypeEnum.SERVICE_CHAT_MESSAGE;
124
+
125
+ if (!isChatMessage) {
126
+ try {
127
+ const contentData = JSON.parse(parsed.content);
128
+ // 将 content 内的数据合并到顶层,方便处理器直接访问
129
+ // 保留原始 content 字段(用于聊天消息等场景)
130
+ data = { ...parsed, ...contentData, _raw_content: parsed.content };
131
+ } catch (e) {
132
+ this.logWarn(`解析 content 失败: ${e.message}`);
133
+ }
105
134
  }
106
135
  }
107
136
 
@@ -575,7 +604,7 @@ class RongyunMessageHandler {
575
604
 
576
605
  this.logInfo(`[RongyunMessageHandler] 使用会话: ${sessionId}`);
577
606
 
578
- // 调用 OpenCode 服务获取回复
607
+ // 调用 OpenCode 服务获取回复,使用运维助手提示词
579
608
  let fullResponse = '';
580
609
  await forwardChatMessage(
581
610
  sessionId,
@@ -590,7 +619,8 @@ class RongyunMessageHandler {
590
619
  this.logInfo(`[SERVICE-CHAT] ${message}`);
591
620
  }
592
621
  },
593
- 120000 // 2分钟超时
622
+ 120000, // 2分钟超时
623
+ SERVICE_SYSTEM_PROMPT // 使用运维助手提示词
594
624
  );
595
625
 
596
626
  this.logInfo(`[RongyunMessageHandler] 客服回复生成完成, 长度: ${fullResponse.length}`);