import type { ThinkingLevel } from "@oh-my-pi/pi-agent-core"; import type { ServiceTierByFamily } from "@oh-my-pi/pi-ai"; import { EventBus } from "../../utils/event-bus.js"; import type { Extension, ExtensionFactory, ExtensionRuntime as IExtensionRuntime, LoadExtensionsResult, PreparedExtension, ProviderConfig, ShortcutConflict, SourceInfo, ToolDefinition, ToolInfo } from "./types.js"; /** * Upstream-shaped provenance for an extension-registered tool. Consumers that * read `sourceInfo` off `getAllRegisteredTools()` (e.g. pi-fabric) receive an * absolute on-disk path: the tool's own `sourcePath` when it is filesystem- * absolute, otherwise the extension's resolved entry (`fallbackPath`). A tool * with no absolute origin at all falls back to the synthetic ``. */ export declare function extensionToolSourceInfo(definition: Pick, fallbackPath: string): SourceInfo; export declare class ExtensionRuntimeNotInitializedError extends Error { constructor(); } /** * Extension runtime with throwing stubs for action methods. * These are replaced with real implementations during initialization. */ export declare class ExtensionRuntime implements IExtensionRuntime { flagValues: Map; pendingProviderRegistrations: Array<{ name: string; config: ProviderConfig; sourceId: string; }>; registerProvider(name: string, config: ProviderConfig, sourceId: string): void; unregisterProvider(name: string): void; getShortcutConflict(): ShortcutConflict | undefined; sendMessage(): void; sendUserMessage(): Promise; appendEntry(): void; setLabel(): void; getActiveTools(): string[]; getAllTools(): ToolInfo[]; setActiveTools(): Promise; getCommands(): never; setModel(): Promise; getThinkingLevel(): ThinkingLevel; setThinkingLevel(): void; getServiceTiers(): ServiceTierByFamily; setServiceTier(): void; getSessionName(): string | undefined; setSessionName(): Promise; } /** Import one extension module and resolve its factory without binding it to a session. */ export declare function importExtensionModule(extensionPath: string, cwd: string): Promise; /** * Create an Extension from an inline factory function. */ export declare function loadExtensionFromFactory(factory: ExtensionFactory, cwd: string, eventBus: EventBus, runtime: IExtensionRuntime, name?: string): Promise; /** * Load extensions from paths. * * Module import (the dominant cold-start cost — file I/O plus module * evaluation) runs concurrently across extensions; factory binding then runs * sequentially in the original path order, so registration semantics * (last-wins collisions, shared runtime flag defaults) stay deterministic. */ export declare function loadExtensions(paths: string[], cwd: string, eventBus?: EventBus, runtime?: IExtensionRuntime): Promise; /** * Bind previously imported extension factories. A fresh session runtime is * created unless `runtime` is given: deferred startup extensions bind into the * live session's runtime so they share its flag values and wired actions. */ export declare function bindPreparedExtensions(preparedExtensions: readonly PreparedExtension[], cwd: string, eventBus?: EventBus, runtime?: IExtensionRuntime): Promise; /** Whether a file name is a JS/TS module the loader imports; hook factories and directory scans use it. */ export declare function isExtensionFile(name: string): boolean; /** * Extension module entry from an installed plugin manifest or a configured * `extensions` path — the lanes {@link discoverExtensionPaths} appends after * native capability discovery. `/extensions` lists the toggleable ones beside * native modules so the dashboard shows what the loader actually loads. */ export interface PackageExtensionModule { /** Entry file; a missing configured path keeps its resolved spelling so the loader reports it. */ path: string; /** Plugin install scope, or the provenance of the configured paths. */ level: "user" | "project"; /** * Whether `disabledExtensions` (`extension-module:`) gates the entry. * False for configured file paths, which load regardless of that list. */ toggleable: boolean; } /** * List installed-plugin entries (when `plugins` is set) followed by configured * path entries, in load order. Configured directories expand through their * manifest, index, or one-level scan. * * @throws When a configured path exists but cannot be stat'ed (anything but ENOENT). */ export declare function listPackageExtensionModules(configuredPaths: readonly string[], cwd: string, options: { plugins: boolean; configuredLevel?: "user" | "project"; }): Promise; /** * Discover absolute paths of extensions to load, without importing or * binding factories. Hot path on session startup — the scan walks native * `.omp`/`.pi` extension capabilities, JS/TS hook factories, the * installed-plugin tree, and any configured paths. * * The root session imports these paths once and forwards prepared factories to * subagents. Each child rebinds fresh Extension instances to its OWN * ExtensionAPI (cwd, eventBus, runtime) without re-evaluating the module graph. */ export interface DiscoverExtensionPathOptions { /** Include ambient native extensions, hooks, and installed plugins. */ ambient?: boolean; /** Include ambient hook factories. Disable for read-only catalog commands. */ includeAmbientHooks?: boolean; } export declare function discoverExtensionPaths(configuredPaths: string[], cwd: string, disabledExtensionIds?: string[], options?: DiscoverExtensionPathOptions): Promise; /** * Discover and load extensions from standard locations. Composed of * {@link discoverExtensionPaths} (FS scan) + {@link loadExtensions} * (per-session binding). */ export declare function discoverAndLoadExtensions(configuredPaths: string[], cwd: string, eventBus?: EventBus, disabledExtensionIds?: string[], options?: DiscoverExtensionPathOptions): Promise;