/** * Schema flatten — ported from reasonix (MIT) and adapted to Franklin's * CapabilitySchema shape. Deep / wide schemas get dropped or hallucinated * by some models (DeepSeek R1, smaller Llamas, some Qwen variants); present * them as dot-paths and re-nest before dispatch. * * Pure functions; no side effects. Wire into a tool registry via * analyzeSchema(spec.input_schema) at registration time, then call * flattenSchema() on the spec sent to the model and nestArguments() on * the parsed call arguments before invoking the handler. */ import type { CapabilitySchema } from '../types.js'; /** Loose recursive schema — properties of a CapabilitySchema are typed * `unknown`, but in practice they are JSON-Schema-like objects. */ export interface SchemaNode { type?: string | string[]; properties?: Record; required?: string[]; items?: SchemaNode; [k: string]: unknown; } export interface FlattenDecision { shouldFlatten: boolean; leafCount: number; maxDepth: number; } export declare function analyzeSchema(schema: SchemaNode | CapabilitySchema | undefined, opts?: { leafLimit?: number; depthLimit?: number; }): FlattenDecision; export declare function flattenSchema(schema: SchemaNode | CapabilitySchema): CapabilitySchema; export declare function nestArguments(flatArgs: Record): Record;