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.6 KB
Raw Blame
// APNs nests custom fields under orca; FCM data is flat/string-valued. Read both and coerce numeric fields.
export type OrcaPushPayload = {
  readonly kind?: 'alert' | 'dismiss'
  readonly hostFingerprint: string
  readonly notificationId?: string
  readonly notificationSeq?: number
  readonly notificationEpoch?: string
  readonly paneKey?: string
  readonly worktreeId?: string
  readonly executionHost?: string
}

function readString(value: unknown): string | undefined {
  return typeof value === 'string' && value.length > 0 ? value : undefined
}

function readSeq(value: unknown): number | undefined {
  const raw = typeof value === 'number' ? value : Number(readString(value))
  return Number.isFinite(raw) ? raw : undefined
}

export function readOrcaPushPayload(data: unknown): OrcaPushPayload | null {
  if (!data || typeof data !== 'object') {
    return null
  }
  const nested = (data as { orca?: unknown }).orca
  const record = (nested && typeof nested === 'object' ? nested : data) as Record<string, unknown>
  // Push and socket alerts use the same paired-host identity.
  const hostFingerprint = readString(record.hostFingerprint)
  if (!hostFingerprint) {
    return null
  }
  return {
    hostFingerprint,
    ...(record.kind === 'dismiss' || record.kind === 'alert' ? { kind: record.kind } : {}),
    notificationId: readString(record.notificationId),
    notificationSeq: readSeq(record.notificationSeq),
    notificationEpoch: readString(record.notificationEpoch),
    paneKey: readString(record.paneKey),
    worktreeId: readString(record.worktreeId),
    executionHost: readString(record.executionHost)
  }
}