import { ZodTypeAny, infer } from 'zod'; import { G as GuardOptions, a as GuardResult, P as ProviderCallOptions, R as ReforgeProvider, M as Message, F as ForgeOptions, b as ForgeResult, c as ForgeFallbackProvider, d as ForgeFallbackOptions } from './types-BthWWfka.cjs'; export { e as ForgeAttemptDetail, f as ForgeEvent, g as ForgeFailure, h as ForgeFailurePayload, i as ForgeProviderHop, j as ForgeRetryPolicy, k as ForgeSuccess, l as ForgeTelemetry, m as GuardDebugArtifacts, n as GuardFailure, o as GuardHeuristicOptions, p as GuardProfile, q as GuardSemanticResolution, r as GuardSemanticResolutionInput, s as GuardSemanticResolver, t as GuardSuccess, u as MessageContent, v as MessageContentBlock, w as MessageImageUrlBlock, x as MessageTextBlock, y as ReforgeTool, z as ReforgeToolCall, A as ReforgeToolResponse, B as RetryPromptContextBlock, C as RetryPromptMode, D as RetryPromptOptions, E as RetryPromptStrategy, H as RetryPromptStrategyInput, T as TelemetryData } from './types-BthWWfka.cjs'; export { OpenAICompatibleCallOptions } from './providers/openai-compatible.cjs'; export { AnthropicCallOptions } from './providers/anthropic.cjs'; export { GoogleCallOptions } from './providers/google.cjs'; export { OpenRouterCallOptions } from './providers/openrouter.cjs'; export { GroqCallOptions } from './providers/groq.cjs'; export { TogetherCallOptions } from './providers/together.cjs'; /** * Validate and repair raw LLM output against a Zod schema. * * `guard()` is the single entry-point for Reforge. It runs a three-stage * pipeline — **parse → validate → report** — and returns a typed, * discriminated-union result that is safe to pattern-match on. * * ### Pipeline * 1. **Dirty Parse** — Extracts JSON from markdown wrappers, fixes trailing * commas / unquoted keys / single quotes, and closes truncated brackets. * 2. **Schema Validation** — Runs `schema.safeParse()` with automatic * coercion for common LLM type mismatches (string `"true"` → boolean, etc.). * 3. **Result** — Returns either `{ success: true, data, telemetry }` or * `{ success: false, retryPrompt, errors, telemetry }`. * * ### Guarantees * - **Never throws.** All error paths return a typed failure object. * - **Synchronous.** No async, no network calls, no I/O. * - **Pure.** No global state is mutated. * - **Fast.** Targets < 5 ms for a 2 KB input string. * * @typeParam T - A Zod schema type (e.g. `z.ZodObject<…>`). * @param llmOutput - The raw string produced by an LLM. * @param schema - The Zod schema the output must conform to. * @returns A `GuardResult>` — either success with typed data * or failure with a retry prompt and error details. * * @example * ```ts * import { z } from 'zod'; * import { guard } from 'reforge-ai'; * * const UserSchema = z.object({ * name: z.string(), * age: z.number(), * }); * * const result = guard('```json\n{"name": "Alice", "age": 30,}\n```', UserSchema); * * if (result.success) { * console.log(result.data); // { name: "Alice", age: 30 } * console.log(result.isRepaired); // true * console.log(result.telemetry); // { durationMs: 0.4, status: "repaired_natively" } * } else { * // Append result.retryPrompt to your LLM conversation * console.log(result.retryPrompt); * } * ``` */ declare function guard(llmOutput: string, schema: T, options?: GuardOptions): GuardResult>; declare class ForgeNetworkError extends Error { readonly providerIndex: number; readonly providerId: string; readonly causeValue: unknown; constructor(message: string, providerIndex: number, providerId: string, causeValue: unknown); } /** * End-to-end structured LLM output: call a provider, validate with * `guard()`, and automatically retry on failure. * * @typeParam T - A Zod schema type. * @param provider - A `ReforgeProvider` (built-in adapter or custom). * @param messages - The conversation messages to send to the LLM. * @param schema - The Zod schema the output must conform to. * @param options - Optional configuration (maxRetries, providerOptions). * @returns A `ForgeResult>` with telemetry. */ declare function forge = ProviderCallOptions>(provider: ReforgeProvider | ReforgeProvider[], messages: Message[], schema: T, options?: ForgeOptions): Promise>>; /** * Try multiple providers in order until one succeeds. * * Each provider can define its own `maxAttempts` and `providerOptions`. * The helper preserves the same `ForgeResult` contract as `forge()`. */ declare function forgeWithFallback(providers: ForgeFallbackProvider[], messages: Message[], schema: T, options?: ForgeFallbackOptions): Promise>>; export { ForgeFallbackOptions, ForgeFallbackProvider, ForgeNetworkError, ForgeOptions, ForgeResult, GuardOptions, GuardResult, Message, ProviderCallOptions, ReforgeProvider, forge, forgeWithFallback, guard };