import type { GridApi } from '../core/grid-api'; import { PhotonAICommandRegistry } from './photon-ai-registry'; import { type PhotonAIProvider } from './provider/ai-provider.types'; import type { PhotonCommandResult } from './photon-ai.types'; /** * The only public entry point into Photon AI. Runs the full deterministic * pipeline for one prompt: * * ``` * split into clauses → (learned-phrase replay | normalize → parse intent → * resolve entities → build command) → execute → learn * ``` * * A compound sentence ("hide the id column and sort by price descending") * is split into independent clauses by {@link splitClauses} and each is run * through the pipeline in order, so multi-step natural-language requests * work without any single intent needing to know about the others. * * Every successfully-executed clause is remembered by a * {@link PhotonAIMemoryStore}, namespaced to this grid's current columns: * the *next* time the same clause is typed, it replays the learned command * directly (skipping intent matching and entity resolution entirely) as * long as the column it refers to still exists — this is what makes Photon * AI "learn" a user's phrasing over time, including phrasings that only * resolved on the first try via fuzzy/implicit matching. * * Every stage past clause-splitting is a small, independent, replaceable * collaborator (`IntentParser`, `EntityResolver`, `CommandBuilder`, * `CommandExecutor`); this class only sequences them and never contains * matching or execution logic itself. */ export declare class PhotonAIService { private api; private readonly registry; private readonly memory; private readonly parser; private readonly resolver; private readonly builder; private readonly executor; /** * Generative back-end, when one was configured (e.g. Gemini). `null` keeps * Photon AI in its default fully-deterministic mode — the two modes share * the same registry, executor, and result contract, so nothing else changes. */ private readonly provider; /** Extra domain guidance appended to the base system instruction; only meaningful when {@link provider} is set. */ private readonly providerSystemInstruction?; /** Builds a fresh grid-context snapshot per generative request. Lazily constructed alongside a provider. */ private readonly contextBuilder; /** * Classifies each prompt into the grid domains it touches, so only the * relevant slice of context is sent. Lazily constructed alongside a provider * — the deterministic pipeline never sends anything anywhere, so it has * nothing to optimize. */ private readonly contextRouter; /** Reshapes model-generated actions into executable commands. Lazily constructed alongside a provider. */ private readonly commandNormalizer; /** * @param api - The grid's own `GridApi` — every command runs through it, never around it. * @param registry - Supply a custom registry to fully replace the built-ins, or omit to get sort/filter/pin/visibility/grouping/selection out of the box. * @param provider - Optional generative back-end. When supplied, {@link submitAsync} routes prompts through it; when omitted, only the synchronous deterministic pipeline is available. * @param providerSystemInstruction - Optional extra guidance appended to the base system instruction sent to {@link provider}. */ constructor(api: GridApi, registry?: PhotonAICommandRegistry, provider?: PhotonAIProvider | null, providerSystemInstruction?: string); /** A registry pre-populated with every built-in intent — the default `PhotonAIService` uses when none is supplied. */ static createDefaultRegistry(): PhotonAICommandRegistry; /** Registers additional custom intents at runtime (e.g. a third-party feature's own `registerAI()`). */ getRegistry(): PhotonAICommandRegistry; /** Forgets every column alias and phrase this service has learned for the current grid — useful after a large schema change or for testing. */ forgetLearnedMemory(): void; /** * Runs one prompt through the full pipeline. Always resolves — * parsing/resolution failures come back as `{ success: false }`, never a * thrown error. A compound sentence runs each clause independently and * aggregates their results. */ submit(rawInput: string): PhotonCommandResult; /** `true` when a generative back-end is configured — i.e. {@link submitAsync} will use the model rather than the deterministic pipeline. */ hasProvider(): boolean; /** * Async counterpart to {@link submit}. When a provider is configured, the * prompt is interpreted by the model: the grid's current context (columns, * capabilities, state) plus the user command are sent to the provider, and * every returned action is executed through the *same* `CommandExecutor` the * deterministic pipeline uses — so the two backends are interchangeable. * * With no provider configured, this simply awaits the synchronous * deterministic pipeline, so callers can always use the async entry point * regardless of mode. Like {@link submit}, it always resolves — provider and * execution failures come back as `{ success: false }`, never a rejection. */ submitAsync(rawInput: string, signal?: AbortSignal): Promise; /** * Runs the model's actions in order and folds them into a single * {@link PhotonCommandResult}. The model's natural-language `reply` is the * user-facing message; per-command execution failures are appended so a * partial success is never silently swallowed. */ private executeGeneratedActions; private runClause; private runCommands; /** * Handles a clause that normalized away to nothing — every one of its * words was filler. Rather than a blanket parse error, greetings and * thanks get a friendly, on-brand reply; anything else (stray filler with * no real words at all) still reports that it couldn't be parsed. */ private replyToSmallTalk; /** A learned command referencing a column that's since been removed/renamed can't be safely replayed — falls back to re-parsing the clause instead. */ private commandStillValid; /** The set of verbs `splitClauses` treats as "this starts a new command" — every registered intent's leading alias word, recomputed per call so custom intents registered at runtime are picked up immediately. */ private clauseVerbs; } //# sourceMappingURL=photon-ai-service.d.ts.map