bs-engineering-suite 2.9.0-rc.18 → 2.9.0-rc.20

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/NOTICE.md CHANGED
@@ -9,7 +9,7 @@ This repository consolidates five previously developed modules into one DeepSeek
9
9
 
10
10
  The original module licenses and third-party notices remain under `packages/`. The suite does not replace or shadow the DeepSeek Harness SDK or bundle a second DSH runtime. DSH, its SDK, Cordis and React remain host-provided shared instances. The Windows x64 `0.1.0-alpha.3-m2.6` archive includes the matching Windows native components; the retained macOS arm64 `0.1.0-alpha.3-m2.5` release includes its macOS OAG native module. These are platform-specific archives, not interchangeable binaries. The Office preview module retains its private Workbench capability and respects the official preview defaults.
11
11
 
12
- The `2.9.0-rc.18` candidate archive includes isolated, modified copies of three MIT-licensed DSH UI packages: `@deepseek-ai/dsh-client-ui-sidebar`, `@deepseek-ai/dsh-client-ui-chat` and `@deepseek-ai/dsh-client-ui-plugin-manager`. For each supported platform it carries the exact published npm `0.2.2-rc.4` payload and the matching Desktop `0.2.2-rc.3` payload. The macOS arm64 layer also includes the exact Desktop `0.2.2-rc.5` payload. They live under `ui-compat/vendor/<variant>/@deepseek-ai/` in the installed suite, outside the host SDK resolution paths. Each copy retains its original copyright notice, `LICENSE`, locales and required assets; the inventory, platform, variant and original/file digests are recorded in `ui-compat/receipt.json` format `bs-ui-bundle/v4`, with per-variant versions under `hostVersions`. These limited UI copies add the BS navigation and running-status slots and persist/filter the native version list; they do not include a DSH or Node installer and do not modify the host installation directory, system PATH or the user's global Node. Activation requires the exact platform, variant host version and every original SHA-256 in one variant to match; npm/Desktop mixed bytes, rc.1/rc.2 bytes or unknown builds retain their native UI and report a stable `BS_UI_FALLBACK` reason. The legacy rc.1 Windows profile overlay remains historical and is not activated by the rc.4 package policy.
12
+ The `2.9.0-rc.20` candidate archive includes isolated, modified copies of three MIT-licensed DSH UI packages: `@deepseek-ai/dsh-client-ui-sidebar`, `@deepseek-ai/dsh-client-ui-chat` and `@deepseek-ai/dsh-client-ui-plugin-manager`. For each supported platform it carries the exact published npm `0.2.2-rc.4` payload and the matching Desktop `0.2.2-rc.3` payload. The macOS arm64 layer also includes the exact Desktop `0.2.2-rc.5` payload. They live under `ui-compat/vendor/<variant>/@deepseek-ai/` in the installed suite, outside the host SDK resolution paths. Each copy retains its original copyright notice, `LICENSE`, locales and required assets; the inventory, platform, variant and original/file digests are recorded in `ui-compat/receipt.json` format `bs-ui-bundle/v4`, with per-variant versions under `hostVersions`. These limited UI copies add the BS navigation and running-status slots and persist/filter the native version list; they do not include a DSH or Node installer and do not modify the host installation directory, system PATH or the user's global Node. Activation requires the exact platform, variant host version and every original SHA-256 in one variant to match; npm/Desktop mixed bytes, rc.1/rc.2 bytes or unknown builds retain their native UI and report a stable `BS_UI_FALLBACK` reason. The legacy rc.1 Windows profile overlay remains historical and is not activated by the rc.4 package policy.
13
13
 
14
14
  The bundled UI compatibility logic uses a read-only runtime policy and a subclass of the host's native Group. It reads the current composed native UI settings, including profile/home layer precedence, without writing a separate profile patch. It disables the matched native UI rows only when the exact versions, SHA-256 digests and settings are compatible, and lets the Group own the replacement children's load/unload lifecycle. Unknown hosts, user-disabled native UI, unsupported custom groups or configuration conflicts retain the original UI with stable `BS_UI_FALLBACK` diagnostics. Disabling or removing the suite restores native UI according to the host's restart prompts. Installation does not depend on `postinstall`; the official host CLI can install the archive with `--ignore-scripts`.
15
15
 
@@ -12,4 +12,4 @@
12
12
 
13
13
  已安装版本可通过卡片的「更新」按钮安装兼容新版。工程和历史任务的固定引用按各自版本保留。安装和更新资料包不调用模型。内容库由同一 DSH Home 下的 Profile 共用,在线任务进度按 Profile 保存。
14
14
 
15
- 原 COS 接入和备用来源的维护细节见 [历史接入记录](https://github.com/jdbsh-AI/bs-engineering-suite/blob/bs-v2.9.0-rc.18/docs/content-packs/COS_SOURCE.md)。
15
+ 原 COS 接入和备用来源的维护细节见 [历史接入记录](https://github.com/jdbsh-AI/bs-engineering-suite/blob/bs-v2.9.0-rc.20/docs/content-packs/COS_SOURCE.md)。
@@ -1,12 +1,12 @@
1
1
  # Windows x64 安装 BS 工程资料系统
2
2
 
3
- 当前指南对应 BS `2.9.0-rc.18` 通用安装包。DSH Web/CLI 目标为 `0.2.2-rc.4`;官方 Desktop feed 尚未发布 rc.4,Desktop UI 继续使用 `0.2.2-rc.3` 精确字节。DSH 实际运行的 Node 须为 `24.9.0` 或更高版本,并具备内置 SQLite 和 FTS5。Windows 原生 `.node`、rc.4 Desktop 和实机界面的 rc.14 验收为 `NOT_RUN`。
3
+ 当前指南对应 BS `2.9.0-rc.20` 通用安装包。DSH Web/CLI 目标为 `0.2.2-rc.4`;官方 Desktop feed 尚未发布 rc.4,Desktop UI 继续使用 `0.2.2-rc.3` 精确字节。DSH 实际运行的 Node 须为 `24.9.0` 或更高版本,并具备内置 SQLite 和 FTS5。Windows 原生 `.node`、rc.4 Desktop 和实机界面的 rc.14 验收为 `NOT_RUN`。
4
4
 
5
5
  ## 在 DSH 插件页安装
6
6
 
7
- 1. 在 DSH rc.4 的「插件」页输入 `bs-engineering-suite@next` 安装,或指定 `bs-engineering-suite@2.9.0-rc.18`。默认 `latest` 为 rc.12,当前 rc.3 Desktop 会拒绝安装 rc.18。pnpm 12 的默认发布时间限制可能使 `@next` 暂时解析为旧版,刚发布时建议指定完整版本。
8
- 2. 使用文件安装时,从 [已发布的 rc.18 Release](https://github.com/jdbsh-AI/bs-engineering-suite/releases/tag/bs-v2.9.0-rc.18) 下载 `bs-engineering-suite-2.9.0-rc.18.tgz`。已发布通用包覆盖 Windows x64 与 macOS arm64。GitHub 下载需要仓库读取权限。使用本地候选时,先在随附回执确认其为 Windows x64 安装包或通用安装包。
9
- 3. 将安装文件的本地绝对路径填入安装源,无需解压。例如 `D:\下载\BS 安装包\bs-engineering-suite-2.9.0-rc.18.tgz`。Release 的源码 ZIP/TAR 供维护者构建使用。
7
+ 1. 在 DSH rc.4 的「插件」页输入 `bs-engineering-suite@next` 安装,或指定 `bs-engineering-suite@2.9.0-rc.20`。默认 `latest` 为 rc.12,当前 rc.3 Desktop 会拒绝安装 rc.20。pnpm 12 的默认发布时间限制可能使 `@next` 暂时解析为旧版,刚发布时建议指定完整版本。
8
+ 2. 使用文件安装时,从 [已发布的 rc.20 Release](https://github.com/jdbsh-AI/bs-engineering-suite/releases/tag/bs-v2.9.0-rc.20) 下载 `bs-engineering-suite-2.9.0-rc.20.tgz`。已发布通用包覆盖 Windows x64 与 macOS arm64。GitHub 下载需要仓库读取权限。使用本地候选时,先在随附回执确认其为 Windows x64 安装包或通用安装包。
9
+ 3. 将安装文件的本地绝对路径填入安装源,无需解压。例如 `D:\下载\BS 安装包\bs-engineering-suite-2.9.0-rc.20.tgz`。Release 的源码 ZIP/TAR 供维护者构建使用。
10
10
  4. 按宿主提示重启。在「插件 → BS工程资料系统」核对版本和模块状态。
11
11
  5. 在插件详情安装所需的 [模板包](content-packs/TEMPLATE_PACKAGE_GUIDE.md) 和 [RAG 资料包](rag-packs/library.md)。再按 [Windows 使用说明](windows-usage.md)在本机建立或打开工程。
12
12
 
@@ -19,7 +19,7 @@
19
19
  已配置 DSH CLI 的维护者也可运行以下命令。其中 `desktop` 替换为实际的 Profile 名称。
20
20
 
21
21
  ```powershell
22
- dsh plugin --profile desktop add 'D:\下载\BS 安装包\bs-engineering-suite-2.9.0-rc.18.tgz' --ignore-scripts
22
+ dsh plugin --profile desktop add 'D:\下载\BS 安装包\bs-engineering-suite-2.9.0-rc.20.tgz' --ignore-scripts
23
23
  ```
24
24
 
25
25
  停用或卸载通过 DSH 的「插件」页操作。工程资料、既有绑定和成果应按各自的本机存储位置保留。
@@ -1,6 +1,6 @@
1
1
  # Windows 使用:从本地工程到候选成果
2
2
 
3
- 本指南对应 BS `2.9.0-rc.18`。DSH Web/CLI 目标为 `0.2.2-rc.4`;官方 Desktop feed 尚未发布 rc.4,因此 Desktop UI 兼容基线仍为 `0.2.2-rc.3`。[安装说明](windows-install.md)包含当前通用包的取得方式、宿主要求和历史 Windows 实机记录。
3
+ 本指南对应 BS `2.9.0-rc.20`。DSH Web/CLI 目标为 `0.2.2-rc.4`;官方 Desktop feed 尚未发布 rc.4,因此 Desktop UI 兼容基线仍为 `0.2.2-rc.3`。[安装说明](windows-install.md)包含当前通用包的取得方式、宿主要求和历史 Windows 实机记录。
4
4
 
5
5
  ## 安装包并进入工程
6
6
 
@@ -27,4 +27,4 @@
27
27
 
28
28
  ## 验证范围
29
29
 
30
- 当前 rc.13 的 Windows 原生 `.node`、rc.4 Desktop 和实机界面为 `NOT_RUN`。此前 Windows 11 的目录、检索、分页和预览检查见 [历史资料阅览台实机记录](https://github.com/jdbsh-AI/bs-engineering-suite/blob/bs-v2.9.0-rc.18/docs/windows-document-library-check-20261112.md)。宿主和安装版本见 [安装说明的历史记录](windows-install.md#历史-windows-实机记录)。
30
+ 当前 rc.13 的 Windows 原生 `.node`、rc.4 Desktop 和实机界面为 `NOT_RUN`。此前 Windows 11 的目录、检索、分页和预览检查见 [历史资料阅览台实机记录](https://github.com/jdbsh-AI/bs-engineering-suite/blob/bs-v2.9.0-rc.20/docs/windows-document-library-check-20261112.md)。宿主和安装版本见 [安装说明的历史记录](windows-install.md#历史-windows-实机记录)。
@@ -1046,7 +1046,7 @@ function environment() {
1046
1046
  browser: ua.includes("Edg/") ? "Edge" : ua.includes("Chrome/") ? "Chrome" : ua.includes("Firefox/") ? "Firefox" : ua.includes("Safari/") ? "Safari" : "Other",
1047
1047
  browserMajor: Number(match?.[1] ?? 0),
1048
1048
  ...surfaceState(),
1049
- bsClientVersion: "2.9.0-rc.18",
1049
+ bsClientVersion: "2.9.0-rc.20",
1050
1050
  viewportWidth: innerWidth,
1051
1051
  viewportHeight: innerHeight,
1052
1052
  dpr: devicePixelRatio,
@@ -1135,8 +1135,8 @@ function createRecorder() {
1135
1135
  }, fallback() {
1136
1136
  const files = makeBundle(
1137
1137
  history.filter((row) => Date.parse(row.timestamp) >= Date.now() - 72 * 36e5).map((row) => ({ ...row, ...projectEvent(row, alias) })),
1138
- { browser: environment(), bsVersion: "2.9.0-rc.18" },
1139
- { version: "2.9.0-rc.18", createdAt: (/* @__PURE__ */ new Date()).toISOString(), retentionHours: 72, complete: false, coverage: { host: false, client: true, persistentStorage: false }, losses: { hostUnavailable: true, browserMemoryOnly: true, browserHistoryDropped: historyLost, browserQueueDropped: queueLost } }
1138
+ { browser: environment(), bsVersion: "2.9.0-rc.20" },
1139
+ { version: "2.9.0-rc.20", createdAt: (/* @__PURE__ */ new Date()).toISOString(), retentionHours: 72, complete: false, coverage: { host: false, client: true, persistentStorage: false }, losses: { hostUnavailable: true, browserMemoryOnly: true, browserHistoryDropped: historyLost, browserQueueDropped: queueLost } }
1140
1140
  );
1141
1141
  return new Blob([zipSync(Object.fromEntries(Object.entries(files).map(([name, text]) => [name, strToU8(text)])))], { type: "application/zip" });
1142
1142
  } };
@@ -1167,7 +1167,7 @@ function DownloadDiagnostics({ recorder }) {
1167
1167
  controller.signal.throwIfAborted();
1168
1168
  const url = URL.createObjectURL(blob), link = document.createElement("a");
1169
1169
  link.href = url;
1170
- link.download = `bs-diagnostics-${"2.9.0-rc.18"}-${(/* @__PURE__ */ new Date()).toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z")}.zip`;
1170
+ link.download = `bs-diagnostics-${"2.9.0-rc.20"}-${(/* @__PURE__ */ new Date()).toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z")}.zip`;
1171
1171
  document.body.appendChild(link);
1172
1172
  link.click();
1173
1173
  link.remove();
@@ -84,7 +84,7 @@ export default class BuildseekDiagnostics extends Service {
84
84
  for(const message of ctx.logger.buffer??[])capture(message)
85
85
  ctx.logger.exporter({export:capture})
86
86
  ctx.inject(['webServer','connection','pluginManager'],web=>web.effect(()=>registerUpdateRoutes({
87
- registrar:web.get('webServer'),fence:web.get('connection'),manager:web.get('pluginManager'),hmr:!!web.get('hmr'),
87
+ registrar:web.get('webServer'),fence:web.get('connection'),manager:web.get('pluginManager'),profileDir:profile.dir,
88
88
  prepareRollback:source=>archiveRollback(source,profile.dir),
89
89
  environment:()=>({version:JSON.parse(readFileSync(createRequire(join(profile.dir,'package.json')).resolve('bs-engineering-suite/package.json'),'utf8')).version,hostVersion,platform:process.platform,arch:process.arch}),record:event=>this.record(event),
90
90
  })))
@@ -1,12 +1,53 @@
1
1
  import semver from 'semver'
2
2
  import {readFile,stat,writeFile,unlink} from 'node:fs/promises'
3
3
  import {join,isAbsolute} from 'node:path'
4
+ import {readFileSync,writeFileSync,renameSync,unlinkSync,statSync} from 'node:fs'
4
5
  import {randomUUID} from 'node:crypto'
5
6
  import {ensurePrivateDirectory} from '@buildseek/platform'
6
7
 
7
8
  const NAME='bs-engineering-suite'
8
9
  const REGISTRY='https://registry.npmjs.org/'
9
10
  const PREFIX='/bs/updates/v1/'
11
+ const RECEIPT_LIMIT=32
12
+ const RECEIPT_RETENTION_MS=24*60*60*1000
13
+ const processKey=Symbol.for('buildseek.plugin-update-process')
14
+ const processIdentity=globalThis[processKey]??=randomUUID()
15
+ const inProgress=entry=>entry?.state==='pending'&&entry.process===processIdentity
16
+ const updateId=id=>typeof id==='string'&&/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/u.test(id)
17
+ const errorCode=error=>/^BS_UPDATE_[A-Z_]+$/.test(error?.message)?error.message:'BS_UPDATE_FAILED'
18
+
19
+ // The originating diagnostics fiber is unloaded during hot replacement.
20
+ // Retain recent results independently from the single native mutation in flight.
21
+ function updateReceipts(profileDir){
22
+ const path=join(profileDir,'bs-update-outcome.json')
23
+ const retained=(entry,now)=>inProgress(entry)||entry.recordedAt>now-RECEIPT_RETENTION_MS
24
+ const read=()=>{
25
+ try{
26
+ const value=JSON.parse(readFileSync(path,'utf8'))
27
+ const entries=Array.isArray(value)?value:[{...value,recordedAt:statSync(path).mtimeMs}]
28
+ const now=Date.now()
29
+ return entries.filter(entry=>updateId(entry?.id)&&retained(entry,now))
30
+ }catch(error){
31
+ if(error.code!=='ENOENT')throw error
32
+ return []
33
+ }
34
+ }
35
+ const write=value=>{
36
+ const entries=read().filter(entry=>entry.id!==value.id)
37
+ const next=[...entries,{...value,recordedAt:Date.now()}].slice(-RECEIPT_LIMIT)
38
+ const temporary=path+'.'+randomUUID()
39
+ try{
40
+ writeFileSync(temporary,JSON.stringify(next),{flag:'wx',mode:0o600})
41
+ renameSync(temporary,path)
42
+ }finally{
43
+ try{unlinkSync(temporary)}catch(error){if(error.code!=='ENOENT')throw error}
44
+ }
45
+ }
46
+ return {read,write}
47
+ }
48
+
49
+ const applied=result=>['applied','restart-required'].includes(result?.application)
50
+ const alreadyInstalled=result=>result?.application==='failed'&&result.changed===false&&result.error?.code==='already-installed'
10
51
  const object=v=>v!==null&&typeof v==='object'&&!Array.isArray(v)
11
52
  const baseVersion=v=>v.replace(/-(?:macos|darwin|win32|windows)-(?:arm64|x64)$/,'')
12
53
  export function platformVersion(version,platform,arch){
@@ -41,10 +82,11 @@ export async function archiveRollback(source,profileDir){
41
82
  const backup=join(dir,randomUUID()+'.tgz');await writeFile(backup,bytes,{flag:'wx',mode:0o600})
42
83
  return {spec:backup,cleanup:()=>unlink(backup)}
43
84
  }
44
- export function registerUpdateRoutes({registrar,fence,manager,environment,hmr=false,prepareRollback,fetcher=fetch,record=()=>{}}){
85
+ export function registerUpdateRoutes({registrar,fence,manager,environment,profileDir,prepareRollback,fetcher=fetch,record=()=>{}}){
45
86
  let cache,pending,busy=false
46
87
  const lifetime=new AbortController()
47
- const status=()=>({...environment(),busy,checkedAt:cache?.at??null,versions:cache?.versions??[]})
88
+ const receipts=updateReceipts(profileDir)
89
+ const status=()=>({...environment(),busy:busy||receipts.read().some(inProgress),checkedAt:cache?.at??null,versions:cache?.versions??[]})
48
90
  const check=()=>pending??=(async()=>{
49
91
  const env=environment(),document=await metadata(fetcher,AbortSignal.any([lifetime.signal,AbortSignal.timeout(20000)]))
50
92
  if(env.version!==environment().version)throw Error('BS_UPDATE_CHANGED')
@@ -52,18 +94,33 @@ export function registerUpdateRoutes({registrar,fence,manager,environment,hmr=fa
52
94
  return status()
53
95
  })().finally(()=>{pending=undefined})
54
96
  const reply=(res,code,value)=>{res.statusCode=code;res.setHeader('Content-Type','application/json; charset=utf-8');res.setHeader('Cache-Control','no-store');res.end(JSON.stringify(value))}
55
- const offs=['status','check','install'].map(action=>registrar.register({kind:'exact',path:PREFIX+action,handler:async(req,res)=>{
97
+ const offs=['status','check','receipt','install'].map(action=>registrar.register({kind:'exact',path:PREFIX+action,handler:async(req,res)=>{
56
98
  try{
57
99
  const denied=fence.requestRejection({headers:req.headers});if(denied!==undefined)return reply(res,denied,{error:'BS_UPDATE_UNAUTHENTICATED'})
58
100
  if(req.method!=='POST')return reply(res,405,{error:'BS_UPDATE_METHOD_INVALID'})
59
101
  if(String(req.headers['content-type']??'').split(';')[0].trim()!=='application/json')return reply(res,415,{error:'BS_UPDATE_REQUEST_INVALID'})
60
102
  let size=0,parts=[];for await(const chunk of req){size+=chunk.length;if(size>2048)throw Error('BS_UPDATE_REQUEST_INVALID');parts.push(chunk)}
61
103
  const input=JSON.parse(Buffer.concat(parts).toString('utf8')||'{}')
62
- if(!object(input)||Object.keys(input).some(k=>!(action==='install'?['version','from']:[]).includes(k)))throw Error('BS_UPDATE_REQUEST_INVALID')
104
+ if(!object(input)||Object.keys(input).some(k=>!(action==='install'?['id','version','from']:action==='receipt'?['id']:[]).includes(k)))throw Error('BS_UPDATE_REQUEST_INVALID')
63
105
  if(action==='status')return reply(res,200,{ok:true,value:status()})
64
106
  if(action==='check')return reply(res,200,{ok:true,value:await check()})
65
- if(busy)return reply(res,409,{error:'BS_UPDATE_BUSY'})
107
+ const recent=receipts.read()
108
+ if(action==='receipt'){
109
+ if(!updateId(input.id))throw Error('BS_UPDATE_REQUEST_INVALID')
110
+ const entry=recent.find(item=>item.id===input.id)
111
+ if(!entry)return reply(res,200,{ok:true,value:null})
112
+ const state=entry.state==='pending'&&!inProgress(entry)?'interrupted':entry.state
113
+ return reply(res,200,{ok:true,value:{id:entry.id,from:entry.from,version:entry.version,state,
114
+ ...(state==='success'?{application:entry.application}:state==='failure'?{error:entry.error}:{})}})
115
+ }
116
+ if(input.id!==undefined&&!updateId(input.id))throw Error('BS_UPDATE_REQUEST_INVALID')
117
+ if(busy||recent.some(inProgress))return reply(res,409,{error:'BS_UPDATE_BUSY'})
118
+ if(input.id!==undefined&&recent.some(entry=>entry.id===input.id))throw Error('BS_UPDATE_CHANGED')
66
119
  if(typeof input.version!=='string'||typeof input.from!=='string'||input.from!==environment().version||cache?.from!==input.from||Date.now()-cache.at>300000||!cache.versions.some(v=>v.version===input.version))throw Error('BS_UPDATE_CHANGED')
120
+ // Persist before the first native mutation. Calls from older clients also
121
+ // reserve this operation, so reloading the route cannot admit a second install.
122
+ const operation={id:input.id??randomUUID(),from:input.from,version:input.version,process:processIdentity}
123
+ receipts.write({...operation,state:'pending'})
67
124
  busy=true
68
125
  try{
69
126
  const liveBundle=(await manager.listBundles()).find(p=>p.name===NAME)
@@ -74,45 +131,59 @@ export function registerUpdateRoutes({registrar,fence,manager,environment,hmr=fa
74
131
  let result
75
132
  if(bundle.update==='registry'){
76
133
  const update=await manager.updateBundle(NAME,input.version,{registry:REGISTRY});result=update.result
77
- if(update.restore&&!['applied','restart-required'].includes(update.restore.application))throw Error('BS_UPDATE_RESTORE_FAILED')
78
- }else if(!hmr)result=await install()
79
- else{
80
- if(!prepareRollback)throw Error('BS_UPDATE_LOCAL_SOURCE')
81
- const rollback=await prepareRollback(bundle.source)
82
- // The public manager lives outside this suite. Its operations, and this already accepted handler,
83
- // remain alive after removing our own rows. No private HMR lock or global console is modified.
84
- const applied=result=>['applied','restart-required'].includes(result?.application)
85
- try {
86
- if(!applied(await manager.removeBundle(NAME)))throw Error('BS_UPDATE_INSTALL_FAILED')
87
- result=await install()
88
- if(!applied(result))throw Error('BS_UPDATE_INSTALL_FAILED')
89
- await rollback.cleanup().catch(()=>{})
90
- } catch {
134
+ if(update.restore&&!applied(update.restore))throw Error('BS_UPDATE_RESTORE_FAILED')
135
+ }else{
136
+ result=await install()
137
+ // The manager owns the live-replacement guard. A clean refusal is the
138
+ // only reason to remove the old archive installation and retry.
139
+ if(alreadyInstalled(result)){
140
+ record({module:'ui',phase:'plugin-update',outcome:'info',code:'BS_UPDATE_MANAGER_ALREADY_INSTALLED'})
141
+ if(!prepareRollback)throw Error('BS_UPDATE_LOCAL_SOURCE')
142
+ const rollback=await prepareRollback(bundle.source)
143
+ const installed=async()=>(await manager.listBundles()).find(p=>p.name===NAME&&p.installed)
144
+ const unchanged=await installed()
145
+ if(unchanged?.version!==bundle.version||unchanged.source!==bundle.source||
146
+ unchanged.enabled!==bundle.enabled||unchanged.readOnlyReason){
147
+ await rollback.cleanup().catch(()=>{})
148
+ throw Error('BS_UPDATE_CHANGED')
149
+ }
150
+ // The public manager and this accepted request survive removal of the suite's rows.
91
151
  try {
92
- const installed=async()=>(await manager.listBundles()).find(p=>p.name===NAME&&p.installed)
93
- const remaining=await installed()
94
- if(remaining?.version===bundle.version&&remaining.source===bundle.source){
95
- if(remaining.enabled!==bundle.enabled&&!applied(await manager.setBundleEnabled(NAME,bundle.enabled)))throw Error('BS_UPDATE_RESTORE_FAILED')
96
- const restored=await installed()
97
- if(restored?.version!==bundle.version||restored.enabled!==bundle.enabled)throw Error('BS_UPDATE_RESTORE_FAILED')
98
- await rollback.cleanup().catch(()=>{})
99
- }else{
100
- if(remaining&&!applied(await manager.removeBundle(NAME)))throw Error('BS_UPDATE_RESTORE_FAILED')
101
- if(!applied(await manager.installBundle(rollback.spec,{enabled:bundle.enabled,expected:{name:NAME,version:input.from}})))throw Error('BS_UPDATE_RESTORE_FAILED')
102
- const restored=await installed()
103
- if(restored?.version!==bundle.version||restored.enabled!==bundle.enabled)throw Error('BS_UPDATE_RESTORE_FAILED')
104
- // The restored local dependency references the persistent copy.
105
- }
106
- } catch {throw Error('BS_UPDATE_RESTORE_FAILED')}
107
- throw Error('BS_UPDATE_INSTALL_FAILED')
152
+ if(!applied(await manager.removeBundle(NAME)))throw Error('BS_UPDATE_INSTALL_FAILED')
153
+ result=await install()
154
+ if(!applied(result))throw Error('BS_UPDATE_INSTALL_FAILED')
155
+ await rollback.cleanup().catch(()=>{})
156
+ } catch {
157
+ try {
158
+ const remaining=await installed()
159
+ if(remaining?.version===bundle.version&&remaining.source===bundle.source){
160
+ if(remaining.enabled!==bundle.enabled&&!applied(await manager.setBundleEnabled(NAME,bundle.enabled)))throw Error('BS_UPDATE_RESTORE_FAILED')
161
+ const restored=await installed()
162
+ if(restored?.version!==bundle.version||restored.enabled!==bundle.enabled)throw Error('BS_UPDATE_RESTORE_FAILED')
163
+ await rollback.cleanup().catch(()=>{})
164
+ }else{
165
+ if(remaining&&!applied(await manager.removeBundle(NAME)))throw Error('BS_UPDATE_RESTORE_FAILED')
166
+ if(!applied(await manager.installBundle(rollback.spec,{enabled:bundle.enabled,expected:{name:NAME,version:input.from}})))throw Error('BS_UPDATE_RESTORE_FAILED')
167
+ const restored=await installed()
168
+ if(restored?.version!==bundle.version||restored.enabled!==bundle.enabled)throw Error('BS_UPDATE_RESTORE_FAILED')
169
+ // The restored local dependency references the persistent copy.
170
+ }
171
+ } catch {throw Error('BS_UPDATE_RESTORE_FAILED')}
172
+ throw Error('BS_UPDATE_INSTALL_FAILED')
173
+ }
108
174
  }
109
175
  }
110
- if(!result||!['applied','restart-required'].includes(result.application))throw Error('BS_UPDATE_INSTALL_FAILED')
176
+ if(!applied(result))throw Error('BS_UPDATE_INSTALL_FAILED')
111
177
  cache=undefined
178
+ const value={version:input.version,application:result.application,restartRequired:result.application==='restart-required',restartReason:result.restartReason??null}
179
+ receipts.write({...operation,state:'success',application:result.application})
112
180
  record({module:'ui',phase:'plugin-update',outcome:'success'})
113
- return reply(res,200,{ok:true,value:{version:input.version,application:result.application,restartRequired:result.application==='restart-required',restartReason:result.restartReason??null}})
181
+ return reply(res,200,{ok:true,value})
182
+ }catch(error){
183
+ receipts.write({...operation,state:'failure',error:errorCode(error)})
184
+ throw error
114
185
  }finally{busy=false}
115
- }catch(error){record({module:'ui',phase:'plugin-update',outcome:'failure',error});reply(res,400,{error:/^BS_UPDATE_[A-Z_]+$/.test(error?.message)?error.message:'BS_UPDATE_FAILED'})}
186
+ }catch(error){record({module:'ui',phase:'plugin-update',outcome:'failure',error});reply(res,400,{error:errorCode(error)})}
116
187
  }}))
117
188
  return()=>{lifetime.abort();for(const off of offs)off()}
118
189
  }
@@ -1 +1 @@
1
- export const VERSION="2.9.0-rc.18"
1
+ export const VERSION="2.9.0-rc.20"
@@ -1869,7 +1869,9 @@ var css = `
1869
1869
  .cp-panel details{margin:12px 0}.cp-panel summary{cursor:pointer}.cp-panel pre{white-space:pre-wrap;overflow-wrap:anywhere}.cp-panel code{overflow-wrap:anywhere}
1870
1870
  .cp-panel .cp-removal-dialog{box-sizing:border-box;width:min(520px,calc(100vw - 32px));max-height:calc(100dvh - 48px);overflow:auto;padding:24px;border:1px solid var(--dsw-alias-border-l2,#8886);border-radius:12px;color:var(--dsw-alias-label-primary,inherit);background:var(--dsw-alias-bg-layer-1,Canvas);font:inherit;line-height:1.65;overflow-wrap:anywhere}
1871
1871
  .cp-panel .cp-removal-dialog .cp-primary{color:var(--dsw-alias-label-primary,inherit);background:var(--dsw-alias-button-elevated-fill,Canvas);border-color:var(--dsw-alias-state-business-primary,Highlight)}
1872
- .cp-panel .cp-removal-dialog::backdrop{background:rgb(0 0 0 / .45)}.cp-panel .cp-removal-dialog .cp-actions{justify-content:flex-end;margin:20px 0 0}.cp-panel .cp-danger{border-color:var(--dsw-alias-state-error-primary,#b94444);color:var(--dsw-alias-label-primary,inherit)}.cp-panel .cp-removal-dialog [role=alert]{color:var(--dsw-alias-label-primary,inherit);border:1px solid var(--dsw-alias-state-error-primary,#b94444);border-radius:7px;padding:8px 12px}
1872
+ .cp-panel .cp-removal-dialog::backdrop{background:rgb(0 0 0 / .45);-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px)}
1873
+ @media(prefers-reduced-transparency:reduce){.cp-panel .cp-removal-dialog::backdrop{-webkit-backdrop-filter:none;backdrop-filter:none}}
1874
+ .cp-panel .cp-removal-dialog .cp-actions{justify-content:flex-end;margin:20px 0 0}.cp-panel .cp-danger{border-color:var(--dsw-alias-state-error-primary,#b94444);color:var(--dsw-alias-label-primary,inherit)}.cp-panel .cp-removal-dialog [role=alert]{color:var(--dsw-alias-label-primary,inherit);border:1px solid var(--dsw-alias-state-error-primary,#b94444);border-radius:7px;padding:8px 12px}
1873
1875
  `;
1874
1876
 
1875
1877
  // src/client/content-packs-api.ts
@@ -1712,7 +1712,9 @@ var css = `
1712
1712
  .cp-panel details{margin:12px 0}.cp-panel summary{cursor:pointer}.cp-panel pre{white-space:pre-wrap;overflow-wrap:anywhere}.cp-panel code{overflow-wrap:anywhere}
1713
1713
  .cp-panel .cp-removal-dialog{box-sizing:border-box;width:min(520px,calc(100vw - 32px));max-height:calc(100dvh - 48px);overflow:auto;padding:24px;border:1px solid var(--dsw-alias-border-l2,#8886);border-radius:12px;color:var(--dsw-alias-label-primary,inherit);background:var(--dsw-alias-bg-layer-1,Canvas);font:inherit;line-height:1.65;overflow-wrap:anywhere}
1714
1714
  .cp-panel .cp-removal-dialog .cp-primary{color:var(--dsw-alias-label-primary,inherit);background:var(--dsw-alias-button-elevated-fill,Canvas);border-color:var(--dsw-alias-state-business-primary,Highlight)}
1715
- .cp-panel .cp-removal-dialog::backdrop{background:rgb(0 0 0 / .45)}.cp-panel .cp-removal-dialog .cp-actions{justify-content:flex-end;margin:20px 0 0}.cp-panel .cp-danger{border-color:var(--dsw-alias-state-error-primary,#b94444);color:var(--dsw-alias-label-primary,inherit)}.cp-panel .cp-removal-dialog [role=alert]{color:var(--dsw-alias-label-primary,inherit);border:1px solid var(--dsw-alias-state-error-primary,#b94444);border-radius:7px;padding:8px 12px}
1715
+ .cp-panel .cp-removal-dialog::backdrop{background:rgb(0 0 0 / .45);-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px)}
1716
+ @media(prefers-reduced-transparency:reduce){.cp-panel .cp-removal-dialog::backdrop{-webkit-backdrop-filter:none;backdrop-filter:none}}
1717
+ .cp-panel .cp-removal-dialog .cp-actions{justify-content:flex-end;margin:20px 0 0}.cp-panel .cp-danger{border-color:var(--dsw-alias-state-error-primary,#b94444);color:var(--dsw-alias-label-primary,inherit)}.cp-panel .cp-removal-dialog [role=alert]{color:var(--dsw-alias-label-primary,inherit);border:1px solid var(--dsw-alias-state-error-primary,#b94444);border-radius:7px;padding:8px 12px}
1716
1718
  `;
1717
1719
 
1718
1720
  // src/client/content-packs-api.ts