import { AxGen } from './generate.js'; import { AxSignature } from './sig.js'; import type { ParseSignature } from './sigtypes.js'; import type { AxProgramForwardOptions } from './types.js'; // Function for string-based type-safe signature creation export function s( signature: T ): AxSignature['inputs'], ParseSignature['outputs']> { return AxSignature.create(signature); } // Function for type-safe generator creation - supports both strings and AxSignature objects export function ax< const T extends string, ThoughtKey extends string = 'thought', >( signature: T, options?: Readonly< AxProgramForwardOptions & { thoughtFieldName?: ThoughtKey } > ): AxGen< ParseSignature['inputs'], ParseSignature['outputs'] & (string extends ThoughtKey ? { thought?: string } : { [P in ThoughtKey]?: string }) >; export function ax< TInput extends Record, TOutput extends Record, ThoughtKey extends string = 'thought', >( signature: AxSignature, options?: Readonly< AxProgramForwardOptions & { thoughtFieldName?: ThoughtKey } > ): AxGen< TInput, TOutput & (string extends ThoughtKey ? { thought?: string } : { [P in ThoughtKey]?: string }) >; export function ax< T extends string | AxSignature, ThoughtKey extends string = 'thought', TInput extends Record = T extends string ? ParseSignature['inputs'] : T extends AxSignature ? I : never, TOutput extends Record = T extends string ? ParseSignature['outputs'] : T extends AxSignature ? O : never, >( signature: T, options?: Readonly< AxProgramForwardOptions & { thoughtFieldName?: ThoughtKey } > ): AxGen< TInput, TOutput & (string extends ThoughtKey ? { thought?: string } : { [P in ThoughtKey]?: string }) > { const typedSignature = typeof signature === 'string' ? AxSignature.create(signature) : (signature as AxSignature); return new AxGen< TInput, TOutput & (string extends ThoughtKey ? { thought?: string } : { [P in ThoughtKey]?: string }) >(typedSignature, options as any); }