Skip to content

feat(apple): share IosLifiCore and IosQuickAddBridge with macOS - #6

Open
Tequilaar wants to merge 1 commit into
DeadlinerStudio:byosfrom
Tequilaar:mac/apple-lifi
Open

Tequilaar wants to merge 1 commit into
DeadlinerStudio:byosfrom
Tequilaar:mac/apple-lifi

Conversation

@Tequilaar

Copy link
Copy Markdown

背景

Mac 客户端要接入 Lifi AI(对话助手、快速添加的 AI 识别、记忆),与 iOS 使用同一个智能体。目前 IosLifiCore 和 IosQuickAddBridge 放在 iosMain,macOS 用不到。开发者已同意把 Lifi AI 合入 macOS。

改动

  • IosLifiCore、IosQuickAddBridge 从 iosMain 移到 appleMain,类名、包名和方法都不变,iOS 的 Swift 调用不受影响。
  • IosLifiCore.create(databasePath) 原来直接用 IosDatabaseDriverFactory。改为内部的 expect fun appleLifiDatabaseDriverFactory(path):iOS 仍返回 IosDatabaseDriverFactory,macOS 返回 MacosDatabaseDriverFactory。
  • 新增重载 IosLifiCore.createWithDatabase(config: AIConfig, database, ownsDatabase),原来的 createWithDatabase(apiKey, baseUrl, model, timezone, …) 改为调用它,行为不变。
    • 原因:原入口内部构造 AIConfig,温度使用默认的 0.1。OpenAI 的推理模型(o 系列、gpt-5 及之后)只接受默认温度 1,其他取值返回 HTTP 400。宿主需要能传入温度、回复语言等选项(Mac 的月度洞察已因此出过问题)。
    • Mac 端传入 platform = "ios",因为 Lifi 的工具只为 ios / android / harmony 声明,Mac 与 iOS 使用同一套 Apple 工具。

验证

  • ./gradlew -PlifiMode=stub :shared:macosArm64Test:280 个测试全部通过。
  • ./gradlew -PlifiMode=private :shared:macosArm64Test:334 个测试全部通过。
  • compileKotlinIosArm64、compileKotlinIosSimulatorArm64 在 stub / private 模式下都编译通过。
  • compileKotlinOhosArm64 在本机失败(缺少鸿蒙 SDK 的 OH_AI_* 原生库),不应用这次改动时同样失败,与本 PR 无关。
  • Mac 客户端已基于这个分支接入:对话助手、快速添加、记忆管理,Mac 端单元测试 117 个全部通过。

影响

  • 只移动文件并新增一个重载,不修改已有的公开接口。
  • macOS 的 Apple 头文件新增 IosLifiCore、IosLifiEventListener、IosQuickAddBridge。

Move the Lifi lifecycle facade and the quick-add AI bridge from iosMain to appleMain
so the macOS client can use the same AI runtime. The Swift API is unchanged for iOS.
IosLifiCore.create picks the platform SQLite driver through an internal expect/actual.
Add a createWithDatabase(config:) overload so hosts can pass provider options such as
the temperature that reasoning models require.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant