@walkhi/code-relax 0.1.0-beta.108 → 0.1.0-beta.109

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.
@@ -1 +1 @@
1
- {"layout":"npm-platform-packages","version":"0.1.0-beta.108"}
1
+ {"layout":"npm-platform-packages","version":"0.1.0-beta.109"}
@@ -67,7 +67,11 @@ function runtimeDirectories(files) {
67
67
  async function retainDesktopRuntime(executable, installed, stateRoot) {
68
68
  if (!/^[\w.-]+$/.test(installed.package)) throw new Error('Codex Desktop 安装包名称无效。');
69
69
  const source = path.dirname(executable);
70
- const files = runtimeFiles(source);
70
+ // Desktop can run directly from its MSIX package without extracting bin/.
71
+ // Retain the same core siblings as Desktop, not the entire Electron resources.
72
+ const files = path.resolve(executable).toLowerCase() === path.resolve(installed.executable).toLowerCase()
73
+ ? ['codex.exe', 'codex-code-mode-host.exe', 'codex-windows-sandbox-setup.exe', 'codex-command-runner.exe'].sort()
74
+ : runtimeFiles(source);
71
75
  if (files.includes('runtime.json')) throw new Error('Codex 内核目录与保留清单文件名冲突。');
72
76
  const directories = runtimeDirectories(files);
73
77
  const root = path.join(stateRoot, 'desktop-runtimes');
@@ -93,7 +97,7 @@ async function retainDesktopRuntime(executable, installed, stateRoot) {
93
97
  created.push(to);
94
98
  try { fs.linkSync(from, to); }
95
99
  catch (error) {
96
- if (error.code !== 'EXDEV') throw error;
100
+ if (!['EXDEV', 'EPERM'].includes(error.code)) throw error;
97
101
  fs.copyFileSync(from, to);
98
102
  }
99
103
  }
@@ -194,7 +198,11 @@ export async function resolveCodexRuntime(stateRoot, { refresh = false, environm
194
198
  try { installed = await installedDesktopRuntime(); }
195
199
  catch (error) { throw new Error(`无法确认最新 Codex Desktop 内核,未降级到其他 CLI:${error.message}`); }
196
200
  }
197
- for (const candidate of discoverCodex(environment)) {
201
+ const discovered = discoverCodex(environment);
202
+ if (installed && runtimeFilesAvailable(installed.executable)) {
203
+ discovered.push({ executable: installed.executable, source: 'desktop' });
204
+ }
205
+ for (const candidate of discovered) {
198
206
  try {
199
207
  if (candidate.source === 'desktop' && !await matchesInstalledDesktop(candidate.executable, installed)) {
200
208
  continue; // Superseded Desktop extraction directories are not installed candidates.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@walkhi/code-relax",
3
- "version": "0.1.0-beta.108",
3
+ "version": "0.1.0-beta.109",
4
4
  "private": false,
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -149,11 +149,18 @@ if (invokedDirectly && process.env.npm_config_global === 'true') {
149
149
  const previous = installationSnapshot();
150
150
  appendLog(`[postinstall] start package=${process.env.npm_package_version || 'unknown'} ${systemSummary()}`);
151
151
  let setupStarted = false;
152
+ let stage = 'platform';
152
153
  try {
153
154
  const { prepareNativePackage } = await import('../dist/src/platform/native-package.mjs');
154
155
  prepareNativePackage(fileURLToPath(new URL('../', import.meta.url)));
156
+ if (process.platform === 'win32') {
157
+ stage = 'desktop-helper';
158
+ console.log('正在检查并安装桌面操作辅助服务;需要授权时将在工作站弹出 Windows UAC。');
159
+ runStage(entry, stage, ['desktop-helper-install']);
160
+ }
161
+ stage = 'setup';
155
162
  setupStarted = true;
156
- const setupOutput = runStage(entry, 'setup', ['setup', '--json'], formatSetupOutput);
163
+ runStage(entry, 'setup', ['setup', '--json'], formatSetupOutput);
157
164
  try {
158
165
  runStage(entry, 'doctor', ['doctor']);
159
166
  }
@@ -161,29 +168,16 @@ if (invokedDirectly && process.env.npm_config_global === 'true') {
161
168
  console.error('服务安装已完成,但安装后健康检查未通过;请查看上方诊断与安装日志。');
162
169
  process.exitCode = Number.isInteger(error?.status) && error.status > 0 ? error.status : 1;
163
170
  }
164
- let desktopHelperReady = true;
165
- if (!process.exitCode && process.platform === 'win32') {
166
- try {
167
- if (JSON.parse(setupOutput).desktopHelper?.running !== true) {
168
- console.log('正在启用桌面操作辅助服务,请在这台电脑确认 Windows 权限提示。');
169
- runStage(entry, 'desktop-helper-install', ['desktop-helper-install']);
170
- }
171
- } catch {
172
- desktopHelperReady = false;
173
- process.exitCode = 1;
174
- console.error('Code Relax 安装失败:桌面操作辅助服务未就绪。请查看安装日志。');
175
- }
176
- }
177
- if (!process.exitCode && desktopHelperReady) console.log('Code Relax 自动安装成功:工作站健康检查与所需组件均已就绪。');
171
+ if (!process.exitCode) console.log('Code Relax 自动安装成功:工作站健康检查与所需组件均已就绪。');
178
172
  console.log(`安装日志:${installLog}`);
179
- appendLog(!desktopHelperReady ? '[postinstall] failed stage=desktop-helper' : process.exitCode ? '[postinstall] failed stage=doctor' : '[postinstall] success');
173
+ appendLog(process.exitCode ? '[postinstall] failed stage=doctor' : '[postinstall] success');
180
174
  } catch (error) {
181
175
  const current = installationSnapshot();
182
- if (!setupStarted) console.error(`平台组件检查失败:${error.message}`);
176
+ if (!setupStarted) console.error(`${stage === 'desktop-helper' ? '桌面操作辅助服务安装失败' : '平台组件检查失败'}:${error.message}`);
183
177
  console.error(`\nCode Relax 安装未完全完成:\n${setupFailureGuidance(previous, current)}`);
184
178
  if (error?.code && error.code !== 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER') console.error(`启动安装步骤失败:${error.message}`);
185
179
  console.error(`安装日志:${installLog}`);
186
- appendLog('[postinstall] failed stage=setup');
180
+ appendLog(`[postinstall] failed stage=${stage}`);
187
181
  process.exitCode = Number.isInteger(error?.status) && error.status > 0 ? error.status : 1;
188
182
  } finally {
189
183
  try {