Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.
TypeScript adeagent-ideai-agentsautomationbotclaude-codecodexghosttygrok-bothermes-agentmobile-appmuseopenclawopencodeorchestrationpiruntimeterminalworktreesyc-backed
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))
)
}