export interface NerbsEvent {
  id: number;
  spaceId: string;
  channelId: string | null;
  type: string;
  payload: {
    messageId?: string;
    parentId?: string;
    body?: string;
    agentId?: string;
    [key: string]: unknown;
  };
  createdAt: string;
}
export interface CursorStore {
  load(): Promise<number | null>;
  save(cursor: number): Promise<void>;
}
export class NerbsAgent {
  constructor(options: {
    token: string;
    spaceId: string;
    baseUrl?: string;
    fetch?: typeof fetch;
  });
  sendMessage(
    channelId: string,
    body: string,
    options?: { parentId?: string; clientId?: string; signal?: AbortSignal },
  ): Promise<unknown>;
  reply(
    event: NerbsEvent,
    body: string,
    options?: { clientId?: string; signal?: AbortSignal },
  ): Promise<unknown>;
  listen(options: {
    store: CursorStore;
    onEvent(event: NerbsEvent, agent: NerbsAgent): Promise<void>;
    signal?: AbortSignal;
    pollInterval?: number;
  }): Promise<void>;
}
