@artinet/sdk
Version:
A TypeScript SDK for building collaborative AI agents.
55 lines (54 loc) • 1.93 kB
TypeScript
/**
* Sanitizes a string by escaping HTML characters to prevent XSS attacks.
* @param str - The string to sanitize.
* @returns The sanitized string.
*/
export declare function sanitizeString(str: string): string;
/**
* Generates a timestamp in ISO 8601 format.
* @returns The current timestamp as a string.
*/
export declare function getCurrentTimestamp(): string;
/**
* Sleeps for a given number of milliseconds.
* @param ms - The number of milliseconds to sleep.
* @returns A promise that resolves when the sleep is complete.
*
* @example
* ```typescript
* await sleep(1000);
* ```
*/
export declare function sleep(ms: number): Promise<void>;
/**
* Formats a JSON object into a string with indentation.
* @param json - The JSON object to format.
* @param replacer - A function that transforms the results.
* @param space - Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
* @returns A string representation of the JSON object.
*/
export declare function formatJson(json: object, replacer?: (number | string)[] | null, space?: string | number): string;
/**
* Formats an error into a standard error object for logging.
* @param error - The error to format.
* @returns A standard error object.
*/
export declare function formatError(error: unknown): Error;
/**
* Executes a function immediately.
* @param fn - The function to execute.
* @returns The result of the function.
*
* @example
* ```typescript
* const result = iife(() => {
* return 1 + 1;
* });
* console.log(result); // 2
* ```
* LangChain <3
* @see https://github.com/langchain-ai/langchainjs/blob/981cf9c480925187a524fd6ad1dbf0488d2758eb/libs/langchain-core/src/language_models/utils.ts#L5
*/
export declare const iife: <T>(fn: () => T) => T;
export declare function encodeBase64(data: string): string;
export declare function decodeBase64(data: string): string;