diff --git a/docs/QA-1.15.md b/docs/QA-1.15.md index 35c272f3..be69763f 100644 --- a/docs/QA-1.15.md +++ b/docs/QA-1.15.md @@ -14,6 +14,14 @@ Node24构建通过;[49项相关回归](desktop-host-a-accepted.tap)全部通 Electron固定45.2.0的真实二进制为249810432字节,SHA256010ea51bfb528c8143513439aa93fb40754403daa2023f9decd4517da71706ab;安装脚本显式完成,真实窗口尚未运行。开发工具Inno7.1.1安装命令被自动审批策略阻止、无执行;已核对可直接解包的innosetup-compiler6.3.1依赖,D再开发与验收。正式health仍1.14/PID23172,没有升级或重启。 -## B–F +## B:本机加密连接(通过) -本机加密连接正在推进;Electron窗口与IPC、安装/可回退更新、桌面三工程和独立发行尚未实施,按[执行方案](PLAN-1.15.md)验收。 +实际CurrentUser DPAPI保存块放在SQLite独立metadata,与连接登记共同提交;原公开registry/导出不写明文Key。显式新Key或本次确认导入可保存,关闭自动加载、删除本机保存、清除内存与本机保存分开。连接/配置修订、当前用户和数据目录参与绑定。加载失败显示损坏/用户/目录/来源状态,原保存块不重写。 + +[21专项与兼容](desktop-credentials-b-tests.tap)全部通过:实际DPAPI正确/错误entropy及损坏,重开加载与修订、批量导入第二密钥加密失败/事务提交失败回退原行/路由/内存引用,停用/删除/清除及明文扫描。[7组实际浏览器与重启](desktop-credentials-b-actual.json)全部通过,原PID28724/新PID49924;已保存两连接恢复、临时连接丢弃,原公共连接/密文和除runtimeOwner的6表原行保持;恢复后3次自有HTTP请求实际认证成功。日志/SQLite页/WAL/配置/导出不含自有明文测试Key;没有使用正式Key或真实推理。 + +Python依赖缺失的原失败未启动宿主,随后独立桌面虚拟环境固定Playwright1.64.1。真实UI首轮发现select可访问标签不完整,原失败报告/日志保留;补aria-label。首个已通过布局仍拥挤,保留prelayout原截图/报告,采用既有蓝白控制台的表单网格和当前标签可见性,再实际1440/390复验与人工截图审查通过。不同Windows账号未登录验收;已实际验证错误entropy/损坏并验证不同SID拒绝,不将其写为跨账号实测。 + +## C–F + +Electron窗口与IPC正在实施,真实窗口尚未验收;安装/可回退更新、桌面三工程和独立发行按[执行方案](PLAN-1.15.md)继续。 diff --git a/docs/RETROSPECTIVE-1.15.md b/docs/RETROSPECTIVE-1.15.md index ab33ebbb..e8c84c6a 100644 --- a/docs/RETROSPECTIVE-1.15.md +++ b/docs/RETROSPECTIVE-1.15.md @@ -11,3 +11,9 @@ 49相关回归及9组真实主机通过。除签名挑战,核对实际PID创建、用户SID、加载的不可变输入和数据目录;注册失败不发布半成品内存,锁和启动意图防止不明进程被重复创建。模型队列/HTTP和原生driver加入完整关闭。中文工作区及重复DACL设置的原失败证明需要真实Windows验证;所有失败保留,改为UTF-8 base64输入和仅修改Access权限后复验。原历史导出保持原结构,验收从独立SQLite读取完整原tool行。 本切片仅交付主机基础;Electron窗口关闭/重开需C/E真实证明。下一B把密文和注册写入同一SQLite事务,避免两份磁盘文件之间的部分提交;只加密用户新输入/明确确认导入的Key,不自动持久化原内存连接。不同用户/损坏/配置修订失配应分别显示不可加载。 + +## B回顾 + +21专项/兼容和7组实际浏览器、独立宿主重启及HTTP验证通过。DPAPI密文同SQLite事务提交,保存失败回退连接、路由、旧内存引用和全部原行;仅处理用户新填或当前确认导入。已保存连接的原修订跨进程保持,临时连接清除;关闭、删除和清除语义分别验证。SID/目录/源修订异常不自动重写原块。跨Windows账号登录尚未进行,证据不从SID测试外推。 + +浏览器通过不等于视觉完成:首个窄屏截图仍使用挤在一行的默认控件,原结果保留,补既有控制台表单网格和选中导航自动可见后重新验收。下一C继续同一React客户端,原文件入口只在所属项目定位,不执行文件;Task审查核对当前项目/会话/Task。Electron窗口关闭后自行退出,独立Node继续执行;明确退出宿主才等待所属工具结束。单实例、主frame/固定IPC、导航与权限拒绝均需实际Electron验证。 diff --git a/docs/desktop-credentials-b-actual.json b/docs/desktop-credentials-b-actual.json new file mode 100644 index 00000000..83431a0c --- /dev/null +++ b/docs/desktop-credentials-b-actual.json @@ -0,0 +1,95 @@ +{ + "success": true, + "root": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\desktop-credentials-4083fa57-495c-4f03-a634-38b3af7ac525", + "url": "http://127.0.0.1:62117", + "stage": "plaintext leak scan over actual database, WAL, exports and host logs", + "originalHost": { + "url": "http://127.0.0.1:62117", + "identity": { + "schema": 1, + "protocol": "agent-workbench-host-v1", + "app": "agent-workbench", + "version": "1.14.0", + "instanceId": "ad80c3c8-5484-443d-b142-1d763e49350f", + "pid": 28724, + "createdAt": "2026-10-31T01:21:14.095Z", + "userSid": "S-1-5-21-3906741337-925321518-3767092861-1001", + "ownerId": "41b7bfe9-e7f5-4051-a5bc-e371575da94a", + "executable": { + "path": "D:\\Ai-project\\REA逆向\\tools\\node-v24.22.1-win-x64\\node.exe", + "bytes": 93915464, + "sha256": "d702daa815eabbff763c7d3808e235cf031cf2ca70211b56847bc72f51e240e5" + }, + "appRoot": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\desktop-credentials-4083fa57-495c-4f03-a634-38b3af7ac525\\app", + "runtimeRoot": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\desktop-credentials-4083fa57-495c-4f03-a634-38b3af7ac525\\app", + "runtimeIdentity": "e53c216c4180c7b2960028f2e9cb1763fc5510efe0ea088e5370450e76a621d8", + "dataRoot": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\desktop-credentials-4083fa57-495c-4f03-a634-38b3af7ac525\\data", + "port": 62117 + }, + "reused": false, + "logs": { + "stdoutPath": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\desktop-credentials-4083fa57-495c-4f03-a634-38b3af7ac525\\data\\logs\\desktop-host-78659811-d287-4dd2-bee4-655a36c0c328-stdout.log", + "stderrPath": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\desktop-credentials-4083fa57-495c-4f03-a634-38b3af7ac525\\data\\logs\\desktop-host-78659811-d287-4dd2-bee4-655a36c0c328-stderr.log" + } + }, + "freshHost": { + "url": "http://127.0.0.1:62117", + "identity": { + "schema": 1, + "protocol": "agent-workbench-host-v1", + "app": "agent-workbench", + "version": "1.14.0", + "instanceId": "ae5ee3e1-584d-4969-bbe3-7483382035cb", + "pid": 49924, + "createdAt": "2026-10-31T01:21:23.749Z", + "userSid": "S-1-5-21-3906741337-925321518-3767092861-1001", + "ownerId": "5d0fb73d-77b2-450a-9a07-b089a3e6a4c6", + "executable": { + "path": "D:\\Ai-project\\REA逆向\\tools\\node-v24.22.1-win-x64\\node.exe", + "bytes": 93915464, + "sha256": "d702daa815eabbff763c7d3808e235cf031cf2ca70211b56847bc72f51e240e5" + }, + "appRoot": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\desktop-credentials-4083fa57-495c-4f03-a634-38b3af7ac525\\app", + "runtimeRoot": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\desktop-credentials-4083fa57-495c-4f03-a634-38b3af7ac525\\app", + "runtimeIdentity": "e53c216c4180c7b2960028f2e9cb1763fc5510efe0ea088e5370450e76a621d8", + "dataRoot": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\desktop-credentials-4083fa57-495c-4f03-a634-38b3af7ac525\\data", + "port": 62117 + }, + "reused": false, + "logs": { + "stdoutPath": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\desktop-credentials-4083fa57-495c-4f03-a634-38b3af7ac525\\data\\logs\\desktop-host-747ea62f-e2db-46e7-a878-d48d3533ab64-stdout.log", + "stderrPath": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\desktop-credentials-4083fa57-495c-4f03-a634-38b3af7ac525\\data\\logs\\desktop-host-747ea62f-e2db-46e7-a878-d48d3533ab64-stderr.log" + } + }, + "groups": [ + "real connection form and explicit encrypted save", + "real legacy credential save without exposing an existing key", + "real desktop and 390px saved-state controls and layout", + "actual host exit and fresh process restores encrypted revisions", + "fresh host actually uses both DPAPI-restored keys with owned HTTP responses", + "disable, delete and forget through real controls", + "plaintext leak scan over actual database, WAL, exports and host logs" + ], + "requests": [ + { + "path": "/v1/chat/completions", + "authorizedOwnedKey": true + }, + { + "path": "/v1/chat/completions", + "authorizedOwnedKey": true + }, + { + "path": "/v1/chat/completions", + "authorizedOwnedKey": true + } + ], + "images": [ + "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\desktop-credentials-4083fa57-495c-4f03-a634-38b3af7ac525\\credentials-new-connection.png", + "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\desktop-credentials-4083fa57-495c-4f03-a634-38b3af7ac525\\credentials-1440.png", + "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\desktop-credentials-4083fa57-495c-4f03-a634-38b3af7ac525\\credentials-390.png" + ], + "pageErrors": [], + "detail": null, + "scope": "Owned CurrentUser DPAPI and local HTTP fixture; no external model request or existing credential is used." +} \ No newline at end of file diff --git a/docs/desktop-credentials-b-actual.txt b/docs/desktop-credentials-b-actual.txt new file mode 100644 index 00000000..4ccf5f38 --- /dev/null +++ b/docs/desktop-credentials-b-actual.txt @@ -0,0 +1,7 @@ +PASS real connection form and explicit encrypted save +PASS real legacy credential save without exposing an existing key +PASS real desktop and 390px saved-state controls and layout +PASS actual host exit and fresh process restores encrypted revisions +PASS fresh host actually uses both DPAPI-restored keys with owned HTTP responses +PASS disable, delete and forget through real controls +PASS plaintext leak scan over actual database, WAL, exports and host logs diff --git a/docs/desktop-credentials-b-prelayout.json b/docs/desktop-credentials-b-prelayout.json new file mode 100644 index 00000000..e26e842c --- /dev/null +++ b/docs/desktop-credentials-b-prelayout.json @@ -0,0 +1,37 @@ +{ + "success": true, + "root": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\desktop-credentials-4cfcf5da-eaaf-472e-b6c0-99266b1e9a3c", + "url": "http://127.0.0.1:62578", + "stage": "plaintext leak scan over actual database, WAL, exports and host logs", + "groups": [ + "real connection form and explicit encrypted save", + "real legacy credential save without exposing an existing key", + "real desktop and 390px saved-state controls and layout", + "actual host exit and fresh process restores encrypted revisions", + "fresh host actually uses both DPAPI-restored keys with owned HTTP responses", + "disable, delete and forget through real controls", + "plaintext leak scan over actual database, WAL, exports and host logs" + ], + "requests": [ + { + "path": "/v1/chat/completions", + "authorizedOwnedKey": true + }, + { + "path": "/v1/chat/completions", + "authorizedOwnedKey": true + }, + { + "path": "/v1/chat/completions", + "authorizedOwnedKey": true + } + ], + "images": [ + "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\desktop-credentials-4cfcf5da-eaaf-472e-b6c0-99266b1e9a3c\\credentials-new-connection.png", + "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\desktop-credentials-4cfcf5da-eaaf-472e-b6c0-99266b1e9a3c\\credentials-1440.png", + "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\desktop-credentials-4cfcf5da-eaaf-472e-b6c0-99266b1e9a3c\\credentials-390.png" + ], + "pageErrors": [], + "detail": null, + "scope": "Owned CurrentUser DPAPI and local HTTP fixture; no external model request or existing credential is used." +} \ No newline at end of file diff --git a/docs/desktop-credentials-b-prelayout.txt b/docs/desktop-credentials-b-prelayout.txt new file mode 100644 index 00000000..4ccf5f38 --- /dev/null +++ b/docs/desktop-credentials-b-prelayout.txt @@ -0,0 +1,7 @@ +PASS real connection form and explicit encrypted save +PASS real legacy credential save without exposing an existing key +PASS real desktop and 390px saved-state controls and layout +PASS actual host exit and fresh process restores encrypted revisions +PASS fresh host actually uses both DPAPI-restored keys with owned HTTP responses +PASS disable, delete and forget through real controls +PASS plaintext leak scan over actual database, WAL, exports and host logs diff --git a/docs/desktop-credentials-b-tests.tap b/docs/desktop-credentials-b-tests.tap new file mode 100644 index 00000000..b183e08b --- /dev/null +++ b/docs/desktop-credentials-b-tests.tap @@ -0,0 +1,136 @@ +TAP version 13 +# Subtest: actual Windows CurrentUser DPAPI roundtrips owned UTF-8 and rejects damaged bytes and wrong entropy +ok 1 - actual Windows CurrentUser DPAPI roundtrips owned UTF-8 and rejects damaged bytes and wrong entropy + --- + duration_ms: 1703.112 + type: 'test' + ... +# Subtest: only explicitly supplied keys persist; new provider restores original revisions and public views contain no key +ok 2 - only explicitly supplied keys persist; new provider restores original revisions and public views contain no key + --- + duration_ms: 2823.1817 + type: 'test' + ... +# Subtest: registry and cipher commit failure restores original routing, keys, block and every database row +ok 3 - registry and cipher commit failure restores original routing, keys, block and every database row + --- + duration_ms: 1872.4547 + type: 'test' + ... +# Subtest: a two-key import with a protection failure rolls back all registry and cipher entries and retains its preview +ok 4 - a two-key import with a protection failure rolls back all registry and cipher entries and retains its preview + --- + duration_ms: 1892.0773 + type: 'test' + ... +# Subtest: connection revision changes retain the original saved block and report a source mismatch on restart +ok 5 - connection revision changes retain the original saved block and report a source mismatch on restart + --- + duration_ms: 2825.6882 + type: 'test' + ... +# Subtest: disable skips real restart loading, explicit enable restores, delete preserves memory and forget removes both +ok 6 - disable skips real restart loading, explicit enable restores, delete preserves memory and forget removes both + --- + duration_ms: 2609.0633 + type: 'test' + ... +# Subtest: corrupt saved block and another SID do not load; failures are visible without returning ciphertext or plaintext +ok 7 - corrupt saved block and another SID do not load; failures are visible without returning ciphertext or plaintext + --- + duration_ms: 2682.8404 + type: 'test' + ... +# Subtest: legacy persistence requires a new explicit key and binds config and credential revisions; stale requests cannot save +ok 8 - legacy persistence requires a new explicit key and binds config and credential revisions; stale requests cannot save + --- + duration_ms: 2361.2135 + type: 'test' + ... +# Subtest: owned plaintext keys never reach SQLite pages, WAL, config or public execution exports +ok 9 - owned plaintext keys never reach SQLite pages, WAL, config or public execution exports + --- + duration_ms: 1256.7214 + type: 'test' + ... +# Subtest: model registry keeps original credentials/endpoint intact, rejects stale edits, and forgets only volatile keys on restart +ok 10 - model registry keeps original credentials/endpoint intact, rejects stale edits, and forgets only volatile keys on restart + --- + duration_ms: 914.4979 + type: 'test' + ... +# Subtest: config import previews exact revisions, keeps secrets volatile, syncs only when enabled and preserves manual edits on conflicts +ok 11 - config import previews exact revisions, keeps secrets volatile, syncs only when enabled and preserves manual edits on conflicts + --- + duration_ms: 753.8609 + type: 'test' + ... +# Subtest: real HTTP pool fails over 429 to another model and never repeats completed tools; attempts seal actual request bytes and Run identity +ok 12 - real HTTP pool fails over 429 to another model and never repeats completed tools; attempts seal actual request bytes and Run identity + --- + duration_ms: 2729.1166 + type: 'test' + ... +# Subtest: pool rotation and weights select members on new Runs; disabled and missing credentials are excluded without requests +ok 13 - pool rotation and weights select members on new Runs; disabled and missing credentials are excluded without requests + --- + duration_ms: 3857.7792 + type: 'test' + ... +# Subtest: 401 blocks the credential revision; updating the key restores availability without leaking error echoes +ok 14 - 401 blocks the credential revision; updating the key restores availability without leaking error echoes + --- + duration_ms: 2080.9134 + type: 'test' + ... +# Subtest: queued request cancellation and in-flight disable release only owned leases and do not dispatch another HTTP request +ok 15 - queued request cancellation and in-flight disable release only owned leases and do not dispatch another HTTP request + --- + duration_ms: 958.8689 + type: 'test' + ... +# Subtest: compiled model-center HTTP API persists public profiles, blocks forged origins, and local operations never invoke a model +ok 16 - compiled model-center HTTP API persists public profiles, blocks forged origins, and local operations never invoke a model + --- + duration_ms: 2084.6897 + type: 'test' + ... +# Subtest: model registry disk failures restore routing, pool profiles and credential references without partial updates +ok 17 - model registry disk failures restore routing, pool profiles and credential references without partial updates + --- + duration_ms: 957.6324 + type: 'test' + ... +# Subtest: model selection and saved configuration commit together and failures preserve the original mode and endpoint +ok 18 - model selection and saved configuration commit together and failures preserve the original mode and endpoint + --- + duration_ms: 711.9416 + type: 'test' + ... +# Subtest: configuration imports roll back the entire batch and retain one usable preview after validation or commit failure +ok 19 - configuration imports roll back the entire batch and retain one usable preview after validation or commit failure + --- + duration_ms: 726.4839 + type: 'test' + ... +# Subtest: hot upgrade refreshes retained model and importer methods while preserving credential and routing objects +ok 20 - hot upgrade refreshes retained model and importer methods while preserving credential and routing objects + --- + duration_ms: 751.8999 + type: 'test' + ... +# Subtest: hot upgrade refuses active probes and restores retained model methods if installation fails +ok 21 - hot upgrade refuses active probes and restores retained model methods if installation fails + --- + duration_ms: 728.8236 + type: 'test' + ... +1..21 +# tests 21 +# suites 0 +# pass 21 +# fail 0 +# cancelled 0 +# skipped 0 +# todo 0 +# duration_ms 20118.8961 diff --git a/docs/desktop-credentials-first-ui-failure.json b/docs/desktop-credentials-first-ui-failure.json new file mode 100644 index 00000000..9e48451f --- /dev/null +++ b/docs/desktop-credentials-first-ui-failure.json @@ -0,0 +1,14 @@ +{ + "success": false, + "root": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\desktop-credentials-91af1820-7dfa-4ffd-aa0a-6c002014c8c5", + "url": "http://127.0.0.1:60078", + "stage": "real legacy credential save without exposing an existing key", + "groups": [ + "real connection form and explicit encrypted save" + ], + "requests": [], + "images": [], + "pageErrors": [], + "detail": "Locator.select_option: Timeout 30000ms exceeded.\nCall log:\n - waiting for get_by_role(\"dialog\", name=\"模型中心\", exact=True).get_by_role(\"form\", name=\"保存加密凭据\", exact=True).get_by_label(\"选择保存连接\", exact=True)\n", + "scope": "Owned CurrentUser DPAPI and local HTTP fixture; no external model request or existing credential is used." +} \ No newline at end of file diff --git a/docs/desktop-credentials-first-ui-failure.txt b/docs/desktop-credentials-first-ui-failure.txt new file mode 100644 index 00000000..9fbb339c --- /dev/null +++ b/docs/desktop-credentials-first-ui-failure.txt @@ -0,0 +1,20 @@ +PASS real connection form and explicit encrypted save +Traceback (most recent call last): + File "D:\Ai-project\REA逆向\Agent-Workbench\scripts\verify-desktop-credentials.py", line 127, in + form.get_by_label('选择保存连接', exact=True).select_option('legacy-default') + File "D:\Ai-project\REA逆向\Agent-Workbench\.qa\desktop-python\lib\site-packages\playwright\sync_api\_generated.py", line 13173, in select_option + self._sync( + File "D:\Ai-project\REA逆向\Agent-Workbench\.qa\desktop-python\lib\site-packages\playwright\_impl\_sync_base.py", line 111, in _sync + return task.result() + File "D:\Ai-project\REA逆向\Agent-Workbench\.qa\desktop-python\lib\site-packages\playwright\_impl\_locator.py", line 652, in select_option + return await self._frame.select_option( + File "D:\Ai-project\REA逆向\Agent-Workbench\.qa\desktop-python\lib\site-packages\playwright\_impl\_frame.py", line 819, in select_option + return await self._channel.send("selectOption", self._timeout, params) + File "D:\Ai-project\REA逆向\Agent-Workbench\.qa\desktop-python\lib\site-packages\playwright\_impl\_connection.py", line 78, in send + return await self._connection.wrap_api_call( + File "D:\Ai-project\REA逆向\Agent-Workbench\.qa\desktop-python\lib\site-packages\playwright\_impl\_connection.py", line 636, in wrap_api_call + raise rewrite_error(error, f"{parsed_st['apiName']}: {error}") from None +playwright._impl._errors.TimeoutError: Locator.select_option: Timeout 30000ms exceeded. +Call log: + - waiting for get_by_role("dialog", name="模型中心", exact=True).get_by_role("form", name="保存加密凭据", exact=True).get_by_label("选择保存连接", exact=True) + diff --git a/docs/screenshots/desktop-host-1.15/credentials-1440.png b/docs/screenshots/desktop-host-1.15/credentials-1440.png new file mode 100644 index 00000000..3af26f5e Binary files /dev/null and b/docs/screenshots/desktop-host-1.15/credentials-1440.png differ diff --git a/docs/screenshots/desktop-host-1.15/credentials-1440.png.prelayout.png b/docs/screenshots/desktop-host-1.15/credentials-1440.png.prelayout.png new file mode 100644 index 00000000..eb966300 Binary files /dev/null and b/docs/screenshots/desktop-host-1.15/credentials-1440.png.prelayout.png differ diff --git a/docs/screenshots/desktop-host-1.15/credentials-390.png b/docs/screenshots/desktop-host-1.15/credentials-390.png new file mode 100644 index 00000000..ba2f94ef Binary files /dev/null and b/docs/screenshots/desktop-host-1.15/credentials-390.png differ diff --git a/docs/screenshots/desktop-host-1.15/credentials-390.png.prelayout.png b/docs/screenshots/desktop-host-1.15/credentials-390.png.prelayout.png new file mode 100644 index 00000000..d6e9d0c3 Binary files /dev/null and b/docs/screenshots/desktop-host-1.15/credentials-390.png.prelayout.png differ diff --git a/docs/screenshots/desktop-host-1.15/credentials-new-connection.png b/docs/screenshots/desktop-host-1.15/credentials-new-connection.png new file mode 100644 index 00000000..79c40df7 Binary files /dev/null and b/docs/screenshots/desktop-host-1.15/credentials-new-connection.png differ diff --git a/docs/screenshots/desktop-host-1.15/credentials-new-connection.png.prelayout.png b/docs/screenshots/desktop-host-1.15/credentials-new-connection.png.prelayout.png new file mode 100644 index 00000000..5aea43fe Binary files /dev/null and b/docs/screenshots/desktop-host-1.15/credentials-new-connection.png.prelayout.png differ diff --git a/findings.md b/findings.md index ff181e12..92ddc2fd 100644 --- a/findings.md +++ b/findings.md @@ -623,3 +623,6 @@ Claude Code 报告已验证工具输入校验、权限决定、队列并发屏 # 2026-10-31 1.15 A/B衔接 A的49专项和9组实际隔离宿主通过,正式1.14/PID23172保持。PowerShell默认stdin编码在中文路径失效,重新写完整安全描述符误需SeSecurityPrivilege;分别采用UTF-8 base64路径和Access-only DACL。已完成工具的完整原行从只读SQLite核对,保留旧公开导出。B决定以Windows用户级DPAPI加密块存在同一SQLite事务metadata中,配置/密文/内存失败一起回退;显式新Key/确认导入才持久化,原Key不抽取。 +# 2026-10-31 B收口与C边界 + +B实际DPAPI/21专项/7浏览器-重启组通过,未用正式Key。密文与registry同库事务,配置变化保留失效原块;新UI原可访问select错误和prelayout拥挤截图保留,表单网格/活动标签可见后复验。C采用Electron45.2隔离主窗口及6个固定IPC,不导出ipcRenderer/Node;打开目录与文件定位绑定登记项目/当前Task及SHA,窗口退出不结束Node,显式宿主退出保留核验。原窗口内核不复制第二套代理。 diff --git a/progress.md b/progress.md index 49816d80..47992d04 100644 --- a/progress.md +++ b/progress.md @@ -649,3 +649,6 @@ 已接续未提交的A初稿;尚未部署。修正初始化发布时机、全路径祖先/链接及多路径检查、Windows秘密目录当前用户ACL、保留宿主热更新身份、请求与模型队列取消,以及剩余原生driver关闭。Start/Stop入口改为挑战签名与实际PID创建/SID/安装/数据目录验证。下一步独立构建与真实隔离进程验证。 工具层初次读取不存在的父AGENTS/根Start脚本和猜测测试文件、Windows rg通配参数失败均无产品副作用;已使用仓库实际AGENTS及scripts路径,限定rg目录。一次补丁因重复文件操作被拒绝,未生效;拆成有效修改后完成。初次总输出超限未视为已读,已重新按函数小段核对。 +# 2026-10-31 B交付前回顾 + +A提交249f191。B构建及21专项/兼容、7组浏览器/DPAPI恢复/HTTP/全数据目录明文扫描通过,实际28724→49924,新恢复两Key共3次夹具响应。完整公开配置和除runtimeOwner的6表原行保持。原Python缺依赖、首轮无select可访问标签和首个prelayout记录保留,采用独立Playwright1.64.1与既有蓝白网格复验。当前正式仍1.14/PID23172,未启动真实推理;C的主进程/桥/预加载初稿尚未编译或接入,不计交付。 diff --git a/scripts/verify-desktop-credentials.py b/scripts/verify-desktop-credentials.py new file mode 100644 index 00000000..bf2fd8e5 --- /dev/null +++ b/scripts/verify-desktop-credentials.py @@ -0,0 +1,206 @@ +"""Owned Windows DPAPI restart and real browser acceptance; no user credentials.""" +import argparse +import hashlib +import http.server +import json +import os +from pathlib import Path +import re +import shutil +import socket +import sqlite3 +import subprocess +import threading +import time +import urllib.request +import uuid + +parser = argparse.ArgumentParser(description=__doc__) +parser.add_argument('--node', required=True) +args = parser.parse_args() +from playwright.sync_api import sync_playwright, expect +workspace = Path.cwd() +root = workspace / '.qa' / ('desktop-credentials-' + str(uuid.uuid4())) +app_root, data_root = root / 'app', root / 'data' +app_root.mkdir(parents=True) +for name in ['dist-client', 'dist-server']: + shutil.copytree(workspace / name, app_root / name) +shutil.copy2(workspace / 'package.json', app_root / 'package.json') +with socket.socket() as probe: + probe.bind(('127.0.0.1', 0)) + port = probe.getsockname()[1] +url = 'http://127.0.0.1:' + str(port) +node = str(Path(args.node).resolve()) +allowed = re.compile(r'^(path|pathext|systemroot|systemdrive|windir|comspec|temp|tmp|userprofile|homedrive|homepath|home|appdata|localappdata|programfiles(?:\(x86\))?|commonprogramfiles(?:\(x86\))?|lang|lc_all)$', re.I) +environment = {key: value for key, value in os.environ.items() if allowed.match(key)} +environment['PATH'] = str(Path(node).parent) + os.pathsep + environment.get('PATH', environment.get('Path', '')) +for key in list(environment): + if key.lower() == 'path' and key != 'PATH': + del environment[key] +keys = ['OWNED_UI_DPAPI_' + uuid.uuid4().hex, 'OWNED_UI_LEGACY_' + uuid.uuid4().hex, 'OWNED_UI_VOLATILE_' + uuid.uuid4().hex] +requests = [] + +class ModelFixture(http.server.BaseHTTPRequestHandler): + def respond(self): + if self.command == 'POST': + self.rfile.read(int(self.headers.get('Content-Length', 0))) + valid = self.headers.get('Authorization') in ['Bearer ' + key for key in keys] + requests.append({'path': self.path, 'authorizedOwnedKey': valid}) + result = {'data': [{'id': 'owned-fixture'}]} if self.path.endswith('/models') else {'choices': [{'message': {'role': 'assistant', 'content': 'Owned response OK'}, 'finish_reason': 'stop'}], 'usage': {'prompt_tokens': 5, 'completion_tokens': 4, 'total_tokens': 9}} + encoded = json.dumps(result if valid else {'error': {'message': 'Owned fixture credential rejected'}}).encode() + self.send_response(200 if valid else 401) + self.send_header('Content-Type', 'application/json') + self.send_header('Content-Length', str(len(encoded))) + self.end_headers() + self.wfile.write(encoded) + do_GET = respond + do_POST = respond + def log_message(self, *unused): + pass + +fixture = http.server.ThreadingHTTPServer(('127.0.0.1', 0), ModelFixture) +threading.Thread(target=fixture.serve_forever, daemon=True).start() +endpoint = 'http://127.0.0.1:' + str(fixture.server_port) + '/v1' +marks, errors, images = [], [], [] +started, token, stage = False, None, 'host start' + +def host(command): + child = subprocess.run([node, str(app_root / 'dist-server' / 'host-launcher.mjs'), command, '--app-root', str(app_root), '--data-root', str(data_root), '--node', node, '--port', str(port)], cwd=str(app_root), env=environment, capture_output=True, encoding='utf-8', timeout=75, creationflags=subprocess.CREATE_NO_WINDOW) + if child.returncode: + raise RuntimeError('Owned host operation failed: ' + child.stderr) + return json.loads(child.stdout) + +def api(route, payload=None): + req = urllib.request.Request(url + '/api' + route, data=None if payload is None else json.dumps(payload).encode(), headers={'Content-Type': 'application/json', 'X-Workbench-Token': token or '', 'Connection': 'close'}) + with urllib.request.urlopen(req, timeout=30) as response: + return json.load(response) + +def mark(name): + marks.append(name) + print('PASS ' + name, flush=True) + +def snapshot_rows(): + with sqlite3.connect((data_root / 'workbench.sqlite').as_uri() + '?mode=ro', uri=True) as db: + result = {table: db.execute('SELECT * FROM ' + table + ' ORDER BY rowid').fetchall() for table in ['metadata', 'projects', 'sessions', 'records', 'events', 'outbox']} + result['metadata'] = [row for row in result['metadata'] if row[0] != 'runtimeOwner'] + return result + +def save(success, detail=None): + result = {'success': success, 'root': str(root), 'url': url, 'stage': stage, 'originalHost': globals().get('original'), 'freshHost': globals().get('fresh'), 'groups': marks, 'requests': requests, 'images': images, 'pageErrors': errors, 'detail': detail, 'scope': 'Owned CurrentUser DPAPI and local HTTP fixture; no external model request or existing credential is used.'} + (root / 'result.json').write_text(json.dumps(result, ensure_ascii=False, indent=2), encoding='utf-8') + (workspace / '.qa' / 'desktop-credentials-latest.json').write_text(json.dumps(result, ensure_ascii=False, indent=2), encoding='utf-8') + +try: + original = host('start'); started = True + token = api('/bootstrap')['token'] + api('/config', {'mode': 'demo', 'baseUrl': endpoint, 'model': 'owned-legacy'}) + with sync_playwright() as pw: + browser = pw.chromium.launch(channel='msedge', headless=True) + page = browser.new_page(viewport={'width': 1440, 'height': 1000}) + page.on('pageerror', lambda error: errors.append(str(error))) + page.goto(url) + page.wait_for_load_state('networkidle') + assert page.get_by_role('button', name='打开模型中心', exact=True).count() == 1 + page.get_by_role('button', name='打开模型中心', exact=True).click() + dialog = page.get_by_role('dialog', name='模型中心', exact=True) + expect(dialog).to_be_visible() + stage = 'real connection form and explicit encrypted save' + dialog.get_by_role('button', name='添加连接', exact=True).click() + editor = dialog.get_by_role('form', name='编辑模型连接', exact=True) + editor.get_by_label('连接名称', exact=True).fill('Owned Saved Primary') + editor.get_by_label('接口根地址', exact=True).fill(endpoint) + editor.get_by_label('实际模型名称', exact=True).fill('owned-primary') + editor.get_by_label('本机加密保存本次填写的 API Key', exact=True).check() + expect(editor.get_by_role('button', name='保存模型连接', exact=True)).to_be_disabled() + editor.get_by_label('临时 API Key', exact=True).fill(keys[0]) + editor.get_by_role('button', name='保存模型连接', exact=True).click() + expect(dialog.locator('.mc-connection').filter(has_text='Owned Saved Primary')).to_contain_text('可从本机加密保存加载') + assert keys[0] not in page.content() + mark(stage) + initial_image = root / 'credentials-new-connection.png' + page.screenshot(path=str(initial_image), full_page=True) + images.append(str(initial_image)) + center = api('/model-center') + saved = next(value for value in center['connections'] if value['name'] == 'Owned Saved Primary') + volatile = api('/model-center/connections', {'name': 'Owned Volatile', 'model': 'owned-volatile', 'baseUrl': endpoint, 'apiKey': keys[2]}) + stage = 'real legacy credential save without exposing an existing key' + dialog.get_by_role('button', name='凭据保存', exact=True).click() + form = dialog.get_by_role('form', name='保存加密凭据', exact=True) + expect(form).to_be_visible() + form.get_by_label('选择保存连接', exact=True).select_option('legacy-default') + form.get_by_label('重新填写 API Key', exact=True).fill(keys[1]) + form.get_by_role('button', name='加密保存凭据', exact=True).click() + expect(form.get_by_label('重新填写 API Key', exact=True)).to_have_value('') + expect(dialog.locator('.mc-connection').filter(has_text='原模型连接')).to_contain_text('本机加密保存') + mark(stage) + for width in [1440, 390]: + page.set_viewport_size({'width': width, 'height': 1000}) + expect(dialog.get_by_role('heading', name='本机加密凭据', exact=True)).to_be_visible() + assert page.evaluate('document.documentElement.scrollWidth <= innerWidth + 1') + image = root / ('credentials-' + str(width) + '.png') + page.screenshot(path=str(image), full_page=True) + images.append(str(image)) + mark('real desktop and 390px saved-state controls and layout') + browser.close() + stage = 'actual host exit and fresh process restores encrypted revisions' + api('/model-center/probe', {'id': saved['id']}) + before_rows = snapshot_rows() + before_credentials = api('/model-center/credentials') + stopped = host('stop'); started = False + assert stopped['processExited'] + fresh = host('start'); started = True + assert fresh['identity']['instanceId'] != original['identity']['instanceId'] + token = api('/bootstrap')['token'] + restored = api('/model-center') + current = next(value for value in restored['connections'] if value['id'] == saved['id']) + assert current['hasKey'] and current['credentialRevision'] == saved['credentialRevision'] + assert next(value for value in restored['connections'] if value['id'] == volatile['id'])['hasKey'] is False + assert next(value for value in restored['connections'] if value['id'] == 'legacy-default')['hasKey'] + assert snapshot_rows() == before_rows + assert api('/model-center/credentials')['connections'] == before_credentials['connections'] + mark(stage) + api('/model-center/probe', {'id': saved['id']}) + api('/model-center/probe', {'id': 'legacy-default'}) + assert len(requests) == 3 and all(value['authorizedOwnedKey'] for value in requests) + mark('fresh host actually uses both DPAPI-restored keys with owned HTTP responses') + stage = 'disable, delete and forget through real controls' + with sync_playwright() as pw: + browser = pw.chromium.launch(channel='msedge', headless=True) + page = browser.new_page(viewport={'width': 1280, 'height': 900}) + page.goto(url); page.wait_for_load_state('networkidle') + page.get_by_role('button', name='打开模型中心', exact=True).click() + dialog = page.get_by_role('dialog', name='模型中心', exact=True) + dialog.get_by_role('button', name='凭据保存', exact=True).click() + card = dialog.locator('.mc-connection').filter(has_text='Owned Saved Primary') + card.get_by_role('button', name='关闭自动加载', exact=True).click() + expect(card).to_contain_text('关闭自动加载') + card.get_by_role('button', name='启用自动加载', exact=True).click() + expect(card.get_by_role('button', name='关闭自动加载', exact=True)).to_be_visible() + card.get_by_role('button', name='删除本机保存', exact=True).click() + expect(card).to_contain_text('仅本次内存') + assert next(value for value in api('/model-center')['connections'] if value['id'] == saved['id'])['hasKey'] + card.get_by_role('button', name='清除该连接凭据', exact=True).click() + deadline = time.time() + 10 + while next(value for value in api('/model-center')['connections'] if value['id'] == saved['id'])['hasKey']: + if time.time() > deadline: + raise AssertionError('Credential clearing did not settle') + time.sleep(0.1) + browser.close() + mark(stage) + stage = 'plaintext leak scan over actual database, WAL, exports and host logs' + needles = [needle for key in keys for needle in [key.encode(), key.encode('utf-16le')]] + for file in data_root.rglob('*'): + if file.is_file(): + data = file.read_bytes() + assert not any(needle in data for needle in needles), str(file) + assert not any(key in json.dumps(api('/model-center')) for key in keys) + mark(stage) + assert not errors + save(True) +except Exception as error: + save(False, str(error)) + raise +finally: + fixture.shutdown(); fixture.server_close() + if started: + host('stop') diff --git a/src/client/ModelCenter.tsx b/src/client/ModelCenter.tsx index c79b69d7..3428c050 100644 --- a/src/client/ModelCenter.tsx +++ b/src/client/ModelCenter.tsx @@ -1,16 +1,19 @@ import { useEffect, useRef, useState } from 'react'; -import { Activity, Check, CircleHelp, Layers3, Plus, Power, RefreshCw, Route, Server, Settings2 } from 'lucide-react'; +import { Activity, Check, CircleHelp, KeyRound, Layers3, Plus, Power, RefreshCw, Route, Server, Settings2 } from 'lucide-react'; import { api } from './api'; import type { Config } from './types'; import './ModelCenter.css'; type Connection = { id: string; name: string; brand: string; protocol: string; baseUrl: string; model: string; enabled: boolean; revision: number; hasKey: boolean; - requiresKey: boolean; contextLimit: number; maxOutputTokens: number; concurrency: number; status: string; activeRequests: number; health: { state: string; reason?: string; cooldownUntil?: number } }; + requiresKey: boolean; contextLimit: number; maxOutputTokens: number; concurrency: number; status: string; activeRequests: number; savedCredential?: { status: string }; health: { state: string; reason?: string; cooldownUntil?: number } }; type Pool = { id?: string; name: string; members: { connectionId: string; weight: number }[]; strategy: string; sticky: boolean; maxAttempts: number; revision?: number; queueTimeoutMs: number }; type Attempt = { id: string; connectionId: string; poolId: string | null; model: string; status: string; startedAt: string; ordinal: number; usageStatus: string; reason?: string; taskId?: string; runId: string; requestArtifactId?: string; usage?: { prompt_tokens?: number; completion_tokens?: number } }; type ImportRecord = { id: string; source: string; path: string; enabled: boolean; lastCheckedAt?: string; lastSyncedAt?: string; lastError?: string; lastResult?: { imported?: number; conflicts?: string[] } }; type Center = { revision: number; selected: { type: string; id: string }; connections: Connection[]; pools: Pool[]; imports: ImportRecord[]; attempts: Attempt[]; waiting: number }; type Operations = { checkedAt: string; version: string; scope: string; activeTasks: number; queue: number; checks: { id: string; title: string; status: string; detail: string }[] }; +type SavedCredential = { id: string; name: string; revision: number; status: string; enabled?: boolean; savedAt?: string; message: string }; +type CredentialView = { supported: boolean; unavailable: boolean; connections: SavedCredential[]; scope: string }; +const savedStates: Record = { not_saved: '仅本次内存', saved: '本机加密保存', disabled: '关闭自动加载', source_changed: '配置已变化', decrypt_failed: '无法解密', user_mismatch: '用户不匹配', directory_mismatch: '目录不匹配', unavailable: '保存登记不可用' }; const states: Record = { configured: '已配置', needs_key: '待填凭据', disabled: '已停用', needs_attention: '需要处理', cooling: '冷却中', completed: '收到响应', failed: '失败', running: '请求中', unknown: '结果待核对', interrupted: '已中断', passed: '通过', attention: '待配置' }; const initial = { name: '', brand: '自定义', model: '', baseUrl: 'https://api.openai.com/v1', requiresKey: true, enabled: true, contextLimit: 16000, maxOutputTokens: 2048, concurrency: 1 }; const emptyPool: Pool = { name: '', members: [], strategy: 'round-robin', sticky: true, maxAttempts: 3, queueTimeoutMs: 15000 }; @@ -19,6 +22,8 @@ export function ModelCenter({ onConfig, onLegacy, busy }: { onConfig: (value: Co const [tab, setTab] = useState('connections'); const [draft, setDraft] = useState(initial); const [editing, setEditing] = useState(false), [key, setKey] = useState(''); + const [persistKey, setPersistKey] = useState(false), [persistImports, setPersistImports] = useState(false); + const [credentialView, setCredentialView] = useState(null), [credentialKey, setCredentialKey] = useState(''), [credentialTarget, setCredentialTarget] = useState(''); const [pool, setPool] = useState(emptyPool), [poolEditing, setPoolEditing] = useState(false); const [working, setWorking] = useState(false), [notice, setNotice] = useState(''); const [operations, setOperations] = useState(null), [autoInspect, setAutoInspect] = useState(false); @@ -26,40 +31,51 @@ export function ModelCenter({ onConfig, onLegacy, busy }: { onConfig: (value: Co const [preview, setPreview] = useState<{ id: string; entries: { id: string; name: string; model: string; baseUrl: string; hasKey: boolean }[]; notices: string[] } | null>(null); const [discovery, setDiscovery] = useState<{ source: string; path: string; available: boolean; supported: boolean; detail?: string }[]>([]); const alive = useRef(true), generation = useRef(0); + const tabsRef = useRef(null); async function refresh() { const marker = ++generation.current; const result = await api
('/model-center'); if (alive.current && marker === generation.current) setView(result); } async function act(action: () => Promise) { setWorking(true); setNotice(''); - try { await action(); if (alive.current) await refresh(); } + try { await action(); if (alive.current) { await refresh(); if (credentialView) await refreshCredentials(); } } catch (cause) { if (alive.current) setNotice(cause instanceof Error ? cause.message : '操作未完成,请刷新核对。'); } finally { if (alive.current) setWorking(false); } } async function inspect() { const value = await api('/operations'); if (alive.current) setOperations(value); } + async function refreshCredentials() { const value = await api('/model-center/credentials'); if (alive.current) setCredentialView(value); } useEffect(() => { alive.current = true; void refresh().catch(error => { if (alive.current) setNotice(error.message); }); return () => { alive.current = false; generation.current++; }; }, []); useEffect(() => { if (!autoInspect || tab !== 'operations') return; const timer = window.setInterval(() => { void inspect().catch(error => { if (alive.current) setNotice(error.message); }); }, 30000); return () => window.clearInterval(timer); }, [autoInspect, tab]); + useEffect(() => { setCredentialKey(''); if (tab === 'credentials') void refreshCredentials().catch(error => { if (alive.current) setNotice(error.message); }); }, [tab]); + useEffect(() => { + const ensureVisible = () => { const nav = tabsRef.current, button = nav?.querySelector('button[aria-current]'); if (!nav || !button) return; + const area = nav.getBoundingClientRect(), target = button.getBoundingClientRect(), start = target.left - area.left; + if (start < 0) nav.scrollLeft += start - 12; else if (start + target.width > nav.clientWidth) nav.scrollLeft += start + target.width - nav.clientWidth + 12; + }; + const frame = requestAnimationFrame(ensureVisible); window.addEventListener('resize', ensureVisible); + return () => { cancelAnimationFrame(frame); window.removeEventListener('resize', ensureVisible); }; + }, [tab]); const selected = view?.selected; const selectionName = selected?.type === 'pool' ? view?.pools.find(value => value.id === selected.id)?.name : view?.connections.find(value => value.id === selected?.id)?.name; const locked = working || busy; return
MODEL CONTROL

连接有序,执行有据。

统一管理模型服务、调度和每次真实请求。

当前路由{selectionName || '原模型连接'}{view?.waiting ?? 0} 等待
-