UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

51 lines • 2.66 kB
import type { PathSpec } from '../../types.ts'; import { ApiError } from '../api/errors.ts'; export type DiscordMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'; export type DiscordResponse = unknown; export declare class DiscordApiError extends ApiError { readonly endpoint: string; readonly discordError: string; readonly payload?: unknown | undefined; readonly status: number; constructor(endpoint: string, status: number, discordError: string, payload?: unknown | undefined); } /** * Report a channel Discord will not show as permission denied. * * A 401 or 403 (Missing Access) is Discord declining to show what the path * names, never the channel saying it is empty, so the path answers the way a * directory the caller may not open does: ls names it and fails, find reports * it and walks on. A 404 is the channel gone since it was listed. Any other * failure, a 429 that outlasted its retries among them, propagates. */ export declare function refusalsDenied<T>(pathSpec: PathSpec, run: () => Promise<T>): Promise<T>; export interface DiscordFile { name: string; data: Uint8Array; } export interface DiscordTransport { call(method: DiscordMethod, endpoint: string, params?: Record<string, string | number>, body?: Record<string, unknown>): Promise<DiscordResponse>; postFiles?(endpoint: string, body: Record<string, unknown>, files: readonly DiscordFile[]): Promise<DiscordResponse>; } export declare abstract class HttpDiscordTransport implements DiscordTransport { protected readonly timeout?: number | undefined; protected readonly fetch: typeof fetch; constructor(timeout?: number | undefined); protected abstract baseUrl(): string; protected abstract authHeaders(): Promise<Record<string, string>> | Record<string, string>; call(method: DiscordMethod, endpoint: string, params?: Record<string, string | number>, body?: Record<string, unknown>): Promise<DiscordResponse>; /** * POST a message with attachments, as Discord takes them: a multipart body * whose `payload_json` part is the JSON body and whose `files[n]` parts are * the files, each named by an `attachments` entry of the same id. */ postFiles(endpoint: string, body: Record<string, unknown>, files: readonly DiscordFile[]): Promise<DiscordResponse>; } export declare class NodeDiscordTransport extends HttpDiscordTransport { private readonly token; private readonly base?; constructor(token: string, base?: string | undefined, timeout?: number); protected baseUrl(): string; protected authHeaders(): Record<string, string>; } //# sourceMappingURL=client.d.ts.map