DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
fix(macos): 补齐语音输入的麦克风权限声明(Info.plist + entitlements)
hairyf00d2be5f6b1d
diff --git a/docs/AGENTS.desktop.md b/docs/AGENTS.desktop.mdindex 83fe23e6..6380a3ef 100644--- a/docs/AGENTS.desktop.md+++ b/docs/AGENTS.desktop.md@@ -349,6 +349,8 @@ export function FooComponent(props: FooProps) {- pnpm 工作区多文档(issue #526):`$DSH_HOME/profiles/<档案>/pnpm-workspace.yaml` 被手工/工具拼接成多个 YAML 文档(`---` 分隔)时,pnpm(js-yaml `load`)与 serde_yaml **都只接受单文档流**(`expected a single document in the stream, but found more` / `deserializing from YAML containing more than one document is not supported`)。`service/profile/mod.rs::ensure_profile_pnpm_policy`(issue #222 的 zod release-age 例外)在插件安装前置步骤里解析该文件,于是整个启动卡在「Plugin installation」阶段,且原报错不含任何文件路径。修法:新增 `service/profile/mod.rs::parse_workspace_document(content)`,单文档正常返回;解析失败时逐文档尝试(`serde_yaml::Deserializer::from_str` 的 Iterator),**全部是映射**才按「后者覆盖前者」合并成一个映射并返回 `normalized = true`,否则保留原始解析错误(issue #49 的重复映射键不会被误当成多文档)。`ensure_profile_pnpm_policy` 与 `service/plugin/install/allowlist.rs::apply_allow_build_keys` 共用它,`normalized` 本身即视为需要落盘的改动,把文件自愈成 pnpm 也能读的单文档(日志 `PROFILE_WORKSPACE_MULTI_DOCUMENT`)。解析错误统一带路径便于定位:`PROFILE_WORKSPACE_INVALID_YAML: <路径>: <解析错误>`。+- macOS 麦克风/摄像头权限(issue #214):内嵌 WKWebView 里的 `getUserMedia` 要同时满足两处,缺任何一处都拿不到流——`src-tauri/Info.plist` 的 `NSMicrophoneUsageDescription` / `NSCameraUsageDescription`(**缺用途说明时 TCC 直接终止进程**,连授权框都不弹,日志里只有 `attempted to access privacy-sensitive data without a usage description`)与 `src-tauri/Entitlements.plist` 的 `com.apple.security.device.audio-input` / `com.apple.security.device.camera`(`bundle.macOS.hardenedRuntime` 默认 true,Hardened Runtime 会把资源访问全部关上,没有对应 entitlement 即使有用途说明也无效)。两处都在 `bundle.macOS` 里显式声明(`infoPlist` / `entitlements`),**相对路径按 bundle 时的 CWD 解析**——`crates/tauri-cli/src/bundle.rs` 会先 `set_current_dir(dirs.tauri)`,所以写 `Info.plist` 而不是 `src-tauri/Info.plist`;CLI 另外还会自动合并 `tauri.conf.json` 同目录下的 `Info.plist`。WKWebView 的 `requestMediaCapturePermissionForOrigin` 不用自己接:wry 0.55.1 的 `WryWebViewUIDelegate` 无条件回 `WKPermissionDecision::Grant`(`src/wkwebview/class/wry_web_view_ui_delegate.rs`)。回归测试见 `src-tauri/src/desktop/builder.rs` 的 `macos_bundle_tests`(macOS 上额外用 `plutil -lint` 校验 plist 语法;`tauri dev` 不产 `.app`,走终端的 TCC 授权,不在覆盖范围内)。+## Summary- **API Import**: 直接 `import { invoke } from '@tauri-apps/api/core'`(本仓库没有 `@/apis` 层);类型就近定义在 hooks/组件文件中diff --git a/src-tauri/Entitlements.plist b/src-tauri/Entitlements.plistnew file mode 100644index 00000000..29b082f9--- /dev/null+++ b/src-tauri/Entitlements.plist@@ -0,0 +1,21 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<!--+ macOS 代码签名 entitlements(issue #214)。++ bundle.macOS.hardenedRuntime 为 true 时,Hardened Runtime 的资源访问+ 默认全部关闭:没有 com.apple.security.device.audio-input,+ 已签名的 .app 即使 Info.plist 写了用途说明也拿不到麦克风。++ 只声明这两项资源访问:不使用 App Sandbox,因此不需要+ com.apple.security.app-sandbox;JIT/可变内存类 entitlement 也不需要+ (WebKit 自身的 WebContent 进程是系统进程,由系统签名携带)。+-->+<plist version="1.0">+<dict>+ <key>com.apple.security.device.audio-input</key>+ <true/>+ <key>com.apple.security.device.camera</key>+ <true/>+</dict>+</plist>diff --git a/src-tauri/Info.plist b/src-tauri/Info.plistnew file mode 100644index 00000000..bb377a3a--- /dev/null+++ b/src-tauri/Info.plist@@ -0,0 +1,24 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<!--+ 合并进 macOS .app 的 Info.plist(issue #214)。++ WKWebView 里 dsh 页面(dsh-ears / dsh-voice-scribe)调用 getUserMedia 时,+ macOS 的 TCC 只读取宿主 .app 的用途说明:缺少 NSMicrophoneUsageDescription+ 时不会弹授权框,而是直接终止进程("attempted to access privacy-sensitive+ data without a usage description")。浏览器里正常、桌面端必现就是这个原因。++ 相机是同类问题:壳层的 iframe allow 与 WebView2 授权都放行 camera,+ macOS 侧若缺 NSCameraUsageDescription 同样会在采集时被杀进程。++ Tauri 会自动合并 tauri.conf.json 同目录下的 Info.plist,+ 这里仍在 bundle.macOS.infoPlist 里显式声明,便于定位与回归。+-->+<plist version="1.0">+<dict>+ <key>NSMicrophoneUsageDescription</key>+ <string>Voice input in DeepSeek Harness requires access to the microphone.</string>+ <key>NSCameraUsageDescription</key>+ <string>Video capture in DeepSeek Harness requires access to the camera.</string>+</dict>+</plist>diff --git a/src-tauri/src/desktop/builder.rs b/src-tauri/src/desktop/builder.rsindex 9173bebd..3cb89a05 100644--- a/src-tauri/src/desktop/builder.rs+++ b/src-tauri/src/desktop/builder.rs@@ -785,6 +785,60 @@ mod security_tests {}}+#[cfg(test)]+mod macos_bundle_tests {+ use serde_json::Value;++ /// issue #214:macOS 的麦克风授权完全落在打包配置上——iframe `allow`+ /// 与 WebView2 侧权限已由 PR #216 修复,macOS 还缺「用途说明 + 签名授权」,+ /// 两者缺任何一个,内嵌 WKWebView 里的 `getUserMedia` 都拿不到流+ /// (缺用途说明时 TCC 直接终止进程,连授权框都不弹)。+ #[test]+ fn macos_media_capture_permissions_are_declared() {+ let config: Value = serde_json::from_str(include_str!("../../tauri.conf.json")).unwrap();+ let macos = &config["bundle"]["macOS"];+ assert_eq!(+ macos["hardenedRuntime"].as_bool(),+ Some(true),+ "entitlements 只在开启 Hardened Runtime 的签名上生效"+ );+ // 相对路径按 bundle 时的 CWD(src-tauri)解析。+ assert_eq!(macos["infoPlist"].as_str(), Some("Info.plist"));+ assert_eq!(macos["entitlements"].as_str(), Some("Entitlements.plist"));++ // 用带 <key> 的完整标签匹配,避免注释里出现的键名让断言蒙混过关。+ let info_plist = include_str!("../../Info.plist");+ assert!(info_plist.contains("<key>NSMicrophoneUsageDescription</key>"));+ assert!(info_plist.contains("<key>NSCameraUsageDescription</key>"));++ let entitlements = include_str!("../../Entitlements.plist");+ assert!(entitlements.contains("<key>com.apple.security.device.audio-input</key>"));+ assert!(entitlements.contains("<key>com.apple.security.device.camera</key>"));+ }++ /// plist 语法只有 macOS 的 `plutil` 能权威校验(Rust 侧没有 plist 依赖),+ /// 放在现有 macOS CI 上跑,免得打包/公证阶段才发现坏文件。+ #[cfg(target_os = "macos")]+ #[test]+ fn macos_bundle_plists_are_valid() {+ for file in ["Info.plist", "Entitlements.plist"] {+ let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join(file);+ let output = std::process::Command::new("plutil")+ .arg("-lint")+ .arg(&path)+ .output()+ .expect("plutil must be available on macOS");+ assert!(+ output.status.success(),+ "plutil -lint {} failed: {}{}",+ path.display(),+ String::from_utf8_lossy(&output.stdout),+ String::from_utf8_lossy(&output.stderr)+ );+ }+ }+}+// configure invoke handlerpub fn handler() -> impl Fn(Invoke<Wry>) -> bool + Send + Sync + 'static {tauri::generate_handler![diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.jsonindex a2331adf..8942254f 100644--- a/src-tauri/tauri.conf.json+++ b/src-tauri/tauri.conf.json@@ -33,7 +33,9 @@"copyright": "Copyright © 2026 Deepseek Harness Desktop contributors","macOS": {"minimumSystemVersion": "10.15",- "hardenedRuntime": true+ "hardenedRuntime": true,+ "infoPlist": "Info.plist",+ "entitlements": "Entitlements.plist"},"windows": {"nsis": {