Repository navigation
Conversation
send_file_to_wechat / send_image_to_wechat 在非桥接的 pi 进程里调用时 (例如另一个 iTerm 窗口的会话,桥接跑在 tmux 的另一个 pi 进程), guardSendToWechat 只能看到本进程的 running=false,于是报 「微信桥接未启动,请先在 TUI 执行 /wechat start」—— 但桥接其实活得好好的, 这会把人引向完全错误的排查方向。 改为:命中 !client || !running 时先读 ~/.pi/agent/wechat-assistant/session.lock, 若持锁进程仍存活且不是本进程,直接告知真正的持有者 PID / sessionId, 以及把发送指令投递给它的办法;确认本机没有其它活桥接时,维持原有文案。 仅诊断信息变化,无新增能力与权限(process.kill(pid, 0) 只做存活探测)。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
现象
在非桥接的 pi 进程里调用
send_image_to_wechat/send_file_to_wechat(常见场景:桥接跑在 tmux 的一个 pi 会话里,人又开了另一个 iTerm 窗口用 pi),会返回:但桥接其实完全正常 ——
session.lock有活着的持锁进程、cursor.json持续更新。于是排查方向被彻底带偏(会一直去查「桥接为什么没起来」)。根因
guardSendToWechat判断的client/running都是进程内局部状态,非桥接进程无从得知另一个进程里的桥接状况,只能落进!running分支,并被当成「未启动」。另外!client分支文案(「微信未登录」)在跨进程场景下同样会误导。改动
命中
!client || !running时先读~/.pi/agent/wechat-assistant/session.lock:持锁进程仍存活且不是本进程 → 直接告知真正的持有者与投递办法:
确认本机没有其它活着的桥接 → 保持原有两条文案不变。
安全性
只有诊断信息变化,不新增任何能力或权限。唯一新增的系统调用是
process.kill(pid, 0),只做进程存活探测、不发送任何信号;读的是本扩展自己的 state 目录下的锁文件。路径沙箱、lastWechatUser校验等守卫逻辑一字未动。验证
node --experimental-strip-types --check src/index.ts通过