/** * The Reasoner seam: the one interface an LLM later implements. A reasoner turns an * utterance plus a {@link GridContext} into a {@link Plan}. {@link RuleBasedReasoner} * is the default, LLM-free reasoner: it composes intent detection, entity * resolution, and planning. Its `score` is the detector's confidence, which the * Router (P3) uses to decide whether to escalate to an LLM reasoner. * * @see plans/ai-reasoning-layer-spec.md (section 4.8) */ import type { GridContext } from './context.js'; import { type EntityResolver } from './entities.js'; import { type IntentDetector } from './intent.js'; import { type Planner } from './planner.js'; import type { Plan } from './types.js'; /** * Split a compound utterance into command clauses. A connective only starts a new * clause when the fragment after it begins with a command verb, so "sort by region and * product" stays one clause (two sort columns) while "sort by X and remove rows..." * splits into two. Exported for testing. */ export declare function segmentClauses(utterance: string): string[]; /** Produces a {@link Plan} from an utterance. The pluggable brain of the pipeline. */ export interface Reasoner { /** Provenance stamped on plans, e.g. `'rule'` or `'llm:claude'`. */ readonly name: string; /** Cheap triage in `[0, 1]` the Router uses to choose a reasoner. 0 = cannot handle. */ score(utterance: string, ctx: GridContext): number; /** Produce a plan (control steps or an ask answer). */ reason(utterance: string, ctx: GridContext): Promise; } /** Injectable pieces of the {@link RuleBasedReasoner} (all default to the built-ins). */ export interface RuleBasedReasonerDeps { detector?: IntentDetector; resolver?: EntityResolver; planner?: Planner; } /** * The default, deterministic reasoner: no LLM, no network. Detect the intent, * resolve its entities against the schema / memory / live state, and plan the * matching tool calls. */ export declare class RuleBasedReasoner implements Reasoner { #private; readonly name = "rule"; constructor(deps?: RuleBasedReasonerDeps); score(utterance: string, ctx: GridContext): number; reason(utterance: string, ctx: GridContext): Promise; } /** Create the default rule-based {@link Reasoner}. */ export declare function createRuleBasedReasoner(deps?: RuleBasedReasonerDeps): RuleBasedReasoner;