Handlers/Health.swift

PhoneClaw · Tools/Handlers/Health.swift · swift · Apache-2.0
pos

Provides HealthKit data reading tools for iOS apps.

// Source: https://github.com/kellyvv/PhoneClaw | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
import Foundation
#if canImport(HealthKit)
import HealthKit

// MARK: - Health Tools
//
// 读取 HealthKit 里用户的健康数据。只读,不写。
//
// HealthKit 是 iOS-only framework. macOS 系统物理上没有 HealthKit, 这整个文件主体
// 用 #if canImport(HealthKit) 守护. macOS CLI 走文件末尾的 #else 分支 — 但
// PhoneClawCLI/Sources/PhoneClawCLI/MockToolHandlers.swift 里有 fixture-based
// HealthTools, ToolRegistry 注册到那个版本. CLI scenario 仍能跑, 用 fixture 数据.
// (这不是 design 选择, 是 Mac 没真实健康数据的物理事实.)
//
// 权限策略: 每次调用时检查授权, 首次会弹系统对话框。用户拒绝后直接返回
// failurePayload, 由 skill body 里的指令让模型给用户一个友好解释。

enum HealthTools {

    /// HealthKit store 单例 — Apple 官方

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key