first commit

This commit is contained in:
2025-10-26 23:10:15 +08:00
commit 8f0345b7be
14961 changed files with 2356381 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
import { z } from 'zod';
/**
* This file contains the logic for parsing node parameters and extracting $fromAI calls
*/
export type FromAIArgumentType = 'string' | 'number' | 'boolean' | 'json';
export type FromAIArgument = {
key: string;
description?: string;
type?: FromAIArgumentType;
defaultValue?: string | number | boolean | Record<string, unknown>;
};
/**
* Generates a Zod schema based on the provided FromAIArgument placeholder.
* @param placeholder The FromAIArgument object containing key, type, description, and defaultValue.
* @returns A Zod schema corresponding to the placeholder's type and constraints.
*/
export declare function generateZodSchema(placeholder: FromAIArgument): z.ZodTypeAny;
/**
* Extracts all $fromAI calls from a given string
* @param str The string to search for $fromAI calls.
* @returns An array of FromAIArgument objects.
*
* This method uses a regular expression to find the start of each $fromAI function call
* in the input string. It then employs a character-by-character parsing approach to
* accurately extract the arguments of each call, handling nested parentheses and quoted strings.
*
* The parsing process:
* 1. Finds the starting position of a $fromAI call using regex.
* 2. Iterates through characters, keeping track of parentheses depth and quote status.
* 3. Handles escaped characters within quotes to avoid premature quote closing.
* 4. Builds the argument string until the matching closing parenthesis is found.
* 5. Parses the extracted argument string into a FromAIArgument object.
* 6. Repeats the process for all $fromAI calls in the input string.
*
*/
export declare function extractFromAICalls(str: string): FromAIArgument[];
/**
* Recursively traverses the nodeParameters object to find all $fromAI calls.
* @param payload The current object or value being traversed.
* @param collectedArgs The array collecting FromAIArgument objects.
*/
export declare function traverseNodeParameters(payload: unknown, collectedArgs: FromAIArgument[]): void;
export declare function traverseNodeParametersWithParamNames(payload: unknown, collectedArgs: Map<string, FromAIArgument>, name?: string): void;
//# sourceMappingURL=from-ai-parse-utils.d.ts.map