orchid-ai 1.1.0 → 1.2.1

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 (58) hide show
  1. package/README.md +29 -0
  2. package/dist/cli/cli/generate-schemas.d.ts +1 -0
  3. package/dist/cli/components/ChatPanel.d.ts +131 -0
  4. package/dist/cli/components/Conversation.d.ts +75 -0
  5. package/dist/cli/components/ErrorBoundary.d.ts +16 -0
  6. package/dist/cli/components/Icon.d.ts +84 -0
  7. package/dist/cli/components/ModelSwitcher.d.ts +24 -0
  8. package/dist/cli/components/SuggestionsPanel.d.ts +27 -0
  9. package/dist/cli/constants.d.ts +353 -0
  10. package/dist/cli/generate-schemas.d.ts +1 -0
  11. package/dist/cli/generate-schemas.js +2595 -0
  12. package/dist/cli/hooks/useAiMerge.d.ts +20 -0
  13. package/dist/cli/hooks/useModelSwitcher.d.ts +65 -0
  14. package/dist/cli/hooks/useStreamingAI.d.ts +29 -0
  15. package/dist/cli/hooks/useSuggestions.d.ts +48 -0
  16. package/dist/cli/index.d.ts +13 -0
  17. package/dist/cli/server/contextual-service.d.ts +59 -0
  18. package/dist/cli/server/document-processor.d.ts +60 -0
  19. package/dist/cli/server/index.d.ts +14 -0
  20. package/dist/cli/server/intent-detection.d.ts +132 -0
  21. package/dist/cli/server/monastery-analyzer.d.ts +53 -0
  22. package/dist/cli/server/mongodb-rag.d.ts +106 -0
  23. package/dist/cli/server/schema-generator.d.ts +150 -0
  24. package/dist/cli/server/server.d.ts +32 -0
  25. package/dist/cli/server/service.d.ts +267 -0
  26. package/dist/cli/server/training-schema.d.ts +17 -0
  27. package/dist/cli/server/training.d.ts +232 -0
  28. package/dist/cli/server/typescript-analyzer.d.ts +56 -0
  29. package/dist/cli/server/utils.d.ts +209 -0
  30. package/dist/cli/types/types.d.ts +502 -0
  31. package/dist/cli/utils/fileHandler.d.ts +20 -0
  32. package/dist/cli/utils.d.ts +19 -0
  33. package/dist/components/ChatPanel.d.ts +9 -1
  34. package/dist/components/Icon.d.ts +1 -1
  35. package/dist/index.esm.js +118 -92
  36. package/dist/index.js +118 -92
  37. package/dist/server/cli/generate-schemas.d.ts +1 -0
  38. package/dist/server/components/ChatPanel.d.ts +9 -1
  39. package/dist/server/components/Icon.d.ts +1 -1
  40. package/dist/server/index.d.ts +3 -0
  41. package/dist/server/index.esm.js +1704 -155
  42. package/dist/server/index.js +1707 -154
  43. package/dist/server/intent-detection.d.ts +18 -4
  44. package/dist/server/monastery-analyzer.d.ts +53 -0
  45. package/dist/server/schema-generator.d.ts +150 -0
  46. package/dist/server/server/index.d.ts +3 -0
  47. package/dist/server/server/intent-detection.d.ts +18 -4
  48. package/dist/server/server/monastery-analyzer.d.ts +53 -0
  49. package/dist/server/server/schema-generator.d.ts +150 -0
  50. package/dist/server/server/training.d.ts +2 -1
  51. package/dist/server/server/typescript-analyzer.d.ts +56 -0
  52. package/dist/server/server/utils.d.ts +1 -1
  53. package/dist/server/training.d.ts +2 -1
  54. package/dist/server/types/types.d.ts +15 -0
  55. package/dist/server/typescript-analyzer.d.ts +56 -0
  56. package/dist/server/utils.d.ts +1 -1
  57. package/dist/types/types.d.ts +15 -0
  58. package/package.json +5 -1
package/README.md CHANGED
@@ -93,8 +93,37 @@ The system automatically discovers and structures your application data:
93
93
  - **Enhanced Context Understanding**: Relationship mapping and business rules
94
94
  - **Consistent JSON Output**: Reliable formatting across all chat levels
95
95
 
96
+ ## Schema Generation
97
+
98
+ Generate AI-ready schemas from your TypeScript types and Monastery models:
99
+
100
+ ```bash
101
+ # Generate schemas.ts in your project root
102
+ npx orchid-generate-schemas init
103
+
104
+ # Interactive mode (prompts for each model)
105
+ npx orchid-generate-schemas init --interactive
106
+
107
+ # Custom output location
108
+ npx orchid-generate-schemas init --schemas-path src/schemas.ts
109
+
110
+ # Verbose output
111
+ npx orchid-generate-schemas init --verbose
112
+ ```
113
+
114
+ **What it generates:**
115
+ - `SchemaDefinition` objects from TypeScript interfaces
116
+ - Automatic CRUD route detection from TSX files
117
+ - Monastery model integration
118
+ - Ready-to-use schemas for `ContextualCommandService`
119
+
120
+ See [Schema Generation Guide](docs/SCHEMA_GENERATION.md) for detailed usage.
121
+
96
122
  ## Documentation
97
123
 
124
+ - [**Schema Generation**](docs/SCHEMA_GENERATION.md)
125
+ Auto-generate schemas from TypeScript types and Monastery models
126
+
98
127
  - [**Training Data Setup**](docs/training.md)
99
128
  Configure structured training data with provider-specific optimization
100
129
 
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,131 @@
1
+ import React from 'react';
2
+ import { type IconName } from './Icon';
3
+ import { CommandTheme, ChatMessage, ModelInfo, ChatTheme, ServerConfig } from '../types/types';
4
+ interface ChatPanelProps {
5
+ isOpen: boolean;
6
+ setIsOpen?: (isOpen: boolean) => void;
7
+ onClose: () => void;
8
+ onOpen?: () => void;
9
+ userId: string;
10
+ formData?: Record<string, unknown>;
11
+ setFormState: (state: Record<string, unknown>, actionType: string) => void;
12
+ onNavigate: (path: string) => void;
13
+ theme?: CommandTheme;
14
+ chatTheme?: Partial<ChatTheme>;
15
+ themeMode?: 'light' | 'dark' | 'system';
16
+ showHistory?: boolean;
17
+ showProfileBubbles?: boolean;
18
+ modalPosition?: 'left' | 'right';
19
+ serverConfig?: ServerConfig;
20
+ models?: Record<string, ModelInfo[]>;
21
+ defaultModel?: {
22
+ provider: string;
23
+ model: string;
24
+ };
25
+ showUsageStats?: boolean;
26
+ maxFileSize?: string;
27
+ features?: {
28
+ modelSwitching?: boolean;
29
+ usageTracking?: boolean;
30
+ imageAnalysis?: boolean;
31
+ fileUploads?: boolean;
32
+ enableImageUploads?: boolean;
33
+ };
34
+ showFloatingButton?: boolean;
35
+ floatingButtonIcon?: React.ReactNode;
36
+ floatingButtonPosition?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
37
+ floatingButtonSize?: 'sm' | 'md' | 'lg';
38
+ floatingButtonClassName?: string;
39
+ chats?: Record<string, ChatMessage[]>;
40
+ setChats?: React.Dispatch<React.SetStateAction<Record<string, ChatMessage[]>>>;
41
+ currentChatId?: string;
42
+ setCurrentChatId?: React.Dispatch<React.SetStateAction<string>>;
43
+ chatLevel?: 'full' | 'basic' | 'none';
44
+ initialQuery?: {
45
+ query: string;
46
+ context?: string;
47
+ };
48
+ setInitialQuery?: React.Dispatch<React.SetStateAction<{
49
+ query: string;
50
+ context?: string;
51
+ } | undefined>>;
52
+ headerIcon?: IconName;
53
+ headerTitle?: string;
54
+ headerSubtitle?: string;
55
+ }
56
+ /**
57
+ * ChatPanel component
58
+ * @param isOpen - Whether the chat panel is open
59
+ * @param setIsOpen - Function to set the chat panel open state
60
+ * @param onClose - Function to close the chat panel
61
+ * @param onOpen - Function to open the chat panel
62
+ * @param userId - User ID - used to identify the user in the streaming server
63
+ * @param formData - Form data - used to reference the existing form data in the streaming server
64
+ * @param setFormState - Function to set the form state
65
+ * @param onNavigate - Function to navigate to a new path
66
+ * @param theme - Theme
67
+ * @param showHistory - Whether to show chat history sidebar (default: false)
68
+ * @param showProfileBubbles - Whether to show profile bubbles in chat (default: false)
69
+ * @param serverConfig - Flexible server configuration object
70
+ * @param showFloatingButton - Whether to show the floating button
71
+ * @param floatingButtonIcon - Icon for the floating button
72
+ * @param floatingButtonPosition - Position of the floating button
73
+ * @param floatingButtonSize - Size of the floating button
74
+ * @param floatingButtonClassName - Class name for the floating button
75
+ * @param chats - Optional external chat history
76
+ * @param setChats - Optional function to set external chat history
77
+ * @param currentChatId - Optional external current chat ID
78
+ * @param setCurrentChatId - Optional function to set external current chat ID
79
+ * @param chatLevel - Optional chat level - 'full' or 'basic' or 'none'
80
+ * @param initialQuery - Optional initial query to send when modal opens
81
+ * @param setInitialQuery - Optional function to set/clear the initial query
82
+ * @param headerIcon - Optional icon name to display in header (default: 'command' bot icon)
83
+ * @param headerTitle - Optional header title text (default: 'AI Logistics & Customs Expert')
84
+ * @param headerSubtitle - Optional header subtitle text (default: 'Ready to assist you with your queries')
85
+ */
86
+ export declare function ChatPanel({ isOpen, setIsOpen, onClose, onOpen, userId, formData, setFormState, onNavigate, theme, // Legacy support
87
+ chatTheme, // New theme system
88
+ themeMode, // Default to system preference
89
+ showHistory, // Default to hidden
90
+ showProfileBubbles, // Default to hidden
91
+ modalPosition, // Default to left position
92
+ serverConfig, models, defaultModel, showUsageStats, maxFileSize, features, showFloatingButton, floatingButtonIcon, floatingButtonPosition, floatingButtonSize, floatingButtonClassName, chats, setChats, currentChatId, setCurrentChatId, chatLevel, initialQuery, setInitialQuery, headerIcon, // Default to bot icon
93
+ headerTitle, headerSubtitle, }: ChatPanelProps): import("react/jsx-runtime").JSX.Element;
94
+ /**
95
+ * ChatInput component
96
+ * @param query - The current query
97
+ * @param setQuery - Function to set the query
98
+ * @param onSend - Function to send the query
99
+ * @param isLoading - Whether the input is loading
100
+ * @param inputRef - Ref to the textarea element
101
+ * @param attachedFiles - Array of attached files
102
+ * @param setAttachedFiles - Function to set the attached files
103
+ * @param serverConfig - Flexible server configuration object
104
+ * @param modelsByProvider - Models by provider
105
+ * @param currentModel - Current model
106
+ * @param currentCapabilities - Current model capabilities
107
+ * @param usageStats - Usage stats
108
+ * @param modelSwitcherLoading - Model switcher loading
109
+ * @param modelSwitcherError - Model switcher error
110
+ * @param switchModel - Function to switch model
111
+ * @param integrationMode - Integration mode
112
+ */
113
+ type FloatingChatButtonProps = {
114
+ onClick: () => void;
115
+ theme?: CommandTheme;
116
+ icon?: React.ReactNode;
117
+ className?: string;
118
+ position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
119
+ size?: 'sm' | 'md' | 'lg';
120
+ };
121
+ /**
122
+ * FloatingChatButton component
123
+ * @param onClick - Function to handle the click event
124
+ * @param theme - Theme
125
+ * @param icon - Icon for the floating button
126
+ * @param className - Class name for the floating button
127
+ * @param position - Position of the floating button
128
+ * @param size - Size of the floating button
129
+ */
130
+ export declare function FloatingChatButton({ onClick, theme, icon, className, position, size, }: FloatingChatButtonProps): import("react/jsx-runtime").JSX.Element;
131
+ 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' | 'command' | '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;