import type { Clock } from "./clock"; import type { FsPort } from "./fs"; import type { Timers } from "./timers"; export interface UiPort { notify(message: string): void; setStatus(key: string, message?: string): void; confirm(message: string): Promise; /** R22/D-W2: optional interactive dialogs, present only in hosts with dialog support (TUI/RPC). * `undefined` returns mean Esc/timeout. Optional members keep every existing consumer (e.g. * ConfigStore's `Pick`) byte-identical. */ select?(title: string, options: readonly string[]): Promise; input?(title: string, placeholder?: string): Promise; } export type CompletionMessage = { role: "user"; content: string }; export type CompletionContext = { messages: readonly CompletionMessage[] }; export type CompleteFn = (model: Model, context: CompletionContext) => Promise; export interface EntriesPort { append(type: string, data?: Data): void; branch(): readonly Data[]; } export type IdGen = () => string; export interface ModelRegistryPort { complete: CompleteFn; } export interface ExtensionContextPort { cwd: string; clock: Clock; timers: Timers; fs: FsPort; ui: UiPort; entries: EntriesPort; idGen: IdGen; modelRegistry: ModelRegistryPort; } export type ExtensionContext = ExtensionContextPort; export type EventHandler = (...args: readonly unknown[]) => unknown | Promise; export interface ExtensionApiPort { on(event: string, handler: EventHandler): void; registerCommand(name: string, handler: EventHandler): void; }