feat(models): persist explicitly saved credentials with user-scoped DPAPI

This commit is contained in:
Agent Workbench Dev
2026-10-31 09:30:38 +08:00
parent 249f191ebc
commit 72a496adfa
27 changed files with 857 additions and 21 deletions
+10 -2
View File
@@ -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)继续。
+6
View File
@@ -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验证。
+95
View File
@@ -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."
}
+7
View File
@@ -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
+37
View File
@@ -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."
}
+7
View File
@@ -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
+136
View File
@@ -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
@@ -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."
}
@@ -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 <module>
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)
Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB