Просмотр исходного кода

发布 v0.4.69:修复模型凭据作用域并启用正式签名公证

Samien 1 месяц назад
Родитель
Сommit
6d5c62c267

+ 6 - 6
README.md

@@ -1,6 +1,6 @@
 # 夭夭 AI
 
-当前 Web 与 macOS 桌面发布版本:**v0.4.68**。桌面版提供 Apple Silicon(arm64)DMG,详见 [发布说明](docs/releases/v0.4.68.md)。
+当前 Web 与 macOS 桌面发布版本:**v0.4.69**。桌面版提供 Apple Silicon(arm64)DMG,详见 [发布说明](docs/releases/v0.4.69.md)。
 
 夭夭 AI 为网页、iOS 和安卓提供统一的 Agent、群聊、文件库及语音配置服务。Hermes 通过标准 9119 HTTP/WebSocket 接口执行任务。
 
@@ -40,7 +40,7 @@ Web 数据默认保存在 `~/.yaoyao`,可用 `YAOYAO_HOME` 指定(兼容 `HE
 
 ## macOS 桌面版
 
-在 [v0.4.68 发布页](https://github.com/Lsamien/yaoyao/releases/tag/v0.4.68) 下载 `Yaoyao-0.4.68-arm64.dmg`,将“夭夭”拖到应用程序后打开。首次启动会核对并同步配套本机 Web 服务;普通退出保留后台运行,“停止后台服务并退出”可完整停止本应用管理的后台。详细说明见 [macOS App](docs/macos-app.md)。
+在 [v0.4.69 发布页](https://github.com/Lsamien/yaoyao/releases/tag/v0.4.69) 下载 `Yaoyao-0.4.69-arm64.dmg`,将“夭夭”拖到应用程序后打开。首次启动会核对并同步配套本机 Web 服务;普通退出保留后台运行,“停止后台服务并退出”可完整停止本应用管理的后台。详细说明见 [macOS App](docs/macos-app.md)。
 
 桌面安装包的签名、公证状态及自动升级可用范围见对应版本的 GitHub 发布说明。
 
@@ -50,11 +50,11 @@ Web 数据默认保存在 `~/.yaoyao`,可用 `YAOYAO_HOME` 指定(兼容 `HE
 
 | 镜像 | 架构 |
 | --- | --- |
-| `samienluo/yaoyao:v0.4.68-amd` | AMD64 |
-| `samienluo/yaoyao:v0.4.68` | 自动匹配 AMD64 / ARM64 |
-| `samienluo/yaoyao:latest` | 最新稳定版通用镜像,当前与 `v0.4.68` 相同 |
+| `samienluo/yaoyao:v0.4.69-amd` | AMD64 |
+| `samienluo/yaoyao:v0.4.69` | 自动匹配 AMD64 / ARM64 |
+| `samienluo/yaoyao:latest` | 最新稳定版通用镜像,当前与 `v0.4.69` 相同 |
 
-准备好 Docker Engine/Compose 和容器可访问的 Hermes 9119 服务,在仓库目录将 `docker.env.example` 复制为 `docker.env`。配置上游地址,并设置 `HERMES_YAOYAO_IMAGE=samienluo/yaoyao:v0.4.68`(或 `samienluo/yaoyao:latest`),即可使用远程镜像:
+准备好 Docker Engine/Compose 和容器可访问的 Hermes 9119 服务,在仓库目录将 `docker.env.example` 复制为 `docker.env`。配置上游地址,并设置 `HERMES_YAOYAO_IMAGE=samienluo/yaoyao:v0.4.69`(或 `samienluo/yaoyao:latest`),即可使用远程镜像:
 
 ```sh
 docker compose --env-file docker.env pull web

+ 3 - 0
desktop/release-artifacts.test.mjs

@@ -14,6 +14,9 @@ test('formal desktop releases require a distribution identity and notarization c
   const options = releaseSigningOptions({ CSC_NAME: 'Developer ID Application: Test', APPLE_API_KEY: '/fixture/key.p8', APPLE_API_KEY_ID: 'key', APPLE_API_ISSUER: 'issuer' })
   assert.equal(options.forceCodeSigning, true); assert.equal(options.mac.notarize, true)
   assert.equal(options.mac.identity, 'Test'); assert.equal(options.mac.type, 'distribution')
+  assert.deepEqual(releaseSigningOptions({ CSC_NAME: 'Developer ID Application: Test', APPLE_KEYCHAIN_PROFILE: 'yaoyao-notary' }), options)
+  assert.throws(() => releaseSigningOptions({ CSC_NAME: 'Developer ID Application: Test', APPLE_KEYCHAIN: '/fixture/login.keychain-db' }), /公证/)
+  assert.throws(() => releaseSigningOptions({ CSC_NAME: 'Developer ID Application: Test', APPLE_KEYCHAIN_PROFILE: '  ' }), /公证/)
 })
 
 test('release verification rejects incomplete, mixed-version and corrupt updater artifacts', async () => {

+ 1 - 1
docker.env.example

@@ -3,7 +3,7 @@ HERMES_YAOYAO_BIND_ADDRESS=127.0.0.1
 HERMES_YAOYAO_PUBLISHED_PORT=15300
 # 远程通用镜像支持 AMD64 / ARM64;每次发布更新 latest 并保留旧版本标签。
 # HERMES_YAOYAO_IMAGE=samienluo/yaoyao:latest
-# 固定版本:samienluo/yaoyao:v0.4.68;仅 AMD64:samienluo/yaoyao:v0.4.68-amd。
+# 固定版本:samienluo/yaoyao:v0.4.69;仅 AMD64:samienluo/yaoyao:v0.4.69-amd。
 # 留空时使用本地构建名称 yaoyao:local。
 # YAOYAO_DESKTOP_IMAGE=hermes-yaoyao-desktop:0.4.0
 # Cursor Universal 兼容桌面的本地构建名称;基础镜像在 deploy/computer/Dockerfile.cursor 中固定。

+ 7 - 7
docs/docker-install.md

@@ -12,14 +12,14 @@
 
 | 标签 | 架构 |
 | --- | --- |
-| `v0.4.68-amd` | `linux/amd64` |
-| `v0.4.68` | `linux/amd64`、`linux/arm64`,拉取时自动匹配 |
-| `latest` | 最新稳定通用镜像,当前指向与 `v0.4.68` 相同的镜像 |
+| `v0.4.69-amd` | `linux/amd64` |
+| `v0.4.69` | `linux/amd64`、`linux/arm64`,拉取时自动匹配 |
+| `latest` | 最新稳定通用镜像,当前指向与 `v0.4.69` 相同的镜像 |
 
 ```sh
-docker pull samienluo/yaoyao:v0.4.68
+docker pull samienluo/yaoyao:v0.4.69
 # 需要固定 AMD64 时:
-docker pull samienluo/yaoyao:v0.4.68-amd
+docker pull samienluo/yaoyao:v0.4.69-amd
 ```
 
 每次新版本发布都会更新 `latest`,旧版本标签继续保留。需要固定部署版本时使用具体版本标签。
@@ -34,7 +34,7 @@ cp docker.env.example docker.env
 
 | 配置 | 用途 |
 | --- | --- |
-| `HERMES_YAOYAO_IMAGE` | 远程镜像可设为 `samienluo/yaoyao:v0.4.68` 或 `samienluo/yaoyao:latest`;未设置时使用本地构建名称 |
+| `HERMES_YAOYAO_IMAGE` | 远程镜像可设为 `samienluo/yaoyao:v0.4.69` 或 `samienluo/yaoyao:latest`;未设置时使用本地构建名称 |
 | `HERMES_YAOYAO_UPSTREAM` | Hermes 上游地址,默认 `http://host.docker.internal:9119` |
 | `HERMES_YAOYAO_BIND_ADDRESS` | Web 的宿主机发布地址,默认 `127.0.0.1`;局域网访问可设为 `0.0.0.0` |
 | `HERMES_YAOYAO_PUBLISHED_PORT` | 宿主机 Web 端口,默认 `15300` |
@@ -211,7 +211,7 @@ curl --fail http://127.0.0.1:15300/healthz
 使用 Docker Hub 发布镜像时,在 `docker.env` 设置:
 
 ```dotenv
-HERMES_YAOYAO_IMAGE=samienluo/yaoyao:v0.4.68
+HERMES_YAOYAO_IMAGE=samienluo/yaoyao:v0.4.69
 YAOYAO_CURSOR_DESKTOP_IMAGE=samienluo/yaoyao-desktop:v0.4.12-cursor-amd
 ```
 

+ 6 - 5
docs/release-process.md

@@ -9,18 +9,19 @@
 3. 构建 Web 源码包、macOS 桌面安装包和适用的 Android 正式签名 APK,验证签名、架构、启动及完整性,生成 `SHA256SUMS.txt`。
 4. 推送源码与版本标签,上传 GitHub Release 附件,核对远端附件状态、大小和 SHA-256。已发布的 Git 标签与旧附件保持不变。
 
-### macOS 手动安装包
+### macOS 发布方式
 
-当前发布沿用 Apple Silicon 开发签名 DMG,供用户手动安装;不做 Apple 公证。缺少正式分发证书或公证配置,不阻塞这种安装包的 GitHub 发布,也不需要重复确认已确定的发布方式。
+macOS 新版本默认使用 Developer ID Application 正式分发签名、Apple 公证和下方的完整自动更新产物流程。本机公证凭据使用钥匙串配置 `yaoyao-notary`,通过 `APPLE_KEYCHAIN_PROFILE` 指定。正式发布应同时提供首次安装用的 DMG 和自动升级用的 ZIP、清单及差分文件。
 
-从干净的发布源码快照构建,并明确指定 DMG 和开发签名:`npm run desktop:build`,然后执行 `npx electron-builder --mac dmg --arm64 --publish never --config.mac.type=development`。验证签名完整性、架构、内置服务的版本与构建身份、实际启动以及 DMG 完整性,再上传 DMG、源码包和 `SHA256SUMS.txt`。发布说明明确写明开发签名、未公证、手动安装;不上传自动升级 ZIP、差分文件或 `latest-mac.yml`,不宣称已支持自动安装更新。
+开发签名 DMG 仅用于明确选择的手动安装测试版本:从干净源码快照执行 `npm run desktop:build`,再执行 `npx electron-builder --mac dmg --arm64 --publish never --config.mac.type=development`。这类包需要验证签名完整性、架构、内置服务身份、实际启动和 DMG 完整性,并明确标记开发签名、未公证、手动安装;不上传自动升级 ZIP、差分文件或 `latest-mac.yml`。
 
-### macOS 自动更新产物(具备正式分发条件时)
+### macOS 正式签名与自动更新产物
 
 `npm run desktop:pack` 用于本地打包;发布支持自动升级的正式分发包时使用 `npm run desktop:release`,其上传行为固定为 `never`,先生成可检查的本地产物。需要:
 
 - `CSC_NAME` 指定 `Developer ID Application: ...` 分发签名身份。
-- 配置 `APPLE_API_KEY`、`APPLE_API_KEY_ID`、`APPLE_API_ISSUER`,或 `APPLE_ID`、`APPLE_APP_SPECIFIC_PASSWORD`、`APPLE_TEAM_ID` 供公证使用。凭据通过环境注入,不写入仓库或发布说明。
+- 公证优先使用本机钥匙串:运行 `xcrun notarytool store-credentials yaoyao-notary --apple-id <邮箱> --team-id <团队 ID>`,按隐藏输入提示录入 App 专用密码,验证通过后设置 `APPLE_KEYCHAIN_PROFILE=yaoyao-notary`。自定义钥匙串可另设 `APPLE_KEYCHAIN` 路径。
+- 也支持配置 `APPLE_API_KEY`、`APPLE_API_KEY_ID`、`APPLE_API_ISSUER`,或 `APPLE_ID`、`APPLE_APP_SPECIFIC_PASSWORD`、`APPLE_TEAM_ID`。凭据通过钥匙串或环境注入,不写入仓库或发布说明。
 
 正式命令启用强制签名与公证,并校验包内 `app-update.yml` 指向 `Lsamien/yaoyao`、签名完整性、公证票据,以及 `latest-mac.yml` 的版本、附件名、大小和 SHA-512。当前仍只发布 Apple Silicon 桌面包;不要上传指向不存在的 Intel 包的清单。
 

+ 41 - 0
docs/releases/v0.4.69.md

@@ -0,0 +1,41 @@
+# 夭夭 AI v0.4.69
+
+本次发布 Web、macOS Apple Silicon 桌面版和 Docker 双架构镜像,不提供 APK。
+
+## 更新内容
+
+- 修复 Bot 模型设置在多 Profile 环境下无法加载模型列表或解析配置的问题。模型选择与解析同时使用当前 Profile 的配置和凭据作用域。
+- 保持并发请求、嵌套调用和异常退出时的 Profile 凭据隔离,并兼容旧版服务的配置作用域入口。
+- 桌面发布改用 Developer ID Application 正式分发签名及 Apple 公证,提供 DMG、自动更新 ZIP、差分文件和更新清单。
+
+## 升级说明
+
+- 升级前备份完整 `.yaoyao` 数据目录和上游配置目录。升级服务端后,在服务管理页面更新工具桥,并在空闲时重启对应服务,让模型设置修复生效。
+- 历史开发签名桌面版本请先手动下载安装本次正式签名 DMG;后续正式签名版本可使用“下载更新 → 重启更新”。
+- 本次不构建、不上传 APK,旧版本标签和附件继续保留。
+- 主项目采用 Apache-2.0,第三方组件保留各自许可与署名。
+
+## 下载
+
+- `Yaoyao-0.4.69-arm64.dmg`:macOS Apple Silicon 首次安装及旧版手动迁移。
+- `Yaoyao-0.4.69-arm64.zip`、对应 `.blockmap` 和 `latest-mac.yml`:桌面自动更新载荷与清单。
+- `Yaoyao-0.4.69-source.tar.gz`:Web/桌面源码及部署配置。
+- `SHA256SUMS.txt`:所有发布附件的 SHA-256 校验值。
+
+## Docker Hub
+
+| 镜像 | 架构 |
+| --- | --- |
+| `samienluo/yaoyao:v0.4.69-amd` | `linux/amd64` |
+| `samienluo/yaoyao:v0.4.69` | `linux/amd64`、`linux/arm64` |
+| `samienluo/yaoyao:latest` | 验证后更新为同一通用镜像 |
+
+```sh
+docker pull samienluo/yaoyao:v0.4.69
+docker compose --env-file docker.env pull web
+docker compose --env-file docker.env up -d --no-build web
+```
+
+Compose 中设置 `HERMES_YAOYAO_IMAGE=samienluo/yaoyao:v0.4.69`。镜像发布到 Docker Hub,GitHub 提供桌面安装及更新包、源码和校验文件。
+
+附件摘要、镜像摘要与实际验证结果见 [GitHub 发布页](https://github.com/Lsamien/yaoyao/releases/tag/v0.4.69)。

+ 1 - 0
integrations/hermes-bots-bridge/README.md

@@ -47,6 +47,7 @@ Runner 包内可直接运行同目录的 `install-hermes-bridge.py`。安装器
 - `GET /capabilities?profile=...`:检查对应 Profile 及托管能力。
 - `GET /model-options?profile=...`:读取 Profile 的模型目录、默认值、思考能力与速度能力;只返回公开配置,不返回凭据。
 - `POST /model-settings/resolve`:接收 `profile` 与 `settings`,通过 Hermes 原生解析器校验完整组合,返回版本 1 的有效配置和模型确认提示;不写 Profile 配置。
+- 模型目录与配置解析均使用 Hermes 原生配置作用域,同时绑定 Profile 目录和凭据;多 Profile Dashboard 不会因缺少凭据作用域而报错,也不会借用其他 Profile 的环境变量。默认 Profile 保留 Hermes 自身的启动凭据规则。
 - `POST /bind`:绑定真实 Hermes 会话、Profile 和当前轮次;最多 30 分钟,支持同轮续租。
 - `POST /unbind`:只撤销匹配的会话与轮次。
 - `POST /computer-file`:当前运行轮次的文件传输;验证 HTTP 身份、会话、轮次、Profile、文件保护规则,最多 25 MiB。请求不能选择其他 Profile。

+ 12 - 5
integrations/hermes-bots-bridge/model_settings.py

@@ -9,15 +9,22 @@ class ModelSettingsError(Exception):
 
 @contextmanager
 def profile_scope(profile):
-    from hermes_cli.profiles import get_profile_dir, profile_exists
-    from hermes_constants import set_hermes_home_override, reset_hermes_home_override
+    from hermes_cli.profiles import profile_exists
     if not isinstance(profile, str) or not re.fullmatch(r"[a-z0-9][a-z0-9_-]{0,63}", profile) or not profile_exists(profile):
         raise ModelSettingsError("基础机器人不存在")
-    token = set_hermes_home_override(get_profile_dir(profile))
+    # Match Hermes' own model picker: home AND credentials must be scoped.
+    # A home-only override raises UnscopedSecretError under multi-profile hosting.
+    # The native scope also preserves launch credentials and hydrates named profiles
+    # without borrowing process-global credentials or taking the skills lock.
     try:
+        from hermes_cli.web_server_profiles import _config_profile_scope
+    except ModuleNotFoundError as exc:
+        if exc.name != "hermes_cli.web_server_profiles":
+            raise
+        # Older Hermes versions kept the same helper in the monolithic server.
+        from hermes_cli.web_server import _config_profile_scope
+    with _config_profile_scope(profile):
         yield
-    finally:
-        reset_hermes_home_override(token)
 
 
 def defaults(ctx, config):

+ 87 - 1
integrations/hermes-bots-bridge/tests/test_model_settings.py

@@ -1,6 +1,9 @@
 import importlib.util
 import json
-from contextlib import nullcontext
+from contextlib import contextmanager, nullcontext
+from contextvars import ContextVar
+from concurrent.futures import ThreadPoolExecutor
+from threading import Barrier
 from pathlib import Path
 from types import SimpleNamespace
 from unittest.mock import Mock, patch
@@ -35,6 +38,89 @@ class BotModelSettingsTests(unittest.TestCase):
         self.scoped.start(); self.modules.start()
         self.addCleanup(self.scoped.stop); self.addCleanup(self.modules.stop)
 
+    def native_scope_fixture(self):
+        self.scoped.stop()
+        home = ContextVar('test_model_home', default='caller')
+        secret = ContextVar('test_model_secret', default=None)
+        calls = []
+
+        @contextmanager
+        def scope(profile):
+            calls.append(profile)
+            home_token = home.set(profile)
+            secret_token = secret.set(profile + '-credential')
+            try:
+                yield
+            finally:
+                secret.reset(secret_token)
+                home.reset(home_token)
+
+        def picker():
+            if secret.get() != home.get() + '-credential':
+                raise RuntimeError('UnscopedSecretError: missing Profile secret scope')
+            return self.ctx
+
+        import sys
+        constants = sys.modules['hermes_constants']
+        constants.set_hermes_home_override = home.set
+        constants.reset_hermes_home_override = home.reset
+        sys.modules['hermes_cli.inventory'].load_picker_context = picker
+        modules = {
+            'hermes_cli.profiles': SimpleNamespace(profile_exists=lambda p: p in ('default', 'writer'), get_profile_dir=lambda p: p),
+            'hermes_cli.web_server_profiles': SimpleNamespace(_config_profile_scope=scope),
+        }
+        patcher = patch.dict('sys.modules', modules)
+        patcher.start(); self.addCleanup(patcher.stop)
+        return home, secret, calls
+
+    def test_catalogue_and_resolution_bind_profile_secrets_in_multiplex_mode(self):
+        home, secret, calls = self.native_scope_fixture()
+        for profile in ('default', 'writer'):
+            self.assertEqual(models.options(profile)['version'], 1)
+            self.assertEqual(models.resolve(profile, None)['version'], 1)
+        self.assertEqual(calls, ['default', 'default', 'writer', 'writer'])
+        self.assertEqual(home.get(), 'caller')
+        self.assertIsNone(secret.get())
+
+    def test_scopes_are_thread_local_and_restore_the_caller_even_on_error(self):
+        home, secret, _ = self.native_scope_fixture()
+        barrier = Barrier(2)
+
+        def read(profile):
+            with models.profile_scope(profile):
+                barrier.wait(timeout=5)
+                self.assertEqual(home.get(), profile)
+                self.assertEqual(secret.get(), profile + '-credential')
+                with models.profile_scope('default'):
+                    self.assertEqual(secret.get(), 'default-credential')
+                self.assertEqual(secret.get(), profile + '-credential')
+            return home.get(), secret.get()
+
+        with ThreadPoolExecutor(max_workers=2) as pool:
+            self.assertEqual(list(pool.map(read, ('default', 'writer'))), [('caller', None), ('caller', None)])
+        with self.assertRaisesRegex(ValueError, 'fixture failure'):
+            with models.profile_scope('writer'):
+                raise ValueError('fixture failure')
+        self.assertEqual(home.get(), 'caller')
+        self.assertIsNone(secret.get())
+
+    def test_invalid_profiles_never_enter_a_credential_scope(self):
+        _, _, calls = self.native_scope_fixture()
+        for profile in ('../writer', 'missing', None, ''):
+            with self.subTest(profile=profile), self.assertRaises(models.ModelSettingsError):
+                models.options(profile)
+        self.assertEqual(calls, [])
+
+    def test_older_hermes_uses_its_native_scope_without_home_only_fallback(self):
+        home, secret, calls = self.native_scope_fixture()
+        import sys
+        native = sys.modules['hermes_cli.web_server_profiles']
+        with patch.dict('sys.modules', {'hermes_cli.web_server_profiles': None, 'hermes_cli.web_server': native}):
+            self.assertEqual(models.options('writer')['version'], 1)
+        self.assertEqual(calls, ['writer'])
+        self.assertEqual(home.get(), 'caller')
+        self.assertIsNone(secret.get())
+
     def test_catalogue_preserves_defaults_modes_and_does_not_disclose_credentials(self):
         value = models.options('default')
         self.assertEqual(value['defaults']['fastMode'], 'auto')

+ 2 - 2
package-lock.json

@@ -1,12 +1,12 @@
 {
   "name": "yaoyao",
-  "version": "0.4.68",
+  "version": "0.4.69",
   "lockfileVersion": 3,
   "requires": true,
   "packages": {
     "": {
       "name": "yaoyao",
-      "version": "0.4.68",
+      "version": "0.4.69",
       "license": "Apache-2.0",
       "dependencies": {
         "@koa/bodyparser": "^5.0.0",

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "yaoyao",
-  "version": "0.4.68",
+  "version": "0.4.69",
   "private": true,
   "license": "Apache-2.0",
   "description": "夭夭 AI:聊天、多 Agent 团队、文件库与电脑工作空间",

+ 3 - 3
release.json

@@ -1,6 +1,6 @@
 {
   "schemaVersion": 1,
-  "releaseVersion": "0.4.68",
-  "webVersion": "0.4.68",
-  "gitTag": "v0.4.68"
+  "releaseVersion": "0.4.69",
+  "webVersion": "0.4.69",
+  "gitTag": "v0.4.69"
 }

+ 2 - 1
scripts/desktop-release.mjs

@@ -11,7 +11,8 @@ export function releaseSigningOptions(env = process.env) {
     throw new Error('正式自动更新包需要 CSC_NAME 指定 Developer ID Application 签名身份')
   const apiKey = env.APPLE_API_KEY && env.APPLE_API_KEY_ID && env.APPLE_API_ISSUER
   const appleId = env.APPLE_ID && env.APPLE_APP_SPECIFIC_PASSWORD && env.APPLE_TEAM_ID
-  if (!apiKey && !appleId) throw new Error('请配置 Apple 公证凭据:APPLE_API_KEY/APPLE_API_KEY_ID/APPLE_API_ISSUER,或 APPLE_ID/APPLE_APP_SPECIFIC_PASSWORD/APPLE_TEAM_ID')
+  const keychainProfile = env.APPLE_KEYCHAIN_PROFILE?.trim()
+  if (!apiKey && !appleId && !keychainProfile) throw new Error('请配置 Apple 公证凭据:APPLE_KEYCHAIN_PROFILE,APPLE_API_KEY/APPLE_API_KEY_ID/APPLE_API_ISSUER,或 APPLE_ID/APPLE_APP_SPECIFIC_PASSWORD/APPLE_TEAM_ID')
   // electron-builder selects the certificate type itself and rejects its prefix
   // in the identity qualifier. Enforce a distribution identity, then strip it.
   const identity = env.CSC_NAME.slice('Developer ID Application:'.length).trim()