@walkhi/code-relax 0.1.0-beta.107 → 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.107"}
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.107",
3
+ "version": "0.1.0-beta.109",
4
4
  "private": false,
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -41,6 +41,7 @@ function runStage(entry, stage, args, formatOutput = value => value) {
41
41
  stdio: ['inherit', 'pipe', 'pipe'] });
42
42
  if (output) { process.stdout.write(formatOutput(output)); appendLog(`[${stage}] stdout\n${output.trimEnd()}`); }
43
43
  appendLog(`[${stage}] success`);
44
+ return output;
44
45
  } catch (error) {
45
46
  if (error?.stdout) { process.stdout.write(error.stdout); appendLog(`[${stage}] stdout\n${String(error.stdout).trimEnd()}`); }
46
47
  if (error?.stderr) { process.stderr.write(error.stderr); appendLog(`[${stage}] stderr\n${String(error.stderr).trimEnd()}`); }
@@ -148,29 +149,35 @@ if (invokedDirectly && process.env.npm_config_global === 'true') {
148
149
  const previous = installationSnapshot();
149
150
  appendLog(`[postinstall] start package=${process.env.npm_package_version || 'unknown'} ${systemSummary()}`);
150
151
  let setupStarted = false;
152
+ let stage = 'platform';
151
153
  try {
152
154
  const { prepareNativePackage } = await import('../dist/src/platform/native-package.mjs');
153
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';
154
162
  setupStarted = true;
155
- runStage(entry, 'setup', ['setup', '--json'], output => formatSetupOutput(output));
163
+ runStage(entry, 'setup', ['setup', '--json'], formatSetupOutput);
156
164
  try {
157
165
  runStage(entry, 'doctor', ['doctor']);
158
- console.log('Code Relax 自动安装成功:setup 与安装后健康检查均已通过,无需重复执行 setup。');
159
- console.log('npm 的脚本安全提示与安装结果分别判断;本次安装脚本已实际执行,未修改 npm 安全配置。');
160
166
  }
161
167
  catch (error) {
162
168
  console.error('服务安装已完成,但安装后健康检查未通过;请查看上方诊断与安装日志。');
163
169
  process.exitCode = Number.isInteger(error?.status) && error.status > 0 ? error.status : 1;
164
170
  }
171
+ if (!process.exitCode) console.log('Code Relax 自动安装成功:工作站健康检查与所需组件均已就绪。');
165
172
  console.log(`安装日志:${installLog}`);
166
173
  appendLog(process.exitCode ? '[postinstall] failed stage=doctor' : '[postinstall] success');
167
174
  } catch (error) {
168
175
  const current = installationSnapshot();
169
- if (!setupStarted) console.error(`平台组件检查失败:${error.message}`);
176
+ if (!setupStarted) console.error(`${stage === 'desktop-helper' ? '桌面操作辅助服务安装失败' : '平台组件检查失败'}:${error.message}`);
170
177
  console.error(`\nCode Relax 安装未完全完成:\n${setupFailureGuidance(previous, current)}`);
171
178
  if (error?.code && error.code !== 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER') console.error(`启动安装步骤失败:${error.message}`);
172
179
  console.error(`安装日志:${installLog}`);
173
- appendLog('[postinstall] failed stage=setup');
180
+ appendLog(`[postinstall] failed stage=${stage}`);
174
181
  process.exitCode = Number.isInteger(error?.status) && error.status > 0 ? error.status : 1;
175
182
  } finally {
176
183
  try {