askexperts
Version:
AskExperts SDK: build and use AI experts - ask them questions and pay with bitcoin on an open protocol
73 lines (72 loc) • 2.89 kB
TypeScript
import type { DBExpert } from "../db/interfaces.js";
import type { ExpertClient } from "./ExpertClient.js";
/**
* Remote implementation of the ExpertClient interface
* Uses fetch to communicate with an ExpertServer instance
*/
export declare class ExpertRemoteClient implements ExpertClient {
private baseUrl;
private privateKey?;
/**
* Creates a new ExpertRemoteClient instance
* @param url - URL of the ExpertServer (e.g., 'http://localhost:3000/api')
* @param privateKey - Optional private key for authentication (as Uint8Array)
*/
constructor(url: string, privateKey?: Uint8Array);
/**
* Create request headers with authentication if privateKey is provided
* @param method - HTTP method for the request
* @param url - URL for the request
* @returns Headers object with authentication if available
*/
private createHeaders;
/**
* List all experts
* @returns Promise resolving to an array of expert objects
*/
listExperts(): Promise<DBExpert[]>;
/**
* List experts by specific IDs
* @param ids - Array of expert pubkeys to retrieve
* @returns Promise resolving to an array of expert objects matching the provided IDs
*/
listExpertsByIds(ids: string[]): Promise<DBExpert[]>;
/**
* Get an expert by pubkey
* @param pubkey - Pubkey of the expert to get
* @returns Promise resolving to the expert if found, null otherwise
*/
getExpert(pubkey: string): Promise<DBExpert | null>;
/**
* Insert a new expert
* @param expert - Expert to insert
* @returns Promise resolving to true if expert was inserted, false otherwise
*/
insertExpert(expert: DBExpert): Promise<boolean>;
/**
* Update an existing expert
* @param expert - Expert to update
* @returns Promise resolving to true if expert was updated, false otherwise
*/
updateExpert(expert: DBExpert): Promise<boolean>;
/**
* Set the disabled status of an expert
* @param pubkey - Pubkey of the expert to update
* @param disabled - Whether the expert should be disabled
* @returns Promise resolving to true if expert was updated, false otherwise
*/
setExpertDisabled(pubkey: string, disabled: boolean): Promise<boolean>;
/**
* Delete an expert
* @param pubkey - Pubkey of the expert to delete
* @returns Promise resolving to true if expert was deleted, false otherwise
*/
deleteExpert(pubkey: string): Promise<boolean>;
}
/**
* Get an ExpertClient instance
* @param url - Optional URL for remote expert client
* @returns ExpertClient instance (DB if url is undefined, RemoteExpertClient otherwise)
* @throws Error if url is provided (RemoteExpertClient not fully implemented yet)
*/
export declare function getExpertClient(url?: string, privateKey?: Uint8Array): ExpertClient;