@nexo-labs/chat-agent 1.7.3 → 1.8.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/react.d.mts CHANGED
@@ -1,13 +1,116 @@
1
1
  import React$1, { ComponentType, FC, ReactNode } from "react";
2
2
  import * as react_jsx_runtime0 from "react/jsx-runtime";
3
3
 
4
+ //#region src/adapters/ChatAdapter.d.ts
5
+ interface Source {
6
+ id: string;
7
+ title: string;
8
+ slug: string;
9
+ type: 'article' | 'book';
10
+ chunkIndex: number;
11
+ relevanceScore: number;
12
+ content: string;
13
+ excerpt?: string;
14
+ }
15
+ interface Message$1 {
16
+ role: 'user' | 'assistant';
17
+ content: string;
18
+ timestamp: Date;
19
+ sources?: Source[];
20
+ }
21
+ interface SessionSummary {
22
+ conversation_id: string;
23
+ title?: string;
24
+ last_activity: string;
25
+ status: string;
26
+ agentSlug?: string;
27
+ }
28
+ interface PublicAgentInfo {
29
+ slug: string;
30
+ name: string;
31
+ welcomeTitle?: string;
32
+ welcomeSubtitle?: string;
33
+ suggestedQuestions?: Array<{
34
+ prompt: string;
35
+ title: string;
36
+ description: string;
37
+ }>;
38
+ avatar?: string;
39
+ }
40
+ interface TokenUsage {
41
+ limit: number;
42
+ used: number;
43
+ remaining: number;
44
+ percentage: number;
45
+ reset_at: string;
46
+ }
47
+ interface SendMessageContext {
48
+ conversationId: string | null;
49
+ selectedDocuments: string[];
50
+ agentSlug?: string | null;
51
+ }
52
+ interface StreamCallbacks {
53
+ onConversationId?: (id: string) => void;
54
+ onToken?: (token: string) => void;
55
+ onSources?: (sources: Source[]) => void;
56
+ onDone?: () => void;
57
+ onUsage?: (usage: any) => void;
58
+ onError?: (error: Error) => void;
59
+ }
60
+ interface ChatAdapter {
61
+ sendMessage(message: string, context: SendMessageContext, callbacks: StreamCallbacks, signal?: AbortSignal): Promise<void>;
62
+ getActiveSession(): Promise<{
63
+ conversationId: string;
64
+ messages: Message$1[];
65
+ } | null>;
66
+ getHistory(): Promise<SessionSummary[]>;
67
+ loadSession(id: string): Promise<{
68
+ conversationId: string;
69
+ messages: Message$1[];
70
+ } | null>;
71
+ renameSession(id: string, newTitle: string): Promise<boolean>;
72
+ deleteSession(id: string): Promise<boolean>;
73
+ getAgents(): Promise<PublicAgentInfo[]>;
74
+ }
75
+ //#endregion
4
76
  //#region src/components/chat-context.d.ts
5
-
77
+ interface ChatContextType {
78
+ adapter: ChatAdapter;
79
+ isPanelOpen: boolean;
80
+ isMaximized: boolean;
81
+ openPanel: () => void;
82
+ closePanel: () => void;
83
+ setMaximized: (value: boolean) => void;
84
+ tokenUsage: TokenUsage | null;
85
+ isLoadingTokens: boolean;
86
+ updateTokenUsage: (newUsage: Partial<TokenUsage>) => void;
87
+ limitError: string | null;
88
+ setLimitError: (error: string | null) => void;
89
+ agents: PublicAgentInfo[];
90
+ selectedAgent: string | null;
91
+ setSelectedAgent: (slug: string) => void;
92
+ isLoadingAgents: boolean;
93
+ conversationId: string | null;
94
+ setConversationId: (id: string | null) => void;
95
+ messages: Message$1[];
96
+ setMessages: React.Dispatch<React.SetStateAction<Message$1[]>>;
97
+ isLoadingSession: boolean;
98
+ handleNewConversation: () => Promise<void>;
99
+ sessionsHistory: SessionSummary[];
100
+ isLoadingHistory: boolean;
101
+ loadHistory: () => Promise<void>;
102
+ loadSession: (conversationId: string) => Promise<void>;
103
+ renameSession: (conversationId: string, newTitle: string) => Promise<boolean>;
104
+ deleteSession: (conversationId: string) => Promise<boolean>;
105
+ }
6
106
  declare const ChatProvider: ({
7
- children
107
+ children,
108
+ adapter: customAdapter
8
109
  }: {
9
110
  children: ReactNode;
111
+ adapter?: ChatAdapter;
10
112
  }) => react_jsx_runtime0.JSX.Element;
113
+ declare const useChat: () => ChatContextType;
11
114
  //#endregion
12
115
  //#region src/types/components.d.ts
13
116
  /**
@@ -54,7 +157,7 @@ interface User {
54
157
  [key: string]: unknown;
55
158
  }
56
159
  interface FloatingChatManagerProps {
57
- aiIcon: string;
160
+ aiIcon?: string;
58
161
  useUser: () => {
59
162
  user: User | null;
60
163
  };
@@ -2148,6 +2251,11 @@ interface ThreadProps {
2148
2251
  runtime: ReturnType<typeof useExternalStoreRuntime>;
2149
2252
  welcomeTitle?: string;
2150
2253
  welcomeSubtitle?: string;
2254
+ suggestedQuestions?: Array<{
2255
+ prompt: string;
2256
+ title: string;
2257
+ description: string;
2258
+ }>;
2151
2259
  generateHref: (props: {
2152
2260
  type: string;
2153
2261
  value: {
@@ -2156,6 +2264,7 @@ interface ThreadProps {
2156
2264
  };
2157
2265
  }) => string;
2158
2266
  LinkComponent?: LinkComponent;
2267
+ agentName?: string;
2159
2268
  }
2160
2269
  /**
2161
2270
  * Main Thread component styled for Oraculo de Escohotado
@@ -2172,22 +2281,6 @@ interface MarkdownTextProps {
2172
2281
  declare const MarkdownText: FC<MarkdownTextProps>;
2173
2282
  //#endregion
2174
2283
  //#region src/hooks/useAssistantRuntime.d.ts
2175
- interface Source {
2176
- id: string;
2177
- title: string;
2178
- slug: string;
2179
- type: 'article' | 'book';
2180
- chunkIndex: number;
2181
- relevanceScore: number;
2182
- content: string;
2183
- excerpt?: string;
2184
- }
2185
- interface Message$1 {
2186
- role: 'user' | 'assistant';
2187
- content: string;
2188
- timestamp: Date;
2189
- sources?: Source[];
2190
- }
2191
2284
  interface Document {
2192
2285
  id: string;
2193
2286
  title: string;
@@ -2215,5 +2308,43 @@ declare function useAssistantRuntime({
2215
2308
  selectedAgent
2216
2309
  }: UseAssistantRuntimeProps): AssistantRuntime;
2217
2310
  //#endregion
2218
- export { AssistantMessage, ChatProvider, Composer, FloatingChatManager, MarkdownText, Thread, UserMessage, useAssistantRuntime };
2311
+ //#region src/adapters/NexoPayloadChatAdapter.d.ts
2312
+ declare class NexoPayloadChatAdapter implements ChatAdapter {
2313
+ sendMessage(message: string, context: SendMessageContext, callbacks: StreamCallbacks, signal?: AbortSignal): Promise<void>;
2314
+ private processStream;
2315
+ getActiveSession(): Promise<{
2316
+ conversationId: string;
2317
+ messages: Message$1[];
2318
+ } | null>;
2319
+ getHistory(): Promise<SessionSummary[]>;
2320
+ loadSession(id: string): Promise<{
2321
+ conversationId: string;
2322
+ messages: Message$1[];
2323
+ } | null>;
2324
+ renameSession(id: string, newTitle: string): Promise<boolean>;
2325
+ deleteSession(id: string): Promise<boolean>;
2326
+ getAgents(): Promise<PublicAgentInfo[]>;
2327
+ private parseBackendMessages;
2328
+ }
2329
+ //#endregion
2330
+ //#region src/adapters/MockAdapter.d.ts
2331
+ declare class MockAdapter implements ChatAdapter {
2332
+ private sessions;
2333
+ constructor();
2334
+ sendMessage(message: string, context: SendMessageContext, callbacks: StreamCallbacks, signal?: AbortSignal): Promise<void>;
2335
+ getActiveSession(): Promise<{
2336
+ conversationId: string;
2337
+ messages: Message$1[];
2338
+ } | null>;
2339
+ getHistory(): Promise<SessionSummary[]>;
2340
+ loadSession(id: string): Promise<{
2341
+ conversationId: string;
2342
+ messages: Message$1[];
2343
+ } | null>;
2344
+ renameSession(id: string, newTitle: string): Promise<boolean>;
2345
+ deleteSession(id: string): Promise<boolean>;
2346
+ getAgents(): Promise<PublicAgentInfo[]>;
2347
+ }
2348
+ //#endregion
2349
+ export { AssistantMessage, type ChatAdapter, ChatProvider, Composer, FloatingChatManager, MarkdownText, type Message$1 as Message, MockAdapter, NexoPayloadChatAdapter, type SessionSummary, type Source, type StreamCallbacks, Thread, UserMessage, useAssistantRuntime, useChat };
2219
2350
  //# sourceMappingURL=react.d.mts.map