rdesign/frontend/node_modules/@copilotkitnext/shared/dist/utils.d.cts

25 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//#region src/utils.d.ts
declare function randomUUID(): string;
declare function partialJSONParse(json: string): unknown;
/**
* Safely parses a JSON string into a plain object for tool arguments.
* Handles two failure modes:
* 1. Malformed JSON (SyntaxError from JSON.parse)
* 2. Valid JSON that isn't a plain object (e.g. "", [], null, 42, true)
* Falls back to an empty object for safety in both cases.
*/
declare function safeParseToolArgs(raw: string): Record<string, unknown>;
/**
* Returns an exponential backoff function suitable for Phoenix.js
* `reconnectAfterMs` and `rejoinAfterMs` options.
*
* @param baseMs - Initial delay for the first retry attempt.
* @param maxMs - Upper bound — delays are capped at this value.
*
* Phoenix calls the returned function with a 1-based `tries` count.
* The delay doubles on each attempt: baseMs, 2×baseMs, 4×baseMs, …, maxMs.
*/
declare function phoenixExponentialBackoff(baseMs: number, maxMs: number): (tries: number) => number;
//#endregion
export { partialJSONParse, phoenixExponentialBackoff, randomUUID, safeParseToolArgs };
//# sourceMappingURL=utils.d.cts.map