@walkhi/code-relax 0.1.0-beta.104 → 0.1.0-beta.106

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.
@@ -274,7 +274,14 @@ async function main() {
274
274
  const desktopNeedsRestart = !hadInstalledService && desktopBeforeSetup.running && !preserveCodex;
275
275
  const previous = hadInstalledService ? await service.status() : { processRunning: false };
276
276
  const legacyRelaySession = readRecord(path.join(stateRoot, 'self-relay-session.json'));
277
- const previousRelay = legacyRelaySession ? await controlRequest(legacyRelaySession) : await selfRelay('relay-status', stateRoot);
277
+ let previousRelay;
278
+ try {
279
+ previousRelay = legacyRelaySession ? await controlRequest(legacyRelaySession) : await selfRelay('relay-status', stateRoot);
280
+ } catch (error) {
281
+ if (error.code !== 'ECONNREFUSED') throw error;
282
+ // A saved session can outlive its listener after an interrupted installation.
283
+ previousRelay = { running: false };
284
+ }
278
285
  const resumeAfterUpdate = previous.processRunning || previousRelay.running;
279
286
  const executable = currentNodeExecutable();
280
287
  const startInstalled = async () => {
@@ -284,7 +291,7 @@ async function main() {
284
291
  child.stderr.on('data', chunk => { errors += chunk; });
285
292
  const code = await new Promise((resolve, reject) => { child.once('error', reject); child.once('exit', resolve); });
286
293
  try {
287
- if (code !== 0) throw new Error(errors.trim().replace(/^(?:Code Relax:)+/u, '') || '桌面服务启动失败');
294
+ if (code !== 0) throw new Error(`启动固定目录的工作站服务失败:${errors.trim().replace(/^(?:Code Relax:)+/u, '') || `退出码 ${code}`}`);
288
295
  if (previousRelay.deviceId) {
289
296
  const restoredRelay = await selfRelay('relay-status', stateRoot);
290
297
  if (restoredRelay.deviceId !== previousRelay.deviceId ||
@@ -1 +1 @@
1
- {"layout":"npm-platform-packages","version":"0.1.0-beta.104"}
1
+ {"layout":"npm-platform-packages","version":"0.1.0-beta.106"}
@@ -59,7 +59,13 @@ if ($Action -eq 'enable') {
59
59
  $exec.Path = $wscript
60
60
  $exec.Arguments = $arguments
61
61
  $exec.WorkingDirectory = $env:USERPROFILE
62
- [void]$root.RegisterTaskDefinition($taskName, $definition, 6, $null, $null, 3, $null) # TASK_CREATE_OR_UPDATE
62
+ try {
63
+ [void]$root.RegisterTaskDefinition($taskName, $definition, 6, $null, $null, 3, $null) # TASK_CREATE_OR_UPDATE
64
+ } catch {
65
+ if ($_.Exception.GetBaseException().HResult -ne -2147024891) { throw }
66
+ @{ enabled=$false; taskPresent=($registered.Count -gt 0); scope='current-user-logon'; mechanism='task-scheduler'; error='Windows Task Scheduler denied registration (0x80070005).' } | ConvertTo-Json -Compress
67
+ return
68
+ }
63
69
  if ($legacyRegistered.Count -gt 0) { $root.DeleteTask($legacyTaskName, 0) }
64
70
  } elseif ($Action -eq 'disable') {
65
71
  if ($registered.Count -gt 0) { $root.DeleteTask($taskName, 0) }
@@ -41,6 +41,7 @@ export async function doctor({ paths, host, service, skillTarget, ensureAutostar
41
41
  });
42
42
  await check('autostart', async () => {
43
43
  const state = await ensureAutostart();
44
+ if (state.error) { add('autostart', 'warning', `登录自启未启用:${state.error}`); return; }
44
45
  add('autostart', 'ok', `当前用户登录自启:${state.repaired ? '已自动恢复' : '已启用'}。`);
45
46
  });
46
47
  await check('service', async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@walkhi/code-relax",
3
- "version": "0.1.0-beta.104",
3
+ "version": "0.1.0-beta.106",
4
4
  "private": false,
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -54,7 +54,8 @@ export function formatSetupOutput(output) {
54
54
  const result = JSON.parse(output);
55
55
  const migration = result.managedAppServerMigration || {};
56
56
  return `Code Relax ${result.version || '未知版本'} setup 已完成;接下来执行安装后健康检查。\n`
57
- + '工作站服务和 Codex 内核已就绪,已启用登录自启。\n'
57
+ + '工作站服务和 Codex 内核已就绪。\n'
58
+ + (result.autostart?.enabled ? '已启用登录自启。\n' : `登录自启未启用。${result.autostart?.error || ''}\n`)
58
59
  + (result.preserveCodex ? '过渡版保留当前 Codex 和内核运行状态;待手机发起下一次完整更新。\n' : migration.restarted ? `Codex 内核已更新:${migration.previousVersion || '未知'} → ${result.managedAppServer?.version || '未知'}(PID ${migration.previousPid} → ${migration.currentPid})。\n` : 'Codex 内核已是当前选定版本,无需切换。\n')
59
60
  + (result.preserveCodex ? '' : result.desktopRestarted ? '电脑版 Codex 已重启,并确认连接到工作站内核。\n' : migration.restarted ? '桌面连接已随内核更新处理,无需再次重启。\n' : result.desktopWasRunning ? '电脑版 Codex 保持运行,服务更新无需重启桌面。\n' : '安装前未运行电脑版 Codex,保持关闭。\n')
60
61
  + (result.desktopRestartRecommended ? 'Codex Desktop:请完全退出后重新打开。\n' : '');