mirror of
https://github.com/stablyai/orca.git
synced 2026-11-06 03:57:35 +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
73 lines
2.6 KiB
TypeScript
73 lines
2.6 KiB
TypeScript
import {
|
|
readWholeAgentSessionFailureFact,
|
|
type AgentSessionFailureFact
|
|
} from './agent-session-failure'
|
|
import type { AgentJournalRenderItem } from './agent-session-journal-types'
|
|
import { isStructuredAgentSessionStartFailureRow } from './structured-agent-session-start-failure-row-key'
|
|
|
|
/** Loaded startup causes and authentication explanations already visible in the transcript. */
|
|
export function agentSessionVisibleFailureFacts(
|
|
items: readonly AgentJournalRenderItem[]
|
|
): AgentSessionFailureFact[] {
|
|
const facts: AgentSessionFailureFact[] = []
|
|
for (const item of items) {
|
|
if (item.body.kind === 'status') {
|
|
const fact = readWholeAgentSessionFailureFact(item.body.failure)
|
|
if (
|
|
fact &&
|
|
(isStructuredAgentSessionStartFailureRow(item.itemId) || fact.kind === 'notSignedIn')
|
|
) {
|
|
facts.push(fact)
|
|
}
|
|
}
|
|
}
|
|
return facts
|
|
}
|
|
|
|
function sameInstallation(
|
|
a: { installedVersion: string | null; minimumVersion: string } | undefined,
|
|
b: { installedVersion: string | null; minimumVersion: string } | undefined
|
|
): boolean {
|
|
return a?.installedVersion === b?.installedVersion && a?.minimumVersion === b?.minimumVersion
|
|
}
|
|
|
|
/** Whether two facts are one failure: a start's row and the messages it rejected share one. */
|
|
export function sameAgentSessionFailureFact(
|
|
a: AgentSessionFailureFact,
|
|
b: AgentSessionFailureFact
|
|
): boolean {
|
|
return (
|
|
a.kind === b.kind &&
|
|
a.account === b.account &&
|
|
a.detail?.text === b.detail?.text &&
|
|
a.detail?.audience === b.detail?.audience &&
|
|
a.refusal?.code === b.refusal?.code &&
|
|
a.refusal?.details?.reason === b.refusal?.details?.reason &&
|
|
(a.refusal?.code !== 'agent_session_operation_invalid' ||
|
|
b.refusal?.code !== 'agent_session_operation_invalid' ||
|
|
(sameInstallation(
|
|
a.refusal.details?.agentInstallation,
|
|
b.refusal.details?.agentInstallation
|
|
) &&
|
|
sameInstallation(
|
|
a.refusal.details?.codexInstallation,
|
|
b.refusal.details?.codexInstallation
|
|
))) &&
|
|
a.attachment?.reason === b.attachment?.reason &&
|
|
a.attachment?.limit === b.attachment?.limit &&
|
|
a.retry?.error === b.retry?.error &&
|
|
a.retry?.status === b.retry?.status
|
|
)
|
|
}
|
|
|
|
/** Whether a loaded row already states this failure, comparing facts rather than wording. */
|
|
export function agentSessionFailureStatedByRow(
|
|
failure: unknown,
|
|
statedFailures: readonly AgentSessionFailureFact[]
|
|
): boolean {
|
|
const fact = readWholeAgentSessionFailureFact(failure)
|
|
return (
|
|
fact !== undefined && statedFailures.some((stated) => sameAgentSessionFailureFact(stated, fact))
|
|
)
|
|
}
|