@velatir/sdk
Version:
Official TypeScript SDK for Velatir - Monitor and approve/reject AI function calls
86 lines (79 loc) • 2.84 kB
TypeScript
declare enum LogLevel {
NONE = 0,
ERROR = 1,
INFO = 2,
DEBUG = 3
}
interface VelatirResponse$1 {
requestId: string;
state: 'approved' | 'denied' | 'pending';
}
interface ClientConfig {
apiKey?: string;
baseUrl?: string;
timeout?: number;
logLevel?: LogLevel | number;
maxRetries?: number;
retryBackoff?: number;
}
interface WatchOptions {
pollingInterval?: number;
maxAttempts?: number;
metadata?: Record<string, unknown>;
}
declare class VelatirResponse implements VelatirResponse$1 {
readonly requestId: string;
readonly state: 'approved' | 'denied' | 'pending';
constructor(data: VelatirResponse$1);
get isApproved(): boolean;
get isDenied(): boolean;
get isPending(): boolean;
}
declare class Client {
private static readonly DEFAULT_BASE_URL;
private static readonly DEFAULT_TIMEOUT;
private readonly apiKey?;
private readonly baseUrl;
private readonly timeout;
private readonly logLevel;
private readonly maxRetries;
private readonly retryBackoff;
private httpClient;
constructor(config?: ClientConfig);
private parseLogLevel;
private createHttpClient;
private log;
private request;
private shouldRetry;
private handleError;
private sleep;
createWatchRequest(functionName: string, args: Record<string, unknown>, doc?: string, metadata?: Record<string, unknown>): Promise<VelatirResponse>;
getWatchStatus(requestId: string): Promise<VelatirResponse>;
waitForApproval(requestId: string, pollingInterval?: number, maxAttempts?: number): Promise<VelatirResponse>;
}
interface WatchDecoratorOptions extends WatchOptions {
}
declare function watch(options?: WatchDecoratorOptions): MethodDecorator;
declare class VelatirError extends Error {
constructor(message: string);
}
declare class VelatirAPIError extends VelatirError {
readonly code?: string | number;
readonly httpStatus?: number;
readonly httpBody?: string;
constructor(message: string, code?: string | number, httpStatus?: number, httpBody?: string);
}
declare class VelatirTimeoutError extends VelatirError {
constructor(message: string);
}
declare class VelatirWatchDeniedError extends VelatirError {
readonly requestId: string;
constructor(requestId: string);
}
declare const VERSION = "0.1.0";
declare function init(config?: ClientConfig): Client;
declare function resetGlobalClient(): void;
declare function getClient(): Client;
declare function configureLogging(level: LogLevel | number): void;
export { Client, LogLevel, VERSION, VelatirAPIError, VelatirError, VelatirResponse, VelatirTimeoutError, VelatirWatchDeniedError, configureLogging, getClient, init, resetGlobalClient, watch };
export type { ClientConfig, VelatirResponse$1 as IVelatirResponse, WatchOptions };