import type { EliceCDK } from './EliceCDK'; import type { AiChatEventListener, AiChatMessage, AiChatModel, AiChatPromptOptions } from './typings'; export declare class EliceCDKAiChat implements AiChatModel { #private; private readonly ctx; constructor(ctx: EliceCDK); /** * Loads a previously saved chat session from storage. * * After loading, you can continue the conversation using `prompt()`. * * @param sessionId - UUID of the session to load. * @returns Object containing `sessionId` and `messages` array. * @throws {EliceCDKError} If the session ID is empty or the session is not found. * * @example * ```ts * import { EliceCDK } from '@eliceio/cdk'; * * const sdk = new EliceCDK(); * await sdk.init(); * * const { sessionId, messages } = await sdk.ai.chat.load('550e8400-e29b-41d4-a716-446655440000'); * console.log('Loaded messages:', messages.length); * ``` */ load(sessionId: string): Promise<{ sessionId: string; messages: AiChatMessage[]; }>; /** * Deletes a chat session from server storage. * * Use this to permanently remove a session's chat history. * Note: This does not reset the local session state; use `reset()` for that. * * @param sessionId - UUID of the session to delete. * @throws {EliceCDKError} If the session deletion fails. * * @example * ```ts * import { EliceCDK } from '@eliceio/cdk'; * * const sdk = new EliceCDK(); * await sdk.init(); * * await sdk.ai.chat.clear('550e8400-e29b-41d4-a716-446655440000'); * ``` */ clear(sessionId: string): Promise; /** * Resets the local chat session state. * * Clears the current session ID and messages from memory. Does not affect * data stored on the server. The next `prompt()` call will start a new session. * * @example * ```ts * import { EliceCDK } from '@eliceio/cdk'; * * const sdk = new EliceCDK(); * await sdk.init(); * * // Start a conversation * await sdk.ai.chat.prompt('Hello'); * * // Reset to start fresh * sdk.ai.chat.reset(); * console.log(sdk.ai.chat.sessionId); // null * ``` */ reset(): void; /** * Subscribes to chat events such as new messages, session loads, resets, and clears. * * @param listener - Callback function invoked when a chat event occurs. * @returns Object with `unsubscribe()` method to stop listening. * * @example * ```ts * import { EliceCDK } from '@eliceio/cdk'; * * const sdk = new EliceCDK(); * await sdk.init(); * * const { unsubscribe } = sdk.ai.chat.subscribe((event) => { * if (event.type === 'comment') { * console.log('New message:', event.payload.content); * } * }); * * // Stop listening when done * unsubscribe(); * ``` */ subscribe(listener: AiChatEventListener): { unsubscribe: () => void; }; /** * Sends a message to the AI and receives a response. * * If no session is active, a new session is automatically created with a UUID. * To resume a previous session, call `load(sessionId)` first. * * @param contentRequest - The user's message to send. * @param options - Optional settings including `systemInstruction` to guide the AI's behavior. * @returns Object containing `sessionId` and `responseMessageContent`. * @throws {EliceCDKError} If the prompt fails or session exceeds 100 messages. * * @example * ```ts * import { EliceCDK } from '@eliceio/cdk'; * * const sdk = new EliceCDK(); * await sdk.init(); * * // Simple prompt * const { sessionId, responseMessageContent } = await sdk.ai.chat.prompt( * 'What is the capital of Korea?' * ); * * // With system instruction * await sdk.ai.chat.prompt('Explain variables', { * systemInstruction: 'Explain like teaching a beginner.', * }); * ``` */ prompt(contentRequest: string, options?: AiChatPromptOptions): Promise<{ sessionId: string; responseMessageContent: string; }>; /** * Returns the current session ID, or `null` if no session is active. * * @example * ```ts * import { EliceCDK } from '@eliceio/cdk'; * * const sdk = new EliceCDK(); * await sdk.init(); * * console.log(sdk.ai.chat.sessionId); // null (before first prompt) * * await sdk.ai.chat.prompt('Hello'); * console.log(sdk.ai.chat.sessionId); // '550e8400-e29b-41d4-a716-446655440000' * ``` */ get sessionId(): string | null; /** * Returns the current session's message history. * * Each message has `role` ('system', 'user', or 'assistant'), `content`, and `ts` (timestamp). * * @returns Array of chat messages, or empty array if no session is active. * * @example * ```ts * import { EliceCDK } from '@eliceio/cdk'; * * const sdk = new EliceCDK(); * await sdk.init(); * * await sdk.ai.chat.prompt('Hello'); * console.log(sdk.ai.chat.messages); * // [ * // { role: 'user', content: 'Hello', ts: 1234567890 }, * // { role: 'assistant', content: 'Hi there!', ts: 1234567891 } * // ] * ``` */ get messages(): AiChatMessage[]; }