agentworkshop 0.17.4 → 0.17.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.output/nitro.json +1 -1
- package/.output/public/_nuxt/builds/latest.json +1 -1
- package/.output/public/_nuxt/builds/meta/147c0379-4e07-437d-a7d2-e700d633efad.json +1 -0
- package/.output/server/chunks/_/nitro.mjs +949 -949
- package/.output/server/package.json +1 -1
- package/README-zh.md +13 -6
- package/README.md +13 -6
- package/config.yml +1 -1
- package/desktop/chrome/contract.mjs +59 -3
- package/desktop/chrome/preload-splash.cjs +29 -0
- package/desktop/chrome/preload.cjs +2 -0
- package/desktop/chrome/settings.mjs +24 -0
- package/desktop/chrome/splash.html +629 -0
- package/desktop/chrome/titlebar.html +8 -1
- package/desktop/chrome/tray-menu.mjs +56 -0
- package/desktop/main.mjs +694 -42
- package/desktop/sidecar.mjs +12 -2
- package/docs/cli.en.md +1 -1
- package/docs/cli.md +1 -1
- package/docs/desktop.md +21 -3
- package/docs/plugins.en.md +1 -1
- package/docs/plugins.md +1 -1
- package/docs/sdk.en.md +1 -1
- package/docs/sdk.md +1 -1
- package/package.json +223 -219
- package/.output/public/_nuxt/builds/meta/2547f38c-dfaf-48fa-9b29-334889a73f2c.json +0 -1
package/README-zh.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
[](https://www.npmjs.com/package/agentworkshop)
|
|
12
12
|
[](https://www.npmjs.com/package/agentworkshop)
|
|
13
|
-
[](https://github.com/kingdol666/AgentWorkShop/releases/tag/v0.17.
|
|
13
|
+
[](https://github.com/kingdol666/AgentWorkShop/releases/tag/v0.17.5)
|
|
14
14
|
[](https://github.com/kingdol666/AgentWorkShop/stargazers)
|
|
15
15
|
[](https://github.com/kingdol666/AgentWorkShop/commits)
|
|
16
16
|
[](https://github.com/kingdol666/AgentWorkShop/issues)
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
|
|
29
29
|
**[English](./README.md)** · **[在线文档](https://kingdol666.github.io/AgentWorkShop)** · **[版本发布](https://github.com/kingdol666/AgentWorkShop/releases)** · **[更新日志](./changelog.md)** · **[插件 API](./docs/plugins.md)** · **[SDK](./docs/sdk.md)**
|
|
30
30
|
|
|
31
|
-
<sub><b>源码 v0.17.
|
|
31
|
+
<sub><b>源码 v0.17.5(2026-11-23 发布)</b> · 桌面托盘与启动动画 · 一体化桌面壳与应用内更新 · 桌面/Web 共用 <code>~/.AgentWorkShop</code> · 14 个执行引擎 · 6 种现场协议(5 内置 + 串口插件)+ MES REST(镜像与直连双路径)· **项目中心** · **RSI 经验演化** · **受治理产品经验** · **IDD/RAG 插件集成** · **AgentPrefab / Skill / MCP 能力供应链** · 双语文档(简体中文 / English)</sub>
|
|
32
32
|
|
|
33
33
|
<br />
|
|
34
34
|
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
|
|
37
37
|
</div>
|
|
38
38
|
|
|
39
|
-
[快速开始](#快速开始) · [当前源码](#当前源码-v0-17-
|
|
39
|
+
[快速开始](#快速开始) · [当前源码](#当前源码-v0-17-5) · [0.17.5 发布说明](#whats-new-in-0175) · [Agent 团队模型](#agent-团队模型) · [核心能力](#核心能力) · [设计架构](#设计架构) · [验证与验收](#验证与验收) · [文档站](https://kingdol666.github.io/AgentWorkShop)
|
|
40
40
|
|
|
41
41
|
---
|
|
42
42
|
|
|
@@ -49,12 +49,19 @@
|
|
|
49
49
|
- **交付是一等概念**:**Project 模式**把蓝图变成计划、带依赖的 WBS、L1 技术复核、L2 Owner 验收与真实交付物——交付物不通过,项目不算完成;
|
|
50
50
|
- **作业链按治理阶段实现**:读取 → 分析 → 提案 → 按有效策略审批(如适用)→ 下发 → 回读/审计;每份验收证据应注明实际覆盖范围及使用模拟器还是物理设备。
|
|
51
51
|
|
|
52
|
-
## 当前源码 v0.17.
|
|
52
|
+
## 当前源码 v0.17.5
|
|
53
53
|
|
|
54
|
-
当前源码版本为 **0.17.
|
|
54
|
+
当前源码版本为 **0.17.5**(npm + GitHub Release,2026-11-23)。桌面壳现在按常驻应用工作:关闭窗口默认收进系统托盘,托盘原生菜单提供服务状态与端口、重新加载界面、重启本地服务、检查更新、数据/日志目录、诊断信息,以及 5 项持久化设置(关闭到托盘、开机自启、启动后最小化、托盘通知、自动检查更新);窗口隐藏时后端继续服务同一份共享 home。启动时立即显示 660×440 的初始化动画,按真实阶段(环境 → 数据 → 服务 → 工作台)展示带时间戳的启动日志、耗时与进度;只有 `/api/health` 返回 `status=ok` / `workshop=ready` 且页面加载完成后才进入主界面,失败时提供重试、打开日志与退出。本版保留 0.17.4 的 `/town` 与 `/workshop/w/:id` 「返回主界面」入口、40px 标题导轨、桌面/Web/CLI 共用 `~/.AgentWorkShop` 与 0.17.3 的 WSH 静默安装助手。同时保留 0.16.x 全部内容——0.15.x 的「AgentPrefab 能力装配」计划(#252–#258)加上 **Leader 自主管理 Worker 的 AgentPrefab 能力**(合并 PR #262/#264/#265):Channel Leader 创建 Worker 时可携带已发布 revision 选择器并原子固定 `(prefabId, revision, slotValues, contentHash)`;名册带 `manageable`/`protected` 标记;可按 revision 切换/解绑绑定;且只能移除自己创建的 Worker。Worker 创建来源持久化(`created_by_kind`/`created_by_id`/`created_via`/`created_reason`);人类绑定 Worker、其他 Leader 的 Worker、Lead、Project Leader 与未关闭 Session 克隆均受删除保护,移除时回收任务、同事务取消待投递并清理实例节点绑定,不动全局模板与不可变 revision。native/REST/MCP/Project 各路径 dispatch 对损坏/哈希不匹配绑定、停用成员、角色/版本不匹配与模板可见性越界一律 fail-closed;Project 任务实例重试复用首次固定的快照并做 CAS/哈希校验。已发布 Prefab profile 按字段应用到受支持 harness(OMP thinking level 走 RPC);唯一 Skill 别名解析为 canonical revision id。数据库契约 **v10** 新增来源列(存量行保守迁移为 `system`/`protected`)。
|
|
55
55
|
|
|
56
56
|
v0.16.0 验证:#262/#264/#265/#263/#266 PR quick-gate 全绿;focused 套件 **38/38**、合并后 **22/22** 与 **13/13**、Project/Prefab/Session 回归集 **235/235**;发布构建实机隔离验收——Leader/Prefab 全链 **30/30 ×2**(创建带 Prefab 的 Worker → SQLite 来源核验 → 名册标记 → 目录收窄 → dispatch 放行/拒绝 → 用户路径 Worker 保护 → lead 自改拒绝 → revision 切换即收窄 → 解绑 → 移除保留模板与 revision → REST 删 lead 409),官方 L10 全新实例 **21/21**,AgentTeam CRUD/部署/派发 **25/25**,前端 SSR 路由 200。Mimosa 深扫有封印(`sha256:a91957e0…`,54 findings,依赖风险 0)——findings 如实呈报,不作安全通过声明。边界:外部 MCP 正向实网联通、Prefab 指导下的真实 OMP 模型作业、浏览器 UI 点击验收为 NOT_RUN。见[全流程验收报告](docs/audit/evidence/2026-11-21-fullflow-round/REPORT.md)与[Prefab/Skills/MCP 实机报告](docs/audit/evidence/2026-11-21-agent-prefab-acceptance/REPORT.md)。
|
|
57
57
|
|
|
58
|
+
## What's new in 0.17.5
|
|
59
|
+
|
|
60
|
+
- **关闭到托盘**:标题栏关闭按钮改为隐藏窗口,不再杀掉后端;单击/双击托盘图标恢复窗口。需要「关闭即退出」时可在托盘设置里关闭「关闭时最小化到托盘」。关闭窗口默认最小化到托盘,后端与正在运行的任务继续工作。
|
|
61
|
+
- **托盘菜单**:实时显示本机服务状态与 `127.0.0.1:<port>`,提供重新加载界面、重启本地服务、检查更新、打开数据/日志目录、诊断信息,以及「设置」子菜单中的 5 项持久化开关:关闭到托盘、开机自动启动、启动后最小化到托盘、托盘通知、自动检查更新。设置保存在 `<home>/electron/settings.json`。
|
|
62
|
+
- **启动初始化动画**:启动立即显示无边框 660×440 初始化窗口,按真实阶段(环境 → 数据 → 服务 → 工作台)展示带时间戳的启动日志、耗时与进度;只有 `/api/health` 返回 `status=ok` / `workshop=ready` 且页面加载完成后才显示主窗口。失败时提供重试、打开日志与退出,而不是静默失败。
|
|
63
|
+
- **验收证据**:托盘在后端之前创建,`desktop-status.json` 记录 phase/port/trayCreated/windowVisible/settings。源码模式 E2E 覆盖:初始化动画 → 就绪、关闭 → 隐藏且后端健康、二次启动恢复窗口、启动即最小化、关闭即退出、自动退出后无残留后端。见 `docs/design/desktop-chrome/acceptance.md`。
|
|
64
|
+
|
|
58
65
|
## What's new in 0.17.4
|
|
59
66
|
|
|
60
67
|
- **独立页面返回主界面**:`/town`(数字孪生,town 布局)与 `/workshop/w/:id`(裸 console 布局)新增本地化 `AppBackToMain` 控件,`NuxtLink` 指向仪表盘 `/`(default 布局,带侧栏导航);640px 以下只显示箭头,`aria-label`/`title` 保留。数字孪生与裸控制台新增「返回主界面」入口,桌面端不再被困在全屏页面。
|
|
@@ -503,7 +510,7 @@ curl -X POST http://localhost:3001/api/workshop/projects/instantiate \
|
|
|
503
510
|
|
|
504
511
|
**如果这个项目对你有用,点一个 ⭐ 能让更多人找到它。**
|
|
505
512
|
|
|
506
|
-
当前源码版本:**v0.17.
|
|
513
|
+
当前源码版本:**v0.17.5(已发布 2026-11-23)** —— [最新版本 v0.17.5](https://github.com/kingdol666/AgentWorkShop/releases/tag/v0.17.5) · [更新日志](./changelog.md) · [在线文档](https://kingdol666.github.io/AgentWorkShop)
|
|
507
514
|
|
|
508
515
|
<a href="https://star-history.com/#kingdol666/AgentWorkShop&Date">
|
|
509
516
|
<img src="https://api.star-history.com/svg?repos=kingdol666/AgentWorkShop&type=Date" alt="Star history" width="70%" />
|
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
[](https://www.npmjs.com/package/agentworkshop)
|
|
12
12
|
[](https://www.npmjs.com/package/agentworkshop)
|
|
13
|
-
[](https://github.com/kingdol666/AgentWorkShop/releases/tag/v0.17.
|
|
13
|
+
[](https://github.com/kingdol666/AgentWorkShop/releases/tag/v0.17.5)
|
|
14
14
|
[](https://github.com/kingdol666/AgentWorkShop/stargazers)
|
|
15
15
|
[](https://github.com/kingdol666/AgentWorkShop/commits)
|
|
16
16
|
[](https://github.com/kingdol666/AgentWorkShop/issues)
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
|
|
29
29
|
**[简体中文](./README-zh.md)** · **[Documentation](https://kingdol666.github.io/AgentWorkShop)** · **[Releases](https://github.com/kingdol666/AgentWorkShop/releases)** · **[Changelog](./changelog.md)** · **[Plugin API](./docs/plugins.md)** · **[SDK](./docs/sdk.md)**
|
|
30
30
|
|
|
31
|
-
<sub><b>source v0.17.
|
|
31
|
+
<sub><b>source v0.17.5 (released 2026-11-23)</b> · desktop tray + boot splash · integrated desktop shell with in-app updates · shared <code>~/.AgentWorkShop</code> home · 14 engines · 6 field protocols (5 built-in + serial plugin) + MES REST (mirror & live) · **Project center** · **RSI experience evolution** · **governed product experience** · **IDD/RAG plugin integration** · **AgentPrefab / Skills / MCP capability supply chain** · bilingual docs (简体中文 / English)</sub>
|
|
32
32
|
|
|
33
33
|
<br />
|
|
34
34
|
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
|
|
37
37
|
</div>
|
|
38
38
|
|
|
39
|
-
[Quick start](#quick-start) · [Current source](#current-source-v0-17-
|
|
39
|
+
[Quick start](#quick-start) · [Current source](#current-source-v0-17-5) · [0.17.5 release notes](#whats-new-in-0175) · [Agent team model](#the-agent-team-model) · [Capabilities](#capabilities) · [Architecture](#architecture) · [Verification](#verification) · [Docs site](https://kingdol666.github.io/AgentWorkShop)
|
|
40
40
|
|
|
41
41
|
---
|
|
42
42
|
|
|
@@ -49,12 +49,19 @@ A configuration-driven platform where **AI agent teams** and industrial systems
|
|
|
49
49
|
- **Delivery is a first-class concept**: **Project mode** turns a blueprint into a plan, a WBS with dependencies, L1 technical review, L2 owner acceptance and real deliverables — the project closes only when the deliverables pass;
|
|
50
50
|
- **The loop is implemented in governed stages**: read → analyze → propose → policy-controlled approval where required → write → readback/audit; the scope of each test and whether it used a simulator or physical equipment are stated with its evidence.
|
|
51
51
|
|
|
52
|
-
## Current source: v0.17.
|
|
52
|
+
## Current source: v0.17.5
|
|
53
53
|
|
|
54
|
-
The source version is **0.17.
|
|
54
|
+
The source version is **0.17.5** (npm + GitHub Release, 2026-11-23). The desktop shell now behaves like a resident application: closing the window hides it to the system tray, whose native menu exposes the local service state and port, reload, restart-service, update check, data/log directories, diagnostics and five persisted settings (close to tray, launch at login, start hidden, tray notifications, automatic update checks); the backend keeps serving the shared home while the window is hidden. Startup shows a dedicated 660×440 boot splash with the real stages (environment → data → service → workshop), a live trace and elapsed time; the main window is revealed only after `/api/health` reports `status=ok` / `workshop=ready` and the page has loaded, with retry / open logs / quit on failure. It retains 0.17.4's “返回主界面” entry on `/town` and `/workshop/w/:id`, the 40px title rail, the shared `~/.AgentWorkShop` data home and the 0.17.3 WSH silent-install update helper. It retains the 0.16.x baseline — everything in 0.15.x — the AgentPrefab capability-assembly plan (#252–#258) plus **Leader-managed worker Prefabs** (merged PRs #262/#264/#265): a Channel Leader can create workers with a published AgentPrefab selector atomically pinned to `(prefabId, revision, slotValues, contentHash)`, inspect the roster with `manageable`/`protected` flags, switch or detach bindings per revision, and remove only the workers it created. Worker creation provenance is durable (`created_by_kind`/`created_by_id`/`created_via`/`created_reason`); human-bound workers, other leaders' workers, leads, Project Leaders and open Session clones are protected from removal, and removal recycles tasks, cancels pending chat deliveries and clears instance node bindings without touching global templates or immutable revisions. Dispatch (native/REST/MCP/Project) fails closed on malformed or hash-mismatched bindings, disabled members, role/version mismatches and template visibility crossings; Project task-instance retries reuse the originally pinned snapshot with CAS/hash validation. Published Prefab profiles apply to supported harness fields (OMP thinking level via RPC); unique Skill aliases resolve to canonical revision ids. Database schema contract v10 adds the provenance columns (existing rows migrate conservatively as `system`/`protected`).
|
|
55
55
|
|
|
56
56
|
v0.16.0 verification: PR quick-gates green on #262/#264/#265/#263/#266; focused suites **38/38**, post-merge **22/22** and **13/13**, Project/Prefab/Session regression set **235/235**; live isolated-instance acceptance on the release build — Leader/Prefab full chain **30/30 ×2** (create-with-prefab → provenance in SQLite → roster flags → catalog narrowing → dispatch allow/deny → user-worker protection → lead self-op denial → revision switch drops capability → unbind → remove preserves template+revisions → REST lead-delete 409), official L10 **21/21** on a fresh instance, AgentTeam CRUD/deploy/dispatch **25/25**, frontend SSR routes 200. Mimosa deep scan sealed (`sha256:a91957e0…`, 54 findings, dependency risk 0) — findings reported, not a security pass. Boundaries: external MCP positive live trace, real-OMP-model work under a prefab, and browser UI click-through remain NOT_RUN. See the [full-flow acceptance report](docs/audit/evidence/2026-11-21-fullflow-round/REPORT.md) and the [Prefab/Skills/MCP live report](docs/audit/evidence/2026-11-21-agent-prefab-acceptance/REPORT.md).
|
|
57
57
|
|
|
58
|
+
## What's new in 0.17.5
|
|
59
|
+
|
|
60
|
+
- **Close to tray**: the titlebar close button now hides the window instead of killing the backend. The tray icon restores it on click/double-click, and `关闭时最小化到托盘` can be turned off when a user prefers close-to-exit. 关闭窗口默认最小化到托盘,后端与正在运行的任务继续工作。
|
|
61
|
+
- **Tray menu**: live service state and `127.0.0.1:<port>`, reload UI, restart local service, check updates, open data/log directories, diagnostics, and a 设置 submenu with five persisted toggles: close to tray, launch at login, start hidden, tray notifications, automatic update checks. Settings live in `<home>/electron/settings.json`. 托盘菜单提供服务状态、重启服务、更新检查、数据/日志入口、诊断与 5 项设置。
|
|
62
|
+
- **Boot splash**: a frameless 660×440 initialization window appears immediately, reports the real stages (environment → data → service → workshop), a timestamped trace, elapsed time and progress, and reveals the main window only after `/api/health` reports `status=ok` / `workshop=ready` and the page has loaded. Failures offer retry, open logs and quit instead of dying silently. 启动动画显示真实初始化阶段;后端就绪后才进入主界面,失败可重试。
|
|
63
|
+
- **Acceptance evidence**: the tray is created before the backend and `desktop-status.json` records phase/port/trayCreated/windowVisible/settings. Source-mode E2E covered splash → ready, close → hidden with a healthy backend, second-instance re-show, start-hidden, close-to-exit, and clean autoquit with no orphan backend. 本轮 E2E 证据见 `docs/design/desktop-chrome/acceptance.md`。
|
|
64
|
+
|
|
58
65
|
## What's new in 0.17.4
|
|
59
66
|
|
|
60
67
|
- **Back to main on standalone pages**: `/town` (digital twin, `town` layout) and `/workshop/w/:id` (bare `console` layout) now render a localized `AppBackToMain` control — a NuxtLink to the dashboard `/`, which is the default layout with the navigation sidebar. The icon-only form is used below 640px, and the control keeps `aria-label`/`title`. 数字孪生与裸控制台新增「返回主界面」入口,回到带导航栏的仪表盘;桌面端不再被困在全屏页面。
|
|
@@ -499,7 +506,7 @@ Please **do not** open public issues for vulnerabilities — report privately vi
|
|
|
499
506
|
|
|
500
507
|
**If this project is useful to you, a ⭐ helps others find it.**
|
|
501
508
|
|
|
502
|
-
Current source version: **v0.17.
|
|
509
|
+
Current source version: **v0.17.5 (released 2026-11-23)** — [Latest release v0.17.5](https://github.com/kingdol666/AgentWorkShop/releases/tag/v0.17.5) · [Changelog](./changelog.md) · [Documentation](https://kingdol666.github.io/AgentWorkShop)
|
|
503
510
|
|
|
504
511
|
<a href="https://star-history.com/#kingdol666/AgentWorkShop&Date">
|
|
505
512
|
<img src="https://api.star-history.com/svg?repos=kingdol666/AgentWorkShop&type=Date" alt="Star history" width="70%" />
|
package/config.yml
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
// Shared, Electron-free contract between the desktop shell
|
|
2
|
-
// Keeping the values here lets unit tests
|
|
3
|
-
// importing electron (which cannot load outside
|
|
1
|
+
// Shared, Electron-free contract between the desktop shell, its titlebar, the
|
|
2
|
+
// boot splash and the test suite. Keeping the values here lets unit tests
|
|
3
|
+
// assert the IPC surface without importing electron (which cannot load outside
|
|
4
|
+
// the Electron runtime).
|
|
4
5
|
|
|
5
6
|
export const TITLEBAR_HEIGHT = 40
|
|
6
7
|
|
|
@@ -13,10 +14,19 @@ export const CHROME_CHANNELS = Object.freeze({
|
|
|
13
14
|
status: 'aw-chrome:status',
|
|
14
15
|
theme: 'aw-chrome:theme',
|
|
15
16
|
title: 'aw-chrome:title',
|
|
17
|
+
prefs: 'aw-chrome:prefs',
|
|
16
18
|
update: 'aw-chrome:update',
|
|
17
19
|
updateState: 'aw-chrome:update-state',
|
|
18
20
|
})
|
|
19
21
|
|
|
22
|
+
export const SPLASH_CHANNELS = Object.freeze({
|
|
23
|
+
action: 'aw-splash:action',
|
|
24
|
+
hello: 'aw-splash:hello',
|
|
25
|
+
state: 'aw-splash:state',
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
export const SPLASH_ACTIONS = Object.freeze(['retry', 'open-logs', 'quit'])
|
|
29
|
+
|
|
20
30
|
export const CHROME_THEMES = Object.freeze(['dark', 'light'])
|
|
21
31
|
|
|
22
32
|
/** True for the three window-control actions; everything else is ignored. */
|
|
@@ -24,6 +34,11 @@ export function isChromeAction(value) {
|
|
|
24
34
|
return typeof value === 'string' && CHROME_ACTIONS.includes(value)
|
|
25
35
|
}
|
|
26
36
|
|
|
37
|
+
/** True for the fixed splash actions; no other message reaches the main process. */
|
|
38
|
+
export function isSplashAction(value) {
|
|
39
|
+
return typeof value === 'string' && SPLASH_ACTIONS.includes(value)
|
|
40
|
+
}
|
|
41
|
+
|
|
27
42
|
/** Normalize a document title for the rail: drop the product suffix, clamp length.
|
|
28
43
|
* A bare product title carries no page information, so it is treated as empty. */
|
|
29
44
|
export function cleanPageTitle(raw) {
|
|
@@ -37,3 +52,44 @@ export function cleanPageTitle(raw) {
|
|
|
37
52
|
export function normalizeTheme(value) {
|
|
38
53
|
return value === 'light' ? 'light' : 'dark'
|
|
39
54
|
}
|
|
55
|
+
|
|
56
|
+
// Boot stages drive both the splash copy and the real boot order. Progress is
|
|
57
|
+
// monotonic; the splash never invents a percentage the backend has not reached.
|
|
58
|
+
export const BOOT_STAGES = Object.freeze([
|
|
59
|
+
Object.freeze({ id: 'prepare', title: '准备运行环境', detail: '校验安装载荷与用户数据目录', progress: 10 }),
|
|
60
|
+
Object.freeze({ id: 'data', title: '初始化工作区', detail: '创建数据目录并检查数据库结构', progress: 28 }),
|
|
61
|
+
Object.freeze({ id: 'service', title: '启动本机服务', detail: '启动 Nitro、API 与插件宿主', progress: 52 }),
|
|
62
|
+
Object.freeze({ id: 'workshop', title: '装配智能体工作台', detail: '恢复 Channel、Session 与任务状态', progress: 78 }),
|
|
63
|
+
Object.freeze({ id: 'ready', title: '工作台已就绪', detail: '正在进入主界面', progress: 100 }),
|
|
64
|
+
])
|
|
65
|
+
|
|
66
|
+
export function bootStage(id) {
|
|
67
|
+
return BOOT_STAGES.find(stage => stage.id === id) ?? BOOT_STAGES[0]
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Ids of the four steps rendered as a checklist (ready is the completed rail). */
|
|
71
|
+
export const SPLASH_STEPS = Object.freeze(BOOT_STAGES.filter(stage => stage.id !== 'ready').map(stage => stage.id))
|
|
72
|
+
|
|
73
|
+
// Tray settings. Defaults are the safe, least-surprising behavior for a
|
|
74
|
+
// desktop app that owns a local backend: closing hides instead of killing the
|
|
75
|
+
// running workshop, and updates keep checking in the background.
|
|
76
|
+
export const DEFAULT_SETTINGS = Object.freeze({
|
|
77
|
+
closeToTray: true,
|
|
78
|
+
launchAtLogin: false,
|
|
79
|
+
startHidden: false,
|
|
80
|
+
trayNotifications: true,
|
|
81
|
+
autoCheckUpdates: true,
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
export const SETTINGS_KEYS = Object.freeze(Object.keys(DEFAULT_SETTINGS))
|
|
85
|
+
|
|
86
|
+
/** Coerce persisted JSON into the exact boolean settings surface. Unknown keys
|
|
87
|
+
* are dropped so a hand-edited settings file cannot add privileged behavior. */
|
|
88
|
+
export function normalizeSettings(raw) {
|
|
89
|
+
const source = raw && typeof raw === 'object' && !Array.isArray(raw) ? raw : {}
|
|
90
|
+
const settings = {}
|
|
91
|
+
for (const key of SETTINGS_KEYS) {
|
|
92
|
+
settings[key] = typeof source[key] === 'boolean' ? source[key] : DEFAULT_SETTINGS[key]
|
|
93
|
+
}
|
|
94
|
+
return settings
|
|
95
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Sandboxed preload for the boot splash. It exposes only the fixed splash
|
|
2
|
+
// surface; the renderer never receives ipcRenderer itself.
|
|
3
|
+
const { contextBridge, ipcRenderer } = require('electron')
|
|
4
|
+
|
|
5
|
+
// Keep in sync with contract.mjs (sandboxed preloads cannot import local ESM).
|
|
6
|
+
const CHANNELS = {
|
|
7
|
+
action: 'aw-splash:action',
|
|
8
|
+
hello: 'aw-splash:hello',
|
|
9
|
+
state: 'aw-splash:state',
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function subscribe(channel, callback) {
|
|
13
|
+
const handler = (_event, payload) => {
|
|
14
|
+
try {
|
|
15
|
+
callback(payload)
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
// A splash listener must never take down the boot window.
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
ipcRenderer.on(channel, handler)
|
|
22
|
+
return () => ipcRenderer.removeListener(channel, handler)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
contextBridge.exposeInMainWorld('awSplash', {
|
|
26
|
+
action: name => ipcRenderer.send(CHANNELS.action, name),
|
|
27
|
+
hello: () => ipcRenderer.send(CHANNELS.hello),
|
|
28
|
+
onState: callback => subscribe(CHANNELS.state, callback),
|
|
29
|
+
})
|
|
@@ -10,6 +10,7 @@ const CHANNELS = {
|
|
|
10
10
|
status: 'aw-chrome:status',
|
|
11
11
|
theme: 'aw-chrome:theme',
|
|
12
12
|
title: 'aw-chrome:title',
|
|
13
|
+
prefs: 'aw-chrome:prefs',
|
|
13
14
|
update: 'aw-chrome:update',
|
|
14
15
|
updateState: 'aw-chrome:update-state',
|
|
15
16
|
}
|
|
@@ -36,5 +37,6 @@ contextBridge.exposeInMainWorld('awChrome', {
|
|
|
36
37
|
onStatus: callback => subscribe(CHANNELS.status, callback),
|
|
37
38
|
onTheme: callback => subscribe(CHANNELS.theme, callback),
|
|
38
39
|
onTitle: callback => subscribe(CHANNELS.title, callback),
|
|
40
|
+
onPrefs: callback => subscribe(CHANNELS.prefs, callback),
|
|
39
41
|
onUpdate: callback => subscribe(CHANNELS.updateState, callback),
|
|
40
42
|
})
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Settings persistence for the desktop shell. Kept Electron-free so the
|
|
2
|
+
// read/normalize/write contract can be tested with plain Node.
|
|
3
|
+
import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs'
|
|
4
|
+
import { dirname } from 'node:path'
|
|
5
|
+
import { DEFAULT_SETTINGS, normalizeSettings } from './contract.mjs'
|
|
6
|
+
|
|
7
|
+
export function loadSettings(file) {
|
|
8
|
+
try {
|
|
9
|
+
return normalizeSettings(JSON.parse(readFileSync(file, 'utf8')))
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
// A missing or corrupt settings file must never block startup.
|
|
13
|
+
return { ...DEFAULT_SETTINGS }
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function saveSettings(file, settings) {
|
|
18
|
+
const normalized = normalizeSettings(settings)
|
|
19
|
+
mkdirSync(dirname(file), { recursive: true })
|
|
20
|
+
const temporary = `${file}.tmp`
|
|
21
|
+
writeFileSync(temporary, `${JSON.stringify(normalized, null, 2)}\n`, 'utf8')
|
|
22
|
+
renameSync(temporary, file)
|
|
23
|
+
return normalized
|
|
24
|
+
}
|