/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ import type { EastType } from "@elaraai/east"; /** * What a builder's fit asks, and how. * * @typeParam Q - A question * @typeParam P - The plan a question is asked of: the builder's drafts * @typeParam C - The context it is asked in * @typeParam R - An answer */ export interface FitQuestions { /** The app's function's name; `null` with none, and nothing is asked. */ name: string | null; /** What the function takes. */ requestType: EastType; /** What it answers. */ resultType: EastType; /** A question's key: its East text. */ key: (question: Q) => string; /** The key of the question an answer answers, from what it echoes. */ answers: (result: R) => string; /** The function's argument for a question about a plan, in a context. */ request: (question: Q, plan: P, context: C) => unknown; } /** * A builder's fit (see the module docs). * * @typeParam Q - A question * @typeParam P - A plan * @typeParam R - An answer */ export interface FitAnswers { /** The answer to a question about the plan as it stands, or about one derived from it, once it has landed (F1). */ answer: (question: Q, of?: P) => R | undefined; /** * Asks a question of the plan as it stands, or of one derived from it: answered from what is kept, else sent once nothing is in * flight. A new plan or context is a new `ask`, so an effect that asks, listing it, asks again then (F1). */ ask: (question: Q, of?: P) => void; /** Whether a question asked of the plan as it stands is unanswered (F2). */ pending: boolean; /** Why the last call failed (F3). */ error: string | undefined; /** Asks the failed question again (F3). */ retry: () => void; } /** * A builder's fit (see the module docs). * * @typeParam Q - A question * @typeParam P - The plan a question is asked of, kept by identity: a new plan, new answers * @typeParam C - The context it is asked in, kept by identity: a new context, new answers * @typeParam R - An answer * @param questions - The function, and how a question is keyed, answered and asked * @param plan - The builder's drafts as they stand * @param context - What every question is asked in * @returns The fit */ export declare function useFit(questions: FitQuestions, plan: P, context: C): FitAnswers; //# sourceMappingURL=use-fit.d.ts.map