@erdoai/ui 0.1.69 → 0.1.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +35 -11
- package/dist/index.d.cts +116 -58
- package/dist/index.d.ts +116 -58
- package/dist/index.js +35 -11
- package/package.json +5 -4
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as React$1 from 'react';
|
|
3
|
-
import React__default from 'react';
|
|
4
|
-
import { ErdoClient, ContentItem, InvokeResult, LogEntry, ToolGroup, InvocationStatus as InvocationStatus$1,
|
|
3
|
+
import React__default, { ReactNode } from 'react';
|
|
4
|
+
import { ErdoClient, ContentItem, InvokeResult, LogEntry, ToolGroup, InvocationStatus as InvocationStatus$1, AgentStreamState, SSEEvent, Thread } from '@erdoai/types';
|
|
5
5
|
export { ContentItem } from '@erdoai/types';
|
|
6
6
|
import * as RechartsPrimitive from 'recharts';
|
|
7
|
+
import { StoreApi } from 'zustand';
|
|
7
8
|
import { ClassValue } from 'clsx';
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -131,9 +132,10 @@ interface ErdoProviderConfig {
|
|
|
131
132
|
*/
|
|
132
133
|
onSuggestionClick?: (suggestion: string) => void;
|
|
133
134
|
/**
|
|
134
|
-
* Enable the
|
|
135
|
-
* When true,
|
|
136
|
-
*
|
|
135
|
+
* Enable the agent event system (flat content model).
|
|
136
|
+
* When true, routes step_started/step_finished and message content events
|
|
137
|
+
* through handleAgentEvent into AgentStreamState.
|
|
138
|
+
* When false (default), uses legacy path-based event routing (bot service).
|
|
137
139
|
*/
|
|
138
140
|
useAgentEvents?: boolean;
|
|
139
141
|
}
|
|
@@ -842,6 +844,7 @@ interface ContentProps {
|
|
|
842
844
|
components?: Record<string, React__default.ComponentType<any>>;
|
|
843
845
|
}
|
|
844
846
|
declare function Content({ content, className, components }: ContentProps): react_jsx_runtime.JSX.Element | null;
|
|
847
|
+
declare function normalizeUIGenerationChunks(value: unknown): ContentChunk[] | null;
|
|
845
848
|
|
|
846
849
|
interface ErdoUIProps {
|
|
847
850
|
/** Result from an Erdo invocation */
|
|
@@ -1005,8 +1008,8 @@ interface ThinkingContentProps {
|
|
|
1005
1008
|
className?: string;
|
|
1006
1009
|
}
|
|
1007
1010
|
/**
|
|
1008
|
-
* Renders Claude's thinking/reasoning content
|
|
1009
|
-
*
|
|
1011
|
+
* Renders Claude's thinking/reasoning content as subtle inline text.
|
|
1012
|
+
* No container/chrome; supports redacted (encrypted) thinking blocks.
|
|
1010
1013
|
*/
|
|
1011
1014
|
declare function ThinkingContent({ item, className }: ThinkingContentProps): react_jsx_runtime.JSX.Element;
|
|
1012
1015
|
|
|
@@ -1085,7 +1088,7 @@ interface CollapsibleCodeBlockProps {
|
|
|
1085
1088
|
/**
|
|
1086
1089
|
* A collapsible code block with syntax highlighting.
|
|
1087
1090
|
*/
|
|
1088
|
-
declare
|
|
1091
|
+
declare const CollapsibleCodeBlock: React$1.NamedExoticComponent<CollapsibleCodeBlockProps>;
|
|
1089
1092
|
|
|
1090
1093
|
interface SqlContentProps {
|
|
1091
1094
|
item: ContentItem;
|
|
@@ -1102,8 +1105,7 @@ interface CodegenContentProps {
|
|
|
1102
1105
|
}
|
|
1103
1106
|
/**
|
|
1104
1107
|
* Renders code generation content with step-by-step explanation, code, and warnings.
|
|
1105
|
-
*
|
|
1106
|
-
* Expects parsedJson to be populated upstream (via normalizeContent or SSE handler).
|
|
1108
|
+
* Prefers canonical `content` (parsed object); falls back to legacy `parsedJson` (DB string path).
|
|
1107
1109
|
*/
|
|
1108
1110
|
declare function CodegenContent({ item, className }: CodegenContentProps): react_jsx_runtime.JSX.Element | null;
|
|
1109
1111
|
|
|
@@ -1113,6 +1115,7 @@ interface CodeexecContentProps {
|
|
|
1113
1115
|
}
|
|
1114
1116
|
/**
|
|
1115
1117
|
* Renders code execution output (stdout, stderr, warnings).
|
|
1118
|
+
* Prefers canonical `content`; falls back to legacy `parsedJson`.
|
|
1116
1119
|
*/
|
|
1117
1120
|
declare function CodeexecContent({ item, className }: CodeexecContentProps): react_jsx_runtime.JSX.Element | null;
|
|
1118
1121
|
|
|
@@ -1282,8 +1285,8 @@ interface MemoryContentProps {
|
|
|
1282
1285
|
declare function MemoryContent({ content, className }: MemoryContentProps): react_jsx_runtime.JSX.Element;
|
|
1283
1286
|
|
|
1284
1287
|
interface StepTreeContentProps {
|
|
1285
|
-
/** The
|
|
1286
|
-
|
|
1288
|
+
/** The agent stream state containing all steps and content */
|
|
1289
|
+
agentState: AgentStreamState;
|
|
1287
1290
|
/** Optional Content component for rendering ui_generation/codegen */
|
|
1288
1291
|
ContentComponent?: React__default.ComponentType<{
|
|
1289
1292
|
content: ContentItem;
|
|
@@ -1296,7 +1299,7 @@ interface StepTreeContentProps {
|
|
|
1296
1299
|
*
|
|
1297
1300
|
* Used for both streaming and reload paths to ensure consistent rendering.
|
|
1298
1301
|
*/
|
|
1299
|
-
declare function StepTreeContent({
|
|
1302
|
+
declare function StepTreeContent({ agentState, ContentComponent, className }: StepTreeContentProps): react_jsx_runtime.JSX.Element | null;
|
|
1300
1303
|
|
|
1301
1304
|
/** Node structure from UI generation content */
|
|
1302
1305
|
interface UINode {
|
|
@@ -1492,6 +1495,42 @@ declare function useMultipleDatasetRequests(requests: DatasetFetchRequest[], inv
|
|
|
1492
1495
|
*/
|
|
1493
1496
|
declare function useMultipleDatasetContents(datasetSlugs: string[], invocationId: string, sqlQueries?: Record<string, string>, resourceKeys?: Record<string, string>): UseDatasetContentsResult[];
|
|
1494
1497
|
|
|
1498
|
+
/**
|
|
1499
|
+
* Zustand store for agent streaming state.
|
|
1500
|
+
*
|
|
1501
|
+
* Holds the global AgentStreamState and per-invocation sliced states.
|
|
1502
|
+
* Components subscribe to individual invocation slices via useInvocationState(),
|
|
1503
|
+
* so only the affected component re-renders when an event arrives.
|
|
1504
|
+
*
|
|
1505
|
+
* The store calls handleAgentEvent internally — consumers just push raw SSE events.
|
|
1506
|
+
*/
|
|
1507
|
+
|
|
1508
|
+
declare function sliceAgentStateToRoot(state: AgentStreamState, rootStepID: string): AgentStreamState;
|
|
1509
|
+
interface AgentStreamStore {
|
|
1510
|
+
/** The single merged state from all events */
|
|
1511
|
+
globalState: AgentStreamState;
|
|
1512
|
+
/** Per-invocation sliced states. Key: invocation_id */
|
|
1513
|
+
invocationStates: Record<string, AgentStreamState>;
|
|
1514
|
+
/** Maps invocation_id → root step_id */
|
|
1515
|
+
invocationRootSteps: Record<string, string>;
|
|
1516
|
+
/** Queue for invocations awaiting their root step_started */
|
|
1517
|
+
pendingInvocationQueue: string[];
|
|
1518
|
+
/**
|
|
1519
|
+
* Push a raw SSE event into the store.
|
|
1520
|
+
* Calls handleAgentEvent internally and re-slices affected invocations.
|
|
1521
|
+
* @param event The raw SSE event
|
|
1522
|
+
* @param reconcile Optional post-processing (e.g., reconcileThinkingContentState)
|
|
1523
|
+
*/
|
|
1524
|
+
pushEvent: (event: SSEEvent, reconcile?: (state: AgentStreamState) => AgentStreamState) => void;
|
|
1525
|
+
/** Register an invocation_id (from agent_invocation event). Queues it for root mapping. */
|
|
1526
|
+
registerInvocation: (invocationId: string) => void;
|
|
1527
|
+
/** Map an invocation_id to its root step_id (from step_started with type: 'agent'). */
|
|
1528
|
+
mapInvocationRoot: (invocationId: string, rootStepId: string) => void;
|
|
1529
|
+
/** Reset the store (new session). */
|
|
1530
|
+
reset: () => void;
|
|
1531
|
+
}
|
|
1532
|
+
declare function createAgentStreamStore(): StoreApi<AgentStreamStore>;
|
|
1533
|
+
|
|
1495
1534
|
interface UseThreadOptions {
|
|
1496
1535
|
/** Initial thread ID to use (if resuming an existing thread) */
|
|
1497
1536
|
threadId?: string;
|
|
@@ -1513,8 +1552,8 @@ interface UseThreadReturn {
|
|
|
1513
1552
|
error: Error | null;
|
|
1514
1553
|
/** Active messages being streamed (with parsedJson populated) */
|
|
1515
1554
|
activeMessages: MessageWithContents[];
|
|
1516
|
-
/**
|
|
1517
|
-
|
|
1555
|
+
/** Agent stream state (flat content model) */
|
|
1556
|
+
agentState: AgentStreamState;
|
|
1518
1557
|
/**
|
|
1519
1558
|
* Flattened, filtered contents ready for rendering with the Content component.
|
|
1520
1559
|
* Only includes visible content (user_visibility === 'visible').
|
|
@@ -1526,6 +1565,8 @@ interface UseThreadReturn {
|
|
|
1526
1565
|
cancel: () => void;
|
|
1527
1566
|
/** Function to create or set the thread */
|
|
1528
1567
|
setThread: (thread: Thread) => void;
|
|
1568
|
+
/** The Zustand store — pass to AgentStreamStoreProvider for granular subscriptions */
|
|
1569
|
+
agentStreamStore: StoreApi<AgentStreamStore>;
|
|
1529
1570
|
}
|
|
1530
1571
|
/**
|
|
1531
1572
|
* Hook for managing a thread and sending messages.
|
|
@@ -1584,23 +1625,23 @@ interface UseThreadReturn {
|
|
|
1584
1625
|
*
|
|
1585
1626
|
* @example
|
|
1586
1627
|
* ```tsx
|
|
1587
|
-
* import { useThread, Content } from '@erdoai/ui';
|
|
1628
|
+
* import { useThread, Content, AgentStreamStoreProvider } from '@erdoai/ui';
|
|
1588
1629
|
*
|
|
1589
1630
|
* function MyChat() {
|
|
1590
|
-
* const { isStreaming, streamingContents, sendMessage } = useThread({
|
|
1631
|
+
* const { isStreaming, streamingContents, sendMessage, agentStreamStore } = useThread({
|
|
1591
1632
|
* botKey: 'org.my-bot',
|
|
1592
1633
|
* onFinish: (finalContents) => console.log('Message complete with', finalContents.length, 'items'),
|
|
1593
1634
|
* });
|
|
1594
1635
|
*
|
|
1595
1636
|
* return (
|
|
1596
|
-
* <
|
|
1637
|
+
* <AgentStreamStoreProvider store={agentStreamStore}>
|
|
1597
1638
|
* {streamingContents.map((content, idx) => (
|
|
1598
1639
|
* <Content key={content.id || idx} content={content} />
|
|
1599
1640
|
* ))}
|
|
1600
1641
|
* <button onClick={() => sendMessage('Hello')} disabled={isStreaming}>
|
|
1601
1642
|
* Send
|
|
1602
1643
|
* </button>
|
|
1603
|
-
* </
|
|
1644
|
+
* </AgentStreamStoreProvider>
|
|
1604
1645
|
* );
|
|
1605
1646
|
* }
|
|
1606
1647
|
* ```
|
|
@@ -1811,54 +1852,71 @@ declare function handleSSEEvent(eventType: string, event: SSEEventData, path: st
|
|
|
1811
1852
|
declare function handleIncrementalMixedJsonParsing(outputContent: MessageContent | OutputContent, content: string): MessageContent | OutputContent;
|
|
1812
1853
|
|
|
1813
1854
|
/**
|
|
1814
|
-
* Agent Event Handler
|
|
1855
|
+
* Agent Event Handler (flat content model)
|
|
1815
1856
|
*
|
|
1816
|
-
*
|
|
1817
|
-
*
|
|
1818
|
-
*
|
|
1857
|
+
* Replaces the nested step content model (handle-step-events.ts) with a flat model:
|
|
1858
|
+
* - Steps are structural nodes (no content on them)
|
|
1859
|
+
* - Content is always message content with optional stepId for location
|
|
1860
|
+
* - No step_content event type
|
|
1861
|
+
* - One tree, one rendering pass
|
|
1819
1862
|
*/
|
|
1820
1863
|
|
|
1864
|
+
/** Create initial empty agent state. */
|
|
1865
|
+
declare function createInitialAgentState(): AgentStreamState;
|
|
1821
1866
|
/**
|
|
1822
|
-
*
|
|
1823
|
-
|
|
1824
|
-
declare function isStepEvent(event: SSEEvent): boolean;
|
|
1825
|
-
/**
|
|
1826
|
-
* Creates initial state for step-based streaming.
|
|
1867
|
+
* Handle an agent SSE event and return updated state.
|
|
1868
|
+
* Pure function — does not mutate input state.
|
|
1827
1869
|
*/
|
|
1828
|
-
declare function
|
|
1870
|
+
declare function handleAgentEvent(state: AgentStreamState, event: SSEEvent): AgentStreamState;
|
|
1871
|
+
declare function completeStreamingContent(state: AgentStreamState): AgentStreamState;
|
|
1829
1872
|
/**
|
|
1830
|
-
*
|
|
1831
|
-
*
|
|
1873
|
+
* Returns true when the agent state contains assistant content that will
|
|
1874
|
+
* visibly render (actual text/JSON from the assistant, not structural steps).
|
|
1875
|
+
*
|
|
1876
|
+
* Specifically checks for content nodes with:
|
|
1877
|
+
* - Non-empty text (from message content delta)
|
|
1878
|
+
* - Parsed JSON chunks (incremental JSON streaming)
|
|
1879
|
+
* - A final result (from message content result)
|
|
1880
|
+
*
|
|
1881
|
+
* Excludes tool_invocation / tool_result / agent_invocation content types
|
|
1882
|
+
* which are structural, not user-visible assistant output.
|
|
1883
|
+
*
|
|
1884
|
+
* Does NOT count step tree rows (tool_call, agent steps) — those are structural
|
|
1885
|
+
* indicators, not assistant content. This ensures typing stays visible until the
|
|
1886
|
+
* first actual text/chart/output token arrives.
|
|
1887
|
+
*
|
|
1888
|
+
* Use this to gate typing indicators: keep typing visible until this returns true.
|
|
1832
1889
|
*/
|
|
1833
|
-
declare function
|
|
1890
|
+
declare function hasRenderableAssistantOutput(state: AgentStreamState): boolean;
|
|
1834
1891
|
/**
|
|
1835
|
-
*
|
|
1892
|
+
* Convert AgentStreamState into ContentItem[] for rendering.
|
|
1836
1893
|
*
|
|
1837
|
-
*
|
|
1838
|
-
*
|
|
1839
|
-
*
|
|
1840
|
-
* - Sub-agent tool_calls → tool_invocation while running, tool_result when done
|
|
1841
|
-
* (sub-agent internals are NOT shown — AgentProgress handles progress labels)
|
|
1894
|
+
* Single forward pass over state.nodes in event-arrival order. Renders
|
|
1895
|
+
* assistant content (text, JSON) while skipping tool artifacts (rendered
|
|
1896
|
+
* exclusively by StepTreeContent's buildStepTree).
|
|
1842
1897
|
*/
|
|
1843
|
-
declare function
|
|
1898
|
+
declare function agentStateToContents(state: AgentStreamState): ContentItem[];
|
|
1844
1899
|
|
|
1845
|
-
interface
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
declare function
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1900
|
+
interface AgentStreamStoreProviderProps {
|
|
1901
|
+
store: StoreApi<AgentStreamStore>;
|
|
1902
|
+
children: ReactNode;
|
|
1903
|
+
}
|
|
1904
|
+
declare function AgentStreamStoreProvider({ store, children }: AgentStreamStoreProviderProps): react_jsx_runtime.JSX.Element;
|
|
1905
|
+
/**
|
|
1906
|
+
* Get the raw store API for imperative use (e.g., in event handlers).
|
|
1907
|
+
* Returns null if no provider is present (backward compat).
|
|
1908
|
+
*/
|
|
1909
|
+
declare function useAgentStreamStoreOptional(): StoreApi<AgentStreamStore> | null;
|
|
1910
|
+
/**
|
|
1911
|
+
* Subscribe to a specific invocation's sliced agent state.
|
|
1912
|
+
* Only re-renders when that invocation's state reference changes.
|
|
1913
|
+
* Returns undefined if the invocation is not yet registered or no provider.
|
|
1914
|
+
*/
|
|
1915
|
+
declare function useInvocationState(invocationId: string | undefined): AgentStreamState | undefined;
|
|
1916
|
+
/**
|
|
1917
|
+
* Subscribe to the full global agent state.
|
|
1918
|
+
* Re-renders on every event — use sparingly.
|
|
1919
|
+
*/
|
|
1920
|
+
declare function useAgentStreamGlobalState(): AgentStreamState;
|
|
1863
1921
|
|
|
1864
|
-
export { type
|
|
1922
|
+
export { type AgentStreamStore, AgentStreamStoreProvider, type AgentStreamStoreProviderProps, BarChart, type BaseChartProps, type BotInvocation, BotInvocationContent, type BotInvocationContentData, type BotInvocationContentProps, type BotInvocationData, type BotInvocationEventInfo, type BotInvocationStatusInfo, Chart, type ChartConfig, ChartContainer, ChartContent, type ChartContentProps, ChartLegend, ChartLegendContent, ChartNode, type ChartNodeContent, ChartStyle, ChartTooltip, ChartTooltipContent, CodeexecContent, type CodeexecContentProps, CodegenContent, type CodegenContentProps, CollapsibleCodeBlock, type CollapsibleCodeBlockProps, Content, type ContentChartConfig, type ContentChunk, type ContentComponentProps, type ContentProps, type ContentType, type DataFetcher, DatasetChart, type DatasetChartProps, type DatasetDetails, DatasetDownload, type DatasetDownloadProps, type DatasetFetchRequest, DatasetTable, type DatasetTableProps, DownloadButtonNode, type DownloadButtonNodeContent, type Entity, type EntityType, ErdoProvider, type ErdoProviderConfig, type ErdoProviderProps, ErdoUI, type ErdoUIProps, ErrorBoundary, ExecutionStatus, ExpandableOutputContent, type ExpandableOutputContentProps, FileDownloadsNode, type FileDownloadsNodeContent, type GeneratedFile, HeatmapChart, InvocationEvent, type InvocationEventProps, InvocationEvents, type InvocationEventsProps, InvocationStatus, JSONStreamParser, type JSONValue, JsonContent, type JsonContentProps, LineChart, Loader, Log, LogContent, type LogContentProps, type LogProps, MarkdownContent, type MarkdownContentProps, type Memory, MemoryContent, type MemoryContentProps, type Message, type MessageContent, type MessageStreamingState, type MessageWithContents, type NodeRendererProps, type NullString, Output, type OutputContent, type OutputProps, type OutputWithContents, PieChart, type RawApiContent, type ResolvedBotInvocation, type ResultHandler, type SSEEventData, ScatterChart, type SpinnerStatus, SqlContent, type SqlContentProps, type Status, type StatusEvent, StatusSpinner, type StatusSpinnerProps, StderrText, StdoutText, StdwarnText, type Step, StepInvocation, type StepInvocationProps, StepInvocationStatus, type StepInvocationStatusProps, StepTreeContent, type StepTreeContentProps, SuggestionsNode, type SuggestionsNodeContent, TableContent, type TableContentProps, TableNode, type TableNodeContent, TextContent, type TextContentProps, TextMarkdownNode, type TextMarkdownNodeContent, ThinkingContent, type ThinkingContentProps, ToolGroupContent, type ToolGroupContentProps, UIGenerationNodes, type UIGenerationNodesProps, type UINode, type UseDatasetContentsResult, type UseThreadOptions, type UseThreadReturn, WebParseContent, type WebParseContentProps, WebSearchContent, type WebSearchContentProps, type WrapperType, WritingLoader, agentStateToContents, cn, completeStreamingContent, createAgentStreamStore, createInitialAgentState, extractContentItems, formatValue, handleAgentEvent, handleIncrementalMixedJsonParsing, handleSSEEvent, hasRenderableAssistantOutput, isJsonLike, isNullString, isParsingComplete, isParsingInProgress, isWhitespaceChar, nodeComponents, normalizeContent, normalizeContents, normalizeUIGenerationChunks, normalizeUINodes, parseCompleteJson, parseMixedJson, parseToDate, resolveKeyFromData, sliceAgentStateToRoot, toSnakeCase, unwrapNullString, unwrapNullStringOr, useAgentStreamGlobalState, useAgentStreamStoreOptional, useChartZoom, useDatasetContents, useErdoConfig, useErdoConfigOptional, useInvocationState, useMultipleDatasetContents, useMultipleDatasetRequests, useThread };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as React$1 from 'react';
|
|
3
|
-
import React__default from 'react';
|
|
4
|
-
import { ErdoClient, ContentItem, InvokeResult, LogEntry, ToolGroup, InvocationStatus as InvocationStatus$1,
|
|
3
|
+
import React__default, { ReactNode } from 'react';
|
|
4
|
+
import { ErdoClient, ContentItem, InvokeResult, LogEntry, ToolGroup, InvocationStatus as InvocationStatus$1, AgentStreamState, SSEEvent, Thread } from '@erdoai/types';
|
|
5
5
|
export { ContentItem } from '@erdoai/types';
|
|
6
6
|
import * as RechartsPrimitive from 'recharts';
|
|
7
|
+
import { StoreApi } from 'zustand';
|
|
7
8
|
import { ClassValue } from 'clsx';
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -131,9 +132,10 @@ interface ErdoProviderConfig {
|
|
|
131
132
|
*/
|
|
132
133
|
onSuggestionClick?: (suggestion: string) => void;
|
|
133
134
|
/**
|
|
134
|
-
* Enable the
|
|
135
|
-
* When true,
|
|
136
|
-
*
|
|
135
|
+
* Enable the agent event system (flat content model).
|
|
136
|
+
* When true, routes step_started/step_finished and message content events
|
|
137
|
+
* through handleAgentEvent into AgentStreamState.
|
|
138
|
+
* When false (default), uses legacy path-based event routing (bot service).
|
|
137
139
|
*/
|
|
138
140
|
useAgentEvents?: boolean;
|
|
139
141
|
}
|
|
@@ -842,6 +844,7 @@ interface ContentProps {
|
|
|
842
844
|
components?: Record<string, React__default.ComponentType<any>>;
|
|
843
845
|
}
|
|
844
846
|
declare function Content({ content, className, components }: ContentProps): react_jsx_runtime.JSX.Element | null;
|
|
847
|
+
declare function normalizeUIGenerationChunks(value: unknown): ContentChunk[] | null;
|
|
845
848
|
|
|
846
849
|
interface ErdoUIProps {
|
|
847
850
|
/** Result from an Erdo invocation */
|
|
@@ -1005,8 +1008,8 @@ interface ThinkingContentProps {
|
|
|
1005
1008
|
className?: string;
|
|
1006
1009
|
}
|
|
1007
1010
|
/**
|
|
1008
|
-
* Renders Claude's thinking/reasoning content
|
|
1009
|
-
*
|
|
1011
|
+
* Renders Claude's thinking/reasoning content as subtle inline text.
|
|
1012
|
+
* No container/chrome; supports redacted (encrypted) thinking blocks.
|
|
1010
1013
|
*/
|
|
1011
1014
|
declare function ThinkingContent({ item, className }: ThinkingContentProps): react_jsx_runtime.JSX.Element;
|
|
1012
1015
|
|
|
@@ -1085,7 +1088,7 @@ interface CollapsibleCodeBlockProps {
|
|
|
1085
1088
|
/**
|
|
1086
1089
|
* A collapsible code block with syntax highlighting.
|
|
1087
1090
|
*/
|
|
1088
|
-
declare
|
|
1091
|
+
declare const CollapsibleCodeBlock: React$1.NamedExoticComponent<CollapsibleCodeBlockProps>;
|
|
1089
1092
|
|
|
1090
1093
|
interface SqlContentProps {
|
|
1091
1094
|
item: ContentItem;
|
|
@@ -1102,8 +1105,7 @@ interface CodegenContentProps {
|
|
|
1102
1105
|
}
|
|
1103
1106
|
/**
|
|
1104
1107
|
* Renders code generation content with step-by-step explanation, code, and warnings.
|
|
1105
|
-
*
|
|
1106
|
-
* Expects parsedJson to be populated upstream (via normalizeContent or SSE handler).
|
|
1108
|
+
* Prefers canonical `content` (parsed object); falls back to legacy `parsedJson` (DB string path).
|
|
1107
1109
|
*/
|
|
1108
1110
|
declare function CodegenContent({ item, className }: CodegenContentProps): react_jsx_runtime.JSX.Element | null;
|
|
1109
1111
|
|
|
@@ -1113,6 +1115,7 @@ interface CodeexecContentProps {
|
|
|
1113
1115
|
}
|
|
1114
1116
|
/**
|
|
1115
1117
|
* Renders code execution output (stdout, stderr, warnings).
|
|
1118
|
+
* Prefers canonical `content`; falls back to legacy `parsedJson`.
|
|
1116
1119
|
*/
|
|
1117
1120
|
declare function CodeexecContent({ item, className }: CodeexecContentProps): react_jsx_runtime.JSX.Element | null;
|
|
1118
1121
|
|
|
@@ -1282,8 +1285,8 @@ interface MemoryContentProps {
|
|
|
1282
1285
|
declare function MemoryContent({ content, className }: MemoryContentProps): react_jsx_runtime.JSX.Element;
|
|
1283
1286
|
|
|
1284
1287
|
interface StepTreeContentProps {
|
|
1285
|
-
/** The
|
|
1286
|
-
|
|
1288
|
+
/** The agent stream state containing all steps and content */
|
|
1289
|
+
agentState: AgentStreamState;
|
|
1287
1290
|
/** Optional Content component for rendering ui_generation/codegen */
|
|
1288
1291
|
ContentComponent?: React__default.ComponentType<{
|
|
1289
1292
|
content: ContentItem;
|
|
@@ -1296,7 +1299,7 @@ interface StepTreeContentProps {
|
|
|
1296
1299
|
*
|
|
1297
1300
|
* Used for both streaming and reload paths to ensure consistent rendering.
|
|
1298
1301
|
*/
|
|
1299
|
-
declare function StepTreeContent({
|
|
1302
|
+
declare function StepTreeContent({ agentState, ContentComponent, className }: StepTreeContentProps): react_jsx_runtime.JSX.Element | null;
|
|
1300
1303
|
|
|
1301
1304
|
/** Node structure from UI generation content */
|
|
1302
1305
|
interface UINode {
|
|
@@ -1492,6 +1495,42 @@ declare function useMultipleDatasetRequests(requests: DatasetFetchRequest[], inv
|
|
|
1492
1495
|
*/
|
|
1493
1496
|
declare function useMultipleDatasetContents(datasetSlugs: string[], invocationId: string, sqlQueries?: Record<string, string>, resourceKeys?: Record<string, string>): UseDatasetContentsResult[];
|
|
1494
1497
|
|
|
1498
|
+
/**
|
|
1499
|
+
* Zustand store for agent streaming state.
|
|
1500
|
+
*
|
|
1501
|
+
* Holds the global AgentStreamState and per-invocation sliced states.
|
|
1502
|
+
* Components subscribe to individual invocation slices via useInvocationState(),
|
|
1503
|
+
* so only the affected component re-renders when an event arrives.
|
|
1504
|
+
*
|
|
1505
|
+
* The store calls handleAgentEvent internally — consumers just push raw SSE events.
|
|
1506
|
+
*/
|
|
1507
|
+
|
|
1508
|
+
declare function sliceAgentStateToRoot(state: AgentStreamState, rootStepID: string): AgentStreamState;
|
|
1509
|
+
interface AgentStreamStore {
|
|
1510
|
+
/** The single merged state from all events */
|
|
1511
|
+
globalState: AgentStreamState;
|
|
1512
|
+
/** Per-invocation sliced states. Key: invocation_id */
|
|
1513
|
+
invocationStates: Record<string, AgentStreamState>;
|
|
1514
|
+
/** Maps invocation_id → root step_id */
|
|
1515
|
+
invocationRootSteps: Record<string, string>;
|
|
1516
|
+
/** Queue for invocations awaiting their root step_started */
|
|
1517
|
+
pendingInvocationQueue: string[];
|
|
1518
|
+
/**
|
|
1519
|
+
* Push a raw SSE event into the store.
|
|
1520
|
+
* Calls handleAgentEvent internally and re-slices affected invocations.
|
|
1521
|
+
* @param event The raw SSE event
|
|
1522
|
+
* @param reconcile Optional post-processing (e.g., reconcileThinkingContentState)
|
|
1523
|
+
*/
|
|
1524
|
+
pushEvent: (event: SSEEvent, reconcile?: (state: AgentStreamState) => AgentStreamState) => void;
|
|
1525
|
+
/** Register an invocation_id (from agent_invocation event). Queues it for root mapping. */
|
|
1526
|
+
registerInvocation: (invocationId: string) => void;
|
|
1527
|
+
/** Map an invocation_id to its root step_id (from step_started with type: 'agent'). */
|
|
1528
|
+
mapInvocationRoot: (invocationId: string, rootStepId: string) => void;
|
|
1529
|
+
/** Reset the store (new session). */
|
|
1530
|
+
reset: () => void;
|
|
1531
|
+
}
|
|
1532
|
+
declare function createAgentStreamStore(): StoreApi<AgentStreamStore>;
|
|
1533
|
+
|
|
1495
1534
|
interface UseThreadOptions {
|
|
1496
1535
|
/** Initial thread ID to use (if resuming an existing thread) */
|
|
1497
1536
|
threadId?: string;
|
|
@@ -1513,8 +1552,8 @@ interface UseThreadReturn {
|
|
|
1513
1552
|
error: Error | null;
|
|
1514
1553
|
/** Active messages being streamed (with parsedJson populated) */
|
|
1515
1554
|
activeMessages: MessageWithContents[];
|
|
1516
|
-
/**
|
|
1517
|
-
|
|
1555
|
+
/** Agent stream state (flat content model) */
|
|
1556
|
+
agentState: AgentStreamState;
|
|
1518
1557
|
/**
|
|
1519
1558
|
* Flattened, filtered contents ready for rendering with the Content component.
|
|
1520
1559
|
* Only includes visible content (user_visibility === 'visible').
|
|
@@ -1526,6 +1565,8 @@ interface UseThreadReturn {
|
|
|
1526
1565
|
cancel: () => void;
|
|
1527
1566
|
/** Function to create or set the thread */
|
|
1528
1567
|
setThread: (thread: Thread) => void;
|
|
1568
|
+
/** The Zustand store — pass to AgentStreamStoreProvider for granular subscriptions */
|
|
1569
|
+
agentStreamStore: StoreApi<AgentStreamStore>;
|
|
1529
1570
|
}
|
|
1530
1571
|
/**
|
|
1531
1572
|
* Hook for managing a thread and sending messages.
|
|
@@ -1584,23 +1625,23 @@ interface UseThreadReturn {
|
|
|
1584
1625
|
*
|
|
1585
1626
|
* @example
|
|
1586
1627
|
* ```tsx
|
|
1587
|
-
* import { useThread, Content } from '@erdoai/ui';
|
|
1628
|
+
* import { useThread, Content, AgentStreamStoreProvider } from '@erdoai/ui';
|
|
1588
1629
|
*
|
|
1589
1630
|
* function MyChat() {
|
|
1590
|
-
* const { isStreaming, streamingContents, sendMessage } = useThread({
|
|
1631
|
+
* const { isStreaming, streamingContents, sendMessage, agentStreamStore } = useThread({
|
|
1591
1632
|
* botKey: 'org.my-bot',
|
|
1592
1633
|
* onFinish: (finalContents) => console.log('Message complete with', finalContents.length, 'items'),
|
|
1593
1634
|
* });
|
|
1594
1635
|
*
|
|
1595
1636
|
* return (
|
|
1596
|
-
* <
|
|
1637
|
+
* <AgentStreamStoreProvider store={agentStreamStore}>
|
|
1597
1638
|
* {streamingContents.map((content, idx) => (
|
|
1598
1639
|
* <Content key={content.id || idx} content={content} />
|
|
1599
1640
|
* ))}
|
|
1600
1641
|
* <button onClick={() => sendMessage('Hello')} disabled={isStreaming}>
|
|
1601
1642
|
* Send
|
|
1602
1643
|
* </button>
|
|
1603
|
-
* </
|
|
1644
|
+
* </AgentStreamStoreProvider>
|
|
1604
1645
|
* );
|
|
1605
1646
|
* }
|
|
1606
1647
|
* ```
|
|
@@ -1811,54 +1852,71 @@ declare function handleSSEEvent(eventType: string, event: SSEEventData, path: st
|
|
|
1811
1852
|
declare function handleIncrementalMixedJsonParsing(outputContent: MessageContent | OutputContent, content: string): MessageContent | OutputContent;
|
|
1812
1853
|
|
|
1813
1854
|
/**
|
|
1814
|
-
* Agent Event Handler
|
|
1855
|
+
* Agent Event Handler (flat content model)
|
|
1815
1856
|
*
|
|
1816
|
-
*
|
|
1817
|
-
*
|
|
1818
|
-
*
|
|
1857
|
+
* Replaces the nested step content model (handle-step-events.ts) with a flat model:
|
|
1858
|
+
* - Steps are structural nodes (no content on them)
|
|
1859
|
+
* - Content is always message content with optional stepId for location
|
|
1860
|
+
* - No step_content event type
|
|
1861
|
+
* - One tree, one rendering pass
|
|
1819
1862
|
*/
|
|
1820
1863
|
|
|
1864
|
+
/** Create initial empty agent state. */
|
|
1865
|
+
declare function createInitialAgentState(): AgentStreamState;
|
|
1821
1866
|
/**
|
|
1822
|
-
*
|
|
1823
|
-
|
|
1824
|
-
declare function isStepEvent(event: SSEEvent): boolean;
|
|
1825
|
-
/**
|
|
1826
|
-
* Creates initial state for step-based streaming.
|
|
1867
|
+
* Handle an agent SSE event and return updated state.
|
|
1868
|
+
* Pure function — does not mutate input state.
|
|
1827
1869
|
*/
|
|
1828
|
-
declare function
|
|
1870
|
+
declare function handleAgentEvent(state: AgentStreamState, event: SSEEvent): AgentStreamState;
|
|
1871
|
+
declare function completeStreamingContent(state: AgentStreamState): AgentStreamState;
|
|
1829
1872
|
/**
|
|
1830
|
-
*
|
|
1831
|
-
*
|
|
1873
|
+
* Returns true when the agent state contains assistant content that will
|
|
1874
|
+
* visibly render (actual text/JSON from the assistant, not structural steps).
|
|
1875
|
+
*
|
|
1876
|
+
* Specifically checks for content nodes with:
|
|
1877
|
+
* - Non-empty text (from message content delta)
|
|
1878
|
+
* - Parsed JSON chunks (incremental JSON streaming)
|
|
1879
|
+
* - A final result (from message content result)
|
|
1880
|
+
*
|
|
1881
|
+
* Excludes tool_invocation / tool_result / agent_invocation content types
|
|
1882
|
+
* which are structural, not user-visible assistant output.
|
|
1883
|
+
*
|
|
1884
|
+
* Does NOT count step tree rows (tool_call, agent steps) — those are structural
|
|
1885
|
+
* indicators, not assistant content. This ensures typing stays visible until the
|
|
1886
|
+
* first actual text/chart/output token arrives.
|
|
1887
|
+
*
|
|
1888
|
+
* Use this to gate typing indicators: keep typing visible until this returns true.
|
|
1832
1889
|
*/
|
|
1833
|
-
declare function
|
|
1890
|
+
declare function hasRenderableAssistantOutput(state: AgentStreamState): boolean;
|
|
1834
1891
|
/**
|
|
1835
|
-
*
|
|
1892
|
+
* Convert AgentStreamState into ContentItem[] for rendering.
|
|
1836
1893
|
*
|
|
1837
|
-
*
|
|
1838
|
-
*
|
|
1839
|
-
*
|
|
1840
|
-
* - Sub-agent tool_calls → tool_invocation while running, tool_result when done
|
|
1841
|
-
* (sub-agent internals are NOT shown — AgentProgress handles progress labels)
|
|
1894
|
+
* Single forward pass over state.nodes in event-arrival order. Renders
|
|
1895
|
+
* assistant content (text, JSON) while skipping tool artifacts (rendered
|
|
1896
|
+
* exclusively by StepTreeContent's buildStepTree).
|
|
1842
1897
|
*/
|
|
1843
|
-
declare function
|
|
1898
|
+
declare function agentStateToContents(state: AgentStreamState): ContentItem[];
|
|
1844
1899
|
|
|
1845
|
-
interface
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
declare function
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1900
|
+
interface AgentStreamStoreProviderProps {
|
|
1901
|
+
store: StoreApi<AgentStreamStore>;
|
|
1902
|
+
children: ReactNode;
|
|
1903
|
+
}
|
|
1904
|
+
declare function AgentStreamStoreProvider({ store, children }: AgentStreamStoreProviderProps): react_jsx_runtime.JSX.Element;
|
|
1905
|
+
/**
|
|
1906
|
+
* Get the raw store API for imperative use (e.g., in event handlers).
|
|
1907
|
+
* Returns null if no provider is present (backward compat).
|
|
1908
|
+
*/
|
|
1909
|
+
declare function useAgentStreamStoreOptional(): StoreApi<AgentStreamStore> | null;
|
|
1910
|
+
/**
|
|
1911
|
+
* Subscribe to a specific invocation's sliced agent state.
|
|
1912
|
+
* Only re-renders when that invocation's state reference changes.
|
|
1913
|
+
* Returns undefined if the invocation is not yet registered or no provider.
|
|
1914
|
+
*/
|
|
1915
|
+
declare function useInvocationState(invocationId: string | undefined): AgentStreamState | undefined;
|
|
1916
|
+
/**
|
|
1917
|
+
* Subscribe to the full global agent state.
|
|
1918
|
+
* Re-renders on every event — use sparingly.
|
|
1919
|
+
*/
|
|
1920
|
+
declare function useAgentStreamGlobalState(): AgentStreamState;
|
|
1863
1921
|
|
|
1864
|
-
export { type
|
|
1922
|
+
export { type AgentStreamStore, AgentStreamStoreProvider, type AgentStreamStoreProviderProps, BarChart, type BaseChartProps, type BotInvocation, BotInvocationContent, type BotInvocationContentData, type BotInvocationContentProps, type BotInvocationData, type BotInvocationEventInfo, type BotInvocationStatusInfo, Chart, type ChartConfig, ChartContainer, ChartContent, type ChartContentProps, ChartLegend, ChartLegendContent, ChartNode, type ChartNodeContent, ChartStyle, ChartTooltip, ChartTooltipContent, CodeexecContent, type CodeexecContentProps, CodegenContent, type CodegenContentProps, CollapsibleCodeBlock, type CollapsibleCodeBlockProps, Content, type ContentChartConfig, type ContentChunk, type ContentComponentProps, type ContentProps, type ContentType, type DataFetcher, DatasetChart, type DatasetChartProps, type DatasetDetails, DatasetDownload, type DatasetDownloadProps, type DatasetFetchRequest, DatasetTable, type DatasetTableProps, DownloadButtonNode, type DownloadButtonNodeContent, type Entity, type EntityType, ErdoProvider, type ErdoProviderConfig, type ErdoProviderProps, ErdoUI, type ErdoUIProps, ErrorBoundary, ExecutionStatus, ExpandableOutputContent, type ExpandableOutputContentProps, FileDownloadsNode, type FileDownloadsNodeContent, type GeneratedFile, HeatmapChart, InvocationEvent, type InvocationEventProps, InvocationEvents, type InvocationEventsProps, InvocationStatus, JSONStreamParser, type JSONValue, JsonContent, type JsonContentProps, LineChart, Loader, Log, LogContent, type LogContentProps, type LogProps, MarkdownContent, type MarkdownContentProps, type Memory, MemoryContent, type MemoryContentProps, type Message, type MessageContent, type MessageStreamingState, type MessageWithContents, type NodeRendererProps, type NullString, Output, type OutputContent, type OutputProps, type OutputWithContents, PieChart, type RawApiContent, type ResolvedBotInvocation, type ResultHandler, type SSEEventData, ScatterChart, type SpinnerStatus, SqlContent, type SqlContentProps, type Status, type StatusEvent, StatusSpinner, type StatusSpinnerProps, StderrText, StdoutText, StdwarnText, type Step, StepInvocation, type StepInvocationProps, StepInvocationStatus, type StepInvocationStatusProps, StepTreeContent, type StepTreeContentProps, SuggestionsNode, type SuggestionsNodeContent, TableContent, type TableContentProps, TableNode, type TableNodeContent, TextContent, type TextContentProps, TextMarkdownNode, type TextMarkdownNodeContent, ThinkingContent, type ThinkingContentProps, ToolGroupContent, type ToolGroupContentProps, UIGenerationNodes, type UIGenerationNodesProps, type UINode, type UseDatasetContentsResult, type UseThreadOptions, type UseThreadReturn, WebParseContent, type WebParseContentProps, WebSearchContent, type WebSearchContentProps, type WrapperType, WritingLoader, agentStateToContents, cn, completeStreamingContent, createAgentStreamStore, createInitialAgentState, extractContentItems, formatValue, handleAgentEvent, handleIncrementalMixedJsonParsing, handleSSEEvent, hasRenderableAssistantOutput, isJsonLike, isNullString, isParsingComplete, isParsingInProgress, isWhitespaceChar, nodeComponents, normalizeContent, normalizeContents, normalizeUIGenerationChunks, normalizeUINodes, parseCompleteJson, parseMixedJson, parseToDate, resolveKeyFromData, sliceAgentStateToRoot, toSnakeCase, unwrapNullString, unwrapNullStringOr, useAgentStreamGlobalState, useAgentStreamStoreOptional, useChartZoom, useDatasetContents, useErdoConfig, useErdoConfigOptional, useInvocationState, useMultipleDatasetContents, useMultipleDatasetRequests, useThread };
|