sneakoscope 8.1.2 → 8.2.0
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/README.md +96 -58
- package/crates/sks-core/Cargo.lock +1 -1
- package/crates/sks-core/Cargo.toml +1 -1
- package/dist/bin/fast-inline.js +5 -51
- package/dist/cli/command-manifest-lite.js +2 -1
- package/dist/cli/command-registry.js +2 -1
- package/dist/cli/global-mode-router.js +1 -1
- package/dist/cli/install-helpers-codex-lb-config.js +112 -914
- package/dist/cli/install-helpers-codex-lb-shared.js +3 -44
- package/dist/cli/install-helpers-install-support.js +4 -20
- package/dist/cli/install-helpers.js +36 -2716
- package/dist/cli/router.js +9 -9
- package/dist/commands/bridge-command-output.js +111 -0
- package/dist/commands/bridge.js +320 -0
- package/dist/commands/codex-app.js +39 -123
- package/dist/commands/doctor-helpers.js +380 -0
- package/dist/commands/doctor-profile.js +3 -0
- package/dist/commands/doctor.js +114 -873
- package/dist/commands/mad-sks.js +0 -4
- package/dist/config/skills-manifest.json +1 -1
- package/dist/core/agents/agent-effort-policy.js +11 -21
- package/dist/core/agents/agent-recursion-guard.js +26 -0
- package/dist/core/agents/agent-runner-codex-exec.js +7 -9
- package/dist/core/architecture-hardening/contracts/contracts.js +225 -161
- package/dist/core/architecture-hardening/state/state-service.js +49 -13
- package/dist/core/auto-review.js +15 -9
- package/dist/core/codex/codex-config-guard.js +8 -0
- package/dist/core/codex-adapter.js +8 -10
- package/dist/core/codex-app/codex-app-fast-ui-repair.js +7 -29
- package/dist/core/codex-app/codex-app-launcher.js +10 -12
- package/dist/core/codex-app/codex-app-restart.js +10 -12
- package/dist/core/codex-app/menubar/constants.js +2 -5
- package/dist/core/codex-app/menubar/global-install.js +3 -2
- package/dist/core/codex-app/menubar/installer/result.js +23 -0
- package/dist/core/codex-app/menubar/installer/runtime.js +28 -0
- package/dist/core/codex-app/menubar/installer.js +5 -96
- package/dist/core/codex-app/menubar/migration.js +1 -42
- package/dist/core/codex-app/openrouter-provider.js +0 -78
- package/dist/core/codex-app.js +97 -360
- package/dist/core/codex-control/codex-app-server-runtime-env.js +8 -28
- package/dist/core/codex-control/codex-current-image-path-real-probe.js +2 -3
- package/dist/core/codex-control/codex-current-web-search-probe.js +2 -3
- package/dist/core/codex-control/codex-sdk-adapter.js +5 -48
- package/dist/core/codex-control/codex-task-runner.js +16 -60
- package/dist/core/codex-control/desktop-bridge-launch-guard.js +227 -0
- package/dist/core/codex-exec-output-schema.js +11 -13
- package/dist/core/codex-lb/bridge-contracts.js +2 -0
- package/dist/core/codex-lb/bridge-runtime-validation/capability.js +104 -0
- package/dist/core/codex-lb/bridge-runtime-validation/catalog.js +52 -0
- package/dist/core/codex-lb/bridge-runtime-validation/shared.js +109 -0
- package/dist/core/codex-lb/bridge-runtime-validation/status.js +250 -0
- package/dist/core/codex-lb/bridge-runtime-validation.js +106 -0
- package/dist/core/codex-lb/capability-runner.js +505 -201
- package/dist/core/codex-lb/codex-lb-env.js +179 -12
- package/dist/core/codex-lb/combined-catalog/builder.js +86 -0
- package/dist/core/codex-lb/combined-catalog/contracts.js +5 -0
- package/dist/core/codex-lb/combined-catalog/normalize.js +170 -0
- package/dist/core/codex-lb/combined-catalog/persistence.js +207 -0
- package/dist/core/codex-lb/combined-catalog/shared.js +12 -0
- package/dist/core/codex-lb/combined-catalog/storage.js +171 -0
- package/dist/core/codex-lb/combined-catalog.js +12 -0
- package/dist/core/codex-lb/desktop-bridge/client.js +4 -1
- package/dist/core/codex-lb/desktop-bridge/header-policy.js +48 -63
- package/dist/core/codex-lb/desktop-bridge/http-forward.js +115 -83
- package/dist/core/codex-lb/desktop-bridge/launchd.js +20 -13
- package/dist/core/codex-lb/desktop-bridge/location-rewrite.js +4 -1
- package/dist/core/codex-lb/desktop-bridge/security.js +381 -267
- package/dist/core/codex-lb/desktop-bridge/server.js +148 -19
- package/dist/core/codex-lb/desktop-bridge/state.js +56 -70
- package/dist/core/codex-lb/desktop-bridge/types.js +6 -1
- package/dist/core/codex-lb/desktop-bridge/websocket-forward.js +281 -106
- package/dist/core/codex-lb/desktop-bridge-migration/historical-config.js +245 -0
- package/dist/core/codex-lb/desktop-bridge-migration/historical-toml.js +56 -0
- package/dist/core/codex-lb/desktop-bridge-migration/metadata.js +73 -0
- package/dist/core/codex-lb/desktop-bridge-migration/receipt.js +52 -0
- package/dist/core/codex-lb/desktop-bridge-migration/retired-runtime-cleanup.js +106 -0
- package/dist/core/codex-lb/desktop-bridge-migration/types.js +1 -0
- package/dist/core/codex-lb/desktop-bridge-migration.js +238 -0
- package/dist/core/codex-lb/desktop-controller-v3/catalog.js +257 -0
- package/dist/core/codex-lb/desktop-controller-v3/diagnostics.js +62 -0
- package/dist/core/codex-lb/desktop-controller-v3/lifecycle-commands.js +203 -0
- package/dist/core/codex-lb/desktop-controller-v3/live-probes.js +293 -0
- package/dist/core/codex-lb/desktop-controller-v3/preflight-probes.js +144 -0
- package/dist/core/codex-lb/desktop-controller-v3/provider-commands.js +182 -0
- package/dist/core/codex-lb/desktop-controller-v3/shared.js +279 -0
- package/dist/core/codex-lb/desktop-controller-v3/status.js +269 -0
- package/dist/core/codex-lb/desktop-controller-v3/types.js +1 -0
- package/dist/core/codex-lb/desktop-controller-v3/verification.js +89 -0
- package/dist/core/codex-lb/desktop-controller-v3.js +67 -0
- package/dist/core/codex-lb/desktop-controller.js +2 -1730
- package/dist/core/codex-lb/desktop-service.js +462 -627
- package/dist/core/codex-lb/migration-receipt.js +560 -118
- package/dist/core/codex-lb/probes/auxiliary-surfaces-probe.js +37 -53
- package/dist/core/codex-lb/probes/bridge-probe.js +125 -64
- package/dist/core/codex-lb/probes/catalog-probe.js +36 -136
- package/dist/core/codex-lb/probes/computer-use-probe.js +63 -39
- package/dist/core/codex-lb/probes/image-generation-probe.js +98 -41
- package/dist/core/codex-lb/probes/probe-evidence.js +32 -33
- package/dist/core/codex-lb/probes/voice-realtime-probe.js +69 -43
- package/dist/core/codex-lb/provider-credentials/configuration.js +127 -0
- package/dist/core/codex-lb/provider-credentials/locks.js +11 -0
- package/dist/core/codex-lb/provider-credentials/private-snapshot.js +28 -0
- package/dist/core/codex-lb/provider-credentials/removal.js +33 -0
- package/dist/core/codex-lb/provider-credentials/resolution.js +59 -0
- package/dist/core/codex-lb/provider-credentials/runtime.js +55 -0
- package/dist/core/codex-lb/provider-credentials/types.js +1 -0
- package/dist/core/codex-lb/provider-credentials/validation-store.js +137 -0
- package/dist/core/codex-lb/provider-credentials.js +5 -0
- package/dist/core/codex-lb/provider-registry.js +323 -0
- package/dist/core/codex-lb/provider-route-policy.js +118 -0
- package/dist/core/codex-lb/request-route-resolver.js +172 -0
- package/dist/core/codex-lb/route-index.js +148 -0
- package/dist/core/codex-lb/trusted-deep-evidence.js +158 -286
- package/dist/core/commands/basic-cli.js +1 -1
- package/dist/core/commands/check-command.js +3 -10
- package/dist/core/commands/gate-result-contract.js +10 -14
- package/dist/core/commands/intent-normalization/normalizer.js +1 -1
- package/dist/core/commands/mad-sks-command.js +2 -6
- package/dist/core/commands/release-command.js +11 -1
- package/dist/core/commands/telegram-command.js +46 -6
- package/dist/core/doctor/doctor-readiness-matrix.js +9 -7
- package/dist/core/doctor/skill-legacy-surface.js +5 -5
- package/dist/core/evidence/v2/evidence-key.js +30 -3
- package/dist/core/feature-fixtures.js +8 -1
- package/dist/core/feature-registry.js +3 -2
- package/dist/core/hooks-runtime/stop-finalization.js +11 -1
- package/dist/core/hooks-runtime/subagent-context.js +15 -1
- package/dist/core/hooks-runtime/subagent-skill-availability-contract.js +1 -1
- package/dist/core/hooks-runtime/tool-output-quarantine.js +1 -1
- package/dist/core/hooks-runtime.js +73 -87
- package/dist/core/image-ux-review/imagegen-adapter.js +108 -94
- package/dist/core/image-ux-review/real-callout-extractor.js +144 -14
- package/dist/core/imagegen/desktop-bridge-imagegen-target.js +77 -0
- package/dist/core/imagegen/imagegen-capability.js +43 -151
- package/dist/core/init/skills/filesystem.js +89 -0
- package/dist/core/init/skills/inventory.js +97 -0
- package/dist/core/init/skills/manifest.js +151 -0
- package/dist/core/init/skills.js +5 -325
- package/dist/core/init.js +0 -63
- package/dist/core/install/installed-package-smoke.js +1 -1
- package/dist/core/managed-assets/managed-assets-manifest.js +0 -1
- package/dist/core/policy/latest-version-guidance.js +15 -2
- package/dist/core/preflight/parallel-preflight-engine.js +27 -51
- package/dist/core/provider/provider-badge.js +9 -4
- package/dist/core/provider/provider-context.js +57 -107
- package/dist/core/providers/openrouter/openrouter-account.js +3 -1
- package/dist/core/providers/openrouter/openrouter-secret-store.js +91 -22
- package/dist/core/release/desktop-bridge-release-evidence.js +457 -0
- package/dist/core/release/gate-manifest.js +0 -1
- package/dist/core/release/main-push-guard.js +13 -0
- package/dist/core/release/main-push-receipt.js +11 -0
- package/dist/core/release/physical-release-gates.js +664 -61
- package/dist/core/release/publish-preflight.js +3 -3
- package/dist/core/release/release-gate-batch-runner.js +19 -6
- package/dist/core/release/release-gate-dag.js +33 -6
- package/dist/core/release/release-gate-node.js +1 -3
- package/dist/core/release/release-gate-output-contract.js +55 -0
- package/dist/core/release/release-pack-contract.js +1 -1
- package/dist/core/release/release-pack-receipt.js +209 -8
- package/dist/core/release/release-real-contract.js +1 -1
- package/dist/core/release/stage-publish.js +106 -28
- package/dist/core/retention/temp-lease.js +204 -0
- package/dist/core/retention.js +18 -195
- package/dist/core/routes.js +1 -2
- package/dist/core/safety/intent-contract/intent-contract.js +3 -3
- package/dist/core/subagents/naruto-host-credentials.js +6 -1
- package/dist/core/subagents/official-subagent-config.js +27 -9
- package/dist/core/subagents/official-subagent-runner.js +14 -31
- package/dist/core/subagents/wave-lifecycle.js +36 -8
- package/dist/core/subagents/wave-parent-guidance.js +2 -1
- package/dist/core/telegram/doctor.js +2 -2
- package/dist/core/telegram/liveness.js +10 -4
- package/dist/core/triwiki/context-graph/compiler/index.js +18 -18
- package/dist/core/update/update-migration-state/fast-mode-config.js +172 -0
- package/dist/core/update/update-migration-state/session-state-split.js +247 -0
- package/dist/core/update/update-migration-state/simple-stages.js +46 -0
- package/dist/core/update/update-migration-state.js +4 -481
- package/dist/core/version.js +1 -1
- package/dist/native/sks-menubar/Sources/OperationCoordinator.swift +28 -4
- package/dist/native/sks-menubar/Sources/OperationModels.swift +112 -2
- package/dist/native/sks-menubar/Sources/ProviderRouteExplanation.swift +21 -0
- package/dist/native/sks-menubar/Sources/ProvidersBridgeCatalog.swift +140 -0
- package/dist/native/sks-menubar/Sources/ProvidersOpenRouter.swift +107 -470
- package/dist/native/sks-menubar/Sources/ProvidersReliability.swift +27 -197
- package/dist/native/sks-menubar/Sources/ProvidersRoutingTruth.swift +335 -269
- package/dist/native/sks-menubar/Sources/ProvidersViewController.swift +233 -437
- package/dist/native/sks-menubar/Sources/RemoteCodingViewController.swift +16 -7
- package/dist/native/sks-menubar/Sources/SecureProcessEnvelope.swift +39 -9
- package/dist/native/sks-menubar/Sources/TelegramSupport.swift +56 -0
- package/dist/scripts/canonical-test-runner.js +7 -1
- package/dist/scripts/check-runtime-schemas.js +7 -2
- package/dist/scripts/codex-sdk-real-smoke-check.js +3 -1
- package/dist/scripts/desktop-bridge-capabilities-check.js +123 -0
- package/dist/scripts/{codex-lb-desktop-bridge-latency-check.js → desktop-bridge-latency-check.js} +61 -16
- package/dist/scripts/desktop-bridge-real-evidence-check.js +64 -0
- package/dist/scripts/{codex-lb-desktop-bridge-check.js → desktop-bridge-transport-check.js} +92 -155
- package/dist/scripts/desktop-bridge-transport-client.js +116 -0
- package/dist/scripts/desktop-bridge-unification-check.js +276 -0
- package/dist/scripts/doctor-fixes-codex-app-fast-ui-check.js +12 -8
- package/dist/scripts/gate-policy-audit-check.js +52 -2
- package/dist/scripts/provider-badge-context-check.js +55 -12
- package/dist/scripts/publish-preflight.js +1 -2
- package/dist/scripts/release-affected-selector-check.js +1 -2
- package/dist/scripts/release-aggressive-resource-governor-check.js +1 -1
- package/dist/scripts/release-cache-glob-hashing-check.js +1 -0
- package/dist/scripts/release-cache-version-neutral-fixture-check.js +1 -0
- package/dist/scripts/release-full-parallelism-blackbox.js +1 -1
- package/dist/scripts/release-gate-batch-runner-check.js +9 -0
- package/dist/scripts/release-gate-dag-runner-check.js +6 -0
- package/dist/scripts/release-gate-dag-runner.js +4 -2
- package/dist/scripts/release-metadata-check.js +16 -3
- package/dist/scripts/release-pack-receipt.js +29 -6
- package/dist/scripts/release-physical-gates-check.js +39 -0
- package/dist/scripts/release-real-check.js +7 -5
- package/package.json +6 -8
- package/release-gates.v2.json +156 -157
- package/runtime-required-scripts.json +11 -11
- package/schemas/codex/desktop-bridge-status-v3.schema.json +286 -0
- package/schemas/codex/desktop-capabilities-v3.schema.json +198 -0
- package/schemas/release/release-gate-node.schema.json +2 -3
- package/dist/cli/codex-lb-setup-warning-output.js +0 -17
- package/dist/cli/install-helpers-codex-lb-chain.js +0 -529
- package/dist/commands/codex-lb.js +0 -1232
- package/dist/core/architecture-hardening/migration/migration.js +0 -111
- package/dist/core/codex-app/auxiliary-oauth-policy.js +0 -36
- package/dist/core/codex-app/catalog-compat/catalog-service.js +0 -104
- package/dist/core/codex-app/child-policy/child-policy.js +0 -35
- package/dist/core/codex-app/desktop-routing-snapshot.js +0 -233
- package/dist/core/codex-app/glm-model-profile.js +0 -1
- package/dist/core/codex-app/glm-profile-installer.js +0 -191
- package/dist/core/codex-app/glm-profile-schema.js +0 -42
- package/dist/core/codex-app/multi-provider-router.js +0 -391
- package/dist/core/codex-app/openrouter-activate.js +0 -405
- package/dist/core/codex-app/openrouter-model-catalog.js +0 -217
- package/dist/core/codex-app/provider-child-policy.js +0 -64
- package/dist/core/codex-app/provider-mode.js +0 -91
- package/dist/core/codex-app/provider-session-policy.js +0 -85
- package/dist/core/codex-app/session-policy/session-pinning.js +0 -68
- package/dist/core/codex-control/codex-lb-launch-recovery.js +0 -319
- package/dist/core/codex-lb/codex-lb-setup.js +0 -293
- package/dist/core/codex-lb/codex-lb-tool-catalog.js +0 -456
- package/dist/core/codex-lb/codex-lb-tool-output-recovery.js +0 -290
- package/dist/core/codex-lb/desktop-center-credentials.js +0 -1083
- package/dist/core/codex-lb/desktop-mode.js +0 -32
- package/dist/core/codex-lb/desktop-real-evidence.js +0 -168
- package/dist/core/codex-lb/legacy-migration.js +0 -576
- package/dist/core/codex-lb/native-openai-transport/transport.js +0 -68
- package/dist/core/codex-lb/provider-routing/provider-router.js +0 -58
- package/dist/core/codex-lb/routing-truth.js +0 -327
- package/dist/core/imagegen/codex-lb-imagegen-target.js +0 -92
- package/dist/native/sks-menubar/Sources/ProvidersConnectTest.swift +0 -118
- package/dist/native/sks-menubar/Sources/ProvidersFastMode.swift +0 -17
- package/dist/native/sks-menubar/Sources/ProvidersMultiProvider.swift +0 -331
- package/dist/native/sks-menubar/Sources/ProvidersRoleModels.swift +0 -260
- package/dist/scripts/codex-lb-catalog-passthrough-check.js +0 -120
- package/dist/scripts/codex-lb-desktop-auth-invariant-check.js +0 -169
- package/dist/scripts/codex-lb-desktop-capabilities-check.js +0 -287
- package/dist/scripts/codex-lb-desktop-real-evidence-check.js +0 -123
- package/dist/scripts/codex-lb-fast-mode-truth-check.js +0 -114
- package/dist/scripts/codex-lb-fast-ui-preservation-check.js +0 -152
- package/dist/scripts/codex-lb-gpt56-fast-profile-check.js +0 -231
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
import { codexLbBaseUrlSecurityBlocker, normalizeCodexLbBaseUrl } from './codex-lb-env.js';
|
|
2
|
-
import { redactString } from '../secret-redaction.js';
|
|
3
|
-
export const CODEX_LB_TOOL_OUTPUT_RECOVERY_SCHEMA = 'sks.codex-lb-tool-output-recovery.v1';
|
|
4
|
-
export const CODEX_LB_TOOL_OUTPUT_RECOVERY_MIN_VERSION = '1.21.0-beta.3';
|
|
5
|
-
export const CODEX_LB_TOOL_OUTPUT_RECOVERY_OVERRIDE_ENV = 'SKS_ALLOW_UNVERIFIED_CODEX_LB_RECOVERY';
|
|
6
|
-
export const CODEX_LB_TOOL_OUTPUT_RECOVERY_OVERRIDE_FLAG = '--allow-unverified-codex-lb-recovery';
|
|
7
|
-
const UPGRADE_ACTION = `Upgrade codex-lb to ${CODEX_LB_TOOL_OUTPUT_RECOVERY_MIN_VERSION} or later, then rerun \`sks codex-lb status\`.`;
|
|
8
|
-
const OAUTH_ACTION = 'To bypass codex-lb routing while preserving ChatGPT OAuth, run `sks codex-lb disable`; SKS will not change routing silently.';
|
|
9
|
-
const FRESH_THREAD_ACTION = 'After upgrading or switching providers, open a fresh Codex thread and continue the persisted mission; do not replay the corrupted turn.';
|
|
10
|
-
export async function probeCodexLbToolOutputRecovery(opts = {}) {
|
|
11
|
-
const baseUrl = normalizeCodexLbBaseUrl(opts.baseUrl);
|
|
12
|
-
if (!baseUrl) {
|
|
13
|
-
return blockedProbe('invalid_base_url', {
|
|
14
|
-
baseUrl: null,
|
|
15
|
-
healthUrl: null,
|
|
16
|
-
blockers: ['codex_lb_tool_output_recovery_base_url_missing']
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
const transportBlocker = codexLbBaseUrlSecurityBlocker(baseUrl);
|
|
20
|
-
if (transportBlocker) {
|
|
21
|
-
return blockedProbe('transport_blocked', {
|
|
22
|
-
baseUrl,
|
|
23
|
-
healthUrl: codexLbHealthUrl(baseUrl),
|
|
24
|
-
blockers: [transportBlocker]
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
const healthUrl = codexLbHealthUrl(baseUrl);
|
|
28
|
-
if (!healthUrl) {
|
|
29
|
-
return blockedProbe('invalid_base_url', {
|
|
30
|
-
baseUrl,
|
|
31
|
-
healthUrl: null,
|
|
32
|
-
blockers: ['codex_lb_tool_output_recovery_base_url_invalid']
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
if (opts.allowReservedTestHostBypass === true && isReservedTestHost(baseUrl)) {
|
|
36
|
-
return {
|
|
37
|
-
...baseProbe(baseUrl, healthUrl),
|
|
38
|
-
ok: true,
|
|
39
|
-
status: 'skipped_reserved_host',
|
|
40
|
-
required: false,
|
|
41
|
-
test_bypass: true
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
const fetchImpl = opts.fetchImpl || globalThis.fetch;
|
|
45
|
-
if (typeof fetchImpl !== 'function') {
|
|
46
|
-
return applyCodexLbToolOutputRecoveryOverride(blockedProbe('probe_unavailable', {
|
|
47
|
-
baseUrl,
|
|
48
|
-
healthUrl,
|
|
49
|
-
blockers: ['codex_lb_tool_output_recovery_probe_unavailable']
|
|
50
|
-
}), opts.allowUnverified === true);
|
|
51
|
-
}
|
|
52
|
-
const controller = new AbortController();
|
|
53
|
-
const timeoutMs = Math.max(250, Number(opts.timeoutMs || 4_000));
|
|
54
|
-
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
55
|
-
timer.unref?.();
|
|
56
|
-
try {
|
|
57
|
-
const response = await fetchImpl(healthUrl, {
|
|
58
|
-
method: 'GET',
|
|
59
|
-
headers: { accept: 'application/json' },
|
|
60
|
-
redirect: 'error',
|
|
61
|
-
signal: controller.signal
|
|
62
|
-
});
|
|
63
|
-
if (!response.ok) {
|
|
64
|
-
return applyCodexLbToolOutputRecoveryOverride(blockedProbe('probe_unavailable', {
|
|
65
|
-
baseUrl,
|
|
66
|
-
healthUrl,
|
|
67
|
-
httpStatus: response.status,
|
|
68
|
-
blockers: [`codex_lb_tool_output_recovery_health_http_error:${response.status}`]
|
|
69
|
-
}), opts.allowUnverified === true);
|
|
70
|
-
}
|
|
71
|
-
const observedVersion = normalizeCodexLbVersion(response.headers.get('x-app-version'));
|
|
72
|
-
if (!observedVersion) {
|
|
73
|
-
return applyCodexLbToolOutputRecoveryOverride(blockedProbe('version_unverified', {
|
|
74
|
-
baseUrl,
|
|
75
|
-
healthUrl,
|
|
76
|
-
httpStatus: response.status,
|
|
77
|
-
blockers: ['codex_lb_tool_output_recovery_version_unverified']
|
|
78
|
-
}), opts.allowUnverified === true);
|
|
79
|
-
}
|
|
80
|
-
const compatible = compareCodexLbVersions(observedVersion, CODEX_LB_TOOL_OUTPUT_RECOVERY_MIN_VERSION) >= 0;
|
|
81
|
-
const result = {
|
|
82
|
-
...baseProbe(baseUrl, healthUrl),
|
|
83
|
-
ok: compatible,
|
|
84
|
-
status: compatible ? 'compatible' : 'version_too_old',
|
|
85
|
-
observed_version: observedVersion,
|
|
86
|
-
supports_interrupted_tool_output_recovery: compatible,
|
|
87
|
-
verified: true,
|
|
88
|
-
http_status: response.status,
|
|
89
|
-
blockers: compatible ? [] : ['codex_lb_tool_output_recovery_version_too_old']
|
|
90
|
-
};
|
|
91
|
-
return applyCodexLbToolOutputRecoveryOverride(result, opts.allowUnverified === true);
|
|
92
|
-
}
|
|
93
|
-
catch (err) {
|
|
94
|
-
const error = err instanceof Error
|
|
95
|
-
? err.name === 'AbortError' ? 'codex-lb health probe timed out' : redactCodexLbProbeText(err.message)
|
|
96
|
-
: redactCodexLbProbeText(String(err));
|
|
97
|
-
return applyCodexLbToolOutputRecoveryOverride(blockedProbe('probe_unavailable', {
|
|
98
|
-
baseUrl,
|
|
99
|
-
healthUrl,
|
|
100
|
-
blockers: ['codex_lb_tool_output_recovery_probe_failed'],
|
|
101
|
-
error
|
|
102
|
-
}), opts.allowUnverified === true);
|
|
103
|
-
}
|
|
104
|
-
finally {
|
|
105
|
-
clearTimeout(timer);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
export function codexLbToolOutputRecoveryNotSelected() {
|
|
109
|
-
return {
|
|
110
|
-
...baseProbe(null, null),
|
|
111
|
-
ok: true,
|
|
112
|
-
required: false,
|
|
113
|
-
status: 'not_selected'
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
export function codexLbToolOutputRecoveryNotChecked(required = false) {
|
|
117
|
-
return {
|
|
118
|
-
...baseProbe(null, null),
|
|
119
|
-
ok: !required,
|
|
120
|
-
required,
|
|
121
|
-
status: 'not_checked',
|
|
122
|
-
blockers: required ? ['codex_lb_tool_output_recovery_not_checked'] : []
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
export function codexLbToolOutputRecoveryOverrideAcknowledged(input = {}) {
|
|
126
|
-
const args = (input.args || []).map((arg) => String(arg));
|
|
127
|
-
const env = input.env || process.env;
|
|
128
|
-
return args.includes(CODEX_LB_TOOL_OUTPUT_RECOVERY_OVERRIDE_FLAG)
|
|
129
|
-
|| env[CODEX_LB_TOOL_OUTPUT_RECOVERY_OVERRIDE_ENV] === '1';
|
|
130
|
-
}
|
|
131
|
-
export function applyCodexLbToolOutputRecoveryOverride(probe, acknowledged) {
|
|
132
|
-
if (probe.ok || !acknowledged)
|
|
133
|
-
return probe;
|
|
134
|
-
return {
|
|
135
|
-
...probe,
|
|
136
|
-
ok: true,
|
|
137
|
-
status: 'override_acknowledged',
|
|
138
|
-
override_acknowledged: true,
|
|
139
|
-
blockers: [],
|
|
140
|
-
warnings: [
|
|
141
|
-
...probe.warnings,
|
|
142
|
-
`Operator explicitly acknowledged unverified codex-lb tool-output recovery via ${CODEX_LB_TOOL_OUTPUT_RECOVERY_OVERRIDE_FLAG} or ${CODEX_LB_TOOL_OUTPUT_RECOVERY_OVERRIDE_ENV}=1.`,
|
|
143
|
-
...probe.blockers
|
|
144
|
-
]
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
export function codexLbHealthUrl(baseUrl) {
|
|
148
|
-
try {
|
|
149
|
-
const parsed = new URL(normalizeCodexLbBaseUrl(baseUrl));
|
|
150
|
-
return new URL('/health', parsed.origin).toString();
|
|
151
|
-
}
|
|
152
|
-
catch {
|
|
153
|
-
return null;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
export function normalizeCodexLbVersion(value) {
|
|
157
|
-
const match = String(value || '').trim().match(/v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?/);
|
|
158
|
-
if (!match)
|
|
159
|
-
return null;
|
|
160
|
-
const major = Number(match[1]);
|
|
161
|
-
const minor = Number(match[2]);
|
|
162
|
-
const patch = Number(match[3]);
|
|
163
|
-
if (![major, minor, patch].every(Number.isSafeInteger))
|
|
164
|
-
return null;
|
|
165
|
-
return `${major}.${minor}.${patch}${match[4] ? `-${match[4]}` : ''}`;
|
|
166
|
-
}
|
|
167
|
-
export function compareCodexLbVersions(left, right) {
|
|
168
|
-
const a = parseVersion(left);
|
|
169
|
-
const b = parseVersion(right);
|
|
170
|
-
if (!a || !b)
|
|
171
|
-
return -1;
|
|
172
|
-
for (let index = 0; index < 3; index += 1) {
|
|
173
|
-
const delta = (a.core[index] || 0) - (b.core[index] || 0);
|
|
174
|
-
if (delta !== 0)
|
|
175
|
-
return delta > 0 ? 1 : -1;
|
|
176
|
-
}
|
|
177
|
-
if (!a.pre.length && !b.pre.length)
|
|
178
|
-
return 0;
|
|
179
|
-
if (!a.pre.length)
|
|
180
|
-
return 1;
|
|
181
|
-
if (!b.pre.length)
|
|
182
|
-
return -1;
|
|
183
|
-
const length = Math.max(a.pre.length, b.pre.length);
|
|
184
|
-
for (let index = 0; index < length; index += 1) {
|
|
185
|
-
const aPart = a.pre[index];
|
|
186
|
-
const bPart = b.pre[index];
|
|
187
|
-
if (aPart === undefined)
|
|
188
|
-
return -1;
|
|
189
|
-
if (bPart === undefined)
|
|
190
|
-
return 1;
|
|
191
|
-
if (aPart === bPart)
|
|
192
|
-
continue;
|
|
193
|
-
const aNumber = /^\d+$/.test(aPart) ? Number(aPart) : null;
|
|
194
|
-
const bNumber = /^\d+$/.test(bPart) ? Number(bPart) : null;
|
|
195
|
-
if (aNumber !== null && bNumber !== null)
|
|
196
|
-
return aNumber > bNumber ? 1 : -1;
|
|
197
|
-
if (aNumber !== null)
|
|
198
|
-
return -1;
|
|
199
|
-
if (bNumber !== null)
|
|
200
|
-
return 1;
|
|
201
|
-
return aPart > bPart ? 1 : -1;
|
|
202
|
-
}
|
|
203
|
-
return 0;
|
|
204
|
-
}
|
|
205
|
-
function baseProbe(baseUrl, healthUrl) {
|
|
206
|
-
return {
|
|
207
|
-
schema: CODEX_LB_TOOL_OUTPUT_RECOVERY_SCHEMA,
|
|
208
|
-
ok: false,
|
|
209
|
-
required: true,
|
|
210
|
-
status: 'version_unverified',
|
|
211
|
-
base_url: redactCodexLbProbeUrl(baseUrl),
|
|
212
|
-
health_url: redactCodexLbProbeUrl(healthUrl),
|
|
213
|
-
observed_version: null,
|
|
214
|
-
minimum_version: CODEX_LB_TOOL_OUTPUT_RECOVERY_MIN_VERSION,
|
|
215
|
-
version_header: 'x-app-version',
|
|
216
|
-
supports_interrupted_tool_output_recovery: null,
|
|
217
|
-
verified: false,
|
|
218
|
-
override_acknowledged: false,
|
|
219
|
-
test_bypass: false,
|
|
220
|
-
http_status: null,
|
|
221
|
-
blockers: [],
|
|
222
|
-
warnings: [],
|
|
223
|
-
operator_actions: [UPGRADE_ACTION, OAUTH_ACTION, FRESH_THREAD_ACTION]
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
function blockedProbe(status, input) {
|
|
227
|
-
return {
|
|
228
|
-
...baseProbe(input.baseUrl, input.healthUrl),
|
|
229
|
-
status,
|
|
230
|
-
blockers: input.blockers,
|
|
231
|
-
...(input.httpStatus === undefined ? {} : { http_status: input.httpStatus }),
|
|
232
|
-
...(input.error === undefined ? {} : { error: redactCodexLbProbeText(input.error) })
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
function redactCodexLbProbeUrl(value) {
|
|
236
|
-
if (!value)
|
|
237
|
-
return null;
|
|
238
|
-
try {
|
|
239
|
-
const parsed = new URL(value);
|
|
240
|
-
parsed.username = '';
|
|
241
|
-
parsed.password = '';
|
|
242
|
-
parsed.hash = '';
|
|
243
|
-
for (const key of [...parsed.searchParams.keys()]) {
|
|
244
|
-
if (/(?:access[_-]?token|api[_-]?key|secret|password|token|credential)/i.test(key)) {
|
|
245
|
-
parsed.searchParams.set(key, 'redacted');
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
return redactCodexLbProbeText(parsed.toString());
|
|
249
|
-
}
|
|
250
|
-
catch {
|
|
251
|
-
return redactCodexLbProbeText(value);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
function redactCodexLbProbeText(value) {
|
|
255
|
-
return redactString(String(value || ''))
|
|
256
|
-
.replace(/([a-z][a-z0-9+.-]*:\/\/)[^/@\s]+@/gi, '$1[redacted]@')
|
|
257
|
-
.replace(/([?&](?:access[_-]?token|api[_-]?key|secret|password|token|credential)=)[^&#\s]*/gi, '$1[redacted]')
|
|
258
|
-
.replace(/(\b(?:access[_-]?token|api[_-]?key|secret|password|token|credential)\s*[:=]\s*)(?:\[redacted\]|"[^"]*"|'[^']*'|[^\s,;}\]]+)/gi, '$1[redacted]');
|
|
259
|
-
}
|
|
260
|
-
function parseVersion(value) {
|
|
261
|
-
const normalized = normalizeCodexLbVersion(value);
|
|
262
|
-
if (!normalized)
|
|
263
|
-
return null;
|
|
264
|
-
const [coreText = '', preText = ''] = normalized.split('-', 2);
|
|
265
|
-
const coreParts = coreText.split('.').map(Number);
|
|
266
|
-
const major = coreParts[0];
|
|
267
|
-
const minor = coreParts[1];
|
|
268
|
-
const patch = coreParts[2];
|
|
269
|
-
if (major === undefined || minor === undefined || patch === undefined)
|
|
270
|
-
return null;
|
|
271
|
-
return { core: [major, minor, patch], pre: preText ? preText.split('.') : [] };
|
|
272
|
-
}
|
|
273
|
-
function isReservedTestHost(baseUrl) {
|
|
274
|
-
try {
|
|
275
|
-
const hostname = new URL(baseUrl).hostname.toLowerCase();
|
|
276
|
-
return hostname === 'example.test'
|
|
277
|
-
|| hostname.endsWith('.example.test')
|
|
278
|
-
|| hostname === 'example.invalid'
|
|
279
|
-
|| hostname.endsWith('.example.invalid')
|
|
280
|
-
|| hostname === 'example.com'
|
|
281
|
-
|| hostname.endsWith('.example.com')
|
|
282
|
-
|| hostname === 'example.org'
|
|
283
|
-
|| hostname.endsWith('.example.org')
|
|
284
|
-
|| hostname === 'example.net'
|
|
285
|
-
|| hostname.endsWith('.example.net');
|
|
286
|
-
}
|
|
287
|
-
catch {
|
|
288
|
-
return false;
|
|
289
|
-
}
|
|
290
|
-
}
|