orchid-ai 1.0.0

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.
Files changed (52) hide show
  1. package/README.md +225 -0
  2. package/dist/components/ChatPanel.d.ts +123 -0
  3. package/dist/components/Conversation.d.ts +75 -0
  4. package/dist/components/ErrorBoundary.d.ts +16 -0
  5. package/dist/components/Icon.d.ts +84 -0
  6. package/dist/components/ModelSwitcher.d.ts +24 -0
  7. package/dist/components/SuggestionsPanel.d.ts +27 -0
  8. package/dist/constants.d.ts +353 -0
  9. package/dist/hooks/useAiMerge.d.ts +20 -0
  10. package/dist/hooks/useModelSwitcher.d.ts +65 -0
  11. package/dist/hooks/useStreamingAI.d.ts +29 -0
  12. package/dist/hooks/useSuggestions.d.ts +48 -0
  13. package/dist/index.d.ts +13 -0
  14. package/dist/index.esm.js +3385 -0
  15. package/dist/index.js +3400 -0
  16. package/dist/server/components/ChatPanel.d.ts +123 -0
  17. package/dist/server/components/Conversation.d.ts +75 -0
  18. package/dist/server/components/ErrorBoundary.d.ts +16 -0
  19. package/dist/server/components/Icon.d.ts +84 -0
  20. package/dist/server/components/ModelSwitcher.d.ts +24 -0
  21. package/dist/server/components/SuggestionsPanel.d.ts +27 -0
  22. package/dist/server/constants.d.ts +353 -0
  23. package/dist/server/contextual-service.d.ts +59 -0
  24. package/dist/server/document-processor.d.ts +60 -0
  25. package/dist/server/hooks/useAiMerge.d.ts +20 -0
  26. package/dist/server/hooks/useModelSwitcher.d.ts +65 -0
  27. package/dist/server/hooks/useStreamingAI.d.ts +29 -0
  28. package/dist/server/hooks/useSuggestions.d.ts +48 -0
  29. package/dist/server/index.d.ts +7 -0
  30. package/dist/server/index.esm.js +14008 -0
  31. package/dist/server/index.js +14019 -0
  32. package/dist/server/server/contextual-service.d.ts +59 -0
  33. package/dist/server/server/document-processor.d.ts +60 -0
  34. package/dist/server/server/index.d.ts +7 -0
  35. package/dist/server/server/server.d.ts +32 -0
  36. package/dist/server/server/service.d.ts +267 -0
  37. package/dist/server/server/training-schema.d.ts +17 -0
  38. package/dist/server/server/training.d.ts +231 -0
  39. package/dist/server/server/utils.d.ts +209 -0
  40. package/dist/server/server.d.ts +32 -0
  41. package/dist/server/service.d.ts +267 -0
  42. package/dist/server/training-schema.d.ts +17 -0
  43. package/dist/server/training.d.ts +231 -0
  44. package/dist/server/types/types.d.ts +481 -0
  45. package/dist/server/utils/fileHandler.d.ts +20 -0
  46. package/dist/server/utils/mergeWithAi.d.ts +19 -0
  47. package/dist/server/utils.d.ts +209 -0
  48. package/dist/types/types.d.ts +481 -0
  49. package/dist/utils/fileHandler.d.ts +20 -0
  50. package/dist/utils/mergeWithAi.d.ts +19 -0
  51. package/dist/utils.d.ts +19 -0
  52. package/package.json +137 -0
@@ -0,0 +1,123 @@
1
+ import React from 'react';
2
+ import { CommandTheme, ChatMessage, ModelInfo, ChatTheme, ServerConfig } from '../types/types';
3
+ interface ChatPanelProps {
4
+ isOpen: boolean;
5
+ setIsOpen?: (isOpen: boolean) => void;
6
+ onClose: () => void;
7
+ onOpen?: () => void;
8
+ userId: string;
9
+ formData?: Record<string, unknown>;
10
+ setFormState: (state: Record<string, unknown>, actionType: string) => void;
11
+ onNavigate: (path: string) => void;
12
+ theme?: CommandTheme;
13
+ chatTheme?: Partial<ChatTheme>;
14
+ themeMode?: 'light' | 'dark' | 'system';
15
+ showHistory?: boolean;
16
+ showProfileBubbles?: boolean;
17
+ modalPosition?: 'left' | 'right';
18
+ serverConfig?: ServerConfig;
19
+ models?: Record<string, ModelInfo[]>;
20
+ defaultModel?: {
21
+ provider: string;
22
+ model: string;
23
+ };
24
+ showUsageStats?: boolean;
25
+ maxFileSize?: string;
26
+ features?: {
27
+ modelSwitching?: boolean;
28
+ usageTracking?: boolean;
29
+ imageAnalysis?: boolean;
30
+ fileUploads?: boolean;
31
+ enableImageUploads?: boolean;
32
+ };
33
+ showFloatingButton?: boolean;
34
+ floatingButtonIcon?: React.ReactNode;
35
+ floatingButtonPosition?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
36
+ floatingButtonSize?: 'sm' | 'md' | 'lg';
37
+ floatingButtonClassName?: string;
38
+ chats?: Record<string, ChatMessage[]>;
39
+ setChats?: React.Dispatch<React.SetStateAction<Record<string, ChatMessage[]>>>;
40
+ currentChatId?: string;
41
+ setCurrentChatId?: React.Dispatch<React.SetStateAction<string>>;
42
+ chatLevel?: 'full' | 'basic' | 'none';
43
+ initialQuery?: {
44
+ query: string;
45
+ context?: string;
46
+ };
47
+ setInitialQuery?: React.Dispatch<React.SetStateAction<{
48
+ query: string;
49
+ context?: string;
50
+ } | undefined>>;
51
+ }
52
+ /**
53
+ * ChatPanel component
54
+ * @param isOpen - Whether the chat panel is open
55
+ * @param setIsOpen - Function to set the chat panel open state
56
+ * @param onClose - Function to close the chat panel
57
+ * @param onOpen - Function to open the chat panel
58
+ * @param userId - User ID - used to identify the user in the streaming server
59
+ * @param formData - Form data - used to reference the existing form data in the streaming server
60
+ * @param setFormState - Function to set the form state
61
+ * @param onNavigate - Function to navigate to a new path
62
+ * @param theme - Theme
63
+ * @param showHistory - Whether to show chat history sidebar (default: false)
64
+ * @param showProfileBubbles - Whether to show profile bubbles in chat (default: false)
65
+ * @param serverConfig - Flexible server configuration object
66
+ * @param showFloatingButton - Whether to show the floating button
67
+ * @param floatingButtonIcon - Icon for the floating button
68
+ * @param floatingButtonPosition - Position of the floating button
69
+ * @param floatingButtonSize - Size of the floating button
70
+ * @param floatingButtonClassName - Class name for the floating button
71
+ * @param chats - Optional external chat history
72
+ * @param setChats - Optional function to set external chat history
73
+ * @param currentChatId - Optional external current chat ID
74
+ * @param setCurrentChatId - Optional function to set external current chat ID
75
+ * @param chatLevel - Optional chat level - 'full' or 'basic' or 'none'
76
+ * @param initialQuery - Optional initial query to send when modal opens
77
+ * @param setInitialQuery - Optional function to set/clear the initial query
78
+ */
79
+ export declare function ChatPanel({ isOpen, setIsOpen, onClose, onOpen, userId, formData, setFormState, onNavigate, theme, // Legacy support
80
+ chatTheme, // New theme system
81
+ themeMode, // Default to system preference
82
+ showHistory, // Default to hidden
83
+ showProfileBubbles, // Default to hidden
84
+ modalPosition, // Default to left position
85
+ serverConfig, models, defaultModel, showUsageStats, maxFileSize, features, showFloatingButton, floatingButtonIcon, floatingButtonPosition, floatingButtonSize, floatingButtonClassName, chats, setChats, currentChatId, setCurrentChatId, chatLevel, initialQuery, setInitialQuery, }: ChatPanelProps): import("react/jsx-runtime").JSX.Element;
86
+ /**
87
+ * ChatInput component
88
+ * @param query - The current query
89
+ * @param setQuery - Function to set the query
90
+ * @param onSend - Function to send the query
91
+ * @param isLoading - Whether the input is loading
92
+ * @param inputRef - Ref to the textarea element
93
+ * @param attachedFiles - Array of attached files
94
+ * @param setAttachedFiles - Function to set the attached files
95
+ * @param serverConfig - Flexible server configuration object
96
+ * @param modelsByProvider - Models by provider
97
+ * @param currentModel - Current model
98
+ * @param currentCapabilities - Current model capabilities
99
+ * @param usageStats - Usage stats
100
+ * @param modelSwitcherLoading - Model switcher loading
101
+ * @param modelSwitcherError - Model switcher error
102
+ * @param switchModel - Function to switch model
103
+ * @param integrationMode - Integration mode
104
+ */
105
+ type FloatingChatButtonProps = {
106
+ onClick: () => void;
107
+ theme?: CommandTheme;
108
+ icon?: React.ReactNode;
109
+ className?: string;
110
+ position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
111
+ size?: 'sm' | 'md' | 'lg';
112
+ };
113
+ /**
114
+ * FloatingChatButton component
115
+ * @param onClick - Function to handle the click event
116
+ * @param theme - Theme
117
+ * @param icon - Icon for the floating button
118
+ * @param className - Class name for the floating button
119
+ * @param position - Position of the floating button
120
+ * @param size - Size of the floating button
121
+ */
122
+ export declare function FloatingChatButton({ onClick, theme, icon, className, position, size, }: FloatingChatButtonProps): import("react/jsx-runtime").JSX.Element;
123
+ export {};
@@ -0,0 +1,75 @@
1
+ import React from 'react';
2
+ import { CommandSuggestion, ChatMessage, ChatTheme, ModelInfo, ModelCapabilities, ServerConfig } from '../types/types';
3
+ interface ConversationProps {
4
+ chat?: ChatMessage[];
5
+ onSuggestionClick: (s: CommandSuggestion) => void;
6
+ theme: ChatTheme;
7
+ showProfileBubbles?: boolean;
8
+ className?: string;
9
+ autoScroll?: boolean;
10
+ maxHeight?: string;
11
+ userId?: string;
12
+ serverConfig?: ServerConfig;
13
+ formData?: Record<string, unknown>;
14
+ setFormState?: (state: Record<string, unknown>, actionType: string) => void;
15
+ onNavigate?: (path: string) => void;
16
+ chatLevel?: 'full' | 'basic' | 'none';
17
+ chats?: Record<string, ChatMessage[]>;
18
+ setChats?: React.Dispatch<React.SetStateAction<Record<string, ChatMessage[]>>>;
19
+ currentChatId?: string;
20
+ setCurrentChatId?: React.Dispatch<React.SetStateAction<string>>;
21
+ query?: string;
22
+ setQuery?: (q: string) => void;
23
+ onSend?: (additionalContext?: string, queryToSend?: string) => void;
24
+ isLoading?: boolean;
25
+ attachedFiles?: File[];
26
+ setAttachedFiles?: (files: File[]) => void;
27
+ models?: Record<string, ModelInfo[]>;
28
+ defaultModel?: {
29
+ provider: string;
30
+ model: string;
31
+ };
32
+ showUsageStats?: boolean;
33
+ maxFileSize?: string;
34
+ features?: {
35
+ modelSwitching?: boolean;
36
+ usageTracking?: boolean;
37
+ imageAnalysis?: boolean;
38
+ fileUploads?: boolean;
39
+ enableImageUploads?: boolean;
40
+ };
41
+ currentModelSelection?: {
42
+ provider: string;
43
+ model: string;
44
+ capabilities: ModelCapabilities;
45
+ };
46
+ onModelSelectionChange?: (modelInfo: {
47
+ provider: string;
48
+ model: string;
49
+ capabilities: ModelCapabilities;
50
+ }) => void;
51
+ showInput?: boolean;
52
+ initialQuery?: {
53
+ query: string;
54
+ context?: string;
55
+ };
56
+ setInitialQuery?: React.Dispatch<React.SetStateAction<{
57
+ query: string;
58
+ context?: string;
59
+ } | undefined>>;
60
+ showClearChat?: boolean;
61
+ onClearChat?: () => void;
62
+ additionalContext?: string | Record<string, unknown>;
63
+ }
64
+ /**
65
+ * Conversation component - displays a single chat conversation
66
+ * @param chat - The chat messages to display
67
+ * @param onSuggestionClick - Function to handle suggestion clicks
68
+ * @param theme - Chat theme
69
+ * @param showProfileBubbles - Whether to show profile bubbles
70
+ * @param className - Additional CSS classes
71
+ * @param autoScroll - Whether to auto-scroll to bottom on new messages
72
+ * @param maxHeight - Maximum height of the conversation container
73
+ */
74
+ export declare function Conversation({ chat: externalChat, onSuggestionClick, theme, showProfileBubbles, className, autoScroll, maxHeight, userId, serverConfig, formData, setFormState, onNavigate, chatLevel, chats: externalChats, setChats: externalSetChats, currentChatId: externalCurrentChatId, setCurrentChatId: externalSetCurrentChatId, query: externalQuery, setQuery: externalSetQuery, onSend: externalOnSend, isLoading: externalIsLoading, attachedFiles: externalAttachedFiles, setAttachedFiles: externalSetAttachedFiles, models, defaultModel, showUsageStats, maxFileSize, features, currentModelSelection: externalCurrentModelSelection, onModelSelectionChange: externalOnModelSelectionChange, showInput, initialQuery, setInitialQuery, showClearChat, onClearChat, additionalContext, }: ConversationProps): import("react/jsx-runtime").JSX.Element;
75
+ export {};
@@ -0,0 +1,16 @@
1
+ import React, { Component, ErrorInfo, ReactNode } from 'react';
2
+ interface Props {
3
+ children: ReactNode;
4
+ fallback?: ReactNode;
5
+ }
6
+ interface State {
7
+ hasError: boolean;
8
+ error?: Error;
9
+ }
10
+ export declare class ErrorBoundary extends Component<Props, State> {
11
+ constructor(props: Props);
12
+ static getDerivedStateFromError(error: Error): State;
13
+ componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
14
+ render(): string | number | boolean | import("react/jsx-runtime").JSX.Element | Iterable<React.ReactNode> | null | undefined;
15
+ }
16
+ export {};
@@ -0,0 +1,84 @@
1
+ import React from 'react';
2
+ import { Action } from '../types/types';
3
+ /**
4
+ * Universal Icon Component
5
+ *
6
+ * A flexible, centralized icon system that supports all UI, action, and file type icons.
7
+ * Can return React components or SVG strings for vanilla JavaScript applications.
8
+ *
9
+ * @example
10
+ * // React usage with preset sizes
11
+ * <Icon name="ai" size="md" />
12
+ * <Icon name="user" size="lg" className="text-blue-500" />
13
+ *
14
+ * // Custom size (numeric pixels)
15
+ * <Icon name="pdf" size={32} />
16
+ *
17
+ * // With custom styling
18
+ * <Icon name="send" size="sm" color="#ff0000" style={{ opacity: 0.8 }} />
19
+ *
20
+ * // Vanilla JS usage - get SVG string
21
+ * const svgString = getIcon('plus', { size: 24 });
22
+ *
23
+ * // Action-based icon selection
24
+ * const editIcon = getActionIcon('edit', 'react'); // Returns React component
25
+ * const editSvg = getActionIcon('edit', 'vanilla'); // Returns SVG string
26
+ *
27
+ * // Available sizes: 'xs' (12px), 'sm' (16px), 'md' (20px), 'lg' (24px), 'xl' (32px)
28
+ * // Or any numeric value for custom pixel size
29
+ */
30
+ export type IconSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number;
31
+ export type IconName = 'ai' | 'user' | 'system' | 'paperclip' | 'image' | 'noImage' | 'microphone' | 'send' | 'plus' | 'pencil' | 'trash' | 'eye' | 'claude' | 'openai' | 'gemini' | 'grok' | 'error' | 'warning' | 'timeout' | 'auth-error' | 'pdf' | 'word' | 'excel' | 'csv' | 'text' | 'rtf' | 'file-generic';
32
+ export interface IconProps {
33
+ name: IconName;
34
+ size?: IconSize;
35
+ className?: string;
36
+ color?: string;
37
+ style?: React.CSSProperties;
38
+ }
39
+ export interface VanillaIconOptions {
40
+ size?: IconSize;
41
+ color?: string;
42
+ className?: string;
43
+ }
44
+ export declare const getIconNameForAction: (action: Action) => IconName | null;
45
+ export declare const Icon: React.FC<IconProps>;
46
+ /**
47
+ * Get an icon as an SVG string for vanilla JavaScript applications
48
+ * @param name - Icon name
49
+ * @param options - Icon options (size, color, className)
50
+ * @returns SVG string or null if icon not found
51
+ */
52
+ export declare const getIcon: (name: IconName, options?: VanillaIconOptions) => string | null;
53
+ /**
54
+ * Universal action icon function - works for both React and vanilla JS
55
+ * @param action - Action type string
56
+ * @param framework - Target framework ('react' or 'vanilla')
57
+ * @param options - Icon options (only used for vanilla)
58
+ * @returns React component or SVG string based on framework
59
+ */
60
+ export declare const getActionIcon: (action: Action, framework?: "react" | "vanilla", options?: VanillaIconOptions) => React.ReactElement | string | null;
61
+ /**
62
+ * Get action icon as React component (legacy compatibility)
63
+ * @param action - Action type string
64
+ * @returns React component or null
65
+ */
66
+ export declare const getActionIconReact: (action: Action) => React.ReactElement | null;
67
+ /**
68
+ * Get action icon as SVG string (legacy compatibility)
69
+ * @param action - Action type string
70
+ * @returns SVG string or null
71
+ */
72
+ export declare const getActionIconString: (action: Action) => string | null;
73
+ /**
74
+ * Get provider icon name for AI providers
75
+ * @param provider - Provider name (openai, claude, gemini)
76
+ * @returns Icon name or null if not found
77
+ */
78
+ export declare const getProviderIconName: (provider: string | undefined) => IconName | null;
79
+ export declare const Icons: Record<IconName, (props: {
80
+ size: number;
81
+ className?: string;
82
+ color?: string;
83
+ }) => React.ReactElement>;
84
+ export default Icon;
@@ -0,0 +1,24 @@
1
+ import { ModelCapabilities, ModelInfo, ChatTheme } from '../types/types';
2
+ interface ModelSwitcherProps {
3
+ className?: string;
4
+ models?: Record<string, ModelInfo[]>;
5
+ defaultModel?: {
6
+ provider: string;
7
+ model: string;
8
+ };
9
+ showUsageStats?: boolean;
10
+ theme?: ChatTheme;
11
+ onModelSelectionChange?: (modelInfo: {
12
+ provider: string;
13
+ model: string;
14
+ capabilities: ModelCapabilities;
15
+ }) => void;
16
+ }
17
+ /**
18
+ * ModelSwitcher component for switching between AI models
19
+ * Now uses the simplified useModelSwitcher hook directly
20
+ * Uses Tailwind classes for styling
21
+ */
22
+ export declare function ModelSwitcher({ className, models, defaultModel, showUsageStats, // Default to false to match modal design
23
+ theme, onModelSelectionChange, }: ModelSwitcherProps): import("react/jsx-runtime").JSX.Element;
24
+ export {};
@@ -0,0 +1,27 @@
1
+ import { CommandSuggestion, ChatTheme, ServerConfig } from '../types/types';
2
+ interface SuggestionsPanelProps {
3
+ query: string;
4
+ onSuggestionSelect: (suggestion: CommandSuggestion) => void;
5
+ onClose?: () => void;
6
+ userId: string;
7
+ formData?: Record<string, unknown>;
8
+ serverConfig?: ServerConfig;
9
+ theme?: ChatTheme;
10
+ isLoading?: boolean;
11
+ placeholder?: string;
12
+ maxSuggestions?: number;
13
+ showIcons?: boolean;
14
+ className?: string;
15
+ }
16
+ export interface SuggestionCardProps {
17
+ suggestion: CommandSuggestion;
18
+ onClick: (s: CommandSuggestion) => void;
19
+ isHighlighted?: boolean;
20
+ theme?: ChatTheme;
21
+ showIcon?: boolean;
22
+ }
23
+ export declare function SuggestionCard({ suggestion, onClick, isHighlighted, theme, showIcon, }: SuggestionCardProps): import("react/jsx-runtime").JSX.Element;
24
+ export declare function SuggestionsPanel({ query, onSuggestionSelect, onClose, userId, formData, serverConfig, theme, isLoading, placeholder, maxSuggestions, showIcons, className, context, }: SuggestionsPanelProps & {
25
+ context?: string;
26
+ }): import("react/jsx-runtime").JSX.Element;
27
+ export default SuggestionsPanel;