import { ChatResponseContent } from './chat-model'; import { SerializableChatResponseContentData } from './chat-model-serialization'; import { ContributionProvider, ILogger, MaybePromise } from '@theia/core'; export declare const ChatContentDeserializer: unique symbol; /** * A deserializer for a specific kind of chat response content. * * Deserializers are responsible for reconstructing `ChatResponseContent` instances * from their serialized data representations. Each deserializer handles a single * content type identified by its `kind` property. * * @template T The type of the data object that this deserializer can process. * * @example * ```typescript * const textDeserializer: ChatContentDeserializer = { * kind: 'text', * deserialize: (data) => new TextChatResponseContentImpl(data.content) * }; * ``` */ export interface ChatContentDeserializer { /** * The unique identifier for the content type this deserializer handles. * This must match the `kind` property of the serialized content data. */ readonly kind: string; /** * Deserializes the given data into a `ChatResponseContent` instance. * * @param data The serialized data to deserialize. The structure depends on the content kind. * @returns The deserialized content, or a Promise that resolves to the deserialized content. */ deserialize(data: T): MaybePromise; } /** * Contribution point for registering chat content deserializers. * * Implement this interface to contribute custom deserializers for application-specific * or extension-specific chat response content types. Multiple contributions can be * registered, and all will be collected via the contribution provider pattern. * * @example * ```typescript * @injectable() * export class MyDeserializerContribution implements ChatContentDeserializerContribution { * registerDeserializers(registry: ChatContentDeserializerRegistry): void { * registry.register({ * kind: 'customContent', * deserialize: (data: CustomContentData) => * new CustomContentImpl(data.title, data.items) * }); * } * } * * // In your module: * bind(ChatContentDeserializerContribution).to(MyDeserializerContribution).inSingletonScope(); * ``` * * @see {@link ChatContentDeserializerRegistry} for the registry that collects deserializers * @see {@link DefaultChatContentDeserializerContribution} for built-in content type deserializers */ export interface ChatContentDeserializerContribution { /** * Registers one or more deserializers with the provided registry. * * This method is called during the registry's initialization phase (at `@postConstruct()` time). * * @param registry The registry to register deserializers with */ registerDeserializers(registry: ChatContentDeserializerRegistry): void; } export declare const ChatContentDeserializerContribution: unique symbol; /** * Registry for chat content deserializers. * * This registry maintains a collection of deserializers for different content types * and provides methods to register new deserializers and deserialize content data. * * @example * ```typescript * // Usage in a service: * @inject(ChatContentDeserializerRegistry) * protected deserializerRegistry: ChatContentDeserializerRegistry; * * async restoreContent(): Promise { * const restoredContent = this.deserializerRegistry.deserialize(serializedData); * } * ``` * * @see {@link ChatContentDeserializerContribution} for how to contribute deserializers * @see {@link ChatContentDeserializerRegistryImpl} for the default implementation */ export interface ChatContentDeserializerRegistry { /** * Registers a deserializer for a specific content kind. * * If a deserializer for the same kind is already registered, it will be replaced. * * @param deserializer The deserializer to register */ register(deserializer: ChatContentDeserializer): void; /** * Deserializes the given serialized content data into a `ChatResponseContent` instance. * * The registry looks up the appropriate deserializer based on the `kind` property * of the serialized data and delegates to that deserializer's `deserialize` method. * * If no deserializer is found for the content kind, an `UnknownChatResponseContentImpl` * instance is returned with the original data and fallback message preserved. * A warning is also logged with the missing kind and available kinds. * * @param serialized The serialized content data to deserialize * @returns The deserialized content, or a Promise that resolves to the deserialized content */ deserialize(serialized: SerializableChatResponseContentData): MaybePromise; } export declare const ChatContentDeserializerRegistry: unique symbol; /** * Default implementation of the chat content deserializer registry. * * This registry collects deserializers from all bound `ChatContentDeserializerContribution` * instances during its post-construction initialization phase. Deserializers are stored * in a map keyed by their content kind. * * The registry handles unknown content types gracefully by returning an * `UnknownChatResponseContentImpl` instance when no deserializer is found, * ensuring that chat sessions can still be loaded even if some content types * are no longer supported or available. * * @see {@link ChatContentDeserializerRegistry} for the interface definition */ export declare class ChatContentDeserializerRegistryImpl implements ChatContentDeserializerRegistry { /** * Map of registered deserializers, keyed by content kind. */ protected deserializers: Map>; protected readonly deserializerContributions: ContributionProvider; protected readonly logger: ILogger; /** * Initializes the registry by collecting deserializers from all contributions. * This method is automatically called after construction due to the `@postConstruct` decorator. */ protected initDeserializers(): void; register(deserializer: ChatContentDeserializer): void; deserialize(serialized: SerializableChatResponseContentData): MaybePromise; } /** * Default implementation of the chat content deserializer contribution. * * This contribution registers deserializers for all built-in content types supported * by Theia AI. * * Note that some content types have limitations when deserialized from persistence. * * @see {@link ChatContentDeserializerContribution} for the contribution interface */ export declare class DefaultChatContentDeserializerContribution implements ChatContentDeserializerContribution { registerDeserializers(registry: ChatContentDeserializerRegistry): void; } //# sourceMappingURL=chat-content-deserializer.d.ts.map