@bitkyc08/opencodex 2.100.3 → 2.100.5-preview.20261118.1
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/AGENTS_INSTALL.md +23 -1
- package/bin/ocx.mjs +8 -1
- package/gui/dist/assets/{App-Dnb6VMsP.js → App-BiOGtxDS.js} +21 -20
- package/gui/dist/assets/{Tray-BV4ms9U9.js → Tray-BwsMejUO.js} +1 -1
- package/gui/dist/assets/brand-mark-BY1dgACL.js +1 -0
- package/gui/dist/assets/{index-DCdXsMyZ.js → index-CwHSKMdG.js} +46 -13
- package/gui/dist/assets/index-DJxM-imn.css +2 -0
- package/gui/dist/assets/{segment-thumb-features-DXSidY6D.js → segment-thumb-features-Bds9Hb_7.js} +1 -1
- package/gui/dist/classic/assets/{App-DA-scMPq.js → App-CGLOiqQL.js} +20 -19
- package/gui/dist/classic/assets/{Tray-BrHaVRAq.js → Tray-Da4r2O70.js} +1 -1
- package/gui/dist/classic/assets/{index-BqOaGLf5.js → index-CvoKXKL9.js} +46 -13
- package/gui/dist/classic/assets/quota-summary-DvqzfCmr.js +1 -0
- package/gui/dist/classic/index.html +1 -1
- package/gui/dist/index.html +2 -2
- package/native/ocx-child/src/cli.rs +5 -3
- package/native/ocx-child/src/codex_home.rs +1 -0
- package/native/ocx-child/src/link_ws.rs +24 -19
- package/native/ocx-child/src/link_ws_frame.rs +136 -50
- package/package.json +3 -3
- package/src/adapters/anthropic/per-message-effort.ts +296 -0
- package/src/adapters/anthropic-input-schema.ts +270 -0
- package/src/adapters/anthropic.ts +4 -63
- package/src/adapters/claude-cli/adapter.ts +1 -0
- package/src/adapters/command-code-tool-text.ts +9 -1
- package/src/adapters/command-code.ts +18 -2
- package/src/adapters/devin/cloud-direct/chat.ts +95 -14
- package/src/adapters/devin/live-models.ts +11 -1
- package/src/adapters/google-errors.ts +14 -2
- package/src/adapters/kiro/reasoning.ts +3 -0
- package/src/adapters/kiro-tools.ts +14 -9
- package/src/adapters/openai-responses/passthrough.ts +3 -1
- package/src/adapters/openai-responses/request-strips.ts +1 -0
- package/src/adapters/qoder/adapter.ts +9 -1
- package/src/adapters/tool-catalog-nudge.ts +1 -1
- package/src/adapters/zed.ts +4 -2
- package/src/claude/chat-tool-dispatch.ts +4 -1
- package/src/claude/desktop-remote-store.ts +60 -10
- package/src/cli/account-api.ts +4 -0
- package/src/cli/account-auth.ts +30 -2
- package/src/cli/account-extended.ts +33 -2
- package/src/cli/capabilities-access-remote.ts +3 -3
- package/src/cli/capabilities-accounts.ts +3 -3
- package/src/cli/capabilities-base.ts +11 -6
- package/src/cli/capabilities-observe-system.ts +2 -2
- package/src/cli/claude.ts +3 -3
- package/src/cli/disconnect-runtime.ts +16 -6
- package/src/cli/dispatch.ts +7 -1
- package/src/cli/index.ts +2 -2
- package/src/cli/link-apply-restart.ts +4 -2
- package/src/cli/link-routes.ts +4 -1
- package/src/cli/link.ts +5 -4
- package/src/cli/logout-command.ts +23 -4
- package/src/cli/preflight-exemptions.ts +3 -0
- package/src/cli/provider.ts +3 -2
- package/src/cli/registry.ts +5 -2
- package/src/cli/resolve.ts +23 -8
- package/src/cli/restart-failure.ts +11 -1
- package/src/cli/runtime-api.ts +4 -0
- package/src/cli/status.ts +4 -1
- package/src/cli/system-command.ts +1 -1
- package/src/cli/system-restart-client.ts +9 -3
- package/src/cli/system-settings-parity.ts +2 -1
- package/src/client/connect.ts +73 -11
- package/src/client/desktop-refusal.ts +38 -0
- package/src/client/lifecycle-lock.ts +29 -4
- package/src/client/runtime-restart.ts +27 -15
- package/src/client/runtime.ts +4 -2
- package/src/client/state.ts +14 -0
- package/src/clients/config-export.ts +12 -7
- package/src/codex/account-lifecycle.ts +3 -1
- package/src/codex/account-pause.ts +4 -0
- package/src/codex/account-runtime-state.ts +4 -0
- package/src/codex/auth-api/main-account-probe.ts +3 -1
- package/src/codex/auth-api/main-hard-lock-refusal-read.ts +172 -0
- package/src/codex/auth-context.ts +40 -2
- package/src/codex/catalog/build-entries.ts +10 -0
- package/src/codex/catalog/derive-entry.ts +7 -0
- package/src/codex/catalog/metadata.ts +8 -0
- package/src/codex/catalog/native-models.ts +16 -6
- package/src/codex/catalog/pinned-models.ts +1 -0
- package/src/codex/catalog/provider-models.ts +5 -5
- package/src/codex/catalog/reserve-warn.ts +7 -5
- package/src/codex/catalog/reserve.ts +4 -3
- package/src/codex/catalog/retained-sync.ts +2 -0
- package/src/codex/catalog/routed-defaults.ts +35 -0
- package/src/codex/catalog-auto-refresh.ts +13 -2
- package/src/codex/config-drift-heal.ts +40 -12
- package/src/codex/config-write-lock.ts +39 -1
- package/src/codex/convergence.ts +2 -0
- package/src/codex/data/roster-pinned-models.json +346 -1
- package/src/codex/inject/config-write-section.ts +39 -1
- package/src/codex/inject/plan.ts +10 -8
- package/src/codex/inject/remove.ts +21 -19
- package/src/codex/inject/restore.ts +5 -1
- package/src/codex/inject-coordination.ts +58 -7
- package/src/codex/inject.ts +10 -12
- package/src/codex/journal-config-restore.ts +42 -0
- package/src/codex/journal.ts +62 -8
- package/src/codex/loopback-target.ts +22 -8
- package/src/codex/main-account.ts +94 -30
- package/src/codex/native-main-auth-file.ts +14 -0
- package/src/codex/native-main-credentials.ts +276 -0
- package/src/codex/native-main-owner.ts +3 -0
- package/src/codex/native-main-refresh-mode.ts +14 -1
- package/src/codex/quota.ts +63 -14
- package/src/combos/failover.ts +195 -1
- package/src/combos/index.ts +5 -0
- package/src/combos/resolve.ts +115 -19
- package/src/config/diagnostics.ts +3 -0
- package/src/config/live-reconcile.ts +6 -3
- package/src/config/load-degrade.ts +2 -0
- package/src/config/persisted-mutation.ts +2 -2
- package/src/config/persisted-projections.ts +18 -0
- package/src/config/process-state.ts +4 -3
- package/src/config/reserve-capability.ts +96 -0
- package/src/config/schema/config-schema.ts +6 -0
- package/src/config/schema/leaf-validators.ts +2 -0
- package/src/config/schema/routed-catalog-defaults.ts +49 -0
- package/src/config/subagent-models.ts +20 -12
- package/src/config.ts +7 -7
- package/src/desktop-update/acquire.ts +202 -0
- package/src/desktop-update/cli.ts +168 -0
- package/src/desktop-update/drain.ts +40 -0
- package/src/desktop-update/headless.ts +285 -0
- package/src/desktop-update/image.ts +85 -0
- package/src/desktop-update/install.ts +53 -0
- package/src/desktop-update/msi.ts +72 -0
- package/src/desktop-update/release.ts +128 -0
- package/src/desktop-update/runtime.ts +155 -0
- package/src/desktop-update/staging.ts +118 -0
- package/src/desktop-update/trust.ts +45 -0
- package/src/generated/compatibility-version.json +327 -195
- package/src/generated/model-metadata.ts +3 -3
- package/src/images/fulfill-video.ts +3 -3
- package/src/images/loop.ts +6 -2
- package/src/images/plan.ts +147 -11
- package/src/images/types.ts +13 -4
- package/src/images/xai-video-client.ts +72 -10
- package/src/lib/client-error-body.ts +6 -0
- package/src/lib/developer-role-rejection.ts +15 -0
- package/src/lib/gcp-adc.ts +48 -4
- package/src/lib/offline-resend.ts +150 -0
- package/src/lib/paced-stream.ts +3 -3
- package/src/lib/provider-outbound.ts +17 -6
- package/src/lib/request-failure-model.ts +2 -0
- package/src/lib/response-body-inactivity.ts +23 -1
- package/src/lib/upstream-retry.ts +39 -6
- package/src/link/explicit-route.ts +4 -4
- package/src/link/remote-windows.ts +79 -31
- package/src/link/residual-recovery.ts +20 -8
- package/src/messaging/budget.ts +23 -5
- package/src/messaging/remote-ports.ts +22 -10
- package/src/messaging/rpc.ts +4 -4
- package/src/oauth/antigravity-risk.ts +126 -0
- package/src/oauth/credential-siblings.ts +32 -0
- package/src/oauth/generic-account-failover.ts +113 -30
- package/src/oauth/generic-session-affinity.ts +10 -3
- package/src/oauth/index.ts +22 -14
- package/src/oauth/login-cli.ts +35 -1
- package/src/oauth/pool-kernel.ts +3 -3
- package/src/oauth/store.ts +38 -7
- package/src/providers/anthropic-billing-refusal.ts +27 -3
- package/src/providers/anthropic-reset-grants.ts +4 -0
- package/src/providers/claude-cli-usage.ts +2 -0
- package/src/providers/codebuddy-models.ts +11 -0
- package/src/providers/google-vertex-model-discovery.ts +49 -15
- package/src/providers/kiro-models.ts +5 -0
- package/src/providers/model-rename-fields.ts +2 -0
- package/src/providers/quota/workbuddy.ts +6 -2
- package/src/providers/registry/entries-core.ts +9 -3
- package/src/providers/registry/entries-extended.ts +20 -9
- package/src/providers/registry/model-seeds.ts +4 -1
- package/src/providers/stale-context-window-migration.ts +2 -0
- package/src/providers/workbuddy-credit-balance.ts +125 -16
- package/src/responses/citation-markers.ts +26 -23
- package/src/responses/effort-history.ts +732 -0
- package/src/routing/history/integrity.ts +41 -4
- package/src/server/auth-cors.ts +13 -3
- package/src/server/codex-model-list.ts +2 -1
- package/src/server/direct-local-http.ts +26 -3
- package/src/server/index/link-listener.ts +20 -14
- package/src/server/index/serve-options.ts +1 -0
- package/src/server/index.ts +3 -2
- package/src/server/link-turn.ts +17 -5
- package/src/server/management/config-routes.ts +39 -3
- package/src/server/management/link-child-preflight.ts +1 -1
- package/src/server/management/link-enrollment.ts +3 -3
- package/src/server/management/link-route-edit.ts +20 -1
- package/src/server/management/link-route-request.ts +11 -5
- package/src/server/management/oauth-account-routes.ts +43 -13
- package/src/server/management/provider-credential-release.ts +44 -0
- package/src/server/management/provider-overwrite-carry.ts +3 -0
- package/src/server/management/provider-routes.ts +12 -12
- package/src/server/management/static-catalog-probe.ts +33 -0
- package/src/server/management/usage-aggregate-cache.ts +6 -3
- package/src/server/messages-native.ts +16 -2
- package/src/server/proxy-liveness.ts +54 -9
- package/src/server/relay.ts +6 -1
- package/src/server/request-log-conversation.ts +8 -4
- package/src/server/request-log-failure-detail.ts +26 -9
- package/src/server/request-log.ts +5 -1
- package/src/server/reserve-capability-startup.ts +32 -0
- package/src/server/responses/adapter-continuation.ts +59 -25
- package/src/server/responses/adapter-delivery.ts +2 -0
- package/src/server/responses/adapter-dispatch.ts +39 -18
- package/src/server/responses/antigravity-fault-rotation.ts +24 -0
- package/src/server/responses/antigravity-validation-refusal.ts +43 -6
- package/src/server/responses/codex-tool-catalog.ts +47 -10
- package/src/server/responses/combo-selection-keepalive.ts +254 -0
- package/src/server/responses/combo-session-recall.ts +26 -1
- package/src/server/responses/combo-stream-preflight.ts +35 -26
- package/src/server/responses/core-combo-failure.ts +6 -0
- package/src/server/responses/core-combo-native.ts +2 -1
- package/src/server/responses/core-combo.ts +67 -28
- package/src/server/responses/core-errors.ts +9 -6
- package/src/server/responses/core-options.ts +10 -0
- package/src/server/responses/core.ts +21 -0
- package/src/server/responses/estimated-usage.ts +115 -0
- package/src/server/responses/input-admission.ts +41 -3
- package/src/server/responses/jev-model-invoke.ts +7 -2
- package/src/server/responses/passthrough-completion.ts +6 -3
- package/src/server/responses/passthrough-delivery.ts +47 -8
- package/src/server/responses/passthrough-dispatch.ts +3 -0
- package/src/server/responses/request-prepare.ts +9 -5
- package/src/server/responses/request-send-budget.ts +1 -1
- package/src/server/responses/request-transport.ts +10 -2
- package/src/server/responses/sidecar-execution.ts +11 -4
- package/src/service/desktop-supervision.d.mts +2 -0
- package/src/service/desktop-supervision.mjs +5 -0
- package/src/service/windows-checked-stop-live.ts +28 -5
- package/src/stall-timeout.ts +11 -0
- package/src/types/config.ts +15 -92
- package/src/types/provider.ts +13 -0
- package/src/types/request.ts +23 -3
- package/src/types/routed-catalog-defaults.ts +17 -0
- package/src/types/routing-profile.ts +90 -0
- package/src/types.ts +1 -0
- package/src/update/index.ts +1 -1
- package/src/usage/expected-prices.ts +35 -0
- package/src/usage/ledger-scanner.ts +44 -10
- package/src/usage/log.ts +14 -4
- package/src/usage/telemetry-contract.ts +1 -0
- package/src/web-search/loop.ts +20 -2
- package/src/web-search/parse.ts +2 -12
- package/src/web-search/passthrough-bridge.ts +7 -0
- package/src/web-search/sources.ts +13 -0
- package/gui/dist/assets/brand-mark-XOLJbomA.js +0 -1
- package/gui/dist/assets/index-DQtCRNAw.css +0 -2
- package/gui/dist/classic/assets/quota-summary-Dy5_wfTT.js +0 -1
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Replacing the runtime that still serves an old version after a Desktop MSI install (#8246).
|
|
3
|
+
*
|
|
4
|
+
* Windows Installer replaces `ocx.exe` on disk but leaves running processes alone, so the old
|
|
5
|
+
* runtime keeps answering /healthz with its old version. This module only ever acts on a runtime
|
|
6
|
+
* this home attests (its runtime record and per-process secret) whose image is the installed
|
|
7
|
+
* `ocx.exe` being updated. It asks that runtime for its own bound in-place restart, the same
|
|
8
|
+
* owner-aware path `ocx restart` uses: a Desktop-supervised child hands its replacement to the
|
|
9
|
+
* Desktop app (which starts the sibling `ocx.exe`), a service child exits for its manager, and a
|
|
10
|
+
* detached runtime relaunches its own image. All three now run the installed bytes.
|
|
11
|
+
*
|
|
12
|
+
* A connected-client runtime under the Desktop app refuses that restart (409
|
|
13
|
+
* `restart_supervised_desktop`): it keeps itself until its owner replaces it. When the Desktop
|
|
14
|
+
* supervision probe proves this installation's app is the parent of exactly that pid, the runtime
|
|
15
|
+
* is drained with the installed `ocx stop --json`, the same stop the app's own updater drain runs,
|
|
16
|
+
* and the app's supervisor starts its sibling `ocx.exe` again after its backoff.
|
|
17
|
+
*
|
|
18
|
+
* Success is a different process answering with the target version; anything else is reported,
|
|
19
|
+
* never assumed. A runtime from another installation, an unattested one, or a newer one is not
|
|
20
|
+
* touched.
|
|
21
|
+
*/
|
|
22
|
+
import { win32 } from "node:path";
|
|
23
|
+
import type { LiveProxy } from "../server/proxy-liveness";
|
|
24
|
+
import type { ProxyRestartRequestOutcome } from "../cli/tray-proxy";
|
|
25
|
+
import { computeVersionSkew } from "../cli/version-skew";
|
|
26
|
+
|
|
27
|
+
export interface RuntimeReplaceDeps {
|
|
28
|
+
findLive(): Promise<LiveProxy | null>;
|
|
29
|
+
/** Drive-qualified image path of the process, or null when it cannot be read. */
|
|
30
|
+
runtimeImage(pid: number): string | null;
|
|
31
|
+
requestRestart(live: LiveProxy & { pid: number }, targetVersion: string): Promise<ProxyRestartRequestOutcome>;
|
|
32
|
+
/** The Desktop app image proven to supervise exactly this runtime pid, or null. */
|
|
33
|
+
desktopSupervisor(pid: number): string | null;
|
|
34
|
+
/** Drain the runtime with the installed CLI's `ocx stop --json`; ok only for a confirmed stop. */
|
|
35
|
+
drainRuntime(): Promise<{ ok: boolean; detail?: string }>;
|
|
36
|
+
/** Restart this installation's background service with the installed `ocx service restart`. */
|
|
37
|
+
restartService(): Promise<{ ok: boolean; detail?: string }>;
|
|
38
|
+
now(): number;
|
|
39
|
+
wait(ms: number): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type StaleRuntimeReason =
|
|
43
|
+
| "unknown-version"
|
|
44
|
+
| "runtime-newer"
|
|
45
|
+
| "incomparable"
|
|
46
|
+
| "unattested"
|
|
47
|
+
| "foreign-image"
|
|
48
|
+
| "restart-refused"
|
|
49
|
+
| "drain-failed"
|
|
50
|
+
| "service-restart-failed"
|
|
51
|
+
| "replacement-timeout";
|
|
52
|
+
|
|
53
|
+
export type RuntimeOutcome =
|
|
54
|
+
| { kind: "serving-target"; live: LiveProxy; replaced: boolean }
|
|
55
|
+
| { kind: "not-running" }
|
|
56
|
+
| { kind: "stale"; live: LiveProxy | null; reason: StaleRuntimeReason; detail?: string };
|
|
57
|
+
|
|
58
|
+
export const RUNTIME_OBSERVE_INTERVAL_MS = 250;
|
|
59
|
+
|
|
60
|
+
/** Windows paths compare case-insensitively and with either separator. */
|
|
61
|
+
export function sameWindowsPath(left: string, right: string): boolean {
|
|
62
|
+
const normalize = (path: string) => path.replaceAll("/", "\\").replace(/\\+$/, "").toLowerCase();
|
|
63
|
+
return normalize(left) === normalize(right);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Name the updater gives the running `ocx.exe` it moves aside before Windows Installer runs. */
|
|
67
|
+
export const MOVED_IMAGE_PATTERN = /^ocx\.exe\.\d+-\d+\.update-old$/i;
|
|
68
|
+
|
|
69
|
+
export function movedImageName(pid: number, at: number): string {
|
|
70
|
+
return `ocx.exe.${pid}-${at}.update-old`;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The installed executable, or a previous image of it that this updater moved aside in the same
|
|
75
|
+
* directory: Windows may report a running process under the name its image file has now.
|
|
76
|
+
*/
|
|
77
|
+
export function isInstalledImage(image: string, installedExe: string): boolean {
|
|
78
|
+
if (sameWindowsPath(image, installedExe)) return true;
|
|
79
|
+
const normalized = image.replaceAll("/", "\\");
|
|
80
|
+
return sameWindowsPath(win32.dirname(normalized), win32.dirname(installedExe)) && MOVED_IMAGE_PATTERN.test(win32.basename(normalized));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Make the serving runtime the installed version.
|
|
85
|
+
*
|
|
86
|
+
* `wasRunning` says whether a runtime answered before the install; without one this never starts
|
|
87
|
+
* a runtime just to prove the update, and reports `not-running` instead.
|
|
88
|
+
*/
|
|
89
|
+
export async function settleRuntime(
|
|
90
|
+
input: { installedExe: string; targetVersion: string; deadlineAt: number; wasRunning: boolean; expectedPort?: number },
|
|
91
|
+
deps: RuntimeReplaceDeps,
|
|
92
|
+
): Promise<RuntimeOutcome> {
|
|
93
|
+
const found = await deps.findLive();
|
|
94
|
+
// Only this home's attested runtime record identifies the runtime this installation serves; a
|
|
95
|
+
// proxy found on the configured port without it may belong to another home.
|
|
96
|
+
const live = found && found.source === "runtime" && found.pid !== null ? found : null;
|
|
97
|
+
if (!live) {
|
|
98
|
+
if (input.wasRunning && input.expectedPort !== undefined) return observe(input, deps, null, input.expectedPort);
|
|
99
|
+
if (!found || found.version === input.targetVersion) return { kind: "not-running" };
|
|
100
|
+
return { kind: "stale", live: found, reason: "unattested" };
|
|
101
|
+
}
|
|
102
|
+
if (live.version === input.targetVersion) return { kind: "serving-target", live, replaced: false };
|
|
103
|
+
if (!live.version) return { kind: "stale", live, reason: "unknown-version" };
|
|
104
|
+
const relation = computeVersionSkew(input.targetVersion, live.version).relation;
|
|
105
|
+
if (relation === "proxy-newer") return { kind: "stale", live, reason: "runtime-newer" };
|
|
106
|
+
if (relation !== "cli-newer") return { kind: "stale", live, reason: "incomparable" };
|
|
107
|
+
const pid = live.pid!;
|
|
108
|
+
let image: string | null;
|
|
109
|
+
try { image = deps.runtimeImage(pid); } catch { image = null; }
|
|
110
|
+
if (!image || !isInstalledImage(image, input.installedExe)) {
|
|
111
|
+
return { kind: "stale", live, reason: "foreign-image", ...(image ? { detail: image } : {}) };
|
|
112
|
+
}
|
|
113
|
+
const request = await deps.requestRestart({ ...live, pid }, input.targetVersion);
|
|
114
|
+
if (!request.accepted && !request.uncertain) {
|
|
115
|
+
const detail = request.error instanceof Error ? request.error.message : undefined;
|
|
116
|
+
if (detail === "restart_supervised_service") {
|
|
117
|
+
// The runtime's own image is this installation's, so its service runs the installed bytes;
|
|
118
|
+
// `ocx service restart` is the owner path the refusal names.
|
|
119
|
+
const restarted = await deps.restartService();
|
|
120
|
+
if (!restarted.ok) return { kind: "stale", live, reason: "service-restart-failed", ...(restarted.detail ? { detail: restarted.detail } : {}) };
|
|
121
|
+
return observe(input, deps, pid, live.port);
|
|
122
|
+
}
|
|
123
|
+
if (detail === "restart_supervised_desktop") {
|
|
124
|
+
let app: string | null;
|
|
125
|
+
try { app = deps.desktopSupervisor(pid); } catch { app = null; }
|
|
126
|
+
if (app && sameWindowsPath(win32.dirname(app), win32.dirname(input.installedExe))) {
|
|
127
|
+
const drained = await deps.drainRuntime();
|
|
128
|
+
if (!drained.ok) return { kind: "stale", live, reason: "drain-failed", ...(drained.detail ? { detail: drained.detail } : {}) };
|
|
129
|
+
return observe(input, deps, pid, live.port);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return { kind: "stale", live, reason: "restart-refused", ...(detail ? { detail } : {}) };
|
|
133
|
+
}
|
|
134
|
+
// An uncertain answer may still have been accepted: observe instead of asking twice.
|
|
135
|
+
return observe(input, deps, pid, live.port);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async function observe(
|
|
139
|
+
input: { targetVersion: string; deadlineAt: number },
|
|
140
|
+
deps: RuntimeReplaceDeps,
|
|
141
|
+
oldPid: number | null,
|
|
142
|
+
port: number,
|
|
143
|
+
): Promise<RuntimeOutcome> {
|
|
144
|
+
let last: LiveProxy | null = null;
|
|
145
|
+
while (deps.now() < input.deadlineAt) {
|
|
146
|
+
last = await deps.findLive();
|
|
147
|
+
// Bound to the replaced runtime: this home's attested record, on the same port, with a new pid.
|
|
148
|
+
if (last && last.source === "runtime" && last.port === port && last.version === input.targetVersion
|
|
149
|
+
&& last.pid !== null && last.pid !== oldPid) {
|
|
150
|
+
return { kind: "serving-target", live: last, replaced: true };
|
|
151
|
+
}
|
|
152
|
+
await deps.wait(Math.max(0, Math.min(RUNTIME_OBSERVE_INTERVAL_MS, input.deadlineAt - deps.now())));
|
|
153
|
+
}
|
|
154
|
+
return { kind: "stale", live: last, reason: "replacement-timeout" };
|
|
155
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where `ocx update --desktop` stages the verified MSI and the installer log (#8246).
|
|
3
|
+
*
|
|
4
|
+
* msiexec opens the package by path after this process has verified it. When the command runs
|
|
5
|
+
* elevated, a directory in the user's TEMP would let any non-elevated process of the same user
|
|
6
|
+
* swap the package, plant a link at the log path, or move the directory away between that
|
|
7
|
+
* verification and msiexec opening the file, and the elevated installer would act on the
|
|
8
|
+
* substitute. So an elevated run stages under the Windows directory's Temp, in a fresh directory
|
|
9
|
+
* created with a protected security descriptor that lets only SYSTEM and Administrators write.
|
|
10
|
+
* Non-elevated processes may create entries in that Temp but cannot delete or rename another
|
|
11
|
+
* account's, and cannot write inside this one. A run that is not elevated keeps its own TEMP: its
|
|
12
|
+
* msiexec has no more rights than a process that could change the file there.
|
|
13
|
+
*/
|
|
14
|
+
import { mkdtempSync } from "node:fs";
|
|
15
|
+
import { randomBytes } from "node:crypto";
|
|
16
|
+
import { tmpdir } from "node:os";
|
|
17
|
+
import { join, win32 } from "node:path";
|
|
18
|
+
import { dlopen, ptr } from "bun:ffi";
|
|
19
|
+
import { trustedWindowsSystemDirectory } from "../service/desktop-supervision.mjs";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Protected (no inherited entries); full access for SYSTEM and Administrators, inherited by the
|
|
23
|
+
* files inside; the owner's implicit right to rewrite the descriptor reduced to reading it.
|
|
24
|
+
*/
|
|
25
|
+
export const PROTECTED_STAGING_SDDL = "D:P(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)(A;OICI;RC;;;OW)";
|
|
26
|
+
export const STAGING_PREFIX = "ocx-desktop-update-";
|
|
27
|
+
|
|
28
|
+
export interface StagingDirectoryDeps {
|
|
29
|
+
/** Whether this process runs with an elevated token; a throw counts as elevated. */
|
|
30
|
+
elevated(): boolean;
|
|
31
|
+
windowsDirectory(): string;
|
|
32
|
+
/** Create a new directory with this descriptor; throws when the path already exists. */
|
|
33
|
+
createProtectedDirectory(path: string, sddl: string): void;
|
|
34
|
+
createPrivateTempDirectory(): string;
|
|
35
|
+
randomSuffix(): string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function createStagingDirectory(deps: StagingDirectoryDeps): string {
|
|
39
|
+
let elevated = true;
|
|
40
|
+
try { elevated = deps.elevated(); } catch { /* unknown: stage as if elevated */ }
|
|
41
|
+
if (!elevated) return deps.createPrivateTempDirectory();
|
|
42
|
+
const path = win32.join(deps.windowsDirectory(), "Temp", `${STAGING_PREFIX}${deps.randomSuffix()}`);
|
|
43
|
+
deps.createProtectedDirectory(path, PROTECTED_STAGING_SDDL);
|
|
44
|
+
return path;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const TOKEN_QUERY = 0x0008;
|
|
48
|
+
const TOKEN_ELEVATION_CLASS = 20;
|
|
49
|
+
const SDDL_REVISION_1 = 1;
|
|
50
|
+
|
|
51
|
+
function loadSystemLibraries<A extends Parameters<typeof dlopen>[1], K extends Parameters<typeof dlopen>[1]>(advapiSymbols: A, kernelSymbols: K) {
|
|
52
|
+
const directory = trustedWindowsSystemDirectory();
|
|
53
|
+
const advapi = dlopen(win32.join(directory, "advapi32.dll"), advapiSymbols);
|
|
54
|
+
try {
|
|
55
|
+
const kernel = dlopen(win32.join(directory, "kernel32.dll"), kernelSymbols);
|
|
56
|
+
return { advapi, kernel, close: () => { kernel.close(); advapi.close(); } };
|
|
57
|
+
} catch (error) {
|
|
58
|
+
advapi.close();
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function processIsElevated(): boolean {
|
|
64
|
+
const lib = loadSystemLibraries({
|
|
65
|
+
OpenProcessToken: { args: ["u64", "u32", "ptr"], returns: "i32" },
|
|
66
|
+
GetTokenInformation: { args: ["u64", "u32", "ptr", "u32", "ptr"], returns: "i32" },
|
|
67
|
+
}, {
|
|
68
|
+
GetCurrentProcess: { args: [], returns: "u64" },
|
|
69
|
+
CloseHandle: { args: ["u64"], returns: "i32" },
|
|
70
|
+
});
|
|
71
|
+
try {
|
|
72
|
+
const token = new BigUint64Array(1);
|
|
73
|
+
if (!lib.advapi.symbols.OpenProcessToken(lib.kernel.symbols.GetCurrentProcess(), TOKEN_QUERY, ptr(token))) throw new Error("OpenProcessToken failed");
|
|
74
|
+
try {
|
|
75
|
+
const elevation = new Uint32Array(1);
|
|
76
|
+
const length = new Uint32Array(1);
|
|
77
|
+
if (!lib.advapi.symbols.GetTokenInformation(token[0]!, TOKEN_ELEVATION_CLASS, ptr(elevation), 4, ptr(length))) throw new Error("GetTokenInformation failed");
|
|
78
|
+
return elevation[0] !== 0;
|
|
79
|
+
} finally { lib.kernel.symbols.CloseHandle(token[0]!); }
|
|
80
|
+
} finally { lib.close(); }
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function createProtectedDirectoryWin32(path: string, sddl: string): void {
|
|
84
|
+
const lib = loadSystemLibraries({
|
|
85
|
+
ConvertStringSecurityDescriptorToSecurityDescriptorW: { args: ["ptr", "u32", "ptr", "ptr"], returns: "i32" },
|
|
86
|
+
}, {
|
|
87
|
+
CreateDirectoryW: { args: ["ptr", "ptr"], returns: "i32" },
|
|
88
|
+
LocalFree: { args: ["u64"], returns: "u64" },
|
|
89
|
+
GetLastError: { args: [], returns: "u32" },
|
|
90
|
+
});
|
|
91
|
+
try {
|
|
92
|
+
const descriptor = new BigUint64Array(1);
|
|
93
|
+
const text = Buffer.from(`${sddl}\0`, "utf16le");
|
|
94
|
+
if (!lib.advapi.symbols.ConvertStringSecurityDescriptorToSecurityDescriptorW(ptr(text), SDDL_REVISION_1, ptr(descriptor), null)) {
|
|
95
|
+
throw new Error(`the staging security descriptor was rejected (Windows error ${lib.kernel.symbols.GetLastError()})`);
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
// SECURITY_ATTRIBUTES on x64: DWORD nLength, (pad), LPVOID lpSecurityDescriptor, BOOL bInheritHandle, (pad).
|
|
99
|
+
const attributes = Buffer.alloc(24);
|
|
100
|
+
attributes.writeUInt32LE(24, 0);
|
|
101
|
+
attributes.writeBigUInt64LE(descriptor[0]!, 8);
|
|
102
|
+
attributes.writeInt32LE(0, 16);
|
|
103
|
+
const wide = Buffer.from(`${path}\0`, "utf16le");
|
|
104
|
+
if (!lib.kernel.symbols.CreateDirectoryW(ptr(wide), ptr(attributes))) {
|
|
105
|
+
throw new Error(`could not create the protected staging directory ${path} (Windows error ${lib.kernel.symbols.GetLastError()})`);
|
|
106
|
+
}
|
|
107
|
+
} finally { lib.kernel.symbols.LocalFree(descriptor[0]!); }
|
|
108
|
+
} finally { lib.close(); }
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export const windowsStagingDeps: StagingDirectoryDeps = {
|
|
112
|
+
elevated: processIsElevated,
|
|
113
|
+
windowsDirectory: () => win32.dirname(trustedWindowsSystemDirectory()),
|
|
114
|
+
createProtectedDirectory: createProtectedDirectoryWin32,
|
|
115
|
+
createPrivateTempDirectory: () => mkdtempSync(join(tmpdir(), STAGING_PREFIX)),
|
|
116
|
+
randomSuffix: () => randomBytes(16).toString("hex"),
|
|
117
|
+
};
|
|
118
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trust and transport constants for the headless Windows Desktop updater (#8246).
|
|
3
|
+
*
|
|
4
|
+
* The public key and feed are the ones the Desktop GUI updater embeds in
|
|
5
|
+
* `desktop/src-tauri/tauri.conf.json` (`plugins.updater`). They are restated here because a
|
|
6
|
+
* compiled `ocx.exe` cannot read the Tauri configuration at run time;
|
|
7
|
+
* `tests/update/update-desktop-headless-release.test.ts` fails if either copy drifts, so the headless path
|
|
8
|
+
* can never verify with a key the GUI would not use.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** Base64 of the minisign public-key box; byte-identical to `plugins.updater.pubkey`. */
|
|
12
|
+
export const DESKTOP_UPDATER_PUBKEY =
|
|
13
|
+
"dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEFDNzZCMDg0NkVCRUJGODEKUldTQnY3NXVoTEIyckhRUXJMOXJRUDR0aHQ2L3pLVHVweXFSc1lzS24vWDNiSUJ5MXJIZmpyb2sK";
|
|
14
|
+
|
|
15
|
+
/** The published channel the GUI updater checks; identical to `plugins.updater.endpoints[0]`. */
|
|
16
|
+
export const DESKTOP_UPDATE_FEED_URL = "https://github.com/lidge-jun/opencodex/releases/latest/download/latest.json";
|
|
17
|
+
|
|
18
|
+
/** Every request starts on this exact release source. */
|
|
19
|
+
export const DESKTOP_RELEASE_ORIGIN = "https://github.com";
|
|
20
|
+
export const DESKTOP_RELEASE_PATH_PREFIX = "/lidge-jun/opencodex/releases/";
|
|
21
|
+
|
|
22
|
+
/** Redirect targets GitHub uses for release assets. Anything else is refused, never widened. */
|
|
23
|
+
export const DESKTOP_REDIRECT_HOSTS: readonly string[] = Object.freeze([
|
|
24
|
+
"github.com",
|
|
25
|
+
"release-assets.githubusercontent.com",
|
|
26
|
+
"objects.githubusercontent.com",
|
|
27
|
+
]);
|
|
28
|
+
|
|
29
|
+
/** The latest.json platform key the Windows x64 MSI is published under. */
|
|
30
|
+
export const DESKTOP_WINDOWS_PLATFORM = "windows-x86_64";
|
|
31
|
+
|
|
32
|
+
export const DESKTOP_ACQUIRE_LIMITS = Object.freeze({
|
|
33
|
+
maxRedirects: 3,
|
|
34
|
+
/** Implementation maximum for the installer; a Content-Length header is advisory only. */
|
|
35
|
+
maxArtifactBytes: 1024 * 1024 * 1024,
|
|
36
|
+
maxFeedBytes: 256 * 1024,
|
|
37
|
+
connectMs: 10_000,
|
|
38
|
+
idleReadMs: 30_000,
|
|
39
|
+
totalMs: 20 * 60_000,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
/** Exact asset URL a verified release record must name for this version. */
|
|
43
|
+
export function desktopInstallerUrl(version: string): string {
|
|
44
|
+
return `${DESKTOP_RELEASE_ORIGIN}${DESKTOP_RELEASE_PATH_PREFIX}download/v${version}/OpenCodex-${version}-windows-x64.msi`;
|
|
45
|
+
}
|