Skip to content

armgit / orca

Public Imported from GitHub
0

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.

1.1 KB
Raw Blame
import {
  isAgentSessionConversationCommand,
  type AgentSessionConversationCommandResult
} from './agent-session/agent-session-conversation-command'
import { readWholeAgentSessionFailureFact } from './agent-session-failure'
import type { StructuredAgentSessionCommandRefusalCause } from './structured-agent-session-composer'

/** Host refusal reasons that map to visible chat conditions. */
const CAUSE_OF_HOST_REFUSAL: Partial<Record<string, StructuredAgentSessionCommandRefusalCause>> = {
  turnActive: 'working',
  messagesUnsettled: 'working',
  promptPending: 'prompt',
  backgroundTasksRunning: 'background'
}

/** Map only fully readable host refusals; other failures have no waiting condition. */
export function structuredAgentSessionCommandHostRefusalCause(
  result: AgentSessionConversationCommandResult
): StructuredAgentSessionCommandRefusalCause | undefined {
  const details = isAgentSessionConversationCommand(result.command)
    ? readWholeAgentSessionFailureFact(result.failure)?.refusal?.details
    : undefined
  return details && 'reason' in details && typeof details.reason === 'string'
    ? CAUSE_OF_HOST_REFUSAL[details.reason]
    : undefined
}