import * as i0 from '@angular/core';
import { Type } from '@angular/core';
import { Observable } from 'rxjs';
import { FetchClient } from '@c8y/client';

interface AIMessageStreamSteps extends AIMessage {
    componentSteps$?: Observable<{
        content: Type<any> | string;
        origin: AgentStep;
    }[]>;
}
interface AIMessage {
    role: 'user' | 'assistant';
    content: string;
    options?: AIMessageOptions;
    steps?: Array<AgentStep>;
    finishReason?: 'stop' | 'error' | 'tool_use';
    timestamp?: string;
}
interface AIMessageOptions {
    skipToLLM?: boolean;
    hiddenContent?: string;
    variables?: {
        [key: string]: any;
    };
}
declare enum DataStreamType {
    TEXT_DELTA = "text-delta",
    TOOL_CALL = "tool-call",
    TOOL_CALL_STREAMING = "tool-call-streaming",
    TOOL_CALL_DELTA = "tool-call-delta",
    TOOL_RESULT = "tool-result",
    REASONING = "reasoning",
    REASONING_DELTA = "reasoning-delta",
    REDACTED_REASONING = "redacted-reasoning",
    REASONING_SIGNATURE = "reasoning-signature",
    FINISH_REASONING = "finish-reasoning",
    FINISH = "finish",
    FINISH_STEP = "finish-step",
    ERROR = "error",
    DATA = "data",
    MESSAGE_ANNOTATIONS = "message-annotations",
    SOURCE = "source",
    FILE = "file",
    STEP_START = "start-step",
    STEP_FINISH = "finish-step",
    STEP_START_V4 = "step-start",
    STEP_FINISH_V4 = "step-finish"
}
type AgentStep = {
    type: 'text' | 'reasoning' | string;
    text: string;
    reasoning?: string;
    textDelta?: string;
    toolCalls?: Array<ToolCall>;
    toolResults?: Array<ToolResult>;
    aborted?: boolean;
};
interface Tool {
    toolName: string;
    toolId: string;
    type: 'tool-call' | 'tool-result';
}
interface ToolCall extends Tool {
    arguments: {
        [key: string]: any;
    };
}
interface ToolResult extends Tool {
    result: {
        content: {
            text: string;
            type: string;
        }[];
    };
}
interface ClientAgentDefinition {
    /**
     * If set to true, the agent will be created each time. This is useful for development.
     */
    snapshot: boolean;
    /**
     * The label of the agent that is shown to the user.
     */
    label: string;
    /**
     * The definitions of the agent.
     *
     * You can use multiple definitions that can be used in an agent-2-agent scenario
     * The first definition is the entry point.
     */
    definitions: {
        name: string;
        type: 'object' | 'text';
        agent: {
            system: string;
            [key: string]: any;
        };
        mcp: Array<{
            serverName: string;
            tools: string[];
        }>;
    }[];
}
interface ChatConfig {
    title: string;
    headline: string;
    welcomeText: string;
    placeholder: string;
    sendButtonText: string;
    cancelButtonText: string;
    disclaimerText: string;
    userInterfaceIcons: {
        send: string;
        cancel: string;
    };
}
interface AgentHealthCheckResponse {
    /**
     * Indicates if the agent exists and can be used.
     * If false, the agent was not found.
     */
    exists: boolean;
    /**
     * Indicates if the user can create the agent, and if a global provider is configured.
     */
    canCreate: boolean;
    /**
     * Indicates if the provider is configured.
     * If false, the agent cannot be created as the provider is not configured.
     */
    isProviderConfigured: boolean;
    /**
     * If canCreate or exist is false, this array contains messages
     * that explain why the agent cannot be used or created.
     */
    messages?: string[];
}

declare class AIService {
    private client;
    private baseUrl;
    constructor(client: FetchClient);
    createOrUpdateAgent(agentsDef: ClientAgentDefinition): Promise<void>;
    /**
     * Check if an agent exists.
     * @param name Agent name
     * @returns Agent health check response.
     */
    getAgentHealth(name: string): Promise<AgentHealthCheckResponse>;
    /**
     * Send a text message to the agent.
     * @param name Agent name
     * @param messages Messages to send
     * @param variables Variables to include
     * @returns Text response from the agent.
     */
    text(name: string, messages: AIMessage[], variables: {
        [key: string]: any;
    }): Promise<string>;
    /**
     * Stream a text message to the agent.
     * @param agentName Agent name
     * @param messages Messages to send
     * @param variables Variables to include
     * @param abortController An AbortController to cancel the request.
     * @returns An observable that emits partial AIMessage objects as they are received. The observable can be cancelled using the provided AbortController.
     * The observable will emit an error if the request fails or is aborted.
     * The observable will complete when the stream is finished.
     *
     * The messages sent to the agent can include special options:
     * - `hiddenContent`: If set, this content will be sent to the agent instead of the `content` field.
     * - `skipToLLM`: If set to true, this message will be skipped when sending to the agent.
     *
     * Example usage:
     * ```typescript
     * const abortController = new AbortController();
     * const messages: AIMessage[] = [
     *   { role: 'user', content: 'Hello' },
     *   { role: 'assistant', content: 'Hi there!' },
     *   { role: 'user', content: 'Tell me a joke.', options: { hiddenContent: 'Tell me a joke about cats.' } }
     * ];
     * const observable = aiService.stream$('my-agent', messages, {}, abortController);
     * const subscription = observable.subscribe({
     *   next: (message) => console.log('Received message part:', message),
     *   error: (err) => console.error('Error:', err),
     *   complete: () => console.log('Stream complete')
     * });
     *
     * // To cancel the request:
     * abortController.abort();
     * subscription.unsubscribe();
     * ```
     */
    stream$(agentName: string, messages: AIMessage[], variables: {
        [key: string]: any;
    }, abortController: AbortController): Promise<Observable<AIMessage>>;
    private parseMessages;
    private processLine;
    static ɵfac: i0.ɵɵFactoryDeclaration<AIService, never>;
    static ɵprov: i0.ɵɵInjectableDeclaration<AIService>;
}

export { AIService, DataStreamType };
export type { AIMessage, AIMessageOptions, AIMessageStreamSteps, AgentHealthCheckResponse, AgentStep, ChatConfig, ClientAgentDefinition, Tool, ToolCall, ToolResult };
//# sourceMappingURL=index.d.ts.map
