@distri/react 0.3.5 → 0.3.6
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/globals.css +69 -0
- package/dist/index.cjs +1453 -856
- package/dist/index.d.cts +139 -3
- package/dist/index.d.ts +139 -3
- package/dist/index.js +1379 -786
- package/package.json +8 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Agent as Agent$1, DistriChatMessage, DistriBaseTool, ToolExecutionOptions, DistriMessage, DistriPart, AgentDefinition, DistriThread, ThreadListParams, AgentUsageInfo, DistriFnTool, ToolCall, ToolResult, PlanStep, TodoItem, DistriConfiguration, DistriClient, DistriClientConfig, SpeechToTextConfig, StreamingTranscriptionOptions, ConfigurationMeta, ConfigurationResponse, MessageReadStatus, MessageVoteSummary, MessageVote, DistriEvent, ImagePart } from '@distri/core';
|
|
1
|
+
import { Agent as Agent$1, DistriChatMessage, DistriBaseTool, ToolExecutionOptions, DistriMessage, DistriPart, AgentDefinition, DistriThread, ThreadListParams, AgentUsageInfo, ProviderModelsStatus, DistriFnTool, ToolCall, ToolResult, PlanStep, TodoItem, DistriConfiguration, ContextHealth, DistriClient, DistriClientConfig, SpeechToTextConfig, StreamingTranscriptionOptions, ConfigurationMeta, ConfigurationResponse, MessageReadStatus, MessageVoteSummary, MessageVote, ContextCompactionEvent, WorkflowDefinition, StepResult, StepStatus, WorkflowRunnerOptions, WorkflowStep, ExecutionContext, WorkflowEvent, WorkflowStatus, DistriEvent, ImagePart } from '@distri/core';
|
|
2
2
|
import * as React$1 from 'react';
|
|
3
3
|
import React__default, { ReactNode } from 'react';
|
|
4
4
|
import * as zustand from 'zustand';
|
|
@@ -103,6 +103,17 @@ interface UseThreadMessagesOptions {
|
|
|
103
103
|
threadId: string | null;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
interface UseModelsResult {
|
|
107
|
+
providers: ProviderModelsStatus[];
|
|
108
|
+
loading: boolean;
|
|
109
|
+
error: Error | null;
|
|
110
|
+
refetch: () => Promise<void>;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Hook to fetch available models grouped by provider with configuration status.
|
|
114
|
+
*/
|
|
115
|
+
declare function useModels(): UseModelsResult;
|
|
116
|
+
|
|
106
117
|
type LoadingAnimationPreset = 'typing-dots' | 'pulse-ring' | 'teacher-typing' | 'spinner' | 'wave';
|
|
107
118
|
interface LoadingAnimationConfig {
|
|
108
119
|
/** Preset animation style */
|
|
@@ -167,9 +178,10 @@ interface ThinkingRendererProps {
|
|
|
167
178
|
name?: string;
|
|
168
179
|
thoughtText?: string;
|
|
169
180
|
}
|
|
170
|
-
declare const LoadingShimmer: ({ text, className }: {
|
|
181
|
+
declare const LoadingShimmer: ({ text, className, showIcon }: {
|
|
171
182
|
text: string;
|
|
172
183
|
className?: string;
|
|
184
|
+
showIcon?: boolean;
|
|
173
185
|
}) => react_jsx_runtime.JSX.Element;
|
|
174
186
|
declare const ThinkingRenderer: React__default.FC<ThinkingRendererProps>;
|
|
175
187
|
|
|
@@ -231,6 +243,7 @@ interface ChatState {
|
|
|
231
243
|
currentRunId?: string;
|
|
232
244
|
currentTaskId?: string;
|
|
233
245
|
currentPlanId?: string;
|
|
246
|
+
currentAgentId?: string;
|
|
234
247
|
messages: DistriChatMessage[];
|
|
235
248
|
streamingIndicator: StreamingIndicator | undefined;
|
|
236
249
|
currentThought?: string;
|
|
@@ -554,6 +567,25 @@ interface AskFollowUpOutput {
|
|
|
554
567
|
declare const ASK_FOLLOW_UP_TOOL_NAME = "ask_follow_up";
|
|
555
568
|
declare function createAskFollowUpTool(): DistriUiTool;
|
|
556
569
|
|
|
570
|
+
interface ContextIndicatorProps {
|
|
571
|
+
contextHealth: ContextHealth | null;
|
|
572
|
+
isCompacting?: boolean;
|
|
573
|
+
className?: string;
|
|
574
|
+
}
|
|
575
|
+
/**
|
|
576
|
+
* Visual indicator for context window health.
|
|
577
|
+
*
|
|
578
|
+
* Shows a progress bar representing context usage and compaction status.
|
|
579
|
+
* Can be placed in a chat header, sidebar, or status bar.
|
|
580
|
+
*
|
|
581
|
+
* Usage:
|
|
582
|
+
* ```tsx
|
|
583
|
+
* const { contextHealth, isCompacting } = useContextHealth();
|
|
584
|
+
* <ContextIndicator contextHealth={contextHealth} isCompacting={isCompacting} />
|
|
585
|
+
* ```
|
|
586
|
+
*/
|
|
587
|
+
declare function ContextIndicator({ contextHealth, isCompacting, className, }: ContextIndicatorProps): react_jsx_runtime.JSX.Element | null;
|
|
588
|
+
|
|
557
589
|
interface DistriContextValue {
|
|
558
590
|
client: DistriClient | null;
|
|
559
591
|
error: Error | null;
|
|
@@ -808,6 +840,31 @@ interface UseMessageVotesResult {
|
|
|
808
840
|
*/
|
|
809
841
|
declare function useMessageVotes(options: UseMessageVotesOptions): UseMessageVotesResult;
|
|
810
842
|
|
|
843
|
+
/**
|
|
844
|
+
* Hook that tracks context health by listening for ContextCompaction events
|
|
845
|
+
* in the agent event stream.
|
|
846
|
+
*
|
|
847
|
+
* Usage:
|
|
848
|
+
* ```tsx
|
|
849
|
+
* const { contextHealth, lastCompaction, isCompacting } = useContextHealth();
|
|
850
|
+
* ```
|
|
851
|
+
*
|
|
852
|
+
* This hook maintains a running picture of context usage. It updates whenever
|
|
853
|
+
* a `context_compaction` event is received from the server event stream.
|
|
854
|
+
*/
|
|
855
|
+
declare function useContextHealth(): {
|
|
856
|
+
/** Current context health snapshot, or null if no compaction has occurred yet */
|
|
857
|
+
contextHealth: ContextHealth | null;
|
|
858
|
+
/** The most recent compaction event */
|
|
859
|
+
lastCompaction: ContextCompactionEvent | null;
|
|
860
|
+
/** Whether a compaction just occurred (true for ~1.5s after event) */
|
|
861
|
+
isCompacting: boolean;
|
|
862
|
+
/** Call with raw event objects from the stream to update health */
|
|
863
|
+
handleEvent: (event: Record<string, unknown>) => void;
|
|
864
|
+
/** Reset state (e.g., when switching threads) */
|
|
865
|
+
reset: () => void;
|
|
866
|
+
};
|
|
867
|
+
|
|
811
868
|
/**
|
|
812
869
|
* Wraps a DistriFnTool as a DistriUiTool with DefaultToolActions component
|
|
813
870
|
*/
|
|
@@ -817,6 +874,85 @@ declare function wrapFnToolAsUiTool(fnTool: DistriFnTool, options?: ToolExecutio
|
|
|
817
874
|
*/
|
|
818
875
|
declare function wrapTools(tools: (DistriFnTool | DistriUiTool)[], options?: ToolExecutionOptions): DistriUiTool[];
|
|
819
876
|
|
|
877
|
+
/**
|
|
878
|
+
* useWorkflow — React hook for tracking and running workflows.
|
|
879
|
+
*
|
|
880
|
+
* Provides:
|
|
881
|
+
* - workflow state (steps, status, progress)
|
|
882
|
+
* - runNextStep() to advance the workflow
|
|
883
|
+
* - runAll() to run all remaining steps
|
|
884
|
+
* - isRunning flag
|
|
885
|
+
*/
|
|
886
|
+
|
|
887
|
+
interface UseWorkflowOptions {
|
|
888
|
+
/** Initial workflow definition */
|
|
889
|
+
workflow: WorkflowDefinition;
|
|
890
|
+
/** Called when a step needs to be executed. Returns the step result. */
|
|
891
|
+
onExecuteStep: (stepId: string, step: WorkflowDefinition['steps'][0], context: Record<string, unknown>) => Promise<StepResult>;
|
|
892
|
+
/** Called when workflow state changes (for persistence) */
|
|
893
|
+
onStateChange?: (workflow: WorkflowDefinition) => void;
|
|
894
|
+
}
|
|
895
|
+
interface UseWorkflowReturn {
|
|
896
|
+
/** Current workflow state */
|
|
897
|
+
workflow: WorkflowDefinition;
|
|
898
|
+
/** Whether any step is currently running */
|
|
899
|
+
isRunning: boolean;
|
|
900
|
+
/** Progress percentage (0-100) */
|
|
901
|
+
progress: number;
|
|
902
|
+
/** Step counts by status */
|
|
903
|
+
counts: Record<StepStatus, number>;
|
|
904
|
+
/** Run the next pending step */
|
|
905
|
+
runNextStep: () => Promise<void>;
|
|
906
|
+
/** Run all remaining steps */
|
|
907
|
+
runAll: () => Promise<void>;
|
|
908
|
+
/** Update workflow state directly (e.g., from SSE events) */
|
|
909
|
+
updateWorkflow: (workflow: WorkflowDefinition) => void;
|
|
910
|
+
}
|
|
911
|
+
declare function useWorkflow({ workflow: initial, onExecuteStep, onStateChange }: UseWorkflowOptions): UseWorkflowReturn;
|
|
912
|
+
|
|
913
|
+
/**
|
|
914
|
+
* useWorkflowRunner — React hook that runs workflows using DistriClient.
|
|
915
|
+
*
|
|
916
|
+
* Combines WorkflowRunner (from @distri/core) with React state management.
|
|
917
|
+
* Steps execute against distri-cloud APIs. Events update state in real-time.
|
|
918
|
+
*
|
|
919
|
+
* Usage:
|
|
920
|
+
* const { run, status, events, steps, isRunning } = useWorkflowRunner()
|
|
921
|
+
* await run(workflowDef, { doc_id: 'abc' })
|
|
922
|
+
*/
|
|
923
|
+
|
|
924
|
+
interface UseWorkflowRunnerOptions {
|
|
925
|
+
/** Hook to customize HTTP requests (add auth headers, base URL, etc.) */
|
|
926
|
+
buildRequest?: WorkflowRunnerOptions['buildRequest'];
|
|
927
|
+
/** Environment variables for {env.X} namespace */
|
|
928
|
+
env?: Record<string, unknown>;
|
|
929
|
+
/** Custom step executor override */
|
|
930
|
+
executeStep?: (step: WorkflowStep, resolvedInput: unknown, context: ExecutionContext) => Promise<StepResult>;
|
|
931
|
+
/** Called on each event */
|
|
932
|
+
onEvent?: (event: WorkflowEvent) => void;
|
|
933
|
+
}
|
|
934
|
+
interface UseWorkflowRunnerReturn {
|
|
935
|
+
/** Run a workflow with the given input. */
|
|
936
|
+
run: (workflow: WorkflowDefinition, input?: Record<string, unknown>) => Promise<WorkflowStatus>;
|
|
937
|
+
/** Whether a workflow is currently running. */
|
|
938
|
+
isRunning: boolean;
|
|
939
|
+
/** Current status (null if not started). */
|
|
940
|
+
status: WorkflowStatus | null;
|
|
941
|
+
/** All events emitted so far. */
|
|
942
|
+
events: WorkflowEvent[];
|
|
943
|
+
/** Stop the running workflow. */
|
|
944
|
+
stop: () => void;
|
|
945
|
+
}
|
|
946
|
+
declare function useWorkflowRunner(options?: UseWorkflowRunnerOptions): UseWorkflowRunnerReturn;
|
|
947
|
+
|
|
948
|
+
interface WorkflowProgressProps {
|
|
949
|
+
workflow: WorkflowDefinition;
|
|
950
|
+
className?: string;
|
|
951
|
+
/** Show step details (kind, result preview) */
|
|
952
|
+
detailed?: boolean;
|
|
953
|
+
}
|
|
954
|
+
declare function WorkflowProgress({ workflow, className, detailed }: WorkflowProgressProps): react_jsx_runtime.JSX.Element;
|
|
955
|
+
|
|
820
956
|
declare const buttonVariants: {
|
|
821
957
|
variant: {
|
|
822
958
|
default: string;
|
|
@@ -1129,4 +1265,4 @@ interface UserMessageRendererProps {
|
|
|
1129
1265
|
}
|
|
1130
1266
|
declare const UserMessageRenderer: React__default.FC<UserMessageRendererProps>;
|
|
1131
1267
|
|
|
1132
|
-
export { ASK_FOLLOW_UP_TOOL_NAME, AgentSelect, type AskFollowUpInput, type AskFollowUpOutput, AssistantMessageRenderer, type AssistantMessageRendererProps, type AttachedImage, AuthLoading, type AuthStatus, Badge, BrowserPreviewPanel, BrowserViewport, type BrowserViewportProps, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Chat, type ChatContainerProps, type ChatCustomRenderers, type ChatEmptyStateCategory, type ChatEmptyStateController, type ChatEmptyStateOptions, type ChatEmptyStateStarter, ChatInner, ChatInput, type ChatInputProps, type ChatInstance, type ChatProps, type ChatState, type ChatStateStore, ConfigurationPanel, DialogRoot as Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger, type DistriAnyTool, DistriAuthProvider, DistriContext, DistriProvider, type DistriUiTool, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, type ExtractedContent, type FollowUpQuestion, ImageRenderer, type ImageRendererProps, Input, LoadingAnimation, type LoadingAnimationConfig, type LoadingAnimationPreset, type LoadingAnimationProps, LoadingShimmer, MessageFeedback, type MessageFeedbackProps, MessageReadProvider, type MessageReadProviderProps, MessageReadTracker, type MessageReadTrackerProps, MessageRenderer, type MessageRendererProps, type ModelOption, type PlanState, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, StepBasedRenderer, type StepBasedRendererProps, type StepState, type StreamingIndicator, StreamingTextRenderer, type StreamingTtsOptions, type TaskState, Textarea, ThemeProvider, ThemeToggle, ThinkingRenderer, type ThinkingRendererProps, TodosDisplay, type TodosDisplayProps, type ToolCallState, type ToolCallStatus, type ToolRendererMap, type ToolRendererProps, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, type TtsConfig, type TtsRequest, TypingIndicator, type UiToolProps, type UseAgentOptions, type UseAgentResult, type UseAgentsByUsageOptions, type UseAgentsByUsageResult, type UseAgentsResult, type UseChatMessagesOptions, type UseChatMessagesReturn, type UseChatOptions, type UseChatReturn, type UseConfigurationResult, type UseMessageReadStatusOptions, type UseMessageReadStatusResult, type UseMessageVoteOptions, type UseMessageVoteResult, type UseMessageVotesOptions, type UseMessageVotesResult, type UseThreadMessagesOptions, type UseThreadReadStatusOptions, type UseThreadReadStatusResult, type UseThreadsOptions, type UseThreadsResult, UserMessageRenderer, type UserMessageRendererProps, VoiceInput, type VoiceInputProps, createAskFollowUpTool, extractContent, useAgent, useAgentDefinitions, useAgentsByUsage, useChat, useChatMessages, useChatStateStore, useConfiguration, useDistri, useDistriAuth, useDistriToken, useMessageReadContext, useMessageReadStatus, useMessageVote, useMessageVotes, useSidebar, useSpeechToText, useTheme, useThreadReadStatus, useThreads, useTts, useWorkspace, wrapFnToolAsUiTool, wrapTools };
|
|
1268
|
+
export { ASK_FOLLOW_UP_TOOL_NAME, AgentSelect, type AskFollowUpInput, type AskFollowUpOutput, AssistantMessageRenderer, type AssistantMessageRendererProps, type AttachedImage, AuthLoading, type AuthStatus, Badge, BrowserPreviewPanel, BrowserViewport, type BrowserViewportProps, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Chat, type ChatContainerProps, type ChatCustomRenderers, type ChatEmptyStateCategory, type ChatEmptyStateController, type ChatEmptyStateOptions, type ChatEmptyStateStarter, ChatInner, ChatInput, type ChatInputProps, type ChatInstance, type ChatProps, type ChatState, type ChatStateStore, ConfigurationPanel, ContextIndicator, DialogRoot as Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger, type DistriAnyTool, DistriAuthProvider, DistriContext, DistriProvider, type DistriUiTool, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, type ExtractedContent, type FollowUpQuestion, ImageRenderer, type ImageRendererProps, Input, LoadingAnimation, type LoadingAnimationConfig, type LoadingAnimationPreset, type LoadingAnimationProps, LoadingShimmer, MessageFeedback, type MessageFeedbackProps, MessageReadProvider, type MessageReadProviderProps, MessageReadTracker, type MessageReadTrackerProps, MessageRenderer, type MessageRendererProps, type ModelOption, type PlanState, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, StepBasedRenderer, type StepBasedRendererProps, type StepState, type StreamingIndicator, StreamingTextRenderer, type StreamingTtsOptions, type TaskState, Textarea, ThemeProvider, ThemeToggle, ThinkingRenderer, type ThinkingRendererProps, TodosDisplay, type TodosDisplayProps, type ToolCallState, type ToolCallStatus, type ToolRendererMap, type ToolRendererProps, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, type TtsConfig, type TtsRequest, TypingIndicator, type UiToolProps, type UseAgentOptions, type UseAgentResult, type UseAgentsByUsageOptions, type UseAgentsByUsageResult, type UseAgentsResult, type UseChatMessagesOptions, type UseChatMessagesReturn, type UseChatOptions, type UseChatReturn, type UseConfigurationResult, type UseMessageReadStatusOptions, type UseMessageReadStatusResult, type UseMessageVoteOptions, type UseMessageVoteResult, type UseMessageVotesOptions, type UseMessageVotesResult, type UseModelsResult, type UseThreadMessagesOptions, type UseThreadReadStatusOptions, type UseThreadReadStatusResult, type UseThreadsOptions, type UseThreadsResult, type UseWorkflowOptions, type UseWorkflowReturn, type UseWorkflowRunnerOptions, type UseWorkflowRunnerReturn, UserMessageRenderer, type UserMessageRendererProps, VoiceInput, type VoiceInputProps, WorkflowProgress, type WorkflowProgressProps, createAskFollowUpTool, extractContent, useAgent, useAgentDefinitions, useAgentsByUsage, useChat, useChatMessages, useChatStateStore, useConfiguration, useContextHealth, useDistri, useDistriAuth, useDistriToken, useMessageReadContext, useMessageReadStatus, useMessageVote, useMessageVotes, useModels, useSidebar, useSpeechToText, useTheme, useThreadReadStatus, useThreads, useTts, useWorkflow, useWorkflowRunner, useWorkspace, wrapFnToolAsUiTool, wrapTools };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Agent as Agent$1, DistriChatMessage, DistriBaseTool, ToolExecutionOptions, DistriMessage, DistriPart, AgentDefinition, DistriThread, ThreadListParams, AgentUsageInfo, DistriFnTool, ToolCall, ToolResult, PlanStep, TodoItem, DistriConfiguration, DistriClient, DistriClientConfig, SpeechToTextConfig, StreamingTranscriptionOptions, ConfigurationMeta, ConfigurationResponse, MessageReadStatus, MessageVoteSummary, MessageVote, DistriEvent, ImagePart } from '@distri/core';
|
|
1
|
+
import { Agent as Agent$1, DistriChatMessage, DistriBaseTool, ToolExecutionOptions, DistriMessage, DistriPart, AgentDefinition, DistriThread, ThreadListParams, AgentUsageInfo, ProviderModelsStatus, DistriFnTool, ToolCall, ToolResult, PlanStep, TodoItem, DistriConfiguration, ContextHealth, DistriClient, DistriClientConfig, SpeechToTextConfig, StreamingTranscriptionOptions, ConfigurationMeta, ConfigurationResponse, MessageReadStatus, MessageVoteSummary, MessageVote, ContextCompactionEvent, WorkflowDefinition, StepResult, StepStatus, WorkflowRunnerOptions, WorkflowStep, ExecutionContext, WorkflowEvent, WorkflowStatus, DistriEvent, ImagePart } from '@distri/core';
|
|
2
2
|
import * as React$1 from 'react';
|
|
3
3
|
import React__default, { ReactNode } from 'react';
|
|
4
4
|
import * as zustand from 'zustand';
|
|
@@ -103,6 +103,17 @@ interface UseThreadMessagesOptions {
|
|
|
103
103
|
threadId: string | null;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
interface UseModelsResult {
|
|
107
|
+
providers: ProviderModelsStatus[];
|
|
108
|
+
loading: boolean;
|
|
109
|
+
error: Error | null;
|
|
110
|
+
refetch: () => Promise<void>;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Hook to fetch available models grouped by provider with configuration status.
|
|
114
|
+
*/
|
|
115
|
+
declare function useModels(): UseModelsResult;
|
|
116
|
+
|
|
106
117
|
type LoadingAnimationPreset = 'typing-dots' | 'pulse-ring' | 'teacher-typing' | 'spinner' | 'wave';
|
|
107
118
|
interface LoadingAnimationConfig {
|
|
108
119
|
/** Preset animation style */
|
|
@@ -167,9 +178,10 @@ interface ThinkingRendererProps {
|
|
|
167
178
|
name?: string;
|
|
168
179
|
thoughtText?: string;
|
|
169
180
|
}
|
|
170
|
-
declare const LoadingShimmer: ({ text, className }: {
|
|
181
|
+
declare const LoadingShimmer: ({ text, className, showIcon }: {
|
|
171
182
|
text: string;
|
|
172
183
|
className?: string;
|
|
184
|
+
showIcon?: boolean;
|
|
173
185
|
}) => react_jsx_runtime.JSX.Element;
|
|
174
186
|
declare const ThinkingRenderer: React__default.FC<ThinkingRendererProps>;
|
|
175
187
|
|
|
@@ -231,6 +243,7 @@ interface ChatState {
|
|
|
231
243
|
currentRunId?: string;
|
|
232
244
|
currentTaskId?: string;
|
|
233
245
|
currentPlanId?: string;
|
|
246
|
+
currentAgentId?: string;
|
|
234
247
|
messages: DistriChatMessage[];
|
|
235
248
|
streamingIndicator: StreamingIndicator | undefined;
|
|
236
249
|
currentThought?: string;
|
|
@@ -554,6 +567,25 @@ interface AskFollowUpOutput {
|
|
|
554
567
|
declare const ASK_FOLLOW_UP_TOOL_NAME = "ask_follow_up";
|
|
555
568
|
declare function createAskFollowUpTool(): DistriUiTool;
|
|
556
569
|
|
|
570
|
+
interface ContextIndicatorProps {
|
|
571
|
+
contextHealth: ContextHealth | null;
|
|
572
|
+
isCompacting?: boolean;
|
|
573
|
+
className?: string;
|
|
574
|
+
}
|
|
575
|
+
/**
|
|
576
|
+
* Visual indicator for context window health.
|
|
577
|
+
*
|
|
578
|
+
* Shows a progress bar representing context usage and compaction status.
|
|
579
|
+
* Can be placed in a chat header, sidebar, or status bar.
|
|
580
|
+
*
|
|
581
|
+
* Usage:
|
|
582
|
+
* ```tsx
|
|
583
|
+
* const { contextHealth, isCompacting } = useContextHealth();
|
|
584
|
+
* <ContextIndicator contextHealth={contextHealth} isCompacting={isCompacting} />
|
|
585
|
+
* ```
|
|
586
|
+
*/
|
|
587
|
+
declare function ContextIndicator({ contextHealth, isCompacting, className, }: ContextIndicatorProps): react_jsx_runtime.JSX.Element | null;
|
|
588
|
+
|
|
557
589
|
interface DistriContextValue {
|
|
558
590
|
client: DistriClient | null;
|
|
559
591
|
error: Error | null;
|
|
@@ -808,6 +840,31 @@ interface UseMessageVotesResult {
|
|
|
808
840
|
*/
|
|
809
841
|
declare function useMessageVotes(options: UseMessageVotesOptions): UseMessageVotesResult;
|
|
810
842
|
|
|
843
|
+
/**
|
|
844
|
+
* Hook that tracks context health by listening for ContextCompaction events
|
|
845
|
+
* in the agent event stream.
|
|
846
|
+
*
|
|
847
|
+
* Usage:
|
|
848
|
+
* ```tsx
|
|
849
|
+
* const { contextHealth, lastCompaction, isCompacting } = useContextHealth();
|
|
850
|
+
* ```
|
|
851
|
+
*
|
|
852
|
+
* This hook maintains a running picture of context usage. It updates whenever
|
|
853
|
+
* a `context_compaction` event is received from the server event stream.
|
|
854
|
+
*/
|
|
855
|
+
declare function useContextHealth(): {
|
|
856
|
+
/** Current context health snapshot, or null if no compaction has occurred yet */
|
|
857
|
+
contextHealth: ContextHealth | null;
|
|
858
|
+
/** The most recent compaction event */
|
|
859
|
+
lastCompaction: ContextCompactionEvent | null;
|
|
860
|
+
/** Whether a compaction just occurred (true for ~1.5s after event) */
|
|
861
|
+
isCompacting: boolean;
|
|
862
|
+
/** Call with raw event objects from the stream to update health */
|
|
863
|
+
handleEvent: (event: Record<string, unknown>) => void;
|
|
864
|
+
/** Reset state (e.g., when switching threads) */
|
|
865
|
+
reset: () => void;
|
|
866
|
+
};
|
|
867
|
+
|
|
811
868
|
/**
|
|
812
869
|
* Wraps a DistriFnTool as a DistriUiTool with DefaultToolActions component
|
|
813
870
|
*/
|
|
@@ -817,6 +874,85 @@ declare function wrapFnToolAsUiTool(fnTool: DistriFnTool, options?: ToolExecutio
|
|
|
817
874
|
*/
|
|
818
875
|
declare function wrapTools(tools: (DistriFnTool | DistriUiTool)[], options?: ToolExecutionOptions): DistriUiTool[];
|
|
819
876
|
|
|
877
|
+
/**
|
|
878
|
+
* useWorkflow — React hook for tracking and running workflows.
|
|
879
|
+
*
|
|
880
|
+
* Provides:
|
|
881
|
+
* - workflow state (steps, status, progress)
|
|
882
|
+
* - runNextStep() to advance the workflow
|
|
883
|
+
* - runAll() to run all remaining steps
|
|
884
|
+
* - isRunning flag
|
|
885
|
+
*/
|
|
886
|
+
|
|
887
|
+
interface UseWorkflowOptions {
|
|
888
|
+
/** Initial workflow definition */
|
|
889
|
+
workflow: WorkflowDefinition;
|
|
890
|
+
/** Called when a step needs to be executed. Returns the step result. */
|
|
891
|
+
onExecuteStep: (stepId: string, step: WorkflowDefinition['steps'][0], context: Record<string, unknown>) => Promise<StepResult>;
|
|
892
|
+
/** Called when workflow state changes (for persistence) */
|
|
893
|
+
onStateChange?: (workflow: WorkflowDefinition) => void;
|
|
894
|
+
}
|
|
895
|
+
interface UseWorkflowReturn {
|
|
896
|
+
/** Current workflow state */
|
|
897
|
+
workflow: WorkflowDefinition;
|
|
898
|
+
/** Whether any step is currently running */
|
|
899
|
+
isRunning: boolean;
|
|
900
|
+
/** Progress percentage (0-100) */
|
|
901
|
+
progress: number;
|
|
902
|
+
/** Step counts by status */
|
|
903
|
+
counts: Record<StepStatus, number>;
|
|
904
|
+
/** Run the next pending step */
|
|
905
|
+
runNextStep: () => Promise<void>;
|
|
906
|
+
/** Run all remaining steps */
|
|
907
|
+
runAll: () => Promise<void>;
|
|
908
|
+
/** Update workflow state directly (e.g., from SSE events) */
|
|
909
|
+
updateWorkflow: (workflow: WorkflowDefinition) => void;
|
|
910
|
+
}
|
|
911
|
+
declare function useWorkflow({ workflow: initial, onExecuteStep, onStateChange }: UseWorkflowOptions): UseWorkflowReturn;
|
|
912
|
+
|
|
913
|
+
/**
|
|
914
|
+
* useWorkflowRunner — React hook that runs workflows using DistriClient.
|
|
915
|
+
*
|
|
916
|
+
* Combines WorkflowRunner (from @distri/core) with React state management.
|
|
917
|
+
* Steps execute against distri-cloud APIs. Events update state in real-time.
|
|
918
|
+
*
|
|
919
|
+
* Usage:
|
|
920
|
+
* const { run, status, events, steps, isRunning } = useWorkflowRunner()
|
|
921
|
+
* await run(workflowDef, { doc_id: 'abc' })
|
|
922
|
+
*/
|
|
923
|
+
|
|
924
|
+
interface UseWorkflowRunnerOptions {
|
|
925
|
+
/** Hook to customize HTTP requests (add auth headers, base URL, etc.) */
|
|
926
|
+
buildRequest?: WorkflowRunnerOptions['buildRequest'];
|
|
927
|
+
/** Environment variables for {env.X} namespace */
|
|
928
|
+
env?: Record<string, unknown>;
|
|
929
|
+
/** Custom step executor override */
|
|
930
|
+
executeStep?: (step: WorkflowStep, resolvedInput: unknown, context: ExecutionContext) => Promise<StepResult>;
|
|
931
|
+
/** Called on each event */
|
|
932
|
+
onEvent?: (event: WorkflowEvent) => void;
|
|
933
|
+
}
|
|
934
|
+
interface UseWorkflowRunnerReturn {
|
|
935
|
+
/** Run a workflow with the given input. */
|
|
936
|
+
run: (workflow: WorkflowDefinition, input?: Record<string, unknown>) => Promise<WorkflowStatus>;
|
|
937
|
+
/** Whether a workflow is currently running. */
|
|
938
|
+
isRunning: boolean;
|
|
939
|
+
/** Current status (null if not started). */
|
|
940
|
+
status: WorkflowStatus | null;
|
|
941
|
+
/** All events emitted so far. */
|
|
942
|
+
events: WorkflowEvent[];
|
|
943
|
+
/** Stop the running workflow. */
|
|
944
|
+
stop: () => void;
|
|
945
|
+
}
|
|
946
|
+
declare function useWorkflowRunner(options?: UseWorkflowRunnerOptions): UseWorkflowRunnerReturn;
|
|
947
|
+
|
|
948
|
+
interface WorkflowProgressProps {
|
|
949
|
+
workflow: WorkflowDefinition;
|
|
950
|
+
className?: string;
|
|
951
|
+
/** Show step details (kind, result preview) */
|
|
952
|
+
detailed?: boolean;
|
|
953
|
+
}
|
|
954
|
+
declare function WorkflowProgress({ workflow, className, detailed }: WorkflowProgressProps): react_jsx_runtime.JSX.Element;
|
|
955
|
+
|
|
820
956
|
declare const buttonVariants: {
|
|
821
957
|
variant: {
|
|
822
958
|
default: string;
|
|
@@ -1129,4 +1265,4 @@ interface UserMessageRendererProps {
|
|
|
1129
1265
|
}
|
|
1130
1266
|
declare const UserMessageRenderer: React__default.FC<UserMessageRendererProps>;
|
|
1131
1267
|
|
|
1132
|
-
export { ASK_FOLLOW_UP_TOOL_NAME, AgentSelect, type AskFollowUpInput, type AskFollowUpOutput, AssistantMessageRenderer, type AssistantMessageRendererProps, type AttachedImage, AuthLoading, type AuthStatus, Badge, BrowserPreviewPanel, BrowserViewport, type BrowserViewportProps, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Chat, type ChatContainerProps, type ChatCustomRenderers, type ChatEmptyStateCategory, type ChatEmptyStateController, type ChatEmptyStateOptions, type ChatEmptyStateStarter, ChatInner, ChatInput, type ChatInputProps, type ChatInstance, type ChatProps, type ChatState, type ChatStateStore, ConfigurationPanel, DialogRoot as Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger, type DistriAnyTool, DistriAuthProvider, DistriContext, DistriProvider, type DistriUiTool, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, type ExtractedContent, type FollowUpQuestion, ImageRenderer, type ImageRendererProps, Input, LoadingAnimation, type LoadingAnimationConfig, type LoadingAnimationPreset, type LoadingAnimationProps, LoadingShimmer, MessageFeedback, type MessageFeedbackProps, MessageReadProvider, type MessageReadProviderProps, MessageReadTracker, type MessageReadTrackerProps, MessageRenderer, type MessageRendererProps, type ModelOption, type PlanState, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, StepBasedRenderer, type StepBasedRendererProps, type StepState, type StreamingIndicator, StreamingTextRenderer, type StreamingTtsOptions, type TaskState, Textarea, ThemeProvider, ThemeToggle, ThinkingRenderer, type ThinkingRendererProps, TodosDisplay, type TodosDisplayProps, type ToolCallState, type ToolCallStatus, type ToolRendererMap, type ToolRendererProps, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, type TtsConfig, type TtsRequest, TypingIndicator, type UiToolProps, type UseAgentOptions, type UseAgentResult, type UseAgentsByUsageOptions, type UseAgentsByUsageResult, type UseAgentsResult, type UseChatMessagesOptions, type UseChatMessagesReturn, type UseChatOptions, type UseChatReturn, type UseConfigurationResult, type UseMessageReadStatusOptions, type UseMessageReadStatusResult, type UseMessageVoteOptions, type UseMessageVoteResult, type UseMessageVotesOptions, type UseMessageVotesResult, type UseThreadMessagesOptions, type UseThreadReadStatusOptions, type UseThreadReadStatusResult, type UseThreadsOptions, type UseThreadsResult, UserMessageRenderer, type UserMessageRendererProps, VoiceInput, type VoiceInputProps, createAskFollowUpTool, extractContent, useAgent, useAgentDefinitions, useAgentsByUsage, useChat, useChatMessages, useChatStateStore, useConfiguration, useDistri, useDistriAuth, useDistriToken, useMessageReadContext, useMessageReadStatus, useMessageVote, useMessageVotes, useSidebar, useSpeechToText, useTheme, useThreadReadStatus, useThreads, useTts, useWorkspace, wrapFnToolAsUiTool, wrapTools };
|
|
1268
|
+
export { ASK_FOLLOW_UP_TOOL_NAME, AgentSelect, type AskFollowUpInput, type AskFollowUpOutput, AssistantMessageRenderer, type AssistantMessageRendererProps, type AttachedImage, AuthLoading, type AuthStatus, Badge, BrowserPreviewPanel, BrowserViewport, type BrowserViewportProps, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Chat, type ChatContainerProps, type ChatCustomRenderers, type ChatEmptyStateCategory, type ChatEmptyStateController, type ChatEmptyStateOptions, type ChatEmptyStateStarter, ChatInner, ChatInput, type ChatInputProps, type ChatInstance, type ChatProps, type ChatState, type ChatStateStore, ConfigurationPanel, ContextIndicator, DialogRoot as Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger, type DistriAnyTool, DistriAuthProvider, DistriContext, DistriProvider, type DistriUiTool, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, type ExtractedContent, type FollowUpQuestion, ImageRenderer, type ImageRendererProps, Input, LoadingAnimation, type LoadingAnimationConfig, type LoadingAnimationPreset, type LoadingAnimationProps, LoadingShimmer, MessageFeedback, type MessageFeedbackProps, MessageReadProvider, type MessageReadProviderProps, MessageReadTracker, type MessageReadTrackerProps, MessageRenderer, type MessageRendererProps, type ModelOption, type PlanState, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, StepBasedRenderer, type StepBasedRendererProps, type StepState, type StreamingIndicator, StreamingTextRenderer, type StreamingTtsOptions, type TaskState, Textarea, ThemeProvider, ThemeToggle, ThinkingRenderer, type ThinkingRendererProps, TodosDisplay, type TodosDisplayProps, type ToolCallState, type ToolCallStatus, type ToolRendererMap, type ToolRendererProps, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, type TtsConfig, type TtsRequest, TypingIndicator, type UiToolProps, type UseAgentOptions, type UseAgentResult, type UseAgentsByUsageOptions, type UseAgentsByUsageResult, type UseAgentsResult, type UseChatMessagesOptions, type UseChatMessagesReturn, type UseChatOptions, type UseChatReturn, type UseConfigurationResult, type UseMessageReadStatusOptions, type UseMessageReadStatusResult, type UseMessageVoteOptions, type UseMessageVoteResult, type UseMessageVotesOptions, type UseMessageVotesResult, type UseModelsResult, type UseThreadMessagesOptions, type UseThreadReadStatusOptions, type UseThreadReadStatusResult, type UseThreadsOptions, type UseThreadsResult, type UseWorkflowOptions, type UseWorkflowReturn, type UseWorkflowRunnerOptions, type UseWorkflowRunnerReturn, UserMessageRenderer, type UserMessageRendererProps, VoiceInput, type VoiceInputProps, WorkflowProgress, type WorkflowProgressProps, createAskFollowUpTool, extractContent, useAgent, useAgentDefinitions, useAgentsByUsage, useChat, useChatMessages, useChatStateStore, useConfiguration, useContextHealth, useDistri, useDistriAuth, useDistriToken, useMessageReadContext, useMessageReadStatus, useMessageVote, useMessageVotes, useModels, useSidebar, useSpeechToText, useTheme, useThreadReadStatus, useThreads, useTts, useWorkflow, useWorkflowRunner, useWorkspace, wrapFnToolAsUiTool, wrapTools };
|