import { CombinedAutocompleteProvider } from '@earendil-works/pi-tui'; import type { BrokerDataFrame, RefMeta } from '../../../core/runtime/broker-protocol.js'; import { type PreviewableCommand } from '../slash/prompt-preview.js'; import type { AttachBindings } from './bindings.js'; import type { AttachSession } from './context.js'; export declare function buildAttachAutocompleteProvider(cwd: string, fdPath: string | null, commands?: ReadonlyArray<{ name: string; description?: string; }>, remote?: boolean, createProvider?: (items: ReadonlyArray<{ name: string; description?: string; }>, cwd: string, fdPath: string | null) => CombinedAutocompleteProvider): CombinedAutocompleteProvider; /** Requests the broker's memory-ref inventory (`request({type:'list_memory_refs'})`) * and drives `setMemoryRefs` — the epoch-guarded lifecycle behind inline memory * references. Every `reset()` call: * 1. bumps a monotonic epoch, immediately superseding any still-in-flight * request from a prior `reset()` (a stale welcome/reload/reconnect); * 2. clears the inventory synchronously via `setMemoryRefs([])`, so a * partially-typed ref never keeps highlighting/completing against a * dead broker's stale names; * 3. issues one correlated request and installs its `refs` ONLY if the reply * both belongs to the latest epoch AND is a well-formed * `list_memory_refs` data frame. * A timeout, rejection, or malformed/mismatched `kind` degrades silently to * the already-empty inventory — no retry, no local fallback. Command and ref * arrival are independent: this coordinator never touches command state. */ export interface MemoryRefRefreshCoordinator { reset: () => void; } export declare function createMemoryRefRefreshCoordinator(setMemoryRefs: (refs: ReadonlyArray, engineLeadingCommandNames: ReadonlyArray) => void, request: (frame: { type: 'list_memory_refs'; }) => Promise): MemoryRefRefreshCoordinator; /** The verbs `runAttach` still needs from the inventory owner. Nothing outside * this module writes the command/ref state — the orchestrator only feeds * arrivals in (`setCommands`, `resetMemoryRefs`) and mirrors editor text * (`syncCommandPreview`). */ export interface EditorInventory { /** Install the broker's command metadata (frames wiring: `get_commands`). */ setCommands: (next?: ReadonlyArray) => void; /** Restart the epoch-guarded ref-inventory lifecycle (welcome / `/reload`). */ resetMemoryRefs: () => void; /** Recompute the loaded-command preview from the current editor text. */ syncCommandPreview: (text: string) => void; /** tmux/nvim popup showing the loaded prompt template's exact payload. */ inspectLoadedCommand: () => void; } export interface EditorInventoryHooks { setNotice: (msg: string) => void; /** Live binding snapshot — read at call time so a `/reload` is honored. */ bindings: () => AttachBindings; /** Resolved once in `runAttach`; never changes for the session. */ fdPath: string | null; } /** Owns everything the editor can complete against — the merged slash-command * list, the loaded-command preview, the broker's raw command metadata, and the * memory-ref inventory — plus the popup that inspects the loaded template. * Construction seeds the command list with builtins-only (`setCommands()`), so * autocomplete works before the broker's first `get_commands` ack. */ export declare function createEditorInventory(ctx: Pick, hooks: EditorInventoryHooks): EditorInventory;