import type { ExtensionEvent, ExtensionFactoryCtx, RuntimeCallbacks } from '../core/types/runtime.js'; import type { RillValue } from '../core/types/structures.js'; /** * Minimal interface for extension event emission. * Allows emitExtensionEvent to accept any context with callbacks. */ interface RuntimeContextLike { readonly callbacks?: RuntimeCallbacks | undefined; } /** * Result object returned by extension factories. * Contains the mounted RillValue with optional lifecycle hooks. * Lifecycle hooks live on the factory result, not on the value dict. */ export interface ExtensionFactoryResult { readonly value: RillValue; dispose?: () => void | Promise; suspend?: () => unknown; restore?: (state: unknown) => void; } /** * Factory function contract for creating extensions. * * Accepts typed configuration and a factory-scope {@link ExtensionFactoryCtx}. * Returns (or resolves to) an {@link ExtensionFactoryResult}. * * The factory-scope ctx exposes exactly `{ registerErrorCode, signal }` * Host-scope helpers like `invalidate` and `catch` are * intentionally absent at factory init time. */ export type ExtensionFactory = (config: TConfig, ctx: ExtensionFactoryCtx) => ExtensionFactoryResult | Promise; /** * Descriptor for a single configuration field in an extension schema. * The secret flag is advisory: harness tooling uses it to mask or omit values. * It does not affect runtime behavior. */ export interface ConfigFieldDescriptor { readonly type: 'string' | 'number' | 'boolean'; readonly required?: boolean; readonly secret?: boolean; } /** * Schema definition for extension configuration. * Maps field names to their descriptors. */ export type ExtensionConfigSchema = Record; /** * Manifest describing a self-contained extension. * Carries the factory, optional config schema, and version metadata. */ export interface ExtensionManifest { readonly factory: ExtensionFactory; readonly configSchema?: ExtensionConfigSchema | undefined; readonly version?: string | undefined; } /** * Emit an extension event with auto-generated timestamp. * Adds ISO timestamp if event.timestamp is undefined, then calls onLogEvent callback. * * @param ctx - Runtime context or context-like object containing callbacks * @param event - Extension event (timestamp auto-added if omitted) * @throws {TypeError} If ctx is null or undefined * @throws {Error} If event.event is missing or empty * * @example * ```typescript * emitExtensionEvent(ctx, { * event: 'extension_initialized', * subsystem: 'extension:openai', * config: { model: 'gpt-4' } * }); * // Calls ctx.callbacks.onLogEvent with timestamp added * ``` */ export declare function emitExtensionEvent(ctx: RuntimeContextLike, event: Omit & { timestamp?: string | undefined; }): void; export {};