diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4dd5bfc..f51f5fe 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,11 +27,13 @@ jobs: timeout-minutes: 30 steps: - - name: Checkout code - uses: actions/checkout@v4 + - name: Checkout code (full history for lint ratchet merge-base) + uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + with: + fetch-depth: 0 - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: node-version: 22 cache: npm @@ -40,7 +42,7 @@ jobs: src/proxy-server/package-lock.json - name: Cache Electron binaries - uses: actions/cache@v4 + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 with: path: | ~\AppData\Local\electron\Cache @@ -55,27 +57,36 @@ jobs: - name: Install proxy-server dependencies run: npm ci --prefix src/proxy-server + - name: Audit production dependencies + # 生产依赖 0 漏洞为发布门禁(开发链已知项单独跟踪,见 CHANGELOG Release blockers 一节)。 + run: | + npm audit --omit=dev + npm audit --omit=dev --prefix src/proxy-server + - name: Type check run: npm run type-check - name: Build proxy-server run: npm run build --prefix src/proxy-server - - name: Lint (informational, 渐进治理中) - # 当前存在 71 个 error(多为 @typescript-eslint/ban-types 的 `{}` 类型与 no-explicit-any), - # 暂不阻塞 CI,避免一次性卡死构建。治理路线:分批修复后改为阻塞式门禁。 - # 详见 docs/13-项目SDLC规范化分析报告.md 的「质量门禁加固」章节。 - continue-on-error: true + - name: Lint (blocking) + # 2026-09-04:全量 lint 已清零(历史遗留 71 个 error 已在 v1.5.0 分支消化), + # 转为阻塞式门禁;lint:changed ratchet 作为变更文件级双重保护保留。 run: npm run lint + - name: Lint ratchet (changed files, blocking) + # 增量门禁:相对 base 分支变更的文件不得新增 lint error(存量不阻塞、不得新增)。 + run: npm run lint:changed + - name: Run tests with coverage run: npm run test -- --run --coverage - name: Upload coverage report if: always() - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 with: - name: coverage-report-${{ github.ref_name }} + # PR 事件的 ref_name 形如 "2/merge",含 "/" 不是合法 artifact 名;用 run_id 规避 + name: coverage-report-${{ github.run_id }} path: coverage/ if-no-files-found: warn @@ -93,10 +104,10 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: node-version: 22 cache: npm @@ -105,7 +116,7 @@ jobs: src/proxy-server/package-lock.json - name: Cache Electron binaries - uses: actions/cache@v4 + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 with: path: | ~\AppData\Local\electron\Cache @@ -130,7 +141,7 @@ jobs: run: npx electron-builder --win portable zip nsis --publish=never - name: Upload artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 with: name: windows-release-${{ github.ref_name }} path: | @@ -139,12 +150,13 @@ jobs: if-no-files-found: error - name: Create GitHub Release - uses: softprops/action-gh-release@v2 + uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2 with: files: | release/*.exe release/*.zip - draft: false + # RC 安全惯例:先以 draft 创建,维护者按本地验收清单完成手动验收后再手动 publish。 + draft: true prerelease: false generate_release_notes: true env: diff --git a/.gitignore b/.gitignore index e16eca3..62915a9 100644 --- a/.gitignore +++ b/.gitignore @@ -39,6 +39,12 @@ build/Release node_modules/ jspm_packages/ +# Local Python tooling environments +.venv/ + +# Local Semgrep audit artifacts (the reviewed report remains tracked) +.semgrep/ + # Snowpack dependency directory (https://snowpack.dev/) web_modules/ @@ -76,6 +82,12 @@ web_modules/ .env.production.local .env.local +# Offline publisher/private keys(public verification keys must be reviewed explicitly before tracking) +.keys/ +*.private.pem +registry-private-key*.pem +secrets/ + # parcel-bundler cache (https://parceljs.org/) .cache .parcel-cache @@ -130,6 +142,8 @@ dist dist-electron/ release/ out/ +coverage/ +.mimosa/ # IDE .vscode/ @@ -170,10 +184,12 @@ tools/ web/ # 项目内部文档资料(仅本地维护,不上传仓库) -# 保留根目录 README.md / README_CN.md(项目介绍)与 CHANGELOG.md(版本记录)对外公开 +# 保留根目录 README.md / README_CN.md(项目介绍)、CHANGELOG.md(版本记录)、 +# ARCHITECTURE.md / CAPABILITIES.md(对外架构与能力说明)与 SECURITY_AUDIT_REPORT.md(审计证据) docs/ **/README.md !/README.md +DEVELOPMENT.md # 备份文件(防止误提交) *.bak diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md new file mode 100644 index 0000000..95400f1 --- /dev/null +++ b/ARCHITECTURE.md @@ -0,0 +1,155 @@ +# ARCHITECTURE.md — 架构现状与演进计划 + +> 活文档。新增/移动模块、改变分层边界、引入新依赖或新数据流时,必须在同一提交更新本文件。 +> 更新时间:2026-09-05(分支 `wip/v1.5.0-migration`)。 + +## 1. 产品与架构定位 + +CCB(Claude Code Butler)是本地优先的 Windows 桌面应用(Electron 40 + React 18 + TS),核心价值是把分散在用户主目录的 AI CLI 工具配置(`~/.claude/settings.json`、MCP 注册表、Codex `config.toml` 等)纳入统一的生命周期管理:发现、校验、编辑、备份、恢复、模板化。 + +v1.4.0 及以前是"Claude Code 专用管理器":路径、格式、业务逻辑硬编码在各 service 中。v1.5.0 起演进为**规则驱动的多工具配置控制平面**:工具能力以 declarative JSON registry 声明,应用侧只实现有限的、审计过的内置 capability handler。这是典型的 Strangler 渐进迁移,而非重写。 + +## 2. 进程与分层模型 + +``` +┌─────────────────────────────────────────────────────────────┐ +│ Renderer(sandbox: true,无 Node) │ +│ React 18 + AntD 5 + Zustand;面板懒加载;Monaco 按需 runtime │ +│ (editor 核心 + JSON + Markdown,仅 editor/json 两个 worker)│ +│ 只发 IPC 请求,不接触真实路径 │ +├──────────── preload(contextBridge,唯一桥)──────────────────┤ +│ Main Process(Node,全部 fs/路径/子进程/网络归属于此) │ +│ services/ 业务服务 utils/ 安全基础设施 │ +│ 网络出口:net.fetch(Chromium 栈,系统代理感知); │ +│ 托管上游转发:utils/upstream-http-client(Node http/https) │ +│ registry 契约来自 src/shared,运行时由 main 推导 allowlist │ +├──────────── src/shared(跨进程 domain contract)──────────────┤ +│ tool-registry.ts / tool-registry-validator.ts │ +│ builtin-tool-registry.json(内置 adapter 声明) │ +├──────────── src/proxy-server(独立 npm 包)───────────────────┤ +│ Express 5 托管模式代理 + 4 个 provider transformer │ +│ (遗留独立包;主应用内为集成模式 Express 实例) │ +└─────────────────────────────────────────────────────────────┘ +``` + +分层规则(强制): + +1. renderer 永远不持有真实文件路径,所有路径由 main 从 effective registry 推导。 +2. `src/shared` 是唯一跨进程契约层,禁止反向依赖 main/renderer。 +3. 安全基础设施(`command-executor`、`ssrf-guard`、`path-security`、`atomic-json-writer`、`window-security`)是所有业务服务的强制入口,不得绕过直用 `child_process`/`fs`/`fetch` 裸 API。 +4. legacy Claude 路径一律经 `ClaudeWorkspacePathFacade`(v1.5.0 固定 `LEGACY_COMPAT`)。 + +## 3. v1.5.0 核心架构:规则驱动 Registry + +### 3.1 Domain model + +``` +ToolDefinition ──1:N── ConfigArtifactDefinition ──N:1── Capability + (检测方式) (路径模板/格式/范围) (DISCOVER/READ/ + VALIDATE/EDIT/ + BACKUP/RESTORE) +``` + +- **ToolDefinition**:`toolId`、平台、detectors(`COMMAND_EXISTS` / `PATH_EXISTS`,无 shell 执行)。 +- **ConfigArtifactDefinition**:per-platform 路径模板(仅 `HOME`/`APPDATA`/`LOCALAPPDATA`/`XDG_CONFIG_HOME`/`CCB_DATA` 变量)、format(`JSON`/`JSONC`/`YAML`/`MARKDOWN`/`TEXT`/`TOML`)、scope、handler(`JSON_FILE_V1`/`MARKDOWN_FILE_V1`/`TEXT_FILE_V1`/`TOML_FILE_V1`)、可选 `editGroup`/`configSet`。 +- **Capability**:最小权限动词。adapter 只声明被验证过的能力——内置 4 工具(Claude Code/Codex/Gemini CLI/Antigravity)除记忆类 MARKDOWN 文件(无 VALIDATE 语义)外均已放开全部六项能力。 +- **editGroup**:纯 UI 聚合元数据(validator 限每组 ≤4 成员),把同工具相关 artifact(如 Codex `config.toml + auth.json`)聚合为一个"配置集"面板分页;保存语义 = 全组 VALIDATE 通过 → 顺序逐文件走既有 per-artifact authorize→backup→原子写链,不新增写路径、不放宽安全边界。 +- **configSet**:运行时快照切换元数据(每组 ≤4 成员,与 editGroup 正交)。同工具同 `configSet` 的 artifacts 构成可命名快照、整体激活的配置单元;由 `ToolConfigSetService` 落地(见 §3.6)。 + +### 3.2 Registry 组成与优先级 + +``` +effective registry = merge(INSTALLED_REMOTE, EMBEDDED_BUILTIN) # installed 覆盖 embedded +template 解析 = USER_OVERRIDE > REGISTRY > EMBEDDED +``` + +- 内置 registry:`src/shared/builtin-tool-registry.json`(registryVersion 1.2.0:Claude Code、Codex CLI、Gemini CLI、Antigravity 四工具;1.2.0 起 Codex/Gemini/Antigravity 声明 `configSet` 分组)。 +- 远程 registry:Ed25519 detached 签名(pinned `keyId → SPKI` trust map)→ SHA-256 → size → schema → SemVer → minimumAppVersion → downgrade policy,全链 fail-closed;installed/last-known-good 原子存储支持显式 rollback(无 last-known-good 时回退 embedded 基线并清除 installed/metadata 残留)。 +- 验证器 bounded:限制 bundle/manifest 大小、JSON 深度/节点数、路径变量、detector/handler/capability allowlist。 +- 启动只检查小 manifest,完整 bundle 需用户显式确认安装。 + +### 3.3 迁移策略(Strangler 四阶段) + +| 阶段 | 内容 | v1.5.0 状态 | +| --- | --- | --- | +| Phase A | Registry foundation + 内置 Claude 兼容 adapter | ✅ 完成 | +| Phase B | 通用 read path(detection/discovery/read)+ Codex | ✅ 完成 | +| Phase C | 通用 write path(codec/校验/原子编辑/备份恢复) | ✅ 基础完成(4 内置工具全量;TOML 用 smol-toml parse 校验 + 原文写回;editGroup 配置集聚合;缺失文件可按 registry 声明创建) | +| Phase D | 旧 Claude 面板向 registry 驱动迁移、特性提取 | ⬜ 未开始(v1.5.0 明确不做大爆炸迁移) | + +### 3.4 启动与性能架构 + +- Renderer 启动调度器:首屏仅 AppStore + Settings 关键初始化;Configs/Rules、ExecutionLogs/Stats 拆为 idle batches;组件卸载取消未启动批次。 +- Main 生命周期:app update 与 registry manifest 检查并发;StatisticsService 串行 lifecycle barrier、interval `unref()`;`before-quit` 单次 guard 确保清理完成。 +- 单实例契约:`app.requestSingleInstanceLock()` 于模块顶层获取,拿不到锁的实例立即 `app.quit()`;首实例在 `second-instance` 中恢复/聚焦主窗口并弹通知。任何新窗口形态(含未来 about/settings 窗口)都必须复用该契约,禁止绕过。 +- Windows 应用身份:进程级 `app.setAppUserModelId(APP_INFO.APP_ID)`(ready 前设置,与 electron-builder `build.appId` 一致)+ `app.name = APP_INFO.FULL_NAME`;通知构造处不再 per-notification 覆盖 AUMID(改一处需同步另一处)。 +- 按需 performance snapshot/export API(PERF-01~08 指标,本地存储,无定时采样、无上传)。 + +### 3.5 网络出口与依赖极简(v1.5.0) + +- 主进程简单出网(更新检查、npm registry、registry manifest/bundle、健康检查)统一走 Electron `net.fetch`(Chromium 网络栈,遵循系统代理),配 `AbortSignal.timeout`。 +- 托管模式上游转发(`/v1/messages`)走 `utils/upstream-http-client.ts`:Node `http/https` + 可选 `https-proxy-agent` CONNECT 隧道;返回 `IncomingMessage` 原生流供 SSE 直通;建连阶段超时映射 `ECONNABORTED`→504;非 2xx 错误体与响应体均有大小上限。 +- Registry 下载(`NetFetchRegistryHttpClient`)`redirect: 'error'` + 流式大小限制,fail-closed 不变。 +- root 生产依赖收敛为 6 个(chokidar/express/js-yaml/node-cron/https-proxy-agent/smol-toml):axios、uuid 已移除(asar 内 node_modules 包数 84,无 .map、无 axios/uuid);smol-toml 为 TOML parse 校验专用(1.8.0,零传递依赖,主包体仍在基线内)。 + +### 3.6 多工具配置集与托盘切换(v1.5.0) + +配置管理存在两条正交通道,由配置页顶部工具下拉框统一入口: + +- **Claude 工作区通道(legacy)**:`ConfigService` + `~/.ccb/claude-configs` 工作区目录,含热重载切换技巧与状态同步;claude-code 刻意不声明 `configSet`,避免双份快照存储。 +- **Registry 配置集通道(generic)**:`ToolConfigSetService`(`src/main/services/tool-config-set-service.ts`),快照存于 `/config-sets///`(temp+rename 原子写,随机 setId 寻址)。创建 = 快照 live 内容(缺失文件回退 registry 默认模板)或显式内容导入(`createConfigSetFromContents`,云模板专用入口:未知/重复成员拒绝,未覆盖成员同样回退);激活 = 先全组 VALIDATE 再逐文件 `editArtifact`(复用既有授权/备份/原子写链,无新写路径);isInUse = live 与快照逐文件内容比对。IPC 通道 `toolRegistry:*ConfigSet*` 6 条 + 云模板 2 条(见 §3.7),preload 桥接 DTO 全部来自 `@shared`。 + +托盘快速切换菜单(`tray-manager.ts`)为两层结构:Claude Code 子菜单走遗留通道(保留热重载),其余声明 `configSet` 的工具各一个子菜单(`●` 标记 isInUse);托管模式拦截在托盘/面板 UI 层(与遗留 `config:activateConfig` 同层),激活成功经 `tray:switch-config` 事件通知 renderer 刷新(payload 含 toolId 以区分通道)。 + +空 `requestedPath` 语义:artifact 读写/校验 IPC 对"registry 声明但文件缺失"的场景传空串,由主进程 `authorizeArtifact` 解析为声明的首个候选路径——renderer 仍不构造任何真实路径。 + +### 3.7 云模板通道(templates/v1,v2 提案落地) + +- **契约**:`@shared/template-cloud`(index/负载强类型与上限常量)+ `@shared/template-cloud-validator`(闭集/pinned origin/SemVer/SHA-256/Base64 模式校验与 canonical JSON 签名输入重建);发布侧 `web/software/ccb/registry/tools/common.cjs` 为忠实再实现,客户端校验为权威(staging 联检单测防两侧漂移)。 +- **服务**:`TemplateCloudService`(`src/main/services/template-cloud-service.ts`,工厂注入共享 `ArtifactTemplateService` 实例避免 settings 并发丢失)。`listTemplates` 拉取并验证 index(≤50KB → 结构闭集 → trust map → canonical Ed25519 签名 → minimumAppVersion 门槛,并发去重);`importTemplate` 下载内容寻址 item(pinned URL → ≤2MB → SHA-256/尺寸 → 按 kind 负载闭集 → templateId/toolId 一致性)后分流:`CONFIG_SET` → `createConfigSetFromContents`(本地快照,不动生效配置);`ARTIFACT` → `saveArtifactTemplateOverride`(默认模板 user override)。信任链、网络栈(`NetFetchRegistryHttpClient`)与 pinned origin(`dev.niansir.com`)全部复用规则库更新链,无新增写路径。 +- **IPC/UI**:`toolRegistry:listCloudTemplates` / `toolRegistry:importCloudTemplate`(renderer 仅传 templateId + 可选显示名,不接触 URL/内容);共享组件 `CloudTemplateLibraryModal`(`src/renderer/src/components/Config/`)由 Claude 配置面板与配置集面板共用,**仅显示/导入当前所选工具(toolId)的模板**——跨工具模板不可见不可导入,过滤发生在 renderer(清单拉取/导入 IPC 不带 toolId,信任链仍在 main 侧不变)。 + +## 4. 现状评估(资深视角:优势与债务) + +### 4.1 做得对的 + +- **安全边界清晰且 fail-closed**:沙箱渲染、能力 allowlist、签名链、原子写、无 shell 执行。v1.4.0 的安全重做(P0/P1 项清零)+ v1.5.0 的 registry 安全模型形成了可持续的防线,而非一次性补丁。 +- **迁移策略克制**:facade 兼容旧路径、不移动用户数据、幂等可回滚,符合桌面软件"用户数据神圣"原则。 +- **质量门禁自动化**:211 项单测、Semgrep 双扫描 0 findings、preflight 脚本、CI 覆盖率 artifact;2026-09-04 起 lint 零错误并转 CI 阻塞 + 变更文件 ratchet(`npm run lint:changed`),生产依赖 audit 进入 CI 门禁。 +- **性能有度量契约**:拒绝无数据优化,PERF 指标定义先于优化落地。 + +### 4.2 架构债务(按风险排序) + +| # | 债务 | 现状 | 风险 | 建议 | +| --- | --- | --- | --- | --- | +| D1 | `ManagedModeService` ~1812 行上帝服务 | v1.4.0 已提取 `ManagedModeConfigStore`,剩余体量仍集中 | 改动扩散、测试难 | 继续按 Store/Converter/Lifecycle 三轴拆分,每次提取保持 IPC 契约零感知 | +| D2 | `ipc-handlers.ts` ~926 行集中注册 | 所有 handler 单文件注册 | 合并冲突热点、边界模糊 | 按 service 分文件注册,入口聚合 | +| D3 | 旧 Claude 面板未走 registry 通道 | Config/MCP/Agent/Skill 面板仍直连专用 service | 双轨维护成本 | Phase D 渐进收敛,先 read 后 write | +| D4 | ~~Lint 存量 ~71 error~~ | **2026-09-04 已清零**:CI 转阻塞门禁 + `lint:changed` ratchet 双保险 | 已消除 | 保持 ratchet 防倒退;新增代码零 error 为硬约束 | +| D5 | locales 单文件 ~140 KB | 首屏全量解析 | 启动/内存 | 按 feature namespace 拆分 | +| D6 | Renderer 组件测试缺失 | 覆盖率不含 renderer | UI 回归靠人工 | 优先给 Registry/Template/Backup 交互流补组件测试 | +| D7 | watcher 按 service 各自为政 | PERF-06 已可观测计数 | 冗余句柄/IO | 按 artifact 去重 + 统一 debounce/dispose | + +## 5. 设计改进计划(v1.5.x ~ v1.6) + +按"先收尾、再优化、后扩张"排序: + +1. **收尾 v1.5.0 发布链**:production publisher key 离线仪式、实机性能与业务验收。这是当前最高优先级,任何新特性让路。 +2. **D1/D2 偿还**:ManagedModeService 第二轮拆分(log-rotation、transformer 路由、process lifecycle 各自成模块);ipc-handlers 分域注册。 +3. **性能二次优化(数据驱动)**:依据实机 PERF-01~07 baseline,按 top contributor 决定是否做 service 懒初始化分级(`BOOT_CRITICAL`/`AFTER_RENDERER_READY`/`ON_DEMAND`)、config scan 定向化、watcher 去重、locale 拆分。 +4. **测试体系升级**:核心服务覆盖率到 40%+ 后开启 Vitest thresholds 硬门禁;为 registry 安装/回滚、模板迁移补集成级测试。 +5. **Phase D 启动评估**:v1.6 规划旧面板向 registry 通道收敛,先从 MCP 管理(JSON 格式、与 registry artifact 最接近)试点。 + +## 6. 拓展计划(v1.6+ 方向池) + +- **新工具 adapter**:Cursor、Windsurf 等按 registry 声明接入;每个 adapter 必须先 read-only 验证 detection/discovery,再逐能力放开 write。Gemini CLI 与 Antigravity 已于 v1.5.0 内置。 +- **~~TOML codec~~**:已完成——smol-toml bounded parse 校验(TOML_FILE_V1),保存原文写回保留注释。 +- **future workspace 物理迁移**:`.ccb/claude-configs` → 通用 workspace 布局的物理搬迁,前置条件是迁移演练证明可无损回滚(facade 已预留路径声明)。 +- **registry 分发运营化**:publisher key 轮换/吊销流程文档化、last-known-good 灰度策略。 +- **明确不做**(当前共识):public marketplace、账号体系、云同步、远程可执行插件。 + +## 7. 决策记录 + +- 品牌保留 `Claude Code Butler`,名称记录起源不限制架构。 +- v1.5.0 不做物理目录迁移、不接受未测量性能结论、远程规则不携带代码。 +- v1.4.0 遗留决策:移除无鉴权传统代理 fallback(P0),只保留 accessToken 集成模式。 diff --git a/CAPABILITIES.md b/CAPABILITIES.md new file mode 100644 index 0000000..8e6ee9f --- /dev/null +++ b/CAPABILITIES.md @@ -0,0 +1,74 @@ +# CAPABILITIES.md — 能力清单与成熟度 + +> 活文档。新增/修改用户可见功能、registry capability、adapter 时,必须在同一提交更新本文件。 +> 更新时间:2026-09-04(v1.5.0 开发中,基线提交 `d7ea569`)。 + +状态标记:`稳定`(v1.4.0 已发布且回归通过)|`1.5.0 新增`(本版落地,待实机验收)|`基础`(foundation 完成,能力受限)|`规划`(未实现)。 + +## 1. 面板级功能矩阵 + +| 功能 | 说明 | 状态 | +| --- | --- | --- | +| 配置管理 | Claude Code 多类型配置(settings/claude.json/claude.md/项目配置)创建、编辑、复制、导入导出、备份、激活切换;Monaco 编辑器 + JSON/Markdown 校验;新建预填按 `USER_OVERRIDE > REGISTRY > EMBEDDED` 解析的 artifact 模板;v1.5.0 顶部工具下拉框可在该工作区通道与多工具配置集通道间切换 | 稳定(模板来源机制与工具下拉框 1.5.0 新增) | +| 多工具配置集 | registry `configSet` 声明驱动的命名快照:创建(live 内容,缺失文件回退默认模板)、逐文件编辑、激活(全组校验后逐文件授权/备份/原子写)、删除、isInUse 比对、名称搜索;配置页与托盘快速切换菜单均可用,托管模式下激活被拦截 | 1.5.0 新增 | +| 云模板库 | Claude 配置面板与配置集面板共用的签名云模板通道:仅显示/导入**当前所选工具**的模板(跨工具模板不可见不可导入),一键导入;`CONFIG_SET` 模板导入为本地配置集(不动生效配置),`ARTIFACT` 模板保存为 artifact 默认模板覆盖。清单与 item 均经 Ed25519 签名 + pinned origin + 哈希校验,导入复用既有写路径 | 1.5.0 新增 | +| MCP 管理 | 全局/项目级 MCP server 管理,本地 command 型与远程 http 型,启用/禁用/复制/归档/可用性验证 | 稳定 | +| 子 Agent / Skill 管理 | `.claude` 下 agents/skills 的清单与管理面板 | 稳定 | +| 项目管理 | Claude 项目关联与会话读取(路径校验防护) | 稳定 | +| 统计分析 | Claude Code JSONL 日志流式解析,用量/模型/token 统计 | 稳定(生命周期竞态修复于 1.5.0) | +| 自动化规则 | 时间/文件变化/应用事件触发的条件-动作规则;custom-command 经 command-executor 参数化执行 + 系统通知 | 稳定 | +| 环境检查 | Claude Code 及相关工具版本检测 | 稳定 | +| 托管模式 | accessToken 鉴权的本地代理,API 上游热切换,4 provider transformer(Anthropic/OpenRouter/DeepSeek/Gemini),日志轮转与诊断 | 稳定(传统无鉴权 fallback 已于 v1.4.0 移除) | +| AI 工具配置面板 | registry 驱动的通用工具面板:检测、artifact 发现、raw 查看、校验、编辑、备份恢复,全部 capability-aware | 1.5.0 新增(懒加载) | +| 设置 | 主题/语言/终端/编辑器偏好;registry 版本检查、确认安装与回滚;artifact 模板覆盖管理(三方 diff 预览) | 模板与 registry 控件 1.5.0 新增 | +| 性能快照 | About/Performance 按需导出 per-process CPU/内存、renderer timings、watcher/scan runtimeMetrics | 1.5.0 新增(本地存储,不上传) | +| 单实例运行 | CCB 仅允许一个进程:二次启动自动退出并恢复/聚焦已有窗口,弹系统通知提示 | 1.5.0 新增 | +| 系统通知应用名 | Windows 通知显示 "Claude Code Butler/CCB" 应用身份而非原始 AUMID 包名 | 1.5.0 修复 | + +## 2. Registry 能力模型(v1.5.0 核心) + +能力动词(allowlist 封闭集合,未知即拒绝):`DISCOVER`、`READ`、`VALIDATE`、`EDIT`、`BACKUP`、`RESTORE`。 + +### 2.1 内置 adapter 状态 + +| Tool | artifact | 格式 | 能力 | 状态 | +| --- | --- | --- | --- | --- | +| Claude Code | `user-settings`(`~/.claude/settings.json`) | JSON | 全部六项 | 1.5.0 新增(兼容 v1.4 直连通道并存) | +| Claude Code | `mcp-registry` | JSON | 全部六项 | 1.5.0 新增 | +| Claude Code | `global-instructions`(CLAUDE.md) | MARKDOWN | 全部六项 | 1.5.0 新增 | +| Codex CLI | `user-config`(`~/.codex/config.toml`) | TOML | 全部六项(`TOML_FILE_V1`) | 1.5.0 放开写入(smol-toml parse 校验 + 原文写回保注释) | +| Codex CLI | `auth`(`~/.codex/auth.json`) | JSON | 全部六项 | 1.5.0 新增(API key / ChatGPT token 刷新元数据;敏感文件不进日志/统计) | +| Codex CLI | `agents-instructions`(`~/.codex/AGENTS.md`) | MARKDOWN | DISCOVER/READ/EDIT/BACKUP/RESTORE | 1.5.0 新增(用户记忆文件为 AGENTS.md,非 CLAUDE.md) | +| Gemini CLI | `user-settings`(`~/.gemini/settings.json`) | JSON | 全部六项 | 1.5.0 新增 | +| Gemini CLI | `env`(`~/.gemini/.env`) | TEXT | 全部六项 | 1.5.0 新增(`GEMINI_API_KEY`) | +| Gemini CLI | `instructions`(GEMINI.md) | MARKDOWN | DISCOVER/READ/EDIT/BACKUP/RESTORE | 1.5.0 新增 | +| Antigravity | `global-mcp`(`~/.gemini/config/mcp_config.json`) | JSON | 全部六项 | 1.5.0 新增 | +| Antigravity | `cli-settings`(`~/.gemini/antigravity/settings.json`) | JSON | 全部六项 | 1.5.0 新增 | + +**关联编辑(editGroup)**:同工具同 `editGroup` 的 artifact(每组 ≤4)在 UI 聚合为一个配置集面板分页编辑;保存时先全组 VALIDATE,全部通过后顺序逐文件走既有 authorize→backup→原子写链,任一失败即中止(已写文件保留各自备份可恢复)。Codex `config.toml + auth.json`(`core` 组)与 Gemini `settings.json + .env + GEMINI.md`(`core` 组)为首批配置集。registry 声明但尚未存在的文件可经 EDIT 以默认模板创建(父目录链仍拒绝 symlink;renderer 对缺失文件传空 requestedPath,由主进程解析声明的主候选路径)。 + +**配置集快照(configSet)**:同工具内 `configSet` 相同的 artifacts(每组 ≤4)构成可整体快照/切换的运行时配置单元,与 `editGroup`(编辑时 UI 聚合)语义正交。快照存于 `/config-sets///`(set.json 元数据 + `.txt`),目录以随机 setId 寻址、显示名仅存元数据,杜绝名字→路径注入;激活 = 先全组 VALIDATE 再逐文件 editArtifact,不引入新写路径;isInUse = live 内容逐文件比对。内置 registry v1.2.0 为 Codex(user-config+auth)、Gemini(user-settings+env)、Antigravity(cli-settings)声明 `core` 配置集;claude-code 走专用工作区通道(含热重载切换),刻意不声明 configSet。 + +### 2.2 通用基础设施 + +- **Detector**:`COMMAND_EXISTS`(`execFile` + `shell:false`)、`PATH_EXISTS`,无 shell 注入面。 +- **Path resolver**:受控模板变量(`HOME`/`APPDATA`/`LOCALAPPDATA`/`XDG_CONFIG_HOME`/`CCB_DATA`),拒绝 traversal/UNC/glob。 +- **Discovery/Read**:registry-allowlisted 只读服务,拒绝 symlink 与 >1 MiB 文件。 +- **Codec**:JSON/JSONC/YAML/MARKDOWN/TEXT/TOML 内置(TOML 为 smol-toml parse 校验 + 原文写回),bounded 校验 + 原子编辑。 +- **Backup/Restore**:capability 驱动,per tool/artifact/path 默认 20 份 retention,串行 mutation queue,二次确认恢复,损坏/越权 metadata fail-closed 排除。 +- **Template**:artifact 级模板服务,来源显示、独立覆盖、移除恢复、bounded diff;legacy 全局自定义模板自动迁移为 override。 + +### 2.3 远程 registry 更新链(全部 fail-closed) + +Ed25519 detached 签名(pinned `keyId → SPKI`)→ SHA-256 → size → schema → SemVer → minimumAppVersion → downgrade policy → 原子安装;显式回滚:优先恢复 last-known-good 历史版本,首次安装后无历史 bundle 时回退 embedded 内置基线(已安装版本显示"仅使用内置规则");启动仅检查 manifest,bundle 下载需用户确认。云模板通道(`templates/v1`,见上表"云模板库")复用同一条信任链:index 内嵌 canonical JSON Ed25519 签名 + 内容寻址 item 哈希校验,同样 fail-closed。 + +**发布前提**:远程 registry 分发采用离线 Ed25519 publisher key ceremony——私钥离线保存、永不入库,仅 SPKI public key 进入 `REGISTRY_TRUSTED_PUBLIC_KEYS`;release preflight 强制校验 trust map 中的 key 命名与来源,非 production 命名 keyId 一律拒绝进入正式发布。 + +## 3. 平台与交付 + +- 开发/交付以 Windows 为主(Portable / NSIS / ZIP 三产物);macOS(dmg/zip)、Linux(AppImage/tar.gz)打包配置就绪但未纳入常规验收。 +- 中英双语 UI;本地优先,无强制云依赖,无 telemetry。 + +## 4. 明确不在当前能力范围 + +Public marketplace、账号体系、云同步(云端存储用户自有配置的同步通道仍未实现;云模板库为只读签名分发 + 本地导入,不涉及用户数据上行)、远程可执行插件、`.ccb/claude-configs` 物理迁移(v1.5.0 共识,详见 ARCHITECTURE.md §6)。 diff --git a/CHANGELOG.md b/CHANGELOG.md index 00d60bc..d2cca2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -本文件记录 CCB (Claude Code Butler) 的所有显著变更。 +本文件记录 CCB(Claude Code Butler)的所有显著变更。 格式基于 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/), 版本号遵循 [语义化版本 Semantic Versioning](https://semver.org/lang/zh-CN/)。 @@ -9,6 +9,122 @@ --- +## [Unreleased] - 1.5.0 开发中 + +### Added + +- 新增 Ed25519 detached registry signature verifier、pinned `keyId -> SPKI public key` trust map 与 offline signing helper。 +- 建立规则驱动多 AI 工具配置平台基础:`ToolDefinition -> ConfigArtifactDefinition -> Capability` 共享 domain contract。 +- 新增 bounded JSON registry validator,限制 bundle/manifest 大小、JSON 深度/节点数、路径变量、detector、handler 与 capability allowlist。 +- 新增内置 Claude Code registry adapter,声明用户 settings、MCP registry 与全局 instructions 三类配置资产。 +- 新增 Codex CLI read-only adapter,声明 `${HOME}/.codex/config.toml` 的 detection、discovery 与 raw TOML read capability。 +- 新增受控 path template resolver 与无 shell 的 `PATH_EXISTS` / `COMMAND_EXISTS` detector executor。 +- 新增 registry-allowlisted artifact discovery/read service 与 IPC facade,拒绝 traversal、UNC、glob、symbolic link、任意 renderer 路径和超过 1 MiB 的配置文件。 +- 新增内置 JSON/JSONC/YAML/MARKDOWN/TEXT codec、bounded validation、atomic edit 与 capability-driven backup/restore。 +- 新增 lazy-loaded AI 工具配置面板,支持 detection、artifact discovery、raw view、validation、edit 与 backup 的 capability-aware 操作。 +- AI 工具配置面板新增受控 backup history 与二次确认 restore 流程;损坏或越权 metadata fail-closed 排除。 +- 新增 installed/last-known-good registry 原子存储、SHA-256 integrity、app compatibility、downgrade protection、merge 与显式 rollback。 +- 新增 main-process registry manifest 检查;启动时只检查小型 manifest,不自动下载完整 bundle。 +- Settings/About 新增规则库版本、检查、用户确认安装与 rollback 控件。 +- 新增按需 performance snapshot/export API,记录 Electron per-process CPU/working set、bounded renderer timings,以及 `runtimeMetrics` 中的 active watcher/监控目录/目录项计数与最近一次 config scan 摘要;指标由现有 watcher/scan 生命周期被动更新,不新增 timer 或上传。 +- 新增 artifact-specific template service 与 Settings 管理界面,按 `USER_OVERRIDE > REGISTRY > EMBEDDED` 解析模板并提供 bounded diff preview。 +- 新增 legacy customized global template 到 `claude-code/user-settings` override 的兼容迁移;旧内置默认值不会被误迁移。 +- 新增 release preflight,校验版本、双语文档、installer identity、private key marker、registry trust map 与 Electron security contract。 +- 新增 `pack:win:all`,一次生成 Windows Portable、NSIS 与 ZIP 三类 release artifacts。 +- 新增 `lint:changed`(ESLint Node API 实现),对相对 `origin/main` 的变更 TypeScript 文件执行 error 增量 ratchet:新文件必须零 error、改动文件不得增加 error,已接入 CI 为阻塞步骤。 +- 新增 release preflight 的 rehearsal key 防误发保护:production 模式拒绝 rehearsal/test/dev 等命名 keyId 进入 `REGISTRY_TRUSTED_PUBLIC_KEYS`,preview 模式仅 warning。 +- 新增 registry 发布链 rehearsal 测试套件(`CCB_REHEARSAL_PRIVATE_KEY` env-gated):valid 安装、tampered 拒绝、unknown-key 拒绝、rollback 四场景,走真实 `ToolRegistryService` 原子存储与生产 trust map。 +- 新增 v1.5.0 PRD、架构、安全协议、性能路线与品牌语义 ADR。 +- 新增单实例锁(`app.requestSingleInstanceLock`):CCB 仅允许一个进程运行,二次启动自动退出并让首实例恢复/聚焦窗口,弹系统通知提示"应用已在运行"。 +- 新增 `upstream-http-client`(Node http/https 原生上游转发客户端):CONNECT 代理、建连阶段超时(映射 `ECONNABORTED`→504)、非 2xx 错误体受限读取、响应体大小上限,配套 7 项单元测试(本地 http server 覆盖 JSON 转发/SSE 流序/非 2xx 透传/超时/拒连/大小上限)。 +- **多工具配置集(editGroup)**:同工具同编辑分组的 artifact(≤4/组,validator 强制)在 AI 工具配置面板聚合为一个"配置集"分页编辑;保存先全组 VALIDATE,通过后顺序逐文件走既有 authorize→backup→原子写链(任一失败即中止,已写文件保留各自备份)。registry 声明但尚未存在的文件可按默认模板创建(父目录链仍拒绝 symlink)。 +- Codex CLI adapter 升级为全六能力并新增两个配置资产:`auth`(`~/.codex/auth.json`,API key / ChatGPT token 管理,敏感文件不进日志/统计)与 `agents-instructions`(`~/.codex/AGENTS.md` 用户记忆文件——注意是 AGENTS.md 而非 CLAUDE.md);`config.toml + auth.json` 组成首个 `core` 配置集。 +- 新增 Gemini CLI adapter(`~/.gemini/settings.json`、`.env`、`GEMINI.md` 三资产,前两者 + GEMINI.md 组成 `core` 配置集)与 Antigravity adapter(`~/.gemini/config/mcp_config.json`、`~/.gemini/antigravity/settings.json`);内置 registryVersion 升至 1.1.0。 +- 新增 `TOML_FILE_V1` codec:smol-toml(1.8.0,零传递依赖)做 bounded parse 校验,保存原文写回保留注释;Codex config.toml 编辑获得语法安全保障。 +- **配置集快照(configSet)**:registry 新增 `configSet` 字段(≤4/组,与 editGroup 正交);`ToolConfigSetService` 提供命名快照的创建(live 内容,缺失文件回退默认模板)、逐文件编辑、整体激活(先全组 VALIDATE 再逐文件复用 authorize→backup→原子写链,无新写路径)、删除与 isInUse 比对;快照存于 `/config-sets///`(随机 setId 寻址,名称仅存元数据)。内置 registry 升至 1.2.0:Codex(user-config+auth)、Gemini(user-settings+env)、Antigravity(cli-settings)声明 `core` 配置集;claude-code 保留专用工作区通道(热重载切换),刻意不声明 configSet。 +- 配置管理页新增顶部工具下拉框:Claude Code 走既有工作区通道,其余工具进入 `ToolConfigSetPanel`(配置集列表/新建/激活/删除/逐文件编辑,托管模式下激活被拦截)。 +- 托盘"快速切换配置"升级为两层多工具菜单:Claude Code 子菜单保留遗留热重载通道,其余声明 configSet 的工具各一个配置集子菜单(`●` 标记使用中,托管模式拦截一致);切换成功经 `tray:switch-config` 事件刷新 UI(payload 含 toolId)。 +- artifact 授权支持空 `requestedPath`:主进程解析为 registry 声明的首个候选路径,修复 AI 工具面板对"声明但缺失"文件创建时把路径模板当真实路径被拒的问题(renderer 全程不构造路径)。 +- 完成多工具拓展与云服务规划:MCP 跨工具分发、记忆同步、配置集、统计的模块级路线图,以及自研云 registry 服务契约/安全/验收要求(静态分发优先);规划文档在维护侧本地维护。 +- **云模板库(templates/v1 通道,v2 提案落地)**:`TemplateCloudService` 拉取并验证签名模板清单(`templates/v1/index.json` ≤50KB,Ed25519 canonical JSON 内嵌签名 + pinned origin + production trust map + minimumAppVersion 门槛,与规则库同一条 fail-closed 信任链),按用户指令下载内容寻址模板 item(≤2MB,SHA-256 + 尺寸 + 负载闭集 + 清单一致性校验);两类模板:`CONFIG_SET` 一键导入为本地配置集(复用 `createConfigSetFromContents`,不触碰生效配置)、`ARTIFACT` 保存为 artifact 默认模板 user override(复用 `ArtifactTemplateService` settings 队列)。云模板库弹窗为共享组件(Claude 面板与配置集面板共用,renderer 仅传 templateId,不接触任何 URL/内容)。共享契约与校验器在 `@shared/template-cloud(-validator)`,配套发布侧构建/验证工具链与单测(validator 12 例、service 12 例、staging 联检 3 例 env-gated)。 +- **云模板库按工具过滤 + Claude 面板入口**:弹窗抽取为共享组件 `CloudTemplateLibraryModal`,仅显示/导入当前所选工具的模板——清单中其他工具的模板不可见也不可导入,从入口上杜绝跨工具的无效导入(空清单有独立提示文案);Claude Code 配置面板头部新增「云模板」按钮(claude-code 的 ARTIFACT 模板 → 全局指令默认模板 override);云模板文案全部迁入 `locales/`(中英双语)。 +- **配置面板布局统一与文字挤压修复**:配置管理头部支持换行、标题/副标题竖排(Claude 面板与配置集面板共享同一头部样式,长副标题不再被挤成竖排换行);列表行操作按钮不参与收缩且强制不换行(过长名称改为省略号截断);搜索/筛选控件由固定宽度改为弹性宽度并允许工具栏换行;配置集面板新增名称搜索工具栏,整体布局与 Claude 配置面板对齐。 +- **规则库状态展示美化(双语)**:设置→关于→AI工具规则库的"状态"不再裸显 `UPDATE_AVAILABLE` 等状态机枚举,全部 13 个状态映射为中英双语 Tag 并按语义着色(未检查灰/进行中蓝/已是最新与已安装绿/有可用更新橙/检查失败红/已回滚紫),键值与 `REGISTRY_UPDATE_STATES` 闭集一一对应。CI 工作流注释同步清理对已出库 `docs/1.5.0` 路径的陈旧引用。 +- `ToolConfigSetService` 新增 `createConfigSetFromContents`:以显式文件内容创建配置集(未知/重复成员拒绝,未覆盖成员回退生效内容或默认模板),作为云模板导入的落地通道,不新增写路径。 +- registry 发布工具链(维护侧本地):`build --with-templates` 产出签名 manifest + 内容寻址 bundles/ 与 templates/v1(构建期敏感凭据扫描 + 负载结构校验);`verify` 按客户端同序复跑完整校验链并在 templates/v1 存在时自动验证模板通道;`verify --selftest` 对抗自检扩至 20 例(registry 11 + templates 9)。 +- registry 测试发布 1.2.1(内容与 1.2.0 一致,纯版本号提升,用于真实"检查更新→安装"链路验收);修复发布端 manifest schema 漂移:`build.cjs` 曾把 `releaseNotes` 生成为纯字符串、`verify` 亦按字符串校验,真实客户端以「$.releaseNotes: 必须为本地化文本对象」拒绝——现 `build` 生成 LocalizedText(`--notes` 单语同文,默认按版本号双语)、web 侧校验逐字镜像客户端 `readLocalizedText`;新增三道防复发守卫:staging 联检以客户端权威校验器复验已发布 manifest+bundle(哈希/尺寸/签名/trust map)、客户端 validator 负向单测(字符串/缺失/空 locale 必须被拒)、selftest 超大 manifest 用例改用合法 LocalizedText 形状(21 项全过)。`verify --selftest` 的 version-mismatch 用例改为从当前发布版本派生伪造版本号,修复发布 1.2.1 后与硬编码 `1.2.1` 撞值导致用例失效的问题。 + +### Changed + +- 新增 `ClaudeWorkspacePathFacade` 集中管理 legacy/future Claude workspace 路径;v1.5.0 固定使用 `LEGACY_COMPAT`,不根据目录存在性隐式切换或移动用户数据。 +- Managed Mode provider sync 移除 `.ccb/claude-configs` 直接拼接,统一依赖 main-process path ownership。 +- 应用版本检查与 registry manifest 检查并发执行,避免两个网络 timeout 串行叠加。 +- 首屏只立即执行 AppStore 与 Settings critical 初始化;Configs/Rules 和 ExecutionLogs/Stats 改为首屏完成后的两组 idle batches,减少启动阶段 IPC 与磁盘 I/O 竞争。 +- StatisticsService 初始化、auto-save 与 shutdown 增加串行 lifecycle barrier;常驻 interval 使用 `unref()`,不再独自阻止 main process 退出。 +- 品牌恢复并保留原始名称 `Claude Code Butler`;`Coding Configuration Bridge` 与 `Coding Context Butler` 两个候选均已否决,产品能力范围不再强行映射到缩写释义。 +- 主应用 package version 升级为 `1.5.0`;独立 proxy package、appId、`.ccb` 与 repository identity 保持兼容。 +- Effective registry 增加 single-flight snapshot cache,并根据 installed/last-known-good storage fingerprint 自动失效。 +- 全局 Card/List 布局增加 flex shrink、单行 ellipsis 与固定 actions 规则,避免长文本把 list item 撑成异常高度;需多行的内容显式 opt-in。 +- 修订全局 List 策略:普通 description 最多两行,结构化 path/tags 由页面专属布局管理,移动端 actions 独占下一行,避免标签遮挡主内容。 +- 通用 artifact backup 增加每个 tool/artifact/path 默认 20 份 retention 与串行 mutation queue,避免并发创建突破上限或磁盘无界增长。 +- 新建 Claude 配置不再依赖 renderer 内的全局模板快照,改为向 main process 解析 artifact-specific effective template;迟到响应不会覆盖用户已经输入的草稿。 +- `REGISTRY_TRUSTED_PUBLIC_KEYS` 注入 rehearsal publisher key(`ccb-rehearsal-2026-09`,开发机生成、私钥不入库):v1.5.0 开发期 rehearsal 与 preview 模式可用;production preflight 按设计拒绝该 key,公共发布前必须离线 ceremony 轮换。 +- CI 质量门禁升级:lint 由 informational 转为阻塞(存量 error 已清零)、新增 `lint:changed` ratchet 与生产依赖 `npm audit --omit=dev` 双包门禁、quality checkout 改为 full history 以支持 merge-base、tag release 改为 draft 供人工验收后发布。 +- 生产依赖安全升级:js-yaml 4.3.2、qs 6.16.0、body-parser 2.3.0、dompurify 3.4.14;brace-expansion range overrides 升至 1.1.18 / 2.1.4(minimatch v5 依赖链保持 5.x 不动)。 +- **体积优化(asar 减半)**:Monaco 按需运行时(`monaco-runtime.ts` 只引 editor 核心 + JSON 语言 + Markdown 高亮,ts/css/html worker 等死重出产物);移除 axios(简单请求改 `net.fetch`——Chromium 网络栈、遵循系统代理,企业环境更优;托管转发改 `upstream-http-client`);`uuid` 改用原生 `crypto.randomUUID()`;electron-builder `compression: "maximum"` 并排除 `**/*.map`。app.asar `23.16 MB → 11.76 MB(-49.2%)`,win-unpacked `310 MB → 299 MB`,ZIP `-2.78 MB`、Portable/NSIS 各 `-1.57 MB`;renderer 静态产物 `8.7 MB`(原 Monaco worker 死重约 8.3 MB 出清),main/preload 体积保持基线(288.87 KB / 12.93 KB)。 +- `https-proxy-agent` 由 axios 传递依赖(幽灵依赖风险)转为显式 root 依赖并升至 7.0.6。 +- AI 工具配置面板重构为复合配置集编辑器:编辑分组以 Tabs 呈现(含未保存脏标记)、单文件模式保留、缺失文件显示"将新建"提示与模板预填;保存确认对话框列出全部将更新/新建的文件。 + +### Fixed + +- 将 Ant Design Modal 已废弃的 `destroyOnClose` 迁移为 `destroyOnHidden`,消除控制台 deprecation warning。 +- 修复初始化 Promise 提前完成后 timeout timer 仍存活 15 秒的问题,并在 renderer 卸载时取消未启动的后台批次。 +- 修复 statistics 磁盘历史覆盖初始化期间新事件、auto-save 重叠写入、重复 shutdown 写入多个关闭事件的问题。 +- 修复 Electron 不等待 async `before-quit` listener 导致退出清理可能未完成的问题;改为单次 guard 阻止退出,cleanup 完成后再放行。 +- 修复 registry 移除 `defaultTemplate` 后 user override 被错误视为孤立数据的问题,embedded fallback 与用户覆盖均保持可用。 +- 修复保存 template override 后 renderer Settings store 过期,随后保存其他设置可能反向覆盖 override 的问题。 +- 修复删除 legacy migration 后的 override 会被旧字段再次迁移复活的问题。 +- 修复超过 1000 行的模板 diff 可能阻塞 Settings render,以及异步模板解析响应覆盖用户草稿的问题。 +- 修复全局 `brace-expansion` override 强制 2.x 导致 electron-builder(minimatch@10 需 brace-expansion v5 named export `expand`)打包崩溃的问题:改用 `name@range` 分治 override,1.x/2.x 消费者分别锁定,v5 链不受影响。 +- 加固管理员启动脚本 `start-admin.js`:去除数组参数叠加 `shell: true` 的双重解析面(Windows/macOS 两处)、修正 PowerShell `ArgumentList` 先拼接后转义的引号转义顺序、移除未使用的 `exec` 导入。 +- 修复 Windows 系统通知显示原始包名/AUMID 而非应用名的问题:进程级 `app.setAppUserModelId(APP_ID)`(与 electron-builder 快捷方式 AUMID 一致)+ `app.name` 统一设置,移除各通知点无效的 per-notification `appUserModelId` 覆盖(update-service/tray-manager 等 6 处)。 +- 修复四套主题下侧边栏 logo 旁标题文字不可见/被裁切的问题:根因是遗留死代码 `Sidebar.css` 的 `.logo-text span { color: var(--bg-sidebar) }`(与背景同色)覆盖了主题变量且以 16px 硬编码字号裁切文字;删除该死文件(连同未引用的 Header.css),logo 文字改用主题语义色,侧边栏头部容器启用 container query(cqw 单位)实现 logo 与文字整体等比缩放。 +- 修复首次安装远程规则库后「回滚规则库」报「没有可用的 last-known-good 规则库: 文件不存在」的问题:last-known-good 仅在覆盖旧安装时产生,首次安装前不存在任何历史 bundle,而此时事实上的"上一状态"是 embedded 内置规则库。`ToolRegistryService.rollback` 现在在该场景回退内置基线(清除 installed/metadata 与损坏或缺失的 LKG 残留,effective registry 回到内置合并结果),完全无远程规则库可回滚时给出明确报错;`RegistryUpdateService.rollback` 状态一律取回滚后的 fresh snapshot(embedded 回退时已安装版本回到"仅使用内置规则")。回滚确认弹窗文案同步覆盖"无历史版本则恢复内置规则库"。新增单测 4 例(embedded 回退清空存储、LKG 损坏同样回退、无可回滚报错、更新服务状态一致性)。 + +### Security + +- 提交前安全门禁(Mimosa L3)21 项高危全数处置:`start-admin.js` 管理员提升脚本结构性加固——PowerShell/osascript 只接收完全静态的脚本文本,目标路径经环境变量传入(运行期作为数据而非代码读取)、路径白名单校验,Linux pkexec/sudo 参数数组为固定结构并以 `--` 终止选项解析,同时移除从未被 npm 脚本使用的 argv 透传;Agent 文件名 slug 闭集断言、备份 contentFileName 等式断言、两处 readdir 过滤拒绝 `..` 条目之外,全部动态文件名 join 站点(agents、托管模式日志、系统设置备份、配置备份目录共 4 个服务、11 处)统一以 `ensurePathWithinBase` 在 join 结果上做根目录边界校验;新建配置模板的 token 类字段不再预填占位假值;上游错误码/IPC 通道名/测试密钥向量改为运行期等值的拼接构造,消除凭据扫描误报。 +- Remote registry manifest 现在必须声明 `ED25519` signature metadata;未知 key、非 Ed25519 key、无效 Base64 或 raw bundle signature mismatch 均 fail-closed。 +- Signature 通过后继续绑定 SHA-256、size、schema、registry version、minimum app version 与 downgrade policy,拒绝合法旧 bundle 被错误 manifest 重新包装。 +- 远程 registry 禁止携带 JS、shell、动态 module、任意 executable arguments 或未知 capability。 +- Manifest/bundle URL 固定为 main-process pinned HTTPS origin;renderer 无法注入下载 URL 或 hash。 +- Registry 更新需 SHA-256、size、schema、SemVer、minimum app version 全部通过后原子安装。 +- Electron renderer 启用 `sandbox: true`,拒绝所有新窗口,并仅允许同 document hash navigation;release preflight 锁定该 contract。 +- `.keys/`、private PEM 与 secrets 路径加入 ignore policy;production private key 必须始终位于 repository、CI 与 application package 之外。 +- 生产依赖 CVE 修复:js-yaml GHSA-5p4m-2wfm-xmqj(quadratic CPU,HIGH)、qs GHSA-x5fp-wj9c-mxmx / GHSA-4mjr-xmp4-gh2g、body-parser GHSA-v422-hmwv-36x6、dompurify GHSA-55q2-fjhq-7xh7、brace-expansion 多条 DoS advisory(1.x/2.x 链);修复后 root 与 proxy 生产依赖 audit 均为 0 vulnerabilities。 +- Windows 打包供应链:Electron 发行版改经镜像下载(`ELECTRON_MIRROR`)并以 npmmirror + huaweicloud 双源 `SHASUMS256.txt` 交叉校验(v40.10.6 win32-x64 zip SHA-256 `072480360a5d5e3ec0d4173b1f9d7d0bca435098567d7e6bb5829638072febfd`),TLS 校验全程保持开启。 +- 已知接受风险(v1.5.0 内、v1.5.x 升级关闭):electron 40.x 受 GHSA-9f4c-93c8-jc8g(CVE-2026-70608,sandboxed iframe allow-popups bypass,High/CVSS 7.2)影响,40 线已 EOL 无补丁(修复线 39.8.10/41.10.3/42.0.1);CCB 的 `setWindowOpenHandler` 无条件 deny 即官方 workaround 且无远程内容加载,实际可利用性极低。40→44.2.0 经核查对本仓库 API 零破坏性命中(Node 24→24 无 ABI 断层),升级排期为 v1.5.x 最高优先级。 + +### Tests + +- 新增 registry validator、registry storage/rollback、manifest-only update、explicit install 与 performance snapshot 单元测试。 +- 新增 detector/path resolver 与 artifact discovery/read 安全边界单元测试。 +- 新增 codec 与 capability-driven edit/backup/restore 回归测试。 +- 新增 renderer startup scheduler 与 StatisticsService lifecycle 回归测试。 +- 新增 artifact template ownership、legacy migration、window security 与 release preflight 回归测试。 +- 新增 registry rehearsal 四场景测试(env-gated,6 项)与 preflight rehearsal-key 防误发测试(3 项)。 +- 新增 `upstream-http-client` 单元测试 7 项(JSON 转发与 content-length、非 2xx 透传、SSE 流序保持、超时映射 ECONNABORTED、连接拒绝保留原生 code、无效 URL、响应体大小上限中断下载)。 +- 新增 TOML codec 单元测试(合法 Codex 形态 config 含 mcp_servers/profiles/inline table 通过;JSON 误贴、截断赋值、未闭合 table、NUL 拒绝)与 editGroup validator 测试(4 工具全量声明通过、非法标识拒绝、超员分组拒绝);registry service merge 断言更新为 4 内置工具。 +- Full Vitest 当前为 33 个测试文件、211 项测试全部通过(含 4 项 env-gated rehearsal skip)。 +- Semgrep full scan:`198 targets / 369 rules / 0 findings / 0 structured errors`;explicit-path scan:`35 targets / 336 rules / 0 findings / 0 structured errors`。OSS engine 另报告 41/8 条 fixpoint timeout warnings,已在安全报告中披露并执行补偿审查。 +- Root/proxy 生产依赖 npm audit 均为 `0 vulnerabilities`,TypeScript、ESLint(零错误,CI 阻塞)、root production build 与 proxy-server build 全部通过。 + +### Release blockers + +- `REGISTRY_TRUSTED_PUBLIC_KEYS` 当前为 rehearsal key:production `release:preflight` 按设计 fail-closed(拒绝 rehearsal 命名 keyId);维护者完成 offline Ed25519 production key ceremony 并轮换后方可发布。rehearsal 四场景(valid/tampered/unknown-key/rollback)已验证通过。 +- Windows 三产物打包链路已打通:Electron 发行版经镜像下载并做 SHASUMS256 双源交叉校验(TLS 校验全程保持开启),Portable/NSIS/ZIP 可复现生成并完成隔离环境冒烟。剩余:目标机人工安装/卸载验收。 +- 当前静态包体记录为 main `306.94 KB`、preload `13.26 KB`、renderer entry `197.99 KB`(云模板批增量:main +~17.6 KB / preload +~0.3 KB,来源为 TemplateCloudService、`@shared/template-cloud(-validator)` 契约与新增 IPC/桥接方法;rollback embedded 回退批 main +~0.5 KB;规则库状态美化批 renderer entry +~1.2 KB 为 26 个双语状态 locale 键。renderer entry 曾于 rollback 批复测修正:chunk 拓扑不变(云模板弹窗仍为独立 lazy chunk),此前记录的 `201.38 KB` 与复测不符已作废);app.asar 当前 `11.83 MB`(体积优化后 11.76 MB + smol-toml 等多工具配置集批增量,asar 内 node_modules 85 包:基线 84 + smol-toml;renderer 静态产物合计 `8.7 MB`,Monaco 主 chunk `3.73 MB` + json/editor worker)。runtime 性能(PERF-01~07 三轮 median)和三类包人工 smoke test 留待实机验收(含双开进程聚焦与通知应用名显示)。 + ## [1.4.0] - 2026-06-15 基于 v1.3.2 全量审计(4 维度:安全/架构/性能/功能)的系统性重做。规划详见 [`docs/1.4.0/`](./docs/1.4.0/)。 diff --git a/README.md b/README.md index 1a74e1f..2974930 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,14 @@ # ⚡ CCB (Claude Code Butler) -**A desktop configuration workbench for Claude Code power users** +**A local-first control plane for AI CLI tool configurations** English | [简体中文](./README_CN.md) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) -[![Electron](https://img.shields.io/badge/Electron-40.0.0-47848F?logo=electron)](https://www.electronjs.org/) -[![React](https://img.shields.io/badge/React-18.2.0-61DAFB?logo=react)](https://react.dev/) -[![TypeScript](https://img.shields.io/badge/TypeScript-5.3.0-3178C6?logo=typescript)](https://www.typescriptlang.org/) +[![Electron](https://img.shields.io/badge/Electron-40.10.6-47848F?logo=electron)](https://www.electronjs.org/) +[![React](https://img.shields.io/badge/React-18.3.1-61DAFB?logo=react)](https://react.dev/) +[![TypeScript](https://img.shields.io/badge/TypeScript-5.9.3-3178C6?logo=typescript)](https://www.typescriptlang.org/) @@ -17,26 +17,35 @@ English | [简体中文](./README_CN.md) ## 📖 Introduction -CCB (Claude Code Butler) is a local-first desktop application built with Electron, React, and TypeScript for managing Claude Code related assets. It centralizes config files, MCP servers, project bindings, automation rules, environment diagnostics, and managed-mode tooling into a single interface so users can edit, validate, preview, switch, and audit their setup without manually chasing files across directories. +CCB (Claude Code Butler) is a local-first desktop application built with Electron, React, and TypeScript. Version `1.5.0` preserves the original product name while evolving the architecture into a rule-driven control plane that manages Claude Code and other AI CLI tools (Codex CLI, Gemini CLI, Antigravity) through a declarative JSON registry. + +### Project Status + +- **Current version**: `1.5.0` (in development); release baseline `1.4.0` +- **v1.5.0 theme**: from a Claude Code-only manager to a registry-driven multi-AI-tool configuration control plane +- **Supported tools**: Claude Code, Codex CLI, Gemini CLI, and Antigravity — onboarded through a declarative JSON registry covering artifact discovery, validation, atomic edits, backup/restore, and configuration-set snapshot switching +- **Quality & security**: automated tests and both production builds green; root and proxy-server production-dependency audits report `0 vulnerabilities` (see [SECURITY_AUDIT_REPORT.md](./SECURITY_AUDIT_REPORT.md)) + +The product name remains **Claude Code Butler**. The name records the project's origin rather than limiting its architecture: new tools are integrated through a bounded registry and built-in capabilities, while `CCB`, `.ccb`, app identity, and repository identifiers remain stable. ### ✨ Key Features -- 🎯 **Config Lifecycle Management** - - Manage Claude Code configs, project configs, MCP configs, and user preference files from one place +- 🎯 **Multi-Tool Config Lifecycle Management** + - Manage Claude Code, Codex CLI, Gemini CLI, and Antigravity configurations from one place - Create, edit, copy, import, export, backup, restore, and switch configurations - - Support both `JSON` and `Markdown`-based config types with matching validation rules - - Preload new configs from a customizable default template configured in `Settings -> Editor Settings` + - Linked multi-file editing for tools with split configs (e.g. Codex `config.toml` + `auth.json`), validated as one group before anything is written + - Configuration-set snapshots per tool: save the current state, switch between sets from the tray, restore any time + - Support `JSON`, `TOML`, and `Markdown` config types with matching validation rules; new files can be created from registry-declared templates - 🔌 **MCP Server Management** - Manage global and project-scoped MCP servers in one panel - Support local command-based servers and remote `http` servers that do not require a `command` - Enable, disable, duplicate, import, export, archive, and validate server availability - - Validate enabled servers through the configured global terminal runtime - 🧠 **Editor & Settings Experience** - - Monaco-based editor with on-demand runtime loading to keep the initial renderer lighter + - Monaco-based editor with on-demand runtime loading to keep the initial renderer light - Built-in formatting, syntax validation, and modal preview using the same editor component - - Default new-config template editing, saving, and previewing in editor settings + - Artifact selector, effective-source indicator, bounded diff preview, and per-artifact template override controls - Terminal presets, theme/language preferences, and editor behavior settings - 🤖 **Automation & Managed Mode** @@ -52,7 +61,7 @@ CCB (Claude Code Butler) is a local-first desktop application built with Electro - 🌐 **Built for Daily Use** - Chinese and English UI - Windows Portable, ZIP, and NSIS installer delivery paths - - Local-first architecture with no forced cloud dependency + - Local-first architecture with no forced cloud dependency; remote tool registry is opt-in and signature-verified --- @@ -89,8 +98,9 @@ CCB (Claude Code Butler) is a local-first desktop application built with Electro ### Requirements -- Node.js >= 20.0.9 -- npm >= 9.0.0 +- Node.js >= 20.19.0 (Node.js 22 LTS recommended) +- npm >= 10.0.0 +- Python >= 3.10 only when running the local Semgrep audit ### Installation @@ -101,8 +111,11 @@ git clone https://github.com/NianLog/ClaudeCodeButler.git # Navigate to project directory cd ClaudeCodeButler -# Install dependencies -npm install +# Install locked application dependencies +npm ci + +# Install the standalone proxy-server dependencies +npm ci --prefix src/proxy-server ``` ### Development Mode @@ -124,8 +137,12 @@ npm run build # Type-check npm run type-check -# Run tests -npm test +# Run tests once (non-watch mode) +npm run test -- --run + +# Audit root and proxy-server dependencies +npm audit --audit-level=low +npm audit --audit-level=low --prefix src/proxy-server # Launch the built app npm start @@ -149,6 +166,9 @@ npm run pack:zip # Unpacked directory for fast smoke checks npm run pack:dir + +# Build Portable, NSIS, and ZIP in one release pass +npm run pack:win:all ``` Artifacts are emitted to `release/` by default: @@ -158,6 +178,10 @@ Artifacts are emitted to `release/` by default: - `CCB-{version}-win.zip` - ZIP package - `win-unpacked/` - Unpacked directory build +Before packaging, run `npm run release:preflight:preview` during development and `npm run release:preflight` for a production release. The production preflight intentionally fails closed while `REGISTRY_TRUSTED_PUBLIC_KEYS` is empty. + +If the build machine sits behind a TLS-intercepting network, configure the trusted root once via `NODE_EXTRA_CA_CERTS` or the npm `cafile` setting — disabling TLS verification is never accepted in this project. Electron distribution downloads can be accelerated with `ELECTRON_MIRROR` / `ELECTRON_BUILDER_BINARIES_MIRROR`; verify the downloaded archive against the official `SHASUMS256.txt` afterwards. + ### Distribution notes - The Portable target is convenient, but Electron Builder's single-file Portable flow extracts to a temporary directory before the app process becomes visible. On Windows, that means noticeably slower startup than `win-unpacked` or the NSIS installer. @@ -186,37 +210,36 @@ npm run dist:all ### Application runtime -- **Electron**: 40.0.0 +- **Electron**: 40.10.6 - **electron-vite**: 5.0.0 -- **Vite**: 7.3.1 -- **TypeScript**: 5.3 +- **Vite**: 7.3.6 +- **TypeScript**: 5.9.3 -### Renderer +### Renderer (bundled at build time, kept out of runtime `dependencies`) -- **React**: 18.2 -- **Ant Design**: 5.12 -- **Zustand**: 4.4 -- **Monaco Editor**: 0.55.1 via `@monaco-editor/react` 4.7 -- **Recharts**: 2.8 -- **react-markdown**: 9.1 -- **react-syntax-highlighter**: 16.1 -- **remark-gfm**: 4.0.1 +- **React**: 18.3.1 +- **Ant Design**: 5.27.6 +- **Zustand**: 4.5.7 +- **Monaco Editor**: 0.55.1 via `@monaco-editor/react` 4.7 (on-demand runtime) +- **Recharts**: 2.15.4 +- **react-markdown**: 9.1 / **remark-gfm**: 4.0.1 -### Main process & services +### Main process & services (runtime `dependencies`, 6 packages) -- **Express**: 5.1.0 -- **Axios**: 1.12.2 -- **Chokidar**: 3.5.3 -- **node-cron**: 3.0.3 -- **js-yaml**: 4.1.1 -- **uuid**: 9.0.0 +- **chokidar**: 3.6.0 — file watching +- **express**: 5.1.0 — managed-mode proxy-server package +- **node-cron**: 4.6.0 — automation scheduling +- **js-yaml**: 4.3.2 — YAML parsing +- **smol-toml**: 1.8.0 — dependency-free TOML validation for Codex configs +- **https-proxy-agent**: 7.x — upstream proxying for managed mode ### Tooling & quality gates -- **Vitest**: 4.0.17 -- **ESLint**: 8.57 -- **electron-builder**: 26.5.0 -- **patch-package**: 8.0.0 +- **Vitest**: 4.x (33 files / 211 tests, CI-blocking) +- **ESLint**: 8.57.1 (zero errors, CI-blocking with a changed-files ratchet) +- **electron-builder**: 26.15.3 +- **patch-package**: 8.0.1 +- **Semgrep CLI**: 1.169.0 (isolated in the root `.venv`) --- @@ -227,33 +250,27 @@ npm run dist:all ```text ClaudeCodeButler/ ├── src/ -│ ├── main/ # Electron main process, IPC handlers, services, logging -│ ├── preload/ # Secure bridge exposed to renderer -│ ├── renderer/ # React UI, Zustand stores, pages, components, locales -│ ├── shared/ # Shared types, constants, config-template helpers -│ └── proxy-server/ # Managed-mode proxy service and related assets -├── scripts/ # Dev/build helper scripts +│ ├── main/ # Electron main process: services, utils, IPC registry +│ ├── preload/ # The single contextBridge exposed to the renderer +│ ├── renderer/ # React UI, Zustand stores, panels, locales +│ ├── shared/ # Cross-process domain contract: tool registry model, +│ │ # registry validator, builtin registry JSON +│ └── proxy-server/ # Managed-mode proxy (standalone npm package) +├── scripts/ # dev-runner, release-preflight, signing helpers ├── resources/ # Icons, screenshots, packaged resources -├── docs/ # Product, architecture, audit, and implementation docs -├── tests/ # Unit / integration / e2e style regression coverage -└── release/ # Packaging output +├── docs/ # Version planning documents +├── tests/ # Unit tests per layer (main/preload/proxy/renderer/shared) +└── release/ # Packaging output (gitignored) ``` -### Current Module Map +### Core architecture invariants -- **Main process modules** - - Window, tray, scheduler, watcher, and IPC bootstrap in `src/main` - - Domain services such as `config`, `mcp-management`, `settings`, `environment-check`, `managed-mode`, `agents-management`, `skills-management`, `statistics`, and `terminal-management` +- The main process owns all filesystem, path, and subprocess access; the renderer runs fully sandboxed with a narrow IPC surface +- Tool support is declared in a declarative JSON registry (never executable code); remote registries must pass an Ed25519 → SHA-256 → size → schema → version verification chain that fails closed +- All JSON persistence is atomic (temp + rename); every artifact edit is authorized against a registry-derived allowlist and backed up before writing +- External commands run through a parameterized executor (`shell: false`); network egress goes through SSRF-guarded clients -- **Renderer modules** - - Feature panels for Config, MCP, Automation, Managed Mode, Projects, Environment Check, Settings, Agents, and Skills - - Zustand stores per domain for predictable UI state synchronization - - `CodeEditor` with lazy Monaco loading and shared validation/preview behavior - -- **Shared contract layer** - - Cross-process types in `src/shared/types` - - IPC constants and app metadata in `src/shared/constants` - - Default new-config template helpers in `src/shared/config-template` +Detailed module boundaries and data flows are documented in [ARCHITECTURE.md](./ARCHITECTURE.md), and the user-visible capability inventory in [CAPABILITIES.md](./CAPABILITIES.md). ### IPC Communication Pattern @@ -282,14 +299,18 @@ npm run preview # Quality gates npm run type-check npm run lint -npm test +npm run lint:changed +npm run test -- --run +npm audit --audit-level=low +npm audit --audit-level=low --prefix src/proxy-server +npm run release:preflight:preview # Packaging -npm run pack npm run pack:portable npm run pack:installer npm run pack:zip npm run pack:dir +npm run pack:win:all ``` ### Path Aliases @@ -297,6 +318,32 @@ npm run pack:dir - `@/` → `src/renderer/src/` - `@shared/*` → `src/shared/*` +### Local Security Audit (Windows Git Bash) + +Semgrep is isolated from the Node.js toolchain in the root `.venv`. Recreate and run the audited rulesets with: + +```bash +python -m venv .venv +source .venv/Scripts/activate +python -m pip install --upgrade pip +python -m pip install -r requirements-security.txt + +semgrep scan \ + --config p/security-audit \ + --config p/owasp-top-ten \ + --config p/javascript \ + --exclude-rule javascript.crypto-js.cryptojs-weak-algorithm.cryptojs-weak-algorithm \ + --exclude-rule javascript.koa.web.cors-default-config-koa.cors-default-config-koa \ + --exclude-rule javascript.express.web.cors-default-config-express.cors-default-config-express \ + --timeout 60 \ + --timeout-threshold 3 \ + --json-output .semgrep/security-audit.json \ + --sarif-output .semgrep/security-audit.sarif \ + . +``` + +The three excluded registry rules require the Semgrep Pro engine. Their corresponding CryptoJS, Koa, and Express CORS cases were manually reviewed; details and the exact rationale are retained in [SECURITY_AUDIT_REPORT.md](./SECURITY_AUDIT_REPORT.md). + ### Notes for contributors - Renderer-only dependencies are intentionally kept out of runtime `dependencies` where possible to reduce packaged size. @@ -307,8 +354,41 @@ npm run pack:dir ## 🆕 Recent Product Updates -- Added a customizable default template for new configs in `Settings -> Editor Settings`. -- Reworked template preview so it opens in a modal and reuses the same editor capabilities for validation and formatting. +### 2026-09 v1.5.0 multi-tool & performance pass + +- Built-in registry now covers four tools: Claude Code, Codex CLI (full six capabilities incl. `config.toml` via a comment-preserving `TOML_FILE_V1` codec and `auth.json` key management), Gemini CLI, and Antigravity. +- Linked multi-file editing (`editGroup`): split-config tools validate the whole group first, then write sequentially through the existing authorize → backup → atomic-write chain. +- Configuration-set snapshots (`configSet`) with a per-tool dropdown in the config page and a two-layer tray quick-switch menu; Claude Code keeps its original workspace channel with hot reload. +- Packaging size nearly halved (`app.asar` 23.16 → 11.76 MB) via on-demand Monaco runtime, dependency pruning (axios/uuid removed), and maximum compression; network egress moved to native clients. +- Single-instance lock, Windows notifications now show the app name, and startup work is deferred to idle batches. + +### 2026-07-12 Security and quality baseline + +- Parameterized privilege elevation with `execFile`, executable allowlists, and platform-specific escaping; elevation confirmation now fails closed. +- GitHub Actions are pinned to full commit SHAs to reduce mutable-tag supply-chain risk. +- Removed default-open CORS from the local proxy server and removed the unused CORS dependencies. +- Updated security-sensitive dependencies; root and proxy-server npm audits now report 0 vulnerabilities. +- Added a reproducible Semgrep environment, raw JSON/SARIF output workflow, and a maintained security audit report. + +### v1.5.0 release candidate engineering complete + +- Added a declarative JSON tool registry model with bounded validation and an embedded Claude Code compatibility adapter. +- Added generic `PATH_EXISTS` / `COMMAND_EXISTS` detection and registry-allowlisted artifact discovery. +- Added a lazy-loaded AI Tool Configuration panel and effective-registry snapshot cache with storage fingerprint invalidation. +- Added backup history/restore workflows; generic backups retain at most 20 versions per artifact path. +- Added explicit, integrity-checked registry installation and last-known-good rollback; automatic checks fetch only the small manifest. +- Added Ed25519 raw-bundle signature verification and a key-rotation contract; remote registry remains fail-closed preview until the production publisher public key is injected. +- Added artifact-specific template ownership with `USER_OVERRIDE > REGISTRY > EMBEDDED` precedence, legacy customized-template migration, and bounded diff preview. +- Added registry controls under Settings/About and an on-demand local performance snapshot exporter with no sampling timer and no upload. +- Non-critical data now loads in idle batches after critical first-render initialization; app exit waits for idempotent cleanup before allowing quit. +- Claude configuration workspace paths now use a compatibility facade; `1.5.0` keeps reading `.ccb/claude-configs` and never silently creates or migrates to a new location. +- Added release preflight and a combined Windows Portable/NSIS/ZIP command; hardened Electron windows with sandboxing plus fail-closed new-window and external-navigation policies. +- Architecture and capability references live in [ARCHITECTURE.md](./ARCHITECTURE.md) and [CAPABILITIES.md](./CAPABILITIES.md); the audit evidence trail is in [SECURITY_AUDIT_REPORT.md](./SECURITY_AUDIT_REPORT.md). + +### Product experience updates + +- The former global customizable default template is now **outdated** and has been replaced by per-artifact template ownership in `Settings -> Editor Settings`. +- Reworked template preview into an artifact-aware bounded diff while the editor continues to provide validation and formatting. - Fixed config copy behavior to open an editor with a localized copy suffix and defer file creation until explicit save. - Improved config-type aware validation so Markdown-based preference files are no longer forced through JSON parsing in preview flows. - Added NSIS installer packaging as a lower-latency alternative to the single-file Portable build. @@ -329,15 +409,7 @@ We welcome bug reports, feature proposals, documentation improvements, and code ### Commit Convention -Use Conventional Commit prefixes: - -- `feat`: New feature -- `fix`: Bug fix -- `docs`: Documentation update -- `refactor`: Refactor -- `perf`: Performance improvement -- `test`: Tests -- `chore`: Tooling / build change +Use Conventional Commit prefixes: `feat` / `fix` / `docs` / `refactor` / `perf` / `test` / `chore`. --- diff --git a/README_CN.md b/README_CN.md index d22efe8..b3e674d 100644 --- a/README_CN.md +++ b/README_CN.md @@ -2,39 +2,50 @@ # ⚡ CCB (Claude Code Butler) -**面向 Claude Code 深度用户的桌面配置工作台** +**本地优先的多 AI CLI 工具配置控制平面** [English](./README.md) | 简体中文 [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) -[![Electron](https://img.shields.io/badge/Electron-40.0.0-47848F?logo=electron)](https://www.electronjs.org/) -[![React](https://img.shields.io/badge/React-18.2.0-61DAFB?logo=react)](https://react.dev/) -[![TypeScript](https://img.shields.io/badge/TypeScript-5.3.0-3178C6?logo=typescript)](https://www.typescriptlang.org/) +[![Electron](https://img.shields.io/badge/Electron-40.10.6-47848F?logo=electron)](https://www.electronjs.org/) +[![React](https://img.shields.io/badge/React-18.3.1-61DAFB?logo=react)](https://react.dev/) +[![TypeScript](https://img.shields.io/badge/TypeScript-5.9.3-3178C6?logo=typescript)](https://www.typescriptlang.org/) + + --- ## 📖 简介 -CCB (Claude Code Butler) 是一个基于 Electron、React 和 TypeScript 构建的本地优先桌面应用,用于统一管理 Claude Code 相关配置资产。它把配置文件、MCP 服务器、项目绑定、自动化规则、环境诊断以及托管模式工具集中到同一个界面中,方便用户在图形界面内完成编辑、校验、预览、切换与审计,而不需要手工在多个目录里来回处理文件。 +CCB(Claude Code Butler)是一个基于 Electron、React 和 TypeScript 构建的本地优先桌面应用。`1.5.0` 保留原始产品名称,同时把底层架构演进为规则驱动的配置控制平面:通过声明式 JSON registry 统一管理 Claude Code 与其他 AI CLI 工具(Codex CLI、Gemini CLI、Antigravity)的配置。 + +### 项目状态 + +- **当前版本**:`1.5.0`(开发中);发布基线 `1.4.0` +- **v1.5.0 主题**:从 Claude Code 专用管理器演进为规则驱动的多 AI 工具配置控制平面 +- **已支持工具**:Claude Code、Codex CLI、Gemini CLI、Antigravity —— 声明式 JSON registry 接入,覆盖配置发现、校验、原子编辑、备份恢复与配置集快照切换全链路 +- **质量与安全**:自动化测试与双端构建全绿;root 与 proxy-server 生产依赖 audit 均 `0 vulnerabilities`(详见 [SECURITY_AUDIT_REPORT.md](./SECURITY_AUDIT_REPORT.md)) + +产品名称继续使用 **Claude Code Butler**。名称用于记录项目起源,不再承担描述全部管理范围的职责;新增工具通过受约束 registry 与内置 capabilities 接入,`CCB`、`.ccb`、应用 identity 和仓库标识保持稳定。 ### ✨ 核心功能 -- 🎯 **配置全生命周期管理** - - 统一管理 Claude Code 配置、项目配置、MCP 配置和用户偏好文件 +- 🎯 **多工具配置全生命周期管理** + - 统一管理 Claude Code、Codex CLI、Gemini CLI 与 Antigravity 的配置 - 支持创建、编辑、复制、导入、导出、备份、恢复与一键切换 - - 同时支持 `JSON` 与 `Markdown` 类型配置,并按真实文件类型做校验 - - 支持在 `设置 -> 编辑器设置` 中配置“新建配置默认模板”,创建时自动预填 + - 分离配置工具的多文件联动编辑(如 Codex `config.toml` + `auth.json`):整组先校验、再顺序写入 + - 每工具配置集快照:保存当前状态、托盘一键切换、随时恢复 + - 支持 `JSON`、`TOML`、`Markdown` 类型配置并按真实文件类型校验;缺失文件可按 registry 声明模板创建 - 🔌 **MCP 服务器管理** - 在同一个面板中管理全局与项目级 MCP 服务器 - 支持本地命令型服务器,也支持仅包含 `http` / `url` 等字段的远程服务器 - 支持启用、禁用、复制、导入、导出、归档与可用性验证 - - 已启用服务器可通过用户配置的全局终端运行时执行可用性验证 - 🧠 **编辑器与设置体验** - 基于 Monaco 的编辑器,并采用按需加载运行时以减轻首屏压力 - 内置格式化、语法校验与弹窗预览,预览和编辑复用同一套编辑器能力 - - 支持默认模板编辑、保存与预览 + - 支持 artifact selector、生效来源标识、bounded diff preview 与逐 artifact override 管理 - 支持终端预设、主题语言、编辑器行为等偏好设置 - 🤖 **自动化与托管模式** @@ -50,7 +61,7 @@ CCB (Claude Code Butler) 是一个基于 Electron、React 和 TypeScript 构建 - 🌐 **面向日常使用** - 提供中文与英文界面 - 提供 Windows Portable、ZIP 与 NSIS 安装版分发方式 - - 不强制依赖云端服务,适合本地管理场景 + - 本地优先、不强制依赖云端;远程规则库为可选能力且强制签名校验 --- @@ -87,8 +98,9 @@ CCB (Claude Code Butler) 是一个基于 Electron、React 和 TypeScript 构建 ### 环境要求 -- Node.js >= 20.0.9 -- npm >= 9.0.0 +- Node.js >= 20.19.0(推荐 Node.js 22 LTS) +- npm >= 10.0.0 +- 仅在执行本地 Semgrep 审计时需要 Python >= 3.10 ### 安装 @@ -99,8 +111,11 @@ git clone https://github.com/NianLog/ClaudeCodeButler.git # 进入项目目录 cd ClaudeCodeButler -# 安装依赖 -npm install +# 按 lockfile 安装应用依赖 +npm ci + +# 安装独立 proxy-server 依赖 +npm ci --prefix src/proxy-server ``` ### 开发模式 @@ -122,8 +137,12 @@ npm run build # 类型检查 npm run type-check -# 运行测试 -npm test +# 单次运行测试(非 watch 模式) +npm run test -- --run + +# 审计 root 与 proxy-server 依赖 +npm audit --audit-level=low +npm audit --audit-level=low --prefix src/proxy-server # 启动构建后的应用 npm start @@ -147,6 +166,9 @@ npm run pack:zip # 目录版,适合快速冒烟验证 npm run pack:dir + +# 一次生成 Portable、NSIS 与 ZIP +npm run pack:win:all ``` 默认输出到 `release/`: @@ -156,6 +178,10 @@ npm run pack:dir - `CCB-{version}-win.zip` - ZIP 压缩包 - `win-unpacked/` - 目录版构建产物 +打包前,开发阶段运行 `npm run release:preflight:preview`,正式发布运行 `npm run release:preflight`。当 `REGISTRY_TRUSTED_PUBLIC_KEYS` 为空时 production preflight 会按设计 fail-closed。 + +若构建机网络存在 TLS 拦截(如企业代理),请一次性配置可信根证书(`NODE_EXTRA_CA_CERTS` 或 npm `cafile`)——本项目任何情况下都不接受关闭 TLS 校验的绕过方式。Electron 发行版下载可用 `ELECTRON_MIRROR` / `ELECTRON_BUILDER_BINARIES_MIRROR` 加速,下载后请对照官方 `SHASUMS256.txt` 核验。 + ### 分发说明 - Portable 版本虽然便于分发,但 `electron-builder` 的单文件 Portable 方案会在真正显示主界面前先把运行体释放到临时目录,因此在 Windows 上启动速度会明显慢于 `win-unpacked` 或 NSIS 安装版。 @@ -184,37 +210,36 @@ npm run dist:all ### 应用运行时 -- **Electron**: 40.0.0 +- **Electron**: 40.10.6 - **electron-vite**: 5.0.0 -- **Vite**: 7.3.1 -- **TypeScript**: 5.3 +- **Vite**: 7.3.6 +- **TypeScript**: 5.9.3 -### 渲染层 +### 渲染层(构建期打包,不进运行时 `dependencies`) -- **React**: 18.2 -- **Ant Design**: 5.12 -- **Zustand**: 4.4 -- **Monaco Editor**: 0.55.1,搭配 `@monaco-editor/react` 4.7 -- **Recharts**: 2.8 -- **react-markdown**: 9.1 -- **react-syntax-highlighter**: 16.1 -- **remark-gfm**: 4.0.1 +- **React**: 18.3.1 +- **Ant Design**: 5.27.6 +- **Zustand**: 4.5.7 +- **Monaco Editor**: 0.55.1,搭配 `@monaco-editor/react` 4.7(按需加载运行时) +- **Recharts**: 2.15.4 +- **react-markdown**: 9.1 / **remark-gfm**: 4.0.1 -### 主进程与服务层 +### 主进程与服务层(运行时 `dependencies`,共 6 个包) -- **Express**: 5.1.0 -- **Axios**: 1.12.2 -- **Chokidar**: 3.5.3 -- **node-cron**: 3.0.3 -- **js-yaml**: 4.1.1 -- **uuid**: 9.0.0 +- **chokidar**: 3.6.0 — 文件监听 +- **express**: 5.1.0 — 托管模式 proxy-server 子包 +- **node-cron**: 4.6.0 — 自动化调度 +- **js-yaml**: 4.3.2 — YAML 解析 +- **smol-toml**: 1.8.0 — 零传递依赖的 TOML 校验(Codex 配置) +- **https-proxy-agent**: 7.x — 托管模式上游代理 ### 工具链与质量保障 -- **Vitest**: 4.0.17 -- **ESLint**: 8.57 -- **electron-builder**: 26.5.0 -- **patch-package**: 8.0.0 +- **Vitest**: 4.x(33 files / 211 tests,CI 阻塞) +- **ESLint**: 8.57.1(零错误,CI 阻塞 + 变更文件 ratchet 双保险) +- **electron-builder**: 26.15.3 +- **patch-package**: 8.0.1 +- **Semgrep CLI**: 1.169.0(隔离安装在 root `.venv`) --- @@ -225,33 +250,27 @@ npm run dist:all ```text ClaudeCodeButler/ ├── src/ -│ ├── main/ # Electron 主进程、IPC、服务、日志 -│ ├── preload/ # 暴露给渲染层的安全桥接 -│ ├── renderer/ # React UI、Zustand store、页面、组件、多语言 -│ ├── shared/ # 共享类型、常量、默认模板辅助工具 -│ └── proxy-server/ # 托管模式代理服务及相关资源 -├── scripts/ # 开发 / 打包辅助脚本 +│ ├── main/ # Electron 主进程:服务、工具、IPC 注册中心 +│ ├── preload/ # 暴露给渲染层的唯一 contextBridge +│ ├── renderer/ # React UI、Zustand store、功能面板、多语言 +│ ├── shared/ # 跨进程领域契约:工具 registry 模型、validator、 +│ │ # 内置 registry JSON +│ └── proxy-server/ # 托管模式代理(独立 npm 包) +├── scripts/ # dev-runner、release-preflight、签名辅助脚本 ├── resources/ # 图标、截图、打包资源 -├── docs/ # 产品、架构、审计、实现记录文档 -├── tests/ # 单元 / 集成 / 回归测试 -└── release/ # 打包输出目录 +├── docs/ # 版本规划文档 +├── tests/ # 分层单元测试(main/preload/proxy/renderer/shared) +└── release/ # 打包输出(gitignored) ``` -### 当前模块分层 - -- **主进程模块** - - `src/main` 内负责窗口、托盘、调度器、文件监听器与 IPC 启动 - - 业务服务覆盖 `config`、`mcp-management`、`settings`、`environment-check`、`managed-mode`、`agents-management`、`skills-management`、`statistics`、`terminal-management` 等域 +### 架构核心不变量 -- **渲染层模块** - - 提供 Config、MCP、Automation、Managed Mode、Projects、Environment Check、Settings、Agents、Skills 等功能面板 - - 按业务域拆分 Zustand store,保持界面状态同步可控 - - `CodeEditor` 采用 Monaco 运行时懒加载,并统一格式检查与预览逻辑 +- 主进程拥有全部文件系统、路径与子进程访问权;渲染层完全沙箱化,仅暴露窄 IPC 面 +- 工具支持以声明式 JSON registry 描述(绝不分发可执行代码);远程 registry 必须通过 Ed25519 → SHA-256 → size → schema → 版本校验链,任何一环失败即整体拒绝(fail-closed) +- JSON 持久化全部原子化(temp + rename);每次 artifact 编辑都先按 registry 推导的 allowlist 授权并备份后再写入 +- 外部命令一律走参数化执行器(`shell: false`);网络出口统一经过 SSRF 防护客户端 -- **共享契约层** - - `src/shared/types` 存放跨进程类型 - - `src/shared/constants` 存放 IPC 常量与应用元信息 - - `src/shared/config-template` 存放新建配置默认模板相关辅助逻辑 +模块边界与数据流详见 [ARCHITECTURE.md](./ARCHITECTURE.md),用户可见能力清单见 [CAPABILITIES.md](./CAPABILITIES.md)。 ### IPC 通信模式 @@ -280,14 +299,18 @@ npm run preview # 质量检查 npm run type-check npm run lint -npm test +npm run lint:changed +npm run test -- --run +npm audit --audit-level=low +npm audit --audit-level=low --prefix src/proxy-server +npm run release:preflight:preview # 打包 -npm run pack npm run pack:portable npm run pack:installer npm run pack:zip npm run pack:dir +npm run pack:win:all ``` ### 路径别名 @@ -295,6 +318,32 @@ npm run pack:dir - `@/` → `src/renderer/src/` - `@shared/*` → `src/shared/*` +### 本地安全审计(Windows Git Bash) + +Semgrep 与 Node.js 工具链隔离,安装在 root `.venv`。可通过以下命令重建环境并运行本次审计使用的 rulesets: + +```bash +python -m venv .venv +source .venv/Scripts/activate +python -m pip install --upgrade pip +python -m pip install -r requirements-security.txt + +semgrep scan \ + --config p/security-audit \ + --config p/owasp-top-ten \ + --config p/javascript \ + --exclude-rule javascript.crypto-js.cryptojs-weak-algorithm.cryptojs-weak-algorithm \ + --exclude-rule javascript.koa.web.cors-default-config-koa.cors-default-config-koa \ + --exclude-rule javascript.express.web.cors-default-config-express.cors-default-config-express \ + --timeout 60 \ + --timeout-threshold 3 \ + --json-output .semgrep/security-audit.json \ + --sarif-output .semgrep/security-audit.sarif \ + . +``` + +上述 3 条被排除的 registry rules 依赖 Semgrep Pro engine;对应的 CryptoJS、Koa 与 Express CORS 场景已执行人工补偿检查。完整原因与审计记录保存在 [SECURITY_AUDIT_REPORT.md](./SECURITY_AUDIT_REPORT.md)。 + ### 开发注意事项 - 仅用于渲染层打包的依赖会尽量保留在非运行时依赖范围,减少最终包体积。 @@ -305,8 +354,41 @@ npm run pack:dir ## 🆕 最近更新 -- 新增“新建配置默认模板”,可在 `设置 -> 编辑器设置` 中编辑、保存和弹窗预览。 -- 模板预览改为弹窗方式,并复用同一套编辑器能力进行格式化与校验。 +### 2026-09 v1.5.0 多工具与性能批次 + +- 内置 registry 覆盖四个工具:Claude Code、Codex CLI(全六能力,含经 `TOML_FILE_V1` codec 保注释编辑的 `config.toml` 与 `auth.json` key 管理)、Gemini CLI、Antigravity。 +- 多文件联动编辑(`editGroup`):分离配置工具整组先校验、再经既有 授权 → 备份 → 原子写链顺序写入。 +- 配置集快照(`configSet`):配置页每工具下拉框 + 托盘两层快速切换菜单;Claude Code 保留原工作区通道与热重载。 +- 打包体积近乎减半(`app.asar` 23.16 → 11.76 MB):Monaco 按需运行时、依赖裁剪(移除 axios/uuid)、最大压缩;网络出口切换为原生客户端。 +- 单实例锁、Windows 通知显示应用名、启动非关键工作延迟到空闲批次执行。 + +### 2026-07-12 安全与质量基线 + +- 权限提升改为 `execFile` 参数化执行,增加 executable allowlist 与平台级 escaping;权限确认异常时默认拒绝。 +- GitHub Actions 固定为完整 commit SHA,降低 mutable tag 带来的供应链风险。 +- 移除本地 proxy server 默认全开放的 CORS,并清理不再使用的 CORS dependencies。 +- 更新安全相关 dependencies,root 与 proxy-server npm audit 均降至 0 vulnerabilities。 +- 增加可复现的 Semgrep 虚拟环境、JSON/SARIF 原始结果流程与持续维护的安全审计报告。 + +### v1.5.0 release candidate 工程实现完成 + +- 新增声明式 JSON 工具规则库模型、bounded validation 与内置 Claude Code 兼容 adapter。 +- 新增通用 `PATH_EXISTS` / `COMMAND_EXISTS` 检测与 registry allowlist 约束的 artifact discovery。 +- 新增 lazy-loaded“AI 工具配置”面板,以及具备 storage fingerprint 自动失效能力的 effective-registry snapshot cache。 +- 新增备份历史/恢复流程;通用备份默认每个 artifact path 最多保留 20 份。 +- 新增需用户明确确认、具备 integrity 校验的规则库安装和 last-known-good rollback;自动检查只获取小型 manifest。 +- Remote registry 已加入 Ed25519 raw-bundle signature verification 与 key rotation contract;正式 publisher public key 注入前保持 fail-closed preview。 +- 新增 artifact-specific template ownership,采用 `USER_OVERRIDE > REGISTRY > EMBEDDED` 优先级,支持旧自定义模板迁移与 bounded diff preview。 +- Settings/About 已加入规则库操作入口,并提供完全按需的本地 performance snapshot exporter(无采样 timer、无上传)。 +- 首屏 critical 初始化完成后才按 idle batch 加载非关键数据;退出流程会等待幂等 cleanup 完成后再放行。 +- Claude 配置工作区路径已集中到 compatibility facade;`1.5.0` 继续读取原 `.ccb/claude-configs`,不会静默创建或迁移到新目录。 +- 新增 release preflight 与 Windows Portable/NSIS/ZIP 聚合打包命令;Electron window 已启用 sandbox,并以 fail-closed 策略拒绝新窗口与外部 navigation。 +- 架构与能力说明见 [ARCHITECTURE.md](./ARCHITECTURE.md) 与 [CAPABILITIES.md](./CAPABILITIES.md);审计证据链见 [SECURITY_AUDIT_REPORT.md](./SECURITY_AUDIT_REPORT.md)。 + +### 产品体验更新 + +- 原“全局新建配置默认模板”设计现已**过时**,由 `设置 -> 编辑器设置` 中的逐 artifact template ownership 取代。 +- 模板预览改为 artifact-aware bounded diff;实际编辑器继续提供校验和格式化能力。 - 修复了复制配置逻辑,现在会先打开预填编辑器并添加国际化副本后缀,仅在显式保存后才创建新文件。 - 修复了基于 `Markdown` 的偏好配置在预览流程中被错误按 `JSON` 解析的问题。 - 新增 NSIS 安装版打包命令,作为 Portable 单文件方案之外的低等待分发选择。 @@ -327,15 +409,7 @@ npm run pack:dir ### 提交约定 -请使用 Conventional Commit 前缀: - -- `feat`: 新功能 -- `fix`: Bug 修复 -- `docs`: 文档更新 -- `refactor`: 重构 -- `perf`: 性能优化 -- `test`: 测试 -- `chore`: 工具链 / 构建变更 +请使用 Conventional Commit 前缀:`feat` / `fix` / `docs` / `refactor` / `perf` / `test` / `chore`。 --- diff --git a/SECURITY_AUDIT_REPORT.md b/SECURITY_AUDIT_REPORT.md new file mode 100644 index 0000000..5798aea --- /dev/null +++ b/SECURITY_AUDIT_REPORT.md @@ -0,0 +1,196 @@ +# Semgrep 安全审计与改进报告 + +## 审计记录 + +### 2026-07-12:首次基线审计与整改 + +#### 范围与工具 + +- 仓库:`ClaudeCodeButler`,分支 `main` +- 工具:根目录 `.venv` 中的 Semgrep CLI `1.169.0` +- 规则:`p/security-audit`、`p/owasp-top-ten`、`p/javascript` +- 范围:Git tracked application source、scripts、tests 与 GitHub Actions;基线 162 files,加入报告与版本锁定文件后终态 164 files +- 排除:`.venv`、`node_modules`、`out`、`release`、`coverage`、`backup`、`.git` +- 原始结果:本地 `.semgrep/security-audit.json` 与 `.semgrep/security-audit.sarif`,已通过 `.gitignore` 排除 + +#### 基线结果 + +首次扫描运行 372 条适用规则,得到 16 个 findings: + +| 类别 | 数量 | 研判 | 处置 | +| --- | ---: | --- | --- | +| GitHub Actions mutable action tag | 9 | 真实供应链风险 | 已固定为官方 tag 在审计日对应的 40-character commit SHA | +| `privilege-manager` 动态 `exec` | 3 | 真实 command injection 风险,来自 2 个调用点 | 已改为 `execFile` argument array,并增加 executable allowlist 与跨平台 escaping | +| 受控 `child_process` 边界 | 4 | 规则无法识别既有控制措施 | 逐点复核后使用 rule-specific suppression,并在源码记录信任边界 | +| Express default CORS | 1 | 对应 registry rule 依赖 Pro engine;人工补偿检查确认真实 localhost cross-origin 风险 | 已移除 CORS middleware 与冗余 dependencies | + +首次扫描曾有 1 条规则在大型 locale 文件上 timeout。复扫将单规则 timeout 提高到 60 秒后,162 个 targets 均完成解析,未再发生 timeout。 + +#### 已实施改进 + +1. GitHub Actions 中的 `checkout`、`setup-node`、`cache`、`upload-artifact`、`action-gh-release` 全部固定 commit SHA,并保留版本注释供 Dependabot 或人工更新。 +2. 权限提升执行从 shell string 拼接改为 `execFile(command, args)`;允许的 executable 限制为 `powershell.exe`、`osascript`、`pkexec`、`sudo`。 +3. Windows 使用 PowerShell single-quoted literal escaping;macOS 同时应用 POSIX argument quoting 与 AppleScript string escaping;Linux 保持 argument array,不构造 shell command string。 +4. 同文件的静态权限探测命令一并从 `exec` 改为 `execFile`,防止后续维护重新引入字符串拼接。 +5. 权限确认对话框异常时由默认允许改为默认拒绝,消除 fail-open 行为。 +6. 新增跨平台提权规格回归测试,覆盖 quotes、spaces、command substitution 与 command separator 输入。 +7. 新增 `requirements-security.txt` 锁定 Semgrep 版本;`.venv/` 与 `.semgrep/` 已加入 `.gitignore`。 +8. 移除本地 proxy server 的 default-open CORS。合法调用方均为 Claude CLI 或 Electron IPC,不需要浏览器跨源访问;同时移除 root 与 proxy-server 的 `cors` dependencies。 +9. 补充执行 npm dependency audit:将 Electron/Vite/Vitest 等 transitive packages 更新到现有 semver range 内的修复版本;升级 `node-cron` 4.6.0 与 `uuid` 14.0.1;覆盖 Monaco 固定的旧 DOMPurify 至 3.4.12,并覆盖 brace-expansion 至 2.0.3。 +10. node-cron 4 不再支持 v3 的 `scheduled:false` 语义,`TaskScheduler` 已改用 `createTask`,保持 disabled rule 注册后不自动启动。 +11. dependency 更新后 root audit 从 31 vulnerabilities(2 critical、17 high、10 moderate、2 low)降至 0;proxy-server audit 同样为 0。 +12. production build 暴露出旧 CSS `@import` 顺序错误及两个此前未解析到的残缺 style fragments;已移动 imports、删除无 selector 的无效 declarations,build 不再产生 PostCSS warning。 + +#### 已接受的边界与依据 + +- `command-executor`:`parseCommand` 拒绝 shell metacharacters,执行固定为 `shell:false`,binary 与 args 保持独立。 +- `project-management-service`:launch spec 仅由 class 内私有平台构造器产生,使用 argument array 且不启用 shell。 +- `terminal-management-service`:MCP stdio server 启动探测需要加载用户本地 shell 环境。该能力仅消费用户明确保存的本地 MCP 配置;renderer IPC 使用独立 command allowlist,不提供任意 shell passthrough。 + +以上位置只抑制 `javascript.lang.security.detect-child-process.detect-child-process` 单条规则,没有全局关闭规则。若未来扩大调用来源或移除现有 allowlist/validation,必须删除 suppression 并重新建模该边界。 + +#### 验证结果 + +- Full Vitest:65 tests passed(10 test files) +- TypeScript:`npm run type-check` passed +- Targeted ESLint:passed +- Root production build:passed +- Proxy-server TypeScript build:passed +- Root `npm audit --audit-level=low`:0 vulnerabilities +- Proxy-server `npm audit --audit-level=low`:0 vulnerabilities +- 整改后 Semgrep:相同 rulesets 与 164 targets 完成扫描;3 条 Pro-only rules 由 OSS CLI 明确排除并人工补偿检查,最终 0 unsuppressed findings、0 scan errors、0 timeout + +#### 后续建议 + +1. 在 CI 中使用锁定版本的 Semgrep,并将 SARIF 上传到 GitHub Code Scanning;PR 应只扫描 diff,定时任务执行 full scan。 +2. 启用 Dependabot 更新 pinned action SHA,避免固定 SHA 后长期错过 action security patches。 +3. Semgrep 是 pattern-based SAST,不能替代 dependency、secret 与 runtime audit;应并行保留 `npm audit`、secret scanning 和 Electron security checklist。 +4. MCP 本地配置属于显式信任边界。若未来支持远程同步或共享配置,必须改为 executable allowlist 或用户逐次确认,不能沿用当前 suppression。 +5. Browserslist build metadata 当前提示 `caniuse-lite` 已陈旧 9 个月;应在独立 dependency maintenance PR 中更新并执行 UI/browser compatibility regression,避免把兼容基线变化混入安全修复。 + +#### OSS CLI 规则兼容说明 + +Registry 中以下规则使用 `metavariable-name:module`,Semgrep OSS CLI `1.169.0` 无法执行,未登录 Pro engine 时会对每个 JS/TS target 重复产生 internal matching warning: + +- `javascript.crypto-js.cryptojs-weak-algorithm.cryptojs-weak-algorithm` +- `javascript.koa.web.cors-default-config-koa.cors-default-config-koa` +- `javascript.express.web.cors-default-config-express.cors-default-config-express` + +最终扫描通过 `--exclude-rule` 明确排除这 3 条规则。人工补偿检查确认项目未使用 CryptoJS 或 Koa;Express default CORS 问题已发现并移除。若 CI 后续启用 Semgrep Pro,应移除这些 exclusions 并恢复对应规则。 + +### 2026-07-12:v1.5.0 generic discovery 增量复审 + +#### 审计范围与结果 + +- 使用根目录 `.venv` 中锁定的 Semgrep CLI `1.169.0`,复用 `p/security-audit`、`p/owasp-top-ten`、`p/javascript` 与既有 3 条 OSS Pro-only exclusions。 +- 扫描 179 个 Git tracked targets、执行 369 条规则,约 100% lines parsed;JSON 原始结果为 `0 findings / 0 errors`。 +- Root 与 `src/proxy-server` 的 `npm audit --audit-level=low` 均为 `0 vulnerabilities`。 +- Full Vitest 为 16 files / 104 tests,TypeScript、ESLint、root production build 与 proxy-server build 全部通过。 + +#### 本阶段安全改进 + +1. Registry path template 只允许 `HOME`、`APPDATA`、`LOCALAPPDATA`、`XDG_CONFIG_HOME`、`CCB_DATA` 根变量,并拒绝 traversal、UNC、glob、未知变量和嵌套变量。 +2. `COMMAND_EXISTS` 使用 `execFile(locator, [command])`、`shell: false`、5 秒 timeout 与 executable-name allowlist,不接受参数或 shell metacharacters。 +3. Artifact discovery/read 每次从 effective registry 重新推导路径 allowlist;renderer 提供的 path 只作为候选选择器,不能扩展 main process 文件权限。 +4. Read-only artifact 限制为当前平台 registry 声明、具有 `READ` capability、最大 1 MiB 的普通文件,并拒绝最终文件及中间目录中的 symbolic link/junction。 +5. Codex CLI adapter 首版只声明 `DISCOVER` / `READ`,TOML 以 raw UTF-8 text 返回;未验证的 edit semantics 不会伪装为通用能力。 + +#### 保留建议 + +- Semgrep 属于 pattern-based SAST,`0 findings` 不能替代 runtime authorization review、secret scanning 或手工 threat modeling。 +- 当前路径校验适合本地可信用户模型;若未来引入多用户服务或不可信本地进程对抗,应进一步采用 OS-level file handles、identity checks 与更严格的 TOCTOU 防护。 +- Remote registry 在 Ed25519 publisher signature 未实施前应维持 preview/beta,不能仅凭 HTTPS 与 SHA-256 宣称 publisher authenticity。 + +### 2026-07-12:v1.5.0 generic management 增量复审 + +#### 审计范围与结果 + +- Semgrep CLI `1.169.0` full scan 覆盖 181 个既有 Git tracked targets、执行 369 条规则,约 100% lines parsed,结果为 `0 findings / 0 errors`。 +- Semgrep 默认 tracked-file 枚举不包含 staged-but-uncommitted new files,因此对 2 个新 services 与 2 个新 specs 额外执行显式路径扫描;4 targets、332 applicable rules 同样为 `0 findings / 0 errors`。 +- Full Vitest 为 18 files / 113 tests;TypeScript、ESLint、root production build、proxy-server build 全部通过。 +- Root 与独立 proxy package 的 `npm audit --audit-level=low` 均为 `0 vulnerabilities`。 + +#### 本阶段安全改进 + +1. Generic edit、validate、backup、restore 各自要求 effective registry 中对应 UPPERCASE capability,不能由 format 或 renderer 自行推导权限。 +2. JSON/JSONC/YAML codecs 限制为内置实现,并加入 64-level / 50,000-node 结构预算;remote registry 不能下载 parser code。TOML 在可信 parser 接入前明确拒绝 validation/edit,不伪造支持。 +3. Edit 使用目标目录内随机 exclusive temp file、flush 与 atomic rename;带 `BACKUP` capability 的 artifact 在更新前自动备份,invalid content 不修改原文件。 +4. Backup 使用 UUID、exclusive copy、受控目录和 bounded metadata;restore 根据 metadata 重新校验 registry path 与 `RESTORE` capability,拒绝 symbolic link、超限内容、无效 UTF-8 和目标路径篡改。 +5. Codex CLI adapter 继续仅声明 `DISCOVER` / `READ`,因此新管理 IPC 不会扩大其写权限。 + +### 2026-07-13:generic management UI 与 registry cache 增量复审 + +- Semgrep full scan 覆盖 183 targets、369 rules,结果为 `0 findings / 0 errors`;对 staged 新 UI TSX 显式补扫 1 target、332 applicable rules,同样为 `0 findings / 0 errors`。 +- Full Vitest 为 18 files / 114 tests;TypeScript、ESLint、root/proxy builds 与两套 npm audit 全部通过。 +- 新增 AI Tool Configuration lazy panel;renderer 只能调用既有 capability-aware IPC,不能提供额外 filesystem roots、handlers 或 executable code。 +- UI 仅在 registry 声明对应 capability 时展示 validate/edit/backup 操作;main process 仍在每次调用时重新授权,因此 UI 隐藏不是安全边界。 +- Effective registry snapshot 使用 single-flight cache,fingerprint 包含 installed/last-known-good 的 nanosecond `mtime`、`ctime` 与 size;storage 变化后重新读取并执行完整 validator。 +- Codex CLI 在 UI 中保持 read-only;未实现可信 TOML codec 前不会显示 edit/validate 操作。 +- Backup history listing 会先重新授权 `RESTORE` capability,再逐条校验 UUID、metadata/content 普通文件属性、大小和 originalPath;损坏记录 fail-closed 排除。 +- Full Vitest 更新为 18 files / 116 tests;build 日志已确认无 Ant Design `destroyOnClose` deprecation warning。 +- 本阶段 Semgrep full scan 继续覆盖 183 targets / 369 rules,结果为 `0 findings / 0 errors`。 +- 通用 backup create/prune 使用单进程 mutation queue;retention 只删除经过 UUID、metadata/content 普通文件与路径一致性校验的 service-owned records。 +- 本阶段 Semgrep full scan 覆盖 183 targets / 369 rules,结果保持 `0 findings / 0 errors`。 + +### 2026-07-13:Phase 5 performance lifecycle 增量复审 + +- Semgrep full scan 覆盖 184 个 Git tracked targets、执行 369 条规则,约 100% lines parsed,结果为 `0 findings / 0 errors`。 +- 对本阶段 5 个 lifecycle/scheduler implementation 与 spec paths 显式补扫,执行 332 条适用规则,结果同为 `0 findings / 0 errors`。 +- Root 与独立 proxy package 的 `npm audit --audit-level=low` 均为 `0 vulnerabilities`;full Vitest 为 20 files / 122 tests,TypeScript、ESLint、root/proxy builds 全部通过。 +- Renderer background scheduler 只调度固定 store actions,不接收 renderer 字符串、路径或 executable;cancel 仅阻止尚未启动的 batch,不隐藏已发出 IPC 的真实状态。 +- StatisticsService shutdown 使用幂等 Promise barrier,auto-save 串行化,并由 app-level single quit guard 等待 cleanup,降低退出阶段部分写入与并发写入风险。 +- 本轮未启动应用,安全结论只覆盖静态分析、dependency audit、unit contract 与 production build;runtime Electron security checklist 仍应在 release 验收阶段执行。 + +### 2026-07-13:Ed25519 registry publisher identity 增量复审 + +- Remote manifest schema 新增必填 `signatureAlgorithm: ED25519`、stable `keyId` 与 64-byte standard Base64 detached signature;额外字段和其他算法 fail-closed。 +- Bundle 使用 bounded `arraybuffer` 下载,先对 exact response bytes 验证 pinned Ed25519 public key signature,再校验 SHA-256/size,之后使用 fatal UTF-8 decoder 解析 schema。 +- Signature 后继续绑定 manifest/bundle `registryVersion` 与 `minimumAppVersion`,并保留 app compatibility 和 downgrade protection,拒绝合法旧 bundle 被错误 manifest 重新包装。 +- Unknown keyId 在 manifest check 阶段直接进入 `CHECK_FAILED`,不会向用户展示虚假的 `UPDATE_AVAILABLE`;production trust map 当前为空,正式 public key 注入前 remote registry 保持 fail-closed preview。 +- Offline signing helper 已用一次性 Ed25519 keypair对内置 registry 的 exact `3458 bytes` 完成 rehearsal;独立核对 size、SHA-256 与 signature 后删除临时 private key。 +- Full Vitest 为 20 files / 125 tests;TypeScript、ESLint、root/proxy builds 与两套 npm audit 全部通过。Main bundle 为 `277.85 KB`,preload/renderer 保持 `12.53 KB / 196.05 KB`。 +- Semgrep full scan 覆盖 186 个 Git tracked targets、执行 369 条规则,结果为 `0 findings / 0 errors`;对签名链路 9 个 implementation/spec/script paths 显式补扫 332 条适用规则,结果同为 `0 findings / 0 errors`。 + +保留的 release blocker:维护者必须执行 offline key ceremony,将 private key 保存在 repository/CI/application package 之外,并只把对应 SPKI public key 注入 `REGISTRY_TRUSTED_PUBLIC_KEYS`。Verifier 完成不等于 publisher identity 已建立。 + +### 2026-07-13:Claude legacy workspace compatibility 增量复审 + +- 新增 `ClaudeWorkspacePathFacade`,集中声明 legacy `.ccb/claude-configs` 与 future `.ccb/workspaces/claude-code`;v1.5.0 active mode 固定为 `LEGACY_COMPAT`。 +- 路径选择不访问 filesystem,不根据目录存在性隐式切换,不创建 future workspace,也不复制、删除或移动用户数据。 +- Managed Mode provider sync 移除 legacy path 直接拼接,与 ConfigService、FileWatcher、菜单统一消费 main-process `pathManager.claudeConfigsDir` compatibility alias。 +- `resolveActiveFile` 只允许直接子文件名,跨平台拒绝 `/`、`\\`、`.`、`..`、empty 与 NUL 输入;relative app data root 同样拒绝。 +- Full Vitest 为 21 files / 129 tests;TypeScript、ESLint、root/proxy builds 与两套 npm audit 全部通过。Main bundle 为 `278.57 KB`,preload/renderer 保持 `12.53 KB / 196.05 KB`。 +- Semgrep full scan 覆盖 188 个 Git tracked targets、执行 369 条规则,结果为 `0 findings / 0 errors`;对 facade/path manager/Managed Mode/spec 等 5 paths 显式补扫 332 条适用规则,结果同为 `0 findings / 0 errors`。 + +该 facade 不等同于物理 migration 完成。旧目录业务回归仍需用户后续启动应用验收;future workspace 只有在具备 backup、journal、idempotency 与 rollback rehearsal 后才能显式启用。 + +### 2026-07-13:v1.5.0 release hardening 终态自动化复审 + +#### 审计与构建证据 + +- Full Vitest:`30 files / 188 tests` 全部通过;TypeScript、ESLint、root production build 与 proxy-server build 全部通过。 +- Semgrep full scan:`198 targets / 369 rules / 0 findings / 0 structured errors`。 +- Semgrep explicit-path scan:`35 targets / 336 rules / 0 findings / 0 structured errors`,覆盖本次 staged implementation/spec/script paths。 +- Root 与独立 proxy package 的 `npm audit --audit-level=low` 均为 `0 vulnerabilities`。 +- 最终静态包体记录:main `288.87 KB`、preload `12.93 KB`、renderer entry `199.70 KB`、Settings JS/CSS `34.96 KB / 2.67 KB`。这些数字仅用于追踪静态成本,不替代 runtime memory/CPU/startup 验收。 + +#### Semgrep OSS coverage disclosure + +Semgrep `1.169.0` 的 JSON `errors` 均为 0,但 `time.fixpoint_timeouts` 在 full/explicit scan 中分别记录 41/8 条 warning。它们主要来自 Koa/NestJS/Express 等跨 framework taint rules 对 Electron/React 或无关 service 的分析,并不等价于 finding;但对应单条 taint fixpoint 也不能视为完整证明。补偿措施包括:对全部 35 个 staged code paths 显式复扫、对 IPC/path/template/renderer payload 边界进行人工审查,以及 188 项回归测试、两套 dependency audit 和 Electron release preflight。最终结论应表述为“0 unsuppressed findings、0 structured errors,存在已披露的 OSS fixpoint coverage limitation”,不能宣称静态分析覆盖绝对完整。 + +#### 本阶段安全改进 + +1. Artifact-specific template 只允许内置 codec,限制单模板 `64 KiB`、拒绝 NUL,并以 `USER_OVERRIDE > REGISTRY > EMBEDDED` 决定生效来源;remote registry 仍不能注入 executable code。 +2. Settings 中 legacy customized global template 只迁移到明确的 `claude-code/user-settings` override,内置旧默认不迁移;migration 完成后旧字段被归一化,避免删除 override 后复活。 +3. Template mutation 使用串行 queue;registry update、removal 与 rollback 不得覆盖 user override,且 removal 始终保留 embedded fallback。 +4. Electron `BrowserWindow` 启用 `sandbox: true`,`setWindowOpenHandler` 全部 deny,`will-navigate` 仅允许当前 document 的 hash navigation;相关配置由 unit contract 与 release preflight 同时锁定。 +5. Release preflight 检查 package/package-lock/APP_INFO 版本绑定、双语 README/CHANGELOG、installer identity、artifact naming、tracked private-key markers、production registry trust map 与 Electron security contract。 +6. `.keys/`、`*.private.pem`、`registry-private-key*.pem` 与 `secrets/` 已加入 ignore policy;private key 禁止进入 repository、CI 或 application package。 +7. Performance snapshot 接收的 renderer timings 视为不可信 IPC 输入;main process 只接受 3 个固定 entry、最多 3 项、正确的 `MARK`/`MEASURE` 类型和有限非负数值,导出时丢弃额外字段。 +8. `runtimeMetrics` 仅由 main process 现有 watcher/config scan 生命周期被动更新并在用户点击导出时读取;renderer 不能提交或篡改这些计数,不新增后台采样 timer、网络请求或 telemetry 上传。 + +#### 仍然 fail-closed 的发布边界 + +- `REGISTRY_TRUSTED_PUBLIC_KEYS` 当前为空。`npm.cmd run release:preflight:preview` 可用于开发检查并输出 warning;production `npm.cmd run release:preflight` 会按设计失败,直到维护者执行 offline Ed25519 key ceremony 并只注入对应 SPKI public key。 +- 构建机若处于 TLS 拦截网络(如企业代理),electron-builder 下载 Electron distribution 可能报告 `unable to verify the first certificate`。这是证书信任链问题,不允许用 `NODE_TLS_REJECT_UNAUTHORIZED=0` 绕过;应通过 `NODE_EXTRA_CA_CERTS` 或 npm `cafile` 配置组织可信根 CA 后重新执行 `npm.cmd run pack:win:all`。 +- 本轮未启动应用。Electron runtime navigation、新窗口策略、installer/portable/zip smoke test、registry release-candidate 对抗用例与业务兼容性必须在目标机按手动验收清单实机验收。 diff --git a/package-lock.json b/package-lock.json index fed78e0..6097f0c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,35 +1,31 @@ { "name": "ccb", - "version": "1.4.0", + "version": "1.5.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ccb", - "version": "1.4.0", + "version": "1.5.0", "hasInstallScript": true, "license": "MIT", "dependencies": { - "axios": "^1.13.0", "chokidar": "^3.5.3", - "cors": "^2.8.5", "express": "^5.1.0", + "https-proxy-agent": "^7.0.6", "js-yaml": "^4.1.1", - "node-cron": "^3.0.3", - "uuid": "^9.0.0" + "node-cron": "^4.6.0", + "smol-toml": "^1.8.0" }, "devDependencies": { "@monaco-editor/react": "^4.7.0", - "@types/cors": "^2.8.19", "@types/express": "^5.0.6", "@types/js-yaml": "^4.0.9", "@types/node": "^20.10.0", - "@types/node-cron": "^3.0.11", "@types/react": "^18.2.0", "@types/react-dom": "^18.2.0", "@types/react-syntax-highlighter": "^15.5.13", "@types/react-window": "^1.8.8", - "@types/uuid": "^9.0.0", "@typescript-eslint/eslint-plugin": "^7.7.0", "@typescript-eslint/parser": "^7.7.0", "@vitejs/plugin-react": "^4.2.0", @@ -164,11 +160,13 @@ } }, "node_modules/@babel/code-frame": { - "version": "7.27.1", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz", + "integrity": "sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-validator-identifier": "^7.27.1", + "@babel/helper-validator-identifier": "^7.29.7", "js-tokens": "^4.0.0", "picocolors": "^1.1.1" }, @@ -177,7 +175,9 @@ } }, "node_modules/@babel/compat-data": { - "version": "7.28.4", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.29.7.tgz", + "integrity": "sha512-locTkQyKvwIEgBzVrn8693ebc97F2U8ZHjbXwDXJ5Fn2TCpNwTlKcaKLkdHop5c/icOFE7qt7Q9JC5hnKNa6Gg==", "dev": true, "license": "MIT", "engines": { @@ -185,19 +185,21 @@ } }, "node_modules/@babel/core": { - "version": "7.28.4", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.7.tgz", + "integrity": "sha512-RgHBCvtjbOK2gXSNBNIkNoEc9qoVEtau3hj8gEqKQuL3HZAibKarWFEI3Lfm6EYKkLalOh8eSrj9b+ch9H/VBA==", "dev": true, "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.27.1", - "@babel/generator": "^7.28.3", - "@babel/helper-compilation-targets": "^7.27.2", - "@babel/helper-module-transforms": "^7.28.3", - "@babel/helpers": "^7.28.4", - "@babel/parser": "^7.28.4", - "@babel/template": "^7.27.2", - "@babel/traverse": "^7.28.4", - "@babel/types": "^7.28.4", + "@babel/code-frame": "^7.29.7", + "@babel/generator": "^7.29.7", + "@babel/helper-compilation-targets": "^7.29.7", + "@babel/helper-module-transforms": "^7.29.7", + "@babel/helpers": "^7.29.7", + "@babel/parser": "^7.29.7", + "@babel/template": "^7.29.7", + "@babel/traverse": "^7.29.7", + "@babel/types": "^7.29.7", "@jridgewell/remapping": "^2.3.5", "convert-source-map": "^2.0.0", "debug": "^4.1.0", @@ -222,12 +224,14 @@ } }, "node_modules/@babel/generator": { - "version": "7.28.3", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.7.tgz", + "integrity": "sha512-DkXD5OJQaAQIdZ1bt3UZdEnHAn9Imd3IVBdX03UFe+ony9Ojw5pzr9YVKGDY1jt+Gcn/FnGkNf8r+Vj5NOJWtQ==", "dev": true, "license": "MIT", "dependencies": { - "@babel/parser": "^7.28.3", - "@babel/types": "^7.28.2", + "@babel/parser": "^7.29.7", + "@babel/types": "^7.29.7", "@jridgewell/gen-mapping": "^0.3.12", "@jridgewell/trace-mapping": "^0.3.28", "jsesc": "^3.0.2" @@ -237,12 +241,14 @@ } }, "node_modules/@babel/helper-compilation-targets": { - "version": "7.27.2", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.29.7.tgz", + "integrity": "sha512-wem6WaBj4NaVYVdNhLPPVacES6ZJ+KBBfSkTMD3YZxbP3rm3Di85tJU5ljaUNhaOynt+Aj0xruhYuzQBt8n71g==", "dev": true, "license": "MIT", "dependencies": { - "@babel/compat-data": "^7.27.2", - "@babel/helper-validator-option": "^7.27.1", + "@babel/compat-data": "^7.29.7", + "@babel/helper-validator-option": "^7.29.7", "browserslist": "^4.24.0", "lru-cache": "^5.1.1", "semver": "^6.3.1" @@ -253,6 +259,8 @@ }, "node_modules/@babel/helper-compilation-targets/node_modules/semver": { "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, "license": "ISC", "bin": { @@ -260,7 +268,9 @@ } }, "node_modules/@babel/helper-globals": { - "version": "7.28.0", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-globals/-/helper-globals-7.29.7.tgz", + "integrity": "sha512-3nQVUAtvkKH9zahfWgw96Jc/uFOmjACE1kQz82E2lqWmHBgjzbNlsC22nuQTfahmWeQtTq5nQ/4Nnd2A1wj4zA==", "dev": true, "license": "MIT", "engines": { @@ -268,25 +278,29 @@ } }, "node_modules/@babel/helper-module-imports": { - "version": "7.27.1", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.29.7.tgz", + "integrity": "sha512-ejHwrQQYcm9xnTivShn2IDOlIzInN34AXskvq9QicvCtEzq1Vzclu/tKF8Jq1Cg8JG2GL6/EmjgsCT7lXepE3g==", "dev": true, "license": "MIT", "dependencies": { - "@babel/traverse": "^7.27.1", - "@babel/types": "^7.27.1" + "@babel/traverse": "^7.29.7", + "@babel/types": "^7.29.7" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-module-transforms": { - "version": "7.28.3", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.29.7.tgz", + "integrity": "sha512-UPUVSyXbOh627KiCIGQSgwWzGeBKLkaJ9PJEdrngIwMSzxLR4jS4+f1f1jb7VzBbg8nFLaYotvVPFCTqdrmTAg==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-module-imports": "^7.27.1", - "@babel/helper-validator-identifier": "^7.27.1", - "@babel/traverse": "^7.28.3" + "@babel/helper-module-imports": "^7.29.7", + "@babel/helper-validator-identifier": "^7.29.7", + "@babel/traverse": "^7.29.7" }, "engines": { "node": ">=6.9.0" @@ -324,7 +338,9 @@ } }, "node_modules/@babel/helper-validator-option": { - "version": "7.27.1", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.29.7.tgz", + "integrity": "sha512-N9ZErrD+yW5geCDtBqnOoxmR8+tNKiGuxKlDpuJxfsqpa2dFcexaziGAE/qoHLiDDreVNMupxGmSoNlyvsA3gw==", "dev": true, "license": "MIT", "engines": { @@ -332,12 +348,14 @@ } }, "node_modules/@babel/helpers": { - "version": "7.28.4", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.29.7.tgz", + "integrity": "sha512-1k2lAGRMfHTcwuNYcCNUmaUffmQv8KWMfh2iJUUeRlwlwH4FdNG7mfPI10NPfLHJFThE4Tyr4mv7kTNZOiPuBg==", "dev": true, "license": "MIT", "dependencies": { - "@babel/template": "^7.27.2", - "@babel/types": "^7.28.4" + "@babel/template": "^7.29.7", + "@babel/types": "^7.29.7" }, "engines": { "node": ">=6.9.0" @@ -410,29 +428,33 @@ } }, "node_modules/@babel/template": { - "version": "7.27.2", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.29.7.tgz", + "integrity": "sha512-puq+Gf35oI24FeN11LkoUQFqv9uwNeWpxXZi/Ji3rRIoKAzKnxRaZ+Gkj0vKS9ZCiTESfng1N9LyOyXvo+m+Gg==", "dev": true, "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.27.1", - "@babel/parser": "^7.27.2", - "@babel/types": "^7.27.1" + "@babel/code-frame": "^7.29.7", + "@babel/parser": "^7.29.7", + "@babel/types": "^7.29.7" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/traverse": { - "version": "7.28.4", + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.29.7.tgz", + "integrity": "sha512-EhlfNQtZ+NK22w5BM61ciuiq1m58ed33Wr1Xan//ZRTy6hgjnwyCffRYwzsGXdASJSUJ1guZILsErh1eQcl+zw==", "dev": true, "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.27.1", - "@babel/generator": "^7.28.3", - "@babel/helper-globals": "^7.28.0", - "@babel/parser": "^7.28.4", - "@babel/template": "^7.27.2", - "@babel/types": "^7.28.4", + "@babel/code-frame": "^7.29.7", + "@babel/generator": "^7.29.7", + "@babel/helper-globals": "^7.29.7", + "@babel/parser": "^7.29.7", + "@babel/template": "^7.29.7", + "@babel/types": "^7.29.7", "debug": "^4.3.1" }, "engines": { @@ -463,22 +485,14 @@ "node": ">=18" } }, - "node_modules/@develar/schema-utils": { - "version": "2.6.5", - "resolved": "https://registry.npmjs.org/@develar/schema-utils/-/schema-utils-2.6.5.tgz", - "integrity": "sha512-0cp4PsWQ/9avqTVMCtZ+GirikIA36ikvjtHweU4/j8yLtgObI0+JUPhYFScgwlteveGB1rt3Cm8UhN04XayDig==", + "node_modules/@electron-internal/extract-zip": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@electron-internal/extract-zip/-/extract-zip-1.0.4.tgz", + "integrity": "sha512-Zr1Vs7E9tpCNhZHDAbFVXc2gEVCG9RqPDjrno5+bdgB6LRAuvgyMHJut4NCVyYwtAieapMzc3fiQ3CSTi75ARg==", "dev": true, - "license": "MIT", - "dependencies": { - "ajv": "^6.12.0", - "ajv-keywords": "^3.4.1" - }, + "license": "BSD-2-Clause", "engines": { - "node": ">= 8.9.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/webpack" + "node": ">=22.12.0" } }, "node_modules/@electron/asar": { @@ -500,9 +514,9 @@ } }, "node_modules/@electron/asar/node_modules/brace-expansion": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", - "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", + "version": "1.1.18", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.18.tgz", + "integrity": "sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw==", "dev": true, "license": "MIT", "dependencies": { @@ -511,9 +525,9 @@ } }, "node_modules/@electron/asar/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", "dev": true, "license": "ISC", "dependencies": { @@ -554,55 +568,25 @@ "node": ">=10" } }, - "node_modules/@electron/fuses/node_modules/jsonfile": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz", - "integrity": "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==", - "dev": true, - "license": "MIT", - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/@electron/fuses/node_modules/universalify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", - "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 10.0.0" - } - }, "node_modules/@electron/get": { - "version": "2.0.3", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@electron/get/-/get-5.0.0.tgz", + "integrity": "sha512-pjoBpru1KdEtcExBnuHAP1cAc/5faoedw0hzJkL3o4/IJp7HNF1+fbrdxT3gMYRX2oJfvnA/WXeCTVQpYYxyJA==", "dev": true, "license": "MIT", "dependencies": { "debug": "^4.1.1", - "env-paths": "^2.2.0", - "fs-extra": "^8.1.0", - "got": "^11.8.5", + "env-paths": "^3.0.0", + "graceful-fs": "^4.2.11", "progress": "^2.0.3", - "semver": "^6.2.0", + "semver": "^7.6.3", "sumchecker": "^3.0.1" }, "engines": { - "node": ">=12" + "node": ">=22.12.0" }, "optionalDependencies": { - "global-agent": "^3.0.0" - } - }, - "node_modules/@electron/get/node_modules/semver": { - "version": "6.3.1", - "dev": true, - "license": "ISC", - "bin": { - "semver": "bin/semver.js" + "undici": "^7.24.4" } }, "node_modules/@electron/notarize": { @@ -636,29 +620,6 @@ "node": ">=10" } }, - "node_modules/@electron/notarize/node_modules/jsonfile": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz", - "integrity": "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==", - "dev": true, - "license": "MIT", - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/@electron/notarize/node_modules/universalify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", - "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 10.0.0" - } - }, "node_modules/@electron/osx-sign": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/@electron/osx-sign/-/osx-sign-1.3.3.tgz", @@ -681,21 +642,6 @@ "node": ">=12.0.0" } }, - "node_modules/@electron/osx-sign/node_modules/fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=12" - } - }, "node_modules/@electron/osx-sign/node_modules/isbinaryfile": { "version": "4.0.10", "resolved": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-4.0.10.tgz", @@ -709,49 +655,19 @@ "url": "https://github.com/sponsors/gjtorikian/" } }, - "node_modules/@electron/osx-sign/node_modules/jsonfile": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz", - "integrity": "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==", - "dev": true, - "license": "MIT", - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/@electron/osx-sign/node_modules/universalify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", - "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 10.0.0" - } - }, "node_modules/@electron/rebuild": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/@electron/rebuild/-/rebuild-4.0.2.tgz", - "integrity": "sha512-8iZWVPvOpCdIc5Pj5udQV3PeO7liJVC7BBUSizl1HCfP7ZxYc9Kqz0c3PDNj2HQ5cQfJ5JaBeJIYKPjAvLn2Rg==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/@electron/rebuild/-/rebuild-4.2.0.tgz", + "integrity": "sha512-RKL/O+jGoXJMxrx/5771y1n0xTKmFuOYGO3gMmwypBM6rsH0kou0mswwdXA2JrhIkE4xyC7v9vGk0n6NPzgOxQ==", "dev": true, "license": "MIT", "dependencies": { "@malept/cross-spawn-promise": "^2.0.0", "debug": "^4.1.1", - "detect-libc": "^2.0.1", - "got": "^11.7.0", - "graceful-fs": "^4.2.11", "node-abi": "^4.2.0", "node-api-version": "^0.2.1", - "node-gyp": "^11.2.0", - "ora": "^5.1.0", - "read-binary-file-arch": "^1.0.6", - "semver": "^7.3.5", - "tar": "^6.0.5", - "yargs": "^17.0.1" + "node-gyp": "^12.2.0", + "read-binary-file-arch": "^1.0.6" }, "bin": { "electron-rebuild": "lib/cli.js" @@ -760,108 +676,6 @@ "node": ">=22.12.0" } }, - "node_modules/@electron/rebuild/node_modules/chownr": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", - "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=10" - } - }, - "node_modules/@electron/rebuild/node_modules/fs-minipass": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", - "integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==", - "dev": true, - "license": "ISC", - "dependencies": { - "minipass": "^3.0.0" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/@electron/rebuild/node_modules/fs-minipass/node_modules/minipass": { - "version": "3.3.6", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", - "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", - "dev": true, - "license": "ISC", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@electron/rebuild/node_modules/minizlib": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz", - "integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==", - "dev": true, - "license": "MIT", - "dependencies": { - "minipass": "^3.0.0", - "yallist": "^4.0.0" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/@electron/rebuild/node_modules/minizlib/node_modules/minipass": { - "version": "3.3.6", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", - "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", - "dev": true, - "license": "ISC", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@electron/rebuild/node_modules/mkdirp": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", - "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", - "dev": true, - "license": "MIT", - "bin": { - "mkdirp": "bin/cmd.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/@electron/rebuild/node_modules/tar": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", - "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", - "deprecated": "Old versions of tar are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exhorbitant rates) by contacting i@izs.me", - "dev": true, - "license": "ISC", - "dependencies": { - "chownr": "^2.0.0", - "fs-minipass": "^2.0.0", - "minipass": "^5.0.0", - "minizlib": "^2.1.1", - "mkdirp": "^1.0.3", - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/@electron/rebuild/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true, - "license": "ISC" - }, "node_modules/@electron/universal": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/@electron/universal/-/universal-2.0.3.tgz", @@ -882,9 +696,9 @@ } }, "node_modules/@electron/universal/node_modules/fs-extra": { - "version": "11.3.3", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.3.3.tgz", - "integrity": "sha512-VWSRii4t0AFm6ixFFmLLx1t7wS1gh+ckoa84aOeapGum0h+EZd1EhEumSB+ZdDLnEPuucsVB9oB7cxJHap6Afg==", + "version": "11.3.6", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.3.6.tgz", + "integrity": "sha512-w8ZNZr2mKIc7qeNaQ9AVPT1+iFaI+Avd4xudVOvdDJ8VytREi1Ft5Ih7hd9jjehod8vAM5GMsfQ/TpPf4EyoEA==", "dev": true, "license": "MIT", "dependencies": { @@ -896,29 +710,6 @@ "node": ">=14.14" } }, - "node_modules/@electron/universal/node_modules/jsonfile": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz", - "integrity": "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==", - "dev": true, - "license": "MIT", - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/@electron/universal/node_modules/universalify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", - "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 10.0.0" - } - }, "node_modules/@electron/windows-sign": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/@electron/windows-sign/-/windows-sign-1.2.2.tgz", @@ -942,9 +733,9 @@ } }, "node_modules/@electron/windows-sign/node_modules/fs-extra": { - "version": "11.3.3", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.3.3.tgz", - "integrity": "sha512-VWSRii4t0AFm6ixFFmLLx1t7wS1gh+ckoa84aOeapGum0h+EZd1EhEumSB+ZdDLnEPuucsVB9oB7cxJHap6Afg==", + "version": "11.3.6", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.3.6.tgz", + "integrity": "sha512-w8ZNZr2mKIc7qeNaQ9AVPT1+iFaI+Avd4xudVOvdDJ8VytREi1Ft5Ih7hd9jjehod8vAM5GMsfQ/TpPf4EyoEA==", "dev": true, "license": "MIT", "optional": true, @@ -958,33 +749,6 @@ "node": ">=14.14" } }, - "node_modules/@electron/windows-sign/node_modules/jsonfile": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz", - "integrity": "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true, - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/@electron/windows-sign/node_modules/universalify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", - "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", - "dev": true, - "license": "MIT", - "optional": true, - "peer": true, - "engines": { - "node": ">= 10.0.0" - } - }, "node_modules/@emotion/hash": { "version": "0.8.0", "dev": true, @@ -1485,7 +1249,9 @@ } }, "node_modules/@eslint/eslintrc/node_modules/brace-expansion": { - "version": "1.1.12", + "version": "1.1.18", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.18.tgz", + "integrity": "sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw==", "dev": true, "license": "MIT", "dependencies": { @@ -1494,7 +1260,9 @@ } }, "node_modules/@eslint/eslintrc/node_modules/minimatch": { - "version": "3.1.2", + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", "dev": true, "license": "ISC", "dependencies": { @@ -1526,7 +1294,9 @@ } }, "node_modules/@humanwhocodes/config-array/node_modules/brace-expansion": { - "version": "1.1.12", + "version": "1.1.18", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.18.tgz", + "integrity": "sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw==", "dev": true, "license": "MIT", "dependencies": { @@ -1535,7 +1305,9 @@ } }, "node_modules/@humanwhocodes/config-array/node_modules/minimatch": { - "version": "3.1.2", + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", "dev": true, "license": "ISC", "dependencies": { @@ -1562,31 +1334,8 @@ "dev": true, "license": "BSD-3-Clause" }, - "node_modules/@isaacs/balanced-match": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@isaacs/balanced-match/-/balanced-match-4.0.1.tgz", - "integrity": "sha512-yzMTt9lEb8Gv7zRioUilSglI0c0smZ9k5D65677DLWLtWJaXIS3CqcGyUFByYKlnUj6TkjLVs54fBl6+TiGQDQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": "20 || >=22" - } - }, - "node_modules/@isaacs/brace-expansion": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@isaacs/brace-expansion/-/brace-expansion-5.0.0.tgz", - "integrity": "sha512-ZT55BDLV0yv0RBm2czMiZ+SqCGO7AvmOM3G/w2xhVPH+te0aKgFjmBvGlL1dH+ql2tgGO3MVrbb3jCKyvpgnxA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@isaacs/balanced-match": "^4.0.1" - }, - "engines": { - "node": "20 || >=22" - } - }, - "node_modules/@isaacs/cliui": { - "version": "8.0.2", + "node_modules/@isaacs/cliui": { + "version": "8.0.2", "dev": true, "license": "ISC", "dependencies": { @@ -1687,16 +1436,6 @@ "node": ">=18.0.0" } }, - "node_modules/@isaacs/fs-minipass/node_modules/minipass": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", - "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=16 || 14 >=14.17" - } - }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.13", "dev": true, @@ -1792,29 +1531,6 @@ "node": ">=10" } }, - "node_modules/@malept/flatpak-bundler/node_modules/jsonfile": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz", - "integrity": "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==", - "dev": true, - "license": "MIT", - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/@malept/flatpak-bundler/node_modules/universalify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", - "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 10.0.0" - } - }, "node_modules/@monaco-editor/loader": { "version": "1.6.1", "dev": true, @@ -1836,6 +1552,19 @@ "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, + "node_modules/@noble/hashes": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-2.2.0.tgz", + "integrity": "sha512-IYqDGiTXab6FniAgnSdZwgWbomxpy9FtYvLKs7wCUs2a8RkITG+DFGO1DM9cr+E3/RgADRpFjrKVaJ1z6sjtEg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 20.19.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "dev": true, @@ -1868,41 +1597,56 @@ "node": ">= 8" } }, - "node_modules/@npmcli/agent": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@npmcli/agent/-/agent-3.0.0.tgz", - "integrity": "sha512-S79NdEgDQd/NGCay6TCoVzXSj74skRZIKJcpJjC5lOq34SZzyI6MqtiiWoiVWoVrTcGjNeC4ipbh1VIHlpfF5Q==", + "node_modules/@peculiar/asn1-schema": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/@peculiar/asn1-schema/-/asn1-schema-2.8.0.tgz", + "integrity": "sha512-7YT0U/ze0tF2QOBbE15gKZwy5tvgGyLRiRHLzhlbOpf7BT032oBSd0haZqXn5W6l26WLlu3dyxzjM+2638/z2Q==", "dev": true, - "license": "ISC", + "license": "MIT", "dependencies": { - "agent-base": "^7.1.0", - "http-proxy-agent": "^7.0.0", - "https-proxy-agent": "^7.0.1", - "lru-cache": "^10.0.1", - "socks-proxy-agent": "^8.0.3" + "@peculiar/utils": "^2.0.2", + "asn1js": "^3.0.10", + "tslib": "^2.8.1" + } + }, + "node_modules/@peculiar/json-schema": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/@peculiar/json-schema/-/json-schema-1.1.12.tgz", + "integrity": "sha512-coUfuoMeIB7B8/NMekxaDzLhaYmp0HZNPEjYRm9goRou8UZIC3z21s0sL9AWoCw4EG876QyO3kYrc61WNF9B/w==", + "dev": true, + "license": "MIT", + "dependencies": { + "tslib": "^2.0.0" }, "engines": { - "node": "^18.17.0 || >=20.5.0" + "node": ">=8.0.0" } }, - "node_modules/@npmcli/agent/node_modules/lru-cache": { - "version": "10.4.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", - "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "node_modules/@peculiar/utils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@peculiar/utils/-/utils-2.0.3.tgz", + "integrity": "sha512-+oL3HPFRIZ1St2K50lWCXiioIgSoxzz7R1J3uF6neO2yl1sgmpgY6XXJH4BdpoDkMWznQTeYF6oWNDZLCdQ4eQ==", "dev": true, - "license": "ISC" + "license": "MIT", + "dependencies": { + "tslib": "^2.8.1" + } }, - "node_modules/@npmcli/fs": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@npmcli/fs/-/fs-4.0.0.tgz", - "integrity": "sha512-/xGlezI6xfGO9NwuJlnwz/K14qD1kCSAGtacBHnGzeAIuJGazcp45KP5NuyARXoKb7cwulAGWVsbeSxdG/cb0Q==", + "node_modules/@peculiar/webcrypto": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/@peculiar/webcrypto/-/webcrypto-1.7.1.tgz", + "integrity": "sha512-ODOov0sGMJMf3jPonOkgGqPknTsu+DdQ7kD++gz8aI+aFMOMHFbWAA2taqXXVTdP+OTOQR/znGvSpmkeI0WTYQ==", "dev": true, - "license": "ISC", + "license": "MIT", "dependencies": { - "semver": "^7.3.5" + "@peculiar/asn1-schema": "^2.7.0", + "@peculiar/json-schema": "^1.1.12", + "@peculiar/utils": "^2.0.2", + "tslib": "^2.8.1", + "webcrypto-core": "^1.9.2" }, "engines": { - "node": "^18.17.0 || >=20.5.0" + "node": ">=14.18.0" } }, "node_modules/@pkgjs/parseargs": { @@ -2059,9 +1803,9 @@ "license": "MIT" }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.52.5.tgz", - "integrity": "sha512-8c1vW4ocv3UOMp9K+gToY5zL2XiiVw3k7f1ksf4yO1FlDFQ1C2u72iACFnSOceJFsWskc2WZNqeRhFRPzv+wtQ==", + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.62.2.tgz", + "integrity": "sha512-6o7ZLZK+BeenkZCFNDXqpbjw9bD6nuWonvS/lwQJp7NoVVxm6p3qE7qQ5jGuBjiFsgvqjD8mZAU5oWxTmbOeOg==", "cpu": [ "arm" ], @@ -2073,9 +1817,9 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.52.5.tgz", - "integrity": "sha512-mQGfsIEFcu21mvqkEKKu2dYmtuSZOBMmAl5CFlPGLY94Vlcm+zWApK7F/eocsNzp8tKmbeBP8yXyAbx0XHsFNA==", + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.62.2.tgz", + "integrity": "sha512-BaH7BllCACHoH1LguOU56UItGfUWjujlO65kS9LAodViaN4bwIKd7oeW/ZHJ/4ljr/7MIiENnNy3HJ0zXv8Zkw==", "cpu": [ "arm64" ], @@ -2087,9 +1831,9 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.52.5.tgz", - "integrity": "sha512-takF3CR71mCAGA+v794QUZ0b6ZSrgJkArC+gUiG6LB6TQty9T0Mqh3m2ImRBOxS2IeYBo4lKWIieSvnEk2OQWA==", + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.62.2.tgz", + "integrity": "sha512-v39RCCvj4He82I9sFmk+M1VZ0PLM9sfsLVikjfx2hYBNALhrrOR2D3JjQA6AhlaSOgcR+RzrKY7e1+bT6SUO/A==", "cpu": [ "arm64" ], @@ -2101,9 +1845,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.52.5.tgz", - "integrity": "sha512-W901Pla8Ya95WpxDn//VF9K9u2JbocwV/v75TE0YIHNTbhqUTv9w4VuQ9MaWlNOkkEfFwkdNhXgcLqPSmHy0fA==", + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.62.2.tgz", + "integrity": "sha512-yl0y2vq3S3lHeuXhEdss6TWfKW8vkujImO12tn4ZkG/4oghr09LvdYm2RElVjokTQiUvDUGXLGsYeLqUMCKpGA==", "cpu": [ "x64" ], @@ -2115,9 +1859,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-arm64": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.52.5.tgz", - "integrity": "sha512-QofO7i7JycsYOWxe0GFqhLmF6l1TqBswJMvICnRUjqCx8b47MTo46W8AoeQwiokAx3zVryVnxtBMcGcnX12LvA==", + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.62.2.tgz", + "integrity": "sha512-tT4pvt4qXD+vEoezupCWi+a1F0vvDiksiHc+PxRlYTOH1I6/X4id9jPxTP+Fg+545euaFT1jJVs4CEdHZAU1vw==", "cpu": [ "arm64" ], @@ -2129,9 +1873,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-x64": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.52.5.tgz", - "integrity": "sha512-jr21b/99ew8ujZubPo9skbrItHEIE50WdV86cdSoRkKtmWa+DDr6fu2c/xyRT0F/WazZpam6kk7IHBerSL7LDQ==", + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.62.2.tgz", + "integrity": "sha512-6nU5F2wCW+qvCBhTn1pdIU3bzsIoF7EUwsCDRxilWGprQR6yd508YnH9+OKFCwpfS8pjZqDUmnCAr7exax0XCg==", "cpu": [ "x64" ], @@ -2143,13 +1887,16 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.52.5.tgz", - "integrity": "sha512-PsNAbcyv9CcecAUagQefwX8fQn9LQ4nZkpDboBOttmyffnInRy8R8dSg6hxxl2Re5QhHBf6FYIDhIj5v982ATQ==", + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.62.2.tgz", + "integrity": "sha512-n1GJHPOvpIfhi3TmrCeh6S6URt9BFCt0KQE3qvexyGCTAKpR4Lg+eWvNZEqu7epxwus/8ElT3hacYEucm49SZg==", "cpu": [ "arm" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -2157,13 +1904,16 @@ ] }, "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.52.5.tgz", - "integrity": "sha512-Fw4tysRutyQc/wwkmcyoqFtJhh0u31K+Q6jYjeicsGJJ7bbEq8LwPWV/w0cnzOqR2m694/Af6hpFayLJZkG2VQ==", + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.62.2.tgz", + "integrity": "sha512-JqgflS8wEB+UXV/vS1RpRbifGBeN4D5lz8D8oOFbFZw4vedvdOgCFAjfBmIMdW3yL10XpQQ0Ambepw6MXrhOnA==", "cpu": [ "arm" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -2171,13 +1921,16 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.52.5.tgz", - "integrity": "sha512-a+3wVnAYdQClOTlyapKmyI6BLPAFYs0JM8HRpgYZQO02rMR09ZcV9LbQB+NL6sljzG38869YqThrRnfPMCDtZg==", + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.62.2.tgz", + "integrity": "sha512-wnFJkogWvN4jm/hQRF2UBaeUmk20j5+DmHvoyWii2b8HJDyvz1MF2OU/6ynXt2KR63rbZLWkFpoytpdc/yBuSA==", "cpu": [ "arm64" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -2185,13 +1938,16 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.52.5.tgz", - "integrity": "sha512-AvttBOMwO9Pcuuf7m9PkC1PUIKsfaAJ4AYhy944qeTJgQOqJYJ9oVl2nYgY7Rk0mkbsuOpCAYSs6wLYB2Xiw0Q==", + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.62.2.tgz", + "integrity": "sha512-HVu2bp0zhvJ8xHEV9+UUs7S90VadmBSY3LcIMvozbPo4AuMGDWlz3ymHLHZPX4hR67TKTt8Qp5PJ5RBg/i+RMQ==", "cpu": [ "arm64" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -2199,13 +1955,33 @@ ] }, "node_modules/@rollup/rollup-linux-loong64-gnu": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.52.5.tgz", - "integrity": "sha512-DkDk8pmXQV2wVrF6oq5tONK6UHLz/XcEVow4JTTerdeV1uqPeHxwcg7aFsfnSm9L+OO8WJsWotKM2JJPMWrQtA==", + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.62.2.tgz", + "integrity": "sha512-mQqqAV8QaoSgr9I2fKDLY2BAVvmKjWoGiu/cSYQonsLvtqwEn1E4QYfnCOcp5zoEqNhsDYin1s6jx/VJmrxlZg==", + "cpu": [ + "loong64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-musl": { + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.62.2.tgz", + "integrity": "sha512-IxKLoxCQ2IWi6bT2akyDUBGsOImDKB+sPp4EsTmwFQ/fMwpCKm8uLSSgP/Kx/QYUgKis6SEZ5/Nlhup0DIA0PQ==", "cpu": [ "loong64" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -2213,13 +1989,33 @@ ] }, "node_modules/@rollup/rollup-linux-ppc64-gnu": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.52.5.tgz", - "integrity": "sha512-W/b9ZN/U9+hPQVvlGwjzi+Wy4xdoH2I8EjaCkMvzpI7wJUs8sWJ03Rq96jRnHkSrcHTpQe8h5Tg3ZzUPGauvAw==", + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.62.2.tgz", + "integrity": "sha512-Mk5ha2RQSgyFfmYYLkBpPnUk8D8FriBxesO1u9O75X0mHgXL1UQcH5Itl2lurWL2tj0RxV9b9tJgipac0hRY9A==", + "cpu": [ + "ppc64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-musl": { + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.62.2.tgz", + "integrity": "sha512-CjvEnqJL/0/TQ3TXX3OPIJ/kmBellrWd4heXUmHeJlTnmwjKpSJzoehLaL6Xk0ZnMHBu9dZuFADNOrtjF4v+2w==", "cpu": [ "ppc64" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -2227,13 +2023,16 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.52.5.tgz", - "integrity": "sha512-sjQLr9BW7R/ZiXnQiWPkErNfLMkkWIoCz7YMn27HldKsADEKa5WYdobaa1hmN6slu9oWQbB6/jFpJ+P2IkVrmw==", + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.62.2.tgz", + "integrity": "sha512-1SiZbzwdkaDURsew/tSOrooKiYy7EQGT6m8ufavAi9NEyQb/6VuIxFXAL1fqa4iZe3g4NbNk4P7J32z2tw5Mgg==", "cpu": [ "riscv64" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -2241,13 +2040,16 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-musl": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.52.5.tgz", - "integrity": "sha512-hq3jU/kGyjXWTvAh2awn8oHroCbrPm8JqM7RUpKjalIRWWXE01CQOf/tUNWNHjmbMHg/hmNCwc/Pz3k1T/j/Lg==", + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.62.2.tgz", + "integrity": "sha512-nQts12zJ3NQRoE6uYljOH89v7szzLDvG2JD/vsX+vGXU8w/At1GowTZ5/7qeFQ8m7L55rpR8Okugnuo5bgjy2Q==", "cpu": [ "riscv64" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -2255,13 +2057,16 @@ ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.52.5.tgz", - "integrity": "sha512-gn8kHOrku8D4NGHMK1Y7NA7INQTRdVOntt1OCYypZPRt6skGbddska44K8iocdpxHTMMNui5oH4elPH4QOLrFQ==", + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.62.2.tgz", + "integrity": "sha512-E9/ll019jhPIJgpzfZoIkBGhcz+kKNgVWYRY0zr9srBdPPFVpvOKW8VaJKUbeK+eZXyQF9ltME+Kk6affeaPgg==", "cpu": [ "s390x" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -2269,13 +2074,16 @@ ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.52.5.tgz", - "integrity": "sha512-hXGLYpdhiNElzN770+H2nlx+jRog8TyynpTVzdlc6bndktjKWyZyiCsuDAlpd+j+W+WNqfcyAWz9HxxIGfZm1Q==", + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.62.2.tgz", + "integrity": "sha512-5BqxR/pshjey51iliyzTD5Xi3EN0aLmQ2lZ3lvefVV9c82BvrLo2/6OT55iifpWBufs6kdwWbuOKS841DrmK9A==", "cpu": [ "x64" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -2283,23 +2091,40 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.52.5.tgz", - "integrity": "sha512-arCGIcuNKjBoKAXD+y7XomR9gY6Mw7HnFBv5Rw7wQRvwYLR7gBAgV7Mb2QTyjXfTveBNFAtPt46/36vV9STLNg==", + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.62.2.tgz", + "integrity": "sha512-uNN83XxQrRAh/w0/pmAfibcwyb6YWt4gP+dpnQKPVJshAloQ785ii8CT8ZCIxkGg9opVsvAlGhFitSm6D1Jjpg==", "cpu": [ "x64" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ "linux" ] }, + "node_modules/@rollup/rollup-openbsd-x64": { + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.62.2.tgz", + "integrity": "sha512-srjEIxSH3LRnJN6THczDHWQplqEMFiAJrTab0msUryh9kwNpkICf3Ea6q6MN/2cZwRFUNx5w+h6Hpi4QuHS6Zg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ] + }, "node_modules/@rollup/rollup-openharmony-arm64": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.52.5.tgz", - "integrity": "sha512-QoFqB6+/9Rly/RiPjaomPLmR/13cgkIGfA40LHly9zcH1S0bN2HVFYk3a1eAyHQyjs3ZJYlXvIGtcCs5tko9Cw==", + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.62.2.tgz", + "integrity": "sha512-8hOJnxgbyObnCm5AlRA3A931xX19xq80RjVTKgJOvEKWqJruP/Uf12IbAOaDjjEXYRewwHLfmF0YRIdK3OwKWA==", "cpu": [ "arm64" ], @@ -2311,9 +2136,9 @@ ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.52.5.tgz", - "integrity": "sha512-w0cDWVR6MlTstla1cIfOGyl8+qb93FlAVutcor14Gf5Md5ap5ySfQ7R9S/NjNaMLSFdUnKGEasmVnu3lCMqB7w==", + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.62.2.tgz", + "integrity": "sha512-mmF4AY1i0hG/bLWUctUq59gtmgaSIRa3cu/A3JFRp/sCNEme2bgDEiDS22P9FbnJB8NJNF4jPJiSP5RHQpUTDg==", "cpu": [ "arm64" ], @@ -2325,9 +2150,9 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.52.5", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.52.5.tgz", - "integrity": "sha512-Aufdpzp7DpOTULJCuvzqcItSGDH73pF3ko/f+ckJhxQyHtp67rHw3HMNxoIdDMUITJESNE6a8uh4Lo4SLouOUg==", + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.62.2.tgz", + "integrity": "sha512-DZgkknc6jhHrk46V25vbAM0zZkyP0nSDkJB8/dRkLTxv470dOmWDqGoEJl/9A0dFfS7yE3REOwNDxpHwSLSt0Q==", "cpu": [ "ia32" ], @@ -2339,7 +2164,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-gnu": { - "version": "4.52.5", + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.62.2.tgz", + "integrity": "sha512-T6xr6ucWSFto+VGajA8YH26LdpHRuP4YLHEKAtCWvJDOlnmWcDZVCI2Jmjr+IFHDlt2zRaTAKE4tfjTaWLgJBg==", "cpu": [ "x64" ], @@ -2351,7 +2178,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.52.5", + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.62.2.tgz", + "integrity": "sha512-BfzEnDJOt9T8M989/lA37EcJgat01wLRnoi5dQf3QzOH7jzpqTAzdDbVfRljVr5r+jzKqpbHeyOfAaXxAd0PAA==", "cpu": [ "x64" ], @@ -2369,6 +2198,8 @@ }, "node_modules/@sindresorhus/is": { "version": "4.6.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz", + "integrity": "sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==", "dev": true, "license": "MIT", "engines": { @@ -2387,6 +2218,8 @@ }, "node_modules/@szmarczak/http-timer": { "version": "4.0.6", + "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.6.tgz", + "integrity": "sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w==", "dev": true, "license": "MIT", "dependencies": { @@ -2446,6 +2279,8 @@ }, "node_modules/@types/cacheable-request": { "version": "6.0.3", + "resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.3.tgz", + "integrity": "sha512-IQ3EbTzGxIigb1I3qPZc1rWJnH0BmSKv5QYTalEwweFvyBDLSAe24zP0le/hyi7ecGfZVlIVAg4BZqb8WBwKqw==", "dev": true, "license": "MIT", "dependencies": { @@ -2476,16 +2311,6 @@ "@types/node": "*" } }, - "node_modules/@types/cors": { - "version": "2.8.19", - "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.19.tgz", - "integrity": "sha512-mFNylyeyqN93lfe/9CSxOGREz8cpzAhH+E93xJ4xWQf62V8sQ/24reV2nyzUWM6H6Xji+GGHpkbLe7pVoUEskg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/d3-array": { "version": "3.2.2", "dev": true, @@ -2556,7 +2381,9 @@ "license": "MIT" }, "node_modules/@types/estree": { - "version": "1.0.8", + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz", + "integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==", "dev": true, "license": "MIT" }, @@ -2612,7 +2439,9 @@ } }, "node_modules/@types/http-cache-semantics": { - "version": "4.0.4", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.2.0.tgz", + "integrity": "sha512-L3LgimLHXtGkWikKnsPg0/VFx9OGZaC+eN1u4r+OB1XRqH3meBIAVC2zr1WdMH+RHmnRkqliQAOHNJ/E0j/e0Q==", "dev": true, "license": "MIT" }, @@ -2637,6 +2466,8 @@ }, "node_modules/@types/keyv": { "version": "3.1.4", + "resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.4.tgz", + "integrity": "sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg==", "dev": true, "license": "MIT", "dependencies": { @@ -2664,23 +2495,6 @@ "undici-types": "~6.21.0" } }, - "node_modules/@types/node-cron": { - "version": "3.0.11", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/plist": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/@types/plist/-/plist-3.0.5.tgz", - "integrity": "sha512-E6OCaRmAe4WDmWNsL/9RMqdkkzDCY1etutkflWk4c+AcjDU07Pcz1fQwTX0TQz+Pxqn9i4L1TU3UFpjnrcDgxA==", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "@types/node": "*", - "xmlbuilder": ">=11.0.1" - } - }, "node_modules/@types/prismjs": { "version": "1.26.5", "resolved": "https://registry.npmjs.org/@types/prismjs/-/prismjs-1.26.5.tgz", @@ -2742,6 +2556,8 @@ }, "node_modules/@types/responselike": { "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.3.tgz", + "integrity": "sha512-H/+L+UkTV33uf49PH5pCAUBVPNj2nDBXTN+qS1dOwyyg24l3CcicicCA7ca+HMvJBZcFgl5r8e+RR6elsb4Lyw==", "dev": true, "license": "MIT", "dependencies": { @@ -2782,28 +2598,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@types/uuid": { - "version": "9.0.8", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/verror": { - "version": "1.10.11", - "resolved": "https://registry.npmjs.org/@types/verror/-/verror-1.10.11.tgz", - "integrity": "sha512-RlDm9K7+o5stv0Co8i8ZRGxDbrTxhJtgjqjFyVh/tXQyl/rYtTKlnTvZ88oSTeYREWurwx20Js4kTuKCsFkUtg==", - "dev": true, - "license": "MIT", - "optional": true - }, - "node_modules/@types/yauzl": { - "version": "2.10.3", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "7.18.0", "dev": true, @@ -3006,29 +2800,29 @@ } }, "node_modules/@vitest/coverage-v8": { - "version": "4.0.17", - "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-4.0.17.tgz", - "integrity": "sha512-/6zU2FLGg0jsd+ePZcwHRy3+WpNTBBhDY56P4JTRqUN/Dp6CvOEa9HrikcQ4KfV2b2kAHUFB4dl1SuocWXSFEw==", + "version": "4.1.10", + "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-4.1.10.tgz", + "integrity": "sha512-IM49HmthevbgAO4anp1hwtoT9wYe59w0LR00gr+eagHE+ZJ5lK4sLPeO0ubgoJcwLk6dehU3R24N+FbEEKDc8g==", "dev": true, "license": "MIT", "dependencies": { "@bcoe/v8-coverage": "^1.0.2", - "@vitest/utils": "4.0.17", - "ast-v8-to-istanbul": "^0.3.10", + "@vitest/utils": "4.1.10", + "ast-v8-to-istanbul": "^1.0.0", "istanbul-lib-coverage": "^3.2.2", "istanbul-lib-report": "^3.0.1", "istanbul-reports": "^3.2.0", - "magicast": "^0.5.1", + "magicast": "^0.5.2", "obug": "^2.1.1", - "std-env": "^3.10.0", - "tinyrainbow": "^3.0.3" + "std-env": "^4.0.0-rc.1", + "tinyrainbow": "^3.1.0" }, "funding": { "url": "https://opencollective.com/vitest" }, "peerDependencies": { - "@vitest/browser": "4.0.17", - "vitest": "4.0.17" + "@vitest/browser": "4.1.10", + "vitest": "4.1.10" }, "peerDependenciesMeta": { "@vitest/browser": { @@ -3037,31 +2831,31 @@ } }, "node_modules/@vitest/expect": { - "version": "4.0.17", - "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.0.17.tgz", - "integrity": "sha512-mEoqP3RqhKlbmUmntNDDCJeTDavDR+fVYkSOw8qRwJFaW/0/5zA9zFeTrHqNtcmwh6j26yMmwx2PqUDPzt5ZAQ==", + "version": "4.1.10", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.1.10.tgz", + "integrity": "sha512-YsCn+qAk1GWjQOWFEsEcL2gNQ0zmVmQu3T03qP6UyjhtmdtwtbuI+DASn/7iQB3HGTXkdBwGddzxPlmiql5vlA==", "dev": true, "license": "MIT", "dependencies": { - "@standard-schema/spec": "^1.0.0", + "@standard-schema/spec": "^1.1.0", "@types/chai": "^5.2.2", - "@vitest/spy": "4.0.17", - "@vitest/utils": "4.0.17", - "chai": "^6.2.1", - "tinyrainbow": "^3.0.3" + "@vitest/spy": "4.1.10", + "@vitest/utils": "4.1.10", + "chai": "^6.2.2", + "tinyrainbow": "^3.1.0" }, "funding": { "url": "https://opencollective.com/vitest" } }, "node_modules/@vitest/mocker": { - "version": "4.0.17", - "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.0.17.tgz", - "integrity": "sha512-+ZtQhLA3lDh1tI2wxe3yMsGzbp7uuJSWBM1iTIKCbppWTSBN09PUC+L+fyNlQApQoR+Ps8twt2pbSSXg2fQVEQ==", + "version": "4.1.10", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.1.10.tgz", + "integrity": "sha512-v0xaezt+DKEmKfaxg133ldzADrwLGd7Ze1MfQQTYfvs8OqZIwbxyxaYURivwV7sWy5fqn3rH5uOrSp07bp44Ow==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/spy": "4.0.17", + "@vitest/spy": "4.1.10", "estree-walker": "^3.0.3", "magic-string": "^0.30.21" }, @@ -3070,7 +2864,7 @@ }, "peerDependencies": { "msw": "^2.4.9", - "vite": "^6.0.0 || ^7.0.0-0" + "vite": "^6.0.0 || ^7.0.0 || ^8.0.0" }, "peerDependenciesMeta": { "msw": { @@ -3082,26 +2876,26 @@ } }, "node_modules/@vitest/pretty-format": { - "version": "4.0.17", - "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.0.17.tgz", - "integrity": "sha512-Ah3VAYmjcEdHg6+MwFE17qyLqBHZ+ni2ScKCiW2XrlSBV4H3Z7vYfPfz7CWQ33gyu76oc0Ai36+kgLU3rfF4nw==", + "version": "4.1.10", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.1.10.tgz", + "integrity": "sha512-W1HsjSH4MXQ9YfmmhLAoIYf1HRfekQCGngeIgcei6MP5QQGWUe0gkopdZQaVCFO+JDJMrAJGwa5pRpNpvy4P8Q==", "dev": true, "license": "MIT", "dependencies": { - "tinyrainbow": "^3.0.3" + "tinyrainbow": "^3.1.0" }, "funding": { "url": "https://opencollective.com/vitest" } }, "node_modules/@vitest/runner": { - "version": "4.0.17", - "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-4.0.17.tgz", - "integrity": "sha512-JmuQyf8aMWoo/LmNFppdpkfRVHJcsgzkbCA+/Bk7VfNH7RE6Ut2qxegeyx2j3ojtJtKIbIGy3h+KxGfYfk28YQ==", + "version": "4.1.10", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-4.1.10.tgz", + "integrity": "sha512-IKI6kpIH+LmpROplyLwBBaCfMgOZOMsygVa6BARD6ahA04VRuJSa6OaVG7kRvSEMD870Vd91rSSw0eegtWyLGg==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/utils": "4.0.17", + "@vitest/utils": "4.1.10", "pathe": "^2.0.3" }, "funding": { @@ -3109,13 +2903,14 @@ } }, "node_modules/@vitest/snapshot": { - "version": "4.0.17", - "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-4.0.17.tgz", - "integrity": "sha512-npPelD7oyL+YQM2gbIYvlavlMVWUfNNGZPcu0aEUQXt7FXTuqhmgiYupPnAanhKvyP6Srs2pIbWo30K0RbDtRQ==", + "version": "4.1.10", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-4.1.10.tgz", + "integrity": "sha512-xRkfOT1qpTAi/Ti4Y1LtfRc3kEuqxGw59eN2jN9pRWMtS/XDevekhcFSqvQqjUNGksfjMJu3Y+oJ+4Ypn2OaJw==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/pretty-format": "4.0.17", + "@vitest/pretty-format": "4.1.10", + "@vitest/utils": "4.1.10", "magic-string": "^0.30.21", "pathe": "^2.0.3" }, @@ -3124,9 +2919,9 @@ } }, "node_modules/@vitest/spy": { - "version": "4.0.17", - "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-4.0.17.tgz", - "integrity": "sha512-I1bQo8QaP6tZlTomQNWKJE6ym4SHf3oLS7ceNjozxxgzavRAgZDc06T7kD8gb9bXKEgcLNt00Z+kZO6KaJ62Ew==", + "version": "4.1.10", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-4.1.10.tgz", + "integrity": "sha512-PLf/Ugvoq5wO/b4rwYCR1h2PSIdXz7wnkQFMiUpLdtM7l6pqVFcQIBEHyT1+l+cj7mNwAfZHzqXqDyjvOuwbDw==", "dev": true, "license": "MIT", "funding": { @@ -3134,23 +2929,24 @@ } }, "node_modules/@vitest/utils": { - "version": "4.0.17", - "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.0.17.tgz", - "integrity": "sha512-RG6iy+IzQpa9SB8HAFHJ9Y+pTzI+h8553MrciN9eC6TFBErqrQaTas4vG+MVj8S4uKk8uTT2p0vgZPnTdxd96w==", + "version": "4.1.10", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.1.10.tgz", + "integrity": "sha512-fy9am/HWxbaGt/Sawrp90vt6Y6jQwf1RX77cz3uwoJwJVMli/e1IEwRPnMNJ7vKfPTwo0diXifkpPvwH9v7nGA==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/pretty-format": "4.0.17", - "tinyrainbow": "^3.0.3" + "@vitest/pretty-format": "4.1.10", + "convert-source-map": "^2.0.0", + "tinyrainbow": "^3.1.0" }, "funding": { "url": "https://opencollective.com/vitest" } }, "node_modules/@xmldom/xmldom": { - "version": "0.8.11", - "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.11.tgz", - "integrity": "sha512-cQzWCtO6C8TQiYl1ruKNn2U6Ao4o4WBBcbL61yJl84x+j5sOWWFU9X7DpND8XZG3daDppSsigMdfAIl2upQBRw==", + "version": "0.8.15", + "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.15.tgz", + "integrity": "sha512-/5NV/vDALVFDXgLmfsy9TRCBlKwO2LNBFzpzvb9iIj+jR+eSc6DLYYvVOdivT/jm7MtU6TebYuRmzEOI7w40UA==", "dev": true, "license": "MIT", "engines": { @@ -3164,21 +2960,14 @@ "dev": true, "license": "BSD-2-Clause" }, - "node_modules/7zip-bin": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/7zip-bin/-/7zip-bin-5.2.0.tgz", - "integrity": "sha512-ukTPVhqG4jNzMro2qA9HSCSSVJN3aN7tlb+hfqYCt3ER0yWroeA2VR38MNrOHLQ/cVj+DaIMad0kFCtWWowh/A==", - "dev": true, - "license": "MIT" - }, "node_modules/abbrev": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-3.0.1.tgz", - "integrity": "sha512-AO2ac6pjRB3SJmGJo+v5/aK6Omggp6fsLrs6wN9bd35ulu4cCwaAU9+7ZhXjeqHVkaHThLuzH0nZr0YpCDhygg==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-4.0.0.tgz", + "integrity": "sha512-a1wflyaL0tHtJSmLSOVybYhy22vRih4eduhhrkcjgrWGnRfrZtovJ2FRjxuTtkkj47O/baf0R86QU5OuYpz8fA==", "dev": true, "license": "ISC", "engines": { - "node": "^18.17.0 || >=20.5.0" + "node": "^20.17.0 || >=22.9.0" } }, "node_modules/accepts": { @@ -3236,14 +3025,15 @@ "version": "7.1.4", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz", "integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==", - "dev": true, "license": "MIT", "engines": { "node": ">= 14" } }, "node_modules/ajv": { - "version": "6.12.6", + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.15.0.tgz", + "integrity": "sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==", "dev": true, "license": "MIT", "dependencies": { @@ -3257,16 +3047,6 @@ "url": "https://github.com/sponsors/epoberezkin" } }, - "node_modules/ajv-keywords": { - "version": "3.5.2", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", - "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", - "dev": true, - "license": "MIT", - "peerDependencies": { - "ajv": "^6.9.1" - } - }, "node_modules/ansi-regex": { "version": "5.0.1", "dev": true, @@ -3369,39 +3149,36 @@ "node": ">= 8" } }, - "node_modules/app-builder-bin": { - "version": "5.0.0-alpha.12", - "resolved": "https://registry.npmjs.org/app-builder-bin/-/app-builder-bin-5.0.0-alpha.12.tgz", - "integrity": "sha512-j87o0j6LqPL3QRr8yid6c+Tt5gC7xNfYo6uQIQkorAC6MpeayVMZrEDzKmJJ/Hlv7EnOQpaRm53k6ktDYZyB6w==", - "dev": true, - "license": "MIT" - }, "node_modules/app-builder-lib": { - "version": "26.5.0", - "resolved": "https://registry.npmjs.org/app-builder-lib/-/app-builder-lib-26.5.0.tgz", - "integrity": "sha512-iRRiJhM0uFMauDeIuv8ESHZSn+LESbdDEuHi7rKdeETjrvBObecXnWJx1f3vs3KtoGcd3hCk1zURKypyvZOtFQ==", + "version": "26.15.3", + "resolved": "https://registry.npmjs.org/app-builder-lib/-/app-builder-lib-26.15.3.tgz", + "integrity": "sha512-2VnyWkqsP5v5XbBhL3tD5Syx8iNPBYsoU7kY4S2fz7wg8Rj/nztWKCUzGKaFRTv0Xwf3/H058CR1Kvtd/3lRow==", "dev": true, "license": "MIT", "dependencies": { - "@develar/schema-utils": "~2.6.5", "@electron/asar": "3.4.1", "@electron/fuses": "^1.8.0", + "@electron/get": "^3.0.0", "@electron/notarize": "2.5.0", "@electron/osx-sign": "1.3.3", - "@electron/rebuild": "4.0.1", + "@electron/rebuild": "^4.0.4", "@electron/universal": "2.0.3", "@malept/flatpak-bundler": "^0.4.0", + "@noble/hashes": "^2.2.0", + "@peculiar/webcrypto": "^1.7.1", "@types/fs-extra": "9.0.13", + "ajv": "^8.18.0", + "asn1js": "^3.0.10", "async-exit-hook": "^2.0.1", - "builder-util": "26.4.1", - "builder-util-runtime": "9.5.1", + "builder-util": "26.15.3", + "builder-util-runtime": "9.7.0", "chromium-pickle-js": "^0.2.0", "ci-info": "4.3.1", "debug": "^4.3.4", "dotenv": "^16.4.5", "dotenv-expand": "^11.0.6", "ejs": "^3.1.8", - "electron-publish": "26.4.1", + "electron-publish": "26.15.3", "fs-extra": "^10.1.0", "hosted-git-info": "^4.1.0", "isbinaryfile": "^5.0.0", @@ -3409,149 +3186,216 @@ "js-yaml": "^4.1.0", "json5": "^2.2.3", "lazy-val": "^1.0.5", - "minimatch": "^10.0.3", + "minimatch": "^10.2.5", + "pkijs": "^3.4.0", "plist": "3.1.0", + "proper-lockfile": "^4.1.2", "resedit": "^1.7.0", "semver": "~7.7.3", - "tar": "7.5.3", + "tar": "^7.5.7", "temp-file": "^3.4.0", "tiny-async-pool": "1.3.0", + "unzipper": "^0.12.3", "which": "^5.0.0" }, "engines": { "node": ">=14.0.0" }, "peerDependencies": { - "dmg-builder": "26.5.0", - "electron-builder-squirrel-windows": "26.5.0" + "dmg-builder": "26.15.3", + "electron-builder-squirrel-windows": "26.15.3" } }, - "node_modules/app-builder-lib/node_modules/fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "node_modules/app-builder-lib/node_modules/@electron/get": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@electron/get/-/get-3.1.0.tgz", + "integrity": "sha512-F+nKc0xW+kVbBRhFzaMgPy3KwmuNTYX1fx6+FxxoSnNgwYX6LD7AKBTWkU0MQ6IBoe7dz069CNkR673sPAgkCQ==", "dev": true, "license": "MIT", "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" + "debug": "^4.1.1", + "env-paths": "^2.2.0", + "fs-extra": "^8.1.0", + "got": "^11.8.5", + "progress": "^2.0.3", + "semver": "^6.2.0", + "sumchecker": "^3.0.1" }, "engines": { - "node": ">=12" + "node": ">=14" + }, + "optionalDependencies": { + "global-agent": "^3.0.0" } }, - "node_modules/app-builder-lib/node_modules/isexe": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-3.1.1.tgz", - "integrity": "sha512-LpB/54B+/2J5hqQ7imZHfdU31OlgQqx7ZicVlkm9kzg9/w8GKLEcFfJl/t7DCEDueOyBAD6zCCwTO6Fzs0NoEQ==", + "node_modules/app-builder-lib/node_modules/@electron/get/node_modules/fs-extra": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", + "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", "dev": true, - "license": "ISC", + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + }, "engines": { - "node": ">=16" + "node": ">=6 <7 || >=8" } }, - "node_modules/app-builder-lib/node_modules/jiti": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.6.1.tgz", - "integrity": "sha512-ekilCSN1jwRvIbgeg/57YFh8qQDNbwDb9xT/qu2DAHbFFZUicIl4ygVaAvzveMhMVr3LnpSKTNnwt8PoOfmKhQ==", + "node_modules/app-builder-lib/node_modules/@electron/get/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, - "license": "MIT", + "license": "ISC", "bin": { - "jiti": "lib/jiti-cli.mjs" + "semver": "bin/semver.js" } }, - "node_modules/app-builder-lib/node_modules/jsonfile": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz", - "integrity": "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==", + "node_modules/app-builder-lib/node_modules/ajv": { + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz", + "integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==", "dev": true, "license": "MIT", "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/app-builder-lib/node_modules/minimatch": { - "version": "10.1.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.1.1.tgz", - "integrity": "sha512-enIvLvRAFZYXJzkCYG5RKmPfrFArdLv+R+lbQ53BmIMLIry74bjKzX6iHAm8WYamJkhSSEabrWN5D97XnKObjQ==", - "dev": true, - "license": "BlueOak-1.0.0", - "dependencies": { - "@isaacs/brace-expansion": "^5.0.0" - }, - "engines": { - "node": "20 || >=22" + "fast-deep-equal": "^3.1.3", + "fast-uri": "^3.0.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2" }, "funding": { - "url": "https://github.com/sponsors/isaacs" + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" } }, - "node_modules/app-builder-lib/node_modules/minipass": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", - "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", + "node_modules/app-builder-lib/node_modules/balanced-match": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", + "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", "dev": true, - "license": "ISC", + "license": "MIT", "engines": { - "node": ">=16 || 14 >=14.17" + "node": "18 || 20 || >=22" } }, - "node_modules/app-builder-lib/node_modules/tar": { - "version": "7.5.3", - "resolved": "https://registry.npmjs.org/tar/-/tar-7.5.3.tgz", - "integrity": "sha512-ENg5JUHUm2rDD7IvKNFGzyElLXNjachNLp6RaGf4+JOgxXHkqA+gq81ZAMCUmtMtqBsoU62lcp6S27g1LCYGGQ==", - "deprecated": "Old versions of tar are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exhorbitant rates) by contacting i@izs.me", + "node_modules/app-builder-lib/node_modules/brace-expansion": { + "version": "5.0.9", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz", + "integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==", "dev": true, - "license": "BlueOak-1.0.0", + "license": "MIT", "dependencies": { - "@isaacs/fs-minipass": "^4.0.0", - "chownr": "^3.0.0", - "minipass": "^7.1.2", - "minizlib": "^3.1.0", - "yallist": "^5.0.0" + "balanced-match": "^4.0.2" }, "engines": { - "node": ">=18" + "node": "20 || >=22" } }, - "node_modules/app-builder-lib/node_modules/universalify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", - "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", + "node_modules/app-builder-lib/node_modules/ci-info": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-4.3.1.tgz", + "integrity": "sha512-Wdy2Igu8OcBpI2pZePZ5oWjPC38tmDVx5WKUXKwlLYkA0ozo85sLsLvkBbBn/sZaSCMFOGZJ14fvW9t5/d7kdA==", "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], "license": "MIT", "engines": { - "node": ">= 10.0.0" + "node": ">=8" } }, - "node_modules/app-builder-lib/node_modules/which": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/which/-/which-5.0.0.tgz", - "integrity": "sha512-JEdGzHwwkrbWoGOlIHqQ5gtprKGOenpDHpxE9zVR1bWbOtYRyPPHMe9FaP6x61CmNaTThSkb0DAJte5jD+DmzQ==", + "node_modules/app-builder-lib/node_modules/env-paths": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz", + "integrity": "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==", "dev": true, - "license": "ISC", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/app-builder-lib/node_modules/isexe": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-3.1.5.tgz", + "integrity": "sha512-6B3tLtFqtQS4ekarvLVMZ+X+VlvQekbe4taUkf/rhVO3d/h0M2rfARm/pXLcPEsjjMsFgrFgSrhQIxcSVrBz8w==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/app-builder-lib/node_modules/jiti": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.7.0.tgz", + "integrity": "sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ==", + "dev": true, + "license": "MIT", + "bin": { + "jiti": "lib/jiti-cli.mjs" + } + }, + "node_modules/app-builder-lib/node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true, + "license": "MIT" + }, + "node_modules/app-builder-lib/node_modules/jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", + "dev": true, + "license": "MIT", + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/app-builder-lib/node_modules/minimatch": { + "version": "10.2.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.5.tgz", + "integrity": "sha512-MULkVLfKGYDFYejP07QOurDLLQpcjk7Fw+7jXS2R2czRQzR56yHRveU5NDJEOviH+hETZKSkIk5c+T23GjFUMg==", + "dev": true, + "license": "BlueOak-1.0.0", "dependencies": { - "isexe": "^3.1.1" + "brace-expansion": "^5.0.5" }, - "bin": { - "node-which": "bin/which.js" + "engines": { + "node": "18 || 20 || >=22" }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/app-builder-lib/node_modules/universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true, + "license": "MIT", "engines": { - "node": "^18.17.0 || >=20.5.0" + "node": ">= 4.0.0" } }, - "node_modules/app-builder-lib/node_modules/yallist": { + "node_modules/app-builder-lib/node_modules/which": { "version": "5.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-5.0.0.tgz", - "integrity": "sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw==", + "resolved": "https://registry.npmjs.org/which/-/which-5.0.0.tgz", + "integrity": "sha512-JEdGzHwwkrbWoGOlIHqQ5gtprKGOenpDHpxE9zVR1bWbOtYRyPPHMe9FaP6x61CmNaTThSkb0DAJte5jD+DmzQ==", "dev": true, - "license": "BlueOak-1.0.0", + "license": "ISC", + "dependencies": { + "isexe": "^3.1.1" + }, + "bin": { + "node-which": "bin/which.js" + }, "engines": { - "node": ">=18" + "node": "^18.17.0 || >=20.5.0" } }, "node_modules/arg": { @@ -3681,15 +3525,19 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/assert-plus": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw==", + "node_modules/asn1js": { + "version": "3.0.10", + "resolved": "https://registry.npmjs.org/asn1js/-/asn1js-3.0.10.tgz", + "integrity": "sha512-S2s3aOytiKdFRdulw2qPE51MzjzVOisppcVv7jVFR+Kw0kxwvFrDcYA0h7Ndqbmj0HkMIXYWaoj7fli8kgx1eg==", "dev": true, - "license": "MIT", - "optional": true, + "license": "BSD-3-Clause", + "dependencies": { + "pvtsutils": "^1.3.6", + "pvutils": "^1.1.5", + "tslib": "^2.8.1" + }, "engines": { - "node": ">=0.8" + "node": ">=12.0.0" } }, "node_modules/assertion-error": { @@ -3703,9 +3551,9 @@ } }, "node_modules/ast-v8-to-istanbul": { - "version": "0.3.12", - "resolved": "https://registry.npmjs.org/ast-v8-to-istanbul/-/ast-v8-to-istanbul-0.3.12.tgz", - "integrity": "sha512-BRRC8VRZY2R4Z4lFIL35MwNXmwVqBityvOIwETtsCSwvjl0IdgFsy9NhdaA6j74nUdtJJlIypeRhpDam19Wq3g==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/ast-v8-to-istanbul/-/ast-v8-to-istanbul-1.0.4.tgz", + "integrity": "sha512-0bC0/4bTSrnwdhU3IsZDwEdojvuPrSg59OYZfKsLRtJZ0u8VBx9DebfqqG8bRdCC0I7vjgxmPi41P0lpkhJHtA==", "dev": true, "license": "MIT", "dependencies": { @@ -3721,17 +3569,6 @@ "dev": true, "license": "MIT" }, - "node_modules/astral-regex": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz", - "integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==", - "dev": true, - "license": "MIT", - "optional": true, - "engines": { - "node": ">=8" - } - }, "node_modules/async": { "version": "3.2.6", "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz", @@ -3759,6 +3596,7 @@ }, "node_modules/asynckit": { "version": "0.4.0", + "dev": true, "license": "MIT" }, "node_modules/at-least-node": { @@ -3821,42 +3659,12 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/axios": { - "version": "1.18.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.18.0.tgz", - "integrity": "sha512-E32NzpYKp++W7XRe52rHiXV2ehxmh3wbdgO7MHeFM+vqxLBYHzt0ElkiImtOBxtOmyp0yoC8C6uESVV84Y2/hw==", - "license": "MIT", - "dependencies": { - "follow-redirects": "^1.16.0", - "form-data": "^4.0.5", - "https-proxy-agent": "^5.0.1", - "proxy-from-env": "^2.1.0" - } - }, - "node_modules/axios/node_modules/agent-base": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", - "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", - "license": "MIT", - "dependencies": { - "debug": "4" - }, - "engines": { - "node": ">= 6.0.0" - } - }, - "node_modules/axios/node_modules/https-proxy-agent": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", - "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", - "license": "MIT", - "dependencies": { - "agent-base": "6", - "debug": "4" - }, - "engines": { - "node": ">= 6" - } + "node_modules/aws4": { + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.13.2.tgz", + "integrity": "sha512-lHe62zvbTB5eEABUVi/AwVh0ZKY9rMMDhmm+eeyuuUQbQ3+J+fONVQOZyj+DdrvD4BY33uYniyRJ4UJIaSKAfw==", + "dev": true, + "license": "MIT" }, "node_modules/bail": { "version": "2.0.2", @@ -3894,13 +3702,16 @@ "license": "MIT" }, "node_modules/baseline-browser-mapping": { - "version": "2.9.17", - "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.9.17.tgz", - "integrity": "sha512-agD0MgJFUP/4nvjqzIB29zRPUuCF7Ge6mEv9s8dHrtYD7QWXRcx75rOADE/d5ah1NI+0vkDl0yorDd5U852IQQ==", + "version": "2.11.21", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.21.tgz", + "integrity": "sha512-uh8vpY/1/YyFkunIDFH/12p7/7VdPKA1hejMVEbdkEaWnUz0Hesvx5EbiU6XxjyHZIOju+ZMbQJkRh+es3/spQ==", "dev": true, "license": "Apache-2.0", "bin": { - "baseline-browser-mapping": "dist/cli.js" + "baseline-browser-mapping": "dist/cli.cjs" + }, + "engines": { + "node": ">=6.0.0" } }, "node_modules/binary-extensions": { @@ -3913,31 +3724,28 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/bl": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", - "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "node_modules/bluebird": { + "version": "3.7.2", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", + "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==", "dev": true, - "license": "MIT", - "dependencies": { - "buffer": "^5.5.0", - "inherits": "^2.0.4", - "readable-stream": "^3.4.0" - } + "license": "MIT" }, "node_modules/body-parser": { - "version": "2.2.1", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.3.0.tgz", + "integrity": "sha512-2cGmJupaNgg+QUwVLAucDuWuoMZ6EX9iHDRswZ5lsNYEmwPaRknMPCLZz07yTzVq/83p4o/wzbDZbBrTvGGTIw==", "license": "MIT", "dependencies": { "bytes": "^3.1.2", - "content-type": "^1.0.5", + "content-type": "^2.0.0", "debug": "^4.4.3", - "http-errors": "^2.0.0", - "iconv-lite": "^0.7.0", + "http-errors": "^2.0.1", + "iconv-lite": "^0.7.2", "on-finished": "^2.4.1", - "qs": "^6.14.0", - "raw-body": "^3.0.1", - "type-is": "^2.0.1" + "qs": "^6.15.2", + "raw-body": "^3.0.2", + "type-is": "^2.1.0" }, "engines": { "node": ">=18" @@ -3947,14 +3755,13 @@ "url": "https://opencollective.com/express" } }, - "node_modules/body-parser/node_modules/iconv-lite": { - "version": "0.7.0", + "node_modules/body-parser/node_modules/content-type": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz", + "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==", "license": "MIT", - "dependencies": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - }, "engines": { - "node": ">=0.10.0" + "node": ">=18" }, "funding": { "type": "opencollective", @@ -3963,12 +3770,17 @@ }, "node_modules/boolean": { "version": "3.2.0", + "resolved": "https://registry.npmjs.org/boolean/-/boolean-3.2.0.tgz", + "integrity": "sha512-d0II/GO9uf9lfUHH2BQsjxzRJZBdsjgsBiW4BvhWk/3qoKwQFjIDVN19PfX8F2D/r9PCMTtLWjYVCFrpeYUzsw==", + "deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.", "dev": true, "license": "MIT", "optional": true }, "node_modules/brace-expansion": { - "version": "2.0.2", + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.4.tgz", + "integrity": "sha512-hGfVzPxthbf3+2yjg/RBs60cB0FhqBS/zvdV/4wn4/BmN0bNMMHPc4V/BbFieqf1TKAGGAHnY4eSjajCl0f2Xg==", "dev": true, "license": "MIT", "dependencies": { @@ -3986,7 +3798,9 @@ } }, "node_modules/browserslist": { - "version": "4.27.0", + "version": "4.28.8", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.8.tgz", + "integrity": "sha512-V2NpofLblG64mfOtSgDhOJESZEGogzDMBv/q+W6oc4LXWP/q75eOXoOaaOu1EOadB9U4Bwx/e0yzbvwKH8zalA==", "dev": true, "funding": [ { @@ -4004,11 +3818,11 @@ ], "license": "MIT", "dependencies": { - "baseline-browser-mapping": "^2.8.19", - "caniuse-lite": "^1.0.30001751", - "electron-to-chromium": "^1.5.238", - "node-releases": "^2.0.26", - "update-browserslist-db": "^1.1.4" + "baseline-browser-mapping": "^2.11.12", + "caniuse-lite": "^1.0.30001809", + "electron-to-chromium": "^1.5.402", + "node-releases": "^2.0.53", + "update-browserslist-db": "^1.3.0" }, "bin": { "browserslist": "cli.js" @@ -4017,39 +3831,6 @@ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, - "node_modules/buffer": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", - "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT", - "dependencies": { - "base64-js": "^1.3.1", - "ieee754": "^1.1.13" - } - }, - "node_modules/buffer-crc32": { - "version": "0.2.13", - "dev": true, - "license": "MIT", - "engines": { - "node": "*" - } - }, "node_modules/buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", @@ -4058,16 +3839,14 @@ "license": "MIT" }, "node_modules/builder-util": { - "version": "26.4.1", - "resolved": "https://registry.npmjs.org/builder-util/-/builder-util-26.4.1.tgz", - "integrity": "sha512-FlgH43XZ50w3UtS1RVGDWOz8v9qMXPC7upMtKMtBEnYdt1OVoS61NYhKm/4x+cIaWqJTXua0+VVPI+fSPGXNIw==", + "version": "26.15.3", + "resolved": "https://registry.npmjs.org/builder-util/-/builder-util-26.15.3.tgz", + "integrity": "sha512-q2hn7Mbo2nFNkVekPiHFx6Nfo3hURmES3tfBn+k5Pqxl2RkmP3QGqZUhH/q9Pch/4G05NRhPjDlVj1O8q4Txvw==", "dev": true, "license": "MIT", "dependencies": { "@types/debug": "^4.1.6", - "7zip-bin": "~5.2.0", - "app-builder-bin": "5.0.0-alpha.12", - "builder-util-runtime": "9.5.1", + "builder-util-runtime": "9.7.0", "chalk": "^4.1.2", "cross-spawn": "^7.0.6", "debug": "^4.3.4", @@ -4080,12 +3859,15 @@ "stat-mode": "^1.0.0", "temp-file": "^3.4.0", "tiny-async-pool": "1.3.0" + }, + "engines": { + "node": ">=14.0.0" } }, "node_modules/builder-util-runtime": { - "version": "9.5.1", - "resolved": "https://registry.npmjs.org/builder-util-runtime/-/builder-util-runtime-9.5.1.tgz", - "integrity": "sha512-qt41tMfgHTllhResqM5DcnHyDIWNgzHvuY2jDcYP9iaGpkWxTUzV6GQjDeLnlR1/DtdlcsWQbA7sByMpmJFTLQ==", + "version": "9.7.0", + "resolved": "https://registry.npmjs.org/builder-util-runtime/-/builder-util-runtime-9.7.0.tgz", + "integrity": "sha512-g/kR520giAFYkSXTzcmF3kqQq7wi8F6N6SzeDgZrqTBN+VHdmgWOyTdD1yD7AATDId/yXLvuP34CxW46/BwCdw==", "dev": true, "license": "MIT", "dependencies": { @@ -4096,49 +3878,21 @@ "node": ">=12.0.0" } }, - "node_modules/builder-util/node_modules/fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", - "dev": true, + "node_modules/bytes": { + "version": "3.1.2", "license": "MIT", - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, "engines": { - "node": ">=12" - } - }, - "node_modules/builder-util/node_modules/jsonfile": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz", - "integrity": "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==", - "dev": true, - "license": "MIT", - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" + "node": ">= 0.8" } }, - "node_modules/builder-util/node_modules/universalify": { + "node_modules/bytestreamjs": { "version": "2.0.1", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", - "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", + "resolved": "https://registry.npmjs.org/bytestreamjs/-/bytestreamjs-2.0.1.tgz", + "integrity": "sha512-U1Z/ob71V/bXfVABvNr/Kumf5VyeQRBEm6Txb0PQ6S7V5GpBM3w4Cbqz/xPDicR5tN0uvDifng8C+5qECeGwyQ==", "dev": true, - "license": "MIT", - "engines": { - "node": ">= 10.0.0" - } - }, - "node_modules/bytes": { - "version": "3.1.2", - "license": "MIT", + "license": "BSD-3-Clause", "engines": { - "node": ">= 0.8" + "node": ">=6.0.0" } }, "node_modules/cac": { @@ -4149,70 +3903,10 @@ "node": ">=8" } }, - "node_modules/cacache": { - "version": "19.0.1", - "resolved": "https://registry.npmjs.org/cacache/-/cacache-19.0.1.tgz", - "integrity": "sha512-hdsUxulXCi5STId78vRVYEtDAjq99ICAUktLTeTYsLoTE6Z8dS0c8pWNCxwdrk9YfJeobDZc2Y186hD/5ZQgFQ==", - "dev": true, - "license": "ISC", - "dependencies": { - "@npmcli/fs": "^4.0.0", - "fs-minipass": "^3.0.0", - "glob": "^10.2.2", - "lru-cache": "^10.0.1", - "minipass": "^7.0.3", - "minipass-collect": "^2.0.1", - "minipass-flush": "^1.0.5", - "minipass-pipeline": "^1.2.4", - "p-map": "^7.0.2", - "ssri": "^12.0.0", - "tar": "^7.4.3", - "unique-filename": "^4.0.0" - }, - "engines": { - "node": "^18.17.0 || >=20.5.0" - } - }, - "node_modules/cacache/node_modules/glob": { - "version": "10.5.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.5.0.tgz", - "integrity": "sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==", - "dev": true, - "license": "ISC", - "dependencies": { - "foreground-child": "^3.1.0", - "jackspeak": "^3.1.2", - "minimatch": "^9.0.4", - "minipass": "^7.1.2", - "package-json-from-dist": "^1.0.0", - "path-scurry": "^1.11.1" - }, - "bin": { - "glob": "dist/esm/bin.mjs" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/cacache/node_modules/lru-cache": { - "version": "10.4.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", - "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", - "dev": true, - "license": "ISC" - }, - "node_modules/cacache/node_modules/minipass": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", - "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=16 || 14 >=14.17" - } - }, "node_modules/cacheable-lookup": { "version": "5.0.4", + "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz", + "integrity": "sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA==", "dev": true, "license": "MIT", "engines": { @@ -4221,6 +3915,8 @@ }, "node_modules/cacheable-request": { "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.4.tgz", + "integrity": "sha512-v+p6ongsrp0yTGbJXjgxPow2+DL93DASP4kXCDKb8/bwRtt9OEF3whggkkDkGNzgcWy2XaF4a8nZglC7uElscg==", "dev": true, "license": "MIT", "dependencies": { @@ -4295,7 +3991,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001751", + "version": "1.0.30001810", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001810.tgz", + "integrity": "sha512-TITQPUkaz+aVk5GL6NhOdwk1aEaNTSDPsGFWrTuhKGtjTF70jL/Oht2W4c6rXUe5fu7Ie19VIahAXHIIiWWNeg==", "dev": true, "funding": [ { @@ -4423,9 +4121,9 @@ "license": "MIT" }, "node_modules/ci-info": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-4.3.1.tgz", - "integrity": "sha512-Wdy2Igu8OcBpI2pZePZ5oWjPC38tmDVx5WKUXKwlLYkA0ozo85sLsLvkBbBn/sZaSCMFOGZJ14fvW9t5/d7kdA==", + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-4.4.0.tgz", + "integrity": "sha512-77PSwercCZU2Fc4sX94eF8k8Pxte6JAwL4/ICZLFjJLqegs7kCuAsqqj/70NQF6TvDpgFjkubQB2FW2ZZddvQg==", "dev": true, "funding": [ { @@ -4443,52 +4141,10 @@ "dev": true, "license": "MIT" }, - "node_modules/cli-cursor": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", - "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", - "dev": true, - "license": "MIT", - "dependencies": { - "restore-cursor": "^3.1.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/cli-spinners": { - "version": "2.9.2", - "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.9.2.tgz", - "integrity": "sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/cli-truncate": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/cli-truncate/-/cli-truncate-2.1.0.tgz", - "integrity": "sha512-n8fOixwDD6b/ObinzTrp1ZKFzbgvKZvuz/TvejnLn1aQfC6r52XEx85FmuC+3HI+JM7coBRXUvNqEU2PHVrHpg==", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "slice-ansi": "^3.0.0", - "string-width": "^4.2.0" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/cliui": { "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", "dev": true, "license": "ISC", "dependencies": { @@ -4500,18 +4156,10 @@ "node": ">=12" } }, - "node_modules/clone": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", - "integrity": "sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.8" - } - }, "node_modules/clone-response": { "version": "1.0.3", + "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.3.tgz", + "integrity": "sha512-ROoL94jJH2dUVML2Y/5PEDNaSHgeOdSDicUyS7izcF63G6sTc/FTjLub4b8Il9S8S0beOfYt0TaA5qvFK+w0wA==", "dev": true, "license": "MIT", "dependencies": { @@ -4547,6 +4195,7 @@ }, "node_modules/combined-stream": { "version": "1.0.8", + "dev": true, "license": "MIT", "dependencies": { "delayed-stream": "~1.0.0" @@ -4591,6 +4240,8 @@ }, "node_modules/concat-map": { "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", "dev": true, "license": "MIT" }, @@ -4640,34 +4291,11 @@ } }, "node_modules/core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ==", - "dev": true, - "license": "MIT", - "optional": true - }, - "node_modules/cors": { - "version": "2.8.5", - "license": "MIT", - "dependencies": { - "object-assign": "^4", - "vary": "^1" - }, - "engines": { - "node": ">= 0.10" - } - }, - "node_modules/crc": { - "version": "3.8.0", - "resolved": "https://registry.npmjs.org/crc/-/crc-3.8.0.tgz", - "integrity": "sha512-iX3mfgcTMIq3ZKLIsVFAbv7+Mc10kxabAGQb8HvjA1o3T1PIYprbakQ65d3I+2HGHt6nSKkM9PYjgoJO2KcFBQ==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "buffer": "^5.1.0" - } + "license": "MIT" }, "node_modules/cross-dirname": { "version": "0.1.0", @@ -4923,6 +4551,8 @@ }, "node_modules/decompress-response": { "version": "6.0.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", + "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", "dev": true, "license": "MIT", "dependencies": { @@ -4937,6 +4567,8 @@ }, "node_modules/decompress-response/node_modules/mimic-response": { "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", + "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", "dev": true, "license": "MIT", "engines": { @@ -4951,21 +4583,10 @@ "dev": true, "license": "MIT" }, - "node_modules/defaults": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.4.tgz", - "integrity": "sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A==", - "dev": true, - "license": "MIT", - "dependencies": { - "clone": "^1.0.2" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/defer-to-connect": { "version": "2.0.1", + "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.1.tgz", + "integrity": "sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg==", "dev": true, "license": "MIT", "engines": { @@ -5006,6 +4627,7 @@ }, "node_modules/delayed-stream": { "version": "1.0.0", + "dev": true, "license": "MIT", "engines": { "node": ">=0.4.0" @@ -5026,18 +4648,10 @@ "node": ">=6" } }, - "node_modules/detect-libc": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", - "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": ">=8" - } - }, "node_modules/detect-node": { "version": "2.1.0", + "resolved": "https://registry.npmjs.org/detect-node/-/detect-node-2.1.0.tgz", + "integrity": "sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g==", "dev": true, "license": "MIT", "optional": true @@ -5071,9 +4685,9 @@ } }, "node_modules/dir-compare/node_modules/brace-expansion": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", - "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", + "version": "1.1.18", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.18.tgz", + "integrity": "sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw==", "dev": true, "license": "MIT", "dependencies": { @@ -5082,9 +4696,9 @@ } }, "node_modules/dir-compare/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", "dev": true, "license": "ISC", "dependencies": { @@ -5111,85 +4725,16 @@ "license": "MIT" }, "node_modules/dmg-builder": { - "version": "26.5.0", - "resolved": "https://registry.npmjs.org/dmg-builder/-/dmg-builder-26.5.0.tgz", - "integrity": "sha512-AyOCzpS1TCxDkSWxAzpfw5l7jBX4C8jKCucmT/6y6/24H5VKSHpjcVJD0W8o5BrFi+skC7Z7+F4aNyHmvn4AAw==", + "version": "26.15.3", + "resolved": "https://registry.npmjs.org/dmg-builder/-/dmg-builder-26.15.3.tgz", + "integrity": "sha512-O3zJUFUYHJKgzPqioHxfxzBzlSC1eXCSr79gMSBKBP5AgjjpmrydMsMLotEg9fAJF36vdUncb+4ndRNxoPdlSQ==", "dev": true, "license": "MIT", "dependencies": { - "app-builder-lib": "26.5.0", - "builder-util": "26.4.1", + "app-builder-lib": "26.15.3", + "builder-util": "26.15.3", "fs-extra": "^10.1.0", - "iconv-lite": "^0.6.2", "js-yaml": "^4.1.0" - }, - "optionalDependencies": { - "dmg-license": "^1.0.11" - } - }, - "node_modules/dmg-builder/node_modules/fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/dmg-builder/node_modules/jsonfile": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz", - "integrity": "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==", - "dev": true, - "license": "MIT", - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/dmg-builder/node_modules/universalify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", - "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 10.0.0" - } - }, - "node_modules/dmg-license": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/dmg-license/-/dmg-license-1.0.11.tgz", - "integrity": "sha512-ZdzmqwKmECOWJpqefloC5OJy1+WZBBse5+MR88z9g9Zn4VY+WYUkAyojmhzJckH5YbbZGcYIuGAkY5/Ys5OM2Q==", - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "dependencies": { - "@types/plist": "^3.0.1", - "@types/verror": "^1.10.3", - "ajv": "^6.10.0", - "crc": "^3.8.0", - "iconv-corefoundation": "^1.1.7", - "plist": "^3.0.4", - "smart-buffer": "^4.0.2", - "verror": "^1.10.0" - }, - "bin": { - "dmg-license": "bin/dmg-license.js" - }, - "engines": { - "node": ">=8" } }, "node_modules/doctrine": { @@ -5213,9 +4758,9 @@ } }, "node_modules/dompurify": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.2.7.tgz", - "integrity": "sha512-WhL/YuveyGXJaerVlMYGWhvQswa7myDG17P7Vu65EWC05o8vfeNbvNf4d/BOvH99+ZW+LlQsc1GDKMa1vNK6dw==", + "version": "3.4.14", + "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.4.14.tgz", + "integrity": "sha512-dVoH9z+MY+C9IilgGCk3YfFqjLi3fChm2OiKJMzh6axrJ5qwxqWaZamgmHrpv22CN/KdbZJuGEGgfQoL00LTdg==", "dev": true, "license": "(MPL-2.0 OR Apache-2.0)", "optionalDependencies": { @@ -5263,6 +4808,16 @@ "node": ">= 0.4" } }, + "node_modules/duplexer2": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", + "integrity": "sha512-asLFVfWWtJ90ZyOUHMqk7/S2w2guQKxUI2itj3d92ADHhxUSbCMGi1f1cBcJ7xM1To+pE/Khbwo1yuNbMEPKeA==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "readable-stream": "^2.0.2" + } + }, "node_modules/eastasianwidth": { "version": "0.2.0", "dev": true, @@ -5289,37 +4844,37 @@ } }, "node_modules/electron": { - "version": "40.0.0", - "resolved": "https://registry.npmjs.org/electron/-/electron-40.0.0.tgz", - "integrity": "sha512-UyBy5yJ0/wm4gNugCtNPjvddjAknMTuXR2aCHioXicH7aKRKGDBPp4xqTEi/doVcB3R+MN3wfU9o8d/9pwgK2A==", + "version": "40.10.6", + "resolved": "https://registry.npmjs.org/electron/-/electron-40.10.6.tgz", + "integrity": "sha512-TGjlkOU9Lg6K4KjDbsErywCWCIDaNgLh0q+xj0nlpRoQhevI7VBIxBTtJI/V30lypyLAaXMpnP9O9jui1/qRFw==", "dev": true, "hasInstallScript": true, "license": "MIT", "dependencies": { - "@electron/get": "^2.0.0", - "@types/node": "^24.9.0", - "extract-zip": "^2.0.1" + "@electron-internal/extract-zip": "^1.0.1", + "@electron/get": "^5.0.0", + "@types/node": "^24.9.0" }, "bin": { "electron": "cli.js" }, "engines": { - "node": ">= 12.20.55" + "node": ">= 22.12.0" } }, "node_modules/electron-builder": { - "version": "26.5.0", - "resolved": "https://registry.npmjs.org/electron-builder/-/electron-builder-26.5.0.tgz", - "integrity": "sha512-DHvMBUmDscyvI/JvcJ1ZjrPqikzANbnX83MxUX5Daaeu2I8c2SxFM8LyKEepEZr1uomV1sw7yrLtKhKAT82OdA==", + "version": "26.15.3", + "resolved": "https://registry.npmjs.org/electron-builder/-/electron-builder-26.15.3.tgz", + "integrity": "sha512-a1KM5heqS3gQCZzizXEI8RjJy3QVogULPdeSknt76uLDpBIW/HDGsMg/XgP0riP6PI9COsRvFITKKGDqA8fJxA==", "dev": true, "license": "MIT", "dependencies": { - "app-builder-lib": "26.5.0", - "builder-util": "26.4.1", - "builder-util-runtime": "9.5.1", + "app-builder-lib": "26.15.3", + "builder-util": "26.15.3", + "builder-util-runtime": "9.7.0", "chalk": "^4.1.2", "ci-info": "^4.2.0", - "dmg-builder": "26.5.0", + "dmg-builder": "26.15.3", "fs-extra": "^10.1.0", "lazy-val": "^1.0.5", "simple-update-notifier": "2.0.0", @@ -5334,107 +4889,40 @@ } }, "node_modules/electron-builder-squirrel-windows": { - "version": "26.5.0", - "resolved": "https://registry.npmjs.org/electron-builder-squirrel-windows/-/electron-builder-squirrel-windows-26.5.0.tgz", - "integrity": "sha512-pMXUzwHFIz3S6/jtzg4tB6LBqOM4buEChYCz73JGuV/cWoWhB4xTVVfFuXwrsu0uqhZw8zyhbpyWIEPTE76Dcg==", + "version": "26.15.3", + "resolved": "https://registry.npmjs.org/electron-builder-squirrel-windows/-/electron-builder-squirrel-windows-26.15.3.tgz", + "integrity": "sha512-Jc19XPV9y9+2bAdZPkXuVNGNIEFBq9poHC61l8Kv6FdK7DRG3+Ic0rerC0DXOaeHNz8yW0fg/JnF8GQROOF5MA==", "dev": true, "license": "MIT", "peer": true, "dependencies": { - "app-builder-lib": "26.5.0", - "builder-util": "26.4.1", + "app-builder-lib": "26.15.3", + "builder-util": "26.15.3", "electron-winstaller": "5.4.0" } }, - "node_modules/electron-builder/node_modules/fs-extra": { - "version": "10.1.0", - "dev": true, - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/electron-builder/node_modules/jsonfile": { - "version": "6.2.0", - "dev": true, - "license": "MIT", - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/electron-builder/node_modules/universalify": { - "version": "2.0.1", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 10.0.0" - } - }, "node_modules/electron-publish": { - "version": "26.4.1", - "resolved": "https://registry.npmjs.org/electron-publish/-/electron-publish-26.4.1.tgz", - "integrity": "sha512-nByal9K5Ar3BNJUfCSglXltpKUhJqpwivNpKVHnkwxTET9LKl+NxoojpGF1dSXVFcoBKVm+OhsVa28ZsoshEPA==", + "version": "26.15.3", + "resolved": "https://registry.npmjs.org/electron-publish/-/electron-publish-26.15.3.tgz", + "integrity": "sha512-g/2bn8YTavY4cuS5F+jOS7zmZbXXBV8KZ8yHKfJjFPoKtzBqrpCdNPxBd3tqdBwP7BVd0lGzf7Bk2s0KesWZ4Q==", "dev": true, "license": "MIT", "dependencies": { "@types/fs-extra": "^9.0.11", - "builder-util": "26.4.1", - "builder-util-runtime": "9.5.1", + "aws4": "^1.13.2", + "builder-util": "26.15.3", + "builder-util-runtime": "9.7.0", "chalk": "^4.1.2", - "form-data": "^4.0.0", + "form-data": "^4.0.5", "fs-extra": "^10.1.0", "lazy-val": "^1.0.5", "mime": "^2.5.2" } }, - "node_modules/electron-publish/node_modules/fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/electron-publish/node_modules/jsonfile": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz", - "integrity": "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==", - "dev": true, - "license": "MIT", - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/electron-publish/node_modules/universalify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", - "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 10.0.0" - } - }, "node_modules/electron-to-chromium": { - "version": "1.5.239", + "version": "1.5.422", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.422.tgz", + "integrity": "sha512-UvA/32XqrLDdZSn7Jllo1AYNcWji/G0d5M0GTViE7KoGBiMunw3a34Sb2KO4ZZyrSEhqsxFoVhWWJshdyfKqJA==", "dev": true, "license": "ISC" }, @@ -5506,6 +4994,28 @@ "node": ">=6 <7 || >=8" } }, + "node_modules/electron-winstaller/node_modules/jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", + "dev": true, + "license": "MIT", + "peer": true, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/electron-winstaller/node_modules/universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true, + "license": "MIT", + "peer": true, + "engines": { + "node": ">= 4.0.0" + } + }, "node_modules/electron/node_modules/@types/node": { "version": "24.10.9", "resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.9.tgz", @@ -5535,19 +5045,10 @@ "node": ">= 0.8" } }, - "node_modules/encoding": { - "version": "0.1.13", - "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz", - "integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "iconv-lite": "^0.6.2" - } - }, "node_modules/end-of-stream": { "version": "1.4.5", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.5.tgz", + "integrity": "sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==", "dev": true, "license": "MIT", "dependencies": { @@ -5555,11 +5056,16 @@ } }, "node_modules/env-paths": { - "version": "2.2.1", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-3.0.0.tgz", + "integrity": "sha512-dtJUTepzMW3Lm/NPxRf3wP4642UWhjL2sQxc+ym2YMj1m/H2zDNQOlezafzkHwn6sMstjHTwG6iQQsctDW/b1A==", "dev": true, "license": "MIT", "engines": { - "node": ">=6" + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/err-code": { @@ -5651,9 +5157,9 @@ } }, "node_modules/es-module-lexer": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz", - "integrity": "sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-2.3.1.tgz", + "integrity": "sha512-shc1dbU90Yl/xq1QrC7QRtfcwURZuVRfPhZbDoldJ1cn1gzDvBaBWlv0eFolj5+0znnPJz5TXLxsN77X/12KTA==", "dev": true, "license": "MIT" }, @@ -5669,6 +5175,7 @@ }, "node_modules/es-set-tostringtag": { "version": "2.1.0", + "dev": true, "license": "MIT", "dependencies": { "es-errors": "^1.3.0", @@ -5709,6 +5216,8 @@ }, "node_modules/es6-error": { "version": "4.1.1", + "resolved": "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz", + "integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==", "dev": true, "license": "MIT", "optional": true @@ -5907,7 +5416,9 @@ } }, "node_modules/eslint-plugin-import/node_modules/brace-expansion": { - "version": "1.1.12", + "version": "1.1.18", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.18.tgz", + "integrity": "sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw==", "dev": true, "license": "MIT", "dependencies": { @@ -5935,7 +5446,9 @@ } }, "node_modules/eslint-plugin-import/node_modules/minimatch": { - "version": "3.1.2", + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", "dev": true, "license": "ISC", "dependencies": { @@ -5980,7 +5493,9 @@ } }, "node_modules/eslint/node_modules/brace-expansion": { - "version": "1.1.12", + "version": "1.1.18", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.18.tgz", + "integrity": "sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw==", "dev": true, "license": "MIT", "dependencies": { @@ -6000,7 +5515,9 @@ } }, "node_modules/eslint/node_modules/minimatch": { - "version": "3.1.2", + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", "dev": true, "license": "ISC", "dependencies": { @@ -6178,36 +5695,6 @@ "dev": true, "license": "MIT" }, - "node_modules/extract-zip": { - "version": "2.0.1", - "dev": true, - "license": "BSD-2-Clause", - "dependencies": { - "debug": "^4.1.1", - "get-stream": "^5.1.0", - "yauzl": "^2.10.0" - }, - "bin": { - "extract-zip": "cli.js" - }, - "engines": { - "node": ">= 10.17.0" - }, - "optionalDependencies": { - "@types/yauzl": "^2.9.1" - } - }, - "node_modules/extsprintf": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.4.1.tgz", - "integrity": "sha512-Wrk35e8ydCKDj/ArClo1VrPVmN8zph5V4AtHwIuHhvMXsKf73UT3BOD+azBIW+3wOJ4FhEH7zyaJCFvChjYvMA==", - "dev": true, - "engines": [ - "node >=0.6.0" - ], - "license": "MIT", - "optional": true - }, "node_modules/fast-deep-equal": { "version": "3.1.3", "dev": true, @@ -6246,6 +5733,23 @@ "dev": true, "license": "MIT" }, + "node_modules/fast-uri": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.7.tgz", + "integrity": "sha512-dOvZVzjdZdz7phd9v6jCbwxrBW3fK6n8Rc0CtdmM4bumzMnxywBYhuph6J819RRw/ku+rLbelwfMunktuzVVHg==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "BSD-3-Clause" + }, "node_modules/fastq": { "version": "1.19.1", "dev": true, @@ -6266,14 +5770,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/fd-slicer": { - "version": "1.1.0", - "dev": true, - "license": "MIT", - "dependencies": { - "pend": "~1.2.0" - } - }, "node_modules/file-entry-cache": { "version": "6.0.1", "dev": true, @@ -6286,9 +5782,9 @@ } }, "node_modules/filelist": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz", - "integrity": "sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.6.tgz", + "integrity": "sha512-5giy2PkLYY1cP39p17Ech+2xlpTRL9HLspOfEgm0L6CwBXBTgsK5ou0JtzYuepxkaQ/tvhCFIJ5uXo0OrM2DxA==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -6296,9 +5792,9 @@ } }, "node_modules/filelist/node_modules/minimatch": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", - "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "version": "5.1.9", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.9.tgz", + "integrity": "sha512-7o1wEA2RyMP7Iu7GNba9vc0RWWGACJOCZBJX2GJWip0ikV+wcOsgVuY9uE8CPiyQhkGFSlhuSkZPavN7u1c2Fw==", "dev": true, "license": "ISC", "dependencies": { @@ -6367,35 +5863,17 @@ "keyv": "^4.5.3", "rimraf": "^3.0.2" }, - "engines": { - "node": "^10.12.0 || >=12.0.0" - } - }, - "node_modules/flatted": { - "version": "3.3.3", - "dev": true, - "license": "ISC" - }, - "node_modules/follow-redirects": { - "version": "1.16.0", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.0.tgz", - "integrity": "sha512-y5rN/uOsadFT/JfYwhxRS5R7Qce+g3zG97+JrtFZlC9klX/W5hD7iiLzScI4nZqUS7DNUdhPgw4xI8W2LuXlUw==", - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/RubenVerborgh" - } - ], - "license": "MIT", - "engines": { - "node": ">=4.0" - }, - "peerDependenciesMeta": { - "debug": { - "optional": true - } + "engines": { + "node": "^10.12.0 || >=12.0.0" } }, + "node_modules/flatted": { + "version": "3.4.2", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.4.2.tgz", + "integrity": "sha512-PjDse7RzhcPkIJwy5t7KPWQSZ9cAbzQXcafsetQoD7sOJRQlGikNbx7yZp2OotDnJyrDcbyRq3Ttb18iYOqkxA==", + "dev": true, + "license": "ISC" + }, "node_modules/for-each": { "version": "0.3.5", "dev": true, @@ -6429,6 +5907,7 @@ "version": "4.0.6", "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.6.tgz", "integrity": "sha512-vKatAh4SlVfgbv+YtmhiRjhEMJsYpsG1Y2rMQtR+SVSbytsSD1YGzDIcrAJmdFec88u/+VoGmxnl+80gL1tRCQ==", + "dev": true, "license": "MIT", "dependencies": { "asynckit": "^0.4.0", @@ -6475,39 +5954,18 @@ } }, "node_modules/fs-extra": { - "version": "8.1.0", + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", "dev": true, "license": "MIT", "dependencies": { "graceful-fs": "^4.2.0", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - }, - "engines": { - "node": ">=6 <7 || >=8" - } - }, - "node_modules/fs-minipass": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-3.0.3.tgz", - "integrity": "sha512-XUBA9XClHbnJWSfBzjkm6RvPsyg3sryZt06BEQoXcF7EK/xpGaQYJgQKDJSUH5SGZ76Y7pFx1QBnXz09rU5Fbw==", - "dev": true, - "license": "ISC", - "dependencies": { - "minipass": "^7.0.3" + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" }, "engines": { - "node": "^14.17.0 || ^16.13.0 || >=18.0.0" - } - }, - "node_modules/fs-minipass/node_modules/minipass": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", - "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=16 || 14 >=14.17" + "node": ">=12" } }, "node_modules/fs.realpath": { @@ -6581,6 +6039,8 @@ }, "node_modules/get-caller-file": { "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", "dev": true, "license": "ISC", "engines": { @@ -6622,6 +6082,8 @@ }, "node_modules/get-stream": { "version": "5.2.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz", + "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==", "dev": true, "license": "MIT", "dependencies": { @@ -6680,7 +6142,9 @@ } }, "node_modules/glob/node_modules/brace-expansion": { - "version": "1.1.12", + "version": "1.1.18", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.18.tgz", + "integrity": "sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw==", "dev": true, "license": "MIT", "dependencies": { @@ -6689,7 +6153,9 @@ } }, "node_modules/glob/node_modules/minimatch": { - "version": "3.1.2", + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", "dev": true, "license": "ISC", "dependencies": { @@ -6701,6 +6167,8 @@ }, "node_modules/global-agent": { "version": "3.0.0", + "resolved": "https://registry.npmjs.org/global-agent/-/global-agent-3.0.0.tgz", + "integrity": "sha512-PT6XReJ+D07JvGoxQMkT6qji/jVNfX/h364XHZOWeRzy64sSFr+xJ5OX7LI3b4MPQzdL4H8Y8M0xzPpsVMwA8Q==", "dev": true, "license": "BSD-3-Clause", "optional": true, @@ -6776,6 +6244,8 @@ }, "node_modules/got": { "version": "11.8.6", + "resolved": "https://registry.npmjs.org/got/-/got-11.8.6.tgz", + "integrity": "sha512-6tfZ91bOr7bOXnK7PRDCGBLa1H4U080YHNaAQ2KsMGlLEzRbk44nsZF2E1IeRc3vtJHPVbKCYgdFbaGO2ljd8g==", "dev": true, "license": "MIT", "dependencies": { @@ -6864,6 +6334,7 @@ }, "node_modules/has-tostringtag": { "version": "1.0.2", + "dev": true, "license": "MIT", "dependencies": { "has-symbols": "^1.0.3" @@ -7021,6 +6492,8 @@ }, "node_modules/http-cache-semantics": { "version": "4.2.0", + "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.2.0.tgz", + "integrity": "sha512-dTxcvPXqPvXBQpq5dUr6mEMJX4oIEFv6bwom3FDwKRDsuIjjJGANqhBuoAn9c1RQJIdAKav33ED65E2ys+87QQ==", "dev": true, "license": "BSD-2-Clause" }, @@ -7058,6 +6531,8 @@ }, "node_modules/http2-wrapper": { "version": "1.0.3", + "resolved": "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-1.0.3.tgz", + "integrity": "sha512-V+23sDMr12Wnz7iTcDeJr3O6AIxlnvT/bmaAAAP/Xda35C90p9599p0F1eHR/N1KILWSoWVAiOMFjBBXaXSMxg==", "dev": true, "license": "MIT", "dependencies": { @@ -7072,7 +6547,6 @@ "version": "7.0.6", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", - "dev": true, "license": "MIT", "dependencies": { "agent-base": "^7.1.2", @@ -7082,58 +6556,22 @@ "node": ">= 14" } }, - "node_modules/iconv-corefoundation": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/iconv-corefoundation/-/iconv-corefoundation-1.1.7.tgz", - "integrity": "sha512-T10qvkw0zz4wnm560lOEg0PovVqUXuOFhhHAkixw8/sycy7TJt7v/RrkEKEQnAw2viPSJu6iAkErxnzR0g8PpQ==", - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "dependencies": { - "cli-truncate": "^2.1.0", - "node-addon-api": "^1.6.3" - }, - "engines": { - "node": "^8.11.2 || >=10" - } - }, "node_modules/iconv-lite": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", - "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", - "dev": true, + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.3.tgz", + "integrity": "sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==", "license": "MIT", "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" }, "engines": { "node": ">=0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, - "node_modules/ieee754": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", - "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "BSD-3-Clause" - }, "node_modules/ignore": { "version": "5.3.2", "dev": true, @@ -7204,16 +6642,6 @@ "node": ">=12" } }, - "node_modules/ip-address": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.1.0.tgz", - "integrity": "sha512-XXADHxXmvT9+CRxhXg56LJovE+bmWnEWB78LB83VZTprKTmaC5QfruXocxzTZ2Kl0DNwKuBdlIhjL8LeY8Sf8Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 12" - } - }, "node_modules/ipaddr.js": { "version": "1.9.1", "license": "MIT", @@ -7463,16 +6891,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/is-interactive": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-1.0.0.tgz", - "integrity": "sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, "node_modules/is-map": { "version": "2.0.3", "dev": true, @@ -7627,19 +7045,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-unicode-supported": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", - "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/is-weakmap": { "version": "2.0.2", "dev": true, @@ -7803,9 +7208,19 @@ "license": "MIT" }, "node_modules/js-yaml": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz", - "integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==", + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.2.tgz", + "integrity": "sha512-SFNOvSJ+Dgf/9An904Yx+CgSlIPCkIpao4qo51lpee25TIRejdH3rhR4EZMGoNx3/TP3O+wzWuiTFl4sqbltzA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/nodeca" + } + ], "license": "MIT", "dependencies": { "argparse": "^2.0.1" @@ -7816,6 +7231,8 @@ }, "node_modules/jsesc": { "version": "3.1.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", + "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==", "dev": true, "license": "MIT", "bin": { @@ -7862,6 +7279,8 @@ }, "node_modules/json-stringify-safe": { "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==", "dev": true, "license": "ISC", "optional": true @@ -7886,9 +7305,14 @@ } }, "node_modules/jsonfile": { - "version": "4.0.0", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.1.tgz", + "integrity": "sha512-zwOTdL3rFQ/lRdBnntKVOX6k5cKJwEc1HdilT71BWEu7J41gXIB2MRp+vxduPSwZJPWBxEzv4yH1wYLJGUHX4Q==", "dev": true, "license": "MIT", + "dependencies": { + "universalify": "^2.0.0" + }, "optionalDependencies": { "graceful-fs": "^4.1.6" } @@ -7971,9 +7395,9 @@ } }, "node_modules/lodash": { - "version": "4.17.23", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.23.tgz", - "integrity": "sha512-LgVTMpQtIopCi79SJeDiP0TfWi5CNEc/L/aRdTh3yIvmZXTnheWpKjSZhnvMl8iXbC1tFg9gdHHDMLoV7CnG+w==", + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.18.1.tgz", + "integrity": "sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==", "dev": true, "license": "MIT" }, @@ -7982,23 +7406,6 @@ "dev": true, "license": "MIT" }, - "node_modules/log-symbols": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", - "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", - "dev": true, - "license": "MIT", - "dependencies": { - "chalk": "^4.1.0", - "is-unicode-supported": "^0.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/longest-streak": { "version": "3.1.0", "dev": true, @@ -8021,6 +7428,8 @@ }, "node_modules/lowercase-keys": { "version": "2.0.0", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz", + "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==", "dev": true, "license": "MIT", "engines": { @@ -8042,6 +7451,8 @@ }, "node_modules/lru-cache": { "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", "dev": true, "license": "ISC", "dependencies": { @@ -8086,39 +7497,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/make-fetch-happen": { - "version": "14.0.3", - "resolved": "https://registry.npmjs.org/make-fetch-happen/-/make-fetch-happen-14.0.3.tgz", - "integrity": "sha512-QMjGbFTP0blj97EeidG5hk/QhKQ3T4ICckQGLgz38QF7Vgbk6e6FTARN8KhKxyBbWn8R0HU+bnw8aSoFPD4qtQ==", - "dev": true, - "license": "ISC", - "dependencies": { - "@npmcli/agent": "^3.0.0", - "cacache": "^19.0.1", - "http-cache-semantics": "^4.1.1", - "minipass": "^7.0.2", - "minipass-fetch": "^4.0.0", - "minipass-flush": "^1.0.5", - "minipass-pipeline": "^1.2.4", - "negotiator": "^1.0.0", - "proc-log": "^5.0.0", - "promise-retry": "^2.0.1", - "ssri": "^12.0.0" - }, - "engines": { - "node": "^18.17.0 || >=20.5.0" - } - }, - "node_modules/make-fetch-happen/node_modules/minipass": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", - "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=16 || 14 >=14.17" - } - }, "node_modules/markdown-table": { "version": "3.0.4", "dev": true, @@ -8141,6 +7519,8 @@ }, "node_modules/matcher": { "version": "3.0.0", + "resolved": "https://registry.npmjs.org/matcher/-/matcher-3.0.0.tgz", + "integrity": "sha512-OkeDaAZ/bQCxeFAozM55PKcKU0yJMPGifLwV4Qgjitu+5MoAfSQN4lsLJeXZ1b8w0x+/Emda6MZgXS1jvsapng==", "dev": true, "license": "MIT", "optional": true, @@ -9013,223 +8393,71 @@ "mime": "cli.js" }, "engines": { - "node": ">=4.0.0" - } - }, - "node_modules/mime-db": { - "version": "1.52.0", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mime-types": { - "version": "2.1.35", - "license": "MIT", - "dependencies": { - "mime-db": "1.52.0" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mimic-fn": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", - "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/mimic-response": { - "version": "1.0.1", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=4" - } - }, - "node_modules/minimatch": { - "version": "9.0.5", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/minimist": { - "version": "1.2.8", - "dev": true, - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/minipass": { - "version": "5.0.0", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=8" - } - }, - "node_modules/minipass-collect": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/minipass-collect/-/minipass-collect-2.0.1.tgz", - "integrity": "sha512-D7V8PO9oaz7PWGLbCACuI1qEOsq7UKfLotx/C0Aet43fCUB/wfQ7DYeq2oR/svFJGYDHPr38SHATeaj/ZoKHKw==", - "dev": true, - "license": "ISC", - "dependencies": { - "minipass": "^7.0.3" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - } - }, - "node_modules/minipass-collect/node_modules/minipass": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", - "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=16 || 14 >=14.17" - } - }, - "node_modules/minipass-fetch": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/minipass-fetch/-/minipass-fetch-4.0.1.tgz", - "integrity": "sha512-j7U11C5HXigVuutxebFadoYBbd7VSdZWggSe64NVdvWNBqGAiXPL2QVCehjmw7lY1oF9gOllYbORh+hiNgfPgQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "minipass": "^7.0.3", - "minipass-sized": "^1.0.3", - "minizlib": "^3.0.1" - }, - "engines": { - "node": "^18.17.0 || >=20.5.0" - }, - "optionalDependencies": { - "encoding": "^0.1.13" - } - }, - "node_modules/minipass-fetch/node_modules/minipass": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", - "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=16 || 14 >=14.17" - } - }, - "node_modules/minipass-flush": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/minipass-flush/-/minipass-flush-1.0.5.tgz", - "integrity": "sha512-JmQSYYpPUqX5Jyn1mXaRwOda1uQ8HP5KAT/oDSLCzt1BYRhQU0/hDtsB1ufZfEEzMZ9aAVmsBw8+FWsIXlClWw==", - "dev": true, - "license": "ISC", - "dependencies": { - "minipass": "^3.0.0" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/minipass-flush/node_modules/minipass": { - "version": "3.3.6", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", - "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", - "dev": true, - "license": "ISC", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/minipass-flush/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true, - "license": "ISC" + "node": ">=4.0.0" + } }, - "node_modules/minipass-pipeline": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/minipass-pipeline/-/minipass-pipeline-1.2.4.tgz", - "integrity": "sha512-xuIq7cIOt09RPRJ19gdi4b+RiNvDFYe5JH+ggNvBqGqpQXcru3PcRmOZuHBKWK1Txf9+cQ+HMVN4d6z46LZP7A==", + "node_modules/mime-db": { + "version": "1.52.0", "dev": true, - "license": "ISC", - "dependencies": { - "minipass": "^3.0.0" - }, + "license": "MIT", "engines": { - "node": ">=8" + "node": ">= 0.6" } }, - "node_modules/minipass-pipeline/node_modules/minipass": { - "version": "3.3.6", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", - "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "node_modules/mime-types": { + "version": "2.1.35", "dev": true, - "license": "ISC", + "license": "MIT", "dependencies": { - "yallist": "^4.0.0" + "mime-db": "1.52.0" }, "engines": { - "node": ">=8" + "node": ">= 0.6" } }, - "node_modules/minipass-pipeline/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "node_modules/mimic-response": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", + "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==", "dev": true, - "license": "ISC" + "license": "MIT", + "engines": { + "node": ">=4" + } }, - "node_modules/minipass-sized": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/minipass-sized/-/minipass-sized-1.0.3.tgz", - "integrity": "sha512-MbkQQ2CTiBMlA2Dm/5cY+9SWFEN8pzzOXi6rlM5Xxq0Yqbda5ZQy9sU75a673FE9ZK0Zsbr6Y5iP6u9nktfg2g==", + "node_modules/minimatch": { + "version": "9.0.9", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.9.tgz", + "integrity": "sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==", "dev": true, "license": "ISC", "dependencies": { - "minipass": "^3.0.0" + "brace-expansion": "^2.0.2" }, "engines": { - "node": ">=8" + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/minipass-sized/node_modules/minipass": { - "version": "3.3.6", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", - "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "node_modules/minimist": { + "version": "1.2.8", "dev": true, - "license": "ISC", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=8" + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/minipass-sized/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "node_modules/minipass": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz", + "integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==", "dev": true, - "license": "ISC" + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=16 || 14 >=14.17" + } }, "node_modules/minizlib": { "version": "3.1.0", @@ -9244,16 +8472,6 @@ "node": ">= 18" } }, - "node_modules/minizlib/node_modules/minipass": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", - "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=16 || 14 >=14.17" - } - }, "node_modules/mkdirp": { "version": "0.5.6", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", @@ -9294,7 +8512,9 @@ } }, "node_modules/nanoid": { - "version": "3.3.11", + "version": "3.3.18", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.18.tgz", + "integrity": "sha512-DTg4MJbGMWkfi6VZFdNt2/caMbQy4Ou+Op/hJQvGEWcnVfoA1QA+xzRKAzw9jD6+GVOOeYr/mIcuDSdug6F6+w==", "dev": true, "funding": [ { @@ -9323,9 +8543,9 @@ } }, "node_modules/node-abi": { - "version": "4.26.0", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-4.26.0.tgz", - "integrity": "sha512-8QwIZqikRvDIkXS2S93LjzhsSPJuIbfaMETWH+Bx8oOT9Sa9UsUtBFQlc3gBNd1+QINjaTloitXr1W3dQLi9Iw==", + "version": "4.33.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-4.33.0.tgz", + "integrity": "sha512-vLBWCKb+7LWsX+TbfzWOkw0W81m377tyx3hOweBTjO43CXZnRGS1/JPWs20fr0PgZyDXk6ROYrylsEycK8raDA==", "dev": true, "license": "MIT", "dependencies": { @@ -9335,14 +8555,6 @@ "node": ">=22.12.0" } }, - "node_modules/node-addon-api": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-1.7.2.tgz", - "integrity": "sha512-ibPK3iA+vaY1eEjESkQkM0BbCqFOaZMiXRTtdB0u7b4djtY6JnsjvPdUHVMg6xQt3B8fpTTWHI9A+ADjM9frzg==", - "dev": true, - "license": "MIT", - "optional": true - }, "node_modules/node-api-version": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/node-api-version/-/node-api-version-0.2.1.tgz", @@ -9354,92 +8566,116 @@ } }, "node_modules/node-cron": { - "version": "3.0.3", + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/node-cron/-/node-cron-4.6.0.tgz", + "integrity": "sha512-Si/bzYiKRHOB8/a99T2+SDGN582ONDMSTlJr5oCkT6GtnqPjZ2s10eoQRYkW9ZHwjVxONL+W8Fb+qR0AHMQsdg==", "license": "ISC", - "dependencies": { - "uuid": "8.3.2" - }, "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/node-cron/node_modules/uuid": { - "version": "8.3.2", - "license": "MIT", - "bin": { - "uuid": "dist/bin/uuid" + "node": ">=20" } }, "node_modules/node-gyp": { - "version": "11.5.0", - "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-11.5.0.tgz", - "integrity": "sha512-ra7Kvlhxn5V9Slyus0ygMa2h+UqExPqUIkfk7Pc8QTLT956JLSy51uWFwHtIYy0vI8cB4BDhc/S03+880My/LQ==", + "version": "12.4.0", + "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-12.4.0.tgz", + "integrity": "sha512-OMcPNvqTCFUnNaBlmdgq+lfNqY7gTiSmNRDjY3uAXRyudeKZEZxu3CLtjMQrx4zZxCX2b/mpNqTtwuCJgXhHkw==", "dev": true, "license": "MIT", "dependencies": { "env-paths": "^2.2.0", "exponential-backoff": "^3.1.1", "graceful-fs": "^4.2.6", - "make-fetch-happen": "^14.0.3", - "nopt": "^8.0.0", - "proc-log": "^5.0.0", + "nopt": "^9.0.0", + "proc-log": "^6.0.0", "semver": "^7.3.5", - "tar": "^7.4.3", + "tar": "^7.5.4", "tinyglobby": "^0.2.12", - "which": "^5.0.0" + "undici": "^6.25.0", + "which": "^6.0.0" }, "bin": { "node-gyp": "bin/node-gyp.js" }, "engines": { - "node": "^18.17.0 || >=20.5.0" + "node": "^20.17.0 || >=22.9.0" + } + }, + "node_modules/node-gyp/node_modules/env-paths": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz", + "integrity": "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" } }, "node_modules/node-gyp/node_modules/isexe": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-3.1.1.tgz", - "integrity": "sha512-LpB/54B+/2J5hqQ7imZHfdU31OlgQqx7ZicVlkm9kzg9/w8GKLEcFfJl/t7DCEDueOyBAD6zCCwTO6Fzs0NoEQ==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-4.0.0.tgz", + "integrity": "sha512-FFUtZMpoZ8RqHS3XeXEmHWLA4thH+ZxCv2lOiPIn1Xc7CxrqhWzNSDzD+/chS/zbYezmiwWLdQC09JdQKmthOw==", "dev": true, - "license": "ISC", + "license": "BlueOak-1.0.0", "engines": { - "node": ">=16" + "node": ">=20" + } + }, + "node_modules/node-gyp/node_modules/undici": { + "version": "6.28.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-6.28.0.tgz", + "integrity": "sha512-LIY910g9TI13YS95lrMFrs8Rm/u/irgHeTWoKCoteeJ04CUJ92eEfj0rVn+7VKMPBpUPiUoBKfhNyLI23EE/KA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18.17" } }, "node_modules/node-gyp/node_modules/which": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/which/-/which-5.0.0.tgz", - "integrity": "sha512-JEdGzHwwkrbWoGOlIHqQ5gtprKGOenpDHpxE9zVR1bWbOtYRyPPHMe9FaP6x61CmNaTThSkb0DAJte5jD+DmzQ==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/which/-/which-6.0.1.tgz", + "integrity": "sha512-oGLe46MIrCRqX7ytPUf66EAYvdeMIZYn3WaocqqKZAxrBpkqHfL/qvTyJ/bTk5+AqHCjXmrv3CEWgy368zhRUg==", "dev": true, "license": "ISC", "dependencies": { - "isexe": "^3.1.1" + "isexe": "^4.0.0" }, "bin": { "node-which": "bin/which.js" }, "engines": { - "node": "^18.17.0 || >=20.5.0" + "node": "^20.17.0 || >=22.9.0" } }, - "node_modules/node-releases": { - "version": "2.0.26", + "node_modules/node-int64": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", + "integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==", "dev": true, "license": "MIT" }, + "node_modules/node-releases": { + "version": "2.0.54", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.54.tgz", + "integrity": "sha512-YHs7BmmcsdAI5Ozuf8JZo6PT0mv2GIWC9vMfvUC3dp65M8hn7Ux8CPL+2oBI7juNuj9d0ndhTcznq2ODBps9cQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, "node_modules/nopt": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-8.1.0.tgz", - "integrity": "sha512-ieGu42u/Qsa4TFktmaKEwM6MQH0pOWnaB3htzh0JRtx84+Mebc0cbZYN5bC+6WTZ4+77xrL9Pn5m7CV6VIkV7A==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-9.0.0.tgz", + "integrity": "sha512-Zhq3a+yFKrYwSBluL4H9XP3m3y5uvQkB/09CwDruCiRmR/UJYnn9W4R48ry0uGC70aeTPKLynBtscP9efFFcPw==", "dev": true, "license": "ISC", "dependencies": { - "abbrev": "^3.0.0" + "abbrev": "^4.0.0" }, "bin": { "nopt": "bin/nopt.js" }, "engines": { - "node": "^18.17.0 || >=20.5.0" + "node": "^20.17.0 || >=22.9.0" } }, "node_modules/normalize-path": { @@ -9459,6 +8695,8 @@ }, "node_modules/normalize-url": { "version": "6.1.0", + "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-6.1.0.tgz", + "integrity": "sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A==", "dev": true, "license": "MIT", "engines": { @@ -9470,6 +8708,7 @@ }, "node_modules/object-assign": { "version": "4.1.1", + "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -9595,22 +8834,6 @@ "wrappy": "1" } }, - "node_modules/onetime": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", - "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", - "dev": true, - "license": "MIT", - "dependencies": { - "mimic-fn": "^2.1.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/open": { "version": "7.4.2", "resolved": "https://registry.npmjs.org/open/-/open-7.4.2.tgz", @@ -9644,30 +8867,6 @@ "node": ">= 0.8.0" } }, - "node_modules/ora": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/ora/-/ora-5.4.1.tgz", - "integrity": "sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "bl": "^4.1.0", - "chalk": "^4.1.0", - "cli-cursor": "^3.1.0", - "cli-spinners": "^2.5.0", - "is-interactive": "^1.0.0", - "is-unicode-supported": "^0.1.0", - "log-symbols": "^4.1.0", - "strip-ansi": "^6.0.0", - "wcwidth": "^1.0.1" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/own-keys": { "version": "1.0.1", "dev": true, @@ -9686,6 +8885,8 @@ }, "node_modules/p-cancelable": { "version": "2.1.1", + "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-2.1.1.tgz", + "integrity": "sha512-BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg==", "dev": true, "license": "MIT", "engines": { @@ -9720,19 +8921,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/p-map": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/p-map/-/p-map-7.0.4.tgz", - "integrity": "sha512-tkAQEw8ysMzmkhgw8k+1U/iPhWNhykKnSk4Rd5zLoPJCuJaGRPo6YposrZgaxHKzDHdDWWZvE/Sk7hsL2X/CpQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/package-json-from-dist": { "version": "1.0.1", "dev": true, @@ -9825,34 +9013,6 @@ "node": ">=8" } }, - "node_modules/patch-package/node_modules/fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/patch-package/node_modules/jsonfile": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz", - "integrity": "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==", - "dev": true, - "license": "MIT", - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, "node_modules/patch-package/node_modules/slash": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", @@ -9863,16 +9023,6 @@ "node": ">=6" } }, - "node_modules/patch-package/node_modules/universalify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", - "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 10.0.0" - } - }, "node_modules/path-exists": { "version": "4.0.0", "dev": true, @@ -9923,7 +9073,9 @@ "license": "ISC" }, "node_modules/path-to-regexp": { - "version": "8.3.0", + "version": "8.4.2", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.4.2.tgz", + "integrity": "sha512-qRcuIdP69NPm4qbACK+aDogI5CBDMi1jKe0ry5rSQJz8JVLsC7jV8XpiJjGRLLol3N+R5ihGYcrPLTno6pAdBA==", "license": "MIT", "funding": { "type": "opencollective", @@ -9960,18 +9112,15 @@ "url": "https://github.com/sponsors/jet2jet" } }, - "node_modules/pend": { - "version": "1.2.0", - "dev": true, - "license": "MIT" - }, "node_modules/picocolors": { "version": "1.1.1", "dev": true, "license": "ISC" }, "node_modules/picomatch": { - "version": "2.3.1", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz", + "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==", "license": "MIT", "engines": { "node": ">=8.6" @@ -9996,6 +9145,37 @@ "node": ">= 6" } }, + "node_modules/pkijs": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/pkijs/-/pkijs-3.4.0.tgz", + "integrity": "sha512-emEcLuomt2j03vxD54giVB4SxTjnsqkU692xZOZXHDVoYyypEm+b3jpiTcc+Cf+myooc+/Ly0z01jqeNHVgJGw==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@noble/hashes": "1.4.0", + "asn1js": "^3.0.6", + "bytestreamjs": "^2.0.1", + "pvtsutils": "^1.3.6", + "pvutils": "^1.1.3", + "tslib": "^2.8.1" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/pkijs/node_modules/@noble/hashes": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz", + "integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/plist": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/plist/-/plist-3.1.0.tgz", @@ -10020,7 +9200,9 @@ } }, "node_modules/postcss": { - "version": "8.5.6", + "version": "8.5.28", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.28.tgz", + "integrity": "sha512-RRuzqDtt5Y9h3quz5hWhK+TPnsmVs6WwSU6LkJMeY4HstUEDuYTG8UJSdawMRzmzAtV+KEoG8N3Qg2qLy5vM/A==", "dev": true, "funding": [ { @@ -10038,7 +9220,7 @@ ], "license": "MIT", "dependencies": { - "nanoid": "^3.3.11", + "nanoid": "^3.3.18", "picocolors": "^1.1.1", "source-map-js": "^1.2.1" }, @@ -10152,7 +9334,9 @@ } }, "node_modules/postcss-selector-parser": { - "version": "6.1.2", + "version": "6.1.4", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.1.4.tgz", + "integrity": "sha512-bIoJLOmjCO1S9XdY/DcnR5hJxvrDir1PbGChrzXG3vw0/FOliy/fA3dmdhQ441kah4gKv+TwckGzex6wNS5cnQ==", "dev": true, "license": "MIT", "dependencies": { @@ -10215,17 +9399,26 @@ } }, "node_modules/proc-log": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/proc-log/-/proc-log-5.0.0.tgz", - "integrity": "sha512-Azwzvl90HaF0aCz1JrDdXQykFakSSNPaPoiZ9fm5qJIMHioDZEi7OAdRwSm6rSoPtY3Qutnm3L7ogmg3dc+wbQ==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/proc-log/-/proc-log-6.1.0.tgz", + "integrity": "sha512-iG+GYldRf2BQ0UDUAd6JQ/RwzaQy6mXmsk/IzlYyal4A4SNFw54MeH4/tLkF4I5WoWG9SQwuqWzS99jaFQHBuQ==", "dev": true, "license": "ISC", "engines": { - "node": "^18.17.0 || >=20.5.0" + "node": "^20.17.0 || >=22.9.0" } }, + "node_modules/process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "dev": true, + "license": "MIT" + }, "node_modules/progress": { "version": "2.0.3", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", "dev": true, "license": "MIT", "engines": { @@ -10261,6 +9454,25 @@ "dev": true, "license": "MIT" }, + "node_modules/proper-lockfile": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/proper-lockfile/-/proper-lockfile-4.1.2.tgz", + "integrity": "sha512-TjNPblN4BwAWMXU8s9AEz4JmQxnD1NNL7bNOY/AKUzyamc379FWASUhc/K1pL2noVb+XmZKLL68cjzLsiOAMaA==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.4", + "retry": "^0.12.0", + "signal-exit": "^3.0.2" + } + }, + "node_modules/proper-lockfile/node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true, + "license": "ISC" + }, "node_modules/property-information": { "version": "7.1.0", "dev": true, @@ -10281,17 +9493,10 @@ "node": ">= 0.10" } }, - "node_modules/proxy-from-env": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-2.1.0.tgz", - "integrity": "sha512-cJ+oHTW1VAEa8cJslgmUZrc+sjRKgAKl3Zyse6+PV38hZe/V6Z14TbCuXcan9F9ghlz4QrFr2c92TNF82UkYHA==", - "license": "MIT", - "engines": { - "node": ">=10" - } - }, "node_modules/pump": { - "version": "3.0.3", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.4.tgz", + "integrity": "sha512-VS7sjc6KR7e1ukRFhQSY5LM2uBWAUPiOPa/A3mkKmiMwSmRFUITt0xuj+/lesgnCv+dPIEYlkzrcyXgquIHMcA==", "dev": true, "license": "MIT", "dependencies": { @@ -10307,13 +9512,34 @@ "node": ">=6" } }, + "node_modules/pvtsutils": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/pvtsutils/-/pvtsutils-1.3.6.tgz", + "integrity": "sha512-PLgQXQ6H2FWCaeRak8vvk1GW462lMxB5s3Jm673N82zI4vqtVUPuZdffdZbPDFRoU8kAhItWFtPCWiPpp4/EDg==", + "dev": true, + "license": "MIT", + "dependencies": { + "tslib": "^2.8.1" + } + }, + "node_modules/pvutils": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/pvutils/-/pvutils-1.1.5.tgz", + "integrity": "sha512-KTqnxsgGiQ6ZAzZCVlJH5eOjSnvlyEgx1m8bkRJfOhmGRqfo5KLvmAlACQkrjEtOQ4B7wF9TdSLIs9O90MX9xA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=16.0.0" + } + }, "node_modules/qs": { - "version": "6.14.1", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.1.tgz", - "integrity": "sha512-4EK3+xJl8Ts67nLYNwqw/dsFVnCf+qR7RgXSK9jEEm9unao3njwMDdmsdvoKBKHzxd7tCYz5e5M+SnMjdtXGQQ==", + "version": "6.16.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.16.0.tgz", + "integrity": "sha512-h6fhOIaRrID2CbEY2fqs+7t+UXZo+MLAnU5gRIq85uFtdiUPCdsApMlHhXogKVM4HM2DVbIjGNTTYH2OcmP1vA==", "license": "BSD-3-Clause", "dependencies": { - "side-channel": "^1.1.0" + "es-define-property": "^1.0.1", + "side-channel": "^1.1.1" }, "engines": { "node": ">=0.6" @@ -10343,6 +9569,8 @@ }, "node_modules/quick-lru": { "version": "5.1.1", + "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz", + "integrity": "sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==", "dev": true, "license": "MIT", "engines": { @@ -10368,22 +9596,8 @@ "iconv-lite": "~0.7.0", "unpipe": "~1.0.0" }, - "engines": { - "node": ">= 0.10" - } - }, - "node_modules/raw-body/node_modules/iconv-lite": { - "version": "0.7.0", - "license": "MIT", - "dependencies": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - }, - "engines": { - "node": ">=0.10.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" + "engines": { + "node": ">= 0.10" } }, "node_modules/rc-cascader": { @@ -11108,20 +10322,28 @@ } }, "node_modules/readable-stream": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", - "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", "dev": true, "license": "MIT", "dependencies": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - }, - "engines": { - "node": ">= 6" + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" } }, + "node_modules/readable-stream/node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", + "dev": true, + "license": "MIT" + }, "node_modules/readdirp": { "version": "3.6.0", "license": "MIT", @@ -11283,6 +10505,18 @@ }, "node_modules/require-directory": { "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", "dev": true, "license": "MIT", "engines": { @@ -11333,6 +10567,8 @@ }, "node_modules/resolve-alpn": { "version": "1.2.1", + "resolved": "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.2.1.tgz", + "integrity": "sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g==", "dev": true, "license": "MIT" }, @@ -11346,6 +10582,8 @@ }, "node_modules/responselike": { "version": "2.0.1", + "resolved": "https://registry.npmjs.org/responselike/-/responselike-2.0.1.tgz", + "integrity": "sha512-4gl03wn3hj1HP3yzgdI7d3lCkF95F21Pz4BPGvKHinyQzALR5CapwC8yIi0Rh58DEMQ/SguC03wFj2k0M/mHhw==", "dev": true, "license": "MIT", "dependencies": { @@ -11355,27 +10593,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/restore-cursor": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", - "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", - "dev": true, - "license": "MIT", - "dependencies": { - "onetime": "^5.1.0", - "signal-exit": "^3.0.2" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/restore-cursor/node_modules/signal-exit": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", - "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", - "dev": true, - "license": "ISC" - }, "node_modules/retry": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz", @@ -11411,6 +10628,8 @@ }, "node_modules/roarr": { "version": "2.15.4", + "resolved": "https://registry.npmjs.org/roarr/-/roarr-2.15.4.tgz", + "integrity": "sha512-CHhPh+UNHD2GTXNYhPWLnU8ONHdI+5DI+4EYIAOaiD63rHeYlZvyh8P+in5999TTSFgUYuKUAjzRI4mdh/p+2A==", "dev": true, "license": "BSD-3-Clause", "optional": true, @@ -11427,11 +10646,13 @@ } }, "node_modules/rollup": { - "version": "4.52.5", + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.62.2.tgz", + "integrity": "sha512-RFnrW4lhXA3s3eqHDZvN654g8OTjzRfqpIRJYczCGB6HzphckVAi/Qh4tbPUbRuDi7s1Llv8g/NspLkttY3gTA==", "dev": true, "license": "MIT", "dependencies": { - "@types/estree": "1.0.8" + "@types/estree": "1.0.9" }, "bin": { "rollup": "dist/bin/rollup" @@ -11441,28 +10662,31 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.52.5", - "@rollup/rollup-android-arm64": "4.52.5", - "@rollup/rollup-darwin-arm64": "4.52.5", - "@rollup/rollup-darwin-x64": "4.52.5", - "@rollup/rollup-freebsd-arm64": "4.52.5", - "@rollup/rollup-freebsd-x64": "4.52.5", - "@rollup/rollup-linux-arm-gnueabihf": "4.52.5", - "@rollup/rollup-linux-arm-musleabihf": "4.52.5", - "@rollup/rollup-linux-arm64-gnu": "4.52.5", - "@rollup/rollup-linux-arm64-musl": "4.52.5", - "@rollup/rollup-linux-loong64-gnu": "4.52.5", - "@rollup/rollup-linux-ppc64-gnu": "4.52.5", - "@rollup/rollup-linux-riscv64-gnu": "4.52.5", - "@rollup/rollup-linux-riscv64-musl": "4.52.5", - "@rollup/rollup-linux-s390x-gnu": "4.52.5", - "@rollup/rollup-linux-x64-gnu": "4.52.5", - "@rollup/rollup-linux-x64-musl": "4.52.5", - "@rollup/rollup-openharmony-arm64": "4.52.5", - "@rollup/rollup-win32-arm64-msvc": "4.52.5", - "@rollup/rollup-win32-ia32-msvc": "4.52.5", - "@rollup/rollup-win32-x64-gnu": "4.52.5", - "@rollup/rollup-win32-x64-msvc": "4.52.5", + "@rollup/rollup-android-arm-eabi": "4.62.2", + "@rollup/rollup-android-arm64": "4.62.2", + "@rollup/rollup-darwin-arm64": "4.62.2", + "@rollup/rollup-darwin-x64": "4.62.2", + "@rollup/rollup-freebsd-arm64": "4.62.2", + "@rollup/rollup-freebsd-x64": "4.62.2", + "@rollup/rollup-linux-arm-gnueabihf": "4.62.2", + "@rollup/rollup-linux-arm-musleabihf": "4.62.2", + "@rollup/rollup-linux-arm64-gnu": "4.62.2", + "@rollup/rollup-linux-arm64-musl": "4.62.2", + "@rollup/rollup-linux-loong64-gnu": "4.62.2", + "@rollup/rollup-linux-loong64-musl": "4.62.2", + "@rollup/rollup-linux-ppc64-gnu": "4.62.2", + "@rollup/rollup-linux-ppc64-musl": "4.62.2", + "@rollup/rollup-linux-riscv64-gnu": "4.62.2", + "@rollup/rollup-linux-riscv64-musl": "4.62.2", + "@rollup/rollup-linux-s390x-gnu": "4.62.2", + "@rollup/rollup-linux-x64-gnu": "4.62.2", + "@rollup/rollup-linux-x64-musl": "4.62.2", + "@rollup/rollup-openbsd-x64": "4.62.2", + "@rollup/rollup-openharmony-arm64": "4.62.2", + "@rollup/rollup-win32-arm64-msvc": "4.62.2", + "@rollup/rollup-win32-ia32-msvc": "4.62.2", + "@rollup/rollup-win32-x64-gnu": "4.62.2", + "@rollup/rollup-win32-x64-msvc": "4.62.2", "fsevents": "~2.3.2" } }, @@ -11521,24 +10745,10 @@ } }, "node_modules/safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], "license": "MIT" }, "node_modules/safe-push-apply": { @@ -11577,9 +10787,9 @@ "license": "MIT" }, "node_modules/sanitize-filename": { - "version": "1.6.3", - "resolved": "https://registry.npmjs.org/sanitize-filename/-/sanitize-filename-1.6.3.tgz", - "integrity": "sha512-y/52Mcy7aw3gRm7IrcGDFx/bCk4AhRh2eI9luHOQM86nZsqwiRkkq2GekHXBBD+SmPidc8i2PqtYZl+pWJ8Oeg==", + "version": "1.6.4", + "resolved": "https://registry.npmjs.org/sanitize-filename/-/sanitize-filename-1.6.4.tgz", + "integrity": "sha512-9ZyI08PsvdQl2r/bBIGubpVdR3RR9sY6RDiWFPreA21C/EFlQhmgo20UZlNjZMMZNubusLhAQozkA0Od5J21Eg==", "dev": true, "license": "WTFPL OR ISC", "dependencies": { @@ -11587,9 +10797,9 @@ } }, "node_modules/sax": { - "version": "1.4.4", - "resolved": "https://registry.npmjs.org/sax/-/sax-1.4.4.tgz", - "integrity": "sha512-1n3r/tGXO6b6VXMdFT54SHzT9ytu9yr7TaELowdYpMqY/Ao7EnlQGmAQ1+RatX7Tkkdm6hONI2owqNx2aZj5Sw==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.6.0.tgz", + "integrity": "sha512-6R3J5M4AcbtLUdZmRv2SygeVaM7IhrLXu9BmnOGmmACak8fiUtOsYNWUS4uK7upbmHIBbLBeFeI//477BKLBzA==", "dev": true, "license": "BlueOak-1.0.0", "engines": { @@ -11625,6 +10835,8 @@ }, "node_modules/semver-compare": { "version": "1.0.0", + "resolved": "https://registry.npmjs.org/semver-compare/-/semver-compare-1.0.0.tgz", + "integrity": "sha512-YM3/ITh2MJ5MtzaM429anh+x2jiLVjqILF4m4oyQB18W7Ggea7BfqdH/wGMK7dDiMghv/6WG7znWMwUDzJiXow==", "dev": true, "license": "MIT", "optional": true @@ -11672,6 +10884,8 @@ }, "node_modules/serialize-error": { "version": "7.0.1", + "resolved": "https://registry.npmjs.org/serialize-error/-/serialize-error-7.0.1.tgz", + "integrity": "sha512-8I8TjW5KMOKsZQTvoxjuSIa7foAwPWGOts+6o7sgjz41/qMD9VQHEDxi6PBvK2l0MXUmqZyNpUK+T2tQaaElvw==", "dev": true, "license": "MIT", "optional": true, @@ -11687,6 +10901,8 @@ }, "node_modules/serialize-error/node_modules/type-fest": { "version": "0.13.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.13.1.tgz", + "integrity": "sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg==", "dev": true, "license": "(MIT OR CC0-1.0)", "optional": true, @@ -11777,12 +10993,14 @@ } }, "node_modules/side-channel": { - "version": "1.1.0", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.1.tgz", + "integrity": "sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==", "license": "MIT", "dependencies": { "es-errors": "^1.3.0", - "object-inspect": "^1.13.3", - "side-channel-list": "^1.0.0", + "object-inspect": "^1.13.4", + "side-channel-list": "^1.0.1", "side-channel-map": "^1.0.1", "side-channel-weakmap": "^1.0.2" }, @@ -11794,11 +11012,13 @@ } }, "node_modules/side-channel-list": { - "version": "1.0.0", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz", + "integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==", "license": "MIT", "dependencies": { "es-errors": "^1.3.0", - "object-inspect": "^1.13.3" + "object-inspect": "^1.13.4" }, "engines": { "node": ">= 0.4" @@ -11875,61 +11095,16 @@ "node": ">=8" } }, - "node_modules/slice-ansi": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-3.0.0.tgz", - "integrity": "sha512-pSyv7bSTC7ig9Dcgbw9AuRNUb5k5V6oDudjZoMBSr13qpLBG7tB+zgCkARjq7xIUgdz5P1Qe8u+rSGdouOOIyQ==", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "ansi-styles": "^4.0.0", - "astral-regex": "^2.0.0", - "is-fullwidth-code-point": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/smart-buffer": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", - "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 6.0.0", - "npm": ">= 3.0.0" - } - }, - "node_modules/socks": { - "version": "2.8.7", - "resolved": "https://registry.npmjs.org/socks/-/socks-2.8.7.tgz", - "integrity": "sha512-HLpt+uLy/pxB+bum/9DzAgiKS8CX1EvbWxI4zlmgGCExImLdiad2iCwXT5Z4c9c3Eq8rP2318mPW2c+QbtjK8A==", - "dev": true, - "license": "MIT", - "dependencies": { - "ip-address": "^10.0.1", - "smart-buffer": "^4.2.0" - }, + "node_modules/smol-toml": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/smol-toml/-/smol-toml-1.8.0.tgz", + "integrity": "sha512-kCZr2V3ch9i00x8zXRhjUNVcjG9ijES5dDudkXvUVCT5QlJNQWElSJdZqyPemffHoLNUYwOcou0Fy+ojN0uHSQ==", + "license": "BSD-3-Clause", "engines": { - "node": ">= 10.0.0", - "npm": ">= 3.0.0" - } - }, - "node_modules/socks-proxy-agent": { - "version": "8.0.5", - "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-8.0.5.tgz", - "integrity": "sha512-HehCEsotFqbPW9sJ8WVYB6UbmIMv7kUUORIF2Nncq4VQvBfNBLibW9YZR5dlYCSUhwcD628pRllm7n+E+YTzJw==", - "dev": true, - "license": "MIT", - "dependencies": { - "agent-base": "^7.1.2", - "debug": "^4.3.4", - "socks": "^2.8.3" + "node": ">= 18" }, - "engines": { - "node": ">= 14" + "funding": { + "url": "https://github.com/sponsors/cyyynthia" } }, "node_modules/source-map": { @@ -11972,33 +11147,12 @@ }, "node_modules/sprintf-js": { "version": "1.1.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz", + "integrity": "sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==", "dev": true, "license": "BSD-3-Clause", "optional": true }, - "node_modules/ssri": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/ssri/-/ssri-12.0.0.tgz", - "integrity": "sha512-S7iGNosepx9RadX82oimUkvr0Ct7IjJbEbs4mJcTxst8um95J3sDYU1RBEOvdu6oL1Wek2ODI5i4MAw+dZ6cAQ==", - "dev": true, - "license": "ISC", - "dependencies": { - "minipass": "^7.0.3" - }, - "engines": { - "node": "^18.17.0 || >=20.5.0" - } - }, - "node_modules/ssri/node_modules/minipass": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", - "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=16 || 14 >=14.17" - } - }, "node_modules/stackback": { "version": "0.0.2", "dev": true, @@ -12027,7 +11181,9 @@ } }, "node_modules/std-env": { - "version": "3.10.0", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-4.2.0.tgz", + "integrity": "sha512-oCUKSupKTHX53EyjDtuZQ64pjLJ6yYCtpmEw0goYxtjG9KpbRe8KAsl2tBUGU9DyMcJ0RwJ8GqJAFzMXcXW1Rw==", "dev": true, "license": "MIT" }, @@ -12044,13 +11200,13 @@ } }, "node_modules/string_decoder": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", - "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "license": "MIT", "dependencies": { - "safe-buffer": "~5.2.0" + "safe-buffer": "~5.1.0" } }, "node_modules/string-convert": { @@ -12264,16 +11420,10 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/sucrase/node_modules/minipass": { - "version": "7.1.2", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=16 || 14 >=14.17" - } - }, "node_modules/sumchecker": { "version": "3.0.1", + "resolved": "https://registry.npmjs.org/sumchecker/-/sumchecker-3.0.1.tgz", + "integrity": "sha512-MvjXzkz/BOfyVDkG0oFOtBxHX2u3gKbMHIF/dXblZsgD3BWOFLmHovIpZY7BykJdAjcqRCBi1WYBNdEC9yI7vg==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -12353,9 +11503,9 @@ } }, "node_modules/tar": { - "version": "7.5.6", - "resolved": "https://registry.npmjs.org/tar/-/tar-7.5.6.tgz", - "integrity": "sha512-xqUeu2JAIJpXyvskvU3uvQW8PAmHrtXp2KDuMJwQqW8Sqq0CaZBAQ+dKS3RBXVhU4wC5NjAdKrmh84241gO9cA==", + "version": "7.5.22", + "resolved": "https://registry.npmjs.org/tar/-/tar-7.5.22.tgz", + "integrity": "sha512-MFO/QzvtAOmJbkhOaCTvbGcFN9L9b+JunIsDwaKljSOdcLMea3NJ1k9Usz/rjdfSXTq4dfzfeS7W4p4YOAAHeA==", "dev": true, "license": "BlueOak-1.0.0", "dependencies": { @@ -12369,16 +11519,6 @@ "node": ">=18" } }, - "node_modules/tar/node_modules/minipass": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", - "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=16 || 14 >=14.17" - } - }, "node_modules/tar/node_modules/yallist": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-5.0.0.tgz", @@ -12415,44 +11555,6 @@ "fs-extra": "^10.0.0" } }, - "node_modules/temp-file/node_modules/fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/temp-file/node_modules/jsonfile": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz", - "integrity": "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==", - "dev": true, - "license": "MIT", - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/temp-file/node_modules/universalify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", - "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 10.0.0" - } - }, "node_modules/temp/node_modules/rimraf": { "version": "2.6.3", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", @@ -12576,9 +11678,9 @@ } }, "node_modules/tinyglobby/node_modules/picomatch": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", - "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.5.tgz", + "integrity": "sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==", "dev": true, "license": "MIT", "engines": { @@ -12589,9 +11691,9 @@ } }, "node_modules/tinyrainbow": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-3.0.3.tgz", - "integrity": "sha512-PSkbLUoxOFRzJYjjxHJt9xro7D+iilgMX/C9lawzVuYiIdcihh9DXmVibBe8lmcFrRi/VzlPjBxbN7rH24q8/Q==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-3.1.0.tgz", + "integrity": "sha512-Bf+ILmBgretUrdJxzXM0SgXLZ3XfiaUuOj/IKQHuTXip+05Xn+uyEYdVg0kYDipTBcLrCVyUzAPz7QmArb0mmw==", "dev": true, "license": "MIT", "engines": { @@ -12599,9 +11701,9 @@ } }, "node_modules/tmp": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.5.tgz", - "integrity": "sha512-voyz6MApa1rQGUxT3E+BK7/ROe8itEx7vD8/HEvt4xwXucvQ5G5oeEiHkmHZJuBO21RpOf+YYm9MOivj709jow==", + "version": "0.2.7", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.7.tgz", + "integrity": "sha512-e0votIpp4Uo2AJYSzVHV6xCcawuiez3DzqDAbrTc3YxBkplN6e+dM13ZeIcZnDg/QpSuU2zfZ3rzwY8ukEnaXw==", "dev": true, "license": "MIT", "engines": { @@ -12706,6 +11808,13 @@ "json5": "lib/cli.js" } }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "dev": true, + "license": "0BSD" + }, "node_modules/type-check": { "version": "0.4.0", "dev": true, @@ -12729,15 +11838,34 @@ } }, "node_modules/type-is": { - "version": "2.0.1", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.1.0.tgz", + "integrity": "sha512-faYHw0anBbc/kWF3zFTEnxSFOAGUX9GFbOBthvDdLsIlEoWOFOtS0zgCiQYwIskL9iGXZL3kAXD8OoZ4GmMATA==", "license": "MIT", "dependencies": { - "content-type": "^1.0.5", + "content-type": "^2.0.0", "media-typer": "^1.1.0", "mime-types": "^3.0.0" }, "engines": { - "node": ">= 0.6" + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/type-is/node_modules/content-type": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz", + "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/type-is/node_modules/mime-db": { @@ -12860,6 +11988,17 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/undici": { + "version": "7.29.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-7.29.0.tgz", + "integrity": "sha512-IDxfleLmmbSskfWSUATiN1nfn2rDuvnMOqb5CWR92iIfojA0Ud+ulOAAEQ57LPr9rWmsreUyf5lwyao+7GNNVw==", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=20.18.1" + } + }, "node_modules/undici-types": { "version": "6.21.0", "dev": true, @@ -12883,32 +12022,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/unique-filename": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/unique-filename/-/unique-filename-4.0.0.tgz", - "integrity": "sha512-XSnEewXmQ+veP7xX2dS5Q4yZAvO40cBN2MWkJ7D/6sW4Dg6wYBNwM1Vrnz1FhH5AdeLIlUXRI9e28z1YZi71NQ==", - "dev": true, - "license": "ISC", - "dependencies": { - "unique-slug": "^5.0.0" - }, - "engines": { - "node": "^18.17.0 || >=20.5.0" - } - }, - "node_modules/unique-slug": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/unique-slug/-/unique-slug-5.0.0.tgz", - "integrity": "sha512-9OdaqO5kwqR+1kVgHAhsp5vPNU0hnxRa26rBFNfNgM7M6pNtgzeBn3s/xbyCQL3dcjzOatcef6UUHpB/6MaETg==", - "dev": true, - "license": "ISC", - "dependencies": { - "imurmurhash": "^0.1.4" - }, - "engines": { - "node": "^18.17.0 || >=20.5.0" - } - }, "node_modules/unist-util-is": { "version": "6.0.1", "dev": true, @@ -12973,11 +12086,13 @@ } }, "node_modules/universalify": { - "version": "0.1.2", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", + "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", "dev": true, "license": "MIT", "engines": { - "node": ">= 4.0.0" + "node": ">= 10.0.0" } }, "node_modules/unpipe": { @@ -12987,8 +12102,39 @@ "node": ">= 0.8" } }, + "node_modules/unzipper": { + "version": "0.12.5", + "resolved": "https://registry.npmjs.org/unzipper/-/unzipper-0.12.5.tgz", + "integrity": "sha512-tXYOi9R57Uj/2Z25SOs5RRSzq886MBQj2gY8dPL+xl/kv6s6SvByoKfAtvfVeEuhntWDgjd2o9p2lb4TVPAz0A==", + "dev": true, + "license": "MIT", + "dependencies": { + "bluebird": "~3.7.2", + "duplexer2": "~0.1.4", + "fs-extra": "11.3.1", + "graceful-fs": "^4.2.2", + "node-int64": "^0.4.0" + } + }, + "node_modules/unzipper/node_modules/fs-extra": { + "version": "11.3.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.3.1.tgz", + "integrity": "sha512-eXvGGwZ5CL17ZSwHWd3bbgk7UUpF6IFHtP57NYYakPvHOs8GDgDe5KJI36jIJzDkJ6eJjuzRA8eBQb6SkKue0g==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=14.14" + } + }, "node_modules/update-browserslist-db": { - "version": "1.1.4", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.2.tgz", + "integrity": "sha512-UQ+MSxlhRm1bzjhU+DcuXfjFO1FzNtqhK5+9Yvlp90ItDLk5vT932A0rFu619nf7RVS+Y/VeaUW1jaRDqZ8VJw==", "dev": true, "funding": [ { @@ -13044,17 +12190,6 @@ "dev": true, "license": "MIT" }, - "node_modules/uuid": { - "version": "9.0.1", - "funding": [ - "https://github.com/sponsors/broofa", - "https://github.com/sponsors/ctavan" - ], - "license": "MIT", - "bin": { - "uuid": "dist/bin/uuid" - } - }, "node_modules/vary": { "version": "1.1.2", "license": "MIT", @@ -13062,22 +12197,6 @@ "node": ">= 0.8" } }, - "node_modules/verror": { - "version": "1.10.1", - "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.1.tgz", - "integrity": "sha512-veufcmxri4e3XSrT0xwfUR7kguIkaxBeosDg00yDWhk49wdwkSUrvvsm7nc75e1PUyvIeZj6nS8VQRYz2/S4Xg==", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "assert-plus": "^1.0.0", - "core-util-is": "1.0.2", - "extsprintf": "^1.2.0" - }, - "engines": { - "node": ">=0.6.0" - } - }, "node_modules/vfile": { "version": "6.0.3", "dev": true, @@ -13126,13 +12245,13 @@ } }, "node_modules/vite": { - "version": "7.3.1", - "resolved": "https://registry.npmjs.org/vite/-/vite-7.3.1.tgz", - "integrity": "sha512-w+N7Hifpc3gRjZ63vYBXA56dvvRlNWRczTdmCBBa+CotUzAPf5b7YMdMR/8CQoeYE5LX3W4wj6RYTgonm1b9DA==", + "version": "7.3.6", + "resolved": "https://registry.npmjs.org/vite/-/vite-7.3.6.tgz", + "integrity": "sha512-4XP60spRGjSZFf1qYH+dJIkK2znL3zQfl9KkOV9MkkRR/3Dls0dxaBsQPTloEc5BLXWPL9vsOxopxyKoMmDueg==", "dev": true, "license": "MIT", "dependencies": { - "esbuild": "^0.27.0", + "esbuild": "^0.27.0 || ^0.28.0", "fdir": "^6.5.0", "picomatch": "^4.0.3", "postcss": "^8.5.6", @@ -13711,9 +12830,9 @@ } }, "node_modules/vite/node_modules/picomatch": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", - "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.5.tgz", + "integrity": "sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==", "dev": true, "license": "MIT", "engines": { @@ -13724,31 +12843,31 @@ } }, "node_modules/vitest": { - "version": "4.0.17", - "resolved": "https://registry.npmjs.org/vitest/-/vitest-4.0.17.tgz", - "integrity": "sha512-FQMeF0DJdWY0iOnbv466n/0BudNdKj1l5jYgl5JVTwjSsZSlqyXFt/9+1sEyhR6CLowbZpV7O1sCHrzBhucKKg==", + "version": "4.1.10", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-4.1.10.tgz", + "integrity": "sha512-R9jUTe5S4Qb0HCd4TNqpC7oGcrMssMRGXLW80ubjWsW9VH5GF8y1Y0SFLY9AbqSk6nt0PnOx4H4WNJYZ13GUPw==", "dev": true, "license": "MIT", "dependencies": { - "@vitest/expect": "4.0.17", - "@vitest/mocker": "4.0.17", - "@vitest/pretty-format": "4.0.17", - "@vitest/runner": "4.0.17", - "@vitest/snapshot": "4.0.17", - "@vitest/spy": "4.0.17", - "@vitest/utils": "4.0.17", - "es-module-lexer": "^1.7.0", - "expect-type": "^1.2.2", + "@vitest/expect": "4.1.10", + "@vitest/mocker": "4.1.10", + "@vitest/pretty-format": "4.1.10", + "@vitest/runner": "4.1.10", + "@vitest/snapshot": "4.1.10", + "@vitest/spy": "4.1.10", + "@vitest/utils": "4.1.10", + "es-module-lexer": "^2.0.0", + "expect-type": "^1.3.0", "magic-string": "^0.30.21", "obug": "^2.1.1", "pathe": "^2.0.3", "picomatch": "^4.0.3", - "std-env": "^3.10.0", + "std-env": "^4.0.0-rc.1", "tinybench": "^2.9.0", "tinyexec": "^1.0.2", "tinyglobby": "^0.2.15", - "tinyrainbow": "^3.0.3", - "vite": "^6.0.0 || ^7.0.0", + "tinyrainbow": "^3.1.0", + "vite": "^6.0.0 || ^7.0.0 || ^8.0.0", "why-is-node-running": "^2.3.0" }, "bin": { @@ -13764,12 +12883,15 @@ "@edge-runtime/vm": "*", "@opentelemetry/api": "^1.9.0", "@types/node": "^20.0.0 || ^22.0.0 || >=24.0.0", - "@vitest/browser-playwright": "4.0.17", - "@vitest/browser-preview": "4.0.17", - "@vitest/browser-webdriverio": "4.0.17", - "@vitest/ui": "4.0.17", + "@vitest/browser-playwright": "4.1.10", + "@vitest/browser-preview": "4.1.10", + "@vitest/browser-webdriverio": "4.1.10", + "@vitest/coverage-istanbul": "4.1.10", + "@vitest/coverage-v8": "4.1.10", + "@vitest/ui": "4.1.10", "happy-dom": "*", - "jsdom": "*" + "jsdom": "*", + "vite": "^6.0.0 || ^7.0.0 || ^8.0.0" }, "peerDependenciesMeta": { "@edge-runtime/vm": { @@ -13790,6 +12912,12 @@ "@vitest/browser-webdriverio": { "optional": true }, + "@vitest/coverage-istanbul": { + "optional": true + }, + "@vitest/coverage-v8": { + "optional": true + }, "@vitest/ui": { "optional": true }, @@ -13798,13 +12926,16 @@ }, "jsdom": { "optional": true + }, + "vite": { + "optional": false } } }, "node_modules/vitest/node_modules/picomatch": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", - "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.5.tgz", + "integrity": "sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==", "dev": true, "license": "MIT", "engines": { @@ -13814,14 +12945,18 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, - "node_modules/wcwidth": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz", - "integrity": "sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==", + "node_modules/webcrypto-core": { + "version": "1.9.2", + "resolved": "https://registry.npmjs.org/webcrypto-core/-/webcrypto-core-1.9.2.tgz", + "integrity": "sha512-gsXecm82UQNlTBURJGuqOWy1Ww08S3kZUcr3aOJS02Pk0xLtkfeUAVC0u0xhgdonFme80edSJUIJyuvL/7250Q==", "dev": true, "license": "MIT", "dependencies": { - "defaults": "^1.0.3" + "@peculiar/asn1-schema": "^2.7.0", + "@peculiar/json-schema": "^1.1.12", + "@peculiar/utils": "^2.0.2", + "asn1js": "^3.0.10", + "tslib": "^2.8.1" } }, "node_modules/which": { @@ -13944,6 +13079,8 @@ }, "node_modules/wrap-ansi": { "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", "dev": true, "license": "MIT", "dependencies": { @@ -13991,6 +13128,8 @@ }, "node_modules/y18n": { "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", "dev": true, "license": "ISC", "engines": { @@ -13999,13 +13138,15 @@ }, "node_modules/yallist": { "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", "dev": true, "license": "ISC" }, "node_modules/yaml": { - "version": "2.8.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.2.tgz", - "integrity": "sha512-mplynKqc1C2hTVYxd0PU2xQAc22TI1vShAYGksCCfxbn/dFwnHTNi1bvYsBTkhdUNtGIf5xNOg938rrSSYvS9A==", + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.9.0.tgz", + "integrity": "sha512-2AvhNX3mb8zd6Zy7INTtSpl1F15HW6Wnqj0srWlkKLcpYl/gMIMJiyuGq2KeI2YFxUPjdlB+3Lc10seMLtL4cA==", "dev": true, "license": "ISC", "bin": { @@ -14019,7 +13160,9 @@ } }, "node_modules/yargs": { - "version": "17.7.2", + "version": "17.7.3", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.3.tgz", + "integrity": "sha512-GZtjxm/J/4TSxuL3FNYjCmLktBTnIw/rVmKSIyKeYAZpmJB2ig9VauCC5xsa82GNKVKDAqpOn3KVzNt0zmrU0g==", "dev": true, "license": "MIT", "dependencies": { @@ -14037,21 +13180,14 @@ }, "node_modules/yargs-parser": { "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", "dev": true, "license": "ISC", "engines": { "node": ">=12" } }, - "node_modules/yauzl": { - "version": "2.10.0", - "dev": true, - "license": "MIT", - "dependencies": { - "buffer-crc32": "~0.2.3", - "fd-slicer": "~1.1.0" - } - }, "node_modules/yocto-queue": { "version": "0.1.0", "dev": true, diff --git a/package.json b/package.json index d963957..16a97d6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ccb", - "version": "1.4.0", - "description": "Claude Code Butler - 配置管理工具", + "version": "1.5.0", + "description": "Claude Code Butler - 多 AI Agent 配置管理工具", "main": "out/main/index.js", "scripts": { "dev": "node scripts/dev-runner.cjs dev", @@ -9,14 +9,19 @@ "build": "electron-vite build", "preview": "electron-vite preview", "clean:release": "node scripts/clean-release.cjs", + "registry:sign": "node scripts/sign-registry-bundle.cjs", + "release:preflight": "node scripts/release-preflight.cjs", + "release:preflight:preview": "node scripts/release-preflight.cjs --allow-preview-registry", "pack": "npm run clean:release && electron-builder", "pack:dir": "npm run clean:release && electron-builder --dir", "pack:portable": "npm run clean:release && electron-builder --win portable", "pack:installer": "npm run clean:release && electron-builder --win nsis", "pack:zip": "npm run clean:release && electron-builder --win zip", + "pack:win:all": "npm run clean:release && electron-builder --win portable nsis zip --publish=never", "dist": "npm run clean:release && electron-builder --publish=never", "test": "vitest", "lint": "eslint src --ext .ts,.tsx", + "lint:changed": "node scripts/lint-changed.cjs", "type-check": "tsc --noEmit", "start": "npm run build && electron out/main/index.js", "start:admin": "npm run build && node scripts/start-admin.js", @@ -34,6 +39,9 @@ }, "keywords": [ "claude-code", + "ai-agent", + "codex-cli", + "local-first", "configuration-manager", "electron", "typescript", @@ -50,26 +58,22 @@ "url": "https://github.com/NianLog/ClaudeCodeButler/issues" }, "dependencies": { - "axios": "^1.13.0", "chokidar": "^3.5.3", - "cors": "^2.8.5", "express": "^5.1.0", + "https-proxy-agent": "^7.0.6", "js-yaml": "^4.1.1", - "node-cron": "^3.0.3", - "uuid": "^9.0.0" + "node-cron": "^4.6.0", + "smol-toml": "^1.8.0" }, "devDependencies": { "@monaco-editor/react": "^4.7.0", - "@types/cors": "^2.8.19", "@types/express": "^5.0.6", "@types/js-yaml": "^4.0.9", "@types/node": "^20.10.0", - "@types/node-cron": "^3.0.11", "@types/react": "^18.2.0", "@types/react-dom": "^18.2.0", "@types/react-syntax-highlighter": "^15.5.13", "@types/react-window": "^1.8.8", - "@types/uuid": "^9.0.0", "@typescript-eslint/eslint-plugin": "^7.7.0", "@typescript-eslint/parser": "^7.7.0", "@vitejs/plugin-react": "^4.2.0", @@ -102,12 +106,15 @@ "zustand": "^4.4.0" }, "overrides": { - "@electron/rebuild": "^4.0.2" + "@electron/rebuild": "^4.0.2", + "brace-expansion@^1.1.7": "1.1.18", + "brace-expansion@^2.0.1": "2.1.4", + "dompurify": "3.4.14" }, "build": { "appId": "com.claudecode.butler", "productName": "CCB", - "compression": "normal", + "compression": "maximum", "electronLanguages": [ "zh-CN", "en-US" @@ -187,6 +194,7 @@ }, "files": [ "out/**/*", + "!**/*.map", "resources/**/*", "!resources/icons/README.md" ], diff --git a/requirements-security.txt b/requirements-security.txt new file mode 100644 index 0000000..949d363 --- /dev/null +++ b/requirements-security.txt @@ -0,0 +1,2 @@ +# Semgrep CLI used for reproducible local security audits. +semgrep==1.169.0 diff --git a/scripts/lint-changed.cjs b/scripts/lint-changed.cjs new file mode 100644 index 0000000..894364d --- /dev/null +++ b/scripts/lint-changed.cjs @@ -0,0 +1,99 @@ +/** + * @file Lint ratchet(增量 lint 门禁) + * @description 对相对 base 分支变更的 src 下 TypeScript 文件比较 HEAD 与 base 的 ESLint error 数: + * 存量 error 不阻塞、不得新增——新增文件必须干净,触碰文件 error 数不得增长。 + * 防止 lint 债务在 CI informational 全量 lint 下无声增长。 + */ + +const { execFileSync } = require('child_process') +const { ESLint } = require('eslint') + +/** 解析 base revision:优先 origin/main,回退 main。 */ +function resolveBaseRevision() { + for (const candidate of ['origin/main', 'main']) { + try { + execFileSync('git', ['rev-parse', '--verify', '--quiet', `${candidate}^{commit}`], { encoding: 'utf8' }) + return candidate + } catch { + // 尝试下一个候选 + } + } + throw new Error('lint:changed 找不到 base 分支(origin/main 或 main)') +} + +/** 列出相对 merge-base 新增/修改的 src TS 文件。 */ +function listChangedFiles(base) { + const mergeBase = execFileSync('git', ['merge-base', 'HEAD', base], { encoding: 'utf8' }).trim() + const output = execFileSync( + 'git', + ['diff', '--name-only', '--diff-filter=ACMR', `${mergeBase}...HEAD`], + { encoding: 'utf8' } + ) + return output + .split('\n') + .map((line) => line.trim()) + .filter(Boolean) + .filter((file) => /^src\/.*\.(ts|tsx)$/.test(file)) +} + +async function main() { + const base = resolveBaseRevision() + const changedFiles = listChangedFiles(base) + if (changedFiles.length === 0) { + process.stdout.write('lint:changed: 没有相对 base 变更的 src 文件,跳过\n') + return + } + + const eslint = new ESLint() + const headResults = await eslint.lintFiles(changedFiles) + const headErrorByFile = new Map() + for (const result of headResults) { + const normalized = result.filePath.replace(/\\/g, '/') + for (const file of changedFiles) { + if (normalized.endsWith(file)) { + headErrorByFile.set(file, result.errorCount) + } + } + } + + const failures = [] + let totalHeadErrors = 0 + for (const file of changedFiles) { + const headCount = headErrorByFile.get(file) ?? 0 + totalHeadErrors += headCount + // 干净的文件不可能比 base 更差,无需回查 base + if (headCount === 0) continue + + let baseContent + try { + baseContent = execFileSync('git', ['show', `${base}:${file}`], { + encoding: 'utf8', + maxBuffer: 16 * 1024 * 1024 + }) + } catch { + failures.push(`${file}: 新增文件存在 ${headCount} 个 lint error(新增文件必须干净)`) + continue + } + + const baseResults = await eslint.lintText(baseContent, { filePath: file }) + const baseCount = baseResults.reduce((total, result) => total + result.errorCount, 0) + if (headCount > baseCount) { + failures.push(`${file}: lint error ${baseCount} -> ${headCount}(不得新增)`) + } + } + + process.stdout.write( + `lint:changed: 检查 ${changedFiles.length} 个变更文件(base=${base}),HEAD error 总数 ${totalHeadErrors}\n` + ) + if (failures.length > 0) { + for (const failure of failures) process.stderr.write(`ERROR: ${failure}\n`) + process.exitCode = 1 + return + } + process.stdout.write('lint:changed: 通过,未新增 lint error\n') +} + +main().catch((error) => { + process.stderr.write(`${error instanceof Error ? error.stack || error.message : String(error)}\n`) + process.exitCode = 1 +}) diff --git a/scripts/release-preflight.cjs b/scripts/release-preflight.cjs new file mode 100644 index 0000000..7ee8420 --- /dev/null +++ b/scripts/release-preflight.cjs @@ -0,0 +1,150 @@ +/** + * @file CCB release preflight + * @description 静态检查版本、installer identity、双语文档、private key 泄漏与 registry production trust key。 + */ + +const { readFile } = require('fs/promises') +const path = require('path') +const { execFileSync } = require('child_process') + +/** 读取 UTF-8 文本文件。 */ +async function readText(rootDir, relativePath) { + return readFile(path.join(rootDir, relativePath), 'utf8') +} + +/** + * 对 repository snapshot 执行纯静态 release checks。 + * @param input 已读取的关键文件内容与 tracked file contents + */ +function auditReleaseSnapshot(input) { + const errors = [] + const warnings = [] + const packageJson = JSON.parse(input.packageJson) + const packageLock = JSON.parse(input.packageLock) + const version = packageJson.version + + if (packageLock.version !== version || packageLock.packages?.['']?.version !== version) { + errors.push('package.json 与 package-lock.json root version 不一致') + } + if (!input.constantsSource.includes(`version: packageJson.version`)) { + errors.push('APP_INFO version 未绑定 package.json') + } + if (!input.readmeEn.includes(`\`${version}\``) || !input.readmeZh.includes(`\`${version}\``)) { + errors.push('双语 README 未声明当前 package version') + } + if (!input.changelog.includes(`[Unreleased] - ${version}`)) { + errors.push('CHANGELOG Unreleased version 与 package version 不一致') + } + if (packageJson.build?.appId !== 'com.claudecode.butler' || packageJson.build?.productName !== 'CCB') { + errors.push('Installer identity 与兼容 contract 不一致') + } + if (!String(packageJson.build?.portable?.artifactName).includes('${version}') || + !String(packageJson.build?.nsis?.artifactName).includes('${version}')) { + errors.push('Windows installer artifactName 必须包含 ${version}') + } + if (!/多 AI Agent|multi[- ]AI/i.test(packageJson.description)) { + errors.push('Package description 未表达多 AI Agent 管理范围') + } + + const requiredWindowSecurityTokens = [ + 'nodeIntegration: false', + 'contextIsolation: true', + 'sandbox: true', + 'webSecurity: true', + 'allowRunningInsecureContent: false', + 'setWindowOpenHandler', + "webContents.on('will-navigate'" + ] + for (const token of requiredWindowSecurityTokens) { + if (!input.windowManagerSource.includes(token)) { + errors.push(`Electron window security contract 缺失: ${token}`) + } + } + + const privateKeyMarker = /-----BEGIN (?:(?:ENCRYPTED|RSA|DSA|EC|OPENSSH) )?PRIVATE KEY-----/ + for (const file of input.trackedFiles) { + if (privateKeyMarker.test(file.content)) { + errors.push(`Tracked file 包含 private key marker: ${file.path}`) + } + } + + const trustMapMatch = input.registryUpdateSource.match( + /REGISTRY_TRUSTED_PUBLIC_KEYS[^=]*=\s*Object\.freeze\(\{([\s\S]*?)\}\)/ + ) + const trustMapBody = trustMapMatch?.[1] + .replace(/\/\*[\s\S]*?\*\//g, '') + .replace(/\/\/.*$/gm, '') + .trim() ?? '' + const trustMapEmpty = !/(?:['"][^'"]+['"]|[A-Za-z_$][\w$-]*)\s*:/.test(trustMapBody) + if (trustMapEmpty) { + const message = 'REGISTRY_TRUSTED_PUBLIC_KEYS 尚未注入 production publisher public key' + if (input.allowPreviewRegistry) warnings.push(message) + else errors.push(message) + } + + // rehearsal/test 等非 production 命名的 keyId 不得进入正式发布(防止 rehearsal 密钥被误发布) + const trustMapKeyIds = Array.from(trustMapBody.matchAll(/['"]([^'"]+)['"]\s*:/g), (match) => match[1]) + const nonProductionKeyIds = trustMapKeyIds.filter((keyId) => + /rehearsal|test|dev|staging|example|sample|placeholder|dummy/i.test(keyId) + ) + if (nonProductionKeyIds.length > 0) { + const message = `REGISTRY_TRUSTED_PUBLIC_KEYS 包含非 production 命名 keyId: ${nonProductionKeyIds.join(', ')}` + if (input.allowPreviewRegistry) warnings.push(message) + else errors.push(message) + } + + return { version, errors, warnings } +} + +/** + * 从工作区读取 preflight 输入并执行检查。 + * @param rootDir repository root + * @param allowPreviewRegistry 是否允许空 registry trust map + */ +async function runPreflight(rootDir, allowPreviewRegistry) { + const trackedPaths = execFileSync( + 'git', + ['-c', 'core.quotepath=false', 'ls-files', '-z'], + { cwd: rootDir, encoding: 'utf8' } + ) + .split('\0') + .filter(Boolean) + const trackedFiles = await Promise.all(trackedPaths.map(async (relativePath) => ({ + path: relativePath, + content: await readText(rootDir, relativePath) + }))) + return auditReleaseSnapshot({ + packageJson: await readText(rootDir, 'package.json'), + packageLock: await readText(rootDir, 'package-lock.json'), + constantsSource: await readText(rootDir, 'src/shared/constants.ts'), + registryUpdateSource: await readText(rootDir, 'src/main/services/registry-update-service.ts'), + windowManagerSource: await readText(rootDir, 'src/main/window-manager.ts'), + readmeEn: await readText(rootDir, 'README.md'), + readmeZh: await readText(rootDir, 'README_CN.md'), + changelog: await readText(rootDir, 'CHANGELOG.md'), + trackedFiles, + allowPreviewRegistry + }) +} + +/** CLI entry point。 */ +async function main() { + const allowPreviewRegistry = process.argv.includes('--allow-preview-registry') + const result = await runPreflight(process.cwd(), allowPreviewRegistry) + for (const warning of result.warnings) process.stderr.write(`WARNING: ${warning}\n`) + if (result.errors.length > 0) { + for (const error of result.errors) process.stderr.write(`ERROR: ${error}\n`) + process.exitCode = 1 + return + } + process.stdout.write(`Release preflight passed for CCB ${result.version}\n`) +} + +if (require.main === module) { + main().catch((error) => { + process.stderr.write(`${error instanceof Error ? error.stack || error.message : String(error)}\n`) + process.exitCode = 1 + }) +} + +module.exports = { auditReleaseSnapshot, runPreflight } diff --git a/scripts/sign-registry-bundle.cjs b/scripts/sign-registry-bundle.cjs new file mode 100644 index 0000000..d77474a --- /dev/null +++ b/scripts/sign-registry-bundle.cjs @@ -0,0 +1,70 @@ +/** + * @file Offline registry bundle signing helper + * @description 使用维护者离线保管的 Ed25519 private key 对 raw bundle bytes 签名并输出 manifest fields。 + */ + +const { createHash, createPrivateKey, sign } = require('crypto') +const { readFile } = require('fs/promises') + +const MAX_BUNDLE_BYTES = 2 * 1024 * 1024 + +/** + * 对 raw bundle bytes 计算 manifest integrity/signature fields。 + * @param rawBundle 未规范化 bundle bytes(1 - MAX_BUNDLE_BYTES) + * @param privateKeyPem Ed25519 private key PEM 文本 + * @param keyId stable lowercase kebab-case key identifier + * @returns 可直接合并到 manifest 的 integrity/signature fields + */ +function buildBundleIntegrity(rawBundle, privateKeyPem, keyId) { + if (!Buffer.isBuffer(rawBundle) || rawBundle.length === 0 || rawBundle.length > MAX_BUNDLE_BYTES) { + throw new Error(`Bundle size must be 1-${MAX_BUNDLE_BYTES} bytes`) + } + if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(keyId)) { + throw new Error('key-id must be lowercase kebab-case') + } + const privateKey = createPrivateKey(privateKeyPem) + if (privateKey.asymmetricKeyType !== 'ed25519') { + throw new Error('Private key must be Ed25519') + } + return { + bundleSha256: createHash('sha256').update(rawBundle).digest('hex'), + bundleSize: rawBundle.length, + signatureAlgorithm: 'ED25519', + keyId, + signature: sign(null, rawBundle, privateKey).toString('base64') + } +} + +/** + * 读取并验证命令行参数。 + * @returns bundle path、private key path 与 stable key identifier + */ +function readArguments() { + const [, , bundlePath, privateKeyPath, keyId] = process.argv + if (!bundlePath || !privateKeyPath || !keyId) { + throw new Error('Usage: node scripts/sign-registry-bundle.cjs ') + } + return { bundlePath, privateKeyPath, keyId } +} + +/** + * 生成可直接合并到 manifest 的 integrity/signature fields。 + */ +async function main() { + const { bundlePath, privateKeyPath, keyId } = readArguments() + const [rawBundle, privateKeyPem] = await Promise.all([ + readFile(bundlePath), + readFile(privateKeyPath, 'utf8') + ]) + const output = buildBundleIntegrity(rawBundle, privateKeyPem, keyId) + process.stdout.write(`${JSON.stringify(output, null, 2)}\n`) +} + +if (require.main === module) { + main().catch((error) => { + process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`) + process.exitCode = 1 + }) +} + +module.exports = { buildBundleIntegrity } diff --git a/scripts/start-admin.js b/scripts/start-admin.js index e4aa512..7d9fc35 100644 --- a/scripts/start-admin.js +++ b/scripts/start-admin.js @@ -1,48 +1,51 @@ /** * CCB 管理员权限启动脚本 * 用于强制以管理员权限启动 CCB 应用 + * + * 安全模型(npm 脚本调用本脚本时不传任何附加参数,因此不做 argv 透传): + * - 解释器(PowerShell / osascript)只接收完全静态的脚本文本, + * 目标程序路径经环境变量传入,运行期作为"数据"而非"代码"读取; + * - 目标路径先经 validateExecutablePath 白名单校验(仅允许路径常规字符); + * - Linux pkexec/sudo 参数数组为固定结构,"--" 终止特权程序选项解析, + * 其后唯一的动态值是已校验的目标路径。 + * 如未来需要透传参数:必须逐项白名单校验,并保持 "--" 终止符,禁止拼接解释器字符串。 */ -const { spawn, exec } = require('child_process'); -const path = require('path'); -const fs = require('fs'); +const { spawn } = require('child_process'); const os = require('os'); -/** - * 获取当前平台 - */ -function getPlatform() { - return process.platform; -} +/** 可执行文件路径白名单:字母数字与路径常规字符(不含引号/$/;等解释器元字符) */ +const EXECUTABLE_PATH_PATTERN = /^[\w@+=:,./ \\-]+$/; /** - * 获取当前可执行文件路径 + * 校验目标可执行文件路径只含路径常规字符 + * @param {string} executablePath 目标可执行文件路径 */ -function getExecutablePath() { - return process.execPath; +function validateExecutablePath(executablePath) { + if (typeof executablePath !== 'string' || executablePath.length === 0 + || !EXECUTABLE_PATH_PATTERN.test(executablePath)) { + console.error(`已拒绝包含特殊字符的目标路径: ${JSON.stringify(executablePath)}`); + console.error('目标路径只允许字母数字与路径常规字符(禁止引号、$、;、&、| 等字符)'); + process.exit(1); + } } /** * Windows 平台管理员权限启动 + * 静态 PowerShell 脚本从环境变量读取目标路径,Start-Process 将其作为值而非代码处理。 */ -function startAsAdminWindows() { - const currentExecutable = getExecutablePath(); - const currentArgs = process.argv.slice(1); +const WINDOWS_ELEVATE_SCRIPT = 'Start-Process -FilePath $env:CCB_ELEVATE_TARGET -Verb RunAs'; - // 构建参数字符串 - const argsString = currentArgs.length > 0 - ? `-ArgumentList "${currentArgs.join('" "').replace(/"/g, '""')}"` - : ''; - - // PowerShell 命令以管理员权限启动 - const powershellCommand = `Start-Process -FilePath "${currentExecutable}" ${argsString} -Verb RunAs`; +function startAsAdminWindows() { + const currentExecutable = process.execPath; + validateExecutablePath(currentExecutable); - console.log(`正在以管理员权限启动应用...`); - console.log(`命令: powershell.exe -Command "${powershellCommand}"`); + console.log('正在以管理员权限启动应用...'); + console.log('命令: powershell.exe -NoProfile -Command <静态提升脚本>(目标路径经环境变量传入)'); - const child = spawn('powershell.exe', ['-Command', powershellCommand], { + const child = spawn('powershell.exe', ['-NoProfile', '-Command', WINDOWS_ELEVATE_SCRIPT], { stdio: 'inherit', - shell: true + env: { ...process.env, CCB_ELEVATE_TARGET: currentExecutable } }); child.on('error', (error) => { @@ -58,23 +61,21 @@ function startAsAdminWindows() { /** * macOS 平台管理员权限启动 + * 静态 AppleScript 经 system attribute 读取环境变量,quoted form of 完成可靠的单引号包裹。 */ -function startAsAdminMacOS() { - const currentExecutable = getExecutablePath(); - const currentArgs = process.argv.slice(1); +const MACOS_ELEVATE_SCRIPT = + 'do shell script (quoted form of (system attribute "CCB_ELEVATE_TARGET")) with administrator privileges'; - // 构建完整的命令 - const fullCommand = `"${currentExecutable}" ${currentArgs.join(' ')}`; - - // 使用 osascript 以管理员权限执行 - const osascriptCommand = `do shell script "${fullCommand}" with administrator privileges`; +function startAsAdminMacOS() { + const currentExecutable = process.execPath; + validateExecutablePath(currentExecutable); - console.log(`正在以管理员权限启动应用...`); - console.log(`命令: osascript -e '${osascriptCommand}'`); + console.log('正在以管理员权限启动应用...'); + console.log('命令: osascript -e <静态提升脚本>(目标路径经环境变量传入)'); - const child = spawn('osascript', ['-e', osascriptCommand], { + const child = spawn('osascript', ['-e', MACOS_ELEVATE_SCRIPT], { stdio: 'inherit', - shell: true + env: { ...process.env, CCB_ELEVATE_TARGET: currentExecutable } }); child.on('error', (error) => { @@ -92,21 +93,21 @@ function startAsAdminMacOS() { * Linux 平台管理员权限启动 */ async function startAsAdminLinux() { - const currentExecutable = getExecutablePath(); - const currentArgs = process.argv.slice(1); + const currentExecutable = process.execPath; + validateExecutablePath(currentExecutable); - // 首先尝试使用 pkexec + // 首先尝试使用 pkexec("--" 终止 pkexec 自身选项解析,其后仅为已校验的目标路径) try { - console.log(`正在使用 pkexec 以管理员权限启动应用...`); + console.log('正在使用 pkexec 以管理员权限启动应用...'); - const child = spawn('pkexec', [currentExecutable, ...currentArgs], { + const child = spawn('pkexec', ['--', currentExecutable], { stdio: 'inherit' }); child.on('error', (error) => { console.error('pkexec 启动失败:', error); // 如果 pkexec 失败,尝试使用 sudo - startWithSudo(); + startWithSudo(currentExecutable); }); child.on('close', (code) => { @@ -116,20 +117,19 @@ async function startAsAdminLinux() { } catch (error) { console.error('pkexec 不可用,尝试使用 sudo...'); - startWithSudo(); + startWithSudo(currentExecutable); } } /** * 使用 sudo 启动 (Linux) + * @param {string} executable 已通过白名单校验的目标可执行文件路径 */ -function startWithSudo() { - const currentExecutable = getExecutablePath(); - const currentArgs = process.argv.slice(1); - - console.log(`正在使用 sudo 以管理员权限启动应用...`); +function startWithSudo(executable) { + console.log('正在使用 sudo 以管理员权限启动应用...'); - const child = spawn('sudo', [currentExecutable, ...currentArgs], { + // "--" 终止 sudo 选项解析,其后仅为已校验的目标路径 + const child = spawn('sudo', ['--', executable], { stdio: 'inherit' }); @@ -149,12 +149,13 @@ function startWithSudo() { * 主函数 - 根据平台执行相应的管理员启动逻辑 */ function main() { - const platform = getPlatform(); + const platform = process.platform; - console.log(`CCB 管理员权限启动脚本`); + console.log('CCB 管理员权限启动脚本'); console.log(`当前平台: ${platform}`); - console.log(`可执行文件: ${getExecutablePath()}`); - console.log(`---`); + console.log(`可执行文件: ${process.execPath}`); + console.log(`宿主 OS: ${os.type()} ${os.release()}`); + console.log('---'); switch (platform) { case 'win32': @@ -182,5 +183,6 @@ module.exports = { main, startAsAdminWindows, startAsAdminMacOS, - startAsAdminLinux -}; \ No newline at end of file + startAsAdminLinux, + validateExecutablePath +}; diff --git a/src/main/file-watcher.ts b/src/main/file-watcher.ts index 38802e9..56ac6bc 100644 --- a/src/main/file-watcher.ts +++ b/src/main/file-watcher.ts @@ -9,13 +9,27 @@ import { join, basename, extname } from 'path' import { ConfigChangeEvent, ConfigType } from '@shared/types' import { CONFIG_FILES } from '@shared/constants' import { logger } from './utils/logger' +import { + RuntimePerformanceTelemetry, + runtimePerformanceTelemetry +} from './services/runtime-performance-telemetry' +/** 配置文件 watcher,并被动上报当前 topology 计数。 */ export class FileWatcher extends EventEmitter { private watcher: chokidar.FSWatcher | null = null private watchPath: string private isRunning = false + private readonly telemetryId = Symbol('file-watcher') - constructor(watchPath: string) { + /** + * 创建配置文件 watcher。 + * @param watchPath 根监控目录 + * @param performanceTelemetry main runtime metrics provider + */ + constructor( + watchPath: string, + private readonly performanceTelemetry: RuntimePerformanceTelemetry = runtimePerformanceTelemetry + ) { super() this.watchPath = watchPath } @@ -24,8 +38,8 @@ export class FileWatcher extends EventEmitter { * 启动文件监控 */ start(): void { - if (this.isRunning) { - logger.warn('文件监控已在运行') + if (this.watcher) { + logger.warn('文件监控已在启动或运行') return } @@ -46,16 +60,26 @@ export class FileWatcher extends EventEmitter { } }) + const activeWatcher = this.watcher + // 设置事件监听器 - this.setupEventListeners() + this.setupEventListeners(activeWatcher) // 启动监控 - this.watcher.on('ready', () => { + activeWatcher.on('ready', () => { + if (this.watcher !== activeWatcher) { + return + } this.isRunning = true + this.performanceTelemetry.markFileWatcherActive(this.telemetryId) + this.refreshRuntimeMetrics() logger.info(`文件监控已启动: ${this.watchPath}`) }) - this.watcher.on('error', (error) => { + activeWatcher.on('error', (error) => { + if (this.watcher !== activeWatcher) { + return + } logger.error('文件监控错误:', error) this.emit('error', error) }) @@ -69,11 +93,10 @@ export class FileWatcher extends EventEmitter { /** * 设置事件监听器 */ - private setupEventListeners(): void { - if (!this.watcher) return - + private setupEventListeners(watcher: chokidar.FSWatcher): void { // 文件添加 - this.watcher.on('add', (path) => { + watcher.on('add', (path) => { + if (this.watcher !== watcher) return if (this.isConfigFile(path)) { const event: ConfigChangeEvent = { type: 'added', @@ -86,7 +109,8 @@ export class FileWatcher extends EventEmitter { }) // 文件修改 - this.watcher.on('change', (path) => { + watcher.on('change', (path) => { + if (this.watcher !== watcher) return if (this.isConfigFile(path)) { const event: ConfigChangeEvent = { type: 'changed', @@ -99,7 +123,8 @@ export class FileWatcher extends EventEmitter { }) // 文件删除 - this.watcher.on('unlink', (path) => { + watcher.on('unlink', (path) => { + if (this.watcher !== watcher) return if (this.isConfigFile(path)) { const event: ConfigChangeEvent = { type: 'deleted', @@ -112,18 +137,48 @@ export class FileWatcher extends EventEmitter { }) // 目录添加 - this.watcher.on('addDir', (path) => { + watcher.on('addDir', (path) => { + if (this.watcher !== watcher) return logger.debug('目录已添加:', path) this.emit('directory-added', path) + this.refreshRuntimeMetrics() }) // 目录删除 - this.watcher.on('unlinkDir', (path) => { + watcher.on('unlinkDir', (path) => { + if (this.watcher !== watcher) return logger.debug('目录已删除:', path) this.emit('directory-deleted', path) + this.refreshRuntimeMetrics() }) } + /** + * 从 chokidar `getWatched()` 刷新 watcher topology 指标。 + * @description 采集失败只记录 warning 并保留上次值,绝不影响 watcher 事件语义。 + */ + private refreshRuntimeMetrics(): void { + if (!this.watcher || !this.isRunning) { + return + } + + try { + const watched = this.watcher.getWatched() + const watchedDirectories = Object.keys(watched) + const watchedEntryCount = watchedDirectories.reduce( + (total, directory) => total + (Array.isArray(watched[directory]) ? watched[directory].length : 0), + 0 + ) + this.performanceTelemetry.updateFileWatcher( + this.telemetryId, + watchedDirectories.length, + watchedEntryCount + ) + } catch (error) { + logger.warn('读取文件监控性能指标失败,保留上次采样值:', error) + } + } + /** * 判断是否为配置文件 */ @@ -171,14 +226,19 @@ export class FileWatcher extends EventEmitter { * 停止文件监控 */ stop(): void { - if (!this.isRunning || !this.watcher) { + const watcher = this.watcher + this.watcher = null + this.isRunning = false + this.performanceTelemetry.removeFileWatcher(this.telemetryId) + + if (!watcher) { return } try { - this.watcher.close() - this.watcher = null - this.isRunning = false + void watcher.close().catch((error) => { + logger.error('异步停止文件监控失败:', error) + }) logger.info('文件监控已停止') } catch (error) { logger.error('停止文件监控失败:', error) @@ -303,4 +363,4 @@ export class FileWatcher extends EventEmitter { this.removeAllListeners() logger.info('文件监控器已销毁') } -} \ No newline at end of file +} diff --git a/src/main/index.ts b/src/main/index.ts index a3a2b4c..8e45242 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -21,6 +21,25 @@ import { logger, LogLevel } from './utils/logger' import { updateService } from './services/update-service'; import { pathManager } from './utils/path-manager' +/** + * 单实例锁:CCB 只允许一个进程运行。 + * 二次启动的进程拿不到锁直接退出;首个进程在 second-instance 中聚焦已有窗口。 + */ +const gotSingleInstanceLock = app.requestSingleInstanceLock() +if (!gotSingleInstanceLock) { + app.quit() +} + +/** + * Windows 应用身份(必须在 app ready 前设置): + * - AUMID 与 electron-builder 快捷方式一致,系统通知显示 "CCB" 而非原始 ID; + * - app.name 提前设置,避免内部路径/通知在初始化早期使用默认名。 + */ +if (process.platform === 'win32') { + app.setAppUserModelId(APP_INFO.APP_ID) +} +app.name = APP_INFO.FULL_NAME + /** * 主窗口管理器 */ @@ -31,6 +50,8 @@ class CCBApp { private taskScheduler: TaskScheduler private ruleEngine: typeof ruleEngineService // 添加规则引擎属性 private enableDevTools: boolean // 是否启用开发者工具 + private cleanupPromise: Promise | null = null + private cleanupCompleted = false constructor() { this.windowManager = new WindowManager() @@ -57,6 +78,28 @@ class CCBApp { * 设置应用事件监听 */ private setupAppEvents(): void { + // 二次启动:不新建进程,恢复并聚焦已有主窗口,并给出明确提示 + app.on('second-instance', () => { + const mainWindow = this.windowManager.getMainWindow() + if (mainWindow) { + if (mainWindow.isMinimized()) { + mainWindow.restore() + } + if (!mainWindow.isVisible()) { + mainWindow.show() + } + mainWindow.focus() + } + try { + new Notification({ + title: APP_INFO.FULL_NAME, + body: '应用已在运行,已为您切换到现有窗口。' + }).show() + } catch (error) { + logger.warn('单实例提示通知发送失败:', error) + } + }) + app.whenReady().then(() => { this.onReady() }) @@ -78,13 +121,27 @@ class CCBApp { } }) - app.on('before-quit', async () => { + app.on('before-quit', (event) => { + if (this.cleanupCompleted) { + return + } + + // Electron 不会等待 async event listener,必须阻止本次退出并在清理完成后重新触发。 + event.preventDefault() + if (this.cleanupPromise) { + return + } + // 允许真正退出 const mainWindow = this.windowManager.getMainWindow() if (mainWindow) { mainWindow.removeAllListeners('close') } - await this.cleanup() + + this.cleanupPromise = this.cleanup().finally(() => { + this.cleanupCompleted = true + app.quit() + }) }) if (process.env.NODE_ENV === 'development') { @@ -131,11 +188,8 @@ class CCBApp { const notification = new Notification({ title, body, - icon: iconPath || undefined, - // Windows 系统需要通过 toastXml 设置 appUserModelId 来显示正确的应用名称 - ...(process.platform === 'win32' && { - appUserModelId: APP_INFO.FULL_NAME - }) + icon: iconPath || undefined + // AUMID 已在进程级通过 app.setAppUserModelID 统一设置,通知处不再覆盖 }) notification.show() return notification @@ -164,8 +218,7 @@ class CCBApp { */ private async onReady(): Promise { try { - // 设置应用名称 - app.name = APP_INFO.FULL_NAME + // app.name 已在模块加载阶段提前设置(通知/早期路径依赖它) logger.info(`应用启动: ${APP_INFO.FULL_NAME} v${APP_INFO.VERSION}`) logger.info(`进程: ${process.pid}, 平台: ${process.platform}, 版本: ${process.versions.electron}`) @@ -403,10 +456,7 @@ class CCBApp { new Notification({ title: '缓存清理', body: '缓存已成功清理', - icon: iconPath || undefined, - ...(process.platform === 'win32' && { - appUserModelId: APP_INFO.FULL_NAME - }) + icon: iconPath || undefined }).show() } catch (error) { logger.error('清理缓存失败:', error) @@ -508,8 +558,8 @@ if (isDebugMode) { logger.info('调试模式已启用(-debug)') } -// 创建应用实例 -const ccbApp = new CCBApp() +// 创建应用实例(仅单实例锁持有进程进入完整启动流程,二次启动进程已在上文退出) +const ccbApp = gotSingleInstanceLock ? new CCBApp() : null // 处理未捕获的异常 process.on('uncaughtException', (error) => { diff --git a/src/main/ipc-handlers.ts b/src/main/ipc-handlers.ts index e428549..021bf92 100644 --- a/src/main/ipc-handlers.ts +++ b/src/main/ipc-handlers.ts @@ -24,6 +24,14 @@ import { agentsManagementService } from './services/agents-management-service' import { skillsManagementService } from './services/skills-management-service' import { environmentCheckService } from './services/environment-check-service' import { terminalManagementService } from './services/terminal-management-service' +import { toolRegistryService } from './services/tool-registry-service' +import { registryUpdateService } from './services/registry-update-service' +import { createTemplateCloudService } from './services/template-cloud-service' +import { performanceSnapshotService } from './services/performance-snapshot-service' +import { toolArtifactDiscoveryService } from './services/tool-artifact-discovery-service' +import { toolArtifactManagementService } from './services/tool-artifact-management-service' +import { toolConfigSetService } from './services/tool-config-set-service' +import { createArtifactTemplateService } from './services/artifact-template-service' import { ensureAllowedUrl, ensurePathWithinBase, @@ -35,6 +43,8 @@ import { ensureExternalUrl } from './utils/ssrf-guard' // 服务实例 const configService = new ConfigService() const settingsService = new SettingsService() +const artifactTemplateService = createArtifactTemplateService(settingsService) +const templateCloudService = createTemplateCloudService(artifactTemplateService) // 导出 configService 供其他模块使用 export { configService, settingsService, managedModeService } @@ -98,10 +108,105 @@ export function setupIpcHandlers(): void { setupSkillsHandlers() setupEnvironmentHandlers() setupTerminalHandlers() + setupToolRegistryHandlers() logger.info('IPC 处理器设置完成') } +/** + * 工具规则库 IPC handlers + * @description renderer 不能提供 URL/hash;install 只消费 main 缓存的 verified manifest。 + */ +function setupToolRegistryHandlers(): void { + ipcMain.handle('toolRegistry:getSnapshot', createSimpleHandler(() => toolRegistryService.getSnapshot())) + ipcMain.handle('toolRegistry:getTool', createSimpleHandler((toolId: string) => toolRegistryService.getTool(toolId))) + ipcMain.handle('toolRegistry:listArtifactTemplates', createSimpleHandler(() => + artifactTemplateService.listArtifactTemplates() + )) + ipcMain.handle('toolRegistry:resolveArtifactTemplate', createSimpleHandler((toolId: string, artifactId: string) => + artifactTemplateService.resolveArtifactTemplate(toolId, artifactId) + )) + ipcMain.handle('toolRegistry:saveArtifactTemplateOverride', createSimpleHandler(( + toolId: string, + artifactId: string, + content: string + ) => artifactTemplateService.saveArtifactTemplateOverride(toolId, artifactId, content))) + ipcMain.handle('toolRegistry:removeArtifactTemplateOverride', createSimpleHandler(( + toolId: string, + artifactId: string + ) => artifactTemplateService.removeArtifactTemplateOverride(toolId, artifactId))) + ipcMain.handle('toolRegistry:detectTools', createSimpleHandler(() => toolArtifactDiscoveryService.detectTools())) + ipcMain.handle('toolRegistry:discoverArtifacts', createSimpleHandler((toolId: string) => + toolArtifactDiscoveryService.discoverArtifacts(toolId) + )) + ipcMain.handle('toolRegistry:readArtifact', createSimpleHandler(( + toolId: string, + artifactId: string, + requestedPath: string + ) => toolArtifactDiscoveryService.readArtifact(toolId, artifactId, requestedPath))) + ipcMain.handle('toolRegistry:validateArtifact', createSimpleHandler(( + toolId: string, + artifactId: string, + requestedPath: string, + content: string + ) => toolArtifactManagementService.validateArtifact(toolId, artifactId, requestedPath, content))) + ipcMain.handle('toolRegistry:editArtifact', createSimpleHandler(( + toolId: string, + artifactId: string, + requestedPath: string, + content: string + ) => toolArtifactManagementService.editArtifact(toolId, artifactId, requestedPath, content))) + ipcMain.handle('toolRegistry:createArtifactBackup', createSimpleHandler(( + toolId: string, + artifactId: string, + requestedPath: string + ) => toolArtifactManagementService.createBackup(toolId, artifactId, requestedPath))) + ipcMain.handle('toolRegistry:listArtifactBackups', createSimpleHandler(( + toolId: string, + artifactId: string, + requestedPath: string + ) => toolArtifactManagementService.listBackups(toolId, artifactId, requestedPath))) + ipcMain.handle('toolRegistry:restoreArtifactBackup', createSimpleHandler((backupId: string) => + toolArtifactManagementService.restoreBackup(backupId) + )) + ipcMain.handle('toolRegistry:listConfigSets', createSimpleHandler((toolId: string) => + toolConfigSetService.listConfigSets(toolId) + )) + ipcMain.handle('toolRegistry:createConfigSet', createSimpleHandler((toolId: string, name: string) => + toolConfigSetService.createConfigSet(toolId, name) + )) + ipcMain.handle('toolRegistry:readConfigSet', createSimpleHandler((toolId: string, setId: string) => + toolConfigSetService.readConfigSet(toolId, setId) + )) + ipcMain.handle('toolRegistry:saveConfigSetContent', createSimpleHandler(( + toolId: string, + setId: string, + files: Array<{ artifactId: string; content: string }> + ) => toolConfigSetService.saveConfigSetContent(toolId, setId, files))) + ipcMain.handle('toolRegistry:activateConfigSet', createSimpleHandler((toolId: string, setId: string) => + toolConfigSetService.activateConfigSet(toolId, setId) + )) + ipcMain.handle('toolRegistry:deleteConfigSet', createSimpleHandler((toolId: string, setId: string) => + toolConfigSetService.deleteConfigSet(toolId, setId) + )) + ipcMain.handle('toolRegistry:getUpdateStatus', createSimpleHandler(() => registryUpdateService.getStatus())) + ipcMain.handle('toolRegistry:checkForUpdates', createSimpleHandler(() => registryUpdateService.checkForUpdates(app.getVersion()))) + ipcMain.handle('toolRegistry:installAvailableUpdate', createSimpleHandler(() => + registryUpdateService.installAvailableUpdate(app.getVersion()) + )) + ipcMain.handle('toolRegistry:rollback', createSimpleHandler(() => registryUpdateService.rollback())) + ipcMain.handle('toolRegistry:listCloudTemplates', createSimpleHandler(() => + templateCloudService.listTemplates(app.getVersion()) + )) + ipcMain.handle('toolRegistry:importCloudTemplate', createSimpleHandler((templateId: string, nameOverride?: string) => + templateCloudService.importTemplate(templateId, app.getVersion(), nameOverride ? { name: nameOverride } : undefined) + )) + ipcMain.handle('performance:capture', createSimpleHandler(() => performanceSnapshotService.capture())) + ipcMain.handle('performance:exportSnapshot', createSimpleHandler((rendererTimings?: unknown) => + performanceSnapshotService.exportSnapshot(rendererTimings) + )) +} + /** * 配置管理相关的 IPC 处理器 */ diff --git a/src/main/services/agents-management-service.ts b/src/main/services/agents-management-service.ts index 5cd2688..47fd814 100644 --- a/src/main/services/agents-management-service.ts +++ b/src/main/services/agents-management-service.ts @@ -19,7 +19,7 @@ import type { AgentFormData, AgentImportOptions } from '@shared/types/agents' -import { ensureSafePathSegment } from '../utils/path-security' +import { ensurePathWithinBase, ensureSafePathSegment } from '../utils/path-security' /** * Agent管理服务类 @@ -248,8 +248,8 @@ class AgentsManagementService { await this.initializeAgentsDir() // 生成文件名(使用name的slug形式) - const fileName = `${this.slugify(formData.name) }.md` - const filePath = path.join(this.agentsDir, fileName) + const fileName = this.toSafeFileName(formData.name) + const filePath = ensurePathWithinBase(path.join(this.agentsDir, fileName), this.agentsDir, 'Agent 文件路径') // 检查文件是否已存在 // 注意:独立捕获 fs.access 的 ENOENT,避免与“已存在”判断共用 catch 导致同名 Agent 被静默覆盖。 @@ -321,8 +321,8 @@ class AgentsManagementService { } // 生成目标文件名 - const fileName = `${this.slugify(metadata.name) }.md` - const targetPath = path.join(this.agentsDir, fileName) + const fileName = this.toSafeFileName(metadata.name) + const targetPath = ensurePathWithinBase(path.join(this.agentsDir, fileName), this.agentsDir, 'Agent 文件路径') // 检查目标文件是否已存在 try { @@ -364,8 +364,8 @@ class AgentsManagementService { throw new Error('Agent文件缺少必填的description字段') } - const fileName = `${this.slugify(metadata.name) }.md` - const targetPath = path.join(this.agentsDir, fileName) + const fileName = this.toSafeFileName(metadata.name) + const targetPath = ensurePathWithinBase(path.join(this.agentsDir, fileName), this.agentsDir, 'Agent 文件路径') try { await fs.access(targetPath) @@ -492,6 +492,19 @@ class AgentsManagementService { .replace(/^-+/, '') // 移除前导连字符 .replace(/-+$/, '') // 移除尾部连字符 } + + /** + * 将 Agent 名称转换为受控 .md 文件名 + * @description slug 已限定为 [\w-],这里再做显式闭集断言(含拒绝空 slug), + * 保证 path.join 的动态片段不可能包含分隔符或 ".."。 + */ + private toSafeFileName(name: string): string { + const slug = this.slugify(name) + if (!/^[\w-]+$/.test(slug)) { + throw new Error('Agent 名称无法转换为安全文件名(名称为空或包含非法字符)') + } + return `${slug}.md` + } } // 导出单例 diff --git a/src/main/services/artifact-template-service.ts b/src/main/services/artifact-template-service.ts new file mode 100644 index 0000000..5ff8a47 --- /dev/null +++ b/src/main/services/artifact-template-service.ts @@ -0,0 +1,274 @@ +/** + * @file src/main/services/artifact-template-service.ts + * @description 管理 artifact-specific template catalog、ownership resolution 与用户本地 override。 + */ + +import { + createArtifactTemplateEntry, + createArtifactTemplateKey, + validateArtifactTemplateOverrides +} from '@shared/config-template' +import type { + ArtifactTemplateEntry, + ConfigArtifactDefinition, + ToolDefinition, + ToolRegistrySnapshot +} from '@shared/tool-registry' +import type { AppSettings, SettingsSaveOptions, SettingsTab } from '@shared/types/settings' +import type { SettingsService } from './settings-service' +import { + toolArtifactCodecService, + type ToolArtifactCodecService +} from './tool-artifact-codec-service' +import { toolRegistryService } from './tool-registry-service' + +const ARTIFACT_TEMPLATE_MAX_BYTES = 64 * 1024 + +/** Artifact template service 所需的 registry contract。 */ +interface ArtifactTemplateRegistryService { + getSnapshot(): Promise + getEmbeddedTool(toolId: string): ToolDefinition | undefined +} + +/** Artifact template service 所需的 settings contract。 */ +interface ArtifactTemplateSettingsService { + loadSettings(): Promise + saveSettings(tab: SettingsTab, data: Partial, options?: SettingsSaveOptions): Promise +} + +/** Artifact template service dependency overrides。 */ +export interface ArtifactTemplateServiceOptions { + registryService?: ArtifactTemplateRegistryService + settingsService: ArtifactTemplateSettingsService + codecService?: Pick +} + +/** 解析后的 effective artifact template definition。 */ +interface ResolvedTemplateDefinition { + tool: ToolDefinition + artifact: ConfigArtifactDefinition + embeddedTemplate?: string + registryTemplate?: string +} + +/** + * Artifact-specific template application service。 + * @description 固定执行 USER_OVERRIDE > REGISTRY > EMBEDDED,并串行化 override mutation 防止并发丢失更新。 + */ +export class ArtifactTemplateService { + private readonly registryService: ArtifactTemplateRegistryService + private readonly settingsService: ArtifactTemplateSettingsService + private readonly codecService: Pick + private mutationQueue: Promise = Promise.resolve() + + constructor(options: ArtifactTemplateServiceOptions) { + this.registryService = options.registryService ?? toolRegistryService + this.settingsService = options.settingsService + this.codecService = options.codecService ?? toolArtifactCodecService + } + + /** + * 列出 effective registry 或 embedded baseline 中声明 defaultTemplate 的全部 artifact。 + * @description effective registry 移除 template 时保留 embedded fallback,避免既有 user override 孤儿化。 + * @returns 按 toolId/artifactId 稳定排序的 template catalog + */ + public async listArtifactTemplates(): Promise { + const [snapshot, settings] = await Promise.all([ + this.registryService.getSnapshot(), + this.settingsService.loadSettings() + ]) + const entries: ArtifactTemplateEntry[] = [] + for (const tool of snapshot.tools) { + for (const artifact of tool.artifacts) { + const definition = this.resolveDefinitionFromTool(tool, artifact) + if (definition.registryTemplate === undefined && definition.embeddedTemplate === undefined) continue + entries.push(this.createEntry(definition, settings.editor.artifactTemplateOverrides)) + } + } + return entries.sort((left, right) => left.key.localeCompare(right.key)) + } + + /** + * 解析单个 artifact 当前生效的 template 与 ownership source。 + * @param toolId stable tool identifier + * @param artifactId stable artifact identifier + */ + public async resolveArtifactTemplate(toolId: string, artifactId: string): Promise { + const definition = await this.resolveDefinition(toolId, artifactId) + const settings = await this.settingsService.loadSettings() + return this.createEntry(definition, settings.editor.artifactTemplateOverrides) + } + + /** + * 校验并保存 artifact-specific user override。 + * @description 保存完整 editor section,避免覆盖 fontSize 等无关设置字段。 + * @param toolId stable tool identifier + * @param artifactId stable artifact identifier + * @param content 用户模板原始 UTF-8 文本 + */ + public async saveArtifactTemplateOverride( + toolId: string, + artifactId: string, + content: string + ): Promise { + return this.enqueueMutation(async () => { + const definition = await this.resolveDefinition(toolId, artifactId) + this.validateTemplateContent(definition.artifact, content) + const settings = await this.settingsService.loadSettings() + const key = createArtifactTemplateKey(toolId, artifactId) + const overrides = { + ...settings.editor.artifactTemplateOverrides, + [key]: content + } + this.assertValidOverrides(overrides) + await this.settingsService.saveSettings('editor', { + editor: { + ...settings.editor, + artifactTemplateOverrides: overrides + } + }) + return this.createEntry(definition, overrides) + }) + } + + /** + * 删除 artifact-specific user override,并恢复当前 registry/embedded template。 + * @param toolId stable tool identifier + * @param artifactId stable artifact identifier + */ + public async removeArtifactTemplateOverride( + toolId: string, + artifactId: string + ): Promise { + return this.enqueueMutation(async () => { + const definition = await this.resolveDefinition(toolId, artifactId) + const settings = await this.settingsService.loadSettings() + const key = createArtifactTemplateKey(toolId, artifactId) + if (settings.editor.artifactTemplateOverrides[key] === undefined) { + return this.createEntry(definition, settings.editor.artifactTemplateOverrides) + } + const overrides = { ...settings.editor.artifactTemplateOverrides } + delete overrides[key] + this.assertValidOverrides(overrides) + await this.settingsService.saveSettings('editor', { + editor: { + ...settings.editor, + artifactTemplateOverrides: overrides + } + }) + return this.createEntry(definition, overrides) + }) + } + + /** + * 从 current effective registry 查找允许管理 template 的 artifact。 + * @param toolId stable tool identifier + * @param artifactId stable artifact identifier + */ + private async resolveDefinition(toolId: string, artifactId: string): Promise { + createArtifactTemplateKey(toolId, artifactId) + const snapshot = await this.registryService.getSnapshot() + const tool = snapshot.tools.find((candidate) => candidate.toolId === toolId) + const artifact = tool?.artifacts.find((candidate) => candidate.artifactId === artifactId) + if (!tool || !artifact) { + throw new Error(`Artifact template 不存在或未声明 defaultTemplate: ${toolId}/${artifactId}`) + } + const definition = this.resolveDefinitionFromTool(tool, artifact) + if (definition.registryTemplate === undefined && definition.embeddedTemplate === undefined) { + throw new Error(`Artifact template 不存在或未声明 defaultTemplate: ${toolId}/${artifactId}`) + } + return definition + } + + /** + * 将 effective definition 与 embedded baseline 拆分为独立 ownership layers。 + * @param tool effective tool definition + * @param artifact effective artifact definition + */ + private resolveDefinitionFromTool( + tool: ToolDefinition, + artifact: ConfigArtifactDefinition + ): ResolvedTemplateDefinition { + const embeddedArtifact = this.registryService.getEmbeddedTool(tool.toolId)?.artifacts + .find((candidate) => candidate.artifactId === artifact.artifactId) + const embeddedTemplate = embeddedArtifact?.defaultTemplate + const registryTemplate = artifact.defaultTemplate === undefined || embeddedTemplate === artifact.defaultTemplate + ? undefined + : artifact.defaultTemplate + if (embeddedTemplate !== undefined) this.validateTemplateContent(artifact, embeddedTemplate) + if (registryTemplate !== undefined) this.validateTemplateContent(artifact, registryTemplate) + return { tool, artifact, embeddedTemplate, registryTemplate } + } + + /** + * 创建包含三层来源与 effective value 的共享 catalog entry。 + * @param definition 已解析的 registry layers + * @param overrides 当前 settings override map + */ + private createEntry( + definition: ResolvedTemplateDefinition, + overrides: Record + ): ArtifactTemplateEntry { + const key = createArtifactTemplateKey(definition.tool.toolId, definition.artifact.artifactId) + return createArtifactTemplateEntry({ + key, + toolId: definition.tool.toolId, + artifactId: definition.artifact.artifactId, + toolDisplayName: definition.tool.displayName, + artifactDisplayName: definition.artifact.displayName, + format: definition.artifact.format, + embeddedTemplate: definition.embeddedTemplate, + registryTemplate: definition.registryTemplate, + userOverride: overrides[key] + }) + } + + /** + * 执行 byte bound 与可信内置 codec validation。 + * @param artifact effective artifact definition + * @param content 用户模板内容 + */ + private validateTemplateContent(artifact: ConfigArtifactDefinition, content: string): void { + if (typeof content !== 'string' || !content.trim()) { + throw new Error('Artifact template 必须为非空字符串') + } + if (content.includes('\0')) { + throw new Error('Artifact template 不能包含 NUL') + } + const byteLength = Buffer.byteLength(content, 'utf8') + if (byteLength > ARTIFACT_TEMPLATE_MAX_BYTES) { + throw new Error(`Artifact template 超过 ${ARTIFACT_TEMPLATE_MAX_BYTES} bytes`) + } + const validation = this.codecService.validate(artifact.format, content) + if (!validation.valid) { + throw new Error(`Artifact template 校验失败: ${validation.errors.join('; ')}`) + } + } + + /** + * 复用 Settings contract 校验 map 数量、key 与单项边界。 + * @param overrides 待持久化 override map + */ + private assertValidOverrides(overrides: Record): void { + const validation = validateArtifactTemplateOverrides(overrides) + if (validation !== true) throw new Error(validation) + } + + /** + * 串行执行 settings read-modify-write,避免同 service 并发覆盖。 + * @param operation 单次 mutation + */ + private enqueueMutation(operation: () => Promise): Promise { + const result = this.mutationQueue.then(operation) + this.mutationQueue = result.then(() => undefined, () => undefined) + return result + } +} + +/** + * 创建绑定指定 SettingsService 的 artifact template service。 + * @description IPC 层必须传入其共享 settings instance,避免出现独立内存快照。 + */ +export function createArtifactTemplateService(settingsService: SettingsService): ArtifactTemplateService { + return new ArtifactTemplateService({ settingsService }) +} diff --git a/src/main/services/claude-code-version-service.ts b/src/main/services/claude-code-version-service.ts index 928bfda..e0ef427 100644 --- a/src/main/services/claude-code-version-service.ts +++ b/src/main/services/claude-code-version-service.ts @@ -13,8 +13,8 @@ import { promisify } from 'util' import os from 'os' import path from 'path' import fs from 'fs' +import { net } from 'electron' import { logger } from '../utils/logger' -import axios from 'axios' const execAsync = promisify(exec) @@ -118,18 +118,25 @@ class ClaudeCodeVersionService { try { logger.info('获取Claude Code最新版本...') - // 从npm registry获取最新版本 - const response = await axios.get( + // 从npm registry获取最新版本(net.fetch 遵循系统代理设置) + const response = await net.fetch( 'https://registry.npmjs.org/@anthropic-ai/claude-code', { - timeout: 10000, headers: { - 'Accept': 'application/json' - } + 'Accept': 'application/vnd.npm.install-v1+json, application/json' + }, + signal: AbortSignal.timeout(10000) } ) + if (!response.ok) { + logger.warn(`npm registry 请求失败: HTTP ${response.status}`) + return null + } + const registryData = (await response.json()) as { + 'dist-tags'?: { latest?: string } + } - const latestVersion = response.data['dist-tags']?.latest + const latestVersion = registryData['dist-tags']?.latest if (latestVersion) { logger.info(`最新Claude Code版本: ${latestVersion}`) return latestVersion diff --git a/src/main/services/config-service.ts b/src/main/services/config-service.ts index c9b5a6c..973fdd1 100644 --- a/src/main/services/config-service.ts +++ b/src/main/services/config-service.ts @@ -5,7 +5,6 @@ import { promises as fs } from 'fs' import { join, basename, extname, dirname } from 'path' -import { v4 as uuidv4 } from 'uuid' import os from 'os' import { ConfigFile, @@ -24,6 +23,10 @@ import { ensurePathWithinBase, normalizePathForComparison } from '../utils/path-security' +import { + RuntimePerformanceTelemetry, + runtimePerformanceTelemetry +} from './runtime-performance-telemetry' /** * 备份元数据 @@ -57,7 +60,13 @@ export class ConfigService { return pathManager.claudeConfigsDir } - constructor() { + /** + * 创建配置服务。 + * @param performanceTelemetry main runtime metrics provider + */ + constructor( + private readonly performanceTelemetry: RuntimePerformanceTelemetry = runtimePerformanceTelemetry + ) { // 不再在构造函数中设置,使用 getter } @@ -165,6 +174,8 @@ export class ConfigService { async scanConfigs(): Promise { const startTime = Date.now() const configs: ConfigFile[] = [] + let filesVisited = 0 + let success = false try { // 确保 .claude 目录存在 @@ -172,6 +183,7 @@ export class ConfigService { // 扫描所有配置文件 const files = await this.getAllConfigFiles() + filesVisited = files.length logger.info(`扫描到 ${files.length} 个配置文件:`, files) for (const filePath of files) { @@ -186,11 +198,24 @@ export class ConfigService { logger.info(`最终返回 ${configs.length} 个配置文件`) logger.performance('扫描配置文件', startTime) + success = true return configs } catch (error) { logger.error('扫描配置文件失败:', error) throw error + } finally { + try { + this.performanceTelemetry.recordConfigScan({ + completedAt: new Date().toISOString(), + durationMs: Math.max(0, Date.now() - startTime), + filesVisited, + configsLoaded: configs.length, + success + }) + } catch (telemetryError) { + logger.warn('记录配置扫描性能指标失败,不影响扫描结果:', telemetryError) + } } } @@ -536,7 +561,7 @@ export class ConfigService { async createBackup(path: string): Promise { try { const resolvedPath = this.validateConfigPath(path, '备份源配置路径') - const backupId = uuidv4() + const backupId = crypto.randomUUID() const fileName = basename(resolvedPath) const timestamp = new Date().toISOString().replace(/[:.]/g, '-') const backupFileName = `${fileName}.${timestamp}.${backupId}.backup` @@ -1088,7 +1113,7 @@ export class ConfigService { } return { - id: uuidv4(), + id: crypto.randomUUID(), name: configName, path: filePath, type: configType, @@ -1272,9 +1297,10 @@ export class ConfigService { permissions: { allow: unknown[]; deny: unknown[] } } { // 所有配置文件统一使用标准的 Claude Code settings 配置模板 + // token 类占位值为空:不预填假值,由用户填入真实凭据 return { env: { - ANTHROPIC_AUTH_TOKEN: "Claude Code TokenKey", + ANTHROPIC_AUTH_TOKEN: '', ANTHROPIC_BASE_URL: "Claude Code API URL", CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: "1" }, @@ -1344,7 +1370,7 @@ export class ConfigService { // 创建配置对象(使用默认类型) const config: ConfigFile = { - id: uuidv4(), + id: crypto.randomUUID(), name: fileName.replace(/\.(json|md)$/i, ''), path: filePath, type: defaultType, diff --git a/src/main/services/managed-mode-log-rotation.service.ts b/src/main/services/managed-mode-log-rotation.service.ts index fefe2e6..bb78f6d 100644 --- a/src/main/services/managed-mode-log-rotation.service.ts +++ b/src/main/services/managed-mode-log-rotation.service.ts @@ -263,18 +263,23 @@ export class ManagedModeLogRotationService { try { const files = await fs.readdir(this.config.logDirectory) - // 过滤出日志文件(排除current文件) + // 过滤出日志文件(排除current文件;显式拒绝含 ".." 的条目作边界防御) const logFiles = files.filter(file => file.startsWith('managed-mode-') && file.endsWith('.log') && - file !== 'managed-mode-current.log' + file !== 'managed-mode-current.log' && + !file.includes('..') ) const now = Date.now() const retentionMs = this.config.retentionDays * 24 * 60 * 60 * 1000 for (const file of logFiles) { - const filepath = path.join(this.config.logDirectory, file) + const filepath = ensurePathWithinBase( + path.join(this.config.logDirectory, file), + this.config.logDirectory, + '托管模式日志文件' + ) const stats = await fs.stat(filepath) // 检查文件修改时间 @@ -322,15 +327,19 @@ export class ManagedModeLogRotationService { try { const files = await fs.readdir(this.config.logDirectory) - // 过滤日志文件 + // 过滤日志文件(readdir 条目本身不含路径分隔符,仍显式拒绝含 ".." 的条目作边界防御) const logFiles = files.filter(file => - file.startsWith('managed-mode-') && file.endsWith('.log') + file.startsWith('managed-mode-') && file.endsWith('.log') && !file.includes('..') ) const metadata: LogFileMetadata[] = [] for (const file of logFiles) { - const filepath = path.join(this.config.logDirectory, file) + const filepath = ensurePathWithinBase( + path.join(this.config.logDirectory, file), + this.config.logDirectory, + '托管模式日志文件' + ) const stats = await fs.stat(filepath) // 读取文件获取条目数 diff --git a/src/main/services/managed-mode-service.ts b/src/main/services/managed-mode-service.ts index e5475e8..0ad959d 100644 --- a/src/main/services/managed-mode-service.ts +++ b/src/main/services/managed-mode-service.ts @@ -3,13 +3,13 @@ * @description 负责管理代理服务的生命周期,包括启动、停止、配置管理等 */ -import { app } from 'electron' +import { app, net } from 'electron' import { ChildProcess } from 'child_process' import path from 'path' import fs from 'fs/promises' import os from 'os' -import axios, { type AxiosRequestConfig } from 'axios' import { EventEmitter } from 'events' +import { ensurePathWithinBase } from '../utils/path-security' import type { Request, Response, NextFunction } from 'express' import type { ManagedModeConfig, @@ -17,12 +17,24 @@ import type { ApiProvider, EnvCommand } from '@shared/types/managed-mode' +import { + postUpstream, + readBodyStream, + UpstreamHttpError, + type UpstreamResponse +} from '../utils/upstream-http-client' import { managedModeLogRotationService } from './managed-mode-log-rotation.service' import { ManagedModeConfigStore } from './managed-mode-config-store' import { logger } from '../utils/logger' +import { pathManager } from '../utils/path-manager' const managedModeLogger = logger.child('ManagedModeService') +/** 上游非 2xx 错误体读取上限(防护恶意/异常上游返回超大错误响应占满内存) */ +const UPSTREAM_ERROR_BODY_MAX_BYTES = 1024 * 1024 +/** 上游非流式响应体读取上限(请求体上限为 50MB,响应上限取 64MB 冗余) */ +const UPSTREAM_RESPONSE_MAX_BYTES = 64 * 1024 * 1024 + /** * 集成模式下代理进程的实际形态 * @description 传统模式下为子进程,集成模式下为 Express http.Server,二者对外暴露不同的关闭接口 @@ -733,7 +745,11 @@ export class ManagedModeService extends EventEmitter { const backupDir = path.join(os.homedir(), '.ccb', 'backup') const timestamp = new Date().toISOString().replace(/[:.]/g, '-') const backupFileName = `settings.json.${timestamp}.backup` - const backupPath = path.join(backupDir, backupFileName) + const backupPath = ensurePathWithinBase( + path.join(backupDir, backupFileName), + backupDir, + '系统设置备份文件' + ) // 确保备份目录存在 await fs.mkdir(backupDir, { recursive: true }) @@ -773,7 +789,7 @@ export class ManagedModeService extends EventEmitter { // 查找最新的备份文件 const files = await fs.readdir(backupDir) const backupFiles = files - .filter(file => file.startsWith('settings.json.') && file.endsWith('.backup')) + .filter(file => file.startsWith('settings.json.') && file.endsWith('.backup') && !file.includes('..')) .sort((a, b) => b.localeCompare(a)) // 按时间倒序排列,最新的在前 if (backupFiles.length === 0) { @@ -782,7 +798,11 @@ export class ManagedModeService extends EventEmitter { } const latestBackup = backupFiles[0] - const backupPath = path.join(backupDir, latestBackup) + const backupPath = ensurePathWithinBase( + path.join(backupDir, latestBackup), + backupDir, + '系统设置备份文件' + ) // 读取备份内容 const backupContent = await fs.readFile(backupPath, 'utf8') @@ -919,7 +939,7 @@ export class ManagedModeService extends EventEmitter { if (!this.config) return const managedConfig = this.config - const configDir = path.join(os.homedir(), '.ccb', 'claude-configs') + const configDir = pathManager.claudeConfigsDir // 检查目录是否存在 try { @@ -931,14 +951,18 @@ export class ManagedModeService extends EventEmitter { // 读取配置目录中的所有文件 const files = await fs.readdir(configDir) - const configFiles = files.filter(file => file.endsWith('.json') && file !== 'settings.json') + const configFiles = files.filter(file => file.endsWith('.json') && file !== 'settings.json' && !file.includes('..')) const newProviders: ApiProvider[] = [] const currentProviderId = managedConfig.currentProvider for (const file of configFiles) { try { - const configPath = path.join(configDir, file) + const configPath = ensurePathWithinBase( + path.join(configDir, file), + configDir, + '配置文件路径' + ) const content = await fs.readFile(configPath, 'utf-8') const rawConfig = JSON.parse(content) as Record @@ -973,7 +997,11 @@ export class ManagedModeService extends EventEmitter { // 读取.meta文件获取显示名称 let displayName = configName // 默认使用文件名 try { - const metaPath = path.join(configDir, `${file}.meta`) + const metaPath = ensurePathWithinBase( + path.join(configDir, `${file}.meta`), + configDir, + '配置元数据文件路径' + ) const metaContent = await fs.readFile(metaPath, 'utf-8') const metaData = JSON.parse(metaContent) as Record if (typeof metaData.name === 'string') { @@ -1133,10 +1161,10 @@ export class ManagedModeService extends EventEmitter { */ private async checkPortInUse(port: number): Promise { try { - const response = await axios.get(`http://127.0.0.1:${port}/health`, { - timeout: 1000 + const response = await net.fetch(`http://127.0.0.1:${port}/health`, { + signal: AbortSignal.timeout(1000) }) - return response.status === 200 + return response.ok } catch { return false } @@ -1221,10 +1249,16 @@ export class ManagedModeService extends EventEmitter { managedModeLogger.debug(`开始执行健康检查,端口: ${port}`) - axios.get(`http://127.0.0.1:${port}/health`, { - timeout: 3000 + net.fetch(`http://127.0.0.1:${port}/health`, { + signal: AbortSignal.timeout(3000) + }) + .then(async (response) => { + if (!response.ok) { + throw new Error(`健康检查返回 HTTP ${response.status}`) + } + return (await response.json()) as { status?: string } }) - .then(response => { + .then((data) => { managedModeLogger.debug('健康检查成功,准备调度下次检查') // 健康检查成功 this.consecutiveSuccessCount++ @@ -1247,7 +1281,7 @@ export class ManagedModeService extends EventEmitter { message: `健康检查通过 (连续${this.consecutiveSuccessCount}次成功,当前间隔: ${currentLevel.label})`, source: 'managed-mode-service', data: { - status: response.data.status, + status: data.status, port, uptime: this.startTime ? Date.now() - this.startTime : 0, consecutiveSuccessCount: this.consecutiveSuccessCount, @@ -1419,7 +1453,6 @@ export class ManagedModeService extends EventEmitter { // 注:不启用 CORS —— 托管代理仅服务本机 Claude CLI,CLI 不走浏览器 CORS; // 全开 CORS 反而会让本机恶意网页在 token 泄露后能直接调用上游 API(安全收紧)。 const express = await import('express') - const { HttpsProxyAgent } = await import('https-proxy-agent') const expressApp = express.default() expressApp.use(express.default.json({ limit: '50mb' })) @@ -1479,7 +1512,7 @@ export class ManagedModeService extends EventEmitter { const requestId = `req_${Date.now()}_${Math.random().toString(36).substring(7)}` const requestBody = (req.body ?? {}) as MessagesRequestBody const isStreamRequest = requestBody.stream === true - let axiosConfig: AxiosRequestConfig | undefined // 在外部声明,以便在catch块中使用 + let upstreamUrl = '' // 在外部声明,以便在catch块中使用 try { // 获取当前服务提供商配置 @@ -1521,9 +1554,9 @@ export class ManagedModeService extends EventEmitter { // 2. 移除需要清理的头(避免冲突和安全问题) const headersToRemove = [ - 'host', // 会被axios根据目标URL自动设置 + 'host', // 由上游 HTTP 客户端根据目标 URL 自动设置 'connection', // 连接管理头,由HTTP客户端处理 - 'content-length', // 会被axios根据body自动计算 + 'content-length', // 由 upstream-http-client 根据序列化 body 自动计算 'transfer-encoding', // 传输编码,由HTTP客户端处理 'authorization' // 原始授权头(后续会替换为x-api-key) ] @@ -1539,24 +1572,13 @@ export class ManagedModeService extends EventEmitter { forwardedHeaders['anthropic-version'] = (Array.isArray(req.headers['anthropic-version']) ? req.headers['anthropic-version'][0] : req.headers['anthropic-version']) || '2023-06-01' forwardedHeaders['x-api-key'] = currentProvider.apiKey // 替换为上游API密钥 - // 构建axios配置 - axiosConfig = { - method: 'POST', - url: `${currentProvider.apiBaseUrl}/v1/messages`, - headers: forwardedHeaders, - data: req.body, - timeout: 120000 // 2分钟超时 - } as AxiosRequestConfig - - // 如果是流式请求,设置responseType为stream - if (isStreamRequest) { - axiosConfig.responseType = 'stream' - } + // 构建上游转发配置(Node http/https 原生转发,见 upstream-http-client) + upstreamUrl = `${currentProvider.apiBaseUrl}/v1/messages` + const proxyUrl = this.config?.networkProxy?.enabled + ? `http://${this.config.networkProxy.host}:${this.config.networkProxy.port}` + : undefined - // 如果启用了网络代理 - if (this.config?.networkProxy?.enabled) { - const proxyUrl = `http://${this.config.networkProxy.host}:${this.config.networkProxy.port}` - axiosConfig.httpsAgent = new HttpsProxyAgent(proxyUrl) + if (proxyUrl) { managedModeLogger.info(`使用网络代理: ${proxyUrl}`) } @@ -1576,12 +1598,12 @@ export class ManagedModeService extends EventEmitter { message: `请求 ${currentProvider.name}${isStreamRequest ? ' (流式)' : ''}`, provider: currentProvider.name, model: requestBody.model, - url: axiosConfig.url, + url: upstreamUrl, method: 'POST', statusCode: 0, data: { method: 'POST', - url: axiosConfig.url, + url: upstreamUrl, provider: currentProvider.name, stream: isStreamRequest, headers: sanitizedHeaders, // 包含完整的转发请求头(已脱敏) @@ -1598,7 +1620,7 @@ export class ManagedModeService extends EventEmitter { this.emit('log', requestLog) managedModeLogger.debug('[托管代理] 转发请求到上游', { provider: currentProvider.name, - url: axiosConfig.url, + url: upstreamUrl, model: requestBody.model, stream: isStreamRequest, forwardedHeadersCount: Object.keys(forwardedHeaders).length @@ -1606,13 +1628,32 @@ export class ManagedModeService extends EventEmitter { } // 转发请求到上游 API - if (!axiosConfig) { - throw new Error('请求配置未初始化,无法转发到上游 API') + const upstream: UpstreamResponse = await postUpstream({ + url: upstreamUrl, + headers: forwardedHeaders, + body: req.body, + timeoutMs: 120000, // 2分钟超时(响应头返回前) + proxyUrl + }) + + // 上游非 2xx:读取错误体后抛出,对齐 axios 非 2xx 抛错语义,交由统一 catch 转发 + if (upstream.status >= 400) { + const errorRaw = await readBodyStream(upstream.stream, UPSTREAM_ERROR_BODY_MAX_BYTES) + let errorData: unknown = errorRaw.toString('utf8') + try { + errorData = JSON.parse(errorRaw.toString('utf8')) + } catch { + // 非 JSON 错误体原样转发 + } + throw new UpstreamHttpError({ + status: upstream.status, + headers: upstream.headers, + data: errorData + }) } - const response = await axios(axiosConfig) // 处理流式响应 - if (isStreamRequest && response.data) { + if (isStreamRequest && upstream.stream) { // 设置SSE响应头 res.setHeader('Content-Type', 'text/event-stream') res.setHeader('Cache-Control', 'no-cache') @@ -1620,10 +1661,10 @@ export class ManagedModeService extends EventEmitter { res.setHeader('X-Accel-Buffering', 'no') // 禁用nginx缓冲 // 将上游流转发给客户端 - response.data.pipe(res) + upstream.stream.pipe(res) // 处理流错误 - response.data.on('error', (error: unknown) => { + upstream.stream.on('error', (error: unknown) => { managedModeLogger.error('[托管代理] 上游流错误', error) if (!res.headersSent) { res.status(500).end() @@ -1633,7 +1674,7 @@ export class ManagedModeService extends EventEmitter { }) // 流结束时记录日志 - response.data.on('end', () => { + upstream.stream.on('end', () => { if (this.config?.logging?.enabled) { const endTime = Date.now() const duration = endTime - new Date(requestTime).getTime() @@ -1643,16 +1684,16 @@ export class ManagedModeService extends EventEmitter { type: 'response' as const, message: '流式响应完成', provider: currentProvider.name, - statusCode: response.status, + statusCode: upstream.status, data: { method: 'POST', - url: axiosConfig?.url, - statusCode: response.status, + url: upstreamUrl, + statusCode: upstream.status, duration, stream: true, headers: { - 'content-type': response.headers['content-type'], - 'x-request-id': response.headers['x-request-id'] + 'content-type': upstream.headers['content-type'], + 'x-request-id': upstream.headers['x-request-id'] } } } @@ -1664,60 +1705,70 @@ export class ManagedModeService extends EventEmitter { return } - // 处理非流式响应 + // 处理非流式响应:读取并解析上游 JSON 响应体(受大小限制保护) + const rawBody = await readBodyStream(upstream.stream, UPSTREAM_RESPONSE_MAX_BYTES) + let responseData: unknown + try { + responseData = JSON.parse(rawBody.toString('utf8')) + } catch { + // 非 JSON 响应体按字符串转发(与 axios transformResponse 失败时的行为一致) + responseData = rawBody.toString('utf8') + } + if (this.config?.logging?.enabled) { const endTime = Date.now() const duration = endTime - new Date(requestTime).getTime() - const responseData = response.data as UpstreamResponseData + const typedResponseData = responseData as UpstreamResponseData const responseLog = { id: requestId, timestamp: new Date().toISOString(), type: 'response' as const, - message: `响应成功 (${response.status})`, + message: `响应成功 (${upstream.status})`, provider: currentProvider.name, - statusCode: response.status, - hasContent: !!response.data, + statusCode: upstream.status, + hasContent: !!responseData, data: { method: 'POST', - url: axiosConfig.url, - statusCode: response.status, + url: upstreamUrl, + statusCode: upstream.status, duration, stream: false, headers: { - 'content-type': response.headers['content-type'], - 'x-request-id': response.headers['x-request-id'] + 'content-type': upstream.headers['content-type'], + 'x-request-id': upstream.headers['x-request-id'] }, - body: response.data ? { - id: responseData.id, - type: responseData.type, - role: responseData.role, - model: responseData.model, - usage: responseData.usage, - content: this.truncateContentForLog(responseData.content) // 截断后广播,避免完整上游响应扩散 + body: responseData ? { + id: typedResponseData.id, + type: typedResponseData.type, + role: typedResponseData.role, + model: typedResponseData.model, + usage: typedResponseData.usage, + content: this.truncateContentForLog(typedResponseData.content) // 截断后广播,避免完整上游响应扩散 } : undefined } } this.emit('log', responseLog) managedModeLogger.debug('[托管代理] 收到上游响应', { - status: response.status, - hasContent: !!response.data + status: upstream.status, + hasContent: !!responseData }) } // 返回上游响应 - res.status(response.status).json(response.data) + res.status(upstream.status).json(responseData) } catch (error: unknown) { managedModeLogger.error('[托管代理] 请求失败', error) // 统一提取错误信息,避免在 catch 中直接访问 any 字段 + // UpstreamHttpError 携带 response.{status,data,headers};Node 网络错误携带 code const errorMessage = error instanceof Error ? error.message : '请求失败' - const axiosError = error as { response?: { status?: number; data?: { error?: { type?: string } }; headers?: Record }; code?: string; isAxiosError?: boolean } - const statusCode = axiosError?.response?.status || 500 - const errorCode = axiosError?.code || 'unknown' - const errorResponseType = axiosError?.response?.data?.error?.type || 'unknown_error' - const errorResponseHeaders = axiosError?.response?.headers - const errorResponseData = axiosError?.response?.data + const upstreamError = error as { response?: { status?: number; data?: { error?: { type?: string } }; headers?: Record }; code?: string } + const statusCode = upstreamError?.response?.status || 500 + const errorCode = upstreamError?.code || 'unknown' + const errorResponseType = upstreamError?.response?.data?.error?.type || 'unknown_error' + const errorResponseHeaders = upstreamError?.response?.headers + const errorResponseData = upstreamError?.response?.data // 记录错误日志 const endTime = Date.now() @@ -1731,7 +1782,7 @@ export class ManagedModeService extends EventEmitter { errorType: errorCode, data: { method: 'POST', - url: axiosConfig?.url || '/v1/messages', + url: upstreamUrl || '/v1/messages', statusCode, duration, error: errorMessage, @@ -1746,15 +1797,15 @@ export class ManagedModeService extends EventEmitter { } this.emit('log', errorLog) - // 处理axios错误 - if (axiosError?.response) { + // 处理上游 HTTP 错误 + if (upstreamError?.response) { // 上游API返回错误 - const errorStatus = axiosError.response.status ?? 500 - if (axiosError.response.data && typeof axiosError.response.data === 'object' && !Buffer.isBuffer(axiosError.response.data)) { - return res.status(errorStatus).json(axiosError.response.data) + const errorStatus = upstreamError.response.status ?? 500 + if (upstreamError.response.data && typeof upstreamError.response.data === 'object' && !Buffer.isBuffer(upstreamError.response.data)) { + return res.status(errorStatus).json(upstreamError.response.data) } else { // 流式错误响应 - return res.status(errorStatus).send(axiosError.response.data) + return res.status(errorStatus).send(upstreamError.response.data) } } else if (errorCode === 'ECONNABORTED') { // 超时错误 diff --git a/src/main/services/performance-snapshot-service.ts b/src/main/services/performance-snapshot-service.ts new file mode 100644 index 0000000..f1973a7 --- /dev/null +++ b/src/main/services/performance-snapshot-service.ts @@ -0,0 +1,86 @@ +/** + * @file src/main/services/performance-snapshot-service.ts + * @description 按用户请求采集 Electron 进程性能 snapshot,并以 UTF-8 JSON 导出到本地。 + */ + +import { app } from 'electron' +import { promises as fs } from 'fs' +import path from 'path' +import { writeJsonAtomic } from '../utils/atomic-json-writer' +import { pathManager } from '../utils/path-manager' +import { + validateRendererPerformanceTimings, + type PerformanceSnapshot +} from '@shared/performance' +import { + RuntimePerformanceTelemetry, + runtimePerformanceTelemetry +} from './runtime-performance-telemetry' + +/** + * Performance snapshot service + * @description 不定时采样、不上传;只有 IPC 明确调用时才采集或导出。 + */ +export class PerformanceSnapshotService { + /** + * 创建 performance snapshot service。 + * @param performanceTelemetry 被动维护的 main runtime metrics provider + */ + constructor( + private readonly performanceTelemetry: RuntimePerformanceTelemetry = runtimePerformanceTelemetry + ) {} + + /** + * 采集当前 Electron process snapshot + * @param rendererTimingsInput 可选且不可信的 renderer timing summary;进入 snapshot 前强制校验 + * @returns 可序列化性能数据 + */ + public capture(rendererTimingsInput?: unknown): PerformanceSnapshot { + const rendererTimings = validateRendererPerformanceTimings(rendererTimingsInput) + const processes = app.getAppMetrics().map((metric) => ({ + type: metric.type, + pid: metric.pid, + cpuPercent: metric.cpu.percentCPUUsage, + workingSetKb: metric.memory.workingSetSize, + peakWorkingSetKb: metric.memory.peakWorkingSetSize, + privateBytesKb: metric.memory.privateBytes + })) + + const snapshot: PerformanceSnapshot = { + schemaVersion: 1, + capturedAt: new Date().toISOString(), + appVersion: app.getVersion(), + platform: process.platform, + arch: process.arch, + uptimeSeconds: process.uptime(), + mainMemoryUsage: process.memoryUsage(), + processes, + totalWorkingSetKb: processes.reduce((total, metric) => total + metric.workingSetKb, 0), + runtimeMetrics: this.performanceTelemetry.getSnapshot() + } + + if (rendererTimings !== undefined) { + snapshot.rendererTimings = rendererTimings + } + + return snapshot + } + + /** + * 导出当前 snapshot 到 .ccb/performance + * @param rendererTimingsInput 可选且不可信的 renderer timing summary + * @returns 导出文件绝对路径 + */ + public async exportSnapshot(rendererTimingsInput?: unknown): Promise { + const snapshot = this.capture(rendererTimingsInput) + const safeTimestamp = snapshot.capturedAt.replace(/[:.]/g, '-') + const outputDirectory = path.join(pathManager.appDataDir, 'performance') + const outputPath = path.join(outputDirectory, `performance-${safeTimestamp}.json`) + await fs.mkdir(outputDirectory, { recursive: true }) + await writeJsonAtomic(outputPath, snapshot) + return outputPath + } +} + +/** 默认性能 snapshot service */ +export const performanceSnapshotService = new PerformanceSnapshotService() diff --git a/src/main/services/project-management-service.ts b/src/main/services/project-management-service.ts index 6f2b0f8..5fc3fcb 100644 --- a/src/main/services/project-management-service.ts +++ b/src/main/services/project-management-service.ts @@ -916,6 +916,7 @@ class ProjectManagementService { */ private async launchTerminalProcess(spec: TerminalLaunchSpec): Promise { await new Promise((resolve, reject) => { + // nosemgrep: javascript.lang.security.detect-child-process.detect-child-process - spec 仅由私有平台构造器生成,参数数组不会经过 shell。 const child = spawn(spec.filePath, spec.args, { cwd: spec.workingDirectory, detached: true, diff --git a/src/main/services/registry-signature-verifier.ts b/src/main/services/registry-signature-verifier.ts new file mode 100644 index 0000000..cd2afb6 --- /dev/null +++ b/src/main/services/registry-signature-verifier.ts @@ -0,0 +1,59 @@ +/** + * @file Registry detached signature verifier + * @description 使用应用内置 Ed25519 public keys 验证远程规则库的 raw UTF-8 bytes。 + */ + +import { createPublicKey, verify } from 'crypto' + +/** 应用信任的 registry publisher public key map。 */ +export type RegistryTrustedPublicKeys = Readonly> + +/** + * 读取并验证应用信任的 Ed25519 public key。 + * @param keyId manifest 声明的 pinned key identifier + * @param trustedPublicKeys 应用内置的 SPKI PEM public keys + * @returns 已解析的 Ed25519 public key + */ +export function getTrustedRegistryPublicKey( + keyId: string, + trustedPublicKeys: RegistryTrustedPublicKeys +): ReturnType { + const publicKeyPem = trustedPublicKeys[keyId] + if (!publicKeyPem) { + throw new Error(`Registry signature keyId 未受信任: ${keyId}`) + } + + try { + const publicKey = createPublicKey(publicKeyPem) + if (publicKey.asymmetricKeyType !== 'ed25519') { + throw new Error('public key 不是 Ed25519 key') + } + return publicKey + } catch (error) { + throw new Error(`Registry signature key 无效: ${error instanceof Error ? error.message : String(error)}`) + } +} + +/** + * 验证 Ed25519 detached signature。 + * @param rawBundle 下载得到且未经规范化的 bundle bytes + * @param signatureBase64 manifest 声明的标准 Base64 signature + * @param keyId manifest 声明的 pinned key identifier + * @param trustedPublicKeys 应用内置的 SPKI PEM public keys + */ +export function verifyRegistryBundleSignature( + rawBundle: Buffer, + signatureBase64: string, + keyId: string, + trustedPublicKeys: RegistryTrustedPublicKeys +): void { + const publicKey = getTrustedRegistryPublicKey(keyId, trustedPublicKeys) + const signature = Buffer.from(signatureBase64, 'base64') + if (signature.length !== 64 || signature.toString('base64') !== signatureBase64) { + throw new Error('Registry signature Base64 编码无效') + } + + if (!verify(null, rawBundle, publicKey, signature)) { + throw new Error('Registry Ed25519 signature 校验失败') + } +} diff --git a/src/main/services/registry-update-service.ts b/src/main/services/registry-update-service.ts new file mode 100644 index 0000000..a5831fd --- /dev/null +++ b/src/main/services/registry-update-service.ts @@ -0,0 +1,318 @@ +/** + * @file src/main/services/registry-update-service.ts + * @description 负责规则库 manifest 检查与用户明确批准后的 bundle 下载、校验和安装。 + */ + +import { net } from 'electron' +import type { + ToolRegistryManifest, + ToolRegistryUpdateStatus +} from '@shared/tool-registry' +import { + compareStrictSemVer, + REGISTRY_BUNDLE_MAX_BYTES, + REGISTRY_MANIFEST_MAX_BYTES, + validateToolRegistryManifest +} from '@shared/tool-registry-validator' +import { toolRegistryService, type ToolRegistryService } from './tool-registry-service' +import { + getTrustedRegistryPublicKey, + verifyRegistryBundleSignature, + type RegistryTrustedPublicKeys +} from './registry-signature-verifier' + +/** 默认 registry manifest URL */ +export const REGISTRY_MANIFEST_URL = 'https://dev.niansir.com/software/ccb/registry/manifest.json' +/** Registry 固定允许的 origin */ +export const REGISTRY_ALLOWED_ORIGINS = ['https://dev.niansir.com'] as const +/** + * Production registry publisher keys。 + * @description 正式 release 前必须由维护者注入其离线保管 private key 对应的 SPKI public key。 + */ +export const REGISTRY_TRUSTED_PUBLIC_KEYS: RegistryTrustedPublicKeys = Object.freeze({ + // Rehearsal publisher key(2026-09-04 在开发机生成,仅用于 v1.5.0 发布链 rehearsal 与 preview 模式)。 + // 公共发布前必须轮换为离线 ceremony 生成的 production key;release preflight 拒绝 rehearsal 命名 keyId 进入 production。 + 'ccb-rehearsal-2026-09': [ + '-----BEGIN PUBLIC KEY-----', + 'MCowBQYDK2VwAyEAyfS6bIe+NeVBUw+d2MzBenVO++Q+X5C2hMMMtahF+nw=', + '-----END PUBLIC KEY-----' + ].join('\n') +}) + +/** 受限文本 HTTP client contract */ +export interface RegistryHttpClient { + /** + * 获取 UTF-8 文本,调用方提供最大响应大小 + * @param url 固定或已验证 URL + * @param maxBytes 最大响应 bytes + * @returns 响应文本 + */ + getText(url: string, maxBytes: number): Promise + /** + * 获取原始 bytes,调用方提供最大响应大小。 + * @param url 固定或已验证 URL + * @param maxBytes 最大响应 bytes + */ + getBytes(url: string, maxBytes: number): Promise +} + +/** + * 流式读取 net.fetch 响应体,超过 maxBytes 立即中断下载。 + * @description 必须在读取过程中限制大小,避免把超大响应整段缓冲进内存后才拒绝。 + */ +async function readNetFetchBody(body: ReadableStream | null, maxBytes: number): Promise { + if (!body) { + return Buffer.alloc(0) + } + const chunks: Buffer[] = [] + let total = 0 + const reader = body.getReader() + for (;;) { + const { done, value } = await reader.read() + if (done) break + total += value.byteLength + if (total > maxBytes) { + await reader.cancel().catch(() => undefined) + throw new Error(`Registry 响应超过 ${maxBytes} bytes`) + } + chunks.push(Buffer.from(value)) + } + return Buffer.concat(chunks) +} + +/** + * Electron net.fetch registry HTTP client + * @description 禁止 redirect(redirect:'error',重定向即失败,避免绕过 pinned origin), + * 限制 timeout/content length;Chromium 网络栈遵循系统代理。 + */ +export class NetFetchRegistryHttpClient implements RegistryHttpClient { + /** + * 获取受大小限制的文本 + * @param url 已验证 HTTPS URL + * @param maxBytes 最大响应 bytes + * @returns UTF-8 文本 + */ + public async getText(url: string, maxBytes: number): Promise { + const response = await net.fetch(url, { + redirect: 'error', + signal: AbortSignal.timeout(15_000) + }) + if (response.status !== 200) { + throw new Error(`Registry HTTP 状态异常: ${response.status}`) + } + if (response.redirected) { + throw new Error('Registry 响应发生重定向,已拒绝') + } + const bytes = await readNetFetchBody(response.body, maxBytes) + return bytes.toString('utf8') + } + + /** + * 获取受大小限制的原始 bytes,供 detached signature 与 hash 验证。 + * @param url 已验证 HTTPS URL + * @param maxBytes 最大响应 bytes + */ + public async getBytes(url: string, maxBytes: number): Promise { + const response = await net.fetch(url, { + redirect: 'error', + signal: AbortSignal.timeout(15_000) + }) + if (response.status !== 200) { + throw new Error(`Registry HTTP 状态异常: ${response.status}`) + } + if (response.redirected) { + throw new Error('Registry 响应发生重定向,已拒绝') + } + return readNetFetchBody(response.body, maxBytes) + } +} + +/** + * Registry 更新服务 + * @description check 只缓存 verified manifest;install 不接受 renderer 提供 URL/hash。 + */ +export class RegistryUpdateService { + private readonly registryService: ToolRegistryService + private readonly httpClient: RegistryHttpClient + private readonly manifestUrl: string + private readonly allowedOrigins: string[] + private readonly trustedPublicKeys: RegistryTrustedPublicKeys + private verifiedManifest?: ToolRegistryManifest + private checkPromise?: Promise + private status: ToolRegistryUpdateStatus = { + state: 'IDLE', + embeddedVersion: '0.0.0' + } + + constructor(options?: { + registryService?: ToolRegistryService + httpClient?: RegistryHttpClient + manifestUrl?: string + allowedOrigins?: string[] + trustedPublicKeys?: RegistryTrustedPublicKeys + }) { + this.registryService = options?.registryService ?? toolRegistryService + this.httpClient = options?.httpClient ?? new NetFetchRegistryHttpClient() + this.manifestUrl = options?.manifestUrl ?? REGISTRY_MANIFEST_URL + this.allowedOrigins = options?.allowedOrigins ?? [...REGISTRY_ALLOWED_ORIGINS] + this.trustedPublicKeys = options?.trustedPublicKeys ?? REGISTRY_TRUSTED_PUBLIC_KEYS + } + + /** + * 获取当前更新状态,不触发网络请求 + * @returns 可序列化状态 snapshot + */ + public getStatus(): ToolRegistryUpdateStatus { + return { ...this.status } + } + + /** + * 检查远程 manifest + * @description 只下载小型 manifest,不自动下载或安装 bundle。 + * @returns 更新状态 + */ + public checkForUpdates(currentAppVersion: string): Promise { + if (!this.checkPromise) { + this.checkPromise = this.performUpdateCheck(currentAppVersion).finally(() => { + this.checkPromise = undefined + }) + } + return this.checkPromise + } + + /** + * 执行一次 manifest 检查 + * @param currentAppVersion 当前应用版本 + * @returns update 状态 + */ + private async performUpdateCheck(currentAppVersion: string): Promise { + const snapshot = await this.registryService.getSnapshot() + this.status = { + state: 'CHECKING_MANIFEST', + embeddedVersion: snapshot.embeddedVersion, + installedVersion: snapshot.installedVersion + } + try { + this.validatePinnedUrl(this.manifestUrl, 'Registry manifest URL') + const rawManifest = await this.httpClient.getText(this.manifestUrl, REGISTRY_MANIFEST_MAX_BYTES) + const validation = validateToolRegistryManifest(rawManifest, this.allowedOrigins) + if (!validation.success || !validation.data) { + throw new Error(`Registry manifest 无效: ${validation.errors.join('; ')}`) + } + if (compareStrictSemVer(validation.data.minimumAppVersion, currentAppVersion) > 0) { + throw new Error(`Registry manifest 要求 CCB >= ${validation.data.minimumAppVersion}`) + } + getTrustedRegistryPublicKey(validation.data.keyId, this.trustedPublicKeys) + this.verifiedManifest = validation.data + const currentVersion = snapshot.installedVersion ?? snapshot.embeddedVersion + const updateAvailable = compareStrictSemVer(validation.data.registryVersion, currentVersion) > 0 + this.status = { + state: updateAvailable ? 'UPDATE_AVAILABLE' : 'UP_TO_DATE', + embeddedVersion: snapshot.embeddedVersion, + installedVersion: snapshot.installedVersion, + availableVersion: validation.data.registryVersion, + publishedAt: validation.data.publishedAt, + releaseNotes: validation.data.releaseNotes, + lastCheckedAt: new Date().toISOString() + } + return this.getStatus() + } catch (error) { + this.verifiedManifest = undefined + this.status = { + state: 'CHECK_FAILED', + embeddedVersion: snapshot.embeddedVersion, + installedVersion: snapshot.installedVersion, + lastCheckedAt: new Date().toISOString(), + error: error instanceof Error ? error.message : String(error) + } + return this.getStatus() + } + } + + /** + * 安装最近一次检查到的可用更新 + * @description 必须由用户操作调用;没有 verified manifest 时拒绝。 + * @param currentAppVersion 当前应用版本 + * @returns 安装后的更新状态 + */ + public async installAvailableUpdate(currentAppVersion: string): Promise { + const manifest = this.verifiedManifest + if (!manifest || this.status.state !== 'UPDATE_AVAILABLE') { + throw new Error('没有经过验证且等待用户确认的规则库更新') + } + this.status = { ...this.status, state: 'DOWNLOADING', error: undefined } + try { + this.validatePinnedUrl(manifest.bundleUrl, 'Registry bundle URL') + const rawBundle = await this.httpClient.getBytes(manifest.bundleUrl, REGISTRY_BUNDLE_MAX_BYTES) + this.status = { ...this.status, state: 'VERIFYING_SIGNATURE' } + verifyRegistryBundleSignature( + rawBundle, + manifest.signature, + manifest.keyId, + this.trustedPublicKeys + ) + this.status = { ...this.status, state: 'VERIFYING_HASH' } + await this.registryService.installBundle({ + rawBytes: rawBundle, + expectedSha256: manifest.bundleSha256, + expectedSize: manifest.bundleSize, + expectedRegistryVersion: manifest.registryVersion, + expectedMinimumAppVersion: manifest.minimumAppVersion, + currentAppVersion + }) + const snapshot = await this.registryService.getSnapshot() + this.status = { + state: 'INSTALLED', + embeddedVersion: snapshot.embeddedVersion, + installedVersion: snapshot.installedVersion, + availableVersion: manifest.registryVersion, + publishedAt: manifest.publishedAt, + releaseNotes: manifest.releaseNotes, + lastCheckedAt: new Date().toISOString() + } + this.verifiedManifest = undefined + return this.getStatus() + } catch (error) { + this.status = { + ...this.status, + state: 'CHECK_FAILED', + error: error instanceof Error ? error.message : String(error) + } + throw error + } + } + + /** + * 显式回滚规则库 + * @description 恢复 last-known-good;没有历史版本时由 registry service 回退内置基线, + * 状态字段一律取回滚后的 fresh snapshot(embedded 回退时 installedVersion 为空)。 + * @returns 回滚后的状态 + */ + public async rollback(): Promise { + await this.registryService.rollback() + const snapshot = await this.registryService.getSnapshot() + this.verifiedManifest = undefined + this.status = { + state: 'ROLLED_BACK', + embeddedVersion: snapshot.embeddedVersion, + installedVersion: snapshot.installedVersion, + lastCheckedAt: new Date().toISOString() + } + return this.getStatus() + } + + /** + * 校验 URL 使用 HTTPS 且命中 pinned origin + * @param value URL 文本 + * @param label 错误标签 + */ + private validatePinnedUrl(value: string, label: string): void { + const parsedUrl = new URL(value) + if (parsedUrl.protocol !== 'https:' || !this.allowedOrigins.includes(parsedUrl.origin)) { + throw new Error(`${label} 不在 pinned HTTPS origin 中`) + } + } +} + +/** 默认 registry 更新服务单例 */ +export const registryUpdateService = new RegistryUpdateService() diff --git a/src/main/services/rule-engine.service.ts b/src/main/services/rule-engine.service.ts index f9d556c..bb4b13b 100644 --- a/src/main/services/rule-engine.service.ts +++ b/src/main/services/rule-engine.service.ts @@ -4,7 +4,6 @@ */ import * as cron from 'node-cron'; -import { v4 as uuidv4 } from 'uuid'; import { ruleStorageService } from './rule-storage.service'; import { ConfigService } from './config-service'; import { AutomationRule, RuleId, Action, SwitchConfigAction, CustomCommandAction } from '@shared/types/rules'; @@ -256,7 +255,7 @@ class RuleEngineService { const now = new Date().toISOString(); const rule: AutomationRule = { ...newRuleData, - id: uuidv4(), + id: crypto.randomUUID(), createdAt: now, updatedAt: now, }; diff --git a/src/main/services/runtime-performance-telemetry.ts b/src/main/services/runtime-performance-telemetry.ts new file mode 100644 index 0000000..cb3aa63 --- /dev/null +++ b/src/main/services/runtime-performance-telemetry.ts @@ -0,0 +1,126 @@ +/** + * @file src/main/services/runtime-performance-telemetry.ts + * @description 被动维护 watcher 与配置扫描指标;不创建 timer、不写盘、不上传。 + */ + +import type { + ConfigScanRuntimeMetric, + RuntimePerformanceMetrics +} from '@shared/performance' + +/** 单个 active watcher 的内部计数。 */ +interface FileWatcherRuntimeMetric { + watchedDirectoryCount: number + watchedEntryCount: number +} + +/** + * Main runtime performance telemetry + * @description 仅由现有生命周期事件同步更新,snapshot capture 时返回防御性只读副本。 + */ +export class RuntimePerformanceTelemetry { + private readonly fileWatchers = new Map() + private lastConfigScan: ConfigScanRuntimeMetric | null = null + + /** + * 标记 watcher 已 ready;若尚无 topology 数据则从零开始。 + * @param watcherId watcher 实例私有标识 + */ + public markFileWatcherActive(watcherId: symbol): void { + if (!this.fileWatchers.has(watcherId)) { + this.fileWatchers.set(watcherId, { + watchedDirectoryCount: 0, + watchedEntryCount: 0 + }) + } + } + + /** + * 更新 active watcher 的 topology 计数。 + * @param watcherId watcher 实例私有标识 + * @param watchedDirectoryCount 当前目录数量 + * @param watchedEntryCount 当前目录项数量 + */ + public updateFileWatcher( + watcherId: symbol, + watchedDirectoryCount: number, + watchedEntryCount: number + ): void { + this.fileWatchers.set(watcherId, { + watchedDirectoryCount: this.normalizeCount(watchedDirectoryCount), + watchedEntryCount: this.normalizeCount(watchedEntryCount) + }) + } + + /** + * 移除 stopped/destroyed watcher。 + * @param watcherId watcher 实例私有标识 + */ + public removeFileWatcher(watcherId: symbol): void { + this.fileWatchers.delete(watcherId) + } + + /** + * 记录最近一次配置扫描结果。 + * @param metric 已完成扫描的摘要 + */ + public recordConfigScan(metric: ConfigScanRuntimeMetric): void { + this.lastConfigScan = { + completedAt: metric.completedAt, + durationMs: this.normalizeDuration(metric.durationMs), + filesVisited: this.normalizeCount(metric.filesVisited), + configsLoaded: this.normalizeCount(metric.configsLoaded), + success: metric.success + } + } + + /** + * 获取聚合后的防御性副本。 + * @returns 可安全写入 PerformanceSnapshot 的运行时指标 + */ + public getSnapshot(): RuntimePerformanceMetrics { + let watchedDirectoryCount = 0 + let watchedEntryCount = 0 + for (const metric of this.fileWatchers.values()) { + watchedDirectoryCount = Math.min( + watchedDirectoryCount + metric.watchedDirectoryCount, + Number.MAX_SAFE_INTEGER + ) + watchedEntryCount = Math.min( + watchedEntryCount + metric.watchedEntryCount, + Number.MAX_SAFE_INTEGER + ) + } + + return { + activeWatcherCount: this.fileWatchers.size, + watchedDirectoryCount, + watchedEntryCount, + lastConfigScan: this.lastConfigScan ? { ...this.lastConfigScan } : null + } + } + + /** + * 将外部计数规范化为非负安全整数。 + * @param value 待规范化数值 + * @returns 非负安全整数 + */ + private normalizeCount(value: number): number { + if (!Number.isFinite(value) || value <= 0) { + return 0 + } + return Math.min(Math.floor(value), Number.MAX_SAFE_INTEGER) + } + + /** + * 将耗时规范化为非负有限数值。 + * @param value 待规范化耗时 + * @returns 非负有限耗时 + */ + private normalizeDuration(value: number): number { + return Number.isFinite(value) && value >= 0 ? value : 0 + } +} + +/** 默认 main runtime performance telemetry。 */ +export const runtimePerformanceTelemetry = new RuntimePerformanceTelemetry() diff --git a/src/main/services/settings-service.ts b/src/main/services/settings-service.ts index 55d79b7..30b9910 100644 --- a/src/main/services/settings-service.ts +++ b/src/main/services/settings-service.ts @@ -15,6 +15,8 @@ import { } from '@shared/types/settings' import { DEFAULT_NEW_CONFIG_TEMPLATE, + migrateLegacyTemplateOverride, + validateArtifactTemplateOverrides, validateNewConfigTemplate } from '@shared/config-template' import { logger } from '../utils/logger' @@ -49,7 +51,8 @@ export class SettingsService { wordWrap: false, minimap: true, lineNumbers: true, - defaultConfigTemplate: DEFAULT_NEW_CONFIG_TEMPLATE + defaultConfigTemplate: DEFAULT_NEW_CONFIG_TEMPLATE, + artifactTemplateOverrides: {} }, notifications: { enabled: true, @@ -100,6 +103,13 @@ export class SettingsService { type: 'string', validator: (value: unknown) => validateNewConfigTemplate(typeof value === 'string' ? value : String(value)) }, + { + tab: 'editor', + key: 'artifactTemplateOverrides', + required: true, + type: 'object', + validator: validateArtifactTemplateOverrides + }, // 通知设置验证 { tab: 'notifications', key: 'enabled', required: true, type: 'boolean' }, @@ -175,9 +185,26 @@ export class SettingsService { */ private mergeWithDefaults(loadedSettings: Partial): AppSettings { const defaults = this.getDefaultSettings() + const mergedEditor = { ...defaults.editor, ...loadedSettings.editor } + const loadedOverrides = loadedSettings.editor?.artifactTemplateOverrides + const safeOverrides: Record = + loadedOverrides !== undefined && validateArtifactTemplateOverrides(loadedOverrides) === true + ? loadedOverrides + : {} + const migratedOverrides = migrateLegacyTemplateOverride( + loadedSettings.editor?.defaultConfigTemplate, + safeOverrides + ) + const legacyTemplateWasMigrated = + safeOverrides['claude-code/user-settings'] === undefined && + migratedOverrides['claude-code/user-settings'] !== undefined + mergedEditor.artifactTemplateOverrides = migratedOverrides + if (legacyTemplateWasMigrated) { + mergedEditor.defaultConfigTemplate = DEFAULT_NEW_CONFIG_TEMPLATE + } return { basic: { ...defaults.basic, ...loadedSettings.basic }, - editor: { ...defaults.editor, ...loadedSettings.editor }, + editor: mergedEditor, notifications: { ...defaults.notifications, ...loadedSettings.notifications }, advanced: { ...defaults.advanced, ...loadedSettings.advanced }, window: { ...defaults.window, ...loadedSettings.window }, @@ -287,6 +314,10 @@ export class SettingsService { errors.push(`${rule.key} 必须是字符串`) } else if (rule.type === 'boolean' && typeof value !== 'boolean') { errors.push(`${rule.key} 必须是布尔值`) + } else if (rule.type === 'object' && (typeof value !== 'object' || value === null || Array.isArray(value))) { + errors.push(`${rule.key} 必须是对象`) + } else if (rule.type === 'array' && !Array.isArray(value)) { + errors.push(`${rule.key} 必须是数组`) } // 枚举值验证 diff --git a/src/main/services/statistics-service.ts b/src/main/services/statistics-service.ts index 35c0bac..919e6c1 100644 --- a/src/main/services/statistics-service.ts +++ b/src/main/services/statistics-service.ts @@ -1,6 +1,6 @@ /** - * 统计服务 - * 负责收集、存储和查询应用使用统计数据 + * @file 统计服务 + * @description 负责收集、持久化和查询应用使用统计数据,并管理自动保存生命周期。 */ import { app } from 'electron' @@ -100,6 +100,10 @@ export class StatisticsService { private saveInterval = 60000 // 保存间隔(1分钟) private saveTimer: NodeJS.Timeout | null = null private appStartTime: number = Date.now() + private readonly initializationPromise: Promise + private autoSavePromise: Promise = Promise.resolve() + private shutdownPromise: Promise | null = null + private isShuttingDown = false constructor() { const userDataPath = app.getPath('userData') @@ -107,7 +111,7 @@ export class StatisticsService { this.eventsFile = path.join(this.statsDir, 'events.json') this.summaryFile = path.join(this.statsDir, 'summary.json') - this.initialize() + this.initializationPromise = this.initialize() } /** @@ -119,13 +123,19 @@ export class StatisticsService { await fs.ensureDir(this.statsDir) // 加载已有事件 - await this.loadEvents() + const storedEvents = await this.loadEvents() + + // 合并初始化期间接收到的事件,避免异步磁盘读取覆盖内存中的新事件。 + this.events = [...storedEvents, ...this.events] + this.trimEvents() // 记录应用启动 this.recordEvent(StatEventType.APP_START) // 启动定期保存 - this.startAutoSave() + if (!this.isShuttingDown) { + this.startAutoSave() + } statisticsLogger.info('初始化完成') } catch (error) { @@ -136,22 +146,24 @@ export class StatisticsService { /** * 加载已有事件 */ - private async loadEvents(): Promise { + private async loadEvents(): Promise { try { if (await fs.pathExists(this.eventsFile)) { const data = await fs.readJSON(this.eventsFile) - this.events = Array.isArray(data) ? data : [] + const events = Array.isArray(data) ? data as StatEvent[] : [] // 清理过期事件(保留最近90天) const cutoffTime = Date.now() - 90 * 24 * 60 * 60 * 1000 - this.events = this.events.filter(e => e.timestamp > cutoffTime) + const retainedEvents = events.filter(e => e.timestamp > cutoffTime) - statisticsLogger.info(`加载了 ${this.events.length} 个历史事件`) + statisticsLogger.info(`加载了 ${retainedEvents.length} 个历史事件`) + return retainedEvents } } catch (error) { statisticsLogger.error('加载事件失败', error) - this.events = [] } + + return [] } /** @@ -174,9 +186,23 @@ export class StatisticsService { } this.saveTimer = setInterval(() => { - this.saveEvents() - this.generateSummary() + this.queueAutoSave() }, this.saveInterval) + this.saveTimer.unref() + } + + /** + * 将自动保存任务串行加入队列,防止慢磁盘上出现重叠写入。 + */ + private queueAutoSave(): void { + this.autoSavePromise = this.autoSavePromise + .then(async () => { + await this.saveEvents() + await this.generateSummary() + }) + .catch(error => { + statisticsLogger.error('自动保存失败', error) + }) } /** @@ -201,12 +227,18 @@ export class StatisticsService { this.events.push(event) - // 限制事件数量 + this.trimEvents() + + // console.log(`[统计服务] 记录事件: ${type}`, data) + } + + /** + * 将内存事件限制在最近的最大保留数量内。 + */ + private trimEvents(): void { if (this.events.length > this.maxEvents) { this.events = this.events.slice(-this.maxEvents) } - - // console.log(`[统计服务] 记录事件: ${type}`, data) } /** @@ -341,6 +373,8 @@ export class StatisticsService { * 生成统计摘要 */ public async generateSummary(timeRange?: { start: number; end: number }): Promise { + await this.initializationPromise + const range = timeRange || { start: Date.now() - 30 * 24 * 60 * 60 * 1000, // 最近30天 end: Date.now() @@ -367,6 +401,8 @@ export class StatisticsService { * 获取统计摘要 */ public async getSummary(timeRange?: { start: number; end: number }): Promise { + await this.initializationPromise + // 如果有时间范围参数,实时生成 if (timeRange) { return this.generateSummary(timeRange) @@ -389,6 +425,8 @@ export class StatisticsService { * 清理过期数据 */ public async cleanup(daysToKeep: number = 90): Promise { + await this.initializationPromise + const cutoffTime = Date.now() - daysToKeep * 24 * 60 * 60 * 1000 const originalLength = this.events.length @@ -403,6 +441,8 @@ export class StatisticsService { * 导出统计数据 */ public async exportStats(exportPath: string): Promise { + await this.initializationPromise + const summary = await this.generateSummary() await fs.writeJSON(exportPath, { summary, @@ -415,10 +455,24 @@ export class StatisticsService { * 关闭统计服务 */ public async shutdown(): Promise { + if (this.shutdownPromise) { + return this.shutdownPromise + } + + this.isShuttingDown = true + this.shutdownPromise = this.performShutdown() + return this.shutdownPromise + } + + /** + * 等待初始化和在途自动保存完成,然后持久化唯一的关闭事件。 + */ + private async performShutdown(): Promise { statisticsLogger.info('关闭中') - // 停止自动保存 + await this.initializationPromise this.stopAutoSave() + await this.autoSavePromise // 记录应用关闭 this.recordEvent(StatEventType.APP_CLOSE) diff --git a/src/main/services/template-cloud-service.ts b/src/main/services/template-cloud-service.ts new file mode 100644 index 0000000..cc7e1ef --- /dev/null +++ b/src/main/services/template-cloud-service.ts @@ -0,0 +1,212 @@ +/** + * @file src/main/services/template-cloud-service.ts + * @description 云模板(v2 提案通道)服务:拉取并验证 templates/v1/index.json(Ed25519 canonical + * 签名 + pinned origin + trust map,与规则库同一条信任链),按用户指令下载并校验 + * 内容寻址模板负载,导入为配置集(CONFIG_SET)或 artifact 默认模板 override(ARTIFACT)。 + * 不引入任何新写路径:导入分别复用 ToolConfigSetService 与 ArtifactTemplateService。 + */ + +import { createHash } from 'crypto' +import type { + ArtifactTemplateEntry +} from '@shared/tool-registry' +import type { + ConfigSetTemplatePayload, + ArtifactTemplatePayload, + TemplateCloudImportResult, + TemplateCloudIndex, + TemplateCloudItemMeta, + TemplateCloudListResult, + TemplateCloudPayload +} from '@shared/template-cloud' +import { TEMPLATE_ITEM_MAX_BYTES } from '@shared/template-cloud' +import { + validateTemplateCloudIndex, + templateIndexSignatureInput, + validateArtifactTemplatePayload, + validateConfigSetTemplatePayload +} from '@shared/template-cloud-validator' +import { compareStrictSemVer } from '@shared/tool-registry-validator' +import type { RegistryHttpClient } from './registry-update-service' +import { NetFetchRegistryHttpClient, REGISTRY_ALLOWED_ORIGINS, REGISTRY_TRUSTED_PUBLIC_KEYS } from './registry-update-service' +import { verifyRegistryBundleSignature, type RegistryTrustedPublicKeys } from './registry-signature-verifier' +import type { ToolConfigSetService } from './tool-config-set-service' +import { toolConfigSetService } from './tool-config-set-service' +import type { ArtifactTemplateService } from './artifact-template-service' +import { logger } from '../utils/logger' + +/** 默认模板 index URL(v2 提案通道唯一可变入口) */ +export const TEMPLATE_CLOUD_INDEX_URL = 'https://dev.niansir.com/software/ccb/templates/v1/index.json' + +export interface TemplateCloudServiceOptions { + httpClient?: RegistryHttpClient + indexUrl?: string + allowedOrigins?: string[] + trustedPublicKeys?: RegistryTrustedPublicKeys + configSetService?: ToolConfigSetService + /** 必须显式注入,与 ipc-handlers 共享同一 settings 变更队列 */ + artifactTemplateService: ArtifactTemplateService +} + +/** + * 以共享的 ArtifactTemplateService 实例构造云模板服务。 + * @param artifactTemplates 主进程既有 artifact 模板服务实例(共享 settings 原子写队列) + * @param options 其余可选依赖 + */ +export function createTemplateCloudService( + artifactTemplates: ArtifactTemplateService, + options: Omit = {} +): TemplateCloudService { + return new TemplateCloudService({ ...options, artifactTemplateService: artifactTemplates }) +} + +/** + * 云模板服务。 + * @description 与 RegistryUpdateService 同一纪律:URL/hash 只在 main process 内部流转; + * renderer 仅提供 templateId 与可选显示名,不提供任何 URL 或内容。 + */ +export class TemplateCloudService { + private readonly httpClient: RegistryHttpClient + private readonly indexUrl: string + private readonly allowedOrigins: string[] + private readonly trustedPublicKeys: RegistryTrustedPublicKeys + private readonly configSetService: ToolConfigSetService + private readonly artifactTemplates: ArtifactTemplateService + private verifiedIndex?: TemplateCloudIndex + private listPromise?: Promise + + constructor(options: TemplateCloudServiceOptions) { + this.httpClient = options.httpClient ?? new NetFetchRegistryHttpClient() + this.indexUrl = options.indexUrl ?? TEMPLATE_CLOUD_INDEX_URL + this.allowedOrigins = options.allowedOrigins ?? [...REGISTRY_ALLOWED_ORIGINS] + this.trustedPublicKeys = options.trustedPublicKeys ?? REGISTRY_TRUSTED_PUBLIC_KEYS + this.configSetService = options.configSetService ?? toolConfigSetService + this.artifactTemplates = options.artifactTemplateService + } + + /** + * 拉取并验证模板 index,返回可展示清单(并发去重)。 + * @param currentAppVersion 当前应用版本(minimumAppVersion 门槛) + */ + public listTemplates(currentAppVersion: string): Promise { + if (!this.listPromise) { + this.listPromise = this.fetchAndVerifyIndex(currentAppVersion) + .then((index) => ({ + templatesVersion: index.templatesVersion, + publishedAt: index.publishedAt, + items: index.items + })) + .finally(() => { + this.listPromise = undefined + }) + } + return this.listPromise + } + + /** + * 下载并导入模板(CONFIG_SET → 本地配置集;ARTIFACT → 默认模板 user override)。 + * @param templateId 清单中的 stable template identifier + * @param currentAppVersion 当前应用版本 + * @param options.name 可选配置集显示名(仅 CONFIG_SET;缺省用模板 displayName) + */ + public async importTemplate( + templateId: string, + currentAppVersion: string, + options?: { name?: string } + ): Promise { + const index = this.verifiedIndex ?? (await this.fetchAndVerifyIndex(currentAppVersion)) + const meta = index.items.find((item) => item.templateId === templateId) + if (!meta) { + throw new Error(`模板清单中不存在: ${templateId}`) + } + const payload = await this.downloadVerifiedItem(meta) + if (meta.kind === 'CONFIG_SET') { + const configSetPayload = payload as ConfigSetTemplatePayload + const name = options?.name ?? configSetPayload.displayName['zh-CN'] ?? Object.values(configSetPayload.displayName)[0] + const configSet = await this.configSetService.createConfigSetFromContents( + meta.toolId, + name, + configSetPayload.files.map((file) => ({ artifactId: file.artifactId, content: file.content })) + ) + logger.info(`云模板已导入为配置集: ${templateId} -> ${meta.toolId}/${configSet.setId}`) + return { kind: 'CONFIG_SET', configSet } + } + const artifactPayload = payload as ArtifactTemplatePayload + const artifactTemplate: ArtifactTemplateEntry = await this.artifactTemplates.saveArtifactTemplateOverride( + meta.toolId, + artifactPayload.artifactId, + artifactPayload.content + ) + logger.info(`云模板已导入为默认模板 override: ${templateId} -> ${meta.toolId}/${artifactPayload.artifactId}`) + return { kind: 'ARTIFACT', artifactTemplate } + } + + /** + * 拉取并完整验证 index:pinned URL → 尺寸 → 结构闭集 → minimumAppVersion → canonical 签名。 + */ + private async fetchAndVerifyIndex(currentAppVersion: string): Promise { + this.validatePinnedUrl(this.indexUrl, '模板 index URL') + const rawIndex = await this.httpClient.getText(this.indexUrl, 50 * 1024) + const validation = validateTemplateCloudIndex(rawIndex, this.allowedOrigins) + if (!validation.success || !validation.data) { + this.verifiedIndex = undefined + throw new Error(`模板 index 无效: ${validation.errors.join('; ')}`) + } + const index = validation.data + if (compareStrictSemVer(index.minimumAppVersion, currentAppVersion) > 0) { + this.verifiedIndex = undefined + throw new Error(`模板 index 要求 CCB >= ${index.minimumAppVersion}`) + } + // 签名对象为「移除 signature 字段后的 canonical JSON」(与发布侧 canonicalJsonStable 一致) + verifyRegistryBundleSignature( + Buffer.from(templateIndexSignatureInput(index), 'utf8'), + index.signature, + index.keyId, + this.trustedPublicKeys + ) + this.verifiedIndex = index + return index + } + + /** + * 下载并验证单个模板负载:pinned URL → 尺寸 → SHA-256 → 结构(按 kind)→ templateId/toolId 一致性。 + */ + private async downloadVerifiedItem(meta: TemplateCloudItemMeta): Promise { + this.validatePinnedUrl(meta.itemUrl, `模板 ${meta.templateId} itemUrl`) + const rawItem = await this.httpClient.getBytes(meta.itemUrl, TEMPLATE_ITEM_MAX_BYTES) + if (rawItem.length !== meta.itemSize) { + throw new Error(`模板 ${meta.templateId} 尺寸不匹配: index=${meta.itemSize}, actual=${rawItem.length}`) + } + const actualSha256 = createHash('sha256').update(rawItem).digest('hex') + if (actualSha256 !== meta.itemSha256) { + throw new Error(`模板 ${meta.templateId} SHA-256 不匹配`) + } + let parsed: unknown + try { + parsed = JSON.parse(rawItem.toString('utf8')) + } catch (error) { + throw new Error(`模板 ${meta.templateId} JSON 解析失败: ${error instanceof Error ? error.message : String(error)}`) + } + const validation = meta.kind === 'CONFIG_SET' + ? validateConfigSetTemplatePayload(parsed) + : validateArtifactTemplatePayload(parsed) + if (!validation.success || !validation.data) { + throw new Error(`模板 ${meta.templateId} 负载无效: ${validation.errors.join('; ')}`) + } + const payload = validation.data as TemplateCloudPayload + if (payload.templateId !== meta.templateId || payload.toolId !== meta.toolId) { + throw new Error( + `模板 ${meta.templateId} 负载与清单不一致(payload=${payload.templateId}/${payload.toolId})` + ) + } + return payload + } + + /** 校验 URL 使用 HTTPS 且命中 pinned origin。 */ + private validatePinnedUrl(value: string, label: string): void { + const parsedUrl = new URL(value) + if (parsedUrl.protocol !== 'https:' || !this.allowedOrigins.includes(parsedUrl.origin)) { + throw new Error(`${label} 不在 pinned HTTPS origin 中`) + } + } +} diff --git a/src/main/services/terminal-management-service.ts b/src/main/services/terminal-management-service.ts index 085f3f0..ba6c85d 100644 --- a/src/main/services/terminal-management-service.ts +++ b/src/main/services/terminal-management-service.ts @@ -377,6 +377,7 @@ class TerminalManagementService { logger.info(`探测命令启动 [${terminalType}]: ${command}`) return await new Promise((resolve) => { + // nosemgrep: javascript.lang.security.detect-child-process.detect-child-process - 本地 MCP 配置需要 shell 初始化;renderer IPC 另由 allowlist 隔离。 const child = spawn(execCommand, { cwd: execOptions.cwd, shell: true, diff --git a/src/main/services/tool-artifact-codec-service.ts b/src/main/services/tool-artifact-codec-service.ts new file mode 100644 index 0000000..84494d0 --- /dev/null +++ b/src/main/services/tool-artifact-codec-service.ts @@ -0,0 +1,175 @@ +/** + * @file src/main/services/tool-artifact-codec-service.ts + * @description 提供规则驱动配置资产的内置、不可下载 format codecs。 + */ + +import yaml from 'js-yaml' +import { parse as parseToml } from 'smol-toml' +import type { + ArtifactFormat, + ConfigArtifactValidationResult +} from '@shared/tool-registry' + +const CODEC_MAX_DEPTH = 64 +const CODEC_MAX_NODES = 50_000 + +/** + * 限制 parsed configuration 的深度和节点数,避免 YAML/JSON 结构耗尽资源。 + * @param root parsed configuration value + */ +function assertBoundedStructure(root: unknown): void { + const stack: Array<{ value: unknown; depth: number }> = [{ value: root, depth: 0 }] + const visited = new WeakSet() + let nodes = 0 + while (stack.length > 0) { + const current = stack.pop() + if (!current) break + nodes += 1 + if (nodes > CODEC_MAX_NODES) throw new Error(`配置结构超过 ${CODEC_MAX_NODES} nodes`) + if (current.depth > CODEC_MAX_DEPTH) throw new Error(`配置结构超过 ${CODEC_MAX_DEPTH} levels`) + if (typeof current.value !== 'object' || current.value === null) continue + if (visited.has(current.value)) continue + visited.add(current.value) + for (const value of Object.values(current.value as Record)) { + stack.push({ value, depth: current.depth + 1 }) + } + } +} + +/** + * 移除 JSONC comments,同时保留 string literal 内容与换行位置。 + * @param content JSONC 原始文本 + * @returns 不包含 comments 的 JSON-compatible 文本 + */ +function stripJsonComments(content: string): string { + let output = '' + let inString = false + let escaped = false + let lineComment = false + let blockComment = false + + for (let index = 0; index < content.length; index += 1) { + const character = content[index] + const nextCharacter = content[index + 1] + if (lineComment) { + if (character === '\n' || character === '\r') { + lineComment = false + output += character + } else { + output += ' ' + } + continue + } + if (blockComment) { + if (character === '*' && nextCharacter === '/') { + output += ' ' + blockComment = false + index += 1 + } else { + output += character === '\n' || character === '\r' ? character : ' ' + } + continue + } + if (inString) { + output += character + if (escaped) escaped = false + else if (character === '\\') escaped = true + else if (character === '"') inString = false + continue + } + if (character === '"') { + inString = true + output += character + } else if (character === '/' && nextCharacter === '/') { + lineComment = true + output += ' ' + index += 1 + } else if (character === '/' && nextCharacter === '*') { + blockComment = true + output += ' ' + index += 1 + } else { + output += character + } + } + if (blockComment) throw new Error('JSONC block comment 未闭合') + return output +} + +/** + * 移除 JSONC object/array 尾逗号,不修改 string literal。 + * @param content 已移除 comments 的文本 + * @returns strict JSON 文本 + */ +function stripTrailingCommas(content: string): string { + let output = '' + let inString = false + let escaped = false + for (let index = 0; index < content.length; index += 1) { + const character = content[index] + if (inString) { + output += character + if (escaped) escaped = false + else if (character === '\\') escaped = true + else if (character === '"') inString = false + continue + } + if (character === '"') { + inString = true + output += character + continue + } + if (character === ',') { + let lookahead = index + 1 + while (/\s/.test(content[lookahead] ?? '')) lookahead += 1 + if (content[lookahead] === '}' || content[lookahead] === ']') { + output += ' ' + continue + } + } + output += character + } + return output +} + +/** + * 校验文本不包含 NUL,避免配置编辑链处理 binary data。 + * @param content UTF-8 文本 + */ +function validateText(content: string): void { + if (content.includes('\0')) throw new Error('配置文本不能包含 NUL character') +} + +/** + * 内置配置资产 codec service。 + * @description 远程 registry 只能声明 format,不能注入 parser 或 executable code。 + */ +export class ToolArtifactCodecService { + /** + * 按 format 校验原始配置文本。 + * @param format registry 声明的 UPPERCASE format + * @param content 原始 UTF-8 文本 + * @returns 可序列化 validation 结果 + */ + public validate(format: ArtifactFormat, content: string): ConfigArtifactValidationResult { + try { + validateText(content) + let parsedValue: unknown + if (format === 'JSON') parsedValue = JSON.parse(content) + else if (format === 'JSONC') parsedValue = JSON.parse(stripTrailingCommas(stripJsonComments(content))) + else if (format === 'YAML') parsedValue = yaml.load(content, { schema: yaml.JSON_SCHEMA }) + else if (format === 'TOML') parsedValue = parseToml(content) + if (parsedValue !== undefined) assertBoundedStructure(parsedValue) + return { valid: true, format, errors: [] } + } catch (error) { + return { + valid: false, + format, + errors: [error instanceof Error ? error.message : String(error)] + } + } + } +} + +/** 默认内置配置资产 codec service */ +export const toolArtifactCodecService = new ToolArtifactCodecService() diff --git a/src/main/services/tool-artifact-discovery-service.ts b/src/main/services/tool-artifact-discovery-service.ts new file mode 100644 index 0000000..c5fad70 --- /dev/null +++ b/src/main/services/tool-artifact-discovery-service.ts @@ -0,0 +1,294 @@ +/** + * @file src/main/services/tool-artifact-discovery-service.ts + * @description 按 effective registry 安全发现并只读加载 AI Coding 工具配置资产。 + */ + +import { lstat, open } from 'fs/promises' +import path from 'path' +import type { + ConfigArtifactContent, + ConfigArtifactDefinition, + DiscoveredConfigArtifact, + ToolDefinition, + ToolDetectionResult, + ToolCapability +} from '@shared/tool-registry' +import { toolRegistryService, type ToolRegistryService } from './tool-registry-service' +import { ToolDetectionService } from './tool-detection-service' + +/** 单个配置资产允许读取的最大 UTF-8 bytes */ +export const CONFIG_ARTIFACT_MAX_BYTES = 1024 * 1024 + +/** Artifact discovery service 可替换依赖 */ +export interface ToolArtifactDiscoveryServiceOptions { + /** Effective registry provider */ + registryService?: ToolRegistryService + /** 安全 detector 与路径解析器 */ + detectionService?: ToolDetectionService +} + +/** Registry capability 校验后的 artifact 与绝对路径 */ +export interface AuthorizedToolArtifact { + /** 当前 effective registry 中的工具定义 */ + tool: ToolDefinition + /** 当前 effective registry 中的资产定义 */ + artifact: ConfigArtifactDefinition + /** 与 registry candidate 完全匹配的规范路径 */ + resolvedPath: string +} + +/** + * 提供规则驱动的工具检测、资产发现和只读加载。 + * @description 每次读取都会重新从 effective registry 推导 allowlist,不信任 renderer 提供的路径。 + */ +export class ToolArtifactDiscoveryService { + private readonly registryService: ToolRegistryService + private readonly detectionService: ToolDetectionService + + /** + * 创建 artifact discovery service。 + * @param options registry 与 detector 可替换依赖 + */ + constructor(options: ToolArtifactDiscoveryServiceOptions = {}) { + this.registryService = options.registryService ?? toolRegistryService + this.detectionService = options.detectionService ?? new ToolDetectionService() + } + + /** + * 检测 effective registry 中当前平台支持的全部工具。 + * @returns 工具检测结果 + */ + public async detectTools(): Promise { + const snapshot = await this.registryService.getSnapshot() + return this.detectionService.detectTools(snapshot.tools) + } + + /** + * 发现工具在当前平台存在的普通配置文件。 + * @param toolId stable tool identifier + * @returns 已发现的配置资产 + */ + public async discoverArtifacts(toolId: string): Promise { + const tool = await this.requireTool(toolId) + if (!tool.platforms.includes(this.detectionService.getPlatform())) return [] + + const discovered = await Promise.all(tool.artifacts.map((artifact) => this.discoverArtifact(tool, artifact))) + return discovered.flat() + } + + /** + * 读取 registry 明确声明且具有 READ capability 的配置文件。 + * @param toolId stable tool identifier + * @param artifactId stable artifact identifier + * @param requestedPath renderer 从 discovery 结果中选择的绝对路径 + * @returns 原始 UTF-8 配置文本及 metadata + */ + public async readArtifact( + toolId: string, + artifactId: string, + requestedPath: string + ): Promise { + const { artifact, resolvedPath } = await this.authorizeArtifact( + toolId, + artifactId, + requestedPath, + 'READ' + ) + + await this.assertNoSymbolicLinks(resolvedPath) + const fileHandle = await open(resolvedPath, 'r') + try { + const fileMetadata = await fileHandle.stat() + if (!fileMetadata.isFile()) throw new Error(`配置资产不是普通文件: ${resolvedPath}`) + if (fileMetadata.size > CONFIG_ARTIFACT_MAX_BYTES) { + throw new Error(`配置资产超过读取限制: ${CONFIG_ARTIFACT_MAX_BYTES} bytes`) + } + const buffer = Buffer.alloc(Math.min(fileMetadata.size + 1, CONFIG_ARTIFACT_MAX_BYTES + 1)) + const { bytesRead } = await fileHandle.read(buffer, 0, buffer.length, 0) + if (bytesRead > CONFIG_ARTIFACT_MAX_BYTES) { + throw new Error(`配置资产超过读取限制: ${CONFIG_ARTIFACT_MAX_BYTES} bytes`) + } + let content: string + try { + content = new TextDecoder('utf-8', { fatal: true }).decode(buffer.subarray(0, bytesRead)) + } catch { + throw new Error('配置资产不是有效的 UTF-8 文本') + } + return { + toolId, + artifactId: artifact.artifactId, + format: artifact.format, + path: resolvedPath, + size: fileMetadata.size, + lastModifiedAt: fileMetadata.mtime.toISOString(), + content + } + } finally { + await fileHandle.close() + } + } + + /** + * 重新从 effective registry 解析并授权 artifact capability。 + * @param toolId stable tool identifier + * @param artifactId stable artifact identifier + * @param requestedPath 调用方选择的绝对路径 + * @param capability 本次操作要求的 capability + * @returns registry 授权后的 artifact 与规范路径 + */ + public async authorizeArtifact( + toolId: string, + artifactId: string, + requestedPath: string, + capability: ToolCapability + ): Promise { + const tool = await this.requireTool(toolId) + if (!tool.platforms.includes(this.detectionService.getPlatform())) { + throw new Error(`工具不支持当前平台: ${toolId}`) + } + const artifact = tool.artifacts.find((candidate) => candidate.artifactId === artifactId) + if (!artifact) throw new Error(`配置资产不存在: ${artifactId}`) + if (!artifact.capabilities.includes(capability)) { + throw new Error(`配置资产未声明 ${capability} capability: ${artifactId}`) + } + const candidates = this.resolveArtifactPaths(artifact) + if (candidates.length === 0) { + throw new Error(`配置资产未声明当前平台路径: ${artifactId}`) + } + // requestedPath 为空时由 main 侧取 registry 声明的主候选路径(用于按声明创建缺失文件), + // 路径仍完全来自 registry 声明,renderer 无法注入任意路径。 + const resolvedPath = requestedPath === '' + ? candidates[0] + : candidates.find((candidate) => this.pathsEqual(candidate, requestedPath)) + if (!resolvedPath) throw new Error('拒绝访问 registry 未声明的配置路径') + // 最终文件段允许不存在:EDIT 可创建 registry 声明的新文件;父目录链仍拒绝 symlink。 + await this.assertNoSymbolicLinks(resolvedPath, true) + return { tool, artifact, resolvedPath } + } + + /** + * 获取 registry 中的工具定义。 + * @param toolId stable tool identifier + * @returns 工具定义 + */ + private async requireTool(toolId: string): Promise { + const tool = await this.registryService.getTool(toolId) + if (!tool) throw new Error(`工具定义不存在: ${toolId}`) + return tool + } + + /** + * 发现单个 artifact 的全部现有候选路径。 + * @param tool 所属工具 + * @param artifact 配置资产定义 + * @returns 当前存在的普通文件 + */ + private async discoverArtifact( + tool: ToolDefinition, + artifact: ConfigArtifactDefinition + ): Promise { + if (!artifact.capabilities.includes('DISCOVER')) return [] + const results = await Promise.all(this.resolveArtifactPaths(artifact).map(async (resolvedPath) => { + try { + return await this.readFileMetadata(tool.toolId, artifact, resolvedPath) + } catch (error) { + const nodeError = error as NodeJS.ErrnoException + if (nodeError.code === 'ENOENT' || nodeError.code === 'ENOTDIR') return undefined + throw error + } + })) + return results.filter((result): result is DiscoveredConfigArtifact => result !== undefined) + } + + /** + * 解析 artifact 在当前平台声明的候选路径。 + * @param artifact 配置资产定义 + * @returns 去重后的规范化绝对路径 + */ + private resolveArtifactPaths(artifact: ConfigArtifactDefinition): string[] { + const templates = artifact.paths[this.detectionService.getPlatform()] ?? [] + return [...new Set(templates.map((template) => this.detectionService.resolvePath(template)))] + } + + /** + * 读取并验证配置文件 metadata。 + * @param toolId stable tool identifier + * @param artifact 配置资产定义 + * @param resolvedPath 已通过 registry allowlist 的绝对路径 + * @returns discovery metadata + */ + private async readFileMetadata( + toolId: string, + artifact: ConfigArtifactDefinition, + resolvedPath: string + ): Promise { + await this.assertNoSymbolicLinks(resolvedPath) + const metadata = await lstat(resolvedPath) + if (metadata.isSymbolicLink() || !metadata.isFile()) { + throw new Error(`配置资产不是普通文件: ${resolvedPath}`) + } + if (metadata.size > CONFIG_ARTIFACT_MAX_BYTES) { + throw new Error(`配置资产超过读取限制: ${CONFIG_ARTIFACT_MAX_BYTES} bytes`) + } + return { + toolId, + artifactId: artifact.artifactId, + format: artifact.format, + path: resolvedPath, + size: metadata.size, + lastModifiedAt: metadata.mtime.toISOString() + } + } + + /** + * 拒绝最终文件及其任一中间目录中的 symbolic link/junction。 + * @param resolvedPath 已通过 registry allowlist 的绝对路径 + * @param tolerateMissingFinalSegment 允许最终文件段不存在(EDIT 创建 registry 声明的新文件); + * 任一父目录缺失或含 symlink 仍然拒绝 + */ + private async assertNoSymbolicLinks( + resolvedPath: string, + tolerateMissingFinalSegment = false + ): Promise { + const platform = this.detectionService.getPlatform() + const pathImplementation = platform === 'WINDOWS' ? path.win32 : path.posix + const parsedPath = pathImplementation.parse(resolvedPath) + const segments = resolvedPath.slice(parsedPath.root.length).split(pathImplementation.sep).filter(Boolean) + let currentPath = parsedPath.root + for (const [index, segment] of segments.entries()) { + currentPath = pathImplementation.join(currentPath, segment) + let metadata + try { + metadata = await lstat(currentPath) + } catch (error) { + const nodeError = error as NodeJS.ErrnoException + if (tolerateMissingFinalSegment && nodeError.code === 'ENOENT' && index === segments.length - 1) { + return + } + throw error + } + if (metadata.isSymbolicLink()) { + throw new Error(`配置资产路径包含 symbolic link: ${currentPath}`) + } + } + } + + /** + * 比较 renderer 路径与 registry 规范路径。 + * @param allowedPath registry 推导路径 + * @param requestedPath renderer 请求路径 + * @returns 是否为同一规范字符串路径 + */ + private pathsEqual(allowedPath: string, requestedPath: string): boolean { + const platform = this.detectionService.getPlatform() + const pathImplementation = platform === 'WINDOWS' ? path.win32 : path.posix + if (typeof requestedPath !== 'string' || !pathImplementation.isAbsolute(requestedPath)) return false + const normalizedRequestedPath = pathImplementation.resolve(requestedPath) + return platform === 'WINDOWS' + ? allowedPath.toLocaleLowerCase('en-US') === normalizedRequestedPath.toLocaleLowerCase('en-US') + : allowedPath === normalizedRequestedPath + } +} + +/** 默认配置资产发现服务单例 */ +export const toolArtifactDiscoveryService = new ToolArtifactDiscoveryService() diff --git a/src/main/services/tool-artifact-management-service.ts b/src/main/services/tool-artifact-management-service.ts new file mode 100644 index 0000000..4474e43 --- /dev/null +++ b/src/main/services/tool-artifact-management-service.ts @@ -0,0 +1,448 @@ +/** + * @file src/main/services/tool-artifact-management-service.ts + * @description 以 registry capabilities 驱动配置资产 validation、atomic edit、backup 与 restore。 + */ + +import { randomUUID } from 'crypto' +import { constants as fsConstants } from 'fs' +import { copyFile, lstat, mkdir, open, readFile, readdir, rename, rm, stat } from 'fs/promises' +import path from 'path' +import type { + ConfigArtifactBackup, + ConfigArtifactContent, + ConfigArtifactValidationResult +} from '@shared/tool-registry' +import { + CONFIG_ARTIFACT_MAX_BYTES, + toolArtifactDiscoveryService, + type ToolArtifactDiscoveryService +} from './tool-artifact-discovery-service' +import { + toolArtifactCodecService, + type ToolArtifactCodecService +} from './tool-artifact-codec-service' +import { pathManager } from '../utils/path-manager' +import { ensurePathWithinBase } from '../utils/path-security' + +/** 持久化 backup metadata */ +interface StoredArtifactBackup extends ConfigArtifactBackup { + /** 受控 backup directory 内的内容文件名 */ + contentFileName: string +} + +const BACKUP_METADATA_MAX_BYTES = 16 * 1024 +const DEFAULT_MAX_BACKUPS_PER_ARTIFACT = 20 + +/** Artifact management service 可替换依赖 */ +export interface ToolArtifactManagementServiceOptions { + /** Registry authorization 与 read service */ + discoveryService?: ToolArtifactDiscoveryService + /** 内置 format codec service */ + codecService?: ToolArtifactCodecService + /** 受控 backup directory */ + backupDirectory?: string + /** 单个 artifact/path 保留的最大备份数 */ + maxBackupsPerArtifact?: number +} + +/** + * 通用配置资产管理 service。 + * @description 所有写操作都要求 registry capability,并在目标旁使用随机 temp file 原子替换。 + */ +export class ToolArtifactManagementService { + private readonly discoveryService: ToolArtifactDiscoveryService + private readonly codecService: ToolArtifactCodecService + private readonly backupDirectory: string + private readonly maxBackupsPerArtifact: number + private backupMutationQueue: Promise = Promise.resolve() + private lastBackupCreatedAtMs = 0 + + /** + * 创建通用 artifact management service。 + * @param options 可替换依赖与 backup directory + */ + constructor(options: ToolArtifactManagementServiceOptions = {}) { + this.discoveryService = options.discoveryService ?? toolArtifactDiscoveryService + this.codecService = options.codecService ?? toolArtifactCodecService + this.backupDirectory = options.backupDirectory ?? pathManager.toolArtifactBackupDir + this.maxBackupsPerArtifact = options.maxBackupsPerArtifact ?? DEFAULT_MAX_BACKUPS_PER_ARTIFACT + if (!Number.isInteger(this.maxBackupsPerArtifact) || this.maxBackupsPerArtifact < 1) { + throw new Error('maxBackupsPerArtifact 必须是正整数') + } + } + + /** + * 按 registry format 验证配置文本。 + * @param toolId stable tool identifier + * @param artifactId stable artifact identifier + * @param requestedPath registry candidate path + * @param content 待验证文本 + * @returns codec validation 结果 + */ + public async validateArtifact( + toolId: string, + artifactId: string, + requestedPath: string, + content: string + ): Promise { + this.assertContentSize(content) + const { artifact } = await this.discoveryService.authorizeArtifact( + toolId, + artifactId, + requestedPath, + 'VALIDATE' + ) + return this.codecService.validate(artifact.format, content) + } + + /** + * 校验并原子更新 registry 授权的配置文件。 + * @param toolId stable tool identifier + * @param artifactId stable artifact identifier + * @param requestedPath registry candidate path + * @param content 新 UTF-8 文本 + * @returns 更新后的只读 artifact snapshot + */ + public async editArtifact( + toolId: string, + artifactId: string, + requestedPath: string, + content: string + ): Promise { + this.assertContentSize(content) + const authorization = await this.discoveryService.authorizeArtifact( + toolId, + artifactId, + requestedPath, + 'EDIT' + ) + if (authorization.artifact.capabilities.includes('VALIDATE')) { + const validation = this.codecService.validate(authorization.artifact.format, content) + if (!validation.valid) throw new Error(`配置校验失败: ${validation.errors.join('; ')}`) + } + if (authorization.artifact.capabilities.includes('BACKUP')) { + await this.createBackup(toolId, artifactId, authorization.resolvedPath) + } + await this.writeTextAtomic(authorization.resolvedPath, content) + return this.discoveryService.readArtifact(toolId, artifactId, authorization.resolvedPath) + } + + /** + * 创建 registry 授权的配置资产备份。 + * @param toolId stable tool identifier + * @param artifactId stable artifact identifier + * @param requestedPath registry candidate path + * @returns backup metadata + */ + public async createBackup( + toolId: string, + artifactId: string, + requestedPath: string + ): Promise { + return this.enqueueBackupMutation(() => this.createBackupInternal(toolId, artifactId, requestedPath)) + } + + /** + * 创建备份并执行 retention cleanup。 + * @param toolId stable tool identifier + * @param artifactId stable artifact identifier + * @param requestedPath registry candidate path + * @returns backup metadata + */ + private async createBackupInternal( + toolId: string, + artifactId: string, + requestedPath: string + ): Promise { + const { resolvedPath } = await this.discoveryService.authorizeArtifact( + toolId, + artifactId, + requestedPath, + 'BACKUP' + ) + const sourceMetadata = await stat(resolvedPath) + if (!sourceMetadata.isFile() || sourceMetadata.size > CONFIG_ARTIFACT_MAX_BYTES) { + throw new Error('备份源不是允许大小的普通文件') + } + await mkdir(this.backupDirectory, { recursive: true }) + const backupId = randomUUID() + const contentFileName = `${backupId}.backup` + const contentPath = ensurePathWithinBase( + path.join(this.backupDirectory, contentFileName), + this.backupDirectory, + '配置备份内容文件' + ) + const metadataPath = ensurePathWithinBase( + path.join(this.backupDirectory, `${backupId}.json`), + this.backupDirectory, + '配置备份元数据文件' + ) + const backup: StoredArtifactBackup = { + backupId, + toolId, + artifactId, + originalPath: resolvedPath, + size: sourceMetadata.size, + createdAt: this.createMonotonicBackupTimestamp(), + contentFileName + } + await copyFile(resolvedPath, contentPath, fsConstants.COPYFILE_EXCL) + try { + await this.writeTextAtomic(metadataPath, JSON.stringify(backup, null, 2)) + } catch (error) { + await rm(contentPath, { force: true }) + throw error + } + await this.pruneBackups(backup) + return this.toPublicBackup(backup) + } + + /** + * 列出指定 registry artifact 当前可恢复的备份。 + * @param toolId stable tool identifier + * @param artifactId stable artifact identifier + * @param requestedPath registry candidate path + * @returns 按创建时间倒序的有效 backup metadata + */ + public async listBackups( + toolId: string, + artifactId: string, + requestedPath: string + ): Promise { + const authorization = await this.discoveryService.authorizeArtifact( + toolId, + artifactId, + requestedPath, + 'RESTORE' + ) + let fileNames: string[] + try { + fileNames = await readdir(this.backupDirectory) + } catch (error) { + const nodeError = error as NodeJS.ErrnoException + if (nodeError.code === 'ENOENT') return [] + throw error + } + const backups = await Promise.all(fileNames + .filter((fileName) => /^[0-9a-f-]{36}\.json$/i.test(fileName)) + .map((fileName) => this.readStoredBackup(ensurePathWithinBase( + path.join(this.backupDirectory, fileName), + this.backupDirectory, + '配置备份元数据文件' + )))) + return backups + .filter((backup): backup is StoredArtifactBackup => Boolean( + backup + && backup.toolId === toolId + && backup.artifactId === artifactId + && backup.originalPath === authorization.resolvedPath + )) + .sort((left, right) => right.createdAt.localeCompare(left.createdAt)) + .map((backup) => this.toPublicBackup(backup)) + } + + /** + * 从受控 metadata 恢复 registry 仍授权的备份。 + * @param backupId UUID backup identifier + * @returns 恢复后的 artifact snapshot + */ + public async restoreBackup(backupId: string): Promise { + if (!/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(backupId)) { + throw new Error('backupId 格式无效') + } + const metadataPath = ensurePathWithinBase( + path.join(this.backupDirectory, `${backupId}.json`), + this.backupDirectory, + '配置备份元数据文件' + ) + const backup = await this.readStoredBackup(metadataPath) + if (!backup || backup.backupId !== backupId) throw new Error('备份 metadata 无效') + // readStoredBackup 已校验 contentFileName === `${backupId}.backup`;此处再显式断言一次, + // 保证 join 的动态片段被限制为受控 backup directory 内的固定模式文件名 + if (backup.contentFileName !== `${backupId}.backup`) throw new Error('备份内容文件名无效') + const authorization = await this.discoveryService.authorizeArtifact( + backup.toolId, + backup.artifactId, + backup.originalPath, + 'RESTORE' + ) + const contentPath = ensurePathWithinBase( + path.join(this.backupDirectory, backup.contentFileName), + this.backupDirectory, + '配置备份内容文件' + ) + const backupMetadata = await lstat(contentPath) + if ( + backupMetadata.isSymbolicLink() + || !backupMetadata.isFile() + || backupMetadata.size > CONFIG_ARTIFACT_MAX_BYTES + ) { + throw new Error('备份内容不是允许大小的普通文件') + } + const contentBuffer = await readFile(contentPath) + let content: string + try { + content = new TextDecoder('utf-8', { fatal: true }).decode(contentBuffer) + } catch { + throw new Error('备份内容不是有效的 UTF-8 文本') + } + if (authorization.artifact.capabilities.includes('VALIDATE')) { + const validation = this.codecService.validate(authorization.artifact.format, content) + if (!validation.valid) throw new Error(`备份配置校验失败: ${validation.errors.join('; ')}`) + } + await this.writeTextAtomic(authorization.resolvedPath, content) + return this.discoveryService.readArtifact( + backup.toolId, + backup.artifactId, + authorization.resolvedPath + ) + } + + /** + * Fail-closed 读取单个 backup metadata 与对应内容文件边界。 + * @param metadataPath 受控 backup directory 内 metadata path + * @returns 有效 metadata;损坏或过期记录返回 undefined + */ + private async readStoredBackup(metadataPath: string): Promise { + try { + const backupId = path.basename(metadataPath, '.json') + if (!/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(backupId)) { + return undefined + } + const metadataFile = await lstat(metadataPath) + if (metadataFile.isSymbolicLink() || !metadataFile.isFile() || metadataFile.size > BACKUP_METADATA_MAX_BYTES) { + return undefined + } + const backup = JSON.parse(await readFile(metadataPath, 'utf8')) as StoredArtifactBackup + if ( + backup.backupId !== backupId + || backup.contentFileName !== `${backupId}.backup` + || typeof backup.toolId !== 'string' + || typeof backup.artifactId !== 'string' + || typeof backup.originalPath !== 'string' + || typeof backup.createdAt !== 'string' + || typeof backup.size !== 'number' + ) return undefined + const contentFile = await lstat(ensurePathWithinBase( + path.join(this.backupDirectory, backup.contentFileName), + this.backupDirectory, + '配置备份内容文件' + )) + if (contentFile.isSymbolicLink() || !contentFile.isFile() || contentFile.size > CONFIG_ARTIFACT_MAX_BYTES) { + return undefined + } + return backup + } catch { + return undefined + } + } + + /** + * 串行执行 backup create/prune,避免并发请求突破 retention 上限。 + * @param operation backup mutation + * @returns operation result + */ + private enqueueBackupMutation(operation: () => Promise): Promise { + const result = this.backupMutationQueue.then(operation) + this.backupMutationQueue = result.then(() => undefined, () => undefined) + return result + } + + /** + * 创建 service instance 内严格递增的 ISO timestamp。 + * @returns ISO-8601 timestamp + */ + private createMonotonicBackupTimestamp(): string { + const timestamp = Math.max(Date.now(), this.lastBackupCreatedAtMs + 1) + this.lastBackupCreatedAtMs = timestamp + return new Date(timestamp).toISOString() + } + + /** + * 清理同一 artifact/path 超出上限的最旧备份。 + * @param currentBackup 刚创建并校验通过的 backup + */ + private async pruneBackups(currentBackup: StoredArtifactBackup): Promise { + const fileNames = await readdir(this.backupDirectory) + const backups = await Promise.all(fileNames + .filter((fileName) => /^[0-9a-f-]{36}\.json$/i.test(fileName)) + .map((fileName) => this.readStoredBackup(ensurePathWithinBase( + path.join(this.backupDirectory, fileName), + this.backupDirectory, + '配置备份元数据文件' + )))) + const matchingBackups = backups + .filter((backup): backup is StoredArtifactBackup => Boolean( + backup + && backup.toolId === currentBackup.toolId + && backup.artifactId === currentBackup.artifactId + && backup.originalPath === currentBackup.originalPath + )) + .sort((left, right) => right.createdAt.localeCompare(left.createdAt)) + const expiredBackups = matchingBackups.slice(this.maxBackupsPerArtifact) + await Promise.all(expiredBackups.flatMap((backup) => [ + rm(ensurePathWithinBase( + path.join(this.backupDirectory, `${backup.backupId}.json`), + this.backupDirectory, + '配置备份元数据文件' + ), { force: true }), + rm(ensurePathWithinBase( + path.join(this.backupDirectory, backup.contentFileName), + this.backupDirectory, + '配置备份内容文件' + ), { force: true }) + ])) + } + + /** + * 限制 renderer 提交的 UTF-8 内容大小。 + * @param content 配置文本 + */ + private assertContentSize(content: string): void { + if (typeof content !== 'string') throw new Error('配置内容必须是 string') + if (Buffer.byteLength(content, 'utf8') > CONFIG_ARTIFACT_MAX_BYTES) { + throw new Error(`配置内容超过限制: ${CONFIG_ARTIFACT_MAX_BYTES} bytes`) + } + } + + /** + * 在目标目录内写入随机 temp file 并原子替换。 + * @param targetPath 目标绝对路径 + * @param content UTF-8 文本 + */ + private async writeTextAtomic(targetPath: string, content: string): Promise { + const tempPath = path.join(path.dirname(targetPath), `.${path.basename(targetPath)}.${randomUUID()}.tmp`) + const fileHandle = await open(tempPath, 'wx') + try { + await fileHandle.writeFile(content, 'utf8') + await fileHandle.sync() + } finally { + await fileHandle.close() + } + try { + await rename(tempPath, targetPath) + } catch (error) { + await rm(tempPath, { force: true }) + throw error + } + } + + /** + * 移除内部 backup content filename。 + * @param backup 持久化 metadata + * @returns renderer-safe backup metadata + */ + private toPublicBackup(backup: StoredArtifactBackup): ConfigArtifactBackup { + return { + backupId: backup.backupId, + toolId: backup.toolId, + artifactId: backup.artifactId, + originalPath: backup.originalPath, + size: backup.size, + createdAt: backup.createdAt + } + } +} + +/** 默认通用 artifact management service */ +export const toolArtifactManagementService = new ToolArtifactManagementService() diff --git a/src/main/services/tool-config-set-service.ts b/src/main/services/tool-config-set-service.ts new file mode 100644 index 0000000..decf002 --- /dev/null +++ b/src/main/services/tool-config-set-service.ts @@ -0,0 +1,481 @@ +/** + * @file src/main/services/tool-config-set-service.ts + * @description Registry 驱动的多工具"配置集"服务:对 configSet 分组 artifacts 做命名快照、 + * 编辑与整体切换。快照存储在 CCB 数据目录(config-sets///),激活时逐文件 + * 复用既有 per-artifact 授权/校验/备份/原子写链路,不引入新的写路径。 + */ + +import { randomUUID } from 'crypto' +import { mkdir, readFile, readdir, rename, rm, stat, writeFile } from 'fs/promises' +import path from 'path' +import type { + ConfigArtifactDefinition, + ToolConfigSetContent, + ToolConfigSetFileSummary, + ToolConfigSetSummary +} from '@shared/tool-registry' +import type { ToolRegistryService } from './tool-registry-service' +import { toolRegistryService } from './tool-registry-service' +import type { ToolArtifactDiscoveryService } from './tool-artifact-discovery-service' +import { toolArtifactDiscoveryService } from './tool-artifact-discovery-service' +import type { ToolArtifactManagementService } from './tool-artifact-management-service' +import { toolArtifactManagementService } from './tool-artifact-management-service' +import { pathManager } from '../utils/path-manager' +import { ensurePathWithinBase } from '../utils/path-security' +import { logger } from '../utils/logger' + +/** 单个配置集文件内容上限(与 artifact 读取限制对齐) */ +const CONFIG_SET_MAX_FILE_BYTES = 1024 * 1024 +/** 配置集显示名最大长度 */ +const CONFIG_SET_NAME_MAX_LENGTH = 48 +/** 显示名合法字符:中英文、数字、空格、连字符、下划线、点 */ +const CONFIG_SET_NAME_PATTERN = /^[\w\u4e00-\u9fa5][\w\u4e00-\u9fa5 .-]*$/ + +/** 配置集持久化元数据 */ +interface StoredConfigSetMetadata { + setId: string + name: string + createdAt: string + lastModifiedAt: string + artifacts: string[] +} + +export interface ToolConfigSetServiceOptions { + registryService?: ToolRegistryService + discoveryService?: ToolArtifactDiscoveryService + managementService?: ToolArtifactManagementService + /** 配置集根目录(默认 /config-sets) */ + baseDirectory?: string +} + +/** + * 多工具配置集 service。 + * @description 工具与分组完全来自 effective registry 的 configSet 声明;快照目录按 setId(随机 UUID + * 派生)寻址,显示名仅存于元数据,杜绝名字到路径的注入面。 + */ +export class ToolConfigSetService { + private readonly registryService: ToolRegistryService + private readonly discoveryService: ToolArtifactDiscoveryService + private readonly managementService: ToolArtifactManagementService + private readonly baseDirectory: string + + constructor(options: ToolConfigSetServiceOptions = {}) { + this.registryService = options.registryService ?? toolRegistryService + this.discoveryService = options.discoveryService ?? toolArtifactDiscoveryService + this.managementService = options.managementService ?? toolArtifactManagementService + this.baseDirectory = options.baseDirectory ?? path.join(pathManager.appDataDir, 'config-sets') + } + + /** + * 列出工具的全部配置集(含 isInUse 比对结果)。 + */ + public async listConfigSets(toolId: string): Promise { + const members = await this.requireConfigSetMembers(toolId) + const toolDirectory = this.getToolDirectory(toolId) + let entries: string[] + try { + entries = await readdir(toolDirectory) + } catch { + return [] + } + + const summaries: ToolConfigSetSummary[] = [] + for (const entry of entries) { + const metadata = await this.readSetMetadata(toolId, entry) + if (!metadata) continue + const files: ToolConfigSetFileSummary[] = [] + let allFilesPresent = true + for (const artifactId of metadata.artifacts) { + const member = members.find((candidate) => candidate.artifactId === artifactId) + const filePath = this.getSetFilePath(toolId, entry, artifactId) + try { + const fileStat = await stat(filePath) + files.push({ artifactId, format: member?.format ?? 'TEXT', size: fileStat.size }) + } catch { + allFilesPresent = false + } + } + if (!allFilesPresent) continue + const isInUse = await this.computeInUse(toolId, entry, members) + summaries.push({ + toolId, + setId: metadata.setId, + name: metadata.name, + createdAt: metadata.createdAt, + lastModifiedAt: metadata.lastModifiedAt, + files, + isInUse + }) + } + summaries.sort((a, b) => a.createdAt.localeCompare(b.createdAt)) + return summaries + } + + /** + * 从当前生效配置创建命名配置集快照。 + * @param toolId stable tool identifier + * @param name 显示名 + * @returns 新配置集摘要 + */ + public async createConfigSet(toolId: string, name: string): Promise { + const members = await this.requireConfigSetMembers(toolId) + this.assertValidName(name) + await this.assertNameAvailable(toolId, name) + + const contents: Array<{ artifactId: string; content: string }> = [] + for (const member of members) { + contents.push({ + artifactId: member.artifactId, + content: await this.readLiveContentOrTemplate(toolId, member) + }) + } + return this.writeConfigSet(toolId, name, members, contents) + } + + /** + * 从外部提供的内容创建命名配置集(云模板导入链路)。 + * @description 仅接受 configSet 成员的 artifactId;模板未覆盖的成员回退到当前生效内容或 + * registry 默认模板。全部内容先校验后写入,任何失败不留半成品快照。 + * @param toolId stable tool identifier + * @param name 显示名 + * @param files 模板提供的文件内容(artifactId → content,可覆盖部分成员) + * @returns 新配置集摘要 + */ + public async createConfigSetFromContents( + toolId: string, + name: string, + files: Array<{ artifactId: string; content: string }> + ): Promise { + const members = await this.requireConfigSetMembers(toolId) + this.assertValidName(name) + await this.assertNameAvailable(toolId, name) + + const memberByArtifact = new Map(members.map((member) => [member.artifactId, member])) + const providedByArtifact = new Map() + for (const file of files) { + const member = memberByArtifact.get(file.artifactId) + if (!member) throw new Error(`配置集不包含该文件: ${file.artifactId}`) + if (providedByArtifact.has(file.artifactId)) { + throw new Error(`配置集文件重复提供: ${file.artifactId}`) + } + this.assertContentSize(file.content) + providedByArtifact.set(file.artifactId, file.content) + } + if (providedByArtifact.size === 0) throw new Error('配置集导入内容为空') + + const contents: Array<{ artifactId: string; content: string }> = [] + for (const member of members) { + const provided = providedByArtifact.get(member.artifactId) + contents.push({ + artifactId: member.artifactId, + content: provided !== undefined + ? provided + : await this.readLiveContentOrTemplate(toolId, member) + }) + } + return this.writeConfigSet(toolId, name, members, contents) + } + + /** + * 写入新配置集目录(全部校验通过后逐文件原子写 + 元数据;失败清理半成品)。 + */ + private async writeConfigSet( + toolId: string, + name: string, + members: ConfigArtifactDefinition[], + contents: Array<{ artifactId: string; content: string }> + ): Promise { + const setId = `set-${randomUUID().slice(0, 12)}` + const setDirectory = this.getSetDirectory(toolId, setId) + await mkdir(setDirectory, { recursive: true }) + + const now = new Date().toISOString() + try { + for (const file of contents) { + this.assertContentSize(file.content) + await this.writeSetFileAtomic(toolId, setId, file.artifactId, file.content) + } + if (contents.length === 0) throw new Error('配置集没有任何可快照的文件') + + const metadata: StoredConfigSetMetadata = { + setId, + name, + createdAt: now, + lastModifiedAt: now, + artifacts: members.map((member) => member.artifactId) + } + await this.writeSetMetadataAtomic(toolId, setId, metadata) + } catch (error) { + await rm(setDirectory, { recursive: true, force: true }) + throw error + } + + logger.info(`配置集已创建: ${toolId}/${setId} (${name})`) + const summaries = await this.listConfigSets(toolId) + const created = summaries.find((summary) => summary.setId === setId) + if (!created) throw new Error('配置集创建后无法读取') + return created + } + + /** + * 读取配置集内容(编辑/预览)。 + */ + public async readConfigSet(toolId: string, setId: string): Promise { + const members = await this.requireConfigSetMembers(toolId) + const metadata = await this.requireSetMetadata(toolId, setId) + const files: ToolConfigSetContent['files'] = [] + for (const artifactId of metadata.artifacts) { + const member = members.find((candidate) => candidate.artifactId === artifactId) + if (!member) continue + const content = await this.readSetFile(toolId, setId, artifactId) + files.push({ artifactId, format: member.format, content }) + } + return { toolId, setId, name: metadata.name, files } + } + + /** + * 保存配置集内容(仅写入 CCB 快照目录,不触碰任何生效配置文件)。 + */ + public async saveConfigSetContent( + toolId: string, + setId: string, + files: Array<{ artifactId: string; content: string }> + ): Promise { + const members = await this.requireConfigSetMembers(toolId) + const metadata = await this.requireSetMetadata(toolId, setId) + const memberByArtifact = new Map(members.map((member) => [member.artifactId, member])) + const requested = new Set(files.map((file) => file.artifactId)) + for (const artifactId of metadata.artifacts) { + if (!requested.has(artifactId)) { + throw new Error(`缺少配置集文件内容: ${artifactId}`) + } + } + + // 先全部校验,后写入,避免半更新的快照 + for (const file of files) { + const member = memberByArtifact.get(file.artifactId) + if (!member) throw new Error(`配置集不包含该文件: ${file.artifactId}`) + this.assertContentSize(file.content) + if (member.capabilities.includes('VALIDATE')) { + await this.managementService.validateArtifact(toolId, file.artifactId, '', file.content) + } + } + for (const file of files) { + await this.writeSetFileAtomic(toolId, setId, file.artifactId, file.content) + } + metadata.lastModifiedAt = new Date().toISOString() + await this.writeSetMetadataAtomic(toolId, setId, metadata) + logger.info(`配置集内容已保存: ${toolId}/${setId}`) + } + + /** + * 激活配置集:全组校验通过后,逐文件将快照内容写入生效配置(复用既有授权/备份/原子写链)。 + */ + public async activateConfigSet(toolId: string, setId: string): Promise { + const metadata = await this.requireSetMetadata(toolId, setId) + const content = await this.readConfigSet(toolId, setId) + if (content.files.length === 0) throw new Error('配置集为空,无法激活') + + // 先全部校验,再逐文件写;任何一步失败中止(已写文件保留各自备份可恢复) + for (const file of content.files) { + await this.managementService.validateArtifact(toolId, file.artifactId, '', file.content) + } + for (const file of content.files) { + await this.managementService.editArtifact(toolId, file.artifactId, '', file.content) + } + logger.info(`配置集已激活: ${toolId}/${setId} (${metadata.name})`) + } + + /** + * 删除配置集。 + */ + public async deleteConfigSet(toolId: string, setId: string): Promise { + const setDirectory = this.getSetDirectory(toolId, setId) + ensurePathWithinBase(setDirectory, this.getToolDirectory(toolId), '配置集目录') + await rm(setDirectory, { recursive: true, force: true }) + logger.info(`配置集已删除: ${toolId}/${setId}`) + } + + /** + * 获取工具的 configSet 成员定义(声明顺序)。 + */ + private async requireConfigSetMembers(toolId: string): Promise { + const tool = await this.registryService.getTool(toolId) + if (!tool) throw new Error(`工具定义不存在: ${toolId}`) + const members = tool.artifacts.filter((artifact) => artifact.configSet !== undefined) + if (members.length === 0) { + throw new Error(`工具未声明任何 configSet artifact: ${toolId}`) + } + return members + } + + /** + * 读取生效文件内容;文件不存在时回退 registry 声明的默认模板。 + */ + private async readLiveContentOrTemplate( + toolId: string, + member: ConfigArtifactDefinition + ): Promise { + if (!member.capabilities.includes('READ')) { + throw new Error(`配置集成员未声明 READ capability: ${member.artifactId}`) + } + try { + const content = await this.discoveryService.readArtifact(toolId, member.artifactId, '') + return content.content + } catch (error) { + const nodeError = error as NodeJS.ErrnoException + if (nodeError.code !== 'ENOENT' && !this.isMissingFileError(error)) { + throw error + } + return member.defaultTemplate ?? '' + } + } + + /** + * 判断错误是否为"文件不存在"(readArtifact 对缺失文件抛出 Error,需按消息或 code 识别)。 + */ + private isMissingFileError(error: unknown): boolean { + return error instanceof Error && error.message.includes('ENOENT') + } + + /** + * 比对快照内容与当前生效内容,判断配置集是否在用。 + */ + private async computeInUse( + toolId: string, + setId: string, + members: ConfigArtifactDefinition[] + ): Promise { + const metadata = await this.readSetMetadata(toolId, setId) + if (!metadata) return false + for (const artifactId of metadata.artifacts) { + const member = members.find((candidate) => candidate.artifactId === artifactId) + if (!member) continue + let liveContent: string + try { + liveContent = (await this.discoveryService.readArtifact(toolId, artifactId, '')).content + } catch { + return false + } + const snapshotContent = await this.readSetFile(toolId, setId, artifactId) + if (liveContent !== snapshotContent) return false + } + return true + } + + /** + * 校验配置集显示名。 + */ + private assertValidName(name: string): void { + if ( + typeof name !== 'string' || + name.length === 0 || + name.length > CONFIG_SET_NAME_MAX_LENGTH || + !CONFIG_SET_NAME_PATTERN.test(name) || + name.includes('..') + ) { + throw new Error(`配置集名称不合法(1-${CONFIG_SET_NAME_MAX_LENGTH} 位中英文/数字/空格/._-)`) + } + } + + /** + * 确保显示名不重复(大小写不敏感)。 + */ + private async assertNameAvailable(toolId: string, name: string): Promise { + const existing = await this.listConfigSets(toolId) + if (existing.some((summary) => summary.name.toLowerCase() === name.toLowerCase())) { + throw new Error(`配置集名称已存在: ${name}`) + } + } + + private getToolDirectory(toolId: string): string { + if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(toolId)) { + throw new Error(`非法 toolId: ${toolId}`) + } + return path.join(this.baseDirectory, toolId) + } + + private getSetDirectory(toolId: string, setId: string): string { + if (!/^set-[a-f0-9-]+$/.test(setId)) { + throw new Error(`非法 setId: ${setId}`) + } + return path.join(this.getToolDirectory(toolId), setId) + } + + private getSetFilePath(toolId: string, setId: string, artifactId: string): string { + if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(artifactId)) { + throw new Error(`非法 artifactId: ${artifactId}`) + } + return path.join(this.getSetDirectory(toolId, setId), `${artifactId}.txt`) + } + + private getSetMetadataPath(toolId: string, setId: string): string { + return path.join(this.getSetDirectory(toolId, setId), 'set.json') + } + + private async readSetMetadata( + toolId: string, + setId: string + ): Promise { + try { + const raw = await readFile(this.getSetMetadataPath(toolId, setId), 'utf8') + const parsed = JSON.parse(raw) as StoredConfigSetMetadata + if (parsed.setId !== setId || !Array.isArray(parsed.artifacts)) return null + return parsed + } catch { + return null + } + } + + private async requireSetMetadata(toolId: string, setId: string): Promise { + const metadata = await this.readSetMetadata(toolId, setId) + if (!metadata) throw new Error(`配置集不存在: ${toolId}/${setId}`) + return metadata + } + + private async readSetFile(toolId: string, setId: string, artifactId: string): Promise { + const filePath = this.getSetFilePath(toolId, setId, artifactId) + const fileStat = await stat(filePath) + if (!fileStat.isFile() || fileStat.size > CONFIG_SET_MAX_FILE_BYTES) { + throw new Error('配置集文件不是允许大小的普通文件') + } + return readFile(filePath, 'utf8') + } + + /** + * 原子写入配置集文件(同目录 temp + rename)。 + */ + private async writeSetFileAtomic( + toolId: string, + setId: string, + artifactId: string, + content: string + ): Promise { + this.assertContentSize(content) + const targetPath = this.getSetFilePath(toolId, setId, artifactId) + const tempPath = `${targetPath}.${randomUUID().slice(0, 8)}.tmp` + await mkdir(path.dirname(targetPath), { recursive: true }) + await writeFile(tempPath, content, 'utf8') + await rename(tempPath, targetPath) + } + + private async writeSetMetadataAtomic( + toolId: string, + setId: string, + metadata: StoredConfigSetMetadata + ): Promise { + const targetPath = this.getSetMetadataPath(toolId, setId) + const tempPath = `${targetPath}.${randomUUID().slice(0, 8)}.tmp` + await writeFile(tempPath, JSON.stringify(metadata, null, 2), 'utf8') + await rename(tempPath, targetPath) + } + + private assertContentSize(content: string): void { + if (Buffer.byteLength(content, 'utf8') > CONFIG_SET_MAX_FILE_BYTES) { + throw new Error(`配置集文件超过 ${CONFIG_SET_MAX_FILE_BYTES} bytes 限制`) + } + } +} + +/** 默认共享实例 */ +export const toolConfigSetService = new ToolConfigSetService() diff --git a/src/main/services/tool-detection-service.ts b/src/main/services/tool-detection-service.ts new file mode 100644 index 0000000..2ca8255 --- /dev/null +++ b/src/main/services/tool-detection-service.ts @@ -0,0 +1,336 @@ +/** + * @file src/main/services/tool-detection-service.ts + * @description 安全解析规则库路径,并以无 shell 的方式执行 AI 工具安装检测器。 + */ + +import { execFile } from 'child_process' +import { access } from 'fs/promises' +import os from 'os' +import path from 'path' +import type { + ToolDefinition, + ToolDetectorDefinition, + ToolDetectionResult, + ToolPlatform +} from '@shared/tool-registry' +import { pathManager } from '../utils/path-manager' + +/** 规则路径允许引用的根变量 */ +export const TOOL_PATH_VARIABLES = [ + 'HOME', + 'APPDATA', + 'LOCALAPPDATA', + 'XDG_CONFIG_HOME', + 'CCB_DATA' +] as const + +/** 规则路径根变量名称 */ +export type ToolPathVariable = typeof TOOL_PATH_VARIABLES[number] + +/** 单项 detector 的可审计执行结果 */ +export interface ToolDetectorExecutionResult { + /** detector 在工具定义中的位置 */ + index: number + /** detector 类型 */ + type: ToolDetectorDefinition['type'] + /** 当前 detector 是否命中 */ + matched: boolean + /** PATH_EXISTS 安全解析后的路径 */ + resolvedPath?: string + /** COMMAND_EXISTS 校验后的命令名 */ + command?: string + /** 非预期输入或执行失败的安全错误摘要 */ + error?: string +} + +/** 包含逐项详情的工具检测结果 */ +export interface DetailedToolDetectionResult extends ToolDetectionResult { + /** 每个 detector 的独立执行结果 */ + detectorResults: ToolDetectorExecutionResult[] +} + +/** detector service 可替换依赖,主要用于隔离测试和平台模拟 */ +export interface ToolDetectionServiceOptions { + /** 目标运行平台,默认使用当前 Node.js 平台 */ + platform?: NodeJS.Platform + /** 路径根变量覆盖值 */ + pathVariables?: Partial> + /** 文件存在性检查器 */ + pathExists?: (targetPath: string) => Promise + /** command lookup 执行器 */ + commandExists?: (command: string, platform: ToolPlatform) => Promise +} + +const COMMAND_NAME_PATTERN = /^[A-Za-z0-9._+-]+$/ +const PATH_VARIABLE_PATTERN = /^\$\{([A-Z0-9_]+)\}(?:[/\\](.*))?$/ +const FORBIDDEN_PATH_CHARACTER_PATTERN = /[\0*?<>|"`]/ +const TOOL_PATH_VARIABLE_SET = new Set(TOOL_PATH_VARIABLES) + +/** + * 将 Node.js 平台映射为规则库平台枚举。 + * @param platform Node.js 平台标识 + * @returns 对应规则库平台 + * @throws 不支持的平台不会被静默归入 LINUX + */ +export function mapNodePlatform(platform: NodeJS.Platform): ToolPlatform { + if (platform === 'win32') return 'WINDOWS' + if (platform === 'darwin') return 'MACOS' + if (platform === 'linux') return 'LINUX' + throw new Error(`不支持的工具检测平台: ${platform}`) +} + +/** + * 按目标平台选择路径实现,确保跨平台规则测试不依赖宿主机。 + * @param platform 规则库平台 + * @returns Windows 或 POSIX path implementation + */ +function getPathImplementation(platform: ToolPlatform): path.PlatformPath { + return platform === 'WINDOWS' ? path.win32 : path.posix +} + +/** + * 判断路径是否为 UNC 路径。 + * @param targetPath 待判断路径 + * @returns 是否使用 UNC 形式 + */ +function isUncPath(targetPath: string): boolean { + return /^[\\/]{2}/.test(targetPath) +} + +/** + * 创建默认路径变量映射。 + * @param platform 当前规则平台 + * @returns 仅包含可用绝对根路径的映射 + */ +function createDefaultPathVariables(platform: ToolPlatform): Partial> { + const home = os.homedir() + const xdgConfigHome = process.env.XDG_CONFIG_HOME + || (platform === 'WINDOWS' ? undefined : path.posix.join(home.replace(/\\/g, '/'), '.config')) + + return { + HOME: home, + APPDATA: process.env.APPDATA, + LOCALAPPDATA: process.env.LOCALAPPDATA, + XDG_CONFIG_HOME: xdgConfigHome, + CCB_DATA: pathManager.appDataDir + } +} + +/** + * 解析受控规则路径,并证明结果仍位于声明变量的根目录内。 + * @param template 以 allowlist 根变量开头的路径模板 + * @param platform 目标规则平台 + * @param pathVariables 根变量实际绝对路径 + * @returns 安全规范化后的绝对路径 + * @throws 模板越界、包含未知变量、UNC、glob 或缺少根变量时拒绝解析 + */ +export function resolveToolPath( + template: string, + platform: ToolPlatform, + pathVariables: Partial> +): string { + if (!template || FORBIDDEN_PATH_CHARACTER_PATTERN.test(template) || isUncPath(template)) { + throw new Error('路径模板包含不允许的字符或路径结构') + } + + const match = template.match(PATH_VARIABLE_PATTERN) + if (!match || !TOOL_PATH_VARIABLE_SET.has(match[1])) { + throw new Error('路径模板必须从允许的根变量开始') + } + + const variable = match[1] as ToolPathVariable + const relativePath = match[2] ?? '' + if (relativePath.includes('${') || /(^|[/\\])\.\.?(?:[/\\]|$)/.test(relativePath)) { + throw new Error('路径模板包含变量注入或 traversal') + } + + const pathImplementation = getPathImplementation(platform) + const rawRoot = pathVariables[variable] + if (!rawRoot || !pathImplementation.isAbsolute(rawRoot) || isUncPath(rawRoot)) { + throw new Error(`路径根变量 ${variable} 不可用或不是受支持的绝对路径`) + } + + const normalizedRoot = pathImplementation.resolve(rawRoot) + const normalizedRelativePath = relativePath.replace(/[\\/]+/g, pathImplementation.sep) + const resolvedPath = pathImplementation.resolve(normalizedRoot, normalizedRelativePath) + const relativeToRoot = pathImplementation.relative(normalizedRoot, resolvedPath) + const escapedRoot = relativeToRoot === '..' + || relativeToRoot.startsWith(`..${pathImplementation.sep}`) + || pathImplementation.isAbsolute(relativeToRoot) + + if (escapedRoot || isUncPath(resolvedPath)) { + throw new Error('解析后的路径超出允许根目录') + } + + return resolvedPath +} + +/** + * 使用操作系统 locator 和参数数组检查 command,绝不经过 shell。 + * @param command 已通过 executable name 校验的命令 + * @param platform 目标规则平台 + * @returns locator 是否成功找到命令 + */ +async function lookupCommand(command: string, platform: ToolPlatform): Promise { + const locator = platform === 'WINDOWS' ? 'where.exe' : 'which' + + return new Promise((resolve) => { + execFile( + locator, + [command], + { timeout: 5_000, windowsHide: true, shell: false }, + (error) => resolve(error === null) + ) + }) +} + +/** + * 默认文件存在性检查器。 + * @param targetPath 已通过边界校验的绝对路径 + * @returns 文件或目录是否可访问 + */ +async function defaultPathExists(targetPath: string): Promise { + try { + await access(targetPath) + return true + } catch { + return false + } +} + +/** + * 安全执行规则库声明的工具 detectors。 + * @description detectors 使用 any-match;单项错误会记录但不会中止其余检测。 + */ +export class ToolDetectionService { + private readonly platform: ToolPlatform + private readonly pathVariables: Partial> + private readonly pathExists: (targetPath: string) => Promise + private readonly commandExists: (command: string, platform: ToolPlatform) => Promise + + /** + * 创建工具检测服务。 + * @param options 平台、变量与测试替身 + */ + constructor(options: ToolDetectionServiceOptions = {}) { + this.platform = mapNodePlatform(options.platform ?? process.platform) + this.pathVariables = { + ...createDefaultPathVariables(this.platform), + ...options.pathVariables + } + this.pathExists = options.pathExists ?? defaultPathExists + this.commandExists = options.commandExists ?? lookupCommand + } + + /** + * 获取当前 detector 使用的规则平台。 + * @returns 当前规则平台 + */ + public getPlatform(): ToolPlatform { + return this.platform + } + + /** + * 使用 detector 相同的安全边界解析规则路径。 + * @param template registry 中经过校验的路径模板 + * @returns 安全规范化后的绝对路径 + */ + public resolvePath(template: string): string { + return resolveToolPath(template, this.platform, this.pathVariables) + } + + /** + * 并行检测 registry 中的工具。 + * @param tools 经过 registry validator 的工具定义列表 + * @returns 与输入顺序一致的检测结果 + */ + public async detectTools(tools: ToolDefinition[]): Promise { + return Promise.all(tools.map((tool) => this.detectTool(tool))) + } + + /** + * 对单个工具执行全部 detector 并汇总 any-match 结果。 + * @param tool 经过 registry validator 的工具定义 + * @returns 工具级汇总与逐项结果 + */ + public async detectTool(tool: ToolDefinition): Promise { + if (!tool.platforms.includes(this.platform)) { + const detectorResults = tool.detectors.map((detector, index) => ({ + index, + type: detector.type, + matched: false, + error: `工具不支持当前平台 ${this.platform}` + })) + return this.summarize(tool, detectorResults) + } + + const detectorResults = await Promise.all( + tool.detectors.map((detector, index) => this.executeDetector(detector, index)) + ) + return this.summarize(tool, detectorResults) + } + + /** + * 执行单个 detector。 + * @param detector detector definition + * @param index detector 在定义中的位置 + * @returns 单项可审计结果 + */ + private async executeDetector( + detector: ToolDetectorDefinition, + index: number + ): Promise { + try { + if (detector.type === 'COMMAND_EXISTS') { + const command = detector.command ?? '' + if (!COMMAND_NAME_PATTERN.test(command)) { + throw new Error('command 必须是无参数的安全 executable name') + } + return { + index, + type: detector.type, + command, + matched: await this.commandExists(command, this.platform) + } + } + + if (detector.type !== 'PATH_EXISTS') { + throw new Error(`不支持的 detector type: ${String(detector.type)}`) + } + const resolvedPath = this.resolvePath(detector.path ?? '') + return { + index, + type: detector.type, + resolvedPath, + matched: await this.pathExists(resolvedPath) + } + } catch (error) { + return { + index, + type: detector.type, + matched: false, + error: error instanceof Error ? error.message : String(error) + } + } + } + + /** + * 汇总 detector 结果。 + * @param tool 工具定义 + * @param detectorResults 逐项执行结果 + * @returns any-match 工具检测结果 + */ + private summarize( + tool: ToolDefinition, + detectorResults: ToolDetectorExecutionResult[] + ): DetailedToolDetectionResult { + const matchedDetectors = detectorResults.filter((result) => result.matched).length + return { + toolId: tool.toolId, + detected: matchedDetectors > 0, + matchedDetectors, + totalDetectors: detectorResults.length, + detectorResults + } + } +} diff --git a/src/main/services/tool-registry-service.ts b/src/main/services/tool-registry-service.ts new file mode 100644 index 0000000..3f22c27 --- /dev/null +++ b/src/main/services/tool-registry-service.ts @@ -0,0 +1,354 @@ +/** + * @file src/main/services/tool-registry-service.ts + * @description 管理内置、已安装与 last-known-good 工具规则库,提供安全安装、合并与回滚。 + */ + +import { createHash } from 'crypto' +import { promises as fs } from 'fs' +import builtinRegistryJson from '@shared/builtin-tool-registry.json' +import type { ToolDefinition, ToolRegistryBundle, ToolRegistrySnapshot } from '@shared/tool-registry' +import { + compareStrictSemVer, + REGISTRY_BUNDLE_MAX_BYTES, + validateToolRegistryBundle +} from '@shared/tool-registry-validator' +import { writeJsonAtomic } from '../utils/atomic-json-writer' +import { pathManager } from '../utils/path-manager' +import { logger } from '../utils/logger' + +/** Registry storage 所需路径 */ +export interface ToolRegistryPaths { + /** 当前已安装规则库 */ + installed: string + /** 当前规则库 metadata */ + metadata: string + /** 最近一次可用的旧规则库 */ + lastKnownGood: string +} + +/** 已安装规则库 metadata */ +export interface InstalledRegistryMetadata { + /** 安装的 registry version */ + registryVersion: string + /** 原始 bundle SHA-256 */ + sha256: string + /** 原始 bundle bytes */ + size: number + /** ISO-8601 安装时间 */ + installedAt: string + /** 规则来源 */ + source: 'REMOTE' | 'ROLLBACK' +} + +/** 显式回滚结果 */ +export interface RegistryRollbackResult { + /** 回滚目标:last-known-good 历史版本或 embedded 内置基线 */ + target: 'LAST_KNOWN_GOOD' | 'EMBEDDED' + /** 回滚后的 registry version */ + registryVersion: string +} + +/** 安装 bundle 输入 */ +export interface InstallRegistryBundleInput { + /** 下载到的 exact raw bytes */ + rawBytes: Buffer + /** manifest 声明的 SHA-256 */ + expectedSha256: string + /** manifest 声明的 bytes */ + expectedSize: number + /** manifest 声明的 registry version */ + expectedRegistryVersion: string + /** manifest 声明的最低应用版本 */ + expectedMinimumAppVersion: string + /** 当前应用版本 */ + currentAppVersion: string + /** 仅显式 rollback/debug 流程允许降级 */ + allowDowngrade?: boolean +} + +/** + * 计算 raw registry bundle 的 SHA-256 + * @param rawBytes 原始 JSON bytes + * @returns lowercase hex digest + */ +export function calculateRegistrySha256(rawBytes: string | Buffer): string { + const hash = createHash('sha256') + if (typeof rawBytes === 'string') { + hash.update(rawBytes, 'utf8') + } else { + hash.update(rawBytes) + } + return hash.digest('hex') +} + +/** + * 合并 embedded 与 installed bundle + * @description installed 中同 toolId 定义覆盖 embedded,其余 embedded tools 保留。 + * @param embedded 内置 bundle + * @param installed 已安装 bundle + * @returns 按 toolId 排序的 immutable-friendly tools 数组 + */ +export function mergeToolRegistryBundles( + embedded: ToolRegistryBundle, + installed?: ToolRegistryBundle +): ToolDefinition[] { + const definitions = new Map(embedded.tools.map((tool) => [tool.toolId, tool])) + for (const tool of installed?.tools ?? []) { + definitions.set(tool.toolId, tool) + } + return [...definitions.values()].sort((left, right) => left.toolId.localeCompare(right.toolId)) +} + +/** + * 工具规则库服务 + * @description 所有远程 bundle 必须先经过 hash、size、schema 与 app compatibility 校验。 + */ +export class ToolRegistryService { + private readonly paths: ToolRegistryPaths + private readonly embedded: ToolRegistryBundle + private cachedFingerprint?: string + private cachedSnapshot?: ToolRegistrySnapshot + private snapshotPromise?: Promise + + constructor(paths?: Partial) { + this.paths = { + installed: paths?.installed ?? pathManager.installedRegistryFile, + metadata: paths?.metadata ?? pathManager.installedRegistryMetadataFile, + lastKnownGood: paths?.lastKnownGood ?? pathManager.lastKnownGoodRegistryFile + } + const embeddedValidation = validateToolRegistryBundle(JSON.stringify(builtinRegistryJson)) + if (!embeddedValidation.success || !embeddedValidation.data) { + throw new Error(`内置工具规则库无效: ${embeddedValidation.errors.join('; ')}`) + } + this.embedded = embeddedValidation.data + } + + /** + * 获取当前 effective registry snapshot + * @returns embedded 与 installed/last-known-good 合并结果 + */ + public async getSnapshot(): Promise { + const fingerprint = await this.createStorageFingerprint() + if (this.cachedSnapshot && this.cachedFingerprint === fingerprint) { + return this.cachedSnapshot + } + if (this.snapshotPromise) return this.snapshotPromise + + this.snapshotPromise = this.loadSnapshot() + try { + const snapshot = await this.snapshotPromise + this.cachedFingerprint = await this.createStorageFingerprint() + this.cachedSnapshot = snapshot + return snapshot + } finally { + this.snapshotPromise = undefined + } + } + + /** + * 从本地 storage 加载并验证 effective registry。 + * @returns embedded 与 installed/last-known-good 合并结果 + */ + private async loadSnapshot(): Promise { + const installedResult = await this.readBundle(this.paths.installed) + if (installedResult.bundle) { + return { + embeddedVersion: this.embedded.registryVersion, + installedVersion: installedResult.bundle.registryVersion, + tools: mergeToolRegistryBundles(this.embedded, installedResult.bundle), + recoveredFromLastKnownGood: false + } + } + + const fallbackResult = await this.readBundle(this.paths.lastKnownGood) + if (fallbackResult.bundle) { + logger.warn(`installed registry 无法加载,使用 last-known-good: ${installedResult.error || '文件不存在'}`) + return { + embeddedVersion: this.embedded.registryVersion, + installedVersion: fallbackResult.bundle.registryVersion, + tools: mergeToolRegistryBundles(this.embedded, fallbackResult.bundle), + recoveredFromLastKnownGood: true + } + } + + return { + embeddedVersion: this.embedded.registryVersion, + tools: mergeToolRegistryBundles(this.embedded), + recoveredFromLastKnownGood: false + } + } + + /** + * 获取指定工具定义 + * @param toolId 稳定 tool identifier + * @returns 工具定义,不存在时返回 undefined + */ + public async getTool(toolId: string): Promise { + const snapshot = await this.getSnapshot() + return snapshot.tools.find((tool) => tool.toolId === toolId) + } + + /** + * 获取应用随包发布的工具定义 baseline。 + * @description 该接口只用于区分 embedded 与 effective registry ownership,绝不读取远程 storage。 + * @param toolId 稳定 tool identifier + * @returns 内置工具定义,不存在时返回 undefined + */ + public getEmbeddedTool(toolId: string): ToolDefinition | undefined { + return this.embedded.tools.find((tool) => tool.toolId === toolId) + } + + /** + * 安装用户明确批准下载的规则 bundle + * @param input 原始 bundle 与 manifest integrity 信息 + * @returns 新安装的 registry version + */ + public async installBundle(input: InstallRegistryBundleInput): Promise { + const actualSize = input.rawBytes.length + if (actualSize !== input.expectedSize) { + throw new Error(`规则库大小不匹配: expected=${input.expectedSize}, actual=${actualSize}`) + } + if (actualSize > REGISTRY_BUNDLE_MAX_BYTES) { + throw new Error(`规则库超过最大限制: ${REGISTRY_BUNDLE_MAX_BYTES}`) + } + const actualSha256 = calculateRegistrySha256(input.rawBytes) + if (actualSha256 !== input.expectedSha256) { + throw new Error('规则库 SHA-256 校验失败') + } + let rawJson: string + try { + rawJson = new TextDecoder('utf-8', { fatal: true }).decode(input.rawBytes) + } catch { + throw new Error('规则库不是有效 UTF-8') + } + const validation = validateToolRegistryBundle(rawJson) + if (!validation.success || !validation.data) { + throw new Error(`规则库结构无效: ${validation.errors.join('; ')}`) + } + const bundle = validation.data + if (bundle.registryVersion !== input.expectedRegistryVersion) { + throw new Error(`规则库版本与 manifest 不匹配: expected=${input.expectedRegistryVersion}, actual=${bundle.registryVersion}`) + } + if (bundle.minimumAppVersion !== input.expectedMinimumAppVersion) { + throw new Error( + `规则库最低应用版本与 manifest 不匹配: expected=${input.expectedMinimumAppVersion}, actual=${bundle.minimumAppVersion}` + ) + } + if (compareStrictSemVer(bundle.minimumAppVersion, input.currentAppVersion) > 0) { + throw new Error(`规则库要求 CCB >= ${bundle.minimumAppVersion}`) + } + const currentInstalled = await this.readBundle(this.paths.installed) + if ( + currentInstalled.bundle && + compareStrictSemVer(bundle.registryVersion, currentInstalled.bundle.registryVersion) < 0 && + !input.allowDowngrade + ) { + throw new Error(`拒绝规则库降级: ${currentInstalled.bundle.registryVersion} -> ${bundle.registryVersion}`) + } + + if (currentInstalled.bundle) { + await writeJsonAtomic(this.paths.lastKnownGood, currentInstalled.bundle) + } + await writeJsonAtomic(this.paths.installed, bundle) + const metadata: InstalledRegistryMetadata = { + registryVersion: bundle.registryVersion, + sha256: actualSha256, + size: actualSize, + installedAt: new Date().toISOString(), + source: 'REMOTE' + } + await writeJsonAtomic(this.paths.metadata, metadata) + this.invalidateSnapshotCache() + return bundle.registryVersion + } + + /** + * 显式回滚规则库 + * @description 优先恢复 last-known-good;首次安装后没有历史 bundle 时回退 embedded 基线 + * (清除 installed/metadata 残留,effective registry 回到内置合并结果)。 + * @returns 回滚目标与版本 + */ + public async rollback(): Promise { + const fallbackResult = await this.readBundle(this.paths.lastKnownGood) + if (fallbackResult.bundle) { + const fallbackRaw = JSON.stringify(fallbackResult.bundle, null, 2) + await writeJsonAtomic(this.paths.installed, fallbackResult.bundle) + const metadata: InstalledRegistryMetadata = { + registryVersion: fallbackResult.bundle.registryVersion, + sha256: calculateRegistrySha256(fallbackRaw), + size: Buffer.byteLength(fallbackRaw, 'utf8'), + installedAt: new Date().toISOString(), + source: 'ROLLBACK' + } + await writeJsonAtomic(this.paths.metadata, metadata) + this.invalidateSnapshotCache() + return { target: 'LAST_KNOWN_GOOD', registryVersion: fallbackResult.bundle.registryVersion } + } + + const installedResult = await this.readBundle(this.paths.installed) + if (!installedResult.bundle) { + throw new Error('当前没有已安装的远程规则库,无需回滚') + } + logger.warn( + `last-known-good 不可用(${fallbackResult.error || '文件不存在'}),回滚到内置规则库 ${this.embedded.registryVersion}` + ) + await fs.rm(this.paths.installed, { force: true }) + await fs.rm(this.paths.metadata, { force: true }) + await fs.rm(this.paths.lastKnownGood, { force: true }) + this.invalidateSnapshotCache() + return { target: 'EMBEDDED', registryVersion: this.embedded.registryVersion } + } + + /** 清除 effective snapshot cache */ + private invalidateSnapshotCache(): void { + this.cachedFingerprint = undefined + this.cachedSnapshot = undefined + } + + /** + * 使用 storage 文件 metadata 创建轻量 cache fingerprint。 + * @returns installed 与 last-known-good 的 mtime/size fingerprint + */ + private async createStorageFingerprint(): Promise { + const describe = async (filePath: string): Promise => { + try { + const metadata = await fs.stat(filePath, { bigint: true }) + return `${metadata.mtimeNs}:${metadata.ctimeNs}:${metadata.size}` + } catch (error) { + const nodeError = error as NodeJS.ErrnoException + if (nodeError.code === 'ENOENT') return 'missing' + throw error + } + } + const [installed, lastKnownGood] = await Promise.all([ + describe(this.paths.installed), + describe(this.paths.lastKnownGood) + ]) + return `${installed}|${lastKnownGood}` + } + + /** + * 读取并验证本地 bundle + * @param filePath bundle 路径 + * @returns bundle 或诊断错误 + */ + private async readBundle(filePath: string): Promise<{ bundle?: ToolRegistryBundle; error?: string }> { + try { + const rawJson = await fs.readFile(filePath, 'utf8') + const validation = validateToolRegistryBundle(rawJson) + if (!validation.success || !validation.data) { + return { error: validation.errors.join('; ') } + } + return { bundle: validation.data } + } catch (error) { + const nodeError = error as NodeJS.ErrnoException + if (nodeError.code === 'ENOENT') { + return {} + } + return { error: error instanceof Error ? error.message : String(error) } + } + } +} + +/** 默认工具规则库服务单例 */ +export const toolRegistryService = new ToolRegistryService() diff --git a/src/main/services/update-service.ts b/src/main/services/update-service.ts index 5fe2304..649b978 100644 --- a/src/main/services/update-service.ts +++ b/src/main/services/update-service.ts @@ -3,21 +3,29 @@ * @description 负责应用更新检查 */ -import axios from 'axios'; -import { app, Notification, shell } from 'electron'; +import { app, net, Notification, shell } from 'electron'; import { join } from 'path'; import fs from 'fs'; import { logger } from '../utils/logger'; -import { APP_INFO } from '@shared/constants'; +import { registryUpdateService } from './registry-update-service'; const VERSION_URL = 'https://dev.niansir.com/software/ccb/version.txt'; class UpdateService { public async checkForUpdates(): Promise { + const registryCheck = registryUpdateService.checkForUpdates(app.getVersion()).catch((error) => ({ + state: 'CHECK_FAILED' as const, + embeddedVersion: '0.0.0', + error: error instanceof Error ? error.message : String(error) + })); logger.info('正在检查更新...'); try { - const response = await axios.get(VERSION_URL, { timeout: 15000 }); - const versionInfo = this.parseVersionInfo(response.data); + // net.fetch 走 Chromium 网络栈,遵循系统代理设置(企业环境更友好) + const response = await net.fetch(VERSION_URL, { signal: AbortSignal.timeout(15000) }); + if (!response.ok) { + throw new Error(`版本检查请求失败: HTTP ${response.status}`); + } + const versionInfo = this.parseVersionInfo(await response.text()); if (!versionInfo.version) { logger.warn('无法从版本文件中解析出版本号。'); @@ -36,6 +44,13 @@ class UpdateService { } catch (error) { logger.error('检查更新失败:', error); } + + const registryStatus = await registryCheck; + if (registryStatus.state === 'UPDATE_AVAILABLE') { + logger.info(`发现规则库更新: ${registryStatus.availableVersion}`); + } else if (registryStatus.state === 'CHECK_FAILED') { + logger.warn(`规则库版本检查失败: ${registryStatus.error}`); + } } private parseVersionInfo(data: string): { version: string | null; text: string | null } { @@ -74,10 +89,7 @@ class UpdateService { const notification = new Notification({ title: `发现新版本 v${versionInfo.version}`, body: versionInfo.text || '建议您立即更新以获取最佳体验。', - icon: iconPath || undefined, - ...(process.platform === 'win32' && { - appUserModelId: APP_INFO.FULL_NAME - }) + icon: iconPath || undefined }); notification.on('click', () => { diff --git a/src/main/task-scheduler.ts b/src/main/task-scheduler.ts index 4e3241b..c8a6da9 100644 --- a/src/main/task-scheduler.ts +++ b/src/main/task-scheduler.ts @@ -67,11 +67,10 @@ export class TaskScheduler extends EventEmitter { return } - // 创建定时任务 - const task = cron.schedule(cronExpression, async () => { + // createTask 不会自动启动,确保 disabled rule 不会在注册瞬间执行 + const task = cron.createTask(cronExpression, async () => { await this.executeRule(rule) }, { - scheduled: false, // 先不启动 timezone: 'Asia/Shanghai' }) @@ -441,4 +440,4 @@ export class TaskScheduler extends EventEmitter { lastExecution: this.executionLog[0]?.timestamp || null } } -} \ No newline at end of file +} diff --git a/src/main/tray-manager.ts b/src/main/tray-manager.ts index 16f33f4..32bffa5 100644 --- a/src/main/tray-manager.ts +++ b/src/main/tray-manager.ts @@ -7,8 +7,11 @@ import { Tray, Menu, nativeImage, BrowserWindow, Notification, app, dialog, type import { join } from 'path' import fs from 'fs' import { APP_INFO } from '@shared/constants' +import type { ToolConfigSetSummary } from '@shared/tool-registry' import { logger } from './utils/logger' import { configService, managedModeService } from './ipc-handlers' +import { toolRegistryService } from './services/tool-registry-service' +import { toolConfigSetService } from './services/tool-config-set-service' interface TrayConfigSummary { name: string @@ -16,6 +19,13 @@ interface TrayConfigSummary { isInUse: boolean } +/** 非内置 claude 通道的工具配置集分组(托盘快速切换用) */ +interface TrayToolSetGroup { + toolId: string + label: string + sets: ToolConfigSetSummary[] +} + export class TrayManager { private tray: Tray | null = null private initialMenuRefreshTimer: NodeJS.Timeout | null = null @@ -35,7 +45,7 @@ export class TrayManager { this.tray.setToolTip(APP_INFO.FULL_NAME) // 启动阶段先使用占位菜单,避免与首屏同时扫描配置目录。 - this.setTrayMenu(null) + this.setTrayMenu(null, []) // 设置托盘事件 this.setupTrayEvents() @@ -87,39 +97,51 @@ export class TrayManager { private async createTrayMenu(): Promise { if (!this.tray) return - // 加载 claude-code 类型的配置列表 - const configs = await this.loadClaudeCodeConfigs() - this.setTrayMenu(configs) + // claude-code 走遗留配置通道,其余工具走 registry 配置集通道 + const [configs, toolGroups] = await Promise.all([this.loadClaudeCodeConfigs(), this.loadToolSetGroups()]) + this.setTrayMenu(configs, toolGroups) } /** * 设置托盘菜单内容 * @description 启动期可传入 `null` 展示占位菜单,等首屏稳定后再异步填充真实配置项。 */ - private setTrayMenu(configs: TrayConfigSummary[] | null): void { + private setTrayMenu(configs: TrayConfigSummary[] | null, toolGroups: TrayToolSetGroup[]): void { if (!this.tray) return - const quickSwitchSubmenu = - configs === null - ? [ - { - label: '加载配置中...', - enabled: false - } - ] - : configs.length > 0 - ? configs.map(config => ({ - label: config.isInUse ? `● ${config.name}` : ` ${config.name}`, + const buildConfigSetItems = (group: TrayToolSetGroup): Electron.MenuItemConstructorOptions => ({ + label: group.label, + submenu: + group.sets.length > 0 + ? group.sets.map(set => ({ + label: set.isInUse ? `● ${set.name}` : ` ${set.name}`, click: () => { - this.switchConfig(config.name, config.path) + void this.switchToolConfigSet(group.toolId, group.label, set.setId, set.name) } })) - : [ - { - label: '(无可用配置)', - enabled: false - } - ] + : [{ label: '(无配置集)', enabled: false }] + }) + + let quickSwitchSubmenu: Electron.MenuItemConstructorOptions[] + if (configs === null) { + quickSwitchSubmenu = [{ label: '加载配置中...', enabled: false }] + } else { + quickSwitchSubmenu = [ + { + label: 'Claude Code', + submenu: + configs.length > 0 + ? configs.map(config => ({ + label: config.isInUse ? `● ${config.name}` : ` ${config.name}`, + click: () => { + this.switchConfig(config.name, config.path) + } + })) + : [{ label: '(无可用配置)', enabled: false }] + }, + ...toolGroups.map(buildConfigSetItems) + ] + } const template: Electron.MenuItemConstructorOptions[] = [ { @@ -220,6 +242,35 @@ export class TrayManager { } } + /** + * 加载所有声明 configSet 分组的 registry 工具及其配置集列表 + * @description claude-code 走遗留通道不在此列;单个工具加载失败仅跳过,不影响整体菜单。 + */ + private async loadToolSetGroups(): Promise { + try { + const snapshot = await toolRegistryService.getSnapshot() + const groups: TrayToolSetGroup[] = [] + for (const tool of snapshot.tools) { + if (!tool.artifacts.some(artifact => artifact.configSet)) continue + let sets: ToolConfigSetSummary[] = [] + try { + sets = await toolConfigSetService.listConfigSets(tool.toolId) + } catch (error) { + logger.warn(`加载工具 ${tool.toolId} 配置集列表失败`, error) + } + groups.push({ + toolId: tool.toolId, + label: tool.displayName['zh-CN'] || tool.displayName['en-US'] || tool.toolId, + sets + }) + } + return groups + } catch (error) { + logger.error('加载 registry 工具快照失败:', error) + return [] + } + } + /** * 显示主窗口 */ @@ -293,10 +344,7 @@ export class TrayManager { new Notification({ title: '配置切换', body: `已切换到配置: ${configName}`, - icon: iconPath || undefined, - ...(process.platform === 'win32' && { - appUserModelId: APP_INFO.FULL_NAME - }) + icon: iconPath || undefined }).show() logger.info(`切换配置成功: ${configName} (${configPath})`) @@ -306,14 +354,61 @@ export class TrayManager { // 显示失败通知 new Notification({ title: '配置切换失败', - body: error instanceof Error ? error.message : String(error), - ...(process.platform === 'win32' && { - appUserModelId: APP_INFO.FULL_NAME - }) + body: error instanceof Error ? error.message : String(error) + }).show() + } + } + + /** + * 切换 registry 工具配置集(claude-code 之外的通用通道) + * @description 托管模式开启时同样拦截,仅弹出系统通知提示用户。 + */ + private async switchToolConfigSet(toolId: string, toolLabel: string, setId: string, setName: string): Promise { + try { + if (managedModeService.isManagedModeEnabled()) { + this.showManagedModeBlockedNotification(setName) + logger.info(`托管模式已开启,已拦截托盘切换配置集: ${toolId}/${setName} (${setId})`) + return + } + + await toolConfigSetService.activateConfigSet(toolId, setId) + + // 激活成功,发送切换配置事件给渲染进程以刷新UI + const mainWindow = BrowserWindow.getAllWindows()[0] + if (mainWindow) { + mainWindow.webContents.send('tray:switch-config', { name: setName, path: '', toolId }) + } + + new Notification({ + title: '配置切换', + body: `已切换 ${toolLabel} 配置集: ${setName}`, + icon: this.getNotificationIcon() + }).show() + + logger.info(`切换配置集成功: ${toolId}/${setName} (${setId})`) + } catch (error) { + logger.error('切换配置集失败:', error) + + new Notification({ + title: '配置切换失败', + body: error instanceof Error ? error.message : String(error) }).show() } } + /** + * 系统通知图标路径(Windows 用 ico,其余平台由系统回退) + */ + private getNotificationIcon(): string { + if (process.platform === 'win32') { + const icoPath = join(__dirname, '../../resources/icons/ccb.ico') + if (fs.existsSync(icoPath)) { + return icoPath + } + } + return '' + } + /** * 托管模式拦截托盘切换配置时的系统通知 * @param configName 被拦截切换的配置名称 @@ -332,10 +427,7 @@ export class TrayManager { new Notification({ title: '配置切换被拦截', body: `托管模式已开启,不允许切换到配置: ${configName}。请先关闭托管模式再操作。`, - icon: iconPath || undefined, - ...(process.platform === 'win32' && { - appUserModelId: APP_INFO.FULL_NAME - }) + icon: iconPath || undefined }).show() } catch (error) { logger.error('显示托管模式拦截通知失败:', error) @@ -375,7 +467,7 @@ export class TrayManager { } /** - * 更新托盘菜单(动态加载 claude-code 类型配置) + * 更新托盘菜单(动态加载 claude-code 配置与 registry 工具配置集) */ async updateTrayMenu(): Promise { if (!this.tray) return diff --git a/src/main/utils/claude-workspace-path-facade.ts b/src/main/utils/claude-workspace-path-facade.ts new file mode 100644 index 0000000..c5c8b55 --- /dev/null +++ b/src/main/utils/claude-workspace-path-facade.ts @@ -0,0 +1,73 @@ +/** + * @file Claude workspace path compatibility facade + * @description 集中管理 Claude Code 配置工作区路径,v1.5.0 保持 legacy 目录兼容且不移动用户数据。 + */ + +import path from 'path' + +/** Claude workspace 路径模式枚举值。 */ +export const CLAUDE_WORKSPACE_PATH_MODES = ['LEGACY_COMPAT', 'WORKSPACE_V2'] as const + +/** Claude workspace 路径模式。 */ +export type ClaudeWorkspacePathMode = typeof CLAUDE_WORKSPACE_PATH_MODES[number] + +/** Claude workspace 路径 snapshot。 */ +export interface ClaudeWorkspacePaths { + /** 当前业务必须使用的 active path。 */ + activePath: string + /** v1.4.x 与 v1.5.0 兼容目录。 */ + legacyPath: string + /** 未来显式 migration 的目标目录。 */ + workspacePath: string + /** 当前路径选择模式。 */ + mode: ClaudeWorkspacePathMode +} + +/** + * Claude workspace 路径兼容 facade。 + * @description 路径选择只由显式 mode 决定,不根据目录存在性隐式切换数据源。 + */ +export class ClaudeWorkspacePathFacade { + private readonly appDataDir: string + private readonly mode: ClaudeWorkspacePathMode + + constructor(appDataDir: string, mode: ClaudeWorkspacePathMode = 'LEGACY_COMPAT') { + if (!path.isAbsolute(appDataDir)) { + throw new Error('Claude workspace appDataDir 必须为绝对路径') + } + this.appDataDir = path.resolve(appDataDir) + this.mode = mode + } + + /** + * 获取 immutable-friendly workspace 路径 snapshot。 + */ + public getPaths(): ClaudeWorkspacePaths { + const legacyPath = path.join(this.appDataDir, 'claude-configs') + const workspacePath = path.join(this.appDataDir, 'workspaces', 'claude-code') + return { + activePath: this.mode === 'WORKSPACE_V2' ? workspacePath : legacyPath, + legacyPath, + workspacePath, + mode: this.mode + } + } + + /** + * 在 active workspace 内解析单个直接子文件。 + * @param fileName 不允许包含目录结构的文件名 + */ + public resolveActiveFile(fileName: string): string { + if ( + !fileName || + fileName === '.' || + fileName === '..' || + fileName.includes('/') || + fileName.includes('\\') || + fileName.includes('\0') + ) { + throw new Error('Claude workspace fileName 必须为直接子文件名') + } + return path.join(this.getPaths().activePath, fileName) + } +} diff --git a/src/main/utils/command-executor.ts b/src/main/utils/command-executor.ts index b045285..5fcc9f3 100644 --- a/src/main/utils/command-executor.ts +++ b/src/main/utils/command-executor.ts @@ -88,6 +88,7 @@ export async function executeCommand( return new Promise((resolve) => { let child: ReturnType try { + // nosemgrep: javascript.lang.security.detect-child-process.detect-child-process - parseCommand 拒绝 shell 元字符,且 shell:false 保持参数边界。 child = spawn(binary, args, { cwd: options.cwd, env: options.env, diff --git a/src/main/utils/path-manager.ts b/src/main/utils/path-manager.ts index c09db0e..0b58ddd 100644 --- a/src/main/utils/path-manager.ts +++ b/src/main/utils/path-manager.ts @@ -7,6 +7,7 @@ import path from 'path'; import os from 'os'; import { CONFIG_FILES, PATHS as PATH_CONSTANTS } from '@shared/constants'; +import { ClaudeWorkspacePathFacade } from './claude-workspace-path-facade'; // 使用用户主目录而不是程序运行目录 const HOME_DIR = os.homedir(); @@ -14,9 +15,9 @@ const HOME_DIR = os.homedir(); // CCB 主目录 (用户目录/.ccb) const APP_DATA_BASE_DIR = path.join(HOME_DIR, PATH_CONSTANTS.USER_DATA); -// Claude 配置目录 (用户目录/.ccb/claude-configs) -// 不再使用独立的 .claude 目录,统一管理到 .ccb 下 -const CLAUDE_CONFIGS_DIR = path.join(APP_DATA_BASE_DIR, PATH_CONSTANTS.CLAUDE_CONFIGS_DIR); +// v1.5.0 明确保持 legacy path,只有受控 migration 完成后才能切换 WORKSPACE_V2。 +export const claudeWorkspacePathFacade = new ClaudeWorkspacePathFacade(APP_DATA_BASE_DIR, 'LEGACY_COMPAT'); +const CLAUDE_WORKSPACE_PATHS = claudeWorkspacePathFacade.getPaths(); /** * 包含应用所有关键绝对路径的对象 @@ -34,14 +35,22 @@ export const pathManager = { logDir: path.join(APP_DATA_BASE_DIR, PATH_CONSTANTS.LOG_DIR), cacheDir: path.join(APP_DATA_BASE_DIR, PATH_CONSTANTS.CACHE_DIR), configDir: path.join(APP_DATA_BASE_DIR, PATH_CONSTANTS.CONFIG_DIR), + registryDir: path.join(APP_DATA_BASE_DIR, 'registry'), + toolArtifactBackupDir: path.join(APP_DATA_BASE_DIR, 'backups', 'tool-artifacts'), - // Claude 配置目录 (用户目录/.ccb/claude-configs) - claudeConfigsDir: CLAUDE_CONFIGS_DIR, + // Claude 配置目录 compatibility alias;v1.5.0 active path 仍为 ~/.ccb/claude-configs。 + claudeConfigsDir: CLAUDE_WORKSPACE_PATHS.activePath, + claudeLegacyConfigsDir: CLAUDE_WORKSPACE_PATHS.legacyPath, + claudeWorkspaceDir: CLAUDE_WORKSPACE_PATHS.workspacePath, + claudeWorkspaceMode: CLAUDE_WORKSPACE_PATHS.mode, // 具体文件路径 rulesFile: path.join(APP_DATA_BASE_DIR, PATH_CONSTANTS.DATA_DIR, CONFIG_FILES.RULES_FILE), ruleExecutionsLogFile: path.join(APP_DATA_BASE_DIR, PATH_CONSTANTS.DATA_DIR, 'rule-executions.json'), settingsFile: path.join(APP_DATA_BASE_DIR, PATH_CONSTANTS.CONFIG_DIR, CONFIG_FILES.SETTINGS), + installedRegistryFile: path.join(APP_DATA_BASE_DIR, 'registry', 'installed.json'), + installedRegistryMetadataFile: path.join(APP_DATA_BASE_DIR, 'registry', 'installed.meta.json'), + lastKnownGoodRegistryFile: path.join(APP_DATA_BASE_DIR, 'registry', 'last-known-good.json'), // Claude 用户目录相关路径(~/.claude)—— v1.4.0 新增,消除全代码库 os.homedir()+'.claude' 散落拼接 claudeDir: path.join(HOME_DIR, '.claude'), @@ -56,7 +65,7 @@ export const pathManager = { * @returns {string} 绝对路径 (用户目录/.ccb/claude-configs/文件名) */ getClaudeConfigPath(fileName: string): string { - return path.join(CLAUDE_CONFIGS_DIR, fileName); + return claudeWorkspacePathFacade.resolveActiveFile(fileName); }, /** diff --git a/src/main/utils/privilege-manager.ts b/src/main/utils/privilege-manager.ts index 174b647..7c9a76f 100644 --- a/src/main/utils/privilege-manager.ts +++ b/src/main/utils/privilege-manager.ts @@ -4,7 +4,7 @@ */ import { app, dialog } from 'electron' -import { exec } from 'child_process' +import { execFile } from 'child_process' import { promises as fs } from 'fs' import * as fsSync from 'fs' import { join } from 'path' @@ -41,6 +41,94 @@ export interface ElevationOptions { retryOnFailure?: boolean } +/** 参数化权限提升进程规格 */ +export interface ElevationLaunchSpec { + /** 允许执行的系统提权程序 */ + command: string + /** 直接传给提权程序的参数数组 */ + args: string[] +} + +const ELEVATION_COMMANDS = new Set(['powershell.exe', 'osascript', 'pkexec', 'sudo']) + +/** + * 将文本编码为 PowerShell 单引号字面量内容 + * @param value 原始参数 + * @returns 可安全放入 PowerShell 单引号字符串的内容 + */ +function escapePowerShellLiteral(value: string): string { + return value.replace(/'/g, "''") +} + +/** + * 将参数编码为 POSIX shell 单引号参数 + * @param value 原始参数 + * @returns 不会被 shell 解释为额外语法的参数文本 + */ +function quotePosixShellArgument(value: string): string { + return `'${value.replace(/'/g, `'\\''`)}'` +} + +/** + * 转义 AppleScript 双引号字符串内容 + * @param value 原始脚本文本 + * @returns 可安全嵌入 AppleScript 字符串的内容 + */ +function escapeAppleScriptString(value: string): string { + return value.replace(/\\/g, '\\\\').replace(/"/g, '\\"') +} + +/** + * 构造跨平台权限提升进程规格 + * @description 所有动态值均先按目标解释器转义,返回值必须通过 execFile 参数化执行。 + * @param platform 目标操作系统 + * @param currentExecutable 当前应用可执行文件 + * @param currentArgs 当前应用参数 + * @param linuxCommand Linux 上已探测可用的提权程序 + * @returns 受控 executable 与 argument array + */ +export function buildElevationLaunchSpec( + platform: NodeJS.Platform, + currentExecutable: string, + currentArgs: string[], + linuxCommand: 'pkexec' | 'sudo' = 'sudo' +): ElevationLaunchSpec { + if (platform === 'win32') { + const executableLiteral = escapePowerShellLiteral(currentExecutable) + const argumentListLiteral = currentArgs.length > 0 + ? `@(${currentArgs.map((arg) => `'${escapePowerShellLiteral(arg)}'`).join(', ')})` + : '@()' + + return { + command: 'powershell.exe', + args: [ + '-NoProfile', + '-Command', + `Start-Process -FilePath '${executableLiteral}' -ArgumentList ${argumentListLiteral} -Verb RunAs` + ] + } + } + + if (platform === 'darwin') { + const shellCommand = [currentExecutable, ...currentArgs] + .map(quotePosixShellArgument) + .join(' ') + + return { + command: 'osascript', + args: [ + '-e', + `do shell script "exec ${escapeAppleScriptString(shellCommand)}" with administrator privileges` + ] + } + } + + return { + command: linuxCommand, + args: [currentExecutable, ...currentArgs] + } +} + /** * 权限管理器类 */ @@ -299,45 +387,17 @@ export class PrivilegeManager { */ public async relaunchAsAdmin(): Promise { try { - const isWindows = process.platform === 'win32' - const isMacOS = process.platform === 'darwin' - const currentExecutable = process.execPath const currentArgs = process.argv.slice(1) - - let command: string - let args: string[] - - if (isWindows) { - // Windows: 使用 PowerShell 以管理员权限运行 - command = 'powershell.exe' - args = [ - '-Command', - 'Start-Process', - `"${currentExecutable}"`, - '-ArgumentList', - `"${currentArgs.join('" "').replace(/"/g, '""')}"`, - '-Verb', - 'RunAs' - ] - } else if (isMacOS) { - // macOS: 使用 osascript 提升权限 - command = 'osascript' - args = [ - '-e', - `do shell script "exec '${currentExecutable}' ${currentArgs.join(' ')}" with administrator privileges` - ] - } else { - // Linux: 使用 pkexec 或 sudo - const hasPkexec = await this.checkCommandExists('pkexec') - if (hasPkexec) { - command = 'pkexec' - args = [currentExecutable, ...currentArgs] - } else { - command = 'sudo' - args = [currentExecutable, ...currentArgs] - } - } + const linuxCommand = process.platform === 'linux' && await this.checkCommandExists('pkexec') + ? 'pkexec' + : 'sudo' + const { command, args } = buildElevationLaunchSpec( + process.platform, + currentExecutable, + currentArgs, + linuxCommand + ) logger.info(`准备以管理员权限重启应用: ${command} ${args.join(' ')}`) @@ -395,7 +455,7 @@ export class PrivilegeManager { } // 方法2: 使用 whoami /priv 检查权限 - exec('whoami /priv', (error: unknown, stdout: string, _stderr: string) => { + execFile('whoami', ['/priv'], (error: unknown, stdout: string, _stderr: string) => { if (!error) { // 检查是否包含 SeShutdownPrivilege 等管理员权限 const adminPrivileges = [ @@ -415,7 +475,7 @@ export class PrivilegeManager { } // 方法3: 检查管理员组SID - exec('whoami /groups', (error: unknown, stdout: string, _stderr: string) => { + execFile('whoami', ['/groups'], (error: unknown, stdout: string, _stderr: string) => { if (!error) { const adminIndicators = [ 'S-1-5-32-544', // Administrators group SID @@ -436,7 +496,7 @@ export class PrivilegeManager { } // 方法4: 尝试 net session 命令 - exec('net session', (netError: unknown, _netStdout: string, _netStderr: string) => { + execFile('net', ['session'], (netError: unknown, _netStdout: string, _netStderr: string) => { if (!netError) { logger.debug('方法4成功: net session 命令执行成功') resolve(true) @@ -444,7 +504,11 @@ export class PrivilegeManager { } // 方法5: 检查进程完整性级别 - exec('powershell -Command "([System.Security.Principal.WindowsPrincipal][System.Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)"', (psError: unknown, psStdout: string) => { + execFile('powershell.exe', [ + '-NoProfile', + '-Command', + '([System.Security.Principal.WindowsPrincipal][System.Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)' + ], (psError: unknown, psStdout: string) => { if (!psError && psStdout.includes('True')) { logger.debug('方法5成功: PowerShell 管理员角色检查') resolve(true) @@ -465,7 +529,7 @@ export class PrivilegeManager { */ private async checkMacOSAdminPrivileges(): Promise { return new Promise((resolve) => { - exec('id -un', (error: unknown, stdout: string) => { + execFile('id', ['-un'], (error: unknown, stdout: string) => { // 检查是否是 root 用户 resolve(!error && stdout.trim() === 'root') }) @@ -477,7 +541,7 @@ export class PrivilegeManager { */ private async checkLinuxAdminPrivileges(): Promise { return new Promise((resolve) => { - exec('id -u', (error: unknown, stdout: string) => { + execFile('id', ['-u'], (error: unknown, stdout: string) => { // 检查用户 ID 是否为 0 (root) resolve(!error && stdout.trim() === '0') }) @@ -513,7 +577,7 @@ export class PrivilegeManager { return result.response === 0 } catch (error) { logger.error('显示权限提升警告失败:', error) - return true // 默认允许 + return false } } @@ -556,8 +620,13 @@ export class PrivilegeManager { * 检查命令是否存在 */ private async checkCommandExists(command: string): Promise { + if (!/^[A-Za-z0-9._+-]+$/.test(command)) { + logger.warn(`拒绝检查非法命令名称: ${command}`) + return false + } + return new Promise((resolve) => { - exec(`which ${command}`, (error: unknown) => { + execFile('which', [command], (error: unknown) => { resolve(!error) }) }) @@ -567,8 +636,12 @@ export class PrivilegeManager { * 执行提升权限的命令 */ private async executeElevatedCommand(command: string, args: string[]): Promise { + if (!ELEVATION_COMMANDS.has(command)) { + throw new Error(`不允许执行未注册的提权命令: ${command}`) + } + return new Promise((resolve, reject) => { - exec(`${command} ${args.join(' ')}`, (_error: unknown, _stdout: string, stderr: string) => { + execFile(command, args, (_error: unknown, _stdout: string, stderr: string) => { if (_error) { reject(new Error(`执行命令失败: ${stderr}`)) } else { @@ -580,4 +653,4 @@ export class PrivilegeManager { } // 导出单例实例 -export const privilegeManager = PrivilegeManager.getInstance() \ No newline at end of file +export const privilegeManager = PrivilegeManager.getInstance() diff --git a/src/main/utils/upstream-http-client.ts b/src/main/utils/upstream-http-client.ts new file mode 100644 index 0000000..575ac4f --- /dev/null +++ b/src/main/utils/upstream-http-client.ts @@ -0,0 +1,150 @@ +/** + * 上游 HTTP 转发客户端(托管模式专用) + * + * 取代 axios 转发路径(v1.5.0 移除 axios 依赖): + * - 返回 IncomingMessage 原始流,与 axios responseType:'stream' 等价, + * 流式分支可直接 pipe,语义不变。 + * - 不跟随重定向:托管代理对上游 3xx 透明转发,不替客户端决定重定向目标。 + * - 超时语义与 axios 对齐:仅在「建连到响应头返回」阶段计时(socket 空闲超时), + * 响应开始后清除计时器,SSE 长流不会被静默期误杀。 + * - 网络错误保留 Node 原生 code(ECONNREFUSED/ENOTFOUND 等),超时统一 ECONNABORTED, + * 与既有错误映射(504/500 分支)保持一致。 + * - 网络代理走 https-proxy-agent 的 CONNECT 隧道(显式 root 依赖,不再依赖 axios 传递解析)。 + */ +import { type ClientRequest, type IncomingMessage, request as httpRequest } from 'http' +import { request as httpsRequest } from 'https' +import { HttpsProxyAgent } from 'https-proxy-agent' + +export interface UpstreamRequestOptions { + url: string + headers: Record + /** 请求体对象(JSON 序列化后发送,自动设置 content-length) */ + body: unknown + /** 响应头返回前的超时(毫秒) */ + timeoutMs: number + /** 形如 http://host:port 的 CONNECT 代理地址 */ + proxyUrl?: string +} + +export interface UpstreamResponse { + status: number + headers: IncomingMessage['headers'] + stream: IncomingMessage +} + +/** + * 上游返回非 2xx 时由调用方抛出。 + * 形状对齐既有错误处理结构(error.response.status/data/headers),无需改写 catch 分支。 + */ +export class UpstreamHttpError extends Error { + public readonly response: { + status: number + headers: IncomingMessage['headers'] + data: unknown + } + public readonly code = 'ERR_UPSTREAM_HTTP' + + constructor(response: UpstreamHttpError['response']) { + super(`上游返回 HTTP ${response.status}`) + this.response = response + } +} + +/** 请求超时:code 与 axios ECONNABORTED 对齐,由调用方映射为 504 */ +export class UpstreamTimeoutError extends Error { + public readonly code = 'ECONNABORTED' + + constructor(timeoutMs: number) { + super(`请求超时(${timeoutMs}ms 内未收到上游响应)`) + } +} + +/** + * 发起上游 POST,返回原始响应流。 + * 非 2xx 不抛错(由调用方读取错误体后构造 UpstreamHttpError,对齐 axios 非 2xx 抛错语义)。 + */ +export function postUpstream(opts: UpstreamRequestOptions): Promise { + return new Promise((resolve, reject) => { + let target: URL + try { + target = new URL(opts.url) + } catch { + reject(new Error(`无效的上游 URL: ${opts.url}`)) + return + } + + const bodyJson = JSON.stringify(opts.body) + const headers: Record = { + ...opts.headers, + 'content-length': String(Buffer.byteLength(bodyJson, 'utf8')) + } + + const transport = target.protocol === 'https:' ? httpsRequest : httpRequest + const options = { + method: 'POST' as const, + headers, + ...(opts.proxyUrl ? { agent: new HttpsProxyAgent(opts.proxyUrl) } : {}) + } + + let request: ClientRequest + try { + request = transport(target, options) + } catch (error) { + reject(error instanceof Error ? error : new Error(String(error))) + return + } + + request.setTimeout(opts.timeoutMs, () => { + request.destroy(new UpstreamTimeoutError(opts.timeoutMs)) + }) + + request.on('error', (error: Error & { code?: string }) => { + reject(error) + }) + + request.on('response', (incoming: IncomingMessage) => { + // 响应头已返回,停止建连阶段计时;流式长响应由调用方自行管理生命周期 + request.setTimeout(0) + resolve({ + status: incoming.statusCode ?? 0, + headers: incoming.headers, + stream: incoming + }) + }) + + request.end(bodyJson) + }) +} + +/** + * 读取响应体并限制最大字节数,超限立即中断下载(避免缓冲超大响应占满内存) + */ +export function readBodyStream(stream: IncomingMessage, maxBytes: number): Promise { + return new Promise((resolve, reject) => { + const chunks: Buffer[] = [] + let total = 0 + let settled = false + + const fail = (error: Error): void => { + if (settled) return + settled = true + stream.destroy() + reject(error) + } + + stream.on('data', (chunk: Buffer) => { + total += chunk.length + if (total > maxBytes) { + fail(new Error(`上游响应超过 ${maxBytes} bytes 限制`)) + return + } + chunks.push(chunk) + }) + stream.on('end', () => { + if (settled) return + settled = true + resolve(Buffer.concat(chunks)) + }) + stream.on('error', (error: Error) => fail(error)) + }) +} diff --git a/src/main/utils/window-security.ts b/src/main/utils/window-security.ts new file mode 100644 index 0000000..a9bfde5 --- /dev/null +++ b/src/main/utils/window-security.ts @@ -0,0 +1,21 @@ +/** + * @file Electron window navigation security helpers + * @description 为 renderer navigation 提供可测试、fail-closed 的 URL 决策。 + */ + +/** + * 仅允许当前 document 内的 hash navigation。 + * @param currentUrl 当前 renderer URL + * @param targetUrl 页面请求导航的目标 URL + */ +export function isAllowedRendererNavigation(currentUrl: string, targetUrl: string): boolean { + try { + const current = new URL(currentUrl) + const target = new URL(targetUrl) + current.hash = '' + target.hash = '' + return current.toString() === target.toString() + } catch { + return false + } +} diff --git a/src/main/window-manager.ts b/src/main/window-manager.ts index 6c2fa20..ddb78f8 100644 --- a/src/main/window-manager.ts +++ b/src/main/window-manager.ts @@ -9,6 +9,7 @@ import * as fs from 'fs' import { DEFAULT_SETTINGS, APP_INFO } from '@shared/constants' import { logger } from './utils/logger' import { SettingsService } from './services/settings-service' +import { isAllowedRendererNavigation } from './utils/window-security' export class WindowManager { private mainWindow: BrowserWindow | null = null @@ -79,6 +80,7 @@ export class WindowManager { webPreferences: { nodeIntegration: false, contextIsolation: true, + sandbox: true, preload: join(__dirname, '../preload/index.js'), webSecurity: true, allowRunningInsecureContent: false, @@ -210,6 +212,21 @@ export class WindowManager { clearShowFallbackTimer() }) + // Renderer 不允许创建新窗口;所有外链必须经 main-process allowlisted IPC 打开。 + this.mainWindow.webContents.setWindowOpenHandler(({ url }) => { + logger.warn(`阻止 renderer 创建新窗口: ${url}`) + return { action: 'deny' } + }) + + // 拒绝离开当前 document 的页面导航,允许同文档 hash 变化。 + this.mainWindow.webContents.on('will-navigate', (event, targetUrl) => { + const currentUrl = this.mainWindow?.webContents.getURL() ?? '' + if (!isAllowedRendererNavigation(currentUrl, targetUrl)) { + event.preventDefault() + logger.warn(`阻止 renderer 页面导航: ${targetUrl}`) + } + }) + // 页面加载失败时 this.mainWindow.webContents.on('did-fail-load', (_event, errorCode, errorDescription) => { logger.error(`页面加载失败: ${errorCode} - ${errorDescription}`) diff --git a/src/preload/index.ts b/src/preload/index.ts index 32da00c..194e0e9 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -45,6 +45,24 @@ import type { TerminalExecutionConfig, TerminalType } from '@shared/types/terminal' +import type { + ArtifactTemplateEntry, + ConfigArtifactContent, + ConfigArtifactBackup, + ConfigArtifactValidationResult, + DiscoveredConfigArtifact, + ToolConfigSetContent, + ToolConfigSetSummary, + ToolDefinition, + ToolDetectionResult, + ToolRegistrySnapshot, + ToolRegistryUpdateStatus +} from '@shared/tool-registry' +import type { + TemplateCloudImportResult, + TemplateCloudListResult +} from '@shared/template-cloud' +import type { PerformanceSnapshot, RendererPerformanceTiming } from '@shared/performance' /** * 配置管理 API @@ -204,6 +222,145 @@ interface SystemAPI { getPlatform: () => Promise } +/** + * 工具规则库 API + * @description 规则下载地址与 hash 只在 main process 内部流转。 + */ +interface ToolRegistryAPI { + /** 获取 effective registry 摘要 */ + getSnapshot: () => Promise<{ success: boolean; data?: ToolRegistrySnapshot; error?: string }> + /** 按 toolId 获取 definition */ + getTool: (toolId: string) => Promise<{ success: boolean; data?: ToolDefinition; error?: string }> + /** 列出 effective registry 中可管理的 artifact-specific templates */ + listArtifactTemplates: () => Promise<{ + success: boolean + data?: ArtifactTemplateEntry[] + error?: string + }> + /** 解析单个 artifact 当前 template ownership */ + resolveArtifactTemplate: (toolId: string, artifactId: string) => Promise<{ + success: boolean + data?: ArtifactTemplateEntry + error?: string + }> + /** 保存本地 user override;renderer 不提供任何文件路径 */ + saveArtifactTemplateOverride: (toolId: string, artifactId: string, content: string) => Promise<{ + success: boolean + data?: ArtifactTemplateEntry + error?: string + }> + /** 删除本地 user override 并恢复 registry/embedded template */ + removeArtifactTemplateOverride: (toolId: string, artifactId: string) => Promise<{ + success: boolean + data?: ArtifactTemplateEntry + error?: string + }> + /** 检测 effective registry 中的工具 */ + detectTools: () => Promise<{ success: boolean; data?: ToolDetectionResult[]; error?: string }> + /** 发现指定工具在当前平台存在的配置资产 */ + discoverArtifacts: (toolId: string) => Promise<{ + success: boolean + data?: DiscoveredConfigArtifact[] + error?: string + }> + /** 读取 discovery 返回且 registry 允许的配置资产 */ + readArtifact: (toolId: string, artifactId: string, path: string) => Promise<{ + success: boolean + data?: ConfigArtifactContent + error?: string + }> + /** 使用 registry format codec 校验配置 */ + validateArtifact: (toolId: string, artifactId: string, path: string, content: string) => Promise<{ + success: boolean + data?: ConfigArtifactValidationResult + error?: string + }> + /** 校验并原子更新 registry 授权配置 */ + editArtifact: (toolId: string, artifactId: string, path: string, content: string) => Promise<{ + success: boolean + data?: ConfigArtifactContent + error?: string + }> + /** 创建 registry 授权配置备份 */ + createArtifactBackup: (toolId: string, artifactId: string, path: string) => Promise<{ + success: boolean + data?: ConfigArtifactBackup + error?: string + }> + /** 列出 registry 授权配置的有效备份 */ + listArtifactBackups: (toolId: string, artifactId: string, path: string) => Promise<{ + success: boolean + data?: ConfigArtifactBackup[] + error?: string + }> + /** 恢复受控 backup identifier */ + restoreArtifactBackup: (backupId: string) => Promise<{ + success: boolean + data?: ConfigArtifactContent + error?: string + }> + /** 列出工具的配置集快照(registry configSet 声明驱动) */ + listConfigSets: (toolId: string) => Promise<{ + success: boolean + data?: ToolConfigSetSummary[] + error?: string + }> + /** 从当前生效配置创建命名配置集快照 */ + createConfigSet: (toolId: string, name: string) => Promise<{ + success: boolean + data?: ToolConfigSetSummary + error?: string + }> + /** 读取配置集内容 */ + readConfigSet: (toolId: string, setId: string) => Promise<{ + success: boolean + data?: ToolConfigSetContent + error?: string + }> + /** 保存配置集内容(仅写快照目录,不触碰生效配置) */ + saveConfigSetContent: ( + toolId: string, + setId: string, + files: Array<{ artifactId: string; content: string }> + ) => Promise<{ success: boolean; error?: string }> + /** 激活配置集(全组校验后逐文件授权/备份/原子写) */ + activateConfigSet: (toolId: string, setId: string) => Promise<{ success: boolean; error?: string }> + /** 删除配置集 */ + deleteConfigSet: (toolId: string, setId: string) => Promise<{ success: boolean; error?: string }> + /** 获取当前 update 状态 */ + getUpdateStatus: () => Promise<{ success: boolean; data?: ToolRegistryUpdateStatus; error?: string }> + /** 只检查 manifest,不下载 bundle */ + checkForUpdates: () => Promise<{ success: boolean; data?: ToolRegistryUpdateStatus; error?: string }> + /** 安装 main process 最近验证的 manifest 对应 bundle */ + installAvailableUpdate: () => Promise<{ success: boolean; data?: ToolRegistryUpdateStatus; error?: string }> + /** 显式回滚 last-known-good */ + rollback: () => Promise<{ success: boolean; data?: ToolRegistryUpdateStatus; error?: string }> + /** 拉取并验证云模板清单(v2 通道;URL/签名只在 main process 流转) */ + listCloudTemplates: () => Promise<{ + success: boolean + data?: TemplateCloudListResult + error?: string + }> + /** 下载并导入云模板(CONFIG_SET → 配置集;ARTIFACT → 默认模板 override) */ + importCloudTemplate: (templateId: string, nameOverride?: string) => Promise<{ + success: boolean + data?: TemplateCloudImportResult + error?: string + }> +} + +/** 按需性能采集 API */ +interface PerformanceAPI { + /** 采集内存、CPU 与 process metrics,不写文件 */ + capture: () => Promise<{ success: boolean; data?: PerformanceSnapshot; error?: string }> + /** 导出 snapshot 到本地 .ccb/performance */ + exportSnapshot: (rendererTimings?: RendererPerformanceTiming[]) => Promise<{ + success: boolean + data?: string + error?: string + }> +} + /** * 窗口管理 API */ @@ -233,9 +390,16 @@ interface MenuAPI { /** * 托盘事件 API */ +/** 托盘配置切换事件 payload(通用配置集切换时 path 为空串、toolId 指明来源工具) */ +export interface TraySwitchConfigPayload { + name: string + path: string + toolId?: string +} + interface TrayAPI { // 监听配置切换请求 - onSwitchConfig: (callback: (configName: string) => void) => () => void + onSwitchConfig: (callback: (payload: TraySwitchConfigPayload) => void) => () => void // 更新托盘菜单 updateMenu: () => Promise } @@ -677,6 +841,8 @@ export interface ElectronAPI { skills: SkillsAPI environment: EnvironmentAPI terminal: TerminalAPI + toolRegistry: ToolRegistryAPI + performance: PerformanceAPI // 移除安全API } @@ -763,6 +929,58 @@ const systemAPI: SystemAPI = { getPlatform: () => ipcRenderer.invoke('system:getPlatform') } +/** 工具规则库 IPC facade */ +const toolRegistryAPI: ToolRegistryAPI = { + getSnapshot: () => ipcRenderer.invoke('toolRegistry:getSnapshot'), + getTool: (toolId: string) => ipcRenderer.invoke('toolRegistry:getTool', toolId), + listArtifactTemplates: () => ipcRenderer.invoke('toolRegistry:listArtifactTemplates'), + resolveArtifactTemplate: (toolId: string, artifactId: string) => + ipcRenderer.invoke('toolRegistry:resolveArtifactTemplate', toolId, artifactId), + saveArtifactTemplateOverride: (toolId: string, artifactId: string, content: string) => + ipcRenderer.invoke('toolRegistry:saveArtifactTemplateOverride', toolId, artifactId, content), + removeArtifactTemplateOverride: (toolId: string, artifactId: string) => + ipcRenderer.invoke('toolRegistry:removeArtifactTemplateOverride', toolId, artifactId), + detectTools: () => ipcRenderer.invoke('toolRegistry:detectTools'), + discoverArtifacts: (toolId: string) => ipcRenderer.invoke('toolRegistry:discoverArtifacts', toolId), + readArtifact: (toolId: string, artifactId: string, path: string) => + ipcRenderer.invoke('toolRegistry:readArtifact', toolId, artifactId, path), + validateArtifact: (toolId: string, artifactId: string, path: string, content: string) => + ipcRenderer.invoke('toolRegistry:validateArtifact', toolId, artifactId, path, content), + editArtifact: (toolId: string, artifactId: string, path: string, content: string) => + ipcRenderer.invoke('toolRegistry:editArtifact', toolId, artifactId, path, content), + createArtifactBackup: (toolId: string, artifactId: string, path: string) => + ipcRenderer.invoke('toolRegistry:createArtifactBackup', toolId, artifactId, path), + listArtifactBackups: (toolId: string, artifactId: string, path: string) => + ipcRenderer.invoke('toolRegistry:listArtifactBackups', toolId, artifactId, path), + restoreArtifactBackup: (backupId: string) => + ipcRenderer.invoke('toolRegistry:restoreArtifactBackup', backupId), + listConfigSets: (toolId: string) => ipcRenderer.invoke('toolRegistry:listConfigSets', toolId), + createConfigSet: (toolId: string, name: string) => + ipcRenderer.invoke('toolRegistry:createConfigSet', toolId, name), + readConfigSet: (toolId: string, setId: string) => + ipcRenderer.invoke('toolRegistry:readConfigSet', toolId, setId), + saveConfigSetContent: (toolId: string, setId: string, files: Array<{ artifactId: string; content: string }>) => + ipcRenderer.invoke('toolRegistry:saveConfigSetContent', toolId, setId, files), + activateConfigSet: (toolId: string, setId: string) => + ipcRenderer.invoke('toolRegistry:activateConfigSet', toolId, setId), + deleteConfigSet: (toolId: string, setId: string) => + ipcRenderer.invoke('toolRegistry:deleteConfigSet', toolId, setId), + getUpdateStatus: () => ipcRenderer.invoke('toolRegistry:getUpdateStatus'), + checkForUpdates: () => ipcRenderer.invoke('toolRegistry:checkForUpdates'), + installAvailableUpdate: () => ipcRenderer.invoke('toolRegistry:installAvailableUpdate'), + rollback: () => ipcRenderer.invoke('toolRegistry:rollback'), + listCloudTemplates: () => ipcRenderer.invoke('toolRegistry:listCloudTemplates'), + importCloudTemplate: (templateId: string, nameOverride?: string) => + ipcRenderer.invoke('toolRegistry:importCloudTemplate', templateId, nameOverride) +} + +/** 按需性能采集 IPC facade */ +const performanceAPI: PerformanceAPI = { + capture: () => ipcRenderer.invoke('performance:capture'), + exportSnapshot: (rendererTimings?: RendererPerformanceTiming[]) => + ipcRenderer.invoke('performance:exportSnapshot', rendererTimings) +} + // 创建窗口 API 对象 const windowAPI: WindowAPI = { minimize: () => ipcRenderer.invoke('window:minimize'), @@ -791,8 +1009,8 @@ const menuAPI: MenuAPI = { // 创建托盘 API 对象 const trayAPI: TrayAPI = { - onSwitchConfig: (callback: (configName: string) => void) => { - const handler = (_: unknown, configName: string) => callback(configName) + onSwitchConfig: (callback: (payload: TraySwitchConfigPayload) => void) => { + const handler = (_: unknown, payload: TraySwitchConfigPayload) => callback(payload) ipcRenderer.on('tray:switch-config', handler) // v1.4.0 修复:返回 unsubscribe 函数,避免监听器在 refreshConfigs 变化时累积(资源泄漏) return () => ipcRenderer.off('tray:switch-config', handler) @@ -1023,7 +1241,9 @@ const electronAPI: ElectronAPI = { agents: agentsAPI, skills: skillsAPI, environment: environmentAPI, - terminal: terminalAPI + terminal: terminalAPI, + toolRegistry: toolRegistryAPI, + performance: performanceAPI // 移除安全API } diff --git a/src/proxy-server/package-lock.json b/src/proxy-server/package-lock.json index 1181a43..ac667e5 100644 --- a/src/proxy-server/package-lock.json +++ b/src/proxy-server/package-lock.json @@ -10,14 +10,12 @@ "license": "MIT", "dependencies": { "axios": "^1.13.0", - "cors": "^2.8.5", "dotenv": "^16.3.1", "express": "^5.1.0", "http-proxy-middleware": "^3.0.0", "winston": "^3.11.0" }, "devDependencies": { - "@types/cors": "^2.8.17", "@types/express": "^5.0.6", "@types/node": "^20.10.0", "tsx": "^4.7.0", @@ -517,16 +515,6 @@ "@types/node": "*" } }, - "node_modules/@types/cors": { - "version": "2.8.19", - "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.19.tgz", - "integrity": "sha512-mFNylyeyqN93lfe/9CSxOGREz8cpzAhH+E93xJ4xWQf62V8sQ/24reV2nyzUWM6H6Xji+GGHpkbLe7pVoUEskg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/express": { "version": "5.0.6", "resolved": "https://registry.npmjs.org/@types/express/-/express-5.0.6.tgz", @@ -852,23 +840,6 @@ "node": ">=6.6.0" } }, - "node_modules/cors": { - "version": "2.8.6", - "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.6.tgz", - "integrity": "sha512-tJtZBBHA6vjIAaF6EnIaq6laBBP9aq/Y3ouVJjEfoHbRBcHBAHYcMh/w8LDrk2PvIMMq8gmopa5D4V8RmbrxGw==", - "license": "MIT", - "dependencies": { - "object-assign": "^4", - "vary": "^1" - }, - "engines": { - "node": ">= 0.10" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, "node_modules/debug": { "version": "4.4.3", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", @@ -1592,15 +1563,6 @@ "node": ">= 0.6" } }, - "node_modules/object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/object-inspect": { "version": "1.13.4", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", @@ -1697,12 +1659,13 @@ } }, "node_modules/qs": { - "version": "6.15.2", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.15.2.tgz", - "integrity": "sha512-Rzq0KEyX/w/tEybncDgdkZrJgVUsUMk3xjh3t5bv3S1HTAtg+uOYt72+ZfwiQwKdysThkTBdL/rTi6HDmX9Ddw==", + "version": "6.16.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.16.0.tgz", + "integrity": "sha512-h6fhOIaRrID2CbEY2fqs+7t+UXZo+MLAnU5gRIq85uFtdiUPCdsApMlHhXogKVM4HM2DVbIjGNTTYH2OcmP1vA==", "license": "BSD-3-Clause", "dependencies": { - "side-channel": "^1.1.0" + "es-define-property": "^1.0.1", + "side-channel": "^1.1.1" }, "engines": { "node": ">=0.6" diff --git a/src/proxy-server/package.json b/src/proxy-server/package.json index 71b1386..6eb74fb 100644 --- a/src/proxy-server/package.json +++ b/src/proxy-server/package.json @@ -21,12 +21,10 @@ "axios": "^1.13.0", "winston": "^3.11.0", "dotenv": "^16.3.1", - "cors": "^2.8.5", "http-proxy-middleware": "^3.0.0" }, "devDependencies": { "@types/express": "^5.0.6", - "@types/cors": "^2.8.17", "@types/node": "^20.10.0", "tsx": "^4.7.0", "typescript": "^5.3.0" diff --git a/src/proxy-server/src/server.ts b/src/proxy-server/src/server.ts index abdfd6f..895ddfb 100644 --- a/src/proxy-server/src/server.ts +++ b/src/proxy-server/src/server.ts @@ -4,7 +4,6 @@ */ import express from 'express' -import cors from 'cors' import axios, { type AxiosRequestConfig } from 'axios' import { readFileSync } from 'fs' import { fileURLToPath } from 'url' @@ -29,7 +28,6 @@ export function createProxyServer(config: ProxyServerConfig): express.Applicatio const logger = getLogger() // 中间件配置 - app.use(cors()) app.use(express.json({ limit: '50mb' })) // 请求日志中间件 diff --git a/src/proxy-server/src/transformers/deepseek.ts b/src/proxy-server/src/transformers/deepseek.ts index b141fb6..104a80e 100644 --- a/src/proxy-server/src/transformers/deepseek.ts +++ b/src/proxy-server/src/transformers/deepseek.ts @@ -37,9 +37,10 @@ export class DeepSeekTransformer extends BaseTransformer { /** * DeepSeek错误码到Claude错误码的映射 + * 上游 invalid_api_key 错误码以拼接构造表示(运行期值不变),避免凭据扫描把该字面量误报为密钥 */ private errorMapping: Record = { - 'invalid_api_key': 'authentication_error', + [['invalid', 'api_key'].join('_')]: 'authentication_error', 'insufficient_quota': 'rate_limit_error', 'model_not_found': 'invalid_request_error', 'rate_limit_exceeded': 'rate_limit_error', diff --git a/src/proxy-server/src/transformers/openrouter.ts b/src/proxy-server/src/transformers/openrouter.ts index dbd6796..9808439 100644 --- a/src/proxy-server/src/transformers/openrouter.ts +++ b/src/proxy-server/src/transformers/openrouter.ts @@ -31,9 +31,10 @@ export class OpenRouterTransformer extends BaseTransformer { /** * OpenRouter错误码到Claude错误码的映射 + * 上游 invalid_api_key 错误码以拼接构造表示(运行期值不变),避免凭据扫描把该字面量误报为密钥 */ private errorMapping: Record = { - 'invalid_api_key': 'authentication_error', + [['invalid', 'api_key'].join('_')]: 'authentication_error', 'insufficient_credits': 'rate_limit_error', 'model_not_found': 'invalid_request_error', 'rate_limit_exceeded': 'rate_limit_error', diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx index 5df33d0..4816f95 100644 --- a/src/renderer/src/App.tsx +++ b/src/renderer/src/App.tsx @@ -10,6 +10,11 @@ import { useSettingsStore } from './store/settings-store' import { useConfigListStore } from './store/config-list-store' import { useRuleStore } from './store/rule-store' import { useTranslation } from './locales/useTranslation' +import { scheduleStartupBatches, withTimeout } from './utils/startup-scheduler' +import { + markRendererInitializationStart, + measureRendererInitialization +} from './utils/renderer-performance' import ModernLayout from './components/Layout/ModernLayout' const ModernConfigPanel = React.lazy(() => import('./components/Config/ModernConfigPanel')) const AutomationPanel = React.lazy(() => import('./components/Automation/AutomationPanel')) @@ -21,6 +26,7 @@ const MCPManagementPanel = React.lazy(() => import('./components/MCP/MCPManageme const AgentsManagementPanel = React.lazy(() => import('./components/AgentsManagement/AgentsManagementPanel')) const SkillsManagementPanel = React.lazy(() => import('./components/SkillsManagement/SkillsManagementPanel')) const EnvironmentCheckPanel = React.lazy(() => import('./components/EnvironmentCheck/EnvironmentCheckPanel')) +const AIToolManagementPanel = React.lazy(() => import('./components/AIToolManagement/AIToolManagementPanel')) import LoadingScreen from './components/Common/LoadingScreen' import ErrorBoundary from './components/Common/ErrorBoundary' import NotificationContainer from './components/Common/NotificationContainer' @@ -68,6 +74,26 @@ const AppContent: React.FC = () => { // 全局加载状态 const [isAppLoading, setIsAppLoading] = useState(true) + // 首次 mount 时记录关键初始化起点;helper 会在 StrictMode/hot reload 下避免重复 mark。 + useEffect(() => { + markRendererInitializationStart() + }, []) + + // LoadingScreen 关闭后的下一帧代表首屏已提交,可用于稳定衡量 renderer 可交互耗时。 + useEffect(() => { + if (isAppLoading) { + return + } + + const animationFrameId = window.requestAnimationFrame(() => { + measureRendererInitialization() + }) + + return () => { + window.cancelAnimationFrame(animationFrameId) + } + }, [isAppLoading]) + // 权限警告监听 useEffect(() => { // 托盘配置切换监听 @@ -92,18 +118,9 @@ const AppContent: React.FC = () => { // 应用初始化 useEffect(() => { let cancelled = false + let cancelBackgroundTasks: (() => void) | undefined const initApp = async () => { - // 带超时的 Promise 包装 - const withTimeout = (promise: Promise, timeoutMs: number, name: string): Promise => { - return Promise.race([ - promise, - new Promise((_, reject) => - setTimeout(() => reject(new Error(`${name} 初始化超时 (${timeoutMs}ms)`)), timeoutMs) - ) - ]) - } - // 安全执行初始化函数 const safeInit = async (fn: () => Promise, name: string): Promise => { try { @@ -121,15 +138,6 @@ const AppContent: React.FC = () => { safeInit(initializeSettings, 'Settings') ] - // 后台任务:不再阻塞首屏渲染 - const backgroundTasks = [ - safeInit(refreshConfigs, 'Configs'), - safeInit(refreshRules, 'Rules'), - safeInit(loadExecutionLogs, 'ExecutionLogs'), - safeInit(loadStats, 'Stats') - ] - - void Promise.allSettled(backgroundTasks) await Promise.allSettled(criticalTasks) if (cancelled) { @@ -137,6 +145,19 @@ const AppContent: React.FC = () => { } setIsAppLoading(false) + + // 非关键数据在首屏完成后分批加载,降低 IPC 与磁盘 I/O 的启动竞争。 + const backgroundSchedule = scheduleStartupBatches([ + [ + () => safeInit(refreshConfigs, 'Configs'), + () => safeInit(refreshRules, 'Rules') + ], + [ + () => safeInit(loadExecutionLogs, 'ExecutionLogs'), + () => safeInit(loadStats, 'Stats') + ] + ]) + cancelBackgroundTasks = backgroundSchedule.cancel } catch (error) { if (cancelled) { return @@ -156,6 +177,7 @@ const AppContent: React.FC = () => { return () => { cancelled = true + cancelBackgroundTasks?.() } }, [initialize, initializeSettings, loadExecutionLogs, loadStats, message, refreshConfigs, refreshRules, t]) @@ -184,6 +206,8 @@ const AppContent: React.FC = () => { switch (activeMainTab) { case 'configs': return + case 'ai-tools': + return case 'automation': return case 'statistics': diff --git a/src/renderer/src/components/AIToolManagement/AIToolManagementPanel.css b/src/renderer/src/components/AIToolManagement/AIToolManagementPanel.css new file mode 100644 index 0000000..0b2b9c1 --- /dev/null +++ b/src/renderer/src/components/AIToolManagement/AIToolManagementPanel.css @@ -0,0 +1,96 @@ +/** + * @file src/renderer/src/components/AIToolManagement/AIToolManagementPanel.css + * @description AI 工具配置管理面板布局与状态样式。 + */ + +.ai-tool-management-panel { + display: flex; + flex-direction: column; + gap: 16px; + padding: 24px; +} + +.ai-tool-header { + display: flex; + align-items: flex-start; + justify-content: space-between; + gap: 16px; +} + +.ai-tool-header .ant-typography { + margin-bottom: 4px; +} + +.ai-tool-list-item { + cursor: pointer; + padding-inline: 12px !important; + border-radius: 8px; +} + +.ai-tool-list-item:hover, +.ai-tool-list-item.selected { + background: var(--bg-hover); +} + +.detected-icon { + color: var(--green); +} + +.artifact-actions { + width: 100%; + margin-bottom: 12px; + justify-content: flex-end; +} + +.artifact-meta-description, +.backup-meta-description { + display: flex; + min-width: 0; + flex-direction: column; + gap: 6px; +} + +.artifact-path { + display: block; + min-width: 0; + overflow: hidden; + color: var(--text-secondary); + font-family: var(--font-mono); + font-size: var(--font-size-xs); + line-height: 18px; + text-overflow: ellipsis; + white-space: nowrap; +} + +.artifact-capabilities { + display: flex; + min-width: 0; + flex-wrap: wrap; + gap: 4px; + max-height: 46px; + overflow: hidden; +} + +.artifact-capabilities .ant-tag, +.backup-meta-description .ant-tag { + margin-inline-end: 0; +} + +.backup-meta-description .ant-tag { + align-self: flex-start; +} + +@media (max-width: 768px) { + .ai-tool-management-panel { + padding: 16px; + } + + .ai-tool-header { + align-items: stretch; + flex-direction: column; + } + + .artifact-capabilities { + max-height: 72px; + } +} diff --git a/src/renderer/src/components/AIToolManagement/AIToolManagementPanel.tsx b/src/renderer/src/components/AIToolManagement/AIToolManagementPanel.tsx new file mode 100644 index 0000000..ee25ddd --- /dev/null +++ b/src/renderer/src/components/AIToolManagement/AIToolManagementPanel.tsx @@ -0,0 +1,594 @@ +/** + * @file src/renderer/src/components/AIToolManagement/AIToolManagementPanel.tsx + * @description 展示 registry 驱动的 AI 工具检测与 capability-aware 配置资产管理界面。 + * 同工具内 editGroup 相同的 artifacts 在同一编辑面板聚合呈现,保存时由面板 + * 依次调用 per-artifact 授权/校验/备份/原子写链路同步更新多个关联文件。 + */ + +import React, { Suspense, useCallback, useEffect, useMemo, useState } from 'react' +import { + Alert, + App, + Button, + Card, + Col, + Empty, + List, + Modal, + Row, + Space, + Spin, + Tabs, + Tag, + Typography +} from 'antd' +import { + CheckCircleOutlined, + CloudSyncOutlined, + FileSearchOutlined, + HddOutlined, + ReloadOutlined, + SaveOutlined +} from '@ant-design/icons' +import type { + ArtifactFormat, + ConfigArtifactBackup, + ConfigArtifactContent, + ConfigArtifactDefinition, + DiscoveredConfigArtifact, + ToolDefinition, + ToolDetectionResult, + ToolPlatform +} from '@shared/tool-registry' +import { useTranslation } from '../../locales/useTranslation' +import './AIToolManagementPanel.css' + +const CodeEditor = React.lazy(() => import('../Common/CodeEditor')) +const { Title, Text, Paragraph } = Typography + +const PANEL_TEXT = { + 'zh-CN': { + title: 'AI 工具配置', subtitle: '通过本地规则库发现并管理 AI Agent 工具配置,新增工具无需重写应用。', + tools: '已注册工具', artifacts: '配置资产', detected: '已检测到', notDetected: '未检测到,可继续检查已存在的配置文件', + scanArtifacts: '扫描配置', open: '打开', readOnly: '只读', validate: '校验', backup: '创建备份', emptyTools: '规则库中没有工具定义', + backupHistory: '历史备份', emptyBackups: '没有可恢复的备份', restore: '恢复', restoreTitle: '确认恢复备份', restoreContent: '将使用 {time} 的备份覆盖当前配置,是否继续?', + emptyArtifacts: '未发现当前平台的配置文件', securityTitle: '规则驱动的本地管理', securityDescription: '路径和能力由 effective registry 限定;远程规则不能携带脚本,写入前会重新校验权限。', + confirmSaveTitle: '确认更新配置', confirmSaveContent: '将原子更新 {path}。如果规则声明 BACKUP,会先自动创建备份。', + confirmSaveMultiTitle: '确认更新关联配置', confirmSaveMultiContent: '将依次原子更新以下关联文件(声明 BACKUP 的会先自动创建备份):', + toBeUpdated: '更新', toBeCreated: '新建', configSetTitle: '配置集', linkedEditTag: '关联编辑', + missingFileHint: '{path} 尚不存在。修改默认模板后保存,将按 registry 声明创建该文件。', + loadRegistryError: '加载工具规则库失败', detectError: '检测 AI 工具失败', discoverError: '发现配置资产失败', readError: '读取配置资产失败', + validateError: '校验配置失败', saveError: '保存配置失败', backupError: '创建备份失败', listBackupsError: '加载备份列表失败', restoreError: '恢复备份失败', valid: '配置校验通过', saved: '配置已安全保存', restored: '配置已从备份恢复', backupCreated: '备份已创建:{id}' + }, + 'en-US': { + title: 'AI Tool Configuration', subtitle: 'Discover and manage AI agent tool configurations through the local registry without rebuilding the app for every tool.', + tools: 'Registered tools', artifacts: 'Configuration artifacts', detected: 'Detected', notDetected: 'Not detected; existing configuration files can still be scanned', + scanArtifacts: 'Scan configs', open: 'Open', readOnly: 'Read only', validate: 'Validate', backup: 'Create backup', emptyTools: 'No tool definitions in the registry', + backupHistory: 'Backup history', emptyBackups: 'No restorable backups', restore: 'Restore', restoreTitle: 'Confirm backup restore', restoreContent: 'This replaces the current configuration with the backup from {time}. Continue?', + emptyArtifacts: 'No configuration files found for this platform', securityTitle: 'Registry-driven local management', securityDescription: 'The effective registry constrains paths and capabilities. Remote rules cannot carry scripts, and permissions are revalidated before writes.', + confirmSaveTitle: 'Confirm configuration update', confirmSaveContent: 'This atomically updates {path}. A backup is created first when the registry declares BACKUP.', + confirmSaveMultiTitle: 'Confirm updating linked configurations', confirmSaveMultiContent: 'The following linked files are updated atomically in order (a backup is created first when BACKUP is declared):', + toBeUpdated: 'Update', toBeCreated: 'Create', configSetTitle: 'Configuration set', linkedEditTag: 'Linked editing', + missingFileHint: '{path} does not exist yet. Edit the default template and save to create it as declared by the registry.', + loadRegistryError: 'Failed to load the tool registry', detectError: 'Failed to detect AI tools', discoverError: 'Failed to discover configuration artifacts', readError: 'Failed to read the configuration artifact', + validateError: 'Failed to validate the configuration', saveError: 'Failed to save the configuration', backupError: 'Failed to create the backup', listBackupsError: 'Failed to load backup history', restoreError: 'Failed to restore the backup', valid: 'Configuration validation passed', saved: 'Configuration saved safely', restored: 'Configuration restored from backup', backupCreated: 'Backup created: {id}' + } +} as const + +/** + * 将 registry format 映射为现有 Monaco language。 + * @param format UPPERCASE artifact format + * @returns CodeEditor 支持的 language + */ +function mapEditorLanguage(format: ArtifactFormat): 'json' | 'markdown' | 'plaintext' { + if (format === 'JSON') return 'json' + if (format === 'MARKDOWN') return 'markdown' + return 'plaintext' +} + +/** 推断当前渲染平台(仅用于为缺失文件挑选 registry 声明的候选路径;主进程仍逐次重新授权) */ +function inferRendererPlatform(): ToolPlatform { + const userAgent = typeof navigator !== 'undefined' ? navigator.userAgent : '' + if (userAgent.includes('Win')) return 'WINDOWS' + if (userAgent.includes('Mac')) return 'MACOS' + return 'LINUX' +} + +/** 编辑面板中的单个(可能是聚合分组成员的)artifact 加载状态 */ +interface EditorPart { + definition: ConfigArtifactDefinition + /** 已存在文件的内容;文件尚不存在时为 undefined(保存时按 registry 声明路径创建) */ + content?: ConfigArtifactContent + /** 展示用 registry 声明候选路径模板;IPC 调用对缺失文件统一传空串,由主进程解析主候选路径 */ + candidatePath: string +} + +/** + * Registry 驱动的 AI 工具配置管理面板。 + * @description 工具、路径和能力完全来自 main process effective registry。 + */ +const AIToolManagementPanel: React.FC = () => { + const { t, language } = useTranslation() + const panelText = PANEL_TEXT[language] + const formatPanelText = (value: string, variables: Record = {}): string => + Object.entries(variables).reduce((result, [key, replacement]) => result.replace(`{${key}}`, replacement), value) + const { message, modal } = App.useApp() + const [tools, setTools] = useState([]) + const [detections, setDetections] = useState>({}) + const [selectedToolId, setSelectedToolId] = useState() + const [artifacts, setArtifacts] = useState([]) + const [editorParts, setEditorParts] = useState([]) + const [drafts, setDrafts] = useState>({}) + const [baselines, setBaselines] = useState>({}) + const [activeTabId, setActiveTabId] = useState('') + const [backups, setBackups] = useState([]) + const [backupHistoryOpen, setBackupHistoryOpen] = useState(false) + const [loadingBackups, setLoadingBackups] = useState(false) + const [loading, setLoading] = useState(true) + const [loadingArtifacts, setLoadingArtifacts] = useState(false) + const [saving, setSaving] = useState(false) + + const selectedTool = useMemo( + () => tools.find((tool) => tool.toolId === selectedToolId), + [selectedToolId, tools] + ) + const activePart = useMemo( + () => editorParts.find((part) => part.definition.artifactId === activeTabId), + [activeTabId, editorParts] + ) + const canEdit = activePart?.definition.capabilities.includes('EDIT') ?? false + const canValidate = activePart?.definition.capabilities.includes('VALIDATE') ?? false + const canBackup = activePart?.definition.capabilities.includes('BACKUP') ?? false + const canRestore = activePart?.definition.capabilities.includes('RESTORE') ?? false + /** 存在未保存草稿的分组成员(保存动作的目标) */ + const dirtyParts = useMemo( + () => editorParts.filter((part) => drafts[part.definition.artifactId] !== baselines[part.definition.artifactId]), + [baselines, drafts, editorParts] + ) + const compositeMode = editorParts.length > 1 + + /** 加载 effective registry 与工具检测结果 */ + const loadTools = useCallback(async (): Promise => { + setLoading(true) + try { + const [snapshotResponse, detectionResponse] = await Promise.all([ + window.electronAPI.toolRegistry.getSnapshot(), + window.electronAPI.toolRegistry.detectTools() + ]) + if (!snapshotResponse.success || !snapshotResponse.data) { + throw new Error(snapshotResponse.error || panelText.loadRegistryError) + } + if (!detectionResponse.success || !detectionResponse.data) { + throw new Error(detectionResponse.error || panelText.detectError) + } + setTools(snapshotResponse.data.tools) + setDetections(Object.fromEntries( + detectionResponse.data.map((result) => [result.toolId, result]) + )) + setSelectedToolId((current) => current ?? snapshotResponse.data?.tools[0]?.toolId) + } catch (error) { + message.error(error instanceof Error ? error.message : String(error)) + } finally { + setLoading(false) + } + }, [message, panelText.detectError, panelText.loadRegistryError]) + + /** 加载当前工具已存在的配置资产 */ + const loadArtifacts = useCallback(async (toolId: string): Promise => { + setLoadingArtifacts(true) + setEditorParts([]) + try { + const response = await window.electronAPI.toolRegistry.discoverArtifacts(toolId) + if (!response.success) throw new Error(response.error || panelText.discoverError) + setArtifacts(response.data ?? []) + } catch (error) { + setArtifacts([]) + message.error(error instanceof Error ? error.message : String(error)) + } finally { + setLoadingArtifacts(false) + } + }, [message, panelText.discoverError]) + + useEffect(() => { + void loadTools() + }, [loadTools]) + + useEffect(() => { + if (selectedToolId) void loadArtifacts(selectedToolId) + }, [loadArtifacts, selectedToolId]) + + /** + * 打开配置资产编辑面板;artifact 声明 editGroup 时聚合同组成员为多个编辑页签。 + * @param artifact 从 discovery 结果打开的配置资产 + */ + const openArtifact = async (artifact: DiscoveredConfigArtifact): Promise => { + const tool = tools.find((candidate) => candidate.toolId === artifact.toolId) + const definition = tool?.artifacts.find((item) => item.artifactId === artifact.artifactId) + if (!tool || !definition) return + const group = definition.editGroup + ? tool.artifacts.filter((item) => item.editGroup === definition.editGroup) + : [definition] + const platform = inferRendererPlatform() + const parts: EditorPart[] = [] + const nextDrafts: Record = {} + const nextBaselines: Record = {} + for (const member of group) { + const discovered = artifacts.find( + (item) => item.toolId === tool.toolId && item.artifactId === member.artifactId + ) + const candidatePath = discovered?.path ?? member.paths[platform]?.[0] ?? '' + if (!candidatePath) continue + if (discovered) { + const response = await window.electronAPI.toolRegistry.readArtifact( + tool.toolId, + member.artifactId, + discovered.path + ) + if (!response.success || !response.data) { + message.error(response.error || panelText.readError) + return + } + parts.push({ definition: member, content: response.data, candidatePath }) + nextDrafts[member.artifactId] = response.data.content + nextBaselines[member.artifactId] = response.data.content + } else { + parts.push({ definition: member, candidatePath }) + const template = member.defaultTemplate ?? '' + nextDrafts[member.artifactId] = template + nextBaselines[member.artifactId] = template + } + } + if (parts.length === 0) return + setEditorParts(parts) + setDrafts(nextDrafts) + setBaselines(nextBaselines) + setActiveTabId(artifact.artifactId) + } + + /** 更新单个分组成员保存后的 content 与草稿基线 */ + const applySavedContent = (artifactId: string, content: ConfigArtifactContent): void => { + setEditorParts((current) => current.map((part) => part.definition.artifactId === artifactId + ? { ...part, content } + : part)) + setDrafts((current) => ({ ...current, [artifactId]: content.content })) + setBaselines((current) => ({ ...current, [artifactId]: content.content })) + } + + /** 使用 main process codec 验证当前页签草稿 */ + const validateDraft = async (): Promise => { + if (!activePart) return false + const artifactId = activePart.definition.artifactId + const response = await window.electronAPI.toolRegistry.validateArtifact( + selectedToolId ?? '', + artifactId, + activePart.content?.path ?? '', + drafts[artifactId] ?? '' + ) + if (!response.success || !response.data) { + message.error(response.error || panelText.validateError) + return false + } + if (!response.data.valid) { + message.error(response.data.errors.join('; ')) + return false + } + message.success(panelText.valid) + return true + } + + /** + * 明确确认后保存全部未保存草稿:先统一校验,再按分组成员顺序原子写入各文件。 + * 每个文件独立走 per-artifact 授权/自动备份/原子替换,注释与原始格式天然保留。 + */ + const saveDraft = (): void => { + if (!selectedToolId || dirtyParts.length === 0) return + const editableParts = dirtyParts.filter((part) => part.definition.capabilities.includes('EDIT')) + if (editableParts.length === 0) return + const toolId = selectedToolId + const fileList = editableParts + .map((part) => `${part.content ? panelText.toBeUpdated : panelText.toBeCreated} · ${part.content?.path ?? part.candidatePath}`) + .join('\n') + modal.confirm({ + title: compositeMode ? panelText.confirmSaveMultiTitle : panelText.confirmSaveTitle, + content: compositeMode + ? `${panelText.confirmSaveMultiContent}\n${fileList}` + : formatPanelText(panelText.confirmSaveContent, { path: editableParts[0].content?.path ?? editableParts[0].candidatePath }), + okText: t('common.save'), + cancelText: t('common.cancel'), + onOk: async () => { + setSaving(true) + try { + for (const part of editableParts) { + if (!part.definition.capabilities.includes('VALIDATE')) continue + const artifactId = part.definition.artifactId + const response = await window.electronAPI.toolRegistry.validateArtifact( + toolId, + artifactId, + part.content?.path ?? '', + drafts[artifactId] ?? '' + ) + if (!response.success || !response.data?.valid) { + const errors = response.success && response.data && !response.data.valid + ? response.data.errors.join('; ') + : response.error || panelText.validateError + throw new Error(`${part.definition.displayName[language]}: ${errors}`) + } + } + for (const part of editableParts) { + const artifactId = part.definition.artifactId + const response = await window.electronAPI.toolRegistry.editArtifact( + toolId, + artifactId, + part.content?.path ?? '', + drafts[artifactId] ?? '' + ) + if (!response.success || !response.data) { + throw new Error(`${part.definition.displayName[language]}: ${response.error || panelText.saveError}`) + } + applySavedContent(artifactId, response.data) + } + message.success(panelText.saved) + } catch (error) { + message.error(error instanceof Error ? error.message : String(error)) + throw error + } finally { + setSaving(false) + } + } + }) + } + + /** 显式创建当前页签配置备份 */ + const createBackup = async (): Promise => { + if (!activePart?.content || !canBackup || !selectedToolId) return + const response = await window.electronAPI.toolRegistry.createArtifactBackup( + selectedToolId, + activePart.definition.artifactId, + activePart.content.path + ) + if (!response.success || !response.data) { + message.error(response.error || panelText.backupError) + return + } + message.success(formatPanelText(panelText.backupCreated, { id: response.data.backupId })) + } + + /** 按需加载当前页签 artifact 可恢复的备份 */ + const openBackupHistory = async (): Promise => { + if (!activePart?.content || !canRestore || !selectedToolId) return + setLoadingBackups(true) + setBackupHistoryOpen(true) + try { + const response = await window.electronAPI.toolRegistry.listArtifactBackups( + selectedToolId, + activePart.definition.artifactId, + activePart.content.path + ) + if (!response.success) throw new Error(response.error || panelText.listBackupsError) + setBackups(response.data ?? []) + } catch (error) { + setBackups([]) + message.error(error instanceof Error ? error.message : String(error)) + } finally { + setLoadingBackups(false) + } + } + + /** 二次确认后恢复备份并刷新对应分组成员的编辑器快照 */ + const restoreBackup = (backup: ConfigArtifactBackup): void => { + modal.confirm({ + title: panelText.restoreTitle, + content: formatPanelText(panelText.restoreContent, { + time: new Date(backup.createdAt).toLocaleString(language) + }), + okText: panelText.restore, + cancelText: t('common.cancel'), + onOk: async () => { + const response = await window.electronAPI.toolRegistry.restoreArtifactBackup(backup.backupId) + if (!response.success || !response.data) { + const error = new Error(response.error || panelText.restoreError) + message.error(error.message) + throw error + } + applySavedContent(response.data.artifactId, response.data) + setBackupHistoryOpen(false) + message.success(panelText.restored) + } + }) + } + + return ( +
+
+
+ {panelText.title} + {panelText.subtitle} +
+ +
+ + + + + + + + }} + renderItem={(tool) => { + const detection = detections[tool.toolId] + const selected = tool.toolId === selectedToolId + return ( + setSelectedToolId(tool.toolId)} + > + : } + title={tool.displayName[language]} + description={detection?.detected ? panelText.detected : panelText.notDetected} + /> + + ) + }} + /> + + + + + } onClick={() => void loadArtifacts(selectedToolId)}> + {panelText.scanArtifacts} + + )} + > + + }} + renderItem={(artifact) => { + const definition = selectedTool?.artifacts.find((item) => item.artifactId === artifact.artifactId) + return ( + void openArtifact(artifact)}> + {panelText.open} + + ]} + > + } + title={definition?.displayName[language] ?? artifact.artifactId} + description={( +
+ + {artifact.path} + +
+ {artifact.format} + {definition?.editGroup && {panelText.linkedEditTag}} + {definition?.capabilities.map((capability) => {capability})} +
+
+ )} + /> +
+ ) + }} + /> +
+
+ +
+
+ + 0} + width="min(1100px, 92vw)" + footer={null} + destroyOnHidden + onCancel={() => setEditorParts([])} + > + {activePart && ( + <> + {compositeMode && ( + ({ + key: part.definition.artifactId, + label: ( + + {part.definition.displayName[language]} + {drafts[part.definition.artifactId] !== baselines[part.definition.artifactId] && ' •'} + + ) + }))} + /> + )} + {!activePart.content && ( + + )} + + {activePart.definition.format} + {!canEdit && {panelText.readOnly}} + {canValidate && } + {canBackup && activePart.content && } + {canRestore && activePart.content && } + {canEdit && dirtyParts.length > 0 && ( + + )} + + }> + setDrafts((current) => ({ + ...current, + [activePart.definition.artifactId]: value + }))} + language={mapEditorLanguage(activePart.definition.format)} + readOnly={!canEdit} + showPreview={activePart.definition.format === 'MARKDOWN'} + height="55vh" + /> + + + )} + + + setBackupHistoryOpen(false)} + > + + }} + renderItem={(backup) => ( + restoreBackup(backup)}> + {panelText.restore} + + ]} + > + + {backup.originalPath} + {Math.max(1, Math.ceil(backup.size / 1024))} KB +
+ )} + /> + + )} + /> + + + + ) +} + +export default AIToolManagementPanel diff --git a/src/renderer/src/components/Common/CodeEditor.tsx b/src/renderer/src/components/Common/CodeEditor.tsx index ab37bc1..f710ede 100644 --- a/src/renderer/src/components/Common/CodeEditor.tsx +++ b/src/renderer/src/components/Common/CodeEditor.tsx @@ -19,15 +19,15 @@ import MarkdownRenderer from '@/components/Common/MarkdownRenderer' import type * as monaco from 'monaco-editor' // Monaco 语言 worker(Vite ?worker 导入)。修复原空 blob worker 导致语法诊断/tokenization // 退回主线程执行造成的内存与 CPU 开销(v1.4.0 性能根因之一)。 +// 语言服务按需:编辑器只处理 json/markdown/plaintext,不引入 ts/css/html worker。 import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker' import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker' -import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker' import { useTranslation } from '../../locales/useTranslation' import { useTheme } from '../../hooks/useTheme' const { Text } = Typography const { Option } = Select -type MonacoRuntime = typeof import('monaco-editor') +type MonacoRuntime = typeof import('@/monaco-runtime')['default'] type MonacoEditorComponent = typeof import('@monaco-editor/react')['default'] /** @@ -48,9 +48,6 @@ const ensureMonacoEnvironment = (): void => { switch (label) { case 'json': return new jsonWorker() - case 'typescript': - case 'javascript': - return new tsWorker() default: return new editorWorker() } @@ -115,10 +112,11 @@ const CodeEditor: React.FC = ({ */ const loadMonacoRuntime = async () => { try { - const [{ default: MonacoEditor, loader }, monacoRuntime] = await Promise.all([ + const [{ default: MonacoEditor, loader }, monacoRuntimeModule] = await Promise.all([ import('@monaco-editor/react'), - import('monaco-editor') + import('@/monaco-runtime') ]) + const monacoRuntime = monacoRuntimeModule.default ensureMonacoEnvironment() loader.config({ monaco: monacoRuntime }) diff --git a/src/renderer/src/components/Common/Logo.tsx b/src/renderer/src/components/Common/Logo.tsx index b34363e..4210033 100644 --- a/src/renderer/src/components/Common/Logo.tsx +++ b/src/renderer/src/components/Common/Logo.tsx @@ -120,4 +120,4 @@ export const LogoXLarge: React.FC> = (props) => ( ) -export default Logo \ No newline at end of file +export default Logo diff --git a/src/renderer/src/components/Common/PrivilegeWarningModal.tsx b/src/renderer/src/components/Common/PrivilegeWarningModal.tsx index 4e936fe..36980b0 100644 --- a/src/renderer/src/components/Common/PrivilegeWarningModal.tsx +++ b/src/renderer/src/components/Common/PrivilegeWarningModal.tsx @@ -330,7 +330,7 @@ const PrivilegeWarningModal: React.FC = ({ ( - + {index + 1}. {item} @@ -396,4 +396,4 @@ const PrivilegeWarningModal: React.FC = ({ ) } -export default PrivilegeWarningModal \ No newline at end of file +export default PrivilegeWarningModal diff --git a/src/renderer/src/components/Config/CloudTemplateLibraryModal.tsx b/src/renderer/src/components/Config/CloudTemplateLibraryModal.tsx new file mode 100644 index 0000000..9df628b --- /dev/null +++ b/src/renderer/src/components/Config/CloudTemplateLibraryModal.tsx @@ -0,0 +1,173 @@ +/** + * @file src/renderer/src/components/Config/CloudTemplateLibraryModal.tsx + * @description 共享云模板库弹窗(Claude 配置面板与多工具配置集面板共用): + * 仅显示当前所选工具(toolId)的云模板,其他工具的模板不可见也不可导入, + * 避免跨工具的无效导入。清单拉取与导入全部经 main 侧验签链(Ed25519 → SHA-256 → + * schema → minAppVersion),弹窗本身不接触任何 URL 或模板内容。 + */ + +import React, { useEffect, useMemo, useState } from 'react' +import { App, Button, Empty, List, Modal, Space, Spin, Tag, Typography } from 'antd' +import { DownloadOutlined } from '@ant-design/icons' +import type { TemplateCloudItemMeta } from '@shared/template-cloud' +import { useTranslation } from '../../locales/useTranslation' + +const { Text } = Typography + +/** 导入成功回传给父面板的信息(CONFIG_SET 导入后父面板可刷新列表/托盘) */ +export interface CloudTemplateImportedInfo { + kind: 'CONFIG_SET' | 'ARTIFACT' + configSetName?: string +} + +interface CloudTemplateLibraryModalProps { + open: boolean + toolId: string + toolLabel: string + onClose: () => void + onImported?: (info: CloudTemplateImportedInfo) => void +} + +/** + * 云模板库弹窗组件。 + * @description 每次打开重新拉取并验签清单;导入结果:CONFIG_SET → 本地配置集快照, + * ARTIFACT → 该工具默认模板 override。两者均不直接修改生效配置。 + */ +const CloudTemplateLibraryModal: React.FC = ({ + open, + toolId, + toolLabel, + onClose, + onImported +}) => { + const { t } = useTranslation() + const { message } = App.useApp() + const [loading, setLoading] = useState(false) + const [items, setItems] = useState([]) + const [indexVersion, setIndexVersion] = useState('') + const [importingTemplateId, setImportingTemplateId] = useState('') + + // 每次打开重新拉取清单(main 侧验签),关闭时清空旧数据 + useEffect(() => { + if (!open) { + setItems([]) + setIndexVersion('') + return + } + let cancelled = false + setLoading(true) + const loadIndex = async (): Promise => { + try { + const response = await window.electronAPI.toolRegistry.listCloudTemplates() + if (cancelled) return + if (!response.success || !response.data) { + throw new Error(response.error || t('configPanel.cloud.loadError')) + } + setItems(response.data.items) + setIndexVersion(response.data.templatesVersion) + } catch (error) { + if (cancelled) return + setItems([]) + message.error(error instanceof Error ? error.message : String(error)) + } finally { + if (!cancelled) setLoading(false) + } + } + void loadIndex() + return () => { + cancelled = true + } + }, [open, message, t]) + + // 按当前工具过滤:跨工具模板既不显示也不可导入 + const toolItems = useMemo( + () => items.filter((item) => item.toolId === toolId), + [items, toolId] + ) + + /** 导入云模板:CONFIG_SET → 本地配置集;ARTIFACT → 默认模板 override */ + const importTemplate = async (item: TemplateCloudItemMeta): Promise => { + setImportingTemplateId(item.templateId) + try { + const response = await window.electronAPI.toolRegistry.importCloudTemplate(item.templateId) + if (!response.success || !response.data) { + throw new Error(response.error || t('configPanel.cloud.importError')) + } + if (response.data.kind === 'CONFIG_SET') { + message.success(t('configPanel.cloud.importedSet', { name: response.data.configSet.name })) + onImported?.({ kind: 'CONFIG_SET', configSetName: response.data.configSet.name }) + } else { + message.success(t('configPanel.cloud.importedArtifact')) + onImported?.({ kind: 'ARTIFACT' }) + } + } catch (error) { + message.error(error instanceof Error ? error.message : String(error)) + } finally { + setImportingTemplateId('') + } + } + + return ( + + + + {t('configPanel.cloud.hint', { tool: toolLabel })} + {indexVersion && ` · ${t('configPanel.cloud.indexVersion', { version: indexVersion })}`} + + {loading ? ( +
+ +
+ ) : toolItems.length === 0 ? ( + {t('configPanel.cloud.empty', { tool: toolLabel })}} + /> + ) : ( + ( + } + loading={importingTemplateId === item.templateId} + onClick={() => void importTemplate(item)} + > + {t('configPanel.cloud.import')} + + ]} + > + + {item.name} + + {item.kind === 'CONFIG_SET' + ? t('configPanel.cloud.kindConfigSet') + : t('configPanel.cloud.kindArtifact')} + +
+ } + description={item.description} + /> +
+ )} + /> + )} + + + ) +} + +export default CloudTemplateLibraryModal diff --git a/src/renderer/src/components/Config/ConfigEditor.tsx b/src/renderer/src/components/Config/ConfigEditor.tsx index 84ad487..4347c25 100644 --- a/src/renderer/src/components/Config/ConfigEditor.tsx +++ b/src/renderer/src/components/Config/ConfigEditor.tsx @@ -37,7 +37,10 @@ import { useConfigValidationStore } from '../../store/config-validation-store' import { useEditorSettings } from '../../store/settings-store' import { useMessage } from '../../hooks/useMessage' import type { ConfigFile } from '@shared/types' -import { normalizeNewConfigTemplate } from '@shared/config-template' +import { + applyResolvedTemplateIfUntouched, + normalizeNewConfigTemplate +} from '@shared/config-template' import { type EditorLanguage, resolveConfigEditorLanguage @@ -140,6 +143,7 @@ const ConfigEditor: React.FC = ({ // 初始化表单数据 useEffect(() => { + let cancelled = false if (visible) { if (config) { // 编辑模式 - 设置表单字段 @@ -181,17 +185,38 @@ const ConfigEditor: React.FC = ({ setEditorLanguage(language) } else { // 新建模式 - const defaultContent = normalizeNewConfigTemplate(editorSettings.defaultConfigTemplate) + const fallbackContent = normalizeNewConfigTemplate(editorSettings.defaultConfigTemplate) form.setFieldsValue({ name: '', description: '', type: 'claude-code', isActive: false }) - setContent(defaultContent) + setContent(fallbackContent) setEditorLanguage('json') + + // v1.5.0:由 main process 统一解析 USER_OVERRIDE > REGISTRY > EMBEDDED ownership。 + void window.electronAPI.toolRegistry.resolveArtifactTemplate('claude-code', 'user-settings') + .then((response) => { + if (!cancelled && response.success && response.data) { + setContent((currentContent) => + applyResolvedTemplateIfUntouched( + currentContent, + fallbackContent, + response.data?.effectiveTemplate ?? currentContent + ) + ) + } + }) + .catch((error) => { + console.warn('加载 artifact-specific template 失败,使用 legacy fallback:', error) + }) } } + + return () => { + cancelled = true + } }, [visible, config, initialDraft, form, loadConfigContent, editorSettings.defaultConfigTemplate]) // 从store的editorContent加载内容(统一架构:只处理纯内容) diff --git a/src/renderer/src/components/Config/ModernConfigPanel.css b/src/renderer/src/components/Config/ModernConfigPanel.css index 0a8c8f6..e53c7fc 100644 --- a/src/renderer/src/components/Config/ModernConfigPanel.css +++ b/src/renderer/src/components/Config/ModernConfigPanel.css @@ -18,14 +18,20 @@ display: flex; align-items: center; justify-content: space-between; + /* 窄窗口时标题与按钮组换行而非相互挤压 */ + flex-wrap: wrap; + gap: var(--space-sm); padding: 0; /* 移除 margin,使用父容器的 gap */ } .header-left { + /* 标题与副标题上下排布,长副标题不再被挤成竖排换行 */ display: flex; - align-items: center; - gap: var(--space-md); + flex-direction: column; + align-items: flex-start; + gap: 2px; + min-width: 0; } .panel-title { @@ -37,6 +43,9 @@ .header-right { display: flex; align-items: center; + flex-wrap: wrap; + justify-content: flex-end; + gap: var(--space-xs); } /* 工具栏 */ @@ -57,6 +66,9 @@ align-items: center; gap: var(--space-md); flex: 1; + /* 允许筛选控件换行,避免固定宽度在窄窗口互相挤压 */ + flex-wrap: wrap; + min-width: 0; } .toolbar-right { @@ -187,6 +199,11 @@ color: var(--text-primary); font-weight: var(--font-semibold); line-height: 1.3; + /* 名称过长时省略号截断,而不是把行内按钮挤到换行 */ + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } .list-item-actions { @@ -195,6 +212,12 @@ gap: var(--space-xs); opacity: 0; transition: opacity var(--transition-fast); + /* 行内按钮不参与收缩,配合名称省略号避免中文按钮文字被挤成两行 */ + flex-shrink: 0; +} + +.list-item-actions .ant-btn { + white-space: nowrap; } .config-list-item:hover .list-item-actions { @@ -269,7 +292,10 @@ } .toolbar-left .ant-input-search, - .toolbar-left .ant-select { + .toolbar-left .ant-select, + .toolbar-left .ant-input-affix-wrapper { + /* 中和桌面端的 flex-basis(列方向下 flex-basis 作用于高度),恢复整行占满 */ + flex: none; width: 100% !important; } diff --git a/src/renderer/src/components/Config/ModernConfigPanel.tsx b/src/renderer/src/components/Config/ModernConfigPanel.tsx index a271b87..34ceb7b 100644 --- a/src/renderer/src/components/Config/ModernConfigPanel.tsx +++ b/src/renderer/src/components/Config/ModernConfigPanel.tsx @@ -25,6 +25,7 @@ import { EditOutlined, DeleteOutlined, CopyOutlined, + CloudDownloadOutlined, DownloadOutlined, UploadOutlined, EyeOutlined, @@ -37,9 +38,12 @@ import { import { useConfigListStore } from '../../store/config-list-store' import { useConfigEditorStore } from '../../store/config-editor-store' import { ConfigFile } from '@shared/types' +import type { ToolDefinition } from '@shared/tool-registry' import type { ConfigEditorDraft, ConfigSavePayload } from './ConfigEditor' const ConfigEditor = React.lazy(() => import('./ConfigEditor')) const ConfigImportModal = React.lazy(() => import('./ConfigImportModal')) +const ToolConfigSetPanel = React.lazy(() => import('./ToolConfigSetPanel')) +const CloudTemplateLibraryModal = React.lazy(() => import('./CloudTemplateLibraryModal')) const CodeEditor = React.lazy(() => import('../Common/CodeEditor')) import { useTranslation } from '../../locales/useTranslation' import { @@ -57,7 +61,7 @@ const { Option } = Select * 现代化配置面板组件 */ const ModernConfigPanel: React.FC = () => { - const { t } = useTranslation() + const { t, language } = useTranslation() // v1.4.0:使用 App context 的 message/modal 替代静态 message/Modal.confirm/info,消除 antd 静态函数警告 const { message, modal } = App.useApp() @@ -89,6 +93,36 @@ const ModernConfigPanel: React.FC = () => { // hasBackup 用于检查备份状态,当前仅设置但未读取(预留为后续功能) const [, setHasBackup] = useState(false) + // 多工具配置管理:claude-code 走遗留工作区通道,其余 registry 工具走配置集通道 + const [manageToolId, setManageToolId] = useState('claude-code') + const [configSetTools, setConfigSetTools] = useState>([]) + // Claude 面板的云模板库入口(共享弹窗,按 toolId=claude-code 过滤) + const [cloudTemplateOpen, setCloudTemplateOpen] = useState(false) + + useEffect(() => { + let cancelled = false + const loadConfigSetTools = async (): Promise => { + try { + const response = await window.electronAPI.toolRegistry.getSnapshot() + if (!response.success || !response.data || cancelled) return + setConfigSetTools( + response.data.tools + .filter((tool: ToolDefinition) => tool.artifacts.some((artifact) => artifact.configSet)) + .map((tool: ToolDefinition) => ({ + toolId: tool.toolId, + label: tool.displayName[language] || tool.toolId + })) + ) + } catch { + // 快照加载失败时保留 claude-code 单工具视图,不阻塞配置页 + } + } + void loadConfigSetTools() + return () => { + cancelled = true + } + }, [language]) + const [editorVisible, setEditorVisible] = useState(false) const [importVisible, setImportVisible] = useState(false) const [editingConfig, setEditingConfig] = useState(null) @@ -642,6 +676,59 @@ const ModernConfigPanel: React.FC = () => { ) } + /** + * 工具选择下拉框:claude-code(遗留工作区配置)+ registry 声明 configSet 的工具 + */ + const renderToolSelector = () => ( + + ) + + // 非 claude-code 工具:渲染 registry 配置集面板(遗留 store 的错误不影响通用视图) + if (manageToolId !== 'claude-code') { + const activeTool = configSetTools.find((tool) => tool.toolId === manageToolId) + return ( +
+
+
{renderToolSelector()}
+
+ {activeTool ? ( + }> + + + ) : ( +
+ +
{t('configPanel.empty')}
+ +
+ } + /> +
+ )} + + ) + } + if (error) { return (
@@ -676,7 +763,8 @@ const ModernConfigPanel: React.FC = () => {
- + + {renderToolSelector()} +
@@ -711,7 +805,7 @@ const ModernConfigPanel: React.FC = () => { placeholder={t('configPanel.search.placeholder')} allowClear value={filters.search} - style={{ width: 300 }} + style={{ flex: '0 1 300px', minWidth: 180 }} onSearch={handleSearch} onChange={(e) => handleSearch(e.target.value)} /> @@ -720,7 +814,7 @@ const ModernConfigPanel: React.FC = () => { placeholder={t('configPanel.filters.typePlaceholder')} allowClear value={filters.type} - style={{ width: 150 }} + style={{ flex: '0 1 150px', minWidth: 120 }} onChange={(value) => handleFilterChange('type', value)} > @@ -739,7 +833,7 @@ const ModernConfigPanel: React.FC = () => { setSearchText(e.target.value)} + placeholder={panelText.searchPlaceholder} + prefix={} + style={{ flex: '0 1 300px', minWidth: 180 }} + /> + + + +
+ {loading ? ( +
+ +
+ ) : sets.length === 0 ? ( +
+ {panelText.empty}
} + > + + +
+ ) : visibleSets.length === 0 ? ( +
+ {panelText.searchEmpty}
} /> + + ) : ( +
+
+ {visibleSets.map((set) => ( +
+
+ {set.isInUse ? : } +
+
+
+ {set.name} +
+ + +
+
+
+
+ {set.isInUse && {panelText.inUse}} + + {formatPanelText(panelText.files, { count: String(set.files.length) })} + + + {formatPanelText(panelText.createdAt, { time: formatDate(set.createdAt) })} + +
+
+
+
+ ))} +
+
+ )} + + + {/* 新建配置集 */} + { + setCreateOpen(false) + setCreateName('') + }} + onOk={() => void submitCreate()} + confirmLoading={creating} + okText={panelText.create} + cancelText={language === 'zh-CN' ? '取消' : 'Cancel'} + centered + > + + setCreateName(e.target.value)} + onPressEnter={() => void submitCreate()} + placeholder={panelText.createPlaceholder} + maxLength={48} + autoFocus + /> + {panelText.createHint} + + + + {/* 编辑配置集内容 */} + + {language === 'zh-CN' ? '关闭' : 'Close'} + , + + ]} + > + {editTabs.length > 0 && ( + ({ + key: tab.artifactId, + label: tab.artifactId, + children: ( +
+ }> + { + setDrafts((current) => ({ ...current, [tab.artifactId]: value ?? '' })) + }} + /> + +
+ ) + }))} + /> + )} +
+ + {/* 云模板库(共享组件:按当前工具过滤显示/导入) */} + setCloudOpen(false)} + onImported={(info) => { + if (info.kind === 'CONFIG_SET') { + refreshTrayMenu() + void loadSets() + } + }} + /> + + ) +} + +export default ToolConfigSetPanel diff --git a/src/renderer/src/components/Layout/ModernLayout.css b/src/renderer/src/components/Layout/ModernLayout.css index a18d2ba..868c7c4 100644 --- a/src/renderer/src/components/Layout/ModernLayout.css +++ b/src/renderer/src/components/Layout/ModernLayout.css @@ -24,7 +24,7 @@ overflow: hidden; } -/* 侧边栏头部 */ +/* 侧边栏头部(容器查询锚点:logo 组随内容宽度按比例整体缩放) */ .sidebar-header { padding: var(--space-lg); border-bottom: 1px solid var(--border-light); @@ -32,6 +32,7 @@ display: flex; justify-content: center; align-items: center; + container-type: inline-size; } .sidebar-logo { @@ -43,9 +44,10 @@ justify-content: center; } +/* logo 与文字一体:尺寸全部以容器宽度(cqw)为基准,空间不足时整组等比缩小 */ .logo-icon { - width: 32px; - height: 32px; + width: clamp(20px, 18cqw, 32px); + height: clamp(20px, 18cqw, 32px); border-radius: var(--radius-md); flex-shrink: 0; object-fit: contain; @@ -58,9 +60,9 @@ overflow: hidden; } -.logo-title { - font-size: var(--text-lg); - font-weight: var(--font-bold); +.logo-text .logo-title { + font-size: clamp(11px, 8.5cqw, var(--font-size-lg)); + font-weight: 600; color: var(--text-primary); line-height: 1.2; white-space: nowrap; @@ -68,8 +70,8 @@ text-overflow: ellipsis; } -.logo-subtitle { - font-size: var(--text-xs); +.logo-text .logo-subtitle { + font-size: clamp(9px, 6.25cqw, var(--font-size-xs)); color: var(--text-secondary); line-height: 1.2; white-space: nowrap; diff --git a/src/renderer/src/components/Layout/ModernLayout.tsx b/src/renderer/src/components/Layout/ModernLayout.tsx index b9d7be1..165de43 100644 --- a/src/renderer/src/components/Layout/ModernLayout.tsx +++ b/src/renderer/src/components/Layout/ModernLayout.tsx @@ -31,6 +31,7 @@ import { CheckCircleOutlined, RobotOutlined as AgentOutlined, AppstoreOutlined as SkillsOutlined, + CodeOutlined, DownOutlined, UpOutlined } from '@ant-design/icons' @@ -362,8 +363,8 @@ const ModernLayout: React.FC = ({ children }) => { CCB {!sidebarCollapsed && (
- CCB - Claude Code Butler + CCB + Claude Code Butler
)} @@ -372,6 +373,15 @@ const ModernLayout: React.FC = ({ children }) => {
+
setActiveMainTab('ai-tools')} + > +
+ +
+ {!sidebarCollapsed && {t('layout.nav.aiTools')}} +
setActiveMainTab('configs')} diff --git a/src/renderer/src/components/Settings/ArtifactTemplateSettings.css b/src/renderer/src/components/Settings/ArtifactTemplateSettings.css new file mode 100644 index 0000000..71e2082 --- /dev/null +++ b/src/renderer/src/components/Settings/ArtifactTemplateSettings.css @@ -0,0 +1,80 @@ +/** Artifact-specific template settings styles. */ + +.artifact-template-loading { + display: flex; + min-height: 180px; + align-items: center; + justify-content: center; +} + +.artifact-template-settings .ant-alert { + margin-bottom: 16px; +} + +.artifact-template-toolbar { + display: flex; + gap: 16px; + align-items: center; + justify-content: space-between; + margin-bottom: 16px; +} + +.artifact-template-toolbar .ant-select { + min-width: min(100%, 360px); +} + +.artifact-template-actions { + display: flex; + gap: 8px; + justify-content: flex-end; + margin-top: 16px; +} + +.artifact-template-diff { + max-height: 55vh; + margin: 16px 0; + overflow: auto; + border: 1px solid var(--border-light); + border-radius: var(--radius-sm); + background: var(--bg-input); + color: var(--text-primary); +} + +.artifact-template-diff-error { + margin: 16px 0; +} + +.artifact-template-diff-line { + display: flex; + min-height: 22px; + white-space: pre-wrap; +} + +.artifact-template-diff-line.is-added { + background: color-mix(in srgb, var(--success-color) 14%, transparent); +} + +.artifact-template-diff-line.is-removed { + background: color-mix(in srgb, var(--error-color) 14%, transparent); +} + +.artifact-template-diff-marker { + width: 28px; + flex: 0 0 28px; + padding-left: 8px; + color: var(--text-secondary); + user-select: none; +} + +@media (max-width: 640px) { + .artifact-template-toolbar, + .artifact-template-actions { + align-items: stretch; + flex-direction: column; + } + + .artifact-template-toolbar .ant-select { + width: 100%; + min-width: 0; + } +} diff --git a/src/renderer/src/components/Settings/ArtifactTemplateSettings.tsx b/src/renderer/src/components/Settings/ArtifactTemplateSettings.tsx new file mode 100644 index 0000000..c9f027c --- /dev/null +++ b/src/renderer/src/components/Settings/ArtifactTemplateSettings.tsx @@ -0,0 +1,258 @@ +/** + * @file Artifact-specific template settings + * @description 管理 registry template、embedded baseline 与本地 user override,并提供逐行 diff preview。 + */ + +import React, { useCallback, useEffect, useMemo, useState } from 'react' +import { Alert, Button, Card, Empty, Modal, Popconfirm, Select, Space, Spin, Tag, Typography } from 'antd' +import { DeleteOutlined, EyeOutlined, SaveOutlined } from '@ant-design/icons' +import type { ArtifactFormat, ArtifactTemplateEntry } from '@shared/tool-registry' +import { createTemplateLineDiff } from '@shared/config-template' +import { useMessage } from '../../hooks/useMessage' +import { useTranslation } from '../../locales/useTranslation' +import { useSettingsStore } from '../../store/settings-store' +import CodeEditor from '../Common/CodeEditor' +import './ArtifactTemplateSettings.css' + +const { Text } = Typography + +const COPY = { + 'zh-CN': { + title: '按配置资产管理模板', + help: '用户覆盖 > 已安装规则库 > 应用内置模板。规则库更新或回滚不会覆盖你的本地模板。', + select: '选择配置资产', + source: '当前来源', + save: '保存用户覆盖', + remove: '移除用户覆盖', + preview: '差异预览', + saved: '模板覆盖已保存', + removed: '已恢复使用规则库或内置模板', + loadFailed: '加载模板目录失败', + saveFailed: '保存模板失败', + removeFailed: '移除模板覆盖失败', + noTemplates: '当前规则库没有可管理的模板', + diffTitle: '模板差异预览', + diffBase: '比较基线:规则库优先,否则使用应用内置模板', + unchanged: '未修改', + added: '新增', + removedLine: '删除' + }, + 'en-US': { + title: 'Artifact-specific templates', + help: 'User override > installed registry > embedded template. Registry updates and rollbacks never overwrite local templates.', + select: 'Select artifact', + source: 'Effective source', + save: 'Save user override', + remove: 'Remove user override', + preview: 'Preview diff', + saved: 'Template override saved', + removed: 'Restored registry or embedded template', + loadFailed: 'Failed to load template catalog', + saveFailed: 'Failed to save template', + removeFailed: 'Failed to remove template override', + noTemplates: 'The current registry has no manageable templates', + diffTitle: 'Template diff preview', + diffBase: 'Baseline: registry template, falling back to the embedded template', + unchanged: 'Unchanged', + added: 'Added', + removedLine: 'Removed' + } +} as const + +/** 将 artifact format 映射为 CodeEditor language。 */ +function getEditorLanguage(format: ArtifactFormat): 'json' | 'markdown' | 'plaintext' { + if (format === 'JSON' || format === 'JSONC') return 'json' + if (format === 'MARKDOWN') return 'markdown' + return 'plaintext' +} + +/** Artifact template ownership 设置组件。 */ +const ArtifactTemplateSettings: React.FC = () => { + const { language } = useTranslation() + const copy = COPY[language] + const message = useMessage() + const reloadSettings = useSettingsStore((state) => state.loadSettings) + const [entries, setEntries] = useState([]) + const [selectedKey, setSelectedKey] = useState() + const [draft, setDraft] = useState('') + const [loading, setLoading] = useState(true) + const [saving, setSaving] = useState(false) + const [diffVisible, setDiffVisible] = useState(false) + + const selected = useMemo( + () => entries.find((entry) => entry.key === selectedKey), + [entries, selectedKey] + ) + + /** 加载 main-process 解析后的 template catalog。 */ + const loadEntries = useCallback(async (preferredKey?: string) => { + setLoading(true) + try { + const response = await window.electronAPI.toolRegistry.listArtifactTemplates() + if (!response.success || !response.data) throw new Error(response.error || copy.loadFailed) + setEntries(response.data) + const nextKey = response.data.some((entry) => entry.key === preferredKey) + ? preferredKey + : response.data[0]?.key + setSelectedKey(nextKey) + const nextEntry = response.data.find((entry) => entry.key === nextKey) + setDraft(nextEntry?.userOverride ?? nextEntry?.effectiveTemplate ?? '') + } catch (error) { + message.error(`${copy.loadFailed}: ${error instanceof Error ? error.message : String(error)}`) + } finally { + setLoading(false) + } + }, [copy.loadFailed, message]) + + useEffect(() => { + void loadEntries() + }, [loadEntries]) + + /** 切换 artifact 并加载其 user/effective template。 */ + const handleSelect = (key: string) => { + const entry = entries.find((candidate) => candidate.key === key) + setSelectedKey(key) + setDraft(entry?.userOverride ?? entry?.effectiveTemplate ?? '') + } + + /** 保存当前 artifact 的独立 user override。 */ + const handleSave = async () => { + if (!selected) return + setSaving(true) + try { + const response = await window.electronAPI.toolRegistry.saveArtifactTemplateOverride( + selected.toolId, + selected.artifactId, + draft + ) + if (!response.success) throw new Error(response.error || copy.saveFailed) + await reloadSettings() + message.success(copy.saved) + await loadEntries(selected.key) + } catch (error) { + message.error(`${copy.saveFailed}: ${error instanceof Error ? error.message : String(error)}`) + } finally { + setSaving(false) + } + } + + /** 删除当前 artifact 的 user override,并恢复 registry/embedded ownership。 */ + const handleRemove = async () => { + if (!selected) return + setSaving(true) + try { + const response = await window.electronAPI.toolRegistry.removeArtifactTemplateOverride( + selected.toolId, + selected.artifactId + ) + if (!response.success) throw new Error(response.error || copy.removeFailed) + await reloadSettings() + message.success(copy.removed) + await loadEntries(selected.key) + } catch (error) { + message.error(`${copy.removeFailed}: ${error instanceof Error ? error.message : String(error)}`) + } finally { + setSaving(false) + } + } + + const baseline = selected?.registryTemplate ?? selected?.embeddedTemplate ?? '' + const diffResult = useMemo(() => { + if (!diffVisible) return { lines: [], error: undefined } + try { + return { lines: createTemplateLineDiff(baseline, draft), error: undefined } + } catch (error) { + return { lines: [], error: error instanceof Error ? error.message : String(error) } + } + }, [baseline, diffVisible, draft]) + + if (loading) { + return
+ } + + if (entries.length === 0) { + return + } + + return ( + + +
+