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.

874 B
Raw Blame
import type { PairedE2EEClientHandshake } from '../../paired-e2ee-client-handshake'
import type WebSocket from 'ws'
import type {
  SharedControlConnectionState,
  SharedControlReadyWaiter
} from './remote-runtime-shared-control-types'
import {
  isSharedControlReady,
  waitForSharedControlReadyWithTimeout
} from './remote-runtime-shared-control-ready'

export function ensureSharedControlReady(args: {
  state: SharedControlConnectionState
  ws: WebSocket | null
  handshake: PairedE2EEClientHandshake | null
  readyWaiters: SharedControlReadyWaiter[]
  timeoutMs: number
  signal?: AbortSignal
  open: () => void
}): Promise<void> {
  if (isSharedControlReady(args)) {
    return Promise.resolve()
  }
  return waitForSharedControlReadyWithTimeout({
    readyWaiters: args.readyWaiters,
    timeoutMs: args.timeoutMs,
    signal: args.signal,
    open: args.open
  })
}