import { $ as TuiKeybindingContribution, D as PiTuiApiInfo, K as TuiAutocompleteRegistryView, M as RegistrationSpec, Q as TuiCommandHandle, X as TuiCommandBridgeView, Z as TuiCommandContribution, at as TuiOverlayHandle, dt as TuiSettingHandle, et as TuiKeybindingHandle, gt as TuiThemeHandle, ht as TuiThemeContribution, i as AutocompleteProviderContribution, it as TuiMessageRendererContribution, j as RegistrationHandle, l as EditorContribution, lt as TuiRendererRegistryView, nt as TuiKeybindingRegistryView, ot as TuiOverlayOptions, pt as TuiSettingsRegistryView, r as AutocompleteHandle, st as TuiRendererHandle, u as EditorHandle, ut as TuiSettingContribution, v as ExtensionView, vt as TuiThemeRegistryView, yt as TuiToolRendererContribution, z as SurfaceStateValues } from "./public-types-C1YgFtwC.mjs"; import { EventEmitter } from "events"; import { Context, Service } from "@deepseek-ai/cordis"; //#region src/extension/service.d.ts /** The service name plugins inject (`piTuiExtensions` in cordis.patch.yml). */ declare const PI_TUI_EXTENSIONS_SERVICE = "piTuiExtensions"; /** The public service surface plugins consume. */ interface PiTuiExtensionService { /** Host identity: version + capability set (feature-detect, never parse versions). */ readonly api: () => PiTuiApiInfo; /** * Register one contribution under a slot. The registration is owned by the * CALLING fiber: it is disposed automatically when that fiber unloads. * @param slot - one of the known slot names. * @param spec - registration identity + ordering metadata. * @param contribution - the contribution value (typed per slot contract). */ register(slot: string, spec: RegistrationSpec, contribution: T): RegistrationHandle; /** The semantic of one slot ('list' | 'single'), or undefined when unknown. */ slotSemantics(slot: string): string | undefined; /** * Subscribe to the live surface state snapshots (first-party builtins and * state-driven contributions). Fires once synchronously with the current * state, then on every change (batched). Returns a disposer. * @param listener - receives the immutable snapshot values. */ subscribeState(listener: (state: SurfaceStateValues) => void): () => void; /** * Register a CLIENT-OWNED command contribution (M5): a slash name whose * behavior lives entirely on the client (the DSH client command * contribution shape). It joins the `/` menu merged with the host catalog * and the runner executes its own `handler` locally; a name that is also a * host command fails loud at candidate synthesis and never shadows it. * Owned by the calling fiber. * @param contribution - the command contribution. */ registerCommand(contribution: TuiCommandContribution): TuiCommandHandle; /** * Register a named theme palette (M5): selectable from the host's theme * picker; owner unload removes it (a selected plugin theme falls back to * the built-in palette). Owned by the calling fiber. * @param contribution - the theme contribution. */ registerTheme(contribution: TuiThemeContribution): TuiThemeHandle; /** * Register an autocomplete provider (M5): consulted after the host's own * provider returns null, in registration order. Owned by the calling * fiber. * @param contribution - the provider contribution. */ registerAutocomplete(contribution: AutocompleteProviderContribution): AutocompleteHandle; /** * Register a settings row (M5): appended to the host's /settings panel. * Owned by the calling fiber. * @param contribution - the row contribution. */ registerSetting(contribution: TuiSettingContribution): TuiSettingHandle; /** * Register a keybinding (M5): normalized key → public semantic action. * The registry validates the contribution (public TuiAction whitelist, * reserved keys, text-producing keys, editor-owned keys, legacy C0 collisions) and its * records feed the LIVE InputRouter lookups + the runner's * effective-keymap plugin rules (M6); routing precedence stays * Host-owned. Rejections throw loudly; the binding is owned by the * calling fiber. * @param contribution - the binding contribution. */ registerKeybinding(contribution: TuiKeybindingContribution): TuiKeybindingHandle; /** * Register a transcript MESSAGE renderer (M7, chain slot): receives a * semantic snapshot; returns an ExtensionView or undefined (abdicate → * next renderer → host fallback). A throwing renderer is isolated. * Owned by the calling fiber. */ registerMessageRenderer(contribution: TuiMessageRendererContribution): TuiRendererHandle; /** * Register a TOOL renderer (M7, keyed slot): presents the tool card for * ONE tool name; undefined abdicates. Priority ties on the same tool * name are an explicit error. Owned by the calling fiber. */ registerToolRenderer(contribution: TuiToolRendererContribution): TuiRendererHandle; /** * Open a MANAGED OVERLAY (M8, plan §13.3): the plugin supplies an * ExtensionView + sizing hints; the host mounts it through its overlay * broker (modal stacking, focus, fullscreen migration, teardown). The * returned lease is generation-scoped (a stale surface's lease closes * with the surface) and its close() is idempotent. The overlay content * is the M4 component kit — a plugin can never mount a raw component * or steal focus. * @param view - the ExtensionView to present. * @param options - sizing/positioning hints. * @returns the overlay lease. */ showOverlay(view: ExtensionView, options?: TuiOverlayOptions): TuiOverlayHandle; /** M5 registries, exposed for the runner's dispatch/pickers (narrow * read-side views — the concrete classes are host-internal, so the * public declarations stay free of internal modules). */ readonly commands: TuiCommandBridgeView; readonly themes: TuiThemeRegistryView; readonly autocomplete: TuiAutocompleteRegistryView; readonly settings: TuiSettingsRegistryView; readonly keybindings: TuiKeybindingRegistryView; /** M7: the transcript/tool renderer registry (the runner wires it into * the surface's message cache; the narrow read-side view keeps the * public declarations free of internal modules). */ readonly renderers: TuiRendererRegistryView; /** Runner-only: wire the host's managed-overlay mount seam (M8). The * seam is SURFACE-scoped (P1-4): it binds to the CURRENT attachment's * surfaceId — a later attach replaces it, and a stale old-generation * detach never unbinds a newer surface's seam (the detachSurface lease). */ setOverlayMount(surfaceId: string, mount: (view: ExtensionView, options?: TuiOverlayOptions) => TuiOverlayHandle): void; /** * Register an EDITOR contribution (M9, plan §14): single-winner by * priority; a tie is an explicit error. The winner occupies the editor * seat through the host's atomic handoff; the host default editor is * the fallback (never a competing registration). Creation is atomic — * a throw keeps the current editor working. Owned by the calling fiber. */ registerEditor(contribution: EditorContribution): EditorHandle; } //#endregion //#region src/extensions.d.ts /** Stable Cordis plugin name for the extension host row. */ declare const name = "pi-tui-extension-host"; /** The host mounts only when the TUI startup flags were parsed (same gate * as the runner row: `dsh --profile pi-tui --help` provides nothing, so no * extension host mounts either). */ declare const inject: string[]; /** * Provide the extension service. The Service base class registers the * instance on `ctx` under `piTuiExtensions` and unregisters it when this * provider fiber unloads; invalidations coalesce into render requests * (until the SurfaceHost attaches in M2 the sink is a no-op). * @param ctx - the provider's plugin context. */ declare function apply(ctx: Context): void; //#endregion export { PiTuiExtensionService as a, PI_TUI_EXTENSIONS_SERVICE as i, inject as n, name as r, apply as t };