@bitkyc08/opencodex 2.92.0 → 2.93.0-preview.20261027
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/bin/ocx.mjs +10 -5
- package/gui/dist/assets/App-CJZoq-uF.js +58 -0
- package/gui/dist/assets/{Tray-BSsxznDm.js → Tray-BWQPcgZn.js} +1 -1
- package/gui/dist/assets/index-DRe8Hhfz.css +1 -0
- package/gui/dist/assets/{index-BlFE_VB_.js → index-Xfct8owH.js} +12 -12
- package/gui/dist/assets/{quota-summary-BRlbXgw0.js → quota-summary-DxToX1rV.js} +1 -1
- package/gui/dist/index.html +2 -2
- package/package.json +5 -5
- package/src/adapters/anthropic.ts +28 -5
- package/src/adapters/coding-agent/batch-dispatcher.ts +122 -0
- package/src/adapters/coding-agent/profile.ts +54 -16
- package/src/adapters/coding-agent/turn.ts +30 -2
- package/src/adapters/command-code.ts +114 -7
- package/src/adapters/cursor/native-exec-fs.ts +11 -9
- package/src/adapters/devin/live-models.ts +4 -0
- package/src/adapters/google-wire-compiler.ts +1 -2
- package/src/adapters/kiro/reasoning.ts +2 -0
- package/src/adapters/kiro-refusal.ts +6 -1
- package/src/adapters/kiro-wire.ts +1 -1
- package/src/adapters/openai-chat/messages.ts +8 -2
- package/src/adapters/openai-chat/passthrough.ts +35 -14
- package/src/adapters/openai-chat/reasoning-replay.ts +27 -16
- package/src/adapters/openai-chat/reasoning-wire.ts +117 -8
- package/src/adapters/openai-chat/required-tool-result.ts +64 -0
- package/src/adapters/openai-chat.ts +7 -8
- package/src/adapters/openai-responses/passthrough.ts +7 -4
- package/src/adapters/openai-responses/reasoning.ts +13 -0
- package/src/adapters/openai-responses/request-strips.ts +1 -1
- package/src/adapters/qoder/adapter.ts +129 -8
- package/src/adapters/qoder/scaffold-guard.ts +5 -0
- package/src/adapters/reasoning-controls.ts +16 -0
- package/src/adapters/tool-call-id.ts +1 -3
- package/src/bridge/errors.ts +27 -0
- package/src/bridge.ts +1 -1
- package/src/chat/inbound.ts +4 -1
- package/src/chat/outbound.ts +9 -2
- package/src/chat/reasoning-details.ts +28 -5
- package/src/claude/desktop-first-party.ts +54 -4
- package/src/claude/desktop-picker.ts +11 -8
- package/src/claude/first-party-settings.ts +3 -1
- package/src/claude/inbound.ts +2 -1
- package/src/claude/intercept/local-ca.ts +2 -1
- package/src/claude/intercept/picker-ca-cleanup.ts +4 -2
- package/src/claude/intercept/picker-ca-startup.ts +3 -1
- package/src/claude/intercept/picker-models.ts +6 -3
- package/src/claude/intercept/picker-runtime.ts +3 -2
- package/src/claude/intercept/runtime.ts +6 -3
- package/src/claude/model-info.ts +31 -8
- package/src/cli/account-api.ts +11 -0
- package/src/cli/capabilities-agents-routing.ts +2 -2
- package/src/cli/capabilities-base.ts +7 -1
- package/src/cli/capabilities-observe-system.ts +10 -0
- package/src/cli/claude-desktop.ts +9 -8
- package/src/cli/claude.ts +3 -2
- package/src/cli/codex-shim-autorestore.ts +9 -0
- package/src/cli/combo-result.ts +7 -0
- package/src/cli/combo.ts +18 -0
- package/src/cli/cross-home-owner.ts +13 -1
- package/src/cli/dispatch.ts +25 -6
- package/src/cli/ensure-desired-integrations.ts +8 -6
- package/src/cli/export-command.ts +4 -1
- package/src/cli/help.ts +2 -1
- package/src/cli/index.ts +45 -45
- package/src/cli/integration-plan-dto.ts +4 -0
- package/src/cli/opencode.ts +20 -9
- package/src/cli/registry.ts +6 -4
- package/src/cli/root.ts +9 -0
- package/src/cli/status.ts +59 -1
- package/src/cli/stop-restore.ts +113 -0
- package/src/cli/sync-expectation.ts +60 -0
- package/src/cli/uninstall-integrations.ts +41 -7
- package/src/client/connect.ts +40 -3
- package/src/client/link-home.ts +10 -1
- package/src/client/machine-api.ts +3 -1
- package/src/client/sync-expectation.ts +118 -0
- package/src/clients/config-export/agent-clients.ts +96 -0
- package/src/clients/config-export/contracts.ts +25 -7
- package/src/clients/config-export/qoder.ts +38 -23
- package/src/clients/config-export/reasoning-metadata.ts +55 -8
- package/src/clients/config-export.ts +12 -0
- package/src/clients/lazycodex.ts +7 -2
- package/src/clients/reasoning-controls.ts +49 -0
- package/src/codex/auth-api/account-identity.ts +14 -0
- package/src/codex/auth-api/account-list.ts +29 -2
- package/src/codex/auth-api/http.ts +13 -0
- package/src/codex/auth-api/main-account-probe.ts +2 -2
- package/src/codex/auth-api/pool-mode-gate.ts +16 -3
- package/src/codex/auth-api/pool-quota-probe.ts +15 -0
- package/src/codex/auth-context.ts +15 -12
- package/src/codex/catalog/build-entries.ts +22 -0
- package/src/codex/catalog/configured-tiers.ts +70 -0
- package/src/codex/catalog/effort.ts +44 -10
- package/src/codex/catalog/gather-capture.ts +1 -0
- package/src/codex/catalog/heal-observation.ts +155 -13
- package/src/codex/catalog/metadata.ts +6 -0
- package/src/codex/catalog/model-hints.ts +60 -11
- package/src/codex/catalog/model-visibility.ts +3 -2
- package/src/codex/catalog/native-models.ts +18 -3
- package/src/codex/catalog/parsing.ts +10 -8
- package/src/codex/catalog/pinned-models.ts +2 -1
- package/src/codex/catalog/provider-models.ts +4 -5
- package/src/codex/catalog/retained-sync.ts +2 -1
- package/src/codex/catalog/routed-gather.ts +19 -20
- package/src/codex/catalog/write-audit.ts +3 -2
- package/src/codex/catalog-self-heal.ts +43 -23
- package/src/codex/collision-identity.ts +30 -5
- package/src/codex/convergence.ts +4 -3
- package/src/codex/data/roster-pinned-models.json +177 -1
- package/src/codex/desired-state.ts +6 -1
- package/src/codex/desktop-compatibility/installed-build.ts +88 -12
- package/src/codex/desktop-compatibility/runtime.ts +29 -5
- package/src/codex/desktop-compatibility/usage-controller.ts +2 -0
- package/src/codex/desktop-compatibility/windows-certificate-trust.ts +46 -12
- package/src/codex/inject/config-toml.ts +0 -18
- package/src/codex/inject/plan.ts +18 -3
- package/src/codex/inject/remove.ts +6 -2
- package/src/codex/inject.ts +1 -1
- package/src/codex/journal.ts +61 -1
- package/src/codex/model-entitlements.ts +1 -1
- package/src/codex/native-main-owner.ts +27 -1
- package/src/codex/native-profile-store.ts +2 -1
- package/src/codex/pool-credit-policy.ts +35 -1
- package/src/codex/quota-types.ts +3 -0
- package/src/codex/quota.ts +24 -4
- package/src/codex/role-auto-assign.ts +6 -2
- package/src/codex/subagent-defaults.ts +49 -4
- package/src/combos/failover.ts +17 -2
- package/src/combos/jev-decision-contract.ts +22 -1
- package/src/combos/jev-service-exchange.ts +3 -1
- package/src/combos/jev.ts +95 -9
- package/src/combos/resolve.ts +45 -1
- package/src/combos/types.ts +24 -0
- package/src/config/load-degrade.ts +5 -0
- package/src/config/paths.ts +19 -3
- package/src/config/pending-teardown.ts +22 -1
- package/src/config/provider-validation.ts +15 -4
- package/src/config/removed-opencode-free.ts +11 -0
- package/src/config/schema/leaf-validators.ts +5 -0
- package/src/generated/compatibility-version.json +314 -230
- package/src/generated/model-metadata.ts +5 -5
- package/src/images/loop.ts +16 -2
- package/src/integrations/catalog-refresh.ts +1 -1
- package/src/integrations/hermes-profiles.ts +251 -0
- package/src/integrations/merge.ts +8 -0
- package/src/integrations/mutation-plan.ts +19 -4
- package/src/integrations/registry.ts +5 -0
- package/src/integrations/state.ts +36 -1
- package/src/integrations/writer.ts +18 -4
- package/src/lib/bun-path-runtime.mjs +2 -1
- package/src/lib/errors.ts +62 -0
- package/src/lib/eventstream-decoder.ts +81 -37
- package/src/lib/opaque-proxy-tunnel.ts +32 -8
- package/src/lib/pinned-http.ts +35 -2
- package/src/lib/process-control.ts +13 -1
- package/src/lib/socks5-fetch.ts +59 -64
- package/src/lib/socks5-upload-waiter.ts +50 -0
- package/src/lib/sse-decoder.ts +7 -2
- package/src/lib/state-store-sweeper.ts +40 -14
- package/src/lib/windows-native-principal-worker.ts +14 -0
- package/src/lib/windows-native-principal.ts +188 -0
- package/src/lib/windows-secret-acl.ts +39 -3
- package/src/lib/windows-user-principal.ts +62 -18
- package/src/link/ssh-config.ts +35 -3
- package/src/providers/account-quota-disk.ts +12 -4
- package/src/providers/codebuddy-models.ts +6 -0
- package/src/providers/codex-capacity.ts +3 -1
- package/src/providers/derive.ts +28 -0
- package/src/providers/kiro-models.ts +3 -0
- package/src/providers/mimo-thinking.ts +12 -0
- package/src/providers/model-rename-fields.ts +1 -0
- package/src/providers/model-rename-migration.ts +10 -0
- package/src/providers/openai-sidecar-credit.ts +2 -2
- package/src/providers/reasoning-capabilities.ts +76 -0
- package/src/providers/registry/entries-core.ts +14 -12
- package/src/providers/registry/entries-extended.ts +63 -20
- package/src/providers/registry/model-ids.ts +2 -0
- package/src/providers/registry/model-seeds.ts +93 -28
- package/src/providers/registry/types.ts +10 -1
- package/src/providers/resolved-model-policy.ts +26 -6
- package/src/providers/routed-config.ts +9 -1
- package/src/providers/stale-model-roster-migration.ts +44 -7
- package/src/remote-control/workspace-pi-runtime.ts +11 -6
- package/src/responses/compaction-summary.ts +45 -0
- package/src/responses/muse-tool-name-alias.ts +1 -2
- package/src/responses/parser.ts +3 -2
- package/src/responses/schema.ts +1 -0
- package/src/responses/thought-signature-replay.ts +10 -2
- package/src/routing/capability.ts +8 -2
- package/src/routing/history/ingest.ts +28 -3
- package/src/server/auth-cors.ts +3 -2
- package/src/server/chat-completions.ts +7 -0
- package/src/server/chat-native-eligibility.ts +7 -0
- package/src/server/chat-native-reasoning.ts +14 -4
- package/src/server/direct-local-http.ts +5 -2
- package/src/server/effort-policy.ts +5 -1
- package/src/server/index/live-sideband.ts +18 -15
- package/src/server/index/serve-options.ts +5 -4
- package/src/server/management/agent-settings-routes.ts +27 -15
- package/src/server/management/combo-routes.ts +4 -0
- package/src/server/management/config-routes.ts +2 -2
- package/src/server/management/decision-discovery.ts +12 -2
- package/src/server/management/hermes-profile-routes.ts +156 -0
- package/src/server/management/integration-routes.ts +85 -24
- package/src/server/management/model-routes.ts +2 -2
- package/src/server/management/model-row-export-metadata.ts +25 -6
- package/src/server/management/model-rows.ts +15 -20
- package/src/server/management/native-integration-routes.ts +11 -8
- package/src/server/management/route-registry.ts +4 -0
- package/src/server/management-api.ts +5 -0
- package/src/server/models-capabilities.ts +21 -3
- package/src/server/responses/adapter-delivery.ts +11 -1
- package/src/server/responses/adapter-dispatch.ts +2 -2
- package/src/server/responses/codex-ws-exchange.ts +39 -9
- package/src/server/responses/codex-ws-session.ts +38 -4
- package/src/server/responses/codex-ws-wire.ts +6 -1
- package/src/server/responses/combo-required-tool-contract.ts +103 -0
- package/src/server/responses/combo-stream-preflight.ts +8 -1
- package/src/server/responses/compact.ts +4 -3
- package/src/server/responses/context-overflow.ts +8 -1
- package/src/server/responses/core-combo-failure.ts +10 -0
- package/src/server/responses/core-combo.ts +23 -15
- package/src/server/responses/core-lifetime.ts +3 -0
- package/src/server/responses/core-normalize.ts +11 -1
- package/src/server/responses/core-options.ts +2 -0
- package/src/server/responses/main-hard-lock-routing.ts +60 -44
- package/src/server/responses/passthrough-delivery.ts +40 -2
- package/src/server/responses/policy-fallback.ts +6 -1
- package/src/server/responses/request-compression.ts +12 -7
- package/src/server/responses/request-prepare.ts +22 -2
- package/src/server/responses/request-sidecar-auth.ts +2 -0
- package/src/server/responses/response-effects.ts +22 -10
- package/src/server/responses/sidecar-execution.ts +11 -3
- package/src/server/stop-teardown.ts +36 -1
- package/src/server/ws-bridge.ts +1 -1
- package/src/service/desktop-supervision.d.mts +7 -4
- package/src/service/desktop-supervision.mjs +90 -13
- package/src/service/ownership-mutation-lease.mjs +21 -7
- package/src/types/config.ts +8 -2
- package/src/types/provider.ts +20 -6
- package/src/types/request.ts +10 -0
- package/src/types.ts +1 -0
- package/src/update/bind-probe.ts +29 -0
- package/src/update/job.ts +10 -29
- package/src/update/npm-install-job.ps1 +173 -0
- package/src/update/npm-install.mjs +70 -0
- package/src/update/stop-contract.d.mts +1 -0
- package/src/update/stop-contract.mjs +14 -0
- package/src/update/stop-decision.d.mts +1 -1
- package/src/update/stop-decision.mjs +13 -3
- package/src/update/teardown-handover.ts +166 -0
- package/src/update/transactional-install.d.mts +14 -3
- package/src/update/transactional-install.mjs +33 -7
- package/src/usage/expected-prices.ts +64 -31
- package/src/usage/timeline.ts +19 -9
- package/src/vision/eligibility.ts +15 -5
- package/src/vision/plan.ts +2 -2
- package/src/web-search/loop.ts +16 -2
- package/gui/dist/assets/App-sUf_8afJ.js +0 -58
- package/gui/dist/assets/index-DPeB9HpV.css +0 -1
package/src/types/provider.ts
CHANGED
|
@@ -278,12 +278,16 @@ export type TierDecision =
|
|
|
278
278
|
| { readonly kind: "drop" }
|
|
279
279
|
| { readonly kind: "set"; readonly value: string };
|
|
280
280
|
|
|
281
|
-
/**
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
281
|
+
/** Independent reasoning axes. Absence means unknown, not an explicit denial. */
|
|
282
|
+
export interface ReasoningCapabilities {
|
|
283
|
+
supportsReasoning?: boolean;
|
|
284
|
+
supportsThinkingToggle?: boolean;
|
|
285
|
+
supportsReasoningEffort?: boolean;
|
|
286
|
+
defaultThinkingEnabled?: boolean;
|
|
287
|
+
}
|
|
288
|
+
|
|
285
289
|
/** Explicit per-model operator declarations; absent axes keep legacy behavior. */
|
|
286
|
-
export interface ModelCapabilities {
|
|
290
|
+
export interface ModelCapabilities extends ReasoningCapabilities {
|
|
287
291
|
inputModalities?: Array<"text" | "image" | "audio" | "video">;
|
|
288
292
|
/** Requested tier only; does not imply an upstream window or activate an unverified wire. */
|
|
289
293
|
contextTier?: "default" | "long_context";
|
|
@@ -292,6 +296,10 @@ export interface ModelCapabilities {
|
|
|
292
296
|
deepseekImageFiles?: boolean;
|
|
293
297
|
}
|
|
294
298
|
|
|
299
|
+
/**
|
|
300
|
+
* One configured provider entry. `authMode` (default `"key"`) decides whether same-target 429
|
|
301
|
+
* retries are allowed; OAuth/forward credentials and local runtimes are never replayed.
|
|
302
|
+
*/
|
|
295
303
|
export interface OcxProviderConfig {
|
|
296
304
|
/** Explicit builtin Pool 2 provenance; endpoints never imply ownership. */
|
|
297
305
|
anthropicOAuthInstance?: "anthropic2";
|
|
@@ -661,6 +669,12 @@ export interface OcxProviderConfig {
|
|
|
661
669
|
modelContextTiers?: Record<string, "default" | "long_context">;
|
|
662
670
|
/** Model-specific Codex catalog input modalities, e.g. ["text"] or ["text", "image"]. */
|
|
663
671
|
modelInputModalities?: Record<string, string[]>;
|
|
672
|
+
/**
|
|
673
|
+
* Provider-wide input modalities, applied to models `modelInputModalities` does not enumerate
|
|
674
|
+
* (a live-discovered id, for example). The registry's value is applied at runtime only, for the
|
|
675
|
+
* preset's own destination, and never persisted; a per-model declaration still wins.
|
|
676
|
+
*/
|
|
677
|
+
inputModalities?: string[];
|
|
664
678
|
modelCapabilities?: Record<string, ModelCapabilities>;
|
|
665
679
|
/** Model-specific max input token limits. Values cap auto_compact_token_limit. */
|
|
666
680
|
modelMaxInputTokens?: Record<string, number>;
|
|
@@ -900,7 +914,7 @@ export interface OcxProviderConfig {
|
|
|
900
914
|
* `reasoningEffortMap`, resolved per model first.
|
|
901
915
|
*/
|
|
902
916
|
modelReasoningEffortMap?: Record<string, Record<string, string>>;
|
|
903
|
-
/**
|
|
917
|
+
/** Chat gateway reasoning object; also opts custom Responses wires into `reasoning.enabled`. */
|
|
904
918
|
reasoningWireFormat?: "gateway-object";
|
|
905
919
|
/**
|
|
906
920
|
* Model ids that do NOT support a reasoning/thinking parameter. The openai-chat adapter drops
|
package/src/types/request.ts
CHANGED
|
@@ -76,6 +76,11 @@ export interface OcxParsedRequest {
|
|
|
76
76
|
* them, and only for api.anthropic.com; every other destination never sees them.
|
|
77
77
|
*/
|
|
78
78
|
_anthropicServerTools?: readonly Record<string, unknown>[];
|
|
79
|
+
/**
|
|
80
|
+
* Routed Anthropic compaction summary: build tools and system exactly as the ordinary request
|
|
81
|
+
* would (prompt-cache prefix), then send tool_choice none so no client or hosted tool runs.
|
|
82
|
+
*/
|
|
83
|
+
_summaryProhibitsToolCalls?: boolean;
|
|
79
84
|
/**
|
|
80
85
|
* Completed server-tool exchanges from the Claude client's history, keyed by the block that
|
|
81
86
|
* followed them (`call:<tool_use id>` / `text:<text>`). Same audience as `_anthropicServerTools`.
|
|
@@ -387,6 +392,11 @@ export interface OcxRequestOptions {
|
|
|
387
392
|
toolChoice?: OcxToolChoice;
|
|
388
393
|
parallelToolCalls?: boolean;
|
|
389
394
|
reasoning?: string;
|
|
395
|
+
/**
|
|
396
|
+
* Independent reasoning toggle resolved at client-compatibility ingress. This is distinct from
|
|
397
|
+
* the strength-like `reasoning` effort: toggle-only models consume this value as `thinking.type`.
|
|
398
|
+
*/
|
|
399
|
+
thinkingEnabled?: boolean;
|
|
390
400
|
hideThinkingSummary?: boolean;
|
|
391
401
|
/** Provider policy: suppress raw content-channel reasoning while summaries stay visible. */
|
|
392
402
|
hideRawReasoning?: boolean;
|
package/src/types.ts
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Strict bind script: exit 0 only after listen+close. Any listen error (including
|
|
5
|
+
* Windows ghost-TCB failures under Bun) is busy — matches published `ocx start`
|
|
6
|
+
* probes that treat every listen error as unavailable.
|
|
7
|
+
*/
|
|
8
|
+
export function strictBindProbeScript(port: number, hostname: string): string {
|
|
9
|
+
return [
|
|
10
|
+
"const net=require('net');",
|
|
11
|
+
"const s=net.createServer();",
|
|
12
|
+
"s.once('error',()=>process.exit(2));",
|
|
13
|
+
`s.listen(${Math.trunc(port)},${JSON.stringify(hostname)},()=>s.close(()=>process.exit(0)));`,
|
|
14
|
+
"setTimeout(()=>process.exit(3),2500);",
|
|
15
|
+
].join("");
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function spawnBindProbe(bin: string, script: string): boolean {
|
|
19
|
+
try {
|
|
20
|
+
const r = spawnSync(bin, ["-e", script], {
|
|
21
|
+
windowsHide: true,
|
|
22
|
+
timeout: 4000,
|
|
23
|
+
stdio: "ignore",
|
|
24
|
+
});
|
|
25
|
+
return r.status === 0;
|
|
26
|
+
} catch {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
package/src/update/job.ts
CHANGED
|
@@ -53,6 +53,8 @@ import {
|
|
|
53
53
|
} from "./npm-cache-preflight.mjs";
|
|
54
54
|
import { guiUpdateWorkerCommand } from "./worker-launch";
|
|
55
55
|
import { withoutSiblingMarker } from "../codex/sibling-start";
|
|
56
|
+
import { spawnBindProbe, strictBindProbeScript } from "./bind-probe";
|
|
57
|
+
import { withoutUpdateTeardownHandover, withUpdateTeardownHandover } from "./teardown-handover";
|
|
56
58
|
import type { WorkerLaunchContext } from "./worker-launch";
|
|
57
59
|
|
|
58
60
|
const RELEASE_NOTES_URL = "https://github.com/lidge-jun/opencodex/releases/latest";
|
|
@@ -140,34 +142,6 @@ function usesNodeLauncher(installer: Installer): boolean {
|
|
|
140
142
|
return installer === "npm" || installer === "pnpm";
|
|
141
143
|
}
|
|
142
144
|
|
|
143
|
-
/**
|
|
144
|
-
* Strict bind script: exit 0 only after listen+close. Any listen error (including
|
|
145
|
-
* Windows ghost-TCB failures under Bun) is busy — matches published `ocx start`
|
|
146
|
-
* probes that treat every listen error as unavailable.
|
|
147
|
-
*/
|
|
148
|
-
function strictBindProbeScript(port: number, hostname: string): string {
|
|
149
|
-
return [
|
|
150
|
-
"const net=require('net');",
|
|
151
|
-
"const s=net.createServer();",
|
|
152
|
-
"s.once('error',()=>process.exit(2));",
|
|
153
|
-
`s.listen(${Math.trunc(port)},${JSON.stringify(hostname)},()=>s.close(()=>process.exit(0)));`,
|
|
154
|
-
"setTimeout(()=>process.exit(3),2500);",
|
|
155
|
-
].join("");
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function spawnBindProbe(bin: string, script: string): boolean {
|
|
159
|
-
try {
|
|
160
|
-
const r = spawnSync(bin, ["-e", script], {
|
|
161
|
-
windowsHide: true,
|
|
162
|
-
timeout: 4000,
|
|
163
|
-
stdio: "ignore",
|
|
164
|
-
});
|
|
165
|
-
return r.status === 0;
|
|
166
|
-
} catch {
|
|
167
|
-
return false;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
145
|
/**
|
|
172
146
|
* Live global package Bun — not the npm rename tree the update worker may still
|
|
173
147
|
* be executing from (`@bitkyc08/.opencodex-*`). Reject the tiny postinstall
|
|
@@ -700,12 +674,14 @@ function runLoggedCommand(
|
|
|
700
674
|
bin: string,
|
|
701
675
|
args: string[],
|
|
702
676
|
timeout: number,
|
|
677
|
+
env?: NodeJS.ProcessEnv,
|
|
703
678
|
): { status: number | null; signal: NodeJS.Signals | null; timedOut: boolean } {
|
|
704
679
|
job = updateJob(job, {}, `$ ${formatCommand(bin, args)}`);
|
|
705
680
|
const result = spawnSync(bin, args, {
|
|
706
681
|
encoding: "utf8",
|
|
707
682
|
timeout,
|
|
708
683
|
windowsHide: true,
|
|
684
|
+
...(env ? { env } : {}),
|
|
709
685
|
});
|
|
710
686
|
const stdout = typeof result.stdout === "string" ? result.stdout.trim() : "";
|
|
711
687
|
const stderr = typeof result.stderr === "string" ? result.stderr.trim() : "";
|
|
@@ -1812,6 +1788,7 @@ export interface GuiUpdateWorkerIo {
|
|
|
1812
1788
|
bin: string,
|
|
1813
1789
|
args: string[],
|
|
1814
1790
|
timeout: number,
|
|
1791
|
+
env?: NodeJS.ProcessEnv,
|
|
1815
1792
|
) => { status: number | null; signal: NodeJS.Signals | null };
|
|
1816
1793
|
}
|
|
1817
1794
|
|
|
@@ -1933,7 +1910,11 @@ export async function runGuiUpdateWorker(
|
|
|
1933
1910
|
- 대안 분석: (1) 서버에서 runUpdate 직접 호출: process.exit/stdio/실행 파일 교체 위험. (2) GUI에서 CLI 명령 안내만 제공: 자동 업데이트 UX 부족. (3) 숨은 worker가 Node launcher/Bun 전역 명령을 실행: 상태 추적과 안전한 재시작이 가능.
|
|
1934
1911
|
- 선택 근거: 현재 CLI의 package-manager self-update 우회를 재사용하면서도 GUI 서버 요청 생명주기와 설치 작업을 분리할 수 있어 가장 안정적이다.
|
|
1935
1912
|
*/
|
|
1936
|
-
|
|
1913
|
+
// #7423: this job restarts the proxy itself, so the update's stop hands Codex routing
|
|
1914
|
+
// and the routed catalog to the replacement instead of restoring native Codex for the
|
|
1915
|
+
// seconds in between. Without a restart the stop restores, even under an inherited marker.
|
|
1916
|
+
const updateEnv = restart ? withUpdateTeardownHandover(process.env) : withoutUpdateTeardownHandover(process.env);
|
|
1917
|
+
const result = (io.runCommandFn ?? runLoggedCommand)(job, cmd.bin, cmd.args, UPDATE_TIMEOUT_MS, updateEnv);
|
|
1937
1918
|
if (result.status !== 0) {
|
|
1938
1919
|
if (check.installer === "pnpm") {
|
|
1939
1920
|
const verifiedLauncher = pnpmOwner
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# ASCII-only Windows PowerShell 5.1 supervisor. Arguments arrive as JSON on stdin.
|
|
2
|
+
# The child is born in our private job; no installer can outlive its supervisor.
|
|
3
|
+
$ErrorActionPreference = 'Stop'
|
|
4
|
+
$utf8 = New-Object System.Text.UTF8Encoding($false, $true)
|
|
5
|
+
$reader = New-Object System.IO.StreamReader([Console]::OpenStandardInput(), $utf8, $false)
|
|
6
|
+
$request = $reader.ReadToEnd() | ConvertFrom-Json
|
|
7
|
+
Add-Type -TypeDefinition @'
|
|
8
|
+
using System;
|
|
9
|
+
using System.ComponentModel;
|
|
10
|
+
using System.Diagnostics;
|
|
11
|
+
using System.Runtime.InteropServices;
|
|
12
|
+
using System.Text;
|
|
13
|
+
using System.Threading;
|
|
14
|
+
|
|
15
|
+
public static class NpmInstallJob {
|
|
16
|
+
[StructLayout(LayoutKind.Sequential)] struct Startup {
|
|
17
|
+
public int cb; public IntPtr reserved, desktop, title;
|
|
18
|
+
public int x, y, width, height, charsX, charsY, fill, flags;
|
|
19
|
+
public short show, reservedSize; public IntPtr reservedData, stdin, stdout, stderr;
|
|
20
|
+
}
|
|
21
|
+
[StructLayout(LayoutKind.Sequential)] struct ProcessInfo {
|
|
22
|
+
public IntPtr process, thread; public uint pid, tid;
|
|
23
|
+
}
|
|
24
|
+
[StructLayout(LayoutKind.Sequential)] struct StartupEx {
|
|
25
|
+
public Startup startup; public IntPtr attributes;
|
|
26
|
+
}
|
|
27
|
+
[StructLayout(LayoutKind.Sequential)] struct Limits {
|
|
28
|
+
public long processTime, jobTime; public uint flags;
|
|
29
|
+
public UIntPtr minWorkingSet, maxWorkingSet; public uint activeLimit;
|
|
30
|
+
public UIntPtr affinity; public uint priority, scheduling;
|
|
31
|
+
}
|
|
32
|
+
[StructLayout(LayoutKind.Sequential)] struct ExtendedLimits {
|
|
33
|
+
public Limits basic;
|
|
34
|
+
public ulong readOps, writeOps, otherOps, readBytes, writeBytes, otherBytes;
|
|
35
|
+
public UIntPtr processMemory, jobMemory, peakProcessMemory, peakJobMemory;
|
|
36
|
+
}
|
|
37
|
+
[StructLayout(LayoutKind.Sequential)] struct Accounting {
|
|
38
|
+
public long userTime, kernelTime, periodUserTime, periodKernelTime;
|
|
39
|
+
public uint faults, total, active, terminated;
|
|
40
|
+
}
|
|
41
|
+
public sealed class Result {
|
|
42
|
+
public object status; public bool processTreeExited; public object error;
|
|
43
|
+
}
|
|
44
|
+
public sealed class InstallError {
|
|
45
|
+
public string code, message;
|
|
46
|
+
public InstallError(string c, string m) { code = c; message = m; }
|
|
47
|
+
}
|
|
48
|
+
[DllImport("kernel32.dll", CharSet=CharSet.Unicode, SetLastError=true)]
|
|
49
|
+
static extern IntPtr CreateJobObject(IntPtr attributes, string name);
|
|
50
|
+
[DllImport("kernel32.dll", SetLastError=true)]
|
|
51
|
+
static extern bool SetInformationJobObject(IntPtr job, int info, ref ExtendedLimits limits, uint size);
|
|
52
|
+
[DllImport("kernel32.dll", SetLastError=true)]
|
|
53
|
+
static extern bool QueryInformationJobObject(IntPtr job, int info, out Accounting data, uint size, IntPtr returned);
|
|
54
|
+
[DllImport("kernel32.dll", CharSet=CharSet.Unicode, SetLastError=true)]
|
|
55
|
+
static extern bool CreateProcess(string file, StringBuilder args, IntPtr pa, IntPtr ta, bool inherit, uint flags,
|
|
56
|
+
IntPtr environment, string cwd, ref StartupEx startup, out ProcessInfo process);
|
|
57
|
+
[DllImport("kernel32.dll", SetLastError=true)]
|
|
58
|
+
static extern bool InitializeProcThreadAttributeList(IntPtr list, int count, uint flags, ref IntPtr size);
|
|
59
|
+
[DllImport("kernel32.dll", SetLastError=true)]
|
|
60
|
+
static extern bool UpdateProcThreadAttribute(IntPtr list, uint flags, IntPtr attribute, IntPtr value,
|
|
61
|
+
IntPtr size, IntPtr previous, IntPtr returned);
|
|
62
|
+
[DllImport("kernel32.dll")] static extern void DeleteProcThreadAttributeList(IntPtr list);
|
|
63
|
+
[DllImport("kernel32.dll", SetLastError=true)] static extern bool TerminateJobObject(IntPtr job, uint code);
|
|
64
|
+
[DllImport("kernel32.dll", SetLastError=true)] static extern uint ResumeThread(IntPtr thread);
|
|
65
|
+
[DllImport("kernel32.dll")] static extern uint WaitForSingleObject(IntPtr handle, uint ms);
|
|
66
|
+
[DllImport("kernel32.dll", SetLastError=true)] static extern bool GetExitCodeProcess(IntPtr process, out uint code);
|
|
67
|
+
[DllImport("kernel32.dll")] static extern IntPtr GetStdHandle(int number);
|
|
68
|
+
[DllImport("kernel32.dll", SetLastError=true)] static extern bool SetHandleInformation(IntPtr handle, uint mask, uint flags);
|
|
69
|
+
[DllImport("kernel32.dll")] static extern bool CloseHandle(IntPtr handle);
|
|
70
|
+
static void Require(bool ok) { if (!ok) throw new Win32Exception(Marshal.GetLastWin32Error()); }
|
|
71
|
+
static void RequireAttribute(bool ok) {
|
|
72
|
+
if (!ok) {
|
|
73
|
+
int code = Marshal.GetLastWin32Error();
|
|
74
|
+
throw new Win32Exception(code,
|
|
75
|
+
"Atomic npm supervision requires Windows 10 or later with Job List and handle-list process attributes; installer was not started: "
|
|
76
|
+
+ new Win32Exception(code).Message);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
static uint Active(IntPtr job) {
|
|
80
|
+
Accounting data;
|
|
81
|
+
Require(QueryInformationJobObject(job, 1, out data, (uint)Marshal.SizeOf(typeof(Accounting)), IntPtr.Zero));
|
|
82
|
+
return data.active;
|
|
83
|
+
}
|
|
84
|
+
public static Result Run(string file, string args, string cwd, int timeoutMs, int joinMs) {
|
|
85
|
+
IntPtr job = IntPtr.Zero, attributes = IntPtr.Zero, jobList = IntPtr.Zero, handles = IntPtr.Zero;
|
|
86
|
+
ProcessInfo process = new ProcessInfo();
|
|
87
|
+
bool started = false, attributesInitialized = false, timedOut = false;
|
|
88
|
+
Result result = new Result { status = null, processTreeExited = true };
|
|
89
|
+
try {
|
|
90
|
+
job = CreateJobObject(IntPtr.Zero, null); Require(job != IntPtr.Zero);
|
|
91
|
+
ExtendedLimits limits = new ExtendedLimits();
|
|
92
|
+
limits.basic.flags = 0x2000; // JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE; no breakaway.
|
|
93
|
+
Require(SetInformationJobObject(job, 9, ref limits, (uint)Marshal.SizeOf(typeof(ExtendedLimits))));
|
|
94
|
+
StartupEx startup = new StartupEx(); startup.startup.cb = Marshal.SizeOf(typeof(StartupEx)); startup.startup.flags = 0x100;
|
|
95
|
+
startup.startup.stdin = GetStdHandle(-10);
|
|
96
|
+
// Keep stdout exclusively for the one supervisor result. npm logs inherit stderr.
|
|
97
|
+
startup.startup.stdout = startup.startup.stderr = GetStdHandle(-12);
|
|
98
|
+
Require(SetHandleInformation(startup.startup.stdin, 1, 1));
|
|
99
|
+
Require(SetHandleInformation(startup.startup.stderr, 1, 1));
|
|
100
|
+
Require(SetHandleInformation(GetStdHandle(-11), 1, 0)); // Result pipe is supervisor-only.
|
|
101
|
+
IntPtr size = IntPtr.Zero;
|
|
102
|
+
InitializeProcThreadAttributeList(IntPtr.Zero, 2, 0, ref size);
|
|
103
|
+
RequireAttribute(size != IntPtr.Zero);
|
|
104
|
+
attributes = Marshal.AllocHGlobal(size);
|
|
105
|
+
RequireAttribute(InitializeProcThreadAttributeList(attributes, 2, 0, ref size));
|
|
106
|
+
attributesInitialized = true; startup.attributes = attributes;
|
|
107
|
+
jobList = Marshal.AllocHGlobal(IntPtr.Size); Marshal.WriteIntPtr(jobList, job);
|
|
108
|
+
// PROC_THREAD_ATTRIBUTE_JOB_LIST: membership is atomic with creation (Windows 10+).
|
|
109
|
+
RequireAttribute(UpdateProcThreadAttribute(attributes, 0, new IntPtr(0x0002000D), jobList,
|
|
110
|
+
new IntPtr(IntPtr.Size), IntPtr.Zero, IntPtr.Zero));
|
|
111
|
+
handles = Marshal.AllocHGlobal(2 * IntPtr.Size);
|
|
112
|
+
Marshal.WriteIntPtr(handles, 0, startup.startup.stdin);
|
|
113
|
+
Marshal.WriteIntPtr(handles, IntPtr.Size, startup.startup.stderr);
|
|
114
|
+
// PROC_THREAD_ATTRIBUTE_HANDLE_LIST: never inherit the Job or result pipe.
|
|
115
|
+
RequireAttribute(UpdateProcThreadAttribute(attributes, 0, new IntPtr(0x00020002), handles,
|
|
116
|
+
new IntPtr(2 * IntPtr.Size), IntPtr.Zero, IntPtr.Zero));
|
|
117
|
+
// Fail closed on unsupported attributes/creation: never retry without the Job list.
|
|
118
|
+
RequireAttribute(CreateProcess(file, new StringBuilder(args), IntPtr.Zero, IntPtr.Zero, true,
|
|
119
|
+
0x08080004, IntPtr.Zero, cwd, ref startup, out process)); // NO_WINDOW | EXTENDED_STARTUPINFO_PRESENT | SUSPENDED
|
|
120
|
+
started = true; result.processTreeExited = false;
|
|
121
|
+
// Keep suspension until local exit-proof/error handling is armed.
|
|
122
|
+
Require(ResumeThread(process.thread) != UInt32.MaxValue);
|
|
123
|
+
Stopwatch clock = Stopwatch.StartNew();
|
|
124
|
+
while (Active(job) != 0 && clock.ElapsedMilliseconds < timeoutMs) Thread.Sleep(20);
|
|
125
|
+
if (Active(job) != 0) {
|
|
126
|
+
timedOut = true;
|
|
127
|
+
result.error = new InstallError("ETIMEDOUT", "npm install exceeded " + timeoutMs + " ms");
|
|
128
|
+
Require(TerminateJobObject(job, 1));
|
|
129
|
+
clock.Restart();
|
|
130
|
+
while (Active(job) != 0 && clock.ElapsedMilliseconds < joinMs) Thread.Sleep(10);
|
|
131
|
+
} else clock.Restart();
|
|
132
|
+
uint remainingJoinMs = (uint)Math.Max(0L, joinMs - clock.ElapsedMilliseconds);
|
|
133
|
+
result.processTreeExited = Active(job) == 0 && WaitForSingleObject(process.process, remainingJoinMs) == 0;
|
|
134
|
+
if (result.processTreeExited && result.error == null) {
|
|
135
|
+
uint code; Require(GetExitCodeProcess(process.process, out code)); result.status = (long)code;
|
|
136
|
+
} else if (!result.processTreeExited) {
|
|
137
|
+
result.error = new InstallError(timedOut ? "ETIMEDOUT" : "EINSTALLJOIN",
|
|
138
|
+
(timedOut ? "npm install exceeded " + timeoutMs + " ms; " : "") + "process-tree exit could not be confirmed; stage retained");
|
|
139
|
+
}
|
|
140
|
+
} catch (Exception error) {
|
|
141
|
+
if (started) {
|
|
142
|
+
TerminateJobObject(job, 1);
|
|
143
|
+
Stopwatch clock = Stopwatch.StartNew();
|
|
144
|
+
while (clock.ElapsedMilliseconds < joinMs) {
|
|
145
|
+
try {
|
|
146
|
+
if (WaitForSingleObject(process.process, 0) == 0 && Active(job) == 0) {
|
|
147
|
+
result.processTreeExited = true; break;
|
|
148
|
+
}
|
|
149
|
+
} catch { break; }
|
|
150
|
+
Thread.Sleep(10);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
InstallError timeout = result.error as InstallError;
|
|
154
|
+
result.error = new InstallError(timeout == null ? "EINSTALLJOIN" : timeout.code,
|
|
155
|
+
(timeout == null ? "" : timeout.message + "; ") + "npm supervision failed: " + error.Message);
|
|
156
|
+
} finally {
|
|
157
|
+
if (attributesInitialized) DeleteProcThreadAttributeList(attributes);
|
|
158
|
+
if (attributes != IntPtr.Zero) Marshal.FreeHGlobal(attributes);
|
|
159
|
+
if (handles != IntPtr.Zero) Marshal.FreeHGlobal(handles);
|
|
160
|
+
if (jobList != IntPtr.Zero) Marshal.FreeHGlobal(jobList);
|
|
161
|
+
if (process.thread != IntPtr.Zero) CloseHandle(process.thread);
|
|
162
|
+
if (process.process != IntPtr.Zero) CloseHandle(process.process);
|
|
163
|
+
if (job != IntPtr.Zero) CloseHandle(job);
|
|
164
|
+
}
|
|
165
|
+
return result;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
'@
|
|
169
|
+
$result = [NpmInstallJob]::Run([string]$request.file, [string]$request.commandLine, [string]$request.cwd,
|
|
170
|
+
[int]$request.timeoutMs, [int]$request.joinMs) | ConvertTo-Json -Compress -Depth 4
|
|
171
|
+
$writer = New-Object System.IO.StreamWriter([Console]::OpenStandardOutput(), $utf8)
|
|
172
|
+
$writer.Write($result)
|
|
173
|
+
$writer.Flush()
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Windows Node-launcher compatibility code. The install owns its entire process tree until
|
|
2
|
+
// exit is proved; a timeout signal alone never authorizes stage removal.
|
|
3
|
+
import { spawn } from "node:child_process";
|
|
4
|
+
import { dirname, join, win32 } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
const JOIN_MS = 10000;
|
|
8
|
+
const failure = message => ({ status: null, processTreeExited: false, error: { code: "EINSTALLJOIN", message } });
|
|
9
|
+
|
|
10
|
+
function quoteWindowsArg(value) {
|
|
11
|
+
return '"' + value.replace(/(\\*)"/g, '$1$1\\"').replace(/(\\*)$/, "$1$1") + '"';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export async function runNpmInstall(invocation, { env = process.env, timeoutMs = 180000 } = {}) {
|
|
15
|
+
if (!invocation) return { status: 1, processTreeExited: true, error: { code: "ENOENT", message: "npm invocation unavailable" } };
|
|
16
|
+
if (process.platform === "win32") {
|
|
17
|
+
// Resolve from the same absolute system directory as the hardened cmd hop.
|
|
18
|
+
// Never search PATH for PowerShell, and never interpolate the JSON as code.
|
|
19
|
+
const roots = new Set(Object.entries(env).filter(([key, value]) => key.toLowerCase() === "systemroot" && value !== undefined).map(([, value]) => value));
|
|
20
|
+
const root = env.SystemRoot ?? (roots.size === 1 ? [...roots][0] : undefined);
|
|
21
|
+
if (!root || !win32.isAbsolute(root)) return failure("absolute SystemRoot is required for npm process supervision");
|
|
22
|
+
const supervisor = win32.join(root, "System32", "WindowsPowerShell", "v1.0", "powershell.exe");
|
|
23
|
+
const helper = join(dirname(fileURLToPath(import.meta.url)), "npm-install-job.ps1");
|
|
24
|
+
return new Promise(resolve => {
|
|
25
|
+
const child = spawn(supervisor, ["-NoLogo", "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-File", helper], {
|
|
26
|
+
env, windowsHide: true, stdio: ["pipe", "pipe", "pipe"],
|
|
27
|
+
});
|
|
28
|
+
let output = "";
|
|
29
|
+
let invalid = false;
|
|
30
|
+
let spawned = false;
|
|
31
|
+
let completed = false;
|
|
32
|
+
const complete = result => {
|
|
33
|
+
if (completed) return;
|
|
34
|
+
completed = true;
|
|
35
|
+
clearTimeout(watchdog);
|
|
36
|
+
child.stdin.destroy(); child.stdout.destroy(); child.stderr.destroy();
|
|
37
|
+
resolve(result);
|
|
38
|
+
};
|
|
39
|
+
const watchdog = setTimeout(() => {
|
|
40
|
+
child.kill();
|
|
41
|
+
complete(failure(`npm supervisor exceeded ${timeoutMs} ms install budget and exit-confirmation budget; stage retained`));
|
|
42
|
+
}, timeoutMs + JOIN_MS + 30000);
|
|
43
|
+
child.on("spawn", () => { spawned = true; });
|
|
44
|
+
child.stderr.on("data", chunk => { if (!completed) process.stderr.write(chunk); });
|
|
45
|
+
child.stdout.setEncoding("utf8");
|
|
46
|
+
child.stdout.on("data", chunk => {
|
|
47
|
+
if (output.length + chunk.length > 16384) { invalid = true; child.kill(); complete(failure("invalid npm supervisor output; stage retained")); }
|
|
48
|
+
else output += chunk.toString("utf8");
|
|
49
|
+
});
|
|
50
|
+
child.on("error", error => {
|
|
51
|
+
complete({ status: null, processTreeExited: !spawned, error: { code: error.code, message: error.message } });
|
|
52
|
+
});
|
|
53
|
+
child.on("close", status => {
|
|
54
|
+
clearTimeout(watchdog);
|
|
55
|
+
try {
|
|
56
|
+
const result = JSON.parse(output);
|
|
57
|
+
if (invalid || status !== 0 || typeof result.processTreeExited !== "boolean"
|
|
58
|
+
|| !(result.status === null || Number.isInteger(result.status))) throw new Error("invalid supervisor result");
|
|
59
|
+
complete(result);
|
|
60
|
+
} catch { complete(failure("npm supervisor did not confirm process-tree exit; stage retained")); }
|
|
61
|
+
});
|
|
62
|
+
child.stdin.on("error", () => { /* close/result decides whether the helper ran */ });
|
|
63
|
+
const args = invocation.options?.windowsVerbatimArguments ? invocation.args.join(" ") : invocation.args.map(quoteWindowsArg).join(" ");
|
|
64
|
+
child.stdin.end(JSON.stringify({ file: invocation.file, commandLine: quoteWindowsArg(invocation.file) + " " + args,
|
|
65
|
+
cwd: process.cwd(), timeoutMs, joinMs: JOIN_MS }));
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return failure("the npm Job Object supervisor is Windows-only");
|
|
70
|
+
}
|
|
@@ -32,3 +32,17 @@ export const STOP_HISTORY_INCOMPLETE_EXIT_CODE = 79;
|
|
|
32
32
|
* dispatcher already emit.
|
|
33
33
|
*/
|
|
34
34
|
export const STOP_HISTORY_DEFERRED_EXIT_CODE = 80;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The exit code `ocx stop` uses to say "the proxy is down and its shared teardown was
|
|
38
|
+
* handed to the proxy this update is about to start" (#7423).
|
|
39
|
+
*
|
|
40
|
+
* Only an update that will restart the proxy asks for this. Restoring native Codex here
|
|
41
|
+
* replaced the routed catalog with the pristine one, and a Codex process that loaded it
|
|
42
|
+
* before the new proxy's first publication kept treating routed models as unknown until
|
|
43
|
+
* it was restarted. Like 80, the receipt stays outstanding, and the stop proved before
|
|
44
|
+
* choosing this code that it is the only obligation left; unlike 80, nothing refused the
|
|
45
|
+
* restore. The replacement discharges the receipt after it publishes, and a stop finishes
|
|
46
|
+
* it if no replacement ever starts.
|
|
47
|
+
*/
|
|
48
|
+
export const STOP_TEARDOWN_HANDED_OVER_EXIT_CODE = 81;
|
|
@@ -6,5 +6,5 @@ export declare function decidePostStopUpdate(input: {
|
|
|
6
6
|
teardownOutstanding?: boolean;
|
|
7
7
|
}): {
|
|
8
8
|
proceed: boolean;
|
|
9
|
-
reason: "stop-failed" | "runtime-state" | "teardown-outstanding" | "proxy-live" | "proxy-unknown" | "history-only" | "history-deferred" | "ok";
|
|
9
|
+
reason: "stop-failed" | "runtime-state" | "teardown-outstanding" | "proxy-live" | "proxy-unknown" | "history-only" | "history-deferred" | "handed-over" | "ok";
|
|
10
10
|
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
STOP_HISTORY_DEFERRED_EXIT_CODE,
|
|
3
|
+
STOP_HISTORY_INCOMPLETE_EXIT_CODE,
|
|
4
|
+
STOP_TEARDOWN_HANDED_OVER_EXIT_CODE,
|
|
5
|
+
} from "./stop-contract.mjs";
|
|
2
6
|
|
|
3
7
|
/**
|
|
4
8
|
* May an update replace package files after `ocx stop` returned?
|
|
@@ -29,15 +33,21 @@ import { STOP_HISTORY_DEFERRED_EXIT_CODE, STOP_HISTORY_INCOMPLETE_EXIT_CODE } fr
|
|
|
29
33
|
* gate still applies: runtime records and a live or unreadable endpoint abort exactly
|
|
30
34
|
* as they do for a clean stop, because package replacement under a live server is the
|
|
31
35
|
* danger this function exists to prevent, and a history refusal says nothing about it.
|
|
36
|
+
* - `handed-over` — proceed; the stop is down and kept its receipt on purpose so the
|
|
37
|
+
* proxy this update restarts can take the routing over without a native gap (#7423).
|
|
38
|
+
* It is gated exactly like `history-deferred`: the child proved its receipt is the only
|
|
39
|
+
* obligation, and runtime records or a live or unreadable endpoint still abort.
|
|
32
40
|
*/
|
|
33
41
|
export function decidePostStopUpdate({ status, hasRuntimeState, liveness, teardownOutstanding = false }) {
|
|
34
42
|
const historyOnly = status === STOP_HISTORY_INCOMPLETE_EXIT_CODE;
|
|
35
43
|
const historyDeferred = status === STOP_HISTORY_DEFERRED_EXIT_CODE;
|
|
36
|
-
|
|
44
|
+
const handedOver = status === STOP_TEARDOWN_HANDED_OVER_EXIT_CODE;
|
|
45
|
+
if (status !== 0 && !historyOnly && !historyDeferred && !handedOver) return { proceed: false, reason: "stop-failed" };
|
|
37
46
|
if (hasRuntimeState) return { proceed: false, reason: "runtime-state" };
|
|
38
|
-
if (teardownOutstanding && !historyDeferred) return { proceed: false, reason: "teardown-outstanding" };
|
|
47
|
+
if (teardownOutstanding && !historyDeferred && !handedOver) return { proceed: false, reason: "teardown-outstanding" };
|
|
39
48
|
if (liveness === "live") return { proceed: false, reason: "proxy-live" };
|
|
40
49
|
if (liveness !== "dead") return { proceed: false, reason: "proxy-unknown" };
|
|
41
50
|
if (historyDeferred) return { proceed: true, reason: "history-deferred" };
|
|
51
|
+
if (handedOver) return { proceed: true, reason: "handed-over" };
|
|
42
52
|
return { proceed: true, reason: historyOnly ? "history-only" : "ok" };
|
|
43
53
|
}
|