/** * The **Photon AI Assistant** — the branch of Photon AI that answers questions * instead of operating the grid. * * `PhotonAIService` turns "sort by salary" into a grid action. This handles * everything else a user might type into the same box: * * | Request kind | Source of truth | Model's role | * |---|---|---| * | "how do I use this with React?" | curated {@link KNOWLEDGE_ARTICLES} | select + phrase | * | "generate dummy columns" | {@link ScaffoldGenerator} | none — returned verbatim | * | "what sells best?" | {@link DataAnalysisService}, computed locally | narrate the numbers | * | "why is my grid slow?" | {@link GridDoctor}, reading live config | narrate the findings | * * The through-line: **facts are computed or curated locally; the model only * phrases them.** That is what keeps answers accurate about a library the model * has never seen, keeps row data on the user's machine, and keeps token cost * proportional to the answer rather than the dataset. * * @packageDocumentation */ import type { GridApi } from '../core/grid-api'; import type { GridOptions } from '../types/grid.types'; import type { ThemeVariableRegistryReader } from '../types/theme-ai.types'; import type { PhotonAIProvider } from './provider/ai-provider.types'; /** What kind of non-command request this is. */ export declare enum AssistantRequestKind { /** Documentation, examples, "how do I…". */ Knowledge = "knowledge", /** "Generate columns / a dataset / theme variables / datasource code". */ Generate = "generate", /** Questions about the data itself. */ Analyze = "analyze", /** Questions about the grid's health or configuration. */ Diagnose = "diagnose" } /** Outcome of an assistant attempt. `handled: false` means "not my request". */ export interface AssistantResult { readonly handled: boolean; readonly message: string; readonly success?: boolean; } /** * Answers non-command Photon AI requests. * * Construct one per grid. {@link handle} returns `handled: false` for anything * it does not claim, so the caller can fall through to the command pipeline — * the same contract `PhotonThemeEngine.handlePanelCommand` already uses. */ export declare class PhotonAIAssistant { private readonly api; private readonly options; private readonly provider; private readonly themeRegistry; private readonly generator; private readonly analysis; private readonly doctor; constructor(api: GridApi, options: GridOptions, provider: PhotonAIProvider | null, themeRegistry: ThemeVariableRegistryReader | null); /** * Attempts to answer `prompt`. * * @returns `handled: false` when this is a grid command rather than a question. */ handle(prompt: string, signal?: AbortSignal): Promise; /** * Decides which branch — if any — owns this prompt. * * Order matters: * 1. Generation first, because "generate columns" also matches knowledge. * 2. Imperative grid commands bail out — they belong to the command AI. * 3. Live-state questions bail out for the same reason. * 4. Diagnose before analyse ("why is my grid slow" contains neither's * vocabulary exclusively). * 5. Knowledge last, and only when the corpus actually has something. */ private classify; private isGenerateRequest; /** Generation is fully deterministic — no provider needed, no tokens spent. */ private handleGenerate; /** Retrieves the relevant article(s) and has the model answer strictly from them. */ private handleKnowledge; /** Computes statistics locally, then has the model narrate them. */ private handleAnalyze; /** Inspects the live config, then has the model explain the findings. */ private handleDiagnose; /** * One provider round-trip returning prose. * * These branches want a written answer, not grid actions, so the reply is * taken and any `actions` ignored. Reusing `provider.generate` keeps every * feature on the one configured back-end, with its timeout, abort handling, * and error taxonomy intact. */ private ask; } //# sourceMappingURL=photon-ai-assistant.d.ts.map