@iota-uz/sdk 0.4.11 → 0.4.13

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.
@@ -4,6 +4,89 @@ import react__default, { ReactNode, Component, ErrorInfo, FC, HTMLAttributes, Re
4
4
  import { I as InitialContext, A as AppConfig$1, L as LocaleContext$1, T as TenantContext$1, U as UserContext$1 } from '../index-Cs_xWkhC.js';
5
5
  import { File as File$1 } from '@phosphor-icons/react';
6
6
 
7
+ /**
8
+ * Split data source interfaces for BiChat.
9
+ *
10
+ * ChatDataSource was a single interface mixing CRUD, streaming, artifacts,
11
+ * and admin. These focused interfaces let consumers implement only what
12
+ * they need. ChatDataSource keeps the same shape (with optional artifact
13
+ * and admin methods) for backwards compatibility — it is NOT a strict
14
+ * intersection of these interfaces.
15
+ */
16
+
17
+ interface SessionStore {
18
+ createSession(): Promise<Session$1>;
19
+ fetchSession(id: string): Promise<{
20
+ session: Session$1;
21
+ turns: ConversationTurn$1[];
22
+ pendingQuestion?: PendingQuestion$1 | null;
23
+ } | null>;
24
+ listSessions(options?: {
25
+ limit?: number;
26
+ offset?: number;
27
+ includeArchived?: boolean;
28
+ }): Promise<SessionListResult$1>;
29
+ archiveSession(sessionId: string): Promise<Session$1>;
30
+ unarchiveSession(sessionId: string): Promise<Session$1>;
31
+ pinSession(sessionId: string): Promise<Session$1>;
32
+ unpinSession(sessionId: string): Promise<Session$1>;
33
+ deleteSession(sessionId: string): Promise<void>;
34
+ renameSession(sessionId: string, title: string): Promise<Session$1>;
35
+ regenerateSessionTitle(sessionId: string): Promise<Session$1>;
36
+ clearSessionHistory(sessionId: string): Promise<{
37
+ success: boolean;
38
+ deletedMessages: number;
39
+ deletedArtifacts: number;
40
+ }>;
41
+ compactSessionHistory(sessionId: string): Promise<{
42
+ success: boolean;
43
+ summary: string;
44
+ deletedMessages: number;
45
+ deletedArtifacts: number;
46
+ }>;
47
+ }
48
+ interface MessageTransport {
49
+ sendMessage(sessionId: string, content: string, attachments?: Attachment$1[], signal?: AbortSignal, options?: SendMessageOptions): AsyncGenerator<StreamChunk>;
50
+ submitQuestionAnswers(sessionId: string, questionId: string, answers: QuestionAnswers): Promise<{
51
+ success: boolean;
52
+ error?: string;
53
+ }>;
54
+ rejectPendingQuestion(sessionId: string): Promise<{
55
+ success: boolean;
56
+ error?: string;
57
+ }>;
58
+ }
59
+ interface ArtifactStore {
60
+ fetchSessionArtifacts(sessionId: string, options?: {
61
+ limit?: number;
62
+ offset?: number;
63
+ }): Promise<{
64
+ artifacts: SessionArtifact[];
65
+ hasMore?: boolean;
66
+ nextOffset?: number;
67
+ }>;
68
+ uploadSessionArtifacts(sessionId: string, files: File[]): Promise<{
69
+ artifacts: SessionArtifact[];
70
+ }>;
71
+ renameSessionArtifact(artifactId: string, name: string, description?: string): Promise<SessionArtifact>;
72
+ deleteSessionArtifact(artifactId: string): Promise<void>;
73
+ }
74
+ interface AdminStore {
75
+ listUsers(): Promise<SessionUser[]>;
76
+ listAllSessions(options?: {
77
+ limit?: number;
78
+ offset?: number;
79
+ includeArchived?: boolean;
80
+ userId?: string | null;
81
+ }): Promise<{
82
+ sessions: Array<Session$1 & {
83
+ owner: SessionUser;
84
+ }>;
85
+ total: number;
86
+ hasMore: boolean;
87
+ }>;
88
+ }
89
+
7
90
  /**
8
91
  * Type definitions for BI-Chat UI components
9
92
  */
@@ -202,6 +285,37 @@ interface QuestionAnswerData {
202
285
  interface QuestionAnswers {
203
286
  [questionId: string]: QuestionAnswerData;
204
287
  }
288
+ type StreamEvent = {
289
+ type: 'content';
290
+ content: string;
291
+ } | {
292
+ type: 'tool_start';
293
+ tool: StreamToolPayload;
294
+ } | {
295
+ type: 'tool_end';
296
+ tool: StreamToolPayload;
297
+ } | {
298
+ type: 'usage';
299
+ usage: DebugUsage$1;
300
+ } | {
301
+ type: 'user_message';
302
+ sessionId: string;
303
+ } | {
304
+ type: 'interrupt';
305
+ interrupt: StreamInterruptPayload;
306
+ sessionId?: string;
307
+ } | {
308
+ type: 'done';
309
+ sessionId?: string;
310
+ generationMs?: number;
311
+ } | {
312
+ type: 'error';
313
+ error: string;
314
+ };
315
+ /**
316
+ * @deprecated Use `StreamEvent` instead. `StreamChunk` is kept for backwards
317
+ * compatibility but the flat all-optional shape is unsound.
318
+ */
205
319
  interface StreamChunk {
206
320
  type: 'chunk' | 'content' | 'tool_start' | 'tool_end' | 'usage' | 'done' | 'error' | 'user_message' | 'interrupt';
207
321
  content?: string;
@@ -281,6 +395,17 @@ interface SessionGroup {
281
395
  name: string;
282
396
  sessions: Session$1[];
283
397
  }
398
+
399
+ /**
400
+ * Full data source interface for BiChat.
401
+ *
402
+ * Combines session CRUD, message transport, and optional artifact/admin
403
+ * methods. Existing implementations satisfy this without changes.
404
+ *
405
+ * For new code, prefer the focused interfaces (`SessionStore`,
406
+ * `MessageTransport`, `ArtifactStore`, `AdminStore`) when you only need a
407
+ * subset of capabilities.
408
+ */
284
409
  interface ChatDataSource {
285
410
  createSession(): Promise<Session$1>;
286
411
  fetchSession(id: string): Promise<{
@@ -321,6 +446,11 @@ interface ChatDataSource {
321
446
  success: boolean;
322
447
  error?: string;
323
448
  }>;
449
+ /**
450
+ * @deprecated Pass `onSessionCreated` to `ChatSessionProvider` instead.
451
+ * This method couples navigation to the data source, causing component
452
+ * remounts during active streams.
453
+ */
324
454
  navigateToSession?(sessionId: string): void;
325
455
  listSessions(options?: {
326
456
  limit?: number;
@@ -353,15 +483,19 @@ interface ChatSessionStateValue {
353
483
  currentSessionId?: string;
354
484
  fetching: boolean;
355
485
  error: string | null;
486
+ errorRetryable: boolean;
356
487
  debugMode: boolean;
357
488
  sessionDebugUsage: SessionDebugUsage;
358
489
  debugLimits: DebugLimits | null;
359
490
  setError: (error: string | null) => void;
491
+ retryFetchSession: () => void;
360
492
  }
361
493
  interface ChatMessagingStateValue {
362
494
  turns: ConversationTurn$1[];
363
495
  streamingContent: string;
364
496
  isStreaming: boolean;
497
+ streamError: string | null;
498
+ streamErrorRetryable: boolean;
365
499
  loading: boolean;
366
500
  pendingQuestion: PendingQuestion$1 | null;
367
501
  codeOutputs: CodeOutput$1[];
@@ -375,6 +509,8 @@ interface ChatMessagingStateValue {
375
509
  handleCopy: (text: string) => Promise<void>;
376
510
  handleSubmitQuestionAnswers: (answers: QuestionAnswers) => void;
377
511
  handleRejectPendingQuestion: () => Promise<void>;
512
+ retryLastMessage: () => Promise<void>;
513
+ clearStreamError: () => void;
378
514
  cancel: () => void;
379
515
  setCodeOutputs: (outputs: CodeOutput$1[]) => void;
380
516
  }
@@ -384,13 +520,23 @@ interface ChatInputStateValue {
384
520
  messageQueue: QueuedMessage[];
385
521
  setMessage: (message: string) => void;
386
522
  setInputError: (error: string | null) => void;
387
- handleSubmit: (e: React.FormEvent, attachments?: Attachment$1[]) => void;
523
+ handleSubmit: (e: {
524
+ preventDefault: () => void;
525
+ }, attachments?: Attachment$1[]) => void;
388
526
  handleUnqueue: () => {
389
527
  content: string;
390
528
  attachments: Attachment$1[];
391
529
  } | null;
530
+ enqueueMessage: (content: string, attachments: Attachment$1[]) => boolean;
531
+ removeQueueItem: (index: number) => void;
532
+ updateQueueItem: (index: number, content: string) => void;
392
533
  }
393
534
  interface ChatSessionContextValue extends ChatSessionStateValue, ChatMessagingStateValue, ChatInputStateValue {
535
+ /**
536
+ * @deprecated Use `retryLastMessage` from `ChatMessagingStateValue` instead.
537
+ * This field is not populated by the current ChatMachine-based provider and
538
+ * will always be `undefined` at runtime.
539
+ */
394
540
  handleRetry?: () => Promise<void>;
395
541
  }
396
542
 
@@ -428,6 +574,13 @@ interface ChatSessionProps {
428
574
  sessionId?: string;
429
575
  /** Optional rate limiter to throttle sendMessage */
430
576
  rateLimiter?: RateLimiter;
577
+ /**
578
+ * Called when a new session is created (e.g. on first message in a "new
579
+ * chat"). Use this to navigate your SPA router to the new session URL.
580
+ *
581
+ * Replaces the deprecated `dataSource.navigateToSession`.
582
+ */
583
+ onSessionCreated?: (sessionId: string) => void;
431
584
  /** Alias for isReadOnly (preferred) */
432
585
  readOnly?: boolean;
433
586
  isReadOnly?: boolean;
@@ -448,6 +601,8 @@ interface ChatSessionProps {
448
601
  onBack?: () => void;
449
602
  /** Custom verbs for the typing indicator (e.g. ['Thinking', 'Analyzing', ...]) */
450
603
  thinkingVerbs?: string[];
604
+ /** Callback invoked after an archived session is restored (e.g. to navigate or refresh) */
605
+ onSessionRestored?: (sessionId: string) => void;
451
606
  /** Enables the built-in right-side artifacts panel for persisted session artifacts */
452
607
  showArtifactsPanel?: boolean;
453
608
  /** Initial expanded state for artifacts panel when no persisted preference exists */
@@ -850,6 +1005,8 @@ interface MessageInputProps {
850
1005
  content: string;
851
1006
  attachments: Attachment$1[];
852
1007
  } | null;
1008
+ onRemoveQueueItem?: (index: number) => void;
1009
+ onUpdateQueueItem?: (index: number, content: string) => void;
853
1010
  placeholder?: string;
854
1011
  maxFiles?: number;
855
1012
  maxFileSize?: number;
@@ -1185,7 +1342,7 @@ interface ToastContainerProps {
1185
1342
  /** Label for dismiss buttons */
1186
1343
  dismissLabel?: string;
1187
1344
  }
1188
- declare function ToastContainer({ toasts, onDismiss, dismissLabel }: ToastContainerProps): react_jsx_runtime.JSX.Element;
1345
+ declare function ToastContainer({ toasts, onDismiss, dismissLabel }: ToastContainerProps): react_jsx_runtime.JSX.Element | null;
1189
1346
 
1190
1347
  /**
1191
1348
  * ConfirmModal Component
@@ -1350,22 +1507,6 @@ interface AllChatsListProps {
1350
1507
  }
1351
1508
  declare function AllChatsList({ dataSource, onSessionSelect, activeSessionId }: AllChatsListProps): react_jsx_runtime.JSX.Element;
1352
1509
 
1353
- /**
1354
- * TabBar Component
1355
- * Horizontal tabs with animated indicator for switching between views
1356
- * Generic: accepts any set of tabs via props
1357
- */
1358
- interface TabBarProps {
1359
- tabs: Array<{
1360
- id: string;
1361
- label: string;
1362
- }>;
1363
- activeTab: string;
1364
- onTabChange: (tabId: string) => void;
1365
- }
1366
- declare function TabBar({ tabs, activeTab, onTabChange }: TabBarProps): react_jsx_runtime.JSX.Element | null;
1367
- declare const MemoizedTabBar: react.MemoExoticComponent<typeof TabBar>;
1368
-
1369
1510
  interface UserFilterProps {
1370
1511
  users: SessionUser[];
1371
1512
  selectedUser: SessionUser | null;
@@ -1489,10 +1630,12 @@ interface StreamErrorProps {
1489
1630
  onRetry?: () => void;
1490
1631
  /** Callback to regenerate the message */
1491
1632
  onRegenerate?: () => void;
1633
+ /** Callback to dismiss the error */
1634
+ onDismiss?: () => void;
1492
1635
  /** Whether to show compact mode (less padding) */
1493
1636
  compact?: boolean;
1494
1637
  }
1495
- declare function StreamError({ error, onRetry, onRegenerate, compact, }: StreamErrorProps): react_jsx_runtime.JSX.Element;
1638
+ declare function StreamError({ error, onRetry, onRegenerate, onDismiss, compact, }: StreamErrorProps): react_jsx_runtime.JSX.Element;
1496
1639
 
1497
1640
  interface ActionableMessage {
1498
1641
  id: string;
@@ -1793,7 +1936,7 @@ declare function useStreaming(options?: UseStreamingOptions): {
1793
1936
  * Translation hook using locale from IotaContext
1794
1937
  */
1795
1938
  declare function useTranslation(): {
1796
- t: (key: string, params?: Record<string, any>) => string;
1939
+ t: (key: string, params?: Record<string, string | number | boolean>) => string;
1797
1940
  locale: string;
1798
1941
  };
1799
1942
 
@@ -2456,29 +2599,6 @@ declare const dropdownVariants: {
2456
2599
  };
2457
2600
  };
2458
2601
  };
2459
- /**
2460
- * Toast notification
2461
- */
2462
- declare const toastVariants: {
2463
- initial: {
2464
- opacity: number;
2465
- y: number;
2466
- };
2467
- animate: {
2468
- opacity: number;
2469
- y: number;
2470
- transition: {
2471
- duration: number;
2472
- };
2473
- };
2474
- exit: {
2475
- opacity: number;
2476
- y: number;
2477
- transition: {
2478
- duration: number;
2479
- };
2480
- };
2481
- };
2482
2602
  /**
2483
2603
  * Session item with subtle slide-right on hover
2484
2604
  */
@@ -2539,15 +2659,30 @@ declare const errorMessageVariants: {
2539
2659
  interface ChatSessionProviderProps {
2540
2660
  dataSource: ChatDataSource;
2541
2661
  sessionId?: string;
2662
+ /**
2663
+ * External rate limiter instance. Captured once at mount — changing this prop
2664
+ * after initial render has no effect. For most cases, use `rateLimitConfig`
2665
+ * instead and let the provider create the limiter internally.
2666
+ */
2542
2667
  rateLimiter?: RateLimiter;
2543
- /** Configuration for the built-in rate limiter (ignored when rateLimiter is provided). */
2668
+ /**
2669
+ * Configuration for the built-in rate limiter (ignored when `rateLimiter` is
2670
+ * provided). Captured once at mount — changing after initial render has no effect.
2671
+ */
2544
2672
  rateLimitConfig?: RateLimiterConfig;
2673
+ /**
2674
+ * Called when the machine creates a new session (e.g. on first message in a
2675
+ * "new chat"). Use this to navigate your SPA router to the new session URL.
2676
+ *
2677
+ * Replaces the deprecated `dataSource.navigateToSession`.
2678
+ */
2679
+ onSessionCreated?: (sessionId: string) => void;
2545
2680
  children: ReactNode;
2546
2681
  }
2547
- declare function ChatSessionProvider({ dataSource, sessionId, rateLimiter: externalRateLimiter, rateLimitConfig, children }: ChatSessionProviderProps): react_jsx_runtime.JSX.Element;
2682
+ declare function ChatSessionProvider({ dataSource, sessionId, rateLimiter: externalRateLimiter, rateLimitConfig, onSessionCreated, children, }: ChatSessionProviderProps): react_jsx_runtime.JSX.Element;
2548
2683
  declare function useChatSession(): ChatSessionStateValue;
2549
2684
  declare function useChatMessaging(): ChatMessagingStateValue;
2550
- /** Returns messaging context or null when outside ChatSessionProvider. Use when component can receive values via props (e.g. SessionArtifactsPanel with artifactsInvalidationTrigger prop). */
2685
+ /** Returns messaging context or null when outside ChatSessionProvider. */
2551
2686
  declare function useOptionalChatMessaging(): ChatMessagingStateValue | null;
2552
2687
  declare function useChatInput(): ChatInputStateValue;
2553
2688
 
@@ -2617,21 +2752,27 @@ type IotaContext = Omit<InitialContext, 'config' | 'extensions'> & {
2617
2752
  };
2618
2753
  declare global {
2619
2754
  interface Window {
2620
- __BICHAT_CONTEXT__: IotaContext;
2755
+ __APPLET_CONTEXT__: IotaContext;
2621
2756
  __CSRF_TOKEN__: string;
2622
2757
  }
2623
2758
  }
2624
2759
 
2625
2760
  interface IotaContextProviderProps {
2761
+ /**
2762
+ * Explicit context object. When provided, the window global is not read.
2763
+ * Useful for tests, Storybook, or apps that manage their own context.
2764
+ */
2765
+ context?: IotaContext;
2626
2766
  children: ReactNode;
2627
2767
  }
2628
- declare function IotaContextProvider({ children }: IotaContextProviderProps): react_jsx_runtime.JSX.Element;
2768
+ declare function IotaContextProvider({ context, children }: IotaContextProviderProps): react_jsx_runtime.JSX.Element;
2629
2769
  declare function useIotaContext(): IotaContext;
2630
2770
  /**
2631
2771
  * Check if user has a specific permission
2632
2772
  */
2633
2773
  declare function hasPermission(permission: string): boolean;
2634
2774
 
2775
+ /** @deprecated Use `IotaContextProvider` with its `context` prop instead. */
2635
2776
  interface BiChatConfig {
2636
2777
  user: {
2637
2778
  id: string;
@@ -2660,11 +2801,12 @@ interface ConfigProviderProps {
2660
2801
  children: ReactNode;
2661
2802
  }
2662
2803
  /**
2663
- * ConfigProvider component
2664
- * Provides configuration to the BiChat library
2804
+ * @deprecated Use `IotaContextProvider` with its `context` prop instead.
2805
+ *
2806
+ * ConfigProvider component — provides configuration to the BiChat library.
2665
2807
  *
2666
2808
  * @param config - Configuration object (preferred method)
2667
- * @param useGlobalConfig - If true, falls back to window.__BICHAT_CONTEXT__ when config is not provided
2809
+ * @param useGlobalConfig - If true, falls back to window.__APPLET_CONTEXT__ when config is not provided
2668
2810
  * @param children - React children
2669
2811
  */
2670
2812
  declare function ConfigProvider({ config, useGlobalConfig, children }: ConfigProviderProps): react_jsx_runtime.JSX.Element;
@@ -2774,7 +2916,11 @@ interface HttpDataSourceConfig {
2774
2916
  csrfToken?: string | (() => string);
2775
2917
  headers?: Record<string, string>;
2776
2918
  timeout?: number;
2777
- /** Optional: called when a new session is created so the host app can navigate (e.g. SPA router) */
2919
+ /**
2920
+ * @deprecated Pass `onSessionCreated` to `ChatSessionProvider` or
2921
+ * `ChatSession` instead. Coupling navigation to the data source causes
2922
+ * component remounts during active streams.
2923
+ */
2778
2924
  navigateToSession?: (sessionId: string) => void;
2779
2925
  }
2780
2926
  interface SessionState {
@@ -3156,6 +3302,241 @@ interface UserTurn {
3156
3302
  createdAt: string;
3157
3303
  }
3158
3304
 
3305
+ /**
3306
+ * Internal types for the ChatMachine.
3307
+ *
3308
+ * These are implementation details — consumers use the existing
3309
+ * ChatSessionStateValue / ChatMessagingStateValue / ChatInputStateValue
3310
+ * types via the public hooks.
3311
+ */
3312
+
3313
+ interface ChatMachineConfig {
3314
+ dataSource: ChatDataSource;
3315
+ rateLimiter: RateLimiter;
3316
+ onSessionCreated?: (sessionId: string) => void;
3317
+ }
3318
+ /**
3319
+ * Mirrors ChatSessionStateValue. Methods are stable (bound once on
3320
+ * machine construction) so they never trigger re-renders by identity change.
3321
+ */
3322
+ interface SessionSnapshot {
3323
+ session: Session$1 | null;
3324
+ currentSessionId?: string;
3325
+ fetching: boolean;
3326
+ error: string | null;
3327
+ errorRetryable: boolean;
3328
+ debugMode: boolean;
3329
+ sessionDebugUsage: SessionDebugUsage;
3330
+ debugLimits: DebugLimits | null;
3331
+ setError: (error: string | null) => void;
3332
+ retryFetchSession: () => void;
3333
+ }
3334
+ /** Mirrors ChatMessagingStateValue. */
3335
+ interface MessagingSnapshot {
3336
+ turns: ConversationTurn$1[];
3337
+ streamingContent: string;
3338
+ isStreaming: boolean;
3339
+ streamError: string | null;
3340
+ streamErrorRetryable: boolean;
3341
+ loading: boolean;
3342
+ pendingQuestion: PendingQuestion$1 | null;
3343
+ codeOutputs: CodeOutput$1[];
3344
+ isCompacting: boolean;
3345
+ compactionSummary: string | null;
3346
+ artifactsInvalidationTrigger: number;
3347
+ sendMessage: (content: string, attachments?: Attachment$1[]) => Promise<void>;
3348
+ handleRegenerate?: (turnId: string) => Promise<void>;
3349
+ handleEdit?: (turnId: string, newContent: string) => Promise<void>;
3350
+ handleCopy: (text: string) => Promise<void>;
3351
+ handleSubmitQuestionAnswers: (answers: QuestionAnswers) => void;
3352
+ handleRejectPendingQuestion: () => Promise<void>;
3353
+ retryLastMessage: () => Promise<void>;
3354
+ clearStreamError: () => void;
3355
+ cancel: () => void;
3356
+ setCodeOutputs: (outputs: CodeOutput$1[]) => void;
3357
+ }
3358
+ /** Mirrors ChatInputStateValue. */
3359
+ interface InputSnapshot {
3360
+ message: string;
3361
+ inputError: string | null;
3362
+ messageQueue: QueuedMessage[];
3363
+ setMessage: (message: string) => void;
3364
+ setInputError: (error: string | null) => void;
3365
+ handleSubmit: (e: {
3366
+ preventDefault: () => void;
3367
+ }, attachments?: Attachment$1[]) => void;
3368
+ handleUnqueue: () => {
3369
+ content: string;
3370
+ attachments: Attachment$1[];
3371
+ } | null;
3372
+ enqueueMessage: (content: string, attachments: Attachment$1[]) => boolean;
3373
+ removeQueueItem: (index: number) => void;
3374
+ updateQueueItem: (index: number, content: string) => void;
3375
+ }
3376
+
3377
+ /**
3378
+ * ChatMachine — framework-agnostic state machine for BiChat.
3379
+ *
3380
+ * Owns all async logic that was previously in ChatContext.tsx:
3381
+ * - Session fetch (with race-condition guards)
3382
+ * - Message sending + streaming
3383
+ * - Slash commands (/debug, /clear, /compact)
3384
+ * - HITL question submission / rejection
3385
+ * - Message queue (auto-drain)
3386
+ * - Rate limiting
3387
+ * - Abort / cancel
3388
+ *
3389
+ * Zero React dependency. Designed for `useSyncExternalStore`:
3390
+ * three subscribe/getSnapshot pairs map to the existing 3-context split.
3391
+ */
3392
+
3393
+ type Listener = () => void;
3394
+ declare class ChatMachine {
3395
+ private dataSource;
3396
+ private rateLimiter;
3397
+ private onSessionCreated?;
3398
+ private state;
3399
+ private abortController;
3400
+ private lastSendAttempt;
3401
+ /** Prevents fetchSession effect from clobbering state while stream is active. */
3402
+ private sendingSessionId;
3403
+ private fetchCancelled;
3404
+ private disposed;
3405
+ /** Memoized sessionDebugUsage — avoids unnecessary session re-renders during streaming. */
3406
+ private lastSessionDebugUsage;
3407
+ private sessionListeners;
3408
+ private messagingListeners;
3409
+ private inputListeners;
3410
+ private cachedSessionSnapshot;
3411
+ private cachedMessagingSnapshot;
3412
+ private cachedInputSnapshot;
3413
+ private sessionSnapshotVersion;
3414
+ private messagingSnapshotVersion;
3415
+ private inputSnapshotVersion;
3416
+ private lastSessionSnapshotVersion;
3417
+ private lastMessagingSnapshotVersion;
3418
+ private lastInputSnapshotVersion;
3419
+ readonly setError: (error: string | null) => void;
3420
+ readonly retryFetchSession: () => void;
3421
+ readonly sendMessage: (content: string, attachments?: Attachment$1[]) => Promise<void>;
3422
+ readonly handleRegenerate: (turnId: string) => Promise<void>;
3423
+ readonly handleEdit: (turnId: string, newContent: string) => Promise<void>;
3424
+ readonly handleCopy: (text: string) => Promise<void>;
3425
+ readonly handleSubmitQuestionAnswers: (answers: QuestionAnswers) => void;
3426
+ readonly handleRejectPendingQuestion: () => Promise<void>;
3427
+ readonly retryLastMessage: () => Promise<void>;
3428
+ readonly clearStreamError: () => void;
3429
+ readonly cancel: () => void;
3430
+ readonly setCodeOutputs: (outputs: CodeOutput$1[]) => void;
3431
+ readonly setMessage: (message: string) => void;
3432
+ readonly setInputError: (error: string | null) => void;
3433
+ readonly handleSubmit: (e: {
3434
+ preventDefault: () => void;
3435
+ }, attachments?: Attachment$1[]) => void;
3436
+ readonly handleUnqueue: () => {
3437
+ content: string;
3438
+ attachments: Attachment$1[];
3439
+ } | null;
3440
+ readonly enqueueMessage: (content: string, attachments: Attachment$1[]) => boolean;
3441
+ readonly removeQueueItem: (index: number) => void;
3442
+ readonly updateQueueItem: (index: number, content: string) => void;
3443
+ constructor(config: ChatMachineConfig);
3444
+ /**
3445
+ * Set the active session ID. Triggers fetch when transitioning to a real
3446
+ * session, or resets state for 'new'/undefined.
3447
+ */
3448
+ setSessionId(id: string | undefined): void;
3449
+ /**
3450
+ * Update mutable config that may change across parent re-renders.
3451
+ * Called from the React provider's useEffect to keep the machine in sync.
3452
+ */
3453
+ updateConfig(config: Pick<ChatMachineConfig, 'dataSource' | 'onSessionCreated'>): void;
3454
+ dispose(): void;
3455
+ subscribeSession: (listener: Listener) => (() => void);
3456
+ getSessionSnapshot: () => SessionSnapshot;
3457
+ subscribeMessaging: (listener: Listener) => (() => void);
3458
+ getMessagingSnapshot: () => MessagingSnapshot;
3459
+ subscribeInput: (listener: Listener) => (() => void);
3460
+ getInputSnapshot: () => InputSnapshot;
3461
+ private _updateSession;
3462
+ private _notifySession;
3463
+ private _updateMessaging;
3464
+ private _notifyMessaging;
3465
+ private _updateInput;
3466
+ private _notifyInput;
3467
+ private _persistQueue;
3468
+ private _fetchSessionIfNeeded;
3469
+ /** Sets turns from fetch, preserving pending user-only turns if server hasn't caught up. */
3470
+ private _setTurnsFromFetch;
3471
+ private _setError;
3472
+ private _retryFetchSession;
3473
+ private _clearStreamError;
3474
+ private _cancel;
3475
+ private _setCodeOutputs;
3476
+ private _setMessage;
3477
+ private _setInputError;
3478
+ private _executeSlashCommand;
3479
+ /**
3480
+ * Public entry point (no options). Calls _sendMessageCore internally.
3481
+ */
3482
+ private _sendMessage;
3483
+ /**
3484
+ * Internal entry point with options (for regenerate/edit).
3485
+ */
3486
+ private _sendMessageDirect;
3487
+ /**
3488
+ * Core send-message logic. Handles slash commands, rate limiting, streaming,
3489
+ * session creation, optimistic turns, and auto-queue-drain.
3490
+ */
3491
+ private _sendMessageCore;
3492
+ private _retryLastMessage;
3493
+ private _handleRegenerate;
3494
+ private _handleEdit;
3495
+ private _handleCopy;
3496
+ private _handleSubmitQuestionAnswers;
3497
+ private _handleRejectPendingQuestion;
3498
+ private _handleSubmit;
3499
+ private _handleUnqueue;
3500
+ private _enqueueMessage;
3501
+ private _removeQueueItem;
3502
+ private _updateQueueItem;
3503
+ }
3504
+
3505
+ /**
3506
+ * SSE stream parser for consuming Server-Sent Events.
3507
+ */
3508
+
3509
+ interface SSEEvent {
3510
+ type: string;
3511
+ content?: string;
3512
+ error?: string;
3513
+ sessionId?: string;
3514
+ toolName?: string;
3515
+ toolCallId?: string;
3516
+ durationMs?: number;
3517
+ success?: boolean;
3518
+ [key: string]: unknown;
3519
+ }
3520
+ /**
3521
+ * Parses an SSE stream and yields parsed JSON events.
3522
+ */
3523
+ declare function parseSSEStream(reader: ReadableStreamDefaultReader<Uint8Array>): AsyncGenerator<SSEEvent, void, unknown>;
3524
+ /**
3525
+ * Parses BiChat SSE stream with normalization and terminal event guarantee.
3526
+ *
3527
+ * Guarantees that the generator always yields a terminal event (`done` or
3528
+ * `error`) as its last item — even when the underlying stream closes silently
3529
+ * without one.
3530
+ */
3531
+ declare function parseBichatStream(reader: ReadableStreamDefaultReader<Uint8Array>): AsyncGenerator<StreamChunk, void, unknown>;
3532
+ /**
3533
+ * Type-safe version of `parseBichatStream` that yields `StreamEvent`
3534
+ * discriminated union members instead of the flat `StreamChunk`.
3535
+ *
3536
+ * Use this in new code for proper type narrowing on `event.type`.
3537
+ */
3538
+ declare function parseBichatStreamEvents(reader: ReadableStreamDefaultReader<Uint8Array>): AsyncGenerator<StreamEvent, void, unknown>;
3539
+
3159
3540
  /**
3160
3541
  * File Utilities
3161
3542
  * Validation, conversion, and formatting for file attachments
@@ -3234,4 +3615,4 @@ declare function isPermissionDeniedError(error: unknown): boolean;
3234
3615
  */
3235
3616
  declare function toErrorDisplay(error: unknown, fallbackTitle: string): RPCErrorDisplay;
3236
3617
 
3237
- export { ATTACHMENT_ACCEPT_ATTRIBUTE, ActionButton, type ActionButtonIconProps, type ActionButtonLabelProps, type ActionButtonRootProps, type ActionButtonTooltipProps, _default$1 as Alert, AllChatsList, type AppConfig, _default as ArchiveBanner, ArchivedChatList, type Artifact$1 as Artifact, type AsChildProps, AssistantMessage, type AssistantMessageActionsSlotProps, type AssistantMessageArtifactsSlotProps, type AssistantMessageAvatarSlotProps, type AssistantMessageChartsSlotProps, type AssistantMessageClassNames, type AssistantMessageCodeOutputsSlotProps, type AssistantMessageContentSlotProps, type AssistantMessageExplanationSlotProps, type AssistantMessageProps, type AssistantMessageSlots, type AssistantMessageSourcesSlotProps, type AssistantTurn$1 as AssistantTurn, AssistantTurnView, type AssistantTurnViewProps, type Attachment$1 as Attachment, MemoizedAttachmentGrid as AttachmentGrid, AttachmentPreview, AttachmentUpload, Avatar, type AvatarFallbackProps, type AvatarImageProps, type AvatarRootProps, type BiChatConfig, BiChatLayout, type BiChatLayoutProps, type BichatRPC, Bubble, type BubbleContentProps, type BubbleFooterProps, type BubbleHeaderProps, type BubbleMetadataProps, type BubbleRootProps, type BubbleVariant, CHART_VISUAL, ChartCard, type ChartData, type ChartSeries, type ChatDataSource, ChatHeader, type ChatInputStateValue, type ChatMessagingStateValue, ChatSession, type ChatSessionContextValue, ChatSessionProvider, type ChatSessionStateValue, type Citation$1 as Citation, MemoizedCodeBlock as CodeBlock, type CodeOutput$1 as CodeOutput, CodeOutputsPanel, CompactionDoodle, ConfigProvider, ConfirmModal, type ConfirmModalProps, ConfirmationStep, type ConversationTurn$1 as ConversationTurn, DateGroupHeader, DebugPanel, type DebugPanelProps, DefaultErrorContent, DownloadCard, MemoizedEditableText as EditableText, type EditableTextProps, type EditableTextRef, MemoizedEmptyState as EmptyState, type EmptyStateProps, ErrorBoundary, type FileValidationError, type FileVisual, HttpDataSource, type HttpDataSourceConfig, type ImageAttachment, type ImageLoadingStatus, ImageModal, InlineQuestionForm, type IotaContext, IotaContextProvider, ListItemSkeleton, MemoizedLoadingSpinner as LoadingSpinner, type LocaleContext, MemoizedMarkdownRenderer as MarkdownRenderer, MessageActions, MessageInput, type MessageInputProps, type MessageInputRef, MessageList, MessageRole, type PendingQuestion$1 as PendingQuestion, PermissionGuard, type PermissionGuardProps, type Question, type QuestionAnswerData, type QuestionAnswers, QuestionForm, type QuestionOption, QuestionStep, type QueuedMessage, type RPCErrorDisplay, RateLimiter, type RateLimiterConfig, RetryActionArea, ScreenReaderAnnouncer, ScrollToBottomButton, MemoizedSearchInput as SearchInput, type SearchInputProps, type Session$1 as Session, type SessionArtifact, SessionArtifactList, SessionArtifactPreview, SessionArtifactsPanel, type SessionGroup, SessionItem, type SessionListResult$1 as SessionListResult, SessionSkeleton, type SessionUser, type ShortcutConfig, Sidebar, type SidebarDrawerProps, type SidebarProps, MemoizedSkeleton as Skeleton, SkeletonAvatar, SkeletonCard, SkeletonGroup, type SkeletonGroupProps, type SkeletonProps, SkeletonText, SkipLink, Slot, type SlotProps, SourcesPanel, type StreamChunk, StreamError, StreamingCursor, SystemMessage, MemoizedTabBar as TabBar, TableExportButton, TableWithExport, type TenantContext, type Theme, type ThemeBorderRadius, type ThemeColors, ThemeProvider, type ThemeSpacing, Toast, ToastContainer, type ToastItem, type ToastProps, type ToastType, type ToolCall$1 as ToolCall, TouchContextMenu, Turn, type TurnActionsProps, type TurnAssistantProps, TurnBubble, type TurnBubbleClassNames, type TurnBubbleProps, type TurnRootProps, type TurnTimestampProps, type TurnUserProps, MemoizedTypingIndicator as TypingIndicator, type TypingIndicatorProps, type UseAttachmentsOptions, type UseAttachmentsReturn, type UseAutoScrollOptions, type UseAutoScrollReturn, type UseImageGalleryOptions, type UseImageGalleryReturn, type UseMarkdownCopyOptions, type UseMarkdownCopyReturn, type UseMessageActionsOptions, type UseMessageActionsReturn, type UseSidebarStateReturn, type UseToastReturn, MemoizedUserAvatar as UserAvatar, type UserAvatarProps, type UserContext, MemoizedUserFilter as UserFilter, UserMessage, type UserMessageActionsSlotProps, type UserMessageAttachmentsSlotProps, type UserMessageAvatarSlotProps, type UserMessageClassNames, type UserMessageContentSlotProps, type UserMessageProps, type UserMessageSlots, type UserTurn$1 as UserTurn, UserTurnView, type UserTurnViewProps, WelcomeContent, addCSRFHeader, backdropVariants, buttonVariants, convertToBase64, createDataUrl, createHeadersWithCSRF, createHttpDataSource, darkTheme, dropdownVariants, errorMessageVariants, fadeInUpVariants, fadeInVariants, floatingButtonVariants, formatFileSize, getCSRFToken, getFileVisual, getValidChildren, groupSessionsByDate, hasPermission, isImageMimeType, isPermissionDeniedError, lightTheme, listItemVariants, messageContainerVariants, messageVariants, scaleFadeVariants, sessionItemVariants, staggerContainerVariants, toErrorDisplay, toastVariants, typingDotVariants, useActionButtonContext, useAttachments, useAutoScroll, useAvatarContext, useBubbleContext, useChatInput, useChatMessaging, useChatSession, useConfig, useFocusTrap, useImageGallery, useIotaContext, useKeyboardShortcuts, useLongPress, useMarkdownCopy, useMessageActions, useModalLock, useOptionalChatMessaging, useRequiredConfig, useScrollToBottom, useSidebarState, useStreaming, useTheme, useToast, useTranslation, useTurnContext, validateAttachmentFile, validateFileCount, validateImageFile, verbTransitionVariants };
3618
+ export { ATTACHMENT_ACCEPT_ATTRIBUTE, ActionButton, type ActionButtonIconProps, type ActionButtonLabelProps, type ActionButtonRootProps, type ActionButtonTooltipProps, type AdminStore, _default$1 as Alert, AllChatsList, type AppConfig, _default as ArchiveBanner, ArchivedChatList, type Artifact$1 as Artifact, type ArtifactStore, type AsChildProps, AssistantMessage, type AssistantMessageActionsSlotProps, type AssistantMessageArtifactsSlotProps, type AssistantMessageAvatarSlotProps, type AssistantMessageChartsSlotProps, type AssistantMessageClassNames, type AssistantMessageCodeOutputsSlotProps, type AssistantMessageContentSlotProps, type AssistantMessageExplanationSlotProps, type AssistantMessageProps, type AssistantMessageSlots, type AssistantMessageSourcesSlotProps, type AssistantTurn$1 as AssistantTurn, AssistantTurnView, type AssistantTurnViewProps, type Attachment$1 as Attachment, MemoizedAttachmentGrid as AttachmentGrid, AttachmentPreview, AttachmentUpload, Avatar, type AvatarFallbackProps, type AvatarImageProps, type AvatarRootProps, type BiChatConfig, BiChatLayout, type BiChatLayoutProps, type BichatRPC, Bubble, type BubbleContentProps, type BubbleFooterProps, type BubbleHeaderProps, type BubbleMetadataProps, type BubbleRootProps, type BubbleVariant, CHART_VISUAL, ChartCard, type ChartData, type ChartSeries, type ChatDataSource, ChatHeader, type ChatInputStateValue, ChatMachine, type ChatMachineConfig, type ChatMessagingStateValue, ChatSession, type ChatSessionContextValue, ChatSessionProvider, type ChatSessionProviderProps, type ChatSessionStateValue, type Citation$1 as Citation, MemoizedCodeBlock as CodeBlock, type CodeOutput$1 as CodeOutput, CodeOutputsPanel, CompactionDoodle, ConfigProvider, ConfirmModal, type ConfirmModalProps, ConfirmationStep, type ConversationTurn$1 as ConversationTurn, DateGroupHeader, DebugPanel, type DebugPanelProps, DefaultErrorContent, DownloadCard, MemoizedEditableText as EditableText, type EditableTextProps, type EditableTextRef, MemoizedEmptyState as EmptyState, type EmptyStateProps, ErrorBoundary, type FileValidationError, type FileVisual, HttpDataSource, type HttpDataSourceConfig, type ImageAttachment, type ImageLoadingStatus, ImageModal, InlineQuestionForm, type IotaContext, IotaContextProvider, ListItemSkeleton, MemoizedLoadingSpinner as LoadingSpinner, type LocaleContext, MemoizedMarkdownRenderer as MarkdownRenderer, MessageActions, MessageInput, type MessageInputProps, type MessageInputRef, MessageList, MessageRole, type MessageTransport, type PendingQuestion$1 as PendingQuestion, PermissionGuard, type PermissionGuardProps, type Question, type QuestionAnswerData, type QuestionAnswers, QuestionForm, type QuestionOption, QuestionStep, type QueuedMessage, type RPCErrorDisplay, RateLimiter, type RateLimiterConfig, RetryActionArea, ScreenReaderAnnouncer, ScrollToBottomButton, MemoizedSearchInput as SearchInput, type SearchInputProps, type Session$1 as Session, type SessionArtifact, SessionArtifactList, SessionArtifactPreview, SessionArtifactsPanel, type SessionGroup, SessionItem, type SessionListResult$1 as SessionListResult, SessionSkeleton, type SessionStore, type SessionUser, type ShortcutConfig, Sidebar, type SidebarDrawerProps, type SidebarProps, MemoizedSkeleton as Skeleton, SkeletonAvatar, SkeletonCard, SkeletonGroup, type SkeletonGroupProps, type SkeletonProps, SkeletonText, SkipLink, Slot, type SlotProps, SourcesPanel, type StreamChunk, StreamError, type StreamEvent, StreamingCursor, SystemMessage, TableExportButton, TableWithExport, type TenantContext, type Theme, type ThemeBorderRadius, type ThemeColors, ThemeProvider, type ThemeSpacing, Toast, ToastContainer, type ToastItem, type ToastProps, type ToastType, type ToolCall$1 as ToolCall, TouchContextMenu, Turn, type TurnActionsProps, type TurnAssistantProps, TurnBubble, type TurnBubbleClassNames, type TurnBubbleProps, type TurnRootProps, type TurnTimestampProps, type TurnUserProps, MemoizedTypingIndicator as TypingIndicator, type TypingIndicatorProps, type UseAttachmentsOptions, type UseAttachmentsReturn, type UseAutoScrollOptions, type UseAutoScrollReturn, type UseImageGalleryOptions, type UseImageGalleryReturn, type UseMarkdownCopyOptions, type UseMarkdownCopyReturn, type UseMessageActionsOptions, type UseMessageActionsReturn, type UseSidebarStateReturn, type UseToastReturn, MemoizedUserAvatar as UserAvatar, type UserAvatarProps, type UserContext, MemoizedUserFilter as UserFilter, UserMessage, type UserMessageActionsSlotProps, type UserMessageAttachmentsSlotProps, type UserMessageAvatarSlotProps, type UserMessageClassNames, type UserMessageContentSlotProps, type UserMessageProps, type UserMessageSlots, type UserTurn$1 as UserTurn, UserTurnView, type UserTurnViewProps, WelcomeContent, addCSRFHeader, backdropVariants, buttonVariants, convertToBase64, createDataUrl, createHeadersWithCSRF, createHttpDataSource, darkTheme, dropdownVariants, errorMessageVariants, fadeInUpVariants, fadeInVariants, floatingButtonVariants, formatFileSize, getCSRFToken, getFileVisual, getValidChildren, groupSessionsByDate, hasPermission, isImageMimeType, isPermissionDeniedError, lightTheme, listItemVariants, messageContainerVariants, messageVariants, parseBichatStream, parseBichatStreamEvents, parseSSEStream, scaleFadeVariants, sessionItemVariants, staggerContainerVariants, toErrorDisplay, typingDotVariants, useActionButtonContext, useAttachments, useAutoScroll, useAvatarContext, useBubbleContext, useChatInput, useChatMessaging, useChatSession, useConfig, useFocusTrap, useImageGallery, useIotaContext, useKeyboardShortcuts, useLongPress, useMarkdownCopy, useMessageActions, useModalLock, useOptionalChatMessaging, useRequiredConfig, useScrollToBottom, useSidebarState, useStreaming, useTheme, useToast, useTranslation, useTurnContext, validateAttachmentFile, validateFileCount, validateImageFile, verbTransitionVariants };