Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b00ca7dac9 | ||
|
|
705c15eb93 | ||
|
|
1340f6c233 | ||
|
|
5aeddacfc9 | ||
|
|
453d288a6c |
No files matched your search
@@ -38,6 +38,7 @@ jobs:
|
||||
tests/dsh/test_issue_broker.py
|
||||
tests/packaging/test_dsh_runtime_staging.py
|
||||
tests/packaging/test_release_configuration.py
|
||||
tests/packaging/test_self_extracting_release.py
|
||||
--junitxml=build/ci-results.xml --tb=short
|
||||
- name: Windows release scope
|
||||
run: |
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
|
||||
面向 **Windows + DxDesigner / Expedition Enterprise 7.9.5** 的器件批量替换工具。一个工程对应一个任务,可以只替换同料号下的部分位号;支持直接编辑和 Excel BOM 导入,同批工程按顺序执行。
|
||||
|
||||
**最新版本:V1.2.1(预发布)** · [下载便携包](https://git.simgreek.com/Skyworth_Digital_Hardware/dxdesigner-part-replacement/releases/download/v1.2.1/DxPartReplace-1.2.1.zip) · [版本说明与附件](https://git.simgreek.com/Skyworth_Digital_Hardware/dxdesigner-part-replacement/releases/tag/v1.2.1) · [完整使用说明](docs/user/v1.1.0-project-tasks.md)
|
||||
**最新版本:V1.2.2(预发布)** · [自解压 EXE](https://git.simgreek.com/Skyworth_Digital_Hardware/dxdesigner-part-replacement/releases/download/v1.2.2/DxPartReplace-1.2.2.exe) · [ZIP 便携包](https://git.simgreek.com/Skyworth_Digital_Hardware/dxdesigner-part-replacement/releases/download/v1.2.2/DxPartReplace-1.2.2.zip) · [版本说明与附件](https://git.simgreek.com/Skyworth_Digital_Hardware/dxdesigner-part-replacement/releases/tag/v1.2.2) · [完整使用说明](docs/user/v1.1.0-project-tasks.md)
|
||||
|
||||
V1.2.1 提供完整 Node/Qt 运行时、DSH 任务功能和全部 UI 资源。升级前备份 data,完整更新 EXE 与 _internal,不要只替换 EXE。
|
||||
V1.2.2 新增操作历史、安全续跑与内置 7-Zip 的自解压 EXE,同时提供完整 Node/Qt 运行时、DSH 任务功能和全部 UI 资源。升级前备份 data,完整更新 EXE 与 _internal,不要只替换 EXE。
|
||||
|
||||
本版修复冻结应用缺少 SVG 资源的问题,保留维护者配置的工单上报能力,并增加云端 CI。[本版变更](docs/releases/v1.2.1.md)。
|
||||
本版合并 PR15 与 PR17,补齐操作历史和模型设置,提供自解压 EXE 与 ZIP 两种同内容发行包。[本版变更](docs/releases/v1.2.2.md)。
|
||||
|
||||
本版提供[目标封装选择](docs/user/target-cell-selection.md):目标封装可留空,此时工具不主动覆写封装,可后续与中心库同步;需要指定时,在料号规则中读取并选择合法封装。BOM 保持原 11 列。
|
||||
|
||||
@@ -24,10 +24,12 @@ DSH助手围绕真实任务中心工作,支持:
|
||||
- 发生异常时自动介入,收集脱敏证据链、保留诊断记录,并在需要时提交受限 Git 工单。
|
||||
- 在右侧任务监管中查看运行、影响、排期、经验、工单和用量;审计损坏、证据缺失和未知计数会明确显示。
|
||||
|
||||
AI 不能直接写入 CAD、运行 Shell、访问任意文件或绕过确认门禁。自动异常诊断为只读;不确定执行不会自动重放,恢复必须重新核对冻结计划、检查点和业务证据。未配置模型时仍可使用任务监管和本地恢复功能,但不会产生真实模型回复。
|
||||
AI 不能直接写入 CAD、运行 Shell 或绕过确认门禁。普通对话可按用户要求读取本地文件;自动异常诊断为只读事件快照。不确定执行不会自动重放,恢复必须重新核对冻结计划、检查点和业务证据。未配置模型时仍可使用任务监管和本地恢复功能,但不会产生真实模型回复。
|
||||
|
||||
首次接入打开 **工具设置 → 模型 → 添加模型提供商 → 自定义模型 API**,填写 API 地址、协议和密钥,点击 **获取可用模型** 并选择需要的模型,也可手动填写模型 ID。保存后在输入框下方选择模型。设置保存在任务中心数据目录的专用 Harness profile,重启会保留;主工具预配置的密钥继续由 Windows DPAPI 保护,模型设置页新增的密钥使用 Harness 本地凭据存储。开发环境也可通过 `DSH_API_BASE`、`DSH_MODEL`、`DSH_API_KEY` 临时提供配置。不要把数据目录、API key 或 Git 凭据提交到 Git。
|
||||
|
||||
对话输入框的 **+ → 文件** 可上传文本、ZIP 等文件;也可通过官方工作区入口选择本地文件夹,或直接提供路径让助手读取、搜索。ZIP 会解压到新的文件夹,返回真实路径后继续分析内容,不覆盖已有文件。启动展示直接使用 Harness 官方加载动画。
|
||||
|
||||
详细的能力边界、异常介入、证据链、排期和工单说明见 [DSH助手使用与监管说明](docs/user/dsh-ai-supervision.md)。源码环境可用下面的命令检查运行时门禁:
|
||||
|
||||
```powershell
|
||||
@@ -44,7 +46,9 @@ node tools/verify_dsh_runtime.mjs
|
||||
|
||||
### 第 1 步:解压并打开应用
|
||||
|
||||
[下载 V1.2.1 便携包](https://git.simgreek.com/Skyworth_Digital_Hardware/dxdesigner-part-replacement/releases/download/v1.2.1/DxPartReplace-1.2.1.zip),**完整解压**,双击 `DxPartReplace.exe`。保留它与 `_internal` 的相对位置,无需安装 Python;本机需要可用的 DxDesigner、许可证和中央库。
|
||||
推荐下载上方自解压 EXE,双击后选择新的解压目录,完成后运行目录内的 DxPartReplace.exe。自解压引擎已内置,无需另外安装 7-Zip,也无需通过 Windows 资源管理器解压。
|
||||
|
||||
[下载 V1.2.2 便携包](https://git.simgreek.com/Skyworth_Digital_Hardware/dxdesigner-part-replacement/releases/download/v1.2.2/DxPartReplace-1.2.2.zip),**完整解压**,双击 `DxPartReplace.exe`。保留它与 `_internal` 的相对位置,无需安装 Python;本机需要可用的 DxDesigner、许可证和中央库。
|
||||
|
||||
打开后看到下图主窗口。首次使用请准备完整的工程副本,执行前保存并关闭待处理工程。
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
# V1.2.2
|
||||
|
||||
本版本合并 PR15 的操作历史与安全续跑改进,并提供带内置 7-Zip 解压引擎的 Windows 自解压包。
|
||||
|
||||
下载 `DxPartReplace-1.2.2.exe` 可使用自解压界面选择目标目录;`DxPartReplace-1.2.2.zip` 作为同内容回退包。两种包都包含完整的 `DxPartReplace.exe`、`_internal`、DSH Node 运行时、Qt WebEngine 依赖和资源文件。
|
||||
|
||||
解压后请保留 `DxPartReplace.exe` 与 `_internal` 的相对位置。本机仍需可用的 DxDesigner、许可证和中央库。沿用旧任务前先安全退出旧版本并备份 `data`,不要同时使用不同版本打开同一数据目录。
|
||||
@@ -0,0 +1,40 @@
|
||||
# DSH 原生文件能力与加载页
|
||||
|
||||
基线:同步项目 `main@1340f6c`,包含 V1.2.2、操作历史与 UI 更新;保留已合并的 PR #17 修复。
|
||||
|
||||
## 变更
|
||||
|
||||
- 恢复官方附件栏、文件引用、目录选择、文件侧栏及其后端;普通对话开放原生 read/read_image、glob/grep、working_directory。启动检查从固定七项任务工具改为七项任务工具加六项文件能力。自动异常会话仍只接受其事件快照。
|
||||
- 增加 extract_zip,复用运行时已有的 fflate 并显式固定依赖;向新目录解压后返回真实路径、条目与截断标记。解压前检查目录越界、数量、大小、重复条目和 CRC。路径、校验或写入失败不保留本次半成品,不覆盖已有文件。支持普通 ZIP;不支持加密、多卷、ZIP64。
|
||||
- 启动直接打开固定官方前端的原版 index.html,通过其公开 __DSH_BOOT_READY__ 等待信号展示原版 HARNESS 动画。运行时就绪后进入官方 HTTP 页面并关闭本地资源访问;删除额外首页标语。没有改写上游 HTML、SVG、CSS 或动画。
|
||||
- 实测一次冷启动需 139.59 秒,原 120 秒计时器提前终止正常启动;等待上限调整到 300 秒。最终验收启动等待 30.49 秒。
|
||||
- 模型调用的文件操作追加既有工具审计,记录名称、回执和错误状态,不记录文件内容。
|
||||
|
||||
## 验证
|
||||
|
||||
- CLI:`node tools/verify_dsh_files.mjs`。先在缺少 read 能力的断言处观察失败;修复后验证中文/空格目录、读取、搜索、切换目录、ZIP 文本和二进制、重复解压不覆盖、路径越界、损坏包及 CRC 拒绝。独立审查也验证了单字节损坏的包在创建输出前被拒绝。
|
||||
- 真正上传与模型操作:`python -X utf8 tools/accept_dsh_desktop.py --output build/dsh-files-live-verified --port 9298 --provider-config <本机配置目录> --file-check --live-model`。
|
||||
- 实际点击官方 + → 文件,在真实 Qt 文件选择框输入自有文本和 ZIP 路径并点击打开;在 Harness 存储中核对两份文件字节一致。自然语言提示未指定工具名,真实测试 API 模型调用 read → extract_zip → read,三次均成功,并准确返回 `DSH_UPLOAD_CONTENT_中文`、`DSH_ZIP_UPLOAD_CONTENT_中文` 和真实解压目录。没有 CAD 操作或用户原始文件修改。
|
||||
- `build/dsh-files-live-verified/desktop-report.json`:status=passed、storedBytesMatched=true、modelToolSucceeded=true、cleanShutdown=true,uncaughtErrors=false、unexpectedUiErrors=false。官方加载、鲸鱼 SVG 动画、模型选择器、原生取消确认及导航后草稿保留通过。
|
||||
- 原版加载页实际截图:`build/dsh-files-live-verified/official-loading.png`,使用 Chromium Page.captureScreenshot 验证 HARNESS 与官方 spinner。附件截图 `file-uploaded.png`,真实回复截图 `dsh-native-final.png`。
|
||||
- Python 回归:`python -m pytest -q tests/dsh tests/packaging --tb=short` 为 217 passed、1 skipped(当前环境未指定官方 7-Zip 发布工具);`python -m pytest -q tests/ui --tb=short` 为 193 passed。合计 410 passed、1 skipped。
|
||||
- 最终 `verify_dsh_files.mjs` 还实际创建自动诊断会话,确认 read 与 extract_zip 在执行前被拒绝,避免继承普通对话的文件访问;该隔离用例不配置模型,不作自动诊断成功验证。`verify_dsh_profile_settings.mjs` 的原生配置保留、迁移与原字节备份通过。`verify_dsh_runtime.mjs` 确认 13 项预期工具、非预期工具拒绝、会话/上下文接口认证及任务中心确认门禁。
|
||||
- 最终独立代码审查未发现新增阻断问题;Python 编译、变更 JS 语法及 diff 检查通过。
|
||||
|
||||
## 验收脚本兼容
|
||||
|
||||
官方文件菜单实际名称为“文件 file”,修正选择器;CDP 发现页在总时限内重试短暂的连接超时。pytest-qt 会在 fixture 结束前删除注册窗口,UI 夹具现在检查 isValid,避免再次关闭已删除窗口;原失败单项复验通过。
|
||||
|
||||
既有协议单测的轻量 UI stub 同步增加 hide、官方加载入口和 WebEngine settings;保留原 UTF-8 分块、重启及坏行恢复断言,并检查真实 HTTP 握手后关闭本地文件访问。
|
||||
|
||||
本次未构建或分发新 EXE,不把源码与本机验收等同于发布包验收。
|
||||
|
||||
## 合并前评论 #197:文件名完整性与解压线程
|
||||
|
||||
原 fflate 异步 unzip 使用普通对象接收文件,根目录 `__proto__` 会被静默漏掉;同时每个较大的条目都可能启动一个 Worker,文件总大小上限无法限制线程数量。新增真实 Harness 回归先在“特殊文件应明确拒绝”的断言处观察失败。
|
||||
|
||||
解压现由专用 Node Worker 执行,全进程最多同时处理两个压缩包,其余排队。每包先做不解压的整包元数据预检,明确拒绝无法可靠表示的根目录 `__proto__`;再在该 Worker 中解压,核对完整名称集合、长度和 CRC 后才传回主进程写入新目录。没有在主服务线程同步解压,也不再按 ZIP 条目创建线程。活动调用取消时终止 Worker,等待退出才结算并释放槽位;排队调用取消后直接移出队列。
|
||||
|
||||
`node tools/verify_dsh_zip_review.mjs`:合法与损坏的特殊文件名均被明确拒绝,无输出目录;4 个压缩包并行、每包 20 个 600 KiB 文件,全部文件完整,恰好创建 4 个 Worker,峰值为 2;活动取消后 Worker 全部退出且不产生半成品。独立审查还验证了 5 个请求中取消一个排队请求,4 个成功、峰值 2、全部线程退出。Worker 文件会随 task-plugin 目录递归打包。
|
||||
|
||||
最终 `python -m pytest -q tests/v1_1 tests/ui tests/dsh tests/packaging --tb=short`:1463 passed、1 skipped(未指定官方 7-Zip 发布工具)、1 条 pywinauto COM 模式警告。原有真实 Harness 文件/目录/ZIP/CRC/自动会话隔离回归再次通过;最终独立审查无新增阻断发现。
|
||||
@@ -16,6 +16,16 @@
|
||||
|
||||
DSH 使用独立原生子窗口承载 WebEngine,切回任务中心后保留原有 Acrylic 玻璃材质;“减少透明度”与系统高对比度等回退规则继续生效。
|
||||
|
||||
启动时直接展示官方前端的 HARNESS 加载动画,不再绘制额外的 Qt 加载页面;运行时就绪后进入官方对话界面。
|
||||
|
||||
### 文件、文件夹与 ZIP
|
||||
|
||||
点击输入框 **+ → 文件**,在文件选择框中选取文件。上传卡片显示进度,失败可重试;上传成功后可连同问题发送。文本由助手实际读取,图片还需要所选模型支持图片输入。
|
||||
|
||||
侧栏的官方工作区入口可选择本机文件夹;也可以在对话中直接提供绝对路径,或用 `@` 引用文件。助手可以读取 UTF-8 文本、查看目录中的文件、搜索内容,并切换会话的当前目录。选择文件夹不会自动执行 CAD 或修改工程。
|
||||
|
||||
例如:“读取这个文件夹里的说明,搜索失败原因”;或上传 ZIP 后说:“解压附件,读取其中说明文件并告诉我内容”。ZIP 解压到当前目录下新建的 `dsh-extracted-*` 文件夹,也可指定一个已有输出父目录;返回绝对目录与文件清单,重复解压会创建新目录。解压前校验路径、大小和 CRC,失败不会留下可误认为成功的输出。本轮支持普通 ZIP,不支持加密、多卷及 ZIP64;压缩文件上限 64 MiB、解压总量 256 MiB、最多 10000 项。上传其他格式不等于模型已经能够解析其内容。
|
||||
|
||||
模型由本机保存的主工具配置加载;也支持启动进程的 `DSH_API_BASE`、`DSH_MODEL`、`DSH_API_KEY`。未配置模型时可查看任务上下文和操作面板,不能获得真实模型回复。
|
||||
|
||||
本机已接入测试端点 `https://wecom-test.skyworth-cloud.cn/v1/`,注册 `skyworth-deepseek-v4-flash-0731` 和 `skyworth-deepseek-v4.1-flash`,默认使用后者。本机配置位于任务中心数据目录的 `dsh/provider.json`,密钥以 Windows DPAPI 加密保存在该配置引用的 `provider-key-<版本号>.dpapi` 中,启动时自动加载;不写入仓库或 Windows 用户环境变量。旧版无版本号的 JSON 与固定 `provider-key.dpapi` 组合仍可读取,下次保存时使用新格式。
|
||||
@@ -56,7 +66,7 @@ DSH 使用独立原生子窗口承载 WebEngine,切回任务中心后保留原
|
||||
|
||||
用户在原执行轮次请求安全暂停或强制结束后,该停止意图会随轮次传递到自动诊断;即使最后一个失败项已收尾、队列结果显示“已结束”,也不会自动准备或执行重试。诊断和证据上报仍可继续。只有用户重新确认执行新轮次,才会创建新的执行控制对象;原轮次的停止记录不会被清除。
|
||||
|
||||
- 普通对话开放快照、创建、任务列表及详情、预检、任务管理、受控执行、综合监管七项能力;综合监管包含影响、运行恢复、排期、经验与工单查询。自动异常诊断会话仍只允许事件快照,其他调用在执行前被拒绝。Shell、通用文件访问、插件安装、子智能体及模型直接 CAD 写入工具均未注册;额外工具会被 guard 阻断。
|
||||
- 普通对话除七项任务能力外,开放本地文件读取、图片读取、文件发现与内容搜索、切换目录和 ZIP 解压;附件、文件引用、文件夹选择使用官方界面。自动异常诊断会话仍只允许事件快照。通用 Shell、插件安装、子智能体及模型直接 CAD 写入工具未注册;任务修改和工程执行继续走任务中心原有确认。
|
||||
- **刷新任务上下文**重新发布当前任务快照。
|
||||
- 手动点击 **准备失败项重试**须在任务中心确认,并通过现有重试按钮的状态检查;该按钮只准备重试。自动介入使用上文限定的一次重试闭环。
|
||||
- **安全暂停**须确认且当前确有执行控制器,使用原队列的安全边界暂停。
|
||||
|
||||
Generated
+2
-1
@@ -5,7 +5,8 @@
|
||||
"packages": {
|
||||
"": {
|
||||
"dependencies": {
|
||||
"@deepseek-ai/dsh": "0.2.1-rc.5"
|
||||
"@deepseek-ai/dsh": "0.2.1-rc.5",
|
||||
"fflate": "0.8.3"
|
||||
},
|
||||
"name": "dxdesigner-dsh-runtime"
|
||||
},
|
||||
|
||||
@@ -4,5 +4,5 @@
|
||||
"type": "module",
|
||||
"scripts": {"doctor": "node start.mjs --doctor", "start": "node start.mjs"},
|
||||
"engines": {"node": ">=24.9.0"},
|
||||
"dependencies": {"@deepseek-ai/dsh": "0.2.1-rc.5"}
|
||||
"dependencies": {"@deepseek-ai/dsh": "0.2.1-rc.5", "fflate": "0.8.3"}
|
||||
}
|
||||
@@ -7,6 +7,9 @@ import {isDeepStrictEqual} from 'node:util';
|
||||
import path from 'node:path';
|
||||
import {createInterface} from 'node:readline';
|
||||
|
||||
export const TASK_TOOLS=['dx_task_snapshot','dx_task_create','dx_task_catalog','dx_task_preflight','dx_task_manage','dx_task_execute','dx_task_operations'];
|
||||
export const FILE_TOOLS=['read','read_image','glob','grep','working_directory','extract_zip'];
|
||||
|
||||
const root = path.dirname(fileURLToPath(import.meta.url));
|
||||
const require = createRequire(import.meta.url);
|
||||
export const VERSION = '0.2.1-rc.5';
|
||||
@@ -14,13 +17,12 @@ export const DISABLED = [
|
||||
'preset-standard','preset-cordis','preset-minimal','preset-ptc',
|
||||
'tool-plugin-manager','plugin-manager','ui-plugin-manager','ui-settings-plugins',
|
||||
'ui-settings-plugin-inventory','ui-agent-preset','cordis-host-runner','cordis-client-runner',
|
||||
'ui-cordis','ui-sidebar-terminal','terminal-controller','ui-sidebar-files',
|
||||
'workspace-files','ui-sidebar-documentpreview','ui-sidebar-browser','office-to-pdf',
|
||||
'open-in-app','ui-open-in-app','directory-picker','ui-directory-picker-native',
|
||||
'ui-directory-picker-browse','ui-attachment','file-reference-local',
|
||||
'ui-reference','ui-skill','ui-subagent','ui-schedule','ui-goal','ui-jobs',
|
||||
'ui-cordis','ui-sidebar-terminal','terminal-controller',
|
||||
'ui-sidebar-documentpreview','ui-sidebar-browser','office-to-pdf',
|
||||
'open-in-app','ui-open-in-app',
|
||||
'ui-skill','ui-subagent','ui-schedule','ui-goal','ui-jobs',
|
||||
'ui-settings-shell','ui-settings-subagent','ui-settings-web-search','ui-settings-agent-loop',
|
||||
'ui-permission','ui-plan','plan-mode','agent-instructions','tool-working-directory',
|
||||
'ui-permission','ui-plan','plan-mode','agent-instructions',
|
||||
'tool-bash','tool-pwsh','tool-fs','tool-fs-search','tool-web','tool-skill','tool-jobs',
|
||||
'tool-schedule','tool-goal','tool-todo','tool-present','tool-workflow',
|
||||
'tool-subagent','tool-subagent-control','tool-subagent-fork',
|
||||
@@ -38,6 +40,8 @@ export function overlay() {
|
||||
rows.push({id:'agent-preset-registry',config:{default:'dx-task'}});
|
||||
rows.push({id:'ui-settings-general',config:{welcomeNoticeVersion:'2026-09-28.1'}});
|
||||
rows.push({id:'ui-settings-models',config:{credentialOnboarding:false}});
|
||||
rows.push({id:'tool-fs',disabled:false,config:{read:true,readImage:true,write:false,edit:false}});
|
||||
rows.push({id:'tool-fs-search',disabled:false,config:{sampleOverCapGlobResults:false}});
|
||||
rows.push({id:'web-runtime',config:{openBrowser:false,printUrl:false,surfaceContext:false}});
|
||||
rows.push({id:'sandbox-policy',config:{mode:'read-only',workspaceRoot:process.env.DX_DSH_WORKSPACE}});
|
||||
rows.push({id:'permission',config:{presets:{'read-only':{sandbox:'read-only',approval:'ask'}}}});
|
||||
@@ -206,7 +210,7 @@ export async function bootRuntime({announce=true} = {}) {
|
||||
await readFile(path.join(root,'task-plugin/client.js'));
|
||||
if (process.argv.includes('--doctor')) {
|
||||
console.log(JSON.stringify({status:'ready',version:VERSION,frontend:'official',
|
||||
tools:['dx_task_snapshot','dx_task_create','dx_task_catalog','dx_task_preflight','dx_task_manage','dx_task_execute','dx_task_operations'],genericTools:false,node:process.version}));
|
||||
tools:[...TASK_TOOLS,...FILE_TOOLS],fileTools:true,genericShell:false,node:process.version}));
|
||||
return;
|
||||
}
|
||||
if (!process.env.DX_DSH_HOME || !process.env.DX_DSH_CONTEXT_FILE) throw Error('Task center context is required');
|
||||
@@ -242,7 +246,7 @@ export async function bootRuntime({announce=true} = {}) {
|
||||
}
|
||||
}
|
||||
const names=ctx.tools.schemas().map(tool=>tool.name);
|
||||
if(names.length!==7 || !['dx_task_snapshot','dx_task_create','dx_task_catalog','dx_task_preflight','dx_task_manage','dx_task_execute','dx_task_operations'].every(name=>names.includes(name))) {
|
||||
if(names.length!==TASK_TOOLS.length+FILE_TOOLS.length || ![...TASK_TOOLS,...FILE_TOOLS].every(name=>names.includes(name))) {
|
||||
await shutdown.shutdown(1);
|
||||
throw Error('The task capability guard did not initialize; assistant startup refused.');
|
||||
}
|
||||
|
||||
@@ -16,7 +16,9 @@ window.__ModuleLoader__.load({id:'@dx/dsh-task',factory:require=>{
|
||||
h('p',null,'在“模型”设置页添加模型提供商或自定义模型 API,填写地址后可获取可用模型,也可手动填写模型 ID。保存后在输入框下方选择,模型设置和会话在重启后保留。'),
|
||||
h('h3',null,'异常工单'),
|
||||
h('p',null,'随工具预置专用工单上报身份,无需安装 Git 或登录。未解决的异常自动提交项目工单,并上传脱敏诊断证据。'),
|
||||
h('p',null,'工程修改与执行核验由任务中心完成。模型不直接访问工程文件或执行命令。'));
|
||||
h('h3',null,'文件与文件夹'),
|
||||
h('p',null,'可上传文件、选择本地文件夹,或在对话中提供路径。助手可读取和搜索文件,ZIP 解压到新的文件夹后继续分析;重复解压不会覆盖已有文件。'),
|
||||
h('p',null,'工程修改与执行核验由任务中心完成。'));
|
||||
}
|
||||
function SettingsLauncher({wide,openSettings}){
|
||||
return h('button',{'data-testid':'dx-tool-settings',type:'button','aria-label':'工具设置',onClick:()=>openSettings(),
|
||||
@@ -276,8 +278,6 @@ window.__ModuleLoader__.load({id:'@dx/dsh-task',factory:require=>{
|
||||
},'dx-task: automatic incident conversation');
|
||||
ctx.slots.inject('settings.launcher',()=>ctx.slots.register({name:'settings.launcher',priority:-10},SettingsLauncher));
|
||||
ctx.slots.inject('settings.section',()=>ctx.slots.register({name:'settings.section',id:'dx-tool',order:-100,label:()=>'DSH工具'},ToolSettings));
|
||||
ctx.slots.inject('conversation.hero.options',()=>ctx.slots.register({name:'conversation.hero.options',id:'dx-tool-hint'},
|
||||
()=>h('p',{style:{fontSize:13,color:'var(--dsw-alias-label-secondary)',textAlign:'center',margin:'4px 0 12px'}},'任务异常分析 · 规则内处理 · 执行监管')));
|
||||
ctx.sidebarRightTabs.register({id:'@dx/dsh-task',kind:'dx-task',priority:'extension',title:()=>'任务监管',guide:[{id:'dx-task',order:0,title:()=>'任务监管',description:()=>'当前任务与受控操作'}]});
|
||||
ctx.slots.inject('sidebar.right.pane.tab',()=>ctx.slots.register({name:'sidebar.right.pane.tab',key:'@dx/dsh-task'},TaskPanel));
|
||||
ctx.slots.inject('sidebar.brand.name',()=>ctx.slots.register({name:'sidebar.brand.name',priority:-10},()=>h('span',null,'DSH助手')));
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
import {mkdir,mkdtemp,writeFile,realpath,rm} from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import {Worker} from 'node:worker_threads';
|
||||
import {defineTool} from '@deepseek-ai/dsh-tools';
|
||||
|
||||
export const fileToolNames=['read','read_image','glob','grep','working_directory','extract_zip'];
|
||||
|
||||
const pending=[];
|
||||
let running=0;
|
||||
function startPending(){
|
||||
while(running<2&&pending.length){
|
||||
const job=pending.shift();
|
||||
if(job.signal.aborted){job.abort();continue;}
|
||||
running++;
|
||||
try{
|
||||
const bytes=Uint8Array.from(job.bytes);
|
||||
job.worker=new Worker(new URL('./zip-worker.mjs',import.meta.url),{
|
||||
workerData:{bytes,fflateUrl:import.meta.resolve('fflate')},transferList:[bytes.buffer],env:{},execArgv:[]});
|
||||
let result,failure;
|
||||
job.worker.once('message',value=>{result=value;});
|
||||
job.worker.once('error',error=>{failure=error;});
|
||||
job.worker.once('exit',code=>{
|
||||
running--;job.signal.removeEventListener('abort',job.abort);
|
||||
if(job.signal.aborted)job.reject(job.signal.reason??Error('ZIP extraction cancelled'));
|
||||
else if(failure||result?.error||code!==0||!result?.entries)
|
||||
job.reject(failure??Error(result?.error??'ZIP worker exited without a result'));
|
||||
else job.resolve(result.entries);
|
||||
startPending();
|
||||
});
|
||||
}catch(error){
|
||||
running--;job.signal.removeEventListener('abort',job.abort);job.reject(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function decompress(bytes,signal){
|
||||
signal.throwIfAborted();
|
||||
return new Promise((resolve,reject)=>{
|
||||
const job={bytes,signal,resolve,reject};
|
||||
job.abort=()=>{
|
||||
if(job.worker){void job.worker.terminate();return;}
|
||||
const index=pending.indexOf(job);if(index>=0)pending.splice(index,1);
|
||||
reject(signal.reason??Error('ZIP extraction cancelled'));
|
||||
};
|
||||
signal.addEventListener('abort',job.abort,{once:true});pending.push(job);startPending();
|
||||
});
|
||||
}
|
||||
|
||||
export function registerFileTools(ctx){
|
||||
ctx.tools.register(defineTool({name:'extract_zip',
|
||||
description:'Extract a local or uploaded ZIP archive into a new folder, returning its absolute path and file names. Relative paths use the conversation working directory. output_directory optionally selects an existing parent folder; defaults to the conversation working directory. Never overwrites existing files. Read the returned paths to inspect extracted content. ZIP only; encrypted archives are unsupported.',
|
||||
parameters:{file_path:{type:'string',required:true},output_directory:{type:'string'}},
|
||||
output:{schema:{type:'object',additionalProperties:true},render:(_args,value)=>[{type:'text',text:JSON.stringify(value)}]},
|
||||
execute:async(args,exec)=>{
|
||||
if(typeof args.file_path!=='string'||!args.file_path.trim())throw Error('file_path is required');
|
||||
const cwd=exec.agent?ctx.workingDirectory.get(exec.agent.session):process.env.DX_DSH_WORKSPACE;
|
||||
const target=await ctx.fs.resolve(args.file_path,{cwd,signal:exec.signal});
|
||||
const bytes=await ctx.fs.readBytes(target,exec.signal,64*1024*1024);
|
||||
const files=await decompress(bytes,exec.signal);
|
||||
exec.signal.throwIfAborted();
|
||||
const parent=await realpath(path.resolve(cwd,args.output_directory||'.'));
|
||||
const directory=await mkdtemp(path.join(parent,'dsh-extracted-'));
|
||||
try{
|
||||
for(const [name,data] of files){
|
||||
exec.signal.throwIfAborted();
|
||||
const output=path.resolve(directory,name.replaceAll('\\','/'));
|
||||
const relative=path.relative(directory,output);
|
||||
if(relative.startsWith('..')||path.isAbsolute(relative))throw Error('Unsafe ZIP entry path');
|
||||
if(name.endsWith('/'))await mkdir(output,{recursive:true});
|
||||
else{await mkdir(path.dirname(output),{recursive:true});await writeFile(output,data,{flag:'wx'});}
|
||||
}
|
||||
return {directory,files:files.slice(0,200).map(([name])=>name),total_entries:files.length,truncated:files.length>200};
|
||||
}catch(error){
|
||||
// Only this invocation's newly created temporary output is removed.
|
||||
if(path.dirname(directory)===parent&&path.basename(directory).startsWith('dsh-extracted-'))
|
||||
await rm(directory,{recursive:true,force:true});
|
||||
throw error;
|
||||
}
|
||||
}}));
|
||||
}
|
||||
@@ -5,8 +5,9 @@ import {defineTool} from '@deepseek-ai/dsh-tools';
|
||||
import {registerLifecycle,lifecycleNames} from './lifecycle.mjs';
|
||||
import {registerRuntimeUsage} from './runtime_usage.mjs';
|
||||
import {modelSnapshot} from './model_results.mjs';
|
||||
import {registerFileTools,fileToolNames} from './files.mjs';
|
||||
|
||||
export const inject=['webServer','connection','tools','workspaceRegistry','sessionController','agents','llm'];
|
||||
export const inject=['webServer','connection','tools','workspaceRegistry','sessionController','agents','llm','fs','workingDirectory'];
|
||||
const actions=new Set(['retry_failed','pause_task','refresh_snapshot','retry_issue','open_evidence']);
|
||||
export async function readContext(){
|
||||
const value=JSON.parse(await readFile(process.env.DX_DSH_CONTEXT_FILE,'utf8'));
|
||||
@@ -19,7 +20,7 @@ export async function apply(ctx){
|
||||
const creations=new Map();
|
||||
let auditTail=Promise.resolve();
|
||||
ctx.on('tools/result',(exec,result)=>{
|
||||
if(!['dx_task_snapshot','dx_task_create',...lifecycleNames].includes(exec.name))return;
|
||||
if(!['dx_task_snapshot','dx_task_create',...lifecycleNames,...fileToolNames].includes(exec.name))return;
|
||||
const row={at:new Date().toISOString(),name:exec.name,call_id:exec.callId,is_error:result.isError,
|
||||
task_id:result.value?.task_id||'',revision:result.value?.revision||'',
|
||||
status:result.value?.status,task_ids:result.value?.task_ids||result.value?.tasks?.map(t=>t.task_id)||[]};
|
||||
@@ -112,7 +113,8 @@ export async function apply(ctx){
|
||||
}finally{clearTimeout(timer);exec.signal.removeEventListener('abort',cancel);creations.delete(request_id);}
|
||||
}}));
|
||||
registerLifecycle(ctx);
|
||||
ctx.tools.guard(exec=>exec.name==='dx_task_snapshot'||(['dx_task_create',...lifecycleNames].includes(exec.name)&&!incidentSnapshots.has(exec.agent?.id))?
|
||||
registerFileTools(ctx);
|
||||
ctx.tools.guard(exec=>exec.name==='dx_task_snapshot'||(['dx_task_create',...lifecycleNames,...fileToolNames].includes(exec.name)&&!incidentSnapshots.has(exec.agent?.id))?
|
||||
undefined:'This tool is not enabled for this session. Automatic incident sessions may only read their snapshot.');
|
||||
const workspace=await ctx.workspaceRegistry.create(process.env.DX_DSH_WORKSPACE,'DxDesigner 任务中心');
|
||||
ctx.webServer.register({kind:'exact',path:'/dx/workspace',handler:async(req,res)=>{
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
import {parentPort,workerData} from 'node:worker_threads';
|
||||
import {crc32} from 'node:zlib';
|
||||
|
||||
function zipChecksums(bytes){
|
||||
const data=Buffer.from(bytes.buffer,bytes.byteOffset,bytes.byteLength);
|
||||
let end=data.length-22;
|
||||
for(;end>=Math.max(0,data.length-65557);end--)
|
||||
if(data.readUInt32LE(end)===0x06054b50&&end+22+data.readUInt16LE(end+20)===data.length)break;
|
||||
if(end<0||data.readUInt32LE(end)!==0x06054b50)throw Error('Invalid ZIP central directory');
|
||||
if(data.readUInt16LE(end+4)||data.readUInt16LE(end+6))throw Error('Multi-volume ZIP is unsupported');
|
||||
const count=data.readUInt16LE(end+10),entries=[];
|
||||
if(count===65535||count>10000)throw Error('ZIP exceeds 10000 entries');
|
||||
let offset=data.readUInt32LE(end+16);
|
||||
for(let i=0;i<count;i++){
|
||||
if(offset+46>end||data.readUInt32LE(offset)!==0x02014b50)throw Error('Invalid ZIP entry');
|
||||
if(data.readUInt16LE(offset+8)&1)throw Error('Encrypted ZIP is unsupported');
|
||||
const size=data.readUInt32LE(offset+24);
|
||||
if(size===0xffffffff)throw Error('ZIP64 entries are unsupported');
|
||||
entries.push({crc:data.readUInt32LE(offset+16),size});
|
||||
offset+=46+data.readUInt16LE(offset+28)+data.readUInt16LE(offset+30)+data.readUInt16LE(offset+32);
|
||||
if(offset>end)throw Error('Invalid ZIP entry length');
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
|
||||
try{
|
||||
const {unzipSync}=await import(workerData.fflateUrl);
|
||||
const bytes=workerData.bytes,checksums=zipChecksums(bytes),expected=new Map();
|
||||
let expanded=0,count=0;
|
||||
// A metadata-only pass finishes before any entry is decompressed.
|
||||
unzipSync(bytes,{filter:entry=>{
|
||||
const name=entry.name.replaceAll('\\','/');
|
||||
if(name.startsWith('/')||name.split('/').some(part=>part==='..'||/[\x00-\x1f:]/.test(part)))
|
||||
throw Error('Unsafe ZIP entry path');
|
||||
if(entry.name==='__proto__')throw Error('Unsupported ZIP entry name: __proto__');
|
||||
if(expected.has(entry.name))throw Error('Duplicate ZIP entry');
|
||||
const checksum=checksums[count];
|
||||
if(!checksum||checksum.size!==entry.originalSize)throw Error('Invalid ZIP entry size');
|
||||
expected.set(entry.name,checksum);
|
||||
expanded+=entry.originalSize;
|
||||
if(++count>10000||expanded>256*1024*1024)throw Error('ZIP exceeds 10000 entries or 256 MiB expanded size');
|
||||
return false;
|
||||
}});
|
||||
if(count!==checksums.length)throw Error('Invalid ZIP entry count');
|
||||
// Synchronous inflation is confined to this single, terminable worker.
|
||||
const files=unzipSync(bytes),entries=Object.entries(files);
|
||||
if(entries.length!==expected.size||[...expected.keys()].some(name=>!Object.hasOwn(files,name)))
|
||||
throw Error('ZIP decompressed file names do not match the archive');
|
||||
for(const [name,data] of entries){
|
||||
const checksum=expected.get(name);
|
||||
if(!checksum||data.length!==checksum.size||crc32(data)!==checksum.crc)throw Error('ZIP checksum mismatch: '+name);
|
||||
}
|
||||
parentPort.postMessage({entries},[...new Set(entries.map(([,data])=>data.buffer))]);
|
||||
}catch(error){parentPort.postMessage({error:error.message});}
|
||||
finally{parentPort.close();}
|
||||
@@ -33,6 +33,12 @@ legacy_runtime_datas = [
|
||||
|
||||
# The native assistant loads the official web UI; include its pinned Node runtime.
|
||||
dsh_root = project_root / 'integration' / 'dsh'
|
||||
for required in ('node_modules/@deepseek-ai/dsh/package.json', 'issue-bootstrap.json',
|
||||
'start.mjs', 'package.json', 'task-plugin/host.mjs'):
|
||||
if not (dsh_root / required).is_file():
|
||||
raise RuntimeError(f'Complete DSH release runtime is required; missing: {required}')
|
||||
if shutil.which('node') is None:
|
||||
raise RuntimeError('Node executable is required for the complete release')
|
||||
if (dsh_root / 'issue-bootstrap.json').is_file():
|
||||
legacy_runtime_datas.append((str(dsh_root / 'issue-bootstrap.json'), 'dsh-runtime'))
|
||||
if (dsh_root / 'node_modules' / '@deepseek-ai' / 'dsh' / 'package.json').is_file():
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
# Windows self-extracting release
|
||||
|
||||
Build the complete application with `Build-DxPartReplace.ps1` first. The spec now fails if the installed DSH package, reporter configuration or Node executable is missing. Keep the entire installed `integration/dsh/node_modules` tree, including lazy runtime dependencies.
|
||||
|
||||
Use the official **7-Zip 26.05 x64** tools from:
|
||||
|
||||
- Binary: https://github.com/ip7z/7zip/releases/download/26.05/7z2605-x64.exe
|
||||
- SHA256: `fd99e86f57d8f429ef5ed045bf98315af962e2309b0f1ba87a147a44c71647d0`
|
||||
- Source and license: https://github.com/ip7z/7zip/releases/tag/26.05 and https://www.7-zip.org/license.txt
|
||||
|
||||
Extract the installer with an existing 7-Zip tool into a build-only directory. No machine-wide installation is needed. Use that directory's `7z.exe`, `7z.dll`, `7z.sfx` and `License.txt`. The standard `7z.sfx` opens a destination selector and extracts to a persistent directory. It is not the install-to-temp SFX module; it takes no installer configuration and does not auto-launch or delete the extracted application.
|
||||
|
||||
```powershell
|
||||
python tools/build_self_extracting_release.py --source-dir dist/DxPartReplace --output-dir G:/dx-release-1.2.2 --version 1.2.2 --seven-zip build/7zip-2605/full/7z.exe --sfx-stub build/7zip-2605/full/7z.sfx --license build/7zip-2605/full/License.txt
|
||||
```
|
||||
|
||||
Use a fresh output directory and keep the completed build input unchanged during packaging. The tool rejects an existing directory, overlapping input/output paths and an application input containing `data`. It stages the complete input using same-volume hardlinks (copying when links are unavailable), includes the 7-Zip license, produces independent EXE + ZIP archives, and writes artifact and per-file SHA256 hashes. LZMA2 level 3 and bounded solid blocks keep decoding memory modest; tiny files still incur filesystem costs, so do not promise a fixed speedup across machines.
|
||||
|
||||
Before publishing, run the self-extracting EXE itself with `-y -o<fresh directory>`, compare every resulting file and every ZIP member against the manifest, and run `tools/verify_packaged_runtime.py` and Qt/DSH UI acceptance on that extracted EXE. Neither merely listing the archive nor the source UI tests replaces this check.
|
||||
|
||||
The optional Windows integration test exercises the real SFX with Chinese/spaced paths and empty/binary files. Set `DX_SFX_TEST_TOOLS` to the official tools directory and run `python -m pytest tests/packaging/test_self_extracting_release.py`. Linux CI runs the portable output-protection checks and explicitly skips the Windows integration.
|
||||
@@ -1,8 +1,8 @@
|
||||
# UTF-8
|
||||
VSVersionInfo(
|
||||
ffi=FixedFileInfo(
|
||||
filevers=(1, 2, 1, 0),
|
||||
prodvers=(1, 2, 1, 0),
|
||||
filevers=(1, 2, 2, 0),
|
||||
prodvers=(1, 2, 2, 0),
|
||||
mask=0x3f,
|
||||
flags=0x2,
|
||||
OS=0x40004,
|
||||
@@ -15,11 +15,11 @@ VSVersionInfo(
|
||||
StringTable('040904B0', [
|
||||
StringStruct('CompanyName', 'DxProductivity'),
|
||||
StringStruct('FileDescription', 'DxDesigner Part Replacement'),
|
||||
StringStruct('FileVersion', '1.2.1.0'),
|
||||
StringStruct('FileVersion', '1.2.2.0'),
|
||||
StringStruct('InternalName', 'DxPartReplace'),
|
||||
StringStruct('OriginalFilename', 'DxPartReplace.exe'),
|
||||
StringStruct('ProductName', 'DxDesigner Part Replacement'),
|
||||
StringStruct('ProductVersion', '1.2.1')
|
||||
StringStruct('ProductVersion', '1.2.2')
|
||||
])
|
||||
]),
|
||||
VarFileInfo([VarStruct('Translation', [1033, 1200])])
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "dx-productivity"
|
||||
version = "1.2.1"
|
||||
version = "1.2.2"
|
||||
requires-python = ">=3.12,<3.13"
|
||||
dependencies = ["PySide6>=6.7,<7", "pywin32>=306", "pywinauto>=0.6.9,<1", "openpyxl>=3.1,<4"]
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import codecs
|
||||
from pathlib import Path
|
||||
|
||||
from PySide6.QtCore import QProcess, QProcessEnvironment, QTimer, QUrl, Signal, Qt
|
||||
from PySide6.QtWebEngineCore import QWebEnginePage, QWebEngineProfile, QWebEngineSettings
|
||||
from PySide6.QtWebEngineCore import QWebEnginePage, QWebEngineProfile, QWebEngineSettings, QWebEngineScript
|
||||
from PySide6.QtWebEngineWidgets import QWebEngineView
|
||||
from PySide6.QtWidgets import QLabel, QPushButton, QVBoxLayout, QWidget
|
||||
from shiboken6 import isValid
|
||||
@@ -17,9 +17,10 @@ from ...dsh.snapshot import TaskSnapshot
|
||||
|
||||
class LocalHarnessPage(QWebEnginePage):
|
||||
allowed_port = None
|
||||
loading_url = QUrl()
|
||||
|
||||
def acceptNavigationRequest(self, url, kind, is_main_frame):
|
||||
return url.scheme() == 'about' or (url.scheme() == 'http' and url.host() == '127.0.0.1' and url.port() == self.allowed_port)
|
||||
return (url == self.loading_url and url.scheme() == 'file') or url.scheme() == 'about' or (url.scheme() == 'http' and url.host() == '127.0.0.1' and url.port() == self.allowed_port)
|
||||
|
||||
def createWindow(self, _kind):
|
||||
return None
|
||||
@@ -64,10 +65,17 @@ class NativeHarnessView(QWidget):
|
||||
self.profile.setCachePath(str(self.data_root / 'browser/cache'))
|
||||
self.profile.setPersistentCookiesPolicy(QWebEngineProfile.PersistentCookiesPolicy.NoPersistentCookies)
|
||||
self.web.setPage(LocalHarnessPage(self.profile, self.web))
|
||||
bootstrap = QWebEngineScript()
|
||||
bootstrap.setName('Official Harness loading until local runtime is ready')
|
||||
bootstrap.setInjectionPoint(QWebEngineScript.InjectionPoint.DocumentCreation)
|
||||
bootstrap.setWorldId(QWebEngineScript.ScriptWorldId.MainWorld)
|
||||
bootstrap.setSourceCode("if(location.protocol==='file:'){globalThis.__DSH_BOOT_READY__={promise:new Promise(()=>{})};}")
|
||||
self.web.page().scripts().insert(bootstrap)
|
||||
self.web.settings().setAttribute(QWebEngineSettings.WebAttribute.JavascriptCanOpenWindows, False)
|
||||
self.web.settings().setAttribute(QWebEngineSettings.WebAttribute.LocalContentCanAccessFileUrls, False)
|
||||
self.status = QLabel('正在启动 DSH助手…')
|
||||
self.status.setWordWrap(True)
|
||||
self.status.hide()
|
||||
self.retry = QPushButton('重试启动')
|
||||
self.retry.hide()
|
||||
self.retry.clicked.connect(self.start)
|
||||
@@ -140,9 +148,9 @@ class NativeHarnessView(QWidget):
|
||||
return
|
||||
self._stopping = False
|
||||
self._started = False
|
||||
self.status.setText('正在加载 DeepSeek Harness 官方界面…')
|
||||
self.status.show()
|
||||
self.status.hide()
|
||||
self.retry.hide()
|
||||
self._show_official_loading(root)
|
||||
env = QProcessEnvironment()
|
||||
try:
|
||||
for key, value in launch_environment(self.data_root).items():
|
||||
@@ -156,7 +164,16 @@ class NativeHarnessView(QWidget):
|
||||
self.process.setProgram(node)
|
||||
self.process.setArguments([str(root / 'start.mjs')])
|
||||
self.process.start()
|
||||
self.timeout.start(120000)
|
||||
# Cold startup of the official file plugins can exceed two minutes.
|
||||
self.timeout.start(300000)
|
||||
|
||||
def _show_official_loading(self, root: Path):
|
||||
frontend = root / 'node_modules/@deepseek-ai/dsh-web-frontend/dist/index.html'
|
||||
if frontend.is_file():
|
||||
self.web.page().loading_url = QUrl.fromLocalFile(str(frontend.resolve()))
|
||||
self.web.settings().setAttribute(QWebEngineSettings.WebAttribute.LocalContentCanAccessFileUrls, True)
|
||||
self.web.show()
|
||||
self.web.load(self.web.page().loading_url)
|
||||
|
||||
def _reset_output(self):
|
||||
self._buffer = ''
|
||||
@@ -187,6 +204,7 @@ class NativeHarnessView(QWidget):
|
||||
self.web.page().allowed_port = url.port()
|
||||
self.timeout.stop()
|
||||
self.status.hide()
|
||||
self.web.settings().setAttribute(QWebEngineSettings.WebAttribute.LocalContentCanAccessFileUrls, False)
|
||||
self.web.load(url)
|
||||
self.ready.emit()
|
||||
queued, self._diagnosis_queue = self._diagnosis_queue, []
|
||||
@@ -220,6 +238,7 @@ class NativeHarnessView(QWidget):
|
||||
self.timeout.stop()
|
||||
self.status.setText(text)
|
||||
self.status.show()
|
||||
self.web.hide()
|
||||
self.retry.show()
|
||||
|
||||
def _finished(self, *_):
|
||||
|
||||
@@ -1 +1 @@
|
||||
VERSION = "1.2.1"
|
||||
VERSION = "1.2.2"
|
||||
@@ -0,0 +1,81 @@
|
||||
from pathlib import Path
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import zipfile
|
||||
|
||||
import pytest
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
sys.path.insert(0, str(ROOT / 'tools'))
|
||||
from build_self_extracting_release import build_release
|
||||
from verify_self_extracting_release import verify
|
||||
|
||||
|
||||
def test_release_refuses_existing_output_without_deleting_it(tmp_path):
|
||||
source = tmp_path / 'app'
|
||||
source.mkdir()
|
||||
output = tmp_path / 'valuable'
|
||||
output.mkdir()
|
||||
sentinel = output / 'keep.txt'
|
||||
sentinel.write_text('user files')
|
||||
tool = tmp_path / 'tool.exe'
|
||||
tool.write_bytes(b'MZ')
|
||||
with pytest.raises((FileExistsError, ValueError)):
|
||||
build_release(source, output, version='1.2.2', seven_zip=tool, sfx_stub=tool)
|
||||
assert sentinel.read_text() == 'user files'
|
||||
|
||||
|
||||
def test_release_rejects_output_inside_source(tmp_path):
|
||||
source = tmp_path / 'app'
|
||||
source.mkdir()
|
||||
tool = tmp_path / 'tool.exe'
|
||||
tool.write_bytes(b'MZ')
|
||||
with pytest.raises(ValueError, match='inside'):
|
||||
build_release(source, source / 'out', version='1.2.2', seven_zip=tool, sfx_stub=tool)
|
||||
assert not (source / 'out').exists()
|
||||
|
||||
|
||||
def test_release_refuses_user_data_in_payload(tmp_path):
|
||||
source = tmp_path / 'app'
|
||||
(source / 'data').mkdir(parents=True)
|
||||
(source / 'data' / 'tasks.db').write_bytes(b'private')
|
||||
tool = tmp_path / 'tool.exe'
|
||||
tool.write_bytes(b'MZ')
|
||||
with pytest.raises(ValueError, match='data'):
|
||||
build_release(source, tmp_path / 'out', version='1.2.2', seven_zip=tool, sfx_stub=tool)
|
||||
assert not (tmp_path / 'out').exists()
|
||||
|
||||
|
||||
@pytest.mark.skipif(os.name != 'nt' or not os.environ.get('DX_SFX_TEST_TOOLS'),
|
||||
reason='Windows and explicit official 7-Zip tools required')
|
||||
def test_actual_sfx_and_zip_extract_identical_unicode_and_empty_files(tmp_path):
|
||||
tools = Path(os.environ['DX_SFX_TEST_TOOLS']).resolve()
|
||||
source = tmp_path / 'payload'
|
||||
source.mkdir()
|
||||
(source / 'DxPartReplace.exe').write_bytes(b'sample application')
|
||||
(source / '中文 目录').mkdir()
|
||||
(source / '中文 目录' / '空.txt').write_bytes(b'')
|
||||
(source / '中文 目录' / 'file.bin').write_bytes(bytes(range(256)) * 2048)
|
||||
(source / 'licenses').mkdir()
|
||||
original_license=source/'licenses'/'7-Zip-LICENSE.txt'
|
||||
original_license.write_text('original input must remain unchanged')
|
||||
output = tmp_path / 'release'
|
||||
manifest = build_release(source, output, version='1.2.2', seven_zip=tools/'7z.exe',
|
||||
sfx_stub=tools/'7z.sfx', license_path=tools/'License.txt')
|
||||
assert original_license.read_text() == 'original input must remain unchanged'
|
||||
destination = tmp_path / '解压 结果'
|
||||
result = verify(output/'release-manifest-1.2.2.json', destination)
|
||||
assert result['passed'] and result['files'] == 4
|
||||
with zipfile.ZipFile(output/'DxPartReplace-1.2.2.zip') as archive:
|
||||
assert archive.testzip() is None
|
||||
assert {p.relative_to(destination).as_posix() for p in destination.rglob('*') if p.is_file()} == set(archive.namelist())
|
||||
assert len(archive.namelist()) == 4 == manifest['file_count']
|
||||
for name in archive.namelist():
|
||||
assert (destination/name).read_bytes() == archive.read(name)
|
||||
assert (destination/'DxPartReplace'/'中文 目录'/'file.bin').read_bytes() == bytes(range(256))*2048
|
||||
with (output/'DxPartReplace-1.2.2.exe').open('ab') as stream:
|
||||
stream.write(b'corrupt download')
|
||||
with pytest.raises(ValueError, match='Artifact checksum'):
|
||||
verify(output/'release-manifest-1.2.2.json', tmp_path/'corrupt-extraction')
|
||||
assert not (tmp_path/'corrupt-extraction').exists()
|
||||
@@ -5,6 +5,7 @@ from types import SimpleNamespace
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import pytest
|
||||
from shiboken6 import isValid
|
||||
from dx_productivity.trial_task_center.logging_setup import configure_logging
|
||||
from dx_productivity.trial_task_center.store import TaskStore
|
||||
from dx_productivity.trial_task_center.service import TaskCenterService
|
||||
@@ -45,4 +46,9 @@ def ui(qtbot, tmp_path):
|
||||
open_task(tasks[0])
|
||||
yield SimpleNamespace(window=window,service=service,store=store,tasks=tasks,
|
||||
calls=calls,settle=settle,open=open_task,data=data)
|
||||
settle();window.plan_panel.discard_all();window.close();store.close()
|
||||
if isValid(window):
|
||||
settle()
|
||||
if isValid(window):
|
||||
window.plan_panel.discard_all()
|
||||
window.close()
|
||||
store.close()
|
||||
@@ -201,7 +201,8 @@ def test_runtime_restart_discards_partial_protocol_and_utf8_characters(qtbot,tmp
|
||||
setattr(state.process,method,lambda *args:None)
|
||||
state.is_running=False
|
||||
state.data_root=tmp_path
|
||||
state.status=SimpleNamespace(setText=lambda *args:None,show=lambda:None)
|
||||
state.status=SimpleNamespace(setText=lambda *args:None,show=lambda:None,hide=lambda:None)
|
||||
state._show_official_loading=lambda root:None
|
||||
state.retry=SimpleNamespace(hide=lambda:None)
|
||||
state.timeout=SimpleNamespace(start=lambda *args:None)
|
||||
package=tmp_path/'node_modules/@deepseek-ai/dsh/package.json'
|
||||
@@ -264,7 +265,9 @@ def test_bad_line_does_not_block_following_local_runtime_handshake(qtbot):
|
||||
state,chunks=protocol_state(qtbot)
|
||||
loaded=[];ready=[]
|
||||
page=SimpleNamespace(allowed_port=None)
|
||||
state.web=SimpleNamespace(page=lambda:page,load=loaded.append)
|
||||
settings_calls=[]
|
||||
state.web=SimpleNamespace(page=lambda:page,load=loaded.append,
|
||||
settings=lambda:SimpleNamespace(setAttribute=lambda *args:settings_calls.append(args)))
|
||||
state.timeout=SimpleNamespace(stop=lambda:None)
|
||||
state.status=SimpleNamespace(hide=lambda:None)
|
||||
state._diagnosis_queue=[]
|
||||
@@ -273,4 +276,5 @@ def test_bad_line_does_not_block_following_local_runtime_handshake(qtbot):
|
||||
NativeHarnessView._stdout(state)
|
||||
assert state._started and ready==[True]
|
||||
assert page.allowed_port==12345
|
||||
assert settings_calls[-1][1] is False
|
||||
assert [url.toString()for url in loaded]==['http://127.0.0.1:12345/']
|
||||
@@ -33,6 +33,7 @@ def main():
|
||||
parser.add_argument('--provider-config', type=Path)
|
||||
parser.add_argument('--live-model', action='store_true')
|
||||
parser.add_argument('--model-settings-check', action='store_true', help='Create an isolated custom provider using a local model-list fixture')
|
||||
parser.add_argument('--file-check', action='store_true', help='Pick and upload a real local text file and ZIP in the official UI')
|
||||
parser.add_argument('--incident', action='store_true', help='Inject a read-only controlled failure and verify automatic diagnosis and Git escalation')
|
||||
parser.add_argument('--outbox-only', action='store_true', help='Verify failed publication stays in local outbox without creating another real issue')
|
||||
parser.add_argument('--without-git', action='store_true', help='Simulate a client with no Git credentials or executable')
|
||||
@@ -40,6 +41,13 @@ def main():
|
||||
args = parser.parse_args()
|
||||
output = args.output.resolve()
|
||||
output.mkdir(parents=True, exist_ok=True)
|
||||
if args.file_check:
|
||||
import zipfile
|
||||
fixtures = output / 'file-fixtures'
|
||||
fixtures.mkdir(exist_ok=True)
|
||||
(fixtures / 'dsh-upload.txt').write_text('DSH_UPLOAD_CONTENT_中文\n', encoding='utf8')
|
||||
with zipfile.ZipFile(fixtures / 'dsh-upload.zip', 'w', zipfile.ZIP_DEFLATED) as archive:
|
||||
archive.writestr('中文目录/说明.txt', 'DSH_ZIP_UPLOAD_CONTENT_中文')
|
||||
data = output / ('data-' + time.strftime('%Y%m%d-%H%M%S'))
|
||||
project_root = output / 'source-projects'
|
||||
source_hashes = {}
|
||||
@@ -65,14 +73,16 @@ def main():
|
||||
os.environ.pop('QT_QPA_PLATFORM', None)
|
||||
from PySide6.QtCore import QTimer, Qt
|
||||
from PySide6.QtTest import QTest
|
||||
from PySide6.QtWidgets import QApplication, QMessageBox, QDialogButtonBox
|
||||
from PySide6.QtWidgets import QApplication, QMessageBox, QDialogButtonBox, QFileDialog, QLineEdit
|
||||
if args.file_check:
|
||||
QApplication.setAttribute(Qt.ApplicationAttribute.AA_DontUseNativeDialogs)
|
||||
from dx_productivity.trial_task_center import application
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
from dx_productivity.trial_task_center.ui.dsh_task_creation import DshTaskCreationDialog
|
||||
|
||||
report = {'driver': 'Qt QTest mouse clicks + Chromium CDP Input events', 'checks': []}
|
||||
state = {'phase': 'select', 'child': None, 'creation_step': 'input',
|
||||
'deadline': time.monotonic() + (420 if args.incident else 300 if args.create_task else 240 if args.live_model else 150)}
|
||||
'deadline': time.monotonic() + (600 if args.file_check else 420 if args.incident else 300 if args.create_task else 240 if args.live_model else 150)}
|
||||
|
||||
def build_window(service):
|
||||
if not args.create_task:
|
||||
@@ -91,6 +101,8 @@ def main():
|
||||
|
||||
def failed(error):
|
||||
report.update(status='failed', error=type(error).__name__ + ': ' + str(error))
|
||||
if window._dsh_view is not None:
|
||||
report['runtimeStatus'] = window._dsh_view.status.text()
|
||||
(output / 'desktop-report.json').write_text(json.dumps(report, ensure_ascii=False, indent=2), encoding='utf8')
|
||||
child = state['child']
|
||||
if child and child.poll() is None:
|
||||
@@ -102,7 +114,43 @@ def main():
|
||||
try:
|
||||
if time.monotonic() > state['deadline']:
|
||||
raise TimeoutError('Native desktop acceptance timed out')
|
||||
if state['phase'] == 'ready' and window._dsh_view is not None and window._dsh_view.retry.isVisible():
|
||||
from dx_productivity.dsh.provider_config import load_provider
|
||||
key = load_provider(data / 'dsh').get('DSH_API_KEY', '')
|
||||
diagnostic = window._dsh_view.last_error
|
||||
if key:
|
||||
diagnostic = diagnostic.replace(key, '[redacted]')
|
||||
report['startupDiagnostic'] = diagnostic[-8000:]
|
||||
raise RuntimeError(window._dsh_view.status.text())
|
||||
modal = QApplication.activeModalWidget()
|
||||
if state['phase'] == 'ready' and window._dsh_view is not None and not report.get('officialLoadingPassed') and not state.get('checkingLoading'):
|
||||
state['checkingLoading'] = True
|
||||
def loading_ready(value):
|
||||
state['checkingLoading'] = False
|
||||
if value and not report.get('officialLoadingPassed'):
|
||||
assert not window._dsh_view.status.isVisible()
|
||||
report['officialLoadingPassed'] = True
|
||||
state['loadingCapture'] = subprocess.Popen(['node', str(REPO / 'tools/dsh_cdp.mjs'),
|
||||
'--capture-loading', str(args.port), str(output / 'official-loading.png')],
|
||||
cwd=REPO, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
creationflags=subprocess.CREATE_NO_WINDOW if os.name == 'nt' else 0)
|
||||
report['checks'].append('unmodified official frontend HARNESS loading spinner rendered before local runtime readiness')
|
||||
window._dsh_view.web.page().runJavaScript("!!document.querySelector('[data-dsh-boot] [data-dsh-boot-spinner]')", loading_ready)
|
||||
if args.file_check and isinstance(modal, QFileDialog) and not modal.property('dshAcceptancePicked'):
|
||||
modal.setProperty('dshAcceptancePicked', True)
|
||||
selected = (output / 'file-picker-request.json')
|
||||
assert selected.is_file(), 'Unexpected file picker'
|
||||
files = json.loads(selected.read_text(encoding='utf8'))
|
||||
edit = modal.findChild(QLineEdit, 'fileNameEdit')
|
||||
assert edit is not None
|
||||
QApplication.clipboard().setText(' '.join('"' + str(Path(f).resolve()) + '"' for f in files))
|
||||
edit.setFocus()
|
||||
QTest.keyClick(edit, Qt.Key.Key_A, Qt.KeyboardModifier.ControlModifier)
|
||||
QTest.keyClick(edit, Qt.Key.Key_V, Qt.KeyboardModifier.ControlModifier)
|
||||
buttons = modal.findChild(QDialogButtonBox)
|
||||
assert buttons is not None
|
||||
QTest.mouseClick(buttons.button(QDialogButtonBox.StandardButton.Open), Qt.MouseButton.LeftButton)
|
||||
report['checks'].append('selected owned text and ZIP fixtures in the real Qt file picker and clicked Open')
|
||||
if args.create_task and isinstance(modal, DshTaskCreationDialog):
|
||||
if state['creation_step'] == 'input':
|
||||
assert modal.name_edit.text() == 'DSH对话换料验收'
|
||||
@@ -124,6 +172,7 @@ def main():
|
||||
assert window.task_list.list.count() == 0
|
||||
click_navigation(window.dsh_action)
|
||||
state['phase'] = 'ready'
|
||||
state['runtimeWaitStarted'] = time.monotonic()
|
||||
report['checks'].append('opened native assistant from an empty task center')
|
||||
elif state['phase'] == 'select' and window.task_list.list.count() and not window._task_query.busy:
|
||||
item = window.task_list.list.item(0)
|
||||
@@ -142,13 +191,18 @@ def main():
|
||||
assert window.content_stack.currentWidget() is window._dsh_view
|
||||
report['checks'].append('clicked task row and opened DSH with one click on the right navigation item')
|
||||
state['phase'] = 'ready'
|
||||
state['runtimeWaitStarted'] = time.monotonic()
|
||||
elif state['phase'] == 'ready' and window._dsh_view is not None and window._dsh_view._started:
|
||||
if 'runtimeWaitStarted' in state:
|
||||
report['runtimeWaitSeconds'] = round(time.monotonic() - state['runtimeWaitStarted'], 2)
|
||||
script = 'verify_dsh_task_creation_ui.mjs' if args.create_task else 'verify_dsh_incident_ui.mjs' if args.incident else 'verify_dsh_native_ui.mjs'
|
||||
command = ['node', str(REPO / 'tools' / script), str(output), str(args.port), '--confirm-cancel']
|
||||
if args.live_model:
|
||||
command.append('--live-model')
|
||||
if args.model_settings_check:
|
||||
command.append('--model-settings-check')
|
||||
if args.file_check:
|
||||
command.append('--file-check')
|
||||
if args.outbox_only:
|
||||
command.append('--outbox-only')
|
||||
state['child'] = subprocess.Popen(command, cwd=REPO, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
@@ -215,6 +269,14 @@ def main():
|
||||
|
||||
application._load_window = lambda: build_window
|
||||
code = application.main(['--data-root', str(data)])
|
||||
capture = state.get('loadingCapture')
|
||||
if capture is not None:
|
||||
try:
|
||||
capture.communicate(timeout=5)
|
||||
except subprocess.TimeoutExpired:
|
||||
capture.terminate()
|
||||
capture.communicate(timeout=5)
|
||||
report['officialLoadingScreenshot'] = capture.returncode == 0
|
||||
if code or report.get('status') != 'passed':
|
||||
print(json.dumps(report, ensure_ascii=False))
|
||||
return 1
|
||||
@@ -226,8 +288,8 @@ def main():
|
||||
audit_file = data / 'dsh/harness-home/task-tool-audit.jsonl'
|
||||
audit = [json.loads(line) for line in audit_file.read_text(encoding='utf8').splitlines()] if audit_file.is_file() else []
|
||||
report['modelToolCalls'] = audit
|
||||
expected_tool = 'dx_task_create' if args.create_task else 'dx_task_snapshot'
|
||||
report['modelToolSucceeded'] = any(row['name'] == expected_tool and row['is_error'] is False for row in audit)
|
||||
expected_tools = ['read', 'extract_zip'] if args.file_check else ['dx_task_create' if args.create_task else 'dx_task_snapshot']
|
||||
report['modelToolSucceeded'] = all(any(row['name'] == name and row['is_error'] is False for row in audit) for name in expected_tools)
|
||||
(output / 'desktop-report.json').write_text(json.dumps(report, ensure_ascii=False, indent=2), encoding='utf8')
|
||||
print(json.dumps(report, ensure_ascii=True))
|
||||
return 0 if report['cleanShutdown'] and not report['uncaughtErrors'] and not report['unexpectedUiErrors'] and (not (args.live_model or args.incident or args.create_task) or report['modelToolSucceeded']) else 1
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
"""Create the ZIP and 7-Zip self-extracting artifacts for a release."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import zipfile
|
||||
|
||||
from self_extracting_release import build_sfx
|
||||
|
||||
|
||||
def _sha256(path: Path) -> str:
|
||||
digest = hashlib.sha256()
|
||||
with path.open("rb") as stream:
|
||||
for chunk in iter(lambda: stream.read(1024 * 1024), b""):
|
||||
digest.update(chunk)
|
||||
return digest.hexdigest()
|
||||
|
||||
|
||||
def _zip_tree(source: Path, output: Path) -> int:
|
||||
files = 0
|
||||
with zipfile.ZipFile(output, "x", compression=zipfile.ZIP_DEFLATED, compresslevel=6, allowZip64=True) as archive:
|
||||
for path in sorted(source.rglob("*")):
|
||||
if path.is_file():
|
||||
archive.write(path, path.relative_to(source.parent).as_posix())
|
||||
files += 1
|
||||
return files
|
||||
|
||||
|
||||
def _stage_file(source, destination):
|
||||
# Release input is immutable during packaging. Same-volume links avoid a
|
||||
# second copy of tens of thousands of runtime files; archives are independent.
|
||||
try:
|
||||
os.link(source, destination)
|
||||
except OSError:
|
||||
shutil.copyfile(source, destination)
|
||||
return destination
|
||||
|
||||
|
||||
def build_release(source_dir: Path, output_dir: Path, *, version: str, seven_zip: Path, sfx_stub: Path,
|
||||
license_path: Path | None = None) -> dict:
|
||||
source_dir = Path(source_dir).resolve(strict=True)
|
||||
output_dir = Path(output_dir).resolve()
|
||||
if not source_dir.is_dir():
|
||||
raise ValueError("source_dir must be a directory")
|
||||
if output_dir.is_relative_to(source_dir) or source_dir.is_relative_to(output_dir):
|
||||
raise ValueError('Output must not be inside or contain the source directory')
|
||||
if (source_dir / 'data').exists():
|
||||
raise ValueError('Release input must not include user data')
|
||||
if not re.fullmatch(r'[0-9]+\.[0-9]+\.[0-9]+(?:-[A-Za-z0-9.]+)?', version):
|
||||
raise ValueError('Invalid release version')
|
||||
seven_zip = Path(seven_zip).resolve(strict=True)
|
||||
sfx_stub = Path(sfx_stub).resolve(strict=True)
|
||||
output_dir.mkdir(parents=True, exist_ok=False)
|
||||
|
||||
staging = output_dir / "staging" / "DxPartReplace"
|
||||
shutil.copytree(source_dir, staging, copy_function=_stage_file)
|
||||
if license_path is not None:
|
||||
license_target = staging / "licenses" / "7-Zip-LICENSE.txt"
|
||||
license_target.parent.mkdir(parents=True, exist_ok=True)
|
||||
# Break a possible staging hardlink before replacing a pre-existing notice.
|
||||
license_target.unlink(missing_ok=True)
|
||||
shutil.copyfile(Path(license_path).resolve(strict=True), license_target)
|
||||
|
||||
archive_7z = output_dir / f"DxPartReplace-{version}.7z"
|
||||
subprocess.run([
|
||||
str(seven_zip), "a", "-t7z", "-mx=3", "-m0=LZMA2", "-mmt=4", "-ms=64m",
|
||||
str(archive_7z), "DxPartReplace"
|
||||
], cwd=staging.parent, check=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True,
|
||||
timeout=3600)
|
||||
|
||||
zip_path = output_dir / f"DxPartReplace-{version}.zip"
|
||||
file_count = _zip_tree(staging, zip_path)
|
||||
sfx_path = output_dir / f"DxPartReplace-{version}.exe"
|
||||
build_sfx(sfx_stub, archive_7z, sfx_path)
|
||||
archive_7z.unlink()
|
||||
|
||||
manifest = {
|
||||
"version": version,
|
||||
"file_count": file_count,
|
||||
"artifacts": {
|
||||
zip_path.name: {"bytes": zip_path.stat().st_size, "sha256": _sha256(zip_path)},
|
||||
sfx_path.name: {"bytes": sfx_path.stat().st_size, "sha256": _sha256(sfx_path)},
|
||||
},
|
||||
"extractor": {
|
||||
"kind": "7zip-sfx",
|
||||
"stub": sfx_stub.name,
|
||||
"stub_sha256": _sha256(sfx_stub),
|
||||
"compressor": seven_zip.name,
|
||||
"compressor_sha256": _sha256(seven_zip),
|
||||
"version_output": subprocess.check_output([str(seven_zip)], text=True, errors='replace')[:500],
|
||||
"settings": "LZMA2 level 3, 4 threads, 64 MiB solid blocks",
|
||||
},
|
||||
"files": {path.relative_to(staging.parent).as_posix(): _sha256(path)
|
||||
for path in sorted(staging.rglob('*')) if path.is_file()},
|
||||
}
|
||||
(output_dir / f"release-manifest-{version}.json").write_text(
|
||||
json.dumps(manifest, ensure_ascii=False, indent=2) + "\n", encoding="utf-8"
|
||||
)
|
||||
(output_dir / f"SHA256SUMS-{version}.txt").write_text(
|
||||
"".join(f"{item['sha256']} {name}\n" for name, item in manifest["artifacts"].items()),
|
||||
encoding="ascii",
|
||||
)
|
||||
return manifest
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--source-dir", type=Path, required=True)
|
||||
parser.add_argument("--output-dir", type=Path, required=True)
|
||||
parser.add_argument("--version", required=True)
|
||||
parser.add_argument("--seven-zip", type=Path, required=True)
|
||||
parser.add_argument("--sfx-stub", type=Path, required=True)
|
||||
parser.add_argument("--license", type=Path)
|
||||
args = parser.parse_args()
|
||||
manifest = build_release(args.source_dir, args.output_dir, version=args.version,
|
||||
seven_zip=args.seven_zip, sfx_stub=args.sfx_stub,
|
||||
license_path=args.license)
|
||||
print(json.dumps(manifest, ensure_ascii=False, indent=2))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
+15
-5
@@ -1,12 +1,14 @@
|
||||
/** Tiny CDP driver for the real Qt Chromium page; no browser mocks. */
|
||||
import {writeFile} from 'node:fs/promises';
|
||||
|
||||
export async function connect(port=9226) {
|
||||
export async function connect(port=9226,{loading=false}={}) {
|
||||
let target;
|
||||
const deadline=Date.now()+45000;
|
||||
const deadline=Date.now()+60000;
|
||||
while(Date.now()<deadline){
|
||||
const targets=await fetch(`http://127.0.0.1:${port}/json`,{signal:AbortSignal.timeout(3000)}).then(r=>r.json());
|
||||
target=targets.find(x=>x.type==='page'&&x.url?.startsWith('http://127.0.0.1:'));
|
||||
let targets;
|
||||
try{targets=await fetch(`http://127.0.0.1:${port}/json`,{signal:AbortSignal.timeout(10000)}).then(r=>r.json());}
|
||||
catch{await new Promise(resolve=>setTimeout(resolve,100));continue;}
|
||||
target=targets.find(x=>x.type==='page'&&(loading?x.url?.startsWith('file:'):x.url?.startsWith('http://127.0.0.1:')));
|
||||
if(target)break;
|
||||
await new Promise(resolve=>setTimeout(resolve,100));
|
||||
}
|
||||
@@ -60,11 +62,19 @@ export async function connect(port=9226) {
|
||||
}
|
||||
|
||||
if(process.argv[1]?.endsWith('dsh_cdp.mjs')) {
|
||||
const client=await connect(Number(process.argv[2] || 9226));
|
||||
const loading=process.argv[2]==='--capture-loading';
|
||||
const client=await connect(Number(process.argv[loading?3:2] || 9226),{loading});
|
||||
try {
|
||||
if(loading){
|
||||
const actual=await client.evaluate(`({official:!!document.querySelector('[data-dsh-boot-spinner]'),text:document.body.innerText})`);
|
||||
if(!actual.official||!actual.text.includes('HARNESS'))throw Error('Official loading page was not rendered');
|
||||
await client.screenshot(process.argv[4]);
|
||||
console.log(JSON.stringify({officialLoading:true}));
|
||||
}else{
|
||||
console.log(JSON.stringify(await client.evaluate(`({title:document.title,text:document.body.innerText,
|
||||
buttons:[...document.querySelectorAll('button')].map(x=>({text:x.innerText,label:x.getAttribute('aria-label'),title:x.title})),
|
||||
svg:document.querySelectorAll('svg').length,animations:document.getAnimations().length,
|
||||
animatedSvg:document.querySelectorAll('animate,animateTransform,animateMotion').length,canvas:document.querySelectorAll('canvas').length})`)));
|
||||
}
|
||||
}finally{client.close();}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
"""Build a 7-Zip SFX wrapper around a prepared .7z release archive."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
import os
|
||||
import shutil
|
||||
|
||||
|
||||
def build_sfx(
|
||||
stub: Path,
|
||||
archive: Path,
|
||||
output: Path,
|
||||
) -> Path:
|
||||
"""Use the official 7z.sfx extractor (not the temporary installer stub).
|
||||
|
||||
Its native dialog selects a persistent destination. No installer config,
|
||||
registry modifications, temporary extraction or automatic launch is needed.
|
||||
"""
|
||||
stub = Path(stub)
|
||||
archive = Path(archive)
|
||||
output = Path(output)
|
||||
if not stub.is_file() or not archive.is_file():
|
||||
raise FileNotFoundError("SFX stub and archive must both exist")
|
||||
if output.exists():
|
||||
raise FileExistsError(output)
|
||||
with stub.open('rb') as stream:
|
||||
if stream.read(2) != b'MZ':
|
||||
raise ValueError('Expected Windows SFX executable')
|
||||
with archive.open('rb') as stream:
|
||||
if stream.read(6) != b'7z\xbc\xaf\x27\x1c':
|
||||
raise ValueError('Expected 7z archive')
|
||||
output.parent.mkdir(parents=True, exist_ok=True)
|
||||
temporary = output.with_name(f".{output.name}.{os.getpid()}.tmp")
|
||||
try:
|
||||
with temporary.open("xb") as target:
|
||||
for source in (stub, archive):
|
||||
with source.open('rb') as stream:
|
||||
shutil.copyfileobj(stream, target, 1024 * 1024)
|
||||
target.flush()
|
||||
os.fsync(target.fileno())
|
||||
os.replace(temporary, output)
|
||||
finally:
|
||||
temporary.unlink(missing_ok=True)
|
||||
return output
|
||||
@@ -0,0 +1,44 @@
|
||||
/** Upload owned files via the real composer menu and Qt's actual file chooser. */
|
||||
import assert from 'node:assert/strict';
|
||||
import {writeFile,readdir,readFile} from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
|
||||
export async function verifyFileUi(c,output){
|
||||
const wait=async(expression)=>{
|
||||
const end=Date.now()+30000;
|
||||
while(Date.now()<end){if(await c.evaluate(expression))return;await new Promise(r=>setTimeout(r,100));}
|
||||
throw Error('File UI timed out: '+expression);
|
||||
};
|
||||
const fixtures=path.join(output,'file-fixtures');
|
||||
const files=['dsh-upload.txt','dsh-upload.zip'].map(name=>path.join(fixtures,name));
|
||||
await writeFile(path.join(output,'file-picker-request.json'),JSON.stringify(files));
|
||||
// Plus opens the official command menu; choose its native attachment action.
|
||||
const plus=`[...document.querySelectorAll('button[aria-label="添加文件或调用指令"]')].find(e=>e.getBoundingClientRect().width>0)`;
|
||||
await c.click(plus);
|
||||
const fileOption=`[...document.querySelectorAll('[role="option"],button')].find(e=>e.getBoundingClientRect().width>0&&/^文件\\s*file/.test(e.textContent.trim()))`;
|
||||
await wait(`!!(${fileOption})`);
|
||||
await c.click(fileOption);
|
||||
await wait(`document.body.innerText.includes('dsh-upload.txt')&&document.body.innerText.includes('dsh-upload.zip')`);
|
||||
await wait(`![...document.querySelectorAll('[role="progressbar"]')].some(e=>e.getBoundingClientRect().width>0)`);
|
||||
await c.screenshot(path.join(output,'file-uploaded.png'));
|
||||
// Validate the uploaded bytes in Harness's actual owned storage, not the DOM echo.
|
||||
const roots=(await readdir(output)).filter(x=>x.startsWith('data-'));
|
||||
assert.equal(roots.length,1);
|
||||
const home=path.join(output,roots[0],'dsh/harness-home');
|
||||
const expected=await Promise.all(files.map(f=>readFile(f)));
|
||||
const found=new Set();
|
||||
async function scan(dir){
|
||||
for(const entry of await readdir(dir,{withFileTypes:true})){
|
||||
const filename=path.join(dir,entry.name);
|
||||
if(entry.isDirectory())await scan(filename);
|
||||
else if(entry.isFile()){
|
||||
const data=await readFile(filename);
|
||||
expected.forEach((bytes,i)=>{if(data.equals(bytes))found.add(i);});
|
||||
}
|
||||
}
|
||||
}
|
||||
const end=Date.now()+20000;
|
||||
while(found.size<files.length&&Date.now()<end){await scan(home);if(found.size<files.length)await new Promise(r=>setTimeout(r,150));}
|
||||
assert.equal(found.size,2,'text and ZIP must reach actual Harness file storage unchanged');
|
||||
return {status:'passed',realQtFilePicker:true,textAndZipUploaded:true,storedBytesMatched:true};
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/** Exercise actual Harness file tools against owned folders and ZIP archives. */
|
||||
import assert from 'node:assert/strict';
|
||||
import {mkdir,mkdtemp,writeFile,readFile,readdir} from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import {createRequire} from 'node:module';
|
||||
import {bootRuntime} from '../integration/dsh/start.mjs';
|
||||
const require=createRequire(new URL('../integration/dsh/start.mjs',import.meta.url));
|
||||
const {zipSync,strToU8}=require('fflate');
|
||||
const output=path.resolve('build/dsh-files-verification');await mkdir(output,{recursive:true});
|
||||
const root=await mkdtemp(path.join(output,'run-'));
|
||||
for(const key of ['DSH_API_KEY','DSH_API_BASE','DSH_MODEL','DX_DSH_MODELS'])delete process.env[key];
|
||||
process.env.DX_DSH_HOME=path.join(root,'home');process.env.DX_DSH_CONTEXT_FILE=path.join(root,'context.json');
|
||||
await writeFile(process.env.DX_DSH_CONTEXT_FILE,'{"task_id":"files-fixture","revision":"files","status":"observe"}');
|
||||
const source=path.join(root,'输入 文件夹');await mkdir(source);
|
||||
await writeFile(path.join(source,'说明.txt'),'DSH_FILE_CONTENT_中文\n');
|
||||
const archive=path.join(source,'资料.zip');
|
||||
await writeFile(archive,zipSync({'子目录/说明.txt':strToU8('DSH_ZIP_CONTENT_中文'),'binary.bin':new Uint8Array([0,1,2,255])}));
|
||||
const {ctx,shutdown}=await bootRuntime({announce:false});
|
||||
try{
|
||||
const names=ctx.tools.schemas().map(x=>x.name);
|
||||
for(const name of ['read','read_image','glob','grep','working_directory','extract_zip'])
|
||||
assert.ok(names.includes(name),'Missing file capability: '+name);
|
||||
const workspace=await ctx.workspaceRegistry.create(process.env.DX_DSH_WORKSPACE,'File fixture');
|
||||
const {sessionId}=await ctx.sessionController.create({workspaceId:workspace.id,agentPreset:'dx-task'});
|
||||
const agent=ctx.agents.get(sessionId);
|
||||
const call=async(name,args)=>ctx.tools.execute({name,arguments:args,callId:crypto.randomUUID(),agent,signal:AbortSignal.timeout(20000)});
|
||||
const ok=async(name,args)=>{
|
||||
const result=await call(name,args);assert.equal(result.isError,false,name+': '+JSON.stringify(result));return result;
|
||||
};
|
||||
assert.match(JSON.stringify(await ok('read',{file_path:path.join(source,'说明.txt')})),/DSH_FILE_CONTENT_中文/);
|
||||
assert.match(JSON.stringify(await ok('glob',{pattern:'*',path:source})),/说明.txt/);
|
||||
assert.match(JSON.stringify(await ok('grep',{pattern:'DSH_FILE_CONTENT',path:source})),/DSH_FILE_CONTENT/);
|
||||
await ok('working_directory',{cd:source});
|
||||
assert.match(JSON.stringify(await ok('read',{file_path:'说明.txt'})),/DSH_FILE_CONTENT/);
|
||||
const extracted=await ok('extract_zip',{file_path:'资料.zip'});
|
||||
const destination=extracted.value.directory;
|
||||
assert.equal(await readFile(path.join(destination,'子目录/说明.txt'),'utf8'),'DSH_ZIP_CONTENT_中文');
|
||||
assert.deepEqual(new Uint8Array(await readFile(path.join(destination,'binary.bin'))),new Uint8Array([0,1,2,255]));
|
||||
assert.match(JSON.stringify(await ok('read',{file_path:path.join(destination,'子目录/说明.txt')})),/DSH_ZIP_CONTENT/);
|
||||
assert.notEqual((await ok('extract_zip',{file_path:archive})).value.directory,destination,'repeated extraction must not overwrite');
|
||||
await writeFile(path.join(source,'unsafe.zip'),zipSync({'../escaped.txt':strToU8('must not escape')}));
|
||||
const before=await readdir(source);
|
||||
assert.equal((await call('extract_zip',{file_path:'unsafe.zip'})).isError,true);
|
||||
assert.deepEqual(await readdir(source),before,'unsafe archive must not publish a partial directory');
|
||||
await writeFile(path.join(source,'broken.zip'),'not a zip');
|
||||
assert.equal((await call('extract_zip',{file_path:'broken.zip'})).isError,true);
|
||||
const corrupt=Buffer.from(zipSync({'evidence.txt':strToU8('ORIGINAL_CONTENT')},{level:0}));
|
||||
const payload=corrupt.indexOf(Buffer.from('ORIGINAL_CONTENT'));assert.ok(payload>0);corrupt[payload]=88;
|
||||
await writeFile(path.join(source,'corrupt.zip'),corrupt);
|
||||
assert.equal((await call('extract_zip',{file_path:'corrupt.zip'})).isError,true,'CRC mismatch must not report successful extraction');
|
||||
assert.equal(await readFile(path.join(source,'说明.txt'),'utf8'),'DSH_FILE_CONTENT_中文\n');
|
||||
ctx.emit('dx/diagnose-request',{request_id:'files-incident-probe',incident_id:'a'.repeat(24),phase:'diagnose',
|
||||
snapshot:{task_id:'files-fixture'},evidence:'Owned fixture; no model is configured.'});
|
||||
let incident;
|
||||
const deadline=Date.now()+20000;
|
||||
while(Date.now()<deadline){
|
||||
incident=ctx.agents.list().find(value=>value.id!==agent.id);
|
||||
if(incident)break;
|
||||
await new Promise(resolve=>setTimeout(resolve,50));
|
||||
}
|
||||
assert.ok(incident,'automatic incident session must be created');
|
||||
let marked=false;
|
||||
while(Date.now()<deadline){
|
||||
const snapshot=await ctx.tools.execute({name:'dx_task_snapshot',arguments:{},callId:crypto.randomUUID(),agent:incident,signal:AbortSignal.timeout(2000)});
|
||||
if(snapshot.value?.revision==='a'.repeat(24)){marked=true;break;}
|
||||
await new Promise(resolve=>setTimeout(resolve,50));
|
||||
}
|
||||
assert.ok(marked,'incident snapshot must be bound before checking admission');
|
||||
for(const [name,args] of [['read',{file_path:path.join(source,'说明.txt')}],['extract_zip',{file_path:archive}]]){
|
||||
const denied=await ctx.tools.execute({name,arguments:args,callId:crypto.randomUUID(),agent:incident,signal:AbortSignal.timeout(2000)});
|
||||
assert.equal(denied.isError,true,'automatic incident must not inherit interactive file access');
|
||||
}
|
||||
const report={status:'passed',realHarness:true,read:true,folderSearch:true,workingDirectory:true,
|
||||
zipTextAndBinary:true,repeatedExtractionNoOverwrite:true,zipTraversalRejected:true,invalidZipRejected:true,corruptZipRejected:true,
|
||||
automaticSessionIsolation:true};
|
||||
await writeFile(path.join(root,'report.json'),JSON.stringify(report,null,2));console.log(JSON.stringify(report));
|
||||
}finally{await shutdown.shutdown(0);}
|
||||
@@ -58,6 +58,10 @@ try {
|
||||
await c.click(`document.querySelectorAll('button[aria-label="新建会话"]')[1]`);
|
||||
await wait(`!!document.querySelector('[data-testid="dx-task-panel"]')`);
|
||||
report.checks.push('native new conversation retains task dock');
|
||||
if(process.argv.includes('--file-check')){
|
||||
const {verifyFileUi}=await import('./verify_dsh_file_ui.mjs');
|
||||
report.files=await verifyFileUi(c,output);
|
||||
}
|
||||
if(!liveModel) {
|
||||
await c.click(`document.querySelector('button[aria-label="收起侧边栏"]')`);
|
||||
await wait(`!!document.querySelector('button[aria-label="打开侧边栏"]')`);
|
||||
@@ -86,7 +90,8 @@ try {
|
||||
await c.call('Input.dispatchKeyEvent',{type:'keyDown',key:'Escape',code:'Escape'});
|
||||
await c.call('Input.dispatchKeyEvent',{type:'keyUp',key:'Escape',code:'Escape'});
|
||||
await c.click(`document.querySelector('[contenteditable="true"]')`);
|
||||
const prompt=liveModel ? '请分析当前任务的状态和异常,告诉我任务名称、现在进展到哪一步以及接下来可以做什么。不要修改工程。' : '请分析当前任务的异常,并说明允许的处理方式。';
|
||||
const fileCheck=process.argv.includes('--file-check');
|
||||
const prompt=liveModel ? (fileCheck?'请分析当前任务的附件:读取上传的 dsh-upload.txt,再解压 dsh-upload.zip 并读取其中说明.txt,分别告诉我这两份文本的完整内容和解压后的真实目录。不要修改原文件或运行 CAD。':'请分析当前任务的状态和异常,告诉我任务名称、现在进展到哪一步以及接下来可以做什么。不要修改工程。') : '请分析当前任务的异常,并说明允许的处理方式。';
|
||||
report.prompt=prompt;
|
||||
report.explicitToolNamesInPrompt=false;
|
||||
await c.call('Input.insertText',{text:prompt});
|
||||
@@ -96,8 +101,8 @@ try {
|
||||
if(liveModel) {
|
||||
await c.click(`document.querySelector('button[aria-label="发送消息"]')`);
|
||||
const replies=`[...document.querySelectorAll('[data-chat-group-part="response"]')].map(e=>e.innerText).join('\\n')`;
|
||||
await wait(`(${replies}).length>30 && /任务|状态/.test(${replies})`,100000);
|
||||
await wait(`![...document.querySelectorAll('button[aria-label="停止生成"]')].some(e=>e.getBoundingClientRect().width>0)`,100000);
|
||||
await wait(fileCheck?`(${replies}).includes('DSH_UPLOAD_CONTENT')&&(${replies}).includes('DSH_ZIP_UPLOAD_CONTENT')`:`(${replies}).length>30 && /任务|状态/.test(${replies})`,fileCheck?180000:100000);
|
||||
await wait(`![...document.querySelectorAll('button[aria-label="停止生成"]')].some(e=>e.getBoundingClientRect().width>0)`,fileCheck?180000:100000);
|
||||
report.reply=await c.evaluate(replies);
|
||||
report.liveModelReplyTested=true;
|
||||
report.liveTurnCompleted=true;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import {mkdtemp,mkdir,readFile,writeFile,readdir} from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import {bootRuntime,overlay,prepareProfileDirectory} from '../integration/dsh/start.mjs';
|
||||
import {bootRuntime,overlay,prepareProfileDirectory,TASK_TOOLS,FILE_TOOLS} from '../integration/dsh/start.mjs';
|
||||
|
||||
const output=path.resolve('build/dsh-profile-settings-verification');
|
||||
await mkdir(output,{recursive:true});
|
||||
@@ -34,7 +34,7 @@ assert.equal(await readFile(path.join(legacyDir,'cordis.patch.yml'),'utf8'),migr
|
||||
const {ctx,shutdown}=await bootRuntime({announce:false});
|
||||
try{
|
||||
assert.deepEqual((await ctx.llm.listModels('profile-fixture')).map(x=>x.id),['persisted-fixture-model']);
|
||||
assert.equal(ctx.tools.schemas().length,7);
|
||||
assert.equal(ctx.tools.schemas().length,TASK_TOOLS.length+FILE_TOOLS.length);
|
||||
console.log(JSON.stringify({status:'passed',nativeSettingsPreserved:true,actualProviderRestored:true,
|
||||
legacyMigrationPreservedModels:true,byteBackup:true,modelRequests:0}));
|
||||
}finally{await shutdown.shutdown(0);}
|
||||
@@ -4,7 +4,7 @@ import {mkdir,writeFile} from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import {fileURLToPath,pathToFileURL} from 'node:url';
|
||||
import {createRequire} from 'node:module';
|
||||
import {bootRuntime} from '../integration/dsh/start.mjs';
|
||||
import {bootRuntime,TASK_TOOLS,FILE_TOOLS} from '../integration/dsh/start.mjs';
|
||||
|
||||
const repo=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'..');
|
||||
const output=path.join(repo,'build/dsh-native-cli-verification');
|
||||
@@ -18,7 +18,7 @@ const report={};
|
||||
try {
|
||||
const schemas=ctx.tools.schemas();
|
||||
report.tools=schemas.map(x=>x.name);
|
||||
assert.deepEqual(report.tools,['dx_task_snapshot','dx_task_create','dx_task_catalog','dx_task_preflight','dx_task_manage','dx_task_execute','dx_task_operations']);
|
||||
assert.deepEqual([...report.tools].sort(),[...TASK_TOOLS,...FILE_TOOLS].sort());
|
||||
const presets=await ctx.agentPresets.list();
|
||||
report.presets=presets.map(x=>x.id);
|
||||
assert.deepEqual(report.presets,['dx-task']);
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/** PR18 #197: no silently omitted names, bounded workers, real cancellation. */
|
||||
import assert from 'node:assert/strict';
|
||||
import {mkdir,mkdtemp,writeFile,readdir,readFile} from 'node:fs/promises';
|
||||
import {spawnSync} from 'node:child_process';
|
||||
import {createRequire,syncBuiltinESMExports} from 'node:module';
|
||||
import path from 'node:path';
|
||||
import {bootRuntime} from '../integration/dsh/start.mjs';
|
||||
const output=path.resolve('build/dsh-zip-review-verification');await mkdir(output,{recursive:true});
|
||||
const root=await mkdtemp(path.join(output,'run-'));
|
||||
const fixture=spawnSync('python',['-c',
|
||||
`import sys,zipfile,struct\nfrom pathlib import Path\np=Path(sys.argv[1])\nwith zipfile.ZipFile(p/'proto.zip','w',zipfile.ZIP_STORED) as z:z.writestr('__proto__','ORIGINAL_CONTENT')\ndata=bytearray((p/'proto.zip').read_bytes());n,e=struct.unpack_from('<HH',data,26);data[30+n+e]^=1;(p/'proto-bad.zip').write_bytes(data)\nwith zipfile.ZipFile(p/'many.zip','w',zipfile.ZIP_DEFLATED) as z:\n for i in range(20):z.writestr(str(i)+'.txt',b'x'*(600*1024))\n`,root],{encoding:'utf8'});
|
||||
assert.equal(fixture.status,0,fixture.stderr);
|
||||
const require=createRequire(import.meta.url),threads=require('node:worker_threads');
|
||||
const NativeWorker=threads.Worker;
|
||||
let active=0,peak=0,created=0,abortOnWorker;
|
||||
threads.Worker=new Proxy(NativeWorker,{construct(target,args){
|
||||
const worker=Reflect.construct(target,args);active++;created++;peak=Math.max(peak,active);
|
||||
worker.once('exit',()=>active--);
|
||||
if(abortOnWorker){const cancel=abortOnWorker;abortOnWorker=undefined;queueMicrotask(cancel);}
|
||||
return worker;
|
||||
}});
|
||||
syncBuiltinESMExports();
|
||||
for(const key of ['DSH_API_BASE','DSH_MODEL','DSH_API_KEY','DX_DSH_MODELS'])delete process.env[key];
|
||||
process.env.DX_DSH_HOME=path.join(root,'home');process.env.DX_DSH_CONTEXT_FILE=path.join(root,'context.json');
|
||||
await writeFile(process.env.DX_DSH_CONTEXT_FILE,'{"task_id":"zip-review","revision":"zip-review","status":"observe"}');
|
||||
const {ctx,shutdown}=await bootRuntime({announce:false});
|
||||
try{
|
||||
const call=(file,signal=AbortSignal.timeout(30000))=>ctx.tools.execute({name:'extract_zip',
|
||||
arguments:{file_path:path.join(root,file),output_directory:root},callId:crypto.randomUUID(),signal});
|
||||
const before=await readdir(root);
|
||||
for(const file of ['proto.zip','proto-bad.zip']){
|
||||
const result=await call(file);
|
||||
assert.equal(result.isError,true,'unsupported __proto__ entry must be explicitly rejected, including corrupt payload');
|
||||
assert.deepEqual(await readdir(root),before,'rejected archive must not publish an empty success directory');
|
||||
}
|
||||
peak=0;created=0;
|
||||
const results=await Promise.all(Array.from({length:4},()=>call('many.zip')));
|
||||
for(const result of results){
|
||||
assert.equal(result.isError,false,JSON.stringify(result));
|
||||
assert.equal(result.value.total_entries,20);
|
||||
for(let i=0;i<20;i++)assert.equal((await readFile(path.join(result.value.directory,i+'.txt'))).length,600*1024);
|
||||
}
|
||||
assert.equal(created,4,'each archive must use one worker, with no per-entry worker fan-out');
|
||||
assert.ok(peak<=2,'ZIP decompression must use at most two workers across concurrent calls, actual '+peak);
|
||||
assert.equal(active,0,'completed calls must release all workers');
|
||||
const cancel=new AbortController(),prior=await readdir(root);
|
||||
abortOnWorker=()=>cancel.abort(new Error('owned cancellation fixture'));
|
||||
const cancelled=await call('many.zip',cancel.signal).catch(error=>({isError:true,error}));
|
||||
assert.equal(cancelled.isError,true);
|
||||
assert.equal(active,0,'cancelled call must settle only after its worker exits');
|
||||
assert.deepEqual(await readdir(root),prior,'cancel must not publish a partial directory');
|
||||
const report={status:'passed',realHarness:true,protoEntryExplicitlyRejected:true,corruptProtoRejected:true,
|
||||
parallelArchives:4,filesPerArchive:20,peakWorkers:peak,cancelledWorkerStopped:true};
|
||||
await writeFile(path.join(root,'report.json'),JSON.stringify(report,null,2));console.log(JSON.stringify(report));
|
||||
}finally{threads.Worker=NativeWorker;syncBuiltinESMExports();await shutdown.shutdown(0);}
|
||||
@@ -0,0 +1,59 @@
|
||||
"""Run the delivered SFX and verify its files and every ZIP member against SHA256."""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import time
|
||||
import zipfile
|
||||
|
||||
|
||||
def digest(stream):
|
||||
return hashlib.file_digest(stream, 'sha256').hexdigest()
|
||||
|
||||
|
||||
def verify(manifest_path: Path, destination: Path):
|
||||
manifest = json.loads(manifest_path.read_text(encoding='utf-8'))
|
||||
root = manifest_path.resolve().parent
|
||||
destination = destination.resolve()
|
||||
if destination.exists():
|
||||
raise FileExistsError('Use a fresh extraction destination')
|
||||
for name, expected in manifest['artifacts'].items():
|
||||
with (root/name).open('rb') as stream:
|
||||
if digest(stream) != expected['sha256']:
|
||||
raise ValueError('Artifact checksum mismatch: '+name)
|
||||
version = manifest['version']
|
||||
started = time.monotonic()
|
||||
subprocess.run([str(root/f'DxPartReplace-{version}.exe'), '-y', '-o'+str(destination)],
|
||||
check=True, timeout=1800, creationflags=getattr(subprocess, 'CREATE_NO_WINDOW', 0))
|
||||
elapsed = time.monotonic()-started
|
||||
actual = {p.relative_to(destination).as_posix(): p for p in destination.rglob('*') if p.is_file()}
|
||||
if set(actual) != set(manifest['files']):
|
||||
raise ValueError('Self-extracted file set differs from manifest')
|
||||
for name, path in actual.items():
|
||||
with path.open('rb') as stream:
|
||||
if digest(stream) != manifest['files'][name]:
|
||||
raise ValueError('Self-extracted checksum mismatch: '+name)
|
||||
with zipfile.ZipFile(root/f'DxPartReplace-{version}.zip') as archive:
|
||||
if len(archive.namelist()) != len(actual) or set(archive.namelist()) != set(actual):
|
||||
raise ValueError('ZIP file set differs from manifest')
|
||||
# Reading to EOF also checks ZIP CRC for every member.
|
||||
for name in archive.namelist():
|
||||
with archive.open(name) as stream:
|
||||
if digest(stream) != manifest['files'][name]:
|
||||
raise ValueError('ZIP checksum mismatch: '+name)
|
||||
return dict(passed=True, files=len(actual), sfx_extraction_seconds=round(elapsed, 3),
|
||||
actual_sfx_executed=True, zip_crc_and_sha256=True,
|
||||
destination=str(destination))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('manifest', type=Path)
|
||||
parser.add_argument('destination', type=Path)
|
||||
parser.add_argument('--report', type=Path, required=True)
|
||||
args = parser.parse_args()
|
||||
result = verify(args.manifest, args.destination)
|
||||
args.report.write_text(json.dumps(result, ensure_ascii=False, indent=2)+'\n', encoding='utf-8')
|
||||
print(json.dumps(result, ensure_ascii=False, indent=2))
|
||||
Reference in new issue
Block a user