asemxin commited on
Commit
42ce1fe
·
1 Parent(s): f1218bb

revert: remove sed patch, improve daemon page_size

Browse files
Files changed (2) hide show
  1. entrypoint.sh +2 -41
  2. image_daemon.py +14 -2
entrypoint.sh CHANGED
@@ -253,47 +253,8 @@ for fpath in glob.glob(os.path.join(agent_dir, "*")):
253
 
254
  PYEOF
255
 
256
- # ============================================
257
- # 启动图片服务器(后台,端口 8765)
258
- # 修复 feishu-openclaw 插件把 token 放在 URL query 参数的 bug
259
- # ============================================
260
- echo "🔧 启动飞书图片代理服务器..."
261
- python3 /app/image_proxy.py --server &
262
- IMAGE_PROXY_PID=$!
263
- echo " Image Proxy PID: $IMAGE_PROXY_PID"
264
- sleep 1
265
-
266
- # ============================================
267
- # Patch feishu-openclaw 插件:图片请求改走本地代理
268
- # ============================================
269
- PLUGIN_DIR="$HOME/.openclaw/extensions/feishu-openclaw"
270
- if [ -d "$PLUGIN_DIR" ]; then
271
- echo "🔧 Patch 飞书插件图片 URL..."
272
-
273
- # 搜索整个插件目录(含 node_modules)中包含 open.feishu.cn 的文件
274
- FEISHU_FILES=$(grep -rl 'open.feishu.cn' "$PLUGIN_DIR" 2>/dev/null || true)
275
- FEISHU_COUNT=$(echo "$FEISHU_FILES" | grep -c '.' 2>/dev/null || echo 0)
276
- echo " 找到含 feishu URL 的文件: $FEISHU_COUNT 个"
277
-
278
- if [ -n "$FEISHU_FILES" ]; then
279
- for f in $FEISHU_FILES; do
280
- BEFORE=$(grep -c 'open.feishu.cn' "$f" 2>/dev/null || echo 0)
281
- sed -i 's|https://open.feishu.cn/open-apis|http://127.0.0.1:8765/open-apis|g' "$f"
282
- sed -i 's|https://open.feishu.cn|http://127.0.0.1:8765|g' "$f"
283
- AFTER=$(grep -c 'open.feishu.cn' "$f" 2>/dev/null || echo 0)
284
- BASENAME=$(basename "$f")
285
- echo " ✅ $BASENAME: $BEFORE → $AFTER 处 feishu URL"
286
- done
287
- else
288
- echo " ⚠️ 未找到含 feishu URL 的文件"
289
- echo " 查看插件目录结构:"
290
- find "$PLUGIN_DIR" -name "*.js" -o -name "*.json" | head -20
291
- echo " 查找可能的 API URL 模式:"
292
- grep -rh 'feishu\|lark' "$PLUGIN_DIR" --include="*.js" -o | sort | uniq -c | sort -rn | head -10 || echo " (无)"
293
- fi
294
- else
295
- echo " ⚠️ 插件目录不存在: $PLUGIN_DIR"
296
- fi
297
 
298
  # ============================================
299
  # 启动 OpenClaw Gateway(后台)
 
253
 
254
  PYEOF
255
 
256
+ # 注意: 不再使用 image_proxy 和 sed patch(会破坏 WebSocket 连接)
257
+ # 图片完全由 image_daemon.py 负责
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
 
259
  # ============================================
260
  # 启动 OpenClaw Gateway(后台)
image_daemon.py CHANGED
@@ -235,7 +235,19 @@ def main():
235
 
236
  new_imgs = 0
237
  for chat_id in chats:
238
- messages = get_recent_messages(token, chat_id, limit=5)
 
 
 
 
 
 
 
 
 
 
 
 
239
  for msg in messages:
240
  msg_id = msg.get("message_id", "")
241
  if msg_id in processed:
@@ -249,7 +261,7 @@ def main():
249
  # 打印每条新消息的类型(调试用)
250
  log(f"📨 新消息: type={msg_type}, sender={sender_type}, preview={body_preview}")
251
 
252
- # 尝试处理所有非文本消息
253
  if msg_type != "text" and sender_type != "app":
254
  process_message(token, chat_id, msg)
255
  new_imgs += 1
 
235
 
236
  new_imgs = 0
237
  for chat_id in chats:
238
+ # 首轮用大 limit 获取更多历史消息
239
+ limit = 20 if cycle == 1 else 10
240
+ messages = get_recent_messages(token, chat_id, limit=limit)
241
+
242
+ # 首轮打印所有消息类型统计
243
+ if cycle == 1:
244
+ type_counts = {}
245
+ for m in messages:
246
+ t = m.get("msg_type", "unknown")
247
+ type_counts[t] = type_counts.get(t, 0) + 1
248
+ log(f"📊 聊天 {chat_id[:12]}... 共 {len(messages)} 条消息")
249
+ log(f" 消息类型分布: {type_counts}")
250
+
251
  for msg in messages:
252
  msg_id = msg.get("message_id", "")
253
  if msg_id in processed:
 
261
  # 打印每条新消息的类型(调试用)
262
  log(f"📨 新消息: type={msg_type}, sender={sender_type}, preview={body_preview}")
263
 
264
+ # 尝试处理所有非文本消息(图片、富文本等)
265
  if msg_type != "text" and sender_type != "app":
266
  process_message(token, chat_id, msg)
267
  new_imgs += 1