Files
orca/src/main/opencode/opencode-model-version-policy.ts
T
Neil e575cc19a3 fix(opencode): refuse model launches on OpenCode 2.x releases that drop the startup prompt (#33436)
OpenCode 2.x model-selection launches require 2.0.19+ (upstream #51938 waits for agent/model before auto-submitting --prompt) or a native-prompt version (2.0.12, 2.0.16), fixing a regression from #33307 where 2.0.14/15/17/18 accepted a picked model but silently dropped the first prompt.
2026-10-24 23:56:27 -07:00

31 lines
1.2 KiB
TypeScript

import { compareAppVersions } from '../../shared/app-version'
import { OPENCODE_NATIVE_PROMPT_VERSIONS } from '../../shared/opencode-cli-version'
// Real-CLI-verified floors, capped to their major: a new major may change the model route.
const LEGACY_FLAG_MODEL_FLOOR = '1.18.30'
const CONFIG_OVERLAY_MODEL_FLOOR = '2.0.14'
// Earlier 2.x submits --prompt before agent/model load and drops it (upstream #51938).
const NATIVE_PROMPT_SUBMIT_FLOOR = '2.0.19'
function isStableReleaseFrom(version: string | null | undefined, floor: string): boolean {
const major = floor.split('.')[0]
return (
typeof version === 'string' &&
/^\d+\.\d+\.\d+$/.test(version) &&
version.split('.')[0] === major &&
compareAppVersions(version, floor) >= 0
)
}
export function isVerifiedOpenCodeLegacyModelVersion(version: string | null | undefined): boolean {
return isStableReleaseFrom(version, LEGACY_FLAG_MODEL_FLOOR)
}
export function isVerifiedOpenCodeConfigModelVersion(version: string | null | undefined): boolean {
return (
isStableReleaseFrom(version, CONFIG_OVERLAY_MODEL_FLOOR) &&
(isStableReleaseFrom(version, NATIVE_PROMPT_SUBMIT_FLOOR) ||
OPENCODE_NATIVE_PROMPT_VERSIONS.some((supported) => supported === version))
)
}