claw-subagent-service 0.0.141 → 0.0.143

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.
@@ -271,15 +271,36 @@ restart_docker() {
271
271
 
272
272
  log_info "正在启动 OpenClaw 服务..."
273
273
 
274
+ # 查找 openclaw 的完整路径
275
+ local openclaw_path=""
276
+ if command -v openclaw &>/dev/null; then
277
+ openclaw_path=$(which openclaw)
278
+ log_info "找到 openclaw: $openclaw_path"
279
+ else
280
+ # 尝试常见路径
281
+ for path in /usr/local/bin/openclaw /usr/bin/openclaw /opt/openclaw/bin/openclaw; do
282
+ if [ -x "$path" ]; then
283
+ openclaw_path="$path"
284
+ log_info "找到 openclaw: $openclaw_path"
285
+ break
286
+ fi
287
+ done
288
+ fi
289
+
290
+ if [ -z "$openclaw_path" ]; then
291
+ log_error "无法找到 openclaw 命令,请确保已安装 OpenClaw"
292
+ exit 1
293
+ fi
294
+
274
295
  # 使用 setsid 创建新会话,完全脱离父进程
275
296
  # 这样即使父进程(Node.js)退出,openclaw 也不会被终止
276
297
  log_info "使用 setsid 启动,确保进程脱离父进程..."
277
298
  if command -v setsid &>/dev/null; then
278
- setsid bash -c "openclaw gateway run --port $PORT" > "$log_file" 2>&1 &
299
+ setsid bash -c "export PATH='$PATH'; $openclaw_path gateway run --port $PORT" > "$log_file" 2>&1 &
279
300
  else
280
301
  # 如果没有 setsid,使用 nohup 作为后备
281
302
  log_warn "setsid 不可用,使用 nohup 作为后备..."
282
- nohup openclaw gateway run --port "$PORT" > "$log_file" 2>&1 &
303
+ nohup bash -c "export PATH='$PATH'; $openclaw_path gateway run --port $PORT" > "$log_file" 2>&1 &
283
304
  fi
284
305
 
285
306
  log_info "OpenClaw 服务启动命令已发送(PID: $!)"
@@ -297,19 +297,40 @@ start_docker() {
297
297
  fuser -k "${PORT}/tcp" 2>/dev/null || true
298
298
  fi
299
299
 
300
+ # 查找 openclaw 的完整路径
301
+ local openclaw_path=""
302
+ if command -v openclaw &>/dev/null; then
303
+ openclaw_path=$(which openclaw)
304
+ log_info "找到 openclaw: $openclaw_path"
305
+ else
306
+ # 尝试常见路径
307
+ for path in /usr/local/bin/openclaw /usr/bin/openclaw /opt/openclaw/bin/openclaw; do
308
+ if [ -x "$path" ]; then
309
+ openclaw_path="$path"
310
+ log_info "找到 openclaw: $openclaw_path"
311
+ break
312
+ fi
313
+ done
314
+ fi
315
+
316
+ if [ -z "$openclaw_path" ]; then
317
+ log_error "无法找到 openclaw 命令,请确保已安装 OpenClaw"
318
+ exit 1
319
+ fi
320
+
300
321
  # 尝试使用正确的参数启动
301
322
  # 注意:openclaw gateway 可能使用不同的参数名
302
- log_info "尝试启动: openclaw gateway run --port $PORT"
323
+ log_info "尝试启动: $openclaw_path gateway run --port $PORT"
303
324
 
304
325
  # 使用 setsid 创建新会话,完全脱离父进程
305
326
  # 这样即使父进程(Node.js)退出,openclaw 也不会被终止
306
327
  log_info "使用 setsid 启动,确保进程脱离父进程..."
307
328
  if command -v setsid &>/dev/null; then
308
- setsid bash -c "openclaw gateway run --port $PORT" > "$log_file" 2>&1 &
329
+ setsid bash -c "export PATH='$PATH'; $openclaw_path gateway run --port $PORT" > "$log_file" 2>&1 &
309
330
  else
310
331
  # 如果没有 setsid,使用 nohup 作为后备
311
332
  log_warn "setsid 不可用,使用 nohup 作为后备..."
312
- nohup openclaw gateway run --port "$PORT" > "$log_file" 2>&1 &
333
+ nohup bash -c "export PATH='$PATH'; $openclaw_path gateway run --port $PORT" > "$log_file" 2>&1 &
313
334
  fi
314
335
  local started_pid=$!
315
336
  log_info "启动的进程 PID: $started_pid"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claw-subagent-service",
3
- "version": "0.0.141",
3
+ "version": "0.0.143",
4
4
  "description": "虾说智能助手",
5
5
  "main": "cli.js",
6
6
  "bin": {
@@ -224,8 +224,9 @@ class RongyunMessageHandler {
224
224
  // 使用解析后的 content(聊天内容),如果没有则使用原始 content
225
225
  const content = data.content || data._raw_content;
226
226
  const requestId = data.request_id;
227
+ const sourceId = data.source_im_id;
227
228
 
228
- this.logInfo(`[RongyunMessageHandler] 收到聊天消息, roomId=${roomId}, sessionId=${sessionId}`);
229
+ this.logInfo(`[RongyunMessageHandler] 收到聊天消息, roomId=${roomId}, sessionId=${sessionId}, from=${sourceId}`);
229
230
 
230
231
  if (!roomId || !sessionId || !content) {
231
232
  await this.sendResponse(RongyunMessageTypeEnum.CHAT_MESSAGE, {
@@ -233,7 +234,7 @@ class RongyunMessageHandler {
233
234
  message: '缺少必要参数',
234
235
  content: '[错误] 缺少必要参数',
235
236
  metadata: {}
236
- }, requestId);
237
+ }, requestId, sourceId);
237
238
  return;
238
239
  }
239
240
 
@@ -258,7 +259,7 @@ class RongyunMessageHandler {
258
259
  message: 'Response received',
259
260
  content: fullResponse,
260
261
  metadata: {}
261
- }, requestId);
262
+ }, requestId, sourceId);
262
263
  } catch (e) {
263
264
  const msg = e instanceof Error ? e.message : String(e);
264
265
  this.logError(`聊天消息处理异常: ${msg}`);
@@ -267,15 +268,16 @@ class RongyunMessageHandler {
267
268
  message: msg,
268
269
  content: `[错误] 转发失败: ${msg}`,
269
270
  metadata: {}
270
- }, requestId);
271
+ }, requestId, sourceId);
271
272
  }
272
273
  }
273
274
 
274
275
  async handleCreateSession(data) {
275
276
  const requestId = data.request_id;
276
277
  const title = data.title || '新会话';
278
+ const sourceId = data.source_im_id;
277
279
 
278
- this.logInfo(`[RongyunMessageHandler] 创建会话, title=${title}`);
280
+ this.logInfo(`[RongyunMessageHandler] 创建会话, title=${title}, from=${sourceId}`);
279
281
 
280
282
  try {
281
283
  const session = await createOpencodeSession(title);
@@ -283,14 +285,14 @@ class RongyunMessageHandler {
283
285
  await this.sendResponse(RongyunMessageTypeEnum.OPENCODE_SESSION_CREATED, {
284
286
  status: 'success',
285
287
  opencode_session_id: session.id
286
- }, requestId);
288
+ }, requestId, sourceId);
287
289
  } catch (e) {
288
290
  const msg = e instanceof Error ? e.message : String(e);
289
291
  this.logError(`创建会话失败: ${msg}`);
290
292
  await this.sendResponse(RongyunMessageTypeEnum.OPENCODE_SESSION_CREATED, {
291
293
  status: 'error',
292
294
  message: msg
293
- }, requestId);
295
+ }, requestId, sourceId);
294
296
  }
295
297
  }
296
298