@gguf/claw
Version:
Multi-channel AI gateway with extensible messaging integrations
64 lines (63 loc) • 2.01 kB
TypeScript
import type { DeviceIdentity } from "../infra/device-identity.js";
import { type GatewayClientMode, type GatewayClientName } from "../utils/message-channel.js";
import { type EventFrame, type HelloOk } from "./protocol/index.js";
export type GatewayClientOptions = {
url?: string;
connectDelayMs?: number;
tickWatchMinIntervalMs?: number;
token?: string;
password?: string;
instanceId?: string;
clientName?: GatewayClientName;
clientDisplayName?: string;
clientVersion?: string;
platform?: string;
mode?: GatewayClientMode;
role?: string;
scopes?: string[];
caps?: string[];
commands?: string[];
permissions?: Record<string, boolean>;
pathEnv?: string;
deviceIdentity?: DeviceIdentity;
minProtocol?: number;
maxProtocol?: number;
tlsFingerprint?: string;
onEvent?: (evt: EventFrame) => void;
onHelloOk?: (hello: HelloOk) => void;
onConnectError?: (err: Error) => void;
onClose?: (code: number, reason: string) => void;
onGap?: (info: {
expected: number;
received: number;
}) => void;
};
export declare const GATEWAY_CLOSE_CODE_HINTS: Readonly<Record<number, string>>;
export declare function describeGatewayCloseCode(code: number): string | undefined;
export declare class GatewayClient {
private ws;
private opts;
private pending;
private backoffMs;
private closed;
private lastSeq;
private connectNonce;
private connectSent;
private connectTimer;
private lastTick;
private tickIntervalMs;
private tickTimer;
constructor(opts: GatewayClientOptions);
start(): void;
stop(): void;
private sendConnect;
private handleMessage;
private queueConnect;
private scheduleReconnect;
private flushPendingErrors;
private startTickWatch;
private validateTlsFingerprint;
request<T = Record<string, unknown>>(method: string, params?: unknown, opts?: {
expectFinal?: boolean;
}): Promise<T>;
}