Feat(client): complete the macOS feature set (phase 0 and 1)
Phase 0 makes implementations that already existed reachable. macOS now declares TERMINAL, SCREEN_CLIPBOARD, PROCESS and C2C_RECV_ACK; PROCESS is a new bit and Linux declares it too. SystemManager was dead code -- its constructor took a second argument and it did not derive IOCPManager, so the sub-connection skeleton could never instantiate it -- and now matches the createHandler/OnReceive contract, so COMMAND_SYSTEM really spawns a sub-connection (proc_listpids, SIGKILL). DataProcess always gets a NULL user, so main.mm keeps a g_pMainClient handle and the V2 C2C receiver finally answers TOKEN_C2C_RECV_RESULT. The server asks for SupportsTerminal() on MAC for exec_command / terminal_* and for SupportsProcess() for kill_process, so an old build gets "client is too old" instead of a command nobody answers; kToolPlatforms and mcp/tools.json follow. http_probe stays win/lnx: the terminal works on macOS, but the probe uses GNU-only base64 -w. Phase 1 is POSIX parity. ScreenPreview captures through CGDisplayCreateImage, scales and ships BGRX for the server to encode, and the capability is only declared when preflight or a real capture says the display is readable. ActivityHistory samples the frontmost layer-0 window once a second and prints the same records as Windows and Linux. COMMAND_SCREEN_KEYFRAME_REQ is now consumed by Linux (x264 IDR) and macOS (VideoToolbox force keyframe): the receive thread raises a flag, the capture thread -- which owns the encoder -- consumes it and puts it back if the frame never went out. The macOS quality level persists in NSUserDefaults because main.mm rewrites config.conf. Linux client and Debug x64 server rebuild green; check_platform_table PASS. Not built or run on a Mac. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
c2b59f5d4a
commit
06b93f7bdb
19 files changed
+890
-121
No files matched your search
@@ -1293,3 +1293,62 @@ region 同样要求新 Windows 客户端(桌面尾块是 `CLIENT_CAP_WINDOW_IN
|
||||
客户端),返回 `-32005`;默认整屏目标行为与字节流完全不变。
|
||||
- window/region 目标各自多一次窗口信息 RPC;region 目标还要多等一次
|
||||
`TOKEN_BITMAPINFO` 到达(通常几十毫秒)。
|
||||
|
||||
## 24. 增补(2026-11-14:macOS 客户端能力补齐,阶段 0 + 1)
|
||||
|
||||
macOS 客户端此前有大量「实现了但服务端不认」的功能,断点有三层,缺任何一层都表现为
|
||||
「工具直接 `-32005`」或「发下去以后等超时」:
|
||||
|
||||
1. 客户端**没接线**(`COMMAND_SYSTEM` 只打一行日志,`SystemManager` 的签名也不满足
|
||||
子连接骨架,从未被实例化);
|
||||
2. 接上了但**没声明能力位**(终端、剪贴板、C2C 回执早就在跑,`moduleVersion` 里却一个位都没有);
|
||||
3. 声明了能力位,但服务端**仍按平台表一律拒绝** `MAC`。
|
||||
|
||||
本批把三层一起补齐。
|
||||
|
||||
### 24.1 阶段 0:让已有实现可达
|
||||
|
||||
- **能力位**(`common/commands.h`):新增 `CLIENT_CAP_PROCESS=0x20000`;macOS 的
|
||||
`DefaultCaps()` 声明 `TERMINAL` / `SCREEN_CLIPBOARD` / `PROCESS` / `C2C_RECV_ACK`,
|
||||
Linux 也补声明 `PROCESS`(`SystemManager` 一直在跑,只是没声明)。
|
||||
Windows 一直支持进程管理与终端但从不声明,调用方按平台区分,行为不变。
|
||||
- **`SystemManager`**(`macos/SystemManager.*`):改成派生 `IOCPManager`、构造只收
|
||||
`IOCPClient*`,满足 `common/sub_conn_thread.h` 的 `createHandler` / `OnReceive` 契约;
|
||||
`main.mm` 的 `COMMAND_SYSTEM` 现在真的起子连接(`proc_listpids` 枚举 + `SIGKILL`)。
|
||||
- **C2C 落盘回执**:`DataProcess` 的 `user` 恒为 NULL,因此在 `main.mm` 增加
|
||||
`g_pMainClient`(同 `linux/main.cpp`),作为 V2 接收端回 `TOKEN_C2C_RECV_RESULT`。
|
||||
`download_file` / `upload_file` / `copy_files_c2c` 的 macOS 目标端 `receiver_ack`
|
||||
由恒 `false` 变为真实回执。
|
||||
- **服务端放行**(`McpServer.cpp`):`exec_command` / `terminal_*` 对 `MAC` 要求
|
||||
`SupportsTerminal()`,`kill_process` 要求 `SupportsProcess()`,老 macOS 构建返回
|
||||
`-32005` 并提示升级,而不是发一条没人接的命令后假报 ok;`kToolPlatforms` 同步。
|
||||
- `http_probe` **仍只放行 Windows/Linux**:macOS 终端已可用,但 POSIX 探测命令用了
|
||||
GNU 专有的 `base64 -w`,BSD base64 没有该开关,等换成两平台通用写法再放开。
|
||||
|
||||
### 24.2 阶段 1:POSIX 对齐
|
||||
|
||||
- **屏幕预览**(`macos/ScreenPreview.*`):`CGDisplayCreateImage` → 等比缩放 →
|
||||
`SCREEN_PREVIEW_FMT_BGRX`,与服务端统一编码 JPEG 的 Linux 路径一致(macOS 不做
|
||||
JPEG 编码)。`CLIENT_CAP_SCREEN_PREVIEW` 只在**登录时已授予录屏权限**时声明
|
||||
(`RefreshLoginCaps`,每次重连重判),否则 `get_screenshot` 会一直等超时。
|
||||
- **历史活动**(`macos/ActivityHistory.*`):每秒采一次前台窗口
|
||||
(`CGWindowListCopyWindowInfo`,第一个 `layer 0` 窗口;窗口标题需录屏授权,没有权限
|
||||
时退化为应用名),输出格式与 Windows/Linux 完全一致;`COMMAND_QUERY_ACTIVITY`
|
||||
在主连接一次性快照回 `TOKEN_REPORT_ACTIVITY`,单飞行。
|
||||
- **强制关键帧**:Web 屏幕墙恢复时服务端发 `COMMAND_SCREEN_KEYFRAME_REQ`。
|
||||
Windows 一直支持;本次让 Linux(x264 `X264_TYPE_IDR`)与 macOS(VideoToolbox
|
||||
`kVTEncodeFrameOptionKey_ForceKeyFrame`)也消费它——接收线程只置标志,采集线程在
|
||||
下一帧 `exchange`,编码器实例仍归采集线程独占。抓帧失败时把请求放回去,下一帧再试。
|
||||
Android 仍未实现,属后续项。
|
||||
- **质量等级持久化**(`macos/ScreenHandler.mm`):`CMD_QUALITY_LEVEL` 的 persist 位
|
||||
以前是 `(void)persist` 的 TODO,现在写入 `NSUserDefaults`(键 `GhostQualityLevel`),
|
||||
启动时读回并套用。**不写** `~/.config/ghost/config.conf`:那份配置由 `main.mm`
|
||||
用内存 map 整体重写,单独追加键会被下一次写盘冲掉。
|
||||
- `kToolPlatforms`:`get_screenshot` / `get_activity_history` 增加 `kPlatMac`。
|
||||
|
||||
### 24.3 兼容与代价
|
||||
|
||||
- 老 macOS 构建:终端/进程类工具返回「client is too old ... upgrade」,不再假报成功。
|
||||
- `remote_open` 仍拒绝 `MAC`(屏幕/注入链路的 macOS 实机验证还没做),本批不动。
|
||||
- `mcp/tools.json` 是生成物(`tools/mcp_tools/`),平台表变更后要用跑起来的服务端
|
||||
重新生成。
|
||||
Reference in new issue
Block a user