react-ai-agent 1.6.7 → 1.6.8

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/index.d.ts CHANGED
@@ -189,6 +189,7 @@ export interface ChatProviderProps {
189
189
  statusComponents?: any;
190
190
  forwardingHandlers?: ForwardingHandlers;
191
191
  enableHistory?: boolean;
192
+ loadHistory?: boolean; // Control initial history loading
192
193
  loadingComponent?: ComponentType<any>;
193
194
  headerComponent?: ComponentType<any>;
194
195
  allowThinking?: boolean;
@@ -196,11 +197,61 @@ export interface ChatProviderProps {
196
197
  agentId?: string; // Unique identifier for multi-instance support
197
198
  refreshTokenCallback?: (refreshToken: string) => Promise<any>;
198
199
  onError?: (error: any) => void; // Error handler callback
200
+ onSessionError?: (error: any) => Promise<void>; // Session error handler
199
201
  // Legacy support (deprecated)
200
202
  sessionData?: SessionData | null;
201
203
  }
202
204
 
203
- export function ChatProvider(props: ChatProviderProps): ReactElement;
205
+ /**
206
+ * ChatProvider Controller Interface
207
+ * Provides imperative access to ChatProvider methods and state via ref
208
+ */
209
+ export interface ChatProviderController {
210
+ // Message operations
211
+ sendMsg: (params?: SendMessageParams) => Promise<void>;
212
+ getHistory: () => Promise<void>;
213
+ loadMoreMessages: () => Promise<void>;
214
+ abort: () => void;
215
+ retryLastMessage: () => Promise<void>;
216
+
217
+ // State getters
218
+ messages: any[];
219
+ isLoading: boolean;
220
+ isStreaming: boolean;
221
+ isResponseStarted: boolean;
222
+ isInitialLoading: boolean;
223
+ isLoadingMore: boolean;
224
+ hasMoreMessages: boolean;
225
+ error: any;
226
+ streamError: any;
227
+ sessionId: string | undefined;
228
+ instanceId: string;
229
+
230
+ // Message manager
231
+ messageManager: {
232
+ addMessage: (msg: any) => any;
233
+ updateMessage: (id: string, updates: any, options?: { silent?: boolean }) => any;
234
+ removeMessage: (id: string) => boolean;
235
+ getMessage: (id: string) => any;
236
+ clear: () => void;
237
+ };
238
+
239
+ // Config setters
240
+ setAuthConfig: (config: { sessionId?: string; accessToken?: string }) => void;
241
+ setLoadHistory: (load: boolean) => void;
242
+ setSessionId: (id: string | undefined) => void;
243
+ clearStreamError: () => void;
244
+
245
+ // Status registry
246
+ statusRegistry: {
247
+ register: (action: string, handler: (data: any) => void) => () => void;
248
+ registerGlobal: (handler: (data: any) => void) => () => void;
249
+ };
250
+ }
251
+
252
+ export const ChatProvider: React.ForwardRefExoticComponent<
253
+ ChatProviderProps & React.RefAttributes<ChatProviderController>
254
+ >;
204
255
 
205
256
  // ============================================================================
206
257
  // Components
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-ai-agent",
3
- "version": "1.6.7",
3
+ "version": "1.6.8",
4
4
  "type": "module",
5
5
  "description": "React Chat Agent - A production-ready chat provider with WebSocket support",
6
6
  "main": "dist/index.cjs",