echo-ai-sdk-ts 2.4.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -828,6 +828,48 @@ declare class ExperimentManager {
828
828
  getVariantConfig(experimentName: string, variantId: string): Record<string, any> | null;
829
829
  }
830
830
 
831
+ interface TTSConfig {
832
+ apiKey: string;
833
+ model?: string;
834
+ }
835
+ declare class HuggingFaceTTS {
836
+ private client;
837
+ private defaultModel;
838
+ constructor(config: TTSConfig);
839
+ /**
840
+ * Converts an AI text response into a spoken audio Blob.
841
+ * Useful for voice-enabled chatbots or IVR systems.
842
+ */
843
+ generateAudio(text: string): Promise<Blob>;
844
+ /**
845
+ * Helper syntax for Node.js backends needing buffers instead of Blobs.
846
+ */
847
+ generateBuffer(text: string): Promise<Buffer>;
848
+ }
849
+
850
+ interface ImageGenConfig {
851
+ apiKey: string;
852
+ model?: string;
853
+ }
854
+ declare class HuggingFaceImageGen {
855
+ private client;
856
+ private defaultModel;
857
+ constructor(config: ImageGenConfig);
858
+ /**
859
+ * Generates an image based on the prompt.
860
+ * Returns standard image Blob.
861
+ */
862
+ generate(prompt: string): Promise<Blob>;
863
+ /**
864
+ * Generates a base64 encoded string compatible with markdown or HTML `img src`.
865
+ */
866
+ generateBase64(prompt: string): Promise<string>;
867
+ /**
868
+ * Exposes this generator as a ToolContext that the AgentExecutor can use dynamically.
869
+ */
870
+ asTool(): ToolContext;
871
+ }
872
+
831
873
  interface SupportBotConfig {
832
874
  gateway: AIModelGateway;
833
875
  companyName: string;
@@ -844,6 +886,8 @@ interface SupportBotConfig {
844
886
  maxIterations?: number;
845
887
  enablePIIRedaction?: boolean;
846
888
  experiments?: Experiment[];
889
+ tts?: TTSConfig;
890
+ imageGen?: ImageGenConfig;
847
891
  }
848
892
  type BotMiddleware = (ctx: {
849
893
  sessionId: string;
@@ -865,6 +909,8 @@ declare class CustomerSupportBot {
865
909
  handoff?: HandoffManager;
866
910
  piiRedactor?: PIIRedactor;
867
911
  experimentManager?: ExperimentManager;
912
+ ttsEngine?: HuggingFaceTTS;
913
+ imageGenEngine?: HuggingFaceImageGen;
868
914
  greeting: string;
869
915
  private defaultSystemPrompt;
870
916
  private middlewares;
@@ -875,6 +921,13 @@ declare class CustomerSupportBot {
875
921
  trackOutcome(sessionId: string, type: string, valueUsd?: number, metadata?: Record<string, any>): void;
876
922
  /** Process a customer message and return the bot's response. */
877
923
  chat(sessionId: string, message: string): Promise<string>;
924
+ /**
925
+ * Process a customer message and return both text and a spoken audio Buffer using the TTS engine.
926
+ */
927
+ chatWithVoice(sessionId: string, message: string): Promise<{
928
+ text: string;
929
+ audio?: Buffer;
930
+ }>;
878
931
  /** Start tracking analytics for a new session. */
879
932
  initSession(sessionId: string): void;
880
933
  }
@@ -982,4 +1035,39 @@ declare class TelegramAdapter extends ChannelAdapter {
982
1035
  private sendMessage;
983
1036
  }
984
1037
 
985
- export { AIModelGateway, APIConnector, type APIConnectorConfig, AgentExecutor, AgentIterationLimitError, AgentPipeline, AgentRouter, type AgentTelemetry, type AnalyticsSnapshot, type BaseMemoryStore, BaseProvider, BaseSTTProvider, BaseSpeakerRecognizer, BaseTTSProvider, type BotMiddleware, CachedGateway, ChannelAdapter, type ChannelConfig, ChatAgent, type ChatMessage, ChatMessageSchema, type ChatRequest, ChatRequestSchema, type ChatResponse, ChatResponseSchema, ChatWidget, type ChatWidgetConfig, type ChatWidgetTheme, type ChunkOptions, ConfigurationError, ConversationAnalytics, type ConversationRecord, CustomerSupportBot, DEFAULT_REDACTION_RULES, EchoAI, EchoVoice, type EscalationTrigger, type Experiment, ExperimentManager, type ExperimentVariant, type FetchResult, FileSessionStore, type GatewayMiddleware, GatewayRoutingError, type HandoffConfig, type HandoffEvent, HandoffManager, type IdentificationResult, InMemoryStore, KnowledgeBase, type KnowledgeBaseConfig, MemorySessionStore, MemoryVectorStore, OPENAI_PRICING, OpenAITTS, OpenAIWhisperSTT, type OutcomeRecord, OutcomeTracker, PIIRedactor, PromptRegistry, PromptTemplate, PromptVersionError, ProviderDependencyError, type RedactionRule, type STTOptions, type SearchResult, type ServerConfig, type SessionStore, SlackAdapter, type SlackConfig, type SpeakerProfile, StructuredOutputError, type SupportBotConfig, type TTSFormat, type TTSOptions, type TTSResult, type TTSVoice, TelegramAdapter, type TelegramConfig, ToolAgent, type ToolContext, ToolExecutionError, type TranscriptionResult, type TranscriptionSegment, type UsageMetrics, UsageMetricsSchema, ValidationError, type VectorEntry, type VerificationResult, VoiceprintStore, applyRequestMiddleware, applyResponseMiddleware, calculatorTool, chunkText, createChatHandler, createTool, dateTimeTool, startChatServer, webSearchTool };
1038
+ interface EndpointConfig {
1039
+ accountId: string;
1040
+ repository: string;
1041
+ accelerator?: string;
1042
+ instanceSize?: string;
1043
+ instanceType?: string;
1044
+ framework?: "pytorch" | "tensorflow" | "custom";
1045
+ }
1046
+ /**
1047
+ * Manages Serverless / Dedicated Endpoints on Hugging Face API.
1048
+ * Uses REST API since @huggingface/inference is primarily for making queries.
1049
+ */
1050
+ declare class InferenceEndpointManager {
1051
+ private token;
1052
+ private baseUrl;
1053
+ constructor(token: string);
1054
+ private get headers();
1055
+ /**
1056
+ * Programmatically creates a dedicated inference endpoint.
1057
+ */
1058
+ createEndpoint(name: string, config: EndpointConfig): Promise<any>;
1059
+ /**
1060
+ * Retrieves the status of an existing endpoint (e.g. "pending", "running", "paused").
1061
+ */
1062
+ getEndpointStatus(accountId: string, endpointName: string): Promise<string>;
1063
+ /**
1064
+ * Pauses a running endpoint to save costs.
1065
+ */
1066
+ pauseEndpoint(accountId: string, endpointName: string): Promise<void>;
1067
+ /**
1068
+ * Resumes a paused endpoint.
1069
+ */
1070
+ resumeEndpoint(accountId: string, endpointName: string): Promise<void>;
1071
+ }
1072
+
1073
+ export { AIModelGateway, APIConnector, type APIConnectorConfig, AgentExecutor, AgentIterationLimitError, AgentPipeline, AgentRouter, type AgentTelemetry, type AnalyticsSnapshot, type BaseMemoryStore, BaseProvider, BaseSTTProvider, BaseSpeakerRecognizer, BaseTTSProvider, type BotMiddleware, CachedGateway, ChannelAdapter, type ChannelConfig, ChatAgent, type ChatMessage, ChatMessageSchema, type ChatRequest, ChatRequestSchema, type ChatResponse, ChatResponseSchema, ChatWidget, type ChatWidgetConfig, type ChatWidgetTheme, type ChunkOptions, ConfigurationError, ConversationAnalytics, type ConversationRecord, CustomerSupportBot, DEFAULT_REDACTION_RULES, EchoAI, EchoVoice, type EndpointConfig, type EscalationTrigger, type Experiment, ExperimentManager, type ExperimentVariant, type FetchResult, FileSessionStore, type GatewayMiddleware, GatewayRoutingError, type HandoffConfig, type HandoffEvent, HandoffManager, HuggingFaceImageGen, HuggingFaceTTS, type IdentificationResult, type ImageGenConfig, InMemoryStore, InferenceEndpointManager, KnowledgeBase, type KnowledgeBaseConfig, MemorySessionStore, MemoryVectorStore, OPENAI_PRICING, OpenAITTS, OpenAIWhisperSTT, type OutcomeRecord, OutcomeTracker, PIIRedactor, PromptRegistry, PromptTemplate, PromptVersionError, ProviderDependencyError, type RedactionRule, type STTOptions, type SearchResult, type ServerConfig, type SessionStore, SlackAdapter, type SlackConfig, type SpeakerProfile, StructuredOutputError, type SupportBotConfig, type TTSConfig, type TTSFormat, type TTSOptions, type TTSResult, type TTSVoice, TelegramAdapter, type TelegramConfig, ToolAgent, type ToolContext, ToolExecutionError, type TranscriptionResult, type TranscriptionSegment, type UsageMetrics, UsageMetricsSchema, ValidationError, type VectorEntry, type VerificationResult, VoiceprintStore, applyRequestMiddleware, applyResponseMiddleware, calculatorTool, chunkText, createChatHandler, createTool, dateTimeTool, startChatServer, webSearchTool };
package/dist/index.d.ts CHANGED
@@ -828,6 +828,48 @@ declare class ExperimentManager {
828
828
  getVariantConfig(experimentName: string, variantId: string): Record<string, any> | null;
829
829
  }
830
830
 
831
+ interface TTSConfig {
832
+ apiKey: string;
833
+ model?: string;
834
+ }
835
+ declare class HuggingFaceTTS {
836
+ private client;
837
+ private defaultModel;
838
+ constructor(config: TTSConfig);
839
+ /**
840
+ * Converts an AI text response into a spoken audio Blob.
841
+ * Useful for voice-enabled chatbots or IVR systems.
842
+ */
843
+ generateAudio(text: string): Promise<Blob>;
844
+ /**
845
+ * Helper syntax for Node.js backends needing buffers instead of Blobs.
846
+ */
847
+ generateBuffer(text: string): Promise<Buffer>;
848
+ }
849
+
850
+ interface ImageGenConfig {
851
+ apiKey: string;
852
+ model?: string;
853
+ }
854
+ declare class HuggingFaceImageGen {
855
+ private client;
856
+ private defaultModel;
857
+ constructor(config: ImageGenConfig);
858
+ /**
859
+ * Generates an image based on the prompt.
860
+ * Returns standard image Blob.
861
+ */
862
+ generate(prompt: string): Promise<Blob>;
863
+ /**
864
+ * Generates a base64 encoded string compatible with markdown or HTML `img src`.
865
+ */
866
+ generateBase64(prompt: string): Promise<string>;
867
+ /**
868
+ * Exposes this generator as a ToolContext that the AgentExecutor can use dynamically.
869
+ */
870
+ asTool(): ToolContext;
871
+ }
872
+
831
873
  interface SupportBotConfig {
832
874
  gateway: AIModelGateway;
833
875
  companyName: string;
@@ -844,6 +886,8 @@ interface SupportBotConfig {
844
886
  maxIterations?: number;
845
887
  enablePIIRedaction?: boolean;
846
888
  experiments?: Experiment[];
889
+ tts?: TTSConfig;
890
+ imageGen?: ImageGenConfig;
847
891
  }
848
892
  type BotMiddleware = (ctx: {
849
893
  sessionId: string;
@@ -865,6 +909,8 @@ declare class CustomerSupportBot {
865
909
  handoff?: HandoffManager;
866
910
  piiRedactor?: PIIRedactor;
867
911
  experimentManager?: ExperimentManager;
912
+ ttsEngine?: HuggingFaceTTS;
913
+ imageGenEngine?: HuggingFaceImageGen;
868
914
  greeting: string;
869
915
  private defaultSystemPrompt;
870
916
  private middlewares;
@@ -875,6 +921,13 @@ declare class CustomerSupportBot {
875
921
  trackOutcome(sessionId: string, type: string, valueUsd?: number, metadata?: Record<string, any>): void;
876
922
  /** Process a customer message and return the bot's response. */
877
923
  chat(sessionId: string, message: string): Promise<string>;
924
+ /**
925
+ * Process a customer message and return both text and a spoken audio Buffer using the TTS engine.
926
+ */
927
+ chatWithVoice(sessionId: string, message: string): Promise<{
928
+ text: string;
929
+ audio?: Buffer;
930
+ }>;
878
931
  /** Start tracking analytics for a new session. */
879
932
  initSession(sessionId: string): void;
880
933
  }
@@ -982,4 +1035,39 @@ declare class TelegramAdapter extends ChannelAdapter {
982
1035
  private sendMessage;
983
1036
  }
984
1037
 
985
- export { AIModelGateway, APIConnector, type APIConnectorConfig, AgentExecutor, AgentIterationLimitError, AgentPipeline, AgentRouter, type AgentTelemetry, type AnalyticsSnapshot, type BaseMemoryStore, BaseProvider, BaseSTTProvider, BaseSpeakerRecognizer, BaseTTSProvider, type BotMiddleware, CachedGateway, ChannelAdapter, type ChannelConfig, ChatAgent, type ChatMessage, ChatMessageSchema, type ChatRequest, ChatRequestSchema, type ChatResponse, ChatResponseSchema, ChatWidget, type ChatWidgetConfig, type ChatWidgetTheme, type ChunkOptions, ConfigurationError, ConversationAnalytics, type ConversationRecord, CustomerSupportBot, DEFAULT_REDACTION_RULES, EchoAI, EchoVoice, type EscalationTrigger, type Experiment, ExperimentManager, type ExperimentVariant, type FetchResult, FileSessionStore, type GatewayMiddleware, GatewayRoutingError, type HandoffConfig, type HandoffEvent, HandoffManager, type IdentificationResult, InMemoryStore, KnowledgeBase, type KnowledgeBaseConfig, MemorySessionStore, MemoryVectorStore, OPENAI_PRICING, OpenAITTS, OpenAIWhisperSTT, type OutcomeRecord, OutcomeTracker, PIIRedactor, PromptRegistry, PromptTemplate, PromptVersionError, ProviderDependencyError, type RedactionRule, type STTOptions, type SearchResult, type ServerConfig, type SessionStore, SlackAdapter, type SlackConfig, type SpeakerProfile, StructuredOutputError, type SupportBotConfig, type TTSFormat, type TTSOptions, type TTSResult, type TTSVoice, TelegramAdapter, type TelegramConfig, ToolAgent, type ToolContext, ToolExecutionError, type TranscriptionResult, type TranscriptionSegment, type UsageMetrics, UsageMetricsSchema, ValidationError, type VectorEntry, type VerificationResult, VoiceprintStore, applyRequestMiddleware, applyResponseMiddleware, calculatorTool, chunkText, createChatHandler, createTool, dateTimeTool, startChatServer, webSearchTool };
1038
+ interface EndpointConfig {
1039
+ accountId: string;
1040
+ repository: string;
1041
+ accelerator?: string;
1042
+ instanceSize?: string;
1043
+ instanceType?: string;
1044
+ framework?: "pytorch" | "tensorflow" | "custom";
1045
+ }
1046
+ /**
1047
+ * Manages Serverless / Dedicated Endpoints on Hugging Face API.
1048
+ * Uses REST API since @huggingface/inference is primarily for making queries.
1049
+ */
1050
+ declare class InferenceEndpointManager {
1051
+ private token;
1052
+ private baseUrl;
1053
+ constructor(token: string);
1054
+ private get headers();
1055
+ /**
1056
+ * Programmatically creates a dedicated inference endpoint.
1057
+ */
1058
+ createEndpoint(name: string, config: EndpointConfig): Promise<any>;
1059
+ /**
1060
+ * Retrieves the status of an existing endpoint (e.g. "pending", "running", "paused").
1061
+ */
1062
+ getEndpointStatus(accountId: string, endpointName: string): Promise<string>;
1063
+ /**
1064
+ * Pauses a running endpoint to save costs.
1065
+ */
1066
+ pauseEndpoint(accountId: string, endpointName: string): Promise<void>;
1067
+ /**
1068
+ * Resumes a paused endpoint.
1069
+ */
1070
+ resumeEndpoint(accountId: string, endpointName: string): Promise<void>;
1071
+ }
1072
+
1073
+ export { AIModelGateway, APIConnector, type APIConnectorConfig, AgentExecutor, AgentIterationLimitError, AgentPipeline, AgentRouter, type AgentTelemetry, type AnalyticsSnapshot, type BaseMemoryStore, BaseProvider, BaseSTTProvider, BaseSpeakerRecognizer, BaseTTSProvider, type BotMiddleware, CachedGateway, ChannelAdapter, type ChannelConfig, ChatAgent, type ChatMessage, ChatMessageSchema, type ChatRequest, ChatRequestSchema, type ChatResponse, ChatResponseSchema, ChatWidget, type ChatWidgetConfig, type ChatWidgetTheme, type ChunkOptions, ConfigurationError, ConversationAnalytics, type ConversationRecord, CustomerSupportBot, DEFAULT_REDACTION_RULES, EchoAI, EchoVoice, type EndpointConfig, type EscalationTrigger, type Experiment, ExperimentManager, type ExperimentVariant, type FetchResult, FileSessionStore, type GatewayMiddleware, GatewayRoutingError, type HandoffConfig, type HandoffEvent, HandoffManager, HuggingFaceImageGen, HuggingFaceTTS, type IdentificationResult, type ImageGenConfig, InMemoryStore, InferenceEndpointManager, KnowledgeBase, type KnowledgeBaseConfig, MemorySessionStore, MemoryVectorStore, OPENAI_PRICING, OpenAITTS, OpenAIWhisperSTT, type OutcomeRecord, OutcomeTracker, PIIRedactor, PromptRegistry, PromptTemplate, PromptVersionError, ProviderDependencyError, type RedactionRule, type STTOptions, type SearchResult, type ServerConfig, type SessionStore, SlackAdapter, type SlackConfig, type SpeakerProfile, StructuredOutputError, type SupportBotConfig, type TTSConfig, type TTSFormat, type TTSOptions, type TTSResult, type TTSVoice, TelegramAdapter, type TelegramConfig, ToolAgent, type ToolContext, ToolExecutionError, type TranscriptionResult, type TranscriptionSegment, type UsageMetrics, UsageMetricsSchema, ValidationError, type VectorEntry, type VerificationResult, VoiceprintStore, applyRequestMiddleware, applyResponseMiddleware, calculatorTool, chunkText, createChatHandler, createTool, dateTimeTool, startChatServer, webSearchTool };