// @flow

// This file is auto-generated by client/protocol/Makefile.
import * as gregor1 from './flow-types-gregor'
import * as keybase1 from './flow-types'
import engine from '../../engine'
import {RPCError} from '../../util/errors'
import {putOnChannelMap, createChannelMap, closeChannelMap} from '../../util/saga'
import {Buffer} from 'buffer'
import type {Exact} from './more'
import type {ChannelConfig, ChannelMap} from './saga'
export type int = number
export type int64 = number
export type uint = number
export type uint64 = number
export type long = number
export type double = number
export type bytes = Buffer
export type WaitingHandlerType = (waiting: boolean, method: string, sessionID: number) => void

const engineRpcOutgoing = (method: string, params: any, callbackOverride: any, incomingCallMapOverride: any) => engine()._rpcOutgoing(method, params, callbackOverride, incomingCallMapOverride)

type requestCommon = {
  waitingHandler?: WaitingHandlerType,
  incomingCallMap?: incomingCallMapType,
}

type requestErrorCallback = {
  callback?: ?(err: ?RPCError) => void
}

type RPCErrorHandler = (err: RPCError) => void

type CommonResponseHandler = {
  error: RPCErrorHandler,
  result: (...rest: Array<void>) => void,
}

function _channelMapRpcHelper(channelConfig: ChannelConfig<*>, partialRpcCall: (incomingCallMap: any, callback: Function) => void): ChannelMap<*> {
  const channelMap = createChannelMap(channelConfig)
  const incomingCallMap = Object.keys(channelMap).reduce((acc, k) => {
    acc[k] = (params, response) => {
      putOnChannelMap(channelMap, k, {params, response})
    }
    return acc
  }, {})
  const callback = (error, params) => {
    channelMap['finished'] && putOnChannelMap(channelMap, 'finished', {error, params})
    closeChannelMap(channelMap)
  }
  partialRpcCall(incomingCallMap, callback)
  return channelMap
}


export const CommonConversationStatus = {
  unfiled: 0,
  favorite: 1,
  ignored: 2,
  blocked: 3,
  muted: 4,
}

export const CommonInboxResType = {
  versionhit: 0,
  full: 1,
}

export const CommonMessageType = {
  none: 0,
  text: 1,
  attachment: 2,
  edit: 3,
  delete: 4,
  metadata: 5,
  tlfname: 6,
  headline: 7,
  attachmentuploaded: 8,
}

export const CommonTLFVisibility = {
  any: 0,
  public: 1,
  private: 2,
}

export const CommonTopicType = {
  none: 0,
  chat: 1,
  dev: 2,
}

export const LocalAssetMetadataType = {
  none: 0,
  image: 1,
  video: 2,
  audio: 3,
}

export const LocalAssetTag = {
  primary: 0,
}

export const LocalBodyPlaintextVersion = {
  v1: 1,
  v2: 2,
  v3: 3,
  v4: 4,
  v5: 5,
  v6: 6,
  v7: 7,
  v8: 8,
  v9: 9,
  v10: 10,
}

export const LocalConversationErrorType = {
  misc: 0,
  missinginfo: 1,
  selfrekeyneeded: 2,
  otherrekeyneeded: 3,
  identify: 4,
  localmaxmessagenotfound: 5,
}

export const LocalHeaderPlaintextVersion = {
  v1: 1,
  v2: 2,
  v3: 3,
  v4: 4,
  v5: 5,
  v6: 6,
  v7: 7,
  v8: 8,
  v9: 9,
  v10: 10,
}

export const LocalMessageUnboxedErrorType = {
  misc: 0,
  badversionCritical: 1,
  badversion: 2,
  identify: 3,
}

export const LocalMessageUnboxedState = {
  valid: 1,
  error: 2,
  outbox: 3,
}

export const LocalOutboxErrorType = {
  misc: 0,
  offline: 1,
  identify: 2,
  toolong: 3,
}

export const LocalOutboxStateType = {
  sending: 0,
  error: 1,
}

export const NotifyChatChatActivityType = {
  reserved: 0,
  incomingMessage: 1,
  readMessage: 2,
  newConversation: 3,
  setStatus: 4,
  failedMessage: 5,
}

export const RemoteMessageBoxedVersion = {
  vnone: 0,
  v1: 1,
  v2: 2,
}

export const RemoteSyncAllNotificationType = {
  state: 0,
  incremental: 1,
}

export const RemoteSyncInboxResType = {
  current: 0,
  incremental: 1,
  clear: 2,
}

export function localCancelPostRpc (request: Exact<requestCommon & requestErrorCallback & {param: localCancelPostRpcParam}>) {
  engineRpcOutgoing('chat.1.local.CancelPost', request)
}

export function localCancelPostRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & requestErrorCallback & {param: localCancelPostRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.local.CancelPost', request, callback, incomingCallMap) })
}

export function localCancelPostRpcPromise (request: $Exact<requestCommon & requestErrorCallback & {param: localCancelPostRpcParam}>): Promise<void> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.local.CancelPost', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function localDownloadAttachmentLocalRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: localDownloadAttachmentLocalResult) => void} & {param: localDownloadAttachmentLocalRpcParam}>) {
  engineRpcOutgoing('chat.1.local.DownloadAttachmentLocal', request)
}

export function localDownloadAttachmentLocalRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localDownloadAttachmentLocalResult) => void} & {param: localDownloadAttachmentLocalRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.local.DownloadAttachmentLocal', request, callback, incomingCallMap) })
}

export function localDownloadAttachmentLocalRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localDownloadAttachmentLocalResult) => void} & {param: localDownloadAttachmentLocalRpcParam}>): Promise<localDownloadAttachmentLocalResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.local.DownloadAttachmentLocal', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function localDownloadFileAttachmentLocalRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: localDownloadFileAttachmentLocalResult) => void} & {param: localDownloadFileAttachmentLocalRpcParam}>) {
  engineRpcOutgoing('chat.1.local.DownloadFileAttachmentLocal', request)
}

export function localDownloadFileAttachmentLocalRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localDownloadFileAttachmentLocalResult) => void} & {param: localDownloadFileAttachmentLocalRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.local.DownloadFileAttachmentLocal', request, callback, incomingCallMap) })
}

export function localDownloadFileAttachmentLocalRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localDownloadFileAttachmentLocalResult) => void} & {param: localDownloadFileAttachmentLocalRpcParam}>): Promise<localDownloadFileAttachmentLocalResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.local.DownloadFileAttachmentLocal', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function localFindConversationsLocalRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: localFindConversationsLocalResult) => void} & {param: localFindConversationsLocalRpcParam}>) {
  engineRpcOutgoing('chat.1.local.findConversationsLocal', request)
}

export function localFindConversationsLocalRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localFindConversationsLocalResult) => void} & {param: localFindConversationsLocalRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.local.findConversationsLocal', request, callback, incomingCallMap) })
}

export function localFindConversationsLocalRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localFindConversationsLocalResult) => void} & {param: localFindConversationsLocalRpcParam}>): Promise<localFindConversationsLocalResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.local.findConversationsLocal', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function localGetCachedThreadRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: localGetCachedThreadResult) => void} & {param: localGetCachedThreadRpcParam}>) {
  engineRpcOutgoing('chat.1.local.getCachedThread', request)
}

export function localGetCachedThreadRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localGetCachedThreadResult) => void} & {param: localGetCachedThreadRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.local.getCachedThread', request, callback, incomingCallMap) })
}

export function localGetCachedThreadRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localGetCachedThreadResult) => void} & {param: localGetCachedThreadRpcParam}>): Promise<localGetCachedThreadResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.local.getCachedThread', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function localGetConversationForCLILocalRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: localGetConversationForCLILocalResult) => void} & {param: localGetConversationForCLILocalRpcParam}>) {
  engineRpcOutgoing('chat.1.local.getConversationForCLILocal', request)
}

export function localGetConversationForCLILocalRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localGetConversationForCLILocalResult) => void} & {param: localGetConversationForCLILocalRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.local.getConversationForCLILocal', request, callback, incomingCallMap) })
}

export function localGetConversationForCLILocalRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localGetConversationForCLILocalResult) => void} & {param: localGetConversationForCLILocalRpcParam}>): Promise<localGetConversationForCLILocalResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.local.getConversationForCLILocal', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function localGetInboxAndUnboxLocalRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: localGetInboxAndUnboxLocalResult) => void} & {param: localGetInboxAndUnboxLocalRpcParam}>) {
  engineRpcOutgoing('chat.1.local.getInboxAndUnboxLocal', request)
}

export function localGetInboxAndUnboxLocalRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localGetInboxAndUnboxLocalResult) => void} & {param: localGetInboxAndUnboxLocalRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.local.getInboxAndUnboxLocal', request, callback, incomingCallMap) })
}

export function localGetInboxAndUnboxLocalRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localGetInboxAndUnboxLocalResult) => void} & {param: localGetInboxAndUnboxLocalRpcParam}>): Promise<localGetInboxAndUnboxLocalResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.local.getInboxAndUnboxLocal', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function localGetInboxNonblockLocalRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: localGetInboxNonblockLocalResult) => void} & {param: localGetInboxNonblockLocalRpcParam}>) {
  engineRpcOutgoing('chat.1.local.getInboxNonblockLocal', request)
}

export function localGetInboxNonblockLocalRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localGetInboxNonblockLocalResult) => void} & {param: localGetInboxNonblockLocalRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.local.getInboxNonblockLocal', request, callback, incomingCallMap) })
}

export function localGetInboxNonblockLocalRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localGetInboxNonblockLocalResult) => void} & {param: localGetInboxNonblockLocalRpcParam}>): Promise<localGetInboxNonblockLocalResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.local.getInboxNonblockLocal', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function localGetInboxSummaryForCLILocalRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: localGetInboxSummaryForCLILocalResult) => void} & {param: localGetInboxSummaryForCLILocalRpcParam}>) {
  engineRpcOutgoing('chat.1.local.getInboxSummaryForCLILocal', request)
}

export function localGetInboxSummaryForCLILocalRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localGetInboxSummaryForCLILocalResult) => void} & {param: localGetInboxSummaryForCLILocalRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.local.getInboxSummaryForCLILocal', request, callback, incomingCallMap) })
}

export function localGetInboxSummaryForCLILocalRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localGetInboxSummaryForCLILocalResult) => void} & {param: localGetInboxSummaryForCLILocalRpcParam}>): Promise<localGetInboxSummaryForCLILocalResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.local.getInboxSummaryForCLILocal', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function localGetMessagesLocalRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: localGetMessagesLocalResult) => void} & {param: localGetMessagesLocalRpcParam}>) {
  engineRpcOutgoing('chat.1.local.GetMessagesLocal', request)
}

export function localGetMessagesLocalRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localGetMessagesLocalResult) => void} & {param: localGetMessagesLocalRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.local.GetMessagesLocal', request, callback, incomingCallMap) })
}

export function localGetMessagesLocalRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localGetMessagesLocalResult) => void} & {param: localGetMessagesLocalRpcParam}>): Promise<localGetMessagesLocalResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.local.GetMessagesLocal', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function localGetThreadLocalRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: localGetThreadLocalResult) => void} & {param: localGetThreadLocalRpcParam}>) {
  engineRpcOutgoing('chat.1.local.getThreadLocal', request)
}

export function localGetThreadLocalRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localGetThreadLocalResult) => void} & {param: localGetThreadLocalRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.local.getThreadLocal', request, callback, incomingCallMap) })
}

export function localGetThreadLocalRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localGetThreadLocalResult) => void} & {param: localGetThreadLocalRpcParam}>): Promise<localGetThreadLocalResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.local.getThreadLocal', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function localGetThreadNonblockRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: localGetThreadNonblockResult) => void} & {param: localGetThreadNonblockRpcParam}>) {
  engineRpcOutgoing('chat.1.local.getThreadNonblock', request)
}

export function localGetThreadNonblockRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localGetThreadNonblockResult) => void} & {param: localGetThreadNonblockRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.local.getThreadNonblock', request, callback, incomingCallMap) })
}

export function localGetThreadNonblockRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localGetThreadNonblockResult) => void} & {param: localGetThreadNonblockRpcParam}>): Promise<localGetThreadNonblockResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.local.getThreadNonblock', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function localMakePreviewRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: localMakePreviewResult) => void} & {param: localMakePreviewRpcParam}>) {
  engineRpcOutgoing('chat.1.local.makePreview', request)
}

export function localMakePreviewRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localMakePreviewResult) => void} & {param: localMakePreviewRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.local.makePreview', request, callback, incomingCallMap) })
}

export function localMakePreviewRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localMakePreviewResult) => void} & {param: localMakePreviewRpcParam}>): Promise<localMakePreviewResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.local.makePreview', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function localMarkAsReadLocalRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: localMarkAsReadLocalResult) => void} & {param: localMarkAsReadLocalRpcParam}>) {
  engineRpcOutgoing('chat.1.local.markAsReadLocal', request)
}

export function localMarkAsReadLocalRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localMarkAsReadLocalResult) => void} & {param: localMarkAsReadLocalRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.local.markAsReadLocal', request, callback, incomingCallMap) })
}

export function localMarkAsReadLocalRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localMarkAsReadLocalResult) => void} & {param: localMarkAsReadLocalRpcParam}>): Promise<localMarkAsReadLocalResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.local.markAsReadLocal', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function localNewConversationLocalRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: localNewConversationLocalResult) => void} & {param: localNewConversationLocalRpcParam}>) {
  engineRpcOutgoing('chat.1.local.newConversationLocal', request)
}

export function localNewConversationLocalRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localNewConversationLocalResult) => void} & {param: localNewConversationLocalRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.local.newConversationLocal', request, callback, incomingCallMap) })
}

export function localNewConversationLocalRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localNewConversationLocalResult) => void} & {param: localNewConversationLocalRpcParam}>): Promise<localNewConversationLocalResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.local.newConversationLocal', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function localPostAttachmentLocalRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: localPostAttachmentLocalResult) => void} & {param: localPostAttachmentLocalRpcParam}>) {
  engineRpcOutgoing('chat.1.local.postAttachmentLocal', request)
}

export function localPostAttachmentLocalRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localPostAttachmentLocalResult) => void} & {param: localPostAttachmentLocalRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.local.postAttachmentLocal', request, callback, incomingCallMap) })
}

export function localPostAttachmentLocalRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localPostAttachmentLocalResult) => void} & {param: localPostAttachmentLocalRpcParam}>): Promise<localPostAttachmentLocalResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.local.postAttachmentLocal', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function localPostDeleteNonblockRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: localPostDeleteNonblockResult) => void} & {param: localPostDeleteNonblockRpcParam}>) {
  engineRpcOutgoing('chat.1.local.postDeleteNonblock', request)
}

export function localPostDeleteNonblockRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localPostDeleteNonblockResult) => void} & {param: localPostDeleteNonblockRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.local.postDeleteNonblock', request, callback, incomingCallMap) })
}

export function localPostDeleteNonblockRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localPostDeleteNonblockResult) => void} & {param: localPostDeleteNonblockRpcParam}>): Promise<localPostDeleteNonblockResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.local.postDeleteNonblock', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function localPostEditNonblockRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: localPostEditNonblockResult) => void} & {param: localPostEditNonblockRpcParam}>) {
  engineRpcOutgoing('chat.1.local.postEditNonblock', request)
}

export function localPostEditNonblockRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localPostEditNonblockResult) => void} & {param: localPostEditNonblockRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.local.postEditNonblock', request, callback, incomingCallMap) })
}

export function localPostEditNonblockRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localPostEditNonblockResult) => void} & {param: localPostEditNonblockRpcParam}>): Promise<localPostEditNonblockResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.local.postEditNonblock', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function localPostFileAttachmentLocalRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: localPostFileAttachmentLocalResult) => void} & {param: localPostFileAttachmentLocalRpcParam}>) {
  engineRpcOutgoing('chat.1.local.postFileAttachmentLocal', request)
}

export function localPostFileAttachmentLocalRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localPostFileAttachmentLocalResult) => void} & {param: localPostFileAttachmentLocalRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.local.postFileAttachmentLocal', request, callback, incomingCallMap) })
}

export function localPostFileAttachmentLocalRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localPostFileAttachmentLocalResult) => void} & {param: localPostFileAttachmentLocalRpcParam}>): Promise<localPostFileAttachmentLocalResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.local.postFileAttachmentLocal', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function localPostLocalNonblockRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: localPostLocalNonblockResult) => void} & {param: localPostLocalNonblockRpcParam}>) {
  engineRpcOutgoing('chat.1.local.postLocalNonblock', request)
}

export function localPostLocalNonblockRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localPostLocalNonblockResult) => void} & {param: localPostLocalNonblockRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.local.postLocalNonblock', request, callback, incomingCallMap) })
}

export function localPostLocalNonblockRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localPostLocalNonblockResult) => void} & {param: localPostLocalNonblockRpcParam}>): Promise<localPostLocalNonblockResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.local.postLocalNonblock', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function localPostLocalRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: localPostLocalResult) => void} & {param: localPostLocalRpcParam}>) {
  engineRpcOutgoing('chat.1.local.postLocal', request)
}

export function localPostLocalRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localPostLocalResult) => void} & {param: localPostLocalRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.local.postLocal', request, callback, incomingCallMap) })
}

export function localPostLocalRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localPostLocalResult) => void} & {param: localPostLocalRpcParam}>): Promise<localPostLocalResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.local.postLocal', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function localPostTextNonblockRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: localPostTextNonblockResult) => void} & {param: localPostTextNonblockRpcParam}>) {
  engineRpcOutgoing('chat.1.local.postTextNonblock', request)
}

export function localPostTextNonblockRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localPostTextNonblockResult) => void} & {param: localPostTextNonblockRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.local.postTextNonblock', request, callback, incomingCallMap) })
}

export function localPostTextNonblockRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localPostTextNonblockResult) => void} & {param: localPostTextNonblockRpcParam}>): Promise<localPostTextNonblockResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.local.postTextNonblock', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function localRetryPostRpc (request: Exact<requestCommon & requestErrorCallback & {param: localRetryPostRpcParam}>) {
  engineRpcOutgoing('chat.1.local.RetryPost', request)
}

export function localRetryPostRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & requestErrorCallback & {param: localRetryPostRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.local.RetryPost', request, callback, incomingCallMap) })
}

export function localRetryPostRpcPromise (request: $Exact<requestCommon & requestErrorCallback & {param: localRetryPostRpcParam}>): Promise<void> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.local.RetryPost', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function localSetConversationStatusLocalRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: localSetConversationStatusLocalResult) => void} & {param: localSetConversationStatusLocalRpcParam}>) {
  engineRpcOutgoing('chat.1.local.SetConversationStatusLocal', request)
}

export function localSetConversationStatusLocalRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localSetConversationStatusLocalResult) => void} & {param: localSetConversationStatusLocalRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.local.SetConversationStatusLocal', request, callback, incomingCallMap) })
}

export function localSetConversationStatusLocalRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: localSetConversationStatusLocalResult) => void} & {param: localSetConversationStatusLocalRpcParam}>): Promise<localSetConversationStatusLocalResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.local.SetConversationStatusLocal', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function remoteGetInboxRemoteRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: remoteGetInboxRemoteResult) => void} & {param: remoteGetInboxRemoteRpcParam}>) {
  engineRpcOutgoing('chat.1.remote.getInboxRemote', request)
}

export function remoteGetInboxRemoteRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: remoteGetInboxRemoteResult) => void} & {param: remoteGetInboxRemoteRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.remote.getInboxRemote', request, callback, incomingCallMap) })
}

export function remoteGetInboxRemoteRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: remoteGetInboxRemoteResult) => void} & {param: remoteGetInboxRemoteRpcParam}>): Promise<remoteGetInboxRemoteResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.remote.getInboxRemote', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function remoteGetInboxVersionRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: remoteGetInboxVersionResult) => void} & {param: remoteGetInboxVersionRpcParam}>) {
  engineRpcOutgoing('chat.1.remote.getInboxVersion', request)
}

export function remoteGetInboxVersionRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: remoteGetInboxVersionResult) => void} & {param: remoteGetInboxVersionRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.remote.getInboxVersion', request, callback, incomingCallMap) })
}

export function remoteGetInboxVersionRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: remoteGetInboxVersionResult) => void} & {param: remoteGetInboxVersionRpcParam}>): Promise<remoteGetInboxVersionResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.remote.getInboxVersion', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function remoteGetMessagesRemoteRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: remoteGetMessagesRemoteResult) => void} & {param: remoteGetMessagesRemoteRpcParam}>) {
  engineRpcOutgoing('chat.1.remote.getMessagesRemote', request)
}

export function remoteGetMessagesRemoteRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: remoteGetMessagesRemoteResult) => void} & {param: remoteGetMessagesRemoteRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.remote.getMessagesRemote', request, callback, incomingCallMap) })
}

export function remoteGetMessagesRemoteRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: remoteGetMessagesRemoteResult) => void} & {param: remoteGetMessagesRemoteRpcParam}>): Promise<remoteGetMessagesRemoteResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.remote.getMessagesRemote', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function remoteGetPublicConversationsRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: remoteGetPublicConversationsResult) => void} & {param: remoteGetPublicConversationsRpcParam}>) {
  engineRpcOutgoing('chat.1.remote.getPublicConversations', request)
}

export function remoteGetPublicConversationsRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: remoteGetPublicConversationsResult) => void} & {param: remoteGetPublicConversationsRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.remote.getPublicConversations', request, callback, incomingCallMap) })
}

export function remoteGetPublicConversationsRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: remoteGetPublicConversationsResult) => void} & {param: remoteGetPublicConversationsRpcParam}>): Promise<remoteGetPublicConversationsResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.remote.getPublicConversations', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function remoteGetS3ParamsRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: remoteGetS3ParamsResult) => void} & {param: remoteGetS3ParamsRpcParam}>) {
  engineRpcOutgoing('chat.1.remote.getS3Params', request)
}

export function remoteGetS3ParamsRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: remoteGetS3ParamsResult) => void} & {param: remoteGetS3ParamsRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.remote.getS3Params', request, callback, incomingCallMap) })
}

export function remoteGetS3ParamsRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: remoteGetS3ParamsResult) => void} & {param: remoteGetS3ParamsRpcParam}>): Promise<remoteGetS3ParamsResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.remote.getS3Params', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function remoteGetThreadRemoteRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: remoteGetThreadRemoteResult) => void} & {param: remoteGetThreadRemoteRpcParam}>) {
  engineRpcOutgoing('chat.1.remote.getThreadRemote', request)
}

export function remoteGetThreadRemoteRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: remoteGetThreadRemoteResult) => void} & {param: remoteGetThreadRemoteRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.remote.getThreadRemote', request, callback, incomingCallMap) })
}

export function remoteGetThreadRemoteRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: remoteGetThreadRemoteResult) => void} & {param: remoteGetThreadRemoteRpcParam}>): Promise<remoteGetThreadRemoteResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.remote.getThreadRemote', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function remoteGetUnreadUpdateFullRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: remoteGetUnreadUpdateFullResult) => void} & {param: remoteGetUnreadUpdateFullRpcParam}>) {
  engineRpcOutgoing('chat.1.remote.GetUnreadUpdateFull', request)
}

export function remoteGetUnreadUpdateFullRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: remoteGetUnreadUpdateFullResult) => void} & {param: remoteGetUnreadUpdateFullRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.remote.GetUnreadUpdateFull', request, callback, incomingCallMap) })
}

export function remoteGetUnreadUpdateFullRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: remoteGetUnreadUpdateFullResult) => void} & {param: remoteGetUnreadUpdateFullRpcParam}>): Promise<remoteGetUnreadUpdateFullResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.remote.GetUnreadUpdateFull', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function remoteMarkAsReadRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: remoteMarkAsReadResult) => void} & {param: remoteMarkAsReadRpcParam}>) {
  engineRpcOutgoing('chat.1.remote.markAsRead', request)
}

export function remoteMarkAsReadRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: remoteMarkAsReadResult) => void} & {param: remoteMarkAsReadRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.remote.markAsRead', request, callback, incomingCallMap) })
}

export function remoteMarkAsReadRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: remoteMarkAsReadResult) => void} & {param: remoteMarkAsReadRpcParam}>): Promise<remoteMarkAsReadResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.remote.markAsRead', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function remoteNewConversationRemote2Rpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: remoteNewConversationRemote2Result) => void} & {param: remoteNewConversationRemote2RpcParam}>) {
  engineRpcOutgoing('chat.1.remote.newConversationRemote2', request)
}

export function remoteNewConversationRemote2RpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: remoteNewConversationRemote2Result) => void} & {param: remoteNewConversationRemote2RpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.remote.newConversationRemote2', request, callback, incomingCallMap) })
}

export function remoteNewConversationRemote2RpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: remoteNewConversationRemote2Result) => void} & {param: remoteNewConversationRemote2RpcParam}>): Promise<remoteNewConversationRemote2Result> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.remote.newConversationRemote2', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function remoteNewConversationRemoteRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: remoteNewConversationRemoteResult) => void} & {param: remoteNewConversationRemoteRpcParam}>) {
  engineRpcOutgoing('chat.1.remote.newConversationRemote', request)
}

export function remoteNewConversationRemoteRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: remoteNewConversationRemoteResult) => void} & {param: remoteNewConversationRemoteRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.remote.newConversationRemote', request, callback, incomingCallMap) })
}

export function remoteNewConversationRemoteRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: remoteNewConversationRemoteResult) => void} & {param: remoteNewConversationRemoteRpcParam}>): Promise<remoteNewConversationRemoteResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.remote.newConversationRemote', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function remotePostRemoteRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: remotePostRemoteResult) => void} & {param: remotePostRemoteRpcParam}>) {
  engineRpcOutgoing('chat.1.remote.postRemote', request)
}

export function remotePostRemoteRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: remotePostRemoteResult) => void} & {param: remotePostRemoteRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.remote.postRemote', request, callback, incomingCallMap) })
}

export function remotePostRemoteRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: remotePostRemoteResult) => void} & {param: remotePostRemoteRpcParam}>): Promise<remotePostRemoteResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.remote.postRemote', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function remotePublishReadMessageRpc (request: Exact<requestCommon & requestErrorCallback & {param: remotePublishReadMessageRpcParam}>) {
  engineRpcOutgoing('chat.1.remote.publishReadMessage', request)
}

export function remotePublishReadMessageRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & requestErrorCallback & {param: remotePublishReadMessageRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.remote.publishReadMessage', request, callback, incomingCallMap) })
}

export function remotePublishReadMessageRpcPromise (request: $Exact<requestCommon & requestErrorCallback & {param: remotePublishReadMessageRpcParam}>): Promise<void> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.remote.publishReadMessage', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function remotePublishSetConversationStatusRpc (request: Exact<requestCommon & requestErrorCallback & {param: remotePublishSetConversationStatusRpcParam}>) {
  engineRpcOutgoing('chat.1.remote.publishSetConversationStatus', request)
}

export function remotePublishSetConversationStatusRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & requestErrorCallback & {param: remotePublishSetConversationStatusRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.remote.publishSetConversationStatus', request, callback, incomingCallMap) })
}

export function remotePublishSetConversationStatusRpcPromise (request: $Exact<requestCommon & requestErrorCallback & {param: remotePublishSetConversationStatusRpcParam}>): Promise<void> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.remote.publishSetConversationStatus', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function remoteS3SignRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: remoteS3SignResult) => void} & {param: remoteS3SignRpcParam}>) {
  engineRpcOutgoing('chat.1.remote.s3Sign', request)
}

export function remoteS3SignRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: remoteS3SignResult) => void} & {param: remoteS3SignRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.remote.s3Sign', request, callback, incomingCallMap) })
}

export function remoteS3SignRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: remoteS3SignResult) => void} & {param: remoteS3SignRpcParam}>): Promise<remoteS3SignResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.remote.s3Sign', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function remoteSetConversationStatusRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: remoteSetConversationStatusResult) => void} & {param: remoteSetConversationStatusRpcParam}>) {
  engineRpcOutgoing('chat.1.remote.SetConversationStatus', request)
}

export function remoteSetConversationStatusRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: remoteSetConversationStatusResult) => void} & {param: remoteSetConversationStatusRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.remote.SetConversationStatus', request, callback, incomingCallMap) })
}

export function remoteSetConversationStatusRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: remoteSetConversationStatusResult) => void} & {param: remoteSetConversationStatusRpcParam}>): Promise<remoteSetConversationStatusResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.remote.SetConversationStatus', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function remoteSyncAllRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: remoteSyncAllResult) => void} & {param: remoteSyncAllRpcParam}>) {
  engineRpcOutgoing('chat.1.remote.syncAll', request)
}

export function remoteSyncAllRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: remoteSyncAllResult) => void} & {param: remoteSyncAllRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.remote.syncAll', request, callback, incomingCallMap) })
}

export function remoteSyncAllRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: remoteSyncAllResult) => void} & {param: remoteSyncAllRpcParam}>): Promise<remoteSyncAllResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.remote.syncAll', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function remoteSyncChatRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: remoteSyncChatResult) => void} & {param: remoteSyncChatRpcParam}>) {
  engineRpcOutgoing('chat.1.remote.syncChat', request)
}

export function remoteSyncChatRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: remoteSyncChatResult) => void} & {param: remoteSyncChatRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.remote.syncChat', request, callback, incomingCallMap) })
}

export function remoteSyncChatRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: remoteSyncChatResult) => void} & {param: remoteSyncChatRpcParam}>): Promise<remoteSyncChatResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.remote.syncChat', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function remoteSyncInboxRpc (request: Exact<requestCommon & {callback?: ?(err: ?any, response: remoteSyncInboxResult) => void} & {param: remoteSyncInboxRpcParam}>) {
  engineRpcOutgoing('chat.1.remote.syncInbox', request)
}

export function remoteSyncInboxRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & {callback?: ?(err: ?any, response: remoteSyncInboxResult) => void} & {param: remoteSyncInboxRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.remote.syncInbox', request, callback, incomingCallMap) })
}

export function remoteSyncInboxRpcPromise (request: $Exact<requestCommon & {callback?: ?(err: ?any, response: remoteSyncInboxResult) => void} & {param: remoteSyncInboxRpcParam}>): Promise<remoteSyncInboxResult> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.remote.syncInbox', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function remoteTlfFinalizeRpc (request: Exact<requestCommon & requestErrorCallback & {param: remoteTlfFinalizeRpcParam}>) {
  engineRpcOutgoing('chat.1.remote.tlfFinalize', request)
}

export function remoteTlfFinalizeRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & requestErrorCallback & {param: remoteTlfFinalizeRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.remote.tlfFinalize', request, callback, incomingCallMap) })
}

export function remoteTlfFinalizeRpcPromise (request: $Exact<requestCommon & requestErrorCallback & {param: remoteTlfFinalizeRpcParam}>): Promise<void> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.remote.tlfFinalize', request, (error, result) => error ? reject(error) : resolve(result)))
}

export function remoteTlfResolveRpc (request: Exact<requestCommon & requestErrorCallback & {param: remoteTlfResolveRpcParam}>) {
  engineRpcOutgoing('chat.1.remote.tlfResolve', request)
}

export function remoteTlfResolveRpcChannelMap (channelConfig: ChannelConfig<*>, request: $Exact<requestCommon & requestErrorCallback & {param: remoteTlfResolveRpcParam}>): ChannelMap<*> {
  return _channelMapRpcHelper(channelConfig, (incomingCallMap, callback) => { engineRpcOutgoing('chat.1.remote.tlfResolve', request, callback, incomingCallMap) })
}

export function remoteTlfResolveRpcPromise (request: $Exact<requestCommon & requestErrorCallback & {param: remoteTlfResolveRpcParam}>): Promise<void> {
  return new Promise((resolve, reject) => engineRpcOutgoing('chat.1.remote.tlfResolve', request, (error, result) => error ? reject(error) : resolve(result)))
}

export type Asset = {
  filename: string,
  region: string,
  endpoint: string,
  bucket: string,
  path: string,
  size: int,
  mimeType: string,
  encHash: Hash,
  key: bytes,
  verifyKey: bytes,
  title: string,
  nonce: bytes,
  metadata: AssetMetadata,
  tag: AssetTag,
}

export type AssetMetadata =
    { assetType: 1, image: ?AssetMetadataImage }
  | { assetType: 2, video: ?AssetMetadataVideo }
  | { assetType: 3, audio: ?AssetMetadataAudio }

export type AssetMetadataAudio = {
  durationMs: int,
}

export type AssetMetadataImage = {
  width: int,
  height: int,
}

export type AssetMetadataType =
    0 // NONE_0
  | 1 // IMAGE_1
  | 2 // VIDEO_2
  | 3 // AUDIO_3

export type AssetMetadataVideo = {
  width: int,
  height: int,
  durationMs: int,
}

export type AssetTag =
    0 // PRIMARY_0

export type BodyPlaintext =
    { version: 1, v1: ?BodyPlaintextV1 }
  | { version: 2, v2: ?BodyPlaintextUnsupported }
  | { version: 3, v3: ?BodyPlaintextUnsupported }
  | { version: 4, v4: ?BodyPlaintextUnsupported }
  | { version: 5, v5: ?BodyPlaintextUnsupported }
  | { version: 6, v6: ?BodyPlaintextUnsupported }
  | { version: 7, v7: ?BodyPlaintextUnsupported }
  | { version: 8, v8: ?BodyPlaintextUnsupported }
  | { version: 9, v9: ?BodyPlaintextUnsupported }
  | { version: 10, v10: ?BodyPlaintextUnsupported }

export type BodyPlaintextMetaInfo = {
  crit: boolean,
}

export type BodyPlaintextUnsupported = {
  mi: BodyPlaintextMetaInfo,
}

export type BodyPlaintextV1 = {
  messageBody: MessageBody,
}

export type BodyPlaintextVersion =
    1 // V1_1
  | 2 // V2_2
  | 3 // V3_3
  | 4 // V4_4
  | 5 // V5_5
  | 6 // V6_6
  | 7 // V7_7
  | 8 // V8_8
  | 9 // V9_9
  | 10 // V10_10

export type ChatActivity =
    { activityType: 1, incomingMessage: ?IncomingMessage }
  | { activityType: 2, readMessage: ?ReadMessageInfo }
  | { activityType: 3, newConversation: ?NewConversationInfo }
  | { activityType: 4, setStatus: ?SetStatusInfo }
  | { activityType: 5, failedMessage: ?FailedMessageInfo }

export type ChatActivityType =
    0 // RESERVED_0
  | 1 // INCOMING_MESSAGE_1
  | 2 // READ_MESSAGE_2
  | 3 // NEW_CONVERSATION_3
  | 4 // SET_STATUS_4
  | 5 // FAILED_MESSAGE_5

export type Conversation = {
  metadata: ConversationMetadata,
  readerInfo?: ?ConversationReaderInfo,
  maxMsgs?: ?Array<MessageBoxed>,
  maxMsgSummaries?: ?Array<MessageSummary>,
}

export type ConversationErrorLocal = {
  typ: ConversationErrorType,
  message: string,
  remoteConv: Conversation,
  permanent: boolean,
  unverifiedTLFName: string,
  rekeyInfo?: ?ConversationErrorRekey,
}

export type ConversationErrorRekey = {
  tlfName: string,
  tlfPublic: boolean,
  rekeyers?: ?Array<string>,
  writerNames?: ?Array<string>,
  readerNames?: ?Array<string>,
}

export type ConversationErrorType =
    0 // MISC_0
  | 1 // MISSINGINFO_1
  | 2 // SELFREKEYNEEDED_2
  | 3 // OTHERREKEYNEEDED_3
  | 4 // IDENTIFY_4
  | 5 // LOCALMAXMESSAGENOTFOUND_5

export type ConversationFinalizeInfo = {
  resetUser: string,
  resetDate: string,
  resetFull: string,
  resetTimestamp: gregor1.Time,
}

export type ConversationID = bytes

export type ConversationIDTriple = {
  tlfid: TLFID,
  topicType: TopicType,
  topicID: TopicID,
}

export type ConversationInfoLocal = {
  id: ConversationID,
  triple: ConversationIDTriple,
  tlfName: string,
  topicName: string,
  visibility: TLFVisibility,
  status: ConversationStatus,
  writerNames?: ?Array<string>,
  readerNames?: ?Array<string>,
  finalizeInfo?: ?ConversationFinalizeInfo,
}

export type ConversationLocal = {
  error?: ?ConversationErrorLocal,
  info: ConversationInfoLocal,
  readerInfo: ConversationReaderInfo,
  supersedes?: ?Array<ConversationMetadata>,
  supersededBy?: ?Array<ConversationMetadata>,
  maxMessages?: ?Array<MessageUnboxed>,
  isEmpty: boolean,
  identifyFailures?: ?Array<keybase1.TLFIdentifyFailure>,
}

export type ConversationMetadata = {
  idTriple: ConversationIDTriple,
  conversationID: ConversationID,
  visibility: TLFVisibility,
  status: ConversationStatus,
  finalizeInfo?: ?ConversationFinalizeInfo,
  supersedes?: ?Array<ConversationMetadata>,
  supersededBy?: ?Array<ConversationMetadata>,
  activeList?: ?Array<gregor1.UID>,
}

export type ConversationReaderInfo = {
  mtime: gregor1.Time,
  readMsgid: MessageID,
  maxMsgid: MessageID,
}

export type ConversationResolveInfo = {
  newTLFName: string,
}

export type ConversationStatus =
    0 // UNFILED_0
  | 1 // FAVORITE_1
  | 2 // IGNORED_2
  | 3 // BLOCKED_3
  | 4 // MUTED_4

export type DownloadAttachmentLocalRes = {
  offline: boolean,
  rateLimits?: ?Array<RateLimit>,
  identifyFailures?: ?Array<keybase1.TLFIdentifyFailure>,
}

export type EncryptedData = {
  v: int,
  e: bytes,
  n: bytes,
}

export type FailedMessageInfo = {
  outboxRecords?: ?Array<OutboxRecord>,
}

export type FindConversationsLocalRes = {
  conversations?: ?Array<ConversationLocal>,
  offline: boolean,
  rateLimits?: ?Array<RateLimit>,
  identifyFailures?: ?Array<keybase1.TLFIdentifyFailure>,
}

export type GenericPayload = {
  Action: string,
}

export type GetConversationForCLILocalQuery = {
  markAsRead: boolean,
  MessageTypes?: ?Array<MessageType>,
  Since?: ?string,
  limit: UnreadFirstNumLimit,
  conv: ConversationLocal,
}

export type GetConversationForCLILocalRes = {
  conversation: ConversationLocal,
  messages?: ?Array<MessageUnboxed>,
  offline: boolean,
  rateLimits?: ?Array<RateLimit>,
}

export type GetConversationMetadataRemoteRes = {
  conv: Conversation,
  rateLimit?: ?RateLimit,
}

export type GetInboxAndUnboxLocalRes = {
  conversations?: ?Array<ConversationLocal>,
  pagination?: ?Pagination,
  offline: boolean,
  rateLimits?: ?Array<RateLimit>,
  identifyFailures?: ?Array<keybase1.TLFIdentifyFailure>,
}

export type GetInboxByTLFIDRemoteRes = {
  convs?: ?Array<Conversation>,
  rateLimit?: ?RateLimit,
}

export type GetInboxLocalQuery = {
  tlfName?: ?string,
  topicName?: ?string,
  convIDs?: ?Array<ConversationID>,
  topicType?: ?TopicType,
  tlfVisibility?: ?TLFVisibility,
  before?: ?gregor1.Time,
  after?: ?gregor1.Time,
  oneChatTypePerTLF?: ?boolean,
  status?: ?Array<ConversationStatus>,
  unreadOnly: boolean,
  readOnly: boolean,
  computeActiveList: boolean,
}

export type GetInboxLocalRes = {
  conversationsUnverified?: ?Array<Conversation>,
  pagination?: ?Pagination,
  offline: boolean,
  rateLimits?: ?Array<RateLimit>,
  identifyFailures?: ?Array<keybase1.TLFIdentifyFailure>,
}

export type GetInboxQuery = {
  convID?: ?ConversationID,
  topicType?: ?TopicType,
  tlfID?: ?TLFID,
  tlfVisibility?: ?TLFVisibility,
  before?: ?gregor1.Time,
  after?: ?gregor1.Time,
  oneChatTypePerTLF?: ?boolean,
  status?: ?Array<ConversationStatus>,
  convIDs?: ?Array<ConversationID>,
  unreadOnly: boolean,
  readOnly: boolean,
  computeActiveList: boolean,
  summarizeMaxMsgs: boolean,
}

export type GetInboxRemoteRes = {
  inbox: InboxView,
  rateLimit?: ?RateLimit,
}

export type GetInboxSummaryForCLILocalQuery = {
  topicType: TopicType,
  after: string,
  before: string,
  visibility: TLFVisibility,
  status?: ?Array<ConversationStatus>,
  unreadFirst: boolean,
  unreadFirstLimit: UnreadFirstNumLimit,
  activitySortedLimit: int,
}

export type GetInboxSummaryForCLILocalRes = {
  conversations?: ?Array<ConversationLocal>,
  offline: boolean,
  rateLimits?: ?Array<RateLimit>,
}

export type GetMessagesLocalRes = {
  messages?: ?Array<MessageUnboxed>,
  offline: boolean,
  rateLimits?: ?Array<RateLimit>,
  identifyFailures?: ?Array<keybase1.TLFIdentifyFailure>,
}

export type GetMessagesRemoteRes = {
  msgs?: ?Array<MessageBoxed>,
  rateLimit?: ?RateLimit,
}

export type GetPublicConversationsRes = {
  conversations?: ?Array<Conversation>,
  rateLimit?: ?RateLimit,
}

export type GetThreadLocalRes = {
  thread: ThreadView,
  offline: boolean,
  rateLimits?: ?Array<RateLimit>,
  identifyFailures?: ?Array<keybase1.TLFIdentifyFailure>,
}

export type GetThreadQuery = {
  markAsRead: boolean,
  messageTypes?: ?Array<MessageType>,
  disableResolveSupersedes: boolean,
  before?: ?gregor1.Time,
  after?: ?gregor1.Time,
}

export type GetThreadRemoteRes = {
  thread: ThreadViewBoxed,
  rateLimit?: ?RateLimit,
}

export type Hash = bytes

export type HeaderPlaintext =
    { version: 1, v1: ?HeaderPlaintextV1 }
  | { version: 2, v2: ?HeaderPlaintextUnsupported }
  | { version: 3, v3: ?HeaderPlaintextUnsupported }
  | { version: 4, v4: ?HeaderPlaintextUnsupported }
  | { version: 5, v5: ?HeaderPlaintextUnsupported }
  | { version: 6, v6: ?HeaderPlaintextUnsupported }
  | { version: 7, v7: ?HeaderPlaintextUnsupported }
  | { version: 8, v8: ?HeaderPlaintextUnsupported }
  | { version: 9, v9: ?HeaderPlaintextUnsupported }
  | { version: 10, v10: ?HeaderPlaintextUnsupported }

export type HeaderPlaintextMetaInfo = {
  crit: boolean,
}

export type HeaderPlaintextUnsupported = {
  mi: HeaderPlaintextMetaInfo,
}

export type HeaderPlaintextV1 = {
  conv: ConversationIDTriple,
  tlfName: string,
  tlfPublic: boolean,
  messageType: MessageType,
  prev?: ?Array<MessagePreviousPointer>,
  sender: gregor1.UID,
  senderDevice: gregor1.DeviceID,
  bodyHash: Hash,
  outboxInfo?: ?OutboxInfo,
  outboxID?: ?OutboxID,
  headerSignature?: ?SignatureInfo,
}

export type HeaderPlaintextVersion =
    1 // V1_1
  | 2 // V2_2
  | 3 // V3_3
  | 4 // V4_4
  | 5 // V5_5
  | 6 // V6_6
  | 7 // V7_7
  | 8 // V8_8
  | 9 // V9_9
  | 10 // V10_10

export type Inbox = {
  version: InboxVers,
  convsUnverified?: ?Array<Conversation>,
  convs?: ?Array<ConversationLocal>,
  pagination?: ?Pagination,
}

export type InboxResType =
    0 // VERSIONHIT_0
  | 1 // FULL_1

export type InboxVers = uint64

export type InboxView =
    { rtype: 0 }
  | { rtype: 1, full: ?InboxViewFull }

export type InboxViewFull = {
  vers: InboxVers,
  conversations?: ?Array<Conversation>,
  pagination?: ?Pagination,
}

export type IncomingMessage = {
  message: MessageUnboxed,
  convID: ConversationID,
  conv?: ?ConversationLocal,
  pagination?: ?Pagination,
}

export type LocalFileSource = {
  filename: string,
}

export type LocalSource = {
  source: keybase1.Stream,
  filename: string,
  size: int,
}

export type MakePreviewRes = {
  mimeType: string,
  filename?: ?string,
  metadata?: ?AssetMetadata,
  baseMetadata?: ?AssetMetadata,
}

export type MarkAsReadLocalRes = {
  offline: boolean,
  rateLimits?: ?Array<RateLimit>,
}

export type MarkAsReadRes = {
  rateLimit?: ?RateLimit,
}

export type MerkleRoot = {
  seqno: long,
  hash: bytes,
}

export type MessageAttachment = {
  object: Asset,
  preview?: ?Asset,
  previews?: ?Array<Asset>,
  metadata: bytes,
  uploaded: boolean,
}

export type MessageAttachmentUploaded = {
  messageID: MessageID,
  object: Asset,
  previews?: ?Array<Asset>,
  metadata: bytes,
}

export type MessageBody =
    { messageType: 1, text: ?MessageText }
  | { messageType: 2, attachment: ?MessageAttachment }
  | { messageType: 3, edit: ?MessageEdit }
  | { messageType: 4, delete: ?MessageDelete }
  | { messageType: 5, metadata: ?MessageConversationMetadata }
  | { messageType: 7, headline: ?MessageHeadline }
  | { messageType: 8, attachmentuploaded: ?MessageAttachmentUploaded }

export type MessageBoxed = {
  version: MessageBoxedVersion,
  serverHeader?: ?MessageServerHeader,
  clientHeader: MessageClientHeader,
  headerCiphertext: SealedData,
  bodyCiphertext: EncryptedData,
  verifyKey: bytes,
  keyGeneration: int,
}

export type MessageBoxedVersion =
    0 // VNONE_0
  | 1 // V1_1
  | 2 // V2_2

export type MessageClientHeader = {
  conv: ConversationIDTriple,
  tlfName: string,
  tlfPublic: boolean,
  messageType: MessageType,
  supersedes: MessageID,
  deletes?: ?Array<MessageID>,
  prev?: ?Array<MessagePreviousPointer>,
  sender: gregor1.UID,
  senderDevice: gregor1.DeviceID,
  merkleRoot?: ?MerkleRoot,
  outboxID?: ?OutboxID,
  outboxInfo?: ?OutboxInfo,
}

export type MessageClientHeaderVerified = {
  conv: ConversationIDTriple,
  tlfName: string,
  tlfPublic: boolean,
  messageType: MessageType,
  prev?: ?Array<MessagePreviousPointer>,
  sender: gregor1.UID,
  senderDevice: gregor1.DeviceID,
  outboxID?: ?OutboxID,
  outboxInfo?: ?OutboxInfo,
}

export type MessageConversationMetadata = {
  conversationTitle: string,
}

export type MessageDelete = {
  messageIDs?: ?Array<MessageID>,
}

export type MessageEdit = {
  messageID: MessageID,
  body: string,
}

export type MessageHeadline = {
  headline: string,
}

export type MessageID = uint

export type MessagePlaintext = {
  clientHeader: MessageClientHeader,
  messageBody: MessageBody,
}

export type MessagePreviousPointer = {
  id: MessageID,
  hash: Hash,
}

export type MessageServerHeader = {
  messageID: MessageID,
  supersededBy: MessageID,
  ctime: gregor1.Time,
}

export type MessageSummary = {
  msgID: MessageID,
  messageType: MessageType,
  tlfName: string,
  tlfPublic: boolean,
  ctime: gregor1.Time,
}

export type MessageText = {
  body: string,
}

export type MessageType =
    0 // NONE_0
  | 1 // TEXT_1
  | 2 // ATTACHMENT_2
  | 3 // EDIT_3
  | 4 // DELETE_4
  | 5 // METADATA_5
  | 6 // TLFNAME_6
  | 7 // HEADLINE_7
  | 8 // ATTACHMENTUPLOADED_8

export type MessageUnboxed =
    { state: 1, valid: ?MessageUnboxedValid }
  | { state: 2, error: ?MessageUnboxedError }
  | { state: 3, outbox: ?OutboxRecord }

export type MessageUnboxedError = {
  errType: MessageUnboxedErrorType,
  errMsg: string,
  messageID: MessageID,
  messageType: MessageType,
  ctime: gregor1.Time,
}

export type MessageUnboxedErrorType =
    0 // MISC_0
  | 1 // BADVERSION_CRITICAL_1
  | 2 // BADVERSION_2
  | 3 // IDENTIFY_3

export type MessageUnboxedState =
    1 // VALID_1
  | 2 // ERROR_2
  | 3 // OUTBOX_3

export type MessageUnboxedValid = {
  clientHeader: MessageClientHeaderVerified,
  serverHeader: MessageServerHeader,
  messageBody: MessageBody,
  senderUsername: string,
  senderDeviceName: string,
  senderDeviceType: string,
  bodyHash: Hash,
  headerHash: Hash,
  headerSignature?: ?SignatureInfo,
  verificationKey?: ?bytes,
  senderDeviceRevokedAt?: ?gregor1.Time,
}

export type NewConversationInfo = {
  conv: ConversationLocal,
}

export type NewConversationLocalRes = {
  conv: ConversationLocal,
  rateLimits?: ?Array<RateLimit>,
  identifyFailures?: ?Array<keybase1.TLFIdentifyFailure>,
}

export type NewConversationPayload = {
  Action: string,
  convID: ConversationID,
  inboxVers: InboxVers,
  unreadUpdate?: ?UnreadUpdate,
}

export type NewConversationRemoteRes = {
  convID: ConversationID,
  rateLimit?: ?RateLimit,
}

export type NewMessagePayload = {
  Action: string,
  convID: ConversationID,
  message: MessageBoxed,
  inboxVers: InboxVers,
  unreadUpdate?: ?UnreadUpdate,
}

export type NonblockFetchRes = {
  offline: boolean,
  rateLimits?: ?Array<RateLimit>,
  identifyFailures?: ?Array<keybase1.TLFIdentifyFailure>,
}

export type NotifyChatChatIdentifyUpdateRpcParam = Exact<{
  update: keybase1.CanonicalTLFNameAndIDWithBreaks
}>

export type NotifyChatChatInboxStaleRpcParam = Exact<{
  uid: keybase1.UID
}>

export type NotifyChatChatTLFFinalizeRpcParam = Exact<{
  uid: keybase1.UID,
  convID: ConversationID,
  finalizeInfo: ConversationFinalizeInfo,
  conv?: ?ConversationLocal
}>

export type NotifyChatChatTLFResolveRpcParam = Exact<{
  uid: keybase1.UID,
  convID: ConversationID,
  resolveInfo: ConversationResolveInfo
}>

export type NotifyChatChatThreadsStaleRpcParam = Exact<{
  uid: keybase1.UID,
  convIDs?: ?Array<ConversationID>
}>

export type NotifyChatNewChatActivityRpcParam = Exact<{
  uid: keybase1.UID,
  activity: ChatActivity
}>

export type OutboxErrorType =
    0 // MISC_0
  | 1 // OFFLINE_1
  | 2 // IDENTIFY_2
  | 3 // TOOLONG_3

export type OutboxID = bytes

export type OutboxInfo = {
  prev: MessageID,
  composeTime: gregor1.Time,
}

export type OutboxRecord = {
  state: OutboxState,
  outboxID: OutboxID,
  convID: ConversationID,
  ctime: gregor1.Time,
  Msg: MessagePlaintext,
  identifyBehavior: keybase1.TLFIdentifyBehavior,
}

export type OutboxState =
    { state: 0, sending: ?int }
  | { state: 1, error: ?OutboxStateError }

export type OutboxStateError = {
  message: string,
  typ: OutboxErrorType,
}

export type OutboxStateType =
    0 // SENDING_0
  | 1 // ERROR_1

export type Pagination = {
  next: bytes,
  previous: bytes,
  num: int,
  last: boolean,
}

export type PostLocalNonblockRes = {
  rateLimits?: ?Array<RateLimit>,
  outboxID: OutboxID,
  identifyFailures?: ?Array<keybase1.TLFIdentifyFailure>,
}

export type PostLocalRes = {
  rateLimits?: ?Array<RateLimit>,
  messageID: MessageID,
  identifyFailures?: ?Array<keybase1.TLFIdentifyFailure>,
}

export type PostRemoteRes = {
  msgHeader: MessageServerHeader,
  rateLimit?: ?RateLimit,
}

export type RateLimit = {
  name: string,
  callsRemaining: int,
  windowReset: int,
  maxCalls: int,
}

export type ReadMessageInfo = {
  convID: ConversationID,
  msgID: MessageID,
  conv?: ?ConversationLocal,
}

export type ReadMessagePayload = {
  Action: string,
  convID: ConversationID,
  msgID: MessageID,
  inboxVers: InboxVers,
  unreadUpdate?: ?UnreadUpdate,
}

export type S3Params = {
  bucket: string,
  objectKey: string,
  accessKey: string,
  acl: string,
  regionName: string,
  regionEndpoint: string,
  regionBucketEndpoint: string,
}

export type SealedData = {
  v: int,
  e: bytes,
  n: bytes,
}

export type ServerCacheVers = {
  inboxVers: int,
  bodiesVers: int,
}

export type SetConversationStatusLocalRes = {
  rateLimits?: ?Array<RateLimit>,
  identifyFailures?: ?Array<keybase1.TLFIdentifyFailure>,
}

export type SetConversationStatusRes = {
  rateLimit?: ?RateLimit,
}

export type SetStatusInfo = {
  convID: ConversationID,
  status: ConversationStatus,
  conv?: ?ConversationLocal,
}

export type SetStatusPayload = {
  Action: string,
  convID: ConversationID,
  status: ConversationStatus,
  inboxVers: InboxVers,
  unreadUpdate?: ?UnreadUpdate,
}

export type SignEncryptedData = {
  v: int,
  e: bytes,
  n: bytes,
}

export type SignatureInfo = {
  v: int,
  s: bytes,
  k: bytes,
}

export type SyncAllNotificationRes =
    { typ: 0, state: ?gregor1.State }
  | { typ: 1, incremental: ?gregor1.SyncResult }

export type SyncAllNotificationType =
    0 // STATE_0
  | 1 // INCREMENTAL_1

export type SyncAllResult = {
  auth: gregor1.AuthResult,
  chat: SyncChatRes,
  notification: SyncAllNotificationRes,
  badge: UnreadUpdateFull,
}

export type SyncChatRes = {
  cacheVers: ServerCacheVers,
  inboxRes: SyncInboxRes,
}

export type SyncInboxRes =
    { typ: 0 }
  | { typ: 1, incremental: ?SyncIncrementalRes }
  | { typ: 2 }

export type SyncInboxResType =
    0 // CURRENT_0
  | 1 // INCREMENTAL_1
  | 2 // CLEAR_2

export type SyncIncrementalRes = {
  vers: InboxVers,
  convs?: ?Array<Conversation>,
}

export type TLFFinalizeUpdate = {
  finalizeInfo: ConversationFinalizeInfo,
  convIDs?: ?Array<ConversationID>,
  inboxVers: InboxVers,
}

export type TLFID = bytes

export type TLFResolveUpdate = {
  convID: ConversationID,
  inboxVers: InboxVers,
}

export type TLFVisibility =
    0 // ANY_0
  | 1 // PUBLIC_1
  | 2 // PRIVATE_2

export type ThreadID = bytes

export type ThreadView = {
  messages?: ?Array<MessageUnboxed>,
  pagination?: ?Pagination,
}

export type ThreadViewBoxed = {
  messages?: ?Array<MessageBoxed>,
  pagination?: ?Pagination,
}

export type TopicID = bytes

export type TopicType =
    0 // NONE_0
  | 1 // CHAT_1
  | 2 // DEV_2

export type UnreadFirstNumLimit = {
  NumRead: int,
  AtLeast: int,
  AtMost: int,
}

export type UnreadUpdate = {
  convID: ConversationID,
  UnreadMessages: int,
}

export type UnreadUpdateFull = {
  ignore: boolean,
  inboxVers: InboxVers,
  updates?: ?Array<UnreadUpdate>,
}

export type chatUiChatAttachmentDownloadProgressRpcParam = Exact<{
  bytesComplete: int,
  bytesTotal: int
}>

export type chatUiChatAttachmentPreviewUploadStartRpcParam = Exact<{
  metadata: AssetMetadata
}>

export type chatUiChatAttachmentUploadOutboxIDRpcParam = Exact<{
  outboxID: OutboxID
}>

export type chatUiChatAttachmentUploadProgressRpcParam = Exact<{
  bytesComplete: int,
  bytesTotal: int
}>

export type chatUiChatAttachmentUploadStartRpcParam = Exact<{
  metadata: AssetMetadata,
  placeholderMsgID: MessageID
}>

export type chatUiChatInboxConversationRpcParam = Exact<{
  conv: ConversationLocal
}>

export type chatUiChatInboxFailedRpcParam = Exact<{
  convID: ConversationID,
  error: ConversationErrorLocal
}>

export type chatUiChatInboxUnverifiedRpcParam = Exact<{
  inbox: GetInboxLocalRes
}>

export type chatUiChatThreadCachedRpcParam = Exact<{
  thread?: ?ThreadView
}>

export type chatUiChatThreadFullRpcParam = Exact<{
  thread: ThreadView
}>

export type localCancelPostRpcParam = Exact<{
  outboxID: OutboxID
}>

export type localDownloadAttachmentLocalRpcParam = Exact<{
  conversationID: ConversationID,
  messageID: MessageID,
  sink: keybase1.Stream,
  preview: boolean,
  identifyBehavior: keybase1.TLFIdentifyBehavior
}>

export type localDownloadFileAttachmentLocalRpcParam = Exact<{
  conversationID: ConversationID,
  messageID: MessageID,
  filename: string,
  preview: boolean,
  identifyBehavior: keybase1.TLFIdentifyBehavior
}>

export type localFindConversationsLocalRpcParam = Exact<{
  tlfName: string,
  visibility: TLFVisibility,
  topicType: TopicType,
  topicName: string,
  oneChatPerTLF?: ?bool,
  identifyBehavior: keybase1.TLFIdentifyBehavior
}>

export type localGetCachedThreadRpcParam = Exact<{
  conversationID: ConversationID,
  query?: ?GetThreadQuery,
  pagination?: ?Pagination,
  identifyBehavior: keybase1.TLFIdentifyBehavior
}>

export type localGetConversationForCLILocalRpcParam = Exact<{
  query: GetConversationForCLILocalQuery
}>

export type localGetInboxAndUnboxLocalRpcParam = Exact<{
  query?: ?GetInboxLocalQuery,
  pagination?: ?Pagination,
  identifyBehavior: keybase1.TLFIdentifyBehavior
}>

export type localGetInboxNonblockLocalRpcParam = Exact<{
  maxUnbox?: ?int,
  query?: ?GetInboxLocalQuery,
  pagination?: ?Pagination,
  identifyBehavior: keybase1.TLFIdentifyBehavior
}>

export type localGetInboxSummaryForCLILocalRpcParam = Exact<{
  query: GetInboxSummaryForCLILocalQuery
}>

export type localGetMessagesLocalRpcParam = Exact<{
  conversationID: ConversationID,
  messageIDs?: ?Array<MessageID>,
  disableResolveSupersedes: boolean,
  identifyBehavior: keybase1.TLFIdentifyBehavior
}>

export type localGetThreadLocalRpcParam = Exact<{
  conversationID: ConversationID,
  query?: ?GetThreadQuery,
  pagination?: ?Pagination,
  identifyBehavior: keybase1.TLFIdentifyBehavior
}>

export type localGetThreadNonblockRpcParam = Exact<{
  conversationID: ConversationID,
  query?: ?GetThreadQuery,
  pagination?: ?Pagination,
  identifyBehavior: keybase1.TLFIdentifyBehavior
}>

export type localMakePreviewRpcParam = Exact<{
  attachment: LocalFileSource,
  outputDir: string
}>

export type localMarkAsReadLocalRpcParam = Exact<{
  conversationID: ConversationID,
  msgID: MessageID
}>

export type localNewConversationLocalRpcParam = Exact<{
  tlfName: string,
  topicType: TopicType,
  tlfVisibility: TLFVisibility,
  topicName?: ?string,
  identifyBehavior: keybase1.TLFIdentifyBehavior
}>

export type localPostAttachmentLocalRpcParam = Exact<{
  conversationID: ConversationID,
  clientHeader: MessageClientHeader,
  attachment: LocalSource,
  preview?: ?MakePreviewRes,
  title: string,
  metadata: bytes,
  identifyBehavior: keybase1.TLFIdentifyBehavior
}>

export type localPostDeleteNonblockRpcParam = Exact<{
  conversationID: ConversationID,
  conv: ConversationIDTriple,
  tlfName: string,
  tlfPublic: boolean,
  supersedes: MessageID,
  clientPrev: MessageID,
  identifyBehavior: keybase1.TLFIdentifyBehavior
}>

export type localPostEditNonblockRpcParam = Exact<{
  conversationID: ConversationID,
  conv: ConversationIDTriple,
  tlfName: string,
  tlfPublic: boolean,
  supersedes: MessageID,
  body: string,
  clientPrev: MessageID,
  identifyBehavior: keybase1.TLFIdentifyBehavior
}>

export type localPostFileAttachmentLocalRpcParam = Exact<{
  conversationID: ConversationID,
  clientHeader: MessageClientHeader,
  attachment: LocalFileSource,
  preview?: ?MakePreviewRes,
  title: string,
  metadata: bytes,
  identifyBehavior: keybase1.TLFIdentifyBehavior
}>

export type localPostLocalNonblockRpcParam = Exact<{
  conversationID: ConversationID,
  msg: MessagePlaintext,
  clientPrev: MessageID,
  identifyBehavior: keybase1.TLFIdentifyBehavior
}>

export type localPostLocalRpcParam = Exact<{
  conversationID: ConversationID,
  msg: MessagePlaintext,
  identifyBehavior: keybase1.TLFIdentifyBehavior
}>

export type localPostTextNonblockRpcParam = Exact<{
  conversationID: ConversationID,
  conv: ConversationIDTriple,
  tlfName: string,
  tlfPublic: boolean,
  body: string,
  clientPrev: MessageID,
  identifyBehavior: keybase1.TLFIdentifyBehavior
}>

export type localRetryPostRpcParam = Exact<{
  outboxID: OutboxID
}>

export type localSetConversationStatusLocalRpcParam = Exact<{
  conversationID: ConversationID,
  status: ConversationStatus,
  identifyBehavior: keybase1.TLFIdentifyBehavior
}>

export type remoteGetInboxRemoteRpcParam = Exact<{
  vers: InboxVers,
  query?: ?GetInboxQuery,
  pagination?: ?Pagination
}>

export type remoteGetInboxVersionRpcParam = Exact<{
  uid: gregor1.UID
}>

export type remoteGetMessagesRemoteRpcParam = Exact<{
  conversationID: ConversationID,
  messageIDs?: ?Array<MessageID>
}>

export type remoteGetPublicConversationsRpcParam = Exact<{
  tlfID: TLFID,
  topicType: TopicType,
  summarizeMaxMsgs: boolean
}>

export type remoteGetS3ParamsRpcParam = Exact<{
  conversationID: ConversationID
}>

export type remoteGetThreadRemoteRpcParam = Exact<{
  conversationID: ConversationID,
  query?: ?GetThreadQuery,
  pagination?: ?Pagination
}>

export type remoteGetUnreadUpdateFullRpcParam = Exact<{
  inboxVers: InboxVers
}>

export type remoteMarkAsReadRpcParam = Exact<{
  conversationID: ConversationID,
  msgID: MessageID
}>

export type remoteNewConversationRemote2RpcParam = Exact<{
  idTriple: ConversationIDTriple,
  TLFMessage: MessageBoxed
}>

export type remoteNewConversationRemoteRpcParam = Exact<{
  idTriple: ConversationIDTriple
}>

export type remotePostRemoteRpcParam = Exact<{
  conversationID: ConversationID,
  messageBoxed: MessageBoxed
}>

export type remotePublishReadMessageRpcParam = Exact<{
  uid: gregor1.UID,
  convID: ConversationID,
  msgID: MessageID
}>

export type remotePublishSetConversationStatusRpcParam = Exact<{
  uid: gregor1.UID,
  convID: ConversationID,
  status: ConversationStatus
}>

export type remoteS3SignRpcParam = Exact<{
  version: int,
  payload: bytes
}>

export type remoteSetConversationStatusRpcParam = Exact<{
  conversationID: ConversationID,
  status: ConversationStatus
}>

export type remoteSyncAllRpcParam = Exact<{
  uid: gregor1.UID,
  deviceID: gregor1.DeviceID,
  session: gregor1.SessionToken,
  inboxVers: InboxVers,
  ctime: gregor1.Time
}>

export type remoteSyncChatRpcParam = Exact<{
  vers: InboxVers
}>

export type remoteSyncInboxRpcParam = Exact<{
  vers: InboxVers
}>

export type remoteTlfFinalizeRpcParam = Exact<{
  tlfID: TLFID,
  resetUser: string,
  resetDate: string,
  resetTimestamp: gregor1.Time,
  resetFull: string
}>

export type remoteTlfResolveRpcParam = Exact<{
  tlfID: TLFID,
  resolvedWriters?: ?Array<gregor1.UID>,
  resolvedReaders?: ?Array<gregor1.UID>
}>
type localDownloadAttachmentLocalResult = DownloadAttachmentLocalRes
type localDownloadFileAttachmentLocalResult = DownloadAttachmentLocalRes
type localFindConversationsLocalResult = FindConversationsLocalRes
type localGetCachedThreadResult = GetThreadLocalRes
type localGetConversationForCLILocalResult = GetConversationForCLILocalRes
type localGetInboxAndUnboxLocalResult = GetInboxAndUnboxLocalRes
type localGetInboxNonblockLocalResult = NonblockFetchRes
type localGetInboxSummaryForCLILocalResult = GetInboxSummaryForCLILocalRes
type localGetMessagesLocalResult = GetMessagesLocalRes
type localGetThreadLocalResult = GetThreadLocalRes
type localGetThreadNonblockResult = NonblockFetchRes
type localMakePreviewResult = MakePreviewRes
type localMarkAsReadLocalResult = MarkAsReadLocalRes
type localNewConversationLocalResult = NewConversationLocalRes
type localPostAttachmentLocalResult = PostLocalRes
type localPostDeleteNonblockResult = PostLocalNonblockRes
type localPostEditNonblockResult = PostLocalNonblockRes
type localPostFileAttachmentLocalResult = PostLocalRes
type localPostLocalNonblockResult = PostLocalNonblockRes
type localPostLocalResult = PostLocalRes
type localPostTextNonblockResult = PostLocalNonblockRes
type localSetConversationStatusLocalResult = SetConversationStatusLocalRes
type remoteGetInboxRemoteResult = GetInboxRemoteRes
type remoteGetInboxVersionResult = InboxVers
type remoteGetMessagesRemoteResult = GetMessagesRemoteRes
type remoteGetPublicConversationsResult = GetPublicConversationsRes
type remoteGetS3ParamsResult = S3Params
type remoteGetThreadRemoteResult = GetThreadRemoteRes
type remoteGetUnreadUpdateFullResult = UnreadUpdateFull
type remoteMarkAsReadResult = MarkAsReadRes
type remoteNewConversationRemote2Result = NewConversationRemoteRes
type remoteNewConversationRemoteResult = NewConversationRemoteRes
type remotePostRemoteResult = PostRemoteRes
type remoteS3SignResult = bytes
type remoteSetConversationStatusResult = SetConversationStatusRes
type remoteSyncAllResult = SyncAllResult
type remoteSyncChatResult = SyncChatRes
type remoteSyncInboxResult = SyncInboxRes

export type rpc =
    localCancelPostRpc
  | localDownloadAttachmentLocalRpc
  | localDownloadFileAttachmentLocalRpc
  | localFindConversationsLocalRpc
  | localGetCachedThreadRpc
  | localGetConversationForCLILocalRpc
  | localGetInboxAndUnboxLocalRpc
  | localGetInboxNonblockLocalRpc
  | localGetInboxSummaryForCLILocalRpc
  | localGetMessagesLocalRpc
  | localGetThreadLocalRpc
  | localGetThreadNonblockRpc
  | localMakePreviewRpc
  | localMarkAsReadLocalRpc
  | localNewConversationLocalRpc
  | localPostAttachmentLocalRpc
  | localPostDeleteNonblockRpc
  | localPostEditNonblockRpc
  | localPostFileAttachmentLocalRpc
  | localPostLocalNonblockRpc
  | localPostLocalRpc
  | localPostTextNonblockRpc
  | localRetryPostRpc
  | localSetConversationStatusLocalRpc
  | remoteGetInboxRemoteRpc
  | remoteGetInboxVersionRpc
  | remoteGetMessagesRemoteRpc
  | remoteGetPublicConversationsRpc
  | remoteGetS3ParamsRpc
  | remoteGetThreadRemoteRpc
  | remoteGetUnreadUpdateFullRpc
  | remoteMarkAsReadRpc
  | remoteNewConversationRemote2Rpc
  | remoteNewConversationRemoteRpc
  | remotePostRemoteRpc
  | remotePublishReadMessageRpc
  | remotePublishSetConversationStatusRpc
  | remoteS3SignRpc
  | remoteSetConversationStatusRpc
  | remoteSyncAllRpc
  | remoteSyncChatRpc
  | remoteSyncInboxRpc
  | remoteTlfFinalizeRpc
  | remoteTlfResolveRpc

export type incomingCallMapType = Exact<{
  'keybase.1.chatUi.chatAttachmentUploadOutboxID'?: (
    params: Exact<{
      sessionID: int,
      outboxID: OutboxID
    }>,
    response: CommonResponseHandler
  ) => void,
  'keybase.1.chatUi.chatAttachmentUploadStart'?: (
    params: Exact<{
      sessionID: int,
      metadata: AssetMetadata,
      placeholderMsgID: MessageID
    }>,
    response: CommonResponseHandler
  ) => void,
  'keybase.1.chatUi.chatAttachmentUploadProgress'?: (
    params: Exact<{
      sessionID: int,
      bytesComplete: int,
      bytesTotal: int
    }>,
    response: CommonResponseHandler
  ) => void,
  'keybase.1.chatUi.chatAttachmentUploadDone'?: (
    params: Exact<{
      sessionID: int
    }>,
    response: CommonResponseHandler
  ) => void,
  'keybase.1.chatUi.chatAttachmentPreviewUploadStart'?: (
    params: Exact<{
      sessionID: int,
      metadata: AssetMetadata
    }>,
    response: CommonResponseHandler
  ) => void,
  'keybase.1.chatUi.chatAttachmentPreviewUploadDone'?: (
    params: Exact<{
      sessionID: int
    }>,
    response: CommonResponseHandler
  ) => void,
  'keybase.1.chatUi.chatAttachmentDownloadStart'?: (
    params: Exact<{
      sessionID: int
    }>,
    response: CommonResponseHandler
  ) => void,
  'keybase.1.chatUi.chatAttachmentDownloadProgress'?: (
    params: Exact<{
      sessionID: int,
      bytesComplete: int,
      bytesTotal: int
    }>,
    response: CommonResponseHandler
  ) => void,
  'keybase.1.chatUi.chatAttachmentDownloadDone'?: (
    params: Exact<{
      sessionID: int
    }>,
    response: CommonResponseHandler
  ) => void,
  'keybase.1.chatUi.chatInboxUnverified'?: (
    params: Exact<{
      sessionID: int,
      inbox: GetInboxLocalRes
    }>,
    response: CommonResponseHandler
  ) => void,
  'keybase.1.chatUi.chatInboxConversation'?: (
    params: Exact<{
      sessionID: int,
      conv: ConversationLocal
    }>,
    response: CommonResponseHandler
  ) => void,
  'keybase.1.chatUi.chatInboxFailed'?: (
    params: Exact<{
      sessionID: int,
      convID: ConversationID,
      error: ConversationErrorLocal
    }>,
    response: CommonResponseHandler
  ) => void,
  'keybase.1.chatUi.chatThreadCached'?: (
    params: Exact<{
      sessionID: int,
      thread?: ?ThreadView
    }>,
    response: CommonResponseHandler
  ) => void,
  'keybase.1.chatUi.chatThreadFull'?: (
    params: Exact<{
      sessionID: int,
      thread: ThreadView
    }>,
    response: CommonResponseHandler
  ) => void,
  'keybase.1.NotifyChat.NewChatActivity'?: (
    params: Exact<{
      uid: keybase1.UID,
      activity: ChatActivity
    }> /* ,
    response: {} // Notify call
    */
  ) => void,
  'keybase.1.NotifyChat.ChatIdentifyUpdate'?: (
    params: Exact<{
      update: keybase1.CanonicalTLFNameAndIDWithBreaks
    }> /* ,
    response: {} // Notify call
    */
  ) => void,
  'keybase.1.NotifyChat.ChatTLFFinalize'?: (
    params: Exact<{
      uid: keybase1.UID,
      convID: ConversationID,
      finalizeInfo: ConversationFinalizeInfo,
      conv?: ?ConversationLocal
    }> /* ,
    response: {} // Notify call
    */
  ) => void,
  'keybase.1.NotifyChat.ChatTLFResolve'?: (
    params: Exact<{
      uid: keybase1.UID,
      convID: ConversationID,
      resolveInfo: ConversationResolveInfo
    }> /* ,
    response: {} // Notify call
    */
  ) => void,
  'keybase.1.NotifyChat.ChatInboxStale'?: (
    params: Exact<{
      uid: keybase1.UID
    }> /* ,
    response: {} // Notify call
    */
  ) => void,
  'keybase.1.NotifyChat.ChatThreadsStale'?: (
    params: Exact<{
      uid: keybase1.UID,
      convIDs?: ?Array<ConversationID>
    }> /* ,
    response: {} // Notify call
    */
  ) => void
}>
