@iota-uz/sdk 0.4.34 → 0.4.35

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.
@@ -370,6 +370,9 @@ type StreamEvent = {
370
370
  type: "interrupt";
371
371
  interrupt: StreamInterruptPayload;
372
372
  sessionId?: string;
373
+ } | {
374
+ type: "text_block_end";
375
+ seq: number;
373
376
  } | {
374
377
  type: "done";
375
378
  sessionId?: string;
@@ -402,7 +405,7 @@ interface AsyncRunAccepted {
402
405
  * compatibility but the flat all-optional shape is unsound.
403
406
  */
404
407
  interface StreamChunk {
405
- type: "chunk" | "content" | "thinking" | "tool_start" | "tool_end" | "usage" | "done" | "error" | "user_message" | "interrupt" | "snapshot" | "stream_started";
408
+ type: "chunk" | "content" | "thinking" | "tool_start" | "tool_end" | "usage" | "done" | "error" | "user_message" | "interrupt" | "snapshot" | "stream_started" | "text_block_end";
406
409
  content?: string;
407
410
  error?: string;
408
411
  sessionId?: string;
@@ -414,6 +417,27 @@ interface StreamChunk {
414
417
  snapshot?: StreamSnapshotPayload;
415
418
  /** Set when type is 'stream_started'; client should store for refresh-safe resume */
416
419
  runId?: string;
420
+ /**
421
+ * Zero-based ordinal of the assistant text segment that just ended.
422
+ * Populated only when type === "text_block_end". Used to split the
423
+ * accumulated assistant content into distinct blocks interleaved with
424
+ * tool_call UI (text → tool → text → tool → final_text).
425
+ */
426
+ textBlockSeq?: number;
427
+ }
428
+ /**
429
+ * Per-tenant active-run status event. Delivered via the
430
+ * GET /bi-chat/stream/active-runs SSE endpoint. The first batch after
431
+ * connect carries `event === "snapshot"` for each currently-running
432
+ * session; subsequent rows carry `event === "update"` as runs
433
+ * transition (queued → streaming → completed / cancelled / failed).
434
+ */
435
+ interface ActiveRunDelivery {
436
+ event: "snapshot" | "update";
437
+ sessionId: string;
438
+ runId: string;
439
+ status: "queued" | "streaming" | "completed" | "cancelled" | "failed";
440
+ updatedAt: number;
417
441
  }
418
442
  interface StreamInterruptPayload {
419
443
  checkpointId: string;
@@ -531,6 +555,13 @@ interface SendMessageOptions {
531
555
  replaceFromMessageID?: string;
532
556
  reasoningEffort?: string;
533
557
  model?: string;
558
+ /**
559
+ * Client-generated idempotency key. Duplicate sends sharing the same
560
+ * requestId within the backend's dedupe window (~30 min) converge on
561
+ * a single server-side run. Omit to disable dedupe for a particular
562
+ * send; the data source auto-generates one per call otherwise.
563
+ */
564
+ requestId?: string;
534
565
  }
535
566
  interface SessionListResult$1 {
536
567
  sessions: Session$1[];
@@ -617,6 +648,32 @@ interface ChatDataSource {
617
648
  * Optional; if absent, resume is not supported.
618
649
  */
619
650
  resumeStream?(sessionId: string, runId: string, onChunk: (chunk: StreamChunk) => void, signal?: AbortSignal): Promise<void>;
651
+ /**
652
+ * Tail a run via native EventSource against GET /stream/events. Honours
653
+ * Last-Event-ID for auto-reconnect on wifi drops / tab sleep. Prefer
654
+ * over resumeStream when connecting to a run that was started by
655
+ * another tab (same request_id) or that needs to survive a reload
656
+ * via cursor-based replay. Optional; data sources that don't
657
+ * implement it fall back to resumeStream.
658
+ */
659
+ subscribeRunEvents?(sessionId: string, runId: string, options: {
660
+ lastEventId?: string;
661
+ onChunk: (chunk: StreamChunk) => void;
662
+ onError?: (event: Event) => void;
663
+ signal?: AbortSignal;
664
+ }): Promise<void>;
665
+ /**
666
+ * Subscribe to the per-tenant active-run fan-out
667
+ * (GET /stream/active-runs). Emits one "snapshot" event per
668
+ * currently-running session on connect, then live "update" deltas.
669
+ * Optional; data sources that don't implement it fall back to
670
+ * per-session polling via getStreamStatus.
671
+ */
672
+ subscribeActiveRuns?(options: {
673
+ onEvent: (event: ActiveRunDelivery) => void;
674
+ onError?: (event: Event) => void;
675
+ signal?: AbortSignal;
676
+ }): Promise<void>;
620
677
  listSessions(options?: {
621
678
  limit?: number;
622
679
  offset?: number;
@@ -2293,6 +2350,54 @@ declare function useStreaming(options?: UseStreamingOptions): {
2293
2350
  reset: () => void;
2294
2351
  };
2295
2352
 
2353
+ /**
2354
+ * useActiveRuns — live map of per-session generation status.
2355
+ *
2356
+ * Subscribes to the data source's `subscribeActiveRuns` channel
2357
+ * (`GET /bi-chat/stream/active-runs`) and maintains a
2358
+ * sessionId → status dictionary so the sidebar can render a status
2359
+ * dot next to each session card without polling /stream/status per
2360
+ * session.
2361
+ *
2362
+ * The hook is a no-op when:
2363
+ * - the data source does not implement subscribeActiveRuns (older
2364
+ * backends without the active-run index);
2365
+ * - `enabled` is false (e.g. the user is offline).
2366
+ */
2367
+
2368
+ interface ActiveRunSnapshot {
2369
+ runId: string;
2370
+ status: ActiveRunDelivery['status'];
2371
+ updatedAt: number;
2372
+ }
2373
+ interface UseActiveRunsOptions {
2374
+ enabled?: boolean;
2375
+ /** Optional hook for raw SSE errors. */
2376
+ onError?: (event: Event) => void;
2377
+ /**
2378
+ * Keep terminal-status entries in the map for this many milliseconds
2379
+ * before pruning them. Default 0 preserves the previous behaviour
2380
+ * (synchronous delete). Useful when consumers want to render a
2381
+ * "completed" pulse animation before the dot disappears.
2382
+ */
2383
+ retainTerminalMs?: number;
2384
+ /**
2385
+ * How long to wait for an initial snapshot batch before declaring
2386
+ * the hook `ready` when the server has zero active runs.
2387
+ * Default 250ms.
2388
+ */
2389
+ emptyStateTimeoutMs?: number;
2390
+ }
2391
+ interface UseActiveRunsResult {
2392
+ /** sessionId → current live status. Terminal statuses are emitted then the entry is removed. */
2393
+ runs: Record<string, ActiveRunSnapshot>;
2394
+ /** True once the initial HGETALL snapshot is delivered. */
2395
+ ready: boolean;
2396
+ /** Convenience: undefined when not active. */
2397
+ status: (sessionId: string) => ActiveRunDelivery['status'] | undefined;
2398
+ }
2399
+ declare function useActiveRuns(dataSource: Pick<ChatDataSource, 'subscribeActiveRuns'>, options?: UseActiveRunsOptions): UseActiveRunsResult;
2400
+
2296
2401
  /**
2297
2402
  * Translation hook using locale from IotaContext
2298
2403
  */
@@ -3131,6 +3236,39 @@ interface SessionState {
3131
3236
  pendingQuestion?: PendingQuestion$1 | null;
3132
3237
  }
3133
3238
 
3239
+ /**
3240
+ * Message sending, SSE streaming, and HITL question handling.
3241
+ *
3242
+ * @internal — Not part of the public API. Consumed by HttpDataSource.
3243
+ */
3244
+
3245
+ /**
3246
+ * Thrown by {@link subscribeRunEvents} when the underlying EventSource
3247
+ * emits `onerror` before the first event arrives within the
3248
+ * initial-connect grace window. Distinguishes boundary failures
3249
+ * (401 / 404 / 503) from transient mid-run flaps, which the browser's
3250
+ * native auto-reconnect continues to handle silently.
3251
+ */
3252
+ declare class RunEventsConnectError extends Error {
3253
+ readonly cause?: Event;
3254
+ constructor(message: string, cause?: Event);
3255
+ }
3256
+ interface SubscribeRunEventsOptions {
3257
+ /** When set, start from the last seen event id instead of a full replay. */
3258
+ lastEventId?: string;
3259
+ /** Fires for every chunk (content / tool / snapshot / done / error / …). */
3260
+ onChunk: (chunk: StreamChunk) => void;
3261
+ /** Optional hook for raw SSE errors (connection blips, parse failures). */
3262
+ onError?: (event: Event) => void;
3263
+ /** AbortSignal closes the underlying EventSource. */
3264
+ signal?: AbortSignal;
3265
+ }
3266
+ interface SubscribeActiveRunsOptions {
3267
+ onEvent: (event: ActiveRunDelivery) => void;
3268
+ onError?: (event: Event) => void;
3269
+ signal?: AbortSignal;
3270
+ }
3271
+
3134
3272
  /**
3135
3273
  * Built-in HTTP data source with SSE streaming and AbortController
3136
3274
  * Implements ChatDataSource interface with real HTTP/RPC calls
@@ -3204,6 +3342,21 @@ declare class HttpDataSource implements ChatDataSource {
3204
3342
  stopGeneration(sessionId: string): Promise<void>;
3205
3343
  getStreamStatus(sessionId: string): Promise<StreamStatus | null>;
3206
3344
  resumeStream(sessionId: string, runId: string, onChunk: (chunk: StreamChunk) => void, signal?: AbortSignal): Promise<void>;
3345
+ /**
3346
+ * Open a native EventSource against GET /stream/events for the given
3347
+ * run. Used by components that want browser-native auto-reconnect
3348
+ * with Last-Event-ID (tab close, wifi drop, device switch). Prefer
3349
+ * over resumeStream when tailing an already-running generation that
3350
+ * another tab started.
3351
+ */
3352
+ subscribeRunEvents(sessionId: string, runId: string, options: SubscribeRunEventsOptions): Promise<void>;
3353
+ /**
3354
+ * Subscribe to the per-tenant active-run fan-out
3355
+ * (GET /stream/active-runs). Never resolves until the caller aborts
3356
+ * via the signal; use from a top-level component (sidebar container)
3357
+ * that mounts for the lifetime of the chat app.
3358
+ */
3359
+ subscribeActiveRuns(options: SubscribeActiveRunsOptions): Promise<void>;
3207
3360
  sendMessage(sessionId: string, content: string, attachments?: Attachment$1[], signal?: AbortSignal, options?: SendMessageOptions): AsyncGenerator<StreamChunk>;
3208
3361
  cancelStream(): void;
3209
3362
  submitQuestionAnswers(sessionId: string, questionId: string, answers: QuestionAnswers): Promise<{
@@ -4259,4 +4412,76 @@ declare function isPermissionDeniedError(error: unknown): boolean;
4259
4412
  */
4260
4413
  declare function toErrorDisplay(error: unknown, fallbackTitle: string): RPCErrorDisplay;
4261
4414
 
4262
- export { ATTACHMENT_ACCEPT_ATTRIBUTE, ActionButton, type ActionButtonIconProps, type ActionButtonLabelProps, type ActionButtonRootProps, type ActionButtonTooltipProps, type ActiveTab, type ActivityStep, ActivityTrace, type ActivityTraceProps, 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 AssistantMessageTablesSlotProps, 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, AvatarStack, type AvatarStackProps, type BiChatConfig, BiChatLayout, type BiChatLayoutProps, type BichatRPC, Bubble, type BubbleContentProps, type BubbleFooterProps, type BubbleHeaderProps, type BubbleMetadataProps, type BubbleRootProps, type BubbleVariant, CHART_VISUAL, ChartCard, type ChartCardHost, type ChartData, type ChartSeries, type ChatDataSource, ChatHeader, type ChatInputStateValue, ChatMachine, type ChatMachineConfig, type ChatMessagingStateValue, ChatSession, type ChatSessionContextValue, type ChatSessionProps, ChatSessionProvider, type ChatSessionProviderProps, type ChatSessionStateValue, type Citation$1 as Citation, MemoizedCodeBlock as CodeBlock, type CodeOutput$1 as CodeOutput, CodeOutputsPanel, type ColumnMeta, type ColumnStats, type ColumnType, CompactionDoodle, ConfigProvider, ConfirmModal, type ConfirmModalProps, ConfirmationStep, type ConversationTurn$1 as ConversationTurn, type DataTableOptions, DateGroupHeader, DebugPanel, type DebugPanelProps, DefaultErrorContent, DownloadCard, MemoizedEditableText as EditableText, type EditableTextProps, type EditableTextRef, MemoizedEmptyState as EmptyState, type EmptyStateProps, ErrorBoundary, type FileValidationError, type FileVisual, type FormattedCell, HttpDataSource, type HttpDataSourceConfig, type ImageAttachment, type ImageLoadingStatus, ImageModal, InlineQuestionForm, InteractiveTableCard, type IotaContext, IotaContextProvider, ListItemSkeleton, MemoizedLoadingSpinner as LoadingSpinner, type LocaleContext, MemoizedMarkdownRenderer as MarkdownRenderer, MessageActions, MessageInput, type MessageInputProps, type MessageInputRef, MessageList, MessageRole, type MessageTransport, ModelSelector, 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, type RenderTableData, type RenderTableExport, RetryActionArea, ScreenReaderAnnouncer, ScrollToBottomButton, MemoizedSearchInput as SearchInput, type SearchInputProps, type Session$1 as Session, type SessionAccess$1 as SessionAccess, type SessionArtifact, SessionArtifactList, SessionArtifactPreview, SessionArtifactsPanel, type SessionGroup, SessionItem, type SessionListResult$1 as SessionListResult, type SessionMember$1 as SessionMember, SessionMembersModal, type SessionMembersModalProps, SessionSkeleton, type SessionStore, type SessionUser$1 as SessionUser, type ShortcutConfig, Sidebar, type SidebarDrawerProps, type SidebarProps, MemoizedSkeleton as Skeleton, SkeletonAvatar, SkeletonCard, SkeletonGroup, type SkeletonGroupProps, type SkeletonProps, SkeletonText, SkipLink, Slot, type SlotProps, type SortState, SourcesPanel, type StreamChunk, StreamError, type StreamEvent, StreamingCursor, SystemMessage, TabbedChartGroup, type TabbedChartGroupProps, TabbedTableGroup, type TabbedTableGroupProps, type TableCardHost, TableExportButton, TableWithExport, type TenantContext, type Theme, type ThemeBorderRadius, type ThemeColors, ThemeProvider, type ThemeSpacing, Toast, type ToastAction, 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 UseBichatRouterParams, type UseBichatRouterReturn, type UseDataTableReturn, 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, getToolLabel, getValidChildren, groupSessionsByDate, groupSteps, hasPermission, isImageMimeType, isPermissionDeniedError, lightTheme, listItemVariants, messageContainerVariants, messageVariants, parseBichatStream, parseBichatStreamEvents, parseSSEStream, scaleFadeVariants, sessionItemVariants, staggerContainerVariants, toErrorDisplay, typingDotVariants, useActionButtonContext, useAttachments, useAutoScroll, useAvatarContext, useBichatRouter, useBubbleContext, useChatInput, useChatMessaging, useChatSession, useConfig, useDataTable, useFocusTrap, useHttpDataSourceConfigFromApplet, useImageGallery, useIotaContext, useKeyboardShortcuts, useLongPress, useMarkdownCopy, useMessageActions, useModalLock, useOptionalChatMessaging, useRequiredConfig, useScrollToBottom, useSidebarState, useStreaming, useTheme, useToast, useTranslation, useTurnContext, validateAttachmentFile, validateFileCount, validateImageFile, verbTransitionVariants };
4415
+ /**
4416
+ * Utilities for splitting accumulated assistant content into the distinct
4417
+ * text blocks the server emitted.
4418
+ *
4419
+ * Background: the executor interleaves text with tool calls within one
4420
+ * turn — `text → tool_call → text → tool_call → final_text`. Before the
4421
+ * backend emitted `text_block_end` markers (iota-uz/iota-sdk#732 M1),
4422
+ * all text segments collapsed into one paragraph on the client. Now the
4423
+ * server emits a `text_block_end` event before each tool_start and at
4424
+ * snapshot time carries byte offsets in `partialMetadata.text_block_offsets`.
4425
+ *
4426
+ * `splitIntoTextBlocks` is the client-side inverse: given the
4427
+ * accumulated content string and the ordered list of byte offsets that
4428
+ * mark segment ends, return one entry per segment. The trailing un-closed
4429
+ * segment (if any) is included as the last entry.
4430
+ */
4431
+ interface AssistantTextBlock {
4432
+ /** Zero-based index matching the seq carried on text_block_end events. */
4433
+ seq: number;
4434
+ /** Markdown source for this segment. */
4435
+ content: string;
4436
+ }
4437
+ /**
4438
+ * Split an accumulated assistant content string into blocks using byte
4439
+ * offsets emitted by the server. Offsets are EXCLUSIVE end markers —
4440
+ * i.e. `offsets[0]` is the length of block 0.
4441
+ *
4442
+ * - When `offsets` is empty or undefined, returns a single block with
4443
+ * the full content.
4444
+ * - When offsets are provided but content is shorter than the last
4445
+ * offset (e.g. stale metadata), offsets beyond the content length are
4446
+ * clamped so no crash propagates up.
4447
+ * - Trailing content after the last offset is included as an extra
4448
+ * block (the un-closed segment during streaming / the final segment
4449
+ * after the last tool call).
4450
+ */
4451
+ declare function splitIntoTextBlocks(content: string, offsets?: ReadonlyArray<number> | null): AssistantTextBlock[];
4452
+ /**
4453
+ * Normalise partialMetadata.text_block_offsets from a StreamSnapshotPayload
4454
+ * into a number[]. Guards against malformed server data (non-array,
4455
+ * non-numeric entries) so UI code never has to think about shapes.
4456
+ */
4457
+ declare function readTextBlockOffsets(partialMetadata?: Record<string, unknown> | null): number[];
4458
+
4459
+ /**
4460
+ * Hand-mirrored copy of the backend's pkg/httpdto.StreamEventType
4461
+ * constant set. Used by subscribeRunEvents / subscribeActiveRuns /
4462
+ * openManagedEventSource to register addEventListener handlers that
4463
+ * match every `event:` label the server emits.
4464
+ *
4465
+ * Drift between this file and the Go definition is caught by
4466
+ * eventNames.test.ts — the test reads the sibling Go source at test
4467
+ * time and diffs the constant set. When the Go file is absent (CI
4468
+ * without the SDK sidecar checkout) the drift guard self-skips.
4469
+ */
4470
+ declare const STREAM_EVENT_TYPES: readonly ["chunk", "content", "thinking", "tool_start", "tool_end", "text_block_end", "snapshot", "interrupt", "citation", "usage", "ping", "stream_started", "done", "cancelled", "error", "failed"];
4471
+ type StreamEventType = typeof STREAM_EVENT_TYPES[number];
4472
+ /**
4473
+ * Subset of {@link STREAM_EVENT_TYPES} that terminates a run from the
4474
+ * client's perspective. Callers should close the EventSource and
4475
+ * settle their promise on any of these.
4476
+ */
4477
+ declare const TERMINAL_STREAM_EVENT_TYPES: readonly ["done", "cancelled", "error", "failed"];
4478
+ type TerminalStreamEventType = typeof TERMINAL_STREAM_EVENT_TYPES[number];
4479
+ /**
4480
+ * Narrow + type-guard helper. Returns true when `name` is one of the
4481
+ * terminal stream event types. The guard narrows precisely to the
4482
+ * terminal subset — callers receiving `true` get {@link TerminalStreamEventType},
4483
+ * not the full {@link StreamEventType} union.
4484
+ */
4485
+ declare function isTerminalEvent(name: string): name is TerminalStreamEventType;
4486
+
4487
+ export { ATTACHMENT_ACCEPT_ATTRIBUTE, ActionButton, type ActionButtonIconProps, type ActionButtonLabelProps, type ActionButtonRootProps, type ActionButtonTooltipProps, type ActiveRunDelivery, type ActiveRunSnapshot, type ActiveTab, type ActivityStep, ActivityTrace, type ActivityTraceProps, 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 AssistantMessageTablesSlotProps, type AssistantTextBlock, 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, AvatarStack, type AvatarStackProps, type BiChatConfig, BiChatLayout, type BiChatLayoutProps, type BichatRPC, Bubble, type BubbleContentProps, type BubbleFooterProps, type BubbleHeaderProps, type BubbleMetadataProps, type BubbleRootProps, type BubbleVariant, CHART_VISUAL, ChartCard, type ChartCardHost, type ChartData, type ChartSeries, type ChatDataSource, ChatHeader, type ChatInputStateValue, ChatMachine, type ChatMachineConfig, type ChatMessagingStateValue, ChatSession, type ChatSessionContextValue, type ChatSessionProps, ChatSessionProvider, type ChatSessionProviderProps, type ChatSessionStateValue, type Citation$1 as Citation, MemoizedCodeBlock as CodeBlock, type CodeOutput$1 as CodeOutput, CodeOutputsPanel, type ColumnMeta, type ColumnStats, type ColumnType, CompactionDoodle, ConfigProvider, ConfirmModal, type ConfirmModalProps, ConfirmationStep, type ConversationTurn$1 as ConversationTurn, type DataTableOptions, DateGroupHeader, DebugPanel, type DebugPanelProps, DefaultErrorContent, DownloadCard, MemoizedEditableText as EditableText, type EditableTextProps, type EditableTextRef, MemoizedEmptyState as EmptyState, type EmptyStateProps, ErrorBoundary, type FileValidationError, type FileVisual, type FormattedCell, HttpDataSource, type HttpDataSourceConfig, type ImageAttachment, type ImageLoadingStatus, ImageModal, InlineQuestionForm, InteractiveTableCard, type IotaContext, IotaContextProvider, ListItemSkeleton, MemoizedLoadingSpinner as LoadingSpinner, type LocaleContext, MemoizedMarkdownRenderer as MarkdownRenderer, MessageActions, MessageInput, type MessageInputProps, type MessageInputRef, MessageList, MessageRole, type MessageTransport, ModelSelector, 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, type RenderTableData, type RenderTableExport, RetryActionArea, RunEventsConnectError, STREAM_EVENT_TYPES, ScreenReaderAnnouncer, ScrollToBottomButton, MemoizedSearchInput as SearchInput, type SearchInputProps, type Session$1 as Session, type SessionAccess$1 as SessionAccess, type SessionArtifact, SessionArtifactList, SessionArtifactPreview, SessionArtifactsPanel, type SessionGroup, SessionItem, type SessionListResult$1 as SessionListResult, type SessionMember$1 as SessionMember, SessionMembersModal, type SessionMembersModalProps, SessionSkeleton, type SessionStore, type SessionUser$1 as SessionUser, type ShortcutConfig, Sidebar, type SidebarDrawerProps, type SidebarProps, MemoizedSkeleton as Skeleton, SkeletonAvatar, SkeletonCard, SkeletonGroup, type SkeletonGroupProps, type SkeletonProps, SkeletonText, SkipLink, Slot, type SlotProps, type SortState, SourcesPanel, type StreamChunk, StreamError, type StreamEvent, type StreamEventType, StreamingCursor, SystemMessage, TERMINAL_STREAM_EVENT_TYPES, TabbedChartGroup, type TabbedChartGroupProps, TabbedTableGroup, type TabbedTableGroupProps, type TableCardHost, TableExportButton, TableWithExport, type TenantContext, type TerminalStreamEventType, type Theme, type ThemeBorderRadius, type ThemeColors, ThemeProvider, type ThemeSpacing, Toast, type ToastAction, 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 UseActiveRunsOptions, type UseActiveRunsResult, type UseAttachmentsOptions, type UseAttachmentsReturn, type UseAutoScrollOptions, type UseAutoScrollReturn, type UseBichatRouterParams, type UseBichatRouterReturn, type UseDataTableReturn, 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, getToolLabel, getValidChildren, groupSessionsByDate, groupSteps, hasPermission, isImageMimeType, isPermissionDeniedError, isTerminalEvent, lightTheme, listItemVariants, messageContainerVariants, messageVariants, parseBichatStream, parseBichatStreamEvents, parseSSEStream, readTextBlockOffsets, scaleFadeVariants, sessionItemVariants, splitIntoTextBlocks, staggerContainerVariants, toErrorDisplay, typingDotVariants, useActionButtonContext, useActiveRuns, useAttachments, useAutoScroll, useAvatarContext, useBichatRouter, useBubbleContext, useChatInput, useChatMessaging, useChatSession, useConfig, useDataTable, useFocusTrap, useHttpDataSourceConfigFromApplet, useImageGallery, useIotaContext, useKeyboardShortcuts, useLongPress, useMarkdownCopy, useMessageActions, useModalLock, useOptionalChatMessaging, useRequiredConfig, useScrollToBottom, useSidebarState, useStreaming, useTheme, useToast, useTranslation, useTurnContext, validateAttachmentFile, validateFileCount, validateImageFile, verbTransitionVariants };
@@ -370,6 +370,9 @@ type StreamEvent = {
370
370
  type: "interrupt";
371
371
  interrupt: StreamInterruptPayload;
372
372
  sessionId?: string;
373
+ } | {
374
+ type: "text_block_end";
375
+ seq: number;
373
376
  } | {
374
377
  type: "done";
375
378
  sessionId?: string;
@@ -402,7 +405,7 @@ interface AsyncRunAccepted {
402
405
  * compatibility but the flat all-optional shape is unsound.
403
406
  */
404
407
  interface StreamChunk {
405
- type: "chunk" | "content" | "thinking" | "tool_start" | "tool_end" | "usage" | "done" | "error" | "user_message" | "interrupt" | "snapshot" | "stream_started";
408
+ type: "chunk" | "content" | "thinking" | "tool_start" | "tool_end" | "usage" | "done" | "error" | "user_message" | "interrupt" | "snapshot" | "stream_started" | "text_block_end";
406
409
  content?: string;
407
410
  error?: string;
408
411
  sessionId?: string;
@@ -414,6 +417,27 @@ interface StreamChunk {
414
417
  snapshot?: StreamSnapshotPayload;
415
418
  /** Set when type is 'stream_started'; client should store for refresh-safe resume */
416
419
  runId?: string;
420
+ /**
421
+ * Zero-based ordinal of the assistant text segment that just ended.
422
+ * Populated only when type === "text_block_end". Used to split the
423
+ * accumulated assistant content into distinct blocks interleaved with
424
+ * tool_call UI (text → tool → text → tool → final_text).
425
+ */
426
+ textBlockSeq?: number;
427
+ }
428
+ /**
429
+ * Per-tenant active-run status event. Delivered via the
430
+ * GET /bi-chat/stream/active-runs SSE endpoint. The first batch after
431
+ * connect carries `event === "snapshot"` for each currently-running
432
+ * session; subsequent rows carry `event === "update"` as runs
433
+ * transition (queued → streaming → completed / cancelled / failed).
434
+ */
435
+ interface ActiveRunDelivery {
436
+ event: "snapshot" | "update";
437
+ sessionId: string;
438
+ runId: string;
439
+ status: "queued" | "streaming" | "completed" | "cancelled" | "failed";
440
+ updatedAt: number;
417
441
  }
418
442
  interface StreamInterruptPayload {
419
443
  checkpointId: string;
@@ -531,6 +555,13 @@ interface SendMessageOptions {
531
555
  replaceFromMessageID?: string;
532
556
  reasoningEffort?: string;
533
557
  model?: string;
558
+ /**
559
+ * Client-generated idempotency key. Duplicate sends sharing the same
560
+ * requestId within the backend's dedupe window (~30 min) converge on
561
+ * a single server-side run. Omit to disable dedupe for a particular
562
+ * send; the data source auto-generates one per call otherwise.
563
+ */
564
+ requestId?: string;
534
565
  }
535
566
  interface SessionListResult$1 {
536
567
  sessions: Session$1[];
@@ -617,6 +648,32 @@ interface ChatDataSource {
617
648
  * Optional; if absent, resume is not supported.
618
649
  */
619
650
  resumeStream?(sessionId: string, runId: string, onChunk: (chunk: StreamChunk) => void, signal?: AbortSignal): Promise<void>;
651
+ /**
652
+ * Tail a run via native EventSource against GET /stream/events. Honours
653
+ * Last-Event-ID for auto-reconnect on wifi drops / tab sleep. Prefer
654
+ * over resumeStream when connecting to a run that was started by
655
+ * another tab (same request_id) or that needs to survive a reload
656
+ * via cursor-based replay. Optional; data sources that don't
657
+ * implement it fall back to resumeStream.
658
+ */
659
+ subscribeRunEvents?(sessionId: string, runId: string, options: {
660
+ lastEventId?: string;
661
+ onChunk: (chunk: StreamChunk) => void;
662
+ onError?: (event: Event) => void;
663
+ signal?: AbortSignal;
664
+ }): Promise<void>;
665
+ /**
666
+ * Subscribe to the per-tenant active-run fan-out
667
+ * (GET /stream/active-runs). Emits one "snapshot" event per
668
+ * currently-running session on connect, then live "update" deltas.
669
+ * Optional; data sources that don't implement it fall back to
670
+ * per-session polling via getStreamStatus.
671
+ */
672
+ subscribeActiveRuns?(options: {
673
+ onEvent: (event: ActiveRunDelivery) => void;
674
+ onError?: (event: Event) => void;
675
+ signal?: AbortSignal;
676
+ }): Promise<void>;
620
677
  listSessions(options?: {
621
678
  limit?: number;
622
679
  offset?: number;
@@ -2293,6 +2350,54 @@ declare function useStreaming(options?: UseStreamingOptions): {
2293
2350
  reset: () => void;
2294
2351
  };
2295
2352
 
2353
+ /**
2354
+ * useActiveRuns — live map of per-session generation status.
2355
+ *
2356
+ * Subscribes to the data source's `subscribeActiveRuns` channel
2357
+ * (`GET /bi-chat/stream/active-runs`) and maintains a
2358
+ * sessionId → status dictionary so the sidebar can render a status
2359
+ * dot next to each session card without polling /stream/status per
2360
+ * session.
2361
+ *
2362
+ * The hook is a no-op when:
2363
+ * - the data source does not implement subscribeActiveRuns (older
2364
+ * backends without the active-run index);
2365
+ * - `enabled` is false (e.g. the user is offline).
2366
+ */
2367
+
2368
+ interface ActiveRunSnapshot {
2369
+ runId: string;
2370
+ status: ActiveRunDelivery['status'];
2371
+ updatedAt: number;
2372
+ }
2373
+ interface UseActiveRunsOptions {
2374
+ enabled?: boolean;
2375
+ /** Optional hook for raw SSE errors. */
2376
+ onError?: (event: Event) => void;
2377
+ /**
2378
+ * Keep terminal-status entries in the map for this many milliseconds
2379
+ * before pruning them. Default 0 preserves the previous behaviour
2380
+ * (synchronous delete). Useful when consumers want to render a
2381
+ * "completed" pulse animation before the dot disappears.
2382
+ */
2383
+ retainTerminalMs?: number;
2384
+ /**
2385
+ * How long to wait for an initial snapshot batch before declaring
2386
+ * the hook `ready` when the server has zero active runs.
2387
+ * Default 250ms.
2388
+ */
2389
+ emptyStateTimeoutMs?: number;
2390
+ }
2391
+ interface UseActiveRunsResult {
2392
+ /** sessionId → current live status. Terminal statuses are emitted then the entry is removed. */
2393
+ runs: Record<string, ActiveRunSnapshot>;
2394
+ /** True once the initial HGETALL snapshot is delivered. */
2395
+ ready: boolean;
2396
+ /** Convenience: undefined when not active. */
2397
+ status: (sessionId: string) => ActiveRunDelivery['status'] | undefined;
2398
+ }
2399
+ declare function useActiveRuns(dataSource: Pick<ChatDataSource, 'subscribeActiveRuns'>, options?: UseActiveRunsOptions): UseActiveRunsResult;
2400
+
2296
2401
  /**
2297
2402
  * Translation hook using locale from IotaContext
2298
2403
  */
@@ -3131,6 +3236,39 @@ interface SessionState {
3131
3236
  pendingQuestion?: PendingQuestion$1 | null;
3132
3237
  }
3133
3238
 
3239
+ /**
3240
+ * Message sending, SSE streaming, and HITL question handling.
3241
+ *
3242
+ * @internal — Not part of the public API. Consumed by HttpDataSource.
3243
+ */
3244
+
3245
+ /**
3246
+ * Thrown by {@link subscribeRunEvents} when the underlying EventSource
3247
+ * emits `onerror` before the first event arrives within the
3248
+ * initial-connect grace window. Distinguishes boundary failures
3249
+ * (401 / 404 / 503) from transient mid-run flaps, which the browser's
3250
+ * native auto-reconnect continues to handle silently.
3251
+ */
3252
+ declare class RunEventsConnectError extends Error {
3253
+ readonly cause?: Event;
3254
+ constructor(message: string, cause?: Event);
3255
+ }
3256
+ interface SubscribeRunEventsOptions {
3257
+ /** When set, start from the last seen event id instead of a full replay. */
3258
+ lastEventId?: string;
3259
+ /** Fires for every chunk (content / tool / snapshot / done / error / …). */
3260
+ onChunk: (chunk: StreamChunk) => void;
3261
+ /** Optional hook for raw SSE errors (connection blips, parse failures). */
3262
+ onError?: (event: Event) => void;
3263
+ /** AbortSignal closes the underlying EventSource. */
3264
+ signal?: AbortSignal;
3265
+ }
3266
+ interface SubscribeActiveRunsOptions {
3267
+ onEvent: (event: ActiveRunDelivery) => void;
3268
+ onError?: (event: Event) => void;
3269
+ signal?: AbortSignal;
3270
+ }
3271
+
3134
3272
  /**
3135
3273
  * Built-in HTTP data source with SSE streaming and AbortController
3136
3274
  * Implements ChatDataSource interface with real HTTP/RPC calls
@@ -3204,6 +3342,21 @@ declare class HttpDataSource implements ChatDataSource {
3204
3342
  stopGeneration(sessionId: string): Promise<void>;
3205
3343
  getStreamStatus(sessionId: string): Promise<StreamStatus | null>;
3206
3344
  resumeStream(sessionId: string, runId: string, onChunk: (chunk: StreamChunk) => void, signal?: AbortSignal): Promise<void>;
3345
+ /**
3346
+ * Open a native EventSource against GET /stream/events for the given
3347
+ * run. Used by components that want browser-native auto-reconnect
3348
+ * with Last-Event-ID (tab close, wifi drop, device switch). Prefer
3349
+ * over resumeStream when tailing an already-running generation that
3350
+ * another tab started.
3351
+ */
3352
+ subscribeRunEvents(sessionId: string, runId: string, options: SubscribeRunEventsOptions): Promise<void>;
3353
+ /**
3354
+ * Subscribe to the per-tenant active-run fan-out
3355
+ * (GET /stream/active-runs). Never resolves until the caller aborts
3356
+ * via the signal; use from a top-level component (sidebar container)
3357
+ * that mounts for the lifetime of the chat app.
3358
+ */
3359
+ subscribeActiveRuns(options: SubscribeActiveRunsOptions): Promise<void>;
3207
3360
  sendMessage(sessionId: string, content: string, attachments?: Attachment$1[], signal?: AbortSignal, options?: SendMessageOptions): AsyncGenerator<StreamChunk>;
3208
3361
  cancelStream(): void;
3209
3362
  submitQuestionAnswers(sessionId: string, questionId: string, answers: QuestionAnswers): Promise<{
@@ -4259,4 +4412,76 @@ declare function isPermissionDeniedError(error: unknown): boolean;
4259
4412
  */
4260
4413
  declare function toErrorDisplay(error: unknown, fallbackTitle: string): RPCErrorDisplay;
4261
4414
 
4262
- export { ATTACHMENT_ACCEPT_ATTRIBUTE, ActionButton, type ActionButtonIconProps, type ActionButtonLabelProps, type ActionButtonRootProps, type ActionButtonTooltipProps, type ActiveTab, type ActivityStep, ActivityTrace, type ActivityTraceProps, 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 AssistantMessageTablesSlotProps, 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, AvatarStack, type AvatarStackProps, type BiChatConfig, BiChatLayout, type BiChatLayoutProps, type BichatRPC, Bubble, type BubbleContentProps, type BubbleFooterProps, type BubbleHeaderProps, type BubbleMetadataProps, type BubbleRootProps, type BubbleVariant, CHART_VISUAL, ChartCard, type ChartCardHost, type ChartData, type ChartSeries, type ChatDataSource, ChatHeader, type ChatInputStateValue, ChatMachine, type ChatMachineConfig, type ChatMessagingStateValue, ChatSession, type ChatSessionContextValue, type ChatSessionProps, ChatSessionProvider, type ChatSessionProviderProps, type ChatSessionStateValue, type Citation$1 as Citation, MemoizedCodeBlock as CodeBlock, type CodeOutput$1 as CodeOutput, CodeOutputsPanel, type ColumnMeta, type ColumnStats, type ColumnType, CompactionDoodle, ConfigProvider, ConfirmModal, type ConfirmModalProps, ConfirmationStep, type ConversationTurn$1 as ConversationTurn, type DataTableOptions, DateGroupHeader, DebugPanel, type DebugPanelProps, DefaultErrorContent, DownloadCard, MemoizedEditableText as EditableText, type EditableTextProps, type EditableTextRef, MemoizedEmptyState as EmptyState, type EmptyStateProps, ErrorBoundary, type FileValidationError, type FileVisual, type FormattedCell, HttpDataSource, type HttpDataSourceConfig, type ImageAttachment, type ImageLoadingStatus, ImageModal, InlineQuestionForm, InteractiveTableCard, type IotaContext, IotaContextProvider, ListItemSkeleton, MemoizedLoadingSpinner as LoadingSpinner, type LocaleContext, MemoizedMarkdownRenderer as MarkdownRenderer, MessageActions, MessageInput, type MessageInputProps, type MessageInputRef, MessageList, MessageRole, type MessageTransport, ModelSelector, 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, type RenderTableData, type RenderTableExport, RetryActionArea, ScreenReaderAnnouncer, ScrollToBottomButton, MemoizedSearchInput as SearchInput, type SearchInputProps, type Session$1 as Session, type SessionAccess$1 as SessionAccess, type SessionArtifact, SessionArtifactList, SessionArtifactPreview, SessionArtifactsPanel, type SessionGroup, SessionItem, type SessionListResult$1 as SessionListResult, type SessionMember$1 as SessionMember, SessionMembersModal, type SessionMembersModalProps, SessionSkeleton, type SessionStore, type SessionUser$1 as SessionUser, type ShortcutConfig, Sidebar, type SidebarDrawerProps, type SidebarProps, MemoizedSkeleton as Skeleton, SkeletonAvatar, SkeletonCard, SkeletonGroup, type SkeletonGroupProps, type SkeletonProps, SkeletonText, SkipLink, Slot, type SlotProps, type SortState, SourcesPanel, type StreamChunk, StreamError, type StreamEvent, StreamingCursor, SystemMessage, TabbedChartGroup, type TabbedChartGroupProps, TabbedTableGroup, type TabbedTableGroupProps, type TableCardHost, TableExportButton, TableWithExport, type TenantContext, type Theme, type ThemeBorderRadius, type ThemeColors, ThemeProvider, type ThemeSpacing, Toast, type ToastAction, 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 UseBichatRouterParams, type UseBichatRouterReturn, type UseDataTableReturn, 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, getToolLabel, getValidChildren, groupSessionsByDate, groupSteps, hasPermission, isImageMimeType, isPermissionDeniedError, lightTheme, listItemVariants, messageContainerVariants, messageVariants, parseBichatStream, parseBichatStreamEvents, parseSSEStream, scaleFadeVariants, sessionItemVariants, staggerContainerVariants, toErrorDisplay, typingDotVariants, useActionButtonContext, useAttachments, useAutoScroll, useAvatarContext, useBichatRouter, useBubbleContext, useChatInput, useChatMessaging, useChatSession, useConfig, useDataTable, useFocusTrap, useHttpDataSourceConfigFromApplet, useImageGallery, useIotaContext, useKeyboardShortcuts, useLongPress, useMarkdownCopy, useMessageActions, useModalLock, useOptionalChatMessaging, useRequiredConfig, useScrollToBottom, useSidebarState, useStreaming, useTheme, useToast, useTranslation, useTurnContext, validateAttachmentFile, validateFileCount, validateImageFile, verbTransitionVariants };
4415
+ /**
4416
+ * Utilities for splitting accumulated assistant content into the distinct
4417
+ * text blocks the server emitted.
4418
+ *
4419
+ * Background: the executor interleaves text with tool calls within one
4420
+ * turn — `text → tool_call → text → tool_call → final_text`. Before the
4421
+ * backend emitted `text_block_end` markers (iota-uz/iota-sdk#732 M1),
4422
+ * all text segments collapsed into one paragraph on the client. Now the
4423
+ * server emits a `text_block_end` event before each tool_start and at
4424
+ * snapshot time carries byte offsets in `partialMetadata.text_block_offsets`.
4425
+ *
4426
+ * `splitIntoTextBlocks` is the client-side inverse: given the
4427
+ * accumulated content string and the ordered list of byte offsets that
4428
+ * mark segment ends, return one entry per segment. The trailing un-closed
4429
+ * segment (if any) is included as the last entry.
4430
+ */
4431
+ interface AssistantTextBlock {
4432
+ /** Zero-based index matching the seq carried on text_block_end events. */
4433
+ seq: number;
4434
+ /** Markdown source for this segment. */
4435
+ content: string;
4436
+ }
4437
+ /**
4438
+ * Split an accumulated assistant content string into blocks using byte
4439
+ * offsets emitted by the server. Offsets are EXCLUSIVE end markers —
4440
+ * i.e. `offsets[0]` is the length of block 0.
4441
+ *
4442
+ * - When `offsets` is empty or undefined, returns a single block with
4443
+ * the full content.
4444
+ * - When offsets are provided but content is shorter than the last
4445
+ * offset (e.g. stale metadata), offsets beyond the content length are
4446
+ * clamped so no crash propagates up.
4447
+ * - Trailing content after the last offset is included as an extra
4448
+ * block (the un-closed segment during streaming / the final segment
4449
+ * after the last tool call).
4450
+ */
4451
+ declare function splitIntoTextBlocks(content: string, offsets?: ReadonlyArray<number> | null): AssistantTextBlock[];
4452
+ /**
4453
+ * Normalise partialMetadata.text_block_offsets from a StreamSnapshotPayload
4454
+ * into a number[]. Guards against malformed server data (non-array,
4455
+ * non-numeric entries) so UI code never has to think about shapes.
4456
+ */
4457
+ declare function readTextBlockOffsets(partialMetadata?: Record<string, unknown> | null): number[];
4458
+
4459
+ /**
4460
+ * Hand-mirrored copy of the backend's pkg/httpdto.StreamEventType
4461
+ * constant set. Used by subscribeRunEvents / subscribeActiveRuns /
4462
+ * openManagedEventSource to register addEventListener handlers that
4463
+ * match every `event:` label the server emits.
4464
+ *
4465
+ * Drift between this file and the Go definition is caught by
4466
+ * eventNames.test.ts — the test reads the sibling Go source at test
4467
+ * time and diffs the constant set. When the Go file is absent (CI
4468
+ * without the SDK sidecar checkout) the drift guard self-skips.
4469
+ */
4470
+ declare const STREAM_EVENT_TYPES: readonly ["chunk", "content", "thinking", "tool_start", "tool_end", "text_block_end", "snapshot", "interrupt", "citation", "usage", "ping", "stream_started", "done", "cancelled", "error", "failed"];
4471
+ type StreamEventType = typeof STREAM_EVENT_TYPES[number];
4472
+ /**
4473
+ * Subset of {@link STREAM_EVENT_TYPES} that terminates a run from the
4474
+ * client's perspective. Callers should close the EventSource and
4475
+ * settle their promise on any of these.
4476
+ */
4477
+ declare const TERMINAL_STREAM_EVENT_TYPES: readonly ["done", "cancelled", "error", "failed"];
4478
+ type TerminalStreamEventType = typeof TERMINAL_STREAM_EVENT_TYPES[number];
4479
+ /**
4480
+ * Narrow + type-guard helper. Returns true when `name` is one of the
4481
+ * terminal stream event types. The guard narrows precisely to the
4482
+ * terminal subset — callers receiving `true` get {@link TerminalStreamEventType},
4483
+ * not the full {@link StreamEventType} union.
4484
+ */
4485
+ declare function isTerminalEvent(name: string): name is TerminalStreamEventType;
4486
+
4487
+ export { ATTACHMENT_ACCEPT_ATTRIBUTE, ActionButton, type ActionButtonIconProps, type ActionButtonLabelProps, type ActionButtonRootProps, type ActionButtonTooltipProps, type ActiveRunDelivery, type ActiveRunSnapshot, type ActiveTab, type ActivityStep, ActivityTrace, type ActivityTraceProps, 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 AssistantMessageTablesSlotProps, type AssistantTextBlock, 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, AvatarStack, type AvatarStackProps, type BiChatConfig, BiChatLayout, type BiChatLayoutProps, type BichatRPC, Bubble, type BubbleContentProps, type BubbleFooterProps, type BubbleHeaderProps, type BubbleMetadataProps, type BubbleRootProps, type BubbleVariant, CHART_VISUAL, ChartCard, type ChartCardHost, type ChartData, type ChartSeries, type ChatDataSource, ChatHeader, type ChatInputStateValue, ChatMachine, type ChatMachineConfig, type ChatMessagingStateValue, ChatSession, type ChatSessionContextValue, type ChatSessionProps, ChatSessionProvider, type ChatSessionProviderProps, type ChatSessionStateValue, type Citation$1 as Citation, MemoizedCodeBlock as CodeBlock, type CodeOutput$1 as CodeOutput, CodeOutputsPanel, type ColumnMeta, type ColumnStats, type ColumnType, CompactionDoodle, ConfigProvider, ConfirmModal, type ConfirmModalProps, ConfirmationStep, type ConversationTurn$1 as ConversationTurn, type DataTableOptions, DateGroupHeader, DebugPanel, type DebugPanelProps, DefaultErrorContent, DownloadCard, MemoizedEditableText as EditableText, type EditableTextProps, type EditableTextRef, MemoizedEmptyState as EmptyState, type EmptyStateProps, ErrorBoundary, type FileValidationError, type FileVisual, type FormattedCell, HttpDataSource, type HttpDataSourceConfig, type ImageAttachment, type ImageLoadingStatus, ImageModal, InlineQuestionForm, InteractiveTableCard, type IotaContext, IotaContextProvider, ListItemSkeleton, MemoizedLoadingSpinner as LoadingSpinner, type LocaleContext, MemoizedMarkdownRenderer as MarkdownRenderer, MessageActions, MessageInput, type MessageInputProps, type MessageInputRef, MessageList, MessageRole, type MessageTransport, ModelSelector, 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, type RenderTableData, type RenderTableExport, RetryActionArea, RunEventsConnectError, STREAM_EVENT_TYPES, ScreenReaderAnnouncer, ScrollToBottomButton, MemoizedSearchInput as SearchInput, type SearchInputProps, type Session$1 as Session, type SessionAccess$1 as SessionAccess, type SessionArtifact, SessionArtifactList, SessionArtifactPreview, SessionArtifactsPanel, type SessionGroup, SessionItem, type SessionListResult$1 as SessionListResult, type SessionMember$1 as SessionMember, SessionMembersModal, type SessionMembersModalProps, SessionSkeleton, type SessionStore, type SessionUser$1 as SessionUser, type ShortcutConfig, Sidebar, type SidebarDrawerProps, type SidebarProps, MemoizedSkeleton as Skeleton, SkeletonAvatar, SkeletonCard, SkeletonGroup, type SkeletonGroupProps, type SkeletonProps, SkeletonText, SkipLink, Slot, type SlotProps, type SortState, SourcesPanel, type StreamChunk, StreamError, type StreamEvent, type StreamEventType, StreamingCursor, SystemMessage, TERMINAL_STREAM_EVENT_TYPES, TabbedChartGroup, type TabbedChartGroupProps, TabbedTableGroup, type TabbedTableGroupProps, type TableCardHost, TableExportButton, TableWithExport, type TenantContext, type TerminalStreamEventType, type Theme, type ThemeBorderRadius, type ThemeColors, ThemeProvider, type ThemeSpacing, Toast, type ToastAction, 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 UseActiveRunsOptions, type UseActiveRunsResult, type UseAttachmentsOptions, type UseAttachmentsReturn, type UseAutoScrollOptions, type UseAutoScrollReturn, type UseBichatRouterParams, type UseBichatRouterReturn, type UseDataTableReturn, 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, getToolLabel, getValidChildren, groupSessionsByDate, groupSteps, hasPermission, isImageMimeType, isPermissionDeniedError, isTerminalEvent, lightTheme, listItemVariants, messageContainerVariants, messageVariants, parseBichatStream, parseBichatStreamEvents, parseSSEStream, readTextBlockOffsets, scaleFadeVariants, sessionItemVariants, splitIntoTextBlocks, staggerContainerVariants, toErrorDisplay, typingDotVariants, useActionButtonContext, useActiveRuns, useAttachments, useAutoScroll, useAvatarContext, useBichatRouter, useBubbleContext, useChatInput, useChatMessaging, useChatSession, useConfig, useDataTable, useFocusTrap, useHttpDataSourceConfigFromApplet, useImageGallery, useIotaContext, useKeyboardShortcuts, useLongPress, useMarkdownCopy, useMessageActions, useModalLock, useOptionalChatMessaging, useRequiredConfig, useScrollToBottom, useSidebarState, useStreaming, useTheme, useToast, useTranslation, useTurnContext, validateAttachmentFile, validateFileCount, validateImageFile, verbTransitionVariants };