@bitkyc08/opencodex 2.100.3 → 2.100.4

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.
Files changed (181) hide show
  1. package/AGENTS_INSTALL.md +23 -1
  2. package/bin/ocx.mjs +8 -1
  3. package/gui/dist/assets/{App-Dnb6VMsP.js → App-DcpyI78f.js} +20 -19
  4. package/gui/dist/assets/{Tray-BV4ms9U9.js → Tray-CzjPJprT.js} +1 -1
  5. package/gui/dist/assets/brand-mark-BTIi7e69.js +1 -0
  6. package/gui/dist/assets/index-DJxM-imn.css +2 -0
  7. package/gui/dist/assets/index-DVgU6S3y.js +138 -0
  8. package/gui/dist/assets/{segment-thumb-features-DXSidY6D.js → segment-thumb-features-Bn6Y-g3R.js} +1 -1
  9. package/gui/dist/classic/assets/{App-DA-scMPq.js → App-eYJAyNHM.js} +19 -18
  10. package/gui/dist/classic/assets/{Tray-BrHaVRAq.js → Tray-xHMYxLkV.js} +1 -1
  11. package/gui/dist/classic/assets/index-DSaVRW4F.js +138 -0
  12. package/gui/dist/classic/assets/quota-summary-DyzHlkFl.js +1 -0
  13. package/gui/dist/classic/index.html +1 -1
  14. package/gui/dist/index.html +2 -2
  15. package/native/ocx-child/src/cli.rs +5 -3
  16. package/native/ocx-child/src/codex_home.rs +1 -0
  17. package/package.json +2 -2
  18. package/src/adapters/anthropic/per-message-effort.ts +296 -0
  19. package/src/adapters/anthropic.ts +3 -0
  20. package/src/adapters/claude-cli/adapter.ts +1 -0
  21. package/src/adapters/devin/cloud-direct/chat.ts +71 -14
  22. package/src/adapters/google-errors.ts +14 -2
  23. package/src/adapters/qoder/adapter.ts +9 -1
  24. package/src/adapters/zed.ts +4 -2
  25. package/src/claude/desktop-remote-store.ts +60 -10
  26. package/src/cli/account-api.ts +4 -0
  27. package/src/cli/account-auth.ts +30 -2
  28. package/src/cli/account-extended.ts +33 -2
  29. package/src/cli/capabilities-access-remote.ts +3 -3
  30. package/src/cli/capabilities-accounts.ts +3 -3
  31. package/src/cli/capabilities-base.ts +11 -6
  32. package/src/cli/capabilities-observe-system.ts +2 -2
  33. package/src/cli/claude.ts +3 -3
  34. package/src/cli/disconnect-runtime.ts +16 -6
  35. package/src/cli/dispatch.ts +7 -1
  36. package/src/cli/index.ts +2 -2
  37. package/src/cli/link-apply-restart.ts +4 -2
  38. package/src/cli/link-routes.ts +4 -1
  39. package/src/cli/link.ts +5 -4
  40. package/src/cli/preflight-exemptions.ts +3 -0
  41. package/src/cli/registry.ts +5 -2
  42. package/src/cli/resolve.ts +23 -8
  43. package/src/cli/restart-failure.ts +11 -1
  44. package/src/cli/runtime-api.ts +4 -0
  45. package/src/cli/status.ts +4 -1
  46. package/src/cli/system-command.ts +1 -1
  47. package/src/cli/system-restart-client.ts +9 -3
  48. package/src/cli/system-settings-parity.ts +2 -1
  49. package/src/client/connect.ts +63 -9
  50. package/src/client/desktop-refusal.ts +38 -0
  51. package/src/client/lifecycle-lock.ts +29 -4
  52. package/src/client/runtime-restart.ts +27 -15
  53. package/src/client/runtime.ts +4 -2
  54. package/src/client/state.ts +14 -0
  55. package/src/codex/account-pause.ts +4 -0
  56. package/src/codex/account-runtime-state.ts +4 -0
  57. package/src/codex/auth-api/main-account-probe.ts +3 -1
  58. package/src/codex/auth-api/main-hard-lock-refusal-read.ts +172 -0
  59. package/src/codex/auth-context.ts +40 -2
  60. package/src/codex/catalog/build-entries.ts +10 -0
  61. package/src/codex/catalog/derive-entry.ts +7 -0
  62. package/src/codex/catalog/reserve-warn.ts +7 -5
  63. package/src/codex/catalog/reserve.ts +4 -3
  64. package/src/codex/catalog/retained-sync.ts +2 -0
  65. package/src/codex/catalog/routed-defaults.ts +35 -0
  66. package/src/codex/convergence.ts +2 -0
  67. package/src/codex/loopback-target.ts +22 -8
  68. package/src/codex/main-account.ts +88 -29
  69. package/src/codex/native-main-auth-file.ts +14 -0
  70. package/src/codex/native-main-credentials.ts +270 -0
  71. package/src/codex/native-main-owner.ts +3 -0
  72. package/src/codex/native-main-refresh-mode.ts +14 -1
  73. package/src/codex/quota.ts +63 -14
  74. package/src/combos/failover.ts +12 -1
  75. package/src/combos/index.ts +5 -0
  76. package/src/combos/resolve.ts +115 -19
  77. package/src/config/diagnostics.ts +3 -0
  78. package/src/config/live-reconcile.ts +6 -3
  79. package/src/config/load-degrade.ts +2 -0
  80. package/src/config/persisted-mutation.ts +2 -2
  81. package/src/config/persisted-projections.ts +18 -0
  82. package/src/config/process-state.ts +4 -3
  83. package/src/config/reserve-capability.ts +96 -0
  84. package/src/config/schema/config-schema.ts +6 -0
  85. package/src/config/schema/leaf-validators.ts +2 -0
  86. package/src/config/schema/routed-catalog-defaults.ts +49 -0
  87. package/src/config.ts +7 -7
  88. package/src/desktop-update/acquire.ts +202 -0
  89. package/src/desktop-update/cli.ts +168 -0
  90. package/src/desktop-update/drain.ts +40 -0
  91. package/src/desktop-update/headless.ts +285 -0
  92. package/src/desktop-update/image.ts +85 -0
  93. package/src/desktop-update/install.ts +53 -0
  94. package/src/desktop-update/msi.ts +72 -0
  95. package/src/desktop-update/release.ts +128 -0
  96. package/src/desktop-update/runtime.ts +155 -0
  97. package/src/desktop-update/staging.ts +118 -0
  98. package/src/desktop-update/trust.ts +45 -0
  99. package/src/generated/compatibility-version.json +246 -130
  100. package/src/images/fulfill-video.ts +3 -3
  101. package/src/images/loop.ts +6 -2
  102. package/src/images/plan.ts +147 -11
  103. package/src/images/types.ts +13 -4
  104. package/src/images/xai-video-client.ts +72 -10
  105. package/src/lib/gcp-adc.ts +48 -4
  106. package/src/lib/offline-resend.ts +150 -0
  107. package/src/lib/paced-stream.ts +3 -3
  108. package/src/lib/provider-outbound.ts +17 -6
  109. package/src/lib/request-failure-model.ts +2 -0
  110. package/src/lib/response-body-inactivity.ts +23 -1
  111. package/src/lib/upstream-retry.ts +38 -5
  112. package/src/link/explicit-route.ts +4 -4
  113. package/src/link/remote-windows.ts +79 -31
  114. package/src/link/residual-recovery.ts +20 -8
  115. package/src/messaging/budget.ts +23 -5
  116. package/src/messaging/rpc.ts +4 -4
  117. package/src/oauth/antigravity-risk.ts +126 -0
  118. package/src/oauth/generic-account-failover.ts +89 -18
  119. package/src/oauth/generic-session-affinity.ts +10 -3
  120. package/src/oauth/login-cli.ts +35 -1
  121. package/src/oauth/pool-kernel.ts +3 -3
  122. package/src/providers/anthropic-billing-refusal.ts +27 -3
  123. package/src/providers/google-vertex-model-discovery.ts +6 -1
  124. package/src/providers/model-rename-fields.ts +2 -0
  125. package/src/providers/quota/workbuddy.ts +6 -2
  126. package/src/providers/workbuddy-credit-balance.ts +125 -16
  127. package/src/responses/effort-history.ts +732 -0
  128. package/src/routing/history/integrity.ts +41 -4
  129. package/src/server/auth-cors.ts +13 -3
  130. package/src/server/codex-model-list.ts +2 -1
  131. package/src/server/direct-local-http.ts +26 -3
  132. package/src/server/index/link-listener.ts +20 -14
  133. package/src/server/index/serve-options.ts +1 -0
  134. package/src/server/index.ts +3 -2
  135. package/src/server/link-turn.ts +17 -5
  136. package/src/server/management/config-routes.ts +39 -3
  137. package/src/server/management/link-child-preflight.ts +1 -1
  138. package/src/server/management/link-route-edit.ts +20 -1
  139. package/src/server/management/oauth-account-routes.ts +22 -5
  140. package/src/server/management/provider-overwrite-carry.ts +3 -0
  141. package/src/server/management/provider-routes.ts +4 -4
  142. package/src/server/management/static-catalog-probe.ts +33 -0
  143. package/src/server/proxy-liveness.ts +54 -9
  144. package/src/server/relay.ts +6 -1
  145. package/src/server/request-log-conversation.ts +2 -2
  146. package/src/server/request-log.ts +5 -1
  147. package/src/server/reserve-capability-startup.ts +32 -0
  148. package/src/server/responses/adapter-delivery.ts +2 -0
  149. package/src/server/responses/adapter-dispatch.ts +31 -10
  150. package/src/server/responses/antigravity-fault-rotation.ts +24 -0
  151. package/src/server/responses/antigravity-validation-refusal.ts +43 -6
  152. package/src/server/responses/combo-selection-keepalive.ts +254 -0
  153. package/src/server/responses/core-combo.ts +24 -9
  154. package/src/server/responses/core-errors.ts +9 -6
  155. package/src/server/responses/core-options.ts +8 -0
  156. package/src/server/responses/core.ts +21 -0
  157. package/src/server/responses/estimated-usage.ts +115 -0
  158. package/src/server/responses/jev-model-invoke.ts +7 -2
  159. package/src/server/responses/passthrough-completion.ts +6 -3
  160. package/src/server/responses/passthrough-delivery.ts +47 -8
  161. package/src/server/responses/passthrough-dispatch.ts +3 -0
  162. package/src/server/responses/request-prepare.ts +9 -5
  163. package/src/server/responses/sidecar-execution.ts +5 -0
  164. package/src/service/desktop-supervision.d.mts +2 -0
  165. package/src/service/desktop-supervision.mjs +5 -0
  166. package/src/stall-timeout.ts +11 -0
  167. package/src/types/config.ts +15 -92
  168. package/src/types/provider.ts +13 -0
  169. package/src/types/request.ts +19 -0
  170. package/src/types/routed-catalog-defaults.ts +17 -0
  171. package/src/types/routing-profile.ts +90 -0
  172. package/src/types.ts +1 -0
  173. package/src/update/index.ts +1 -1
  174. package/src/usage/log.ts +14 -4
  175. package/src/usage/telemetry-contract.ts +1 -0
  176. package/src/web-search/passthrough-bridge.ts +7 -0
  177. package/gui/dist/assets/brand-mark-XOLJbomA.js +0 -1
  178. package/gui/dist/assets/index-DCdXsMyZ.js +0 -105
  179. package/gui/dist/assets/index-DQtCRNAw.css +0 -2
  180. package/gui/dist/classic/assets/index-BqOaGLf5.js +0 -105
  181. package/gui/dist/classic/assets/quota-summary-Dy5_wfTT.js +0 -1
@@ -0,0 +1,285 @@
1
+ /**
2
+ * Headless Windows Desktop update (`ocx update --desktop`, #8246).
3
+ *
4
+ * One pass: read the published channel, and when it announces a newer version, download the
5
+ * Windows MSI under the acquisition contract, verify it with the GUI updater's embedded key,
6
+ * stage it where nothing with fewer rights than the installer can change it (`./staging.ts`) and
7
+ * verify the staged copy again, install it non-interactively and wait for the installer's exit
8
+ * code, read the installed `ocx.exe` version back, then make the serving
9
+ * runtime that version. When nothing newer is published, the same pass still finishes an
10
+ * earlier install whose old runtime is still serving. Every dependency is injected; the
11
+ * production wiring is in `./cli.ts`.
12
+ */
13
+ import { DESKTOP_ACQUIRE_LIMITS, DESKTOP_UPDATE_FEED_URL } from "./trust";
14
+ import { DesktopAcquireError, type AcquireTimers } from "./acquire";
15
+ import { compareToInstalled, DesktopUpdateRefusal, parseDesktopFeed, verifyDesktopInstaller } from "./release";
16
+ import { describeMsiOutcome, isInstalled, runMsiInstall, type InstallerSpawn, type MsiOutcome } from "./msi";
17
+ import { settleRuntime, type RuntimeOutcome, type RuntimeReplaceDeps } from "./runtime";
18
+ import { desktopUpdateCommand, type WindowsDesktopInstall } from "./install";
19
+ import { computeVersionSkew } from "../cli/version-skew";
20
+
21
+ export const HEADLESS_RESULT_SCHEMA = "ocx.desktop.headless-update/1";
22
+
23
+ /** 0 done; 1 nothing installed; 2 installed but the old runtime still serves; 3 uncertain; 64 usage. */
24
+ export const HEADLESS_EXIT = Object.freeze({ ok: 0, unchanged: 1, runtimeStale: 2, uncertain: 3, usage: 64 });
25
+
26
+ export type HeadlessOutcome =
27
+ | "up-to-date"
28
+ | "available"
29
+ | "updated"
30
+ | "runtime-replaced"
31
+ | "installed-stopped"
32
+ | "refused"
33
+ | "failed"
34
+ | "installer-failed"
35
+ | "installer-uncertain"
36
+ | "reboot-required"
37
+ | "installed-version-mismatch"
38
+ | "old-runtime-serving";
39
+
40
+ export interface HeadlessResult {
41
+ schema: typeof HEADLESS_RESULT_SCHEMA;
42
+ outcome: HeadlessOutcome;
43
+ exitCode: number;
44
+ installedVersion: string;
45
+ targetVersion: string | null;
46
+ runtime: { pid: number | null; port: number; version: string | null } | null;
47
+ installer: { exitCode: number | null; log: string | null; rebootRequired: boolean } | null;
48
+ reason: string | null;
49
+ message: string;
50
+ }
51
+
52
+ export interface StagingArea {
53
+ /** Create a private, operation-owned directory and return its path. */
54
+ create(): string;
55
+ write(path: string, bytes: Uint8Array): void;
56
+ read(path: string): Uint8Array;
57
+ join(dir: string, name: string): string;
58
+ /** Remove this operation's directory, keeping only the named files when any are given. */
59
+ discard(dir: string, keep: readonly string[]): void;
60
+ }
61
+
62
+ export interface HeadlessDeps {
63
+ install: WindowsDesktopInstall;
64
+ /** The version of the `ocx.exe` running this command, which is the installed version. */
65
+ currentVersion: string;
66
+ fetch(url: string, maxBytes: number): Promise<Uint8Array>;
67
+ staging: StagingArea;
68
+ /**
69
+ * Rename the running `ocx.exe` image aside inside the installation (Windows allows renaming a
70
+ * running executable) and return its new path, or null when this process is not running the
71
+ * installed image. Without this, Windows Installer's Restart Manager closes this very process,
72
+ * and everything sharing its console, to replace the file, and the install rolls back. Throws
73
+ * when the image cannot be moved.
74
+ */
75
+ moveAsideOwnImage(): string | null;
76
+ /**
77
+ * After an install that did not complete, make sure the installed path holds an `ocx.exe`:
78
+ * true when it already does or the moved image was put back.
79
+ */
80
+ restoreOwnImage(moved: string): boolean;
81
+ /** Best effort: delete images earlier runs moved aside, and schedule `current` for deletion. */
82
+ retireMovedImages(current: string | null): void;
83
+ msiexecPath(): string;
84
+ spawnInstaller: InstallerSpawn;
85
+ timers: AcquireTimers;
86
+ installerTimeoutMs?: number;
87
+ runtimeDeadlineMs?: number;
88
+ readInstalledVersion(ocxExe: string): Promise<string | null>;
89
+ runtime: RuntimeReplaceDeps;
90
+ log(line: string): void;
91
+ /** Fixture key for tests only; the production composition never sets it and uses the embedded key. */
92
+ fixturePublicKey?: string;
93
+ }
94
+
95
+ export const INSTALLER_TIMEOUT_MS = 15 * 60_000;
96
+ /**
97
+ * Room for a connected client's 90-second restart budget, or a 75-second drain or service
98
+ * restart, followed by the owner's respawn and the replacement's startup.
99
+ */
100
+ export const RUNTIME_DEADLINE_MS = 240_000;
101
+
102
+ function runtimeView(live: { pid: number | null; port: number; version?: string } | null): HeadlessResult["runtime"] {
103
+ return live ? { pid: live.pid, port: live.port, version: live.version ?? null } : null;
104
+ }
105
+
106
+ function staleMessage(outcome: Extract<RuntimeOutcome, { kind: "stale" }>, target: string, install: WindowsDesktopInstall): string {
107
+ const live = outcome.live;
108
+ const who = live ? `The proxy on port ${live.port}${live.pid !== null ? ` (pid ${live.pid})` : ""} still serves ${live.version ?? "an unknown version"}` : "No proxy answers with the installed version";
109
+ const retry = `Replace it with: ${desktopUpdateCommand(install)} (or quit and reopen OpenCodex Desktop).`;
110
+ switch (outcome.reason) {
111
+ case "foreign-image":
112
+ return `${who}; this installation is ${target}. It runs from ${outcome.detail ?? "another executable"}, not ${install.ocxExe}, so it was not stopped. Restart it from the installation that owns it.`;
113
+ case "runtime-newer":
114
+ return `${who}, which is newer than this installation (${target}); it was left running.`;
115
+ case "unattested":
116
+ case "unknown-version":
117
+ case "incomparable":
118
+ return `${who}; this installation is ${target}. Its identity or version could not be verified, so it was not stopped. Run 'ocx status', then restart it through its owner. ${retry}`;
119
+ case "restart-refused":
120
+ return `${who}; this installation is ${target}. The runtime refused a restart (${outcome.detail ?? "refused"}), so nothing was stopped. ${retry}`;
121
+ case "drain-failed":
122
+ return `${who}; this installation is ${target}. Stopping it for OpenCodex Desktop to restart did not complete (${outcome.detail ?? "unconfirmed"}). Run 'ocx status'. ${retry}`;
123
+ case "service-restart-failed":
124
+ return `${who}; this installation is ${target}. Its background service owns it, and '${install.ocxExe}' service restart did not replace it (${outcome.detail ?? "unconfirmed"}). `
125
+ + `Nothing else was stopped; the installed version starts the next time that service starts the proxy, for example after Windows restarts. Run 'ocx service status'. ${retry}`;
126
+ case "replacement-timeout":
127
+ return `${who}; this installation is ${target}. A restart was requested but the new version was not observed answering in time. Run 'ocx status'. ${retry}`;
128
+ }
129
+ }
130
+
131
+ export async function runHeadlessDesktopUpdate(options: { check: boolean }, deps: HeadlessDeps): Promise<HeadlessResult> {
132
+ const installed = deps.currentVersion;
133
+ const base = { schema: HEADLESS_RESULT_SCHEMA, installedVersion: installed, installer: null, reason: null } as const;
134
+ const finish = (fields: Partial<HeadlessResult> & Pick<HeadlessResult, "outcome" | "exitCode" | "message">): HeadlessResult =>
135
+ ({ ...base, targetVersion: null, runtime: null, ...fields });
136
+
137
+ // 1. The published channel.
138
+ let candidate;
139
+ try {
140
+ candidate = parseDesktopFeed(await deps.fetch(DESKTOP_UPDATE_FEED_URL, DESKTOP_ACQUIRE_LIMITS.maxFeedBytes));
141
+ } catch (error) {
142
+ return failure(error, null);
143
+ }
144
+ const relation = compareToInstalled(installed, candidate.version);
145
+ const runtimeDeadline = () => deps.runtime.now() + (deps.runtimeDeadlineMs ?? RUNTIME_DEADLINE_MS);
146
+
147
+ // 2. Nothing newer: an earlier install may still have an old runtime serving.
148
+ if (relation !== "newer") {
149
+ if (relation === "unknown") {
150
+ return finish({ outcome: "refused", exitCode: HEADLESS_EXIT.unchanged, targetVersion: candidate.version, reason: "version_unknown",
151
+ message: `The installed version ${installed} cannot be compared with the published ${candidate.version}; nothing was changed.` });
152
+ }
153
+ const live = await deps.runtime.findLive();
154
+ // Only this home's attested runtime, older than this installation, is one an install left behind.
155
+ const stale = live?.source === "runtime" && live.version !== undefined
156
+ && computeVersionSkew(installed, live.version).relation === "cli-newer";
157
+ if (options.check || !stale) {
158
+ return finish({
159
+ outcome: stale ? "old-runtime-serving" : "up-to-date",
160
+ exitCode: stale ? HEADLESS_EXIT.runtimeStale : HEADLESS_EXIT.ok,
161
+ targetVersion: candidate.version, runtime: runtimeView(live),
162
+ message: stale
163
+ ? `OpenCodex Desktop ${installed} is installed, but the running proxy still serves ${live!.version}. Replace it with: ${desktopUpdateCommand(deps.install)}`
164
+ : `OpenCodex Desktop is up to date (${installed}).`,
165
+ });
166
+ }
167
+ deps.log(`OpenCodex Desktop ${installed} is installed, but the running proxy serves ${live!.version}; replacing it.`);
168
+ const settled = await settleRuntime({ installedExe: deps.install.ocxExe, targetVersion: installed, deadlineAt: runtimeDeadline(), wasRunning: true, expectedPort: live!.port }, deps.runtime);
169
+ return fromRuntime(settled, installed, null, "runtime-replaced");
170
+ }
171
+
172
+ if (options.check) {
173
+ const live = await deps.runtime.findLive();
174
+ return finish({ outcome: "available", exitCode: HEADLESS_EXIT.ok, targetVersion: candidate.version, runtime: runtimeView(live),
175
+ message: `OpenCodex Desktop ${candidate.version} is available (installed: ${installed}). Install it with: ${desktopUpdateCommand(deps.install)}` });
176
+ }
177
+
178
+ // 3. Download and verify.
179
+ const found = await deps.runtime.findLive();
180
+ // A proxy without this home's runtime record is not the one this update must replace.
181
+ const before = found?.source === "runtime" ? found : null;
182
+ deps.log(`Downloading OpenCodex Desktop ${candidate.version}…`);
183
+ let bytes: Uint8Array;
184
+ try {
185
+ bytes = await deps.fetch(candidate.url, DESKTOP_ACQUIRE_LIMITS.maxArtifactBytes);
186
+ verifyDesktopInstaller(bytes, candidate, deps.fixturePublicKey);
187
+ } catch (error) {
188
+ return failure(error, candidate.version);
189
+ }
190
+ deps.log(`Verified the installer signature for ${candidate.version}.`);
191
+
192
+ // 4. Stage privately, verify the staged bytes again, install.
193
+ let dir: string | null = null;
194
+ let logPath: string | null = null;
195
+ let moved: string | null = null;
196
+ let installer: MsiOutcome;
197
+ // Best effort: a file still held open (msiexec, an indexer) stays in this operation's directory.
198
+ const discard = (keep: readonly string[]) => {
199
+ if (!dir) return;
200
+ try { deps.staging.discard(dir, keep); } catch { /* left for the user or the next temp cleanup */ }
201
+ };
202
+ try {
203
+ deps.retireMovedImages(null);
204
+ dir = deps.staging.create();
205
+ const msiPath = deps.staging.join(dir, `OpenCodex-${candidate.version}-windows-x64.msi`);
206
+ logPath = deps.staging.join(dir, "msiexec.log");
207
+ deps.staging.write(msiPath, bytes);
208
+ verifyDesktopInstaller(deps.staging.read(msiPath), candidate, deps.fixturePublicKey);
209
+ try { moved = deps.moveAsideOwnImage(); }
210
+ catch (error) {
211
+ throw new Error(`the running ${deps.install.ocxExe} could not be moved aside for the installer (${error instanceof Error ? error.message : String(error)}); run this from an elevated terminal`);
212
+ }
213
+ deps.log("Installing (Windows Installer, no UI)…");
214
+ installer = await runMsiInstall({ msiexec: deps.msiexecPath(), msiPath, logPath, timeoutMs: deps.installerTimeoutMs ?? INSTALLER_TIMEOUT_MS },
215
+ { spawn: deps.spawnInstaller, timers: deps.timers });
216
+ } catch (error) {
217
+ if (moved) deps.restoreOwnImage(moved);
218
+ discard([]);
219
+ return failure(error, candidate.version);
220
+ }
221
+ const installerView = { exitCode: installer.code, log: logPath, rebootRequired: installer.kind === "installed-reboot-required" };
222
+ const previous = moved ? ` The previous ocx.exe is at ${moved}.` : "";
223
+ if (!isInstalled(installer)) {
224
+ // A finished, rolled-back install has restored the copy at the installed path; the moved image
225
+ // goes back only if that path is empty. An installer that may still be running is left alone
226
+ // with everything it may hold open: the package, the log and the moved image.
227
+ const uncertain = installer.kind === "uncertain";
228
+ const restored = moved && !uncertain ? deps.restoreOwnImage(moved) : false;
229
+ const stranded = moved && !restored ? ` The previous ocx.exe is at ${moved}.` : "";
230
+ if (!uncertain) discard(logPath ? [logPath] : []);
231
+ return finish({ outcome: uncertain ? "installer-uncertain" : "installer-failed",
232
+ exitCode: uncertain ? HEADLESS_EXIT.uncertain : HEADLESS_EXIT.unchanged,
233
+ targetVersion: candidate.version, runtime: runtimeView(before), installer: installerView, reason: installer.kind,
234
+ message: `${describeMsiOutcome(installer)} Log: ${logPath}${uncertain ? ` The staged installer is kept in ${dir}.` : ""}${stranded}` });
235
+ }
236
+ deps.log(describeMsiOutcome(installer));
237
+
238
+ // 5. Read the installed binary back; the moved image is retired only once it matches.
239
+ const readBack = await deps.readInstalledVersion(deps.install.ocxExe);
240
+ if (readBack !== candidate.version) {
241
+ discard(logPath ? [logPath] : []);
242
+ const reboot = installer.kind === "installed-reboot-required";
243
+ return finish({ outcome: reboot ? "reboot-required" : "installed-version-mismatch",
244
+ exitCode: reboot ? HEADLESS_EXIT.runtimeStale : HEADLESS_EXIT.uncertain,
245
+ targetVersion: candidate.version, runtime: runtimeView(before), installer: installerView, reason: "installed_version",
246
+ message: reboot
247
+ ? `The installer finished but ${deps.install.ocxExe} still reports ${readBack ?? "no version"}; restart Windows to complete the update to ${candidate.version}. Log: ${logPath}${previous}`
248
+ : `The installer reported success but ${deps.install.ocxExe} reports ${readBack ?? "no version"}, not ${candidate.version}. Log: ${logPath}${previous}` });
249
+ }
250
+ deps.retireMovedImages(moved);
251
+ discard([]);
252
+
253
+ // 6. Replace the runtime that still serves the old version.
254
+ const settled = await settleRuntime({ installedExe: deps.install.ocxExe, targetVersion: candidate.version, deadlineAt: runtimeDeadline(), wasRunning: before !== null, ...(before ? { expectedPort: before.port } : {}) }, deps.runtime);
255
+ return fromRuntime(settled, candidate.version, { ...installerView, log: null }, "updated");
256
+
257
+ function fromRuntime(settled: RuntimeOutcome, target: string, installerResult: HeadlessResult["installer"], done: "updated" | "runtime-replaced"): HeadlessResult {
258
+ const reboot = installerResult?.rebootRequired ? " Windows still has to restart to replace some files." : "";
259
+ if (settled.kind === "serving-target") {
260
+ return finish({ outcome: installerResult || settled.replaced ? done : "up-to-date", exitCode: HEADLESS_EXIT.ok, targetVersion: target,
261
+ runtime: runtimeView(settled.live), installer: installerResult,
262
+ message: `OpenCodex Desktop ${target} is installed and the proxy on port ${settled.live.port} serves ${target}.${reboot}` });
263
+ }
264
+ if (settled.kind === "not-running") {
265
+ return finish({ outcome: "installed-stopped", exitCode: HEADLESS_EXIT.ok, targetVersion: target, installer: installerResult,
266
+ message: `OpenCodex Desktop ${target} is installed. No proxy for this home was found, so none was started.${reboot}` });
267
+ }
268
+ return finish({ outcome: "old-runtime-serving", exitCode: HEADLESS_EXIT.runtimeStale, targetVersion: target,
269
+ runtime: runtimeView(settled.live), installer: installerResult, reason: settled.reason,
270
+ message: staleMessage(settled, target, deps.install) });
271
+ }
272
+
273
+ function failure(error: unknown, target: string | null): HeadlessResult {
274
+ if (error instanceof DesktopUpdateRefusal) {
275
+ return finish({ outcome: "refused", exitCode: HEADLESS_EXIT.unchanged, targetVersion: target, reason: error.code,
276
+ message: `Update refused: ${error.message}. Nothing was installed.` });
277
+ }
278
+ if (error instanceof DesktopAcquireError) {
279
+ return finish({ outcome: "failed", exitCode: HEADLESS_EXIT.unchanged, targetVersion: target, reason: error.code,
280
+ message: `Download failed: ${error.message}${error.retryable ? " (retryable)" : ""}. Nothing was installed.` });
281
+ }
282
+ return finish({ outcome: "failed", exitCode: HEADLESS_EXIT.unchanged, targetVersion: target, reason: "internal",
283
+ message: `Update failed before installation: ${error instanceof Error ? error.message : String(error)}. Nothing was installed.` });
284
+ }
285
+ }
@@ -0,0 +1,85 @@
1
+ /**
2
+ * The updater's own running `ocx.exe` and Windows Installer (#8246).
3
+ *
4
+ * Windows Installer's Restart Manager closes every process that maps a file the package replaces,
5
+ * which would end this command and everything sharing its console and roll the install back.
6
+ * Windows allows renaming a running image, so the running file is renamed aside inside the
7
+ * installation directory, where its mapping stays valid, and an unmapped copy of it takes the
8
+ * installed name. The name is empty only between two back-to-back renames, and then only while
9
+ * Windows Installer itself replaces the file (a major upgrade removes the old one first); the
10
+ * installer finishes or rolls back its own transaction even if this command is killed (Ctrl+C, a
11
+ * closed console, a dropped SSH session), so nothing this command did has to be put back.
12
+ */
13
+ import { constants, copyFileSync, existsSync, readdirSync, renameSync, rmSync } from "node:fs";
14
+ import { win32 } from "node:path";
15
+ import { trustedWindowsSystemDirectory } from "../service/desktop-supervision.mjs";
16
+ import { dlopen, ptr } from "bun:ffi";
17
+ import { movedImageName, sameWindowsPath } from "./runtime";
18
+ import type { WindowsDesktopInstall } from "./install";
19
+
20
+ const MOVEFILE_DELAY_UNTIL_REBOOT = 4;
21
+ /** Images earlier runs moved aside, and copies a run killed mid-swap left behind. */
22
+ const LEFTOVER_IMAGE_PATTERN = /^ocx\.exe\.\d+-\d+\.update-(?:old|new)$/i;
23
+
24
+ /** Ask Windows to delete a still-mapped file at the next restart; best effort. */
25
+ function deleteAtReboot(path: string): void {
26
+ try {
27
+ const kernel32 = dlopen(win32.join(trustedWindowsSystemDirectory(), "kernel32.dll"), { MoveFileExW: { args: ["ptr", "ptr", "u32"], returns: "i32" } });
28
+ try {
29
+ const wide = Buffer.from(`${path}\0`, "utf16le");
30
+ kernel32.symbols.MoveFileExW(ptr(wide), null, MOVEFILE_DELAY_UNTIL_REBOOT);
31
+ } finally { kernel32.close(); }
32
+ } catch { /* the next run removes it instead */ }
33
+ }
34
+
35
+ export interface OwnImageOptions {
36
+ execPath?: string;
37
+ pid?: number;
38
+ now?: () => number;
39
+ join?: (dir: string, name: string) => string;
40
+ deleteAtReboot?: (path: string) => void;
41
+ }
42
+
43
+ export function ownImageMover(install: WindowsDesktopInstall, options: OwnImageOptions = {}) {
44
+ const join = options.join ?? win32.join;
45
+ const scheduleDelete = options.deleteAtReboot ?? deleteAtReboot;
46
+ return {
47
+ moveAsideOwnImage: () => {
48
+ if (!sameWindowsPath(options.execPath ?? process.execPath, install.ocxExe)) return null;
49
+ const name = movedImageName(options.pid ?? process.pid, (options.now ?? Date.now)());
50
+ const moved = join(install.dir, name);
51
+ const copy = join(install.dir, name.replace(/\.update-old$/, ".update-new"));
52
+ // Copy first, then two renames back to back: the installed name is empty only between them.
53
+ copyFileSync(install.ocxExe, copy, constants.COPYFILE_EXCL);
54
+ try { renameSync(install.ocxExe, moved); }
55
+ catch (error) { rmSync(copy, { force: true }); throw error; }
56
+ try { renameSync(copy, install.ocxExe); }
57
+ catch (error) {
58
+ try { renameSync(moved, install.ocxExe); }
59
+ catch {
60
+ // Neither image is back at the installed name: keep both and say where they are, never delete the last copy.
61
+ const detail = error instanceof Error ? error.message : String(error);
62
+ throw new Error(`${install.ocxExe} could not be put back (${detail}). The previous ocx.exe is at ${moved} and an identical copy at ${copy}; rename either one to ${install.ocxExe}.`);
63
+ }
64
+ rmSync(copy, { force: true });
65
+ throw error;
66
+ }
67
+ return moved;
68
+ },
69
+ restoreOwnImage: (moved: string) => {
70
+ if (existsSync(install.ocxExe)) return true;
71
+ try { renameSync(moved, install.ocxExe); return true; } catch { return false; }
72
+ },
73
+ retireMovedImages: (current: string | null) => {
74
+ let names: string[] = [];
75
+ try { names = readdirSync(install.dir); } catch { return; }
76
+ for (const name of names) {
77
+ const path = join(install.dir, name);
78
+ if (!LEFTOVER_IMAGE_PATTERN.test(name) || path === current) continue;
79
+ try { rmSync(path); } catch { /* still mapped by a process; a later run or a restart removes it */ }
80
+ }
81
+ if (current) scheduleDelete(current);
82
+ },
83
+ };
84
+ }
85
+
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Recognizing a Windows OpenCodex Desktop installation from its bundled `ocx.exe` (#8246).
3
+ *
4
+ * The MSI installs `opencodex-desktop.exe` and its sidecar `ocx.exe` side by side; the headless
5
+ * updater and the stale-runtime advice apply only when this CLI is that compiled sidecar.
6
+ */
7
+ import { win32 } from "node:path";
8
+ import { existsSync } from "node:fs";
9
+ import { isStandaloneBinary } from "../lib/standalone";
10
+ import type { VersionSkew } from "../cli/version-skew";
11
+
12
+ export interface WindowsDesktopInstall {
13
+ dir: string;
14
+ ocxExe: string;
15
+ desktopExe: string;
16
+ }
17
+
18
+ export interface DesktopInstallProbe {
19
+ platform?: NodeJS.Platform;
20
+ execPath?: string;
21
+ standalone?: boolean;
22
+ exists?: (path: string) => boolean;
23
+ }
24
+
25
+ export function windowsDesktopInstall(probe: DesktopInstallProbe = {}): WindowsDesktopInstall | null {
26
+ if ((probe.platform ?? process.platform) !== "win32") return null;
27
+ if (!(probe.standalone ?? isStandaloneBinary())) return null;
28
+ const execPath = probe.execPath ?? process.execPath;
29
+ if (win32.basename(execPath).toLowerCase() !== "ocx.exe" || !/^[A-Za-z]:[\\/]/.test(execPath)) return null;
30
+ const dir = win32.dirname(execPath.replaceAll("/", "\\"));
31
+ const desktopExe = win32.join(dir, "opencodex-desktop.exe");
32
+ if (!(probe.exists ?? existsSync)(desktopExe)) return null;
33
+ return { dir, ocxExe: win32.join(dir, "ocx.exe"), desktopExe };
34
+ }
35
+
36
+ /** The command that finishes an installed update by replacing the runtime that still serves. */
37
+ export function desktopUpdateCommand(install: WindowsDesktopInstall): string {
38
+ return `"${install.ocxExe}" update --desktop`;
39
+ }
40
+
41
+ /**
42
+ * On a Desktop installation, a CLI newer than the serving proxy means the MSI installed an update
43
+ * the running runtime has not picked up. Say so, with the command that completes it, only for a
44
+ * proxy this home's runtime record attests: the command never replaces any other.
45
+ */
46
+ export function withDesktopSkewAdvice(skew: VersionSkew, install: WindowsDesktopInstall | null, liveSource: string | undefined): VersionSkew {
47
+ if (!install || liveSource !== "runtime" || skew.relation !== "cli-newer" || !skew.proxyVersion) return skew;
48
+ return {
49
+ ...skew,
50
+ warning: `OpenCodex Desktop ${skew.cliVersion} is installed, but the running proxy still serves ${skew.proxyVersion}. `
51
+ + `Replace it with: ${desktopUpdateCommand(install)} (or quit and reopen OpenCodex Desktop).`,
52
+ };
53
+ }
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Non-interactive Windows Installer execution for the headless Desktop updater (#8246).
3
+ *
4
+ * msiexec runs as a child this process waits on, so the result is the installer's real exit
5
+ * code, not a launch receipt. 0 and 3010 are both an installed product; 3010 (and 1641, which
6
+ * `/norestart` should prevent) also means a reboot finishes replacing files that were in use.
7
+ * Every other code is a failure Windows Installer has rolled back. If the installer outlives its
8
+ * deadline the outcome is uncertain: it is never killed mid-transaction and nothing that follows
9
+ * treats it as installed.
10
+ */
11
+ import type { AcquireTimers } from "./acquire";
12
+
13
+ export interface InstallerProcess {
14
+ /** Resolves with the exit code, or null when the process ended without one. */
15
+ exited: Promise<number | null>;
16
+ }
17
+
18
+ export type InstallerSpawn = (file: string, args: readonly string[]) => InstallerProcess;
19
+
20
+ export type MsiOutcome =
21
+ | { kind: "installed"; code: 0 }
22
+ | { kind: "installed-reboot-required"; code: 3010 | 1641 }
23
+ | { kind: "busy"; code: 1618 }
24
+ | { kind: "cancelled"; code: 1602 }
25
+ | { kind: "failed"; code: number | null }
26
+ | { kind: "uncertain"; code: null };
27
+
28
+ /** Fixed arguments: the verified package, no UI, no reboot, and a verbose log. */
29
+ export function msiexecArguments(msiPath: string, logPath: string): string[] {
30
+ return ["/i", msiPath, "/qn", "/norestart", "/l*v", logPath];
31
+ }
32
+
33
+ export function classifyMsiExit(code: number | null): MsiOutcome {
34
+ if (code === 0) return { kind: "installed", code };
35
+ if (code === 3010 || code === 1641) return { kind: "installed-reboot-required", code };
36
+ if (code === 1618) return { kind: "busy", code };
37
+ if (code === 1602) return { kind: "cancelled", code };
38
+ return { kind: "failed", code };
39
+ }
40
+
41
+ export function isInstalled(outcome: MsiOutcome): outcome is Extract<MsiOutcome, { kind: "installed" | "installed-reboot-required" }> {
42
+ return outcome.kind === "installed" || outcome.kind === "installed-reboot-required";
43
+ }
44
+
45
+ /** Plain explanation of an installer exit for the result and the terminal. */
46
+ export function describeMsiOutcome(outcome: MsiOutcome): string {
47
+ switch (outcome.kind) {
48
+ case "installed": return "Windows Installer finished (exit 0).";
49
+ case "installed-reboot-required": return `Windows Installer finished (exit ${outcome.code}); some files are replaced only after Windows restarts.`;
50
+ case "busy": return "Another installation is in progress (exit 1618); nothing was changed. Retry when it finishes.";
51
+ case "cancelled": return "The installation was cancelled (exit 1602); nothing was changed.";
52
+ case "failed": return `Windows Installer failed (exit ${outcome.code ?? "unknown"}) and rolled back; nothing was changed. Run this from an elevated terminal if the log reports insufficient privileges.`;
53
+ case "uncertain": return "Windows Installer did not finish within its deadline. It was left running; check the log and 'ocx status' before retrying.";
54
+ }
55
+ }
56
+
57
+ export async function runMsiInstall(
58
+ input: { msiexec: string; msiPath: string; logPath: string; timeoutMs: number },
59
+ deps: { spawn: InstallerSpawn; timers: AcquireTimers },
60
+ ): Promise<MsiOutcome> {
61
+ let child: InstallerProcess;
62
+ try { child = deps.spawn(input.msiexec, msiexecArguments(input.msiPath, input.logPath)); }
63
+ catch { return { kind: "failed", code: null }; }
64
+ let cancel = () => {};
65
+ const deadline = new Promise<"deadline">(resolve => { cancel = deps.timers.schedule(input.timeoutMs, () => resolve("deadline")); });
66
+ try {
67
+ const settled = await Promise.race([child.exited.then(code => ({ code }), () => ({ code: null })), deadline]);
68
+ return settled === "deadline" ? { kind: "uncertain", code: null } : classifyMsiExit(settled.code);
69
+ } finally {
70
+ cancel();
71
+ }
72
+ }
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Release-record parsing and installer verification for the headless Desktop updater (#8246).
3
+ *
4
+ * The GUI updater (`tauri-plugin-updater` 2.14.1, `verify_signature`) checks the minisign
5
+ * signature with the embedded key and, when the trusted comment names a version, that it equals
6
+ * the announced one. This verifier is never weaker: it requires the prehashed minisign form the
7
+ * release signer emits and both signatures over the exact trusted-comment bytes, binds the
8
+ * announced version and the Windows x64 MSI target through the exact asset URL and the signed
9
+ * `file:` name, and checks the bytes are an MSI container before any of them reach msiexec.
10
+ */
11
+ import { decodePublicKey, verifyMinisignBytes } from "../update/minisign.mjs";
12
+ import { compareStrictSemver, parseStrictSemver } from "../lib/strict-semver";
13
+ import { DESKTOP_ACQUIRE_LIMITS, DESKTOP_UPDATER_PUBKEY, DESKTOP_WINDOWS_PLATFORM, desktopInstallerUrl } from "./trust";
14
+
15
+ export type DesktopRefusalCode =
16
+ | "feed_malformed"
17
+ | "feed_version"
18
+ | "feed_target_missing"
19
+ | "feed_target_ambiguous"
20
+ | "feed_source"
21
+ | "signature_missing"
22
+ | "signature_invalid"
23
+ | "signed_version"
24
+ | "signed_target"
25
+ | "oversize"
26
+ | "not_msi";
27
+
28
+ export class DesktopUpdateRefusal extends Error {
29
+ constructor(readonly code: DesktopRefusalCode, message: string) {
30
+ super(message);
31
+ this.name = "DesktopUpdateRefusal";
32
+ }
33
+ }
34
+
35
+ export interface DesktopCandidate {
36
+ version: string;
37
+ url: string;
38
+ signature: string;
39
+ }
40
+
41
+ const MAX_SIGNATURE_CHARS = 5464;
42
+ const MSI_MAGIC = [0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1];
43
+
44
+ function record(value: unknown): Record<string, unknown> | null {
45
+ return value && typeof value === "object" && !Array.isArray(value) ? value as Record<string, unknown> : null;
46
+ }
47
+
48
+ /** Parse the published latest.json and select the Windows x64 MSI it announces. */
49
+ export function parseDesktopFeed(bytes: Uint8Array): DesktopCandidate {
50
+ let feed: Record<string, unknown> | null;
51
+ try { feed = record(JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes))); }
52
+ catch { throw new DesktopUpdateRefusal("feed_malformed", "the update feed is not valid JSON"); }
53
+ if (!feed) throw new DesktopUpdateRefusal("feed_malformed", "the update feed is not a JSON object");
54
+ const version = feed.version;
55
+ if (typeof version !== "string" || !parseStrictSemver(version)) {
56
+ throw new DesktopUpdateRefusal("feed_version", "the update feed names no valid version");
57
+ }
58
+ const platforms = record(feed.platforms);
59
+ const entry = record(platforms?.[DESKTOP_WINDOWS_PLATFORM]);
60
+ if (!platforms || !entry) throw new DesktopUpdateRefusal("feed_target_missing", `the update feed has no ${DESKTOP_WINDOWS_PLATFORM} installer`);
61
+ // The GUI updater would prefer an installer-specific key; refuse rather than pick between two.
62
+ const specific = record(platforms[`${DESKTOP_WINDOWS_PLATFORM}-msi`]);
63
+ if (specific && (specific.url !== entry.url || specific.signature !== entry.signature)) {
64
+ throw new DesktopUpdateRefusal("feed_target_ambiguous", "the update feed names two different Windows installers");
65
+ }
66
+ const expected = desktopInstallerUrl(version);
67
+ if (entry.url !== expected) {
68
+ throw new DesktopUpdateRefusal("feed_source", `the Windows installer is not served from the expected release asset ${expected}`);
69
+ }
70
+ const signature = entry.signature;
71
+ if (typeof signature !== "string" || !signature || signature.length > MAX_SIGNATURE_CHARS) {
72
+ throw new DesktopUpdateRefusal("signature_missing", "the Windows installer has no usable signature");
73
+ }
74
+ return { version, url: expected, signature };
75
+ }
76
+
77
+ function escapeRegExp(text: string): string {
78
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
79
+ }
80
+
81
+ /** File names the release signer may have signed for this version's Windows x64 MSI. */
82
+ function signedFileMatches(file: string, version: string): boolean {
83
+ // The release signs the full version in the name, prereleases included (only the WiX
84
+ // ProductVersion inside the package is reduced to the numeric core).
85
+ return new RegExp(`^OpenCodex_${escapeRegExp(version)}_x64_[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*\\.msi$`).test(file);
86
+ }
87
+
88
+ /**
89
+ * Verify downloaded installer bytes against the candidate. Throws {@link DesktopUpdateRefusal} on
90
+ * any mismatch; the bytes are installable only when this returns.
91
+ */
92
+ export function verifyDesktopInstaller(
93
+ bytes: Uint8Array,
94
+ candidate: DesktopCandidate,
95
+ publicKeyBase64: string = DESKTOP_UPDATER_PUBKEY,
96
+ ): { keyId: string; trustedComment: string } {
97
+ if (bytes.byteLength > DESKTOP_ACQUIRE_LIMITS.maxArtifactBytes) {
98
+ throw new DesktopUpdateRefusal("oversize", "the installer exceeds the size cap");
99
+ }
100
+ const key = decodePublicKey(Buffer.from(publicKeyBase64, "base64").toString("utf8"));
101
+ let verified: { keyId: string; trustedComment: string };
102
+ try { verified = verifyMinisignBytes(bytes, candidate.signature, key); }
103
+ catch (error) {
104
+ throw new DesktopUpdateRefusal("signature_invalid", `the installer signature did not verify: ${error instanceof Error ? error.message : String(error)}`);
105
+ }
106
+ const fields = verified.trustedComment.split("\t");
107
+ const signedVersion = fields.find(field => field.startsWith("version:"))?.slice("version:".length);
108
+ if (signedVersion !== undefined && signedVersion.replace(/^v/, "") !== candidate.version) {
109
+ throw new DesktopUpdateRefusal("signed_version", `the signature is for version ${signedVersion}, not ${candidate.version}`);
110
+ }
111
+ const file = fields.find(field => field.startsWith("file:"))?.slice("file:".length);
112
+ if (!file || !signedFileMatches(file, candidate.version)) {
113
+ throw new DesktopUpdateRefusal("signed_target", "the signature does not name this version's Windows x64 MSI");
114
+ }
115
+ if (bytes.byteLength < MSI_MAGIC.length || MSI_MAGIC.some((byte, index) => bytes[index] !== byte)) {
116
+ throw new DesktopUpdateRefusal("not_msi", "the signed file is not a Windows Installer package");
117
+ }
118
+ return { keyId: verified.keyId, trustedComment: verified.trustedComment };
119
+ }
120
+
121
+ /** How a published version relates to the installed one; only "newer" is installed. */
122
+ export function compareToInstalled(installed: string, candidate: string): "newer" | "same" | "older" | "unknown" {
123
+ const left = parseStrictSemver(installed);
124
+ const right = parseStrictSemver(candidate);
125
+ if (!left || !right) return "unknown";
126
+ const order = compareStrictSemver(right, left);
127
+ return order > 0 ? "newer" : order < 0 ? "older" : "same";
128
+ }