Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

1.5 KB
Raw Blame
export type GatewayConnectionStatus =
  'connected' | 'connecting' | 'disconnected' | 'reconnecting' | 'authenticating';

/**
 * Why the last connection attempt ended. Cleared when a new attempt starts or
 * the user turns the connection off.
 */
export type GatewayConnectionErrorCode =
  /** The gateway rejected this login's credential. */
  | 'auth_failed'
  /** The current server's configuration could not be loaded. */
  | 'config_unavailable'
  /** The saved, advertised or overridden gateway address is not a usable URL. */
  | 'invalid_gateway_url'
  | 'not_signed_in';

export interface GatewayConnectionError {
  code: GatewayConnectionErrorCode;
  /** Diagnostic detail for logs and tooltips; user-facing copy comes from `code`. */
  detail?: string;
}

export interface GatewayConnectionState {
  error?: GatewayConnectionError;
  status: GatewayConnectionStatus;
}

export interface GatewayConnectResult {
  error?: string;
  errorCode?: GatewayConnectionErrorCode;
  success: boolean;
}

export type GatewayEndpointSource = 'manual' | 'official' | 'override' | 'server';

export interface GatewayEndpointInfo {
  /** Address of the current connection, once one has been resolved. */
  endpoint?: { source: GatewayEndpointSource; url: string };
  /** Address saved in settings; it beats the server's own. */
  manualUrl?: string;
  /** The server the desktop is signed in to, when there is one. */
  serverUrl?: string;
}

export interface GatewayConnectionBroadcastEvents {
  gatewayConnectionStatusChanged: (params: GatewayConnectionState) => void;
}