mirror of
https://github.com/stablyai/orca.git
synced 2026-11-05 19:47:27 +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
50 lines
1.6 KiB
TypeScript
50 lines
1.6 KiB
TypeScript
import { isValidAppVersion } from './app-version'
|
|
import type { CodexInstallationProblem } from './codex-cli-installation'
|
|
import type { TuiAgent } from './tui-agent'
|
|
import { isTuiAgent } from './tui-agent-config'
|
|
|
|
/** A chat start refused because the agent's binary is older than its chats need; names the agent
|
|
* so a replayed or phone refusal says whose without the chat. */
|
|
export type AgentCliInstallationProblem = {
|
|
agent: TuiAgent
|
|
installedVersion: string
|
|
minimumVersion: string
|
|
}
|
|
|
|
export function readAgentCliInstallationProblem(
|
|
value: unknown
|
|
): AgentCliInstallationProblem | undefined {
|
|
if (
|
|
typeof value !== 'object' ||
|
|
value === null ||
|
|
!('agent' in value) ||
|
|
!('installedVersion' in value) ||
|
|
!('minimumVersion' in value) ||
|
|
!isTuiAgent(value.agent) ||
|
|
typeof value.installedVersion !== 'string' ||
|
|
!isValidAppVersion(value.installedVersion) ||
|
|
typeof value.minimumVersion !== 'string' ||
|
|
!isValidAppVersion(value.minimumVersion)
|
|
) {
|
|
return undefined
|
|
}
|
|
return {
|
|
agent: value.agent,
|
|
installedVersion: value.installedVersion,
|
|
minimumVersion: value.minimumVersion
|
|
}
|
|
}
|
|
|
|
/** A refusal's facts for `problem`; Codex's are also sent the way clients before
|
|
* `agentInstallation` read them. */
|
|
export function agentCliInstallationFacts(problem: AgentCliInstallationProblem): {
|
|
agentInstallation: AgentCliInstallationProblem
|
|
codexInstallation?: CodexInstallationProblem
|
|
} {
|
|
const { agent, installedVersion, minimumVersion } = problem
|
|
return {
|
|
agentInstallation: problem,
|
|
...(agent === 'codex' ? { codexInstallation: { installedVersion, minimumVersion } } : {})
|
|
}
|
|
}
|