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.

4.0 KB
Raw Blame
import type { AgentSessionSlashCommand } from '../../../src/shared/agent-session-wire'
import type { RpcClient } from '../transport/rpc-client'
import type { StructuredAgentSessionHostSupport } from './mobile-structured-agent-session-host-support'
import type { MobileNativeChatSendOutcome } from './native-chat/mobile-native-chat-send'
import type { MobileNativeChatVisualSource } from './native-chat/visual/mobile-native-chat-visual-read'
import type { MobileChatPermission } from './native-chat/input/mobile-native-chat-permission'
import type { MobileChatQuestion } from './native-chat/input/mobile-native-chat-question'
import type { MobileNativeChatSession } from './use-mobile-native-chat-session'
import type { NativeChatLiveTurnIndicator } from '../../../src/shared/native-chat-turn-status'
import type { NativeChatResolvedPrompt } from '../../../src/shared/native-chat-resolution-receipt'
import type { useMobileStructuredAgentOptions } from './use-mobile-structured-agent-options'
import type { useMobileStructuredAgentTurnTiming } from './use-mobile-structured-agent-turn-timing'
import type { StructuredMobileSendAttachment } from './use-mobile-structured-send-with-outcome'
import type { AgentJournalSkillRef } from '../../../src/shared/agent-session-journal-types'
import type {
  MobileNativeChatCommandRefusalCauses,
  MobileNativeChatSendErrorReporter
} from './native-chat/use-mobile-native-chat-send-error'
import type { MobileStructuredQueuedMessageControls } from './use-mobile-structured-queued-message-controls'
import type { MobileStructuredBackgroundTasks } from './use-mobile-structured-background-tasks'

export type StructuredMobileSession = ReturnType<typeof useMobileStructuredAgentOptions> &
  ReturnType<typeof useMobileStructuredAgentTurnTiming> & {
    session: MobileNativeChatSession
    asyncQuestionSourceScope: string
    isWorking: boolean
    /** Desktop's Stop rule: a running turn, or conversation Stop while working or sending. */
    canStop: boolean
    turnId: string | null
    turnIndicator: NativeChatLiveTurnIndicator
    sendWithOutcome: (
      text: string,
      images?: string[],
      deadline?: number,
      attachments?: readonly StructuredMobileSendAttachment[],
      skills?: readonly AgentJournalSkillRef[]
    ) => Promise<MobileNativeChatSendOutcome>
    cancel: () => void
    receipts: ReadonlyMap<string, NativeChatResolvedPrompt>
    /** Undefined from a host too old to say. */
    actionablePromptIds: readonly string[] | undefined
    permission: MobileChatPermission | null
    question: MobileChatQuestion | null
    respondPermission: (optionId: string) => Promise<boolean>
    respondQuestion: (answer: string, prompt?: MobileChatQuestion['prompt']) => Promise<boolean>
    cancelPrompt: (prompt?: { itemId: string; expectedRevision: number }) => Promise<boolean>
    queued: MobileStructuredQueuedMessageControls
    commandRefusalCauses: MobileNativeChatCommandRefusalCauses
    backgroundTasks: MobileStructuredBackgroundTasks
    visualSource: MobileNativeChatVisualSource | null
    imagePreviewsByMessageId: Record<string, string[]>
  }

export type MobileStructuredAgentSessionArgs = {
  client: RpcClient | null
  sessionId: string | null
  /** Host/workspace scope used to keep same provider ids isolated. */
  sourceIdentity?: string
  enabled: boolean
  /** Live transport only; gates the connection-scoped hold, and whether child rows may read live. */
  connected: boolean
  /** Capability facts from the shared runtime status probe; null follows the legacy wire. */
  hostSupport: StructuredAgentSessionHostSupport | null
  agent: string | null
  /** What the session reported for its `/` menu; undefined until read or on an older host. */
  onCommandsChanged?: () => void
  sessionCommands?: readonly AgentSessionSlashCommand[]
  composerScopeKey?: string | null
  appendComposerText?: (text: string) => boolean
  onQueuedEditNotice?: (message: string) => void
  onSendError: MobileNativeChatSendErrorReporter
  // Accepted queued actions retire the route’s failure banner.
  onActionResolved?: () => void
}