/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ /** * The copilot runner (`Sheet Spec.md` §6.2 — B§5): providers run against the * row AS IT WOULD BE if the open editor committed, over the bridged WIRE * functions of §4.8 — the runner never sees the host's row type. Per column, * the first provider that yields wins, by position; owned rows are skipped; * nothing lands in an occupied cell; a fill the planner dismissed on that row * is not asked for again; results are memoised per (anchor, provisional row, * column, provider). Fills CHAIN in column order — a later column's providers * (and the proposers) see the earlier columns' fills as if taken, the * prototype's `row.start || fill.start`: the end derives from a predicted * start, the notes phrase and the station count read the predicted quantity. A synchronous provider answers inline; an asynchronous * one is returned as work the component tracks (`suggest-async.ts`) — a * later synchronous provider answers meanwhile, and an earlier asynchronous * one that lands replaces it (first that yields wins, still by position). * Proposers run the same way once per anchor, their rows capped at `ahead`, * never into an occupied slot, minus the follower pairings the planner * rejected. * * @packageDocumentation */ import { type SheetKind } from "./model.js"; import type { PendingFill, PendingRow, Rejections, Suggestions } from "./sheet-types.js"; import type { SheetCellValue, SheetContextValue, SheetProposerValue, SheetProviderValue, SheetRowValue } from "./values.js"; /** The copilot's latency per kind (B§3): deterministic kinds fire fast, the rest wait for a pause in typing. */ export declare const LATENCY_MS: { readonly instant: 150; readonly idle: 1100; }; /** A provider or a proposer on the wire — the compiled closure under its `sync` / `async` arm. */ export type WireProvider = SheetProviderValue | SheetProposerValue; /** One column's fill providers. */ export interface FillColumn { key: string; kind: SheetKind; editable: boolean; /** Whether a row's cell takes a fill — its column writes and no mark locks it (#1560); `editable` alone when absent. */ writable?: ((cells: ReadonlyMap) => boolean) | undefined; providers: readonly SheetProviderValue[]; } /** What one run reads. */ export interface SuggestInput { /** The anchor — a real row's id, or a blank row's synthetic id. */ anchorId: string; /** The provisional anchor row (the open editor's value applied). */ row: SheetRowValue; /** The column being edited — not filled, unless it is a link (predicted into). */ skipKey: string | undefined; columns: readonly FillColumn[]; proposers: readonly SheetProposerValue[]; /** At most this many proposed rows. */ ahead: number; /** The slot below the anchor is occupied — never propose into it. */ nextBusy: boolean; /** The anchor's driver key (the rejected-follower pairings). */ driverKey: string | undefined; driverColumn: string | undefined; rejected: Rejections; /** The wire context over a row — the provisional anchor, or the anchor with one cell blanked. */ contextOf: (row: SheetRowValue) => SheetContextValue; memo: SuggestMemo; } /** An async provider's settled result. */ export type AsyncResult = { kind: "fill"; fill: PendingFill | null; } | { kind: "rows"; rows: PendingRow[]; }; /** An async provider the component tracks — delivered only while its generation is current. */ export interface AsyncWork { /** The column key, or `"rows"`. */ key: string; index: number; run: () => Promise; } /** One run's outcome. */ export interface SuggestOutcome { sugg: Suggestions | null; async: AsyncWork[]; } /** The memo — settled results and in-flight promises per (anchor, provisional row, column, provider). */ export declare class SuggestMemo { private readonly map; get(key: string): unknown; has(key: string): boolean; set(key: string, value: unknown): void; clear(): void; } /** A row's cells, printed — the memo's notion of "the same provisional row". */ export declare function hashRow(row: SheetRowValue): string; /** Run the copilot once for an anchor. */ export declare function runSuggest(input: SuggestInput): SuggestOutcome; //# sourceMappingURL=suggest.d.ts.map