mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 00:57:45 +00:00
* fix(native-chat): agents need only a minimum version for chat; newer releases and prereleases run OpenCode chats accepted only the 1.x and 2.x lines and Pi only 0.x and 1.x, every prerelease was refused, and a slow or failed --version run counted as unsupported. A new major would open as a terminal and existing chats said "Orca can't run this agent in a chat here." Each agent now lists ascending minimum versions; a version must reach the latest one on or below its own major line, compared by semver. The check answers ready, too old, unknown (slow, failed or wordless run) or missing (did not start). Only too old refuses a launch, as Codex already did, with "<Agent> X is too old for chats. Update to Y or newer." carried in a new optional refusal fact agentInstallation; Codex keeps sending codexInstallation for older clients. Codex's reader and error fold into the same check. * refactor(native-chat): a launch check declares its minimum versions; create support and the agent health snapshot run the one shared check * fix(native-chat): read an agent's version from stderr too, so Pi 0.73 is known too old instead of unreadable
39 lines
1.5 KiB
TypeScript
39 lines
1.5 KiB
TypeScript
import { isValidAppVersion, parseCliVersion } from './app-version'
|
|
|
|
export const CODEX_MINIMUM_SUPPORTED_VERSION = '0.136.0'
|
|
|
|
/** Codex's binary problem in the shape builds before `agentInstallation` send and save. */
|
|
export type CodexInstallationProblem = {
|
|
installedVersion: string | null
|
|
minimumVersion: string
|
|
}
|
|
|
|
export function parseCodexCliVersion(output: string | null | undefined): string | null {
|
|
const lines = output?.split(/\r?\n/).map((line) => line.trim()) ?? []
|
|
const identified = lines.filter((line) => /^codex(?:-cli)?\s/i.test(line))
|
|
const candidates = identified.length ? identified : lines.filter(Boolean)
|
|
const versions = candidates.map((line) => {
|
|
const value = line.replace(/^codex(?:-cli)?\s+/i, '').replace(/^v/i, '')
|
|
return isValidAppVersion(value) ? parseCliVersion(value) : null
|
|
})
|
|
return versions.length && versions.every((version) => version !== null && version === versions[0])
|
|
? versions[0]
|
|
: null
|
|
}
|
|
|
|
export function readCodexInstallationProblem(value: unknown): CodexInstallationProblem | undefined {
|
|
if (
|
|
typeof value !== 'object' ||
|
|
value === null ||
|
|
!('installedVersion' in value) ||
|
|
!('minimumVersion' in value) ||
|
|
(value.installedVersion !== null &&
|
|
(typeof value.installedVersion !== 'string' || !isValidAppVersion(value.installedVersion))) ||
|
|
typeof value.minimumVersion !== 'string' ||
|
|
!isValidAppVersion(value.minimumVersion)
|
|
) {
|
|
return undefined
|
|
}
|
|
return { installedVersion: value.installedVersion, minimumVersion: value.minimumVersion }
|
|
}
|